summaryrefslogtreecommitdiffstats
path: root/sys/boot/ficl
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>1998-11-04 03:42:16 +0000
committermsmith <msmith@FreeBSD.org>1998-11-04 03:42:16 +0000
commit4797b6fa60000ab790f3f53f1ed988f9cd74299f (patch)
tree533965078811aeef3cd5a975158bbf4f08152817 /sys/boot/ficl
parentb5e4ddf831c7992e5bd3fe436cf5e735d84f18c3 (diff)
downloadFreeBSD-src-4797b6fa60000ab790f3f53f1ed988f9cd74299f.zip
FreeBSD-src-4797b6fa60000ab790f3f53f1ed988f9cd74299f.tar.gz
Fix includes; we were still pulling in <stdlib.h> in some places.
Support building a standalone interpreter with 'make testmain', remove win32 and egregious gets() in testmain.c
Diffstat (limited to 'sys/boot/ficl')
-rw-r--r--sys/boot/ficl/Makefile7
-rw-r--r--sys/boot/ficl/alpha/sysdep.c5
-rw-r--r--sys/boot/ficl/dict.c6
-rw-r--r--sys/boot/ficl/ficl.c4
-rw-r--r--sys/boot/ficl/i386/sysdep.c5
-rw-r--r--sys/boot/ficl/stack.c6
-rw-r--r--sys/boot/ficl/sysdep.c5
-rw-r--r--sys/boot/ficl/testmain.c38
-rw-r--r--sys/boot/ficl/vm.c6
-rw-r--r--sys/boot/ficl/words.c6
10 files changed, 54 insertions, 34 deletions
diff --git a/sys/boot/ficl/Makefile b/sys/boot/ficl/Makefile
index 5a6b978..1100063 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 <bsd.lib.mk>
+
+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 732b048..3822364 100644
--- a/sys/boot/ficl/alpha/sysdep.c
+++ b/sys/boot/ficl/alpha/sysdep.c
@@ -7,7 +7,12 @@
**
*******************************************************************/
+#ifdef TESTMAIN
+#include <stdio.h>
+#include <stdlib.h>
+#else
#include <stand.h>
+#endif
#include "ficl.h"
/*
diff --git a/sys/boot/ficl/dict.c b/sys/boot/ficl/dict.c
index 3fb2443..640a2fd 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 <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#else
#include <stand.h>
+#endif
#include <string.h>
#include "ficl.h"
diff --git a/sys/boot/ficl/ficl.c b/sys/boot/ficl/ficl.c
index e02f136..6bf6503 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 <stdlib.h>
+#else
+#include <stand.h>
+#endif
#include <string.h>
#include "ficl.h"
diff --git a/sys/boot/ficl/i386/sysdep.c b/sys/boot/ficl/i386/sysdep.c
index 732b048..3822364 100644
--- a/sys/boot/ficl/i386/sysdep.c
+++ b/sys/boot/ficl/i386/sysdep.c
@@ -7,7 +7,12 @@
**
*******************************************************************/
+#ifdef TESTMAIN
+#include <stdio.h>
+#include <stdlib.h>
+#else
#include <stand.h>
+#endif
#include "ficl.h"
/*
diff --git a/sys/boot/ficl/stack.c b/sys/boot/ficl/stack.c
index d06f3ce..aee9f8f 100644
--- a/sys/boot/ficl/stack.c
+++ b/sys/boot/ficl/stack.c
@@ -5,8 +5,12 @@
** Created: 16 Oct 1997
**
*******************************************************************/
-#include <stdlib.h>
+#ifdef TESTMAIN
+#include <stdlib.h>
+#else
+#include <stand.h>
+#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 732b048..3822364 100644
--- a/sys/boot/ficl/sysdep.c
+++ b/sys/boot/ficl/sysdep.c
@@ -7,7 +7,12 @@
**
*******************************************************************/
+#ifdef TESTMAIN
+#include <stdio.h>
+#include <stdlib.h>
+#else
#include <stand.h>
+#endif
#include "ficl.h"
/*
diff --git a/sys/boot/ficl/testmain.c b/sys/boot/ficl/testmain.c
index 3e70195..f7cdc44 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 <stdlib.h>
#include <stdio.h>
#include <string.h>
-#ifdef WIN32
-#include <direct.h>
-#endif
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef linux
#include <unistd.h>
-#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 3040ee4..6852c62 100644
--- a/sys/boot/ficl/vm.c
+++ b/sys/boot/ficl/vm.c
@@ -13,7 +13,13 @@
** of the interp.
*/
+#ifdef TESTMAIN
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#else
#include <stand.h>
+#endif
#include <stdarg.h>
#include <string.h>
#include "ficl.h"
diff --git a/sys/boot/ficl/words.c b/sys/boot/ficl/words.c
index 68723b5..71b8c6b 100644
--- a/sys/boot/ficl/words.c
+++ b/sys/boot/ficl/words.c
@@ -7,7 +7,13 @@
**
*******************************************************************/
+#ifdef TESTMAIN
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#else
#include <stand.h>
+#endif
#include <string.h>
#include "ficl.h"
#include "math64.h"
OpenPOWER on IntegriCloud