[Fedora-directory-devel] cleaning up FILE_PATHSEP?

Rob Crittenden rcritten at redhat.com
Mon May 21 13:50:19 UTC 2007


Andrew Bartlett wrote:
> I recently began work on bug 239765, and came across the wonder of
> FILE_PATHSEP:
> 
> #ifdef XP_UNIX
> 
> #define FILE_PATHSEP  '/'
> #define FILE_PATHSEPP "/"
> #define FILE_PARENT   "../"
> #define WSACleanup()
> 
> #elif defined(XP_WIN32)
> 
> #define FILE_PATHSEP  '/'
> #define FILE_PATHSEPP "\\\\"
> #define FILE_PARENT   "..\\"
> 
> #endif /* XP_WIN32 */
> 
> Firstly, what little I knew about windows file handling told me that we
> could, at least on the supply side, use a unix /.
> 
> Indeed, I noted that much of create_instance does exactly that *and*
> passes in FILE_PATHSEP via %c.  If we needed FILE_PATHSEP, then this
> would already be a problem:
> 
>     /* generate <confdir>/slapd-collations.conf */
>     PR_snprintf(src, sizeof(src), "%s%c%s%c/config/%s-collations.conf",
>                 cf->sysconfdir, FILE_PATHSEP, cf->package_name,
>                 FILE_PATHSEP, PRODUCT_NAME);
>     PR_snprintf(dest, sizeof(dest), "%s%c%s-collations.conf",
>             cf->config_dir, FILE_PATHSEP, PRODUCT_NAME);
> 
> Even more priceless is the use of FILE_PATHSEP in
> ldap/admin/src/configure_instance.cpp:create_console_script().  (is
> there a /bin/sh that doesn't accept / as a path?).
> 
> Anyway, for my own amusement, I'll post a patch (probably untested on
> win32) to make this a little easier on the eyes, and perhaps even easier
> on new programmers to the codebase. 
> 
> Thoughts?
> 
> Andrew Bartlett

DS used to include a significant portion Netscape Enterprise Server 
(NES) 3.0. Prior to open sourcing I removed several hundred unused files 
and hundreds more lines of unnecessary code. I suspect that this is 
NES-specific code that found its way into DS in a viral sort of way.

In any case, it is only the 2 P version that is really a problem, right? 
The code you included would do single-character replacements AFAICT.

Prior to open sourcing I spent more time than I'd like to admit on 
getting it to at least compile on win32.

On top of this there are separate re-definitions of this code, in 
configure_instance.cpp for example. That can probably be removed.

Now certainly one shouldn't mix FILE_PATHSEP with an explicit "/" in the 
same PR_snprintf. I think that there is less effort these days to 
support win32.

As for create_console_script(), I have a fairly old source tree but in 
mine the whole function is #if 0'd out and even then is only meant to 
run on unix-like systems.

Its important to remember that portitions of the DS code supported 
versions of Solaris back to 2.4, OSF1, Irix, HP/ux, AIX, Linux and 
Windows (and perhaps one or two more that have slipped my mine). You 
haven't lived until you've broken the build on 6 platforms :-) On my 
team the unlucky developer got the attached plungers displayed on top of 
their cube.

rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plungers.jpg
Type: image/jpeg
Size: 84681 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-directory-devel/attachments/20070521/c62a5e13/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3245 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/fedora-directory-devel/attachments/20070521/c62a5e13/attachment.bin>


More information about the Fedora-directory-devel mailing list