diff options
author | jkh <jkh@FreeBSD.org> | 1998-11-06 23:20:32 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1998-11-06 23:20:32 +0000 |
commit | d539a87b020432df01445b07b69542daccf0ea16 (patch) | |
tree | ad79b3cbe57b7c37f078744fa0eac36cd9491bc3 /sys/boot | |
parent | 93ce759c73e21f7ac6642b79a8e6146522b452aa (diff) | |
download | FreeBSD-src-d539a87b020432df01445b07b69542daccf0ea16.zip FreeBSD-src-d539a87b020432df01445b07b69542daccf0ea16.tar.gz |
Make fexists/fload work with existing string literals instead. Doing
my own string literal handling is just too wonky.
Diffstat (limited to 'sys/boot')
-rw-r--r-- | sys/boot/ficl/softwords/softcore.fr | 2 | ||||
-rw-r--r-- | sys/boot/ficl/words.c | 48 |
2 files changed, 9 insertions, 41 deletions
diff --git a/sys/boot/ficl/softwords/softcore.fr b/sys/boot/ficl/softwords/softcore.fr index ad3d55b..4f38ee0 100644 --- a/sys/boot/ficl/softwords/softcore.fr +++ b/sys/boot/ficl/softwords/softcore.fr @@ -122,7 +122,7 @@ 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 ; +: init ( -- ) s" /boot/boot.4th" fexists if s" /boot/boot.4th" fload 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 35e4348..886b429 100644 --- a/sys/boot/ficl/words.c +++ b/sys/boot/ficl/words.c @@ -4025,37 +4025,20 @@ static void forget(FICL_VM *pVM) * * grabbed out of testmain.c example and frobbed to fit. * - * Usage: - * fload test.ficl + * fload ( addr count -- ) */ #define nLINEBUF 256 static void fload(FICL_VM *pVM) { - char *p, cp[nLINEBUF]; FICL_STRING *pFilename; + char cp[nLINEBUF]; int i, fd, nLine = 0; char ch; CELL id; - 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, "fload: no filename specified", 1); - return; - } - p = (*pFilename->text == '\"') ? pFilename->text + 1 : pFilename->text; - fd = open(p, O_RDONLY); + pFilename->count = stackPopINT32(pVM->pStack); + pFilename->text = stackPopPtr(pVM->pStack); + fd = open(pFilename->text, O_RDONLY); if (fd == -1) { vmTextOut(pVM, "fload: Unable to open file: ", 0); @@ -4105,25 +4088,10 @@ 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); + pFilename->count = stackPopINT32(pVM->pStack); + pFilename->text = stackPopPtr(pVM->pStack); + fd = open(pFilename->text, O_RDONLY); if (fd > 0) { stackPushINT32(pVM->pStack, TRUE); close(fd); |