home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / Editors / mjovesrc.zoo / funcdefs.c < prev    next >
C/C++ Source or Header  |  1992-04-04  |  15KB  |  427 lines

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