ficl.c (40989) | ficl.c (43078) |
---|---|
1/******************************************************************* 2** f i c l . c 3** Forth Inspired Command Language - external interface 4** Author: John Sadler (john_sadler@alum.mit.edu) 5** Created: 19 July 1997 6** 7*******************************************************************/ 8/* --- 156 unchanged lines hidden (view full) --- 165** VM_ERREXIT means that the interp encountered a syntax error 166** and the vm has been reset to recover (some or all 167** of the text block got ignored 168** VM_USEREXIT means that the user executed the "bye" command 169** to shut down the interpreter. This would be a good 170** time to delete the vm, etc -- or you can ignore this 171** signal. 172**************************************************************************/ | 1/******************************************************************* 2** f i c l . c 3** Forth Inspired Command Language - external interface 4** Author: John Sadler (john_sadler@alum.mit.edu) 5** Created: 19 July 1997 6** 7*******************************************************************/ 8/* --- 156 unchanged lines hidden (view full) --- 165** VM_ERREXIT means that the interp encountered a syntax error 166** and the vm has been reset to recover (some or all 167** of the text block got ignored 168** VM_USEREXIT means that the user executed the "bye" command 169** to shut down the interpreter. This would be a good 170** time to delete the vm, etc -- or you can ignore this 171** signal. 172**************************************************************************/ |
173int ficlExec(FICL_VM *pVM, char *pText) | 173int ficlExec(FICL_VM *pVM, char *pText, INT32 size) |
174{ 175 int except; 176 FICL_WORD *tempFW; 177 jmp_buf vmState; 178 jmp_buf *oldState; 179 TIB saveTib; 180 181 assert(pVM); 182 | 174{ 175 int except; 176 FICL_WORD *tempFW; 177 jmp_buf vmState; 178 jmp_buf *oldState; 179 TIB saveTib; 180 181 assert(pVM); 182 |
183 vmPushTib(pVM, pText, &saveTib); | 183 vmPushTib(pVM, pText, size, &saveTib); |
184 185 /* 186 ** Save and restore VM's jmp_buf to enable nested calls to ficlExec 187 */ 188 oldState = pVM->pState; 189 pVM->pState = &vmState; /* This has to come before the setjmp! */ 190 except = setjmp(vmState); 191 --- 40 unchanged lines hidden (view full) --- 232 233 case VM_QUIT: 234 if (pVM->state == COMPILE) 235 dictAbortDefinition(dp); 236 vmQuit(pVM); 237 break; 238 239 case VM_ERREXIT: | 184 185 /* 186 ** Save and restore VM's jmp_buf to enable nested calls to ficlExec 187 */ 188 oldState = pVM->pState; 189 pVM->pState = &vmState; /* This has to come before the setjmp! */ 190 except = setjmp(vmState); 191 --- 40 unchanged lines hidden (view full) --- 232 233 case VM_QUIT: 234 if (pVM->state == COMPILE) 235 dictAbortDefinition(dp); 236 vmQuit(pVM); 237 break; 238 239 case VM_ERREXIT: |
240 case VM_ABORT: 241 case VM_ABORTQ: |
|
240 default: /* user defined exit code?? */ 241 if (pVM->state == COMPILE) 242 { 243 dictAbortDefinition(dp); 244#if FICL_WANT_LOCALS 245 dictEmpty(localp, localp->pForthWords->size); 246#endif 247 } --- 32 unchanged lines hidden (view full) --- 280 while ((status = read(fd, &ch, 1)) > 0 && ch != '\n') 281 cp[i++] = ch; 282 nLine++; 283 if (!i) { 284 if (status < 1) 285 break; 286 continue; 287 } | 242 default: /* user defined exit code?? */ 243 if (pVM->state == COMPILE) 244 { 245 dictAbortDefinition(dp); 246#if FICL_WANT_LOCALS 247 dictEmpty(localp, localp->pForthWords->size); 248#endif 249 } --- 32 unchanged lines hidden (view full) --- 282 while ((status = read(fd, &ch, 1)) > 0 && ch != '\n') 283 cp[i++] = ch; 284 nLine++; 285 if (!i) { 286 if (status < 1) 287 break; 288 continue; 289 } |
288 cp[i] = '\0'; 289 if ((rval = ficlExec(pVM, cp)) >= VM_ERREXIT) | 290 if ((rval = ficlExec(pVM, cp, i)) >= VM_ERREXIT) |
290 { 291 pVM->sourceID = id; 292 vmThrowErr(pVM, "ficlExecFD: Error at line %d", nLine); 293 break; 294 } 295 } 296 /* 297 ** Pass an empty line with SOURCE-ID == 0 to flush 298 ** any pending REFILLs (as required by FILE wordset) 299 */ 300 pVM->sourceID.i = -1; | 291 { 292 pVM->sourceID = id; 293 vmThrowErr(pVM, "ficlExecFD: Error at line %d", nLine); 294 break; 295 } 296 } 297 /* 298 ** Pass an empty line with SOURCE-ID == 0 to flush 299 ** any pending REFILLs (as required by FILE wordset) 300 */ 301 pVM->sourceID.i = -1; |
301 ficlExec(pVM, ""); | 302 ficlExec(pVM, "", 0); |
302 303 pVM->sourceID = id; 304 return rval; 305} 306 307/************************************************************************** 308 f i c l L o o k u p 309** Look in the system dictionary for a match to the given name. If --- 123 unchanged lines hidden --- | 303 304 pVM->sourceID = id; 305 return rval; 306} 307 308/************************************************************************** 309 f i c l L o o k u p 310** Look in the system dictionary for a match to the given name. If --- 123 unchanged lines hidden --- |