Allow unmatched right paren in regexes. Fixes Issue #40.

This commit is contained in:
Arnold D. Robbins 2019-06-04 23:53:31 -06:00
parent 4189ef5d58
commit 28dacbd66b
5 changed files with 28 additions and 5 deletions

View File

@ -1,3 +1,10 @@
2019-06-05 Arnold D. Robbins <arnold@skeeve.com>
* 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 <arnold@skeeve.com>
* lib.c (isclvar): Remove check for additional '=' after

10
FIXES
View File

@ -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.

Binary file not shown.

14
b.c
View File

@ -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;

2
main.c
View File

@ -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 <stdio.h>