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

zsh-workers/10059

This commit is contained in:
Tanaka Akira 2000-03-11 00:11:02 +00:00
parent c294357477
commit d1688ca541
5 changed files with 41 additions and 20 deletions

View file

@ -1816,17 +1816,17 @@ bin_typeset(char *name, char **argv, char *ops, int func)
/* Sanity checks on the options. Remove conficting options. */
if (on & PM_FFLOAT) {
off |= PM_RIGHT_B | PM_LEFT | PM_RIGHT_Z | PM_UPPER | PM_ARRAY
| PM_INTEGER | PM_EFLOAT;
off |= PM_RIGHT_B | PM_LEFT | PM_RIGHT_Z | PM_UPPER | PM_ARRAY |
PM_HASHED | PM_INTEGER | PM_EFLOAT;
/* Allow `float -F' to work even though float sets -E by default */
on &= ~PM_EFLOAT;
}
if (on & PM_EFLOAT)
off |= PM_RIGHT_B | PM_LEFT | PM_RIGHT_Z | PM_UPPER | PM_ARRAY
| PM_INTEGER | PM_FFLOAT;
off |= PM_RIGHT_B | PM_LEFT | PM_RIGHT_Z | PM_UPPER | PM_ARRAY |
PM_HASHED | PM_INTEGER | PM_FFLOAT;
if (on & PM_INTEGER)
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)
off |= PM_RIGHT_B | PM_INTEGER | PM_EFLOAT | PM_FFLOAT;
if (on & PM_RIGHT_B)

View file

@ -339,10 +339,9 @@ yylex(void)
char *name;
hwbegin(0);
cmdpush(WC_REDIR_TYPE(*(hdocs->pc)) == HEREDOC ?
CS_HEREDOC : CS_HEREDOCD);
cmdpush(hdocs->type == HEREDOC ? CS_HEREDOC : CS_HEREDOCD);
STOPHIST
name = gethere(hdocs->str, WC_REDIR_TYPE(*hdocs->pc));
name = gethere(hdocs->str, hdocs->type);
ALLOWHIST
cmdpop();
hwend();

View file

@ -233,6 +233,18 @@ Eccstr ecstrs;
/**/
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. */
static void
@ -250,6 +262,7 @@ ecispace(int p, int n)
if ((m = ecused - p) > 0)
memmove(ecbuf + p + n, ecbuf + p, m * sizeof(wordcode));
ecused += n;
ecadjusthere(p, n);
}
/* Add one wordcode. */
@ -278,6 +291,7 @@ ecdel(int p)
if (n > 0)
memmove(ecbuf + p, ecbuf + p + 1, n * sizeof(wordcode));
ecused--;
ecadjusthere(p, -1);
}
/* 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);
ecispace(r, 3);
p += 3;
ecbuf[r] = WCB_REDIR(MERGEOUT);
ecbuf[r + 1] = 2;
ecbuf[r + 2] = ecstrcode("1");
@ -690,6 +703,8 @@ par_pline(int *complex)
*complex = 1;
cmdpush(CS_ERRPIPE);
yylex();
while (tok == SEPER)
yylex();
ecbuf[p] = WCB_PIPE(WC_PIPE_MID, (line >= 0 ? line + 1 : 0));
ecispace(p + 1, 1);
ecbuf[p + 1] = ecused - 1 - p;
@ -1577,12 +1592,6 @@ par_redir(int *rp)
/* <<[-] name */
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
* the factors in par_cmd() and par_simple(), too. */
ecispace(r, 3);
@ -1590,6 +1599,13 @@ par_redir(int *rp)
ecbuf[r] = WCB_REDIR(type);
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();
return;
}
@ -1626,10 +1642,10 @@ par_redir(int *rp)
/**/
void
setheredoc(Wordcode pc, int type, char *str)
setheredoc(int pc, int type, char *str)
{
pc[0] = WCB_REDIR(type);
pc[2] = ecstrcode(str);
ecbuf[pc] = WCB_REDIR(type);
ecbuf[pc + 2] = ecstrcode(str);
}
/*

View file

@ -737,7 +737,12 @@ getredirs(LinkList redirs)
taddchr('0' + f->fd1);
taddstr(fstr[f->type]);
taddchr(' ');
taddstr(f->name);
if (f->type == HERESTR) {
taddchr('\'');
taddstr(bslashquote(f->name, NULL, 1));
taddchr('\'');
} else
taddstr(f->name);
taddchr(' ');
break;
#ifdef DEBUG

View file

@ -737,7 +737,8 @@ struct execstack {
struct heredocs {
struct heredocs *next;
Wordcode pc;
int type;
int pc;
char *str;
};