aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2023-11-23 19:21:50 +0200
committerArnold D. Robbins <arnold@skeeve.com>2023-11-23 19:21:50 +0200
commit583e89479f9b358005a328c999cf1555d27f3340 (patch)
tree68aeb13cbe86a64824a5fbea5f1404bccd6b38a8
parent345f907c404ff05165834601009835a42c90463d (diff)
parentb84620a7b5c89e84ec76821ba3fd31d70b29ee7b (diff)
downloadone-true-awk-583e89479f9b358005a328c999cf1555d27f3340.tar.gz
Merge branch 'master' into improve-gototab
-rw-r--r--FIXES11
-rw-r--r--lex.c14
-rw-r--r--main.c2
-rw-r--r--run.c3
-rwxr-xr-xtestdir/T.misc14
5 files changed, 34 insertions, 10 deletions
diff --git a/FIXES b/FIXES
index 5d2b459..e84bd44 100644
--- a/FIXES
+++ b/FIXES
@@ -25,13 +25,19 @@ THIS SOFTWARE.
This file lists all bug fixes, changes, etc., made since the
second edition of the AWK book was published in September 2023.
-Nov 20, 2023
+Nov 23, 2023:
+ Fix Issue #169, related to escape sequences in strings.
+ Thanks to Github user rajeevvp.
+ Fix Issue #147, reported by Github user drawkula, and fixed
+ by Miguel Pineiro Jr.
+
+Nov 20, 2023:
rewrite of fnematch to fix a number of issues, including
extraneous output, out-of-bounds access, number of bytes
to push back after a failed match etc.
thanks to Miguel Pineiro Jr.
-Nov 15, 2023
+Nov 15, 2023:
Man page edit, regression test fixes. thanks to Arnold Robbins
consolidation of sub and gsub into dosub, removing duplicate
code. thanks to Miguel Pineiro Jr.
@@ -44,7 +50,6 @@ Oct 30, 2023:
systems. also fixed an out-of-bounds read for empty CCL.
fixed a buffer overflow in substr with utf-8 strings.
many thanks to Todd C Miller.
-
Sep 24, 2023:
fnematch and getrune have been overhauled to solve issues around
diff --git a/lex.c b/lex.c
index 675c116..0473a33 100644
--- a/lex.c
+++ b/lex.c
@@ -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/main.c b/main.c
index 4f2d78a..a5f49c6 100644
--- a/main.c
+++ b/main.c
@@ -22,7 +22,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
-const char *version = "version 20231120";
+const char *version = "version 20231123";
#define DEBUG
#include <stdio.h>
diff --git a/run.c b/run.c
index e78cae9..7462c38 100644
--- a/run.c
+++ b/run.c
@@ -1540,8 +1540,9 @@ Cell *assign(Node **a, int n) /* a[0] = a[1], a[0] += a[1], etc. */
if (x == y && !(x->tval & (FLD|REC)) && x != nfloc)
; /* self-assignment: leave alone unless it's a field or NF */
else if ((y->tval & (STR|NUM)) == (STR|NUM)) {
+ yf = getfval(y);
setsval(x, getsval(y));
- x->fval = getfval(y);
+ x->fval = yf;
x->tval |= NUM;
}
else if (isstr(y))
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'