|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56191 - trunk/tools/jam/src
From: ghost_at_[hidden]
Date: 2009-09-14 12:57:58
Author: vladimir_prus
Date: 2009-09-14 12:57:57 EDT (Mon, 14 Sep 2009)
New Revision: 56191
URL: http://svn.boost.org/trac/boost/changeset/56191
Log:
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.
Text files modified:
trunk/tools/jam/src/builtins.c | 26 ++++++++++++++++++++++++++
trunk/tools/jam/src/builtins.h | 1 +
2 files changed, 27 insertions(+), 0 deletions(-)
Modified: trunk/tools/jam/src/builtins.c
==============================================================================
--- trunk/tools/jam/src/builtins.c (original)
+++ trunk/tools/jam/src/builtins.c 2009-09-14 12:57:57 EDT (Mon, 14 Sep 2009)
@@ -141,6 +141,12 @@
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 @@
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 )
{
Modified: trunk/tools/jam/src/builtins.h
==============================================================================
--- trunk/tools/jam/src/builtins.h (original)
+++ trunk/tools/jam/src/builtins.h 2009-09-14 12:57:57 EDT (Mon, 14 Sep 2009)
@@ -31,6 +31,7 @@
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 );
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