mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-17 10:26:15 +00:00
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
66683792a4
commit
4ce140ae69
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=40883
@ -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}
|
||||
|
@ -7,7 +7,12 @@
|
||||
**
|
||||
*******************************************************************/
|
||||
|
||||
#ifdef TESTMAIN
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include <stand.h>
|
||||
#endif
|
||||
#include "ficl.h"
|
||||
|
||||
/*
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -7,7 +7,12 @@
|
||||
**
|
||||
*******************************************************************/
|
||||
|
||||
#ifdef TESTMAIN
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include <stand.h>
|
||||
#endif
|
||||
#include "ficl.h"
|
||||
|
||||
/*
|
||||
|
@ -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)
|
||||
|
@ -7,7 +7,12 @@
|
||||
**
|
||||
*******************************************************************/
|
||||
|
||||
#ifdef TESTMAIN
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include <stand.h>
|
||||
#endif
|
||||
#include "ficl.h"
|
||||
|
||||
/*
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user