if (v.substr(v.size() - s.size()) == s){
if (s.size() < v.size() && v.substr(v.size() - s.size()) == s){
string substVars(string & in){  string out = "";  string var;  int i = 0;  char vname[MAX_STRING];  char suff[MAX_STRING];  int noscan;  while (i < in.length()){    if (in[i] != '$')      out += in[i];    else {      if (in[i + 1] == '('){	i += 2;	var = "";	while (i < in.length() && in[i] != ')'){	  if (in[i] == '\\' )	    i++;	  var += in[i++];	}	if (var.find_first_not_of("0123456789") == var.npos){	  // string is a number	  int n = strtol(var.c_str(), NULL, 10);	  if (n >= cmdLnVars.size()){	    cerr << "Cannot find command line parameter " << n << endl;	    if (logFile.is_open())	      logFile << timeStr() << "Cannot find command line parameter " 		      << n << endl;	    finish(1);	  }	  out += cmdLnVars[n];	} else if (sscanf(var.c_str(), "%s %n", vname, &noscan) == 1 && string(vname) == "shell") { // shell command	  string v = var.substr(noscan);	  out += doCommandStr(v);	} else if (sscanf(var.c_str(), "strip %s %s", suff, vname) == 2){	  if (variables.find(string(vname)) == variables.end()){	    cerr << "Cannot substitute variable " << var << endl;	    if (logFile.is_open())	      logFile << timeStr() << "Cannot substitute variable " 		      << var << endl;	    finish(1);	  }	  string v = variables[string(vname)];	  string s = string(suff);	  if (v.substr(v.size() - s.size()) == s){ // if suffix in string	    v = v.substr(0, v.size() - s.size());	  }	  out += v;	} else {	  if (variables.find(var) == variables.end()){	    cerr << "Cannot substitute variable " << var << endl;	    if (logFile.is_open())	      logFile << timeStr() << "Cannot substitute variable " 		      << var << endl;	    finish(1);	  }	  out += variables[var];	}      } else { // if not a $() string	out += in[i];      }    }    i++;  }  return out;} // substVars