diff options
author | jilles <jilles@FreeBSD.org> | 2010-12-18 23:03:51 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2010-12-18 23:03:51 +0000 |
commit | 84941f8297970e3618d7e98cdbef942031b9a596 (patch) | |
tree | 25ca73deea96a1e4bb9d3b97235aa742e7f61254 /bin/sh | |
parent | 2a8eefc56b6eda956a168d2be7354df603b97b24 (diff) | |
download | FreeBSD-src-84941f8297970e3618d7e98cdbef942031b9a596.zip FreeBSD-src-84941f8297970e3618d7e98cdbef942031b9a596.tar.gz |
sh: arith: Disallow decimal constants starting with 0 (containing 8 or 9).
Constants in arithmetic starting with 0 should be octal only.
This avoids the following highly puzzling result:
$ echo $((018-017))
3
by making it an error instead.
Diffstat (limited to 'bin/sh')
-rw-r--r-- | bin/sh/arith_lex.l | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/bin/sh/arith_lex.l b/bin/sh/arith_lex.l index b4a04d3..f93608a 100644 --- a/bin/sh/arith_lex.l +++ b/bin/sh/arith_lex.l @@ -74,12 +74,12 @@ int yylex(void); return ARITH_NUM; } -0[0-7]+ { +0[0-7]* { yylval.l_value = strtoarith_t(yytext, NULL, 8); return ARITH_NUM; } -[0-9]+ { +[1-9][0-9]* { yylval.l_value = strtoarith_t(yytext, NULL, 10); return ARITH_NUM; } |