home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume26 / pdksh / patch01b < prev    next >
Encoding:
Text File  |  1991-11-25  |  36.5 KB  |  1,583 lines

  1. Newsgroups: comp.sources.misc
  2. From: sjg@zen.void.oz.au (Simon J. Gerraty)
  3. Subject:  v26i072:  pdksh - Public Domain Korn Shell, Version 4, Patch01b/2
  4. Message-ID: <1991Nov26.040159.1946@sparky.imd.sterling.com>
  5. X-Md4-Signature: 1b38b74626a64e8e7e9c62a17f892e61
  6. Date: Tue, 26 Nov 1991 04:01:59 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: sjg@zen.void.oz.au (Simon J. Gerraty)
  10. Posting-number: Volume 26, Issue 72
  11. Archive-name: pdksh/patch01b
  12. Environment: UNIX
  13. Patch-To: pdksh: Volume 25, Issue 47-55
  14.  
  15. This is the second half of patch01
  16.  
  17. --------------------8<--------------------
  18. *** sh/emacs.c.old    Mon Nov 25 13:38:09 1991
  19. --- sh/emacs.c    Mon Nov 25 13:33:14 1991
  20. ***************
  21. *** 11,25 ****
  22.   
  23.   #ifndef lint
  24.   static char *RCSid = "$Id: emacs.c,v 3.2 89/03/27 15:49:17 egisin Exp $";
  25. ! static char *sccs_id = "@(#)emacs.c    1.5 91/11/09 15:35:13 (sjg)";
  26.   #endif
  27.   
  28. ! #include <stddef.h>
  29. ! #include <stdlib.h>
  30. ! #include <string.h>
  31. ! #include <stdio.h>
  32.   #include <signal.h>
  33. - #include <sys/types.h>
  34.   #include <sys/stat.h>
  35.   #include <dirent.h>
  36.   #include <unistd.h>
  37. --- 11,21 ----
  38.   
  39.   #ifndef lint
  40.   static char *RCSid = "$Id: emacs.c,v 3.2 89/03/27 15:49:17 egisin Exp $";
  41. ! static char *sccs_id = "@(#)emacs.c    1.7 91/11/25 13:32:56 (sjg)";
  42.   #endif
  43.   
  44. ! #include "stdh.h"
  45.   #include <signal.h>
  46.   #include <sys/stat.h>
  47.   #include <dirent.h>
  48.   #include <unistd.h>
  49. ***************
  50. *** 74,87 ****
  51.   #define    BEL        0x07
  52.   #define    CMASK        0x7F    /* 7-bit ASCII character mask */
  53.   
  54.   static    int    x_prefix1 = CTRL('['), x_prefix2 = CTRL('X');
  55.   static    char   **x_histp;    /* history position */
  56.   static    char   **x_nextcmdp;    /* for newline-and-next */
  57.   static    char    *xmp;        /* mark pointer */
  58.   static    int    (*x_last_command)();
  59. ! /*static    struct    x_ftab *x_tab[3][128];*/
  60. ! static    struct    x_ftab Const *(*x_tab)[128] = NULL; /* key definition */
  61. ! static    char    *(*x_atab)[128] = NULL; /* macro definitions */
  62.   #define    KILLSIZE    20
  63.   static    char    *killstack[KILLSIZE];
  64.   static    int    killsp, killtp;
  65. --- 70,84 ----
  66.   #define    BEL        0x07
  67.   #define    CMASK        0x7F    /* 7-bit ASCII character mask */
  68.   
  69. + #define X_TABSZ    128            /* size of keydef tables etc */
  70.   static    int    x_prefix1 = CTRL('['), x_prefix2 = CTRL('X');
  71.   static    char   **x_histp;    /* history position */
  72.   static    char   **x_nextcmdp;    /* for newline-and-next */
  73.   static    char    *xmp;        /* mark pointer */
  74.   static    int    (*x_last_command)();
  75. ! static    struct    x_ftab Const *(*x_tab)[X_TABSZ] = NULL; /* key definition */
  76. ! static    char    *(*x_atab)[X_TABSZ] = NULL; /* macro definitions */
  77.   #define    KILLSIZE    20
  78.   static    char    *killstack[KILLSIZE];
  79.   static    int    killsp, killtp;
  80. ***************
  81. *** 1150,1156 ****
  82.   
  83.       ainit(AEDIT);
  84.   
  85. !     x_tab = (struct x_ftab ***) alloc(sizeofN(*x_tab, 3), AEDIT);
  86.       for (j = 0; j < 128; j++)
  87.           x_tab[0][j] = xft_insert;
  88.       for (i = 1; i < 3; i++)
  89. --- 1147,1153 ----
  90.   
  91.       ainit(AEDIT);
  92.   
  93. !     x_tab = (struct x_ftab *(*)[X_TABSZ]) alloc(sizeofN(*x_tab, 3), AEDIT);
  94.       for (j = 0; j < 128; j++)
  95.           x_tab[0][j] = xft_insert;
  96.       for (i = 1; i < 3; i++)
  97. ***************
  98. *** 1160,1166 ****
  99.           if (fp->xf_db_char || fp->xf_db_tab)
  100.               x_tab[fp->xf_db_tab][fp->xf_db_char] = fp;
  101.   
  102. !     x_atab = (char ***) alloc(sizeofN(*x_atab, 3), AEDIT);
  103.       for (i = 1; i < 3; i++)
  104.           for (j = 0; j < 128; j++)
  105.               x_atab[i][j] = NULL;
  106. --- 1157,1163 ----
  107.           if (fp->xf_db_char || fp->xf_db_tab)
  108.               x_tab[fp->xf_db_tab][fp->xf_db_char] = fp;
  109.   
  110. !     x_atab = (char *(*)[X_TABSZ]) alloc(sizeofN(*x_atab, 3), AEDIT);
  111.       for (i = 1; i < 3; i++)
  112.           for (j = 0; j < 128; j++)
  113.               x_atab[i][j] = NULL;
  114. *** sh/eval.c.old    Mon Nov 25 13:38:33 1991
  115. --- sh/eval.c    Fri Nov 22 22:54:14 1991
  116. ***************
  117. *** 2,16 ****
  118.    * Expansion - quoting, separation, substitution, globbing
  119.    */
  120.   
  121.   static char *RCSid = "$Id: eval.c,v 3.4 89/03/27 15:49:55 egisin Exp $";
  122.   
  123. ! #include <stddef.h>
  124. ! #include <stdio.h>
  125. ! #include <string.h>
  126.   #include <errno.h>
  127.   #include <setjmp.h>
  128.   #include <unistd.h>
  129. - #include <sys/types.h>
  130.   #include <dirent.h>
  131.   #include <pwd.h>
  132.   #include "sh.h"
  133. --- 2,16 ----
  134.    * Expansion - quoting, separation, substitution, globbing
  135.    */
  136.   
  137. + #ifndef lint
  138.   static char *RCSid = "$Id: eval.c,v 3.4 89/03/27 15:49:55 egisin Exp $";
  139. + static char *sccs_id = "@(#)eval.c    1.2 91/11/22 22:53:39 (sjg)";
  140. + #endif
  141.   
  142. ! #include "stdh.h"
  143.   #include <errno.h>
  144.   #include <setjmp.h>
  145.   #include <unistd.h>
  146.   #include <dirent.h>
  147.   #include <pwd.h>
  148.   #include "sh.h"
  149. *** sh/exec.c.old    Mon Nov 25 13:38:25 1991
  150. --- sh/exec.c    Mon Nov 25 13:33:15 1991
  151. ***************
  152. *** 4,21 ****
  153.   
  154.   #ifndef lint
  155.   static char *RCSid = "$Id: exec.c,v 3.4 89/03/27 15:50:10 egisin Exp $";
  156. ! static char *sccs_id = "@(#)exec.c    1.3 91/11/09 15:35:22 (sjg)";
  157.   #endif
  158.   
  159. ! #include <stddef.h>
  160. ! #include <stdio.h>
  161. ! #include <string.h>
  162.   #include <errno.h>
  163.   #include <signal.h>
  164.   #include <setjmp.h>
  165.   #include <unistd.h>
  166.   #include <fcntl.h>
  167. - #include <sys/types.h>
  168.   #include <sys/stat.h>
  169.   #include "sh.h"
  170.   #include "lex.h"
  171. --- 4,18 ----
  172.   
  173.   #ifndef lint
  174.   static char *RCSid = "$Id: exec.c,v 3.4 89/03/27 15:50:10 egisin Exp $";
  175. ! static char *sccs_id = "@(#)exec.c    1.6 91/11/25 13:33:03 (sjg)";
  176.   #endif
  177.   
  178. ! #include "stdh.h"
  179.   #include <errno.h>
  180.   #include <signal.h>
  181.   #include <setjmp.h>
  182.   #include <unistd.h>
  183.   #include <fcntl.h>
  184.   #include <sys/stat.h>
  185.   #include "sh.h"
  186.   #include "lex.h"
  187. ***************
  188. *** 31,36 ****
  189. --- 28,67 ----
  190.   #endif
  191.   
  192.   /*
  193. +  * handle systems that don't have F_SETFD
  194. +  */
  195. + #ifndef F_SETFD
  196. + # ifndef MAXFD
  197. + #   define  MAXFD 64
  198. + # endif
  199. + /*
  200. +  * a bit field would be smaller, but this
  201. +  * will work
  202. +  */
  203. + static char clexec_tab[MAXFD+1];
  204. + /* this is so that main() can clear it */
  205. + void
  206. + init_clexec()
  207. + {
  208. +   (void) memset(clexec_tab, 0, sizeof(clexec_tab)-1);
  209. + }
  210. + int
  211. + fd_clexec(fd)
  212. +   int fd;
  213. + {
  214. +   if (fd < sizeof(clexec_tab))
  215. +   {
  216. +     clexec_tab[fd] = 1;
  217. +     return 0;
  218. +   }
  219. +   return -1;
  220. + }
  221. + #endif
  222. + /*
  223.    * execute command tree
  224.    */
  225.   int
  226. ***************
  227. *** 185,193 ****
  228.         case TEXEC:        /* an eval'd TCOM */
  229.           s = t->args[0];
  230.           ap = makenv();
  231. ! #ifdef _MINIX                /* no F_SETFD close-on-exec */
  232. !         for (i = 10; i < 20; i++)
  233. !             close(i);
  234.   #endif
  235.           execve(t->str, t->args, ap);
  236.           if (errno == ENOEXEC) {
  237. --- 216,228 ----
  238.         case TEXEC:        /* an eval'd TCOM */
  239.           s = t->args[0];
  240.           ap = makenv();
  241. ! #ifndef F_SETFD
  242. !         for (i = 0; i < sizeof(clexec_tab); i++)
  243. !           if (clexec_tab[i])
  244. !           {
  245. !             close(i);
  246. !             clexec_tab[i] = 0;
  247. !           }
  248.   #endif
  249.           execve(t->str, t->args, ap);
  250.           if (errno == ENOEXEC) {
  251. *** sh/expr.c.old    Mon Nov 25 13:38:53 1991
  252. --- sh/expr.c    Fri Nov 22 22:54:15 1991
  253. ***************
  254. *** 2,10 ****
  255.    * Korn expression evaluation
  256.    */
  257.   
  258.   static char *RCSid = "$Id: expr.c,v 3.2 89/03/27 15:50:20 egisin Exp $";
  259.   
  260. ! #include <stddef.h>
  261.   #include <errno.h>
  262.   #include <setjmp.h>
  263.   #include "sh.h"
  264. --- 2,13 ----
  265.    * Korn expression evaluation
  266.    */
  267.   
  268. + #ifndef lint
  269.   static char *RCSid = "$Id: expr.c,v 3.2 89/03/27 15:50:20 egisin Exp $";
  270. + static char *sccs_id = "@(#)expr.c    1.2 91/11/22 22:53:42 (sjg)";
  271. + #endif
  272.   
  273. ! #include "stdh.h"
  274.   #include <errno.h>
  275.   #include <setjmp.h>
  276.   #include "sh.h"
  277. *** sh/getopts.c.old    Mon Nov 25 13:39:10 1991
  278. --- sh/getopts.c    Fri Nov 22 22:54:15 1991
  279. ***************
  280. *** 6,15 ****
  281.    * modified for PD ksh by Eric Gisin
  282.    */
  283.   
  284.   static char *RCSid = "$Id: getopts.c,v 3.3 89/03/27 15:50:27 egisin Exp $";
  285.   
  286. ! #include <stddef.h>
  287. ! #include <string.h>
  288.   #include <errno.h>
  289.   #include <setjmp.h>
  290.   #include "sh.h"
  291. --- 6,17 ----
  292.    * modified for PD ksh by Eric Gisin
  293.    */
  294.   
  295. + #ifndef lint
  296.   static char *RCSid = "$Id: getopts.c,v 3.3 89/03/27 15:50:27 egisin Exp $";
  297. + static char *sccs_id = "@(#)getopts.c    1.2 91/11/22 22:53:43 (sjg)";
  298. + #endif
  299.   
  300. ! #include "stdh.h"
  301.   #include <errno.h>
  302.   #include <setjmp.h>
  303.   #include "sh.h"
  304. *** sh/history.c.old    Mon Nov 25 13:38:43 1991
  305. --- sh/history.c    Fri Nov 22 22:54:16 1991
  306. ***************
  307. *** 4,14 ****
  308.    * only implements in-memory history.
  309.    */
  310.   
  311.   static char *RCSid = "$Id: history.c,v 3.3 89/01/27 00:08:27 egisin Exp $";
  312.   
  313. ! #include <stddef.h>
  314. ! #include <stdio.h>
  315. ! #include <string.h>
  316.   #include <errno.h>
  317.   #include <setjmp.h>
  318.   #include "sh.h"
  319. --- 4,15 ----
  320.    * only implements in-memory history.
  321.    */
  322.   
  323. + #ifndef lint
  324.   static char *RCSid = "$Id: history.c,v 3.3 89/01/27 00:08:27 egisin Exp $";
  325. + static char *sccs_id = "@(#)history.c    1.2 91/11/22 22:53:45 (sjg)";
  326. + #endif
  327.   
  328. ! #include "stdh.h"
  329.   #include <errno.h>
  330.   #include <setjmp.h>
  331.   #include "sh.h"
  332. *** sh/io.c.old    Mon Nov 25 13:39:11 1991
  333. --- sh/io.c    Mon Nov 25 13:33:16 1991
  334. ***************
  335. *** 2,12 ****
  336.    * shell buffered IO and formatted output
  337.    */
  338.   
  339.   static char *RCSid = "$Id: io.c,v 3.4 89/03/27 15:50:52 egisin Exp $";
  340.   
  341. ! #include <stddef.h>
  342. ! #include <stdlib.h>
  343. ! #include <stdio.h>
  344.   #include <errno.h>
  345.   #include <unistd.h>
  346.   #include <fcntl.h>
  347. --- 2,13 ----
  348.    * shell buffered IO and formatted output
  349.    */
  350.   
  351. + #ifndef lint
  352.   static char *RCSid = "$Id: io.c,v 3.4 89/03/27 15:50:52 egisin Exp $";
  353. + static char *sccs_id = "@(#)io.c    1.4 91/11/25 13:33:08 (sjg)";
  354. + #endif
  355.   
  356. ! #include "stdh.h"
  357.   #include <errno.h>
  358.   #include <unistd.h>
  359.   #include <fcntl.h>
  360. ***************
  361. *** 135,141 ****
  362. --- 136,146 ----
  363.                   return -1;
  364.               else
  365.                   errorf("too many files open in shell\n");
  366. + #ifdef F_SETFD
  367.           (void) fcntl(nfd, F_SETFD, FD_CLEXEC);
  368. + #else
  369. +         (void) fd_clexec(ttyfd);
  370. + #endif
  371.           close(fd);
  372.       } else
  373.           nfd = fd;
  374. *** sh/jobs.c.old    Mon Nov 25 13:38:19 1991
  375. --- sh/jobs.c    Fri Nov 22 22:54:10 1991
  376. ***************
  377. *** 3,9 ****
  378.    */
  379.   #ifndef lint
  380.   static char *RCSid = "$Id: jobs.c,v 3.5 89/03/27 15:51:01 egisin Exp $";
  381. ! static char  sccs_id[] = "@(#)jobs.c     1.4  91/08/16  17:36:59  (sjg)";
  382.   #endif
  383.   
  384.   /*
  385. --- 3,9 ----
  386.    */
  387.   #ifndef lint
  388.   static char *RCSid = "$Id: jobs.c,v 3.5 89/03/27 15:51:01 egisin Exp $";
  389. ! static char  sccs_id[] = "@(#)jobs.c     1.5  91/11/22  22:53:20  (sjg)";
  390.   #endif
  391.   
  392.   /*
  393. ***************
  394. *** 21,34 ****
  395.    *    There is a simple work-around if there is no SA_RESTART.
  396.    */
  397.   
  398. ! #include <stddef.h>
  399. ! #include <string.h>
  400. ! #include <stdio.h>
  401.   #include <errno.h>
  402.   #include <unistd.h>
  403.   #include <signal.h>
  404.   #include <setjmp.h>
  405. - #include <sys/types.h>
  406.   #include <sys/times.h>
  407.   #include <sys/wait.h>
  408.   #include "sh.h"
  409. --- 21,31 ----
  410.    *    There is a simple work-around if there is no SA_RESTART.
  411.    */
  412.   
  413. ! #include "stdh.h"
  414.   #include <errno.h>
  415.   #include <unistd.h>
  416.   #include <signal.h>
  417.   #include <setjmp.h>
  418.   #include <sys/times.h>
  419.   #include <sys/wait.h>
  420.   #include "sh.h"
  421. ***************
  422. *** 41,48 ****
  423.   #endif
  424.   #endif
  425.   
  426. ! #ifndef WIFCORED
  427. ! #define    WIFCORED(x)    (!!((x)&0x80)) /* non-standard */
  428.   #endif
  429.   
  430.   /* as of P1003.1 Draft 12.3:
  431. --- 38,78 ----
  432.   #endif
  433.   #endif
  434.   
  435. ! #ifdef _BSD
  436. ! /*
  437. !  * These macros are for the benefit of SunOS 4.0.2 and 4.0.3
  438. !  * SunOS 4.1.1 already defines most of them.
  439. !  * Clearly these are aimed at SunOS, they may work for other
  440. !  * BSD systems but I can't promise.
  441. !  */
  442. ! # ifndef WIFSTOPPED
  443. ! #   define WIFSTOPPED(x)    ((x).w_stopval == WSTOPPED)
  444. ! # endif
  445. ! # ifndef WIFSIGNALED
  446. ! #   define WIFSIGNALED(x) ((x).w_stopval != WSTOPPED && (x).w_termsig != 0)
  447. ! # endif
  448. ! # ifndef WIFEXITED
  449. ! #   define WIFEXITED(x)    ((x).w_stopval != WSTOPPED && (x).w_termsig == 0)
  450. ! # endif
  451. ! # ifndef WSTOPSIG
  452. ! #   define WSTOPSIG(x)    ((x).w_stopsig)
  453. ! # endif
  454. ! # ifndef WTERMSIG
  455. ! #   define WTERMSIG(x)    ((x).w_termsig)
  456. ! # endif
  457. ! # ifndef WIFCORED
  458. ! #   define WIFCORED(x)    ((x).w_coredump)
  459. ! # endif
  460. ! # ifndef WEXITSTATUS
  461. ! #   define WEXITSTATUS(x)    ((x).w_retcode)
  462. ! # endif
  463. ! # ifndef HAVE_WAITPID
  464. ! #   define    waitpid(pid, sp, opts)    wait3(sp, opts, (Void*)NULL)
  465. ! # endif
  466. ! #else                    /* not _BSD */
  467. ! # ifndef WIFCORED
  468. ! #   define    WIFCORED(x)    (!!((x)&0x80)) /* non-standard */
  469. ! # endif
  470.   #endif
  471.   
  472.   /* as of P1003.1 Draft 12.3:
  473. ***************
  474. *** 67,72 ****
  475. --- 97,109 ----
  476.   #ifndef    SIGCHLD
  477.   #define    SIGCHLD    SIGCLD
  478.   #endif
  479. + #ifndef WAIT_T
  480. + #ifdef _BSD
  481. + #define WAIT_T union wait
  482. + #else
  483. + #define WAIT_T int
  484. + #endif
  485. + #endif
  486.   
  487.   typedef struct Proc Proc;
  488.   struct Proc {
  489. ***************
  490. *** 78,84 ****
  491.       pid_t    proc;        /* process id */
  492.       pid_t    pgrp;        /* process group if flag[FMONITOR] */
  493.       short    flags;        /* execute flags */
  494. !     int    status;        /* wait status */
  495.       clock_t    utime, stime;    /* user/system time when JDONE */
  496.       char    com [48];    /* command */
  497.   };
  498. --- 115,121 ----
  499.       pid_t    proc;        /* process id */
  500.       pid_t    pgrp;        /* process group if flag[FMONITOR] */
  501.       short    flags;        /* execute flags */
  502. !     WAIT_T    status;        /* wait status */
  503.       clock_t    utime, stime;    /* user/system time when JDONE */
  504.       char    com [48];    /* command */
  505.   };
  506. ***************
  507. *** 454,460 ****
  508.   
  509.       do {
  510.           register Proc *j;
  511. !         int pid, status;
  512.   #ifdef JOBS
  513.           if (flag[FMONITOR])
  514.               pid = waitpid(-1, &status, (WNOHANG|WUNTRACED));
  515. --- 491,498 ----
  516.   
  517.       do {
  518.           register Proc *j;
  519. !         int pid;
  520. !         WAIT_T status;
  521.   #ifdef JOBS
  522.           if (flag[FMONITOR])
  523.               pid = waitpid(-1, &status, (WNOHANG|WUNTRACED));
  524. *** sh/lex.c.old    Mon Nov 25 13:38:35 1991
  525. --- sh/lex.c    Fri Nov 22 22:54:09 1991
  526. ***************
  527. *** 4,15 ****
  528.   
  529.   #ifndef lint
  530.   static char *RCSid = "$Id: lex.c,v 3.6 89/03/27 15:51:20 egisin Exp $";
  531. ! static char *sccs_id = "@(#)lex.c    1.3 91/11/09 15:35:19 (sjg)";
  532.   #endif
  533.   
  534. ! #include <stddef.h>
  535. ! #include <stdio.h>
  536. ! #include <string.h>
  537.   #include <errno.h>
  538.   #include <setjmp.h>
  539.   #include <unistd.h>
  540. --- 4,13 ----
  541.   
  542.   #ifndef lint
  543.   static char *RCSid = "$Id: lex.c,v 3.6 89/03/27 15:51:20 egisin Exp $";
  544. ! static char *sccs_id = "@(#)lex.c    1.4 91/11/22 22:53:17 (sjg)";
  545.   #endif
  546.   
  547. ! #include "stdh.h"
  548.   #include <errno.h>
  549.   #include <setjmp.h>
  550.   #include <unistd.h>
  551. *** sh/mail.c.old    Mon Nov 25 13:38:54 1991
  552. --- sh/mail.c    Fri Nov 22 22:54:16 1991
  553. ***************
  554. *** 2,15 ****
  555.    * Mailbox checking code by Robert J. Gibson, adapted for PD ksh by
  556.    * John R. MacMillan
  557.    */
  558.   
  559. ! #include <stddef.h>
  560. ! #include <stdio.h>
  561. ! #include <string.h>
  562.   #include <signal.h>
  563.   #include <errno.h>
  564.   #include <setjmp.h>
  565. - #include <sys/types.h>
  566.   #include <sys/stat.h>
  567.   #include "sh.h"
  568.   #include "table.h"
  569. --- 2,15 ----
  570.    * Mailbox checking code by Robert J. Gibson, adapted for PD ksh by
  571.    * John R. MacMillan
  572.    */
  573. + #ifndef lint
  574. + static char *sccs_id = "@(#)mail.c    1.2 91/11/22 22:53:47 (sjg)";
  575. + #endif
  576.   
  577. ! #include "stdh.h"
  578.   #include <signal.h>
  579.   #include <errno.h>
  580.   #include <setjmp.h>
  581.   #include <sys/stat.h>
  582.   #include "sh.h"
  583.   #include "table.h"
  584. *** sh/main.c.old    Mon Nov 25 13:38:45 1991
  585. --- sh/main.c    Mon Nov 25 13:33:16 1991
  586. ***************
  587. *** 4,18 ****
  588.   
  589.   #ifndef lint
  590.   static char *RCSid = "$Id: main.c,v 3.3 89/03/27 15:51:39 egisin Exp $";
  591. ! static char *sccs_id = "@(#)main.c    1.3 91/11/09 15:34:27 (sjg)";
  592.   #endif
  593.   
  594.   #define    Extern                /* define Externs in sh.h */
  595.   
  596. ! #include <stddef.h>
  597. ! #include <stdlib.h>
  598. ! #include <stdio.h>
  599. ! #include <string.h>
  600.   #include <unistd.h>
  601.   #include <fcntl.h>
  602.   #include <signal.h>
  603. --- 4,15 ----
  604.   
  605.   #ifndef lint
  606.   static char *RCSid = "$Id: main.c,v 3.3 89/03/27 15:51:39 egisin Exp $";
  607. ! static char *sccs_id = "@(#)main.c    1.6 91/11/25 13:33:06 (sjg)";
  608.   #endif
  609.   
  610.   #define    Extern                /* define Externs in sh.h */
  611.   
  612. ! #include "stdh.h"
  613.   #include <unistd.h>
  614.   #include <fcntl.h>
  615.   #include <signal.h>
  616. ***************
  617. *** 24,29 ****
  618. --- 21,30 ----
  619.   #include "tree.h"
  620.   #include "table.h"
  621.   
  622. + #ifndef HAVE_REMOVE
  623. + #define remove(x)    unlink(x)
  624. + #endif
  625.   /*
  626.    * global data
  627.    */
  628. ***************
  629. *** 100,105 ****
  630. --- 101,109 ----
  631.   
  632.       ainit(&aperm);        /* initialize permanent Area */
  633.   
  634. + #ifndef F_SETFD
  635. +   init_clexec();
  636. + #endif
  637.       /* set up base enviroment */
  638.       e.type = E_NONE;
  639.       ainit(&e.area);
  640. ***************
  641. *** 211,217 ****
  642. --- 215,225 ----
  643.       }
  644.       if (s->type == STTY) {
  645.           ttyfd = fcntl(0, F_DUPFD, FDBASE);
  646. + #ifdef F_SETFD
  647.           (void) fcntl(ttyfd, F_SETFD, FD_CLEXEC);
  648. + #else
  649. +         (void) fd_clexec(ttyfd);
  650. + #endif
  651.   #ifdef EMACS
  652.           x_init_emacs();
  653.   #endif
  654. *** sh/misc.c.old    Mon Nov 25 13:38:56 1991
  655. --- sh/misc.c    Fri Nov 22 22:54:16 1991
  656. ***************
  657. *** 2,17 ****
  658.    * Miscellaneous functions
  659.    */
  660.   
  661.   static char *RCSid = "$Id: misc.c,v 3.2 89/03/27 15:51:44 egisin Exp $";
  662.   
  663. ! #include <stddef.h>
  664. ! #include <limits.h>
  665. ! #include <string.h>
  666.   #include <signal.h>
  667.   #include <errno.h>
  668.   #include <setjmp.h>
  669.   #include "sh.h"
  670.   #include "expand.h"
  671.   
  672.   char ctypes [UCHAR_MAX+1];    /* type bits for unsigned char */
  673.   
  674. --- 2,23 ----
  675.    * Miscellaneous functions
  676.    */
  677.   
  678. + #ifndef lint
  679.   static char *RCSid = "$Id: misc.c,v 3.2 89/03/27 15:51:44 egisin Exp $";
  680. + static char *sccs_id = "@(#)misc.c    1.2 91/11/22 22:53:50 (sjg)";
  681. + #endif
  682.   
  683. ! #include "stdh.h"
  684.   #include <signal.h>
  685.   #include <errno.h>
  686.   #include <setjmp.h>
  687.   #include "sh.h"
  688.   #include "expand.h"
  689. + #ifndef NOSTDHDRS
  690. + # include <limits.h>
  691. + #else
  692. + # define UCHAR_MAX    0xFF
  693. + #endif
  694.   
  695.   char ctypes [UCHAR_MAX+1];    /* type bits for unsigned char */
  696.   
  697. *** sh/sh.h.old    Mon Nov 25 13:38:57 1991
  698. --- sh/sh.h    Fri Nov 22 22:54:11 1991
  699. ***************
  700. *** 8,14 ****
  701.   
  702.   /* allow for non-Unix linkers. main.c has a "#define Extern " */
  703.   #ifndef Extern
  704. ! #define    Extern    extern
  705.   #endif
  706.   
  707.   #ifndef SHELL
  708. --- 8,14 ----
  709.   
  710.   /* allow for non-Unix linkers. main.c has a "#define Extern " */
  711.   #ifndef Extern
  712. ! # define Extern    extern
  713.   #endif
  714.   
  715.   #ifndef SHELL
  716. ***************
  717. *** 16,21 ****
  718. --- 16,22 ----
  719.   #endif
  720.   
  721.   /* some people object to this use of __STDC__ */
  722. + #ifndef Void
  723.   #if __STDC__
  724.   #define    ARGS(args)    args    /* prototype declaration */
  725.   #define    Void    void        /* generic pointer */
  726. ***************
  727. *** 27,32 ****
  728. --- 28,34 ----
  729.   #define    Const    
  730.   #define    Volatile 
  731.   #endif
  732. + #endif
  733.   
  734.   #ifdef _ULTRIX            /* Ultrix 2.x gets dup2 wrong */
  735.   int dup2 ARGS ((int, int));
  736. ***************
  737. *** 140,145 ****
  738. --- 142,148 ----
  739.   /*
  740.    * other functions
  741.    */
  742. + char * substitute ARGS((char Const *, int));
  743.   char   *search();
  744.   struct tbl *findcom();
  745.   char   *strsave ARGS((char *, Area *));
  746. ***************
  747. *** 258,261 ****
  748.    * use my simple debug tracing... 
  749.    */
  750.   #include "trace.h"
  751. --- 261,263 ----
  752. *** /dev/null    Mon Nov 25 11:15:05 1991
  753. --- sh/stdh.h    Mon Nov 25 13:33:17 1991
  754. ***************
  755. *** 0 ****
  756. --- 1,88 ----
  757. + /* NAME:
  758. +  *      stdh.h - standard headers
  759. +  *
  760. +  * SYNOPSIS:
  761. +  *      #include "stdh.h"
  762. +  *
  763. +  * DESCRIPTION:
  764. +  *      We use this header to encapsulate all the stddef et al 
  765. +  *      inclusion so that most of the source can ignore the 
  766. +  *      problems that their lack might cause.
  767. +  *
  768. +  * SEE ALSO:
  769. +  *      
  770. +  *
  771. +  * AMENDED:
  772. +  *      91/11/25  13:33:12  (sjg)
  773. +  *
  774. +  * RELEASED:
  775. +  *      91/11/25  13:33:17  v1.3
  776. +  *
  777. +  * SCCSID:
  778. +  *      @(#)stdh.h  1.3  91/11/25  13:33:12  (sjg)
  779. +  *
  780. +  */
  781. + #ifndef Void
  782. + # if defined(__STDC__) || defined(__GNUC__)
  783. + #   define    ARGS(args)    args    /* prototype declaration */
  784. + #   define    Void    void        /* generic pointer */
  785. + #   define    Const    const        /* constant data */
  786. + #   define    Volatile volatile    /* you know */
  787. + # else
  788. + #   define    ARGS(args)    ()    /* K&R declaration */
  789. + #   define    Void    char
  790. + #   define    Const    
  791. + #   define    Volatile 
  792. + # endif
  793. + #endif
  794. + #include <stdio.h>
  795. + /* if we have std headers then include them here
  796. +  * otherwise make allowances
  797. +  */
  798. + #ifndef NOSTDHDRS
  799. + # include <stddef.h>
  800. + # include <stdlib.h>
  801. + # include <string.h>
  802. + # include <sys/types.h>
  803. + #else
  804. + # ifdef HAVE_SYS_STDTYPES
  805. + #   include <sys/stdtypes.h>
  806. + # else
  807. + #   include <sys/types.h>
  808. + /* just in case they have sys/stdtypes and don't know it
  809. +  */
  810. + #   ifndef    __sys_stdtypes_h
  811. + typedef int pid_t;
  812. + typedef long clock_t;
  813. + #   endif
  814. + # endif
  815. + # ifdef _SYSV
  816. + #   include <string.h>
  817. + # else
  818. + #   include <strings.h>
  819. + #   define strchr index
  820. + #   define strrchr rindex
  821. + # endif
  822. + /* just a useful subset of what stdlib.h would have
  823. +  */
  824. + extern char * getenv  ARGS((Const char *));
  825. + extern Void * malloc  ARGS((size_t));
  826. + extern int    free    ARGS((Void *));
  827. + extern int    exit    ARGS((int));
  828. + #endif /* NOSTDHDRS */
  829. + /* these _should_ match ANSI */
  830. + extern char * strstr  ARGS((Const char *, Const char *));
  831. + extern Void * memmove ARGS((Void *, Const Void *, size_t));
  832. + extern Void * memcpy  ARGS((Void *, Const Void *, size_t));
  833. +   
  834. + #ifndef offsetof
  835. + #define    offsetof(type,id) ((size_t)&((type*)NULL)->id)
  836. + #endif
  837. + #if defined(F_SETFD) && !defined(FD_CLEXEC)
  838. + # define FD_CLEXEC 1
  839. + #endif
  840. *** sh/syn.c.old    Mon Nov 25 13:38:36 1991
  841. --- sh/syn.c    Fri Nov 22 22:54:17 1991
  842. ***************
  843. *** 2,12 ****
  844.    * shell parser (C version)
  845.    */
  846.   
  847.   static char *RCSid = "$Id: syn.c,v 3.3 89/03/27 15:51:51 egisin Exp $";
  848.   
  849. ! #include <stddef.h>
  850. ! #include <stdio.h>
  851. ! #include <string.h>
  852.   #include <errno.h>
  853.   #include <setjmp.h>
  854.   #include "sh.h"
  855. --- 2,13 ----
  856.    * shell parser (C version)
  857.    */
  858.   
  859. + #ifndef lint
  860.   static char *RCSid = "$Id: syn.c,v 3.3 89/03/27 15:51:51 egisin Exp $";
  861. + static char *sccs_id = "@(#)syn.c    1.2 91/11/22 22:53:52 (sjg)";
  862. + #endif
  863.   
  864. ! #include "stdh.h"
  865.   #include <errno.h>
  866.   #include <setjmp.h>
  867.   #include "sh.h"
  868. *** sh/table.c.old    Mon Nov 25 13:38:58 1991
  869. --- sh/table.c    Fri Nov 22 22:54:17 1991
  870. ***************
  871. *** 1,10 ****
  872.   static char *RCSid = "$Id: table.c,v 3.2 89/03/27 15:51:58 egisin Exp $";
  873.   
  874.   /*
  875.    * dynamic hashed associative table for commands and variables
  876.    */
  877.   
  878. ! #include <stddef.h>
  879.   #include <errno.h>
  880.   #include <setjmp.h>
  881.   #include "sh.h"
  882. --- 1,13 ----
  883. + #ifndef lint
  884.   static char *RCSid = "$Id: table.c,v 3.2 89/03/27 15:51:58 egisin Exp $";
  885. + static char *sccs_id = "@(#)table.c    1.2 91/11/22 22:53:55 (sjg)";
  886. + #endif
  887.   
  888.   /*
  889.    * dynamic hashed associative table for commands and variables
  890.    */
  891.   
  892. ! #include "stdh.h"
  893.   #include <errno.h>
  894.   #include <setjmp.h>
  895.   #include "sh.h"
  896. *** sh/trace.c.old    Mon Nov 25 13:38:20 1991
  897. --- sh/trace.c    Fri Nov 22 22:54:18 1991
  898. ***************
  899. *** 30,39 ****
  900.    *      
  901.    *
  902.    * AMENDED:
  903. !  *      %E%  %U%  (%Y%)
  904.    *
  905.    * RELEASED:
  906. !  *      %D%  %T%  v%I%
  907.    *
  908.    *      @(#)Copyright (c) 1990 Simon J. Gerraty.
  909.    */
  910. --- 30,39 ----
  911.    *      
  912.    *
  913.    * AMENDED:
  914. !  *      91/11/22  22:53:56  (sjg)
  915.    *
  916.    * RELEASED:
  917. !  *      91/11/22  22:54:17  v1.2
  918.    *
  919.    *      @(#)Copyright (c) 1990 Simon J. Gerraty.
  920.    */
  921. ***************
  922. *** 40,46 ****
  923.   #ifdef USE_TRACE
  924.   
  925.   #ifndef lint
  926. ! static char  sccs_id[] = "%Z%%M%     %I%  %E%  %U%  (%Y%)";
  927.   #endif
  928.   
  929.   /* include files */
  930. --- 40,46 ----
  931.   #ifdef USE_TRACE
  932.   
  933.   #ifndef lint
  934. ! static char  sccs_id[] = "@(#)trace.c     1.2  91/11/22  22:53:56  (sjg)";
  935.   #endif
  936.   
  937.   /* include files */
  938. *** sh/trace.h.old    Mon Nov 25 13:39:15 1991
  939. --- sh/trace.h    Fri Nov 22 22:54:18 1991
  940. ***************
  941. *** 12,24 ****
  942.    *      
  943.    *
  944.    * AMENDED:
  945. !  *      %E%  %U%  (%Y%)
  946.    *
  947.    * RELEASED:
  948. !  *      %D%  %T%  v%I%
  949.    *
  950.    * SCCSID:
  951. !  *      %Z%%M%  %I%  %E%  %U%  (%Y%)
  952.    *
  953.    *      @(#)Copyright (c) 1990 Simon J. Gerraty.
  954.    */
  955. --- 12,24 ----
  956.    *      
  957.    *
  958.    * AMENDED:
  959. !  *      91/11/22  22:53:58  (sjg)
  960.    *
  961.    * RELEASED:
  962. !  *      91/11/22  22:54:18  v1.2
  963.    *
  964.    * SCCSID:
  965. !  *      @(#)trace.h  1.2  91/11/22  22:53:58  (sjg)
  966.    *
  967.    *      @(#)Copyright (c) 1990 Simon J. Gerraty.
  968.    */
  969. *** sh/trap.c.old    Mon Nov 25 13:39:16 1991
  970. --- sh/trap.c    Fri Nov 22 22:54:19 1991
  971. ***************
  972. *** 2,11 ****
  973.    * signal handling
  974.    */
  975.   
  976.   static char *RCSid = "$Id: trap.c,v 3.2 89/03/27 15:52:06 egisin Exp $";
  977.   
  978. ! #include <stddef.h>
  979. ! #include <string.h>
  980.   #include <errno.h>
  981.   #include <signal.h>
  982.   #include <setjmp.h>
  983. --- 2,13 ----
  984.    * signal handling
  985.    */
  986.   
  987. + #ifndef lint
  988.   static char *RCSid = "$Id: trap.c,v 3.2 89/03/27 15:52:06 egisin Exp $";
  989. + static char *sccs_id = "@(#)trap.c    1.2 91/11/22 22:54:00 (sjg)";
  990. + #endif
  991.   
  992. ! #include "stdh.h"
  993.   #include <errno.h>
  994.   #include <signal.h>
  995.   #include <setjmp.h>
  996. *** sh/tree.c.old    Mon Nov 25 13:38:46 1991
  997. --- sh/tree.c    Fri Nov 22 22:54:19 1991
  998. ***************
  999. *** 2,15 ****
  1000.    * command tree climbing
  1001.    */
  1002.   
  1003.   static char *RCSid = "$Id: tree.c,v 3.2 89/03/27 15:52:13 egisin Exp $";
  1004.   
  1005. ! #include <stddef.h>
  1006. ! #include <string.h>
  1007. ! #include <stdio.h>
  1008.   #include <errno.h>
  1009.   #include <setjmp.h>
  1010. ! #include <varargs.h>
  1011.   #include "sh.h"
  1012.   #include "tree.h"
  1013.   
  1014. --- 2,16 ----
  1015.    * command tree climbing
  1016.    */
  1017.   
  1018. + #ifndef lint
  1019.   static char *RCSid = "$Id: tree.c,v 3.2 89/03/27 15:52:13 egisin Exp $";
  1020. + static char *sccs_id = "@(#)tree.c    1.2 91/11/22 22:54:02 (sjg)";
  1021. + #endif
  1022.   
  1023. ! #include "stdh.h"
  1024.   #include <errno.h>
  1025.   #include <setjmp.h>
  1026. ! #include <varargs.h>            /* TODO: use stdarg */
  1027.   #include "sh.h"
  1028.   #include "tree.h"
  1029.   
  1030. *** sh/ulimit.c.old    Mon Nov 25 13:38:59 1991
  1031. --- sh/ulimit.c    Fri Nov 22 22:54:20 1991
  1032. ***************
  1033. *** 12,20 ****
  1034.       that was originally under case SYSULIMIT in source file "xec.c".
  1035.   */
  1036.   
  1037.   static char *RCSid = "$Id: ulimit.c,v 3.2 89/03/27 15:52:19 egisin Exp $";
  1038.   
  1039. ! #include <stddef.h>
  1040.   #include <errno.h>
  1041.   #include <signal.h>
  1042.   #include <setjmp.h>
  1043. --- 12,23 ----
  1044.       that was originally under case SYSULIMIT in source file "xec.c".
  1045.   */
  1046.   
  1047. + #ifndef lint
  1048.   static char *RCSid = "$Id: ulimit.c,v 3.2 89/03/27 15:52:19 egisin Exp $";
  1049. + static char *sccs_id = "@(#)ulimit.c    1.2 91/11/22 22:54:04 (sjg)";
  1050. + #endif
  1051.   
  1052. ! #include "stdh.h"
  1053.   #include <errno.h>
  1054.   #include <signal.h>
  1055.   #include <setjmp.h>
  1056. *** sh/var.c.old    Mon Nov 25 13:38:11 1991
  1057. --- sh/var.c    Fri Nov 22 22:54:09 1991
  1058. ***************
  1059. *** 1,10 ****
  1060.   #ifndef lint
  1061.   static char *RCSid = "$Id: var.c,v 3.2 89/03/27 15:52:21 egisin Exp $";
  1062. ! static char *sccs_id = "@(#)var.c    1.3 91/11/09 15:35:17 (sjg)";
  1063.   #endif
  1064.   
  1065. ! #include <stddef.h>
  1066. ! #include <string.h>
  1067.   #include <errno.h>
  1068.   #include <setjmp.h>
  1069.   #include <time.h>
  1070. --- 1,9 ----
  1071.   #ifndef lint
  1072.   static char *RCSid = "$Id: var.c,v 3.2 89/03/27 15:52:21 egisin Exp $";
  1073. ! static char *sccs_id = "@(#)var.c    1.4 91/11/22 22:53:13 (sjg)";
  1074.   #endif
  1075.   
  1076. ! #include "stdh.h"
  1077.   #include <errno.h>
  1078.   #include <setjmp.h>
  1079.   #include <time.h>
  1080. ***************
  1081. *** 517,524 ****
  1082. --- 516,525 ----
  1083.   
  1084.   extern    time_t time();
  1085.   static    time_t    seconds;        /* time SECONDS last set */
  1086. + #ifdef NOSTDHDRS
  1087.   extern    int    rand();
  1088.   extern    void    srand();
  1089. + #endif
  1090.   
  1091.   static void
  1092.   getspec(vp)
  1093. *** sh/version.c.old    Mon Nov 25 13:39:26 1991
  1094. --- sh/version.c    Fri Nov 22 22:54:12 1991
  1095. ***************
  1096. *** 4,18 ****
  1097.   
  1098.   #ifndef lint
  1099.   static char *RCSid = "$Id: version.c,v 3.3 89/03/27 15:52:29 egisin Exp $";
  1100. ! static char *sccs_id = "@(#)version.c    4.1 91/11/09 14:55:16 (sjg)";
  1101.   #endif
  1102.   
  1103. ! #include <stddef.h>
  1104.   #include <setjmp.h>
  1105.   #include "sh.h"
  1106.   
  1107.   char ksh_version [] =
  1108. !     "KSH_VERSION=@(#)PD KSH v4.1 91/11/09 14:55:16";
  1109.   
  1110.   /***
  1111.   $Log:    version.c,v $
  1112. --- 4,18 ----
  1113.   
  1114.   #ifndef lint
  1115.   static char *RCSid = "$Id: version.c,v 3.3 89/03/27 15:52:29 egisin Exp $";
  1116. ! static char *sccs_id = "@(#)version.c    4.2 91/11/22 22:53:29 (sjg)";
  1117.   #endif
  1118.   
  1119. ! #include "stdh.h"
  1120.   #include <setjmp.h>
  1121.   #include "sh.h"
  1122.   
  1123.   char ksh_version [] =
  1124. !     "KSH_VERSION=@(#)PD KSH v4.2 91/11/22 22:53:29";
  1125.   
  1126.   /***
  1127.   $Log:    version.c,v $
  1128. *** sh/vi.c.old    Mon Nov 25 13:38:28 1991
  1129. --- sh/vi.c    Fri Nov 22 22:54:07 1991
  1130. ***************
  1131. *** 10,22 ****
  1132.   
  1133.   #ifndef lint
  1134.   static char *RCSid = "$Id: vi.c,v 3.1 89/01/28 15:29:20 egisin Exp $";
  1135. ! static char *sccs_id = "@(#)vi.c    1.3 91/11/09 15:35:09 (sjg)";
  1136.   #endif
  1137.   
  1138. ! #include <stddef.h>
  1139. ! #include <stdlib.h>
  1140. ! #include <string.h>
  1141. ! #include <stdio.h>
  1142.   #include <unistd.h>
  1143.   #include <signal.h>
  1144.   #include <fcntl.h>
  1145. --- 10,19 ----
  1146.   
  1147.   #ifndef lint
  1148.   static char *RCSid = "$Id: vi.c,v 3.1 89/01/28 15:29:20 egisin Exp $";
  1149. ! static char *sccs_id = "@(#)vi.c    1.4 91/11/22 22:53:02 (sjg)";
  1150.   #endif
  1151.   
  1152. ! #include "stdh.h"
  1153.   #include <unistd.h>
  1154.   #include <signal.h>
  1155.   #include <fcntl.h>
  1156. ***************
  1157. *** 1701,1704 ****
  1158.       vecp[1] = NULL;
  1159.       return(eval(vecp, DOBLANK|DOGLOB|DOTILDE));
  1160.       }
  1161. ! #endif /* ifdef VI */
  1162. --- 1698,1701 ----
  1163.       vecp[1] = NULL;
  1164.       return(eval(vecp, DOBLANK|DOGLOB|DOTILDE));
  1165.       }
  1166. ! #endif /* VI */
  1167. *** std/Makefile.old    Mon Nov 25 13:39:26 1991
  1168. --- std/Makefile    Fri Nov 22 22:48:58 1991
  1169. ***************
  1170. *** 3,8 ****
  1171. --- 3,9 ----
  1172.   #
  1173.   
  1174.   SHELL = /bin/sh
  1175. + MAKE  = make
  1176.   
  1177.   #CONFIG = -D_SYSV
  1178.   CONFIG = -D_BSD
  1179. ***************
  1180. *** 9,28 ****
  1181.   
  1182.   LN = ln
  1183.   
  1184. ! libs:    h libstdc.a #libposix.a
  1185.   
  1186.   h:
  1187.       mkdir h
  1188. !     ( cd stdc ; $(MAKE) 'CC=$(CC)' 'CONFIG=$(CONFIG)' clobber link )
  1189. !     ( cd posix  ; $(MAKE) 'CC=$(CC)' 'CONFIG=$(CONFIG)' clobber link )
  1190.   
  1191.   libstdc.a: FORCED
  1192. !     ( cd stdc ; $(MAKE) 'CC=$(CC)' 'CONFIG=$(CONFIG)' $@ )
  1193. !     -$(LN) stdc/$@ $@
  1194.   
  1195.   libposix.a: FORCED
  1196. !     ( cd posix ; $(MAKE) 'CC=$(CC)' 'CONFIG=$(CONFIG)' $@ )
  1197. !     -$(LN) posix/$@ .
  1198.   
  1199.   clean:
  1200.       -rm -f *.out
  1201. --- 10,28 ----
  1202.   
  1203.   LN = ln
  1204.   
  1205. ! libs:    h libstdc.a libposix.a
  1206.   
  1207.   h:
  1208.       mkdir h
  1209. !     ( cd stdc ; $(MAKE) 'CC=$(CC)' 'CONFIG=$(CONFIG)' 'LN=$(LN)' clobber link )
  1210. !     ( cd posix  ; $(MAKE) 'CC=$(CC)' 'CONFIG=$(CONFIG)' 'LN=$(LN)' clobber link )
  1211. !     ( cd ../sh ;  $(MAKE) 'CC=$(CC)' 'CONFIG=$(CONFIG)' 'LN=$(LN)' link )
  1212.   
  1213.   libstdc.a: FORCED
  1214. !     ( cd stdc ; $(MAKE) 'CC=$(CC)' 'CONFIG=$(CONFIG)' all )
  1215.   
  1216.   libposix.a: FORCED
  1217. !     ( cd posix ; $(MAKE) 'CC=$(CC)' 'CONFIG=$(CONFIG)' all )
  1218.   
  1219.   clean:
  1220.       -rm -f *.out
  1221. *** /dev/null    Mon Nov 25 11:15:05 1991
  1222. --- std/mklinks    Fri Nov 22 21:21:12 1991
  1223. ***************
  1224. *** 0 ****
  1225. --- 1,14 ----
  1226. + :
  1227. + # Make links 
  1228. + # we do it this way so that we can support symlinks
  1229. + # easily.
  1230. + src=`pwd`
  1231. + cd $1
  1232. + shift
  1233. + LN="${LN:-ln}"
  1234. + for f in $*
  1235. + do
  1236. +   $LN $src/$f .
  1237. + done
  1238. *** /dev/null    Mon Nov 25 11:15:05 1991
  1239. --- std/posix/ChangeLog    Mon Nov 25 13:18:09 1991
  1240. ***************
  1241. *** 0 ****
  1242. --- 1,4 ----
  1243. + Mon Nov 25 13:17:04 1991  Simon J. Gerraty  (sjg at zen)
  1244. +     * wait.h: use "/./usr/include/sys/wait.h for sun's
  1245. *** std/posix/Makefile.old    Mon Nov 25 13:39:28 1991
  1246. --- std/posix/Makefile    Mon Nov 25 13:34:01 1991
  1247. ***************
  1248. *** 1,10 ****
  1249.   # POSIX P1003.1 compatability
  1250.   
  1251.   SHELL = /bin/sh
  1252.   
  1253. - # This is for the sun386i your mileage may vary :-)
  1254. - #CC=gcc -ansi -Dsun386 -Dsun -Di386
  1255.   #CONFIG = -D_SYSV
  1256.   CONFIG = -D_BSD
  1257.   
  1258. --- 1,9 ----
  1259.   # POSIX P1003.1 compatability
  1260. + # @(#)Makefile 1.3 91/11/25 13:33:57
  1261.   
  1262.   SHELL = /bin/sh
  1263. + MAKE  = make
  1264.   
  1265.   #CONFIG = -D_SYSV
  1266.   CONFIG = -D_BSD
  1267.   
  1268. ***************
  1269. *** 12,26 ****
  1270.   RANLIB = ranlib        # For BSD systems
  1271.   #RANLIB = echo Updated
  1272.   
  1273. ! LIB = libposix.a
  1274.   INCL = ../h
  1275.   
  1276.   CFLAGS = $(CCOPTS) -I$(INCL) $(CONFIG)
  1277.   
  1278.   MISC =    Makefile 
  1279. ! HDRS =    io.h wait.h times.h unistd.h fcntl.h dirent.h 
  1280.   SRCS =    unistd.c fcntl.c times.c dup2.c
  1281. ! OBJS =    unistd.o fcntl.o times.o dup2.o
  1282.   
  1283.   all:    $(LIB)
  1284.   
  1285. --- 11,30 ----
  1286.   RANLIB = ranlib        # For BSD systems
  1287.   #RANLIB = echo Updated
  1288.   
  1289. ! LIB = ../libposix.a
  1290.   INCL = ../h
  1291.   
  1292.   CFLAGS = $(CCOPTS) -I$(INCL) $(CONFIG)
  1293.   
  1294.   MISC =    Makefile 
  1295. ! HDRS =    io.h unistd.h fcntl.h dirent.h 
  1296. ! SYSHDRS = wait.h time.h times.h
  1297.   SRCS =    unistd.c fcntl.c times.c dup2.c
  1298. ! OBJS =    $(LIB)(unistd.o) \
  1299. !     $(LIB)(fcntl.o) \
  1300. !     $(LIB)(times.o) \
  1301. !     $(LIB)(dup2.o)
  1302.   
  1303.   all:    $(LIB)
  1304.   
  1305. ***************
  1306. *** 27,38 ****
  1307.   link:    $(HDRS)
  1308.       [ -d $(INCL) ] || mkdir $(INCL)
  1309.       [ -d $(INCL)/sys ] || mkdir $(INCL)/sys
  1310. !     -$(LN) wait.h time.h times.h $(INCL)/sys
  1311. !     -$(LN) io.h fcntl.h unistd.h $(INCL)
  1312. !     -if [ ! -r /usr/include/unistd.h ]; then $(LN) dirent.h $(INCL); fi
  1313.   
  1314.   $(LIB):    $(OBJS)
  1315. !     ar r $@ $?
  1316.       $(RANLIB) $@
  1317.   
  1318.   clean:
  1319. --- 31,44 ----
  1320.   link:    $(HDRS)
  1321.       [ -d $(INCL) ] || mkdir $(INCL)
  1322.       [ -d $(INCL)/sys ] || mkdir $(INCL)/sys
  1323. !     ($(SHELL) ../mklinks $(INCL) $(HDRS))
  1324. !     ($(SHELL) ../mklinks $(INCL)/sys $(SYSHDRS))
  1325. !     -if [ -r /usr/include/unistd.h ]; then $(RM) $(INCL)/unistd.h; fi 
  1326.   
  1327.   $(LIB):    $(OBJS)
  1328. ! # if you make doesn't know how to put objects in libraries
  1329. ! # then simply make all the .o's and use the following line
  1330. ! #    ar r $@ $?
  1331.       $(RANLIB) $@
  1332.   
  1333.   clean:
  1334. *** std/posix/fcntl.h.old    Mon Nov 25 13:39:32 1991
  1335. --- std/posix/fcntl.h    Mon Nov 25 13:34:02 1991
  1336. ***************
  1337. *** 1,6 ****
  1338.   /* P1003.1 fcntl/open definitions */
  1339.   /* Based on a version by Terrence W. Holm */
  1340.   /*  for fcntl(2)  */
  1341.   
  1342.   #define    F_DUPFD        0
  1343. --- 1,6 ----
  1344.   /* P1003.1 fcntl/open definitions */
  1345.   /* Based on a version by Terrence W. Holm */
  1346. ! /* @(#)fcntl.h    1.3 91/11/25 13:34:00 (sjg) */
  1347.   /*  for fcntl(2)  */
  1348.   
  1349.   #define    F_DUPFD        0
  1350. *** std/posix/wait.h.old    Mon Nov 25 13:39:36 1991
  1351. --- std/posix/wait.h    Mon Nov 25 13:34:02 1991
  1352. ***************
  1353. *** 7,19 ****
  1354.   #define    ARGS(args)    ()
  1355.   #endif
  1356.   
  1357. ! #ifndef sparc
  1358.   typedef int pid_t;        /* belong in sys/types.h */
  1359.   #endif
  1360.   
  1361. ! #ifdef sparc
  1362. ! # include "/usr/include/sys/wait.h"
  1363.   #else
  1364.   
  1365.   /* waitpid options */
  1366.   #define WNOHANG        1    /* don't hang in wait */
  1367. --- 7,23 ----
  1368.   #define    ARGS(args)    ()
  1369.   #endif
  1370.   
  1371. ! #ifdef HAVE_SYS_STDTYPES
  1372. ! # include <sys/stdtypes.h>
  1373. ! #else
  1374.   typedef int pid_t;        /* belong in sys/types.h */
  1375.   #endif
  1376.   
  1377. ! #ifdef sun
  1378. ! # include "/./usr/include/sys/wait.h"
  1379.   #else
  1380. + #define WAIT_T int
  1381.   
  1382.   /* waitpid options */
  1383.   #define WNOHANG        1    /* don't hang in wait */
  1384. *** /dev/null    Mon Nov 25 11:15:05 1991
  1385. --- std/stdc/ChangeLog    Mon Nov 25 13:19:37 1991
  1386. ***************
  1387. *** 0 ****
  1388. --- 1,5 ----
  1389. + Mon Nov 25 13:19:01 1991  Simon J. Gerraty  (sjg at zen)
  1390. +     * Added all source modules to Makefile, but most remain commented
  1391. +     out as they are untested.
  1392. *** std/stdc/Makefile.old    Mon Nov 25 13:39:37 1991
  1393. --- std/stdc/Makefile    Mon Nov 25 13:24:29 1991
  1394. ***************
  1395. *** 1,10 ****
  1396.   # Standard C (ANSI) compatabilaty
  1397.   
  1398.   SHELL = /bin/sh
  1399.   
  1400. - # This is for the sun386i your mileage may vary :-)
  1401. - #CC=gcc -ansi -Dsun386 -Dsun -Di386
  1402.   #CONFIG = -D_SYSV
  1403.   CONFIG = -D_BSD
  1404.   
  1405. --- 1,12 ----
  1406.   # Standard C (ANSI) compatabilaty
  1407. + # @(#)Makefile 1.3 91/11/25 13:24:27
  1408.   
  1409. + # edit this makefile such that only the functions that
  1410. + # your systems doesn't have are provided.
  1411.   SHELL = /bin/sh
  1412. + MAKE  = make
  1413.   
  1414.   #CONFIG = -D_SYSV
  1415.   CONFIG = -D_BSD
  1416.   
  1417. ***************
  1418. *** 12,18 ****
  1419.   RANLIB = ranlib        # For BSD systems
  1420.   #RANLIB = echo Updated
  1421.   
  1422. ! LIB = libstdc.a
  1423.   INCL = ../h
  1424.   
  1425.   CFLAGS = $(CCOPTS) -I$(INCL) $(CONFIG)
  1426. --- 14,20 ----
  1427.   RANLIB = ranlib        # For BSD systems
  1428.   #RANLIB = echo Updated
  1429.   
  1430. ! LIB = ../libstdc.a
  1431.   INCL = ../h
  1432.   
  1433.   CFLAGS = $(CCOPTS) -I$(INCL) $(CONFIG)
  1434. ***************
  1435. *** 19,37 ****
  1436.   
  1437.   MISC =    Makefile stdio.h_std
  1438.   HDRS =    limits.h stddef.h stdlib.h string.h time.h stdarg.h 
  1439. ! SRCS =    strstr.c memmove.c stdio.c #clock.c
  1440. ! OBJS =    strstr.o memmove.o stdio.o #clock.o 
  1441.   
  1442.   all:    $(LIB)
  1443.   
  1444.   link:    $(HDRS) stdio.h 
  1445.       [ -d $(INCL) ] || mkdir $(INCL)
  1446.       [ -d $(INCL)/sys ] || mkdir $(INCL)/sys
  1447. !     -$(LN) types.h $(INCL)/sys
  1448. !     -$(LN) limits.h stddef.h stdlib.h stdio.h string.h time.h stdarg.h $(INCL)
  1449.   
  1450.   $(LIB):    $(OBJS)
  1451. !     ar r $@ $?
  1452.       $(RANLIB) $@
  1453.   
  1454.   stdio.h: stdio.h_std stdio.sed /usr/include/stdio.h 
  1455. --- 21,79 ----
  1456.   
  1457.   MISC =    Makefile stdio.h_std
  1458.   HDRS =    limits.h stddef.h stdlib.h string.h time.h stdarg.h 
  1459. ! SYSHDRS = types.h
  1460.   
  1461. + SRCS =    strstr.c memmove.c stdio.c clock.c fprintf.c memchr.c \
  1462. +     memcmp.c memcpy.c memset.c setvbuf.c sprintf.c \
  1463. +     stdio.c strcat.c strchr.c strcmp.c strcpy.c strcspn.c \
  1464. +     strerror.c strlen.c strncat.c strncmp.c strncpy.c \
  1465. +     strpbrk.c strrchr.c strspn.c strtok.c vprintf.c
  1466. + # only add to this list the modules that you _need_
  1467. + # some of these are untested!
  1468. + OBJS =    $(LIB)(strstr.o) \
  1469. +     $(LIB)(memmove.o) \
  1470. +     $(LIB)(stdio.o) \
  1471. +     $(LIB)(clock.o) \
  1472. + #    $(LIB)(fprintf.o) \
  1473. + #    $(LIB)(vprintf.o) \
  1474. + #    $(LIB)(strtok.o) \
  1475. + #    $(LIB)(memchr.o) \
  1476. + #    $(LIB)(memcmp.o) \
  1477. + #    $(LIB)(memcpy.o) \
  1478. + #    $(LIB)(memset.o) \
  1479. + #    $(LIB)(setvbuf.o) \
  1480. + #    $(LIB)(sprintf.o) \
  1481. + #    $(LIB)(stdio.o) \
  1482. + #    $(LIB)(strcat.o) \
  1483. + #    $(LIB)(strchr.o) \
  1484. + #    $(LIB)(strcmp.o) \
  1485. + #    $(LIB)(strcpy.o) \
  1486. + #    $(LIB)(strcspn.o) \
  1487. + #    $(LIB)(strerror.o) \
  1488. + #    $(LIB)(strlen.o) \
  1489. + #    $(LIB)(strncat.o) \
  1490. + #    $(LIB)(strncmp.o) \
  1491. + #    $(LIB)(strncpy.o) \
  1492. + #    $(LIB)(strpbrk.o) \
  1493. + #    $(LIB)(strrchr.o) \
  1494. + #    $(LIB)(strspn.o) \
  1495.   all:    $(LIB)
  1496.   
  1497.   link:    $(HDRS) stdio.h 
  1498.       [ -d $(INCL) ] || mkdir $(INCL)
  1499.       [ -d $(INCL)/sys ] || mkdir $(INCL)/sys
  1500. !     ($(SHELL) ../mklinks $(INCL) stdio.h $(HDRS))
  1501. !     ($(SHELL) ../mklinks $(INCL)/sys $(SYSHDRS))
  1502.   
  1503.   $(LIB):    $(OBJS)
  1504. ! # if you make doesn't know how to put objects in libraries
  1505. ! # then simply make all the .o's and use the following line
  1506. ! #    ar r $@ $?
  1507.       $(RANLIB) $@
  1508.   
  1509.   stdio.h: stdio.h_std stdio.sed /usr/include/stdio.h 
  1510. *** std/stdc/memmove.c.old    Mon Nov 25 13:39:41 1991
  1511. --- std/stdc/memmove.c    Fri Nov 22 22:49:38 1991
  1512. ***************
  1513. *** 1,6 ****
  1514.   /* $Header$ */
  1515.   
  1516. ! #include <string.h>
  1517.   
  1518.   Void *
  1519.   memmove(dap, sap, n)
  1520. --- 1,9 ----
  1521.   /* $Header$ */
  1522. + #ifndef lint
  1523. + static char *sccs_id = "@(#)memmove.c    1.2 91/11/22 22:49:36 (sjg)";
  1524. + #endif
  1525.   
  1526. ! #include "stdh.h"
  1527.   
  1528.   Void *
  1529.   memmove(dap, sap, n)
  1530. *** std/stdc/strstr.c.old    Mon Nov 25 13:39:55 1991
  1531. --- std/stdc/strstr.c    Fri Nov 22 22:49:38 1991
  1532. ***************
  1533. *** 1,4 ****
  1534. ! #include <string.h>
  1535.   
  1536.   /*
  1537.    * strstr - find first occurrence of wanted in s
  1538. --- 1,8 ----
  1539. ! #ifndef lint
  1540. ! static char *sccs_id = "@(#)strstr.c    1.2 91/11/22 22:49:34 (sjg)";
  1541. ! #endif
  1542. ! #include "stdh.h"
  1543.   
  1544.   /*
  1545.    * strstr - find first occurrence of wanted in s
  1546.  
  1547. exit 0 # Just in case...
  1548. -- 
  1549. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1550. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1551. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1552. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1553.