awk: input numbers are never octal or hex (only program consts can be)

function                                             old     new   delta
next_token                                           825     930    +105
getvar_i                                             114     129     +15
nextchar                                              49      53      +4
my_strtod                                            138       -    -138
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 3/0 up/down: 124/-138)          Total: -14 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2022-01-08 22:42:35 +01:00
parent 84a1305888
commit e2952dfaff
2 changed files with 33 additions and 8 deletions

View File

@@ -102,9 +102,13 @@ testing "awk unused function args are evaluated" \
optional DESKTOP
testing "awk hex const 1" "awk '{ print or(0xffffffff,1) }'" "4294967295\n" "" "\n"
testing "awk hex const 2" "awk '{ print or(0x80000000,1) }'" "2147483649\n" "" "\n"
testing "awk oct const" "awk '{ print or(01234,1) }'" "669\n" "" "\n"
testing "awk oct const" "awk '{ print or(01234,1) }'" "669\n" "" "\n"
SKIP=
# check that "hex/oct integer" heuristic doesn't kick in on input
# (must be done only when parsing program text)
testing "awk input is never oct" "awk '{ print \$1, \$1+1 }'" "011 12\n" "" "011\n"
# check that "hex/oct integer" heuristic doesn't kick in on 00NN.NNN
testing "awk floating const with leading zeroes" \
"awk '{ printf \"%f %f\n\", \"000.123\", \"009.123\" }'" \
@@ -469,4 +473,10 @@ testing 'awk printf %% prints one %' \
"%\n" \
'' ''
testing 'awk backslash+newline eaten with no trace' \
"awk 'BEGIN { printf \"Hello\\
world\n\" }'" \
"Hello world\n" \
'' ''
exit $FAILCOUNT