home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume14 / ms_sh-1.6 / patch02 / Patch1.6.3 < prev   
Encoding:
Text File  |  1990-08-29  |  35.5 KB  |  1,437 lines

  1. Index: Notes1.6
  2. *** ../sh16.2/Notes1.6    Tue Jun 26 19:46:22 1990
  3. --- Notes1.6    Fri Aug 17 21:29:59 1990
  4. ***************
  5. *** 1,4 ****
  6. ! Version 1.6.2 Release Notes:
  7.   
  8.   Note: Release 1.6.1 did occur to comp.ibm.pc.binaries.  However, the
  9.   transmission was corrupt and by the time I was notified (the moderator having
  10. --- 1,4 ----
  11. ! Version 1.6.3 Release Notes:
  12.   
  13.   Note: Release 1.6.1 did occur to comp.ibm.pc.binaries.  However, the
  14.   transmission was corrupt and by the time I was notified (the moderator having
  15. ***************
  16. *** 35,40 ****
  17. --- 35,46 ----
  18.     18.    The directory routines have been modified to correctly handle
  19.       all valid Unix format directory names (ie a Unix directory name
  20.       can end in /.  However, DOS does not think this is a directory).
  21. +   19.    A bug in director.c which caused the shell to crash or hang has
  22. +     been fixed.
  23. +   20.    The DOS 4 command processor does not like the use of switchar.
  24. +     The code has been fixed to cope with DOS 4.
  25. +   21.    A bug in the processing of functions has been fixed which caused
  26. +     the shell to crash or hang has been fixed.
  27.   
  28.   The following enhancements have been made:
  29.   
  30. ***************
  31. *** 69,74 ****
  32. --- 75,83 ----
  33.       data and stack space after the first write.
  34.      19.    The ms_dio function have been enhanced to support raw and block
  35.       devices (well not really - just the stat and fstat functions).
  36. +    20.  The POSIX variable substitution command ${#name} to give the
  37. +     string length has been implemented.
  38. +    21.  The POSIX I/O option <> has been implemented.
  39.   
  40.   The following enhancements/bugs remain outstanding:
  41.   
  42. Index: ReadMe
  43. Prereq: 1.7
  44. *** ../sh16.2/ReadMe    Fri Apr  6 17:58:18 1990
  45. --- ReadMe    Fri Aug 17 21:31:12 1990
  46. ***************
  47. *** 13,21 ****
  48.    2.  The sources (or parts thereof) or objects generated from the
  49.        sources (or parts of sources) cannot be sold under any circumstances.
  50.   
  51. !     $Header: readme 1.7 90/04/03 18:07:01 MS_user Exp $
  52.   
  53.       $Log:    readme $
  54.       Revision 1.7  90/04/03  18:07:01  MS_user
  55.       Some changes for 1.6 (Int 24 and Config file)
  56.       
  57. --- 13,24 ----
  58.    2.  The sources (or parts thereof) or objects generated from the
  59.        sources (or parts of sources) cannot be sold under any circumstances.
  60.   
  61. !     $Header: C:/SRC/SHELL/RCS/readme 1.8 90/08/15 01:18:53 MS_user Exp $
  62.   
  63.       $Log:    readme $
  64. +     Revision 1.8  90/08/15  01:18:53  MS_user
  65. +     Add 1.6.3 comment
  66. +     
  67.       Revision 1.7  90/04/03  18:07:01  MS_user
  68.       Some changes for 1.6 (Int 24 and Config file)
  69.       
  70. ***************
  71. *** 107,112 ****
  72. --- 110,117 ----
  73.       Unix V.4.
  74.   
  75.   11) A configuration file is supported to allow edit key specification.
  76. + 12) The support of POSIX P1003.2 commands has been started.
  77.   
  78.   The shell was built using MS-DOS C and MASM v5.1 in large model mode.
  79.   
  80. Index: lib/director.c
  81. *** ../sh16.2/lib/director.c    Fri Jun 22 09:18:24 1990
  82. --- lib/director.c    Fri Aug 17 21:31:57 1990
  83. ***************
  84. *** 20,28 ****
  85.   #include <dos.h>
  86.   
  87.   #define    ATTRIBUTES        (_A_SUBDIR | _A_HIDDEN | _A_SYSTEM | \
  88. !                  _A_NORMAL | _A_RDONLY | _A_ARCH | _A_VOLID)
  89.   
  90. ! static void    free_dircontents (struct _dircontents *);
  91.   
  92.   DIR    *opendir(name)
  93.   char    *name;
  94. --- 20,29 ----
  95.   #include <dos.h>
  96.   
  97.   #define    ATTRIBUTES        (_A_SUBDIR | _A_HIDDEN | _A_SYSTEM | \
  98. !                  _A_NORMAL | _A_RDONLY | _A_ARCH)
  99.   
  100. ! typedef struct _dircontents    DIRCONT;
  101. ! static void            free_dircontents (DIRCONT *);
  102.   
  103.   DIR    *opendir(name)
  104.   char    *name;
  105. ***************
  106. *** 30,36 ****
  107.       struct stat        statb;
  108.       DIR            *dirp;
  109.       char        *last;
  110. !     struct _dircontents    *dp;
  111.       char        *nbuf;
  112.       struct find_t    dtabuf;
  113.       int            len = strlen (name);
  114. --- 31,37 ----
  115.       struct stat        statb;
  116.       DIR            *dirp;
  117.       char        *last;
  118. !     DIRCONT        *dp;
  119.       char        *nbuf;
  120.       struct find_t    dtabuf;
  121.       int            len = strlen (name);
  122. ***************
  123. *** 41,47 ****
  124.       return (DIR *)NULL;
  125.       }
  126.   
  127. !     if ((nbuf = malloc (len + 4)) == (char *)NULL)
  128.       return (DIR *) NULL;
  129.   
  130.       strcpy (nbuf, name);
  131. --- 42,48 ----
  132.       return (DIR *)NULL;
  133.       }
  134.   
  135. !     if ((nbuf = malloc (len + 5)) == (char *)NULL)
  136.       return (DIR *) NULL;
  137.   
  138.       strcpy (nbuf, name);
  139. ***************
  140. *** 90,97 ****
  141.       strcat (last, "*.*");
  142.   
  143.       dirp->dd_loc      = 0;
  144. !     dirp->dd_cp       = (struct _dircontents *) NULL;
  145. !     dirp->dd_contents = (struct _dircontents *) NULL;
  146.   
  147.       if (_dos_findfirst (nbuf, ATTRIBUTES, &dtabuf) != 0)
  148.       {
  149. --- 91,98 ----
  150.       strcat (last, "*.*");
  151.   
  152.       dirp->dd_loc      = 0;
  153. !     dirp->dd_cp       = (DIRCONT *) NULL;
  154. !     dirp->dd_contents = (DIRCONT *) NULL;
  155.   
  156.       if (_dos_findfirst (nbuf, ATTRIBUTES, &dtabuf) != 0)
  157.       {
  158. ***************
  159. *** 101,124 ****
  160.   
  161.       do 
  162.       {
  163. !     if (((dp = (struct _dircontents *) malloc (sizeof (struct _dircontents))) == (struct _dircontents *) NULL) ||
  164.           ((dp->_d_entry = strdup (dtabuf.name)) == (char *) NULL))
  165.       {
  166.           if (dp != (char *)NULL)
  167. !         free ((char *) dp);
  168.   
  169.           free (nbuf);
  170.           free_dircontents (dirp->dd_contents);
  171.           return (DIR *) NULL;
  172.       }
  173.   
  174. !     if (dirp->dd_contents)
  175.           dirp->dd_cp = dirp->dd_cp->_d_next = dp;
  176.   
  177.       else
  178.           dirp->dd_contents = dirp->dd_cp = dp;
  179.   
  180. !     dp->_d_next = (struct _dircontents *) NULL;
  181.   
  182.       } while (_dos_findnext (&dtabuf) == 0);
  183.   
  184. --- 102,125 ----
  185.   
  186.       do 
  187.       {
  188. !     if (((dp = (DIRCONT *) malloc (sizeof (DIRCONT))) == (DIRCONT *)NULL) ||
  189.           ((dp->_d_entry = strdup (dtabuf.name)) == (char *) NULL))
  190.       {
  191.           if (dp != (char *)NULL)
  192. !         free ((char *)dp);
  193.   
  194.           free (nbuf);
  195.           free_dircontents (dirp->dd_contents);
  196.           return (DIR *) NULL;
  197.       }
  198.   
  199. !     if (dirp->dd_contents != (DIRCONT *) NULL)
  200.           dirp->dd_cp = dirp->dd_cp->_d_next = dp;
  201.   
  202.       else
  203.           dirp->dd_contents = dirp->dd_cp = dp;
  204.   
  205. !     dp->_d_next = (DIRCONT *) NULL;
  206.   
  207.       } while (_dos_findnext (&dtabuf) == 0);
  208.   
  209. ***************
  210. *** 132,138 ****
  211.   DIR    *dirp;
  212.   {
  213.       free_dircontents (dirp->dd_contents);
  214. !     free ((char *) dirp);
  215.       return 0;
  216.   }
  217.   
  218. --- 133,139 ----
  219.   DIR    *dirp;
  220.   {
  221.       free_dircontents (dirp->dd_contents);
  222. !     free ((char *)dirp);
  223.       return 0;
  224.   }
  225.   
  226. ***************
  227. *** 141,147 ****
  228.   {
  229.       static struct dirent    dp;
  230.       
  231. !     if (dirp->dd_cp == (struct _dircontents *) NULL)
  232.       return (struct dirent *) NULL;
  233.   
  234.       dp.d_reclen = strlen (strcpy (dp.d_name, dirp->dd_cp->_d_entry));
  235. --- 142,148 ----
  236.   {
  237.       static struct dirent    dp;
  238.       
  239. !     if (dirp->dd_cp == (DIRCONT *) NULL)
  240.       return (struct dirent *) NULL;
  241.   
  242.       dp.d_reclen = strlen (strcpy (dp.d_name, dirp->dd_cp->_d_entry));
  243. ***************
  244. *** 163,175 ****
  245.   DIR    *dirp;
  246.   off_t    off;
  247.   {
  248. !     long        i = off;
  249. !     struct _dircontents    *dp;
  250.   
  251.       if (off < 0L)
  252.       return;
  253.   
  254. !     for (dp = dirp->dd_contents ; --i >= 0 && dp ; dp = dp->_d_next)
  255.       ;
  256.   
  257.       dirp->dd_loc = off - (i + 1);
  258. --- 164,177 ----
  259.   DIR    *dirp;
  260.   off_t    off;
  261.   {
  262. !     long    i = off;
  263. !     DIRCONT    *dp;
  264.   
  265.       if (off < 0L)
  266.       return;
  267.   
  268. !     for (dp = dirp->dd_contents; (--i >= 0) && (dp != (DIRCONT *)NULL);
  269. !      dp = dp->_d_next)
  270.       ;
  271.   
  272.       dirp->dd_loc = off - (i + 1);
  273. ***************
  274. *** 182,198 ****
  275.       return dirp->dd_loc;
  276.   }
  277.   
  278. ! static void        free_dircontents(dp)
  279. ! struct _dircontents    *dp;
  280.   {
  281. !     struct _dircontents    *odp;
  282.   
  283. !     while (dp) 
  284.       {
  285. !     if (dp->_d_entry)
  286. !         free(dp->_d_entry);
  287.   
  288. !     dp = (odp = dp)->_d_next;
  289. !     free((char *) odp);
  290.       }
  291.   }
  292. --- 184,200 ----
  293.       return dirp->dd_loc;
  294.   }
  295.   
  296. ! static void    free_dircontents (dp)
  297. ! DIRCONT        *dp;
  298.   {
  299. !     DIRCONT    *odp;
  300.   
  301. !     while ((odp = dp) != (DIRCONT *)NULL) 
  302.       {
  303. !     if (dp->_d_entry != (char *)NULL)
  304. !         free (dp->_d_entry);
  305.   
  306. !     dp = dp->_d_next;
  307. !     free ((char *)odp);
  308.       }
  309.   }
  310. Index: sh.1
  311. Prereq: 1.10
  312. *** ../sh16.2/sh.1    Tue May  1 20:02:16 1990
  313. --- sh.1    Fri Aug 17 21:31:41 1990
  314. ***************
  315. *** 14,22 ****
  316.   .\" 2.  The sources (or parts thereof) or objects generated from the sources
  317.   .\"     (or parts of sources) cannot be sold under any circumstances.
  318.   .\"
  319. ! .\"    $Header: sh.1 1.10 90/05/01 19:58:38 MS_user Exp $
  320.   .\"
  321.   .\"    $Log:    sh.1 $
  322.   .\"    Revision 1.10  90/05/01  19:58:38  MS_user
  323.   .\"    Fix typing error
  324.   .\"    
  325. --- 14,25 ----
  326.   .\" 2.  The sources (or parts thereof) or objects generated from the sources
  327.   .\"     (or parts of sources) cannot be sold under any circumstances.
  328.   .\"
  329. ! .\"    $Header: C:/SRC/SHELL/RCS/sh.1 1.11 90/08/14 23:17:25 Ian_Stewartson Exp $
  330.   .\"
  331.   .\"    $Log:    sh.1 $
  332. + .\"    Revision 1.11  90/08/14  23:17:25  Ian_Stewartson
  333. + .\"    Add IO read/write open
  334. + .\"    
  335.   .\"    Revision 1.10  90/05/01  19:58:38  MS_user
  336.   .\"    Fix typing error
  337.   .\"    
  338. ***************
  339. *** 487,492 ****
  340. --- 490,499 ----
  341.   \fB<\h@-.1m@&\h@-.1m@\-\fR
  342.   The standard input is closed.  Similarly for the standard output using
  343.   \fB>\h@-.1m@&\h@-.1m@\-\fR.
  344. + .TP
  345. + \fBn<\h@-.3m@>word\fR
  346. + causes the file \fIword\fR to be opened on file descriptor \fIn\fR for both
  347. + reading and writing.  The file must already exist.
  348.   .PD
  349.   .PP
  350.   If any of the above is preceded by a digit, the file descriptor which will be
  351. Index: shell/sh3.c
  352. Prereq: 1.22
  353. *** ../sh16.2/shell/sh3.c    Thu Jun 21 21:48:04 1990
  354. --- shell/sh3.c    Fri Aug 17 21:34:34 1990
  355. ***************
  356. *** 13,21 ****
  357.    * 2.  The sources (or parts thereof) or objects generated from the sources
  358.    *     (or parts of sources) cannot be sold under any circumstances.
  359.    *
  360. !  *    $Header: sh3.c 1.22 90/06/21 11:10:47 MS_user Exp $
  361.    *
  362.    *    $Log:    sh3.c $
  363.    * Revision 1.22  90/06/21  11:10:47  MS_user
  364.    * Ensure Areanum is set correctly for memory areas
  365.    * 
  366. --- 13,28 ----
  367.    * 2.  The sources (or parts thereof) or objects generated from the sources
  368.    *     (or parts of sources) cannot be sold under any circumstances.
  369.    *
  370. !  *    $Header: C:/SRC/SHELL/RCS/sh3.c 1.24 90/08/16 10:28:47 Ian_Stewartson Exp $
  371.    *
  372.    *    $Log:    sh3.c $
  373. +  * Revision 1.24  90/08/16  10:28:47  Ian_Stewartson
  374. +  * Find setting of switch character for DOS4 for batch files
  375. +  * 
  376. +  * Revision 1.23  90/08/14  23:34:09  MS_user
  377. +  * Fix memory bugs - Copy function tree before execution
  378. +  * Save Extended line file name correctly
  379. +  * 
  380.    * Revision 1.22  90/06/21  11:10:47  MS_user
  381.    * Ensure Areanum is set correctly for memory areas
  382.    * 
  383. ***************
  384. *** 213,219 ****
  385.           Break_List  = (Break_C *)NULL;
  386.           bc.nextlev  = SShell_List;
  387.           SShell_List = &bc;
  388. !         rv = forkexec (t, pin, pout, act, wp);
  389.           }
  390.   
  391.   /* Restore the original environment */
  392. --- 220,226 ----
  393.           Break_List  = (Break_C *)NULL;
  394.           bc.nextlev  = SShell_List;
  395.           SShell_List = &bc;
  396. !         rv = execute (t->left, pin, pout, act);
  397.           }
  398.   
  399.   /* Restore the original environment */
  400. ***************
  401. *** 472,477 ****
  402. --- 479,492 ----
  403.   
  404.       if (t->type == TCOM)
  405.       {
  406. + /* Malloc failed somewhere - given up */
  407. +     if (wp == (char **)NULL)
  408. +         return setstatus (-1);
  409. + /* Skip over any assignments */
  410.       while ((cp = *wp++) != (char *)NULL)
  411.           ;
  412.   
  413. ***************
  414. *** 592,597 ****
  415. --- 607,613 ----
  416.       Break_C            *s_SList = SShell_List;
  417.       int            LS_depth = Execute_stack_depth;
  418.       Break_C            bc;
  419. +     C_Op            *New;
  420.   
  421.   /* Set up $0..$n for the function */
  422.   
  423. ***************
  424. *** 604,610 ****
  425.           Break_List  = (Break_C *)NULL;
  426.           bc.nextlev  = Return_List;
  427.           Return_List = &bc;
  428. !         rv = execute (fop->tree->left, NOPIPE, NOPIPE, FEXEC);
  429.       }
  430.   
  431.   /* A return has been executed - Unlike, while and for, we just need to
  432. --- 620,627 ----
  433.           Break_List  = (Break_C *)NULL;
  434.           bc.nextlev  = Return_List;
  435.           Return_List = &bc;
  436. !         New = Copy_Function (fop->tree->left);
  437. !         rv = execute (New, NOPIPE, NOPIPE, FEXEC);
  438.       }
  439.   
  440.   /* A return has been executed - Unlike, while and for, we just need to
  441. ***************
  442. *** 719,728 ****
  443.           cp = "here file";
  444.           break;
  445.   
  446. !     case IOWRITE | IOCAT:            /* >>            */
  447.           if (check_rsh (cp))
  448.           return TRUE;
  449.   
  450.           if ((u = S_open (FALSE, cp, O_WRONLY | O_TEXT)) >= 0)
  451.           {
  452.           lseek (u, 0L, SEEK_END);
  453. --- 736,752 ----
  454.           cp = "here file";
  455.           break;
  456.   
  457. !     case IOWRITE | IOREAD:            /* <>            */
  458.           if (check_rsh (cp))
  459.           return TRUE;
  460.   
  461. +         u = S_open (FALSE, cp, O_RDWR);
  462. +         break;
  463. +     case IOWRITE | IOCAT:            /* >>            */
  464. +         if (check_rsh (cp))
  465. +         return TRUE;
  466.           if ((u = S_open (FALSE, cp, O_WRONLY | O_TEXT)) >= 0)
  467.           {
  468.           lseek (u, 0L, SEEK_END);
  469. ***************
  470. *** 946,952 ****
  471.               r.x.ax = 0x3700;
  472.               intdos (&r, &r);
  473.   
  474. !             if (r.h.al == 0)
  475.                   *new_argv[1] = (char)(r.h.dl);
  476.               }
  477.   
  478. --- 970,976 ----
  479.               r.x.ax = 0x3700;
  480.               intdos (&r, &r);
  481.   
  482. !             if ((r.h.al == 0) && (_osmajor < 4))
  483.                   *new_argv[1] = (char)(r.h.dl);
  484.               }
  485.   
  486. ***************
  487. *** 1654,1660 ****
  488.           ((fd = S_open (FALSE, Extend_file = g_tempname (), O_CMASK,
  489.                  0600)) >= 0))
  490.       {
  491. !         Extend_file = strsave (Extend_file, 0);
  492.   
  493.   /* Copy to end of list */
  494.   
  495. --- 1678,1686 ----
  496.           ((fd = S_open (FALSE, Extend_file = g_tempname (), O_CMASK,
  497.                  0600)) >= 0))
  498.       {
  499. !         if ((Extend_file = strsave (Extend_file, 0)) == null)
  500. !         Extend_file = (char *)NULL;
  501.   
  502.   /* Copy to end of list */
  503.   
  504. Index: shell/sh4.c
  505. Prereq: 1.7
  506. *** ../sh16.2/shell/sh4.c    Thu Jun 21 21:48:52 1990
  507. --- shell/sh4.c    Fri Aug 17 21:34:51 1990
  508. ***************
  509. *** 13,21 ****
  510.    * 2.  The sources (or parts thereof) or objects generated from the sources
  511.    *     (or parts of sources) cannot be sold under any circumstances.
  512.    *
  513. !  *    $Header: sh4.c 1.7 90/06/21 11:11:51 MS_user Exp $
  514.    *
  515.    *    $Log:    sh4.c $
  516.    * Revision 1.7  90/06/21  11:11:51  MS_user
  517.    * Ensure Areanum is set correctly for memory areas
  518.    * 
  519. --- 13,29 ----
  520.    * 2.  The sources (or parts thereof) or objects generated from the sources
  521.    *     (or parts of sources) cannot be sold under any circumstances.
  522.    *
  523. !  *    $Header: C:/SRC/SHELL/RCS/sh4.c 1.9 90/08/16 10:29:27 Ian_Stewartson Exp $
  524.    *
  525.    *    $Log:    sh4.c $
  526. +  * Revision 1.9  90/08/16  10:29:27  Ian_Stewartson
  527. +  * Add support from String length option in ${}.
  528. +  * Restore the memcpys
  529. +  * 
  530. +  * Revision 1.8  90/08/14  23:34:35  MS_user
  531. +  * Fix memory bugs - ensure string copy is terminated
  532. +  * Change some memcpys to local copy functions - don't know why.
  533. +  * 
  534.    * Revision 1.7  90/06/21  11:11:51  MS_user
  535.    * Ensure Areanum is set correctly for memory areas
  536.    * 
  537. ***************
  538. *** 64,69 ****
  539. --- 72,78 ----
  540.   static Word_B        *New_Elist;
  541.   static char        *spcl  = "[?*";
  542.   static char        *spcl1 = "\"'";
  543. + static char        *bad_subs = "sh: bad substitution\n";
  544.   
  545.   static void        globname (char *, char *);
  546.   static bool        expand (char *, Word_B **, int);
  547. ***************
  548. *** 135,141 ****
  549.   {
  550.       register Word_B    *wb = (Word_B *)NULL;
  551.       register Var_List    *vp;
  552. !     char        *cp, *sp;
  553.       int            len = 0;
  554.   
  555.       for (vp = vlist; vp != (Var_List *)NULL; vp = vp->next)
  556. --- 144,150 ----
  557.   {
  558.       register Word_B    *wb = (Word_B *)NULL;
  559.       register Var_List    *vp;
  560. !     char        *cp;
  561.       int            len = 0;
  562.   
  563.       for (vp = vlist; vp != (Var_List *)NULL; vp = vp->next)
  564. ***************
  565. *** 410,415 ****
  566. --- 419,425 ----
  567.       register char    *s, c, *cp;
  568.       Var_List        *vp;
  569.       bool        colon_f = FALSE;
  570. +     bool        hash_f = FALSE;
  571.       char        *dol_special = "$ ";
  572.   
  573.       c = (char)readc ();
  574. ***************
  575. *** 429,435 ****
  576.           while (((c = (char)readc ()) != 0) && isalnum (c))
  577.           {
  578.           if (e.linep < e.eline)
  579. !             *e.linep++ = c;
  580.           }
  581.   
  582.           unget(c);
  583. --- 439,445 ----
  584.           while (((c = (char)readc ()) != 0) && isalnum (c))
  585.           {
  586.           if (e.linep < e.eline)
  587. !             *e.linep++ = c;
  588.           }
  589.   
  590.           unget(c);
  591. ***************
  592. *** 465,475 ****
  593.           return c;
  594.       }
  595.   
  596. ! /* Check for zero length string */
  597.   
  598.       if (s == e.linep)
  599.       {
  600. !         print_error ("sh: bad substitution\n");
  601.           gflg++;
  602.           return c;
  603.       }
  604. --- 475,494 ----
  605.           return c;
  606.       }
  607.   
  608. ! /* Check for Hash at start */
  609.   
  610. +     if ((*s == '#') && ((s - e.linep) > 1))
  611. +     {
  612. +         hash_f = TRUE;
  613. +         memcpy (s, s + 1, e.linep - s - 1);
  614. +         --e.linep;
  615. +     }
  616. + /* Check for zero length string */
  617.       if (s == e.linep)
  618.       {
  619. !         print_error (bad_subs);
  620.           gflg++;
  621.           return c;
  622.       }
  623. ***************
  624. *** 513,528 ****
  625.       }
  626.       }
  627.   
  628. ! /* Check for * and @ processing */
  629.   
  630.       if (s[1] == 0 && (*s == '*' || *s == '@'))
  631.       {
  632.       if (dolc > 1)
  633.       {
  634.           e.linep = s;
  635. !         PUSHIO (awordlist, dolv + 1, dol_char);
  636. !         e.iop->dflag = (char)(!quoted ? DSA_NULL
  637. !                       : ((*s == '*') ? DSA_STAR : DSA_AMP));
  638.           return 0;
  639.       }
  640.   
  641. --- 532,575 ----
  642.       }
  643.       }
  644.   
  645. ! /* Cannot have both # & : */
  646.   
  647. +     if (hash_f && colon_f)
  648. +     {
  649. +     print_error (bad_subs);
  650. +     gflg++;
  651. +     return c;
  652. +     }
  653. + /* Check for * and @ processing */
  654.       if (s[1] == 0 && (*s == '*' || *s == '@'))
  655.       {
  656.       if (dolc > 1)
  657.       {
  658.           e.linep = s;
  659. ! /* If hash flag set, convert to string length */
  660. !         if (hash_f)
  661. !         {
  662. !         int    slen, n;
  663. !         for (n = 1, slen = 0; dolv[n] != (char *)NULL;
  664. !              slen += (strlen (dolv[n++]) + 1));
  665. !         dolp = strsave (putn (slen - 1), areanum);
  666. !         PUSHIO (aword, dolp, quoted ? qstrchar : strchar);
  667. !         }
  668. !         else
  669. !         {
  670. !         PUSHIO (awordlist, dolv + 1, dol_char);
  671. !         e.iop->dflag = (char)(!quoted ? DSA_NULL
  672. !                           : ((*s == '*') ? DSA_STAR
  673. !                                  : DSA_AMP));
  674. !         }
  675.           return 0;
  676.       }
  677.   
  678. ***************
  679. *** 592,597 ****
  680. --- 639,649 ----
  681.       gflg++;
  682.       }
  683.   
  684. + /* If hash flag set, convert to string length */
  685. +     if (hash_f)
  686. +     dolp = strsave (putn (strlen (dolp)), areanum);
  687.       e.linep = s;
  688.       PUSHIO (aword, dolp, quoted ? qstrchar : strchar);
  689.       return 0;
  690. ***************
  691. *** 821,834 ****
  692.       for (i = 0; i < C_EList->w_nword; i++)
  693.       unquote (C_EList->w_words[i]);
  694.   
  695. -     qsort (C_EList->w_words, C_EList->w_nword, sizeof (char *), sort_compare);
  696.   /* Did we find any files matching the specification.  Yes - add them to
  697.    * the block
  698.    */
  699.   
  700.       if (C_EList->w_nword)
  701.       {
  702.       for (i = 0; i < C_EList->w_nword; i++)
  703.           wb = addword (C_EList->w_words[i], wb);
  704.   
  705. --- 873,887 ----
  706.       for (i = 0; i < C_EList->w_nword; i++)
  707.       unquote (C_EList->w_words[i]);
  708.   
  709.   /* Did we find any files matching the specification.  Yes - add them to
  710.    * the block
  711.    */
  712.   
  713.       if (C_EList->w_nword)
  714.       {
  715. +     qsort (C_EList->w_words, C_EList->w_nword, sizeof (char *),
  716. +            sort_compare);
  717.       for (i = 0; i < C_EList->w_nword; i++)
  718.           wb = addword (C_EList->w_words[i], wb);
  719.   
  720. ***************
  721. *** 852,858 ****
  722.   {
  723.       register char    *np, *cp;
  724.       char        *name, *gp, *dp;
  725. -     DIR            *dn;
  726.       struct dirent    *d_ce;
  727.       char        dname[NAME_MAX + 1];
  728.       struct stat        dbuf;
  729. --- 905,910 ----
  730. ***************
  731. *** 889,895 ****
  732.   
  733.   /* Open the directory */
  734.   
  735. !     if ((dn = opendir (dp)) == (DIR *)NULL)
  736.       {
  737.       DELETE (dp);
  738.       DELETE (gp);
  739. --- 941,947 ----
  740.   
  741.   /* Open the directory */
  742.   
  743. !     if ((e.cdir = opendir (dp)) == (DIR *)NULL)
  744.       {
  745.       DELETE (dp);
  746.       DELETE (gp);
  747. ***************
  748. *** 898,908 ****
  749.   
  750.   /* Scan for matches */
  751.   
  752. !     while ((d_ce = readdir (dn)) != (struct dirent *)NULL)
  753.       {
  754. !     if ((*(strcpy (dname, d_ce->d_name)) == '.') && (*gp != '.'))
  755.           continue;
  756.   
  757.       for (cp = dname; *cp; cp++)
  758.       {
  759.           if (any (*cp, spcl))
  760. --- 950,961 ----
  761.   
  762.   /* Scan for matches */
  763.   
  764. !     while ((d_ce = readdir (e.cdir)) != (struct dirent *)NULL)
  765.       {
  766. !     if ((*(strncpy (dname, d_ce->d_name, NAME_MAX)) == '.') && (*gp != '.'))
  767.           continue;
  768.   
  769. +     dname[NAME_MAX] = 0;
  770.       for (cp = dname; *cp; cp++)
  771.       {
  772.           if (any (*cp, spcl))
  773. ***************
  774. *** 935,941 ****
  775.       }
  776.       }
  777.   
  778. !     closedir (dn);
  779.       DELETE (dp);
  780.       DELETE (gp);
  781.   }
  782. --- 988,995 ----
  783.       }
  784.       }
  785.   
  786. !     closedir (e.cdir);
  787. !     e.cdir = (DIR *)NULL;
  788.       DELETE (dp);
  789.       DELETE (gp);
  790.   }
  791. ***************
  792. *** 1034,1055 ****
  793.   register Word_B    *wb;
  794.   {
  795.       register char    **wd;
  796. !     register nb;
  797.   
  798.   /* If the word block is empty or does not exist, return no list */
  799.   
  800.       if (wb == (Word_B **)NULL)
  801.       return (char *)NULL;
  802.   
  803. !     if (wb->w_nword == 0)
  804.       {
  805.       DELETE (wb);
  806.       return (char *)NULL;
  807.       }
  808. - /* Get some space for the array and set it up */
  809. -     wd = (char **)space (nb = sizeof (char *) * wb->w_nword);
  810.   
  811.       memcpy ((char *)wd, (char *)wb->w_words, nb);
  812.       DELETE (wb);    /* perhaps should done by caller */
  813. --- 1088,1108 ----
  814.   register Word_B    *wb;
  815.   {
  816.       register char    **wd;
  817. !     register int    nb;
  818.   
  819.   /* If the word block is empty or does not exist, return no list */
  820.   
  821.       if (wb == (Word_B **)NULL)
  822.       return (char *)NULL;
  823.   
  824. ! /* Get some space for the array and set it up */
  825. !     if (((nb = sizeof (char *) * wb->w_nword) == 0) ||
  826. !     ((wd = (char **)space (nb)) == (char **)NULL))
  827.       {
  828.       DELETE (wb);
  829.       return (char *)NULL;
  830.       }
  831.   
  832.       memcpy ((char *)wd, (char *)wb->w_words, nb);
  833.       DELETE (wb);    /* perhaps should done by caller */
  834. Index: shell/sh5.c
  835. Prereq: 1.9
  836. *** ../sh16.2/shell/sh5.c    Thu Jun 21 21:49:29 1990
  837. --- shell/sh5.c    Fri Aug 17 21:35:07 1990
  838. ***************
  839. *** 13,21 ****
  840.    * 2.  The sources (or parts thereof) or objects generated from the sources
  841.    *     (or parts of sources) cannot be sold under any circumstances.
  842.    *
  843. !  *    $Header: sh5.c 1.9 90/05/11 18:45:40 MS_user Exp $
  844.    *
  845.    *    $Log:    sh5.c $
  846.    * Revision 1.9  90/05/11  18:45:40  MS_user
  847.    * Fix problem when at end of buffer on re-load from file
  848.    * 
  849. --- 13,24 ----
  850.    * 2.  The sources (or parts thereof) or objects generated from the sources
  851.    *     (or parts of sources) cannot be sold under any circumstances.
  852.    *
  853. !  *    $Header: C:/SRC/SHELL/RCS/sh5.c 1.10 90/08/14 23:30:47 Ian_Stewartson Exp $
  854.    *
  855.    *    $Log:    sh5.c $
  856. +  * Revision 1.10  90/08/14  23:30:47  Ian_Stewartson
  857. +  * Changes to env structure.
  858. +  * 
  859.    * Revision 1.9  90/05/11  18:45:40  MS_user
  860.    * Fix problem when at end of buffer on re-load from file
  861.    * 
  862. ***************
  863. *** 58,63 ****
  864. --- 61,67 ----
  865.   #include <fcntl.h>
  866.   #include <io.h>
  867.   #include <limits.h>
  868. + #include <dirent.h>
  869.   #include <unistd.h>
  870.   #include "sh.h"
  871.   
  872. Index: shell/sh6.c
  873. Prereq: 1.13
  874. *** ../sh16.2/shell/sh6.c    Thu Jun 21 21:49:38 1990
  875. --- shell/sh6.c    Fri Aug 17 21:35:10 1990
  876. ***************
  877. *** 13,21 ****
  878.    * 2.  The sources (or parts thereof) or objects generated from the sources
  879.    *     (or parts of sources) cannot be sold under any circumstances.
  880.    *
  881. !  *    $Header: sh6.c 1.13 90/05/15 21:10:19 MS_user Exp $
  882.    *
  883.    *    $Log:    sh6.c $
  884.    * Revision 1.13  90/05/15  21:10:19  MS_user
  885.    * Release 1.6.2
  886.    * 
  887. --- 13,24 ----
  888.    * 2.  The sources (or parts thereof) or objects generated from the sources
  889.    *     (or parts of sources) cannot be sold under any circumstances.
  890.    *
  891. !  *    $Header: C:/SRC/SHELL/RCS/sh6.c 1.14 90/08/14 23:34:49 MS_user Exp $
  892.    *
  893.    *    $Log:    sh6.c $
  894. +  * Revision 1.14  90/08/14  23:34:49  MS_user
  895. +  * Changed for release 1.6.3
  896. +  * 
  897.    * Revision 1.13  90/05/15  21:10:19  MS_user
  898.    * Release 1.6.2
  899.    * 
  900. ***************
  901. *** 65,75 ****
  902.   #include <setjmp.h>
  903.   #include <stdlib.h>
  904.   #include <limits.h>
  905.   #include <unistd.h>
  906.   #include <string.h>
  907.   #include "sh.h"
  908.   
  909. ! static char    *Copy_Right1 = "MS-DOS SH Version 1.6.2 - %s (DOS %d.%d)\n";
  910.   static char    *Copy_Right2 = "Copyright (c) Data Logic Ltd and Charles Forsyth 1990\n";
  911.   char        **dolv;        /* Parameter array            */
  912.   int        dolc;        /* Number of entries in parameter array    */
  913. --- 68,79 ----
  914.   #include <setjmp.h>
  915.   #include <stdlib.h>
  916.   #include <limits.h>
  917. + #include <dirent.h>
  918.   #include <unistd.h>
  919.   #include <string.h>
  920.   #include "sh.h"
  921.   
  922. ! static char    *Copy_Right1 = "MS-DOS SH Version 1.6.3 - %s (DOS %d.%d)\n";
  923.   static char    *Copy_Right2 = "Copyright (c) Data Logic Ltd and Charles Forsyth 1990\n";
  924.   char        **dolv;        /* Parameter array            */
  925.   int        dolc;        /* Number of entries in parameter array    */
  926. ***************
  927. *** 151,156 ****
  928. --- 155,161 ----
  929.       (int *)NULL,
  930.       FALSE,            /* End of file processing        */
  931.       FDBASE,            /* Base file handler            */
  932. +     (DIR *)NULL,        /* Currently open directory        */
  933.       (Environ *)NULL        /* Previous Env pointer            */
  934.   };
  935.   
  936. Index: shell/sh7.c
  937. Prereq: 1.17
  938. *** ../sh16.2/shell/sh7.c    Thu Jun 21 21:50:36 1990
  939. --- shell/sh7.c    Fri Aug 17 21:35:57 1990
  940. ***************
  941. *** 15,23 ****
  942.    * 2.  The sources (or parts thereof) or objects generated from the sources
  943.    *     (or parts of sources) cannot be sold under any circumstances.
  944.    *
  945. !  *    $Header: sh7.c 1.17 90/05/31 09:50:05 MS_user Exp $
  946.    *
  947.    *    $Log:    sh7.c $
  948.    * Revision 1.17  90/05/31  09:50:05  MS_user
  949.    * Implement partial write when swapping to disk
  950.    * 
  951. --- 15,27 ----
  952.    * 2.  The sources (or parts thereof) or objects generated from the sources
  953.    *     (or parts of sources) cannot be sold under any circumstances.
  954.    *
  955. !  *    $Header: C:/SRC/SHELL/RCS/sh7.c 1.18 90/08/14 23:34:55 MS_user Exp $
  956.    *
  957.    *    $Log:    sh7.c $
  958. +  * Revision 1.18  90/08/14  23:34:55  MS_user
  959. +  * Fix directory display on change directory
  960. +  * Fix spelling mistake.
  961. +  * 
  962.    * Revision 1.17  90/05/31  09:50:05  MS_user
  963.    * Implement partial write when swapping to disk
  964.    * 
  965. ***************
  966. *** 88,93 ****
  967. --- 92,98 ----
  968.   #include <stdlib.h>
  969.   #include <fcntl.h>
  970.   #include <limits.h>
  971. + #include <dirent.h>
  972.   #include <stdarg.h>
  973.   #include "sh.h"
  974.   
  975. ***************
  976. *** 1026,1032 ****
  977.   
  978.           Getcwd ();
  979.   
  980. !         if (first || (strchr (p, '/') != (char *)NULL))
  981.           dopwd (t);
  982.   
  983.           return 0;
  984. --- 1031,1037 ----
  985.   
  986.           Getcwd ();
  987.   
  988. !         if (first)
  989.           dopwd (t);
  990.   
  991.           return 0;
  992. ***************
  993. *** 1756,1762 ****
  994.   #endif
  995.   
  996.   /*
  997. !  * Type fucntion: For each name, indicate how it would be interpreted
  998.    */
  999.   
  1000.   static char    *type_ext[] = {
  1001. --- 1761,1767 ----
  1002.   #endif
  1003.   
  1004.   /*
  1005. !  * Type function: For each name, indicate how it would be interpreted
  1006.    */
  1007.   
  1008.   static char    *type_ext[] = {
  1009. ***************
  1010. *** 1789,1794 ****
  1011. --- 1794,1805 ----
  1012.   
  1013.       while ((cp = t->words[n++]) != (char *)NULL)
  1014.       {
  1015. +     if (inbuilt (cp))
  1016. +     {
  1017. +         v1_puts (cp);
  1018. +         v1a_puts (" is a shell internal command");
  1019. +         continue;
  1020. +     }
  1021.   
  1022.   /* Check for a function */
  1023.   
  1024. ***************
  1025. *** 1844,1849 ****
  1026. --- 1855,1861 ----
  1027.                    (stricmp (xp, ".bat") != 0))
  1028.               continue;
  1029.   
  1030. +             Convert_Backslashes (strlwr (l_path));
  1031.               print_error ("%s is %s\n", cp, l_path);
  1032.               found = TRUE;
  1033.           }
  1034. Index: shell/sh8.c
  1035. Prereq: 1.11
  1036. *** ../sh16.2/shell/sh8.c    Thu Jun 21 21:51:03 1990
  1037. --- shell/sh8.c    Fri Aug 17 21:35:41 1990
  1038. ***************
  1039. *** 12,20 ****
  1040.    * 2.  The sources (or parts thereof) or objects generated from the sources
  1041.    *     (or parts of sources) cannot be sold under any circumstances.
  1042.    *
  1043. !  *    $Header: sh8.c 1.11 90/06/21 11:12:13 MS_user Exp $
  1044.    *
  1045.    *    $Log:    sh8.c $
  1046.    * Revision 1.11  90/06/21  11:12:13  MS_user
  1047.    * Ensure Areanum is set correctly for memory areas
  1048.    * 
  1049. --- 12,23 ----
  1050.    * 2.  The sources (or parts thereof) or objects generated from the sources
  1051.    *     (or parts of sources) cannot be sold under any circumstances.
  1052.    *
  1053. !  *    $Header: C:/SRC/SHELL/RCS/sh8.c 1.12 90/08/14 23:31:08 Ian_Stewartson Exp $
  1054.    *
  1055.    *    $Log:    sh8.c $
  1056. +  * Revision 1.12  90/08/14  23:31:08  Ian_Stewartson
  1057. +  * Changes to env structure.
  1058. +  * 
  1059.    * Revision 1.11  90/06/21  11:12:13  MS_user
  1060.    * Ensure Areanum is set correctly for memory areas
  1061.    * 
  1062. ***************
  1063. *** 64,69 ****
  1064. --- 67,73 ----
  1065.   #include <string.h>
  1066.   #include <unistd.h>
  1067.   #include <limits.h>
  1068. + #include <dirent.h>
  1069.   #include <ctype.h>
  1070.   #include "sh.h"
  1071.   
  1072. Index: shell/sh9.c
  1073. Prereq: 1.12
  1074. *** ../sh16.2/shell/sh9.c    Thu Jun 21 21:51:46 1990
  1075. --- shell/sh9.c    Fri Aug 17 21:36:02 1990
  1076. ***************
  1077. *** 12,18 ****
  1078.    * 2.  The sources (or parts thereof) or objects generated from the sources
  1079.    *     (or parts of sources) cannot be sold under any circumstances.
  1080.    *
  1081. !  *    $Header: sh9.c 1.12 90/05/31 10:39:26 MS_user Exp $
  1082.    *
  1083.    *    $Log:    sh9.c $
  1084.    * Revision 1.12  90/05/31  10:39:26  MS_user
  1085. --- 12,18 ----
  1086.    * 2.  The sources (or parts thereof) or objects generated from the sources
  1087.    *     (or parts of sources) cannot be sold under any circumstances.
  1088.    *
  1089. !  *    $Header: C:/SRC/SHELL/RCS/sh9.c 1.12 90/05/31 10:39:26 MS_user Exp $
  1090.    *
  1091.    *    $Log:    sh9.c $
  1092.    * Revision 1.12  90/05/31  10:39:26  MS_user
  1093. Index: shell/makefile
  1094. Prereq: 1.3
  1095. *** ../sh16.2/shell/makefile    Thu Jun 21 21:43:10 1990
  1096. --- shell/makefile    Fri Aug 17 21:33:08 1990
  1097. ***************
  1098. *** 8,16 ****
  1099.   # source form.
  1100.   #
  1101.   #
  1102. ! #    $Header: makefile 1.3 90/01/18 15:41:48 MS_user Locked $
  1103.   #
  1104.   #    $Log:    makefile $
  1105.   # Revision 1.3  90/01/18  15:41:48  MS_user
  1106.   # ANother change for new make
  1107.   # 
  1108. --- 8,25 ----
  1109.   # source form.
  1110.   #
  1111.   #
  1112. ! #    $Header: C:/SRC/SHELL/RCS/makefile 1.6 90/08/16 12:21:40 Ian_Stewartson Exp $
  1113.   #
  1114.   #    $Log:    makefile $
  1115. + # Revision 1.6  90/08/16  12:21:40  Ian_Stewartson
  1116. + # Remove command on sh6.obj line
  1117. + # 
  1118. + # Revision 1.5  90/08/15  01:42:32  MS_user
  1119. + # Remove local directory functions
  1120. + # 
  1121. + # Revision 1.4  90/08/15  01:16:36  MS_user
  1122. + # Add stack command
  1123. + # 
  1124.   # Revision 1.3  90/01/18  15:41:48  MS_user
  1125.   # ANother change for new make
  1126.   # 
  1127. ***************
  1128. *** 22,28 ****
  1129.   # 
  1130.   #
  1131.   
  1132. ! ASFLAGS= /Ml /Zi /Zd
  1133.   
  1134.   OBJS=sh0.obj sh1.obj sh2.obj sh3.obj sh4.obj sh5.obj sh6.obj    \
  1135.        sh7.obj sh8.obj sh9.obj sh10.obj
  1136. --- 31,37 ----
  1137.   # 
  1138.   #
  1139.   
  1140. ! ASFLAGS= /Ml 
  1141.   
  1142.   OBJS=sh0.obj sh1.obj sh2.obj sh3.obj sh4.obj sh5.obj sh6.obj    \
  1143.        sh7.obj sh8.obj sh9.obj sh10.obj
  1144. ***************
  1145. *** 34,38 ****
  1146.   sh6.obj: $(SRCS)
  1147.   
  1148.   sh.exe:    $(OBJS)
  1149. !     link sh0+sh1+sh2+sh3+sh4+sh5+sh6+sh7+sh8+sh9+sh10/co/noi, sh.exe\;
  1150. !     link sh0+sh1+sh2+sh3+sh4+sh5+sh6+sh7+sh8+sh9+sh10/noi, nd_sh.exe\;
  1151. --- 43,47 ----
  1152.   sh6.obj: $(SRCS)
  1153.   
  1154.   sh.exe:    $(OBJS)
  1155. !     link sh0+sh1+sh2+sh3+sh4+sh5+sh6+sh7+sh8+sh9+sh10/co/noi/stack:0x2000, sh.exe\;
  1156. !     link sh0+sh1+sh2+sh3+sh4+sh5+sh6+sh7+sh8+sh9+sh10/noi/stack:0x2000, nd_sh.exe\;
  1157. Index: shell/sh.h
  1158. Prereq: 1.20
  1159. *** ../sh16.2/shell/sh.h    Thu Jun 21 21:43:37 1990
  1160. --- shell/sh.h    Fri Aug 17 21:33:20 1990
  1161. ***************
  1162. *** 13,21 ****
  1163.    * 2.  The sources (or parts thereof) or objects generated from the sources
  1164.    *     (or parts of sources) cannot be sold under any circumstances.
  1165.    *
  1166. !  *    $Header: sh.h 1.20 90/05/31 09:47:41 MS_user Exp $
  1167.    *
  1168.    *    $Log:    sh.h $
  1169.    * Revision 1.20  90/05/31  09:47:41  MS_user
  1170.    * Implement partial write when swapping to disk
  1171.    * 
  1172. --- 13,26 ----
  1173.    * 2.  The sources (or parts thereof) or objects generated from the sources
  1174.    *     (or parts of sources) cannot be sold under any circumstances.
  1175.    *
  1176. !  *    $Header: C:/SRC/SHELL/RCS/sh.h 1.21 90/08/14 23:54:44 MS_user Exp $
  1177.    *
  1178.    *    $Log:    sh.h $
  1179. +  * Revision 1.21  90/08/14  23:54:44  MS_user
  1180. +  * Add addition value to env structure
  1181. +  * Add some new publics
  1182. +  * Update patchlevel
  1183. +  * 
  1184.    * Revision 1.20  90/05/31  09:47:41  MS_user
  1185.    * Implement partial write when swapping to disk
  1186.    * 
  1187. ***************
  1188. *** 80,86 ****
  1189.    * 
  1190.    */
  1191.   
  1192. ! #define PATCHLEVEL    6
  1193.   #define    LINE_MAX    1000    /* Command line length            */
  1194.   #define HISTORY_MAX    100    /* History array length            */
  1195.                   /* Space for full file name        */
  1196. --- 85,91 ----
  1197.    * 
  1198.    */
  1199.   
  1200. ! #define PATCHLEVEL    7
  1201.   #define    LINE_MAX    1000    /* Command line length            */
  1202.   #define HISTORY_MAX    100    /* History array length            */
  1203.                   /* Space for full file name        */
  1204. ***************
  1205. *** 327,332 ****
  1206. --- 332,338 ----
  1207.       int        *errpt;
  1208.       bool    eof_p;            /* EOF processing enabled    */
  1209.       int        iofd;
  1210. +     DIR        *cdir;            /* Currently open directory    */
  1211.       struct env    *oenv;            /* Previous environment        */
  1212.   } Environ;
  1213.   
  1214. ***************
  1215. *** 622,627 ****
  1216. --- 628,635 ----
  1217.   extern void    Print_Version (int);
  1218.   extern bool    anys (char *, char *);
  1219.   extern void    Clear_Swap_File (void);
  1220. + extern C_Op    *Copy_Function (C_Op *);
  1221. + extern void    Convert_Backslashes (char *);
  1222.   
  1223.   /*
  1224.    * Interrupt handling
  1225. Index: shell/sh0.asm
  1226. Prereq: 1.10
  1227. *** ../sh16.2/shell/sh0.asm    Thu Jun 21 21:45:35 1990
  1228. --- shell/sh0.asm    Fri Aug 17 21:33:41 1990
  1229. ***************
  1230. *** 16,22 ****
  1231.   ; 2.  The sources (or parts thereof) or objects generated from the sources
  1232.   ;     (or parts of sources) cannot be sold under any circumstances.
  1233.   ;
  1234. ! ;    $Header: sh0.asm 1.10 90/05/31 17:46:31 MS_user Exp $
  1235.   ;
  1236.   ;    $Log:    sh0.asm $
  1237.   ;    Revision 1.10  90/05/31  17:46:31  MS_user
  1238. --- 16,22 ----
  1239.   ; 2.  The sources (or parts thereof) or objects generated from the sources
  1240.   ;     (or parts of sources) cannot be sold under any circumstances.
  1241.   ;
  1242. ! ;    $Header: C:/SRC/SHELL/RCS/sh0.asm 1.10 90/05/31 17:46:31 MS_user Exp $
  1243.   ;
  1244.   ;    $Log:    sh0.asm $
  1245.   ;    Revision 1.10  90/05/31  17:46:31  MS_user
  1246. Index: shell/sh1.c
  1247. Prereq: 1.16
  1248. *** ../sh16.2/shell/sh1.c    Thu Jun 21 21:46:25 1990
  1249. --- shell/sh1.c    Fri Aug 17 21:32:33 1990
  1250. ***************
  1251. *** 13,21 ****
  1252.    * 2.  The sources (or parts thereof) or objects generated from the sources
  1253.    *     (or parts of sources) cannot be sold under any circumstances.
  1254.    *
  1255. !  *    $Header: sh1.c 1.16 90/05/31 09:48:06 MS_user Exp $
  1256.    *
  1257.    *    $Log:    sh1.c $
  1258.    * Revision 1.16  90/05/31  09:48:06  MS_user
  1259.    * Implement partial write when swapping to disk
  1260.    * Add some signal lockouts to prevent corruption
  1261. --- 13,25 ----
  1262.    * 2.  The sources (or parts thereof) or objects generated from the sources
  1263.    *     (or parts of sources) cannot be sold under any circumstances.
  1264.    *
  1265. !  *    $Header: C:/SRC/SHELL/RCS/sh1.c 1.17 90/08/14 23:32:53 MS_user Exp $
  1266.    *
  1267.    *    $Log:    sh1.c $
  1268. +  * Revision 1.17  90/08/14  23:32:53  MS_user
  1269. +  * Fix memory bugs - Add malloc checking functions for debug
  1270. +  * Make Convert_Backslashes public
  1271. +  * 
  1272.    * Revision 1.16  90/05/31  09:48:06  MS_user
  1273.    * Implement partial write when swapping to disk
  1274.    * Add some signal lockouts to prevent corruption
  1275. ***************
  1276. *** 83,88 ****
  1277. --- 87,93 ----
  1278.   #include <ctype.h>
  1279.   #include <fcntl.h>
  1280.   #include <limits.h>
  1281. + #include <dirent.h>
  1282.   #include <dos.h>
  1283.   #include <time.h>
  1284.   #include "sh.h"
  1285. ***************
  1286. *** 92,98 ****
  1287. --- 97,119 ----
  1288.    * without having to know about it.
  1289.    */
  1290.   
  1291. + #undef CHECK_MALLOC
  1292. + #ifdef CHECK_MALLOC
  1293. + #define    MAGIC1        0xd8a5
  1294. + #define    MAGIC2        0xa5d8
  1295. + static void        sh_free (void *);
  1296. + static void        sh_chkmem (char *, char *, size_t, bool);
  1297. + #define SH_FREE        sh_free
  1298. + #else
  1299. + #define SH_FREE        free
  1300. + #endif
  1301.   typedef struct region {
  1302. + #ifdef CHECK_MALLOC
  1303. +     unsigned int    magic1;
  1304. +     unsigned int    len;
  1305. + #endif
  1306.       struct region    *next;
  1307.       int            area;
  1308.   } s_region;
  1309. ***************
  1310. *** 125,131 ****
  1311.   static void    Check_Mail (void);
  1312.   static void    Pre_Process_Argv (char **);
  1313.   static void    Load_G_VL (void);
  1314. - static void    Convert_Backslashes (char *);
  1315.   static void    Load_profiles (void);
  1316.   static void    U2D_Path (void);
  1317.   
  1318. --- 146,151 ----
  1319. ***************
  1320. *** 530,540 ****
  1321.   char    *fmt;
  1322.   {
  1323.       va_list    ap;
  1324. -     char    x[100];
  1325.   
  1326.       va_start (ap, fmt);
  1327. !     vsprintf (x, fmt, ap);
  1328. !     S_puts (x);
  1329.       exstat = -1;
  1330.   
  1331.   /* If leave on error - exit */
  1332. --- 550,558 ----
  1333.   char    *fmt;
  1334.   {
  1335.       va_list    ap;
  1336.   
  1337.       va_start (ap, fmt);
  1338. !     vfprintf (stderr, fmt, ap);
  1339.       exstat = -1;
  1340.   
  1341.   /* If leave on error - exit */
  1342. ***************
  1343. *** 553,565 ****
  1344.   char    *fmt;
  1345.   {
  1346.       va_list    ap;
  1347. -     char    x[100];
  1348.   
  1349.   /* Error message processing */
  1350.   
  1351.       va_start (ap, fmt);
  1352. !     vsprintf (x, fmt, ap);
  1353. !     S_puts (x);
  1354.       exstat = -1;
  1355.   
  1356.       if (FL_TEST ('e'))
  1357. --- 571,581 ----
  1358.   char    *fmt;
  1359.   {
  1360.       va_list    ap;
  1361.   
  1362.   /* Error message processing */
  1363.   
  1364.       va_start (ap, fmt);
  1365. !     vfprintf (stderr, fmt, ap);
  1366.       exstat = -1;
  1367.   
  1368.       if (FL_TEST ('e'))
  1369. ***************
  1370. *** 636,641 ****
  1371. --- 652,665 ----
  1372.   
  1373.       if ((ep = e.oenv) != (Environ *)NULL)
  1374.       {
  1375. + /* Close any open directories */
  1376. +     if (e.cdir != (DIR *)NULL)
  1377. +         closedir (e.cdir);
  1378. + /* Get the files used in this environment to close */
  1379.       fd = e.iofd;
  1380.       e = *ep;
  1381.   
  1382. ***************
  1383. *** 1269,1290 ****
  1384.    * Get a string in a malloced area
  1385.    */
  1386.   
  1387. ! char        *getcell(nbytes)
  1388.   unsigned int    nbytes;
  1389.   {
  1390.       s_region        *np;
  1391.       void        (*save_signal)(int);
  1392.   
  1393.       if (nbytes == 0)
  1394.       abort ();    /* silly and defeats the algorithm */
  1395.   
  1396.   /* Grab some space */
  1397.   
  1398. !     if ((np = (s_region *)calloc (nbytes + sizeof (s_region), 1)) == (s_region *)NULL)
  1399. !         return (char *)NULL;
  1400.   
  1401. ! /* Disable signals */
  1402.   
  1403.       save_signal = signal (SIGINT, SIG_IGN);
  1404.   
  1405.   /* Link into chain */
  1406.