Make fexists/fload work with existing string literals instead. Doing

my own string literal handling is just too wonky.
This commit is contained in:
Jordan K. Hubbard 1998-11-06 23:20:32 +00:00
parent d8acd8dc5c
commit f476d38a01
2 changed files with 9 additions and 41 deletions

View File

@ -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

View File

@ -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);