home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2327 < prev    next >
Internet Message Format  |  1990-12-28  |  83KB

  1. From: pfalstad@phoenix.Princeton.EDU (Paul John Falstad)
  2. Newsgroups: alt.sources
  3. Subject: zsh - ksh/tcsh-like shell (part 8 of 8)
  4. Message-ID: <4750@idunno.Princeton.EDU>
  5. Date: 14 Dec 90 23:34:18 GMT
  6.  
  7. ---cut here---cut here---cut here---
  8. -/* The last key bindings file read. */
  9. -static char *last_readline_init_file = "~/.inputrc";
  10. -
  11. -/* Re-read the current keybindings file. */
  12. -rl_re_read_init_file (count, ignore)
  13. -int count, ignore;
  14. -{
  15. -    rl_read_init_file (last_readline_init_file);
  16. -}
  17. -
  18. -/* Do key bindings from a file.  If FILENAME is NULL it defaults
  19. -   to `~/.inputrc'.  If the file existed and could be opened and
  20. -   read, 0 is returned, otherwise errno is returned. */
  21. -int
  22. -rl_read_init_file (filename)
  23. -char *filename;
  24. -{
  25. -    extern int errno;
  26. -    int line_size, line_index;
  27. -    char *line = (char *)xmalloc (line_size = 100);
  28. -    char *openname;
  29. -    FILE *file;
  30. -
  31. -    int c;
  32. -
  33. -    /* Default the filename. */
  34. -    if (!filename)
  35. -        filename = "~/.inputrc";
  36. -
  37. -    openname = tilde_expand (filename);
  38. -
  39. -    /* Open the file. */
  40. -    file = fopen (openname, "r");
  41. -    free (openname);
  42. -
  43. -    if (!file)
  44. -        return (errno);
  45. -
  46. -    last_readline_init_file = filename;
  47. -
  48. -    /* Loop reading lines from the file.  Lines that start with `#' are
  49. -     comments, all other lines are commands for readline initialization. */
  50. -    while ((c = rl_getc (file)) != EOF)
  51. -    {
  52. -        /* If comment, flush to EOL. */
  53. -        if (c == '#')
  54. -        {
  55. -            while ((c = rl_getc (file)) != EOF && c != '\n');
  56. -            if (c == EOF)
  57. -                goto function_exit;
  58. -            continue;
  59. -        }
  60. -
  61. -        /* Otherwise, this is the start of a line.  Read the
  62. -     line from the file. */
  63. -        line_index = 0;
  64. -        while (c != EOF && c != '\n')
  65. -        {
  66. -            line[line_index++] = c;
  67. -            if (line_index == line_size)
  68. -                line = (char *)xrealloc (line, line_size += 100);
  69. -            c = rl_getc (file);
  70. -        }
  71. -        line[line_index] = '\0';
  72. -
  73. -        /* Parse the line. */
  74. -        rl_parse_and_bind (line);
  75. -    }
  76. -
  77. -function_exit:
  78. -
  79. -    free (line);
  80. -    /* Close up the file and exit. */
  81. -    fclose (file);
  82. -    return (0);
  83. -}
  84. -
  85. -
  86. -/* **************************************************************** */
  87. -/*                                    */
  88. -/*            Parser Directives                   */
  89. -/*                                    */
  90. -/* **************************************************************** */
  91. -
  92. -/* Conditionals. */
  93. -
  94. -/* Calling programs set this to have their argv[0]. */
  95. -char *rl_readline_name = "other";
  96. -
  97. -/* Stack of previous values of parsing_conditionalized_out. */
  98. -static unsigned char *if_stack = (unsigned char *)NULL;
  99. -static int if_stack_depth = 0;
  100. -static int if_stack_size = 0;
  101. -
  102. -/* Push parsing_conditionalized_out, and set parser state based on ARGS. */
  103. -parser_if (args)
  104. -char *args;
  105. -{
  106. -    register int i;
  107. -
  108. -    /* Push parser state. */
  109. -    if (if_stack_depth + 1 >= if_stack_size)
  110. -    {
  111. -        if (!if_stack)
  112. -            if_stack = (unsigned char *)xmalloc (if_stack_size = 20);
  113. -        else
  114. -            if_stack = (unsigned char *)xrealloc (if_stack, if_stack_size += 20);
  115. -    }
  116. -    if_stack[if_stack_depth++] = parsing_conditionalized_out;
  117. -
  118. -    /* We only check to see if the first word in ARGS is the same as the
  119. -     value stored in rl_readline_name. */
  120. -
  121. -    /* Isolate first argument. */
  122. -    for (i = 0; args[i] && !whitespace (args[i]); i++);
  123. -
  124. -    if (args[i])
  125. -        args[i++] = '\0';
  126. -
  127. -    if (stricmp (args, rl_readline_name) == 0)
  128. -        parsing_conditionalized_out = 0;
  129. -    else
  130. -        parsing_conditionalized_out = 1;
  131. -}
  132. -
  133. -/* Invert the current parser state if there is anything on the stack. */
  134. -parser_else (args)
  135. -char *args;
  136. -{
  137. -    if (if_stack_depth)
  138. -        parsing_conditionalized_out = !parsing_conditionalized_out;
  139. -    else
  140. -    {
  141. -        /* *** What, no error message? *** */
  142. -    }
  143. -}
  144. -
  145. -/* Terminate a conditional, popping the value of
  146. -   parsing_conditionalized_out from the stack. */
  147. -parser_endif (args)
  148. -char *args;
  149. -{
  150. -    if (if_stack_depth)
  151. -        parsing_conditionalized_out = if_stack[--if_stack_depth];
  152. -    else
  153. -    {
  154. -        /* *** What, no error message? *** */
  155. -    }
  156. -}
  157. -
  158. -/* Associate textual names with actual functions. */
  159. -static struct {
  160. -    char *name;
  161. -    Function *function;
  162. -} parser_directives [] = {
  163. -    { "if", parser_if },
  164. -    { "endif", parser_endif },
  165. -    { "else", parser_else },
  166. -    { (char *)0x0, (Function *)0x0 }
  167. -};
  168. -
  169. -
  170. -/* Handle a parser directive.  STATEMENT is the line of the directive
  171. -   without any leading `$'. */
  172. -static int
  173. -handle_parser_directive (statement)
  174. -char *statement;
  175. -{
  176. -    register int i;
  177. -    char *directive, *args;
  178. -
  179. -    /* Isolate the actual directive. */
  180. -
  181. -    /* Skip whitespace. */
  182. -    for (i = 0; whitespace (statement[i]); i++);
  183. -
  184. -    directive = &statement[i];
  185. -
  186. -    for (; statement[i] && !whitespace (statement[i]); i++);
  187. -
  188. -    if (statement[i])
  189. -        statement[i++] = '\0';
  190. -
  191. -    for (; statement[i] && whitespace (statement[i]); i++);
  192. -
  193. -    args = &statement[i];
  194. -
  195. -    /* Lookup the command, and act on it. */
  196. -    for (i = 0; parser_directives[i].name; i++)
  197. -        if (stricmp (directive, parser_directives[i].name) == 0)
  198. -        {
  199. -            (*parser_directives[i].function) (args);
  200. -            return (0);
  201. -        }
  202. -
  203. -    /* *** Should an error message be output? */
  204. -    return (1);
  205. -}
  206. -
  207. -/* Read the binding command from STRING and perform it.
  208. -   A key binding command looks like: Keyname: function-name\0,
  209. -   a variable binding command looks like: set variable value.
  210. -   A new-style keybinding looks like "\C-x\C-x": exchange-point-and-mark. */
  211. -rl_parse_and_bind (string)
  212. -char *string;
  213. -{
  214. -    extern char *possible_control_prefixes[], *possible_meta_prefixes[];
  215. -    char *rindex (), *funname, *kname;
  216. -    static int substring_member_of_array ();
  217. -    register int c;
  218. -    int key, i;
  219. -
  220. -    if (!string || !*string || *string == '#')
  221. -        return;
  222. -
  223. -    /* If this is a parser directive, act on it. */
  224. -    if (*string == '$')
  225. -    {
  226. -        handle_parser_directive (&string[1]);
  227. -        return;
  228. -    }
  229. -
  230. -    /* If we are supposed to be skipping parsing right now, then do it. */
  231. -    if (parsing_conditionalized_out)
  232. -        return;
  233. -
  234. -    i = 0;
  235. -    /* If this keyname is a complex key expression surrounded by quotes,
  236. -     advance to after the matching close quote. */
  237. -    if (*string == '"')
  238. -    {
  239. -        for (i = 1; c = string[i]; i++)
  240. -        {
  241. -            if (c == '"' && string[i - 1] != '\\')
  242. -                break;
  243. -        }
  244. -    }
  245. -
  246. -    /* Advance to the colon (:) or whitespace which separates the two objects. */
  247. -    for (; (c = string[i]) && c != ':' && c != ' ' && c != '\t'; i++ );
  248. -
  249. -    /* Mark the end of the command (or keyname). */
  250. -    if (string[i])
  251. -        string[i++] = '\0';
  252. -
  253. -    /* If this is a command to set a variable, then do that. */
  254. -    if (stricmp (string, "set") == 0)
  255. -    {
  256. -        char *var = string + i;
  257. -        char *value;
  258. -
  259. -        /* Make VAR point to start of variable name. */
  260. -        while (*var && whitespace (*var)) var++;
  261. -
  262. -        /* Make value point to start of value string. */
  263. -        value = var;
  264. -        while (*value && !whitespace (*value)) value++;
  265. -        if (*value)
  266. -            *value++ = '\0';
  267. -        while (*value && whitespace (*value)) value++;
  268. -
  269. -        rl_variable_bind (var, value);
  270. -        return;
  271. -    }
  272. -
  273. -    /* Skip any whitespace between keyname and funname. */
  274. -    for (; string[i] && whitespace (string[i]); i++);
  275. -    funname = &string[i];
  276. -
  277. -    /* Now isolate funname.
  278. -     For straight function names just look for whitespace, since
  279. -     that will signify the end of the string.  But this could be a
  280. -     macro definition.  In that case, the string is quoted, so skip
  281. -     to the matching delimiter. */
  282. -    if (*funname == '\'' || *funname == '"')
  283. -    {
  284. -        int delimiter = string[i++];
  285. -
  286. -        for (; c = string[i]; i++)
  287. -        {
  288. -            if (c == delimiter && string[i - 1] != '\\')
  289. -                break;
  290. -        }
  291. -        if (c)
  292. -            i++;
  293. -    }
  294. -
  295. -    /* Advance to the end of the string.  */
  296. -    for (; string[i] && !whitespace (string[i]); i++);
  297. -
  298. -    /* No extra whitespace at the end of the string. */
  299. -    string[i] = '\0';
  300. -
  301. -    /* If this is a new-style key-binding, then do the binding with
  302. -     rl_set_key ().  Otherwise, let the older code deal with it. */
  303. -    if (*string == '"')
  304. -    {
  305. -        char *seq = (char *)alloca (1 + strlen (string));
  306. -        register int j, k = 0;
  307. -
  308. -        for (j = 1; string[j]; j++)
  309. -        {
  310. -            if (string[j] == '"' && string[j - 1] != '\\')
  311. -                break;
  312. -
  313. -            seq[k++] = string[j];
  314. -        }
  315. -        seq[k] = '\0';
  316. -
  317. -        /* Binding macro? */
  318. -        if (*funname == '\'' || *funname == '"')
  319. -        {
  320. -            j = strlen (funname);
  321. -
  322. -            if (j && funname[j - 1] == *funname)
  323. -                funname[j - 1] = '\0';
  324. -
  325. -            rl_macro_bind (seq, &funname[1], keymap);
  326. -        }
  327. -        else
  328. -            rl_set_key (seq, rl_named_function (funname), keymap);
  329. -
  330. -        return;
  331. -    }
  332. -
  333. -    /* Get the actual character we want to deal with. */
  334. -    kname = rindex (string, '-');
  335. -    if (!kname)
  336. -        kname = string;
  337. -    else
  338. -        kname++;
  339. -
  340. -    key = glean_key_from_name (kname);
  341. -
  342. -    /* Add in control and meta bits. */
  343. -    if (substring_member_of_array (string, possible_control_prefixes))
  344. -        key = CTRL (to_upper (key));
  345. -
  346. -    if (substring_member_of_array (string, possible_meta_prefixes))
  347. -        key = META (key);
  348. -
  349. -    /* Temporary.  Handle old-style keyname with macro-binding. */
  350. -    if (*funname == '\'' || *funname == '"')
  351. -    {
  352. -        char seq[2];
  353. -        int fl = strlen (funname);
  354. -
  355. -        seq[0] = key; 
  356. -        seq[1] = '\0';
  357. -        if (fl && funname[fl - 1] == *funname)
  358. -            funname[fl - 1] = '\0';
  359. -
  360. -        rl_macro_bind (seq, &funname[1], keymap);
  361. -    }
  362. -    else
  363. -        rl_bind_key (key, rl_named_function (funname));
  364. -}
  365. -
  366. -rl_variable_bind (name, value)
  367. -char *name, *value;
  368. -{
  369. -    if (stricmp (name, "editing-mode") == 0)
  370. -    {
  371. -        if (strnicmp (value, "vi", 2) == 0)
  372. -        {
  373. -#ifdef VI_MODE
  374. -            keymap = vi_insertion_keymap;
  375. -            rl_editing_mode = vi_mode;
  376. -#endif /* VI_MODE */
  377. -        }
  378. -        else if (strnicmp (value, "emacs", 5) == 0)
  379. -        {
  380. -            keymap = emacs_standard_keymap;
  381. -            rl_editing_mode = emacs_mode;
  382. -        }
  383. -    }
  384. -    else if (stricmp (name, "horizontal-scroll-mode") == 0)
  385. -    {
  386. -        if (!*value || stricmp (value, "On") == 0)
  387. -            horizontal_scroll_mode = 1;
  388. -        else
  389. -            horizontal_scroll_mode = 0;
  390. -    }
  391. -}
  392. -
  393. -/* Return the character which matches NAME.
  394. -   For example, `Space' returns ' '. */
  395. -
  396. -typedef struct {
  397. -    char *name;
  398. -    int value;
  399. -} assoc_list;
  400. -
  401. -assoc_list name_key_alist[] = {
  402. -    { "Space", ' ' },
  403. -    { "SPC", ' ' },
  404. -    { "Rubout", 0x7f },
  405. -    { "DEL", 0x7f },
  406. -    { "Tab", 0x09 },
  407. -    { "Newline", '\n' },
  408. -    { "Return", '\r' },
  409. -    { "RET", '\r' },
  410. -    { "LFD", '\n' },
  411. -    { "Escape", '\033' },
  412. -    { "ESC", '\033' },
  413. -    { (char *)0x0, 0 }
  414. -};
  415. -
  416. -
  417. -int
  418. -glean_key_from_name (name)
  419. -char *name;
  420. -{
  421. -    register int i;
  422. -
  423. -    for (i = 0; name_key_alist[i].name; i++)
  424. -        if (stricmp (name, name_key_alist[i].name) == 0)
  425. -            return (name_key_alist[i].value);
  426. -
  427. -    return (*name);
  428. -}
  429. -
  430. -
  431. -/* **************************************************************** */
  432. -/*                                    */
  433. -/*            String Utility Functions            */
  434. -/*                                    */
  435. -/* **************************************************************** */
  436. -
  437. -/* Return non-zero if any members of ARRAY are a substring in STRING. */
  438. -static int
  439. -substring_member_of_array (string, array)
  440. -char *string, **array;
  441. -{
  442. -    static char *strindex ();
  443. -
  444. -    while (*array)
  445. -    {
  446. -        if (strindex (string, *array))
  447. -            return (1);
  448. -        array++;
  449. -    }
  450. -    return (0);
  451. -}
  452. -
  453. -/* Whoops, Unix doesn't have strnicmp. */
  454. -
  455. -/* Compare at most COUNT characters from string1 to string2.  Case
  456. -   doesn't matter. */
  457. -static int
  458. -strnicmp (string1, string2, count)
  459. -char *string1, *string2;
  460. -{
  461. -    register char ch1, ch2;
  462. -
  463. -    while (count)
  464. -    {
  465. -        ch1 = *string1++;
  466. -        ch2 = *string2++;
  467. -        if (to_upper(ch1) == to_upper(ch2))
  468. -            count--;
  469. -        else break;
  470. -    }
  471. -    return (count);
  472. -}
  473. -
  474. -/* strcmp (), but caseless. */
  475. -static int
  476. -stricmp (string1, string2)
  477. -char *string1, *string2;
  478. -{
  479. -    register char ch1, ch2;
  480. -
  481. -    while (*string1 && *string2)
  482. -    {
  483. -        ch1 = *string1++;
  484. -        ch2 = *string2++;
  485. -        if (to_upper(ch1) != to_upper(ch2))
  486. -            return (1);
  487. -    }
  488. -    return (*string1 | *string2);
  489. -}
  490. -
  491. -/* Determine if s2 occurs in s1.  If so, return a pointer to the
  492. -   match in s1.  The compare is case insensitive. */
  493. -static char *
  494. -strindex (s1, s2)
  495. -register char *s1, *s2;
  496. -{
  497. -    register int i, l = strlen (s2);
  498. -    register int len = strlen (s1);
  499. -
  500. -    for (i = 0; (len - i) >= l; i++)
  501. -        if (strnicmp (&s1[i], s2, l) == 0)
  502. -            return (s1 + i);
  503. -    return ((char *)NULL);
  504. -}
  505. -
  506. -
  507. -/* **************************************************************** */
  508. -/*                                    */
  509. -/*            SYSV Support                    */
  510. -/*                                    */
  511. -/* **************************************************************** */
  512. -
  513. -/* Since system V reads input differently than we do, I have to
  514. -   make a special version of getc for that. */
  515. -
  516. -#include <sys/errno.h>
  517. -
  518. -int
  519. -rl_getc (stream)
  520. -FILE *stream;
  521. -{
  522. -    int result;
  523. -    unsigned char c;
  524. -    
  525. -    rl_waiting = 1;
  526. -    result = read (fileno (stream), &c, sizeof (char));
  527. -    rl_waiting = 0;
  528. -    if (result == sizeof (char))
  529. -        return (c);
  530. -
  531. -    if (errno != EINTR)
  532. -        return EOF;
  533. -    rl_done = rl_end = errflag = 1;
  534. -    return EOF;
  535. -}
  536. -
  537. -#ifdef STATIC_MALLOC
  538. -
  539. -/* **************************************************************** */
  540. -/*                                    */
  541. -/*            xmalloc and xrealloc ()                     */
  542. -/*                                    */
  543. -/* **************************************************************** */
  544. -
  545. -static void memory_error_and_abort ();
  546. -
  547. -static char *
  548. -xmalloc (bytes)
  549. -int bytes;
  550. -{
  551. -    char *temp = (char *)malloc (bytes);
  552. -
  553. -    if (!temp)
  554. -        memory_error_and_abort ();
  555. -    return (temp);
  556. -}
  557. -
  558. -static char *
  559. -xrealloc (pointer, bytes)
  560. -char *pointer;
  561. -int bytes;
  562. -{
  563. -    char *temp = (char *)realloc (pointer, bytes);
  564. -
  565. -    if (!temp)
  566. -        memory_error_and_abort ();
  567. -    return (temp);
  568. -}
  569. -
  570. -static void
  571. -memory_error_and_abort ()
  572. -{
  573. -    fprintf (stderr, "readline: Out of virtual memory!\n");
  574. -    abort ();
  575. -}
  576. -#endif /* STATIC_MALLOC */
  577. -/*
  578. - * Local variables:
  579. - * compile-command: "gcc -g -traditional -I. -I.. -DTEST -o readline readline.c keymaps.o funmap.o history.o -ltermcap"
  580. - * end:
  581. - */
  582. -
  583. -rl_function_key(count)  /* pjf */
  584. -{
  585. -    switch(rl_getc(rl_instream))
  586. -    {
  587. -    case 'A':
  588. -        rl_get_previous_history(count);
  589. -        break;
  590. -    case 'B':
  591. -        rl_get_next_history(count);
  592. -        break;
  593. -    case 'C':
  594. -        rl_forward(count);
  595. -        break;
  596. -    case 'D':
  597. -        rl_backward(count);
  598. -        break;
  599. -    default:
  600. -        ding();
  601. -        break;
  602. -    }
  603. -}
  604. -
  605. -static char *spname();
  606. -
  607. -rl_check_spelling()
  608. -{
  609. -    char *match;
  610. -    int start, end, delimiter = 0;
  611. -    char *text;
  612. -
  613. -    /* We now look backwards for the start of a filename/variable word. */
  614. -    end = rl_point;
  615. -    if (rl_point)
  616. -    {
  617. -        while (--rl_point &&
  618. -            !rindex (rl_completer_word_break_characters, the_line[rl_point]));
  619. -
  620. -        /* If we are at a word break, then advance past it. */
  621. -        if (rindex (rl_completer_word_break_characters,  (the_line[rl_point])))
  622. -        {
  623. -            /* If the character that caused the word break was a quoting
  624. -         character, then remember it as the delimiter. */
  625. -            if (rindex ("\"'", the_line[rl_point]) && (end - rl_point) > 1)
  626. -                delimiter = the_line[rl_point];
  627. -
  628. -            /* If the character isn't needed to determine something special
  629. -         about what kind of completion to perform, then advance past it. */
  630. -
  631. -            if (!rl_special_prefixes ||
  632. -                !rindex (rl_special_prefixes, the_line[rl_point]))
  633. -                rl_point++;
  634. -        }
  635. -    }
  636. -
  637. -    start = rl_point;
  638. -    rl_point = end;
  639. -    text = rl_copy (start, end);
  640. -
  641. -    match = spname(text);
  642. -
  643. -    free (text);
  644. -
  645. -    if (!match)
  646. -        ding ();
  647. -    else
  648. -    {
  649. -        rl_delete_text (start, rl_point);
  650. -        rl_point = start;
  651. -        rl_insert_text (match);
  652. -    }
  653. -}
  654. -
  655. -/* next 3 functions stolen from Kernighan & Pike */
  656. -/* "The UNIX Programming Environment" (w/o permission) */
  657. -
  658. -static char *spname (oldname) char *oldname;
  659. -{
  660. -    char *p,guess[MAXPATHLEN+1],best[MAXPATHLEN+1];
  661. -    char newname[MAXPATHLEN+1];
  662. -    char *new = newname, *old = oldname;
  663. -
  664. -    for (;;)
  665. -    {
  666. -        while (*old == '/')
  667. -            *new++ = *old++;
  668. -        *new = '\0';
  669. -        if (*old == '\0')
  670. -            return newname;
  671. -        p = guess;
  672. -        for (; *old != '/' && *old != '\0'; old++)
  673. -            if (p < guess+MAXPATHLEN)
  674. -                *p++ = *old;
  675. -        *p = '\0';
  676. -        if (mindist(newname,guess,best) >= 3)
  677. -            return oldname;
  678. -        for (p = best; *new = *p++; )
  679. -            new++;
  680. -    }
  681. -}
  682. -
  683. -mindist(dir,guess,best) char *dir,*guess,*best;
  684. -{
  685. -    int d,nd;
  686. -    DIR *dd;
  687. -    struct direct *de;
  688. -
  689. -    if (dir[0] == '\0')
  690. -        dir = ".";
  691. -    d = 3;
  692. -    if (!(dd = opendir(dir)))
  693. -        return d;
  694. -    while (de = readdir(dd))
  695. -    {
  696. -        nd = spdist(de->d_name,guess);
  697. -        if (nd <= d && nd != 3) {
  698. -            strcpy(best,de->d_name);
  699. -            d = nd;
  700. -            if (d == 0)
  701. -                break;
  702. -        }
  703. -    }
  704. -    closedir(dd);
  705. -    return d;
  706. -}
  707. -
  708. -#define EQ(s,t) (strcmp(s,t) == 0)
  709. -
  710. -spdist(s,t) char *s, *t;
  711. -{
  712. -    while (*s++ == *t)
  713. -        if (*t++ == '\0')
  714. -            return 0;
  715. -    if (*--s)
  716. -    {
  717. -        if (*t)
  718. -        {
  719. -            if (s[1] && t[1] && *s == t[1] && *t == s[1] &&
  720. -                EQ(s+2,t+2))
  721. -                return 1;
  722. -            if (EQ(s+1,t+1))
  723. -                return 2;
  724. -        }
  725. -        if (EQ(s+1,t))
  726. -            return 2;
  727. -    }
  728. -    if (*t && EQ(s,t+1))
  729. -        return 2;
  730. -    return 3;
  731. -}
  732. -
  733. -char *strpbrk(s,t) char *s,*t;
  734. -{
  735. -    char *u = t;
  736. -
  737. -    while (*s)
  738. -    {
  739. -        for (t = u; *t; t++)
  740. -            if (*s == *t)
  741. -                return s;
  742. -        s++;
  743. -    }
  744. -    return NULL;
  745. -}
  746. -
  747. -void rl_safe_insert_text(s) char *s;
  748. -{
  749. -    char *bad = " \\!#$^*()|=[]{}`\'\";?><";
  750. -    char *t;
  751. -
  752. -    for(;;)
  753. -        if (t = strpbrk(s,bad))
  754. -        {
  755. -            char a = *t;
  756. -
  757. -            *t = '\0';
  758. -            rl_insert_text(s);
  759. -            rl_insert_text("\\");
  760. -            *t = a;
  761. -            a = t[1];
  762. -            t[1] = '\0';
  763. -            rl_insert_text(t);
  764. -            t[1] = a;
  765. -            s = t+1;
  766. -        }
  767. -        else
  768. -        {
  769. -            rl_insert_text(s);
  770. -            return;
  771. -        }
  772. -}
  773. -
  774. -#define HERR -125
  775. -
  776. -extern int magic;
  777. -char *strdup();
  778. -int hgetc();
  779. -
  780. -rl_magic_space ()
  781. -{
  782. -    int c,pt = 0;
  783. -    char *str;
  784. -
  785. -    the_line[rl_end] = '\0'; /* necessary? */
  786. -    str = strdup(the_line);
  787. -    strinbeg();
  788. -    magic = 1;
  789. -    hungets(strdup("\n"));
  790. -    hungets(strdup(the_line));
  791. -    while ((c = hgetc()) != EOF)
  792. -    {
  793. -        if (c == HERR)
  794. -        {
  795. -            strcpy(the_line,str);
  796. -            free(str);
  797. -            hflush();
  798. -            magic = 0;
  799. -            strinend();
  800. -            rl_on_new_line();
  801. -            rl_redisplay();
  802. -            return 0;
  803. -        }
  804. -        if (c == '!')
  805. -            the_line[pt++] = '\\';
  806. -        the_line[pt++] = c;
  807. -    }
  808. -    if (!pt)
  809. -        fprintf(stderr,"Whoops.\n");
  810. -    the_line[rl_end = rl_point = pt-1] = '\0';
  811. -    magic = 0;
  812. -    strinend();
  813. -    free(str);
  814. -}
  815. End of readline/readline.c
  816. echo readline/readline.h 1>&2
  817. sed 's/^-//' >readline/readline.h <<'End of readline/readline.h'
  818. -/* Readline.h -- the names of functions callable from within readline. */
  819. -
  820. -#ifndef _READLINE_H_
  821. -#define _READLINE_H_
  822. -
  823. -#include <readline/keymaps.h>
  824. -
  825. -#ifndef __FUNCTION_DEF
  826. -typedef int Function ();
  827. -#define __FUNCTION_DEF
  828. -#endif
  829. -
  830. -/* The functions for manipulating the text of the line within readline.
  831. -Most of these functions are bound to keys by default. */
  832. -extern int
  833. -rl_beg_of_line (), rl_backward (), rl_delete (), rl_end_of_line (),
  834. -rl_forward (), ding (), rl_backward (), rl_newline (), rl_kill_line (),
  835. -rl_clear_screen (), rl_get_next_history (), rl_get_previous_history (),
  836. -rl_quoted_insert (), rl_transpose_chars
  837. -(), rl_unix_line_discard (), rl_quoted_insert (), rl_unix_word_rubout
  838. -(), rl_yank (), rl_rubout (), rl_backward_word (), rl_kill_word (),
  839. -rl_forward_word (), rl_tab_insert (), rl_yank_pop (), rl_yank_nth_arg (),
  840. -rl_backward_kill_word (), rl_backward_kill_line (), rl_transpose_words
  841. -(), rl_complete (), rl_possible_completions (), rl_do_lowercase_version
  842. -(), rl_digit_argument (), rl_universal_argument (), rl_abort (),
  843. -rl_undo_command (), rl_revert_line (), rl_beginning_of_history (),
  844. -rl_end_of_history (), rl_insert (),
  845. -rl_upcase_word (), rl_downcase_word (), rl_capitalize_word (),
  846. -rl_restart_output (), rl_re_read_init_file ();
  847. -
  848. -extern int rl_function_key(); /* pjf */
  849. -extern int rl_check_spelling(),rl_magic_space();
  850. -extern int rl_break_c();
  851. -
  852. -/* These are *both* defined even when VI_MODE is not. */
  853. -extern int rl_vi_editing_mode (), rl_emacs_editing_mode ();
  854. -
  855. -#ifdef VI_MODE
  856. -/* Things for vi mode. */
  857. -extern int rl_vi_movement_mode (), rl_vi_insertion_mode (), rl_vi_arg_digit (),
  858. -rl_vi_prev_word (), rl_vi_next_word (), rl_vi_char_search (),
  859. -rl_vi_eof_maybe (), rl_vi_append_mode (), rl_vi_put (),
  860. -rl_vi_append_eol (), rl_vi_insert_beg (), rl_vi_delete (), rl_vi_comment (),
  861. -rl_vi_first_print (), rl_vi_fword (), rl_vi_fWord (), rl_vi_bword (),
  862. -rl_vi_bWord (), rl_vi_eword (), rl_vi_eWord (), rl_vi_end_word (),
  863. -rl_vi_change_case (), rl_vi_match (), rl_vi_bracktype (), rl_vi_change_char (),
  864. -rl_vi_yank_arg (), rl_vi_search (), rl_vi_search_again (),
  865. -rl_vi_dosearch (), rl_vi_subst (), rl_vi_overstrike (),
  866. -rl_vi_overstrike_delete (), rl_vi_replace(), rl_vi_column (),
  867. -rl_vi_delete_to (), rl_vi_change_to (), rl_vi_yank_to (), rl_vi_complete ();
  868. -#endif /* VI_MODE */
  869. -
  870. -/* Keyboard macro commands. */
  871. -extern int
  872. -rl_start_kbd_macro (), rl_end_kbd_macro (), rl_call_last_kbd_macro ();
  873. -
  874. -/* Maintaining the state of undo.  We remember individual deletes and inserts
  875. -   on a chain of things to do. */
  876. -
  877. -/* The actions that undo knows how to undo.  Notice that UNDO_DELETE means
  878. -   to insert some text, and UNDO_INSERT means to delete some text.   I.e.,
  879. -   the code tells undo what to undo, not how to undo it. */
  880. -enum undo_code { UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END };
  881. -
  882. -/* What an element of THE_UNDO_LIST looks like. */
  883. -typedef struct undo_list {
  884. -  struct undo_list *next;
  885. -  int start, end;        /* Where the change took place. */
  886. -  char *text;            /* The text to insert, if undoing a delete. */
  887. -  enum undo_code what;        /* Delete, Insert, Begin, End. */
  888. -} UNDO_LIST;
  889. -
  890. -/* The current undo list for RL_LINE_BUFFER. */
  891. -extern UNDO_LIST *rl_undo_list;
  892. -
  893. -/* The data structure for mapping textual names to code addresses. */
  894. -typedef struct {
  895. -  char *name;
  896. -  Function *function;
  897. -} FUNMAP;
  898. -
  899. -extern FUNMAP **funmap;
  900. -
  901. -/* **************************************************************** */
  902. -/*                                    */
  903. -/*            Well Published Variables            */
  904. -/*                                    */
  905. -/* **************************************************************** */
  906. -
  907. -/* The name of the calling program.  You should initialize this to
  908. -   whatever was in argv[0].  It is used when parsing conditionals. */
  909. -extern char *rl_readline_name;
  910. -
  911. -/* The line buffer that is in use. */
  912. -extern char *rl_line_buffer;
  913. -
  914. -/* The location of point, and end. */
  915. -extern int rl_point, rl_end;
  916. -
  917. -/* The name of the terminal to use. */
  918. -extern char *rl_terminal_name;
  919. -
  920. -/* The input and output streams. */
  921. -extern FILE *rl_instream, *rl_outstream;
  922. -
  923. -/* The basic list of characters that signal a break between words for the
  924. -   completer routine.  The contents of this variable is what breaks words
  925. -   in the shell, i.e. "n\"\\'`@$>". */
  926. -extern char *rl_basic_word_break_characters;
  927. -
  928. -/* The list of characters that signal a break between words for
  929. -   rl_complete_internal.  The default list is the contents of
  930. -   rl_basic_word_break_characters.  */
  931. -extern char *rl_completer_word_break_characters;
  932. -
  933. -/* List of characters that are word break characters, but should be left
  934. -   in TEXT when it is passed to the completion function.  The shell uses
  935. -   this to help determine what kind of completing to do. */
  936. -extern char *rl_special_prefixes;
  937. -
  938. -/* Pointer to the generator function for completion_matches ().
  939. -   NULL means to use filename_entry_function (), the default filename
  940. -   completer. */
  941. -extern Function *rl_completion_entry_function;
  942. -
  943. -/* Pointer to alternative function to create matches.
  944. -   Function is called with TEXT, START, and END.
  945. -   START and END are indices in RL_LINE_BUFFER saying what the boundaries
  946. -   of TEXT are.
  947. -   If this function exists and returns NULL then call the value of
  948. -   rl_completion_entry_function to try to match, otherwise use the
  949. -   array of strings returned. */
  950. -extern Function *rl_attempted_completion_function;
  951. -
  952. -/* If non-null, this contains the address of a function to call if the
  953. -   standard meaning for expanding a tilde fails.  The function is called
  954. -   with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
  955. -   which is the expansion, or a NULL pointer if there is no expansion. */
  956. -extern Function *rl_tilde_expander;
  957. -
  958. -/* If non-zero, then this is the address of a function to call just
  959. -   before readline_internal () prints the first prompt. */
  960. -extern Function *rl_startup_hook;
  961. -
  962. -/* If non-zero, then this is the address of a function to call when
  963. -   completing on a directory name.  The function is called with
  964. -   the address of a string (the current directory name) as an arg. */
  965. -extern Function *rl_symbolic_link_hook;
  966. -
  967. -/* Non-zero means that modified history lines are preceded
  968. -   with an asterisk. */
  969. -extern int rl_show_star;
  970. -
  971. -/* **************************************************************** */
  972. -/*                                    */
  973. -/*            Well Published Functions            */
  974. -/*                                    */
  975. -/* **************************************************************** */
  976. -
  977. -/* Read a line of input.  Prompt with PROMPT.  A NULL PROMPT means none. */
  978. -extern char *readline ();
  979. -
  980. -/* Return an array of strings which are the result of repeatadly calling
  981. -   FUNC with TEXT. */
  982. -extern char **completion_matches ();
  983. -
  984. -/* rl_add_defun (char *name, Function *function, int key)
  985. -   Add NAME to the list of named functions.  Make FUNCTION
  986. -   be the function that gets called.
  987. -   If KEY is not -1, then bind it. */
  988. -extern int rl_add_defun ();
  989. -
  990. -
  991. -#endif /* _READLINE_H_ */
  992. -
  993. End of readline/readline.h
  994. echo readline/vi_keymap.c 1>&2
  995. sed 's/^-//' >readline/vi_keymap.c <<'End of readline/vi_keymap.c'
  996. -/* vi_keymap.c -- the keymap for vi_mode in readline (). */
  997. -
  998. -/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
  999. -
  1000. -   This file is part of GNU Readline, a library for reading lines
  1001. -   of text with interactive input and history editing.
  1002. -
  1003. -   Readline is free software; you can redistribute it and/or modify it
  1004. -   under the terms of the GNU General Public License as published by the
  1005. -   Free Software Foundation; either version 1, or (at your option) any
  1006. -   later version.
  1007. -
  1008. -   Readline is distributed in the hope that it will be useful, but
  1009. -   WITHOUT ANY WARRANTY; without even the implied warranty of
  1010. -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  1011. -   General Public License for more details.
  1012. -
  1013. -   You should have received a copy of the GNU General Public License
  1014. -   along with Readline; see the file COPYING.  If not, write to the Free
  1015. -   Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  1016. -
  1017. -#ifndef FILE
  1018. -#include <stdio.h>
  1019. -#endif /* FILE */
  1020. -
  1021. -#include "readline.h"
  1022. -
  1023. -extern KEYMAP_ENTRY_ARRAY vi_escape_keymap;
  1024. -
  1025. -/* The keymap arrays for handling vi mode. */
  1026. -KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
  1027. -
  1028. -  /* The regular control keys come first. */
  1029. -  { ISFUNC, (Function *)0x0 },        /* Control-@ */
  1030. -  { ISFUNC, (Function *)0x0 },        /* Control-a */
  1031. -  { ISFUNC, (Function *)0x0 },        /* Control-b */
  1032. -  { ISFUNC, (Function *)0x0 },        /* Control-c */
  1033. -  { ISFUNC, rl_vi_eof_maybe },        /* Control-d */
  1034. -  { ISFUNC, rl_emacs_editing_mode },    /* Control-e */
  1035. -  { ISFUNC, (Function *)0x0 },        /* Control-f */
  1036. -  { ISFUNC, rl_abort },            /* Control-g */
  1037. -  { ISFUNC, rl_rubout },        /* Control-h */ /* pjf */
  1038. -  { ISFUNC, (Function *)0x0 },        /* Control-i */
  1039. -  { ISFUNC, rl_newline },        /* Control-j */
  1040. -  { ISFUNC, rl_kill_line },        /* Control-k */
  1041. -  { ISFUNC, rl_clear_screen },        /* Control-l */
  1042. -  { ISFUNC, rl_newline },        /* Control-m */
  1043. -  { ISFUNC, rl_get_next_history },    /* Control-n */
  1044. -  { ISFUNC, (Function *)0x0 },        /* Control-o */
  1045. -  { ISFUNC, rl_get_previous_history },    /* Control-p */
  1046. -  { ISFUNC, rl_quoted_insert },        /* Control-q */
  1047. -  { ISFUNC, (Function *)0x0 },  /* Control-r */
  1048. -  { ISFUNC, (Function *)0x0 },  /* Control-s */
  1049. -  { ISFUNC, rl_transpose_chars },    /* Control-t */
  1050. -  { ISFUNC, rl_unix_line_discard },    /* Control-u */
  1051. -  { ISFUNC, rl_quoted_insert },        /* Control-v */
  1052. -  { ISFUNC, rl_unix_word_rubout },    /* Control-w */
  1053. -  { ISFUNC, (Function *)0x0 },        /* Control-x */
  1054. -  { ISFUNC, rl_yank },            /* Control-y */
  1055. -  { ISFUNC, (Function *)0x0 },        /* Control-z */
  1056. -
  1057. -  { ISKMAP, (Function *)vi_escape_keymap }, /* Control-[ */
  1058. -  { ISFUNC, (Function *)0x0 },        /* Control-\ */
  1059. -  { ISFUNC, (Function *)0x0 },        /* Control-] */
  1060. -  { ISFUNC, (Function *)0x0 },        /* Control-^ */
  1061. -  { ISFUNC, rl_undo_command },        /* Control-_ */
  1062. -
  1063. -  /* The start of printing characters. */
  1064. -  { ISFUNC, rl_forward },        /* SPACE */
  1065. -  { ISFUNC, (Function *)0x0 },        /* ! */
  1066. -  { ISFUNC, (Function *)0x0 },        /* " */
  1067. -  { ISFUNC, rl_vi_comment },        /* # */
  1068. -  { ISFUNC, rl_end_of_line },        /* $ */
  1069. -  { ISFUNC, rl_vi_match },        /* % */
  1070. -  { ISFUNC, (Function *)0x0 },        /* & */
  1071. -  { ISFUNC, (Function *)0x0 },        /* ' */
  1072. -  { ISFUNC, (Function *)0x0 },        /* ( */
  1073. -  { ISFUNC, (Function *)0x0 },        /* ) */
  1074. -  { ISFUNC, rl_vi_complete },        /* * */
  1075. -  { ISFUNC, rl_get_next_history},    /* + */
  1076. -  { ISFUNC, rl_vi_char_search },    /* , */
  1077. -  { ISFUNC, rl_get_previous_history },    /* - */
  1078. -  { ISFUNC, (Function *)0x0 },        /* . */
  1079. -  { ISFUNC, rl_vi_search },        /* / */
  1080. -
  1081. -  /* Regular digits. */
  1082. -  { ISFUNC, rl_vi_arg_digit },        /* 0 */
  1083. -  { ISFUNC, rl_vi_arg_digit },        /* 1 */
  1084. -  { ISFUNC, rl_vi_arg_digit },        /* 2 */
  1085. -  { ISFUNC, rl_vi_arg_digit },        /* 3 */
  1086. -  { ISFUNC, rl_vi_arg_digit },        /* 4 */
  1087. -  { ISFUNC, rl_vi_arg_digit },        /* 5 */
  1088. -  { ISFUNC, rl_vi_arg_digit },        /* 6 */
  1089. -  { ISFUNC, rl_vi_arg_digit },        /* 7 */
  1090. -  { ISFUNC, rl_vi_arg_digit },        /* 8 */
  1091. -  { ISFUNC, rl_vi_arg_digit },        /* 9 */
  1092. -
  1093. -  /* A little more punctuation. */
  1094. -  { ISFUNC, (Function *)0x0 },        /* : */
  1095. -  { ISFUNC, rl_vi_char_search },    /* ; */
  1096. -  { ISFUNC, (Function *)0x0 },        /* < */
  1097. -  { ISFUNC, (Function *)0x0 },        /* = */
  1098. -  { ISFUNC, (Function *)0x0 },        /* > */
  1099. -  { ISFUNC, rl_vi_search },        /* ? */
  1100. -  { ISFUNC, (Function *)0x0 },        /* @ */
  1101. -
  1102. -  /* Uppercase alphabet. */
  1103. -  { ISFUNC, rl_vi_append_eol },        /* A */
  1104. -  { ISFUNC, rl_vi_prev_word},        /* B */
  1105. -  { ISFUNC, rl_vi_change_to },        /* C */
  1106. -  { ISFUNC, rl_vi_delete_to },        /* D */
  1107. -  { ISFUNC, rl_vi_end_word },        /* E */
  1108. -  { ISFUNC, rl_vi_char_search },    /* F */
  1109. -  { ISFUNC, (Function *)0x0 },        /* G */
  1110. -  { ISFUNC, (Function *)0x0 },        /* H */
  1111. -  { ISFUNC, rl_vi_insert_beg },        /* I */
  1112. -  { ISFUNC, (Function *)0x0 },        /* J */
  1113. -  { ISFUNC, (Function *)0x0 },        /* K */
  1114. -  { ISFUNC, (Function *)0x0 },        /* L */
  1115. -  { ISFUNC, (Function *)0x0 },        /* M */
  1116. -  { ISFUNC, rl_vi_search_again },    /* N */
  1117. -  { ISFUNC, (Function *)0x0 },        /* O */
  1118. -  { ISFUNC, rl_vi_put },        /* P */
  1119. -  { ISFUNC, (Function *)0x0 },        /* Q */
  1120. -  { ISFUNC, rl_vi_replace },        /* R */
  1121. -  { ISFUNC, rl_vi_subst },        /* S */
  1122. -  { ISFUNC, rl_vi_char_search },    /* T */
  1123. -  { ISFUNC, rl_revert_line },        /* U */
  1124. -  { ISFUNC, (Function *)0x0 },        /* V */
  1125. -  { ISFUNC, rl_vi_next_word },        /* W */
  1126. -  { ISFUNC, rl_rubout },        /* X */
  1127. -  { ISFUNC, rl_vi_yank_to },        /* Y */
  1128. -  { ISFUNC, (Function *)0x0 },        /* Z */
  1129. -
  1130. -  /* Some more punctuation. */
  1131. -  { ISFUNC, (Function *)0x0 },        /* [ */
  1132. -  { ISFUNC, (Function *)0x0 },        /* \ */
  1133. -  { ISFUNC, (Function *)0x0 },        /* ] */
  1134. -  { ISFUNC, rl_vi_first_print },    /* ^ */
  1135. -  { ISFUNC, rl_vi_yank_arg },        /* _ */
  1136. -  { ISFUNC, (Function *)0x0 },        /* ` */
  1137. -
  1138. -  /* Lowercase alphabet. */
  1139. -  { ISFUNC, rl_vi_append_mode },    /* a */
  1140. -  { ISFUNC, rl_vi_prev_word },        /* b */
  1141. -  { ISFUNC, rl_vi_change_to },        /* c */
  1142. -  { ISFUNC, rl_vi_delete_to },        /* d */
  1143. -  { ISFUNC, rl_vi_end_word },        /* e */
  1144. -  { ISFUNC, rl_vi_char_search },    /* f */
  1145. -  { ISFUNC, (Function *)0x0 },        /* g */
  1146. -  { ISFUNC, rl_backward },        /* h */
  1147. -  { ISFUNC, rl_vi_insertion_mode },    /* i */
  1148. -  { ISFUNC, rl_get_next_history },    /* j */
  1149. -  { ISFUNC, rl_get_previous_history },    /* k */
  1150. -  { ISFUNC, rl_forward },        /* l */
  1151. -  { ISFUNC, (Function *)0x0 },        /* m */
  1152. -  { ISFUNC, rl_vi_search_again },    /* n */
  1153. -  { ISFUNC, (Function *)0x0 },        /* o */
  1154. -  { ISFUNC, rl_vi_put },        /* p */
  1155. -  { ISFUNC, (Function *)0x0 },        /* q */
  1156. -  { ISFUNC, rl_vi_change_char },    /* r */
  1157. -  { ISFUNC, rl_vi_subst },        /* s */
  1158. -  { ISFUNC, rl_vi_char_search },    /* t */
  1159. -  { ISFUNC, rl_undo_command },        /* u */
  1160. -  { ISFUNC, (Function *)0x0 },        /* v */
  1161. -  { ISFUNC, rl_vi_next_word },        /* w */
  1162. -  { ISFUNC, rl_vi_delete },        /* x */
  1163. -  { ISFUNC, rl_vi_yank_to },        /* y */
  1164. -  { ISFUNC, (Function *)0x0 },        /* z */
  1165. -
  1166. -  /* Final punctuation. */
  1167. -  { ISFUNC, (Function *)0x0 },        /* { */
  1168. -  { ISFUNC, rl_vi_column },        /* | */
  1169. -  { ISFUNC, (Function *)0x0 },        /* } */
  1170. -  { ISFUNC, rl_vi_change_case },    /* ~ */
  1171. -  { ISFUNC, rl_backward }        /* RUBOUT */
  1172. -};
  1173. -
  1174. -
  1175. -KEYMAP_ENTRY_ARRAY vi_insertion_keymap = {
  1176. -
  1177. -  /* The regular control keys come first. */
  1178. -  { ISFUNC, (Function *)0x0 },        /* Control-@ */
  1179. -  { ISFUNC, rl_insert },        /* Control-a */
  1180. -  { ISFUNC, rl_insert },        /* Control-b */
  1181. -  { ISFUNC, rl_insert },        /* Control-c */
  1182. -  { ISFUNC, rl_vi_eof_maybe },        /* Control-d */
  1183. -  { ISFUNC, rl_insert },        /* Control-e */
  1184. -  { ISFUNC, rl_insert },        /* Control-f */
  1185. -  { ISFUNC, rl_insert },        /* Control-g */
  1186. -  { ISFUNC, rl_rubout },        /* Control-h */
  1187. -  { ISFUNC, rl_complete },        /* Control-i */
  1188. -  { ISFUNC, rl_newline },        /* Control-j */
  1189. -  { ISFUNC, rl_insert },        /* Control-k */
  1190. -  { ISFUNC, rl_insert },        /* Control-l */
  1191. -  { ISFUNC, rl_newline },        /* Control-m */
  1192. -  { ISFUNC, rl_insert },        /* Control-n */
  1193. -  { ISFUNC, rl_insert },        /* Control-o */
  1194. -  { ISFUNC, rl_insert },        /* Control-p */
  1195. -  { ISFUNC, rl_insert },        /* Control-q */
  1196. -  { ISFUNC, (Function *)0x0 },
  1197. -  { ISFUNC, (Function *)0x0 },
  1198. -  { ISFUNC, rl_transpose_chars },    /* Control-t */
  1199. -  { ISFUNC, rl_unix_line_discard },    /* Control-u */
  1200. -  { ISFUNC, rl_quoted_insert },        /* Control-v */
  1201. -  { ISFUNC, rl_unix_word_rubout },    /* Control-w */
  1202. -  { ISFUNC, rl_insert },        /* Control-x */
  1203. -  { ISFUNC, rl_yank },            /* Control-y */
  1204. -  { ISFUNC, rl_insert },        /* Control-z */
  1205. -
  1206. -  { ISFUNC, rl_vi_movement_mode },    /* Control-[ */
  1207. -  { ISFUNC, rl_insert },        /* Control-\ */
  1208. -  { ISFUNC, rl_insert },        /* Control-] */
  1209. -  { ISFUNC, rl_insert },        /* Control-^ */
  1210. -  { ISFUNC, rl_undo_command },        /* Control-_ */
  1211. -
  1212. -  /* The start of printing characters. */
  1213. -  { ISFUNC, rl_insert },        /* SPACE */
  1214. -  { ISFUNC, rl_insert },        /* ! */
  1215. -  { ISFUNC, rl_insert },        /* " */
  1216. -  { ISFUNC, rl_insert },        /* # */
  1217. -  { ISFUNC, rl_insert },        /* $ */
  1218. -  { ISFUNC, rl_insert },        /* % */
  1219. -  { ISFUNC, rl_insert },        /* & */
  1220. -  { ISFUNC, rl_insert },        /* ' */
  1221. -  { ISFUNC, rl_insert },        /* ( */
  1222. -  { ISFUNC, rl_insert },        /* ) */
  1223. -  { ISFUNC, rl_insert },        /* * */
  1224. -  { ISFUNC, rl_insert },        /* + */
  1225. -  { ISFUNC, rl_insert },        /* , */
  1226. -  { ISFUNC, rl_insert },        /* - */
  1227. -  { ISFUNC, rl_insert },        /* . */
  1228. -  { ISFUNC, rl_insert },        /* / */
  1229. -
  1230. -  /* Regular digits. */
  1231. -  { ISFUNC, rl_insert },        /* 0 */
  1232. -  { ISFUNC, rl_insert },        /* 1 */
  1233. -  { ISFUNC, rl_insert },        /* 2 */
  1234. -  { ISFUNC, rl_insert },        /* 3 */
  1235. -  { ISFUNC, rl_insert },        /* 4 */
  1236. -  { ISFUNC, rl_insert },        /* 5 */
  1237. -  { ISFUNC, rl_insert },        /* 6 */
  1238. -  { ISFUNC, rl_insert },        /* 7 */
  1239. -  { ISFUNC, rl_insert },        /* 8 */
  1240. -  { ISFUNC, rl_insert },        /* 9 */
  1241. -
  1242. -  /* A little more punctuation. */
  1243. -  { ISFUNC, rl_insert },        /* : */
  1244. -  { ISFUNC, rl_insert },        /* ; */
  1245. -  { ISFUNC, rl_insert },        /* < */
  1246. -  { ISFUNC, rl_insert },        /* = */
  1247. -  { ISFUNC, rl_insert },        /* > */
  1248. -  { ISFUNC, rl_insert },        /* ? */
  1249. -  { ISFUNC, rl_insert },        /* @ */
  1250. -
  1251. -  /* Uppercase alphabet. */
  1252. -  { ISFUNC, rl_insert },        /* A */
  1253. -  { ISFUNC, rl_insert },        /* B */
  1254. -  { ISFUNC, rl_insert },        /* C */
  1255. -  { ISFUNC, rl_insert },        /* D */
  1256. -  { ISFUNC, rl_insert },        /* E */
  1257. -  { ISFUNC, rl_insert },        /* F */
  1258. -  { ISFUNC, rl_insert },        /* G */
  1259. -  { ISFUNC, rl_insert },        /* H */
  1260. -  { ISFUNC, rl_insert },        /* I */
  1261. -  { ISFUNC, rl_insert },        /* J */
  1262. -  { ISFUNC, rl_insert },        /* K */
  1263. -  { ISFUNC, rl_insert },        /* L */
  1264. -  { ISFUNC, rl_insert },        /* M */
  1265. -  { ISFUNC, rl_insert },        /* N */
  1266. -  { ISFUNC, rl_insert },        /* O */
  1267. -  { ISFUNC, rl_insert },        /* P */
  1268. -  { ISFUNC, rl_insert },        /* Q */
  1269. -  { ISFUNC, rl_insert },        /* R */
  1270. -  { ISFUNC, rl_insert },        /* S */
  1271. -  { ISFUNC, rl_insert },        /* T */
  1272. -  { ISFUNC, rl_insert },        /* U */
  1273. -  { ISFUNC, rl_insert },        /* V */
  1274. -  { ISFUNC, rl_insert },        /* W */
  1275. -  { ISFUNC, rl_insert },        /* X */
  1276. -  { ISFUNC, rl_insert },        /* Y */
  1277. -  { ISFUNC, rl_insert },        /* Z */
  1278. -
  1279. -  /* Some more punctuation. */
  1280. -  { ISFUNC, rl_insert },        /* [ */
  1281. -  { ISFUNC, rl_insert },        /* \ */
  1282. -  { ISFUNC, rl_insert },        /* ] */
  1283. -  { ISFUNC, rl_insert },        /* ^ */
  1284. -  { ISFUNC, rl_insert },        /* _ */
  1285. -  { ISFUNC, rl_insert },        /* ` */
  1286. -
  1287. -  /* Lowercase alphabet. */
  1288. -  { ISFUNC, rl_insert },        /* a */
  1289. -  { ISFUNC, rl_insert },        /* b */
  1290. -  { ISFUNC, rl_insert },        /* c */
  1291. -  { ISFUNC, rl_insert },        /* d */
  1292. -  { ISFUNC, rl_insert },        /* e */
  1293. -  { ISFUNC, rl_insert },        /* f */
  1294. -  { ISFUNC, rl_insert },        /* g */
  1295. -  { ISFUNC, rl_insert },        /* h */
  1296. -  { ISFUNC, rl_insert },        /* i */
  1297. -  { ISFUNC, rl_insert },        /* j */
  1298. -  { ISFUNC, rl_insert },        /* k */
  1299. -  { ISFUNC, rl_insert },        /* l */
  1300. -  { ISFUNC, rl_insert },        /* m */
  1301. -  { ISFUNC, rl_insert },        /* n */
  1302. -  { ISFUNC, rl_insert },        /* o */
  1303. -  { ISFUNC, rl_insert },        /* p */
  1304. -  { ISFUNC, rl_insert },        /* q */
  1305. -  { ISFUNC, rl_insert },        /* r */
  1306. -  { ISFUNC, rl_insert },        /* s */
  1307. -  { ISFUNC, rl_insert },        /* t */
  1308. -  { ISFUNC, rl_insert },        /* u */
  1309. -  { ISFUNC, rl_insert },        /* v */
  1310. -  { ISFUNC, rl_insert },        /* w */
  1311. -  { ISFUNC, rl_insert },        /* x */
  1312. -  { ISFUNC, rl_insert },        /* y */
  1313. -  { ISFUNC, rl_insert },        /* z */
  1314. -
  1315. -  /* Final punctuation. */
  1316. -  { ISFUNC, rl_insert },        /* { */
  1317. -  { ISFUNC, rl_insert },        /* | */
  1318. -  { ISFUNC, rl_insert },        /* } */
  1319. -  { ISFUNC, rl_insert },        /* ~ */
  1320. -  { ISFUNC, rl_rubout }            /* RUBOUT */
  1321. -};
  1322. -
  1323. -KEYMAP_ENTRY_ARRAY vi_escape_keymap = {
  1324. -
  1325. -  /* The regular control keys come first. */
  1326. -  { ISFUNC, (Function *)0x0 },        /* Control-@ */
  1327. -  { ISFUNC, (Function *)0x0 },        /* Control-a */
  1328. -  { ISFUNC, (Function *)0x0 },        /* Control-b */
  1329. -  { ISFUNC, (Function *)0x0 },        /* Control-c */
  1330. -  { ISFUNC, (Function *)0x0 },        /* Control-d */
  1331. -  { ISFUNC, (Function *)0x0 },        /* Control-e */
  1332. -  { ISFUNC, (Function *)0x0 },        /* Control-f */
  1333. -  { ISFUNC, (Function *)0x0 },        /* Control-g */
  1334. -  { ISFUNC, (Function *)0x0 },        /* Control-h */
  1335. -  { ISFUNC, rl_tab_insert},        /* Control-i */
  1336. -  { ISFUNC, rl_emacs_editing_mode},    /* Control-j */
  1337. -  { ISFUNC, rl_kill_line },        /* Control-k */
  1338. -  { ISFUNC, (Function *)0x0 },        /* Control-l */
  1339. -  { ISFUNC, rl_emacs_editing_mode},    /* Control-m */
  1340. -  { ISFUNC, (Function *)0x0 },        /* Control-n */
  1341. -  { ISFUNC, (Function *)0x0 },        /* Control-o */
  1342. -  { ISFUNC, (Function *)0x0 },        /* Control-p */
  1343. -  { ISFUNC, (Function *)0x0 },        /* Control-q */
  1344. -  { ISFUNC, (Function *)0x0 },        /* Control-r */
  1345. -  { ISFUNC, (Function *)0x0 },        /* Control-s */
  1346. -  { ISFUNC, (Function *)0x0 },        /* Control-t */
  1347. -  { ISFUNC, (Function *)0x0 },        /* Control-u */
  1348. -  { ISFUNC, (Function *)0x0 },        /* Control-v */
  1349. -  { ISFUNC, (Function *)0x0 },        /* Control-w */
  1350. -  { ISFUNC, (Function *)0x0 },        /* Control-x */
  1351. -  { ISFUNC, (Function *)0x0 },        /* Control-y */
  1352. -  { ISFUNC, (Function *)0x0 },        /* Control-z */
  1353. -
  1354. -  { ISFUNC, rl_vi_movement_mode },    /* Control-[ */
  1355. -  { ISFUNC, (Function *)0x0 },        /* Control-\ */
  1356. -  { ISFUNC, (Function *)0x0 },        /* Control-] */
  1357. -  { ISFUNC, (Function *)0x0 },        /* Control-^ */
  1358. -  { ISFUNC, rl_undo_command },        /* Control-_ */
  1359. -
  1360. -  /* The start of printing characters. */
  1361. -  { ISFUNC, (Function *)0x0 },        /* SPACE */
  1362. -  { ISFUNC, (Function *)0x0 },        /* ! */
  1363. -  { ISFUNC, (Function *)0x0 },        /* " */
  1364. -  { ISFUNC, (Function *)0x0 },        /* # */
  1365. -  { ISFUNC, (Function *)0x0 },        /* $ */
  1366. -  { ISFUNC, (Function *)0x0 },        /* % */
  1367. -  { ISFUNC, (Function *)0x0 },        /* & */
  1368. -  { ISFUNC, (Function *)0x0 },        /* ' */
  1369. -  { ISFUNC, (Function *)0x0 },        /* ( */
  1370. -  { ISFUNC, (Function *)0x0 },        /* ) */
  1371. -  { ISFUNC, (Function *)0x0 },        /* * */
  1372. -  { ISFUNC, (Function *)0x0 },        /* + */
  1373. -  { ISFUNC, (Function *)0x0 },        /* , */
  1374. -  { ISFUNC, (Function *)0x0 },        /* - */
  1375. -  { ISFUNC, (Function *)0x0 },        /* . */
  1376. -  { ISFUNC, (Function *)0x0 },        /* / */
  1377. -
  1378. -  /* Regular digits. */
  1379. -  { ISFUNC, rl_vi_arg_digit },        /* 0 */
  1380. -  { ISFUNC, rl_vi_arg_digit },        /* 1 */
  1381. -  { ISFUNC, rl_vi_arg_digit },        /* 2 */
  1382. -  { ISFUNC, rl_vi_arg_digit },        /* 3 */
  1383. -  { ISFUNC, rl_vi_arg_digit },        /* 4 */
  1384. -  { ISFUNC, rl_vi_arg_digit },        /* 5 */
  1385. -  { ISFUNC, rl_vi_arg_digit },        /* 6 */
  1386. -  { ISFUNC, rl_vi_arg_digit },        /* 7 */
  1387. -  { ISFUNC, rl_vi_arg_digit },        /* 8 */
  1388. -  { ISFUNC, rl_vi_arg_digit },        /* 9 */
  1389. -
  1390. -  /* A little more punctuation. */
  1391. -  { ISFUNC, (Function *)0x0 },        /* : */
  1392. -  { ISFUNC, (Function *)0x0 },        /* ; */
  1393. -  { ISFUNC, (Function *)0x0 },        /* < */
  1394. -  { ISFUNC, (Function *)0x0 },        /* = */
  1395. -  { ISFUNC, (Function *)0x0 },        /* > */
  1396. -  { ISFUNC, (Function *)0x0 },        /* ? */
  1397. -  { ISFUNC, (Function *)0x0 },        /* @ */
  1398. -
  1399. -  /* Uppercase alphabet. */
  1400. -  { ISFUNC, rl_do_lowercase_version },    /* A */
  1401. -  { ISFUNC, rl_do_lowercase_version },    /* B */
  1402. -  { ISFUNC, rl_do_lowercase_version },    /* C */
  1403. -  { ISFUNC, rl_do_lowercase_version },    /* D */
  1404. -  { ISFUNC, rl_do_lowercase_version },    /* E */
  1405. -  { ISFUNC, rl_do_lowercase_version },    /* F */
  1406. -  { ISFUNC, rl_do_lowercase_version },    /* G */
  1407. -  { ISFUNC, rl_do_lowercase_version },    /* H */
  1408. -  { ISFUNC, rl_do_lowercase_version },    /* I */
  1409. -  { ISFUNC, rl_do_lowercase_version },    /* J */
  1410. -  { ISFUNC, rl_do_lowercase_version },    /* K */
  1411. -  { ISFUNC, rl_do_lowercase_version },    /* L */
  1412. -  { ISFUNC, rl_do_lowercase_version },    /* M */
  1413. -  { ISFUNC, rl_do_lowercase_version },    /* N */
  1414. -  { ISFUNC, rl_do_lowercase_version },    /* O */
  1415. -  { ISFUNC, rl_do_lowercase_version },    /* P */
  1416. -  { ISFUNC, rl_do_lowercase_version },    /* Q */
  1417. -  { ISFUNC, rl_do_lowercase_version },    /* R */
  1418. -  { ISFUNC, rl_do_lowercase_version },    /* S */
  1419. -  { ISFUNC, rl_do_lowercase_version },    /* T */
  1420. -  { ISFUNC, rl_do_lowercase_version },    /* U */
  1421. -  { ISFUNC, rl_do_lowercase_version },    /* V */
  1422. -  { ISFUNC, rl_do_lowercase_version },    /* W */
  1423. -  { ISFUNC, rl_do_lowercase_version },    /* X */
  1424. -  { ISFUNC, rl_do_lowercase_version },    /* Y */
  1425. -  { ISFUNC, rl_do_lowercase_version },    /* Z */
  1426. -
  1427. -  /* Some more punctuation. */
  1428. -  { ISFUNC, (Function *)0x0 },        /* [ */
  1429. -  { ISFUNC, (Function *)0x0 },        /* \ */
  1430. -  { ISFUNC, (Function *)0x0 },        /* ] */
  1431. -  { ISFUNC, (Function *)0x0 },        /* ^ */
  1432. -  { ISFUNC, (Function *)0x0 },        /* _ */
  1433. -  { ISFUNC, (Function *)0x0 },        /* ` */
  1434. -
  1435. -  /* Lowercase alphabet. */
  1436. -  { ISFUNC, (Function *)0x0 },        /* a */
  1437. -  { ISFUNC, (Function *)0x0 },        /* b */
  1438. -  { ISFUNC, (Function *)0x0 },        /* c */
  1439. -  { ISFUNC, (Function *)0x0 },        /* d */
  1440. -  { ISFUNC, (Function *)0x0 },        /* e */
  1441. -  { ISFUNC, (Function *)0x0 },        /* f */
  1442. -  { ISFUNC, (Function *)0x0 },        /* g */
  1443. -  { ISFUNC, (Function *)0x0 },        /* h */
  1444. -  { ISFUNC, (Function *)0x0 },        /* i */
  1445. -  { ISFUNC, (Function *)0x0 },        /* j */
  1446. -  { ISFUNC, (Function *)0x0 },        /* k */
  1447. -  { ISFUNC, (Function *)0x0 },        /* l */
  1448. -  { ISFUNC, (Function *)0x0 },        /* m */
  1449. -  { ISFUNC, (Function *)0x0 },        /* n */
  1450. -  { ISFUNC, (Function *)0x0 },        /* o */
  1451. -  { ISFUNC, (Function *)0x0 },        /* p */
  1452. -  { ISFUNC, (Function *)0x0 },        /* q */
  1453. -  { ISFUNC, (Function *)0x0 },        /* r */
  1454. -  { ISFUNC, (Function *)0x0 },        /* s */
  1455. -  { ISFUNC, (Function *)0x0 },        /* t */
  1456. -  { ISFUNC, (Function *)0x0 },        /* u */
  1457. -  { ISFUNC, (Function *)0x0 },        /* v */
  1458. -  { ISFUNC, (Function *)0x0 },        /* w */
  1459. -  { ISFUNC, (Function *)0x0 },        /* x */
  1460. -  { ISFUNC, (Function *)0x0 },        /* y */
  1461. -  { ISFUNC, (Function *)0x0 },        /* z */
  1462. -
  1463. -  /* Final punctuation. */
  1464. -  { ISFUNC, (Function *)0x0 },        /* { */
  1465. -  { ISFUNC, (Function *)0x0 },        /* | */
  1466. -  { ISFUNC, (Function *)0x0 },        /* } */
  1467. -  { ISFUNC, (Function *)0x0 },        /* ~ */
  1468. -  { ISFUNC, rl_backward_kill_word }    /* RUBOUT */
  1469. -};
  1470. End of readline/vi_keymap.c
  1471. echo readline/vi_mode.c 1>&2
  1472. sed 's/^-//' >readline/vi_mode.c <<'End of readline/vi_mode.c'
  1473. -/* vi_mode.c -- A vi emulation mode for Bash.
  1474. -
  1475. -   Derived from code written by Jeff Sparkes (jeff1@????).
  1476. - */
  1477. -
  1478. -
  1479. -/* **************************************************************** */
  1480. -/*                                    */
  1481. -/*            VI Emulation Mode                */
  1482. -/*                                    */
  1483. -/* **************************************************************** */
  1484. -
  1485. -/* Last string searched for from `/' or `?'. */
  1486. -static char *vi_last_search = (char *)NULL;
  1487. -static int vi_histpos;
  1488. -
  1489. -/* Non-zero means enter insertion mode. */
  1490. -int vi_doing_insert = 0;
  1491. -
  1492. -/* *** UNCLEAN *** */
  1493. -/* Command keys which do movement for xxx_to commands. */
  1494. -static char *vi_motion = " hl^$0ftFt;,%wbeWBE|";
  1495. -
  1496. -/* Keymap used for vi replace characters.  Created dynamically since
  1497. -   rarely used. */
  1498. -static Keymap vi_replace_map = (Keymap)NULL;
  1499. -
  1500. -/* The number of characters inserted in the last replace operation. */
  1501. -static vi_replace_count = 0;
  1502. -
  1503. -/* Yank the nth arg from the previous line into this line at point. */
  1504. -rl_vi_yank_arg (count)
  1505. -     int count;
  1506. -{
  1507. -  rl_yank_nth_arg (count, 0);
  1508. -}
  1509. -
  1510. -/* Search again for the last thing searched for. */
  1511. -rl_vi_search_again (ignore, key)
  1512. -     int ignore, key;
  1513. -{
  1514. -  switch (key)
  1515. -    {
  1516. -    case 'n':
  1517. -      rl_vi_dosearch (vi_last_search, -1);
  1518. -      break;
  1519. -
  1520. -    case 'N':
  1521. -      rl_vi_dosearch (vi_last_search, 1);
  1522. -      break;
  1523. -    }
  1524. -}
  1525. -
  1526. -/* Do a vi style search. */
  1527. -rl_vi_search (count, key)
  1528. -     int count, key;
  1529. -{
  1530. -  int dir, c, save_pos;
  1531. -  char *p;
  1532. -
  1533. -  switch (key)
  1534. -    {
  1535. -    case '?':
  1536. -      dir = 1;
  1537. -      break;
  1538. -
  1539. -    case '/':
  1540. -      dir = -1;
  1541. -      break;
  1542. -
  1543. -    default:
  1544. -      ding ();
  1545. -      return;
  1546. -    }
  1547. -
  1548. -  vi_histpos = where_history ();
  1549. -  maybe_save_line ();
  1550. -  save_pos = rl_point;
  1551. -
  1552. -  /* Reuse the line input buffer to read the search string. */
  1553. -  the_line[0] = 0;
  1554. -  rl_end = rl_point = 0;
  1555. -  p = (char *)alloca (2 + (rl_prompt ? strlen (rl_prompt) : 0));
  1556. -
  1557. -  sprintf (p, "%s%c", rl_prompt ? rl_prompt : "", key);
  1558. -
  1559. -  rl_message (p, 0, 0);
  1560. -
  1561. -  while (c = rl_read_key ())
  1562. -    {
  1563. -      switch (c)
  1564. -    {
  1565. -    case CTRL('H'):
  1566. -    case RUBOUT:
  1567. -      if (rl_point == 0)
  1568. -        {
  1569. -          maybe_unsave_line ();
  1570. -          rl_clear_message ();
  1571. -          rl_point = save_pos;
  1572. -          return;
  1573. -        }
  1574. -
  1575. -    case CTRL('W'):
  1576. -    case CTRL('U'):
  1577. -      rl_dispatch (c, keymap);
  1578. -      break;
  1579. -
  1580. -    case ESC:
  1581. -    case RETURN:
  1582. -    case NEWLINE:
  1583. -      goto dosearch;
  1584. -      break;
  1585. -
  1586. -    case CTRL('C'):
  1587. -      maybe_unsave_line ();
  1588. -      rl_clear_message ();
  1589. -      rl_point = 0;
  1590. -      ding ();
  1591. -      return;
  1592. -
  1593. -    default:
  1594. -      rl_insert (1, c);
  1595. -      break;
  1596. -    }
  1597. -      rl_redisplay ();
  1598. -    }
  1599. - dosearch:
  1600. -  if (vi_last_search)
  1601. -    free (vi_last_search);
  1602. -
  1603. -  vi_last_search = savestring (the_line);
  1604. -  rl_vi_dosearch (the_line, dir);
  1605. -}
  1606. -
  1607. -rl_vi_dosearch (string, dir)
  1608. -     char *string;
  1609. -     int dir;
  1610. -{
  1611. -#ifdef 0
  1612. -  int old, save = vi_histpos;
  1613. -  HIST_ENTRY *h;
  1614. -
  1615. -  if (string == 0 || *string == 0 || vi_histpos < 0)
  1616. -    {
  1617. -      ding ();
  1618. -      return;
  1619. -    }
  1620. -
  1621. -  if ((save = history_search_pos (string, dir, vi_histpos + dir)) == -1)
  1622. -    {
  1623. -      maybe_unsave_line ();
  1624. -      rl_clear_message ();
  1625. -      rl_point = 0;
  1626. -      ding ();
  1627. -      return;
  1628. -    }
  1629. -
  1630. -  vi_histpos = save;
  1631. -
  1632. -  old = where_history ();
  1633. -  history_set_pos (vi_histpos);
  1634. -  h = current_history ();
  1635. -  history_set_pos (old);
  1636. -
  1637. -  strcpy (the_line, h->line);
  1638. -  rl_undo_list = (UNDO_LIST *)h->data;
  1639. -  rl_end = strlen (the_line);
  1640. -  rl_point = 0;
  1641. -  rl_clear_message ();
  1642. -#endif
  1643. -}
  1644. -
  1645. -/* Completion, from vi's point of view. */
  1646. -rl_vi_complete (ignore, key)
  1647. -     int ignore, key;
  1648. -{
  1649. -  if (!whitespace (the_line[rl_point]))
  1650. -    {
  1651. -      if (!whitespace (the_line[rl_point + 1]))
  1652. -    rl_vi_end_word (1, 'E');
  1653. -      rl_point++;
  1654. -    }
  1655. -
  1656. -  if (key == '*')
  1657. -    rl_complete_internal ('*');
  1658. -  else
  1659. -    rl_complete (0, key);
  1660. -
  1661. -  rl_vi_insertion_mode ();
  1662. -}
  1663. -
  1664. -/* Previous word in vi mode. */
  1665. -rl_vi_prev_word (count, key)
  1666. -     int count, key;
  1667. -{
  1668. -  if (count < 0)
  1669. -    {
  1670. -      rl_vi_next_word (-count, key);
  1671. -      return;
  1672. -    }
  1673. -
  1674. -  if (uppercase_p (key))
  1675. -    rl_vi_bWord (count);
  1676. -  else
  1677. -    rl_vi_bword (count);
  1678. -}
  1679. -
  1680. -/* Next word in vi mode. */
  1681. -rl_vi_next_word (count, key)
  1682. -     int count;
  1683. -{
  1684. -  if (count < 0)
  1685. -    {
  1686. -      rl_vi_prev_word (-count, key);
  1687. -      return;
  1688. -    }
  1689. -
  1690. -  if (uppercase_p (key))
  1691. -    rl_vi_fWord (count);
  1692. -  else
  1693. -    rl_vi_fword (count);
  1694. -}
  1695. -
  1696. -/* Move to the end of the ?next? word. */
  1697. -rl_vi_end_word (count, key)
  1698. -     int count, key;
  1699. -{
  1700. -  if (count < 0)
  1701. -    {
  1702. -      ding ();
  1703. -      return;
  1704. -    }
  1705. -
  1706. -  if (uppercase_p (key))
  1707. -    rl_vi_eWord (count);
  1708. -  else
  1709. -    rl_vi_eword (count);
  1710. -}
  1711. -
  1712. -/* Move forward a word the way that 'W' does. */
  1713. -rl_vi_fWord (count)
  1714. -     int count;
  1715. -{
  1716. -  while (count-- && rl_point < (rl_end - 1))
  1717. -    {
  1718. -      /* Skip until whitespace. */
  1719. -      while (!whitespace (the_line[rl_point]) && rl_point < rl_end)
  1720. -    rl_point++;
  1721. -
  1722. -      /* Now skip whitespace. */
  1723. -      while (whitespace (the_line[rl_point]) && rl_point < rl_end)
  1724. -    rl_point++;
  1725. -    }
  1726. -}
  1727. -
  1728. -rl_vi_bWord (count)
  1729. -     int count;
  1730. -{
  1731. -  while (count-- && rl_point > 0)
  1732. -    {
  1733. -      while (rl_point-- >= 0 && whitespace (the_line[rl_point]));
  1734. -      while (rl_point >= 0 && !whitespace (the_line[rl_point]))
  1735. -    rl_point--;
  1736. -      rl_point++;
  1737. -    }
  1738. -}
  1739. -
  1740. -rl_vi_eWord (count)
  1741. -     int count;
  1742. -{
  1743. -  while (count -- && rl_point < (rl_end - 1))
  1744. -    {
  1745. -      while (rl_point++ < rl_end && whitespace (the_line[rl_point]));
  1746. -      while (rl_point++ < rl_end && !whitespace (the_line[rl_point]));
  1747. -      rl_point--;
  1748. -    }
  1749. -}
  1750. -
  1751. -rl_vi_fword (count)
  1752. -     int count;
  1753. -{
  1754. -  while (count -- && rl_point < (rl_end - 1))
  1755. -    {
  1756. -      if (isident (the_line[rl_point]))
  1757. -    {
  1758. -      while (isident (the_line[rl_point]) && rl_point < rl_end)
  1759. -        rl_point += 1;
  1760. -    }
  1761. -      else if (!whitespace (the_line[rl_point]))
  1762. -    {
  1763. -      while (!isident (the_line[rl_point]) &&
  1764. -         !whitespace (the_line[rl_point]) && rl_point < rl_end)
  1765. -        rl_point += 1;
  1766. -    }
  1767. -
  1768. -      while (whitespace (the_line[rl_point]) && rl_point < rl_end)
  1769. -    rl_point++;
  1770. -    }
  1771. -}
  1772. -
  1773. -rl_vi_bword (count)
  1774. -     int count;
  1775. -{
  1776. -  while (count -- && rl_point > 0)
  1777. -    {
  1778. -      while (--rl_point > 0 && whitespace (the_line[rl_point]));
  1779. -      if (rl_point > 0)
  1780. -    {
  1781. -      if (isident (the_line[rl_point]))
  1782. -        while (--rl_point >= 0 && isident (the_line[rl_point]));
  1783. -      else
  1784. -        while (--rl_point >= 0 && !isident (the_line[rl_point]) &&
  1785. -           !whitespace (the_line[rl_point]));
  1786. -      rl_point++;
  1787. -    }
  1788. -    }
  1789. -}
  1790. -
  1791. -rl_vi_eword (count)
  1792. -     int count;
  1793. -{
  1794. -  while (count -- && rl_point < rl_end - 1)
  1795. -    {
  1796. -      while (++rl_point < rl_end && whitespace (the_line[rl_point]));
  1797. -
  1798. -      if (rl_point < rl_end)
  1799. -    {
  1800. -      if (isident (the_line[rl_point]))
  1801. -        while (++rl_point < rl_end && isident (the_line[rl_point]));
  1802. -      else
  1803. -        while (++rl_point < rl_end && !isident (the_line[rl_point])
  1804. -           && !whitespace (the_line[rl_point]));
  1805. -      rl_point--;
  1806. -    }
  1807. -    }
  1808. -}
  1809. -
  1810. -rl_vi_insert_beg ()
  1811. -{
  1812. -  rl_beg_of_line ();
  1813. -  rl_vi_insertion_mode ();
  1814. -  return 0;
  1815. -}
  1816. -
  1817. -rl_vi_append_mode ()
  1818. -{
  1819. -  if (rl_point < rl_end)
  1820. -    rl_point += 1;
  1821. -  rl_vi_insertion_mode ();
  1822. -  return 0;
  1823. -}
  1824. -
  1825. -rl_vi_append_eol ()
  1826. -{
  1827. -  rl_end_of_line ();
  1828. -  rl_vi_append_mode ();
  1829. -  return 0;
  1830. -}
  1831. -
  1832. -/* What to do in the case of C-d. */
  1833. -rl_vi_eof_maybe (count, c)
  1834. -     int count, c;
  1835. -{
  1836. -  rl_newline (1, '\n');
  1837. -}
  1838. -
  1839. -/* Insertion mode stuff. */
  1840. -
  1841. -/* Switching from one mode to the other really just involves
  1842. -   switching keymaps. */
  1843. -rl_vi_insertion_mode ()
  1844. -{
  1845. -  keymap = vi_insertion_keymap;
  1846. -}
  1847. -
  1848. -rl_vi_movement_mode ()
  1849. -{
  1850. -  if (rl_point > 0)
  1851. -    rl_backward (1);
  1852. -
  1853. -  keymap = vi_movement_keymap;
  1854. -  vi_done_inserting ();
  1855. -}
  1856. -
  1857. -vi_done_inserting ()
  1858. -{
  1859. -  if (vi_doing_insert)
  1860. -    {
  1861. -      rl_end_undo_group ();
  1862. -      vi_doing_insert = 0;
  1863. -    }
  1864. -}
  1865. -
  1866. -rl_vi_arg_digit (count, c)
  1867. -     int count, c;
  1868. -{
  1869. -  if (c == '0' && rl_numeric_arg == 1 && !rl_explicit_arg)
  1870. -    rl_beg_of_line ();
  1871. -  else
  1872. -    rl_digit_argument (count, c);
  1873. -}
  1874. -
  1875. -/* Doesn't take an arg count in vi */
  1876. -rl_vi_change_case (ignore1, ignore2)
  1877. -     int ignore1, ignore2;
  1878. -{
  1879. -  char c = 0;
  1880. -
  1881. -  if (uppercase_p (the_line[rl_point]))
  1882. -    c = to_lower (the_line[rl_point]);
  1883. -  else if (lowercase_p (the_line[rl_point]))
  1884. -    c = to_upper (the_line[rl_point]);
  1885. -
  1886. -  /* Vi is kind of strange here. */
  1887. -  if (c)
  1888. -    {
  1889. -      rl_begin_undo_group ();
  1890. -      rl_delete (1, c);
  1891. -      rl_insert (1, c);
  1892. -      rl_end_undo_group ();
  1893. -      rl_vi_check ();
  1894. -    }
  1895. -  else
  1896. -    rl_forward (1);
  1897. -}
  1898. -
  1899. -rl_vi_put (count, key)
  1900. -     int count, key;
  1901. -{
  1902. -  if (!uppercase_p (key))
  1903. -    rl_forward (1);
  1904. -
  1905. -  rl_yank ();
  1906. -  rl_backward (1);
  1907. -}
  1908. -
  1909. -rl_vi_check ()
  1910. -{
  1911. -  if (rl_point && rl_point == rl_end)
  1912. -    rl_point--;
  1913. -}
  1914. -
  1915. -rl_vi_column (count)
  1916. -{
  1917. -  if (count > rl_end)
  1918. -    rl_end_of_line ();
  1919. -  else
  1920. -    rl_point = count - 1;
  1921. -}
  1922. -
  1923. -int
  1924. -rl_vi_domove (key, nextkey)
  1925. -     int key, *nextkey;
  1926. -{
  1927. -  int c, save;
  1928. -
  1929. -  rl_mark = rl_point;
  1930. -  c = rl_read_key ();
  1931. -  *nextkey = c;
  1932. -
  1933. -  if (!member (c, vi_motion))
  1934. -    {
  1935. -      if (digit (c))
  1936. -    {
  1937. -      save = rl_numeric_arg;
  1938. -      rl_digit_loop1 ();
  1939. -      rl_numeric_arg *= save;
  1940. -    }
  1941. -      else if ((key == 'd' && c == 'd') ||
  1942. -           (key == 'c' && c == 'c'))
  1943. -    {
  1944. -      rl_mark = rl_end;
  1945. -      rl_beg_of_line ();
  1946. -      return (0);
  1947. -    }
  1948. -      else
  1949. -    return (-1);
  1950. -    }
  1951. -
  1952. -  rl_dispatch (c, keymap);
  1953. -
  1954. -  /* No change in position means the command failed. */
  1955. -  if (rl_mark == rl_point)
  1956. -    return (-1);
  1957. -
  1958. -  if ((c == 'w' || c == 'W') && rl_point < rl_end)
  1959. -    rl_point--;
  1960. -
  1961. -  if (rl_mark < rl_point)
  1962. -    exchange (rl_point, rl_mark);
  1963. -
  1964. -  return (0);
  1965. -}
  1966. -
  1967. -/* A simplified loop for vi. Don't dispatch key at end.
  1968. -   Don't recognize minus sign? */
  1969. -rl_digit_loop1 ()
  1970. -{
  1971. -  int key, c;
  1972. -
  1973. -  while (1)
  1974. -    {
  1975. -      rl_message ("(arg: %d) ", arg_sign * rl_numeric_arg, 0);
  1976. -      key = c = rl_read_key ();
  1977. -
  1978. -      if (keymap[c].type == ISFUNC &&
  1979. -      keymap[c].function == rl_universal_argument)
  1980. -    {
  1981. -      rl_numeric_arg *= 4;
  1982. -      continue;
  1983. -    }
  1984. -      c = UNMETA (c);
  1985. -      if (numeric (c))
  1986. -    {
  1987. -      if (rl_explicit_arg)
  1988. -        rl_numeric_arg = (rl_numeric_arg * 10) + (c - '0');
  1989. -      else
  1990. -        rl_numeric_arg = (c - '0');
  1991. -      rl_explicit_arg = 1;
  1992. -    }
  1993. -      else
  1994. -    {
  1995. -      rl_clear_message ();
  1996. -      rl_stuff_char (key);
  1997. -    }
  1998. -    }
  1999. -}
  2000. -
  2001. -rl_vi_delete_to (count, key)
  2002. -     int count, key;
  2003. -{
  2004. -  int c;
  2005. -
  2006. -  if (uppercase_p (key))
  2007. -    rl_stuff_char ('$');
  2008. -
  2009. -  if (rl_vi_domove (key, &c))
  2010. -    {
  2011. -      ding ();
  2012. -      return;
  2013. -    }
  2014. -
  2015. -  if ((c != '|') && (c != 'h') && rl_mark < rl_end)
  2016. -    rl_mark++;
  2017. -
  2018. -  rl_kill_text (rl_point, rl_mark);
  2019. -}
  2020. -
  2021. -rl_vi_change_to (count, key)
  2022. -     int count, key;
  2023. -{
  2024. -  int c;
  2025. -
  2026. -  if (uppercase_p (key))
  2027. -    rl_stuff_char ('$');
  2028. -
  2029. -  if (rl_vi_domove (key, &c))
  2030. -    {
  2031. -      ding ();
  2032. -      return;
  2033. -    }
  2034. -
  2035. -  if ((c != '|') && (c != 'h') && rl_mark < rl_end)
  2036. -    rl_mark++;
  2037. -
  2038. -  rl_begin_undo_group ();
  2039. -  vi_doing_insert = 1;
  2040. -  rl_kill_text (rl_point, rl_mark);
  2041. -  rl_vi_insertion_mode ();
  2042. -}
  2043. -
  2044. -rl_vi_yank_to (count, key)
  2045. -     int count, key;
  2046. -{
  2047. -  int c, save = rl_point;
  2048. -
  2049. -  if (uppercase_p (key))
  2050. -    rl_stuff_char ('$');
  2051. -
  2052. -  if (rl_vi_domove (key, &c))
  2053. -    {
  2054. -      ding ();
  2055. -      return;
  2056. -    }
  2057. -
  2058. -  rl_begin_undo_group ();
  2059. -  rl_kill_text (rl_point, rl_mark);
  2060. -  rl_end_undo_group ();
  2061. -  rl_do_undo ();
  2062. -  rl_point = save;
  2063. -}
  2064. -
  2065. -rl_vi_delete (count)
  2066. -{
  2067. -  if (rl_point >= rl_end - 1)
  2068. -    {
  2069. -      rl_delete (count, 0);
  2070. -      if (rl_point > 0)
  2071. -    rl_backward (1);
  2072. -    }
  2073. -  else
  2074. -    rl_delete (count, 0);
  2075. -}
  2076. -
  2077. -/* Turn the current line into a comment in shell history.  A ksh function */
  2078. -rl_vi_comment ()
  2079. -{
  2080. -  rl_beg_of_line ();
  2081. -  rl_insert_text (": ");    /* # doesn't work in interactive mode */
  2082. -  rl_redisplay ();
  2083. -  rl_newline (1, '\010');
  2084. -}
  2085. -
  2086. -rl_vi_first_print ()
  2087. -{
  2088. -  rl_back_to_indent ();
  2089. -}
  2090. -
  2091. -rl_back_to_indent (ignore1, ignore2)
  2092. -     int ignore1, ignore2;
  2093. -{
  2094. -  rl_beg_of_line ();
  2095. -  while (rl_point < rl_end && whitespace (the_line[rl_point]))
  2096. -    rl_point++;
  2097. -}
  2098. -
  2099. -/* NOTE: it is necessary that opposite directions are inverses */
  2100. -#define    FTO     1        /* forward to */
  2101. -#define BTO    -1        /* backward to */
  2102. -#define FFIND     2        /* forward find */
  2103. -#define BFIND    -2        /* backward find */
  2104. -
  2105. -rl_vi_char_search (count, key)
  2106. -     int count, key;
  2107. -{
  2108. -  static char target;
  2109. -  static int orig_dir, dir;
  2110. -  int pos;
  2111. -
  2112. -  if (key == ';' || key == ',')
  2113. -    dir = (key == ';' ? orig_dir : -orig_dir);
  2114. -  else
  2115. -    {
  2116. -      target = rl_getc (in_stream);
  2117. -
  2118. -      switch (key)
  2119. -    {
  2120. -    case 't':
  2121. -      orig_dir = dir = FTO;
  2122. -      break;
  2123. -
  2124. -    case 'T':
  2125. -      orig_dir = dir = BTO;
  2126. -      break;
  2127. -
  2128. -    case 'f':
  2129. -      orig_dir = dir = FFIND;
  2130. -      break;
  2131. -
  2132. -    case 'F':
  2133. -      orig_dir = dir = BFIND;
  2134. -      break;
  2135. -    }
  2136. -    }
  2137. -
  2138. -  pos = rl_point;
  2139. -
  2140. -  if (dir < 0)
  2141. -    {
  2142. -      pos--;
  2143. -      do
  2144. -    {
  2145. -      if (the_line[pos] == target)
  2146. -        {
  2147. -          if (dir == BTO)
  2148. -        rl_point = pos + 1;
  2149. -          else
  2150. -        rl_point = pos;
  2151. -          return;
  2152. -        }
  2153. -    }
  2154. -      while (pos--);
  2155. -
  2156. -      if (pos < 0)
  2157. -    {
  2158. -      ding ();
  2159. -      return;
  2160. -    }
  2161. -    }
  2162. -  else
  2163. -    {            /* dir > 0 */
  2164. -      pos++;
  2165. -      do
  2166. -    {
  2167. -      if (the_line[pos] == target)
  2168. -        {
  2169. -          if (dir == FTO)
  2170. -        rl_point = pos - 1;
  2171. -          else
  2172. -        rl_point = pos;
  2173. -          return;
  2174. -        }
  2175. -    }
  2176. -      while (++pos < rl_end);
  2177. -
  2178. -      if (pos >= (rl_end - 1))
  2179. -    ding ();
  2180. -    }
  2181. -}
  2182. -
  2183. -/* Match brackets */
  2184. -rl_vi_match ()
  2185. -{
  2186. -  int count = 1, brack, pos;
  2187. -
  2188. -  pos = rl_point;
  2189. -  if ((brack = rl_vi_bracktype (the_line[rl_point])) == 0)
  2190. -    {
  2191. -      while ((brack = rl_vi_bracktype (the_line[rl_point])) == 0 &&
  2192. -         rl_point < rl_end - 1)
  2193. -    rl_forward (1);
  2194. -
  2195. -      if (brack <= 0)
  2196. -    {
  2197. -      rl_point = pos;
  2198. -      ding ();
  2199. -      return;
  2200. -    }
  2201. -    }
  2202. -
  2203. -  pos = rl_point;
  2204. -
  2205. -  if (brack < 0)
  2206. -    {
  2207. -      while (count)
  2208. -    {
  2209. -      if (--pos >= 0)
  2210. -        {
  2211. -          int b = rl_vi_bracktype (the_line[pos]);
  2212. -          if (b == -brack)
  2213. -        count--;
  2214. -          else if (b == brack)
  2215. -        count++;
  2216. -        }
  2217. -      else
  2218. -        {
  2219. -          ding ();
  2220. -          return;
  2221. -        }
  2222. -    }
  2223. -    }
  2224. -  else
  2225. -    {            /* brack > 0 */
  2226. -      while (count)
  2227. -    {
  2228. -      if (++pos < rl_end)
  2229. -        {
  2230. -          int b = rl_vi_bracktype (the_line[pos]);
  2231. -          if (b == -brack)
  2232. -        count--;
  2233. -          else if (b == brack)
  2234. -        count++;
  2235. -        }
  2236. -      else
  2237. -        {
  2238. -          ding ();
  2239. -          return;
  2240. -        }
  2241. -    }
  2242. -    }
  2243. -  rl_point = pos;
  2244. -}
  2245. -
  2246. -int
  2247. -rl_vi_bracktype (c)
  2248. -     int c;
  2249. -{
  2250. -  switch (c)
  2251. -    {
  2252. -    case '(': return  1;
  2253. -    case ')': return -1;
  2254. -    case '[': return  2;
  2255. -    case ']': return -2;
  2256. -    case '{': return  3;
  2257. -    case '}': return -3;
  2258. -    default:  return  0;
  2259. -    }
  2260. -}
  2261. -
  2262. -rl_vi_change_char ()
  2263. -{
  2264. -  int c;
  2265. -
  2266. -  c = rl_getc (in_stream);
  2267. -
  2268. -  switch (c)
  2269. -    {
  2270. -    case '\033':
  2271. -    case CTRL('C'):
  2272. -      return;
  2273. -
  2274. -    default:
  2275. -      rl_begin_undo_group ();
  2276. -      rl_delete (1, c);
  2277. -      rl_insert (1, c);
  2278. -      rl_end_undo_group ();
  2279. -      break;
  2280. -    }
  2281. -}
  2282. -
  2283. -rl_vi_subst (count, key)
  2284. -     int count, key;
  2285. -{
  2286. -  rl_begin_undo_group ();
  2287. -  vi_doing_insert = 1;
  2288. -
  2289. -  if (uppercase_p (key))
  2290. -    {
  2291. -      rl_beg_of_line ();
  2292. -      rl_kill_line (1);
  2293. -    }
  2294. -  else
  2295. -    rl_delete (1, key);
  2296. -
  2297. -  rl_vi_insertion_mode ();
  2298. -}
  2299. -
  2300. -rl_vi_overstrike (count, key)
  2301. -     int count, key;
  2302. -{
  2303. -  int i;
  2304. -
  2305. -  if (vi_doing_insert == 0)
  2306. -    {
  2307. -      vi_doing_insert = 1;
  2308. -      rl_begin_undo_group ();
  2309. -    }
  2310. -
  2311. -  for (i = 0; i < count; i++)
  2312. -    {
  2313. -      vi_replace_count++;
  2314. -      rl_begin_undo_group ();
  2315. -
  2316. -      if (rl_point < rl_end)
  2317. -    {
  2318. -      rl_delete (1, key);
  2319. -      rl_insert (1, key);
  2320. -    }
  2321. -      else
  2322. -    rl_insert (1, key);
  2323. -
  2324. -      rl_end_undo_group ();
  2325. -    }
  2326. -}
  2327. -
  2328. -rl_vi_overstrike_delete (count)
  2329. -     int count;
  2330. -{
  2331. -  int i, s;
  2332. -
  2333. -  for (i = 0; i < count; i++)
  2334. -    {
  2335. -      if (vi_replace_count == 0)
  2336. -    {
  2337. -      ding ();
  2338. -      break;
  2339. -    }
  2340. -      s = rl_point;
  2341. -
  2342. -      if (rl_do_undo ())
  2343. -    vi_replace_count--;
  2344. -
  2345. -      if (rl_point == s)
  2346. -    rl_backward (1);
  2347. -    }
  2348. -
  2349. -  if (vi_replace_count == 0 && vi_doing_insert)
  2350. -    {
  2351. -      rl_end_undo_group ();
  2352. -      rl_do_undo ();
  2353. -      vi_doing_insert = 0;
  2354. -    }
  2355. -}
  2356. -
  2357. -rl_vi_replace ()
  2358. -{
  2359. -  int i;
  2360. -
  2361. -  vi_replace_count = 0;
  2362. -
  2363. -  vi_replace_map = rl_make_bare_keymap ();
  2364. -
  2365. -  for (i = ' '; i < 127; i++)
  2366. -    vi_replace_map[i].function = rl_vi_overstrike;
  2367. -
  2368. -  vi_replace_map[RUBOUT].function = rl_vi_overstrike_delete;
  2369. -  vi_replace_map[ESC].function = rl_vi_movement_mode;
  2370. -  vi_replace_map[RETURN].function = rl_newline;
  2371. -  vi_replace_map[NEWLINE].function = rl_newline;
  2372. -  keymap = vi_replace_map;
  2373. -}
  2374. -
  2375. -/*
  2376. - * Try to complete the word we are standing on or the word that ends with
  2377. - * the previous character. A space matches everything.
  2378. - * Word delimiters are space and ;.
  2379. - */
  2380. -rl_vi_possible_completions()
  2381. -{
  2382. -  int save_pos = rl_point;
  2383. -
  2384. -  if (!index (" ;", the_line[rl_point]))
  2385. -    {
  2386. -      while (!index(" ;", the_line[++rl_point]))
  2387. -    ;
  2388. -    }
  2389. -  else if (the_line[rl_point-1] == ';')
  2390. -    {
  2391. -      ding ();
  2392. -      return (0);
  2393. -    }
  2394. -
  2395. -  rl_possible_completions ();
  2396. -  rl_point = save_pos;
  2397. -
  2398. -  return (0);
  2399. -}
  2400. End of readline/vi_mode.c
  2401. echo readline/Makefile 1>&2
  2402. sed 's/^-//' >readline/Makefile <<'End of readline/Makefile'
  2403. -## -*- text -*- ####################################################
  2404. -#                                   #
  2405. -# Makefile for readline and history libraries.               #
  2406. -#                                   #
  2407. -####################################################################
  2408. -
  2409. -# Here is a rule for making .o files from .c files that doesn't force
  2410. -# the type of the machine (like -sun3) into the flags.
  2411. -.c.o:
  2412. -    $(CC) -c $(CFLAGS) $(LOCAL_INCLUDES) $(CPPFLAGS) $*.c
  2413. -
  2414. -# Destination installation directory.  The libraries are copied to DESTDIR
  2415. -# when you do a `make install', and the header files to INCDIR/readline/*.h.
  2416. -DESTDIR = /usr/gnu/lib
  2417. -INCDIR = /usr/gnu/include
  2418. -
  2419. -# Define TYPES as -DVOID_SIGHANDLER if your operating system uses
  2420. -# a return type of "void" for signal handlers.
  2421. -TYPES = -DVOID_SIGHANDLER
  2422. -
  2423. -# Define SYSV as -DSYSV if you are using a System V operating system.
  2424. -#SYSV = -DSYSV
  2425. -
  2426. -# HP-UX compilation requires the BSD library.
  2427. -#LOCAL_LIBS = -lBSD
  2428. -
  2429. -# Xenix compilation requires -ldir -lx
  2430. -#LOCAL_LIBS = -ldir -lx
  2431. -
  2432. -# Comment this out if you don't think that anyone will ever desire
  2433. -# the vi line editing mode and features.
  2434. -READLINE_DEFINES = -DVI_MODE
  2435. -
  2436. -DEBUG_FLAGS = 
  2437. -LDFLAGS = $(DEBUG_FLAGS) 
  2438. -CFLAGS = $(DEBUG_FLAGS) $(TYPE) $(SYSV) -I.
  2439. -
  2440. -# A good alternative is gcc -traditional.
  2441. -CC = gcc -traditional
  2442. -RANLIB = /usr/bin/ranlib
  2443. -AR = ar
  2444. -RM = rm
  2445. -CP = cp
  2446. -
  2447. -LOCAL_INCLUDES = -I../
  2448. -
  2449. -CSOURCES = readline.c history.c funmap.c keymaps.c vi_mode.c \
  2450. -       emacs_keymap.c vi_keymap.c keymaps.c
  2451. -
  2452. -HSOURCES = readline.h chardefs.h history.h keymaps.h
  2453. -SOURCES  = $(CSOURCES) $(HSOURCES)
  2454. -
  2455. -DOCUMENTATION = readline.texinfo inc-readline.texinfo \
  2456. -        history.texinfo inc-history.texinfo
  2457. -
  2458. -SUPPORT = COPYING Makefile $(DOCUMENTATION) ChangeLog
  2459. -
  2460. -THINGS_TO_TAR = $(SOURCES) $(SUPPORT)
  2461. -
  2462. -##########################################################################
  2463. -
  2464. -all: readline.o funmap.o keymaps.o
  2465. -# all: libreadline.a
  2466. -
  2467. -libreadline.a:    readline.o history.o funmap.o keymaps.o
  2468. -        $(RM) -f libreadline.a
  2469. -        $(AR) clq libreadline.a readline.o history.o funmap.o keymaps.o
  2470. -        -if [ -f $(RANLIB) ]; then $(RANLIB) libreadline.a; fi
  2471. -
  2472. -readline.o:    readline.h chardefs.h  keymaps.h history.h readline.c vi_mode.c
  2473. -    $(CC) -c $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \
  2474. -        $(LOCAL_INCLUDES) $*.c
  2475. -
  2476. -history.o:    history.c history.h
  2477. -    $(CC) -c $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \
  2478. -        $(LOCAL_INCLUDES) $*.c
  2479. -
  2480. -funmap.o:    readline.h
  2481. -    $(CC) -c $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \
  2482. -        $(LOCAL_INCLUDES) $*.c
  2483. -
  2484. -keymaps.o:    emacs_keymap.c vi_keymap.c keymaps.h chardefs.h keymaps.c
  2485. -    $(CC) -c $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \
  2486. -         $(LOCAL_INCLUDES) $*.c
  2487. -
  2488. -libtest:    libreadline.a libtest.c
  2489. -        $(CC) -o libtest $(CFLAGS) $(CPPFLAGS) -L. libtest.c -lreadline -ltermcap
  2490. -
  2491. -readline: readline.c history.o keymaps.o funmap.o readline.h chardefs.h
  2492. -    $(CC) $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \
  2493. -        $(LOCAL_INCLUDES) -DTEST -o readline readline.c funmap.o \
  2494. -         keymaps.o history.o -L. -ltermcap
  2495. -
  2496. -readline.tar:    $(THINGS_TO_TAR)
  2497. -        tar -cf readline.tar $(THINGS_TO_TAR)
  2498. -
  2499. -readline.tar.Z:    readline.tar
  2500. -        compress -f readline.tar
  2501. -
  2502. -install:    $(DESTDIR)/libreadline.a includes
  2503. -
  2504. -includes:
  2505. -        if [ ! -r $(INCDIR)/readline ]; then\
  2506. -         mkdir $(INCDIR)/readline;\
  2507. -         chmod a+r $(INCDIR)/readline;\
  2508. -        fi
  2509. -        $(CP) readline.h keymaps.h chardefs.h $(INCDIR)/readline/
  2510. -clean:
  2511. -        rm -f *.o *.a *.log *.cp *.tp *.vr *.fn *.aux *.pg *.toc
  2512. -
  2513. -$(DESTDIR)/libreadline.a: libreadline.a
  2514. -        -mv $(DESTDIR)/libreadline.a $(DESTDIR)/libreadline.old
  2515. -        cp libreadline.a $(DESTDIR)/libreadline.a
  2516. -        $(RANLIB) -t $(DESTDIR)/libreadline.a
  2517. End of readline/Makefile
  2518. echo zsh.h 1>&2
  2519. sed 's/^-//' >zsh.h <<'End of zsh.h'
  2520. -/*
  2521. -
  2522. -    zsh.h - the header file, basically
  2523. -
  2524. -    This file is part of zsh, the Z shell.
  2525. -
  2526. -   zsh is free software; no one can prevent you from reading the source
  2527. -   code, or giving it to someone else.
  2528. -   This file is copyrighted under the GNU General Public License, which
  2529. -   can be found in the file called COPYING.
  2530. -
  2531. -   Copyright (C) 1990 Paul Falstad
  2532. -
  2533. -   zsh is distributed in the hope that it will be useful, but
  2534. -   WITHOUT ANY WARRANTY.  No author or distributor accepts
  2535. -   responsibility to anyone for the consequences of using it or for
  2536. -   whether it serves any particular purpose or works at all, unless he
  2537. -   says so in writing.  Refer to the GNU General Public License
  2538. -   for full details.
  2539. -
  2540. -   Everyone is granted permission to copy, modify and redistribute
  2541. -   zsh, but only under the conditions described in the GNU General Public
  2542. -   License.   A copy of this license is supposed to have been given to you
  2543. -   along with zsh so you can know your rights and responsibilities.
  2544. -   It should be in a file named COPYING.
  2545. -
  2546. -   Among other things, the copyright notice and this notice must be
  2547. -   preserved on all copies.
  2548. -
  2549. -*/
  2550. -
  2551. -#include "config.h"
  2552. -#include <stdio.h>
  2553. -#include <string.h>
  2554. -#include <ctype.h>
  2555. -#include <sys/types.h>
  2556. -#include <sys/wait.h>
  2557. -#include <sys/time.h>
  2558. -#include <sys/resource.h>
  2559. -#include <sys/file.h>
  2560. -#include <signal.h>
  2561. -#ifdef TERMIOS
  2562. -#include <sys/termios.h>
  2563. -#else
  2564. -#include <sgtty.h>
  2565. -#endif
  2566. -#include <sys/param.h>
  2567. -#include <sys/stat.h>
  2568. -
  2569. -#define VERSIONSTR "zsh v1.0"
  2570. -
  2571. -#define FOREVER for(;;)
  2572. -
  2573. -/* size of job table */
  2574. -
  2575. -#define MAXJOB 16
  2576. -
  2577. -void *realloc(void *,int),*malloc(int),*calloc(int,int);
  2578. -
  2579. -char *getenv(char *);
  2580. -
  2581. -/* the tokens */
  2582. -
  2583. -enum xfubar {
  2584. -    HQUOT = -127,    /* quote char used for history */
  2585. -    ALPOP,            /* marker, causes parser to pop alias stack */
  2586. -    HERR,                /* history error indicator */
  2587. -    Pound,            /* # */
  2588. -    String,            /* $ */
  2589. -    Hat,                /* ^ */
  2590. -    Star,                /* * */
  2591. -    Inpar,            /* ( */
  2592. -    Outpar,            /* ) */
  2593. -    Qstring,            /* $, in quotes */
  2594. -    Equals,            /* = (initial) */
  2595. -    Bar,                /* |, except when used as a pipe char */
  2596. -    Inbrace,            /* {, except when used for current shells */
  2597. -    Outbrace,        /* }, except when used for current shells */
  2598. -    Inbrack,            /* [ */
  2599. -    Outbrack,        /* ] */
  2600. -    Tick,                /* ` */
  2601. -    Inang,            /* <, except when used for redirection */
  2602. -    Outang,            /* >, except when used for redirection */
  2603. -    Quest,            /* ? */
  2604. -    Tilde,            /* ~ (initial) */
  2605. -    Qtick,            /* `, in quotes */
  2606. -    Comma,            /* , */
  2607. -    Nularg            /* marker, keeps explicit null arguments around,
  2608. -                            does some other stuff */
  2609. -    };
  2610. -
  2611. -/* HQUOT separately defined in readline.c */
  2612. -
  2613. -/* returns true if X is a token */
  2614. -
  2615. -#define istok(X) (((char) (X)) <= Nularg)
  2616. -
  2617. -/* HQUOT in the form of a string */
  2618. -
  2619. -#define HQUOTS "\x81"
  2620. -
  2621. -/* ALPOP in the form of a string */
  2622. -
  2623. -#define ALPOPS " \x82"
  2624. -
  2625. -extern char **environ;
  2626. -
  2627. -/* list of tokens */
  2628. -
  2629. -extern char *tokens;
  2630. -
  2631. -/* tokens used in peek variable with gettok/matchit */
  2632. -/* do not confuse with above tokens; above tokens appear in strings,
  2633. -    following tokens possible values of 'peek' variable */
  2634. -
  2635. -enum xpeek {
  2636. -    EMPTY,            /* nothing gotten yet */
  2637. -    SEMI,                /* ; */
  2638. -    DSEMI,            /* ;; */
  2639. -    AMPER,            /* & */
  2640. -    DAMPER,            /* && */
  2641. -    NEWLIN,            /* \n */
  2642. -    INPAR,            /* ( */
  2643. -    INBRACE,            /* { */
  2644. -    OUTPAR,            /* ) */
  2645. -    OUTBRACE,        /* } */
  2646. -    OUTANG,            /* > */
  2647. -    OUTANGBANG,        /* >! */
  2648. -    DOUTANG,            /* >> */
  2649. -    DOUTANGBANG,    /* >>! */
  2650. -    INANG,            /* < */
  2651. -    DINANG,            /* << */
  2652. -    INANGAMP,        /* <& */
  2653. -    OUTANGAMP,        /* >& */
  2654. -    OUTANGAMPBANG,    /* >&! */
  2655. -    DOUTANGAMP,        /* >>& */
  2656. -    DOUTANGAMPBANG,    /* >>&! */
  2657. -    BAR,                /* | */
  2658. -    DBAR,                /* || */
  2659. -    BARAMP,            /* |& */
  2660. -    BANG,                /* ! */
  2661. -    STRING,            /* string of chars and tokens */
  2662. -    ENVSTRING,        /* string of chars and tokens with a = in it */
  2663. -                        /* the below are all reserved words */
  2664. -    DO,
  2665. -    DONE,
  2666. -    ESAC,
  2667. -    THEN,
  2668. -    ELIF,
  2669. -    ELSE,
  2670. -    FI,
  2671. -    FOR,
  2672. -    CASE,
  2673. -    IF,
  2674. -    WHILE,
  2675. -    FUNC,
  2676. -    REPEAT,
  2677. -    TIME,
  2678. -    UNTIL,
  2679. -    EXEC,
  2680. -    COMMAND,
  2681. -    SELECT,
  2682. -    COPROC
  2683. -    };
  2684. -
  2685. -/* linked list data type */
  2686. -
  2687. -typedef struct xlist *table;
  2688. -typedef struct xnode *Node;
  2689. -struct xnode {
  2690. -   Node next,last;
  2691. -   void *dat;
  2692. -   };
  2693. -struct xlist {
  2694. -   Node first,last;
  2695. -   };
  2696. -
  2697. -
  2698. -typedef struct pnode *pline;
  2699. -typedef struct lnode *list;
  2700. -typedef struct l2node *list2;
  2701. -typedef struct cnode *comm;
  2702. -typedef struct jobnode *job;
  2703. -
  2704. -/* tree element for lists */
  2705. -
  2706. -struct lnode {
  2707. -   struct l2node *left;
  2708. -   struct lnode *right;
  2709. -   int type;
  2710. -   };
  2711. -
  2712. -enum ltype {
  2713. -   SYNC,        /* ; */
  2714. -    ASYNC        /* & */
  2715. -   };
  2716. -
  2717. -/* tree element for sublists */
  2718. -
  2719. -struct l2node {
  2720. -    struct pnode *left;
  2721. -    struct l2node *right;
  2722. -    int type;
  2723. -    int flags; /* one of PFLAGS below; applies to pnode *left */
  2724. -    };
  2725. -
  2726. -enum l2type {
  2727. -    ORNEXT = 10,    /* || */
  2728. -    ANDNEXT            /* && */
  2729. -    };
  2730. -
  2731. -#define PFLAG_TIMED 4        /* time ... */
  2732. -#define PFLAG_NOT 1            /* ! ... */
  2733. -#define PFLAG_COPROC 32        /* coproc ... */
  2734. -
  2735. -/* tree element for pipes */
  2736. -
  2737. -struct pnode {
  2738. -   struct cnode *left;
  2739. -   struct pnode *right;
  2740. -   int type;
  2741. -   };
  2742. -
  2743. -enum ptype {
  2744. -   END,        /* pnode *right is null */
  2745. -    PIPE        /* pnode *right is the rest of the pipeline */
  2746. -   };
  2747. -
  2748. -/* tree element for commands */
  2749. -
  2750. -struct cnode {
  2751. -   struct lnode *left;    /* for SUBSH/CURSH/SHFUNC */
  2752. -   char *cmd;                /* command name */
  2753. -   table args;                /* argmument list (char *'s) */
  2754. -   table redir;            /* i/o redirections (struct fnode *'s) */
  2755. -    table vars;                /* parameter list (char *'s), can be null;
  2756. -                                    two entries in table for each parameter
  2757. -                                    assignment; "name" and "value" */
  2758. -   int type;
  2759. -    int flags;
  2760. -    void *info;                /* pointer to appropriate control structure,
  2761. -                                    if this is a CFOR, CWHILE, etc. */
  2762. -   };
  2763. -
  2764. -enum ctype {
  2765. -    SIMPLE,        /* simple command */
  2766. -    SUBSH,        /* ( left ) */
  2767. -    CURSH,        /* { left } */
  2768. -    SHFUNC,        /* converted to { left } in execcomm */
  2769. -    CFOR,
  2770. -    CWHILE,
  2771. -    CREPEAT,
  2772. -    CIF,
  2773. -    CCASE,
  2774. -    CSELECT
  2775. -    };
  2776. -#define CFLAG_EXEC 1            /* exec ... */
  2777. -#define CFLAG_COMMAND 2        /* command ... */
  2778. -
  2779. -struct fnode {
  2780. -    union {
  2781. -        char *name;        /* source/dest filename */
  2782. -        int fd2;            /* source/dest file descriptor */
  2783. -        } u;
  2784. -   int type;
  2785. -    int fd1;                /* affected file descriptor */
  2786. -   };
  2787. -
  2788. -enum ftype {
  2789. -    WRITE,            /* #> name */
  2790. -    WRITENOW,        /* #>! name */
  2791. -    APP,                /* #>> name */
  2792. -    APPNOW,            /* #>>! name */
  2793. -    READ,                /* #< name */
  2794. -    HEREDOC,            /* #<< fd2 */
  2795. -    MERGE,            /* #<& fd2 */
  2796. -    MERGEOUT,        /* #>& fd2 */
  2797. -    CLOSE,            /* #>&-, #<&- */
  2798. -    INPIPE,            /* #< name, where name is <(...) */
  2799. -    OUTPIPE,            /* #> name, where name is >(...)  */
  2800. -    NONE
  2801. -    };
  2802. -
  2803. -struct fornode {        /* for/select */
  2804. -    char *name;            /* parameter to assign values to */
  2805. -    list list;            /* list of names to loop through */
  2806. -    int inflag;            /* != 0 if 'in ...' was specified */
  2807. -    };
  2808. -struct casenode {        /* arg list of cnode struct contains word to test */
  2809. -    struct casenode *next;    /* next pattern */
  2810. -    char *pat;
  2811. -    list list;            /* list to execute */
  2812. -    };
  2813. -struct ifnode {
  2814. -    struct ifnode *next;
  2815. -    list ifl;        /* if/elif test list (can be null in case of else) */
  2816. -    list thenl;        /* then list */
  2817. -    };
  2818. -struct whilenode {
  2819. -    list cont;        /* condition */
  2820. -    list loop;        /* list to execute until condition met */
  2821. -    int cond;        /* 0 for while, 1 for until */
  2822. -    };
  2823. -struct repeatnode {
  2824. -    int count;        /* # of iterations */
  2825. -    list list;
  2826. -    };
  2827. -
  2828. -
  2829. -/* structure used for multiple i/o redirection */
  2830. -/* one for each fd open */
  2831. -
  2832. -struct mnode {
  2833. -    int ct;                /* # of redirections on this fd */
  2834. -    int rflag;            /* 0 if open for reading, 1 if open for writing */
  2835. -    int pipe;            /* fd of pipe if ct > 1 */
  2836. -    int fds[NOFILE];
  2837. -   }; 
  2838. -
  2839. -/* node used in command hash table */
  2840. -
  2841. -struct chnode 
  2842. -{
  2843. -    int type;
  2844. -    int globstat;        /* status of filename gen for this command */
  2845. -    union {
  2846. -        char *nam;        /* full pathname if type != BUILTIN */
  2847. -        int (*func)();    /* func to exec if type == BUILTIN */
  2848. -        } u;
  2849. -    };
  2850. -
  2851. -enum chtype {
  2852. -    EXCMD_PREDOT,        /* external command in PATH before . */
  2853. -    EXCMD_POSTDOT,        /* external command in PATH after . */
  2854. -    BUILTIN
  2855. -    };
  2856. -
  2857. -/* value for globstat field in chnode
  2858. -
  2859. -    sample command: foo -xyz -pdq bar ble boz */
  2860. -
  2861. -enum globx {
  2862. -    GLOB,            /* all args globbed */
  2863. -    MOSTGLOB,    /* ble, boz globbed */
  2864. -    NOGLOB        /* no args globbed */
  2865. -    };
  2866. -
  2867. -/* node used in parameter hash table */
  2868. -
  2869. -struct pmnode {
  2870. -    union {
  2871. -        char *str;        /* value */
  2872. -        long val;        /* value if declared integer */
  2873. -        } u;
  2874. -    int isint;            /* != 0 if declared integer */
  2875. -    };
  2876. -
  2877. -/* tty state structure */
  2878. -
  2879. -struct ttyinfo {
  2880. -#ifdef TERMIOS
  2881. -    struct termios termios;
  2882. -#else
  2883. -    struct sgttyb sgttyb;
  2884. -    struct tchars tchars;
  2885. -    struct ltchars ltchars;
  2886. -#endif
  2887. -    struct winsize winsize;
  2888. -    };
  2889. -
  2890. -extern struct ttyinfo shttyinfo;
  2891. -
  2892. -/* entry in job table */
  2893. -
  2894. -struct jobnode {
  2895. -    long gleader;                    /* process group leader of this job */
  2896. -    int stat;
  2897. -    char *cwd;                        /* current working dir of shell when
  2898. -                                            this job was spawned */
  2899. -    struct procnode *procs;        /* list of processes */
  2900. -    table filelist;                /* list of files to delete when done */
  2901. -    struct ttyinfo ttyinfo;        /* saved tty state */
  2902. -    };
  2903. -
  2904. -#define STAT_CHANGED 1        /* status changed and not reported */
  2905. -#define STAT_STOPPED 2        /* all procs stopped or exited */
  2906. -#define STAT_TIMED 4            /* job is being timed */
  2907. -#define STAT_DONE 8
  2908. -#define STAT_LOCKED 16        /* shell is finished creating this job,
  2909. -                                        may be deleted from job table */
  2910. -#define STAT_INUSE 64        /* this job entry is in use */
  2911. -
  2912. -#define SP_RUNNING -1        /* fake statusp for running jobs */
  2913. -
  2914. -/* node in job process lists */
  2915. -
  2916. -struct procnode {
  2917. -    struct procnode *next;
  2918. -    long pid;
  2919. -    char *text;                        /* text to print when 'jobs' is run */
  2920. -    int statusp;                    /* return code from wait3() */
  2921. -    int lastfg;                        /* set if this procnode represents a
  2922. -                                            fragment of a pipeline run in a subshell
  2923. -                                            for commands like:
  2924. -
  2925. -                                            foo | bar | ble
  2926. -
  2927. -                                            where foo is a current shell function
  2928. -                                            or control structure.  The command
  2929. -                                            actually executed is:
  2930. -
  2931. -                                            foo | (bar | ble)
  2932. -
  2933. -                                            That's two procnodes in the parent
  2934. -                                            shell, the latter having this flag set. */
  2935. -    struct timeval ru_utime;
  2936. -    struct timeval ru_stime;
  2937. -    time_t bgtime;                    /* time job was spawned */
  2938. -    time_t endtime;                /* time job exited */
  2939. -    };
  2940. -
  2941. -/* node in alias hash table */
  2942. -
  2943. -struct anode {
  2944. -    char *text;            /* expansion of alias */
  2945. -    int cmd;                /* one for regular aliases,
  2946. -                                zero for -a aliases,
  2947. -                                negative for reserved words */
  2948. -    int inuse;            /* alias is being expanded */
  2949. -    };
  2950. -
  2951. -/* node in sched list */
  2952. -
  2953. -struct schnode {
  2954. -    struct schnode *next;
  2955. -    char *cmd;        /* command to run */
  2956. -    time_t time;    /* when to run it */
  2957. -    };
  2958. -
  2959. -#define MAXAL 20    /* maximum number of aliases expanded at once */
  2960. -
  2961. -typedef struct xhtab *htable;
  2962. -
  2963. -/* node in hash table */
  2964. -
  2965. -struct hnode {
  2966. -    struct hnode *hchain;
  2967. -    char *nam;
  2968. -    void *dat;
  2969. -    };
  2970. -
  2971. -/* hash table structure */
  2972. -
  2973. -struct xhtab {
  2974. -    int hsize,ct;
  2975. -    struct hnode **nodes;     /* array of size hsize */
  2976. -    };
  2977. -
  2978. -typedef struct xpath *qath;    /* used in globbing - see glob.c */
  2979. -typedef struct xcomp *comp;    /* "" */
  2980. -
  2981. -extern char *sys_errlist[];
  2982. -extern int errno;
  2983. -
  2984. -#define pushnode(X,Y) insnode(X,(Node) X,Y)
  2985. -
  2986. -#define OPT_INVALID 1    /* opt is invalid, like -$ */
  2987. -#define OPT_UNSET 0
  2988. -#define OPT_SET 2
  2989. -
  2990. -#define CLOBBER '1'
  2991. -#define NOBADPATTERN '2'
  2992. -#define NONOMATCH '3'
  2993. -#define GLOBDOTS '4'
  2994. -#define NOTIFY '5'
  2995. -#define ALLEXPORT 'a'
  2996. -#define ERREXIT 'e'
  2997. -#define BGNICE '6'
  2998. -#define IGNOREEOF '7'
  2999. -#define KEYWORD 'k'
  3000. -#define MARKDIRS '8'
  3001. -#define MONITOR 'm'
  3002. -#define NOEXEC 'n'
  3003. -#define NOGLOBOPT 'F'
  3004. -#define NORCS 'f'
  3005. -#define SHINSTDIN 's'
  3006. -#define NOUNSET 'u'
  3007. -#define VERBOSE 'v'
  3008. -#define XTRACE 'x'
  3009. -#define INTERACTIVE 'i'
  3010. -#define AUTOLIST '9'
  3011. -#define CORRECT '0'
  3012. -#define DEXTRACT 'A'
  3013. -#define NOBEEP 'B'
  3014. -#define PRINTEXITVALUE 'C'
  3015. -#define PUSHDTOHOME 'D'
  3016. -#define PUSHDSILENT 'E'
  3017. -#define NULLGLOB 'G'
  3018. -#define RMSTARSILENT 'H'
  3019. -#define IGNOREBRACES 'I'
  3020. -#define CDABLEVARS 'J'
  3021. -#define NOBANGHIST 'K'
  3022. -
  3023. -#define ALSTAT_MORE 1    /* last alias ended with ' ' */
  3024. -#define ALSTAT_JUNK 2    /* don't put word in history list */
  3025. -
  3026. -#undef isset
  3027. -#define isset(X) (opts[X])
  3028. -#define unset(X) (!opts[X])
  3029. -#define interact (isset(INTERACTIVE))
  3030. -#define jobbing (isset(MONITOR))
  3031. -#define nointr() signal(SIGINT,SIG_IGN)
  3032. -
  3033. -#define SIGCOUNT (SIGUSR2+1)
  3034. -#define SIGERR (SIGUSR2+1)
  3035. -#define SIGDEBUG (SIGUSR2+2)
  3036. -#define SIGEXIT 0
  3037. -
  3038. -#define SP(x) (*((union wait *) &(x)))
  3039. -
  3040. -#ifndef WEXITSTATUS
  3041. -#define    WEXITSTATUS(x)    (((union wait*)&(x))->w_retcode)
  3042. -#define    WTERMSIG(x)    (((union wait*)&(x))->w_termsig)
  3043. -#define    WSTOPSIG(x)    (((union wait*)&(x))->w_stopsig)
  3044. -#endif
  3045. -
  3046. -#ifndef S_ISBLK
  3047. -#define    _IFMT        0170000
  3048. -#define    _IFDIR    0040000
  3049. -#define    _IFCHR    0020000
  3050. -#define    _IFBLK    0060000
  3051. -#define    _IFREG    0100000
  3052. -#define    _IFLNK    0120000
  3053. -#define    _IFSOCK    0140000
  3054. -#define    _IFIFO    0010000
  3055. -#define    S_ISBLK(m)    (((m)&_IFMT) == _IFBLK)
  3056. -#define    S_ISCHR(m)    (((m)&_IFMT) == _IFCHR)
  3057. -#define    S_ISDIR(m)    (((m)&_IFMT) == _IFDIR)
  3058. -#define    S_ISFIFO(m)    (((m)&_IFMT) == _IFIFO)
  3059. -#define    S_ISREG(m)    (((m)&_IFMT) == _IFREG)
  3060. -#define    S_ISLNK(m)    (((m)&_IFMT) == _IFLNK)
  3061. -#define    S_ISSOCK(m)    (((m)&_IFMT) == _IFSOCK)
  3062. -#endif
  3063. -
  3064. -/* buffered shell input for non-interactive shells */
  3065. -
  3066. -extern FILE *bshin;
  3067. -
  3068. -/* null-terminated array of pointers to strings containing elements
  3069. -    of PATH and CDPATH */
  3070. -
  3071. -extern char **path,**cdpath;
  3072. -
  3073. -/* number of elements in aforementioned array */
  3074. -
  3075. -extern int pathct,cdpathct;
  3076. -
  3077. -/* error/break flag */
  3078. -
  3079. -extern int errflag;
  3080. -
  3081. -/* current history event number */
  3082. -
  3083. -extern int cev;
  3084. -
  3085. -/* if != 0, this is the first line of the command */
  3086. -
  3087. -extern int firstln;
  3088. -
  3089. -/* if != 0, this is the first char of the command (not including
  3090. -    white space */
  3091. -
  3092. -extern int firstch;
  3093. -
  3094. -/* first event number in the history table */
  3095. -
  3096. -extern int tfev;
  3097. -
  3098. -/* capacity of history table */
  3099. -
  3100. -extern int tevs;
  3101. -
  3102. -/* if = 1, we have performed history substitution on the current line
  3103. -     if = 2, we have used the 'p' modifier */
  3104. -
  3105. -extern int hflag;
  3106. -
  3107. -/* default event (usually cev-1, that is, "!!") */
  3108. -
  3109. -extern int dev;
  3110. -
  3111. -/* != 0 if we are in the middle of parsing a command (== 0 if we
  3112. -     have not yet parsed the command word */
  3113. -
  3114. -extern int incmd;
  3115. -
  3116. -/* the list of history events */
  3117. -
  3118. -extern table histlist;
  3119. -
  3120. -/* the current history event (can be NULL) */
  3121. -
  3122. -extern table curtab;
  3123. -
  3124. -/* the directory stack */
  3125. -
  3126. -extern table dirstack;
  3127. -
  3128. -/* a string containing all the ungot characters (hungetch()) */
  3129. -
  3130. -extern char *ungots;
  3131. -
  3132. -/* the pointer to the next character to read from ungots */
  3133. -
  3134. -extern char *ungotptr;
  3135. -
  3136. -/* the contents of the IFS parameter */
  3137. -
  3138. -extern char *ifs;
  3139. -
  3140. -/* != 0 if this is a subshell */
  3141. -
  3142. -extern int subsh;
  3143. -
  3144. -/* # of break levels (break builtin) */
  3145. -
  3146. -extern int breaks;
  3147. -
  3148. -/* != 0 if we have a return pending (return builtin) */
  3149. -
  3150. -extern int retflag;
  3151. -
  3152. -/* # of nested loops we are in */
  3153. -
  3154. -extern int loops;
  3155. -
  3156. -/* # of continue levels */
  3157. -
  3158. -extern int contflag;
  3159. -
  3160. -/* the job currently being created/waited for (not current job in the sense
  3161. -     of '+' and '-', that's topjob */
  3162. -
  3163. -extern int curjob;
  3164. -
  3165. -/* the current job (+) */
  3166. -
  3167. -extern int topjob;
  3168. -
  3169. -/* the previous job (-) */
  3170. -
  3171. -extern int prevjob;
  3172. -
  3173. -/* hash table containing the aliases and reserved words */
  3174. -
  3175. -extern htable alhtab;
  3176. -
  3177. -/* hash table containing the parameters */
  3178. -
  3179. -extern htable parmhtab;
  3180. -
  3181. -/* hash table containing the builtins/hashed commands */
  3182. -
  3183. -extern htable chtab;
  3184. -
  3185. -/* hash table containing the shell functions */
  3186. -
  3187. -extern htable shfunchtab;
  3188. -
  3189. -/* the job table */
  3190. -
  3191. -extern struct jobnode jobtab[MAXJOB];
  3192. -
  3193. -/* the list of sched jobs pending */
  3194. -
  3195. -extern struct schnode *scheds;
  3196. -
  3197. -/* the last l for s/l/r/ history substitution */
  3198. -
  3199. -extern char *last;
  3200. -
  3201. -/* the last r for s/l/r/ history substitution */
  3202. -
  3203. -extern char *rast;
  3204. -
  3205. -/* if peek == STRING or ENVSTRING, the next token */
  3206. -
  3207. -extern char *tstr;
  3208. -
  3209. -/* who am i */
  3210. -
  3211. -extern char *username;
  3212. -
  3213. -/* the return code of the last command */
  3214. -
  3215. -extern int lastval;
  3216. -
  3217. -/* != 0 if this is a login shell */
  3218. -
  3219. -extern int islogin;
  3220. -
  3221. -/* the next token (enum xtok) */
  3222. -
  3223. -extern int peek;
  3224. -
  3225. -/* the file descriptor associated with the next token, if it
  3226. -     is something like '<' or '>>', etc. */
  3227. -
  3228. -extern int peekfd;
  3229. -
  3230. -/* input fd from the coprocess */
  3231. -
  3232. -extern int spin;
  3233. -
  3234. -/* output fd from the coprocess */
  3235. -
  3236. -extern int spout;
  3237. -
  3238. -/* the last time we checked mail */
  3239. -
  3240. -extern time_t lastmailcheck;
  3241. -
  3242. -/* the last modified date on the mail file last time we checked */
  3243. -
  3244. -extern time_t lastmailval;
  3245. -
  3246. -/* the last time we checked the people in the WATCH variable */
  3247. -
  3248. -extern time_t lastwatch;
  3249. -
  3250. -/* the last time we did the periodic() shell function */
  3251. -
  3252. -extern time_t lastperiod;
  3253. -
  3254. -/* $SECONDS = time(NULL) - shtimer */
  3255. -
  3256. -extern time_t shtimer;
  3257. -
  3258. -/* the size of the mail file last time we checked */
  3259. -
  3260. -extern off_t lastmailsize;
  3261. -
  3262. -/* $$ */
  3263. -
  3264. -extern long procnum;
  3265. -
  3266. -/* $! (the pid of the last background command invoked */
  3267. -
  3268. -extern long proclast;
  3269. -
  3270. -/* the process group of the shell */
  3271. -
  3272. -extern long shpgrp;
  3273. -
  3274. -/* the current working directory */
  3275. -
  3276. -extern char *cwd;
  3277. -
  3278. -/* the hostname, truncated after the '.' */
  3279. -
  3280. -extern char *hostM;
  3281. -
  3282. -/* the hostname */
  3283. -
  3284. -extern char *hostm;
  3285. -
  3286. -/* the home directory */
  3287. -
  3288. -extern char *home;
  3289. -
  3290. -/* the positional parameters */
  3291. -
  3292. -extern table pparms;
  3293. -
  3294. -/* the list of local variables we have to destroy */
  3295. -
  3296. -extern table locallist;
  3297. -
  3298. -/* the shell input fd */
  3299. -
  3300. -extern int SHIN;
  3301. -
  3302. -/* the shell tty fd */
  3303. -
  3304. -extern int SHTTY;
  3305. -
  3306. -/* the stack of aliases we are expanding */
  3307. -
  3308. -extern struct anode *alstack[MAXAL];
  3309. -
  3310. -/* the alias stack pointer; also, the number of aliases currently
  3311. -     being expanded */
  3312. -
  3313. -extern int alix;
  3314. -
  3315. -/* != 0 means we are reading input from a string */
  3316. -
  3317. -extern int strin;
  3318. -
  3319. -/* == 1 means we are doing TAB expansion
  3320. -     == 2 means expansion has occurred during TAB expansion */
  3321. -
  3322. -extern int magic;
  3323. -
  3324. -/* period between periodic() commands, in seconds */
  3325. -
  3326. -extern int period;
  3327. -
  3328. -/* != 0 means history is turned off (through !" or setopt nobanghist) */
  3329. -
  3330. -extern int stophist;
  3331. -
  3332. -/* != 0 means we have removed the current event from the history list */
  3333. -
  3334. -extern int histremmed;
  3335. -
  3336. -/* the options; e.g. if opts['a'] is nonzero, -a is turned on */
  3337. -
  3338. -extern int opts[128];
  3339. -
  3340. -/* LINENO */
  3341. -
  3342. -extern int lineno;
  3343. -
  3344. -/* != 0 means we have called execlist() and then intend to exit(),
  3345. -     so don't fork if not necessary */
  3346. -
  3347. -extern int exiting;
  3348. -
  3349. -/* the limits for child processes */
  3350. -
  3351. -extern struct rlimit limits[RLIM_NLIMITS];
  3352. -
  3353. -/* the tokens */
  3354. -
  3355. -extern char *tokens;
  3356. -
  3357. -/* the current word in the history list */
  3358. -
  3359. -extern char *hlastw;
  3360. -
  3361. -/* the pointer to the current character in the current word
  3362. -     in the history list */
  3363. -
  3364. -extern char *hlastp;
  3365. -
  3366. -/* the size of the current word in the history list */
  3367. -
  3368. -extern int hlastsz;
  3369. -
  3370. -/* the alias expansion status - if == ALSTAT_MORE, we just finished
  3371. -extern     expanding an alias ending with a space */
  3372. -
  3373. -extern int alstat;
  3374. -
  3375. -/* we have printed a 'you have stopped (running) jobs.' message */
  3376. -
  3377. -extern int stopmsg;
  3378. -
  3379. -/* the default tty state */
  3380. -
  3381. -extern struct ttyinfo shttyinfo;
  3382. -
  3383. -/* signal names */
  3384. -
  3385. -extern char *sigs[];
  3386. -
  3387. -/* signals that are trapped = 1, signals ignored =2 */
  3388. -
  3389. -extern int sigtrapped[];
  3390. -
  3391. End of zsh.h
  3392. echo proto 1>&2
  3393. sed 's/^-//' >proto <<'End of proto'
  3394. -#! /bin/sh
  3395. -#
  3396. -# proto - prototype generating script
  3397. -#
  3398. -# This file is part of zsh, the Z shell.
  3399. -#
  3400. -# zsh is free software etc etc.
  3401. -#
  3402. -for i
  3403. -do
  3404. -    rm $i.pro
  3405. -    grep -v '[{};:#]' $i.c | grep '^[A-Za-z]' |
  3406. -        grep -v '^[     ]' |
  3407. -        grep -v static | sed 's/$/;/' >$i.pro
  3408. -done
  3409. -
  3410. End of proto
  3411. ---cut here---cut here---cut here---
  3412.