aboutsummaryrefslogtreecommitdiff
path: root/win32/mingw.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-01-30 12:24:34 +0000
committerRon Yorston <rmy@pobox.com>2023-01-30 12:24:34 +0000
commitb9a1b02dee2b82e4e4a580c446a1e022aa96166d (patch)
tree6dfc496086422beffd9880d8e06ed4506d201495 /win32/mingw.c
parent7a537eb71874cd6c8d0e9ab1f906e6466e7f793c (diff)
downloadbusybox-w32-b9a1b02dee2b82e4e4a580c446a1e022aa96166d.tar.gz
busybox-w32-b9a1b02dee2b82e4e4a580c446a1e022aa96166d.tar.bz2
busybox-w32-b9a1b02dee2b82e4e4a580c446a1e022aa96166d.zip
ash,make: fix CRLF handling
Fix remove_cr() so it only removes CRs which are part of a CRLF pair, not every CR. Add a test case for the shell.
Diffstat (limited to 'win32/mingw.c')
-rw-r--r--win32/mingw.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/win32/mingw.c b/win32/mingw.c
index 5cd7e74db..4d07a24e5 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -2030,8 +2030,9 @@ size_t FAST_FUNC remove_cr(char *p, size_t len)
2030 ssize_t i, j; 2030 ssize_t i, j;
2031 2031
2032 for (i=j=0; i<len; ++i) { 2032 for (i=j=0; i<len; ++i) {
2033 if (p[i] != '\r') 2033 if (p[i] == '\r' && i < len - 1 && p[i+1] == '\n')
2034 p[j++] = p[i]; 2034 continue;
2035 p[j++] = p[i];
2035 } 2036 }
2036 return j; 2037 return j;
2037} 2038}