1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-17 02:51:01 +02:00

Joel Smith: 13230: avoid name clashes with Linux kernel

This commit is contained in:
Peter Stephenson 2000-12-05 10:34:23 +00:00
parent c1a4af81c6
commit 0c96a1b963
7 changed files with 95 additions and 89 deletions

View file

@ -1,3 +1,9 @@
2000-12-05 Peter Stephenson <pws@csr.com>
* Joel Smith <jsmith@caldera.com>: 13230: Src/exec.c, Src/glob.c,
Src/lex.c, Src/parse.c, Src/text.c, Src/zsh.h: avoid name clashes
with Linux kernel.
2000-12-04 Bart Schaefer <schaefer@zsh.org> 2000-12-04 Bart Schaefer <schaefer@zsh.org>
* 13229: Doc/Makefile.in: Include mod_term*.yo in MODDOCSRC. * 13229: Doc/Makefile.in: Include mod_term*.yo in MODDOCSRC.

View file

@ -1786,7 +1786,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
args = newlinklist(); args = newlinklist();
addlinknode(args, dupstring(":")); addlinknode(args, dupstring(":"));
} else if (readnullcmd && *readnullcmd && } else if (readnullcmd && *readnullcmd &&
((Redir) peekfirst(redir))->type == READ && ((Redir) peekfirst(redir))->type == REDIR_READ &&
!nextnode(firstnode(redir))) { !nextnode(firstnode(redir))) {
if (!args) if (!args)
args = newlinklist(); args = newlinklist();
@ -2068,16 +2068,16 @@ execcmd(Estate state, int input, int output, int how, int last1)
/* Do io redirections */ /* Do io redirections */
while (redir && nonempty(redir)) { while (redir && nonempty(redir)) {
fn = (Redir) ugetnode(redir); fn = (Redir) ugetnode(redir);
DPUTS(fn->type == HEREDOC || fn->type == HEREDOCDASH, DPUTS(fn->type == REDIR_HEREDOC || fn->type == REDIR_HEREDOCDASH,
"BUG: unexpanded here document"); "BUG: unexpanded here document");
if (fn->type == INPIPE) { if (fn->type == REDIR_INPIPE) {
if (fn->fd2 == -1) { if (fn->fd2 == -1) {
closemnodes(mfds); closemnodes(mfds);
fixfds(save); fixfds(save);
execerr(); execerr();
} }
addfd(forked, save, mfds, fn->fd1, fn->fd2, 0); addfd(forked, save, mfds, fn->fd1, fn->fd2, 0);
} else if (fn->type == OUTPIPE) { } else if (fn->type == REDIR_OUTPIPE) {
if (fn->fd2 == -1) { if (fn->fd2 == -1) {
closemnodes(mfds); closemnodes(mfds);
fixfds(save); fixfds(save);
@ -2085,7 +2085,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
} }
addfd(forked, save, mfds, fn->fd1, fn->fd2, 1); addfd(forked, save, mfds, fn->fd1, fn->fd2, 1);
} else { } else {
if (fn->type != HERESTR && xpandredir(fn, redir)) if (fn->type != REDIR_HERESTR && xpandredir(fn, redir))
continue; continue;
if (errflag) { if (errflag) {
closemnodes(mfds); closemnodes(mfds);
@ -2099,7 +2099,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
if (unset(EXECOPT)) if (unset(EXECOPT))
continue; continue;
switch(fn->type) { switch(fn->type) {
case HERESTR: case REDIR_HERESTR:
fil = getherestr(fn); fil = getherestr(fn);
if (fil == -1) { if (fil == -1) {
closemnodes(mfds); closemnodes(mfds);
@ -2110,9 +2110,9 @@ execcmd(Estate state, int input, int output, int how, int last1)
} }
addfd(forked, save, mfds, fn->fd1, fil, 0); addfd(forked, save, mfds, fn->fd1, fil, 0);
break; break;
case READ: case REDIR_READ:
case READWRITE: case REDIR_READWRITE:
if (fn->type == READ) if (fn->type == REDIR_READ)
fil = open(unmeta(fn->name), O_RDONLY | O_NOCTTY); fil = open(unmeta(fn->name), O_RDONLY | O_NOCTTY);
else else
fil = open(unmeta(fn->name), fil = open(unmeta(fn->name),
@ -2131,14 +2131,14 @@ execcmd(Estate state, int input, int output, int how, int last1)
isset(SHINSTDIN) && interact && !zleactive) isset(SHINSTDIN) && interact && !zleactive)
init_io(); init_io();
break; break;
case CLOSE: case REDIR_CLOSE:
if (!forked && fn->fd1 < 10 && save[fn->fd1] == -2) if (!forked && fn->fd1 < 10 && save[fn->fd1] == -2)
save[fn->fd1] = movefd(fn->fd1); save[fn->fd1] = movefd(fn->fd1);
closemn(mfds, fn->fd1); closemn(mfds, fn->fd1);
zclose(fn->fd1); zclose(fn->fd1);
break; break;
case MERGEIN: case REDIR_MERGEIN:
case MERGEOUT: case REDIR_MERGEOUT:
if (fn->fd2 < 10) if (fn->fd2 < 10)
closemn(mfds, fn->fd2); closemn(mfds, fn->fd2);
if (fn->fd2 > 9 && if (fn->fd2 > 9 &&
@ -2150,7 +2150,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
} else { } else {
int fd = fn->fd2; int fd = fn->fd2;
if(fd == -2) if(fd == -2)
fd = (fn->type == MERGEOUT) ? coprocout : coprocin; fd = (fn->type == REDIR_MERGEOUT) ? coprocout : coprocin;
fil = dup(fd); fil = dup(fd);
} }
if (fil == -1) { if (fil == -1) {
@ -2163,7 +2163,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
zwarn("%s: %e", fn->fd2 == -2 ? "coprocess" : fdstr, errno); zwarn("%s: %e", fn->fd2 == -2 ? "coprocess" : fdstr, errno);
execerr(); execerr();
} }
addfd(forked, save, mfds, fn->fd1, fil, fn->type == MERGEOUT); addfd(forked, save, mfds, fn->fd1, fil, fn->type == REDIR_MERGEOUT);
break; break;
default: default:
if (IS_APPEND_REDIR(fn->type)) if (IS_APPEND_REDIR(fn->type))
@ -2578,7 +2578,7 @@ gethere(char *str, int typ)
qt = 1; qt = 1;
} }
untokenize(str); untokenize(str);
if (typ == HEREDOCDASH) { if (typ == REDIR_HEREDOCDASH) {
strip = 1; strip = 1;
while (*str == '\t') while (*str == '\t')
str++; str++;
@ -2670,7 +2670,7 @@ getoutput(char *cmd, int qt)
wc_code(pc[1]) == WC_SUBLIST && !WC_SUBLIST_FLAGS(pc[1]) && wc_code(pc[1]) == WC_SUBLIST && !WC_SUBLIST_FLAGS(pc[1]) &&
WC_SUBLIST_TYPE(pc[1]) == WC_SUBLIST_END && WC_SUBLIST_TYPE(pc[1]) == WC_SUBLIST_END &&
wc_code(pc[2]) == WC_PIPE && WC_PIPE_TYPE(pc[2]) == WC_PIPE_END && wc_code(pc[2]) == WC_PIPE && WC_PIPE_TYPE(pc[2]) == WC_PIPE_END &&
wc_code(pc[3]) == WC_REDIR && WC_REDIR_TYPE(pc[3]) == READ && wc_code(pc[3]) == WC_REDIR && WC_REDIR_TYPE(pc[3]) == REDIR_READ &&
!pc[4] && !pc[4] &&
wc_code(pc[6]) == WC_SIMPLE && !WC_SIMPLE_ARGC(pc[6])) { wc_code(pc[6]) == WC_SIMPLE && !WC_SIMPLE_ARGC(pc[6])) {
/* $(< word) */ /* $(< word) */
@ -2990,7 +2990,7 @@ spawnpipes(LinkList l)
n = firstnode(l); n = firstnode(l);
for (; n; incnode(n)) { for (; n; incnode(n)) {
f = (Redir) getdata(n); f = (Redir) getdata(n);
if (f->type == OUTPIPE || f->type == INPIPE) { if (f->type == REDIR_OUTPIPE || f->type == REDIR_INPIPE) {
str = f->name; str = f->name;
f->fd2 = getpipe(str); f->fd2 = getpipe(str);
} }

View file

@ -1626,9 +1626,9 @@ xpandredir(struct redir *fn, LinkList tab)
char *s = peekfirst(&fake); char *s = peekfirst(&fake);
fn->name = s; fn->name = s;
untokenize(s); untokenize(s);
if (fn->type == MERGEIN || fn->type == MERGEOUT) { if (fn->type == REDIR_MERGEIN || fn->type == REDIR_MERGEOUT) {
if (s[0] == '-' && !s[1]) if (s[0] == '-' && !s[1])
fn->type = CLOSE; fn->type = REDIR_CLOSE;
else if (s[0] == 'p' && !s[1]) else if (s[0] == 'p' && !s[1])
fn->fd2 = -2; fn->fd2 = -2;
else { else {
@ -1636,17 +1636,17 @@ xpandredir(struct redir *fn, LinkList tab)
s++; s++;
if (!*s && s > fn->name) if (!*s && s > fn->name)
fn->fd2 = zstrtol(fn->name, NULL, 10); fn->fd2 = zstrtol(fn->name, NULL, 10);
else if (fn->type == MERGEIN) else if (fn->type == REDIR_MERGEIN)
zerr("file number expected", NULL, 0); zerr("file number expected", NULL, 0);
else else
fn->type = ERRWRITE; fn->type = REDIR_ERRWRITE;
} }
} }
} else if (fn->type == MERGEIN) } else if (fn->type == REDIR_MERGEIN)
zerr("file number expected", NULL, 0); zerr("file number expected", NULL, 0);
else { else {
if (fn->type == MERGEOUT) if (fn->type == REDIR_MERGEOUT)
fn->type = ERRWRITE; fn->type = REDIR_ERRWRITE;
while ((nam = (char *)ugetnode(&fake))) { while ((nam = (char *)ugetnode(&fake))) {
/* Loop over matches, duplicating the * /* Loop over matches, duplicating the *
* redirection for each file found. */ * redirection for each file found. */

View file

@ -349,13 +349,13 @@ yylex(void)
char *name; char *name;
hwbegin(0); hwbegin(0);
cmdpush(hdocs->type == HEREDOC ? CS_HEREDOC : CS_HEREDOCD); cmdpush(hdocs->type == REDIR_HEREDOC ? CS_HEREDOC : CS_HEREDOCD);
STOPHIST STOPHIST
name = gethere(hdocs->str, hdocs->type); name = gethere(hdocs->str, hdocs->type);
ALLOWHIST ALLOWHIST
cmdpop(); cmdpop();
hwend(); hwend();
setheredoc(hdocs->pc, HERESTR, name); setheredoc(hdocs->pc, REDIR_HERESTR, name);
zfree(hdocs, sizeof(struct heredocs)); zfree(hdocs, sizeof(struct heredocs));
hdocs = next; hdocs = next;
} }

View file

@ -707,7 +707,7 @@ par_pline(int *complex)
for (r = p + 1; wc_code(ecbuf[r]) == WC_REDIR; r += 3); for (r = p + 1; wc_code(ecbuf[r]) == WC_REDIR; r += 3);
ecispace(r, 3); ecispace(r, 3);
ecbuf[r] = WCB_REDIR(MERGEOUT); ecbuf[r] = WCB_REDIR(REDIR_MERGEOUT);
ecbuf[r + 1] = 2; ecbuf[r + 1] = 2;
ecbuf[r + 2] = ecstrcode("1"); ecbuf[r + 2] = ecstrcode("1");
@ -1572,21 +1572,21 @@ par_simple(int *complex, int nr)
*/ */
static int redirtab[TRINANG - OUTANG + 1] = { static int redirtab[TRINANG - OUTANG + 1] = {
WRITE, REDIR_WRITE,
WRITENOW, REDIR_WRITENOW,
APP, REDIR_APP,
APPNOW, REDIR_APPNOW,
READ, REDIR_READ,
READWRITE, REDIR_READWRITE,
HEREDOC, REDIR_HEREDOC,
HEREDOCDASH, REDIR_HEREDOCDASH,
MERGEIN, REDIR_MERGEIN,
MERGEOUT, REDIR_MERGEOUT,
ERRWRITE, REDIR_ERRWRITE,
ERRWRITENOW, REDIR_ERRWRITENOW,
ERRAPP, REDIR_ERRAPP,
ERRAPPNOW, REDIR_ERRAPPNOW,
HERESTR, REDIR_HERESTR,
}; };
/**/ /**/
@ -1616,8 +1616,8 @@ par_redir(int *rp)
name = tokstr; name = tokstr;
switch (type) { switch (type) {
case HEREDOC: case REDIR_HEREDOC:
case HEREDOCDASH: { case REDIR_HEREDOCDASH: {
/* <<[-] name */ /* <<[-] name */
struct heredocs **hd; struct heredocs **hd;
@ -1638,24 +1638,24 @@ par_redir(int *rp)
yylex(); yylex();
return; return;
} }
case WRITE: case REDIR_WRITE:
case WRITENOW: case REDIR_WRITENOW:
if (tokstr[0] == Outang && tokstr[1] == Inpar) if (tokstr[0] == Outang && tokstr[1] == Inpar)
/* > >(...) */ /* > >(...) */
type = OUTPIPE; type = REDIR_OUTPIPE;
else if (tokstr[0] == Inang && tokstr[1] == Inpar) else if (tokstr[0] == Inang && tokstr[1] == Inpar)
YYERRORV(ecused); YYERRORV(ecused);
break; break;
case READ: case REDIR_READ:
if (tokstr[0] == Inang && tokstr[1] == Inpar) if (tokstr[0] == Inang && tokstr[1] == Inpar)
/* < <(...) */ /* < <(...) */
type = INPIPE; type = REDIR_INPIPE;
else if (tokstr[0] == Outang && tokstr[1] == Inpar) else if (tokstr[0] == Outang && tokstr[1] == Inpar)
YYERRORV(ecused); YYERRORV(ecused);
break; break;
case READWRITE: case REDIR_READWRITE:
if ((tokstr[0] == Inang || tokstr[0] == Outang) && tokstr[1] == Inpar) if ((tokstr[0] == Inang || tokstr[0] == Outang) && tokstr[1] == Inpar)
type = tokstr[0] == Inang ? INPIPE : OUTPIPE; type = tokstr[0] == Inang ? REDIR_INPIPE : REDIR_OUTPIPE;
break; break;
} }
yylex(); yylex();

View file

@ -731,26 +731,26 @@ getredirs(LinkList redirs)
Redir f = (Redir) getdata(n); Redir f = (Redir) getdata(n);
switch (f->type) { switch (f->type) {
case WRITE: case REDIR_WRITE:
case WRITENOW: case REDIR_WRITENOW:
case APP: case REDIR_APP:
case APPNOW: case REDIR_APPNOW:
case ERRWRITE: case REDIR_ERRWRITE:
case ERRWRITENOW: case REDIR_ERRWRITENOW:
case ERRAPP: case REDIR_ERRAPP:
case ERRAPPNOW: case REDIR_ERRAPPNOW:
case READ: case REDIR_READ:
case READWRITE: case REDIR_READWRITE:
case HERESTR: case REDIR_HERESTR:
case MERGEIN: case REDIR_MERGEIN:
case MERGEOUT: case REDIR_MERGEOUT:
case INPIPE: case REDIR_INPIPE:
case OUTPIPE: case REDIR_OUTPIPE:
if (f->fd1 != (IS_READFD(f->type) ? 0 : 1)) if (f->fd1 != (IS_READFD(f->type) ? 0 : 1))
taddchr('0' + f->fd1); taddchr('0' + f->fd1);
taddstr(fstr[f->type]); taddstr(fstr[f->type]);
taddchr(' '); taddchr(' ');
if (f->type == HERESTR) { if (f->type == REDIR_HERESTR) {
taddchr('\''); taddchr('\'');
taddstr(bslashquote(f->name, NULL, 1)); taddstr(bslashquote(f->name, NULL, 1));
taddchr('\''); taddchr('\'');
@ -759,7 +759,7 @@ getredirs(LinkList redirs)
taddchr(' '); taddchr(' ');
break; break;
#ifdef DEBUG #ifdef DEBUG
case CLOSE: case REDIR_CLOSE:
DPUTS(1, "BUG: CLOSE in getredirs()"); DPUTS(1, "BUG: CLOSE in getredirs()");
taddchr(f->fd1 + '0'); taddchr(f->fd1 + '0');
taddstr(">&- "); taddstr(">&- ");

View file

@ -233,31 +233,31 @@ enum {
* below. */ * below. */
enum { enum {
WRITE, /* > */ REDIR_WRITE, /* > */
WRITENOW, /* >| */ REDIR_WRITENOW, /* >| */
APP, /* >> */ REDIR_APP, /* >> */
APPNOW, /* >>| */ REDIR_APPNOW, /* >>| */
ERRWRITE, /* &>, >& */ REDIR_ERRWRITE, /* &>, >& */
ERRWRITENOW, /* >&| */ REDIR_ERRWRITENOW, /* >&| */
ERRAPP, /* >>& */ REDIR_ERRAPP, /* >>& */
ERRAPPNOW, /* >>&| */ REDIR_ERRAPPNOW, /* >>&| */
READWRITE, /* <> */ REDIR_READWRITE, /* <> */
READ, /* < */ REDIR_READ, /* < */
HEREDOC, /* << */ REDIR_HEREDOC, /* << */
HEREDOCDASH, /* <<- */ REDIR_HEREDOCDASH, /* <<- */
HERESTR, /* <<< */ REDIR_HERESTR, /* <<< */
MERGEIN, /* <&n */ REDIR_MERGEIN, /* <&n */
MERGEOUT, /* >&n */ REDIR_MERGEOUT, /* >&n */
CLOSE, /* >&-, <&- */ REDIR_CLOSE, /* >&-, <&- */
INPIPE, /* < <(...) */ REDIR_INPIPE, /* < <(...) */
OUTPIPE /* > >(...) */ REDIR_OUTPIPE /* > >(...) */
}; };
#define IS_WRITE_FILE(X) ((X)>=WRITE && (X)<=READWRITE) #define IS_WRITE_FILE(X) ((X)>=REDIR_WRITE && (X)<=REDIR_READWRITE)
#define IS_APPEND_REDIR(X) (IS_WRITE_FILE(X) && ((X) & 2)) #define IS_APPEND_REDIR(X) (IS_WRITE_FILE(X) && ((X) & 2))
#define IS_CLOBBER_REDIR(X) (IS_WRITE_FILE(X) && ((X) & 1)) #define IS_CLOBBER_REDIR(X) (IS_WRITE_FILE(X) && ((X) & 1))
#define IS_ERROR_REDIR(X) ((X)>=ERRWRITE && (X)<=ERRAPPNOW) #define IS_ERROR_REDIR(X) ((X)>=REDIR_ERRWRITE && (X)<=REDIR_ERRAPPNOW)
#define IS_READFD(X) (((X)>=READWRITE && (X)<=MERGEIN) || (X)==INPIPE) #define IS_READFD(X) (((X)>=REDIR_READWRITE && (X)<=REDIR_MERGEIN) || (X)==REDIR_INPIPE)
#define IS_REDIROP(X) ((X)>=OUTANG && (X)<=TRINANG) #define IS_REDIROP(X) ((X)>=OUTANG && (X)<=TRINANG)
/* Flags for input stack */ /* Flags for input stack */