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

Implement @() expansion during parse phase. (fixes #721)

[SVN r39330]
This commit is contained in:
Rene Rivera
2007-09-16 21:35:19 +00:00
parent a5777c5893
commit 1859f9fb44

View File

@@ -90,19 +90,56 @@ var_expand(
/* This gets alot of cases: $(<) and $(>) */
if( in[0] == '$' && in[1] == '(' && in[3] == ')' && !in[4] )
if( in[0] == '$' && in[1] == '(' && in[3] == ')' && in[4] == '\0' )
{
switch( in[2] )
{
case '1':
case '<':
return list_copy( l, lol_get( lol, 0 ) );
case '2':
case '>':
return list_copy( l, lol_get( lol, 1 ) );
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
return list_copy( l, lol_get( lol, in[2]-'1' ) );
}
}
/* Expand @() files, to single item plus accompanying file. */
if ( in[0] == '@' && in[1] == '(' && *(end-1) == ')' )
{
/* We try the expansion until it fits within the propspective output buffer. */
char * at_buf = 0;
int at_size = MAXJPATH;
int at_len = 0;
do
{
BJAM_FREE(at_buf);
at_buf = (char*)BJAM_MALLOC_ATOMIC(at_size + 1);
at_len = var_string( in, at_buf, at_size, lol );
at_size *= 2;
} while ( at_len < 0 && at_len < INT_MAX / 2 );
/* Return the result as a single item list. */
if ( at_len > 0 )
{
LIST * r;
string_copy( buf, at_buf );
r = list_new( l, newstr( buf->value) );
string_free( buf );
BJAM_FREE(at_buf);
return r;
}
BJAM_FREE(at_buf);
}
/* Just try simple copy of in to out. */