# [PATCH] For Bug #39538

- Thread: https://externals.io/message/26667
- Original archive: https://news-web.php.net/php.internals/26667
- Started by David Soria Parra on 2006-11-19T15:52:20+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #26667 — David Soria Parra — 2006-11-19T15:52:20+00:00

URL: https://externals.io/message/26667#26667

Hi Internals,

I tried to fix the newline bug #39538
(http://bugs.php.net/bug.php?id=39538) that appears using fgetcsv with
unix newlines LF, instead of the csv rfc CRLF.

I didn't fix the backslash escape stuff, as this might be expected
behviour.

Greets
David (dsp@php.net)

The patch against 5_2_0

Index: file.c
===================================================================
RCS file: /repository/php-src/ext/standard/file.c,v
retrieving revision 1.409.2.6.2.10
diff -u -r1.409.2.6.2.10 file.c
--- file.c      15 Nov 2006 00:20:40 -0000      1.409.2.6.2.10
+++ file.c      18 Nov 2006 13:43:48 -0000
@@ -2171,9 +2171,11 @@
                                                                size_t new_len;
                                                                char *new_temp;
 
-                                                               memcpy(tptr, hunk_begin, bptr - hunk_begin);
-                                                               tptr += (bptr - hunk_begin);
-                                                               hunk_begin = bptr;
+                                                               if (hunk_begin != line_end) {
+                                                                       memcpy(tptr, hunk_begin, bptr - hunk_begin);
+                                                                       tptr += (bptr - hunk_begin);
+                                                                       hunk_begin = bptr;
+                                                               }
 
                                                                /* add the embedded line end to the field */
                                                                memcpy(tptr, line_end, line_end_len);

---

## #26696 — David Soria Parra — 2006-11-22T01:40:18+00:00

URL: https://externals.io/message/26667#26696 · In reply to: #26667

anyone who has karma can check that patch? Would be nice.

---

## #26702 — Pierre — 2006-11-22T13:01:17+00:00

URL: https://externals.io/message/26667#26702 · In reply to: #26696

> anyone who has karma can check that patch? Would be nice.

Done, I also updated your test.

--Pierre
