From 3825e6cb1008dea6062ef0c3f5ffecf249a3f420 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 20 Sep 2006 22:51:37 +0000 Subject: You need this rev to build congo. --- src/build.cpp | 11 +++++++++++ src/build.h | 1 + src/buildparser.cpp | 2 +- src/functiondirectoriesin.cpp | 13 ++++++++++++- src/functionregexp.cpp | 35 +++++++++++++++++++++++++++++++++++ 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:: } } +void Build::copyContext( const std::string &src, const std::string &dest ) +{ + if( mContVars.find(src) == mContVars.end() ) + return; + + VarMap &d = mContVars[dest]; + VarMap &s = mContVars[src]; + for( VarMap::iterator i = s.begin(); i != s.end(); i++ ) + d[(*i).first] = (*i).second; +} + std::string Build::getVar( const StringList *cont, const std::string &var, VarMap *mExtra ) { 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: void set( const std::string &cont, const std::string &var, const std::string &val ); void setAdd( const std::string &cont, const std::string &var, const std::string &val ); + void copyContext( const std::string &src, const std::string &dest ); std::string getVar( const StringList *cont, const std::string &var, VarMap *mExtra ); 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() i != lTargetTmp.end(); i++ ) { StringList lTargetNames = buildToStringList( - (*i).first, StringList() + (*i).first, StringList(), bld ); for( StringList::iterator j = lTargetNames.begin(); 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 { if( e->d_name[0] == '.' || e->d_name[0] == '\0' ) continue; - lOutput.push_back( prefix + e->d_name ); + std::string sOut = prefix + e->d_name; + lOutput.push_back( sOut ); + if( bld ) + { + std::string sV = lParams.front() + "/"; + sV += e->d_name; + bld->set( sOut, "fulldir", sV ); + } + else + { + printf("no build access.\n"); + } } } 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 & } else { + if( !bld ) + { + throw BuildException("You apparently can't use regexp with two params here. Isn't that odd?"); + } + + RegExp re( lParams.front().c_str() ); + lParams.pop_front(); + std::string p2 = lParams.front(); + + for( StringList::const_iterator i = lInput.begin(); + i != lInput.end(); i++ ) + { + if( re.execute( (*i).c_str() ) ) + { + VarMap ext; + int jmax = re.getNumSubStrings(); + for( int j = 0; j < jmax; j++ ) + { + char buf[30]; + sprintf( buf, "re:%d", j ); + ext[buf] = re.getSubString( j ); + } + + std::string sNew = bld->replVars( p2, NULL, &ext ); + lOutput.push_back( sNew ); + + for( int j = 0; j < jmax; j++ ) + { + char buf[30]; + sprintf( buf, "re:%d", j ); + bld->set( sNew, buf, re.getSubString( j ) ); + } + bld->copyContext( *i, sNew ); + } + } } } -- cgit v1.2.3