diff --git a/ChangeLog b/ChangeLog index fd03b2b..bb65336 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2019-06-05 Arnold D. Robbins + + * b.c (relex): Count parentheses and treat umatched right paren + as a literal character. + * awktest.tar (testdir/T.re): Added a test case. + * main.c (version): Upated. + 2019-05-29 Arnold D. Robbins * lib.c (isclvar): Remove check for additional '=' after diff --git a/FIXES b/FIXES index 183eaed..0665229 100644 --- a/FIXES +++ b/FIXES @@ -25,6 +25,12 @@ THIS SOFTWARE. This file lists all bug fixes, changes, etc., made since the AWK book was sent to the printers in August, 1987. +June 5, 2019: + Allow unmatched right parenthesis in a regular expression to + be treated literally. Fixes Issue #40. Thanks to GitHub user + Warner Losh (bsdimp) for the report. Thanks to Arnold Robbins + for the fix. + May 29,2019: Fix check for command line arguments to no longer require that first character after '=' not be another '='. Reverts change of @@ -34,7 +40,7 @@ May 29,2019: Apr 7, 2019: Update awktest.tar(p.50) to use modern options to sort. Needed for Android development. Thanks to GitHub user mohd-akram (Mohamed - Akram). From Comment #33. + Akram). From Issue #33. Mar 12, 2019: Added very simplistic support for cross-compiling in the @@ -54,7 +60,7 @@ Mar 3, 2019: #12: Avoid undefined behaviour when using ctype(3) functions in relex(). Thanks to GitHub user iamleot. #31: Make getline handle numeric strings, and update FIXES. Thanks - to GitHub user arnoldrobbins + to GitHub user arnoldrobbins. #32: maketab: support build systems with read-only source. Thanks to GitHub user enh. diff --git a/awktest.tar b/awktest.tar index 4ca482a..011c073 100644 Binary files a/awktest.tar and b/awktest.tar differ diff --git a/b.c b/b.c index 37ea0a5..2eeba2a 100644 --- a/b.c +++ b/b.c @@ -912,6 +912,7 @@ int relex(void) /* lexical analyzer for reparse */ int i; int num, m, commafound, digitfound; const uschar *startreptok; + static int parens = 0; rescan: starttok = prestr; @@ -925,9 +926,18 @@ rescan: case '\0': prestr--; return '\0'; case '^': case '$': - case '(': - case ')': return c; + case '(': + parens++; + return c; + case ')': + if (parens) { + parens--; + return c; + } + /* unmatched close parenthesis; per POSIX, treat as literal */ + rlxval = c; + return CHAR; case '\\': rlxval = quoted(&prestr); return CHAR; diff --git a/main.c b/main.c index 98661fc..2d7a382 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 20190529"; +const char *version = "version 20190605"; #define DEBUG #include