void handleCommandRepeat(){ if(numInHistory == 0){ printf("No commands in history.\n"); } else{ args = copyArgList(previousCommands[numInHistory - 1], numberOfTokensInCommand[numInHistory - 1]); background = runInBackground[numInHistory -1]; tokenNumber = numberOfTokensInCommand[numInHistory - 1]; printf("%s\n", makeCommandOneLine(numInHistory-1)); } }
void parseHistoryMarker(char * argList[]){ int commandNumber = atoi(argList[0]+1); if(commandNumber){ int commandIndex = getCommandIndex(commandNumber); if(-1 == commandIndex){ printf("No such command in history.\n"); } else{ tokenNumber = numberOfTokensInCommand[commandIndex]; args = copyArgList(previousCommands[commandIndex], tokenNumber); background = runInBackground[commandIndex]; printf("%s\n", makeCommandOneLine(commandIndex)); } } }
void addCommandToHistory(char * argList[], int inBackground, int numTokens){ if(strcmp(argList[0], "")){ if(numInHistory >= MAX_HISTORY){ makeSpaceInHistory(); numInHistory--; } if(0 == minHistory){ minHistory++; } maxHistory++; previousCommands[numInHistory] = copyArgList(argList, numTokens); numberOfTokensInCommand[numInHistory] = numTokens; runInBackground[numInHistory] = inBackground; numInHistory++; } }
static void compileFile(const char *compiler, arglist *options, const char *cfile) { char ofile[MAXPATHLEN]; char *ext; arglist *args = copyArgList(options); if ( opt_o && nolink ) { strcpy(ofile, out); } else { strcpy(ofile, cfile); if ( (ext = (char *)file_name_extension(ofile)) ) strcpy(ext, EXT_OBJ); } if ( !opt_E ) prependArgList(args, "-c"); #if defined(HOST_OS_WINDOWS) appendArgList(args, "-D__WINDOWS__"); appendArgList(args, "-D_WINDOWS"); #endif appendArgList(args, "-D__SWI_PROLOG__"); if ( !shared ) appendArgList(args, "-D__SWI_EMBEDDED__"); concatArgList(args, "-I", &includedirs); if ( opt_o || !opt_E ) { appendArgList(args, "-o"); appendArgList(args, ofile); } appendArgList(args, cfile); callprog(compiler, args); appendArgList(&ofiles, ofile); if ( !nolink ) appendArgList(&tmpfiles, ofile); freeArgList(args); }