- if(openParen != -1 && closeParen != -1){
- commandString = input.substr(0, openParen); //commandString contains everything before "("
+ if(openParen != -1 && closeParen != -1){
+ //gobble extra spaces
+ int spot = 0;
+ for (int i = 0; i < input.length(); i++) { if (!(isspace(input[i]))) { spot = i; break; } }
+ if (spot > openParen) { spot = 0; }
+ commandString = input.substr(spot, openParen-spot); //commandString contains everything before "("