awk: disallow "str"++, closes bug 12981
function old new delta parse_expr 887 896 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
45fa3f18ad
commit
6f7a009649
@ -1359,8 +1359,10 @@ static node *parse_expr(uint32_t iexp)
|
|||||||
v = cn->l.v = xzalloc(sizeof(var));
|
v = cn->l.v = xzalloc(sizeof(var));
|
||||||
if (tc & TC_NUMBER)
|
if (tc & TC_NUMBER)
|
||||||
setvar_i(v, t_double);
|
setvar_i(v, t_double);
|
||||||
else
|
else {
|
||||||
setvar_s(v, t_string);
|
setvar_s(v, t_string);
|
||||||
|
xtc &= ~TC_UOPPOST; /* "str"++ is not allowed */
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TC_REGEXP:
|
case TC_REGEXP:
|
||||||
|
@ -390,5 +390,13 @@ testing 'awk negative field access' \
|
|||||||
'' \
|
'' \
|
||||||
'anything'
|
'anything'
|
||||||
|
|
||||||
|
# was misinterpreted as (("str"++) i) instead of ("str" (++i))
|
||||||
|
# (and was executed: "str"++ is "0", thus concatenating "0" and "1"):
|
||||||
|
testing 'awk do not allow "str"++' \
|
||||||
|
'awk -v i=1 "BEGIN {print \"str\" ++i}"' \
|
||||||
|
"str2\n" \
|
||||||
|
'' \
|
||||||
|
'anything'
|
||||||
|
|
||||||
|
|
||||||
exit $FAILCOUNT
|
exit $FAILCOUNT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user