diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2023-11-23 19:13:04 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2023-11-23 19:13:04 +0200 |
commit | ad444edf7b9d72d9c1025764cb76079b6cc84661 (patch) | |
tree | bf4ae5dac904c5a3a03ddd2cf31170e73072c95f | |
parent | ad4249ec70c04690a797a8d8310b1d4ee69a357b (diff) | |
download | one-true-awk-ad444edf7b9d72d9c1025764cb76079b6cc84661.tar.gz |
Integrate fix from Issue #169.
-rw-r--r-- | lex.c | 14 | ||||
-rwxr-xr-x | testdir/T.misc | 14 |
2 files changed, 23 insertions, 5 deletions
@@ -421,8 +421,12 @@ int string(void) { int i; + if (!isxdigit(peek())) { + unput(c); + break; + } n = 0; - for (i = 1; i <= 2; i++) { + for (i = 0; i < 2; i++) { c = input(); if (c == 0) break; @@ -433,13 +437,13 @@ int string(void) n += (c - '0'); else n += 10 + (c - 'a'); - } else + } else { + unput(c); break; + } } - if (n) + if (i) *bp++ = n; - else - unput(c); break; } diff --git a/testdir/T.misc b/testdir/T.misc index 1e5c3c5..a2c0fb8 100755 --- a/testdir/T.misc +++ b/testdir/T.misc @@ -510,3 +510,17 @@ cmp -s foo1 foo2 || echo 'BAD: T.misc exit status on I/O error' echo 1b >foo1 echo ab | $awk '{ sub(/a/, "b" ~ /b/); print }' >foo2 cmp -s foo1 foo2 || echo 'BAD: T.misc lexer regex buffer clobbered' + ++# Check handling of octal (\OOO) and hex (\xHH) esc. seqs. in strings. ++echo 'hello888 ++hello ++hello ++helloxGOO ++hello ++0A' > foo1 ++$awk 'BEGIN { print "hello\888" }' > foo2 ++$awk 'BEGIN { print "hello\x000A" }' >> foo2 ++$awk 'BEGIN { printf "hello\x0A" }' >> foo2 ++$awk 'BEGIN { print "hello\xGOO" }' >> foo2 ++$awk 'BEGIN { print "hello\x0A0A" }' >> foo2 ++cmp -s foo1 foo2 || echo '�BAD: T.misc escape sequences in strings mishandled' |