Boost logo

Boost-Build :

Subject: Re: [Boost-build] UNC path for library search path
From: Jim Gallagher (jim_at_[hidden])
Date: 2012-08-30 18:05:10


Jurko,

I must say that while it took me longer to understand
builtin_normalize_path() than I hoped, actually making the changes went
faster than I feared. The following patch is for engine/builtins.c that
shipped with Boost 1.49.0; sorry it is not the latest. The only use case
tested is where third party libraries live on a share specified with a UNC
path.

Thanks,
Jim

$ diff -u builtins-1.49.0.c boost-build/engine/builtins.c
--- builtins-1.49.0.c 2011-06-06 13:36:22.000000000 -0700
+++ boost-build/engine/builtins.c 2012-08-30 14:35:20.000000000 -0700
@@ -1468,6 +1468,7 @@
        /* Number of '..' elements seen and not processed yet. */
     int dotdots = 0;
     int rooted = 0;
+ int isUNC = 0;
     char * result = 0;

     /* Make a copy of input: we should not change it. Prepend a '/' before
it as
@@ -1497,6 +1498,29 @@
         if ( *current == '\\' )
             *current = '/';

+# if defined( OS_NT ) || defined( OS_CYGWIN )
+ {
+ /* Detect UNC paths. At this point, a UNC path will have
three leading
+ * forward slashes. A UNC path can only have two leading
+ * slashes, // or \\, as any other quantity will not work
for Windows
+ * file operations. Note that even under cygwin, a leading
double slash
+ * is treated as UNC, even if next token is "cygdrive", so
we don't need to
+ * check for the cygdrive case. */
+ static regexp *re;
+ static int been_here = 0;
+
+ if(!been_here)
+ {
+ been_here = 1;
+ re = regcomp("^///[^/:]+/+[^/]");
+ }
+
+ if(in->size > 5 && regexec(re, in->value))
+ isUNC = 1;
+ }
+#endif
+
+
     /* Now we remove any extra path elements by overwriting them with '\1'
      * characters and cound how many more unused '..' path elements there
are
      * remaining. Note that each remaining path element with always starts
with
@@ -1536,6 +1560,13 @@

     string_new( out );

+# if defined( OS_NT ) || defined( OS_CYGWIN )
+ /* A UNC path would now have only a single / in front after
processing above.
+ * Put a leading / in first, and we will end up with the double /
needed. */
+ if(isUNC)
+ string_append( out, "/" );
+# endif
+
     /* Now we know that we need to add exactly dotdots '..' path elements
to the
      * front and that our string is either empty or has a '/' as its first
      * significant character. If we have any dotdots remaining then the
passed



Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk