Make RS as regexp work without ifdef. Add doc, bump version.

This commit is contained in:
Arnold D. Robbins 2019-10-06 22:34:20 +03:00
parent 643a5a3dad
commit 7cae39dfa5
5 changed files with 19 additions and 6 deletions

View File

@ -1,3 +1,11 @@
2019-10-06 Arnold D. Robbins <arnold@skeeve.com>
* lib.c (readrec): Allow RS a regular expression. Imported
the code from the NetBSD awk.
* b.c (fnematch): New function for implementing the feature.
* awk.1: Updated.
* main.c (version): Updated.
2019-06-24 Arnold D. Robbins <arnold@skeeve.com>
* makefile: Revise to take into account there is no more awktest.tar,
@ -18,7 +26,7 @@
* 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.
* main.c (version): Updated.
2019-05-29 Arnold D. Robbins <arnold@skeeve.com>

4
FIXES
View File

@ -25,6 +25,10 @@ THIS SOFTWARE.
This file lists all bug fixes, changes, etc., made since the AWK book
was sent to the printers in August, 1987.
October 6, 2019:
Import code from NetBSD awk that implements RS as a regular
expression.
September 10, 2019:
Fixes for various array / memory overruns found via gcc's
-fsanitize=unknown. Thanks to Alexander Richardson (Github

5
awk.1
View File

@ -478,6 +478,11 @@ the length of a string matched by
.TP
.B RS
input record separator (default newline).
If empty, blank lines separate records.
If more than one character long,
.B RS
is treated as a regular expression, and records are
separated by text matching the expression.
.TP
.B RSTART
the start position of a string matched by

4
lib.c
View File

@ -209,7 +209,6 @@ int readrec(char **pbuf, int *pbufsize, FILE *inf) /* read one record into buf *
int bufsize = *pbufsize;
char *rs = getsval(rsloc);
#ifdef RS_AS_REGEXP
if (*rs && rs[1]) {
int found;
@ -218,7 +217,6 @@ int readrec(char **pbuf, int *pbufsize, FILE *inf) /* read one record into buf *
if (found)
*patbeg = 0;
} else {
#endif
if ((sep = *rs) == 0) {
sep = '\n';
while ((c=getc(inf)) == '\n' && c != EOF) /* skip leading \n's */
@ -247,9 +245,7 @@ int readrec(char **pbuf, int *pbufsize, FILE *inf) /* read one record into buf *
if (!adjbuf(&buf, &bufsize, 1+rr-buf, recsize, &rr, "readrec 3"))
FATAL("input record `%.30s...' too long", buf);
*rr = 0;
#ifdef RS_AS_REGEXP
}
#endif
*pbuf = buf;
*pbufsize = bufsize;
isrec = *buf || !feof(inf);

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 20190910";
const char *version = "version 20191006";
#define DEBUG
#include <stdio.h>