local int cmdDDebug(String dbName, Bool sense) { int i; if (strAEqual(dbName, "show")) { printf("\nThe debug hooks are:"); for (i = 0; dbVarInfo[i].name; i++) printf(" \"%s\"", dbVarInfo[i].name); printf("\n"); return 0; } if (strAEqual(dbName, "all")) { for (i = 0; dbVarInfo[i].name; i++) *dbVarInfo[i].pvar = sense; return 0; } for (i = 0; dbVarInfo[i].name; i++) { if (strAEqual(dbName, dbVarInfo[i].name)) { *(dbVarInfo[i].pvar) = sense; return 0; } } return -1; }
PhTag phNumber(String name) { int i; for (i = 0; i < PH_LIMIT; i++) { if (strAEqual(phInfo[i].name, name)) return (PhTag) i; if (strAEqual(phInfo[i].abbrev, name)) return (PhTag) i; } return PH_LIMIT; }
local int cmdDoOptDebug(String arg) { int rc = 0; if (!arg[0]) rc = -1; else if (strAEqual("db", arg)) emitSetDebug(true); else if (strAEqual("prof", arg)) emitSetProfile(true); else rc = -1; return rc; }
local int cmdDoOptGo(String opt) { int rc = 0; if (strAEqual(opt, "run")) { fintMode = FINT_DONT; emitSetRun(true); } else if (strAEqual(opt, "interp")) { fintMode = FINT_RUN; emitSetInterp(true); } else if (strAEqual(opt, "loop")) { fintMode = FINT_LOOP; emitSetInterp(false); emitSetRun(false); comsgSetInteractiveOption(); } else rc = -1; return rc; }
Bool cmdHasOption(int opt0, String arg0, int argc, String *argv) { int opt, i, j; cmdOptionArg = NULL; for (i = 1, j = 0; ; ) { opt = cmdGetOption(argc, argv, &i, &j, &cmdOptionArg); if (!opt) break; if (!cmdIsOption(opt)) { i++; j = 0; continue; } if (optIs(opt, opt0)) { if (!arg0) return true; if (cmdOptionArg && strAEqual(arg0, cmdOptionArg)) return true; } } return false; }
local ArEntry arFindEntry(Archive ar, String name) { ArEntryList alist; arDEBUG(dbOut, "Looking for \"%s\"", name); name = arEntryKey(name); arDEBUG(dbOut, " as archive key \"%s\"", name); for (alist = ar->members; alist; alist = cdr(alist)) { ArEntry arent = car(alist); if (strAEqual(name, arent->name)) { arDEBUG(dbOut, " at offset %ld\n",arent->pos); return arent; } } arDEBUG(dbOut, " not found.\n"); return NULL; }
int phTraceOption(String flags) { char phName[PH_NAME_MAXLEN], doPh[PH_LIMIT]; String phases; int i; /* Make "phases" point to string tail after separator. */ for (phases = flags; *phases != 0; phases++) if (*phases == PH_FLAG_SEP) { phases++; break; } if (*flags == PH_FLAG_SEP || *phases == 0) return -1; if (strAEqual(phases, "all")) for (i = PH_START; i < PH_LIMIT; i++) doPh[i] = true; else { for (i = PH_START; i < PH_LIMIT; i++) doPh[i] = false; while (*phases) { phases = bite(phName, phases, '+'); if ((i = phNumber(phName)) == PH_LIMIT) return -1; doPh[i] = true; } } for (i = PH_START; i < PH_LIMIT; i++) { String f; if (!doPh[i]) continue; for (f = flags; *f != 0 && *f != PH_FLAG_SEP; f++) switch (toupper(*f)) { case 'A': phInfo[i].flags |= PHX_Announce; break; case 'D': phInfo[i].flags |= PHX_Debug; break; case 'G': phInfo[i].flags |= PHX_GcAfter; break; case 'P': phInfo[i].flags |= PHX_Print; break; case 'R': phInfo[i].flags |= PHX_Report; break; case 'S': phInfo[i].flags |= PHX_StoAudit; break; case 'T': phInfo[i].flags |= PHX_Terminates; break; case '0': phInfo[i].flags = 0; break; default: return -1; } } return 0; }
local int cmdDoOptDeveloper(String arg) { int rc = 0; if (!arg[0]) rc = -1; if (strAEqual("trap", arg)) { cmdTrapFlag = true; } else if (strAEqual("check", arg)) { _dont_assert = false; /* Test assertions. */ stoCtl(StoCtl_Wash, true); /* Initialize of store. */ } else if (strAEqual("no-fatal", arg)) _fatal_assert = false; /* Make assertions non-fatal. */ else if (strAEqual("runtime", arg)) genSetRuntime(); else if (strEqual("debug", arg)) genSetDebugWanted(true); else if (strEqual("debugger", arg)) genSetDebuggerWanted(true); else if (strEqual("depend", arg)) emitSetDependsWanted(true); else if (strEqual("small-hcodes", arg)) genSetSmallHashCodes(true); else if (strEqual("lazy-catch", arg)) gfSetLazyCatch(true); else if (strEqual("dumb-import", arg)) stabSetDumbImport(true); else if (strEqual("trace-cfuns", arg)) gencSetTraceFuns(true); else if (strEqual("no-where", arg)) NoWhereHack = true; else if (strAEqual("runtime-hashcheck", arg)) genSetHashcheck(); else if (strAIsPrefix("keyword", arg)) { String darg = cmdDGetOptArg(arg, "keyword", NULL); cmdDoKeywordStatus(darg, true); } else if (strAIsPrefix("no-keyword", arg)) { String darg = cmdDGetOptArg(arg, "no-keyword", NULL); cmdDoKeywordStatus(darg, false); } else if (strEqual("no-negated-tests", arg)) jflowSetNegate(false); else if (strAEqual("audit", arg)) foamAuditSetAll(); else if (strAEqual("nhash", arg)) genSetAxiomAx(true); else if (strAEqual("missing-ok", arg)) tiSetSoftMissing(true); else if (strAEqual("sexpr", arg)) { cmdSExprFlag = true; } else if (strAEqual("seval", arg)) { cmdSEvalFlag = true; } else if (strAEqual("no-gc", arg)) { /* Handled already - no action need be taken here */ } else if (strAEqual("gc", arg)) { /* Handled already - no action need be taken here */ cmdGcFlag = true; } else if (strAEqual("gcfile", arg)) { /* Handled already - no action need be taken here */ cmdGcFileFlag = true; } else if (strAEqual("loops", arg)) { optSetLoopOption(); } else if (strAEqual("emerge-noalias", arg)) { emSetNoAlias(); } else if (strAIsPrefix("test", arg)) { String darg = cmdDGetOptArg(arg, "test", NULL); testSelf(darg); exitSuccess(); } else if (strAIsPrefix("rtcache", arg)) { String darg = cmdDGetOptArg(arg, "rtcache", NULL); long rtsize; extern void gen0SetRtCacheSize(AInt); sscanf(darg, "%ld", &rtsize); gen0SetRtCacheSize((AInt)rtsize); } else if (strAIsPrefix("D", arg)) { char sep; String darg = cmdDGetOptArg(arg, "D", &sep); rc = cmdDDebug(darg, sep == '+'); } else if (strAIsPrefix("T", arg)) { rc = phTraceOption(arg+strlen("T")); } else if (strAIsPrefix("name", arg)) { String darg = cmdDGetOptArg(arg, "name", NULL); emitSetFileIdName(darg); } else if (strAIsPrefix("prefix", arg)) { String darg = cmdDGetOptArg(arg, "prefix", NULL); emitSetFileIdPrefix(darg); } else if (strAEqual("floatrep", arg)) { cmdFloatRepFlag = true; } else rc = -1; return rc; }
local int cmdDoOptHelp(String arg) { int rc = 0; if (!arg || strAEqual(arg, "elp")) { helpFPrintf(osStdout, ALDOR_H_HelpCmd); } else if (strAEqual(arg, "all")) { helpFPrintf(osStdout, ALDOR_H_HelpCmd); helpFPrintf(osStdout, ALDOR_H_HelpFileTypes, FTYPE_OBJECT); helpFPrintf(osStdout, ALDOR_H_HelpOptionSummary); helpFPrintf(osStdout, ALDOR_H_HelpHelpOpt); helpFPrintf(osStdout, ALDOR_H_HelpArgOpt); helpFPrintf(osStdout, ALDOR_H_HelpDirOpt); helpFPrintf(osStdout, ALDOR_H_HelpFileOpt); helpFPrintf(osStdout, ALDOR_H_HelpGoOpt); helpFPrintf(osStdout, ALDOR_H_HelpOptimOpt); helpFPrintf(osStdout, ALDOR_H_HelpDebugOpt); helpFPrintf(osStdout, ALDOR_H_HelpConfigOpt); helpFPrintf(osStdout, ALDOR_H_HelpCOpt); helpFPrintf(osStdout, ALDOR_H_HelpCppOpt); helpFPrintf(osStdout, ALDOR_H_HelpLispOpt); helpFPrintf(osStdout, ALDOR_H_HelpMsgOpt); helpFPrintf(osStdout, ALDOR_H_HelpDevOpt); } else if (strAEqual(arg, "files")) { helpFPrintf(osStdout, ALDOR_H_HelpFileTypes, FTYPE_OBJECT); helpFPrintf(osStdout, ALDOR_H_HelpMenuPointer); } else if (strAEqual(arg, "options")) { helpFPrintf(osStdout, ALDOR_H_HelpOptionSummary); helpFPrintf(osStdout, ALDOR_H_HelpMenuPointer); } else if (strAEqual(arg, "info")) { helpFPrintf(osStdout, ALDOR_H_HelpProductInfo); } else if (strAEqual(arg, "h") || strAEqual(arg, "help")) { helpFPrintf(osStdout, ALDOR_H_HelpHelpOpt); helpFPrintf(osStdout, ALDOR_H_HelpMenuPointer); } else if (strAEqual(arg, "a") || strAEqual(arg, "args")) { helpFPrintf(osStdout, ALDOR_H_HelpArgOpt); helpFPrintf(osStdout, ALDOR_H_HelpMenuPointer); } else if (strAEqual(arg, "dir")) { helpFPrintf(osStdout, ALDOR_H_HelpDirOpt); helpFPrintf(osStdout, ALDOR_H_HelpMenuPointer); } else if (strAEqual(arg, "F") || strAEqual(arg, "fout")) { helpFPrintf(osStdout, ALDOR_H_HelpFileOpt); helpFPrintf(osStdout, ALDOR_H_HelpMenuPointer); } else if (strAEqual(arg, "g") || strAEqual(arg, "go")) { helpFPrintf(osStdout, ALDOR_H_HelpGoOpt); helpFPrintf(osStdout, ALDOR_H_HelpMenuPointer); } else if (strAEqual(arg, "Q") || strAEqual(arg, "O") || strAEqual(arg, "optimize")) { helpFPrintf(osStdout, ALDOR_H_HelpOptimOpt); helpFPrintf(osStdout, ALDOR_H_HelpMenuPointer); } else if (strAEqual(arg, "Z") || strAEqual(arg, "debug")) { helpFPrintf(osStdout, ALDOR_H_HelpDebugOpt); helpFPrintf(osStdout, ALDOR_H_HelpMenuPointer); } else if (strAEqual(arg, "N") || strAEqual(arg, "config")) { helpFPrintf(osStdout, ALDOR_H_HelpConfigOpt); helpFPrintf(osStdout, ALDOR_H_HelpMenuPointer); } else if (strAEqual(arg, "C")) { helpFPrintf(osStdout, ALDOR_H_HelpCOpt); helpFPrintf(osStdout, ALDOR_H_HelpMenuPointer); } else if (strAEqual(arg, "P")) { helpFPrintf(osStdout, ALDOR_H_HelpCppOpt); helpFPrintf(osStdout, ALDOR_H_HelpMenuPointer); } else if (strAEqual(arg, "S") || strAEqual(arg, "lisp")) { helpFPrintf(osStdout, ALDOR_H_HelpLispOpt); helpFPrintf(osStdout, ALDOR_H_HelpMenuPointer); } else if (strAEqual(arg, "M") || strAEqual(arg, "message")) { helpFPrintf(osStdout, ALDOR_H_HelpMsgOpt); helpFPrintf(osStdout, ALDOR_H_HelpMenuPointer); } else if (strAEqual(arg, "W") || strAEqual(arg, "dev")) { helpFPrintf(osStdout, ALDOR_H_HelpDevOpt); helpFPrintf(osStdout, ALDOR_H_HelpMenuPointer); } else rc = -1; return rc; }
/* * Allow file types to be equal independent of case. */ Bool ftypeEqual(String ft1, String ft2) { return strAEqual(ft1, ft2); }