home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
pc
/
source
/
ms_sh16.lzh
/
ms_sh.5
< prev
next >
Wrap
Text File
|
1990-05-06
|
39KB
|
1,588 lines
#!/bin/sh
# this is part 5 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file Patch1.6 continued
#
CurArch=5
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
exit 1; fi
( read Scheck
if test "$Scheck" != $CurArch
then echo "Please unpack part $Scheck next!"
exit 1;
else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file Patch1.6"
sed 's/^X//' << 'SHAR_EOF' >> Patch1.6
X int i = (int)strtol (cp, &ep, 10);
X
X! /* Get the previous command ? (single !) */
X
X! if (c_len == 0)
X {
X if (c_history < 0)
X- {
X- M_length = -1;
X return Re_start (No_prehistory);
X- }
X
X return TRUE;
X }
X--- 793,811 ----
X
X static bool Scan_History ()
X {
X! char *cp = l_buffer + 1;
X char *ep;
X int i = (int)strtol (cp, &ep, 10);
X
X! /* Get the previous command ? (single ! or double !!) */
X
X! if ((M_length == 0) || (*cp == '!'))
X {
X+ if (c_history >= l_history)
X+ c_history = l_history - 1;
X+
X if (c_history < 0)
X return Re_start (No_prehistory);
X
X return TRUE;
X }
X***************
X*** 627,640 ****
X /* Request for special history number item. Check History file empty */
X
X if (l_history == 0)
X- {
X- M_length = -1;
X return Re_start (No_MatchHistory);
X- }
X
X /* Check for number */
X
X! if (!*ep)
X {
X M_length = -1;
X
X--- 813,823 ----
X /* Request for special history number item. Check History file empty */
X
X if (l_history == 0)
X return Re_start (No_MatchHistory);
X
X /* Check for number */
X
X! if ((*l_buffer == '!') && (ep > cp) && M_length)
X {
X M_length = -1;
X
X***************
X*** 648,654 ****
X else
X {
X for (c_history = l_history - 1;
X! (strncmp (cp, cmd_history[c_history].command, c_len) != 0)
X && (c_history >= 0);
X --c_history);
X }
X--- 831,837 ----
X else
X {
X for (c_history = l_history - 1;
X! (strncmp (cp, cmd_history[c_history].command, M_length) != 0)
X && (c_history >= 0);
X --c_history);
X }
X***************
X*** 674,680 ****
X
X if (l_history == 0)
X {
X- M_length = -1;
X Re_start (No_MatchHistory);
X return;
X }
X--- 857,862 ----
X***************
X*** 686,692 ****
X
X /* Anything found ? */
X
X! if ((c_history < 0) || (c_history == l_history))
X {
X c_history = l_history - 1;
X Re_start (No_MatchHistory);
X--- 868,874 ----
X
X /* Anything found ? */
X
X! if ((c_history < 0) || (c_history >= l_history))
X {
X c_history = l_history - 1;
X Re_start (No_MatchHistory);
X***************
X*** 712,719 ****
X l_history = 0; /* End of history array */
X
X if ((lset = lookup (history_file, TRUE))->value == null)
X! setval (lset, strcat (strcpy (l_buffer, lookup (home, FALSE)->value),
X! "history.sh"));
X
X if (!History_Enabled || ((fp = fopen (lset->value, "rt")) == (FILE *)NULL))
X return;
X--- 894,903 ----
X l_history = 0; /* End of history array */
X
X if ((lset = lookup (history_file, TRUE))->value == null)
X! {
X! setval (lset, (cp = Build_H_Filename ("history.sh")));
X! DELETE (cp);
X! }
X
X if (!History_Enabled || ((fp = fopen (lset->value, "rt")) == (FILE *)NULL))
X return;
X***************
X*** 844,849 ****
X--- 1028,1036 ----
X {
X if (cp != (char *)NULL)
X {
X+ if (strlen (l_buffer) && (s_cursor != -1))
X+ S_putc (NL);
X+
X print_warn (cp);
X erase_to_end_of_line ();
X v1_putc (NL);
X***************
X*** 853,862 ****
X
X /* Re-initialise */
X
X! c_buffer_pos = l_buffer;
X! end_buffer = l_buffer;
X! read_cursor_position ();
X!
X return FALSE;
X }
X
X--- 1040,1046 ----
X
X /* Re-initialise */
X
X! Init_Input (insert_mode);
X return FALSE;
X }
X
X***************
X*** 869,872 ****
X--- 1053,1458 ----
X {
X while (cnt--)
X *(sp1--) = *(sp--);
X+ }
X+
X+ /* Complete file name */
X+
X+ static bool Complete_file (fn_start, fn_search)
X+ char *fn_start;
X+ bool fn_search;
X+ {
X+ char *fn_end, *cp, *fn_mstart, fn_es, *fn_dir;
X+ int fn_len, pre_len, i;
X+ DIR *dn;
X+ char d_name [NAME_MAX + 1];
X+ struct dirent *d_ce;
X+ int found_cnt = 0;
X+ int max_per_line;
X+ static char *ms_drive = "a:/";
X+
X+ while (!isspace (*fn_start) && (fn_start != l_buffer))
X+ --fn_start;
X+
X+ if (isspace (*fn_start))
X+ ++fn_start;
X+
X+ fn_end = fn_start;
X+
X+ while (!isspace (*fn_end) && (fn_end != end_buffer))
X+ ++fn_end;
X+
X+ /* Get the directory name */
X+
X+ if (fn_end != end_buffer)
X+ {
X+ fn_es = *fn_end;
X+ *fn_end = 0;
X+ }
X+
X+ /* Find the directory name */
X+
X+ if ((cp = strrchr (fn_start, '/')) != (char *)NULL)
X+ {
X+ fn_mstart = cp + 1;
X+ fn_dir = fn_start;
X+ }
X+
X+ /* No directory flag - Drive specifier? */
X+
X+ else if (*(fn_start + 1) == ':')
X+ {
X+ *(fn_dir = ms_drive) = *fn_start;
X+ *(fn_dir + 2) = '.';
X+ fn_mstart = fn_start + 2;
X+ }
X+
X+ /* No drive specifier */
X+
X+ else
X+ {
X+ fn_dir = ".";
X+ fn_mstart = fn_start;
X+ }
X+
X+ /* Set up some values - length and end */
X+
X+ fn_len = fn_end - fn_mstart;
X+
X+ if (fn_end != end_buffer)
X+ *fn_end = fn_es;
X+
X+ /* Get the match length which must be nonzero unless we are doing a display
X+ * of the directory
X+ */
X+
X+ if (!fn_len && !fn_search)
X+ {
X+ v1_putc (0x07);
X+ return FALSE;
X+ }
X+
X+ /* Reset the / to a zero to terminate the directory name */
X+
X+ if (cp != (char *)NULL)
X+ *cp = 0;
X+
X+ /* Check for some special cases - root */
X+
X+ if ((i = strlen (fn_dir)) == 0)
X+ fn_dir = "/";
X+
X+ else if ((i == 2) && (*(fn_dir + 1) == ':'))
X+ {
X+ *(fn_dir = ms_drive) = *fn_start;
X+ *(fn_dir + 2) = '/';
X+ }
X+
X+ /* Get the prefix length and open the directory */
X+
X+ pre_len = fn_mstart - l_buffer;
X+ dn = opendir (fn_dir);
X+
X+ if (cp != (char *)NULL)
X+ *cp = '/';
X+
X+ if (dn == (DIR *)NULL)
X+ {
X+ v1_putc (0x07);
X+ return FALSE;
X+ }
X+
X+ /* Initialise the save buffer for a search or a match. In the case of a
X+ * search, we alway want to output NAME_MAX characters. In the case of a
X+ * match we want to know if we found it.
X+ */
X+
X+ d_name[NAME_MAX] = 0;
X+ *d_name = 0;
X+ max_per_line = (Max_Cols / (((NAME_MAX / 8) + 1) * 8));
X+
X+ /* Scan the directory */
X+
X+ while ((d_ce = readdir (dn)) != (struct dirent *)NULL)
X+ {
X+ if (strnicmp (d_ce->d_name, fn_mstart, fn_len) == 0)
X+ {
X+
X+ /* Are we displaying the directory or just searching */
X+
X+ if (fn_search)
X+ {
X+ v1_putc ((char)((found_cnt % max_per_line == 0) ? NL : '\t'));
X+ memset (d_name, ' ', NAME_MAX);
X+ memcpy (d_name, d_ce->d_name, strlen (d_ce->d_name));
X+ v1_puts (d_name);
X+ }
X+
X+ /* Just search - check for first entry match */
X+
X+ else if (!*d_name)
X+ strcpy (d_name, d_ce->d_name);
X+
X+ else
X+ {
X+ for (i = fn_len; d_name[i] == d_ce->d_name[i] ; i++);
X+ d_name[i] = 0;
X+ }
X+
X+ /* Increment counter */
X+
X+ ++found_cnt;
X+ }
X+ }
X+
X+ closedir (dn);
X+
X+ /* If we are searching and we found something - redraw */
X+
X+ if (fn_search && found_cnt)
X+ {
X+ v1_putc (NL);
X+ put_prompt (last_prompt);
X+ read_cursor_position ();
X+ return TRUE;
X+ }
X+
X+ /* Did I find anything? - no exit */
X+
X+ if (!*d_name)
X+ {
X+ v1_putc (0x07);
X+ return FALSE;
X+ }
X+
X+ /* Check that the line is not too long and if there is an end bit, we can
X+ * save a copy of it.
X+ */
X+
X+ cp = null;
X+ fn_len = strlen (fn_end);
X+
X+ if (((fn_len + strlen (d_name) + pre_len) >= LINE_MAX) ||
X+ ((fn_len != 0) && ((cp = strdup (fn_end)) == (char *)NULL)))
X+ {
X+ v1_putc (0x07);
X+ return FALSE;
X+ }
X+
X+ /* Append the new end of line bits */
X+
X+ strcpy (fn_mstart, d_name);
X+ strcat (fn_mstart, cp);
X+
X+ if (cp != null)
X+ free (cp);
X+
X+ end_buffer = &l_buffer[strlen (l_buffer)];
X+ c_buffer_pos = end_buffer;
X+
X+ /* Beep if more than one */
X+
X+ if (found_cnt > 1)
X+ v1_putc (0x07);
X+
X+ return TRUE;
X+ }
X+
X+ /* Initialise input */
X+
X+ static void Init_Input (im)
X+ bool im;
X+ {
X+ c_buffer_pos = l_buffer; /* Initialise */
X+ end_buffer = l_buffer;
X+ insert_mode = im;
X+ M_length = -1;
X+
X+ /* Reset max line length and get the number of columns */
X+
X+ Max_Length = 0;
X+ Get_Screen_Params ();
X+
X+ /* Save the cursor position */
X+
X+ read_cursor_position ();
X+ }
X+
X+ /* Configure Keyboard I/O */
X+
X+ void Configure_Keys ()
X+ {
X+ char *sp; /* Line pointers */
X+ char *cp;
X+ FILE *fp;
X+ char *line; /* Input line */
X+ char c; /* Save character */
X+ int i, fval, cval;
X+ int line_len;
X+
X+ /* Get some memory for the input line and the file name */
X+
X+ line_len = max (strlen (Program_Name) + 4, 200);
X+ if ((line = getcell (line_len)) == (char *)NULL)
X+ return;
X+
X+ strcpy (line, Program_Name);
X+
X+ /* Find the .exe in the name */
X+
X+ if ((cp = strrchr (line, '/')) != (char *)NULL)
X+ ++cp;
X+
X+ else
X+ cp = line;
X+
X+ if ((cp = strrchr (cp, '.')) == (char *)NULL)
X+ cp = &line[strlen (line)];
X+
X+ strcpy (cp, ".ini");
X+
X+ if ((fp = fopen (line, "rt")) == (FILE *)NULL)
X+ {
X+ DELETE (line);
X+ return;
X+ }
X+
X+ while (fgets (line, line_len - 1, fp) != (char *)NULL)
X+ {
X+
X+ /* Ignore comment lines */
X+
X+ if (*line == '#')
X+ continue;
X+
X+ /* Remove the EOL */
X+
X+ if ((cp = strchr (line, '\n')) != (char *)NULL)
X+ *cp = 0;
X+
X+ /* Find the keyword */
X+
X+ cp = line;
X+ while (!isspace (*cp) && *cp && (*cp != '='))
X+ ++cp;
X+
X+ if (!*cp)
X+ continue;
X+
X+ c = *cp;
X+ *cp = 0;
X+
X+ /* Look up the keyword name */
X+
X+ for (i = 0; (i < KF_LENGTH) &&
X+ (stricmp (line, KF_List[i].kf_name) != 0); ++i);
X+
X+ /* Ignore no matches */
X+
X+ if (i == KF_LENGTH)
X+ continue;
X+
X+ /* Find the equals */
X+
X+ *cp = c;
X+ while (isspace (*cp))
X+ ++cp;
X+
X+ if (*(cp++) != '=')
X+ continue;
X+
X+ while (isspace (*cp))
X+ ++cp;
X+
X+ /* Get the value */
X+
X+ errno = 0;
X+ cval = 0;
X+
X+ fval = (int)strtol (cp, &sp, 0);
X+
X+ /* Check for correct terminator */
X+
X+ if (errno || (fval < 0) ||
X+ ((fval != 0) && *sp) ||
X+ ((fval == 0) &&
X+ (((i < KF_END_FKEYS) && !isspace (*sp)) ||
X+ ((i >= KF_END_FKEYS) && *sp))))
X+ continue;
X+
X+ if ((fval == 0) && (i < KF_END_FKEYS))
X+ {
X+ cp = sp;
X+ while (isspace (*cp))
X+ ++cp;
X+
X+ errno = 0;
X+ cval = (int)strtol (cp, &sp, 0);
X+
X+ if (errno || (cval == 0) || *sp)
X+ continue;
X+ }
X+
X+ /* OK we have a valid value, save it */
X+
X+ KF_List[i].akey = (char)fval;
X+ KF_List[i].fkey = (char)cval;
X+ }
X+
X+ DELETE (line);
X+ fclose (fp);
X+ }
X+ #endif
X+
X+ /* Check cursor is in column zero */
X+
X+ void In_Col_Zero ()
X+ {
X+ union REGS r;
X+
X+ Get_Screen_Params ();
X+ read_cursor_position ();
X+
X+ r.h.ah = 0x08;
X+ r.h.bh = 0x00;
X+ int86 (0x10, &r, &r);
X+
X+ if ((s_cursor % Max_Cols) || (r.h.al != ' '))
X+ v1_putc (NL);
X+ }
X+
X+ /* Get screen parameters */
X+
X+ static void Get_Screen_Params ()
X+ {
X+ union REGS r;
X+
X+ Max_Cols = *(int *)(0x0040004aL);
X+ Max_Lines = 25;
X+
X+ /* Is this an EGA? This test was found in NANSI.SYS */
X+
X+ r.h.ah = 0x12;
X+ r.x.bx = 0xff10;
X+ int86 (0x10, &r, &r);
X+
X+ if (r.x.bx & 0xfefc)
X+ return;
X+
X+ /* Else read the number of rows */
X+
X+ r.x.ax = 0x1130;
X+ r.h.bh = 0;
X+ int86 (0x10, &r, &r);
X+ Max_Lines = r.h.dl + 1;
X+ }
X+
X+ /* Ring Bell ? */
X+
X+ bool Ring_Bell ()
X+ {
X+ #ifdef NO_HISTORY
X+ return TRUE;
X+ #else
X+ return (bool)(KF_List[KF_RINGBELL].akey ? TRUE : FALSE);
X+ #endif
X }
XIndex: shell/sh4.c
XPrereq: 1.1
X*** ../sh15/shell/sh4.c Fri Feb 16 19:21:44 1990
X--- shell/sh4.c Tue May 1 19:49:02 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: sh4.c 1.1 90/01/25 13:41:38 MS_user Exp $
X *
X * $Log: sh4.c $
X * Revision 1.1 90/01/25 13:41:38 MS_user
X * Initial revision
X *
X--- 13,37 ----
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: sh4.c 1.6 90/04/25 22:35:26 MS_user Exp $
X *
X * $Log: sh4.c $
X+ * Revision 1.6 90/04/25 22:35:26 MS_user
X+ * Make anys a global function
X+ *
X+ * Revision 1.5 90/03/27 20:33:41 MS_user
X+ * Clear extended file name on interrupt
X+ *
X+ * Revision 1.4 90/03/16 21:27:33 MS_user
X+ * Stop grave changing NL to SP for here documents
X+ *
X+ * Revision 1.3 90/03/16 11:50:41 MS_user
X+ * Correct Bug which prevents $$, $#, $!, $? and $- working.
X+ *
X+ * Revision 1.2 90/03/14 19:30:34 MS_user
X+ * Change subgetc for here document processing. In particular `list`
X+ * processing. I hope the detection method for this is right!
X+ *
X * Revision 1.1 90/01/25 13:41:38 MS_user
X * Initial revision
X *
X***************
X*** 48,62 ****
X
X static void globname (char *, char *);
X static bool expand (char *, Word_B **, int);
X! static char dollar (int);
X! static bool grave (int);
X static Word_B *Expand_globs (char *, Word_B *);
X static bool anyspcl (Word_B *);
X static char *blank (int);
X static char *generate (char *, char *, char *, char *);
X static char *unquote (char *);
X static Word_B *newword (int);
X- static bool anys (char *, char *);
X static char *anys_p (char *, char *);
X static void Glob_MDrives (char *, char *);
X static char *Check_Multi_Drive (char *);
X--- 64,77 ----
X
X static void globname (char *, char *);
X static bool expand (char *, Word_B **, int);
X! static char dollar (bool);
X! static bool grave (bool);
X static Word_B *Expand_globs (char *, Word_B *);
X static bool anyspcl (Word_B *);
X static char *blank (int);
X static char *generate (char *, char *, char *, char *);
X static char *unquote (char *);
X static Word_B *newword (int);
X static char *anys_p (char *, char *);
X static void Glob_MDrives (char *, char *);
X static char *Check_Multi_Drive (char *);
X***************
X*** 169,176 ****
X /* Expand special characters and variables */
X
X static bool expand (cp, wbp, f)
X! register char *cp;
X! register Word_B **wbp;
X {
X jmp_buf ev;
X
X--- 184,192 ----
X /* Expand special characters and variables */
X
X static bool expand (cp, wbp, f)
X! register char *cp; /* String to process */
X! register Word_B **wbp; /* Word block */
X! int f; /* Expand mode */
X {
X jmp_buf ev;
X
X***************
X*** 212,218 ****
X if (((f & DOGLOB) == 0) || FL_TEST ('f'))
X {
X if (f & DOTRIM)
X! unquote(cp);
X
X *wbp = addword (cp, *wbp);
X }
X--- 228,234 ----
X if (((f & DOGLOB) == 0) || FL_TEST ('f'))
X {
X if (f & DOTRIM)
X! unquote (cp);
X
X *wbp = addword (cp, *wbp);
X }
X***************
X*** 238,245 ****
X {
X register int c, c1;
X register char *sp = e.linep;
X! int scanequals = f & DOKEY;
X! int foundequals = 0;
X
X loop:
X switch (c = subgetc ('"', foundequals))
X--- 254,261 ----
X {
X register int c, c1;
X register char *sp = e.linep;
X! int scanequals = (f & DOKEY) ? TRUE : FALSE;
X! bool foundequals = FALSE;
X
X loop:
X switch (c = subgetc ('"', foundequals))
X***************
X*** 259,269 ****
X
X case '"':
X case '\'':
X! scanequals = 0;
X if (INSUB())
X break;
X
X! for (c1 = c; (c = subgetc ((char)c1, 1)) != c1;)
X {
X if (c == 0)
X break;
X--- 275,285 ----
X
X case '"':
X case '\'':
X! scanequals = FALSE;
X if (INSUB())
X break;
X
X! for (c1 = c; (c = subgetc ((char)c1, TRUE)) != c1;)
X {
X if (c == 0)
X break;
X***************
X*** 280,286 ****
X unget(c);
X
X if (!isalpha (c))
X! scanequals = 0;
X
X while (1)
X {
X--- 296,302 ----
X unget(c);
X
X if (!isalpha (c))
X! scanequals = FALSE;
X
X while (1)
X {
X***************
X*** 288,294 ****
X (f & DOBLANK) && any ((char)c, ifs->value) ||
X !INSUB() && any ((char)c, spcl1))
X {
X! scanequals = 0;
X unget (c);
X
X if (any ((char)c, spcl1))
X--- 304,310 ----
X (f & DOBLANK) && any ((char)c, ifs->value) ||
X !INSUB() && any ((char)c, spcl1))
X {
X! scanequals = FALSE;
X unget (c);
X
X if (any ((char)c, spcl1))
X***************
X*** 301,312 ****
X {
X if (c == '=')
X {
X! foundequals = 1;
X! scanequals = 0;
X }
X
X else if (!isalnum (c))
X! scanequals = 0;
X }
X
X *e.linep++ = (char)c;
X--- 317,328 ----
X {
X if (c == '=')
X {
X! foundequals = TRUE;
X! scanequals = FALSE;
X }
X
X else if (!isalnum (c))
X! scanequals = FALSE;
X }
X
X *e.linep++ = (char)c;
X***************
X*** 322,353 ****
X
X int subgetc (ec, quoted)
X register char ec;
X! int quoted;
X {
X register char c;
X
X! again:
X! c = (char)Getc (ec);
X!
X! if (!INSUB() && ec != '\'')
X {
X! if (c == '`')
X! {
X! if (grave (quoted) == 0)
X! return 0;
X
X! e.iop->task = XGRAVE;
X! goto again;
X! }
X!
X! if (c == '$' && (c = dollar (quoted)) == 0)
X {
X- e.iop->task = XDOLL;
X- goto again;
X- }
X- }
X
X! return c;
X }
X
X /*
X--- 338,398 ----
X
X int subgetc (ec, quoted)
X register char ec;
X! bool quoted;
X {
X register char c;
X
X! while (1)
X {
X! c = (char)Getc (ec);
X
X! if (!INSUB() && ec != '\'')
X {
X
X! /* Found a ` - execute the command */
X!
X! if (c == '`')
X! {
X!
X! /* If both ec (end character) is zero and quoted flag is FALSE, this is execute
X! * command request is in a here document, so we have to collect the rest of
X! * the command from input. Otherwise, the command is in e.iop->argp->aword.
X! *
X! * We also need to set quoted so that NL are not processed when reading
X! * the output from the command.
X! */
X! if (!ec && !quoted)
X! {
X! e.linep = e.cline;
X! if (collect (c, c) != 0)
X! return 0;
X!
X! e.iop->argp->aword = e.cline + 1;
X! quoted = MAYBE;
X! }
X!
X! if (grave (quoted) == 0)
X! return 0;
X!
X! /* Re-read the character from the Grave function */
X!
X! e.iop->task = XGRAVE;
X! }
X!
X! /* $ - check for environment variable subsitution */
X!
X! else if (c == '$' && (c = dollar (quoted)) == 0)
X! e.iop->task = XDOLL;
X!
X! /* No special processing required - return the character */
X!
X! else
X! return c;
X! }
X!
X! else
X! return c;
X! }
X }
X
X /*
X***************
X*** 355,367 ****
X */
X
X static char dollar (quoted)
X! int quoted;
X {
X IO_State *oiop;
X char *dolp, otask;
X register char *s, c, *cp;
X Var_List *vp;
X bool colon_f = FALSE;
X
X c = (char)readc ();
X s = e.linep;
X--- 400,413 ----
X */
X
X static char dollar (quoted)
X! bool quoted;
X {
X IO_State *oiop;
X char *dolp, otask;
X register char *s, c, *cp;
X Var_List *vp;
X bool colon_f = FALSE;
X+ char *dol_special = "$ ";
X
X c = (char)readc ();
X s = e.linep;
X***************
X*** 397,403 ****
X otask = e.iop->task;
X e.iop->task = XOTHER;
X
X! while (((c = (char)subgetc ('"', 0)) != 0) && (c != '}') && (c != NL))
X {
X if (e.linep < e.eline)
X *e.linep++ = c;
X--- 443,450 ----
X otask = e.iop->task;
X e.iop->task = XOTHER;
X
X! while (((c = (char)subgetc ('"', FALSE)) != 0) &&
X! (c != '}') && (c != NL))
X {
X if (e.linep < e.eline)
X *e.linep++ = c;
X***************
X*** 414,421 ****
X gflg++;
X return c;
X }
X- }
X
X /* Check line length */
X
X if (e.linep >= e.eline)
X--- 461,477 ----
X gflg++;
X return c;
X }
X
X+ /* Check for zero length string */
X+
X+ if (s == e.linep)
X+ {
X+ print_error ("sh: bad substitution\n");
X+ gflg++;
X+ return c;
X+ }
X+ }
X+
X /* Check line length */
X
X if (e.linep >= e.eline)
X***************
X*** 485,492 ****
X if (*s == '~')
X dolp = null;
X
X! else if ((dolp = (vp = lookup (s, FALSE))->value) == null)
X {
X switch (c)
X {
X case '=':
X--- 541,554 ----
X if (*s == '~')
X dolp = null;
X
X! else if (!*s || !(isalnum (*s) || any (*s, "#-?$!")))
X {
X+ dol_special[1] = *s;
X+ dolp = dol_special;
X+ }
X+
X+ else if ((dolp = (vp = lookup (s, FALSE))->value) == null)
X+ {
X switch (c)
X {
X case '=':
X***************
X*** 537,549 ****
X */
X
X static bool grave (quoted)
X! int quoted;
X {
X char *cp, *sp;
X int localpipe, rv;
X jmp_buf ev, rt;
X C_Op *outtree;
X Break_C bc;
X
X /* Save area */
X
X--- 599,612 ----
X */
X
X static bool grave (quoted)
X! bool quoted;
X {
X char *cp, *sp;
X int localpipe, rv;
X jmp_buf ev, rt;
X C_Op *outtree;
X Break_C bc;
X+ int (*iof)(IO_State *);
X
X /* Save area */
X
X***************
X*** 625,630 ****
X--- 688,696 ----
X }
X }
X
X+ /* Clean up any files around we nolonger need */
X+
X+ Clear_Extended_File ();
X quitenv ();
X }
X
X***************
X*** 661,667 ****
X *(cp++) = '`';
X lseek (localpipe, 0L, SEEK_SET);
X e.iop->argp->aword = cp;
X! PUSHIO (afile, remap (localpipe), quoted ? qgravechar: gravechar);
X return TRUE;
X }
X
X--- 727,735 ----
X *(cp++) = '`';
X lseek (localpipe, 0L, SEEK_SET);
X e.iop->argp->aword = cp;
X! iof = (!quoted) ? gravechar
X! : ((quoted == MAYBE) ? sgravechar : qgravechar);
X! PUSHIO (afile, remap (localpipe), iof);
X return TRUE;
X }
X
X***************
X*** 989,995 ****
X * Is any character from s1 in s2? Return a boolean.
X */
X
X! static bool anys (s1, s2)
X register char *s1, *s2;
X {
X while (*s1)
X--- 1057,1063 ----
X * Is any character from s1 in s2? Return a boolean.
X */
X
X! bool anys (s1, s2)
X register char *s1, *s2;
X {
X while (*s1)
XIndex: shell/sh.h
XPrereq: 1.3
X*** ../sh15/shell/sh.h Fri Feb 16 19:03:36 1990
X--- shell/sh.h Tue May 1 20:01:03 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: sh.h 1.3 90/02/16 16:58:48 MS_user Exp $
X *
X * $Log: sh.h $
X * Revision 1.3 90/02/16 16:58:48 MS_user
X * Set up 1.5 release
X *
X--- 13,64 ----
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: sh.h 1.17 90/05/01 19:58:18 MS_user Exp $
X *
X * $Log: sh.h $
X+ * Revision 1.17 90/05/01 19:58:18 MS_user
X+ * Change Patchlevel
X+ *
X+ * Revision 1.16 90/04/25 22:33:03 MS_user
X+ * The function anys is now global
X+ *
X+ * Revision 1.15 90/04/25 10:58:05 MS_user
X+ * Add offset in buffer to IO_Args to handle TEXT mode
X+ *
X+ * Revision 1.14 90/04/25 09:21:35 MS_user
X+ * Change version message processing
X+ *
X+ * Revision 1.13 90/04/03 18:07:24 MS_user
X+ * Patchlevel
X+ *
X+ * Revision 1.12 90/03/27 20:25:29 MS_user
X+ * Clear_Extended_File required by sh1 for Interrupt cleanup
X+ *
X+ * Revision 1.11 90/03/26 20:58:24 MS_user
X+ * Change I/O restore so that "exec >filename" works
X+ *
X+ * Revision 1.10 90/03/26 04:31:32 MS_user
X+ * Remove original Interrupt 24 save address
X+ *
X+ * Revision 1.9 90/03/16 21:25:55 MS_user
X+ * Create the MAYBE boolean for stopping the removal of NL by grave.
X+ *
X+ * Revision 1.8 90/03/14 19:29:42 MS_user
X+ * Add some new functions and Buffered Output typedef
X+ * Add IOTHERE for <<- redirection
X+ *
X+ * Revision 1.7 90/03/09 16:10:07 MS_user
X+ * Add build file name function
X+ *
X+ * Revision 1.6 90/03/07 09:43:00 MS_user
X+ * Change PATCHLEVEL
X+ *
X+ * Revision 1.5 90/03/06 15:09:09 MS_user
X+ * Add some new procedures
X+ *
X+ * Revision 1.4 90/02/22 16:40:49 MS_user
X+ * Add XMS Support
X+ *
X * Revision 1.3 90/02/16 16:58:48 MS_user
X * Set up 1.5 release
X *
X***************
X*** 28,34 ****
X *
X */
X
X! #define PATCHLEVEL 1
X #define LINE_MAX 1000 /* Command line length */
X #define HISTORY_MAX 100 /* History array length */
X /* Space for full file name */
X--- 71,77 ----
X *
X */
X
X! #define PATCHLEVEL 4
X #define LINE_MAX 1000 /* Command line length */
X #define HISTORY_MAX 100 /* History array length */
X /* Space for full file name */
X***************
X*** 45,50 ****
X--- 88,100 ----
X #define NL '\n'
X #define SP ' '
X #define NOT '^'
X+
X+ /* Here we introduce a new boolean value - MAYBE. This is required for
X+ * a special case of the grave function
X+ */
X+
X+ #define MAYBE (bool)(-1)
X+
X /* Open in create mode */
X #define O_CMASK (O_WRONLY | O_CREAT | O_TRUNC | O_TEXT)
X /* Open in create mode for a pipe */
X***************
X*** 135,141 ****
X extern unsigned int SW_Mode; /* Type of swapping to do */
X /* 1 - disk */
X /* 2 - Extended memory */
X! /* 3 - Expanded memory */
X extern unsigned int SW_EMSFrame; /* EMS Frame segment */
X
X extern int Swap_Mode; /* Swapping mode */
X--- 185,192 ----
X extern unsigned int SW_Mode; /* Type of swapping to do */
X /* 1 - disk */
X /* 2 - Extended memory */
X! /* 3 - EMS Driver */
X! /* 4 - XMS Driver */
X extern unsigned int SW_EMSFrame; /* EMS Frame segment */
X
X extern int Swap_Mode; /* Swapping mode */
X***************
X*** 155,172 ****
X #define DOBLANK 0x02 /* perform blank interpretation */
X #define DOGLOB 0x04 /* interpret [?* */
X #define DOKEY 0x08 /* move words with `=' to 2nd arg. list */
X! #define DOTRIM 0x01 /* trim resulting string */
X
X #define DOALL (DOSUB | DOBLANK | DOGLOB | DOKEY | DOTRIM)
X
X- extern char *Copy_Right1;
X- extern char *Copy_Right2;
X extern char **dolv; /* $<numeric> values */
X extern int dolc; /* $<numeric> count */
X extern int fn_area_number; /* Next function area number */
X extern int exstat;
X extern char gflg;
X! extern int talking; /* interactive (talking-type */
X extern int execflg;
X extern int multiline; /* \n changed to ; */
X extern int *failpt;
X--- 206,221 ----
X #define DOBLANK 0x02 /* perform blank interpretation */
X #define DOGLOB 0x04 /* interpret [?* */
X #define DOKEY 0x08 /* move words with `=' to 2nd arg. list */
X! #define DOTRIM 0x10 /* trim resulting string */
X
X #define DOALL (DOSUB | DOBLANK | DOGLOB | DOKEY | DOTRIM)
X
X extern char **dolv; /* $<numeric> values */
X extern int dolc; /* $<numeric> count */
X extern int fn_area_number; /* Next function area number */
X extern int exstat;
X extern char gflg;
X! extern bool talking; /* interactive (talking-type */
X extern int execflg;
X extern int multiline; /* \n changed to ; */
X extern int *failpt;
X***************
X*** 175,183 ****
X extern int Current_Event; /* Current history event */
X
X /*
X! * Break/Continue (in for and while), Return and Exit handler
X */
X
X typedef struct brkcon {
X jmp_buf brkpt;
X struct brkcon *nextlev;
X--- 224,244 ----
X extern int Current_Event; /* Current history event */
X
X /*
X! * Buffered Output function
X */
X
X+ #define BIO_LENGTH 20 /* BIO size */
X+
X+ typedef struct Out_Buffer {
X+ int ob_fid; /* File handler */
X+ char *ob_start; /* Start of buffer */
X+ char *ob_cur; /* Current position */
X+ } Out_Buf;
X+
X+ /*
X+ * Break/Continue (in for and while), Return and Exit handler
X+ */
X+
X typedef struct brkcon {
X jmp_buf brkpt;
X struct brkcon *nextlev;
X***************
X*** 228,240 ****
X char *io_name; /* file name */
X } IO_Actions;
X
X! #define IOREAD 1 /* < */
X! #define IOHERE 2 /* << (here file) */
X! #define IOWRITE 4 /* > */
X! #define IOCAT 8 /* >> */
X! #define IOXHERE 16 /* ${}, ` in << */
X! #define IODUP 32 /* >&digit */
X! #define IOCLOSE 64 /* >&- */
X
X #define IODEFAULT (-1) /* token for default IO unit */
X
X--- 289,302 ----
X char *io_name; /* file name */
X } IO_Actions;
X
X! #define IOREAD 0x01 /* < */
X! #define IOHERE 0x02 /* << (here file) */
X! #define IOWRITE 0x04 /* > */
X! #define IOCAT 0x08 /* >> */
X! #define IOXHERE 0x10 /* ${}, ` in << */
X! #define IODUP 0x20 /* >&digit */
X! #define IOCLOSE 0x40 /* >&- */
X! #define IOTHERE 0x80 /* <<- (here file */
X
X #define IODEFAULT (-1) /* token for default IO unit */
X
X***************
X*** 249,254 ****
X--- 311,317 ----
X struct io *iobase;
X struct io *iop;
X int *errpt;
X+ bool eof_p; /* EOF processing enabled */
X int iofd;
X struct env *oenv; /* Previous environment */
X } Environ;
X***************
X*** 322,327 ****
X--- 385,391 ----
X extern char *shell; /* Shell string */
X extern char *hsymbol; /* Hash string */
X extern char *msymbol; /* Minus string */
X+ extern char *Program_Name; /* Program name from argv[0] */
X extern char *spcl2;
X extern char *history_file;
X
X***************
X*** 355,360 ****
X--- 419,425 ----
X int afile; /* file descriptor */
X unsigned int afid; /* buffer id */
X long afpos; /* file position */
X+ int afoff; /* Offset in buffer */
X IO_Buf *afbuf; /* buffer for this file */
X } IO_Args;
X
X***************
X*** 401,409 ****
X */
X
X extern IO_Args temparg; /* temporary for PUSHIO */
X! #define PUSHIO(what,arg,gen) ((temparg.what = (arg)), pushio(&temparg,(gen)))
X! #define RUN(what,arg,gen) ((temparg.what = (arg)), run(&temparg,(gen)))
X
X typedef struct wdblock {
X short w_bsize;
X short w_nword;
X--- 466,477 ----
X */
X
X extern IO_Args temparg; /* temporary for PUSHIO */
X! #define PUSHIO(what, arg, gen) ((temparg.what = (arg)), \
X! pushio (&temparg, (gen)))
X
X+ #define RUN(what, arg, gen, loop) ((temparg.what = (arg)), \
X+ run (&temparg, (gen), loop))
X+
X typedef struct wdblock {
X short w_bsize;
X short w_nword;
X***************
X*** 433,439 ****
X extern bool newenv (int);
X extern void quitenv (void);
X extern char *putn (int);
X- extern void next (int);
X extern void onintr (int);
X extern char *space (int);
X extern char *strsave (char *, int);
X--- 501,506 ----
X***************
X*** 452,458 ****
X extern int getarea (char *);
X extern C_Op *yyparse (void);
X extern int execute (C_Op *, int, int, int);
X! extern int run (IO_Args *, int (*)(IO_State *));
X extern int Getc (int);
X extern void unget (int);
X extern int eofc (void);
X--- 519,525 ----
X extern int getarea (char *);
X extern C_Op *yyparse (void);
X extern int execute (C_Op *, int, int, int);
X! extern int run (IO_Args *, int (*)(IO_State *), bool);
X extern int Getc (int);
X extern void unget (int);
X extern int eofc (void);
X***************
X*** 466,471 ****
X--- 533,539 ----
X extern int filechar (IO_State *);
X extern int gravechar (IO_State *);
X extern int qgravechar (IO_State *);
X+ extern int sgravechar (IO_State *);
X extern int linechar (IO_State *);
X extern void closeall (void);
X extern int remap (int);
X***************
X*** 480,486 ****
X extern char **eval (char **, int);
X extern char **makenv (void);
X extern char *evalstr (char *, int);
X! extern int subgetc (char, int);
X extern Word_B *addword (char *, Word_B *);
X extern char **getwords (Word_B *);
X extern void put_prompt (char *);
X--- 548,554 ----
X extern char **eval (char **, int);
X extern char **makenv (void);
X extern char *evalstr (char *, int);
X! extern int subgetc (char, bool);
X extern Word_B *addword (char *, Word_B *);
X extern char **getwords (Word_B *);
X extern void put_prompt (char *);
X***************
X*** 493,509 ****
X extern int S_close (int, bool);
X extern int S_dup (int);
X extern int S_dup2 (int, int);
X! extern void S_Remap (int, int);
X extern void S_Delete (int);
X extern void Getcwd (void);
X extern char *g_tempname (void);
X extern void S_puts (char *);
X extern void S_putc (int);
X extern bool check_rsh (char *);
X! extern int O_for_execute (char *);
X extern int SA_spawn (char **);
X extern char *findeq (char *);
X! extern int restore_std (int);
X extern void Load_History (void);
X extern void Dump_History (void);
X extern void Display_History (void);
X--- 561,577 ----
X extern int S_close (int, bool);
X extern int S_dup (int);
X extern int S_dup2 (int, int);
X! extern int S_Remap (int, int);
X extern void S_Delete (int);
X extern void Getcwd (void);
X extern char *g_tempname (void);
X extern void S_puts (char *);
X extern void S_putc (int);
X extern bool check_rsh (char *);
X! extern int O_for_execute (char *, char **, int *);
X extern int SA_spawn (char **);
X extern char *findeq (char *);
X! extern int restore_std (int, bool);
X extern void Load_History (void);
X extern void Dump_History (void);
X extern void Display_History (void);
X***************
X*** 525,537 ****
X extern void Restore_Dir (void);
X extern void Restore_Environment (int, int);
X extern int sort_compare (char **, char **);
X! extern int Check_Script (char *);
X
X /*
X * Interrupt handling
X */
X
X extern void interrupt SW_Int24 (void); /* Int 24 New address */
X- extern void (interrupt far *SW_I24_V) (void); /* Old address */
X extern void (interrupt far *SW_I0_V) (void); /* Int 0 address */
X extern void (interrupt far *SW_I23_V) (void); /* Int 23 address */
X--- 593,626 ----
X extern void Restore_Dir (void);
X extern void Restore_Environment (int, int);
X extern int sort_compare (char **, char **);
X! extern int Check_Script (char *, char **, int *);
X! extern bool Interactive (void);
X! extern void In_Col_Zero (void);
X! extern char *Build_H_Filename (char *);
X! extern void Configure_Keys (void);
X! extern bool Ring_Bell (void);
X! extern void Close_buffer (Out_Buf *);
X! extern void Add_buffer (char, Out_Buf *);
X! extern void Adds_buffer (char *, Out_Buf *);
X! extern Out_Buf *Open_buffer (int, bool);
X! extern int collect (int, int);
X! extern void Clear_Extended_File (void);
X! extern void Print_Version (int);
X! extern bool anys (char *, char *);
X
X /*
X * Interrupt handling
X */
X
X extern void interrupt SW_Int24 (void); /* Int 24 New address */
X extern void (interrupt far *SW_I0_V) (void); /* Int 0 address */
X extern void (interrupt far *SW_I23_V) (void); /* Int 23 address */
X+
X+ /*
X+ * XMS Driver functions
X+ */
X+
X+ extern void (far *SW_XMS_Driver) (void); /* XMS Driver Interface */
X+ extern int SW_XMS_Gversion (void);
X+ extern int SW_XMS_Allocate (unsigned int);
X+ extern int SW_XMS_Free (int);
XIndex: shell/sh8.c
XPrereq: 1.1
X*** ../sh15/shell/sh8.c Fri Feb 16 19:17:06 1990
X--- shell/sh8.c Tue May 1 19:49:46 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: sh8.c 1.1 90/01/29 17:46:37 MS_user Exp $
X *
X * $Log: sh8.c $
X * Revision 1.1 90/01/29 17:46:37 MS_user
X * Initial revision
X *
X--- 12,43 ----
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: sh8.c 1.8 90/03/26 20:58:11 MS_user Exp $
X *
X * $Log: sh8.c $
X+ * Revision 1.8 90/03/26 20:58:11 MS_user
X+ * Change I/O restore so that "exec >filename" works
X+ *
X+ * Revision 1.7 90/03/22 13:48:03 MS_user
X+ * MSDOS does not handle /dev/ files after find_first correctly
X+ *
X+ * Revision 1.6 90/03/14 19:32:42 MS_user
X+ * Change buffered output to be re-entrant
X+ *
X+ * Revision 1.5 90/03/14 16:46:21 MS_user
X+ * New Open_buffer parameter and Adds_buffer function
X+ *
X+ * Revision 1.4 90/03/13 21:20:50 MS_user
X+ * Add Buffered Output functions
X+ *
X+ * Revision 1.3 90/03/06 15:14:03 MS_user
X+ * Change script detection to look for a character less than 0x08
X+ *
X+ * Revision 1.2 90/03/05 13:54:08 MS_user
X+ * Fix bug in S_dup
X+ * Change the way we detect shell scripts
X+ * Add support for alternate command interpreters a la V.4
X+ *
X * Revision 1.1 90/01/29 17:46:37 MS_user
X * Initial revision
X *
X***************
X*** 32,42 ****
X #include <string.h>
X #include <unistd.h>
X #include <limits.h>
X #include "sh.h"
X
X #define F_START 4
X
X! static char *nopipe = "can't create pipe - try again\n";
X
X /* List of open files to allow us to simulate the Unix open and unlink
X * operation for temporary files
X--- 55,66 ----
X #include <string.h>
X #include <unistd.h>
X #include <limits.h>
X+ #include <ctype.h>
X #include "sh.h"
X
X #define F_START 4
X
X! static char *nopipe = "can't create pipe - try again\n";
X
X /* List of open files to allow us to simulate the Unix open and unlink
X * operation for temporary files
X***************
X*** 93,100 ****
X return -1;
X }
X
X! /* Set up the structure */
X
X fp->fl_name = strcpy (f_name, name);
X fp->fl_close = d_flag;
X fp->fl_size = F_START;
X--- 117,137 ----
X return -1;
X }
X
X! /* Set up the structure. Change two Unix device names to the DOS
X! * equivalents and disable create
SHAR_EOF
echo "End of part 5"
echo "File Patch1.6 is continued in part 6"
echo "6" > s2_seq_.tmp
exit 0