aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2021-08-11 20:16:58 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-08-11 20:16:58 +0000
commit63c0750b5554397f8ec38bde0411ac9e97ce3fe2 (patch)
tree3bd34a7729bc47be8c397d2f123ecbbe847a9ed3
parent6811e9246a0e176189379bff266cc1beef64d214 (diff)
parent20e92d9806d34d67889f3160e872e7237d9079c9 (diff)
downloadone-true-awk-android-s-v2-preview-1.tar.gz
Upgrade one-true-awk to f9affa922c5e074990a999d486d4bc823590fd93 am: 302f11d055 am: 20e92d9806android-s-v2-preview-2android-s-v2-preview-1android-s-v2-beta-2android-s-v2-preview-1
Original change: https://android-review.googlesource.com/c/platform/external/one-true-awk/+/1792169 Change-Id: Ica808fcc9f28cb882e951b087034681aaf11f504
-rw-r--r--FIXES17
-rw-r--r--METADATA6
-rw-r--r--README.md8
-rw-r--r--b.c9
-rw-r--r--lib.c4
-rw-r--r--main.c8
-rwxr-xr-xtestdir/T.misc25
7 files changed, 59 insertions, 18 deletions
diff --git a/FIXES b/FIXES
index 516458e..8a2befc 100644
--- a/FIXES
+++ b/FIXES
@@ -25,6 +25,23 @@ THIS SOFTWARE.
This file lists all bug fixes, changes, etc., made since the AWK book
was sent to the printers in August, 1987.
+July 27, 2021:
+ As per IEEE Std 1003.1-2008, -F "str" is now consistent with
+ -v FS="str" when str is null. Thanks to Warner Losh.
+
+July 24, 2021:
+ Fix readrec's definition of a record. This fixes an issue
+ with NetBSD's RS regular expression support that can cause
+ an infinite read loop. Thanks to Miguel Pineiro Jr.
+
+ Fix regular expression RS ^-anchoring. RS ^-anchoring needs to
+ know if it is reading the first record of a file. This change
+ restores a missing line that was overlooked when porting NetBSD's
+ RS regex functionality. Thanks to Miguel Pineiro Jr.
+
+ Fix size computation in replace_repeat() for special case
+ REPEAT_WITH_Q. Thanks to Todd C. Miller.
+
February 15, 2021:
Small fix so that awk will compile again with g++. Thanks to
Arnold Robbins.
diff --git a/METADATA b/METADATA
index 49d2ed8..631fe7b 100644
--- a/METADATA
+++ b/METADATA
@@ -5,11 +5,11 @@ third_party {
type: GIT
value: "https://github.com/onetrueawk/awk.git"
}
- version: "c0f4e97e4561ff42544e92512bbaf3d7d1f6a671"
+ version: "f9affa922c5e074990a999d486d4bc823590fd93"
license_type: NOTICE
last_upgrade_date {
year: 2021
- month: 4
- day: 1
+ month: 8
+ day: 10
}
}
diff --git a/README.md b/README.md
index b8089b3..76ae3d4 100644
--- a/README.md
+++ b/README.md
@@ -107,13 +107,17 @@ astonishly slow. If `awk` seems slow, you might try fixing that.
More generally, turning on optimization can significantly improve
`awk`'s speed, perhaps by 1/3 for highest levels.
+## A Note About Releases
+
+We don't do releases.
+
## A Note About Maintenance
-NOTICE! Maintenance of this program is on a ``best effort''
+NOTICE! Maintenance of this program is on a ''best effort''
basis. We try to get to issues and pull requests as quickly
as we can. Unfortunately, however, keeping this program going
is not at the top of our priority list.
#### Last Updated
-Fri Dec 25 16:53:34 EST 2020
+Sat Jul 25 14:00:07 EDT 2021
diff --git a/b.c b/b.c
index f889ee5..8042366 100644
--- a/b.c
+++ b/b.c
@@ -935,7 +935,7 @@ replace_repeat(const uschar *reptok, int reptoklen, const uschar *atom,
if (special_case == REPEAT_PLUS_APPENDED) {
size++; /* for the final + */
} else if (special_case == REPEAT_WITH_Q) {
- size += init_q + (atomlen+1)* n_q_reps;
+ size += init_q + (atomlen+1)* (n_q_reps-init_q);
} else if (special_case == REPEAT_ZERO) {
size += 2; /* just a null ERE: () */
}
@@ -964,11 +964,8 @@ replace_repeat(const uschar *reptok, int reptoklen, const uschar *atom,
}
}
memcpy(&buf[j], reptok+reptoklen, suffix_length);
- if (special_case == REPEAT_ZERO) {
- buf[j+suffix_length] = '\0';
- } else {
- buf[size] = '\0';
- }
+ j += suffix_length;
+ buf[j] = '\0';
/* free old basestr */
if (firstbasestr != basestr) {
if (basestr)
diff --git a/lib.c b/lib.c
index 18adbd2..c7709f7 100644
--- a/lib.c
+++ b/lib.c
@@ -176,6 +176,7 @@ int getrec(char **pbuf, int *pbufsize, bool isrecord) /* get next input record *
infile = stdin;
else if ((infile = fopen(file, "r")) == NULL)
FATAL("can't open file %s", file);
+ innew = true;
setfval(fnrloc, 0.0);
}
c = readrec(&buf, &bufsize, infile, innew);
@@ -241,6 +242,7 @@ int readrec(char **pbuf, int *pbufsize, FILE *inf, bool newflag) /* read one rec
}
if (found)
setptr(patbeg, '\0');
+ isrec = (found == 0 && *buf == '\0') ? false : true;
} else {
if ((sep = *rs) == 0) {
sep = '\n';
@@ -270,10 +272,10 @@ int readrec(char **pbuf, int *pbufsize, FILE *inf, bool newflag) /* read one rec
if (!adjbuf(&buf, &bufsize, 1+rr-buf, recsize, &rr, "readrec 3"))
FATAL("input record `%.30s...' too long", buf);
*rr = 0;
+ isrec = (c == EOF && rr == buf) ? false : true;
}
*pbuf = buf;
*pbufsize = bufsize;
- isrec = *buf || !feof(inf);
DPRINTF("readrec saw <%s>, returns %d\n", buf, isrec);
return isrec;
}
diff --git a/main.c b/main.c
index f393634..1e1385e 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 20210215";
+const char *version = "version 20210724";
#define DEBUG
#include <stdio.h>
@@ -91,9 +91,7 @@ setfs(char *p)
/* wart: t=>\t */
if (p[0] == 't' && p[1] == '\0')
return "\t";
- else if (p[0] != '\0')
- return p;
- return NULL;
+ return p;
}
static char *
@@ -169,8 +167,6 @@ int main(int argc, char *argv[])
break;
case 'F': /* set field separator */
fs = setfs(getarg(&argc, &argv, "no field separator"));
- if (fs == NULL)
- WARNING("field separator FS is empty");
break;
case 'v': /* -v a=1 to be done NOW. one -v for each */
vn = getarg(&argc, &argv, "no variable name");
diff --git a/testdir/T.misc b/testdir/T.misc
index dff57db..ad34ab8 100755
--- a/testdir/T.misc
+++ b/testdir/T.misc
@@ -186,6 +186,13 @@ BEGIN { RS = ""
}' >foo1
$awk 'END {print NR}' foo1 | grep 4 >/dev/null || echo 'BAD: T.misc abcdef fails'
+# Test for RS regex matching an empty record at EOF
+echo a | $awk 1 RS='a\n' > foo1
+cat << \EOF > foo2
+
+EOF
+diff foo1 foo2 || echo 'BAD: T.misc RS regex matching an empty record at EOF fails'
+
# Test for RS regex being reapplied
echo aaa1a2a | $awk 1 RS='^a' >foo1
cat << \EOF > foo2
@@ -195,6 +202,24 @@ aa1a2a
EOF
diff foo1 foo2 || echo 'BAD: T.misc ^regex reapplied fails'
+# ^-anchored RS matching should be active at the start of each input file
+tee foo1 foo2 >foo3 << \EOF
+aaa
+EOF
+$awk 1 RS='^a' foo1 foo2 foo3 >foo4
+cat << \EOF > foo5
+
+aa
+
+
+aa
+
+
+aa
+
+EOF
+diff foo4 foo5 || echo 'BAD: T.misc ^RS matches the start of every input file fails'
+
# The following should not produce a warning about changing a constant
# nor about a curdled tempcell list
$awk 'function f(x) { x = 2 }