From 4ce140ae69dcd2f70dfc590ef59bde12ccdaf103 Mon Sep 17 00:00:00 2001 From: Mike Smith Date: Wed, 4 Nov 1998 03:42:16 +0000 Subject: [PATCH] Fix includes; we were still pulling in in some places. Support building a standalone interpreter with 'make testmain', remove win32 and egregious gets() in testmain.c --- sys/boot/ficl/Makefile | 7 +++++-- sys/boot/ficl/alpha/sysdep.c | 5 +++++ sys/boot/ficl/dict.c | 6 ++++++ sys/boot/ficl/ficl.c | 4 ++++ sys/boot/ficl/i386/sysdep.c | 5 +++++ sys/boot/ficl/stack.c | 6 +++++- sys/boot/ficl/sysdep.c | 5 +++++ sys/boot/ficl/testmain.c | 38 +++++++----------------------------- sys/boot/ficl/vm.c | 6 ++++++ sys/boot/ficl/words.c | 6 ++++++ 10 files changed, 54 insertions(+), 34 deletions(-) diff --git a/sys/boot/ficl/Makefile b/sys/boot/ficl/Makefile index 5a6b978f4d7..11000630a5a 100644 --- a/sys/boot/ficl/Makefile +++ b/sys/boot/ficl/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.1 1998/11/03 06:11:34 msmith Exp $ +# $Id: Makefile,v 1.2 1998/11/04 00:29:33 msmith Exp $ # LIB= ficl NOPROFILE= yes @@ -6,7 +6,7 @@ INTERNALLIB= yes INTERNALSTATICLIB= yes SRCS= dict.c ficl.c math64.c softcore.c stack.c sysdep.c \ vm.c words.c -CLEANFILES= softcore.c +CLEANFILES= softcore.c testmain # Standard softwords SOFTWORDS= softcore.fr jhlocal.fr marker.fr @@ -21,3 +21,6 @@ softcore.c: ${SOFTWORDS} softcore.pl .include + +testmain: testmain.c ${SRCS} + cc -o testmain -DTESTMAIN testmain.c ${SRCS} diff --git a/sys/boot/ficl/alpha/sysdep.c b/sys/boot/ficl/alpha/sysdep.c index 732b048b388..38223645c5e 100644 --- a/sys/boot/ficl/alpha/sysdep.c +++ b/sys/boot/ficl/alpha/sysdep.c @@ -7,7 +7,12 @@ ** *******************************************************************/ +#ifdef TESTMAIN +#include +#include +#else #include +#endif #include "ficl.h" /* diff --git a/sys/boot/ficl/dict.c b/sys/boot/ficl/dict.c index 3fb244367d4..640a2fddc1a 100644 --- a/sys/boot/ficl/dict.c +++ b/sys/boot/ficl/dict.c @@ -17,7 +17,13 @@ ** 29 jun 1998 (sadler) added variable sized hash table support */ +#ifdef TESTMAIN +#include +#include +#include +#else #include +#endif #include #include "ficl.h" diff --git a/sys/boot/ficl/ficl.c b/sys/boot/ficl/ficl.c index e02f13636aa..6bf6503082e 100644 --- a/sys/boot/ficl/ficl.c +++ b/sys/boot/ficl/ficl.c @@ -21,7 +21,11 @@ ** Code is written in ANSI C for portability. */ +#ifdef TESTMAIN #include +#else +#include +#endif #include #include "ficl.h" diff --git a/sys/boot/ficl/i386/sysdep.c b/sys/boot/ficl/i386/sysdep.c index 732b048b388..38223645c5e 100644 --- a/sys/boot/ficl/i386/sysdep.c +++ b/sys/boot/ficl/i386/sysdep.c @@ -7,7 +7,12 @@ ** *******************************************************************/ +#ifdef TESTMAIN +#include +#include +#else #include +#endif #include "ficl.h" /* diff --git a/sys/boot/ficl/stack.c b/sys/boot/ficl/stack.c index d06f3cee6cf..aee9f8f5ff5 100644 --- a/sys/boot/ficl/stack.c +++ b/sys/boot/ficl/stack.c @@ -5,8 +5,12 @@ ** Created: 16 Oct 1997 ** *******************************************************************/ -#include +#ifdef TESTMAIN +#include +#else +#include +#endif #include "ficl.h" #define STKDEPTH(s) ((s)->sp - (s)->base) diff --git a/sys/boot/ficl/sysdep.c b/sys/boot/ficl/sysdep.c index 732b048b388..38223645c5e 100644 --- a/sys/boot/ficl/sysdep.c +++ b/sys/boot/ficl/sysdep.c @@ -7,7 +7,12 @@ ** *******************************************************************/ +#ifdef TESTMAIN +#include +#include +#else #include +#endif #include "ficl.h" /* diff --git a/sys/boot/ficl/testmain.c b/sys/boot/ficl/testmain.c index 3e70195ff08..f7cdc4440a8 100644 --- a/sys/boot/ficl/testmain.c +++ b/sys/boot/ficl/testmain.c @@ -1,24 +1,19 @@ /* -** stub main for testing FICL under Win32 +** stub main for testing FICL ** */ #include #include #include -#ifdef WIN32 -#include -#endif #include #include -#ifdef linux #include -#endif #include "ficl.h" /* -** Ficl interface to _getcwd (Win32) +** Ficl interface to getcwd ** Prints the current working directory using the VM's ** textOut method... */ @@ -26,20 +21,16 @@ static void ficlGetCWD(FICL_VM *pVM) { char *cp; -#ifdef WIN32 - cp = _getcwd(NULL, 80); -#else cp = getcwd(NULL, 80); -#endif vmTextOut(pVM, cp, 1); free(cp); return; } /* -** Ficl interface to _chdir (Win32) +** Ficl interface to chdir ** Gets a newline (or NULL) delimited string from the input -** and feeds it to the Win32 chdir function... +** and feeds it to chdir() ** Example: ** cd c:\tmp */ @@ -49,11 +40,7 @@ static void ficlChDir(FICL_VM *pVM) vmGetString(pVM, pFS, '\n'); if (pFS->count > 0) { -#ifdef WIN32 - int err = _chdir(pFS->text); -#else int err = chdir(pFS->text); -#endif if (err) { vmTextOut(pVM, "Error: path not found", 1); @@ -70,7 +57,7 @@ static void ficlChDir(FICL_VM *pVM) /* ** Ficl interface to system (ANSI) ** Gets a newline (or NULL) delimited string from the input -** and feeds it to the Win32 system function... +** and feeds it to system() ** Example: ** system del *.* ** \ ouch! @@ -114,11 +101,7 @@ static void ficlLoad(FICL_VM *pVM) FILE *fp; int result; CELL id; -#ifdef WIN32 - struct _stat buf; -#else struct stat buf; -#endif vmGetString(pVM, pFilename, '\n'); @@ -132,11 +115,7 @@ static void ficlLoad(FICL_VM *pVM) /* ** get the file's size and make sure it exists */ -#ifdef WIN32 - result = _stat( pFilename->text, &buf ); -#else result = stat( pFilename->text, &buf ); -#endif if (result != 0) { @@ -258,8 +237,6 @@ void buildTestInterface(void) } -#if !defined (_WINDOWS) - int main(int argc, char **argv) { char in[256]; @@ -283,7 +260,8 @@ int main(int argc, char **argv) for (;;) { int ret; - gets(in); + if (fgets(in, sizeof(in) - 1, stdin) == NULL) + break; ret = ficlExec(pVM, in); if (ret == VM_USEREXIT) { @@ -295,5 +273,3 @@ int main(int argc, char **argv) return 0; } -#endif - diff --git a/sys/boot/ficl/vm.c b/sys/boot/ficl/vm.c index 3040ee47e2f..6852c62bd66 100644 --- a/sys/boot/ficl/vm.c +++ b/sys/boot/ficl/vm.c @@ -13,7 +13,13 @@ ** of the interp. */ +#ifdef TESTMAIN +#include +#include +#include +#else #include +#endif #include #include #include "ficl.h" diff --git a/sys/boot/ficl/words.c b/sys/boot/ficl/words.c index 68723b50910..71b8c6ba2c0 100644 --- a/sys/boot/ficl/words.c +++ b/sys/boot/ficl/words.c @@ -7,7 +7,13 @@ ** *******************************************************************/ +#ifdef TESTMAIN +#include +#include +#include +#else #include +#endif #include #include "ficl.h" #include "math64.h"