# For more info visit http://www.softsynth.com/pforth/
#
# See "help" target below.
-\r
+
.SUFFIXES: .c .o
# Options include: PF_SUPPORT_FP PF_NO_MALLOC PF_NO_INIT PF_DEBUG
rm -f $(PFDICDAT)
rm -f $(PFORTHDIC)
rm -f $(PFDICAPP)
+ rm -rf $(OBJECTDIR) $(TEMPOBJECTDIR)
+
pfCopyMemory( &buffer[4], &FileName[len-numChars], numChars+1 );\r
CreateDicEntryC( ID_NOOP, buffer, 0 );\r
\r
- Result = ffIncludeFile( fid );\r
+ Result = ffIncludeFile( fid ); /* Also close the file. */\r
\r
/* Create a dictionary word named ;;;; for FILE? */\r
CreateDicEntryC( ID_NOOP, ";;;;", 0 );\r
\r
- sdCloseFile(fid);\r
return Result;\r
}\r
\r
** PFORTH_VERSION changes when PForth is modified and released.\r
** See README file for version info.\r
*/\r
-#define PFORTH_VERSION "26"\r
+#define PFORTH_VERSION "27"\r
\r
/*\r
** PFORTH_FILE_VERSION changes when incompatible changes are made\r
if( FileID )\r
{\r
SAVE_REGISTERS;\r
- Scratch = ffIncludeFile( FileID );\r
+ Scratch = ffIncludeFile( FileID ); /* Also closes the file. */\r
LOAD_REGISTERS;\r
- sdCloseFile( FileID );\r
if( Scratch ) M_THROW(Scratch);\r
}\r
else\r
return -1;\r
}\r
\r
+/* Convert dictionary info chunk between native and on-disk (big-endian). */\r
+static void\r
+convertDictionaryInfoWrite (DictionaryInfoChunk *sd)\r
+{\r
+/* Convert all fields in DictionaryInfoChunk from Native to BigEndian. \r
+ * This assumes they are all 32-bit integers.\r
+ */\r
+ int i;\r
+ uint32_t *p = (uint32_t *) sd;\r
+ for (i=0; i<((int)(sizeof(*sd)/sizeof(uint32_t))); i++)\r
+ {\r
+ Write32BigEndian( (uint8_t *)&p[i], p[i] );\r
+ }\r
+}\r
+\r
+static void\r
+convertDictionaryInfoRead (DictionaryInfoChunk *sd)\r
+{\r
+/* Convert all fields in structure from BigEndian to Native. */\r
+ int i;\r
+ uint32_t *p = (uint32_t *) sd;\r
+ for (i=0; i<((int)(sizeof(*sd)/sizeof(uint32_t))); i++)\r
+ {\r
+ p[i] = Read32BigEndian( (uint8_t *)&p[i] );\r
+ }\r
+}\r
+\r
/****************************************************************\r
** Save Dictionary in File.\r
** If EntryPoint is NULL, save as development environment.\r
uint32_t NameChunkSize = 0;\r
uint32_t CodeChunkSize;\r
uint32_t relativeCodePtr;\r
- int i;\r
\r
fid = sdOpenFile( FileName, "wb" );\r
if( fid == NULL )\r
SD.sd_CodeSize = CodeSize;\r
\r
\r
-/* Convert all fields in DictionaryInfoChunk from Native to BigEndian. \r
- * This assumes they are all 32-bit integers.\r
- */\r
- {\r
- uint32_t *p = (uint32_t *) &SD;\r
- for( i=0; i<((int)(sizeof(SD)/sizeof(uint32_t))); i++ )\r
- {\r
- Write32BigEndian( (uint8_t *)&p[i], p[i] );\r
- }\r
- }\r
+ convertDictionaryInfoWrite (&SD);\r
\r
if( WriteChunkToFile( fid, ID_P4DI, (char *) &SD, sizeof(DictionaryInfoChunk) ) < 0 ) goto error;\r
\r
uint32_t FormSize;\r
uint32_t BytesLeft;\r
uint32_t numr;\r
- int i;\r
int isDicBigEndian;\r
\r
DBUG(("pfLoadDictionary( %s )\n", FileName ));\r
if( numr != ChunkSize ) goto read_error;\r
BytesLeft -= ChunkSize;\r
\r
-/* Convert all fields in structure from BigEndian to Native. */\r
- {\r
- uint32_t *p = (uint32_t *) sd;\r
- for( i=0; i<((int)(sizeof(*sd)/sizeof(uint32_t))); i++ )\r
- {\r
- p[i] = Read32BigEndian( (uint8_t *)&p[i] );\r
- }\r
- }\r
- \r
+ convertDictionaryInfoRead (sd);\r
+\r
isDicBigEndian = sd->sd_Flags & SD_F_BIG_ENDIAN_DIC;\r
\r
if( !gVarQuiet )\r
}\r
\r
/***************************************************************\r
-** Include a file\r
+** Include then close a file\r
***************************************************************/\r
\r
ThrowCode ffIncludeFile( FileStream *InputFile )\r
/* Pop file stream. */\r
ffPopInputStream();\r
\r
+/* ANSI spec specifies that this should also close the file. */\r
+ sdCloseFile(InputFile);\r
+\r
return exception;\r
}\r
\r
c-addr c@ [char] E =\r
c-addr c@ [char] e = OR\r
IF\r
- 1 +-> c-addr -1 +-> u' \ skip char\r
- c-addr c@ [char] + = \ ignore + on exponent\r
+ 1 +-> c-addr -1 +-> u' \ skip E char
+ u' 0>
IF\r
- 1 +-> c-addr -1 +-> u' \ skip char\r
- THEN\r
- c-addr u' ((number?))\r
- num_type_single =\r
- IF\r
- nshift + -> nshift\r
- true -> flag\r
+ c-addr c@ [char] + = \ ignore + on exponent
+ IF\r
+ 1 +-> c-addr -1 +-> u' \ skip char\r
+ THEN\r
+ c-addr u' ((number?))\r
+ num_type_single =\r
+ IF\r
+ nshift + -> nshift\r
+ true -> flag\r
+ THEN
+ ELSE
+ true -> flag \ allow "1E"
THEN\r
THEN\r
ELSE\r
\\r
\ The most recent entry is put at the beginning,\r
\ older entries are shifted up.\r
+
+4 constant KH_LINE_EXTRA_SIZE ( 2 count bytes plus 2 size bytes )
\r
: KH-END ( -- addr , end of history buffer )\r
kh-history kh_history_size +\r
ELSE\r
>r ( save count )\r
\ Set look pointer to point to first count byte of last string.\r
- 0 kh-look !\r
- r@ cell+ kh.make.room\r
+ 0 kh-look !
+\ Make room for this line of text and line header.
+\ PLB20100823 Was cell+ which broke on 64-bit code.\r
+ r@ KH_LINE_EXTRA_SIZE + kh.make.room\r
\ Set count bytes at beginning and end.\r
r@ kh-history c! ( start count )\r
r@ kh.endcount.addr c!\r
drop ." Could not find file " $type cr abort\r
ELSE ( -- $filename good-fid )\r
swap include.mark.start\r
- dup >r \ save fid for close-file\r
depth >r\r
- include-file\r
+ include-file \ will also close the file\r
depth 1+ r> -\r
IF\r
." Warning: stack depth changed during include!" cr\r
.s cr\r
0sp\r
THEN\r
- r> close-file drop\r
include.mark.end\r
THEN\r
trace-include @\r
\r
Documentation for pForth at http://www.softsynth.com/pforth/\r
-V??
+V27
- Fixed REPOSITION-FILE FILE-SIZE and FILE-POSITION.
They used to use single precision offset. Now use double as specified.
+ - Delete object directories in Makefile clean.
+ - Fixed "Issue 4: Filehandle remains locked upon INCLUDE error".
+ http://code.google.com/p/pforth/issues/detail?id=4&can=1
+ - Fixed scambled HISTORY on 64-bit systems. Was using CELL+ but really needed 4 +.
+ - Fixed floating point input. Now accepts "1E" as 1.0. Was Issue #2.
\r
V26 5/20/2010
- 64-bit support for M* UM/MOD etc by Aleksej Saushev. Thanks Aleksej!