Add support for WATCOMC
[pforth] / csrc / pf_inner.c
index 0149da0..dad9265 100644 (file)
@@ -26,6 +26,8 @@
 **\r
 ***************************************************************/\r
 \r
 **\r
 ***************************************************************/\r
 \r
+#include <sys/types.h>\r
+\r
 #include "pf_all.h"\r
 \r
 #ifdef WIN32\r
 #include "pf_all.h"\r
 \r
 #ifdef WIN32\r
@@ -1024,7 +1026,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 +1044,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 +1056,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 +1463,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 +1480,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
@@ -1542,7 +1546,7 @@ DBUG(("XX ah,m,l = 0x%8x,%8x,%8x - qh,l = 0x%8x,%8x\n", ah,am,al, qh,ql ));
                                CodeSize = TOS;\r
                                NameSize = M_POP;\r
                                EntryPoint = M_POP;\r
                                CodeSize = TOS;\r
                                NameSize = M_POP;\r
                                EntryPoint = M_POP;\r
-                               ForthStringToC( gScratch, (char *) M_POP );\r
+                               ForthStringToC( gScratch, (char *) M_POP, sizeof(gScratch) );\r
                                TOS =  ffSaveForth( gScratch, EntryPoint, NameSize, CodeSize );\r
                        }\r
                        endcase;\r
                                TOS =  ffSaveForth( gScratch, EntryPoint, NameSize, CodeSize );\r
                        }\r
                        endcase;\r