Import OpenBSD source tree of short before 17:00 UTC today

This commit is contained in:
tg 2003-05-07 17:15:23 +00:00
parent 93aa08df64
commit 7ebc0530d6
8 changed files with 54 additions and 47 deletions

4
edit.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: edit.c,v 1.15 2002/06/09 05:47:27 todd Exp $ */
/* $OpenBSD: edit.c,v 1.16 2003/05/05 22:02:33 fgsch Exp $ */
/*
* Command line editing - common code
@ -1058,7 +1058,7 @@ x_escape(s, len, putbuf_func)
int rval=0;
for (add = 0, wlen = len; wlen - add > 0; add++) {
if (strchr("\\$(){}*&;#|<>\"'", s[add]) || strchr(ifs, s[add])) {
if (strchr("\\$(){}*&;#|<>\"'`", s[add]) || strchr(ifs, s[add])) {
if (putbuf_func(s, add) != 0) {
rval = -1;
break;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: emacs.c,v 1.18 2003/02/28 09:45:09 jmc Exp $ */
/* $OpenBSD: emacs.c,v 1.19 2003/04/16 23:11:52 tdeval Exp $ */
/*
* Emacs-like command line editing and history
@ -886,9 +886,9 @@ x_load_hist(hp)
}
x_histp = hp;
oldsize = x_size_str(xbuf);
(void)strcpy(xbuf, *hp);
strlcpy(xbuf, *hp, xend - xbuf);
xbp = xbuf;
xep = xcp = xbuf + strlen(*hp);
xep = xcp = xbuf + strlen(xbuf);
xlp_valid = FALSE;
if (xep > x_lastcp())
x_goto(xep);
@ -1022,7 +1022,7 @@ x_del_line(c)
int i, j;
*xep = 0;
i = xep- xbuf;
i = xep - xbuf;
j = x_size_str(xbuf);
xcp = xbuf;
x_push(i);

34
eval.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: eval.c,v 1.12 2003/03/10 03:48:16 david Exp $ */
/* $OpenBSD: eval.c,v 1.13 2003/04/16 23:11:52 tdeval Exp $ */
/*
* Expansion - quoting, separation, substitution, globbing
@ -175,6 +175,7 @@ expand(cp, wp, f)
int UNINITIALIZED(newlines); /* For trailing newlines in COMSUB */
int saw_eq, tilde_ok;
int make_magic;
size_t len;
if (cp == NULL)
internal_errorf(1, "expand(NULL)");
@ -415,10 +416,11 @@ expand(cp, wp, f)
* fatal for special builtins (setstr
* does readonly check).
*/
setstr(st->var, debunk(
(char *) alloc(strlen(dp) + 1,
ATEMP), dp),
KSH_UNWIND_ERROR);
len = strlen(dp) + 1;
setstr(st->var,
debunk((char *) alloc(len, ATEMP),
dp, len),
KSH_UNWIND_ERROR);
x.str = str_val(st->var);
type = XSUB;
if (f&DOBLANK)
@ -432,7 +434,7 @@ expand(cp, wp, f)
errorf("%s: %s", st->var->name,
dp == s ?
"parameter null or not set"
: (debunk(s, s), s));
: (debunk(s, s, strlen(s) + 1), s));
}
}
st = st->prev;
@ -576,7 +578,7 @@ expand(cp, wp, f)
else if ((f & DOPAT) || !(fdo & DOMAGIC_))
XPput(*wp, p);
else
XPput(*wp, debunk(p, p));
XPput(*wp, debunk(p, p, strlen(p) + 1));
fdo = 0;
saw_eq = 0;
tilde_ok = (f & (DOTILDE|DOASNTILDE)) ? 1 : 0;
@ -950,7 +952,7 @@ glob(cp, wp, markdirs)
int oldsize = XPsize(*wp);
if (glob_str(cp, wp, markdirs) == 0)
XPput(*wp, debunk(cp, cp));
XPput(*wp, debunk(cp, cp, strlen(cp) + 1));
else
qsortp(XPptrv(*wp) + oldsize, (size_t)(XPsize(*wp) - oldsize),
xstrcmp);
@ -1085,7 +1087,7 @@ globit(xs, xpp, sp, wp, check)
*/
if (!has_globbing(sp, se)) {
XcheckN(*xs, xp, se - sp + 1);
debunk(xp, sp);
debunk(xp, sp, Xnleft(*xs, xp));
xp += strlen(xp);
*xpp = xp;
globit(xs, xpp, np, wp, check);
@ -1174,15 +1176,18 @@ copy_non_glob(xs, xpp, p)
/* remove MAGIC from string */
char *
debunk(dp, sp)
debunk(dp, sp, dlen)
char *dp;
const char *sp;
size_t dlen;
{
char *d, *s;
if ((s = strchr(sp, MAGIC))) {
if (s - sp >= dlen)
return dp;
memcpy(dp, sp, s - sp);
for (d = dp + (s - sp); *s; s++)
for (d = dp + (s - sp); *s && (d - dp < dlen); s++)
if (!ISMAGIC(*s) || !(*++s & 0x80)
|| !strchr("*+?@! ", *s & 0x7f))
*d++ = *s;
@ -1190,11 +1195,12 @@ debunk(dp, sp)
/* extended pattern operators: *+?@! */
if ((*s & 0x7f) != ' ')
*d++ = *s & 0x7f;
*d++ = '(';
if (d - dp < dlen)
*d++ = '(';
}
*d = '\0';
} else if (dp != sp)
strcpy(dp, sp);
strlcpy(dp, sp, dlen);
return dp;
}
@ -1337,7 +1343,7 @@ alt_expand(wp, start, exp_start, end, fdo)
if (fdo & DOGLOB)
glob(start, wp, fdo & DOMARKDIRS);
else
XPput(*wp, debunk(start, start));
XPput(*wp, debunk(start, start, end - start));
return;
}
brace_end = p;

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: ksh.1tbl,v 1.50 2003/03/20 07:30:37 jmc Exp $
.\" $OpenBSD: ksh.1tbl,v 1.51 2003/04/28 06:27:36 jmc Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@ -1366,7 +1366,7 @@ Not yet implemented.
.It Ev EXECSHELL
If set, this parameter is assumed to contain the shell that is to be used to
execute commands that
.Fn execve 2
.Xr execve 2
fails to execute and which do not start with a
.Dq \&#\&! Ns Ar shell
sequence.
@ -1677,7 +1677,7 @@ characters or
.Dq [..]
sequences.
Once brace expansion has been performed, the shell replaces file
name patterns with the sorted named of all the files that match the pattern
name patterns with the sorted names of all the files that match the pattern
(if no files match, the word is left unchanged).
The pattern elements have the following meaning:
.Bl -tag -width Ds
@ -1865,7 +1865,7 @@ except if
exists it is appended to instead of being truncated.
Also, the file is opened
in append mode, so writes always go to the end of the file (see
.Fn open 2 ) .
.Xr open 2 ) .
.It Ic \&< Ar file
Standard input is redirected from
.Ar file ,
@ -2613,7 +2613,7 @@ above).
.Pp
When listing aliases, one of two formats is used.
Normally, aliases are listed as
.Ar name Ns No = Ar value ,
.Ar name Ns No = Ns Ar value ,
where
.Ar value
is quoted.
@ -2828,7 +2828,7 @@ option suppresses the trailing newline,
.Fl e
enables backslash interpretation (a no-op, since this is normally done), and
.Fl E
which suppresses backslash interpretation.
suppresses backslash interpretation.
.It Ic eval Ar command ...
The arguments are concatenated (with spaces between them) to form a single
string which the shell then parses and executes in the current environment.
@ -3355,7 +3355,7 @@ Background jobs are run with lower priority.
Enable brace expansion (a.k.a., alternation).
.It Ic emacs
Enable BRL emacs-like command-line editing (interactive shells only); see
.Sx Emacs editing mode.
.Sx Emacs editing mode .
.It Ic gmacs
Enable gmacs-like command-line editing (interactive shells only).
Currently identical to emacs editing except that transpose (^T) acts slightly
@ -3475,7 +3475,7 @@ defaults to 1.
.Ic test
evaluates the
.Ar expression
and returns zero status if true, 1 status if false, or greater than 1 if there
and returns zero status if true, 1 if false, or greater than 1 if there
was an error.
It is normally used as the condition command of
.Ic if
@ -3913,7 +3913,7 @@ option.)
.It Fl p
Print complete
.Ic typeset
commands that can be used to re-create the attributes (but not the values) or
commands that can be used to re-create the attributes (but not the values) of
parameters.
This is the default action (option exists for ksh93 compatibility).
.It Fl r
@ -4281,7 +4281,7 @@ interactive session, which is controlled by the
.Ic gmacs ,
and
.Ic vi
options (at most one of these can be set an once).
options (at most one of these can be set at once).
If none of these options are enabled, the shell simply reads lines using the
normal tty driver.
If the
@ -4536,7 +4536,7 @@ appended to them.
Prints a sorted, columnated list of command names (if any) that can complete
the partial word containing the cursor.
.It Ic list-file ^X^Y
Prints a sorted, comunated list of file names (if any) that can complete the
Prints a sorted, columnated list of file names (if any) that can complete the
partial word containing the cursor.
File type indicators are appended as described under
.Ic list
@ -4786,7 +4786,7 @@ directories in the
parameter.
File name expansion matches the big-word against the files in the
current directory.
After expansion, the cursor is places just past the last
After expansion, the cursor is placed just past the last
word and the editor is in insert mode.
.It n\e,\ n^F,\ n<tab>,\ and\ n<esc>
Command/file name completion.

4
misc.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: misc.c,v 1.15 2003/04/04 23:12:02 deraadt Exp $ */
/* $OpenBSD: misc.c,v 1.16 2003/04/16 23:11:52 tdeval Exp $ */
/*
* Miscellaneous functions
@ -542,7 +542,7 @@ gmatch(s, p, isfile)
char tbuf[64];
char *t = len <= sizeof(tbuf) ? tbuf
: (char *) alloc(len, ATEMP);
debunk(t, p);
debunk(t, p, len);
return !strcmp(t, s);
}
return do_gmatch((const unsigned char *) s, (const unsigned char *) se,

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proto.h,v 1.9 2001/02/19 09:49:54 camield Exp $ */
/* $OpenBSD: proto.h,v 1.10 2003/04/16 23:11:52 tdeval Exp $ */
/*
* prototypes for PD-KSH
@ -62,7 +62,7 @@ char * substitute ARGS((const char *cp, int f));
char ** eval ARGS((char **ap, int f));
char * evalstr ARGS((char *cp, int f));
char * evalonestr ARGS((char *cp, int f));
char *debunk ARGS((char *dp, const char *sp));
char *debunk ARGS((char *dp, const char *sp, size_t dlen));
void expand ARGS((char *cp, XPtrV *wp, int f));
int glob_str ARGS((char *cp, XPtrV *wp, int markdirs));
/* exec.c */

16
sh.1tbl
View File

@ -1,4 +1,4 @@
.\" $OpenBSD: sh.1tbl,v 1.31 2003/03/14 11:05:55 jmc Exp $
.\" $OpenBSD: sh.1tbl,v 1.32 2003/04/28 06:27:36 jmc Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@ -1176,7 +1176,7 @@ Not yet implemented.
.It Ev EXECSHELL
If set, this parameter is assumed to contain the shell that is to be used to
execute commands that
.Fn execve 2
.Xr execve 2
fails to execute and which do not start with a
.Dq \&#\&! Ns Ar shell
sequence.
@ -1337,7 +1337,7 @@ characters or
.Dq [..]
sequences.
Once brace expansion has been performed, the shell replaces file
name patterns with the sorted named of all the files that match the pattern
name patterns with the sorted names of all the files that match the pattern
(if no files match, the word is left unchanged).
The pattern elements have the following meaning:
.Bl -tag -width Ds
@ -1521,7 +1521,7 @@ except if
exists it is appended to instead of being truncated.
Also, the file is opened
in append mode, so writes always go to the end of the file (see
.Fn open 2 ) .
.Xr open 2 ) .
.It Ic \&< Ar file
Standard input is redirected from
.Ar file ,
@ -2208,7 +2208,7 @@ above).
.Pp
When listing aliases, one of two formats is used.
Normally, aliases are listed as
.Ar name Ns No = Ar value ,
.Ar name Ns No = Ns Ar value ,
where
.Ar value
is quoted.
@ -2394,7 +2394,7 @@ option suppresses the trailing newline,
.Fl e
enables backslash interpretation (a no-op, since this is normally done), and
.Fl E
which suppresses backslash interpretation.
suppresses backslash interpretation.
.It Ic eval Ar command ...
The arguments are concatenated (with spaces between them) to form a single
string which the shell then parses and executes in the current environment.
@ -2983,7 +2983,7 @@ defaults to 1.
.Ic test
evaluates the
.Ar expression
and returns zero status if true, 1 status if false, or greater than 1 if there
and returns zero status if true, 1 if false, or greater than 1 if there
was an error.
It is normally used as the condition command of
.Ic if
@ -3368,7 +3368,7 @@ option.)
.It Fl p
Print complete
.Ic typeset
commands that can be used to re-create the attributes (but not the values) or
commands that can be used to re-create the attributes (but not the values) of
parameters.
This is the default action (option exists for ksh93 compatibility).
.It Fl r

7
var.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: var.c,v 1.13 2003/03/13 09:03:07 deraadt Exp $ */
/* $OpenBSD: var.c,v 1.14 2003/04/16 23:11:52 tdeval Exp $ */
#include "sh.h"
#include "ksh_time.h"
@ -1132,6 +1132,7 @@ arraysearch(vp, val)
int val;
{
struct tbl *prev, *curr, *new;
size_t namelen = strlen(vp->name) + 1;
vp->flag |= ARRAY|DEFINED;
@ -1152,9 +1153,9 @@ arraysearch(vp, val)
else
new = curr;
} else
new = (struct tbl *)alloc(sizeof(struct tbl)+strlen(vp->name)+1,
new = (struct tbl *)alloc(sizeof(struct tbl) + namelen,
vp->areap);
strcpy(new->name, vp->name);
strlcpy(new->name, vp->name, namelen);
new->flag = vp->flag & ~(ALLOC|DEFINED|ISSET|SPECIAL);
new->type = vp->type;
new->areap = vp->areap;