mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-30 07:10:58 +02:00
users/13295, tweaked: dont reset line numbers when parsing strings, sometimes
This commit is contained in:
parent
dd3a749ce9
commit
59dd1491c6
8 changed files with 25 additions and 14 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2008-09-29 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
|
* users/13295 (with tweak always to keep old line numbers at
|
||||||
|
exit from parse_string()): Src/builtin.c, Src/exec.c, Src/glob.c,
|
||||||
|
Src/parse.c, Src/Modules/parameter.c, Src/Modules/zpty.c,
|
||||||
|
Src/Modules/zutil.c: don't reset $LINENO when parsing strings
|
||||||
|
unless the surrounding environment provides support (funcstack
|
||||||
|
etc.) for it.
|
||||||
|
|
||||||
2008-09-28 Clint Adams <clint@zsh.org>
|
2008-09-28 Clint Adams <clint@zsh.org>
|
||||||
|
|
||||||
* 25764: Completion/Unix/Command/.distfiles,
|
* 25764: Completion/Unix/Command/.distfiles,
|
||||||
|
|
|
@ -279,7 +279,7 @@ setfunction(char *name, char *val, int dis)
|
||||||
|
|
||||||
val = metafy(val, strlen(val), META_REALLOC);
|
val = metafy(val, strlen(val), META_REALLOC);
|
||||||
|
|
||||||
prog = parse_string(val);
|
prog = parse_string(val, 1);
|
||||||
|
|
||||||
if (!prog || prog == &dummy_eprog) {
|
if (!prog || prog == &dummy_eprog) {
|
||||||
zwarn("invalid function definition", value);
|
zwarn("invalid function definition", value);
|
||||||
|
|
|
@ -299,7 +299,7 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock)
|
||||||
if (!ineval)
|
if (!ineval)
|
||||||
scriptname = "(zpty)";
|
scriptname = "(zpty)";
|
||||||
|
|
||||||
prog = parse_string(zjoin(args, ' ', 1));
|
prog = parse_string(zjoin(args, ' ', 1), 0);
|
||||||
if (!prog) {
|
if (!prog) {
|
||||||
errflag = 0;
|
errflag = 0;
|
||||||
scriptname = oscriptname;
|
scriptname = oscriptname;
|
||||||
|
|
|
@ -251,7 +251,7 @@ setstypat(Style s, char *pat, Patprog prog, char **vals, int eval)
|
||||||
if (eval) {
|
if (eval) {
|
||||||
int ef = errflag;
|
int ef = errflag;
|
||||||
|
|
||||||
eprog = parse_string(zjoin(vals, ' ', 1));
|
eprog = parse_string(zjoin(vals, ' ', 1), 0);
|
||||||
errflag = ef;
|
errflag = ef;
|
||||||
|
|
||||||
if (!eprog)
|
if (!eprog)
|
||||||
|
|
|
@ -4781,7 +4781,7 @@ bin_eval(UNUSED(char *nam), char **argv, UNUSED(Options ops), UNUSED(int func))
|
||||||
} else
|
} else
|
||||||
fpushed = 0;
|
fpushed = 0;
|
||||||
|
|
||||||
prog = parse_string(zjoin(argv, ' ', 1));
|
prog = parse_string(zjoin(argv, ' ', 1), 1);
|
||||||
if (prog) {
|
if (prog) {
|
||||||
if (wc_code(*prog->prog) != WC_LIST) {
|
if (wc_code(*prog->prog) != WC_LIST) {
|
||||||
/* No code to execute */
|
/* No code to execute */
|
||||||
|
@ -5781,7 +5781,7 @@ bin_trap(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
|
||||||
arg = *argv++;
|
arg = *argv++;
|
||||||
if (!*arg)
|
if (!*arg)
|
||||||
prog = &dummy_eprog;
|
prog = &dummy_eprog;
|
||||||
else if (!(prog = parse_string(arg))) {
|
else if (!(prog = parse_string(arg, 1))) {
|
||||||
zwarnnam(name, "couldn't parse trap command");
|
zwarnnam(name, "couldn't parse trap command");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
16
Src/exec.c
16
Src/exec.c
|
@ -188,15 +188,17 @@ static struct builtin commandbn =
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
mod_export Eprog
|
mod_export Eprog
|
||||||
parse_string(char *s)
|
parse_string(char *s, int reset_lineno)
|
||||||
{
|
{
|
||||||
Eprog p;
|
Eprog p;
|
||||||
zlong oldlineno = lineno;
|
zlong oldlineno;
|
||||||
|
|
||||||
lexsave();
|
lexsave();
|
||||||
inpush(s, INP_LINENO, NULL);
|
inpush(s, INP_LINENO, NULL);
|
||||||
strinbeg(0);
|
strinbeg(0);
|
||||||
lineno = 1;
|
oldlineno = lineno;
|
||||||
|
if (reset_lineno)
|
||||||
|
lineno = 1;
|
||||||
p = parse_list();
|
p = parse_list();
|
||||||
lineno = oldlineno;
|
lineno = oldlineno;
|
||||||
if (tok == LEXERR && !lastval)
|
if (tok == LEXERR && !lastval)
|
||||||
|
@ -954,7 +956,7 @@ execstring(char *s, int dont_change_job, int exiting)
|
||||||
Eprog prog;
|
Eprog prog;
|
||||||
|
|
||||||
pushheap();
|
pushheap();
|
||||||
if ((prog = parse_string(s)))
|
if ((prog = parse_string(s, 0)))
|
||||||
execode(prog, dont_change_job, exiting);
|
execode(prog, dont_change_job, exiting);
|
||||||
popheap();
|
popheap();
|
||||||
}
|
}
|
||||||
|
@ -3445,7 +3447,7 @@ getoutput(char *cmd, int qt)
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
if (!(prog = parse_string(cmd)))
|
if (!(prog = parse_string(cmd, 0)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ((s = simple_redir_name(prog, REDIR_READ))) {
|
if ((s = simple_redir_name(prog, REDIR_READ))) {
|
||||||
|
@ -3566,7 +3568,7 @@ parsecmd(char *cmd)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*str = '\0';
|
*str = '\0';
|
||||||
if (str[1] || !(prog = parse_string(cmd + 2))) {
|
if (str[1] || !(prog = parse_string(cmd + 2, 0))) {
|
||||||
zerr("parse error in process substitution");
|
zerr("parse error in process substitution");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -4453,7 +4455,7 @@ getfpfunc(char *s, int *ksh, char **fname)
|
||||||
d = metafy(d, rlen, META_REALLOC);
|
d = metafy(d, rlen, META_REALLOC);
|
||||||
|
|
||||||
scriptname = dupstring(s);
|
scriptname = dupstring(s);
|
||||||
r = parse_string(d);
|
r = parse_string(d, 1);
|
||||||
scriptname = oldscriptname;
|
scriptname = oldscriptname;
|
||||||
|
|
||||||
if (fname)
|
if (fname)
|
||||||
|
|
|
@ -3329,7 +3329,7 @@ qualsheval(char *name, UNUSED(struct stat *buf), UNUSED(off_t days), char *str)
|
||||||
{
|
{
|
||||||
Eprog prog;
|
Eprog prog;
|
||||||
|
|
||||||
if ((prog = parse_string(str))) {
|
if ((prog = parse_string(str, 0))) {
|
||||||
int ef = errflag, lv = lastval, ret;
|
int ef = errflag, lv = lastval, ret;
|
||||||
|
|
||||||
unsetparam("reply");
|
unsetparam("reply");
|
||||||
|
|
|
@ -2831,7 +2831,7 @@ build_dump(char *nam, char *dump, char **files, int ali, int map, int flags)
|
||||||
close(fd);
|
close(fd);
|
||||||
file = metafy(file, flen, META_REALLOC);
|
file = metafy(file, flen, META_REALLOC);
|
||||||
|
|
||||||
if (!(prog = parse_string(file)) || errflag) {
|
if (!(prog = parse_string(file, 1)) || errflag) {
|
||||||
errflag = 0;
|
errflag = 0;
|
||||||
close(dfd);
|
close(dfd);
|
||||||
zfree(file, flen);
|
zfree(file, flen);
|
||||||
|
|
Loading…
Reference in a new issue