bool ExecuteIfCommandComplete( void *theEnv) { if ((CompleteCommand(CommandLineData(theEnv)->CommandString) == 0) || (RouterData(theEnv)->CommandBufferInputCount == 0) || (RouterData(theEnv)->AwaitingInput == false)) { return false; } if (CommandLineData(theEnv)->BeforeCommandExecutionFunction != NULL) { if (! (*CommandLineData(theEnv)->BeforeCommandExecutionFunction)(theEnv)) { return false; } } FlushPPBuffer(theEnv); SetPPBufferStatus(theEnv,false); RouterData(theEnv)->CommandBufferInputCount = 0; RouterData(theEnv)->AwaitingInput = false; RouteCommand(theEnv,CommandLineData(theEnv)->CommandString,true); FlushPPBuffer(theEnv); FlushParsingMessages(theEnv); EnvSetHaltExecution(theEnv,false); EnvSetEvaluationError(theEnv,false); FlushCommandString(theEnv); CleanCurrentGarbageFrame(theEnv,NULL); CallPeriodicTasks(theEnv); PrintPrompt(theEnv); return true; }
globle void PrintWarningID( void *theEnv, const char *module, int warningID, int printCR) { #if (! RUN_TIME) && (! BLOAD_ONLY) FlushParsingMessages(theEnv); EnvSetWarningFileName(theEnv,EnvGetParsingFileName(theEnv)); ConstructData(theEnv)->WrnLineNumber = GetLineCount(theEnv); #endif if (printCR) EnvPrintRouter(theEnv,WWARNING,"\n"); EnvPrintRouter(theEnv,WWARNING,"["); EnvPrintRouter(theEnv,WWARNING,module); PrintLongInteger(theEnv,WWARNING,(long int) warningID); EnvPrintRouter(theEnv,WWARNING,"] WARNING: "); }
globle void PrintErrorID( void *theEnv, const char *module, int errorID, int printCR) { #if (! RUN_TIME) && (! BLOAD_ONLY) FlushParsingMessages(theEnv); EnvSetErrorFileName(theEnv,EnvGetParsingFileName(theEnv)); ConstructData(theEnv)->ErrLineNumber = GetLineCount(theEnv); #endif if (printCR) EnvPrintRouter(theEnv,WERROR,"\n"); EnvPrintRouter(theEnv,WERROR,"["); EnvPrintRouter(theEnv,WERROR,module); PrintLongInteger(theEnv,WERROR,(long int) errorID); EnvPrintRouter(theEnv,WERROR,"] "); }
void PrintWarningID( Environment *theEnv, const char *module, int warningID, bool printCR) { #if (! RUN_TIME) && (! BLOAD_ONLY) FlushParsingMessages(theEnv); SetWarningFileName(theEnv,GetParsingFileName(theEnv)); ConstructData(theEnv)->WrnLineNumber = GetLineCount(theEnv); #endif if (printCR) WriteString(theEnv,STDWRN,"\n"); WriteString(theEnv,STDWRN,"["); WriteString(theEnv,STDWRN,module); WriteInteger(theEnv,STDWRN,warningID); WriteString(theEnv,STDWRN,"] "); /*==================================================*/ /* Print the file name and line number if available */ /* and there is no callback for errors/warnings. */ /*==================================================*/ #if (! RUN_TIME) && (! BLOAD_ONLY) if ((ConstructData(theEnv)->ParserErrorCallback == NULL) && (GetLoadInProgress(theEnv) == true)) { const char *fileName; fileName = GetParsingFileName(theEnv); if (fileName != NULL) { WriteString(theEnv,STDERR,fileName); WriteString(theEnv,STDERR,", Line "); WriteInteger(theEnv,STDERR,GetLineCount(theEnv)); WriteString(theEnv,STDERR,", "); } } #endif WriteString(theEnv,STDWRN,"WARNING: "); }
bool BatchStar( Environment *theEnv, const char *fileName) { int inchar; bool done = false; FILE *theFile; char *theString = NULL; size_t position = 0; size_t maxChars = 0; #if (! RUN_TIME) && (! BLOAD_ONLY) char *oldParsingFileName; long oldLineCountValue; #endif /*======================*/ /* Open the batch file. */ /*======================*/ theFile = GenOpen(theEnv,fileName,"r"); if (theFile == NULL) { OpenErrorMessage(theEnv,"batch",fileName); return false; } /*======================================*/ /* Setup for capturing errors/warnings. */ /*======================================*/ #if (! RUN_TIME) && (! BLOAD_ONLY) oldParsingFileName = CopyString(theEnv,GetParsingFileName(theEnv)); SetParsingFileName(theEnv,fileName); CreateErrorCaptureRouter(theEnv); oldLineCountValue = SetLineCount(theEnv,1); #endif /*=====================================*/ /* If embedded, clear the error flags. */ /*=====================================*/ if (EvaluationData(theEnv)->CurrentExpression == NULL) { ResetErrorFlags(theEnv); } /*=============================================*/ /* Evaluate commands from the file one by one. */ /*=============================================*/ while (! done) { inchar = getc(theFile); if (inchar == EOF) { inchar = '\n'; done = true; } theString = ExpandStringWithChar(theEnv,inchar,theString,&position, &maxChars,maxChars+80); if (CompleteCommand(theString) != 0) { FlushPPBuffer(theEnv); SetPPBufferStatus(theEnv,false); RouteCommand(theEnv,theString,false); FlushPPBuffer(theEnv); SetHaltExecution(theEnv,false); SetEvaluationError(theEnv,false); FlushBindList(theEnv,NULL); genfree(theEnv,theString,maxChars); theString = NULL; maxChars = 0; position = 0; #if (! RUN_TIME) && (! BLOAD_ONLY) FlushParsingMessages(theEnv); #endif } if ((inchar == '\r') || (inchar == '\n')) { IncrementLineCount(theEnv); } } if (theString != NULL) { genfree(theEnv,theString,maxChars); } /*=======================*/ /* Close the batch file. */ /*=======================*/ GenClose(theEnv,theFile); /*========================================*/ /* Cleanup for capturing errors/warnings. */ /*========================================*/ #if (! RUN_TIME) && (! BLOAD_ONLY) FlushParsingMessages(theEnv); DeleteErrorCaptureRouter(theEnv); SetLineCount(theEnv,oldLineCountValue); SetParsingFileName(theEnv,oldParsingFileName); DeleteString(theEnv,oldParsingFileName); #endif return true; }
bool RemoveBatch( Environment *theEnv) { struct batchEntry *bptr; bool rv, fileBatch = false; if (FileCommandData(theEnv)->TopOfBatchList == NULL) return false; /*==================================================*/ /* Close the source from which batch input is read. */ /*==================================================*/ if (FileCommandData(theEnv)->TopOfBatchList->batchType == FILE_BATCH) { fileBatch = true; GenClose(theEnv,FileCommandData(theEnv)->TopOfBatchList->fileSource); #if (! RUN_TIME) && (! BLOAD_ONLY) FlushParsingMessages(theEnv); DeleteErrorCaptureRouter(theEnv); #endif } else { CloseStringSource(theEnv,FileCommandData(theEnv)->TopOfBatchList->logicalSource); rm(theEnv,(void *) FileCommandData(theEnv)->TopOfBatchList->theString, strlen(FileCommandData(theEnv)->TopOfBatchList->theString) + 1); } /*=================================*/ /* Remove the entry from the list. */ /*=================================*/ DeleteString(theEnv,(char *) FileCommandData(theEnv)->TopOfBatchList->fileName); bptr = FileCommandData(theEnv)->TopOfBatchList; FileCommandData(theEnv)->TopOfBatchList = FileCommandData(theEnv)->TopOfBatchList->next; DeleteString(theEnv,(char *) bptr->logicalSource); rtn_struct(theEnv,batchEntry,bptr); /*========================================================*/ /* If there are no batch files remaining to be processed, */ /* then free the space used by the batch buffer. */ /*========================================================*/ if (FileCommandData(theEnv)->TopOfBatchList == NULL) { FileCommandData(theEnv)->BottomOfBatchList = NULL; FileCommandData(theEnv)->BatchFileSource = NULL; FileCommandData(theEnv)->BatchLogicalSource = NULL; if (FileCommandData(theEnv)->BatchBuffer != NULL) { rm(theEnv,FileCommandData(theEnv)->BatchBuffer,FileCommandData(theEnv)->BatchMaximumPosition); FileCommandData(theEnv)->BatchBuffer = NULL; } FileCommandData(theEnv)->BatchCurrentPosition = 0; FileCommandData(theEnv)->BatchMaximumPosition = 0; rv = false; #if (! RUN_TIME) && (! BLOAD_ONLY) if (fileBatch) { SetParsingFileName(theEnv,FileCommandData(theEnv)->batchPriorParsingFile); DeleteString(theEnv,FileCommandData(theEnv)->batchPriorParsingFile); FileCommandData(theEnv)->batchPriorParsingFile = NULL; } #endif } /*===========================================*/ /* Otherwise move on to the next batch file. */ /*===========================================*/ else { FileCommandData(theEnv)->BatchType = FileCommandData(theEnv)->TopOfBatchList->batchType; FileCommandData(theEnv)->BatchFileSource = FileCommandData(theEnv)->TopOfBatchList->fileSource; FileCommandData(theEnv)->BatchLogicalSource = FileCommandData(theEnv)->TopOfBatchList->logicalSource; FileCommandData(theEnv)->BatchCurrentPosition = 0; rv = true; #if (! RUN_TIME) && (! BLOAD_ONLY) if (FileCommandData(theEnv)->TopOfBatchList->batchType == FILE_BATCH) { SetParsingFileName(theEnv,FileCommandData(theEnv)->TopOfBatchList->fileName); } SetLineCount(theEnv,FileCommandData(theEnv)->TopOfBatchList->lineNumber); #endif } /*====================================================*/ /* Return true if a batch file if there are remaining */ /* batch files to be processed, otherwise false. */ /*====================================================*/ return(rv); }