mirror of
https://github.com/boostorg/build.git
synced 2026-02-14 00:32:11 +00:00
Implement SPLIT_BY_CHARACTERS.
This is much faster than regex.split if splitting by a single char, or by a set of one-char delimiters. [SVN r56191]
This commit is contained in:
@@ -141,6 +141,12 @@ void load_builtins()
|
||||
bind_builtin( "MATCH",
|
||||
builtin_match, 0, 0 ) );
|
||||
|
||||
{
|
||||
char * args[] = { "string", ":", "delimiters" };
|
||||
bind_builtin( "SPLIT_BY_CHARACTERS",
|
||||
builtin_split_by_characters, 0, 0 );
|
||||
}
|
||||
|
||||
duplicate_rule( "NoCare",
|
||||
bind_builtin( "NOCARE",
|
||||
builtin_flags, T_FLAG_NOCARE, 0 ) );
|
||||
@@ -845,6 +851,26 @@ LIST * builtin_match( PARSE * parse, FRAME * frame )
|
||||
return result;
|
||||
}
|
||||
|
||||
LIST * builtin_split_by_characters( PARSE * parse, FRAME * frame )
|
||||
{
|
||||
LIST * l1 = lol_get( frame->args, 0 );
|
||||
LIST * l2 = lol_get( frame->args, 1 );
|
||||
|
||||
LIST * result = 0;
|
||||
|
||||
char* s = l1->string;
|
||||
char* delimiters = l2->string;
|
||||
char* t;
|
||||
|
||||
t = strtok (s, delimiters);
|
||||
while (t)
|
||||
{
|
||||
result = list_new(result, newstr(t));
|
||||
t = strtok (NULL, delimiters);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LIST * builtin_hdrmacro( PARSE * parse, FRAME * frame )
|
||||
{
|
||||
|
||||
@@ -31,6 +31,7 @@ LIST *builtin_glob( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_glob_recursive( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_subst( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_match( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_split_by_characters( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_hdrmacro( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_rulenames( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_varnames( PARSE *parse, FRAME *args );
|
||||
|
||||
Reference in New Issue
Block a user