Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41324 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56390 invoked from network); 22 Oct 2008 20:17:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Oct 2008 20:17:05 -0000 Authentication-Results: pb1.pair.com header.from=ilia@prohost.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=ilia@prohost.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain prohost.org from 74.125.44.29 cause and error) X-PHP-List-Original-Sender: ilia@prohost.org X-Host-Fingerprint: 74.125.44.29 yx-out-2324.google.com Received: from [74.125.44.29] ([74.125.44.29:23273] helo=yx-out-2324.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EA/D8-41302-F3A8FF84 for ; Wed, 22 Oct 2008 16:17:04 -0400 Received: by yx-out-2324.google.com with SMTP id 3so772953yxj.83 for ; Wed, 22 Oct 2008 13:17:01 -0700 (PDT) Received: by 10.64.27.16 with SMTP id a16mr357490qba.119.1224706620487; Wed, 22 Oct 2008 13:17:00 -0700 (PDT) Received: from ?192.168.1.139? (TOROON63-1279386825.sdsl.bell.ca [76.65.228.201]) by mx.google.com with ESMTPS id q16sm5847592qbq.1.2008.10.22.13.16.58 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 22 Oct 2008 13:16:59 -0700 (PDT) Cc: "Lars Strojny" , internals@lists.php.net Message-ID: <370571A4-8A89-412C-A8CD-1D7439C761F1@prohost.org> To: John Mertic In-Reply-To: <2a9adcf0810221135h1e6ed4ecub55318cfb26b3e7e@mail.gmail.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v929.2) Date: Wed, 22 Oct 2008 16:16:56 -0400 References: <2a9adcf0810221003i70f37558ob5777b5603865cdf@mail.gmail.com> <1224696974.17075.1.camel@localhost> <2a9adcf0810221135h1e6ed4ecub55318cfb26b3e7e@mail.gmail.com> X-Mailer: Apple Mail (2.929.2) Subject: Re: [PHP-DEV] [PATCH] Bug #46367 - fputcsv does not add the correct newline character on Windows From: ilia@prohost.org (Ilia Alshanetsky) You cannot use smart_str_appendc() in this case, since the EOL could be a 2 byte string "\r\n". smart_str_appendl(&csvline, PHP_EOL, sizeof(PHP_EOL)-1); should be used here. On 22-Oct-08, at 2:35 PM, John Mertic wrote: > Hi Lars, > > Thanks for the pointers, updated the patch and added a test. > > Index: file.c > =================================================================== > RCS file: /repository/php-src/ext/standard/file.c,v > retrieving revision 1.530 > diff -u -r1.530 file.c > --- file.c 21 Oct 2008 22:06:48 -0000 1.530 > +++ file.c 22 Oct 2008 18:21:10 -0000 > @@ -2104,7 +2104,7 @@ > } > } > > - smart_str_appendc(&csvline, '\n'); > + smart_str_appendc(&csvline, PHP_EOL); > smart_str_0(&csvline); > > ret = php_stream_write(stream, csvline.c, csvline.len); > > > John Mertic > jmertic@gmail.com > http://jmertic.wordpress.com > > "Explaining a joke is like dissecting a frog: you understand it > better, but the frog dies > in the process." --Mark Twain > > > > On Wed, Oct 22, 2008 at 10:36 AM, Lars Strojny > wrote: >> Hi John, >> >> >> Am Mittwoch, den 22.10.2008, 10:03 -0700 schrieb John Mertic: >> [...] >>> Below is a patch to fix this issue; it uses the constant PHP_EOL to >>> get the correct newline to use on the current platform: >> >> Thanks for your patch. A few things to mention, as it is your first >> patch: please use "diff -ru" to create unified diffs. Also we try to >> always add tests for the things we fix or create. Would you mind >> creating a test for the fix you sent to make sure no regression >> happens >> in the next n years? >> >> Thanks, Lars >> -- >> Jabber: lars@strojny.net >> Weblog: http://usrportage.de >> > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php Ilia Alshanetsky