diff options
| author | android-build-team Robot <android-build-team-robot@google.com> | 2019-03-13 03:09:34 +0000 |
|---|---|---|
| committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-03-13 03:09:34 +0000 |
| commit | 23d092df2a6c5219f5eef63d409e87fb357ffd5b (patch) | |
| tree | f6307e79932c3a0088655ad69bf40daf26910e04 | |
| parent | fbe429f497fca8318d1959431e850d4930b6fb91 (diff) | |
| parent | 440b2ac71cdeb2e449a5f788a28c850e80da8659 (diff) | |
| download | platform_external_one-true-awk-23d092df2a6c5219f5eef63d409e87fb357ffd5b.tar.gz platform_external_one-true-awk-23d092df2a6c5219f5eef63d409e87fb357ffd5b.tar.bz2 platform_external_one-true-awk-23d092df2a6c5219f5eef63d409e87fb357ffd5b.zip | |
Snap for 5370966 from 440b2ac71cdeb2e449a5f788a28c850e80da8659 to qt-release
Change-Id: Ia3be8b859b7c0c446b95a7303cf8337858997b01
| -rw-r--r-- | .gitignore | 6 | ||||
| -rw-r--r-- | Android.bp | 2 | ||||
| -rw-r--r-- | ChangeLog | 9 | ||||
| -rw-r--r-- | FIXES | 10 | ||||
| -rw-r--r-- | METADATA | 14 | ||||
| -rw-r--r-- | b.c | 3 | ||||
| -rw-r--r-- | bugs-fixed/README | 5 | ||||
| -rw-r--r-- | bugs-fixed/getline-numeric.awk | 6 | ||||
| -rw-r--r-- | bugs-fixed/getline-numeric.bad | 3 | ||||
| -rw-r--r-- | bugs-fixed/getline-numeric.in | 1 | ||||
| -rw-r--r-- | bugs-fixed/getline-numeric.ok | 3 | ||||
| -rw-r--r-- | main.c | 2 | ||||
| -rw-r--r-- | makefile | 2 | ||||
| -rw-r--r-- | maketab.c | 8 | ||||
| -rw-r--r-- | run.c | 8 |
15 files changed, 69 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f469d21 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +a.out +maketab +proctab.c +ytab.c +ytab.h +*.o @@ -8,6 +8,8 @@ cc_defaults { "-Wno-missing-field-initializers", "-Wno-self-assign", "-Wno-unused-parameter", + // A loop to UCHAR_MAX in `b.c`. + "-Wno-sign-compare", // And one less harmless used with strtod(3) in `lex.c`. "-Wno-unused-result", // Also ignore harmless macro redefinitions: glibc 2.17 #defines dprintf @@ -1,3 +1,12 @@ +2019-01-26 Arnold D. Robbins <arnold@skeeve.com> + + * main.c (version): Updated. + +2019-01-25 Arnold D. Robbins <arnold@skeeve.com> + + * run.c (awkgetline): Check for numeric value in all getline + variants. See the numeric-getline.* files in bugs-fixed directory. + 2018-08-29 Arnold D. Robbins <arnold@skeeve.com> * REGRESS: Check for existence of a.out. If not there, run @@ -25,6 +25,16 @@ THIS SOFTWARE. This file lists all bug fixes, changes, etc., made since the AWK book was sent to the printers in August, 1987. +Jan 25, 2019: + Make getline handle numeric strings properly in all cases. + (Thanks, Arnold.) + +Jan 21, 2019: + Merged a number of small fixes from GitHub pull requests. + Thanks to GitHub users Arnold Robbins (arnoldrobbins), + Cody Mello (melloc) and Christoph Junghans (junghans). + PR numbers: 13-21, 23, 24, 27. + Oct 25, 2018: Added test in maketab.c to prevent generating a proctab entry for YYSTYPE_IS_DEFINED. It was harmless but some gcc settings @@ -1,15 +1,15 @@ name: "one-true-awk" -description: - "This is the version of awk described in 'The AWK Programming Language', by " - "Al Aho, Brian Kernighan, and Peter Weinberger (Addison-Wesley, 1988, ISBN " - "0-201-07981-X)." - +description: "This is the version of awk described in \'The AWK Programming Language\', by Al Aho, Brian Kernighan, and Peter Weinberger (Addison-Wesley, 1988, ISBN 0-201-07981-X)." third_party { url { type: GIT value: "https://github.com/onetrueawk/awk.git" } - version: "c3c7c1370e9a9969bdcaf2018c5e62096ac15c55" - last_upgrade_date { year: 2019 month: 1 day: 30 } + version: "2d9034a01a91359c5e47fd4275a00debaaab56cc" license_type: NOTICE + last_upgrade_date { + year: 2019 + month: 3 + day: 4 + } } @@ -27,6 +27,7 @@ THIS SOFTWARE. #define DEBUG #include <ctype.h> +#include <limits.h> #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -831,7 +832,7 @@ int relex(void) /* lexical analyzer for reparse */ * not without first adapting the entire * program to track each string's length. */ - for (i = 1; i < NCHARS; i++) { + for (i = 1; i <= UCHAR_MAX; i++) { if (!adjbuf((char **) &buf, &bufsz, bp-buf+1, 100, (char **) &bp, "relex2")) FATAL("out of space for reg expr %.10s...", lastre); if (cc->cc_func(i)) { diff --git a/bugs-fixed/README b/bugs-fixed/README index 9c644f9..2f27c10 100644 --- a/bugs-fixed/README +++ b/bugs-fixed/README @@ -51,4 +51,7 @@ array passed as the second argument, then split() would previously read from the freed memory and possibly produce incorrect results (depending on the system's malloc()/free() behaviour.) - +15. getline-numeric: The `getline xx < file' syntax did not check if +values were numeric, in discordance from POSIX. Test case adapted from +one posted by Ben Bacarisse <ben.usenet@bsb.me.uk> in comp.lang.awk, +January 2019. diff --git a/bugs-fixed/getline-numeric.awk b/bugs-fixed/getline-numeric.awk new file mode 100644 index 0000000..5571a95 --- /dev/null +++ b/bugs-fixed/getline-numeric.awk @@ -0,0 +1,6 @@ +{ + print $0, ($0 <= 50 ? "<=" : ">"), 50 + getline dd < ARGV[1] + print dd, (dd <= 50 ? "<=" : ">"), 50 + if (dd == $0) print "same" +} diff --git a/bugs-fixed/getline-numeric.bad b/bugs-fixed/getline-numeric.bad new file mode 100644 index 0000000..d911c77 --- /dev/null +++ b/bugs-fixed/getline-numeric.bad @@ -0,0 +1,3 @@ +120 > 50 +120 <= 50 +same diff --git a/bugs-fixed/getline-numeric.in b/bugs-fixed/getline-numeric.in new file mode 100644 index 0000000..52bd8e4 --- /dev/null +++ b/bugs-fixed/getline-numeric.in @@ -0,0 +1 @@ +120 diff --git a/bugs-fixed/getline-numeric.ok b/bugs-fixed/getline-numeric.ok new file mode 100644 index 0000000..f7efd3d --- /dev/null +++ b/bugs-fixed/getline-numeric.ok @@ -0,0 +1,3 @@ +120 > 50 +120 > 50 +same @@ -22,7 +22,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ****************************************************************/ -const char *version = "version 20180827"; +const char *version = "version 20190125"; #define DEBUG #include <stdio.h> @@ -67,7 +67,7 @@ y%.c y%.h: awk.h proto.h awkgram.y ytab.h: ytab.c proctab.c: maketab - ./maketab >proctab.c + ./maketab ytab.h >proctab.c maketab: ytab.h maketab.c $(CC) $(CFLAGS) maketab.c -o maketab @@ -125,8 +125,12 @@ int main(int argc, char *argv[]) for (i = SIZE; --i >= 0; ) names[i] = ""; - if ((fp = fopen("ytab.h", "r")) == NULL) { - fprintf(stderr, "maketab can't open ytab.h!\n"); + if (argc != 2) { + fprintf(stderr, "usage: maketab YTAB_H\n"); + exit(1); + } + if ((fp = fopen(argv[1], "r")) == NULL) { + fprintf(stderr, "maketab can't open %s!\n", argv[1]); exit(1); } printf("static char *printname[%d] = {\n", SIZE); @@ -425,6 +425,10 @@ Cell *awkgetline(Node **a, int n) /* get next line from specific input */ } else if (a[0] != NULL) { /* getline var <file */ x = execute(a[0]); setsval(x, buf); + if (is_number(x->sval)) { + x->fval = atof(x->sval); + x->tval |= NUM; + } tempfree(x); } else { /* getline <file */ setsval(fldtab[0], buf); @@ -440,6 +444,10 @@ Cell *awkgetline(Node **a, int n) /* get next line from specific input */ n = getrec(&buf, &bufsize, 0); x = execute(a[0]); setsval(x, buf); + if (is_number(x->sval)) { + x->fval = atof(x->sval); + x->tval |= NUM; + } tempfree(x); } } |
