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

  1. Newsgroups: comp.sources.misc
  2. From: sjg@zen.void.oz.au (Simon J. Gerraty)
  3. Subject:  v29i086:  pdksh - Public Domain Korn Shell, v4, Patch03d/5
  4. Message-ID: <1992Apr26.041615.22389@sparky.imd.sterling.com>
  5. X-Md4-Signature: 05de8910a6b1d539c342b4b5ca831059
  6. Date: Sun, 26 Apr 1992 04:16:15 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 86
  11. Archive-name: pdksh/patch03d
  12. Environment: UNIX
  13. Patch-To: pdksh: Volume 25, Issue 47-55
  14.  
  15. *** /dev/null    Sat Apr 25 07:00:06 1992
  16. --- sh/proto.h    Sat Apr 25 18:29:12 1992
  17. ***************
  18. *** 0 ****
  19. --- 1,234 ----
  20. + /*
  21. +  * prototypes for PD-KSH
  22. +  * originally generated using "cproto.c 3.5 92/04/11 19:28:01 cthuang "
  23. +  * $Id: proto.h,v 1.1 1992/04/25 08:29:02 sjg Exp $
  24. +  */
  25. + #ifndef ARGS
  26. + #if defined(__STDC__) || defined(__cplusplus)
  27. + #define ARGS(s) s
  28. + #else
  29. + #define ARGS(s) ()
  30. + #endif
  31. + #endif
  32. + /* alloc.c */
  33. + Area *    ainit         ARGS((Area *ap));
  34. + void     afreeall     ARGS((Area *ap));
  35. + void *    alloc         ARGS((size_t size, Area *ap));
  36. + void *    aresize         ARGS((void *ptr, size_t size, Area *ap));
  37. + void     afree         ARGS((void *ptr, Area *ap));
  38. + /* c_ksh.c */
  39. + int     c_hash         ARGS((char **wp));
  40. + int     c_cd         ARGS((char **wp));
  41. + int     c_print         ARGS((char **wp));
  42. + int     c_whence     ARGS((char **wp));
  43. + int     c_typeset     ARGS((char **wp));
  44. + int     c_alias         ARGS((char **wp));
  45. + int     c_unalias     ARGS((char **wp));
  46. + int     c_let         ARGS((char **wp));
  47. + int     c_jobs         ARGS((char **wp));
  48. + int     c_fgbg         ARGS((char **wp));
  49. + int     c_kill         ARGS((char **wp));
  50. + int     c_bind         ARGS((char **wp));
  51. + /* c_sh.c */
  52. + int     c_label         ARGS((char **wp));
  53. + int     c_shift         ARGS((char **wp));
  54. + int     c_umask         ARGS((char **wp));
  55. + int     c_dot         ARGS((char **wp));
  56. + int     c_wait         ARGS((char **wp));
  57. + int     c_read         ARGS((char **wp));
  58. + int     c_eval         ARGS((char **wp));
  59. + int     c_trap         ARGS((char **wp));
  60. + void     setsig         ARGS((struct trap *p, void (*f)()));
  61. + int     c_return     ARGS((char **wp));
  62. + int     c_brkcont     ARGS((char **wp));
  63. + int     c_exit         ARGS((char **wp));
  64. + int     c_set         ARGS((char **wp));
  65. + int     c_unset         ARGS((char **wp));
  66. + int     c_ulimit     ARGS((char **wp));
  67. + int     c_times         ARGS((char **wp));
  68. + int     timex         ARGS((struct op *t, int f));
  69. + int     c_exec         ARGS((char **wp));
  70. + int     c_builtin     ARGS((char **wp));
  71. + /* c_test.c */
  72. + int     c_test         ARGS((char **wp));
  73. + int     oexpr         ARGS((int n));
  74. + int     aexpr         ARGS((int n));
  75. + int     nexpr         ARGS((int n));
  76. + int     primary         ARGS((int n));
  77. + int     filstat         ARGS((char *nm, int mode));
  78. + int     t_lex         ARGS((char *s));
  79. + int     newerf         ARGS((char *f1, char *f2));
  80. + int     olderf         ARGS((char *f1, char *f2));
  81. + int     equalf         ARGS((char *f1, char *f2));
  82. + /* do_ulimit.c */
  83. + int     do_ulimit     ARGS((char *a1, char *a2));
  84. + /* edit.c */
  85. + int     x_read         ARGS((int fd, char *buf, size_t len));
  86. + int     x_getc         ARGS((void));
  87. + void     x_flush         ARGS((void));
  88. + void     x_adjust     ARGS((void));
  89. + void     x_putc         ARGS((int c));
  90. + void     x_puts         ARGS((char *s));
  91. + void     x_init         ARGS((void));
  92. + bool_t     x_mode         ARGS((bool_t onoff));
  93. + int     promptlen     ARGS((char *cp));
  94. + int     init_editmode     ARGS((void));
  95. + /* emacs.c */
  96. + int     x_emacs         ARGS((char *buf, size_t len));
  97. + void     x_redraw     ARGS((int limit));
  98. + void     x_bind         ARGS((char *a1, char *a2, int macro));
  99. + void     x_init_emacs     ARGS((void));
  100. + void     x_emacs_keys     ARGS((int erase, int kill, int werase, int intr, int quit));
  101. + char *    x_lastcp     ARGS((void));
  102. + /* eval.c */
  103. + char *    substitute     ARGS((char const *cp, int f));
  104. + char **    eval         ARGS((char **ap, int f));
  105. + char *    evalstr         ARGS((char *cp, int f));
  106. + /* exec.c */
  107. + int     execute         ARGS((struct op *t, volatile int flags));
  108. + int     shcomexec     ARGS((char **wp));
  109. + int     define         ARGS((char *name, struct op *t));
  110. + int     builtin         ARGS((char *name, int (*func)()));
  111. + struct tbl *    findcom     ARGS((char *name, int insert));
  112. + int     flushcom     ARGS((int all));
  113. + char *    search         ARGS((char *name, char *path, int mode));
  114. + /* expr.c */
  115. + void     evalerr         ARGS((char *err));
  116. + long     evaluate     ARGS((const char *expr));
  117. + /* getopts.c */
  118. + void     resetopts     ARGS((void));
  119. + int     c_getopts     ARGS((char **wp));
  120. + /* history.c */
  121. + int     c_fc          ARGS((register char **wp));
  122. + void     histbackup     ARGS((void));
  123. + void     histsave     ARGS((char *cmd));
  124. + char **    histget          ARGS((char *str));
  125. + char *    histrpl          ARGS((char *s, char *pat, char *rep, int global));
  126. + void     hist_init     ARGS((Source *s));
  127. + void     hist_finish     ARGS((void));
  128. + char **    histpos          ARGS((void));
  129. + int     histN          ARGS((void));
  130. + int     histnum          ARGS((int n));
  131. + char *    findhist     ARGS((int start, int fwd, char *str));
  132. + /* io.c */
  133. + int     errorf         ARGS((const char *fmt, ...));
  134. + int     shellf         ARGS((const char *fmt, ...));
  135. + void     fopenshf     ARGS((int fd));
  136. + void     flushshf     ARGS((int fd));
  137. + int     savefd         ARGS((int fd));
  138. + void     restfd         ARGS((int fd, int ofd));
  139. + void     openpipe     ARGS((int *pv));
  140. + void     closepipe     ARGS((int *pv));
  141. + struct temp *    maketemp ARGS((Area *ap));
  142. + /* jobs.c */
  143. + void     j_init         ARGS((void));
  144. + void     j_exit         ARGS((void));
  145. + void     j_change     ARGS((void));
  146. + int     exchild         ARGS((struct op *t, int flags));
  147. + int     waitlast     ARGS((void));
  148. + int     j_reapchld     ARGS((void));
  149. + int     j_reap         ARGS((void));
  150. + int     waitfor         ARGS((int job));
  151. + void     j_kill         ARGS((int job, int sig));
  152. + int     j_resume     ARGS((int job, int bg));
  153. + void     j_jobs         ARGS((void));
  154. + void     j_notify     ARGS((void));
  155. + int     j_lookup     ARGS((char *cp));
  156. + int     j_stopped     ARGS((void));
  157. + /* lex.c */
  158. + int     yylex         ARGS((int cf));
  159. + int     gethere         ARGS((void));
  160. + void     yyerror         ARGS((const char *msg));
  161. + Source * pushs         ARGS((int type));
  162. + int     pprompt         ARGS((char *cp));
  163. + /* mail.c */
  164. + void     mcheck         ARGS((void));
  165. + void     mbset         ARGS((char *p));
  166. + void     mpset         ARGS((char *mptoparse));
  167. + void     mprint         ARGS((void));
  168. + /* main.c */
  169. + int     main         ARGS((int argc, char **argv, char **envp));
  170. + int     include         ARGS((char *name));
  171. + #if 0
  172. + int     command         ARGS((char *comm));
  173. + #endif
  174. + int     shell         ARGS((Source *s));
  175. + void     leave         ARGS((int rv));
  176. + int     error         ARGS((void));
  177. + int     unwind         ARGS((void));
  178. + int     newenv         ARGS((int type));
  179. + int     quitenv         ARGS((void));
  180. + void     aerror         ARGS((Area *ap, const char *msg));
  181. + /* misc.c */
  182. + void     setctypes     ARGS((/* const */ char *s, int t));
  183. + void     initctypes     ARGS((void));
  184. + char *    ulton         ARGS((unsigned long n, int base));
  185. + char *    strsave         ARGS((char *s, Area *ap));
  186. + int     option         ARGS((const char *n));
  187. + char *    getoptions     ARGS((void));
  188. + void     printoptions     ARGS((void));
  189. + int     getn         ARGS((char *as));
  190. + char *    strerror     ARGS((int i));
  191. + int     gmatch         ARGS((char *s, char *p));
  192. + void     qsortp         ARGS((void **base, size_t n, int (*f)()));
  193. + int     qsort1         ARGS((void **base, void **lim, int (*f)()));
  194. + int     xstrcmp         ARGS((void *p1, void *p2));
  195. + void     cleanpath     ARGS((char *pwd, char *dir, char *clean));
  196. + /* syn.c */
  197. + int     yyparse         ARGS((void));
  198. + int     keywords     ARGS((void));
  199. + struct op * compile     ARGS((Source *s));
  200. + /* table.c */
  201. + unsigned int     hash     ARGS((char *n));
  202. + void     tinit         ARGS((struct table *tp, Area *ap));
  203. + struct tbl *    tsearch     ARGS((struct table *tp, char *n, unsigned int h));
  204. + struct tbl *    tenter     ARGS((struct table *tp, char *n, unsigned int h));
  205. + void     tdelete         ARGS((struct tbl *p));
  206. + void     twalk         ARGS((struct table *tp));
  207. + struct tbl *    tnext     ARGS((void));
  208. + struct tbl **    tsort     ARGS((struct table *tp));
  209. + /* trace.c */
  210. + /* trap.c */
  211. + Trap *    gettrap         ARGS((char *name));
  212. + void     trapsig         ARGS((int i));
  213. + int     runtraps     ARGS((void));
  214. + int     runtrap         ARGS((Trap *p));
  215. + int     cleartraps     ARGS((void));
  216. + int     ignoresig     ARGS((int i));
  217. + int     restoresigs     ARGS((void));
  218. + /* tree.c */
  219. + void     ptree         ARGS((struct op *t, FILE *f));
  220. + int     pioact         ARGS((FILE *f, struct ioword *iop));
  221. + int     fptreef         ARGS((FILE *f, char *fmt, ...));
  222. + int     snptreef     ARGS((char *s, int n, char *fmt, ...));
  223. + struct op *    tcopy     ARGS((struct op *t, Area *ap));
  224. + char *    wdcopy         ARGS((char *wp, Area *ap));
  225. + char *    wdscan         ARGS((char *wp, int c));
  226. + void     tfree         ARGS((struct op *t, Area *ap));
  227. + /* var.c */
  228. + void     newblock     ARGS((void));
  229. + void     popblock     ARGS((void));
  230. + struct tbl *    global     ARGS((char *n));
  231. + struct tbl *    local     ARGS((char *n));
  232. + char *    strval         ARGS((struct tbl *vp));
  233. + long     intval         ARGS((struct tbl *vp));
  234. + void     setstr         ARGS((struct tbl *vq, char *s));
  235. + struct tbl *    strint     ARGS((struct tbl *vq, struct tbl *vp));
  236. + void     setint         ARGS((struct tbl *vq, long n));
  237. + int     import         ARGS((char *thing));
  238. + struct tbl *    typeset     ARGS((char *var, int set, int clr));
  239. + void     unset         ARGS((struct tbl *vp));
  240. + int     isassign     ARGS((char *s));
  241. + char **    makenv         ARGS((void));
  242. + /* version.c */
  243. + /* vi.c */
  244. + void     vi_reset     ARGS((char *buf, int len));
  245. + int     vi_hook         ARGS((int ch));
  246. + int     save_cbuf     ARGS((void));
  247. + int     restore_cbuf     ARGS((void));
  248. + int     x_vi         ARGS((char *buf, size_t len));
  249. + int     getch         ARGS((void));
  250. + char **    globstr         ARGS((char *stuff));
  251. *** sh/sh.h.old    Sat Apr 25 17:44:32 1992
  252. --- sh/sh.h    Sat Apr 25 18:32:35 1992
  253. ***************
  254. *** 2,8 ****
  255.    * Public Domain Bourne/Korn shell
  256.    */
  257.   
  258. ! /* $Id: sh.h,v 3.3 89/03/27 15:46:34 egisin Exp $ */
  259.   
  260.   #include "config.h"
  261.   
  262. --- 2,8 ----
  263.    * Public Domain Bourne/Korn shell
  264.    */
  265.   
  266. ! /* $Id: sh.h,v 1.3 1992/04/25 08:29:52 sjg Exp $ */
  267.   
  268.   #include "config.h"
  269.   
  270. ***************
  271. *** 16,33 ****
  272.   #endif
  273.   
  274.   /* some people object to this use of __STDC__ */
  275. ! #ifndef Void
  276. ! #if __STDC__
  277.   #define    ARGS(args)    args    /* prototype declaration */
  278. - #define    Void    void        /* generic pointer */
  279. - #define    Const    const        /* constant data */
  280. - #define    Volatile volatile    /* you know */
  281.   #else
  282.   #define    ARGS(args)    ()    /* K&R declaration */
  283. ! #define    Void    char
  284. ! #define    Const    
  285. ! #define    Volatile 
  286.   #endif
  287.   #endif
  288.   
  289.   #ifdef _ULTRIX            /* Ultrix 2.x gets dup2 wrong */
  290. --- 16,30 ----
  291.   #endif
  292.   
  293.   /* some people object to this use of __STDC__ */
  294. ! #ifdef __STDC__
  295.   #define    ARGS(args)    args    /* prototype declaration */
  296.   #else
  297.   #define    ARGS(args)    ()    /* K&R declaration */
  298. ! #ifdef VOID
  299. ! #define    void    VOID
  300.   #endif
  301. + #define    const    
  302. + #define    volatile 
  303.   #endif
  304.   
  305.   #ifdef _ULTRIX            /* Ultrix 2.x gets dup2 wrong */
  306. ***************
  307. *** 63,69 ****
  308. --- 60,68 ----
  309.   Extern    int    kshpid;        /* $$, shell pid */
  310.   Extern    int    exstat;        /* exit status */
  311.   Extern    int    async;        /* $!, last &'d pid */
  312. + Extern    volatile int sigchld_caught;    /* count of dead children */
  313.   
  314.   /*
  315.    * Area-based allocation built on malloc/free
  316.    */
  317. ***************
  318. *** 76,90 ****
  319.   #define    APERM    &aperm
  320.   #define    ATEMP    &e.area
  321.   
  322. - Area   *ainit ARGS((Area *ap));        /* initialize Area */
  323. - void    afreeall ARGS((Area *ap));    /* free Area's contents */
  324. - void    ashrink ARGS((Area *ap));    /* unimplimented */
  325. - void    aerror ARGS((Area *ap, const char *msg)); /* error handler */
  326. - Void   *alloc ARGS((size_t size, Area *ap)); /* alloc object from Area */
  327. - Void   *aresize ARGS((Void *ptr, size_t size, Area *ap)); /* shrink object */
  328. - void    afree ARGS((Void *ptr, Area *ap)); /* free ojbect in Area */
  329.   /*
  330.    * parsing & execution environment
  331.    */
  332. --- 75,80 ----
  333. ***************
  334. *** 133,139 ****
  335.   #define    FLAG(c)    (1 + c - 'a')    /* map char to flags index */
  336.   #define    FLAGS    32
  337.   Extern    char flag [FLAGS];
  338. ! int    option ARGS((Const char *name));
  339.   char   *getoptions ARGS((void));
  340.   void    printoptions ARGS((void));
  341.   
  342. --- 123,129 ----
  343.   #define    FLAG(c)    (1 + c - 'a')    /* map char to flags index */
  344.   #define    FLAGS    32
  345.   Extern    char flag [FLAGS];
  346. ! int    option ARGS((const char *name));
  347.   char   *getoptions ARGS((void));
  348.   void    printoptions ARGS((void));
  349.   
  350. ***************
  351. *** 142,148 ****
  352.   /*
  353.    * other functions
  354.    */
  355. ! char * substitute ARGS((char Const *, int));
  356.   char   *search();
  357.   struct tbl *findcom();
  358.   char   *strsave ARGS((char *, Area *));
  359. --- 132,138 ----
  360.   /*
  361.    * other functions
  362.    */
  363. ! char * substitute ARGS((char const *, int));
  364.   char   *search();
  365.   struct tbl *findcom();
  366.   char   *strsave ARGS((char *, Area *));
  367. ***************
  368. *** 149,155 ****
  369.   char   *ulton ARGS((unsigned long n, int base));
  370.   int    xstrcmp();
  371.   void    qsortp ARGS((void **base, size_t n, int (*compare)(void *, void *)));
  372. ! long    evaluate ARGS((Const char *expr));
  373.   void    resetopts();
  374.   void    histsave();
  375.   void    histlist();
  376. --- 139,145 ----
  377.   char   *ulton ARGS((unsigned long n, int base));
  378.   int    xstrcmp();
  379.   void    qsortp ARGS((void **base, size_t n, int (*compare)(void *, void *)));
  380. ! long    evaluate ARGS((const char *expr));
  381.   void    resetopts();
  382.   void    histsave();
  383.   void    histlist();
  384. ***************
  385. *** 197,204 ****
  386.   #define    stdout    shf[1]        /* standard output */
  387.   #define    shlout    shf[2]        /* shell output */
  388.   
  389. ! int    shellf ARGS((Const char *fmt, ...)); /* fprintf(shlout, ); */
  390. ! int    errorf ARGS((Const char *fmt, ...)); /* fprintf(shlout, ); error(); */
  391.   
  392.   /*
  393.    * IO control
  394. --- 187,194 ----
  395.   #define    stdout    shf[1]        /* standard output */
  396.   #define    shlout    shf[2]        /* shell output */
  397.   
  398. ! int    shellf ARGS((const char *fmt, ...)); /* fprintf(shlout, ); */
  399. ! int    errorf ARGS((const char *fmt, ...)); /* fprintf(shlout, ); error(); */
  400.   
  401.   /*
  402.    * IO control
  403. ***************
  404. *** 208,214 ****
  405.   int    savefd ARGS((int fd));    /* save user fd */
  406.   void    restfd ARGS((int fd, int ofd));
  407.   void    openpipe ARGS((int [2]));
  408. ! void    closepipe ARGS((int [2]));;
  409.   
  410.   /*
  411.    * trap handlers
  412. --- 198,204 ----
  413.   int    savefd ARGS((int fd));    /* save user fd */
  414.   void    restfd ARGS((int fd, int ofd));
  415.   void    openpipe ARGS((int [2]));
  416. ! void    closepipe ARGS((int [2]));
  417.   
  418.   /*
  419.    * trap handlers
  420. ***************
  421. *** 218,224 ****
  422.       char   *name;        /* short name */
  423.       char   *mess;        /* descriptive name */
  424.       char   *trap;        /* trap command */
  425. !     int    Volatile set;    /* trap pending */
  426.       int    ourtrap;    /* not ignored (?) */
  427.       int    sig_dfl;    /* originally SIG_DFL */
  428.   } Trap;
  429. --- 208,214 ----
  430.       char   *name;        /* short name */
  431.       char   *mess;        /* descriptive name */
  432.       char   *trap;        /* trap command */
  433. !     int    volatile set;    /* trap pending */
  434.       int    ourtrap;    /* not ignored (?) */
  435.       int    sig_dfl;    /* originally SIG_DFL */
  436.   } Trap;
  437. ***************
  438. *** 229,238 ****
  439.   #ifdef    NSIG
  440.   #define    SIGNALS    NSIG
  441.   #else
  442.   #define    SIGNALS    32
  443.   #endif    /* NSIG */
  444.   
  445. ! Extern    int Volatile trap;    /* traps pending? */
  446.   extern    Trap    sigtraps[SIGNALS];
  447.   Trap    *gettrap ARGS((char *)); /* search for struct trap by number or name */
  448.   void    trapsig ARGS((int sig)); /* trap signal handler */
  449. --- 219,239 ----
  450.   #ifdef    NSIG
  451.   #define    SIGNALS    NSIG
  452.   #else
  453. + #ifdef    _MINIX
  454. + #define    SIGNALS    (_NSIG+1)    /* _NSIG is # of signals used, excluding 0. */
  455. + #else
  456.   #define    SIGNALS    32
  457. + #endif    /* _MINIX */
  458.   #endif    /* NSIG */
  459.   
  460. ! #ifdef USE_SIGACT            /* always use it? */
  461. ! #ifndef  SA_NOCLDSTOP
  462. ! # include "sigact.h"            /* use sjg's fake sigaction() */
  463. ! #endif
  464. ! Extern struct sigaction Sigact, Sigact_dfl, Sigact_ign, Sigact_trap;
  465. ! #endif
  466. ! Extern    int volatile trap;    /* traps pending? */
  467.   extern    Trap    sigtraps[SIGNALS];
  468.   Trap    *gettrap ARGS((char *)); /* search for struct trap by number or name */
  469.   void    trapsig ARGS((int sig)); /* trap signal handler */
  470. ***************
  471. *** 248,263 ****
  472.   #define    C_IFS    0x80        /* $IFS */
  473.   
  474.   extern    char ctypes [];
  475.   void    initctypes ARGS((void));
  476. ! void    setctypes ARGS((Const char*, int type));
  477.   #define    ctype(c, t)    !!(ctypes[(unsigned char)(c)]&(t))
  478.   #define    letter(c)    ctype(c, C_ALPHA)
  479.   #define    digit(c)    ctype(c, C_DIGIT)
  480.   #define    letnum(c)    ctype(c, C_ALPHA|C_DIGIT)
  481.   
  482.   /*
  483.    * 91-07-06 <sjg@sun0>
  484.    * use my simple debug tracing... 
  485.    */
  486.   #include "trace.h"
  487. --- 249,274 ----
  488.   #define    C_IFS    0x80        /* $IFS */
  489.   
  490.   extern    char ctypes [];
  491. + #if 0
  492.   void    initctypes ARGS((void));
  493. ! void    setctypes ARGS((const char*, int type));
  494. ! #endif
  495.   #define    ctype(c, t)    !!(ctypes[(unsigned char)(c)]&(t))
  496.   #define    letter(c)    ctype(c, C_ALPHA)
  497.   #define    digit(c)    ctype(c, C_DIGIT)
  498.   #define    letnum(c)    ctype(c, C_ALPHA|C_DIGIT)
  499.   
  500. + #include "table.h"
  501. + #include "tree.h"
  502. + #include "lex.h"
  503. + #include "proto.h"
  504. +   
  505.   /*
  506.    * 91-07-06 <sjg@sun0>
  507.    * use my simple debug tracing... 
  508.    */
  509.   #include "trace.h"
  510. + #ifndef fileno
  511. + #define fileno(p)    ((p)->_file)
  512. + #endif
  513. *** /dev/null    Sat Apr 25 07:00:06 1992
  514. --- sh/sigact.h    Sat Apr 25 01:05:25 1992
  515. ***************
  516. *** 0 ****
  517. --- 1,88 ----
  518. + /* NAME:
  519. +  *      sigact.h - sigaction et al
  520. +  *
  521. +  * SYNOPSIS:
  522. +  *      #include <signal.h>
  523. +  *      #ifndef  SA_NOCLDSTOP
  524. +  *      # include "sigact.h"
  525. +  *      #endif
  526. +  *
  527. +  * DESCRIPTION:
  528. +  *      This header is the interface to a fake sigaction(2) implementation.  
  529. +  *      Do NOT include this header unless your system does not 
  530. +  *      have a real sigaction(2) implementation.
  531. +  */
  532. + /*
  533. +  * $Log: sigact.h,v $
  534. +  * Revision 1.2  1992/04/24  15:04:11  sjg
  535. +  * now compiles with cc
  536. +  *
  537. +  * Revision 1.1  1992/04/24  12:01:38  sjg
  538. +  * Initial revision
  539. +  *
  540. +  */
  541. + #ifndef _SIGACT_H
  542. + #define _SIGACT_H
  543. + #ifndef ARGS
  544. + # if defined(__STDC__)
  545. + #   define ARGS(p) p
  546. + # else
  547. + #   define ARGS(p) ()
  548. + # endif
  549. + #endif
  550. + #ifndef __STDC__
  551. + # define volatile            /* can change without warning */
  552. + # define const                /* read only */
  553. + #endif
  554. + #ifndef SIGKILL
  555. + # include <signal.h>
  556. + #endif
  557. + #ifndef SA_NOCLDSTOP
  558. + /* sa_flags */
  559. + #define    SA_NOCLDSTOP    0x0001        /* don't send SIGCHLD on child stop */
  560. + #define SA_RESTART    0x0002        /* re-start I/O */
  561. + /* sigprocmask flags */
  562. + #define    SIG_BLOCK    0x0001
  563. + #define    SIG_UNBLOCK    0x0002
  564. + #define    SIG_SETMASK    0x0004
  565. + #ifndef __sys_stdtypes_h
  566. + typedef int sigset_t;
  567. + #endif
  568. + struct sigaction
  569. + {
  570. +   void        (*sa_handler)();
  571. +   sigset_t    sa_mask;
  572. +   int        sa_flags;
  573. + };
  574. + int    sigaction    ARGS(( int sig, struct sigaction *act, struct sigaction *oact ));
  575. + int    sigaddset    ARGS(( sigset_t *mask, int sig ));
  576. + int    sigdelset    ARGS(( sigset_t *mask, int sig ));
  577. + int    sigemptyset    ARGS(( sigset_t *mask ));
  578. + int    sigfillset    ARGS(( sigset_t *mask ));
  579. + int    sigismember    ARGS(( sigset_t *mask, int sig ));
  580. + int    sigpending    ARGS(( sigset_t *set ));
  581. + int    sigprocmask    ARGS(( int how, sigset_t *set, sigset_t *oldset ));
  582. + int    sigsuspend    ARGS(( sigset_t *mask ));
  583. + #ifndef sigmask
  584. + #define sigmask(m)    (1<<((m)-1))    /* convert SIGnum to mask */
  585. + #endif
  586. + #if !defined(NSIG) && defined(_NSIG)
  587. + # define NSIG _NSIG
  588. + #endif
  589. + #endif /* ! SA_NOCLDSTOP */
  590. + #endif /* _SIGACT_H */
  591. + /*
  592. +  * Local Variables:
  593. +  * version-control:t
  594. +  * comment-column:40
  595. +  * End:
  596. +  */
  597. *** /dev/null    Sat Apr 25 07:00:06 1992
  598. --- sh/sigact.c    Sat Apr 25 01:05:22 1992
  599. ***************
  600. *** 0 ****
  601. --- 1,297 ----
  602. + /* NAME:
  603. +  *      sigact.c - fake sigaction(2)
  604. +  *
  605. +  * SYNOPSIS:
  606. +  *      #include <signal.h>
  607. +  *      #ifndef  SA_NOCLDSTOP
  608. +  *      # include "sigact.h"
  609. +  *      #endif
  610. +  * 
  611. +  *      int sigaction(int sig, struct sigaction *act, 
  612. +  *                      struct sigaction *oact);
  613. +  *      int sigaddset(sigset_t *mask, int sig);
  614. +  *      int sigdelset(sigset_t *mask, int sig);
  615. +  *      int sigemptyset(sigset_t *mask);
  616. +  *      int sigfillset(sigset_t *mask);
  617. +  *      int sigismember(sigset_t *mask, int sig);
  618. +  *      int sigpending(sigset_t *set);
  619. +  *      int sigprocmask(int how, sigset_t *set, sigset_t *oldset);
  620. +  *      int sigsuspend(sigset_t *mask);
  621. +  *
  622. +  * DESCRIPTION:
  623. +  *      This is a fake sigaction implementation.  It uses 
  624. +  *      sigset(2) if available, otherwise it just uses 
  625. +  *      signal(2).  If it thinks sigaction(2) really exists it 
  626. +  *      compiles to almost nothing.
  627. +  *      
  628. +  *      The need for all this is the problems caused by mixing 
  629. +  *      signal handling routines in the one process.  This 
  630. +  *      module allows for a consistent POSIX compliant interface 
  631. +  *      to whatever is available.
  632. +  *
  633. +  * RETURN VALUE:
  634. +  *      0==success, -1==failure
  635. +  *
  636. +  * FILES:
  637. +  *      None.
  638. +  *
  639. +  * SEE ALSO:
  640. +  *      
  641. +  *
  642. +  * BUGS:
  643. +  *      Since we fake most of this, don't expect fancy usage to 
  644. +  *      work.
  645. +  *      
  646. +  * COPYRIGHT:
  647. +  *      @(#)Copyright (c) 1992 Simon J. Gerraty
  648. +  *
  649. +  *      This is free software.  It comes with NO WARRANTY.
  650. +  *      Permission to use, modify and distribute this source code 
  651. +  *      is granted subject to the following conditions.
  652. +  *      1/ that that the above copyright notice and this notice 
  653. +  *      are preserved in all copies and that due credit be given 
  654. +  *      to the author.  
  655. +  *      2/ that any changes to this code are clearly commented 
  656. +  *      as such so that the author does get blamed for bugs 
  657. +  *      other than his own.
  658. +  *      
  659. +  *      Please send copies of changes and bug-fixes to:
  660. +  *      sjg@zen.void.oz.au
  661. +  *
  662. +  */
  663. + #ifndef lint
  664. + static char  *RCSid = "$Id: sigact.c,v 1.2 1992/04/24 15:04:11 sjg Exp $";
  665. + #endif
  666. + /*
  667. +  * $Log: sigact.c,v $
  668. +  * Revision 1.2  1992/04/24  15:04:11  sjg
  669. +  * now compiles with cc
  670. +  *
  671. +  * Revision 1.1  1992/04/24  12:03:58  sjg
  672. +  * Initial revision
  673. +  *
  674. +  */
  675. + #include <signal.h>
  676. + #ifndef SA_NOCLDSTOP            /* no sigaction() */
  677. + /*
  678. +  * if we haven't been told,
  679. +  * try and guess what we should implement with.
  680. +  */
  681. + #if !defined(USE_SIGSET) && !defined(USE_SIGMASK) && !defined(USE_SIGNAL)
  682. + # if defined(sigmask) || defined(BSD) || defined(_BSD) && !defined(BSD41)
  683. + #   define USE_SIGMASK
  684. + # else
  685. + #   ifndef NO_SIGSET
  686. + #     define USE_SIGSET
  687. + #   else
  688. + #     define USE_SIGNAL
  689. + #   endif
  690. + # endif
  691. + #endif
  692. + /*
  693. +  * if we still don't know, we're in trouble
  694. +  */
  695. + #if !defined(USE_SIGSET) && !defined(USE_SIGMASK) && !defined(USE_SIGNAL)
  696. + #pragma error must know what to implement with
  697. + #endif
  698. + #include "sigact.h"
  699. + int
  700. + sigaction(sig, act, oact)
  701. +   int sig;
  702. +   struct sigaction *act, *oact;
  703. + {
  704. +   void (*oldh)();
  705. +   if (act)
  706. +   {
  707. + #ifdef USE_SIGSET
  708. +     oldh = sigset(sig, act->sa_handler);
  709. + #else
  710. +     oldh = signal(sig, act->sa_handler);
  711. + #endif
  712. +   }
  713. +   else
  714. +   {
  715. +     if (oact)
  716. +     {      
  717. + #ifdef USE_SIGSET
  718. +       oldh = sigset(sig, SIG_IGN);
  719. + #else
  720. +       oldh = signal(sig, SIG_IGN);
  721. + #endif
  722. +       if (oldh != SIG_IGN)
  723. +       {
  724. + #ifdef USE_SIGSET
  725. +     (void) sigset(sig, oldh);
  726. + #else
  727. +     (void) signal(sig, oldh);
  728. + #endif
  729. +       }
  730. +     }
  731. +   }
  732. +   if (oact)
  733. +   {
  734. +     oact->sa_handler = oldh;
  735. +   }
  736. +   return 0;                /* hey we're faking it */
  737. + }
  738. + int
  739. + sigaddset(mask, sig)
  740. +   sigset_t *mask;
  741. +   int sig;
  742. + {
  743. +   *mask |= sigmask(sig);
  744. +   return 0;
  745. + }
  746. + int
  747. + sigdelset(mask, sig)
  748. +   sigset_t *mask;
  749. +   int sig;
  750. + {
  751. +   *mask &= ~(sigmask(sig));
  752. +   return 0;
  753. + }
  754. + int
  755. + sigemptyset(mask)
  756. +   sigset_t *mask;
  757. + {
  758. +   *mask = 0;
  759. +   return 0;
  760. + }
  761. + int
  762. + sigfillset(mask)
  763. +   sigset_t *mask;
  764. + {
  765. +   register int i;
  766. +   
  767. +   for (i = 1; i < NSIG; i++)
  768. +     *mask |= sigmask(i);
  769. +   return 0;
  770. + }
  771. + int
  772. + sigismember(mask, sig)
  773. +   sigset_t *mask;
  774. +   int sig;
  775. + {
  776. +   return ((*mask) & sigmask(sig));
  777. + }
  778. + int
  779. + sigpending(set)
  780. +   sigset_t *set;
  781. + {
  782. +   return 0;
  783. + }
  784. + int
  785. + sigprocmask(how, set, oldset)
  786. +   int how;
  787. +   sigset_t *set, *oldset;
  788. + {
  789. + #ifdef USE_SIGSET
  790. +   register int i;
  791. + #endif
  792. +   sigset_t sm;
  793. + #ifdef USE_SIGMASK
  794. +   sm = sigblock(0);
  795. + #else
  796. +   sm = 0;
  797. + #endif
  798. +   
  799. +   if (oldset)
  800. +     *oldset = sm;    /* dangerous ? */
  801. +   if (set)
  802. +   {
  803. +     switch (how)
  804. +     {
  805. +     case SIG_BLOCK:
  806. +       sm |= *set;
  807. +       break;
  808. +     case SIG_UNBLOCK:
  809. +       sm &= ~(*set);
  810. +       break;
  811. +     case SIG_SETMASK:
  812. +       sm = *set;
  813. +       break;
  814. +     }
  815. + #ifdef USE_SIGMASK
  816. +     (void) sigsetmask(sm);
  817. + #else
  818. + # ifdef USE_SIGSET
  819. +     for (i = 1; i < NSIG; i++)
  820. +     {
  821. +       if (how == SIG_UNBLOCK)
  822. +       {
  823. +     if (*set & sigmask(i))
  824. +       sigrelse(i);
  825. +       }
  826. +       else
  827. +     if (sm & sigmask(i))
  828. +     {
  829. +       sighold(i);
  830. +     }
  831. +     }
  832. + # endif
  833. + #endif
  834. +   }
  835. +   return 0;
  836. + }
  837. + int
  838. + sigsuspend(mask)
  839. +   sigset_t *mask;
  840. + {
  841. + #ifdef USE_SETSIG
  842. +   int sig = SIGCHLD;            /* our default */
  843. +   
  844. +   /*
  845. +    * add as many tests as you think sensible, but
  846. +    * SIGALRM, and SIGCHLD are probably the most
  847. +    * common.
  848. +    */
  849. +   if (*mask & sigmask(SIGALRM))
  850. +     sig = SIGALRM;
  851. +   else
  852. +     if (*mask & sigmask(SIGPIPE))
  853. +       sig = SIGPIPE;
  854. +   sigpause(sig);
  855. + #else
  856. + # ifdef USE_SIGMASK
  857. +   sigpause(mask);
  858. + # else
  859. +   pause();
  860. + # endif
  861. + #endif
  862. +   return 0;
  863. + }
  864. + #endif /* ! SA_NOCLDSTOP */
  865. + /* This lot (for GNU-Emacs) goes at the end of the file. */
  866. + /* 
  867. +  * Local Variables:
  868. +  * version-control:t
  869. +  * comment-column:40
  870. +  * End:
  871. +  */
  872. *** sh/stdh.h.old    Sat Apr 25 17:44:33 1992
  873. --- sh/stdh.h    Mon Apr 20 22:54:46 1992
  874. ***************
  875. *** 23,39 ****
  876.    *
  877.    */
  878.   
  879. ! #ifndef Void
  880. ! # if defined(__STDC__) || defined(__GNUC__)
  881. ! #   define    ARGS(args)    args    /* prototype declaration */
  882. ! #   define    Void    void        /* generic pointer */
  883. ! #   define    Const    const        /* constant data */
  884. ! #   define    Volatile volatile    /* you know */
  885.   # else
  886. ! #   define    ARGS(args)    ()    /* K&R declaration */
  887. ! #   define    Void    char
  888. ! #   define    Const    
  889. ! #   define    Volatile 
  890.   # endif
  891.   #endif
  892.   
  893. --- 23,38 ----
  894.    *
  895.    */
  896.   
  897. ! #ifndef ARGS
  898. ! # ifdef __STDC__
  899. ! #   define ARGS(args) args
  900.   # else
  901. ! #   define ARGS(args) ()
  902. ! #   ifdef VOID
  903. ! #     define void VOID
  904. ! #   endif
  905. ! #   define const
  906. ! #   define volatile
  907.   # endif
  908.   #endif
  909.   
  910. ***************
  911. *** 54,59 ****
  912. --- 53,60 ----
  913.   /* just in case they have sys/stdtypes and don't know it
  914.    */
  915.   #   ifndef    __sys_stdtypes_h
  916. + #define _PID_T
  917. + #define _CLOCK_T
  918.   typedef int pid_t;
  919.   typedef long clock_t;
  920.   #   endif
  921. ***************
  922. *** 67,82 ****
  923.   # endif
  924.   /* just a useful subset of what stdlib.h would have
  925.    */
  926. ! extern char * getenv  ARGS((Const char *));
  927. ! extern Void * malloc  ARGS((size_t));
  928. ! extern int    free    ARGS((Void *));
  929.   extern int    exit    ARGS((int));
  930. - #endif /* NOSTDHDRS */
  931.   
  932.   /* these _should_ match ANSI */
  933. ! extern char * strstr  ARGS((Const char *, Const char *));
  934. ! extern Void * memmove ARGS((Void *, Const Void *, size_t));
  935. ! extern Void * memcpy  ARGS((Void *, Const Void *, size_t));
  936.     
  937.   
  938.   #ifndef offsetof
  939. --- 68,83 ----
  940.   # endif
  941.   /* just a useful subset of what stdlib.h would have
  942.    */
  943. ! extern char * getenv  ARGS((const char *));
  944. ! extern void * malloc  ARGS((size_t));
  945. ! extern int    free    ARGS((void *));
  946.   extern int    exit    ARGS((int));
  947.   
  948.   /* these _should_ match ANSI */
  949. ! extern char * strstr  ARGS((const char *, const char *));
  950. ! extern void * memmove ARGS((void *, const void *, size_t));
  951. ! extern void * memcpy  ARGS((void *, const void *, size_t));
  952. ! #endif /* NOSTDHDRS */
  953.     
  954.   
  955.   #ifndef offsetof
  956. ***************
  957. *** 83,88 ****
  958.   #define    offsetof(type,id) ((size_t)&((type*)NULL)->id)
  959.   #endif
  960.   
  961. - #if defined(F_SETFD) && !defined(FD_CLEXEC)
  962. - # define FD_CLEXEC 1
  963. - #endif
  964. --- 84,86 ----
  965. *** sh/syn.c.old    Sat Apr 25 17:44:34 1992
  966. --- sh/syn.c    Sat Apr 25 18:37:29 1992
  967. ***************
  968. *** 3,10 ****
  969.    */
  970.   
  971.   #ifndef lint
  972. ! static char *RCSid = "$Id: syn.c,v 3.3 89/03/27 15:51:51 egisin Exp $";
  973. ! static char *sccs_id = "@(#)syn.c    1.2 91/11/22 22:53:52 (sjg)";
  974.   #endif
  975.   
  976.   #include "stdh.h"
  977. --- 3,9 ----
  978.    */
  979.   
  980.   #ifndef lint
  981. ! static char *RCSid = "$Id: syn.c,v 1.2 1992/04/25 08:33:28 sjg Exp $";
  982.   #endif
  983.   
  984.   #include "stdh.h"
  985. ***************
  986. *** 11,30 ****
  987.   #include <errno.h>
  988.   #include <setjmp.h>
  989.   #include "sh.h"
  990. - #include "lex.h"
  991. - #include "tree.h"
  992. - #include "table.h"
  993.   #include "expand.h"
  994.   
  995. ! static    void    zzerr();
  996. ! static    struct    op *block(), *newtp();
  997. ! static    struct    op *pipeline(), *andor(), *command();
  998. ! static    struct    op *nested(), *c_list();
  999. ! static    struct    op *dogroup(), *thenpart(), *casepart(), *caselist();
  1000. ! static    struct    op *elsepart();
  1001. ! static    char  **wordlist();
  1002. ! static    void    musthave();
  1003. ! static    struct ioword *synio(), *io();
  1004.   
  1005.   static    struct    op    *outtree; /* yyparse output */
  1006.   
  1007. --- 10,33 ----
  1008.   #include <errno.h>
  1009.   #include <setjmp.h>
  1010.   #include "sh.h"
  1011.   #include "expand.h"
  1012.   
  1013. ! static struct op *pipeline  ARGS((int cf));
  1014. ! static struct op *andor     ARGS((void));
  1015. ! static struct op *c_list    ARGS((void));
  1016. ! static struct ioword *synio ARGS((int cf));
  1017. ! static void     musthave    ARGS((int c, int cf));
  1018. ! static struct op *nested    ARGS((int type, int mark));
  1019. ! static struct op *command   ARGS((int cf));
  1020. ! static struct op *dogroup   ARGS((int onlydone));
  1021. ! static struct op *thenpart  ARGS((void));
  1022. ! static struct op *elsepart  ARGS((void));
  1023. ! static struct op *caselist  ARGS((void));
  1024. ! static struct op *casepart  ARGS((void));
  1025. ! static char **  wordlist    ARGS((void));
  1026. ! static struct op *block     ARGS((int type, struct op *t1, struct op *t2, char **wp));
  1027. ! static struct op *newtp     ARGS((int type));
  1028. ! static void     zzerr       ARGS((void));
  1029.   
  1030.   static    struct    op    *outtree; /* yyparse output */
  1031.   
  1032. ***************
  1033. *** 102,109 ****
  1034.       t = andor();
  1035.       if (t != NULL) {
  1036.           while ((c = token(0)) == ';' || c == '&' ||
  1037. !                (multiline || source->type == SSTRING
  1038. !                 || source->type == SALIAS) && c == '\n') {
  1039.               if (c == '&') {
  1040.                   if (tl)
  1041.                       tl->right = block(TASYNC, tl->right, NOBLOCK, NOWORDS);
  1042. --- 105,112 ----
  1043.       t = andor();
  1044.       if (t != NULL) {
  1045.           while ((c = token(0)) == ';' || c == '&' ||
  1046. !                ((multiline || source->type == SSTRING
  1047. !                 || (source->type == SALIAS)) && c == '\n')) {
  1048.               if (c == '&') {
  1049.                   if (tl)
  1050.                       tl->right = block(TASYNC, tl->right, NOBLOCK, NOWORDS);
  1051. ***************
  1052. *** 328,338 ****
  1053.       }
  1054.   
  1055.       if (iopn == 0) {
  1056. !         afree((Void*) iops, ATEMP);
  1057.           t->ioact = NULL;
  1058.       } else {
  1059.           iops[iopn++] = NULL;
  1060. !         aresize((Void*) iops, sizeofN(struct ioword *, iopn), ATEMP);
  1061.           t->ioact = iops;
  1062.       }
  1063.   
  1064. --- 331,341 ----
  1065.       }
  1066.   
  1067.       if (iopn == 0) {
  1068. !         afree((void*) iops, ATEMP);
  1069.           t->ioact = NULL;
  1070.       } else {
  1071.           iops[iopn++] = NULL;
  1072. !         aresize((void*) iops, sizeofN(struct ioword *, iopn), ATEMP);
  1073.           t->ioact = iops;
  1074.       }
  1075.   
  1076. ***************
  1077. *** 497,503 ****
  1078.       return (t);
  1079.   }
  1080.   
  1081. ! Const    struct res {
  1082.       char    *name;
  1083.       int    val;
  1084.   } restab[] = {
  1085. --- 500,506 ----
  1086.       return (t);
  1087.   }
  1088.   
  1089. ! const    struct res {
  1090.       char    *name;
  1091.       int    val;
  1092.   } restab[] = {
  1093. ***************
  1094. *** 523,529 ****
  1095.   
  1096.   keywords()
  1097.   {
  1098. !     register struct res Const *rp;
  1099.       register struct tbl *p;
  1100.   
  1101.       for (rp = restab; rp->name; rp++) {
  1102. --- 526,532 ----
  1103.   
  1104.   keywords()
  1105.   {
  1106. !     register struct res const *rp;
  1107.       register struct tbl *p;
  1108.   
  1109.       for (rp = restab; rp->name; rp++) {
  1110. *** sh/table.c.old    Sat Apr 25 17:44:34 1992
  1111. --- sh/table.c    Sat Apr 25 18:37:32 1992
  1112. ***************
  1113. *** 1,6 ****
  1114.   #ifndef lint
  1115. ! static char *RCSid = "$Id: table.c,v 3.2 89/03/27 15:51:58 egisin Exp $";
  1116. ! static char *sccs_id = "@(#)table.c    1.2 91/11/22 22:53:55 (sjg)";
  1117.   #endif
  1118.   
  1119.   /*
  1120. --- 1,5 ----
  1121.   #ifndef lint
  1122. ! static char *RCSid = "$Id: table.c,v 1.2 1992/04/25 08:33:28 sjg Exp $";
  1123.   #endif
  1124.   
  1125.   /*
  1126. ***************
  1127. *** 11,17 ****
  1128.   #include <errno.h>
  1129.   #include <setjmp.h>
  1130.   #include "sh.h"
  1131. - #include "table.h"
  1132.   
  1133.   #define    INIT_TBLS    8    /* initial table size (power of 2) */
  1134.   
  1135. --- 10,15 ----
  1136. ***************
  1137. *** 20,27 ****
  1138.       struct tbl **next;
  1139.   } tstate;
  1140.   
  1141. ! static void texpand();
  1142.   
  1143.   unsigned int
  1144.   hash(n)
  1145.       register char * n;
  1146. --- 18,27 ----
  1147.       struct tbl **next;
  1148.   } tstate;
  1149.   
  1150. ! static void     texpand     ARGS((struct table *tp, int nsize));
  1151. ! static int      tnamecmp    ARGS((void *p1, void *p2));
  1152.   
  1153.   unsigned int
  1154.   hash(n)
  1155.       register char * n;
  1156. ***************
  1157. *** 70,76 ****
  1158.       for (i = 0; i < osize; i++)
  1159.           if ((tblp = otblp[i]) != NULL)
  1160.               if ((tblp->flag&DEFINED)) {
  1161. !                 for (p = &ntblp[hash(tblp->name) & tp->size-1];
  1162.                        *p != NULL; p--)
  1163.                       if (p == ntblp) /* wrap */
  1164.                           p += tp->size;
  1165. --- 70,77 ----
  1166.       for (i = 0; i < osize; i++)
  1167.           if ((tblp = otblp[i]) != NULL)
  1168.               if ((tblp->flag&DEFINED)) {
  1169. !                 for (p = &ntblp[hash(tblp->name) &
  1170. !                         (tp->size-1)];
  1171.                        *p != NULL; p--)
  1172.                       if (p == ntblp) /* wrap */
  1173.                           p += tp->size;
  1174. ***************
  1175. *** 77,85 ****
  1176.                   *p = tblp;
  1177.                   tp->free--;
  1178.               } else {
  1179. !                 afree((Void*)tblp, tp->areap);
  1180.               }
  1181. !     afree((Void*)otblp, tp->areap);
  1182.   }
  1183.   
  1184.   struct tbl *
  1185. --- 78,86 ----
  1186.                   *p = tblp;
  1187.                   tp->free--;
  1188.               } else {
  1189. !                 afree((void*)tblp, tp->areap);
  1190.               }
  1191. !     afree((void*)otblp, tp->areap);
  1192.   }
  1193.   
  1194.   struct tbl *
  1195. ***************
  1196. *** 94,100 ****
  1197.           return NULL;
  1198.   
  1199.       /* search for name in hashed table */
  1200. !     for (pp = &tp->tbls[h & tp->size-1]; (p = *pp) != NULL; pp--) {
  1201.           if (*p->name == *n && strcmp(p->name, n) == 0
  1202.               && (p->flag&DEFINED))
  1203.               return p;
  1204. --- 95,101 ----
  1205.           return NULL;
  1206.   
  1207.       /* search for name in hashed table */
  1208. !     for (pp = &tp->tbls[h & (tp->size-1)]; (p = *pp) != NULL; pp--) {
  1209.           if (*p->name == *n && strcmp(p->name, n) == 0
  1210.               && (p->flag&DEFINED))
  1211.               return p;
  1212. ***************
  1213. *** 118,124 ****
  1214.           texpand(tp, INIT_TBLS);
  1215.     Search:
  1216.       /* search for name in hashed table */
  1217. !     for (pp = &tp->tbls[h & tp->size-1]; (p = *pp) != NULL; pp--) {
  1218.           if (*p->name == *n && strcmp(p->name, n) == 0)
  1219.               return p;     /* found */
  1220.           if (pp == tp->tbls) /* wrap */
  1221. --- 119,125 ----
  1222.           texpand(tp, INIT_TBLS);
  1223.     Search:
  1224.       /* search for name in hashed table */
  1225. !     for (pp = &tp->tbls[h & (tp->size-1)]; (p = *pp) != NULL; pp--) {
  1226.           if (*p->name == *n && strcmp(p->name, n) == 0)
  1227.               return p;     /* found */
  1228.           if (pp == tp->tbls) /* wrap */
  1229. ***************
  1230. *** 174,180 ****
  1231.   
  1232.   static int
  1233.   tnamecmp(p1, p2)
  1234. !     Void *p1, *p2;
  1235.   {
  1236.       return strcmp(((struct tbl *)p1)->name, ((struct tbl *)p2)->name);
  1237.   }
  1238. --- 175,181 ----
  1239.   
  1240.   static int
  1241.   tnamecmp(p1, p2)
  1242. !     void *p1, *p2;
  1243.   {
  1244.       return strcmp(((struct tbl *)p1)->name, ((struct tbl *)p2)->name);
  1245.   }
  1246. ***************
  1247. *** 193,199 ****
  1248.           if ((*dp = *sp++) != NULL && ((*dp)->flag&DEFINED))
  1249.               dp++;
  1250.       i = dp - p;
  1251. !     qsortp((Void**)p, (size_t)i, tnamecmp);
  1252.       p[i] = NULL;
  1253.       return p;
  1254.   }
  1255. --- 194,200 ----
  1256.           if ((*dp = *sp++) != NULL && ((*dp)->flag&DEFINED))
  1257.               dp++;
  1258.       i = dp - p;
  1259. !     qsortp((void**)p, (size_t)i, tnamecmp);
  1260.       p[i] = NULL;
  1261.       return p;
  1262.   }
  1263. *** sh/table.h.old    Sat Apr 25 17:41:37 1992
  1264. --- sh/table.h    Sat Apr 25 18:37:35 1992
  1265. ***************
  1266. *** 1,4 ****
  1267. ! /* $Id: table.h,v 3.2 89/03/27 15:46:52 egisin Exp $ */
  1268.   
  1269.   /*
  1270.    * generic hashed associative table for commands and variables.
  1271. --- 1,4 ----
  1272. ! /* $Id: table.h,v 1.2 1992/04/25 08:33:28 sjg Exp $ */
  1273.   
  1274.   /*
  1275.    * generic hashed associative table for commands and variables.
  1276. ***************
  1277. *** 80,86 ****
  1278.       char   *name;
  1279.       int  (*func)();
  1280.   };
  1281. ! Extern Const struct builtin shbuiltins [], kshbuiltins [];
  1282.   
  1283.   /* var spec values */
  1284.   #define    V_NONE    0
  1285. --- 80,89 ----
  1286.       char   *name;
  1287.       int  (*func)();
  1288.   };
  1289. ! /* these really are externs! Look in table.c for them */
  1290. ! extern const struct builtin shbuiltins [], kshbuiltins [];
  1291.   
  1292.   /* var spec values */
  1293.   #define    V_NONE    0
  1294. *** sh/trace.c.old    Sat Apr 25 17:44:35 1992
  1295. --- sh/trace.c    Sun Apr 19 19:21:42 1992
  1296. ***************
  1297. *** 63,73 ****
  1298.   # define TRUE  1
  1299.   # define FALSE 0
  1300.   #endif
  1301. ! #ifndef _P_
  1302.   # if defined(__STDC__) || defined(PROTO)
  1303. ! #   define _P_(p) p
  1304.   # else
  1305. ! #   define _P_(p) ()
  1306.   # endif
  1307.   #endif
  1308.   
  1309. --- 63,73 ----
  1310.   # define TRUE  1
  1311.   # define FALSE 0
  1312.   #endif
  1313. ! #ifndef ARGS
  1314.   # if defined(__STDC__) || defined(PROTO)
  1315. ! #   define ARGS(p) p
  1316.   # else
  1317. ! #   define ARGS(p) ()
  1318.   # endif
  1319.   #endif
  1320.   
  1321. ***************
  1322. *** 85,91 ****
  1323.    * RETURN VALUE:
  1324.    *      None
  1325.    */
  1326. ! extern char * _CDECL strdup    _P_((char *s));
  1327.     
  1328.   #ifdef __STDC__
  1329.   # include <stdarg.h>
  1330. --- 85,91 ----
  1331.    * RETURN VALUE:
  1332.    *      None
  1333.    */
  1334. ! extern char * _CDECL strdup    ARGS((char *s));
  1335.     
  1336.   #ifdef __STDC__
  1337.   # include <stdarg.h>
  1338. ***************
  1339. *** 109,115 ****
  1340.   checkpoint(va_alist)
  1341.     va_dcl
  1342.   {
  1343. !   extern char *getenv    _P_((char *var));
  1344.     char *fmt;
  1345.     int c;
  1346.     va_list arg_ptr;
  1347. --- 109,115 ----
  1348.   checkpoint(va_alist)
  1349.     va_dcl
  1350.   {
  1351. !   extern char *getenv    ARGS((char *var));
  1352.     char *fmt;
  1353.     int c;
  1354.     va_list arg_ptr;
  1355. *** sh/trace.h.old    Sat Apr 25 17:44:35 1992
  1356. --- sh/trace.h    Sun Apr 19 19:21:43 1992
  1357. ***************
  1358. *** 33,43 ****
  1359.   # define TRUE  1
  1360.   # define FALSE 0
  1361.   #endif
  1362. ! #ifndef _P_
  1363.   # if defined(__STDC__) || defined(PROTO)
  1364. ! #   define _P_(p) p
  1365.   # else
  1366. ! #   define _P_(p) ()
  1367.   # endif
  1368.   #endif
  1369.   
  1370. --- 33,43 ----
  1371.   # define TRUE  1
  1372.   # define FALSE 0
  1373.   #endif
  1374. ! #ifndef ARGS
  1375.   # if defined(__STDC__) || defined(PROTO)
  1376. ! #   define ARGS(p) p
  1377.   # else
  1378. ! #   define ARGS(p) ()
  1379.   # endif
  1380.   #endif
  1381.   
  1382. ***************
  1383. *** 71,77 ****
  1384.   EXTERN char * _CDECL    Trace_log;
  1385.   EXTERN int _CDECL     Trace_level;
  1386.   
  1387. ! void _CDECL checkpoint    _P_((char *fmt, ...));
  1388.   
  1389.   /*
  1390.    * This macro takes a variabel number of args. 
  1391. --- 71,77 ----
  1392.   EXTERN char * _CDECL    Trace_log;
  1393.   EXTERN int _CDECL     Trace_level;
  1394.   
  1395. ! void _CDECL checkpoint    ARGS((char *fmt, ...));
  1396.   
  1397.   /*
  1398.    * This macro takes a variabel number of args. 
  1399.  
  1400. exit 0 # Just in case...
  1401.