Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41322 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12494 invoked from network); 22 Oct 2008 18:33:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Oct 2008 18:33:55 -0000 Authentication-Results: pb1.pair.com header.from=jmertic@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=jmertic@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 64.233.182.184 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: jmertic@gmail.com X-Host-Fingerprint: 64.233.182.184 nf-out-0910.google.com Received: from [64.233.182.184] ([64.233.182.184:14500] helo=nf-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D0/CE-41302-1127FF84 for ; Wed, 22 Oct 2008 14:33:54 -0400 Received: by nf-out-0910.google.com with SMTP id b11so1645389nfh.13 for ; Wed, 22 Oct 2008 11:33:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=VJ2zj1B9uMqYyFPNh2RTBsUihg4eKV1018sazBEbIrQ=; b=G7gywHs7SSoM/2NreccEhSXGlaHqqlZEkl5GhyNKeWAj3G+xkYEa51a3fsZ5blnMQh CpIDl7MCQhp77yb9onZFJEs793Czh7cU69rDBJqVhsw7ZDR+n1/EzK84+tUK+MSK0WkA O6lTKepN5xfEuYZdNrfSjg+oOwG8ncBFMsbGI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=Iy1j0djuTwuAYU25wf9ZYAUYdlFBJkEuqyCGbAiMpgftlEtLpY3fuUnBhZEBgwIAOZ 0bBAVAwBnhQ5Pr1R21LsCsRBY67L8jARjupE+af5M1lMqfE685U2x7SaRRWsg82/SEo1 0vZlH19lOoHbP+MslJUAO7n4Xf/fMihyy4KJ8= Received: by 10.210.136.10 with SMTP id j10mr12276307ebd.188.1224700430476; Wed, 22 Oct 2008 11:33:50 -0700 (PDT) Received: by 10.210.125.16 with HTTP; Wed, 22 Oct 2008 11:33:50 -0700 (PDT) Message-ID: <2a9adcf0810221133t3656347dkf0f9a27fcbb88161@mail.gmail.com> Date: Wed, 22 Oct 2008 11:33:50 -0700 Sender: jmertic@gmail.com To: "Stefan Walk" Cc: internals@lists.php.net In-Reply-To: <48FF5F8C.9050103@cs.tu-darmstadt.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <2a9adcf0810221003i70f37558ob5777b5603865cdf@mail.gmail.com> <48FF5F8C.9050103@cs.tu-darmstadt.de> X-Google-Sender-Auth: 09edbaafe1068d1c Subject: Re: [PHP-DEV] [PATCH] Bug #46367 - fputcsv does not add the correct newline character on Windows From: jmertic@php.net ("John Mertic") Hi Stefan, The context on how this function is being used is the case where you are writing out to a file, so in this case I think we should be using the EOL standards of the underlying platform. If we were just keeping the output as a string, I could see us sticking with the standard newline character. And also, the function previously took a character and still will take a character ( PHP_EOL is #defined to whatever character string should be used for the EOL character, be it "\r\n" or "\n" ), unless I'm missing something ( which could be since I haven't done much C in a while ). 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:14 AM, Stefan Walk wrote: > John Mertic wrote: >> >> Hi All, >> >> My first patch so be gentle :-). >> >> Per the documentation for the fputcsv() function, it adds a newline to >> the end of the csv string it returns. However, it is hardcoded to be >> '\n' ( default for unix newline ), while Windows uses \r\n. PHP should >> do this as well. >> >> 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: >> >> Index: php-src/ext/standard/file.c >> =================================================================== >> RCS file: /repository/php-src/ext/standard/file.c,v >> retrieving revision 1.530 >> diff -r1.530 file.c >> 2107c2107 >> < smart_str_appendc(&csvline, '\n'); >> --- >> >>> >>> smart_str_appendc(&csvline, PHP_EOL); >>> >> >> > > This can't work. Either the function takes a character or a pointer to a > character, it can't take both. > > Also, a "newline" is \n. Everywhere. The "End of line"-marker is distinct > from that. > > Regards, > Stefan >