|
|
1.1 ! root 1: /*************************************************************************** ! 2: * This program is Copyright (C) 1986, 1987, 1988 by Jonathan Payne. JOVE * ! 3: * is provided to you without charge, and with no warranty. You may give * ! 4: * away copies of JOVE, including sources, provided that this notice is * ! 5: * included in all the files. * ! 6: ***************************************************************************/ ! 7: ! 8: #include "jove.h" ! 9: #include "ctype.h" ! 10: ! 11: #if !defined(MSDOS) && !defined(SYSV) && !defined(MAC) ! 12: # include <sgtty.h> ! 13: #endif ! 14: ! 15: #if !defined(TXT_TO_C) ! 16: ! 17: #if defined(MAC) ! 18: # define WIRED_CMD(c) (c),'\0','\0' /* for About Jove... */ ! 19: #else ! 20: # define WIRED_CMD(c) (c) ! 21: #endif /* MAC */ ! 22: ! 23: #else /* TXT_TO_C */ ! 24: ! 25: #if defined(MAC) ! 26: # define WIRED_CMD(c) 0,'\0','\0' ! 27: #else ! 28: # define WIRED_CMD(c) 0 ! 29: #endif ! 30: #endif /* TXT_TO_C */ ! 31: ! 32: const struct cmd commands[] = { ! 33: #if defined(LISP) ! 34: FUNCTION, "add-lisp-special", WIRED_CMD(AddSpecial), ! 35: #endif ! 36: FUNCTION, "append-region", WIRED_CMD(AppReg), ! 37: FUNCTION, "apropos", WIRED_CMD(Apropos), ! 38: FUNCTION, "auto-execute-command", WIRED_CMD(CAutoExec), ! 39: FUNCTION, "auto-execute-macro", WIRED_CMD(MAutoExec), ! 40: DefMinor(Fill), "auto-fill-mode", WIRED_CMD(0), ! 41: DefMinor(Indent), "auto-indent-mode", WIRED_CMD(0), ! 42: FUNCTION, "backward-character", WIRED_CMD(BackChar), ! 43: FUNCTION, "backward-list", WIRED_CMD(BList), ! 44: FUNCTION, "backward-paragraph", WIRED_CMD(BackPara), ! 45: FUNCTION, "backward-s-expression", WIRED_CMD(BSexpr), ! 46: FUNCTION, "backward-sentence", WIRED_CMD(Bos), ! 47: FUNCTION, "backward-up-list", WIRED_CMD(BUpList), ! 48: FUNCTION, "backward-word", WIRED_CMD(BackWord), ! 49: FUNCTION, "begin-kbd-macro", WIRED_CMD(Remember), ! 50: FUNCTION, "beginning-of-file", WIRED_CMD(Bof), ! 51: FUNCTION, "beginning-of-line", WIRED_CMD(Bol), ! 52: FUNCTION, "beginning-of-window", WIRED_CMD(Bow), ! 53: FUNCTION, "bind-to-key", WIRED_CMD(BindAKey), ! 54: FUNCTION, "bind-keymap-to-key", WIRED_CMD(KmBind), ! 55: FUNCTION, "bind-macro-to-key", WIRED_CMD(BindMac), ! 56: #if defined(ABBREV) ! 57: FUNCTION, "bind-macro-to-word-abbrev", WIRED_CMD(BindMtoW), ! 58: #endif ! 59: FUNCTION, "buffer-position", WIRED_CMD(BufPos), ! 60: DefMajor(CMODE), "c-mode", WIRED_CMD(0), ! 61: MODFUNC, "case-character-capitalize", WIRED_CMD(CapChar), ! 62: MODFUNC, "case-region-lower", WIRED_CMD(CasRegLower), ! 63: MODFUNC, "case-region-upper", WIRED_CMD(CasRegUpper), ! 64: MODFUNC, "case-word-capitalize", WIRED_CMD(CapWord), ! 65: MODFUNC, "case-word-lower", WIRED_CMD(LowWord), ! 66: MODFUNC, "case-word-upper", WIRED_CMD(UppWord), ! 67: MODFUNC, "character-to-octal-insert", WIRED_CMD(ChrToOct), ! 68: FUNCTION, "cd", WIRED_CMD(Chdir), ! 69: FUNCTION, "clear-and-redraw", WIRED_CMD(ClAndRedraw), ! 70: #if !defined(MAC) ! 71: FUNCTION, "compile-it", WIRED_CMD(MakeErrors), ! 72: #endif ! 73: #if defined(IPROCS) && !defined(PIPEPROCS) && defined(TIOCSLTC) ! 74: FUNCTION, "continue-process", WIRED_CMD(ProcCont), ! 75: #endif ! 76: FUNCTION, "copy-region", WIRED_CMD(CopyRegion), ! 77: #if !defined(MAC) ! 78: FUNCTION, "current-error", WIRED_CMD(ShowErr), ! 79: #endif ! 80: FUNCTION, "date", WIRED_CMD(prCTIME), ! 81: #if defined(IPROCS) ! 82: FUNCTION, "process-dbx-output", WIRED_CMD(DBXpoutput), ! 83: #endif ! 84: #if defined(ABBREV) ! 85: FUNCTION, "define-global-word-abbrev", WIRED_CMD(DefGAbbrev), ! 86: FUNCTION, "define-mode-word-abbrev", WIRED_CMD(DefMAbbrev), ! 87: #endif ! 88: FUNCTION, "define-macro", WIRED_CMD(DefKBDMac), ! 89: MODFUNC, "delete-blank-lines", WIRED_CMD(DelBlnkLines), ! 90: FUNCTION, "delete-buffer", WIRED_CMD(BufKill), ! 91: FUNCTION, "delete-macro", WIRED_CMD(DelMacro), ! 92: MODFUNC, "delete-next-character", WIRED_CMD(DelNChar), ! 93: FUNCTION, "delete-other-windows", WIRED_CMD(OneWindow), ! 94: MODFUNC, "delete-previous-character", WIRED_CMD(DelPChar), ! 95: MODFUNC, "delete-white-space", WIRED_CMD(DelWtSpace), ! 96: FUNCTION, "delete-current-window", WIRED_CMD(DelCurWindow), ! 97: FUNCTION, "describe-bindings", WIRED_CMD(DescBindings), ! 98: FUNCTION, "describe-command", WIRED_CMD(DescCom), ! 99: FUNCTION, "describe-key", WIRED_CMD(KeyDesc), ! 100: FUNCTION, "describe-variable", WIRED_CMD(DescCom), ! 101: FUNCTION, "digit", WIRED_CMD(Digit), ! 102: FUNCTION, "digit-1", WIRED_CMD(Digit1), ! 103: FUNCTION, "digit-2", WIRED_CMD(Digit2), ! 104: FUNCTION, "digit-3", WIRED_CMD(Digit3), ! 105: FUNCTION, "digit-4", WIRED_CMD(Digit4), ! 106: FUNCTION, "digit-5", WIRED_CMD(Digit5), ! 107: FUNCTION, "digit-6", WIRED_CMD(Digit6), ! 108: FUNCTION, "digit-7", WIRED_CMD(Digit7), ! 109: FUNCTION, "digit-8", WIRED_CMD(Digit8), ! 110: FUNCTION, "digit-9", WIRED_CMD(Digit9), ! 111: FUNCTION, "digit-0", WIRED_CMD(Digit0), ! 112: FUNCTION, "dirs", WIRED_CMD(prDIRS), ! 113: FUNCTION, "down-list", WIRED_CMD(FDownList), ! 114: #if defined(IPROCS) && !defined(PIPEPROCS) && defined(TIOCSLTC) ! 115: FUNCTION, "dstop-process", WIRED_CMD(ProcDStop), ! 116: #endif ! 117: #if defined(ABBREV) ! 118: FUNCTION, "edit-word-abbrevs", WIRED_CMD(EditAbbrevs), ! 119: #endif ! 120: FUNCTION, "end-kbd-macro", WIRED_CMD(Forget), ! 121: FUNCTION, "end-of-file", WIRED_CMD(Eof), ! 122: FUNCTION, "end-of-line", WIRED_CMD(Eol), ! 123: FUNCTION, "end-of-window", WIRED_CMD(Eow), ! 124: #if defined(IPROCS) && !defined(PIPEPROCS) ! 125: FUNCTION, "eof-process", WIRED_CMD(ProcEof), ! 126: #endif ! 127: FUNCTION, "erase-buffer", WIRED_CMD(BufErase), ! 128: FUNCTION, "exchange-point-and-mark", WIRED_CMD(PtToMark), ! 129: FUNCTION, "execute-named-command", WIRED_CMD(Extend), ! 130: FUNCTION, "execute-kbd-macro", WIRED_CMD(ExecMacro), ! 131: FUNCTION, "execute-macro", WIRED_CMD(RunMacro), ! 132: FUNCTION, "exit-jove", WIRED_CMD(Leave), ! 133: #if defined(CMT_FMT) ! 134: MODFUNC, "fill-comment", WIRED_CMD(Comment), ! 135: #endif /* CMT_FMT */ ! 136: MODFUNC, "fill-paragraph", WIRED_CMD(Justify), ! 137: MODFUNC, "fill-region", WIRED_CMD(RegJustify), ! 138: #if !defined(MAC) ! 139: MODFUNC, "filter-region", WIRED_CMD(FilterRegion), ! 140: #endif ! 141: FUNCTION, "find-file", WIRED_CMD(FindFile), ! 142: FUNCTION, "find-tag", WIRED_CMD(FindTag), ! 143: FUNCTION, "find-tag-at-point", WIRED_CMD(FDotTag), ! 144: FUNCTION, "first-non-blank", WIRED_CMD(ToIndent), ! 145: FUNCTION, "forward-character", WIRED_CMD(ForChar), ! 146: FUNCTION, "forward-list", WIRED_CMD(FList), ! 147: FUNCTION, "forward-paragraph", WIRED_CMD(ForPara), ! 148: FUNCTION, "forward-s-expression", WIRED_CMD(FSexpr), ! 149: FUNCTION, "forward-sentence", WIRED_CMD(Eos), ! 150: FUNCTION, "forward-word", WIRED_CMD(ForWord), ! 151: DefMajor(FUNDAMENTAL), "fundamental-mode", WIRED_CMD(0), ! 152: FUNCTION, "gather-numeric-argument", WIRED_CMD(TimesFour), ! 153: #if defined(LISP) ! 154: MODFUNC, "grind-s-expr", WIRED_CMD(GSexpr), ! 155: #endif ! 156: FUNCTION, "goto-line", WIRED_CMD(GoLine), ! 157: FUNCTION, "goto-window-with-buffer", WIRED_CMD(GotoWind), ! 158: FUNCTION, "grow-window", WIRED_CMD(GrowWindow), ! 159: MODFUNC, "handle-tab", WIRED_CMD(Tab), ! 160: FUNCTION, "i-search-forward", WIRED_CMD(IncFSearch), ! 161: FUNCTION, "i-search-reverse", WIRED_CMD(IncRSearch), ! 162: MODFUNC, "insert-file", WIRED_CMD(InsFile), ! 163: #if defined(IPROCS) ! 164: FUNCTION, "interrupt-process", WIRED_CMD(ProcInt), ! 165: FUNCTION, "i-shell-command", WIRED_CMD(Iprocess), ! 166: #endif ! 167: MODFUNC, "kill-next-word", WIRED_CMD(DelNWord), ! 168: MODFUNC, "kill-previous-word", WIRED_CMD(DelPWord), ! 169: #if defined(IPROCS) ! 170: FUNCTION, "kill-process", WIRED_CMD(ProcKill), ! 171: #endif ! 172: MODFUNC, "kill-region", WIRED_CMD(DelReg), ! 173: MODFUNC, "kill-s-expression", WIRED_CMD(KillExpr), ! 174: FUNCTION, "kill-some-buffers", WIRED_CMD(KillSome), ! 175: MODFUNC, "kill-to-beginning-of-sentence", WIRED_CMD(KillBos), ! 176: MODFUNC, "kill-to-end-of-line", WIRED_CMD(KillEOL), ! 177: MODFUNC, "kill-to-end-of-sentence", WIRED_CMD(KillEos), ! 178: FUNCTION, "left-margin-here", WIRED_CMD(SetLMargin), ! 179: #if defined(LISP) ! 180: DefMajor(LISPMODE), "lisp-mode", WIRED_CMD(0), ! 181: #endif ! 182: FUNCTION, "list-buffers", WIRED_CMD(BufList), ! 183: #if defined(IPROCS) ! 184: FUNCTION, "list-processes", WIRED_CMD(ProcList), ! 185: #endif ! 186: FUNCTION, "make-buffer-unmodified", WIRED_CMD(NotModified), ! 187: FUNCTION, "make-keymap", WIRED_CMD(MakeKMap), ! 188: FUNCTION, "make-macro-interactive", WIRED_CMD(MacInter), ! 189: FUNCTION, "name-kbd-macro", WIRED_CMD(NameMac), ! 190: MODFUNC, "newline", WIRED_CMD(Newline), ! 191: MODFUNC, "newline-and-backup", WIRED_CMD(OpenLine), ! 192: MODFUNC, "newline-and-indent", WIRED_CMD(LineAI), ! 193: #if !defined(MAC) ! 194: FUNCTION, "next-error", WIRED_CMD(NextError), ! 195: #endif ! 196: FUNCTION, "next-line", WIRED_CMD(NextLine), ! 197: FUNCTION, "next-page", WIRED_CMD(NextPage), ! 198: FUNCTION, "next-window", WIRED_CMD(NextWindow), ! 199: FUNCTION, "number-lines-in-window", WIRED_CMD(WNumLines), ! 200: DefMinor(OverWrite), "over-write-mode", WIRED_CMD(0), ! 201: FUNCTION, "page-next-window", WIRED_CMD(PageNWind), ! 202: MODFUNC, "paren-flash", WIRED_CMD(DoParen), ! 203: #if !defined(MAC) ! 204: FUNCTION, "parse-errors", WIRED_CMD(ErrParse), ! 205: #endif ! 206: #if defined(SPELL) ! 207: FUNCTION, "parse-spelling-errors-in-buffer", WIRED_CMD(SpelWords), ! 208: #endif ! 209: #if defined(JOB_CONTROL) ! 210: FUNCTION, "pause-jove", WIRED_CMD(PauseJove), ! 211: #else ! 212: # ifndef MAC ! 213: FUNCTION, "pause-jove", WIRED_CMD(Push), ! 214: # endif ! 215: #endif ! 216: FUNCTION, "pop-mark", WIRED_CMD(PopMark), ! 217: FUNCTION, "popd", WIRED_CMD(Popd), ! 218: #if !defined(MAC) ! 219: FUNCTION, "previous-error", WIRED_CMD(PrevError), ! 220: #endif ! 221: FUNCTION, "previous-line", WIRED_CMD(PrevLine), ! 222: FUNCTION, "previous-page", WIRED_CMD(PrevPage), ! 223: FUNCTION, "previous-window", WIRED_CMD(PrevWindow), ! 224: FUNCTION, "print", WIRED_CMD(PrVar), ! 225: #if defined(IPROCS) ! 226: FUNCTION, "process-bind-keymap-to-key", WIRED_CMD(ProcKmBind), ! 227: FUNCTION, "process-bind-to-key", WIRED_CMD(ProcBind), ! 228: MODFUNC, "process-newline", WIRED_CMD(ProcNewline), ! 229: FUNCTION, "process-send-data-no-return", WIRED_CMD(ProcSendData), ! 230: #endif ! 231: #if !defined(MAC) ! 232: FUNCTION, "push-shell", WIRED_CMD(Push), ! 233: #endif ! 234: FUNCTION, "pushd", WIRED_CMD(Pushd), ! 235: FUNCTION, "pwd", WIRED_CMD(prCWD), ! 236: MODFUNC, "query-replace-string", WIRED_CMD(QRepSearch), ! 237: #if defined(IPROCS) ! 238: FUNCTION, "quit-process", WIRED_CMD(ProcQuit), ! 239: #endif ! 240: MODFUNC, "quoted-insert", WIRED_CMD(QuotChar), ! 241: DefMinor(ReadOnly), "read-only-mode", WIRED_CMD(0), ! 242: #if defined(ABBREV) ! 243: FUNCTION, "read-word-abbrev-file", WIRED_CMD(RestAbbrevs), ! 244: #endif ! 245: FUNCTION, "redraw-display", WIRED_CMD(RedrawDisplay), ! 246: FUNCTION, "recursive-edit", WIRED_CMD(Recur), ! 247: FUNCTION, "rename-buffer", WIRED_CMD(ReNamBuf), ! 248: MODFUNC, "replace-in-region", WIRED_CMD(RegReplace), ! 249: MODFUNC, "replace-string", WIRED_CMD(RepSearch), ! 250: FUNCTION, "right-margin-here", WIRED_CMD(SetRMargin), ! 251: FUNCTION, "save-file", WIRED_CMD(SaveFile), ! 252: FUNCTION, "scroll-down", WIRED_CMD(DownScroll), ! 253: FUNCTION, "scroll-left", WIRED_CMD(ScrollLeft), ! 254: #if defined(MSDOS) ! 255: FUNCTION, "scroll-next-page", WIRED_CMD(PageScrollUp), ! 256: FUNCTION, "scroll-previous-page", WIRED_CMD(PageScrollDown), ! 257: #endif /* MSDOS */ ! 258: FUNCTION, "scroll-right", WIRED_CMD(ScrollRight), ! 259: FUNCTION, "scroll-up", WIRED_CMD(UpScroll), ! 260: FUNCTION, "search-forward", WIRED_CMD(ForSearch), ! 261: FUNCTION, "search-forward-nd", WIRED_CMD(FSrchND), ! 262: FUNCTION, "search-reverse", WIRED_CMD(RevSearch), ! 263: FUNCTION, "search-reverse-nd", WIRED_CMD(RSrchND), ! 264: FUNCTION, "select-buffer", WIRED_CMD(BufSelect), ! 265: #if defined(MSDOS) ! 266: FUNCTION, "select-buffer-1", WIRED_CMD(Buf1Select), ! 267: FUNCTION, "select-buffer-2", WIRED_CMD(Buf2Select), ! 268: FUNCTION, "select-buffer-3", WIRED_CMD(Buf3Select), ! 269: FUNCTION, "select-buffer-4", WIRED_CMD(Buf4Select), ! 270: FUNCTION, "select-buffer-5", WIRED_CMD(Buf5Select), ! 271: FUNCTION, "select-buffer-6", WIRED_CMD(Buf6Select), ! 272: FUNCTION, "select-buffer-7", WIRED_CMD(Buf7Select), ! 273: FUNCTION, "select-buffer-8", WIRED_CMD(Buf8Select), ! 274: FUNCTION, "select-buffer-9", WIRED_CMD(Buf9Select), ! 275: FUNCTION, "select-buffer-10", WIRED_CMD(Buf10Select), ! 276: #endif /* MSDOS */ ! 277: MODFUNC, "self-insert", WIRED_CMD(SelfInsert), ! 278: FUNCTION, "set", WIRED_CMD(SetVar), ! 279: FUNCTION, "set-mark", WIRED_CMD(SetMark), ! 280: #if defined(IPROCS) /* for GNU compatibility */ ! 281: FUNCTION, "shell", WIRED_CMD(ShellProc), ! 282: #endif ! 283: #if !defined(MAC) ! 284: FUNCTION, "shell-command", WIRED_CMD(ShellCom), ! 285: FUNCTION, "shell-command-no-buffer", WIRED_CMD(ShNoBuf), ! 286: FUNCTION, "shell-command-to-buffer", WIRED_CMD(ShToBuf), ! 287: FUNCTION, "shell-command-with-typeout", WIRED_CMD(Shtypeout), ! 288: #endif ! 289: MODFUNC, "shift-region-left", WIRED_CMD(LRShift), ! 290: MODFUNC, "shift-region-right", WIRED_CMD(RRShift), ! 291: DefMinor(ShowMatch), "show-match-mode", WIRED_CMD(0), ! 292: FUNCTION, "shrink-window", WIRED_CMD(ShrWindow), ! 293: FUNCTION, "source", WIRED_CMD(Source), ! 294: #if defined(SPELL) ! 295: FUNCTION, "spell-buffer", WIRED_CMD(SpelBuffer), ! 296: #endif ! 297: FUNCTION, "split-current-window", WIRED_CMD(SplitWind), ! 298: FUNCTION, "start-remembering", WIRED_CMD(Remember), ! 299: #if defined(IPROCS) && !defined(PIPEPROCS) ! 300: FUNCTION, "stop-process", WIRED_CMD(ProcStop), ! 301: #endif ! 302: FUNCTION, "stop-remembering", WIRED_CMD(Forget), ! 303: FUNCTION, "string-length", WIRED_CMD(StrLength), ! 304: #if defined(JOB_CONTROL) ! 305: FUNCTION, "suspend-jove", WIRED_CMD(PauseJove), ! 306: #endif ! 307: DefMajor(TEXT), "text-mode", WIRED_CMD(0), ! 308: MODFUNC, "transpose-characters", WIRED_CMD(TransChar), ! 309: MODFUNC, "transpose-lines", WIRED_CMD(TransLines), ! 310: FUNCTION, "unbind-key", WIRED_CMD(UnbindC), ! 311: FUNCTION, "version", WIRED_CMD(ShowVersion), ! 312: FUNCTION, "visible-spaces-in-window", WIRED_CMD(WVisSpace), ! 313: FUNCTION, "visit-file", WIRED_CMD(ReadFile), ! 314: FUNCTION, "window-find", WIRED_CMD(WindFind), ! 315: #if defined(ABBREV) ! 316: DefMinor(Abbrev), "word-abbrev-mode", WIRED_CMD(0), ! 317: FUNCTION, "write-word-abbrev-file", WIRED_CMD(SaveAbbrevs), ! 318: #endif ! 319: FUNCTION, "write-file", WIRED_CMD(WriteFile), ! 320: FUNCTION, "write-macros-to-file", WIRED_CMD(WriteMacs), ! 321: FUNCTION, "write-modified-files", WIRED_CMD(WtModBuf), ! 322: FUNCTION, "write-region", WIRED_CMD(WrtReg), ! 323: MODFUNC, "yank", WIRED_CMD(Yank), ! 324: MODFUNC, "yank-pop", WIRED_CMD(YankPop), ! 325: FUNCTION, 0, 0 ! 326: }; ! 327: ! 328: #if !defined(TXT_TO_C) ! 329: data_obj * ! 330: findcom(prompt) ! 331: char *prompt; ! 332: { ! 333: /* This is for faster startup. This just reads until a space or a ! 334: tab or a newline character is reached, and then does a ! 335: semi-hashed lookup on that string. This should be much faster ! 336: than initializing the minibuffer for each line. */ ! 337: if (InJoverc) { ! 338: char cmdbuf[128]; ! 339: register const struct cmd *cmd; ! 340: register char *cp = cmdbuf; ! 341: #if !(defined(IBMPC) || defined(MAC)) ! 342: register int c; ! 343: #else ! 344: int c; ! 345: #endif ! 346: const struct cmd *which; ! 347: size_t cmdlen; ! 348: int found = 0; ! 349: static const struct cmd *cmdhash[26]; ! 350: static int beenhere = NO; ! 351: ! 352: /* special case for prefix commands--only upper case ones */ ! 353: #define hash(c) ((c) - 'a') ! 354: ! 355: /* initialize the hash table */ ! 356: if (beenhere == NO) { ! 357: int lastc = 0; ! 358: ! 359: for (cmd = commands; cmd->Name != 0; cmd++) ! 360: if (lastc != cmd->Name[0]) { ! 361: lastc = cmd->Name[0]; ! 362: cmdhash[hash(lastc)] = cmd; ! 363: } ! 364: beenhere = YES; ! 365: } ! 366: #ifdef MAC ! 367: menus_off(); /* Block menu choices during input */ ! 368: #endif ! 369: /* gather the cmd name */ ! 370: while (((c = getch()) != EOF) && !strchr(" \t\r\n", c)) { ! 371: #if (defined(IBMPC) || defined(MAC)) ! 372: lower((char *) &c); ! 373: #else ! 374: if (isupper(c)) ! 375: c = tolower(c); ! 376: #endif ! 377: *cp++ = c; ! 378: } ! 379: if (c == EOF) ! 380: return 0; ! 381: *cp = '\0'; ! 382: cmdlen = cp - cmdbuf; ! 383: if (cmdlen == 0) ! 384: return 0; ! 385: ! 386: /* look it up (in the reduced search space) */ ! 387: if (islower(cmdbuf[0])) ! 388: for (cmd = cmdhash[hash(cmdbuf[0])]; cmd != 0 && cmd->Name[0] == cmdbuf[0]; cmd++) { ! 389: if (strncmp(cmd->Name, cmdbuf, cmdlen) == 0) { ! 390: if (strcmp(cmd->Name, cmdbuf) == 0) ! 391: return (data_obj *) cmd; ! 392: found += 1; ! 393: which = cmd; ! 394: } ! 395: } ! 396: if (found > 1) { ! 397: complain("[\"%s\" ambiguous]", cmdbuf); ! 398: /* NOTREACHED */ ! 399: } else if (found == 0) { ! 400: complain("[\"%s\" unknown]", cmdbuf); ! 401: /* NOTREACHED */ ! 402: }else ! 403: return (data_obj *) which; ! 404: } else { ! 405: static char *strings[(sizeof commands) / sizeof (commands[0])]; ! 406: static int beenhere = NO; ! 407: register int com; ! 408: ! 409: if (beenhere == NO) { ! 410: register char **strs = strings; ! 411: register const struct cmd *c; ! 412: ! 413: for (c = commands; c->Name != 0; c++) ! 414: *strs++ = c->Name; ! 415: *strs = 0; ! 416: beenhere = YES; ! 417: } ! 418: ! 419: if ((com = complete(strings, prompt, CASEIND)) < 0) ! 420: return 0; ! 421: return (data_obj *) &commands[com]; ! 422: } ! 423: #undef hash ! 424: } ! 425: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.