diff options
| author | Jordan K. Hubbard <jkh@FreeBSD.org> | 1998-11-05 08:39:43 +0000 |
|---|---|---|
| committer | Jordan K. Hubbard <jkh@FreeBSD.org> | 1998-11-05 08:39:43 +0000 |
| commit | 82f35547c9e221d4f3f12da67636ff67077a5eb2 (patch) | |
| tree | 5aadc57b05f5cc846e10dbccbf6ec868b45965ef /sys/boot/ficl | |
| parent | 0eda097a0b56ce0627b16de547e642fa5e2e1dd2 (diff) | |
Notes
Diffstat (limited to 'sys/boot/ficl')
| -rw-r--r-- | sys/boot/ficl/Makefile | 4 | ||||
| -rw-r--r-- | sys/boot/ficl/softwords/softcore.fr | 3 | ||||
| -rw-r--r-- | sys/boot/ficl/words.c | 61 |
3 files changed, 55 insertions, 13 deletions
diff --git a/sys/boot/ficl/Makefile b/sys/boot/ficl/Makefile index 2455714bedee..5dd33e1eaf15 100644 --- a/sys/boot/ficl/Makefile +++ b/sys/boot/ficl/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.4 1998/11/05 04:54:05 msmith Exp $ +# $Id: Makefile,v 1.5 1998/11/05 07:27:55 jkh Exp $ # LIB= ficl NOPROFILE= yes @@ -17,7 +17,7 @@ SOFTWORDS= softcore.fr jhlocal.fr marker.fr CFLAGS+= -I${.CURDIR} softcore.c: ${SOFTWORDS} softcore.pl - (cd ${.CURDIR}/softwords; ${PERL} softcore.pl ${SOFTWORDS}) > ${.TARGET} + (cd ${.CURDIR}/softwords; perl softcore.pl ${SOFTWORDS}) > ${.TARGET} .include <bsd.lib.mk> diff --git a/sys/boot/ficl/softwords/softcore.fr b/sys/boot/ficl/softwords/softcore.fr index bcc2696b6efd..ad3d55be8139 100644 --- a/sys/boot/ficl/softwords/softcore.fr +++ b/sys/boot/ficl/softwords/softcore.fr @@ -121,5 +121,8 @@ decimal 32 constant bl wordlist constant hidden : hide hidden dup >search ficl-set-current ; +\ init - hook for extra startup behavior +: init ( -- ) fexists "/boot/boot.4th" if fload "/boot/boot.4th" then ; + \ ** E N D S O F T C O R E . F R diff --git a/sys/boot/ficl/words.c b/sys/boot/ficl/words.c index 1bd9d3591297..35e43485d728 100644 --- a/sys/boot/ficl/words.c +++ b/sys/boot/ficl/words.c @@ -4031,26 +4031,31 @@ static void forget(FICL_VM *pVM) #define nLINEBUF 256 static void fload(FICL_VM *pVM) { - char cp[nLINEBUF]; - char filename[nLINEBUF]; - FICL_STRING *pFilename = (FICL_STRING *)filename; + char *p, cp[nLINEBUF]; + FICL_STRING *pFilename; int i, fd, nLine = 0; char ch; CELL id; + FICL_DICT *dp = ficlGetDict(); - vmGetString(pVM, pFilename, '\n'); + if (pVM->state == COMPILE) + { + dictAppendCell(dp, LVALUEtoCELL(pStringLit)); + dp->here = PTRtoCELL vmGetString(pVM, (FICL_STRING *)dp->here, '\"'); + dictAlign(dp); + return; + } - if (pFilename->count <= 0) + pFilename = (FICL_STRING *)dp->here; + vmGetString(pVM, pFilename, '\"'); + if (pFilename->count <= 1) { vmTextOut(pVM, "fload: no filename specified", 1); return; } - /* - ** get the file's size and make sure it exists - */ - fd = open(pFilename->text, O_RDONLY); - + p = (*pFilename->text == '\"') ? pFilename->text + 1 : pFilename->text; + fd = open(p, O_RDONLY); if (fd == -1) { vmTextOut(pVM, "fload: Unable to open file: ", 0); @@ -4095,6 +4100,39 @@ static void fload(FICL_VM *pVM) return; } +static void fexists(FICL_VM *pVM) +{ + char *p; + FICL_STRING *pFilename; + int fd; + FICL_DICT *dp = ficlGetDict(); + + if (pVM->state == COMPILE) + { + dictAppendCell(dp, LVALUEtoCELL(pStringLit)); + dp->here = PTRtoCELL vmGetString(pVM, (FICL_STRING *)dp->here, '\"'); + dictAlign(dp); + return; + } + + pFilename = (FICL_STRING *)dp->here; + vmGetString(pVM, pFilename, '\"'); + if (pFilename->count <= 1) + { + vmTextOut(pVM, "fexists: no filename specified", 1); + return; + } + p = (*pFilename->text == '\"') ? pFilename->text + 1 : pFilename->text; + fd = open(p, O_RDONLY); + if (fd > 0) { + stackPushINT32(pVM->pStack, TRUE); + close(fd); + } + else + stackPushINT32(pVM->pStack, FALSE); + return; +} + /* Get a character from stdin */ static void key(FICL_VM *pVM) { @@ -4277,7 +4315,8 @@ void ficlCompileCore(FICL_DICT *dp) dictAppendWord(dp, "\\", commentLine, FW_IMMEDIATE); /* FreeBSD extention words */ - dictAppendWord(dp, "fload", fload, FW_DEFAULT); + dictAppendWord(dp, "fload", fload, FW_IMMEDIATE); + dictAppendWord(dp, "fexists", fexists, FW_IMMEDIATE); dictAppendWord(dp, "key", key, FW_DEFAULT); /* |
