Showing the changes to src/core/util_string.cpp (1 of 1 file). Show all
Unified · Split
| @@ -502,15 +502,16 @@ std::string expandFilePathWindows( const string & path ) · 501 unmodified lines | |||
| 502 | { | 502 | { |
| 503 | // expansion | 503 | // expansion |
| 504 | string exp; | 504 | string exp; |
| 505 | |||
| 506 | // tokens | 505 | // tokens |
| 507 | vector<string> tokens; | 506 | vector<string> tokens; |
| 507 | |||
| 508 | // trim of white spaces | ||
| 509 | string thePath = trim( path ); | ||
| 510 | |||
| 508 | // tokenize | 511 | // tokenize |
| 509 | tokenize( path, tokens, "%" ); | 512 | tokenize( thePath, tokens, "%" ); |
| 510 | // every other one is an environment variable | 513 | // every other one is an environment variable |
| 511 | // HACK: this assumes 1) path does not begin with an env-var | 514 | t_CKBOOL expand = (thePath.length() && thePath[0] == '%'); |
| 512 | // and 2) path does not contain immediately consecutive env-vars | ||
| 513 | t_CKBOOL expand = FALSE; | ||
| 514 | // loop | 515 | // loop |
| 515 | for( t_CKINT i = 0; i < tokens.size(); i++ ) | 516 | for( t_CKINT i = 0; i < tokens.size(); i++ ) |
| 516 | { | 517 | { |
| @@ -520,9 +521,11 @@ std::string expandFilePathWindows( const string & path ) · 3 unmodified lines | |||
| 520 | { | 521 | { |
| 521 | // get environment variable | 522 | // get environment variable |
| 522 | char * v = getenv( tokens[i].c_str() ); | 523 | char * v = getenv( tokens[i].c_str() ); |
| 524 | // if got something back | ||
| 523 | if( v ) exp += v; | 525 | if( v ) exp += v; |
| 524 | else | 526 | else |
| 525 | { | 527 | { |
| 528 | // error message | ||
| 526 | EM_log( CK_LOG_SYSTEM, "ERROR expanding %%%s%% in path...", tokens[i].c_str() ); | 529 | EM_log( CK_LOG_SYSTEM, "ERROR expanding %%%s%% in path...", tokens[i].c_str() ); |
| 527 | // reset | 530 | // reset |
| 528 | exp = ""; | 531 | exp = ""; |
| @@ -530,12 +533,12 @@ std::string expandFilePathWindows( const string & path ) · 1 unmodified line | |||
| 530 | break; | 533 | break; |
| 531 | } | 534 | } |
| 532 | } | 535 | } |
| 533 | // flip | 536 | // flip | HACK: path does not contain immediately consecutive env-vars |
| 534 | expand = !expand; | 537 | expand = !expand; |
| 535 | } | 538 | } |
| 536 | 539 | ||
| 537 | // if exp still empty, no change | 540 | // if exp still empty, no change |
| 538 | if( exp == "" ) exp = path; | 541 | if( exp == "" ) exp = thePath; |
| 539 | 542 | ||
| 540 | // done | 543 | // done |
| 541 | return exp; | 544 | return exp; |
| @@ -922,7 +925,7 @@ void tokenize( const std::string & str, std::vector<string> & tokens, const std: · 380 unmodified lines | |||
| 922 | // substr len | 925 | // substr len |
| 923 | t_CKINT slen = i-start; | 926 | t_CKINT slen = i-start; |
| 924 | // check | 927 | // check |
| 925 | if( len > 0 ) | 928 | if( slen > 0 ) |
| 926 | { | 929 | { |
| 927 | // push back the substr | 930 | // push back the substr |
| 928 | tokens.push_back( str.substr( start, slen ) ); | 931 | tokens.push_back( str.substr( start, slen ) ); |
| @@ -935,7 +938,7 @@ void tokenize( const std::string & str, std::vector<string> & tokens, const std: · 6 unmodified lines | |||
| 935 | // get the remainder | 938 | // get the remainder |
| 936 | t_CKINT slen = len-start; | 939 | t_CKINT slen = len-start; |
| 937 | // check | 940 | // check |
| 938 | if( len > 0 ) | 941 | if( slen > 0 ) |
| 939 | { | 942 | { |
| 940 | // push back the substr | 943 | // push back the substr |
| 941 | tokens.push_back( str.substr( start, slen ) ); | 944 | tokens.push_back( str.substr( start, slen ) ); |