diff options
author | zoulasc <zoulasc@users.noreply.github.com> | 2020-02-28 06:23:54 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-28 13:23:54 +0200 |
commit | ffee7780fe08fa77f662a0903477545d9e26334f (patch) | |
tree | bdeafcbb782b3892f53cad636082292f1aae773a /lib.c | |
parent | 91eaf7f7015ba2223e993532f5d65dfda4d1f33f (diff) | |
download | one-true-awk-ffee7780fe08fa77f662a0903477545d9e26334f.tar.gz |
3 more fixes (#75)
* LC_NUMERIC radix issue.
According to https://pubs.opengroup.org/onlinepubs/7990989775/xcu/awk.html
The period character is the character recognized in processing awk
programs. Make it so that during output we also print the period
character, since this is what other awk implementations do, and it
makes sense from an interoperability point of view.
* print "T.builtin" in the error message
* Fix backslash continuation line handling.
* Keep track of RS processing so we apply the regex properly only once
per record.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -35,6 +35,7 @@ THIS SOFTWARE. char EMPTY[] = { '\0' }; FILE *infile = NULL; +bool innew; /* true = infile has not been read by readrec */ char *file = EMPTY; char *record; int recsize = RECSIZE; @@ -106,6 +107,7 @@ void initgetrec(void) argno++; } infile = stdin; /* no filenames, so use stdin */ + innew = true; } /* @@ -175,7 +177,9 @@ int getrec(char **pbuf, int *pbufsize, bool isrecord) /* get next input record * FATAL("can't open file %s", file); setfval(fnrloc, 0.0); } - c = readrec(&buf, &bufsize, infile); + c = readrec(&buf, &bufsize, infile, innew); + if (innew) + innew = false; if (c != 0 || buf[0] != '\0') { /* normal record */ if (isrecord) { if (freeable(fldtab[0])) @@ -213,7 +217,7 @@ void nextfile(void) argno++; } -int readrec(char **pbuf, int *pbufsize, FILE *inf) /* read one record into buf */ +int readrec(char **pbuf, int *pbufsize, FILE *inf, bool newflag) /* read one record into buf */ { int sep, c, isrec; char *rr, *buf = *pbuf; @@ -224,7 +228,14 @@ int readrec(char **pbuf, int *pbufsize, FILE *inf) /* read one record into buf * bool found; fa *pfa = makedfa(rs, 1); - found = fnematch(pfa, inf, &buf, &bufsize, recsize); + if (newflag) + found = fnematch(pfa, inf, &buf, &bufsize, recsize); + else { + int tempstat = pfa->initstat; + pfa->initstat = 2; + found = fnematch(pfa, inf, &buf, &bufsize, recsize); + pfa->initstat = tempstat; + } if (found) setptr(patbeg, '\0'); } else { |