Fix enviroment variables substitution. (Bugreport from Yaroslav Tchayckovsky 2:5076/14)

This commit is contained in:
Stas Degteff 2005-12-07 18:25:05 +00:00
parent 17d4da66ed
commit 8c8b42afc4

View File

@ -77,7 +77,7 @@ int strschg_environ(std::string& s) {
size_t posn, posn1; size_t posn, posn1;
while(((posn=s.find('%')) != s.npos) and ((posn1=s.find('%', posn+1)) != s.npos)) { while(((posn=s.find('%')) != s.npos) and ((posn1=s.find('%', posn+1)) != s.npos)) {
fnd = s.substr(posn+1, posn1-1); fnd = s.substr(posn+1, posn1-1-posn);
const char* rep = getenv(fnd.c_str()); const char* rep = getenv(fnd.c_str());
rep = rep ? rep : ""; rep = rep ? rep : "";
s.replace(posn, posn1-posn+1, rep); s.replace(posn, posn1-posn+1, rep);