Re: [PATCH] unix path separators in spl

From: Date: Thu, 19 Jun 2008 19:00:52 +0000
Subject: Re: [PATCH] unix path separators in spl
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-38429@lists.php.net to get a copy of this message
Hello Steph, how about having this as an option inside the SPL classes that gets turned on by Phar automatically? Inside SPL we could have it as a user set-only flag. marcus Wednesday, June 18, 2008, 10:28:40 PM, you wrote: > Index: ext/spl/spl_directory.c > =================================================================== > RCS file: /repository/php-src/ext/spl/spl_directory.c,v > retrieving revision 1.45.2.27.2.23.2.22 > diff -u -r1.45.2.27.2.23.2.22 spl_directory.c > --- ext/spl/spl_directory.c 18 Jun 2008 10:05:29 -0000 1.45.2.27.2.23.2.22 > +++ ext/spl/spl_directory.c 18 Jun 2008 17:16:39 -0000 > @@ -185,6 +185,9 @@ > intern->file_name_len = > spprintf(&intern->file_name, 0, "%s%c%s", > > spl_filesystem_object_get_path(intern, NULL TSRMLS_CC), > DEFAULT_SLASH, > intern->u.dir.entry.d_name); > +#ifdef PHP_WIN32 > + spl_unixify_path_separators(intern->file_name, intern->file_name_len); > +#endif > break; > } > } > @@ -1196,6 +1199,9 @@ > subdir->u.dir.sub_path_len = strlen(intern->u.dir.entry.d_name); > subdir->u.dir.sub_path = > estrndup(intern->u.dir.entry.d_name, subdir->u.dir.sub_path_len); > } > +#ifdef PHP_WIN32 > + spl_unixify_path_separators(intern->u.dir.sub_path, > intern->u.dir.sub_path_len); > +#endif > subdir->info_class = intern->info_class; > subdir->file_class = intern->file_class; > subdir->oth = intern->oth; > @@ -1227,6 +1233,9 @@ > > if (intern->u.dir.sub_path) { > len = spprintf(&sub_name, 0, "%s%c%s", > intern->u.dir.sub_path, DEFAULT_SLASH, intern->u.dir.entry.d_name); > +#ifdef PHP_WIN32 > + spl_unixify_path_separators(sub_name, len); > +#endif > RETURN_STRINGL(sub_name, len, 0); > } else { > RETURN_STRING(intern->u.dir.entry.d_name, 1); > Index: ext/spl/spl_directory.h > =================================================================== > RCS file: /repository/php-src/ext/spl/spl_directory.h,v > retrieving revision 1.12.2.5.2.4.2.10 > diff -u -r1.12.2.5.2.4.2.10 spl_directory.h > --- ext/spl/spl_directory.h 20 May 2008 21:46:50 -0000 1.12.2.5.2.4.2.10 > +++ ext/spl/spl_directory.h 18 Jun 2008 17:10:18 -0000 > @@ -112,6 +112,20 @@ > return (spl_filesystem_object*)((char*)it - > XtOffsetOf(spl_filesystem_object, it)); > } > > +#ifdef PHP_WIN32 > +static inline void spl_unixify_path_separators(char *path, int path_len) > +{ > + char *s; > + > + /* unixify win paths */ > + for (s = path; s - path < path_len; ++s) { > + if (*s == '\\') { > + *s = '/'; > + } > + } > +} > +#endif > + > #define SPL_FILE_OBJECT_DROP_NEW_LINE 0x00000001 /* drop new lines */ > #define SPL_FILE_OBJECT_READ_AHEAD 0x00000002 /* read on rewind/next */ > #define SPL_FILE_OBJECT_SKIP_EMPTY 0x00000006 /* skip empty lines */ Best regards, Marcus

« previous php.internals (#38429) next »