home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume29 / pdksh / patch03b < prev    next >
Encoding:
Text File  |  1992-04-25  |  32.9 KB  |  1,378 lines

  1. Newsgroups: comp.sources.misc
  2. From: sjg@zen.void.oz.au (Simon J. Gerraty)
  3. Subject:  v29i084:  pdksh - Public Domain Korn Shell, v4, Patch03b/5
  4. Message-ID: <1992Apr26.041512.22140@sparky.imd.sterling.com>
  5. X-Md4-Signature: 7df7c1bf603caded7da0694639c2a7e6
  6. Date: Sun, 26 Apr 1992 04:15:12 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: sjg@zen.void.oz.au (Simon J. Gerraty)
  10. Posting-number: Volume 29, Issue 84
  11. Archive-name: pdksh/patch03b
  12. Environment: UNIX
  13. Patch-To: pdksh: Volume 25, Issue 47-55
  14.  
  15. *** sh/emacs.c.old    Sat Apr 25 17:44:25 1992
  16. --- sh/emacs.c    Sat Apr 25 18:35:39 1992
  17. ***************
  18. *** 10,17 ****
  19.   #ifdef EMACS
  20.   
  21.   #ifndef lint
  22. ! static char *RCSid = "$Id: emacs.c,v 3.2 89/03/27 15:49:17 egisin Exp $";
  23. ! static char *sccs_id = "@(#)emacs.c    1.7 91/11/25 13:32:56 (sjg)";
  24.   #endif
  25.   
  26.   #include "stdh.h"
  27. --- 10,16 ----
  28.   #ifdef EMACS
  29.   
  30.   #ifndef lint
  31. ! static char *RCSid = "$Id: emacs.c,v 1.2 1992/04/25 08:33:28 sjg Exp $";
  32.   #endif
  33.   
  34.   #include "stdh.h"
  35. ***************
  36. *** 24,32 ****
  37.   #include <errno.h>
  38.   #include <setjmp.h>
  39.   #include "sh.h"
  40. - #include "lex.h"
  41. - #include "tree.h"        /* DOTILDE */
  42. - #include "table.h"
  43.   #include "expand.h"
  44.   #include "edit.h"
  45.   
  46. --- 23,28 ----
  47. ***************
  48. *** 77,83 ****
  49.   static    char   **x_nextcmdp;    /* for newline-and-next */
  50.   static    char    *xmp;        /* mark pointer */
  51.   static    int    (*x_last_command)();
  52. ! static    struct    x_ftab Const *(*x_tab)[X_TABSZ] = NULL; /* key definition */
  53.   static    char    *(*x_atab)[X_TABSZ] = NULL; /* macro definitions */
  54.   #define    KILLSIZE    20
  55.   static    char    *killstack[KILLSIZE];
  56. --- 73,79 ----
  57.   static    char   **x_nextcmdp;    /* for newline-and-next */
  58.   static    char    *xmp;        /* mark pointer */
  59.   static    int    (*x_last_command)();
  60. ! static    struct    x_ftab const *(*x_tab)[X_TABSZ] = NULL; /* key definition */
  61.   static    char    *(*x_atab)[X_TABSZ] = NULL; /* macro definitions */
  62.   #define    KILLSIZE    20
  63.   static    char    *killstack[KILLSIZE];
  64. ***************
  65. *** 86,118 ****
  66.   static    char    *macroptr;
  67.   static    int    x_maxlen;    /* to determine column width */
  68.   
  69. ! static    void    x_goto(), x_bs(), x_delete(), x_ins(), x_mapin();
  70. ! static    int    x_fword(), x_bword(), x_size(), x_size_str();
  71. ! static    void    x_zotc(), x_zots(), x_push(), x_load_hist();
  72. ! static    void    compl_command(), compl_dec(), compl_file();
  73. ! static    int    x_insert(), x_ins_string(), x_del_back();
  74. ! static    int    x_del_char(), x_del_bword(), x_mv_bword(), x_mv_fword();
  75. ! static    int    x_del_fword(), x_mv_back(), x_mv_forw(), x_search_char();
  76. ! static    int    x_newline(), x_end_of_text(), x_abort(), x_error();
  77. ! static    int    x_beg_hist(), x_end_hist(), x_prev_com(), x_next_com();
  78. ! static    int    x_search_hist(), x_del_line(), x_mv_end(), x_mv_begin();
  79. ! static    int    x_draw_line(), x_transpose(), x_meta1(), x_meta2();
  80. ! static    int    x_kill(), x_yank(), x_meta_yank(), x_literal();
  81. ! static    int    x_stuffreset(), x_stuff(), x_complete(), x_enumerate();
  82. ! static    int    x_set_mark(), x_kill_region(), x_xchg_point_mark();
  83. ! static    int    x_nl_next_com(), x_eot_del();
  84. ! static    int    x_copy_arg();
  85. ! static    int    x_noop();
  86.   #ifdef SILLY
  87. ! static    int    x_game_of_life();
  88.   #endif
  89. ! static    int    x_comp_file(), x_comp_comm();
  90. ! static    int    x_list_file(), x_list_comm();
  91. ! static    int    strmatch();
  92. ! static int    x_prev_histword(), x_set_arg(), x_fold_case();
  93.   
  94. ! static    struct x_ftab Const x_ftab[] = {
  95.        {x_insert,    "auto-insert",        0,     0,    0 },
  96.       {x_error,    "error",        0,     0,    0 },
  97.        {x_ins_string,    "macro-string",        0,     0,    XF_NOBIND|XF_ALLOC},
  98. --- 82,164 ----
  99.   static    char    *macroptr;
  100.   static    int    x_maxlen;    /* to determine column width */
  101.   
  102. ! static int      x_insert    ARGS((int c));
  103. ! static int      x_ins_string ARGS((int c));
  104. ! static void     x_ins       ARGS((char *cp));
  105. ! static int      x_del_back  ARGS((int c));
  106. ! static int      x_del_char  ARGS((int c));
  107. ! static void     x_delete    ARGS((int nc));
  108. ! static int      x_del_bword ARGS((int c));
  109. ! static int      x_mv_bword  ARGS((int c));
  110. ! static int      x_mv_fword  ARGS((int c));
  111. ! static int      x_del_fword ARGS((int c));
  112. ! static int      x_bword     ARGS((void));
  113. ! static int      x_fword     ARGS((void));
  114. ! static void     x_goto      ARGS((char *cp));
  115. ! static void     x_bs        ARGS((int c));
  116. ! static int      x_size_str  ARGS((char *cp));
  117. ! static int      x_size      ARGS((int c));
  118. ! static void     x_zots      ARGS((char *str));
  119. ! static void     x_zotc      ARGS((int c));
  120. ! static int      x_mv_back   ARGS((int c));
  121. ! static int      x_mv_forw   ARGS((int c));
  122. ! static int      x_search_char ARGS((int c));
  123. ! static int      x_newline   ARGS((int c));
  124. ! static int      x_end_of_text ARGS((int c));
  125. ! static int      x_beg_hist  ARGS((int c));
  126. ! static int      x_end_hist  ARGS((int c));
  127. ! static int      x_prev_com  ARGS((int c));
  128. ! static int      x_next_com  ARGS((int c));
  129. ! static void     x_load_hist ARGS((char **hp));
  130. ! static int      x_nl_next_com ARGS((int c));
  131. ! static int      x_eot_del   ARGS((int c));
  132. ! static int      x_search_hist ARGS((int c));
  133. ! static int      x_search    ARGS((char *pat, int offset));
  134. ! static int      x_match     ARGS((char *str, char *pat));
  135. ! static int      x_del_line  ARGS((int c));
  136. ! static int      x_mv_end    ARGS((int c));
  137. ! static int      x_mv_begin  ARGS((int c));
  138. ! static int      x_draw_line ARGS((int c));
  139. ! static int      x_transpose ARGS((int c));
  140. ! static int      x_literal   ARGS((int c));
  141. ! static int      x_meta1     ARGS((int c));
  142. ! static int      x_meta2     ARGS((int c));
  143. ! static int      x_kill      ARGS((int c));
  144. ! static void     x_push      ARGS((int nchars));
  145. ! static int      x_yank      ARGS((int c));
  146. ! static int      x_meta_yank ARGS((int c));
  147. ! static int      x_abort     ARGS((int c));
  148. ! static int      x_error     ARGS((int c));
  149. ! static int      x_stuffreset ARGS((int c));
  150. ! static int      x_stuff     ARGS((int c));
  151. ! static void     x_mapin     ARGS((char *cp));
  152. ! static char *   x_mapout    ARGS((int c));
  153. ! static void     x_print     ARGS((int prefix, int key));
  154. ! static int      x_set_mark  ARGS((int c));
  155. ! static int      x_kill_region ARGS((int c));
  156. ! static int      x_xchg_point_mark ARGS((int c));
  157. ! static int      x_copy_arg  ARGS((int c));
  158. ! static int      x_noop      ARGS((int c));
  159.   #ifdef SILLY
  160. ! static int      x_game_of_life ARGS((int c));
  161.   #endif
  162. ! static void     add_stash   ARGS((char *dirnam, char *name));
  163. ! static void     list_stash  ARGS((void));
  164. ! static int      x_comp_comm ARGS((int c));
  165. ! static int      x_list_comm ARGS((int c));
  166. ! static int      x_complete  ARGS((int c));
  167. ! static int      x_enumerate ARGS((int c));
  168. ! static int      x_comp_file ARGS((int c));
  169. ! static int      x_list_file ARGS((int c));
  170. ! static void     compl_dec   ARGS((int type));
  171. ! static void     compl_file  ARGS((int type));
  172. ! static void     compl_command ARGS((int type));
  173. ! static int      strmatch    ARGS((char *s1, char *s2));
  174. ! static int      x_set_arg   ARGS((int c));
  175. ! static int      x_prev_histword ARGS((void));
  176. ! static int      x_fold_case ARGS((int c));
  177.   
  178. ! static    struct x_ftab const x_ftab[] = {
  179.        {x_insert,    "auto-insert",        0,     0,    0 },
  180.       {x_error,    "error",        0,     0,    0 },
  181.        {x_ins_string,    "macro-string",        0,     0,    XF_NOBIND|XF_ALLOC},
  182. ***************
  183. *** 125,130 ****
  184. --- 171,177 ----
  185.       {x_noop,    "no-op",        0,    0,    0 },
  186.   /* Do not move the above! */
  187.       {x_mv_fword,    "forward-word",        1,    'f',    0 },
  188. +     {x_del_char,    "delete-char-forward",    0,    0,    0 },
  189.       {x_del_fword,    "delete-word-forward",     1,    'd',    0 },
  190.       {x_mv_back,    "backward-char",    0, CTRL('B'),    0 },
  191.       {x_mv_forw,    "forward-char",        0, CTRL('F'),    0 },
  192. ***************
  193. *** 307,313 ****
  194.   x_ins(cp)
  195.       char    *cp;
  196.   {
  197. !     int    count, i;
  198.       register int    adj = x_adj_done;
  199.   
  200.       count = strlen(cp);
  201. --- 354,360 ----
  202.   x_ins(cp)
  203.       char    *cp;
  204.   {
  205. !     int    count;
  206.       register int    adj = x_adj_done;
  207.   
  208.       count = strlen(cp);
  209. ***************
  210. *** 608,615 ****
  211.       *xep = '\0';
  212.       if ((c = x_getc()) < 0 ||
  213.           /* we search forward, I don't know what Korn does */
  214. !         (cp = (xcp == xep) ? NULL : strchr(xcp+1, c)) == NULL &&
  215. !         (cp = strchr(xbuf, c)) == NULL) {
  216.           x_putc(BEL);
  217.           return KSTD;
  218.       }
  219. --- 655,662 ----
  220.       *xep = '\0';
  221.       if ((c = x_getc()) < 0 ||
  222.           /* we search forward, I don't know what Korn does */
  223. !         ((cp = (xcp == xep) ? NULL : strchr(xcp+1, c)) == NULL &&
  224. !         (cp = strchr(xbuf, c)) == NULL)) {
  225.           x_putc(BEL);
  226.           return KSTD;
  227.       }
  228. ***************
  229. *** 930,936 ****
  230.       memmove(cp, xcp, nchars);
  231.       cp[nchars] = 0;
  232.       if (killstack[killsp])
  233. !         afree((Void *)killstack[killsp], AEDIT);
  234.       killstack[killsp] = cp;
  235.       killsp = (killsp + 1) % KILLSIZE;
  236.   }
  237. --- 977,983 ----
  238.       memmove(cp, xcp, nchars);
  239.       cp[nchars] = 0;
  240.       if (killstack[killsp])
  241. !         afree((void *)killstack[killsp], AEDIT);
  242.       killstack[killsp] = cp;
  243.       killsp = (killsp + 1) % KILLSIZE;
  244.   }
  245. ***************
  246. *** 1078,1084 ****
  247.       char *a1, *a2;
  248.       int macro;        /* bind -m */
  249.   {
  250. !     struct x_ftab Const *fp;
  251.       int prefix, key;
  252.       char *sp = NULL;
  253.   
  254. --- 1125,1131 ----
  255.       char *a1, *a2;
  256.       int macro;        /* bind -m */
  257.   {
  258. !     struct x_ftab const *fp;
  259.       int prefix, key;
  260.       char *sp = NULL;
  261.   
  262. ***************
  263. *** 1134,1140 ****
  264.       }
  265.   
  266.       if ((x_tab[prefix][key]->xf_flags & XF_ALLOC) && x_atab[prefix][key])
  267. !         afree((Void *)x_atab[prefix][key], AEDIT);
  268.       x_tab[prefix][key] = fp;
  269.       x_atab[prefix][key] = sp;
  270.   }
  271. --- 1181,1187 ----
  272.       }
  273.   
  274.       if ((x_tab[prefix][key]->xf_flags & XF_ALLOC) && x_atab[prefix][key])
  275. !         afree((void *)x_atab[prefix][key], AEDIT);
  276.       x_tab[prefix][key] = fp;
  277.       x_atab[prefix][key] = sp;
  278.   }
  279. ***************
  280. *** 1143,1149 ****
  281.   x_init_emacs()
  282.   {
  283.       register int i, j;
  284. !     struct x_ftab Const *fp;
  285.   
  286.       ainit(AEDIT);
  287.   
  288. --- 1190,1196 ----
  289.   x_init_emacs()
  290.   {
  291.       register int i, j;
  292. !     struct x_ftab const *fp;
  293.   
  294.       ainit(AEDIT);
  295.   
  296. ***************
  297. *** 1319,1325 ****
  298.                   type = '*';
  299.           if (type)
  300.               ++len;
  301. !         afree((Void *)buf, ATEMP);
  302.       }
  303.   
  304.       if (len > x_maxlen)
  305. --- 1366,1372 ----
  306.                   type = '*';
  307.           if (type)
  308.               ++len;
  309. !         afree((void *)buf, ATEMP);
  310.       }
  311.   
  312.       if (len > x_maxlen)
  313. ***************
  314. *** 1363,1373 ****
  315.               x_puts(*record);
  316.               loc += strlen(*record);
  317.               tabstop += x_maxlen;    /* next tab stop */
  318. !             afree((Void *)*record, ATEMP);
  319.           }
  320.       }
  321.   
  322. !     afree((Void*)array, ATEMP);
  323.       x_redraw(-1);
  324.   }
  325.   
  326. --- 1410,1420 ----
  327.               x_puts(*record);
  328.               loc += strlen(*record);
  329.               tabstop += x_maxlen;    /* next tab stop */
  330. !             afree((void *)*record, ATEMP);
  331.           }
  332.       }
  333.   
  334. !     afree((void*)array, ATEMP);
  335.       x_redraw(-1);
  336.   }
  337.   
  338. ***************
  339. *** 1457,1463 ****
  340.   
  341.       *cp = 0;
  342.       strcpy(buf, cp = substitute(buf, DOTILDE));
  343. !     afree((Void*)cp, ATEMP);
  344.       lastp = strrchr(buf, '/');
  345.       if (lastp)
  346.           *lastp = 0;
  347. --- 1504,1510 ----
  348.   
  349.       *cp = 0;
  350.       strcpy(buf, cp = substitute(buf, DOTILDE));
  351. !     afree((void*)cp, ATEMP);
  352.       lastp = strrchr(buf, '/');
  353.       if (lastp)
  354.           *lastp = 0;
  355. ***************
  356. *** 1478,1484 ****
  357.       while ((dp = readdir(dirp)) != NULL)  {
  358.           cp = dp->d_name;
  359.           if (cp[0] == '.' &&
  360. !             (cp[1] == '\0' || cp[1] == '.' && cp[2] == '\0'))
  361.               continue; /* always ignore . and .. */
  362.           if (strncmp(lastp, cp, len) == 0)
  363.               if (type)  {
  364. --- 1525,1531 ----
  365.       while ((dp = readdir(dirp)) != NULL)  {
  366.           cp = dp->d_name;
  367.           if (cp[0] == '.' &&
  368. !             (cp[1] == '\0' || (cp[1] == '.' && cp[2] == '\0')))
  369.               continue; /* always ignore . and .. */
  370.           if (strncmp(lastp, cp, len) == 0)
  371.               if (type)  {
  372. *** sh/eval.c.old    Sat Apr 25 17:44:25 1992
  373. --- sh/eval.c    Sat Apr 25 18:35:45 1992
  374. ***************
  375. *** 3,10 ****
  376.    */
  377.   
  378.   #ifndef lint
  379. ! static char *RCSid = "$Id: eval.c,v 3.4 89/03/27 15:49:55 egisin Exp $";
  380. ! static char *sccs_id = "@(#)eval.c    1.2 91/11/22 22:53:39 (sjg)";
  381.   #endif
  382.   
  383.   #include "stdh.h"
  384. --- 3,9 ----
  385.    */
  386.   
  387.   #ifndef lint
  388. ! static char *RCSid = "$Id: eval.c,v 1.2 1992/04/25 08:33:28 sjg Exp $";
  389.   #endif
  390.   
  391.   #include "stdh.h"
  392. ***************
  393. *** 14,22 ****
  394.   #include <dirent.h>
  395.   #include <pwd.h>
  396.   #include "sh.h"
  397. - #include "lex.h"
  398. - #include "tree.h"
  399. - #include "table.h"
  400.   #include "expand.h"
  401.   
  402.   /*
  403. --- 13,18 ----
  404. ***************
  405. *** 43,55 ****
  406.   #define    XARG    3        /* expanding $*, $@ */
  407.   #define    XCOM    4        /* expanding $() */
  408.   
  409. ! static    void    expand ARGS((char *, XPtrV *, int));
  410. ! static    int    comsub ARGS((Expand *, char *comm));
  411. ! static    int    varsub ARGS((Expand *, char *name, int stype));
  412. ! static    void    glob ARGS((char *cp, XPtrV *wp));
  413. ! static    void    globit ARGS((char *ds, char *dp, char *sp, XPtrV *wp, int check));
  414. ! static    char   *tilde ARGS((char *wp));
  415. ! static    char   *trimsub ARGS((char *str, char *pat, int how));
  416.   
  417.   int    ifs0 = ' ';        /* todo: first char of $IFS */
  418.   
  419. --- 39,53 ----
  420.   #define    XARG    3        /* expanding $*, $@ */
  421.   #define    XCOM    4        /* expanding $() */
  422.   
  423. ! static void     expand      ARGS((char *cp, XPtrV *wp, int f));
  424. ! static int      varsub      ARGS((Expand *xp, char *sp, int stype));
  425. ! static int      comsub      ARGS((Expand *xp, char *cp));
  426. ! static char *   trimsub     ARGS((char *str, char *pat, int how));
  427. ! static void     glob        ARGS((char *cp, XPtrV *wp));
  428. ! static void     globit      ARGS((char *ds, char *dp, char *sp, XPtrV *wp, int check));
  429. ! static char *   debunk      ARGS((char *cp));
  430. ! static char *   tilde       ARGS((char *acp));
  431. ! static char *   homedir     ARGS((char *name));
  432.   
  433.   int    ifs0 = ' ';        /* todo: first char of $IFS */
  434.   
  435. ***************
  436. *** 56,62 ****
  437.   /* compile and expand word */
  438.   char *
  439.   substitute(cp, f)
  440. !     char Const *cp;
  441.       int f;
  442.   {
  443.       struct source *s, *sold;
  444. --- 54,60 ----
  445.   /* compile and expand word */
  446.   char *
  447.   substitute(cp, f)
  448. !     char const *cp;
  449.       int f;
  450.   {
  451.       struct source *s, *sold;
  452. ***************
  453. *** 139,144 ****
  454. --- 137,143 ----
  455.       SubType subtype [10];    /* substitution type stack */
  456.       register SubType *st = subtype + 10;
  457.       int newlines;        /* For trailing newlines in COMSUB */
  458. +     int trimming = 0;    /* flag if expanding ${var#pat} or ${var%pat} */
  459.   
  460.       if (cp == NULL)
  461.           errorf("eval:expand(NULL)\n");
  462. ***************
  463. *** 188,194 ****
  464.                       if (flag[FNOUNSET] &&
  465.                           strval(global(cp)) == null)
  466.                           errorf("%s: unset variable\n", cp);
  467. !                     f |= DOPAT;
  468.                       type = XBASE;
  469.                       *--qst = quote;
  470.                       quote = 0;
  471. --- 187,193 ----
  472.                       if (flag[FNOUNSET] &&
  473.                           strval(global(cp)) == null)
  474.                           errorf("%s: unset variable\n", cp);
  475. !                     trimming++;
  476.                       type = XBASE;
  477.                       *--qst = quote;
  478.                       quote = 0;
  479. ***************
  480. *** 217,222 ****
  481. --- 216,222 ----
  482.                       x.str = trimsub(strval(global(st->name)),
  483.                           dp, st->type);
  484.                       type = XSUB;
  485. +                     trimming--;
  486.                       continue;
  487.                     case '=':
  488.   #if 0
  489. ***************
  490. *** 287,293 ****
  491.           }
  492.   
  493.           /* check for end of word or IFS separation */
  494. !         if (c == 0 || !quote && (f&DOBLANK) && ctype(c, C_IFS)) {
  495.               if (word) {
  496.                   *dp++ = 0;
  497.                   cp = Xclose(ds, dp);
  498. --- 287,293 ----
  499.           }
  500.   
  501.           /* check for end of word or IFS separation */
  502. !         if (c == 0 || (!quote && (f&DOBLANK) && ctype(c, C_IFS))) {
  503.               if (word) {
  504.                   *dp++ = 0;
  505.                   cp = Xclose(ds, dp);
  506. ***************
  507. *** 311,331 ****
  508.                     case '*':
  509.                     case '?':
  510.                     case '[':
  511. !                     if (f&(DOPAT|DOGLOB)) {
  512.                           fdo |= (f&DOGLOB);
  513.                           *dp++ = MAGIC;
  514.                       }
  515.                       break;
  516.                     case NOT:
  517. !                     if ((f&(DOPAT|DOGLOB)) &&
  518.                           dp[-1] == '[' && dp[-2] == MAGIC) {
  519.                           *dp++ = MAGIC;
  520.                       }
  521.                       break;
  522.                     case '~':
  523. !                     if ((f&DOTILDE) && dp == Xstring(ds, dp) ||
  524. !                         !(f&DOBLANK) && 
  525. !                         (dp[-1] == '=' || dp[-1] == ':')) {
  526.                           fdo |= DOTILDE;
  527.                           *dp++ = MAGIC;
  528.                       }
  529. --- 311,332 ----
  530.                     case '*':
  531.                     case '?':
  532.                     case '[':
  533. !                     if (f&(DOPAT|DOGLOB) || trimming) {
  534.                           fdo |= (f&DOGLOB);
  535.                           *dp++ = MAGIC;
  536.                       }
  537.                       break;
  538.                     case NOT:
  539. !                     if ((f&(DOPAT|DOGLOB) || trimming) &&
  540.                           dp[-1] == '[' && dp[-2] == MAGIC) {
  541.                           *dp++ = MAGIC;
  542.                       }
  543.                       break;
  544.                     case '~':
  545. !                     if (((f&DOTILDE) &&
  546. !                          dp == Xstring(ds, dp)) ||
  547. !                         (!(f&DOBLANK) && 
  548. !                         (dp[-1] == '=' || dp[-1] == ':'))) {
  549.                           fdo |= DOTILDE;
  550.                           *dp++ = MAGIC;
  551.                       }
  552. ***************
  553. *** 568,576 ****
  554.           while ((d = readdir(dirp)) != NULL) {
  555.               tsp = d->d_name;
  556.               if (tsp[0] == '.' &&
  557. !                 (tsp[1] == 0 || tsp[1] == '.' && tsp[2] == 0))
  558.                   continue; /* always ignore . and .. */
  559. !             if (*tsp == '.' && *sp != '.' || !gmatch(tsp, sp))
  560.                   continue;
  561.   
  562.               tdp = dp;
  563. --- 569,577 ----
  564.           while ((d = readdir(dirp)) != NULL) {
  565.               tsp = d->d_name;
  566.               if (tsp[0] == '.' &&
  567. !                 (tsp[1] == 0 || (tsp[1] == '.' && tsp[2] == 0)))
  568.                   continue; /* always ignore . and .. */
  569. !             if ((*tsp == '.' && *sp != '.') || !gmatch(tsp, sp))
  570.                   continue;
  571.   
  572.               tdp = dp;
  573. ***************
  574. *** 622,628 ****
  575.       while (1) {
  576.           if ((c = *cp++) == 0) {
  577.               *wp = 0;
  578. !             afree((Void*)acp, ATEMP);
  579.               return strsave(path, ATEMP);
  580.           } else if (c == MAGIC && *cp == '~')
  581.               break;
  582. --- 623,629 ----
  583.       while (1) {
  584.           if ((c = *cp++) == 0) {
  585.               *wp = 0;
  586. !             afree((void*)acp, ATEMP);
  587.               return strsave(path, ATEMP);
  588.           } else if (c == MAGIC && *cp == '~')
  589.               break;
  590. *** sh/exec.c.old    Sat Apr 25 17:44:26 1992
  591. --- sh/exec.c    Sat Apr 25 18:30:45 1992
  592. ***************
  593. *** 3,10 ****
  594.    */
  595.   
  596.   #ifndef lint
  597. ! static char *RCSid = "$Id: exec.c,v 3.4 89/03/27 15:50:10 egisin Exp $";
  598. ! static char *sccs_id = "@(#)exec.c    1.6 91/11/25 13:33:03 (sjg)";
  599.   #endif
  600.   
  601.   #include "stdh.h"
  602. --- 3,9 ----
  603.    */
  604.   
  605.   #ifndef lint
  606. ! static char *RCSid = "$Id: exec.c,v 1.3 1992/04/25 08:29:52 sjg Exp $";
  607.   #endif
  608.   
  609.   #include "stdh.h"
  610. ***************
  611. *** 15,32 ****
  612.   #include <fcntl.h>
  613.   #include <sys/stat.h>
  614.   #include "sh.h"
  615. - #include "lex.h"
  616. - #include "tree.h"
  617. - #include "table.h"
  618.   
  619. ! static    int    comexec ARGS((struct op *t, char **vp, char **ap, int flags));
  620. ! static    void    iosetup ARGS((struct ioword *iop));
  621. ! static    void    echo ARGS((char **, char **));
  622. ! static    int    herein ARGS((char *name, int sub));
  623.   #ifdef    SHARPBANG
  624. ! static    void    scriptexec ARGS((struct op *t, char **ap));
  625.   #endif
  626.   
  627.   /*
  628.    * handle systems that don't have F_SETFD
  629.    */
  630. --- 14,29 ----
  631.   #include <fcntl.h>
  632.   #include <sys/stat.h>
  633.   #include "sh.h"
  634.   
  635. ! static int      comexec     ARGS((struct op *t, char **vp, char **ap, int flags));
  636.   #ifdef    SHARPBANG
  637. ! static void     scriptexec  ARGS((struct op *tp, char **ap));
  638.   #endif
  639. + static void     iosetup     ARGS((struct ioword *iop));
  640. + static int      herein      ARGS((char *hname, int sub));
  641. + static void     echo        ARGS((char **vp, char **ap));
  642.   
  643.   /*
  644.    * handle systems that don't have F_SETFD
  645.    */
  646. ***************
  647. *** 67,76 ****
  648.   int
  649.   execute(t, flags)
  650.       register struct op *t;
  651. !     Volatile int flags;    /* if XEXEC don't fork */
  652.   {
  653.       int i;
  654. !     int Volatile rv = 0;
  655.       int pv[2];
  656.       register char **ap;
  657.       char *s, *cp;
  658. --- 64,73 ----
  659.   int
  660.   execute(t, flags)
  661.       register struct op *t;
  662. !     volatile int flags;    /* if XEXEC don't fork */
  663.   {
  664.       int i;
  665. !     int volatile rv = 0;
  666.       int pv[2];
  667.       register char **ap;
  668.       char *s, *cp;
  669. ***************
  670. *** 373,381 ****
  671.   
  672.           if ((flags&XEXEC)) {
  673.               j_exit();
  674. !             if (flag[FMONITOR] || !(flags&XBGND)) {
  675. !                 signal(SIGINT, SIG_DFL);
  676. !                 signal(SIGQUIT, SIG_DFL);
  677.               }
  678.           }
  679.   
  680. --- 370,384 ----
  681.   
  682.           if ((flags&XEXEC)) {
  683.               j_exit();
  684. !             if (flag[FMONITOR] || !(flags&XBGND))
  685. !             {
  686. ! #ifdef USE_SIGACT
  687. !               sigaction(SIGINT, &Sigact_dfl, NULL);
  688. !               sigaction(SIGQUIT, &Sigact_dfl, NULL);
  689. ! #else
  690. !               signal(SIGINT, SIG_DFL);
  691. !               signal(SIGQUIT, SIG_DFL);
  692. ! #endif
  693.               }
  694.           }
  695.   
  696. ***************
  697. *** 622,629 ****
  698.           for (i = 0; (*tp++ = name[i++]) != '\0';)
  699.               ;
  700.           i = eaccess(line, mode);
  701. !         if (i == 0 && (mode != 1 || stat(line,&buf) == 0 &&
  702. !             (buf.st_mode & S_IFMT) == S_IFREG))
  703.               return line;
  704.           /* what should we do about EACCES? */
  705.           if (*sp++ == '\0')
  706. --- 625,632 ----
  707.           for (i = 0; (*tp++ = name[i++]) != '\0';)
  708.               ;
  709.           i = eaccess(line, mode);
  710. !         if (i == 0 && (mode != 1 || (stat(line,&buf) == 0 &&
  711. !             (buf.st_mode & S_IFMT) == S_IFREG)))
  712.               return line;
  713.           /* what should we do about EACCES? */
  714.           if (*sp++ == '\0')
  715. ***************
  716. *** 710,716 ****
  717.       int sub;
  718.   {
  719.       int fd;
  720. !     FILE * Volatile f = NULL;
  721.   
  722.       f = fopen(hname, "r");
  723.       if (f == NULL)
  724. --- 713,719 ----
  725.       int sub;
  726.   {
  727.       int fd;
  728. !     FILE * volatile f = NULL;
  729.   
  730.       f = fopen(hname, "r");
  731.       if (f == NULL)
  732. *** sh/expand.h.old    Sat Apr 25 17:41:33 1992
  733. --- sh/expand.h    Sun Apr 19 19:21:25 1992
  734. ***************
  735. *** 45,54 ****
  736.           }
  737.   
  738.   /* free string */
  739. ! #define    Xfree(xs, xp)    afree((Void*) (xs).beg, ATEMP)
  740.   
  741.   /* close, return string */
  742. ! #define    Xclose(xs, xp)    (char*) aresize((Void*)(xs).beg, \
  743.                       (size_t)(xp - (xs).beg), ATEMP)
  744.   /* begin of string */
  745.   #define    Xstring(xs, xp)    ((xs).beg)
  746. --- 45,54 ----
  747.           }
  748.   
  749.   /* free string */
  750. ! #define    Xfree(xs, xp)    afree((void*) (xs).beg, ATEMP)
  751.   
  752.   /* close, return string */
  753. ! #define    Xclose(xs, xp)    (char*) aresize((void*)(xs).beg, \
  754.                       (size_t)(xp - (xs).beg), ATEMP)
  755.   /* begin of string */
  756.   #define    Xstring(xs, xp)    ((xs).beg)
  757. ***************
  758. *** 61,73 ****
  759.    */
  760.   
  761.   typedef struct XPtrV {
  762. !     Void  **cur;        /* next avail pointer */
  763. !     Void  **beg, **end;    /* begin, end of vector */
  764.   } XPtrV;
  765.   
  766.   #define    XPinit(x, n) { \
  767. !             register Void **vp; \
  768. !             vp = (Void**) alloc(sizeofN(Void*, n), ATEMP); \
  769.               (x).cur = (x).beg = vp; \
  770.               (x).end = vp + n; \
  771.               }
  772. --- 61,73 ----
  773.    */
  774.   
  775.   typedef struct XPtrV {
  776. !     void  **cur;        /* next avail pointer */
  777. !     void  **beg, **end;    /* begin, end of vector */
  778.   } XPtrV;
  779.   
  780.   #define    XPinit(x, n) { \
  781. !             register void **vp; \
  782. !             vp = (void**) alloc(sizeofN(void*, n), ATEMP); \
  783.               (x).cur = (x).beg = vp; \
  784.               (x).end = vp + n; \
  785.               }
  786. ***************
  787. *** 75,82 ****
  788.   #define    XPput(x, p) { \
  789.               if ((x).cur >= (x).end) { \
  790.                   int n = XPsize(x); \
  791. !                 (x).beg = (Void**) aresize((Void*) (x).beg, \
  792. !                            sizeofN(Void*, n*2), ATEMP); \
  793.                   (x).cur = (x).beg + n; \
  794.                   (x).end = (x).cur + n; \
  795.               } \
  796. --- 75,82 ----
  797.   #define    XPput(x, p) { \
  798.               if ((x).cur >= (x).end) { \
  799.                   int n = XPsize(x); \
  800. !                 (x).beg = (void**) aresize((void*) (x).beg, \
  801. !                            sizeofN(void*, n*2), ATEMP); \
  802.                   (x).cur = (x).beg + n; \
  803.                   (x).end = (x).cur + n; \
  804.               } \
  805. ***************
  806. *** 86,93 ****
  807.   #define    XPptrv(x)    ((x).beg)
  808.   #define    XPsize(x)    ((x).cur - (x).beg)
  809.   
  810. ! #define    XPclose(x)    (Void**) aresize((Void*)(x).beg, \
  811. !                      sizeofN(Void*, XPsize(x)), ATEMP)
  812.   
  813. ! #define    XPfree(x)    afree((Void*) (x).beg, ATEMP)
  814.   
  815. --- 86,93 ----
  816.   #define    XPptrv(x)    ((x).beg)
  817.   #define    XPsize(x)    ((x).cur - (x).beg)
  818.   
  819. ! #define    XPclose(x)    (void**) aresize((void*)(x).beg, \
  820. !                      sizeofN(void*, XPsize(x)), ATEMP)
  821.   
  822. ! #define    XPfree(x)    afree((void*) (x).beg, ATEMP)
  823.   
  824. *** sh/expr.c.old    Sat Apr 25 17:44:27 1992
  825. --- sh/expr.c    Sat Apr 25 18:35:54 1992
  826. ***************
  827. *** 3,10 ****
  828.    */
  829.   
  830.   #ifndef lint
  831. ! static char *RCSid = "$Id: expr.c,v 3.2 89/03/27 15:50:20 egisin Exp $";
  832. ! static char *sccs_id = "@(#)expr.c    1.2 91/11/22 22:53:42 (sjg)";
  833.   #endif
  834.   
  835.   #include "stdh.h"
  836. --- 3,9 ----
  837.    */
  838.   
  839.   #ifndef lint
  840. ! static char *RCSid = "$Id: expr.c,v 1.2 1992/04/25 08:33:28 sjg Exp $";
  841.   #endif
  842.   
  843.   #include "stdh.h"
  844. ***************
  845. *** 11,17 ****
  846.   #include <errno.h>
  847.   #include <setjmp.h>
  848.   #include "sh.h"
  849. - #include "table.h"
  850.   
  851.   #define    ef    else if        /* fashion statement */
  852.   
  853. --- 10,15 ----
  854. ***************
  855. *** 22,35 ****
  856.   #define    LLE    0x05
  857.   #define    LGE    0x06
  858.   
  859. ! static void token();        /* read next token */
  860. ! static Const char *expression;    /* expression being evaluated */
  861. ! static Const char *tokp;    /* lexical position */
  862.   static int tok;            /* token from token() */
  863.   static struct tbl *val;        /* value from token() */
  864.   
  865. ! static struct tbl *tempvar(), *intvar();
  866. ! static struct tbl *asn(), *e6(), *e5(), *e3(), *e2(), *e0();
  867.   
  868.   /*
  869.    * parse and evalute expression
  870. --- 20,39 ----
  871.   #define    LLE    0x05
  872.   #define    LGE    0x06
  873.   
  874. ! static const char *expression;    /* expression being evaluated */
  875. ! static const char *tokp;    /* lexical position */
  876.   static int tok;            /* token from token() */
  877.   static struct tbl *val;        /* value from token() */
  878.   
  879. ! static struct tbl *asn      ARGS((void));
  880. ! static struct tbl *e6       ARGS((void));
  881. ! static struct tbl *e5       ARGS((void));
  882. ! static struct tbl *e3       ARGS((void));
  883. ! static struct tbl *e2       ARGS((void));
  884. ! static struct tbl *e0       ARGS((void));
  885. ! static void     token       ARGS((void));
  886. ! static struct tbl *tempvar  ARGS((void));
  887. ! static struct tbl *intvar   ARGS((struct tbl *vp));
  888.   
  889.   /*
  890.    * parse and evalute expression
  891. ***************
  892. *** 43,49 ****
  893.   
  894.   long
  895.   evaluate(expr)
  896. !     Const char *expr;
  897.   {
  898.       struct tbl *v;
  899.   
  900. --- 47,53 ----
  901.   
  902.   long
  903.   evaluate(expr)
  904. !     const char *expr;
  905.   {
  906.       struct tbl *v;
  907.   
  908. *** sh/getopts.c.old    Sat Apr 25 17:44:27 1992
  909. --- sh/getopts.c    Sat Apr 25 18:35:57 1992
  910. ***************
  911. *** 7,14 ****
  912.    */
  913.   
  914.   #ifndef lint
  915. ! static char *RCSid = "$Id: getopts.c,v 3.3 89/03/27 15:50:27 egisin Exp $";
  916. ! static char *sccs_id = "@(#)getopts.c    1.2 91/11/22 22:53:43 (sjg)";
  917.   #endif
  918.   
  919.   #include "stdh.h"
  920. --- 7,13 ----
  921.    */
  922.   
  923.   #ifndef lint
  924. ! static char *RCSid = "$Id: getopts.c,v 1.2 1992/04/25 08:33:28 sjg Exp $";
  925.   #endif
  926.   
  927.   #include "stdh.h"
  928. ***************
  929. *** 15,21 ****
  930.   #include <errno.h>
  931.   #include <setjmp.h>
  932.   #include "sh.h"
  933. - #include "table.h"
  934.   
  935.   /*
  936.    * The following is derived from getopt() source placed into the public
  937. --- 14,19 ----
  938. *** sh/history.c.old    Sat Apr 25 17:44:28 1992
  939. --- sh/history.c    Sat Apr 25 18:36:23 1992
  940. ***************
  941. *** 5,12 ****
  942.    */
  943.   
  944.   #ifndef lint
  945. ! static char *RCSid = "$Id: history.c,v 3.3 89/01/27 00:08:27 egisin Exp $";
  946. ! static char *sccs_id = "@(#)history.c    1.2 91/11/22 22:53:45 (sjg)";
  947.   #endif
  948.   
  949.   #include "stdh.h"
  950. --- 5,11 ----
  951.    */
  952.   
  953.   #ifndef lint
  954. ! static char *RCSid = "$Id: history.c,v 1.2 1992/04/25 08:33:28 sjg Exp $";
  955.   #endif
  956.   
  957.   #include "stdh.h"
  958. ***************
  959. *** 13,24 ****
  960.   #include <errno.h>
  961.   #include <setjmp.h>
  962.   #include "sh.h"
  963. - #include "lex.h"
  964.   
  965.   char   *histrpl();
  966.   char  **current;
  967.   int    curpos;
  968.   
  969.   c_fc(wp)
  970.       register char **wp;
  971.   {
  972. --- 12,29 ----
  973.   #include <errno.h>
  974.   #include <setjmp.h>
  975.   #include "sh.h"
  976.   
  977.   char   *histrpl();
  978.   char  **current;
  979.   int    curpos;
  980.   
  981. + static FILE *hist_fh = NULL;
  982. + static FILE *hist_open ARGS((char *mode));
  983. + #ifndef HISTFILE
  984. + # define HISTFILE ".pdksh_hist"
  985. + #endif
  986. +   
  987.   c_fc(wp)
  988.       register char **wp;
  989.   {
  990. ***************
  991. *** 169,175 ****
  992.   
  993.       if (histptr > history && last_line != source->line) { 
  994.           source->line--;
  995. !         afree((Void*)*histptr, APERM);
  996.           histptr--;
  997.           last_line = source->line;
  998.       }
  999. --- 174,180 ----
  1000.   
  1001.       if (histptr > history && last_line != source->line) { 
  1002.           source->line--;
  1003. !         afree((void*)*histptr, APERM);
  1004.           histptr--;
  1005.           last_line = source->line;
  1006.       }
  1007. ***************
  1008. *** 186,192 ****
  1009.       char *cp;
  1010.   
  1011.       if (++hp >= history + HISTORY) { /* remove oldest command */
  1012. !         afree((Void*)*history, APERM);
  1013.           for (hp = history; hp < history + HISTORY - 1; hp++)
  1014.               hp[0] = hp[1];
  1015.       }
  1016. --- 191,197 ----
  1017.       char *cp;
  1018.   
  1019.       if (++hp >= history + HISTORY) { /* remove oldest command */
  1020. !         afree((void*)*history, APERM);
  1021.           for (hp = history; hp < history + HISTORY - 1; hp++)
  1022.               hp[0] = hp[1];
  1023.       }
  1024. ***************
  1025. *** 254,349 ****
  1026.       return line;
  1027.   }
  1028.   
  1029. ! #if 0
  1030. ! /* History file management routines (by DPK@BRL) */
  1031.   void
  1032. ! hist_init()
  1033.   {
  1034. !     register struct namnod *n;
  1035. !     int fd;
  1036.   
  1037. !     if (hist_fd >= 0 || (flags&oneflg))
  1038. !         return;
  1039. !     if ((n = findnam(histname)) == (struct namnod *)0
  1040. !      || n->namval == (char *)0)
  1041. !         return;
  1042. !     if ((fd = open(n->namval, O_RDWR)) >= 0) {
  1043. !         hist_load(fd);
  1044. !         (void)fcntl(fd, F_SETFL, O_APPEND);
  1045. !     }
  1046. !     hist_fd = fd;
  1047.   }
  1048.   
  1049.   void
  1050.   hist_finish()
  1051.   {
  1052. !     if (hist_fd >= 0)
  1053. !         (void)close(hist_fd);
  1054. !     hist_fd = -1;
  1055.   }
  1056.   
  1057. - void
  1058. - hist_record(buf, len)
  1059. - char    *buf;
  1060. - int    len;
  1061. - {
  1062. -     if (hist_fd >= 0)
  1063. -         (void)write(hist_fd, buf, (unsigned)len);
  1064. - }
  1065.   
  1066. ! void
  1067. ! hist_load(fd)
  1068. ! int    fd;
  1069.   {
  1070. !     extern long    lseek();
  1071. !     struct stat sb;
  1072. !     char *x;
  1073. !     register char *cmdp, *end;
  1074. !     register int    len;
  1075. !     register int    i;
  1076. !     if (fstat(fd, &sb) < 0 || sb.st_size <= 0)
  1077. !         return;
  1078. !     if (x = alloc((unsigned)(sb.st_size+1))) {
  1079. !         (void)lseek(fd, 0L, 0);
  1080. !         if ((len = read(fd, x, (unsigned)sb.st_size)) <= 0) {
  1081. !             free((struct blk *)x);
  1082. !             return;
  1083. !         }
  1084. !         x[len] = 0;
  1085. !         end = x;
  1086. !         for (;;) {
  1087. !             while(*end == NL)
  1088. !                 end++;        /* Skip NL */
  1089. !             if (*end == 0)
  1090. !                 break;
  1091. !             cmdp = end;
  1092. !             while(*end && *end != NL)
  1093. !                 end++;    /* Goto NL */
  1094. !             if (*end == 0)
  1095. !                 break;
  1096. !             if ((len = (end - cmdp)) < 2)
  1097. !                 continue;
  1098. !             if (len >= BUFSIZ)
  1099. !                 len = BUFSIZ - 1;        /* Protection */
  1100. !             i = curhist % NHISTORY;
  1101. !             if(histbuf[i])
  1102. !                 free((struct blk *)histbuf[i]);
  1103. !             histbuf[i] = alloc((unsigned)(len+1));
  1104. !             (void)strncpy(histbuf[i], cmdp, len);
  1105. !             histbuf[i][len] = 0;
  1106. !             curhist++;
  1107. !             histpc=curhist;
  1108. !         }
  1109. !         free((struct blk *)x);
  1110. !     }
  1111. !     return;
  1112.   }
  1113.   
  1114. - #endif
  1115.   
  1116.   /*
  1117.    * Return the current position.
  1118.    */
  1119. --- 259,358 ----
  1120.       return line;
  1121.   }
  1122.   
  1123. ! /*
  1124. !  * 92-04-25 <sjg@zen>
  1125. !  * A simple history file implementation.
  1126. !  * At present we only save the history when we exit.
  1127. !  * This can cause problems when there are multiple shells are 
  1128. !  * running under the same user-id.  The last shell to exit gets 
  1129. !  * to save its history.
  1130. !  */
  1131.   void
  1132. ! hist_init(s)
  1133. !   Source *s;
  1134.   {
  1135. !   static int once = 0;
  1136. !   FILE *fh;
  1137. !   
  1138. !   if (once++)
  1139. !     return;
  1140.   
  1141. !   if (fh = hist_open("r"))
  1142. !   {
  1143. !     while (fgets(line, sizeof(line), fh) != NULL)
  1144. !     {
  1145. !       histsave(line); 
  1146. !       s->line++;
  1147. !     }
  1148. !     line[0] = '\0';
  1149. !     fclose(fh);
  1150. ! #if 0    /* this might be a good idea? */
  1151. !     hist_fh = hist_open("a");
  1152. ! #endif
  1153. !   }
  1154. !   
  1155.   }
  1156.   
  1157. + /*
  1158. +  * save our history.
  1159. +  * We check that we do not have more than we are allowed.
  1160. +  * If the history file is read-only we do nothing.
  1161. +  * Handy for having all shells start with a useful history set.
  1162. +  */
  1163.   void
  1164.   hist_finish()
  1165.   {
  1166. !   static int once = 0;
  1167. !   FILE *fh;
  1168. !   register int i, mx;
  1169. !   register char **hp, *mode = "w";
  1170. !   
  1171. !   if (once++)
  1172. !     return;
  1173. !   if ((mx = atoi(strval(global("HISTSIZE")))) > HISTORY || mx <= 0)
  1174. !     mx = HISTORY;
  1175. !   /* check how many we have */
  1176. !   i = histptr - history;
  1177. !   if (i >= mx)
  1178. !   {
  1179. !     hp = &histptr[-mx];
  1180. !   }
  1181. !   else
  1182. !   {
  1183. !     hp = history;
  1184. !   }
  1185. !   if (fh = hist_open(mode))
  1186. !   {
  1187. !     for (i = 0; i < mx && hp[i]; i++)
  1188. !       fprintf(fh, "%s\n", hp[i]);
  1189. !     fclose(fh);
  1190. !   }
  1191.   }
  1192.   
  1193.   
  1194. ! /*
  1195. !  * simply grab the nominated history file.
  1196. !  */
  1197. ! static FILE *
  1198. ! hist_open(mode)
  1199. !   char *mode;
  1200.   {
  1201. !   register char *rcp;
  1202. !   FILE *fh;
  1203. !   char name[128];
  1204. !   
  1205. !   if ((rcp = strval(global("HISTFILE"))) == NULL || *rcp == '\0')
  1206. !   {
  1207. !     (void) sprintf(name, "%s/%s", strval(global("HOME")), HISTFILE);
  1208. !     rcp = name;
  1209. !   }
  1210. !   return fopen(rcp, mode);
  1211.   }
  1212.   
  1213.   
  1214.   /*
  1215.    * Return the current position.
  1216.    */
  1217. ***************
  1218. *** 386,392 ****
  1219.       int    fwd;
  1220.       char     *str;
  1221.   {
  1222. -     char     **hp = NULL;
  1223.       int     pos = start;
  1224.       char     *line, *last;
  1225.   
  1226. --- 395,400 ----
  1227. *** sh/io.c.old    Sat Apr 25 17:44:28 1992
  1228. --- sh/io.c    Sat Apr 25 18:36:32 1992
  1229. ***************
  1230. *** 3,10 ****
  1231.    */
  1232.   
  1233.   #ifndef lint
  1234. ! static char *RCSid = "$Id: io.c,v 3.4 89/03/27 15:50:52 egisin Exp $";
  1235. ! static char *sccs_id = "@(#)io.c    1.4 91/11/25 13:33:08 (sjg)";
  1236.   #endif
  1237.   
  1238.   #include "stdh.h"
  1239. --- 3,9 ----
  1240.    */
  1241.   
  1242.   #ifndef lint
  1243. ! static char *RCSid = "$Id: io.c,v 1.2 1992/04/25 08:33:28 sjg Exp $";
  1244.   #endif
  1245.   
  1246.   #include "stdh.h"
  1247. ***************
  1248. *** 13,19 ****
  1249.   #include <fcntl.h>
  1250.   #include <signal.h>
  1251.   #include <setjmp.h>
  1252. ! #if __STDC__
  1253.   #include <stdarg.h>
  1254.   #else
  1255.   #include <varargs.h>
  1256. --- 12,18 ----
  1257.   #include <fcntl.h>
  1258.   #include <signal.h>
  1259.   #include <setjmp.h>
  1260. ! #ifdef __STDC__
  1261.   #include <stdarg.h>
  1262.   #else
  1263.   #include <varargs.h>
  1264. ***************
  1265. *** 44,51 ****
  1266.   
  1267.   /* shellf(...); error() */
  1268.   int
  1269. ! #if __STDC__
  1270. ! errorf(Const char *fmt, ...) {
  1271.   #else
  1272.   errorf(va_alist) va_dcl
  1273.   {
  1274. --- 43,50 ----
  1275.   
  1276.   /* shellf(...); error() */
  1277.   int
  1278. ! #ifdef __STDC__
  1279. ! errorf(const char *fmt, ...) {
  1280.   #else
  1281.   errorf(va_alist) va_dcl
  1282.   {
  1283. ***************
  1284. *** 53,59 ****
  1285.   #endif
  1286.       va_list va;
  1287.   
  1288. ! #if __STDC__
  1289.       va_start(va, fmt);
  1290.   #else
  1291.       va_start(va);
  1292. --- 52,58 ----
  1293.   #endif
  1294.       va_list va;
  1295.   
  1296. ! #ifdef __STDC__
  1297.       va_start(va, fmt);
  1298.   #else
  1299.       va_start(va);
  1300. ***************
  1301. *** 67,74 ****
  1302.   
  1303.   /* printf to shlout (stderr) */
  1304.   int
  1305. ! #if __STDC__
  1306. ! shellf(Const char *fmt, ...) {
  1307.   #else
  1308.   shellf(va_alist) va_dcl
  1309.   {
  1310. --- 66,73 ----
  1311.   
  1312.   /* printf to shlout (stderr) */
  1313.   int
  1314. ! #ifdef __STDC__
  1315. ! shellf(const char *fmt, ...) {
  1316.   #else
  1317.   shellf(va_alist) va_dcl
  1318.   {
  1319. ***************
  1320. *** 76,82 ****
  1321.   #endif
  1322.       va_list va;
  1323.   
  1324. ! #if __STDC__
  1325.       va_start(va, fmt);
  1326.   #else
  1327.       va_start(va);
  1328. --- 75,81 ----
  1329.   #endif
  1330.       va_list va;
  1331.   
  1332. ! #ifdef __STDC__
  1333.       va_start(va, fmt);
  1334.   #else
  1335.       va_start(va);
  1336. ***************
  1337. *** 100,106 ****
  1338. --- 99,109 ----
  1339.       if (shf[fd] != NULL)
  1340.           return;
  1341.       if (fd <= 2)
  1342. + #ifdef _MINIX
  1343. +         /* ? */;
  1344. + #else
  1345.           _iob[fd]._flag = 0; /* re-use stdin, stdout, stderr */
  1346. + #endif
  1347.       shf[fd] = fdopen(fd, "r+");
  1348.       if (shf[fd] == NULL)
  1349.           return;
  1350. ***************
  1351. *** 137,143 ****
  1352.               else
  1353.                   errorf("too many files open in shell\n");
  1354.   #ifdef F_SETFD
  1355. !         (void) fcntl(nfd, F_SETFD, FD_CLEXEC);
  1356.   #else
  1357.           (void) fd_clexec(ttyfd);
  1358.   #endif
  1359. --- 140,146 ----
  1360.               else
  1361.                   errorf("too many files open in shell\n");
  1362.   #ifdef F_SETFD
  1363. !         (void) fcntl(nfd, F_SETFD, 1);
  1364.   #else
  1365.           (void) fd_clexec(ttyfd);
  1366.   #endif
  1367.  
  1368. exit 0 # Just in case...
  1369.