update for HEAD-2003021201
[reactos.git] / lib / msvcrt / io / read.c
index f55875f..4dcdd72 100644 (file)
@@ -49,25 +49,49 @@ size_t _read(int _fd, void *_buf, size_t _nbyte)
    /* text mode */
    if (_rbyte && istext)
    {
+      int found_cr = 0;
       int cr = 0;
       DWORD count = _rbyte;
 
       /* repeat for all bytes in the buffer */
       for(; count; bufp++, count--)
       {
+#if 1
+          /* carriage return */
+          if (*bufp == '\r') {
+            found_cr = 1;
+            if (cr != 0) {
+                *(bufp - cr) = *bufp;
+            }
+            continue;
+          }
+          if (found_cr) {
+            found_cr = 0;
+            if (*bufp == '\n') {
+              cr++;
+              *(bufp - cr) = *bufp;
+            } else {
+            }
+          } else if (cr != 0) {
+            *(bufp - cr) = *bufp;
+          }
+#else
          /* carriage return */
-         if (*bufp == '\r')
+          if (*bufp == '\r') {
             cr++;
+          }
          /* shift characters back, to ignore carriage returns */
-         else if (cr != 0)
+          else if (cr != 0) {
             *(bufp - cr) = *bufp;
-
+          }
+#endif
+      }
+      if (found_cr) {
+        cr++;
       }
-
       /* ignore the carriage returns */
       _rbyte -= cr;
    }
-
    DPRINT("%d\n", _rbyte);
    return _rbyte;
 }