Boost logo

Boost-Commit :

From: jurko.gospodnetic_at_[hidden]
Date: 2008-04-07 06:32:09


Author: jurko
Date: 2008-04-07 06:32:09 EDT (Mon, 07 Apr 2008)
New Revision: 44088
URL: http://svn.boost.org/trac/boost/changeset/44088

Log:
  Fixed a bug with bjam not handling the '\' root Windows path correctly without its drive letter being specified. One effect could be seen by MkDir rule on such a path always attempting to create its base folder even if that folder already exists. For example if you attempted to create folder '\Projects\XYZ\BuildDir' it would incorrectly think that '\Projects' folder does not exist and attempt to create it - thus causing the whole build to fail due to the underlying OS mkdir command failing.

  This was caused by the file_dirscan() function in the filent.c module not working correctly when passed '\' as its dir. It then messed up when formatting its file-selection parameter for the _findfirst()/findfirst() API and constructed it as '\/*' which caused that API to fail and return -1 which was in turn being interpreted as 'file not found'.

Text files modified:
   trunk/tools/jam/src/filent.c | 25 ++++++++++++++++++++-----
   1 files changed, 20 insertions(+), 5 deletions(-)

Modified: trunk/tools/jam/src/filent.c
==============================================================================
--- trunk/tools/jam/src/filent.c (original)
+++ trunk/tools/jam/src/filent.c 2008-04-07 06:32:09 EDT (Mon, 07 Apr 2008)
@@ -87,18 +87,33 @@
         int ret;
         struct _finddata_t finfo[1];
         LIST* files = L0;
+ int d_length = strlen( d->name );
 
         memset( (char *)&f, '\0', sizeof( f ) );
         
         f.f_dir.ptr = d->name;
- f.f_dir.len = strlen(d->name);
-
+ f.f_dir.len = d_length;
+
         /* Now enter contents of directory */
 
- string_copy( filespec, *d->name ? d->name : "." );
- string_append( filespec, "/*" );
+ /* Prepare file search specification for the findfirst() API. */
+ if ( d_length == 0 )
+ string_copy( filespec, ".\\*" );
+ else
+ {
+ /*
+ * We can not simply assume the given folder name will never include
+ * its trailing path separator or otherwise we would not support the
+ * Windows root folder specified without its drive letter, i.e. '\'.
+ */
+ char trailingChar = d->name[ d_length - 1 ] ;
+ string_copy( filespec, d->name );
+ if ( ( trailingChar != '\\' ) && ( trailingChar != '/' ) )
+ string_append( filespec, "\\" );
+ string_append( filespec, "*" );
+ }
 
- if( DEBUG_BINDSCAN )
+ if ( DEBUG_BINDSCAN )
             printf( "scan directory %s\n", dir );
 
         # if defined(__BORLANDC__) && __BORLANDC__ < 0x550


Boost-Commit 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