aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-01-23 10:05:36 +0000
committerRon Yorston <rmy@pobox.com>2019-01-23 10:05:36 +0000
commit8e55f1eabc0632d6060caf1c0bf9325ac1cc19c2 (patch)
tree06def01ca32c7de4385c9920d0c2ac4dcdc62ddb /editors
parente92596d0b1f30fb6751d304c41d59968c237fd79 (diff)
downloadbusybox-w32-8e55f1eabc0632d6060caf1c0bf9325ac1cc19c2.tar.gz
busybox-w32-8e55f1eabc0632d6060caf1c0bf9325ac1cc19c2.tar.bz2
busybox-w32-8e55f1eabc0632d6060caf1c0bf9325ac1cc19c2.zip
awk: fix handling of regular expressions that match end-of-line
awk failed to match regular expressions that included an end-of-line: it was looking for a LF whereas lines were terminated by CRLF. Rather than tinker with the regex code or arrange for input to be in text mode I've stripped CRs from the input.
Diffstat (limited to 'editors')
-rw-r--r--editors/awk.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/editors/awk.c b/editors/awk.c
index 17bbdc62a..86cd9a289 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -1974,6 +1974,30 @@ static int ptest(node *pattern)
1974 return istrue(evaluate(pattern, &G.ptest__v)); 1974 return istrue(evaluate(pattern, &G.ptest__v));
1975} 1975}
1976 1976
1977#if ENABLE_PLATFORM_MINGW32
1978static ssize_t FAST_FUNC safe_read_strip_cr(int fd, void *buf, size_t count)
1979{
1980 ssize_t n, i, j;
1981 char *b = (char *)buf;
1982
1983 retry:
1984 n = safe_read(fd, buf, count);
1985 if (n > 0) {
1986 for (i=j=0; i<n; ++i) {
1987 if (b[i] != '\r')
1988 b[j++] = b[i];
1989 }
1990 if (j == 0)
1991 goto retry;
1992 n = j;
1993 }
1994
1995 return n;
1996}
1997
1998#define safe_read safe_read_strip_cr
1999#endif
2000
1977/* read next record from stream rsm into a variable v */ 2001/* read next record from stream rsm into a variable v */
1978static int awk_getline(rstream *rsm, var *v) 2002static int awk_getline(rstream *rsm, var *v)
1979{ 2003{