From 52be1ef0d126f09ba943c7afcf367e7d9347f2fd Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 8 Nov 2012 22:58:28 +0000 Subject: tabconv: it's all spaces now. --- src/functionmatches.cpp | 216 ++++++++++++++++++++++++------------------------ 1 file changed, 108 insertions(+), 108 deletions(-) (limited to 'src/functionmatches.cpp') diff --git a/src/functionmatches.cpp b/src/functionmatches.cpp index 0f76316..b5b5b64 100644 --- a/src/functionmatches.cpp +++ b/src/functionmatches.cpp @@ -4,7 +4,7 @@ #include PluginInterface3( pluginFunctionMatches, matches, FunctionMatches, Function, - "Mike Buland", 0, 1 ); + "Mike Buland", 0, 1 ); FunctionMatches::FunctionMatches() { @@ -16,130 +16,130 @@ FunctionMatches::~FunctionMatches() Bu::String FunctionMatches::getName() const { - return "matches"; + return "matches"; } bool FunctionMatches::globcmp( const Bu::String &sTxt, const Bu::String &sMatches ) { - Bu::String::const_iterator t, g; - t = sTxt.begin(); - g = sMatches.begin(); + Bu::String::const_iterator t, g; + t = sTxt.begin(); + g = sMatches.begin(); - while( g && t ) - { - switch( *g ) - { - case '*': - // First, if the * is at the end, then we do match, it doesn't - // matter what is in sTxt - if( !(g+1) ) - return true; - // Now attempt to scan for the remainder as a matched set - { - Bu::String::const_iterator tn = t+1, gn = g+1, gi=g+1; - bool bFoundMatch = false; - while( tn && gn ) - { - if( *gn == '*' ) - { - g = gn; - t = tn; - break; - } - if( *tn == *gn ) - { - g = gn; - t = tn; - tn++; - gn++; - bFoundMatch = true; - } - else - { - gn = gi; - tn++; - bFoundMatch = false; - } - } - if( bFoundMatch == false ) - return false; - if( !tn && !gn && bFoundMatch ) - return true; - } - break; + while( g && t ) + { + switch( *g ) + { + case '*': + // First, if the * is at the end, then we do match, it doesn't + // matter what is in sTxt + if( !(g+1) ) + return true; + // Now attempt to scan for the remainder as a matched set + { + Bu::String::const_iterator tn = t+1, gn = g+1, gi=g+1; + bool bFoundMatch = false; + while( tn && gn ) + { + if( *gn == '*' ) + { + g = gn; + t = tn; + break; + } + if( *tn == *gn ) + { + g = gn; + t = tn; + tn++; + gn++; + bFoundMatch = true; + } + else + { + gn = gi; + tn++; + bFoundMatch = false; + } + } + if( bFoundMatch == false ) + return false; + if( !tn && !gn && bFoundMatch ) + return true; + } + break; - case '?': - // Don't bother checking. - t++; - g++; - break; + case '?': + // Don't bother checking. + t++; + g++; + break; - default: - if( *t != *g ) - return false; - t++; - g++; - break; - } - } - if( t || (g && *g != '*') ) - return false; - return true; + default: + if( *t != *g ) + return false; + t++; + g++; + break; + } + } + if( t || (g && *g != '*') ) + return false; + return true; } bool FunctionMatches::matchlist( const Bu::String &sTxt, VarList &lParams ) { - for( VarList::iterator i = lParams.begin(); i; i++ ) - { - if( (*i).getType() == Variable::typeList ) - { - for( VarList::iterator j = (*i).begin(); j; j++ ) - { - if( globcmp( sTxt, (*j).toString() ) ) - return true; - } - } - else - { - if( globcmp( sTxt, (*i).toString() ) ) - return true; - } - } - return false; + for( VarList::iterator i = lParams.begin(); i; i++ ) + { + if( (*i).getType() == Variable::typeList ) + { + for( VarList::iterator j = (*i).begin(); j; j++ ) + { + if( globcmp( sTxt, (*j).toString() ) ) + return true; + } + } + else + { + if( globcmp( sTxt, (*i).toString() ) ) + return true; + } + } + return false; } Variable FunctionMatches::call( Variable &input, VarList lParams ) { - switch( input.getType() ) - { - case Variable::typeString: - { - Bu::String sTxt = input.getString(); - return Variable( matchlist( sTxt, lParams ) ); - } - break; + switch( input.getType() ) + { + case Variable::typeString: + { + Bu::String sTxt = input.getString(); + return Variable( matchlist( sTxt, lParams ) ); + } + break; - case Variable::typeList: - { - Variable vRet( Variable::typeList ); - for( VarList::iterator i = input.begin(); i; i++ ) - { - if( (*i).getType() != Variable::typeString ) - continue; - Bu::String sTxt = (*i).getString(); - if( matchlist( sTxt, lParams ) ) - vRet.append( *i ); - } - return vRet; - } - break; + case Variable::typeList: + { + Variable vRet( Variable::typeList ); + for( VarList::iterator i = input.begin(); i; i++ ) + { + if( (*i).getType() != Variable::typeString ) + continue; + Bu::String sTxt = (*i).getString(); + if( matchlist( sTxt, lParams ) ) + vRet.append( *i ); + } + return vRet; + } + break; - default: - throw Bu::ExceptionBase("You can only use a string or list as the " - "input to matches."); - break; - } + default: + throw Bu::ExceptionBase("You can only use a string or list as the " + "input to matches."); + break; + } - return Variable(); + return Variable(); } -- cgit v1.2.3