Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38364 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6608 invoked from network); 18 Jun 2008 20:27:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jun 2008 20:27:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=steph@phparch.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=steph@phparch.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain phparch.com from 64.99.136.159 cause and error) X-PHP-List-Original-Sender: steph@phparch.com X-Host-Fingerprint: 64.99.136.159 smtprelay-virgin0159.hostedemail.com Linux 2.5 (sometimes 2.4) (4) Received: from [64.99.136.159] ([64.99.136.159:56534] helo=smtprelay-virgin.hostedemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E6/24-03518-9AF69584 for ; Wed, 18 Jun 2008 16:27:22 -0400 Received: from filter.hostedemail.com (ff-bigip1 [10.5.19.254]) by smtprelay06.hostedemail.com (Postfix) with SMTP id BF89C150080 for ; Wed, 18 Jun 2008 20:27:18 +0000 (UTC) X-SpamScore: 1 Received: from foxbox (host86-143-244-1.range86-143.btcentralplus.com [86.143.244.1]) (Authenticated sender: steph.fox) by omf12.hostedemail.com (Postfix) with ESMTP for ; Wed, 18 Jun 2008 20:27:18 +0000 (UTC) Message-ID: <04a501c8d181$e67c6ec0$4401a8c0@foxbox> Reply-To: "Steph Fox" To: "internals" Date: Wed, 18 Jun 2008 21:28:40 +0100 Organization: php|architect MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_04A2_01C8D18A.46B099D0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-session-marker: 73746570682E666F78 X-Spam-Summary: 2,0,0,2375bd325a86aa64,dd4bba892e23c659,steph@phparch.com,,RULES_HIT:152:355:379:539:540:541:542:543:567:945:973:988:989:1000:1155:1156:1260:1308:1309:1313:1314:1345:1437:1515:1516:1518:1535:1541:1575:1587:1594:1676:1711:1730:1747:1764:1766:1792:2073:2075:2078:2393:2553:2559:2562:3352:3622:3865:3866:3867:3868:3869:3870:3871:3872:3873:3874:4362:5007:6119:6261:7281:7862:7875,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:none,DNSBL:none Subject: [PATCH] unix path separators in spl From: steph@phparch.com ("Steph Fox") ------=_NextPart_000_04A2_01C8D18A.46B099D0 Content-Type: text/plain; format=flowed; charset="UTF-8"; reply-type=original Content-Transfer-Encoding: 7bit Hi all, In Phar we have an internal Windows-only function named phar_unixify_path_separators(), which is needed because Phar is intended to be used with web apps. Phar inherits from SPL, which currently uses the system-specific DEFAULT_SLASH when returning directory paths. This isn't actually a problem in Phar (at least, as far as I'm aware) but it does look... well, untidy. The attached patch implements spl_unixify_path_separators(). If it's accepted, we can probably kill the version in Phar and rely on the definition in SPL. However I'm concerned that some other extension might be relying on SPL's current behaviour, unlikely tho' it may seem. I haven't found any change in behaviour running the test suite for: ext/spl, ext/phar, ext/standard/array, ext/simplexml. I haven't tested: ext/pdo, ext/sqlite, ext/mysqli or pecl/spl_types, and I'm not certain if there should be any more on that list. If you find/can see any problems with this change at all, pls adv. If there are no objections, I plan to commit at the end of this week. Thanks, - Steph ------=_NextPart_000_04A2_01C8D18A.46B099D0 Content-Type: text/plain; format=flowed; name="spl_unixify_path_separator.txt"; reply-type=original Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="spl_unixify_path_separator.txt" Index: ext/spl/spl_directory.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /repository/php-src/ext/spl/spl_directory.c,v=0A= retrieving revision 1.45.2.27.2.23.2.22=0A= diff -u -r1.45.2.27.2.23.2.22 spl_directory.c=0A= --- ext/spl/spl_directory.c 18 Jun 2008 10:05:29 -0000 = 1.45.2.27.2.23.2.22=0A= +++ ext/spl/spl_directory.c 18 Jun 2008 17:16:39 -0000=0A= @@ -185,6 +185,9 @@=0A= intern->file_name_len =3D spprintf(&intern->file_name, 0, "%s%c%s",=0A= = spl_filesystem_object_get_path(intern, NULL TSRMLS_CC),=0A= DEFAULT_SLASH, = intern->u.dir.entry.d_name);=0A= +#ifdef PHP_WIN32=0A= + spl_unixify_path_separators(intern->file_name, intern->file_name_len);=0A= +#endif=0A= break;=0A= }=0A= }=0A= @@ -1196,6 +1199,9 @@=0A= subdir->u.dir.sub_path_len =3D strlen(intern->u.dir.entry.d_name);=0A= subdir->u.dir.sub_path =3D estrndup(intern->u.dir.entry.d_name, = subdir->u.dir.sub_path_len);=0A= }=0A= +#ifdef PHP_WIN32=0A= + spl_unixify_path_separators(intern->u.dir.sub_path, = intern->u.dir.sub_path_len);=0A= +#endif=0A= subdir->info_class =3D intern->info_class;=0A= subdir->file_class =3D intern->file_class;=0A= subdir->oth =3D intern->oth;=0A= @@ -1227,6 +1233,9 @@=0A= =0A= if (intern->u.dir.sub_path) {=0A= len =3D spprintf(&sub_name, 0, "%s%c%s", intern->u.dir.sub_path, = DEFAULT_SLASH, intern->u.dir.entry.d_name);=0A= +#ifdef PHP_WIN32=0A= + spl_unixify_path_separators(sub_name, len);=0A= +#endif=0A= RETURN_STRINGL(sub_name, len, 0);=0A= } else {=0A= RETURN_STRING(intern->u.dir.entry.d_name, 1);=0A= Index: ext/spl/spl_directory.h=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /repository/php-src/ext/spl/spl_directory.h,v=0A= retrieving revision 1.12.2.5.2.4.2.10=0A= diff -u -r1.12.2.5.2.4.2.10 spl_directory.h=0A= --- ext/spl/spl_directory.h 20 May 2008 21:46:50 -0000 1.12.2.5.2.4.2.10=0A= +++ ext/spl/spl_directory.h 18 Jun 2008 17:10:18 -0000=0A= @@ -112,6 +112,20 @@=0A= return (spl_filesystem_object*)((char*)it - = XtOffsetOf(spl_filesystem_object, it));=0A= }=0A= =0A= +#ifdef PHP_WIN32=0A= +static inline void spl_unixify_path_separators(char *path, int path_len)=0A= +{=0A= + char *s;=0A= +=0A= + /* unixify win paths */=0A= + for (s =3D path; s - path < path_len; ++s) {=0A= + if (*s =3D=3D '\\') {=0A= + *s =3D '/';=0A= + }=0A= + }=0A= +}=0A= +#endif=0A= +=0A= #define SPL_FILE_OBJECT_DROP_NEW_LINE 0x00000001 /* drop new lines = */=0A= #define SPL_FILE_OBJECT_READ_AHEAD 0x00000002 /* read on = rewind/next */=0A= #define SPL_FILE_OBJECT_SKIP_EMPTY 0x00000006 /* skip empty = lines */=0A= ------=_NextPart_000_04A2_01C8D18A.46B099D0--