home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.misc
- from: istewart@datlog.co.uk
- subject: v14i066: MS-Shell Patch 1.6.3 - Part 2 of 2
- Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 14, Issue 66
- Submitted-by: istewart@datlog.co.uk
- Archive-name: ms_sh-1.6/patch03
-
- #!/bin/sh
- # this is PA.02 (part 2 of a multipart archive)
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file Patch1.6.3 continued
- #
- if touch 2>&1 | fgrep '[-amc]' > /dev/null
- then TOUCH=touch
- else TOUCH=true
- fi
- if test ! -r @shar_seq_.tmp; then
- echo "Please unpack part 1 first!"
- exit 1
- fi
- (read Scheck
- if test "$Scheck" != 2; then
- echo "Please unpack part $Scheck next!"
- exit 1
- else
- exit 0
- fi
- ) < @shar_seq_.tmp || exit 1
- echo "x - Continuing file Patch1.6.3"
- sed 's/^X//' << 'SHAR_EOF' >> Patch1.6.3 &&
- X--- 1293,1337 ----
- X * Get a string in a malloced area
- X */
- X
- X! char *getcell (nbytes)
- X unsigned int nbytes;
- X {
- X s_region *np;
- X void (*save_signal)(int);
- X+ #ifdef CHECK_MALLOC
- X+ char *rp;
- X+ #endif
- X
- X if (nbytes == 0)
- X abort (); /* silly and defeats the algorithm */
- X
- X /* Grab some space */
- X
- X! np = (s_region *)calloc (nbytes + sizeof (s_region)
- X! #ifdef CHECK_MALLOC
- X! + sizeof (unsigned int)
- X! #endif
- X! , 1);
- X
- X! if (np == (s_region *)NULL)
- X! return (char *)NULL;
- X!
- X! #ifdef CHECK_MALLOC
- X! if ((((FP_SEG (np)) << 4L) + FP_OFF (np)) > 0x9fc00L)
- X! {
- X! free (np);
- X! print_warn ("Malloc access to bad segment\n");
- X! return (char *)NULL;
- X! }
- X!
- X! np->magic1 = MAGIC1;
- X! np->len = nbytes;
- X! rp = (char *)(np + 1);
- X! *((int *)(rp + nbytes)) = MAGIC2;
- X! #endif
- X
- X+ /* Disable signals */
- X+
- X save_signal = signal (SIGINT, SIG_IGN);
- X
- X /* Link into chain */
- X***************
- X*** 1339,1345 ****
- X else
- X lp->next = cp->next;
- X
- X! free (cp);
- X break;
- X }
- X }
- X--- 1386,1392 ----
- X else
- X lp->next = cp->next;
- X
- X! SH_FREE (cp);
- X break;
- X }
- X }
- X***************
- X*** 1386,1392 ****
- X cp = cp->next;
- X areastart = cp;
- X
- X! free (lp);
- X lp = (char *)NULL;
- X }
- X
- X--- 1433,1439 ----
- X cp = cp->next;
- X areastart = cp;
- X
- X! SH_FREE (lp);
- X lp = (char *)NULL;
- X }
- X
- X***************
- X*** 1395,1401 ****
- X else
- X {
- X lp->next = cp->next;
- X! free (cp);
- X cp = lp->next;
- X }
- X }
- X--- 1442,1448 ----
- X else
- X {
- X lp->next = cp->next;
- X! SH_FREE (cp);
- X cp = lp->next;
- X }
- X }
- X***************
- X*** 1816,1822 ****
- X * Convert backslashes to slashes for UNIX
- X */
- X
- X! static void Convert_Backslashes (sp)
- X char *sp;
- X {
- X while (*sp)
- X--- 1863,1869 ----
- X * Convert backslashes to slashes for UNIX
- X */
- X
- X! void Convert_Backslashes (sp)
- X char *sp;
- X {
- X while (*sp)
- X***************
- X*** 1919,1921 ****
- X--- 1966,2178 ----
- X
- X return strcat (cp, name);
- X }
- X+
- X+ /* Check alloc functions */
- X+ #ifdef CHECK_MALLOC
- X+ static void sh_free (ap)
- X+ void *ap;
- X+ {
- X+ s_region *cp = (s_region *)ap;
- X+ size_t len = cp->len;
- X+
- X+ if ((cp->magic1 != MAGIC1) ||
- X+ (*((int *)((char *)ap + len + sizeof (s_region))) != MAGIC2))
- X+ {
- X+ print_warn ("ABORT: corrupt malloc\n");
- X+ exit (1);
- X+ }
- X+
- X+ cp->magic1 = 0;
- X+ *((int *)((char *)ap + len)) = 0;
- X+
- X+ free (cp);
- X+ }
- X+
- X+ char *strcat (str1, str2)
- X+ char *str1;
- X+ const char *str2;
- X+ {
- X+ char *rtn = str1;
- X+ int len;
- X+
- X+ len = strlen (str2);
- X+ sh_chkmem ("strcat", (char *)str2, len, FALSE);
- X+
- X+ if (str2 == (const char *)NULL)
- X+ return str1;
- X+
- X+ len += strlen (str1) + 1;
- X+ sh_chkmem ("strcat", str1, len, TRUE);
- X+
- X+ while (*str1)
- X+ str1++;
- X+
- X+ while ((*str1 = *str2) != 0)
- X+ {
- X+ str1++;
- X+ str2++;
- X+ }
- X+
- X+ return rtn;
- X+ }
- X+
- X+ char *strcpy (str1, str2)
- X+ char *str1;
- X+ const char *str2;
- X+ {
- X+ char *rtn = str1;
- X+ int len = strlen (str2) + 1;
- X+
- X+ sh_chkmem ("strcpy", str1, len, TRUE);
- X+
- X+ if (str2 == (const char *)NULL)
- X+ {
- X+ *str1 = 0;
- X+ return str1;
- X+ }
- X+
- X+ sh_chkmem ("strcpy", (char *)str2, len, FALSE);
- X+
- X+ while ((*str1++ = *str2++) != '\0');
- X+
- X+ return rtn;
- X+ }
- X+
- X+ char *strncpy (str1, str2, len1)
- X+ char *str1;
- X+ const char *str2;
- X+ size_t len1;
- X+ {
- X+ int i;
- X+ char *rtn = str1;
- X+ int len = (int)len1;
- X+
- X+ sh_chkmem ("strncpy", str1, len, TRUE);
- X+
- X+ if (str2 == (const char *)NULL)
- X+ {
- X+ *str1 = 0;
- X+ return str1;
- X+ }
- X+
- X+ i = strlen (str2);
- X+
- X+ if (i > len)
- X+ i = len;
- X+
- X+ sh_chkmem ("strncpy", (char *)str2, i, FALSE);
- X+
- X+ while (--len >= 0)
- X+ {
- X+ if ((*(str1++) = *(str2++)) == 0)
- X+ {
- X+ while (--len >= 0)
- X+ *(str1++) = 0;
- X+
- X+ break;
- X+ }
- X+ }
- X+
- X+ return rtn;
- X+ }
- X+
- X+ void *memcpy (rtn, ptr2a, len)
- X+ void *rtn;
- X+ const void *ptr2a;
- X+ size_t len;
- X+ {
- X+ char *ptr1 = rtn;
- X+ char *ptr2 = (char *)ptr2a;
- X+
- X+ sh_chkmem ("memcpy", ptr1, len, TRUE);
- X+ sh_chkmem ("memcpy", ptr2, len, FALSE);
- X+
- X+ if (len > 1200)
- X+ print_warn ("Warning: string length excessive\n");
- X+
- X+ while (--len >= 0)
- X+ *(ptr1++) = *(ptr2++);
- X+
- X+ return rtn;
- X+ }
- X+
- X+ void *memset (rtn, ch, len)
- X+ void *rtn;
- X+ int ch;
- X+ size_t len;
- X+ {
- X+ char *ptr1 = rtn;
- X+
- X+ sh_chkmem ("memset", ptr1, len, TRUE);
- X+
- X+ if (len > 1200)
- X+ print_warn ("Warning: string length excessive\n");
- X+
- X+ while (--len >= 0)
- X+ *(ptr1++) = (char)ch;
- X+
- X+ return rtn;
- X+ }
- X+
- X+ static void sh_chkmem (f, s, l, wflag)
- X+ char *f;
- X+ char *s;
- X+ size_t l;
- X+ bool wflag;
- X+ {
- X+ register s_region *cp = areastart;
- X+ s_region *lp = (s_region *)NULL;
- X+ s_region *sp = (s_region *)(s - sizeof (s_region));
- X+ unsigned long cadd;
- X+ unsigned long cadd1 = (unsigned long)etext << 4L;
- X+
- X+ cadd = ((FP_SEG (s)) << 4L) + FP_OFF (s);
- X+
- X+ if ((cadd == 0L) || (wflag && (s == null)))
- X+ {
- X+ print_warn ("%s: access to NULL segment\n", f);
- X+
- X+ if (wflag)
- X+ exit (1);
- X+ }
- X+
- X+ if (cadd < cadd1)
- X+ print_warn ("warning - %s: access to text segment\n", f);
- X+
- X+ if (l < 0)
- X+ {
- X+ print_warn ("%s: bad length %d\n", f, l);
- X+ exit (1);
- X+ }
- X+
- X+ if (s != (char *)NULL)
- X+ {
- X+ while (cp != (s_region *)NULL)
- X+ {
- X+ if (cp != sp)
- X+ {
- X+ lp = cp;
- X+ cp = cp->next;
- X+ continue;
- X+ }
- X+
- X+ /* Found it, check the length and other things */
- X+
- X+ if ((cp->magic1 != MAGIC1) ||
- X+ (*((int *)(s + cp->len)) != MAGIC2))
- X+ {
- X+ print_warn ("%s: access to deleted block\n", f);
- X+ exit (1);
- X+ }
- X+
- X+ if (l > cp->len)
- X+ {
- X+ print_warn ("%s: bad length %d\n", f, l);
- X+ exit (1);
- X+ }
- X+
- X+ return;
- X+ }
- X+ }
- X+ }
- X+ #endif
- XIndex: shell/sh10.c
- XPrereq: 1.3
- X*** ../sh16.2/shell/sh10.c Thu Jun 21 21:46:42 1990
- X--- shell/sh10.c Fri Aug 17 21:32:51 1990
- X***************
- X*** 12,20 ****
- X * 2. The sources (or parts thereof) or objects generated from the sources
- X * (or parts of sources) cannot be sold under any circumstances.
- X *
- X! * $Header: sh10.c 1.3 90/05/31 09:51:06 MS_user Exp $
- X *
- X * $Log: sh10.c $
- X * Revision 1.3 90/05/31 09:51:06 MS_user
- X * Add some signal lockouts to prevent corruption
- X *
- X--- 12,24 ----
- X * 2. The sources (or parts thereof) or objects generated from the sources
- X * (or parts of sources) cannot be sold under any circumstances.
- X *
- X! * $Header: C:/SRC/SHELL/RCS/sh10.c 1.4 90/08/14 23:33:32 MS_user Exp $
- X *
- X * $Log: sh10.c $
- X+ * Revision 1.4 90/08/14 23:33:32 MS_user
- X+ * Fix memory bugs - Add Copy function code to code a function tree
- X+ * before it is executed.
- X+ *
- X * Revision 1.3 90/05/31 09:51:06 MS_user
- X * Add some signal lockouts to prevent corruption
- X *
- X***************
- X*** 40,49 ****
- X #include <stdlib.h>
- X #include <fcntl.h>
- X #include <limits.h>
- X #include "sh.h"
- X
- X- /* Function declarations */
- X
- X static void Print_Command (C_Op *);
- X static void Print_IO (IO_Actions *);
- X static void Print_Case (C_Op *);
- X--- 44,55 ----
- X #include <stdlib.h>
- X #include <fcntl.h>
- X #include <limits.h>
- X+ #include <dirent.h>
- X #include "sh.h"
- X
- X
- X+ /* Function declarations */
- X+
- X static void Print_Command (C_Op *);
- X static void Print_IO (IO_Actions *);
- X static void Print_Case (C_Op *);
- X***************
- X*** 51,58 ****
- X--- 57,68 ----
- X static void Set_Free_ExTree (C_Op *, void (*)(char *));
- X static void Set_Free_Command (C_Op *, void (*)(char *));
- X static void Set_Free_Case (C_Op *, void (*)(char *));
- X+ static C_Op *Copy_ExTree (C_Op *);
- X+ static void Copy_Command (C_Op *, C_Op *);
- X+ static C_Op *Copy_Case (C_Op *);
- X static void Set_ExTree (char *);
- X static void Free_ExTree (char *);
- X+ static void *field_dup (void *, size_t);
- X
- X static int Print_indent; /* Current indent level */
- X
- X***************
- X*** 628,631 ****
- X--- 638,840 ----
- X (*func)((char *)t1->words);
- X
- X Set_Free_ExTree (t1->left, func);
- X+ }
- X+
- X+ /*
- X+ * Copy function tree area by recursively processing of tree
- X+ */
- X+
- X+ static C_Op *Copy_ExTree (Old_t)
- X+ C_Op *Old_t;
- X+ {
- X+ char **wp;
- X+ C_Op *New_t;
- X+ Word_B *wb = (Word_B *)NULL;
- X+
- X+ if (Old_t == (C_Op *)NULL)
- X+ return (C_Op *)NULL;
- X+
- X+ New_t = (C_Op *) field_dup (Old_t, sizeof (C_Op));
- X+
- X+ /* Check for start of print */
- X+
- X+ if (Old_t->type == TFUNC)
- X+ {
- X+ New_t->words = (char **)getcell (sizeof (char *) * 2);
- X+ *New_t->words = strsave (*Old_t->words, areanum);
- X+ New_t->left = Copy_ExTree (Old_t->left);
- X+ }
- X+
- X+ /* Otherwise, process the tree and print it */
- X+
- X+ switch (Old_t->type)
- X+ {
- X+ case TPAREN: /* () */
- X+ case TCOM: /* A command process */
- X+ Copy_Command (Old_t, New_t);
- X+ break;
- X+
- X+ case TPIPE: /* Pipe processing */
- X+ case TLIST: /* Entries in a for statement */
- X+ case TOR: /* || and && */
- X+ case TAND:
- X+ case TWHILE: /* WHILE and UNTIL functions */
- X+ case TUNTIL:
- X+ New_t->left = Copy_ExTree (Old_t->left);
- X+ New_t->right = Copy_ExTree (Old_t->right);
- X+ break;
- X+
- X+ case TFOR: /* First part of a for statement*/
- X+ New_t->str = strsave (Old_t->str, areanum);
- X+
- X+ if ((wp = Old_t->words) != (char **)NULL)
- X+ {
- X+ while (*wp != (char *)NULL)
- X+ wb = addword (strsave (*(wp++), areanum), wb);
- X+
- X+ New_t->words = getwords (addword ((char *)NULL, wb));
- X+ }
- X+
- X+ New_t->left = Copy_ExTree (Old_t->left);
- X+ break;
- X+
- X+ case TIF: /* IF and ELSE IF functions */
- X+ case TELIF:
- X+ if (Old_t->right != (C_Op *)NULL)
- X+ {
- X+ New_t->right = (C_Op *)field_dup (Old_t->right, sizeof (C_Op));
- X+ New_t->right->left = Copy_ExTree (Old_t->right->left);
- X+ New_t->right->right = Copy_ExTree (Old_t->right->right);
- X+ }
- X+
- X+ case TBRACE: /* {} statement */
- X+ New_t->left = Copy_ExTree (Old_t->left);
- X+ break;
- X+
- X+ case TCASE: /* CASE function */
- X+ New_t->str = strsave (Old_t->str, areanum);
- X+ New_t->left = Copy_Case (Old_t->left);
- X+ break;
- X+ }
- X+
- X+ return New_t;
- X+ }
- X+
- X+ /*
- X+ * Copy a command line
- X+ */
- X+
- X+ static void Copy_Command (Old_t, New_t)
- X+ C_Op *Old_t, *New_t;
- X+ {
- X+ IO_Actions **iopp;
- X+ char **wp = Old_t->words;
- X+ Word_B *wb = (Word_B *)NULL;
- X+ IO_Actions *iop;
- X+
- X+ /* Parenthesis ? */
- X+
- X+ if (Old_t->type == TPAREN)
- X+ New_t->left = Copy_ExTree (Old_t->left);
- X+
- X+ else
- X+ {
- X+ while (*wp != (char *)NULL)
- X+ wb = addword (strsave (*(wp++), areanum), wb);
- X+
- X+ New_t->words = getwords (addword ((char *)NULL, wb));
- X+ }
- X+
- X+ /* Process up any IO required */
- X+
- X+ if ((iopp = Old_t->ioact) != (IO_Actions **)NULL)
- X+ {
- X+ wb = (Word_B *)NULL;
- X+
- X+ while (*iopp != (IO_Actions *)NULL)
- X+ {
- X+ iop = (IO_Actions *)field_dup (*iopp, sizeof (IO_Actions));
- X+ iop->io_name = strsave ((*iopp)->io_name, areanum);
- X+ wb = addword ((char *)iop, wb);
- X+ ++iopp;
- X+ }
- X+
- X+ New_t->ioact = (IO_Actions **)getwords (addword ((char *)NULL, wb));
- X+ }
- X+ }
- X+
- X+ /*
- X+ * Copy the contents of a case statement
- X+ */
- X+
- X+ static C_Op *Copy_Case (Old_t)
- X+ C_Op *Old_t;
- X+ {
- X+ register C_Op *Old_t1, *New_t, *New_t1;
- X+ register char **wp;
- X+ Word_B *wb = (Word_B *)NULL;
- X+
- X+ if (Old_t == (C_Op *)NULL)
- X+ return (C_Op *)NULL;
- X+
- X+ /* type - TLIST - go down the left tree first and then processes this level */
- X+
- X+ New_t = (C_Op *)field_dup (Old_t, sizeof (C_Op));
- X+
- X+ if (Old_t->type == TLIST)
- X+ {
- X+ New_t->left = Copy_Case (Old_t->left);
- X+ New_t->right = (C_Op *)field_dup (Old_t->right, sizeof (C_Op));
- X+ Old_t1 = Old_t->right;
- X+ New_t1 = New_t->right;
- X+ }
- X+
- X+ else
- X+ {
- X+ New_t1 = New_t;
- X+ Old_t1 = Old_t;
- X+ }
- X+
- X+ /* Duplicate the word block */
- X+
- X+ wp = Old_t1->words;
- X+
- X+ while (*wp != (char *)NULL)
- X+ wb = addword (strsave (*(wp++), areanum), wb);
- X+
- X+ New_t1->words = getwords (addword ((char *)NULL, wb));
- X+ New_t1->left = Copy_ExTree (Old_t1->left);
- X+ return New_t;
- X+ }
- X+
- X+
- X+ /*
- X+ * Duplicate a field
- X+ */
- X+
- X+ static void *field_dup (source, size)
- X+ void *source;
- X+ size_t size;
- X+ {
- X+ return memcpy (space (size), source, size);
- X+ }
- X+
- X+ /* Duplicate the tree */
- X+
- X+ C_Op *Copy_Function (Old_t)
- X+ C_Op *Old_t;
- X+ {
- X+ int *save_errpt;
- X+ jmp_buf new_errpt;
- X+ C_Op *New_t = (C_Op *)NULL;
- X+
- X+ /* Set up for error handling - like out of space */
- X+
- X+ save_errpt = e.errpt;
- X+
- X+ if (setjmp (new_errpt) == 0)
- X+ New_t = Copy_ExTree (Old_t);
- X+
- X+ e.errpt = save_errpt;
- X+ return New_t;
- X }
- XIndex: shell/sh2.c
- XPrereq: 1.5
- X*** ../sh16.2/shell/sh2.c Thu Jun 21 21:47:05 1990
- X--- shell/sh2.c Fri Aug 17 21:34:11 1990
- X***************
- X*** 13,21 ****
- X * 2. The sources (or parts thereof) or objects generated from the sources
- X * (or parts of sources) cannot be sold under any circumstances.
- X *
- X! * $Header: sh2.c 1.5 90/04/25 09:18:38 MS_user Exp $
- X *
- X * $Log: sh2.c $
- X * Revision 1.5 90/04/25 09:18:38 MS_user
- X * Fix for ... do to not require terminating colon
- X *
- X--- 13,24 ----
- X * 2. The sources (or parts thereof) or objects generated from the sources
- X * (or parts of sources) cannot be sold under any circumstances.
- X *
- X! * $Header: C:/SRC/SHELL/RCS/sh2.c 1.6 90/08/14 23:30:26 Ian_Stewartson Exp $
- X *
- X * $Log: sh2.c $
- X+ * Revision 1.6 90/08/14 23:30:26 Ian_Stewartson
- X+ * Add support for read/write IO
- X+ *
- X * Revision 1.5 90/04/25 09:18:38 MS_user
- X * Fix for ... do to not require terminating colon
- X *
- X***************
- X*** 42,47 ****
- X--- 45,52 ----
- X #include <string.h>
- X #include <ctype.h>
- X #include <unistd.h>
- X+ #include <limits.h>
- X+ #include <dirent.h>
- X #include "sh.h"
- X
- X /*
- X***************
- X*** 886,898 ****
- X {
- X register int c;
- X
- X if (((c = Getc (0)) == '>') || (c == '<'))
- X {
- X- if (c != ec)
- X- yyerror (syntax_err);
- X
- X! yylval.i = (ec == '>') ? IOWRITE | IOCAT : IOHERE;
- X! c = Getc(0);
- X }
- X
- X else
- X--- 891,915 ----
- X {
- X register int c;
- X
- X+ /* Get the next character to see if it is a re-direction character as well */
- X+
- X if (((c = Getc (0)) == '>') || (c == '<'))
- X {
- X
- X! /* Check for open in read/write mode */
- X!
- X! if ((ec == '<') && (c == '>'))
- X! yylval.i = IOWRITE | IOREAD;
- X!
- X! /* Otherwise, we must have a double character */
- X!
- X! else if (c != ec)
- X! yyerror (syntax_err);
- X!
- X! else
- X! yylval.i = (ec == '>') ? IOWRITE | IOCAT : IOHERE;
- X!
- X! c = Getc (0);
- X }
- X
- X else
- SHAR_EOF
- echo "File Patch1.6.3 is complete" &&
- $TOUCH -am 0820110190 Patch1.6.3 &&
- chmod 0644 Patch1.6.3 ||
- echo "restore of Patch1.6.3 failed"
- set `wc -c Patch1.6.3`;Wc_c=$1
- if test "$Wc_c" != "51095"; then
- echo original size 51095, current size $Wc_c
- fi
- rm -f @shar_seq_.tmp
- echo "You have unpacked the last part"
- exit 0
-
-