mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 22:11:54 +02:00
zsh-workers/10059
This commit is contained in:
parent
c294357477
commit
d1688ca541
5 changed files with 41 additions and 20 deletions
|
@ -1816,17 +1816,17 @@ bin_typeset(char *name, char **argv, char *ops, int func)
|
||||||
|
|
||||||
/* Sanity checks on the options. Remove conficting options. */
|
/* Sanity checks on the options. Remove conficting options. */
|
||||||
if (on & PM_FFLOAT) {
|
if (on & PM_FFLOAT) {
|
||||||
off |= PM_RIGHT_B | PM_LEFT | PM_RIGHT_Z | PM_UPPER | PM_ARRAY
|
off |= PM_RIGHT_B | PM_LEFT | PM_RIGHT_Z | PM_UPPER | PM_ARRAY |
|
||||||
| PM_INTEGER | PM_EFLOAT;
|
PM_HASHED | PM_INTEGER | PM_EFLOAT;
|
||||||
/* Allow `float -F' to work even though float sets -E by default */
|
/* Allow `float -F' to work even though float sets -E by default */
|
||||||
on &= ~PM_EFLOAT;
|
on &= ~PM_EFLOAT;
|
||||||
}
|
}
|
||||||
if (on & PM_EFLOAT)
|
if (on & PM_EFLOAT)
|
||||||
off |= PM_RIGHT_B | PM_LEFT | PM_RIGHT_Z | PM_UPPER | PM_ARRAY
|
off |= PM_RIGHT_B | PM_LEFT | PM_RIGHT_Z | PM_UPPER | PM_ARRAY |
|
||||||
| PM_INTEGER | PM_FFLOAT;
|
PM_HASHED | PM_INTEGER | PM_FFLOAT;
|
||||||
if (on & PM_INTEGER)
|
if (on & PM_INTEGER)
|
||||||
off |= PM_RIGHT_B | PM_LEFT | PM_RIGHT_Z | PM_UPPER | PM_ARRAY |
|
off |= PM_RIGHT_B | PM_LEFT | PM_RIGHT_Z | PM_UPPER | PM_ARRAY |
|
||||||
PM_EFLOAT | PM_FFLOAT;
|
PM_HASHED | PM_EFLOAT | PM_FFLOAT;
|
||||||
if (on & PM_LEFT)
|
if (on & PM_LEFT)
|
||||||
off |= PM_RIGHT_B | PM_INTEGER | PM_EFLOAT | PM_FFLOAT;
|
off |= PM_RIGHT_B | PM_INTEGER | PM_EFLOAT | PM_FFLOAT;
|
||||||
if (on & PM_RIGHT_B)
|
if (on & PM_RIGHT_B)
|
||||||
|
|
|
@ -339,10 +339,9 @@ yylex(void)
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
hwbegin(0);
|
hwbegin(0);
|
||||||
cmdpush(WC_REDIR_TYPE(*(hdocs->pc)) == HEREDOC ?
|
cmdpush(hdocs->type == HEREDOC ? CS_HEREDOC : CS_HEREDOCD);
|
||||||
CS_HEREDOC : CS_HEREDOCD);
|
|
||||||
STOPHIST
|
STOPHIST
|
||||||
name = gethere(hdocs->str, WC_REDIR_TYPE(*hdocs->pc));
|
name = gethere(hdocs->str, hdocs->type);
|
||||||
ALLOWHIST
|
ALLOWHIST
|
||||||
cmdpop();
|
cmdpop();
|
||||||
hwend();
|
hwend();
|
||||||
|
|
36
Src/parse.c
36
Src/parse.c
|
@ -233,6 +233,18 @@ Eccstr ecstrs;
|
||||||
/**/
|
/**/
|
||||||
int ecsoffs, ecssub, ecnfunc;
|
int ecsoffs, ecssub, ecnfunc;
|
||||||
|
|
||||||
|
/* Adjust pointers in here-doc structs. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
ecadjusthere(int p, int d)
|
||||||
|
{
|
||||||
|
struct heredocs *h;
|
||||||
|
|
||||||
|
for (h = hdocs; h; h = h->next)
|
||||||
|
if (h->pc >= p)
|
||||||
|
h->pc += d;
|
||||||
|
}
|
||||||
|
|
||||||
/* Insert n free code-slots at position p. */
|
/* Insert n free code-slots at position p. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -250,6 +262,7 @@ ecispace(int p, int n)
|
||||||
if ((m = ecused - p) > 0)
|
if ((m = ecused - p) > 0)
|
||||||
memmove(ecbuf + p + n, ecbuf + p, m * sizeof(wordcode));
|
memmove(ecbuf + p + n, ecbuf + p, m * sizeof(wordcode));
|
||||||
ecused += n;
|
ecused += n;
|
||||||
|
ecadjusthere(p, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add one wordcode. */
|
/* Add one wordcode. */
|
||||||
|
@ -278,6 +291,7 @@ ecdel(int p)
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
memmove(ecbuf + p, ecbuf + p + 1, n * sizeof(wordcode));
|
memmove(ecbuf + p, ecbuf + p + 1, n * sizeof(wordcode));
|
||||||
ecused--;
|
ecused--;
|
||||||
|
ecadjusthere(p, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build the wordcode for a string. */
|
/* Build the wordcode for a string. */
|
||||||
|
@ -682,7 +696,6 @@ 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);
|
||||||
p += 3;
|
|
||||||
ecbuf[r] = WCB_REDIR(MERGEOUT);
|
ecbuf[r] = WCB_REDIR(MERGEOUT);
|
||||||
ecbuf[r + 1] = 2;
|
ecbuf[r + 1] = 2;
|
||||||
ecbuf[r + 2] = ecstrcode("1");
|
ecbuf[r + 2] = ecstrcode("1");
|
||||||
|
@ -690,6 +703,8 @@ par_pline(int *complex)
|
||||||
*complex = 1;
|
*complex = 1;
|
||||||
cmdpush(CS_ERRPIPE);
|
cmdpush(CS_ERRPIPE);
|
||||||
yylex();
|
yylex();
|
||||||
|
while (tok == SEPER)
|
||||||
|
yylex();
|
||||||
ecbuf[p] = WCB_PIPE(WC_PIPE_MID, (line >= 0 ? line + 1 : 0));
|
ecbuf[p] = WCB_PIPE(WC_PIPE_MID, (line >= 0 ? line + 1 : 0));
|
||||||
ecispace(p + 1, 1);
|
ecispace(p + 1, 1);
|
||||||
ecbuf[p + 1] = ecused - 1 - p;
|
ecbuf[p + 1] = ecused - 1 - p;
|
||||||
|
@ -1577,12 +1592,6 @@ par_redir(int *rp)
|
||||||
/* <<[-] name */
|
/* <<[-] name */
|
||||||
struct heredocs **hd;
|
struct heredocs **hd;
|
||||||
|
|
||||||
for (hd = &hdocs; *hd; hd = &(*hd)->next);
|
|
||||||
*hd = zalloc(sizeof(struct heredocs));
|
|
||||||
(*hd)->next = NULL;
|
|
||||||
(*hd)->pc = ecbuf + r;
|
|
||||||
(*hd)->str = tokstr;
|
|
||||||
|
|
||||||
/* If we ever need more than three codes (or less), we have to change
|
/* If we ever need more than three codes (or less), we have to change
|
||||||
* the factors in par_cmd() and par_simple(), too. */
|
* the factors in par_cmd() and par_simple(), too. */
|
||||||
ecispace(r, 3);
|
ecispace(r, 3);
|
||||||
|
@ -1590,6 +1599,13 @@ par_redir(int *rp)
|
||||||
ecbuf[r] = WCB_REDIR(type);
|
ecbuf[r] = WCB_REDIR(type);
|
||||||
ecbuf[r + 1] = fd1;
|
ecbuf[r + 1] = fd1;
|
||||||
|
|
||||||
|
for (hd = &hdocs; *hd; hd = &(*hd)->next);
|
||||||
|
*hd = zalloc(sizeof(struct heredocs));
|
||||||
|
(*hd)->next = NULL;
|
||||||
|
(*hd)->type = type;
|
||||||
|
(*hd)->pc = r;
|
||||||
|
(*hd)->str = tokstr;
|
||||||
|
|
||||||
yylex();
|
yylex();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1626,10 +1642,10 @@ par_redir(int *rp)
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
void
|
void
|
||||||
setheredoc(Wordcode pc, int type, char *str)
|
setheredoc(int pc, int type, char *str)
|
||||||
{
|
{
|
||||||
pc[0] = WCB_REDIR(type);
|
ecbuf[pc] = WCB_REDIR(type);
|
||||||
pc[2] = ecstrcode(str);
|
ecbuf[pc + 2] = ecstrcode(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -737,7 +737,12 @@ getredirs(LinkList redirs)
|
||||||
taddchr('0' + f->fd1);
|
taddchr('0' + f->fd1);
|
||||||
taddstr(fstr[f->type]);
|
taddstr(fstr[f->type]);
|
||||||
taddchr(' ');
|
taddchr(' ');
|
||||||
taddstr(f->name);
|
if (f->type == HERESTR) {
|
||||||
|
taddchr('\'');
|
||||||
|
taddstr(bslashquote(f->name, NULL, 1));
|
||||||
|
taddchr('\'');
|
||||||
|
} else
|
||||||
|
taddstr(f->name);
|
||||||
taddchr(' ');
|
taddchr(' ');
|
||||||
break;
|
break;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
|
@ -737,7 +737,8 @@ struct execstack {
|
||||||
|
|
||||||
struct heredocs {
|
struct heredocs {
|
||||||
struct heredocs *next;
|
struct heredocs *next;
|
||||||
Wordcode pc;
|
int type;
|
||||||
|
int pc;
|
||||||
char *str;
|
char *str;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue