aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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{