aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-02-14 15:07:36 +0000
committerRon Yorston <rmy@pobox.com>2019-02-14 15:07:36 +0000
commitee7e00dc580c4e8075ab0776aeb3526c2c22f2b6 (patch)
treeb934dcdb7b9d27767c5336ad287408242c426b2f /editors
parent6312c005522de47dcaf442f613065415bcbd8ef7 (diff)
downloadbusybox-w32-ee7e00dc580c4e8075ab0776aeb3526c2c22f2b6.tar.gz
busybox-w32-ee7e00dc580c4e8075ab0776aeb3526c2c22f2b6.tar.bz2
busybox-w32-ee7e00dc580c4e8075ab0776aeb3526c2c22f2b6.zip
win32: add a function to remove CRs from a text buffer
Diffstat (limited to 'editors')
-rw-r--r--editors/awk.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/editors/awk.c b/editors/awk.c
index dbb26068d..c4553728d 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -1998,20 +1998,11 @@ static int ptest(node *pattern)
1998#if ENABLE_PLATFORM_MINGW32 1998#if ENABLE_PLATFORM_MINGW32
1999static ssize_t FAST_FUNC safe_read_strip_cr(int fd, void *buf, size_t count) 1999static ssize_t FAST_FUNC safe_read_strip_cr(int fd, void *buf, size_t count)
2000{ 2000{
2001 ssize_t n, i, j; 2001 ssize_t n;
2002 char *b = (char *)buf; 2002
2003 2003 do {
2004 retry: 2004 n = safe_read(fd, buf, count);
2005 n = safe_read(fd, buf, count); 2005 } while (n > 0 && (n=remove_cr((char *)buf, n)) == 0);
2006 if (n > 0) {
2007 for (i=j=0; i<n; ++i) {
2008 if (b[i] != '\r')
2009 b[j++] = b[i];
2010 }
2011 if (j == 0)
2012 goto retry;
2013 n = j;
2014 }
2015 2006
2016 return n; 2007 return n;
2017} 2008}