Fixed lots of warning and made code compatible with C89 and ANSI with -pedantic.
authorphil@softsynth.com <phil@softsynth.com@b0a0988d-7f52-0410-8c73-4f6cdee1a2cf>
Thu, 26 Aug 2010 02:07:37 +0000 (02:07 +0000)
committerphil@softsynth.com <phil@softsynth.com@b0a0988d-7f52-0410-8c73-4f6cdee1a2cf>
Thu, 26 Aug 2010 02:07:37 +0000 (02:07 +0000)
Use fseek and ftell on WIN32 instead of fseeko and ftello.

build/unix/Makefile
csrc/pf_core.c
csrc/pf_guts.h
csrc/pf_inner.c
csrc/pf_io.h
csrc/pf_main.c
csrc/pf_save.c
csrc/pfcompil.c
csrc/pfcustom.c
releases.txt

index 8896f7c..162cf5b 100644 (file)
@@ -27,11 +27,13 @@ TEMPOBJECTDIR = $(PFORTHDIR)/tempobjects
 WIDTHOPT=
 
 FULL_WARNINGS =  \
 WIDTHOPT=
 
 FULL_WARNINGS =  \
+        -c89 \
         -fsigned-char \
         -fno-builtin \
         -fno-unroll-loops \
         -fpeephole \
         -fno-keep-inline-functions \
         -fsigned-char \
         -fno-builtin \
         -fno-unroll-loops \
         -fpeephole \
         -fno-keep-inline-functions \
+        -pedantic \
         -Wcast-qual \
         -Wall \
         -Wwrite-strings \
         -Wcast-qual \
         -Wall \
         -Wwrite-strings \
@@ -117,6 +119,12 @@ help:
        @echo "   The file 'fth/pfdicdat.h' is generated by pForth. It contains a binary image of the Forth dictionary."
        @echo "   It allows pForth to work as a standalone image that does not need to load a dictionary file."
 
        @echo "   The file 'fth/pfdicdat.h' is generated by pForth. It contains a binary image of the Forth dictionary."
        @echo "   It allows pForth to work as a standalone image that does not need to load a dictionary file."
 
+test: $(PFORTHAPP)
+       cd $(FTHDIR); ../pforth_standalone -q t_corex.fth
+       cd $(FTHDIR); ../pforth_standalone -q t_strings.fth
+       cd $(FTHDIR); ../pforth_standalone -q t_locals.fth
+       cd $(FTHDIR); ../pforth_standalone -q t_alloc.fth
+       cd $(FTHDIR); ../pforth_standalone -q t_floats.fth
 
 clean:
        rm -f $(PFOBJS) $(PFEMBOBJS)
 
 clean:
        rm -f $(PFOBJS) $(PFEMBOBJS)
index 0564a65..f7bf38f 100644 (file)
@@ -92,7 +92,6 @@ static void pfInit( void )
        gVarEcho = 0;       /* Echo input. */\r
        gVarTraceLevel = 0;   /* Trace Level for Inner Interpreter. */\r
        gVarTraceFlags = 0;   /* Enable various internal debug messages. */\r
        gVarEcho = 0;       /* Echo input. */\r
        gVarTraceLevel = 0;   /* Trace Level for Inner Interpreter. */\r
        gVarTraceFlags = 0;   /* Enable various internal debug messages. */\r
-       gVarQuiet = 0;        /* Suppress unnecessary messages, OK, etc. */\r
        gVarReturnCode = 0;   /* Returned to caller of Forth, eg. UNIX shell. */\r
        gIncludeIndex = 0;\r
        \r
        gVarReturnCode = 0;   /* Returned to caller of Forth, eg. UNIX shell. */\r
        gIncludeIndex = 0;\r
        \r
@@ -224,32 +223,32 @@ PForthDictionary pfCreateDictionary( cell_t HeaderSize, cell_t CodeSize )
  * to (ucell_t) on 16 bit systems.\r
  */\r
 #define DIC_ALIGNMENT_SIZE  ((ucell_t)(0x10))\r
  * to (ucell_t) on 16 bit systems.\r
  */\r
 #define DIC_ALIGNMENT_SIZE  ((ucell_t)(0x10))\r
-#define DIC_ALIGN(addr)  ((uint8_t *)((((ucell_t)(addr)) + DIC_ALIGNMENT_SIZE - 1) & ~(DIC_ALIGNMENT_SIZE - 1)))\r
+#define DIC_ALIGN(addr)  ((((ucell_t)(addr)) + DIC_ALIGNMENT_SIZE - 1) & ~(DIC_ALIGNMENT_SIZE - 1))\r
 \r
 /* Allocate memory for header. */\r
        if( HeaderSize > 0 )\r
        {\r
 \r
 /* Allocate memory for header. */\r
        if( HeaderSize > 0 )\r
        {\r
-               dic->dic_HeaderBaseUnaligned = ( uint8_t * ) pfAllocMem( (ucell_t) HeaderSize + DIC_ALIGNMENT_SIZE );\r
+               dic->dic_HeaderBaseUnaligned = (ucell_t) pfAllocMem( (ucell_t) HeaderSize + DIC_ALIGNMENT_SIZE );\r
                if( !dic->dic_HeaderBaseUnaligned ) goto nomem;\r
 /* Align header base. */\r
                dic->dic_HeaderBase = DIC_ALIGN(dic->dic_HeaderBaseUnaligned);\r
                if( !dic->dic_HeaderBaseUnaligned ) goto nomem;\r
 /* Align header base. */\r
                dic->dic_HeaderBase = DIC_ALIGN(dic->dic_HeaderBaseUnaligned);\r
-               pfSetMemory( dic->dic_HeaderBase, 0xA5, (ucell_t) HeaderSize);\r
+               pfSetMemory( (char *) dic->dic_HeaderBase, 0xA5, (ucell_t) HeaderSize);\r
                dic->dic_HeaderLimit = dic->dic_HeaderBase + HeaderSize;\r
                dic->dic_HeaderPtr = dic->dic_HeaderBase;\r
        }\r
        else\r
        {\r
                dic->dic_HeaderLimit = dic->dic_HeaderBase + HeaderSize;\r
                dic->dic_HeaderPtr = dic->dic_HeaderBase;\r
        }\r
        else\r
        {\r
-               dic->dic_HeaderBase = NULL;\r
+               dic->dic_HeaderBase = 0;\r
        }\r
 \r
 /* Allocate memory for code. */\r
        }\r
 \r
 /* Allocate memory for code. */\r
-       dic->dic_CodeBaseUnaligned = ( uint8_t * ) pfAllocMem( (ucell_t) CodeSize + DIC_ALIGNMENT_SIZE );\r
+       dic->dic_CodeBaseUnaligned = (ucell_t) pfAllocMem( (ucell_t) CodeSize + DIC_ALIGNMENT_SIZE );\r
        if( !dic->dic_CodeBaseUnaligned ) goto nomem;\r
        dic->dic_CodeBase = DIC_ALIGN(dic->dic_CodeBaseUnaligned);\r
        if( !dic->dic_CodeBaseUnaligned ) goto nomem;\r
        dic->dic_CodeBase = DIC_ALIGN(dic->dic_CodeBaseUnaligned);\r
-       pfSetMemory( dic->dic_CodeBase, 0x5A, (ucell_t) CodeSize);\r
+       pfSetMemory( (char *) dic->dic_CodeBase, 0x5A, (ucell_t) CodeSize);\r
 \r
        dic->dic_CodeLimit = dic->dic_CodeBase + CodeSize;\r
 \r
        dic->dic_CodeLimit = dic->dic_CodeBase + CodeSize;\r
-       dic->dic_CodePtr.Byte = dic->dic_CodeBase + QUADUP(NUM_PRIMITIVES); \r
+       dic->dic_CodePtr.Byte = ((uint8_t *) (dic->dic_CodeBase + QUADUP(NUM_PRIMITIVES))); \r
        \r
        return (PForthDictionary) dic;\r
 nomem:\r
        \r
        return (PForthDictionary) dic;\r
 nomem:\r
@@ -450,7 +449,7 @@ cell_t pfDoForth( const char *DicFileName, const char *SourceName, cell_t IfInit
        {\r
                pfSetCurrentTask( cftd );\r
                \r
        {\r
                pfSetCurrentTask( cftd );\r
                \r
-               if( !pfQueryQuiet() )\r
+               if( !gVarQuiet )\r
                {\r
                        MSG( "PForth V"PFORTH_VERSION );\r
                        if( IsHostLittleEndian() ) MSG("-LE");\r
                {\r
                        MSG( "PForth V"PFORTH_VERSION );\r
                        if( IsHostLittleEndian() ) MSG("-LE");\r
@@ -508,8 +507,12 @@ cell_t pfDoForth( const char *DicFileName, const char *SourceName, cell_t IfInit
                        }\r
                }\r
                if( dic == NULL ) goto error2;\r
                        }\r
                }\r
                if( dic == NULL ) goto error2;\r
-               EMIT_CR;\r
-\r
+               \r
+               if( !gVarQuiet )\r
+               {\r
+                       EMIT_CR;\r
+               }\r
+               \r
                pfDebugMessage("pfDoForth: try AUTO.INIT\n");\r
                Result = pfExecIfDefined("AUTO.INIT");\r
                if( Result != 0 )\r
                pfDebugMessage("pfDoForth: try AUTO.INIT\n");\r
                Result = pfExecIfDefined("AUTO.INIT");\r
                if( Result != 0 )\r
@@ -560,7 +563,7 @@ cell_t pfDoForth( const char *DicFileName, const char *SourceName, cell_t IfInit
 error2:\r
        MSG("pfDoForth: Error occured.\n");\r
        pfDeleteTask( cftd );\r
 error2:\r
        MSG("pfDoForth: Error occured.\n");\r
        pfDeleteTask( cftd );\r
-       // Terminate so we restore normal shell tty mode.\r
+       /* Terminate so we restore normal shell tty mode. */\r
        pfTerm();\r
 \r
 #ifdef PF_USER_INIT\r
        pfTerm();\r
 \r
 #ifdef PF_USER_INIT\r
index acb92a6..80df530 100644 (file)
@@ -429,9 +429,7 @@ typedef struct pfDictionary_s
        ucell_t dic_HeaderPtr;\r
        ucell_t dic_HeaderLimit;\r
 /* Code segment contains tokenized code and data. */\r
        ucell_t dic_HeaderPtr;\r
        ucell_t dic_HeaderLimit;\r
 /* Code segment contains tokenized code and data. */\r
-\r
        ucell_t dic_CodeBaseUnaligned;\r
        ucell_t dic_CodeBaseUnaligned;\r
-\r
        ucell_t dic_CodeBase;\r
        union\r
        {\r
        ucell_t dic_CodeBase;\r
        union\r
        {\r
@@ -552,15 +550,15 @@ extern cell_t         gIncludeIndex;
 #define IN_DICS(addr) (IN_CODE_DIC(addr) || IN_NAME_DIC(addr))\r
 \r
 /* Address conversion */\r
 #define IN_DICS(addr) (IN_CODE_DIC(addr) || IN_NAME_DIC(addr))\r
 \r
 /* Address conversion */\r
-#define ABS_TO_NAMEREL( a ) ((cell_t)  (((uint8_t *) a) - NAME_BASE ))\r
-#define ABS_TO_CODEREL( a ) ((cell_t)  (((uint8_t *) a) - CODE_BASE ))\r
-#define NAMEREL_TO_ABS( a ) ((char *) (((cell_t) a) + NAME_BASE))\r
-#define CODEREL_TO_ABS( a ) ((cell_t *) (((cell_t) a) + CODE_BASE))\r
+#define ABS_TO_NAMEREL( a ) ((cell_t)  (((ucell_t) a) - NAME_BASE ))\r
+#define ABS_TO_CODEREL( a ) ((cell_t)  (((ucell_t) a) - CODE_BASE ))\r
+#define NAMEREL_TO_ABS( a ) ((ucell_t) (((cell_t) a) + NAME_BASE))\r
+#define CODEREL_TO_ABS( a ) ((ucell_t) (((cell_t) a) + CODE_BASE))\r
 \r
 /* The check for >0 is only needed for CLONE testing. !!! */\r
 #define IsTokenPrimitive(xt) ((xt<gNumPrimitives) && (xt>=0))\r
 \r
 \r
 /* The check for >0 is only needed for CLONE testing. !!! */\r
 #define IsTokenPrimitive(xt) ((xt<gNumPrimitives) && (xt>=0))\r
 \r
-#define FREE_VAR(v) { if (v) { pfFreeMem(v); v = NULL; } }\r
+#define FREE_VAR(v) { if (v) { pfFreeMem((void *)(v)); v = 0; } }\r
 \r
 #define DATA_STACK_DEPTH (gCurrentTask->td_StackBase - gCurrentTask->td_StackPtr)\r
 #define DROP_DATA_STACK (gCurrentTask->td_StackPtr++)\r
 \r
 #define DATA_STACK_DEPTH (gCurrentTask->td_StackBase - gCurrentTask->td_StackPtr)\r
 #define DROP_DATA_STACK (gCurrentTask->td_StackPtr++)\r
index 0149da0..fe60d15 100644 (file)
@@ -1024,7 +1024,7 @@ DBUG(("XX ah,m,l = 0x%8x,%8x,%8x - qh,l = 0x%8x,%8x\n", ah,am,al, qh,ql ));
                                sdSeekFile( FileID, 0, PF_SEEK_END );\r
                                endposition = sdTellFile( FileID );\r
                                M_PUSH(endposition);\r
                                sdSeekFile( FileID, 0, PF_SEEK_END );\r
                                endposition = sdTellFile( FileID );\r
                                M_PUSH(endposition);\r
-                               // Just use a 0 if they are the same size.\r
+                               /* Just use a 0 if they are the same size. */\r
                                offsetHi = (sizeof(off_t) > sizeof(cell_t)) ? (endposition >> (8*sizeof(cell_t))) : 0 ;\r
                                M_PUSH(offsetHi);\r
                                sdSeekFile( FileID, original, PF_SEEK_SET );\r
                                offsetHi = (sizeof(off_t) > sizeof(cell_t)) ? (endposition >> (8*sizeof(cell_t))) : 0 ;\r
                                M_PUSH(offsetHi);\r
                                sdSeekFile( FileID, original, PF_SEEK_SET );\r
@@ -1042,9 +1042,10 @@ DBUG(("XX ah,m,l = 0x%8x,%8x,%8x - qh,l = 0x%8x,%8x\n", ah,am,al, qh,ql ));
 \r
                case ID_FILE_REPOSITION: /* ( ud fid -- ior ) */                                \r
                        {\r
 \r
                case ID_FILE_REPOSITION: /* ( ud fid -- ior ) */                                \r
                        {\r
+                               off_t offset;\r
                                FileID = (FileStream *) TOS;\r
                                FileID = (FileStream *) TOS;\r
-                               off_t offset = M_POP;\r
-                               // Avoid compiler warnings on Mac.\r
+                               offset = M_POP;\r
+                               /* Avoid compiler warnings on Mac. */\r
                                offset = (sizeof(off_t) > sizeof(cell_t)) ? (offset << 8*sizeof(cell_t)) : 0 ;\r
                                offset += M_POP;\r
                                TOS = sdSeekFile( FileID, offset, PF_SEEK_SET );\r
                                offset = (sizeof(off_t) > sizeof(cell_t)) ? (offset << 8*sizeof(cell_t)) : 0 ;\r
                                offset += M_POP;\r
                                TOS = sdSeekFile( FileID, offset, PF_SEEK_SET );\r
@@ -1053,11 +1054,12 @@ DBUG(("XX ah,m,l = 0x%8x,%8x,%8x - qh,l = 0x%8x,%8x\n", ah,am,al, qh,ql ));
 \r
                case ID_FILE_POSITION: /* ( fid -- ud ior ) */\r
                        {\r
 \r
                case ID_FILE_POSITION: /* ( fid -- ud ior ) */\r
                        {\r
+                               off_t position;\r
                                off_t offsetHi;\r
                                FileID = (FileStream *) TOS;\r
                                off_t offsetHi;\r
                                FileID = (FileStream *) TOS;\r
-                               off_t position = sdTellFile( FileID );\r
+                               position = sdTellFile( FileID );\r
                                M_PUSH(position);\r
                                M_PUSH(position);\r
-                               // Just use a 0 if they are the same size.\r
+                               /* Just use a 0 if they are the same size. */\r
                                offsetHi = (sizeof(off_t) > sizeof(cell_t)) ? (position >> (8*sizeof(cell_t))) : 0 ;\r
                                M_PUSH(offsetHi);\r
                                TOS = (position < 0) ? -4 : 0 ; /* !!! err num */\r
                                offsetHi = (sizeof(off_t) > sizeof(cell_t)) ? (position >> (8*sizeof(cell_t))) : 0 ;\r
                                M_PUSH(offsetHi);\r
                                TOS = (position < 0) ? -4 : 0 ; /* !!! err num */\r
@@ -1459,11 +1461,11 @@ DBUG(("XX ah,m,l = 0x%8x,%8x,%8x - qh,l = 0x%8x,%8x\n", ah,am,al, qh,ql ));
                case ID_RESIZE:  /* ( addr1 u -- addr2 result ) */\r
                        {\r
                                cell_t *Addr1 = (cell_t *) M_POP;\r
                case ID_RESIZE:  /* ( addr1 u -- addr2 result ) */\r
                        {\r
                                cell_t *Addr1 = (cell_t *) M_POP;\r
-                               // Point to validator below users address.\r
+                               /* Point to validator below users address. */\r
                                cell_t *FreePtr = Addr1 - 1;\r
                                if( ((ucell_t)*FreePtr) != ((ucell_t)FreePtr ^ PF_MEMORY_VALIDATOR))\r
                                {\r
                                cell_t *FreePtr = Addr1 - 1;\r
                                if( ((ucell_t)*FreePtr) != ((ucell_t)FreePtr ^ PF_MEMORY_VALIDATOR))\r
                                {\r
-                                       // 090218 - Fixed bug, was returning zero.\r
+                                       /* 090218 - Fixed bug, was returning zero. */\r
                                        M_PUSH( Addr1 );\r
                                        TOS = -3;\r
                                }\r
                                        M_PUSH( Addr1 );\r
                                        TOS = -3;\r
                                }\r
@@ -1476,17 +1478,17 @@ DBUG(("XX ah,m,l = 0x%8x,%8x,%8x - qh,l = 0x%8x,%8x\n", ah,am,al, qh,ql ));
                                                /* Copy memory including validation. */\r
                                                pfCopyMemory( (char *) CellPtr, (char *) FreePtr, TOS + sizeof(cell_t) );\r
                                                *CellPtr = (cell_t)(((ucell_t)CellPtr) ^ (ucell_t)PF_MEMORY_VALIDATOR);\r
                                                /* Copy memory including validation. */\r
                                                pfCopyMemory( (char *) CellPtr, (char *) FreePtr, TOS + sizeof(cell_t) );\r
                                                *CellPtr = (cell_t)(((ucell_t)CellPtr) ^ (ucell_t)PF_MEMORY_VALIDATOR);\r
-                                               // 090218 - Fixed bug that was incrementing the address twice. Thanks Reinhold Straub.\r
-                                               // Increment past validator to user address.\r
+                                               /* 090218 - Fixed bug that was incrementing the address twice. Thanks Reinhold Straub. */\r
+                                               /* Increment past validator to user address. */\r
                                    M_PUSH( (cell_t) (CellPtr + 1) );\r
                                    M_PUSH( (cell_t) (CellPtr + 1) );\r
-                                               TOS = 0; // Result code.\r
-                                               // Mark old cell as dead so we can't free it twice.\r
+                                               TOS = 0; /* Result code. */\r
+                                               /* Mark old cell as dead so we can't free it twice. */\r
                                                FreePtr[0] = 0xDeadBeef;\r
                                                pfFreeMem((char *) FreePtr);\r
                                        }\r
                                        else\r
                                        {\r
                                                FreePtr[0] = 0xDeadBeef;\r
                                                pfFreeMem((char *) FreePtr);\r
                                        }\r
                                        else\r
                                        {\r
-                                               // 090218 - Fixed bug, was returning zero.\r
+                                               /* 090218 - Fixed bug, was returning zero. */\r
                                                M_PUSH( Addr1 );\r
                                                TOS = -4;  /* FIXME Fix error code. */\r
                                        }\r
                                                M_PUSH( Addr1 );\r
                                                TOS = -4;  /* FIXME Fix error code. */\r
                                        }\r
index 5ee78f4..2a4af4b 100644 (file)
@@ -118,8 +118,14 @@ void ioTerm( void );
                #define sdFlushFile     fflush\r
                #define sdReadFile      fread\r
                #define sdWriteFile     fwrite\r
                #define sdFlushFile     fflush\r
                #define sdReadFile      fread\r
                #define sdWriteFile     fwrite\r
-               #define sdSeekFile      fseeko\r
-               #define sdTellFile      ftello\r
+               #if WIN32\r
+                       /* TODO To support 64-bit file offset we probably need fseeki64(). */\r
+                       #define sdSeekFile      fseek\r
+                       #define sdTellFile      ftell\r
+               #else\r
+                       #define sdSeekFile      fseeko\r
+                       #define sdTellFile      ftello\r
+               #endif\r
                #define sdCloseFile     fclose\r
                #define sdInputChar     fgetc\r
                \r
                #define sdCloseFile     fclose\r
                #define sdInputChar     fgetc\r
                \r
index df38d0c..71defbc 100644 (file)
@@ -74,6 +74,7 @@ int main( int argc, char **argv )
        argc = ccommand(&argv);\r
 #endif\r
        \r
        argc = ccommand(&argv);\r
 #endif\r
        \r
+       pfSetQuiet( FALSE );\r
 /* Parse command line. */\r
        for( i=1; i<argc; i++ )\r
        {\r
 /* Parse command line. */\r
        for( i=1; i<argc; i++ )\r
        {\r
@@ -97,8 +98,8 @@ int main( int argc, char **argv )
                                \r
                        case 'd':\r
                                if( *s != '\0' ) DicName = s;\r
                                \r
                        case 'd':\r
                                if( *s != '\0' ) DicName = s;\r
-                               // Allow space after -d (Thanks Aleksej Saushev)\r
-                               // Make sure there is another argument.\r
+                               /* Allow space after -d (Thanks Aleksej Saushev) */\r
+                               /* Make sure there is another argument. */\r
                                else if( (i+1) < argc )\r
                                {\r
                                        DicName = argv[++i];\r
                                else if( (i+1) < argc )\r
                                {\r
                                        DicName = argv[++i];\r
index f3f9ac0..d46958a 100644 (file)
@@ -213,8 +213,8 @@ PF_FLOAT ReadFloatLittleEndian( const PF_FLOAT *addr )
 /***************************************************************/\r
 void WriteCellBigEndian( uint8_t *addr, ucell_t data )\r
 {\r
 /***************************************************************/\r
 void WriteCellBigEndian( uint8_t *addr, ucell_t data )\r
 {\r
-       // Write should be in order of increasing address\r
-       // to optimize for burst writes to DRAM.\r
+       /* Write should be in order of increasing address \r
+        * to optimize for burst writes to DRAM. */\r
        if( sizeof(ucell_t) == 8 )\r
        {\r
                *addr++ = (uint8_t) (data>>56);\r
        if( sizeof(ucell_t) == 8 )\r
        {\r
                *addr++ = (uint8_t) (data>>56);\r
@@ -247,11 +247,11 @@ void Write16BigEndian( uint8_t *addr, uint16_t data )
 /***************************************************************/\r
 void WriteCellLittleEndian( uint8_t *addr, ucell_t data )\r
 {\r
 /***************************************************************/\r
 void WriteCellLittleEndian( uint8_t *addr, ucell_t data )\r
 {\r
-       // Write should be in order of increasing address\r
-       // to optimize for burst writes to DRAM.\r
+       /* Write should be in order of increasing address \r
+        * to optimize for burst writes to DRAM. */\r
        if( sizeof(ucell_t) == 8 )\r
        {\r
        if( sizeof(ucell_t) == 8 )\r
        {\r
-               *addr++ = (uint8_t) data;  // LSB at near end\r
+               *addr++ = (uint8_t) data;  /* LSB at near end */\r
                data = data >> 8;\r
                *addr++ = (uint8_t) data;\r
                data = data >> 8;\r
                data = data >> 8;\r
                *addr++ = (uint8_t) data;\r
                data = data >> 8;\r
@@ -653,7 +653,7 @@ DBUG(("pfLoadDictionary( %s )\n", FileName ));
                        gCurrentDictionary = dic;\r
                        if( sd->sd_NameSize > 0 )\r
                        {\r
                        gCurrentDictionary = dic;\r
                        if( sd->sd_NameSize > 0 )\r
                        {\r
-                               gVarContext = (char *) NAMEREL_TO_ABS(sd->sd_RelContext); /* Restore context. */\r
+                               gVarContext = NAMEREL_TO_ABS(sd->sd_RelContext); /* Restore context. */\r
                                gCurrentDictionary->dic_HeaderPtr = (ucell_t)(uint8_t *)\r
                                        NAMEREL_TO_ABS(sd->sd_RelHeaderPtr);\r
                        }\r
                                gCurrentDictionary->dic_HeaderPtr = (ucell_t)(uint8_t *)\r
                                        NAMEREL_TO_ABS(sd->sd_RelHeaderPtr);\r
                        }\r
@@ -674,7 +674,7 @@ DBUG(("pfLoadDictionary( %s )\n", FileName ));
                        pfReportError("pfLoadDictionary", PF_ERR_NO_SHELL );\r
                        goto error;\r
 #else\r
                        pfReportError("pfLoadDictionary", PF_ERR_NO_SHELL );\r
                        goto error;\r
 #else\r
-                       if( NAME_BASE == NULL )\r
+                       if( NAME_BASE == 0 )\r
                        {\r
                                pfReportError("pfLoadDictionary", PF_ERR_NO_NAMES );\r
                                goto error;\r
                        {\r
                                pfReportError("pfLoadDictionary", PF_ERR_NO_NAMES );\r
                                goto error;\r
@@ -689,7 +689,7 @@ DBUG(("pfLoadDictionary( %s )\n", FileName ));
                                pfReportError("pfLoadDictionary", PF_ERR_TOO_BIG);\r
                                goto error;\r
                        }\r
                                pfReportError("pfLoadDictionary", PF_ERR_TOO_BIG);\r
                                goto error;\r
                        }\r
-                       numr = sdReadFile( NAME_BASE, 1, ChunkSize, fid );\r
+                       numr = sdReadFile( (char *) NAME_BASE, 1, ChunkSize, fid );\r
                        if( numr != ChunkSize ) goto read_error;\r
                        BytesLeft -= ChunkSize;\r
 #endif /* PF_NO_SHELL */\r
                        if( numr != ChunkSize ) goto read_error;\r
                        BytesLeft -= ChunkSize;\r
 #endif /* PF_NO_SHELL */\r
@@ -706,7 +706,7 @@ DBUG(("pfLoadDictionary( %s )\n", FileName ));
                                pfReportError("pfLoadDictionary", PF_ERR_TOO_BIG);\r
                                goto error;\r
                        }\r
                                pfReportError("pfLoadDictionary", PF_ERR_TOO_BIG);\r
                                goto error;\r
                        }\r
-                       numr = sdReadFile( CODE_BASE, 1, ChunkSize, fid );\r
+                       numr = sdReadFile( (uint8_t *) CODE_BASE, 1, ChunkSize, fid );\r
                        if( numr != ChunkSize ) goto read_error;\r
                        BytesLeft -= ChunkSize;\r
                        break;\r
                        if( numr != ChunkSize ) goto read_error;\r
                        BytesLeft -= ChunkSize;\r
                        break;\r
@@ -720,7 +720,7 @@ DBUG(("pfLoadDictionary( %s )\n", FileName ));
 \r
        sdCloseFile( fid );\r
 \r
 \r
        sdCloseFile( fid );\r
 \r
-       if( NAME_BASE != NULL)\r
+       if( NAME_BASE != 0)\r
        {\r
                cell_t Result;\r
 /* Find special words in dictionary for global XTs. */\r
        {\r
                cell_t Result;\r
 /* Find special words in dictionary for global XTs. */\r
@@ -809,18 +809,18 @@ PForthDictionary pfLoadStaticDictionary( void )
        gCurrentDictionary = dic = pfCreateDictionary( NewNameSize, NewCodeSize );\r
        if( !dic ) goto nomem_error;\r
 \r
        gCurrentDictionary = dic = pfCreateDictionary( NewNameSize, NewCodeSize );\r
        if( !dic ) goto nomem_error;\r
 \r
-       pfCopyMemory( dic->dic_HeaderBase, MinDicNames, sizeof(MinDicNames) );\r
-       pfCopyMemory( dic->dic_CodeBase, MinDicCode, sizeof(MinDicCode) );\r
+       pfCopyMemory( (uint8_t *) dic->dic_HeaderBase, MinDicNames, sizeof(MinDicNames) );\r
+       pfCopyMemory( (uint8_t *) dic->dic_CodeBase, MinDicCode, sizeof(MinDicCode) );\r
        DBUG(("Static data copied to newly allocated dictionaries.\n"));\r
 \r
        dic->dic_CodePtr.Byte = (uint8_t *) CODEREL_TO_ABS(CODEPTR);\r
        gNumPrimitives = NUM_PRIMITIVES;\r
 \r
        DBUG(("Static data copied to newly allocated dictionaries.\n"));\r
 \r
        dic->dic_CodePtr.Byte = (uint8_t *) CODEREL_TO_ABS(CODEPTR);\r
        gNumPrimitives = NUM_PRIMITIVES;\r
 \r
-       if( NAME_BASE != NULL)\r
+       if( NAME_BASE != 0)\r
        {\r
 /* Setup name space. */\r
                dic->dic_HeaderPtr = (ucell_t)(uint8_t *) NAMEREL_TO_ABS(HEADERPTR);\r
        {\r
 /* Setup name space. */\r
                dic->dic_HeaderPtr = (ucell_t)(uint8_t *) NAMEREL_TO_ABS(HEADERPTR);\r
-               gVarContext = (char *) NAMEREL_TO_ABS(RELCONTEXT); /* Restore context. */\r
+               gVarContext = NAMEREL_TO_ABS(RELCONTEXT); /* Restore context. */\r
 \r
 /* Find special words in dictionary for global XTs. */\r
                if( (Result = FindSpecialXTs()) < 0 )\r
 \r
 /* Find special words in dictionary for global XTs. */\r
                if( (Result = FindSpecialXTs()) < 0 )\r
index 84546c4..feb85db 100644 (file)
@@ -77,8 +77,8 @@ void CreateDicEntry( ExecToken XT, const ForthStringPtr FName, ucell_t Flags )
        gCurrentDictionary->dic_HeaderPtr += sizeof(cfNameLinks);\r
 \r
 /* Laydown name. */\r
        gCurrentDictionary->dic_HeaderPtr += sizeof(cfNameLinks);\r
 \r
 /* Laydown name. */\r
-       gVarContext = (char *) gCurrentDictionary->dic_HeaderPtr;\r
-       pfCopyMemory( (char *)gCurrentDictionary->dic_HeaderPtr, FName, (*FName)+1 );\r
+       gVarContext = gCurrentDictionary->dic_HeaderPtr;\r
+       pfCopyMemory( (uint8_t *) gCurrentDictionary->dic_HeaderPtr, FName, (*FName)+1 );\r
        gCurrentDictionary->dic_HeaderPtr += (*FName)+1;\r
 \r
 /* Set flags. */\r
        gCurrentDictionary->dic_HeaderPtr += (*FName)+1;\r
 \r
 /* Set flags. */\r
@@ -117,7 +117,7 @@ const ForthString *NameToPrevious( const ForthString *NFA )
 /* DBUG(("\nNameToPrevious: RelNamePtr = 0x%x\n", (cell_t) RelNamePtr )); */\r
        if( RelNamePtr )\r
        {\r
 /* DBUG(("\nNameToPrevious: RelNamePtr = 0x%x\n", (cell_t) RelNamePtr )); */\r
        if( RelNamePtr )\r
        {\r
-               return ( NAMEREL_TO_ABS( RelNamePtr ) );\r
+               return ( (ForthString *) NAMEREL_TO_ABS( RelNamePtr ) );\r
        }\r
        else\r
        {\r
        }\r
        else\r
        {\r
@@ -408,7 +408,7 @@ cell_t ffTokenToName( ExecToken XT, const ForthString **NFAPtr )
        cell_t Result = 0;\r
        ExecToken TempXT;\r
        \r
        cell_t Result = 0;\r
        ExecToken TempXT;\r
        \r
-       NameField = gVarContext;\r
+       NameField = (ForthString *) gVarContext;\r
 DBUGX(("\ffCodeToName: gVarContext = 0x%x\n", gVarContext));\r
 \r
        do\r
 DBUGX(("\ffCodeToName: gVarContext = 0x%x\n", gVarContext));\r
 \r
        do\r
@@ -452,7 +452,7 @@ cell_t ffFindNFA( const ForthString *WordName, const ForthString **NFAPtr )
        WordLen = (uint8_t) ((ucell_t)*WordName & 0x1F);\r
        WordChar = WordName+1;\r
        \r
        WordLen = (uint8_t) ((ucell_t)*WordName & 0x1F);\r
        WordChar = WordName+1;\r
        \r
-       NameField = gVarContext;\r
+       NameField = (ForthString *) gVarContext;\r
 DBUG(("\nffFindNFA: WordLen = %d, WordName = %*s\n", WordLen, WordLen, WordChar ));\r
 DBUG(("\nffFindNFA: gVarContext = 0x%x\n", gVarContext));\r
        do\r
 DBUG(("\nffFindNFA: WordLen = %d, WordName = %*s\n", WordLen, WordLen, WordChar ));\r
 DBUG(("\nffFindNFA: gVarContext = 0x%x\n", gVarContext));\r
        do\r
@@ -600,7 +600,7 @@ static cell_t CheckRedefinition( const ForthStringPtr FName )
        if ( flag && !gVarQuiet)\r
        {\r
                ioType( FName+1, (cell_t) *FName );\r
        if ( flag && !gVarQuiet)\r
        {\r
                ioType( FName+1, (cell_t) *FName );\r
-               MSG( " redefined.\n" ); // FIXME - allow user to run off this warning.\r
+               MSG( " redefined.\n" ); /* FIXME - allow user to run off this warning. */\r
        }\r
        return flag;\r
 }\r
        }\r
        return flag;\r
 }\r
index ca42f61..1cacea2 100644 (file)
@@ -77,7 +77,7 @@ Err LoadCustomFunctionTable( void )
 ** If your loader supports global initialization (most do.) then just\r
 ** create the table like this.\r
 */\r
 ** If your loader supports global initialization (most do.) then just\r
 ** create the table like this.\r
 */\r
-void *CustomFunctionTable[] =\r
+CFunc0 CustomFunctionTable[] =\r
 {\r
        (CFunc0) CTest0,\r
        (CFunc0) CTest1\r
 {\r
        (CFunc0) CTest0,\r
        (CFunc0) CTest1\r
index 4830690..615d2cc 100644 (file)
@@ -8,8 +8,10 @@ V27
     - 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
     - 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 scrambled 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.
     - Fixed floating point input. Now accepts "1E" as 1.0. Was Issue #2.
+    - Fixed lots of warning and made code compatible with C89 and ANSI with -pedantic.
+    - Use fseek and ftell on WIN32 instead of fseeko and ftello.
 \r
 V26  5/20/2010
     - 64-bit support for M* UM/MOD etc by Aleksej Saushev. Thanks Aleksej!
 \r
 V26  5/20/2010
     - 64-bit support for M* UM/MOD etc by Aleksej Saushev. Thanks Aleksej!