- std::map<char,char> brackets;
- brackets.insert(std::pair<char,char>('\'','\''));
- brackets.insert(std::pair<char,char>('"','"'));
- brackets.insert(std::pair<char,char>('`','`'));
- brackets.insert(std::pair<char,char>('(',')'));
- brackets.insert(std::pair<char,char>('{','}'));
- brackets.insert(std::pair<char,char>('[',']'));
- brackets.insert(std::pair<char,char>('<','>'));
-
- unsigned int idx=str.find(' ');
- std::string path = str.substr(0, idx != std::string::npos ? idx : slen );
-// eDebug("path = %s", path.c_str() );
- unsigned int plen = path.length();
-
- std::string cmds = slen > plen ? str.substr( plen+1 ) : "";
- unsigned int clen = cmds.length();
-// eDebug("cmds = %s", cmds.c_str() );
-
- idx = 0;
- std::map<char,char>::iterator it = brackets.find(cmds[idx]);
- while ( (idx = cmds.find(' ',idx) ) != std::string::npos ) // count args
- {
- if (it != brackets.end())
- {
- if (cmds[idx-1] == it->second)
- it = brackets.end();
- }
- if (it == brackets.end())
- {
- cnt++;
- it = brackets.find(cmds[idx+1]);
- }
- idx++;
- }