2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-17 13:42:14 +00:00

Use downcased globbing on NT/Cygwin

[SVN r17537]
This commit is contained in:
Dave Abrahams
2003-02-19 16:43:55 +00:00
parent 179487cda4
commit fed31d2af9
6 changed files with 150 additions and 90 deletions

View File

@@ -632,7 +632,7 @@ jam [ -a ] [ -n ] [ -v ] [ -q ]
<P><TABLE WIDTH=75% ALIGN=CENTER><TR><TD><DL>
<P><DT><CODE>
GLOB <i>directories</I> : <I>patterns</I>
GLOB <i>directories</I> : <I>patterns</I> : <I>downcase-opt</I>
</CODE>
<DD> Using the same wildcards as for the patterns in the <A
@@ -642,7 +642,14 @@ jam [ -a ] [ -n ] [ -v ] [ -q ]
A to the list of C source and header files in dir1 or dir2.
The resulting filenames are the full pathnames, including the
directory, but the pattern is applied only to the file name
without the directory.
without the directory.
<p>If <I>downcase-opt</I> is supplied, filenames are converted to
all-lowercase before matching against the pattern; you can use
this to do case-insensitive matching using lowercase patterns.
The paths returned will still have mixed case if the OS supplies
them. On Windows NT and Cygwin, filenames are always downcased
before matching.
</DL></TABLE>

View File

@@ -19,6 +19,7 @@
# include "pwd.h"
# include "pathsys.h"
# include "make.h"
# include <ctype.h>
/*
* builtins.c - builtin jam rules
@@ -93,9 +94,13 @@ load_builtins()
bind_builtin( "EXIT" ,
builtin_exit, 0, 0 ) ) );
duplicate_rule( "Glob" ,
bind_builtin( "GLOB" ,
builtin_glob, 0, 0 ) );
{
char * args[] = { "directories", "*", ":", "patterns", "*", ":", "downcase-filenames", "?", 0 };
duplicate_rule(
"Glob" ,
bind_builtin( "GLOB" , builtin_glob, 0, args )
);
}
duplicate_rule( "Includes" ,
bind_builtin( "INCLUDES" ,
@@ -284,56 +289,73 @@ builtin_flags(
*/
struct globbing {
LIST *patterns;
LIST *results;
LIST *patterns;
LIST *results;
LIST *downcase;
} ;
static void
builtin_glob_back(
void *closure,
char *file,
int status,
time_t time )
void *closure,
char *file,
int status,
time_t time )
{
struct globbing *globbing = (struct globbing *)closure;
LIST *l;
PATHNAME f;
string buf[1];
struct globbing *globbing = (struct globbing *)closure;
LIST *l;
PATHNAME f;
string buf[1];
/* Null out directory for matching. */
/* We wish we had file_dirscan() pass up a PATHNAME. */
/* Null out directory for matching. */
/* We wish we had file_dirscan() pass up a PATHNAME. */
path_parse( file, &f );
f.f_dir.len = 0;
string_new( buf );
path_build( &f, buf, 0 );
path_parse( file, &f );
f.f_dir.len = 0;
string_new( buf );
path_build( &f, buf, 0 );
for( l = globbing->patterns; l; l = l->next )
if( !glob( l->string, buf->value ) )
{
globbing->results = list_new( globbing->results, newstr( file ) );
break;
}
string_free( buf );
if (globbing->downcase)
{
char* p;
for ( p = buf->value; *p; ++p )
{
*p = tolower(*p);
}
}
for( l = globbing->patterns; l; l = l->next )
if( !glob( l->string, buf->value ) )
{
globbing->results = list_new( globbing->results, newstr( file ) );
break;
}
string_free( buf );
}
LIST *
builtin_glob(
PARSE *parse,
FRAME *frame )
PARSE *parse,
FRAME *frame )
{
LIST *l = lol_get( frame->args, 0 );
LIST *r = lol_get( frame->args, 1 );
LIST *l = lol_get( frame->args, 0 );
LIST *r = lol_get( frame->args, 1 );
struct globbing globbing;
struct globbing globbing;
globbing.results = L0;
globbing.patterns = r;
globbing.downcase
# if defined( OS_NT ) || defined( OS_CYGWIN )
= l; /* always downcase filenames if any files can be found */
# else
= lol_get( frame->args, 2 ); /* conditionally downcase filenames */
# endif
for( ; l; l = list_next( l ) )
file_dirscan( l->string, builtin_glob_back, &globbing );
globbing.results = L0;
globbing.patterns = r;
for( ; l; l = list_next( l ) )
file_dirscan( l->string, builtin_glob_back, &globbing );
return globbing.results;
return globbing.results;
}
/*

View File

@@ -632,7 +632,7 @@ jam [ -a ] [ -n ] [ -v ] [ -q ]
<P><TABLE WIDTH=75% ALIGN=CENTER><TR><TD><DL>
<P><DT><CODE>
GLOB <i>directories</I> : <I>patterns</I>
GLOB <i>directories</I> : <I>patterns</I> : <I>downcase-opt</I>
</CODE>
<DD> Using the same wildcards as for the patterns in the <A
@@ -642,7 +642,14 @@ jam [ -a ] [ -n ] [ -v ] [ -q ]
A to the list of C source and header files in dir1 or dir2.
The resulting filenames are the full pathnames, including the
directory, but the pattern is applied only to the file name
without the directory.
without the directory.
<p>If <I>downcase-opt</I> is supplied, filenames are converted to
all-lowercase before matching against the pattern; you can use
this to do case-insensitive matching using lowercase patterns.
The paths returned will still have mixed case if the OS supplies
them. On Windows NT and Cygwin, filenames are always downcased
before matching.
</DL></TABLE>

View File

@@ -19,6 +19,7 @@
# include "pwd.h"
# include "pathsys.h"
# include "make.h"
# include <ctype.h>
/*
* builtins.c - builtin jam rules
@@ -93,9 +94,13 @@ load_builtins()
bind_builtin( "EXIT" ,
builtin_exit, 0, 0 ) ) );
duplicate_rule( "Glob" ,
bind_builtin( "GLOB" ,
builtin_glob, 0, 0 ) );
{
char * args[] = { "directories", "*", ":", "patterns", "*", ":", "downcase-filenames", "?", 0 };
duplicate_rule(
"Glob" ,
bind_builtin( "GLOB" , builtin_glob, 0, args )
);
}
duplicate_rule( "Includes" ,
bind_builtin( "INCLUDES" ,
@@ -284,56 +289,73 @@ builtin_flags(
*/
struct globbing {
LIST *patterns;
LIST *results;
LIST *patterns;
LIST *results;
LIST *downcase;
} ;
static void
builtin_glob_back(
void *closure,
char *file,
int status,
time_t time )
void *closure,
char *file,
int status,
time_t time )
{
struct globbing *globbing = (struct globbing *)closure;
LIST *l;
PATHNAME f;
string buf[1];
struct globbing *globbing = (struct globbing *)closure;
LIST *l;
PATHNAME f;
string buf[1];
/* Null out directory for matching. */
/* We wish we had file_dirscan() pass up a PATHNAME. */
/* Null out directory for matching. */
/* We wish we had file_dirscan() pass up a PATHNAME. */
path_parse( file, &f );
f.f_dir.len = 0;
string_new( buf );
path_build( &f, buf, 0 );
path_parse( file, &f );
f.f_dir.len = 0;
string_new( buf );
path_build( &f, buf, 0 );
for( l = globbing->patterns; l; l = l->next )
if( !glob( l->string, buf->value ) )
{
globbing->results = list_new( globbing->results, newstr( file ) );
break;
}
string_free( buf );
if (globbing->downcase)
{
char* p;
for ( p = buf->value; *p; ++p )
{
*p = tolower(*p);
}
}
for( l = globbing->patterns; l; l = l->next )
if( !glob( l->string, buf->value ) )
{
globbing->results = list_new( globbing->results, newstr( file ) );
break;
}
string_free( buf );
}
LIST *
builtin_glob(
PARSE *parse,
FRAME *frame )
PARSE *parse,
FRAME *frame )
{
LIST *l = lol_get( frame->args, 0 );
LIST *r = lol_get( frame->args, 1 );
LIST *l = lol_get( frame->args, 0 );
LIST *r = lol_get( frame->args, 1 );
struct globbing globbing;
struct globbing globbing;
globbing.results = L0;
globbing.patterns = r;
globbing.downcase
# if defined( OS_NT ) || defined( OS_CYGWIN )
= l; /* always downcase filenames if any files can be found */
# else
= lol_get( frame->args, 2 ); /* conditionally downcase filenames */
# endif
for( ; l; l = list_next( l ) )
file_dirscan( l->string, builtin_glob_back, &globbing );
globbing.results = L0;
globbing.patterns = r;
for( ; l; l = list_next( l ) )
file_dirscan( l->string, builtin_glob_back, &globbing );
return globbing.results;
return globbing.results;
}
/*

View File

@@ -49,23 +49,24 @@ rule init ( version ? path ? : vendor ? : setup ? compiler ? linker ? )
{
local v = [ MATCH ^(6|[^6].*) : $(version) ] ;
local version-6-path = "c:\\Program Files\\Microsoft Visual Studio\\VC98" ;
local version-7.0-path = "c:\\Program Files\\Microsoft Visual Studio .NET\\VC7" ;
local version-7-path = "c:\\Program Files\\Microsoft Visual Studio .NET\\VC7" ;
local version-7.0-path = $(version-7-path) ;
local version-7.1-path = "c:\\Program Files\\Microsoft Visual Studio .NET 2003\\VC7" ;
local default-path = $(version-$(v)-path) ;
# look for the setup program in both the system PATH and in
# its default installation location based on version
local env-PATH = [ modules.peek : PATH ] ;
local PATH-setup = [ GLOB $(env-PATH) : $(setup) $(setup:U) ] ;
local default-setup = [ GLOB $(default-path)\\bin : $(setup) $(setup:U) ] ;
local PATH-setup = [ GLOB $(env-PATH) : $(setup:L) ] ;
local default-setup = [ GLOB $(default-path)\\bin : $(setup:L) ] ;
if $(default-setup) && $(PATH-setup) != $(default-setup)
{
path = $(default-path) ;
}
compiler = $(compiler:U) ;
if ! [ GLOB $(path)\\bin $(env-PATH) : $(compiler:E=CL).EXE $(compiler:E=cl).exe ]
compiler = $(compiler:L) ;
if ! [ GLOB $(path)\\bin $(env-PATH) : $(compiler:E=cl).exe ]
{
error $(condition) initialization: :
couldn't find compiler \"$(compiler:E=CL)\" in PATH or "known default"

View File

@@ -49,23 +49,24 @@ rule init ( version ? path ? : vendor ? : setup ? compiler ? linker ? )
{
local v = [ MATCH ^(6|[^6].*) : $(version) ] ;
local version-6-path = "c:\\Program Files\\Microsoft Visual Studio\\VC98" ;
local version-7.0-path = "c:\\Program Files\\Microsoft Visual Studio .NET\\VC7" ;
local version-7-path = "c:\\Program Files\\Microsoft Visual Studio .NET\\VC7" ;
local version-7.0-path = $(version-7-path) ;
local version-7.1-path = "c:\\Program Files\\Microsoft Visual Studio .NET 2003\\VC7" ;
local default-path = $(version-$(v)-path) ;
# look for the setup program in both the system PATH and in
# its default installation location based on version
local env-PATH = [ modules.peek : PATH ] ;
local PATH-setup = [ GLOB $(env-PATH) : $(setup) $(setup:U) ] ;
local default-setup = [ GLOB $(default-path)\\bin : $(setup) $(setup:U) ] ;
local PATH-setup = [ GLOB $(env-PATH) : $(setup:L) ] ;
local default-setup = [ GLOB $(default-path)\\bin : $(setup:L) ] ;
if $(default-setup) && $(PATH-setup) != $(default-setup)
{
path = $(default-path) ;
}
compiler = $(compiler:U) ;
if ! [ GLOB $(path)\\bin $(env-PATH) : $(compiler:E=CL).EXE $(compiler:E=cl).exe ]
compiler = $(compiler:L) ;
if ! [ GLOB $(path)\\bin $(env-PATH) : $(compiler:E=cl).exe ]
{
error $(condition) initialization: :
couldn't find compiler \"$(compiler:E=CL)\" in PATH or "known default"