aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/build.cpp11
-rw-r--r--src/build.h1
-rw-r--r--src/buildparser.cpp2
-rw-r--r--src/functiondirectoriesin.cpp13
-rw-r--r--src/functionregexp.cpp35
5 files changed, 60 insertions, 2 deletions
diff --git a/src/build.cpp b/src/build.cpp
index b48e9f1..c81c885 100644
--- a/src/build.cpp
+++ b/src/build.cpp
@@ -168,6 +168,17 @@ void Build::setAdd( const std::string &cont, const std::string &var, const std::
168 } 168 }
169} 169}
170 170
171void Build::copyContext( const std::string &src, const std::string &dest )
172{
173 if( mContVars.find(src) == mContVars.end() )
174 return;
175
176 VarMap &d = mContVars[dest];
177 VarMap &s = mContVars[src];
178 for( VarMap::iterator i = s.begin(); i != s.end(); i++ )
179 d[(*i).first] = (*i).second;
180}
181
171std::string Build::getVar( const StringList *cont, const std::string &var, VarMap *mExtra ) 182std::string Build::getVar( const StringList *cont, const std::string &var, VarMap *mExtra )
172{ 183{
173 if( mExtra != NULL ) 184 if( mExtra != NULL )
diff --git a/src/build.h b/src/build.h
index 82e4998..9229617 100644
--- a/src/build.h
+++ b/src/build.h
@@ -46,6 +46,7 @@ public:
46 46
47 void set( const std::string &cont, const std::string &var, const std::string &val ); 47 void set( const std::string &cont, const std::string &var, const std::string &val );
48 void setAdd( const std::string &cont, const std::string &var, const std::string &val ); 48 void setAdd( const std::string &cont, const std::string &var, const std::string &val );
49 void copyContext( const std::string &src, const std::string &dest );
49 std::string getVar( const StringList *cont, const std::string &var, VarMap *mExtra ); 50 std::string getVar( const StringList *cont, const std::string &var, VarMap *mExtra );
50 51
51 Rule *getRule( const std::string &name ); 52 Rule *getRule( const std::string &name );
diff --git a/src/buildparser.cpp b/src/buildparser.cpp
index f5b87c7..403c469 100644
--- a/src/buildparser.cpp
+++ b/src/buildparser.cpp
@@ -430,7 +430,7 @@ Build *BuildParser::genBuild()
430 i != lTargetTmp.end(); i++ ) 430 i != lTargetTmp.end(); i++ )
431 { 431 {
432 StringList lTargetNames = buildToStringList( 432 StringList lTargetNames = buildToStringList(
433 (*i).first, StringList() 433 (*i).first, StringList(), bld
434 ); 434 );
435 for( StringList::iterator j = lTargetNames.begin(); 435 for( StringList::iterator j = lTargetNames.begin();
436 j != lTargetNames.end(); j++ ) 436 j != lTargetNames.end(); j++ )
diff --git a/src/functiondirectoriesin.cpp b/src/functiondirectoriesin.cpp
index ef2f097..c68fa5c 100644
--- a/src/functiondirectoriesin.cpp
+++ b/src/functiondirectoriesin.cpp
@@ -42,7 +42,18 @@ void FunctionDirectoriesIn::execute( Build *bld, const StringList &lInput, Strin
42 { 42 {
43 if( e->d_name[0] == '.' || e->d_name[0] == '\0' ) 43 if( e->d_name[0] == '.' || e->d_name[0] == '\0' )
44 continue; 44 continue;
45 lOutput.push_back( prefix + e->d_name ); 45 std::string sOut = prefix + e->d_name;
46 lOutput.push_back( sOut );
47 if( bld )
48 {
49 std::string sV = lParams.front() + "/";
50 sV += e->d_name;
51 bld->set( sOut, "fulldir", sV );
52 }
53 else
54 {
55 printf("no build access.\n");
56 }
46 } 57 }
47 } 58 }
48 59
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