mirror of
https://github.com/boostorg/build.git
synced 2026-02-13 12:22:17 +00:00
Boost Jam cleanup - synchronized changes between Windows and Unix file_dirscan() implementations, removed some unnecessary short-to-long path conversions on Windows (for root folders), minor stylistic code changes.
BUG: May cause access violations (crashes, core dumps or other undefined behaviour) by dereferencing a NULL pointer on non-Windows builds. [SVN r79311]
This commit is contained in:
@@ -70,7 +70,8 @@ void file_dirscan( OBJECT * dir, scanback func, void * closure )
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !d->files )
|
||||
/* If we do not have the directory's contents information - collect it. */
|
||||
if ( list_empty( d->files ) )
|
||||
{
|
||||
PATHNAME f;
|
||||
string filespec[ 1 ];
|
||||
@@ -84,8 +85,6 @@ void file_dirscan( OBJECT * dir, scanback func, void * closure )
|
||||
f.f_dir.ptr = object_str( long_dir );
|
||||
f.f_dir.len = d_length;
|
||||
|
||||
/* Now enter contents of directory */
|
||||
|
||||
/* Prepare file search specification for the findfirst() API. */
|
||||
if ( !d_length )
|
||||
string_copy( filespec, ".\\*" );
|
||||
@@ -178,12 +177,10 @@ void file_dirscan( OBJECT * dir, scanback func, void * closure )
|
||||
|
||||
/* Special case \ or d:\ : enter it */
|
||||
{
|
||||
unsigned long len = strlen( object_str( d->name ) );
|
||||
unsigned long const len = strlen( object_str( d->name ) );
|
||||
if ( len == 1 && object_str( d->name )[ 0 ] == '\\' )
|
||||
{
|
||||
OBJECT * const long_dir = short_path_to_long_path( d->name );
|
||||
(*func)( closure, long_dir, 1 /* stat()'ed */, d->time );
|
||||
object_free( long_dir );
|
||||
(*func)( closure, d->name, 1 /* stat()'ed */, d->time );
|
||||
}
|
||||
else if ( len == 3 && object_str( d->name )[ 1 ] == ':' )
|
||||
{
|
||||
@@ -199,27 +196,23 @@ void file_dirscan( OBJECT * dir, scanback func, void * closure )
|
||||
* There will be no trailing slash in $(p), but there will be one in
|
||||
* $(p2). But, that seems rather fragile.
|
||||
*/
|
||||
OBJECT * const dir1 = short_path_to_long_path( d->name );
|
||||
char const * const dir1_raw = object_str( dir1 );
|
||||
char const dir2_raw[ 3 ] = { dir1_raw[ 0 ], dir1_raw[ 1 ], 0 };
|
||||
OBJECT * const dir2 = object_new( dir2_raw );
|
||||
(*func)( closure, dir1, 1 /* stat()'ed */, d->time );
|
||||
char const * const str = object_str( d->name );
|
||||
char const dir2_str[] = { str[ 0 ], str[ 1 ], 0 };
|
||||
OBJECT * const dir2 = object_new( dir2_str );
|
||||
(*func)( closure, d->name, 1 /* stat()'ed */, d->time );
|
||||
(*func)( closure, dir2, 1 /* stat()'ed */, d->time );
|
||||
object_free( dir2 );
|
||||
object_free( dir1 );
|
||||
}
|
||||
}
|
||||
|
||||
/* Now enter contents of directory */
|
||||
if ( !list_empty( d->files ) )
|
||||
/* Now enter the directory contents. */
|
||||
{
|
||||
LIST * const files = d->files;
|
||||
LISTITER iter = list_begin( files );
|
||||
LISTITER const end = list_end( files );
|
||||
LISTITER iter = list_begin( d->files );
|
||||
LISTITER const end = list_end( d->files );
|
||||
for ( ; iter != end; iter = list_next( iter ) )
|
||||
{
|
||||
file_info_t const * const ff = file_info( list_item( iter ) );
|
||||
(*func)( closure, list_item( iter ), 1 /* stat()'ed */, ff->time );
|
||||
(*func)( closure, ff->name, 1 /* stat()'ed */, ff->time );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,6 @@ struct ar_hdr /* archive file member header - printable ascii */
|
||||
* fileunix.c - manipulate file names and scan directories on UNIX/AmigaOS
|
||||
*
|
||||
* External routines:
|
||||
*
|
||||
* file_dirscan() - scan a directory for files
|
||||
* file_time() - get timestamp of file, if not done by file_dirscan()
|
||||
* file_archscan() - scan an archive for files
|
||||
@@ -123,36 +122,29 @@ void file_dirscan( OBJECT * dir, scanback func, void * closure )
|
||||
{
|
||||
PROFILE_ENTER( FILE_DIRSCAN );
|
||||
|
||||
file_info_t * d = 0;
|
||||
|
||||
d = file_query( dir );
|
||||
|
||||
file_info_t * const d = file_query( dir );
|
||||
if ( !d || !d->is_dir )
|
||||
{
|
||||
PROFILE_EXIT( FILE_DIRSCAN );
|
||||
return;
|
||||
}
|
||||
|
||||
/* If we do not have the directory's contents information - collect it. */
|
||||
if ( list_empty( d->files ) )
|
||||
{
|
||||
LIST* files = L0;
|
||||
LIST * files = L0;
|
||||
PATHNAME f;
|
||||
DIR *dd;
|
||||
STRUCT_DIRENT *dirent;
|
||||
string filename[1];
|
||||
const char * dirstr = object_str( dir );
|
||||
DIR * dd;
|
||||
STRUCT_DIRENT * dirent;
|
||||
string filename[ 1 ];
|
||||
char const * dirstr = object_str( dir );
|
||||
|
||||
/* First enter directory itself */
|
||||
|
||||
memset( (char *)&f, '\0', sizeof( f ) );
|
||||
|
||||
f.f_dir.ptr = dirstr;
|
||||
f.f_dir.len = strlen( dirstr );
|
||||
|
||||
dirstr = *dirstr ? dirstr : ".";
|
||||
|
||||
/* Now enter contents of directory. */
|
||||
|
||||
if ( !*dirstr ) dirstr = ".";
|
||||
if ( !( dd = opendir( dirstr ) ) )
|
||||
{
|
||||
PROFILE_EXIT( FILE_DIRSCAN );
|
||||
@@ -165,21 +157,17 @@ void file_dirscan( OBJECT * dir, scanback func, void * closure )
|
||||
string_new( filename );
|
||||
while ( ( dirent = readdir( dd ) ) )
|
||||
{
|
||||
OBJECT * filename_obj;
|
||||
# ifdef old_sinix
|
||||
#ifdef old_sinix
|
||||
/* Broken structure definition on sinix. */
|
||||
f.f_base.ptr = dirent->d_name - 2;
|
||||
# else
|
||||
#else
|
||||
f.f_base.ptr = dirent->d_name;
|
||||
# endif
|
||||
#endif
|
||||
f.f_base.len = strlen( f.f_base.ptr );
|
||||
|
||||
string_truncate( filename, 0 );
|
||||
path_build( &f, filename, 0 );
|
||||
|
||||
filename_obj = object_new( filename->value );
|
||||
files = list_push_back( files, filename_obj );
|
||||
file_query( filename_obj );
|
||||
files = list_push_back( files, object_new( filename->value ) );
|
||||
}
|
||||
string_free( filename );
|
||||
|
||||
@@ -194,17 +182,14 @@ void file_dirscan( OBJECT * dir, scanback func, void * closure )
|
||||
(*func)( closure, d->name, 1 /* stat()'ed */, d->time );
|
||||
}
|
||||
|
||||
/* Now enter contents of directory */
|
||||
if ( !list_empty( d->files ) )
|
||||
/* Now enter the directory contents. */
|
||||
{
|
||||
LIST * files = d->files;
|
||||
LISTITER iter = list_begin( files );
|
||||
LISTITER const end = list_end( files );
|
||||
LISTITER iter = list_begin( d->files );
|
||||
LISTITER const end = list_end( d->files );
|
||||
for ( ; iter != end; iter = list_next( iter ) )
|
||||
{
|
||||
file_info_t * const ff = file_info( list_item( iter ) );
|
||||
file_info_t const * const ff = file_query( list_item( iter ) );
|
||||
(*func)( closure, ff->name, 1 /* stat()'ed */, ff->time );
|
||||
files = list_next( files );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user