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
This commit is contained in:
parent
82d864ae88
commit
d41cd1ae0c
@ -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
|
LIB= ficl
|
||||||
NOPROFILE= yes
|
NOPROFILE= yes
|
||||||
@ -6,7 +6,7 @@ INTERNALLIB= yes
|
|||||||
INTERNALSTATICLIB= yes
|
INTERNALSTATICLIB= yes
|
||||||
SRCS= dict.c ficl.c math64.c softcore.c stack.c sysdep.c \
|
SRCS= dict.c ficl.c math64.c softcore.c stack.c sysdep.c \
|
||||||
vm.c words.c
|
vm.c words.c
|
||||||
CLEANFILES= softcore.c
|
CLEANFILES= softcore.c testmain
|
||||||
|
|
||||||
# Standard softwords
|
# Standard softwords
|
||||||
SOFTWORDS= softcore.fr jhlocal.fr marker.fr
|
SOFTWORDS= softcore.fr jhlocal.fr marker.fr
|
||||||
@ -21,3 +21,6 @@ softcore.c: ${SOFTWORDS} softcore.pl
|
|||||||
|
|
||||||
.include <bsd.lib.mk>
|
.include <bsd.lib.mk>
|
||||||
|
|
||||||
|
|
||||||
|
testmain: testmain.c ${SRCS}
|
||||||
|
cc -o testmain -DTESTMAIN testmain.c ${SRCS}
|
||||||
|
@ -7,7 +7,12 @@
|
|||||||
**
|
**
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
|
|
||||||
|
#ifdef TESTMAIN
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#else
|
||||||
#include <stand.h>
|
#include <stand.h>
|
||||||
|
#endif
|
||||||
#include "ficl.h"
|
#include "ficl.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -17,7 +17,13 @@
|
|||||||
** 29 jun 1998 (sadler) added variable sized hash table support
|
** 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>
|
#include <stand.h>
|
||||||
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "ficl.h"
|
#include "ficl.h"
|
||||||
|
|
||||||
|
@ -21,7 +21,11 @@
|
|||||||
** Code is written in ANSI C for portability.
|
** Code is written in ANSI C for portability.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef TESTMAIN
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#else
|
||||||
|
#include <stand.h>
|
||||||
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "ficl.h"
|
#include "ficl.h"
|
||||||
|
|
||||||
|
@ -7,7 +7,12 @@
|
|||||||
**
|
**
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
|
|
||||||
|
#ifdef TESTMAIN
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#else
|
||||||
#include <stand.h>
|
#include <stand.h>
|
||||||
|
#endif
|
||||||
#include "ficl.h"
|
#include "ficl.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -5,8 +5,12 @@
|
|||||||
** Created: 16 Oct 1997
|
** Created: 16 Oct 1997
|
||||||
**
|
**
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
|
#ifdef TESTMAIN
|
||||||
|
#include <stdlib.h>
|
||||||
|
#else
|
||||||
|
#include <stand.h>
|
||||||
|
#endif
|
||||||
#include "ficl.h"
|
#include "ficl.h"
|
||||||
|
|
||||||
#define STKDEPTH(s) ((s)->sp - (s)->base)
|
#define STKDEPTH(s) ((s)->sp - (s)->base)
|
||||||
|
@ -7,7 +7,12 @@
|
|||||||
**
|
**
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
|
|
||||||
|
#ifdef TESTMAIN
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#else
|
||||||
#include <stand.h>
|
#include <stand.h>
|
||||||
|
#endif
|
||||||
#include "ficl.h"
|
#include "ficl.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,24 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
** stub main for testing FICL under Win32
|
** stub main for testing FICL
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifdef WIN32
|
|
||||||
#include <direct.h>
|
|
||||||
#endif
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#ifdef linux
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ficl.h"
|
#include "ficl.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Ficl interface to _getcwd (Win32)
|
** Ficl interface to getcwd
|
||||||
** Prints the current working directory using the VM's
|
** Prints the current working directory using the VM's
|
||||||
** textOut method...
|
** textOut method...
|
||||||
*/
|
*/
|
||||||
@ -26,20 +21,16 @@ static void ficlGetCWD(FICL_VM *pVM)
|
|||||||
{
|
{
|
||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
cp = _getcwd(NULL, 80);
|
|
||||||
#else
|
|
||||||
cp = getcwd(NULL, 80);
|
cp = getcwd(NULL, 80);
|
||||||
#endif
|
|
||||||
vmTextOut(pVM, cp, 1);
|
vmTextOut(pVM, cp, 1);
|
||||||
free(cp);
|
free(cp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Ficl interface to _chdir (Win32)
|
** Ficl interface to chdir
|
||||||
** Gets a newline (or NULL) delimited string from the input
|
** Gets a newline (or NULL) delimited string from the input
|
||||||
** and feeds it to the Win32 chdir function...
|
** and feeds it to chdir()
|
||||||
** Example:
|
** Example:
|
||||||
** cd c:\tmp
|
** cd c:\tmp
|
||||||
*/
|
*/
|
||||||
@ -49,11 +40,7 @@ static void ficlChDir(FICL_VM *pVM)
|
|||||||
vmGetString(pVM, pFS, '\n');
|
vmGetString(pVM, pFS, '\n');
|
||||||
if (pFS->count > 0)
|
if (pFS->count > 0)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
|
||||||
int err = _chdir(pFS->text);
|
|
||||||
#else
|
|
||||||
int err = chdir(pFS->text);
|
int err = chdir(pFS->text);
|
||||||
#endif
|
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
vmTextOut(pVM, "Error: path not found", 1);
|
vmTextOut(pVM, "Error: path not found", 1);
|
||||||
@ -70,7 +57,7 @@ static void ficlChDir(FICL_VM *pVM)
|
|||||||
/*
|
/*
|
||||||
** Ficl interface to system (ANSI)
|
** Ficl interface to system (ANSI)
|
||||||
** Gets a newline (or NULL) delimited string from the input
|
** Gets a newline (or NULL) delimited string from the input
|
||||||
** and feeds it to the Win32 system function...
|
** and feeds it to system()
|
||||||
** Example:
|
** Example:
|
||||||
** system del *.*
|
** system del *.*
|
||||||
** \ ouch!
|
** \ ouch!
|
||||||
@ -114,11 +101,7 @@ static void ficlLoad(FICL_VM *pVM)
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
int result;
|
int result;
|
||||||
CELL id;
|
CELL id;
|
||||||
#ifdef WIN32
|
|
||||||
struct _stat buf;
|
|
||||||
#else
|
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
vmGetString(pVM, pFilename, '\n');
|
vmGetString(pVM, pFilename, '\n');
|
||||||
@ -132,11 +115,7 @@ static void ficlLoad(FICL_VM *pVM)
|
|||||||
/*
|
/*
|
||||||
** get the file's size and make sure it exists
|
** get the file's size and make sure it exists
|
||||||
*/
|
*/
|
||||||
#ifdef WIN32
|
|
||||||
result = _stat( pFilename->text, &buf );
|
|
||||||
#else
|
|
||||||
result = stat( pFilename->text, &buf );
|
result = stat( pFilename->text, &buf );
|
||||||
#endif
|
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
@ -258,8 +237,6 @@ void buildTestInterface(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if !defined (_WINDOWS)
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char in[256];
|
char in[256];
|
||||||
@ -283,7 +260,8 @@ int main(int argc, char **argv)
|
|||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
gets(in);
|
if (fgets(in, sizeof(in) - 1, stdin) == NULL)
|
||||||
|
break;
|
||||||
ret = ficlExec(pVM, in);
|
ret = ficlExec(pVM, in);
|
||||||
if (ret == VM_USEREXIT)
|
if (ret == VM_USEREXIT)
|
||||||
{
|
{
|
||||||
@ -295,5 +273,3 @@ int main(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
@ -13,7 +13,13 @@
|
|||||||
** of the interp.
|
** of the interp.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef TESTMAIN
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#else
|
||||||
#include <stand.h>
|
#include <stand.h>
|
||||||
|
#endif
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "ficl.h"
|
#include "ficl.h"
|
||||||
|
@ -7,7 +7,13 @@
|
|||||||
**
|
**
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
|
|
||||||
|
#ifdef TESTMAIN
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#else
|
||||||
#include <stand.h>
|
#include <stand.h>
|
||||||
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "ficl.h"
|
#include "ficl.h"
|
||||||
#include "math64.h"
|
#include "math64.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user