mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-29 06:51:03 +02:00
37469: do NOT allow semicolons in place of line breaks in conditionals
This commit is contained in:
parent
6e10224f1e
commit
62706b1abc
2 changed files with 19 additions and 14 deletions
|
@ -1,5 +1,8 @@
|
||||||
2015-12-31 Barton E. Schaefer <schaefer@zsh.org>
|
2015-12-31 Barton E. Schaefer <schaefer@zsh.org>
|
||||||
|
|
||||||
|
* 37469: Src/parse.c: do NOT allow semicolons in place of line breaks
|
||||||
|
in conditionals
|
||||||
|
|
||||||
* unposted: Src/builtin.c: enable WARN_CREATE_GLOBAL for print -v
|
* unposted: Src/builtin.c: enable WARN_CREATE_GLOBAL for print -v
|
||||||
|
|
||||||
* 37468: Src/parse.c: allow line breaks in more places in [[ ... ]]
|
* 37468: Src/parse.c: allow line breaks in more places in [[ ... ]]
|
||||||
|
|
30
Src/parse.c
30
Src/parse.c
|
@ -2252,6 +2252,8 @@ void (*condlex) _((void)) = zshlex;
|
||||||
* cond : cond_1 { SEPER } [ DBAR { SEPER } cond ]
|
* cond : cond_1 { SEPER } [ DBAR { SEPER } cond ]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define COND_SEP() (tok == SEPER && condlex != testlex && *zshlextext != ';')
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
static int
|
static int
|
||||||
par_cond(void)
|
par_cond(void)
|
||||||
|
@ -2259,11 +2261,11 @@ par_cond(void)
|
||||||
int p = ecused, r;
|
int p = ecused, r;
|
||||||
|
|
||||||
r = par_cond_1();
|
r = par_cond_1();
|
||||||
while (tok == SEPER)
|
while (COND_SEP())
|
||||||
condlex();
|
condlex();
|
||||||
if (tok == DBAR) {
|
if (tok == DBAR) {
|
||||||
condlex();
|
condlex();
|
||||||
while (tok == SEPER)
|
while (COND_SEP())
|
||||||
condlex();
|
condlex();
|
||||||
ecispace(p, 1);
|
ecispace(p, 1);
|
||||||
par_cond();
|
par_cond();
|
||||||
|
@ -2284,11 +2286,11 @@ par_cond_1(void)
|
||||||
int r, p = ecused;
|
int r, p = ecused;
|
||||||
|
|
||||||
r = par_cond_2();
|
r = par_cond_2();
|
||||||
while (tok == SEPER)
|
while (COND_SEP())
|
||||||
condlex();
|
condlex();
|
||||||
if (tok == DAMPER) {
|
if (tok == DAMPER) {
|
||||||
condlex();
|
condlex();
|
||||||
while (tok == SEPER)
|
while (COND_SEP())
|
||||||
condlex();
|
condlex();
|
||||||
ecispace(p, 1);
|
ecispace(p, 1);
|
||||||
par_cond_1();
|
par_cond_1();
|
||||||
|
@ -2349,7 +2351,7 @@ par_cond_2(void)
|
||||||
* or any other time there are at least two arguments.
|
* or any other time there are at least two arguments.
|
||||||
*/
|
*/
|
||||||
} else
|
} else
|
||||||
while (tok == SEPER)
|
while (COND_SEP())
|
||||||
condlex();
|
condlex();
|
||||||
if (tok == BANG) {
|
if (tok == BANG) {
|
||||||
/*
|
/*
|
||||||
|
@ -2368,10 +2370,10 @@ par_cond_2(void)
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
condlex();
|
condlex();
|
||||||
while (tok == SEPER)
|
while (COND_SEP())
|
||||||
condlex();
|
condlex();
|
||||||
r = par_cond();
|
r = par_cond();
|
||||||
while (tok == SEPER)
|
while (COND_SEP())
|
||||||
condlex();
|
condlex();
|
||||||
if (tok != OUTPAR)
|
if (tok != OUTPAR)
|
||||||
YYERROR(ecused);
|
YYERROR(ecused);
|
||||||
|
@ -2387,7 +2389,7 @@ par_cond_2(void)
|
||||||
/* Check first argument for [[ STRING ]] re-interpretation */
|
/* Check first argument for [[ STRING ]] re-interpretation */
|
||||||
if (s1 /* tok != DOUTBRACK && tok != DAMPER && tok != DBAR */
|
if (s1 /* tok != DOUTBRACK && tok != DAMPER && tok != DBAR */
|
||||||
&& tok != LEXERR && (!dble || n_testargs)) {
|
&& tok != LEXERR && (!dble || n_testargs)) {
|
||||||
do condlex(); while (tok == SEPER && condlex != testlex);
|
do condlex(); while (COND_SEP());
|
||||||
return par_cond_double(dupstring("-n"), s1);
|
return par_cond_double(dupstring("-n"), s1);
|
||||||
} else
|
} else
|
||||||
YYERROR(ecused);
|
YYERROR(ecused);
|
||||||
|
@ -2401,15 +2403,15 @@ par_cond_2(void)
|
||||||
*/
|
*/
|
||||||
tok = STRING;
|
tok = STRING;
|
||||||
} else
|
} else
|
||||||
while (tok == SEPER && condlex != testlex)
|
while (COND_SEP())
|
||||||
condlex();
|
condlex();
|
||||||
if (tok == INANG || tok == OUTANG) {
|
if (tok == INANG || tok == OUTANG) {
|
||||||
enum lextok xtok = tok;
|
enum lextok xtok = tok;
|
||||||
do condlex(); while (tok == SEPER && condlex != testlex);
|
do condlex(); while (COND_SEP());
|
||||||
if (tok != STRING)
|
if (tok != STRING)
|
||||||
YYERROR(ecused);
|
YYERROR(ecused);
|
||||||
s3 = tokstr;
|
s3 = tokstr;
|
||||||
do condlex(); while (tok == SEPER && condlex != testlex);
|
do condlex(); while (COND_SEP());
|
||||||
ecadd(WCB_COND((xtok == INANG ? COND_STRLT : COND_STRGTR), 0));
|
ecadd(WCB_COND((xtok == INANG ? COND_STRLT : COND_STRGTR), 0));
|
||||||
ecstr(s1);
|
ecstr(s1);
|
||||||
ecstr(s3);
|
ecstr(s3);
|
||||||
|
@ -2432,11 +2434,11 @@ par_cond_2(void)
|
||||||
if (!n_testargs)
|
if (!n_testargs)
|
||||||
dble = (s2 && *s2 == '-' && !s2[2]);
|
dble = (s2 && *s2 == '-' && !s2[2]);
|
||||||
incond++; /* parentheses do globbing */
|
incond++; /* parentheses do globbing */
|
||||||
do condlex(); while (tok == SEPER && condlex != testlex);
|
do condlex(); while (COND_SEP());
|
||||||
incond--; /* parentheses do grouping */
|
incond--; /* parentheses do grouping */
|
||||||
if (tok == STRING && !dble) {
|
if (tok == STRING && !dble) {
|
||||||
s3 = tokstr;
|
s3 = tokstr;
|
||||||
do condlex(); while (tok == SEPER && condlex != testlex);
|
do condlex(); while (COND_SEP());
|
||||||
if (tok == STRING) {
|
if (tok == STRING) {
|
||||||
LinkList l = newlinklist();
|
LinkList l = newlinklist();
|
||||||
|
|
||||||
|
@ -2445,7 +2447,7 @@ par_cond_2(void)
|
||||||
|
|
||||||
while (tok == STRING) {
|
while (tok == STRING) {
|
||||||
addlinknode(l, tokstr);
|
addlinknode(l, tokstr);
|
||||||
do condlex(); while (tok == SEPER && condlex != testlex);
|
do condlex(); while (COND_SEP());
|
||||||
}
|
}
|
||||||
return par_cond_multi(s1, l);
|
return par_cond_multi(s1, l);
|
||||||
} else
|
} else
|
||||||
|
|
Loading…
Reference in a new issue