aboutsummaryrefslogtreecommitdiff
path: root/src/functionregexp.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-09-20 22:51:37 +0000
committerMike Buland <eichlan@xagasoft.com>2006-09-20 22:51:37 +0000
commit3825e6cb1008dea6062ef0c3f5ffecf249a3f420 (patch)
tree5c9fe11285d07ae30aea77ba28b7d569e97e50c7 /src/functionregexp.cpp
parent030ab69b236f53357a79fa912956f43f975d79e2 (diff)
downloadbuild-3825e6cb1008dea6062ef0c3f5ffecf249a3f420.tar.gz
build-3825e6cb1008dea6062ef0c3f5ffecf249a3f420.tar.bz2
build-3825e6cb1008dea6062ef0c3f5ffecf249a3f420.tar.xz
build-3825e6cb1008dea6062ef0c3f5ffecf249a3f420.zip
You need this rev to build congo.
Diffstat (limited to '')
-rw-r--r--src/functionregexp.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/functionregexp.cpp b/src/functionregexp.cpp
index 74c19ee..27fdbbd 100644
--- a/src/functionregexp.cpp
+++ b/src/functionregexp.cpp
@@ -39,6 +39,41 @@ void FunctionRegexp::execute( Build *bld, const StringList &lInput, StringList &
39 } 39 }
40 else 40 else
41 { 41 {
42 if( !bld )
43 {
44 throw BuildException("You apparently can't use regexp with two params here. Isn't that odd?");
45 }
46
47 RegExp re( lParams.front().c_str() );
48 lParams.pop_front();
49 std::string p2 = lParams.front();
50
51 for( StringList::const_iterator i = lInput.begin();
52 i != lInput.end(); i++ )
53 {
54 if( re.execute( (*i).c_str() ) )
55 {
56 VarMap ext;
57 int jmax = re.getNumSubStrings();
58 for( int j = 0; j < jmax; j++ )
59 {
60 char buf[30];
61 sprintf( buf, "re:%d", j );
62 ext[buf] = re.getSubString( j );
63 }
64
65 std::string sNew = bld->replVars( p2, NULL, &ext );
66 lOutput.push_back( sNew );
67
68 for( int j = 0; j < jmax; j++ )
69 {
70 char buf[30];
71 sprintf( buf, "re:%d", j );
72 bld->set( sNew, buf, re.getSubString( j ) );
73 }
74 bld->copyContext( *i, sNew );
75 }
76 }
42 } 77 }
43} 78}
44 79