Am 16.01.2011 um 16:12 schrieb Pavel Sanda:

> Stephan Witt wrote:
>> Am 16.01.2011 um 14:25 schrieb Peter Kümmel:
>> 
>>> The patch complete removes the regex logic in replaceEnvironmentPath because
>>> it seems to be buggy, could someone have a look at it, I think it would be
>>> better to fix the regex code.
>> 
>> The boost regex (as I understand the docs) returns the last match in string.
>> 
>> So we have two problems AFAICS:
>> 1) the last environment var gets replaced only 
>> 2) a missing environment var is passed verbatim
>> E.g. "$UNDEFINED" => "$UNDEFINED", a shell would make "$UNDEFINED" => ""
>> The second problem makes it hard to correct the first.
>> 
>> The attached patch changes (corrects) 2) and fixes 1).
>> The code is much simpler now. If we want to retain 2)
>> I have to make another more complex patch...
> 
> so it depends whether the guys are satisfied with this.

Vincent,

svn blame points to you...
What's your opinion regarding the change in behavior with
undefined variables? Why do you pass the undefined variable
verbatim?

Stephan

> 
>> Index: src/support/filetools.cpp
>> ===================================================================
>> --- src/support/filetools.cpp        (Revision 37216)
>> +++ src/support/filetools.cpp        (Arbeitskopie)
>> @@ -547,23 +547,17 @@
>>      static regex envvar_br_re("(.*)" + envvar_br + "(.*)");
>>      static regex envvar_re("(.*)" + envvar + "(.*)");
>>      smatch what;
>> -    string result;
>> -    string remaining = path;
>> +    string result = path;
>>      while (1) {
>> -            regex_match(remaining, what, envvar_br_re);
>> +            regex_match(result, what, envvar_br_re);
>>              if (!what[0].matched) {
>> -                    regex_match(remaining, what, envvar_re);
>> +                    regex_match(result, what, envvar_re);
>>                      if (!what[0].matched) {
>> -                            result += remaining;
>>                              break;
>>                      }
>>              }
>>              string env_var = getEnv(what.str(2));
>> -            if (!env_var.empty())
>> -                    result += what.str(1) + env_var;
>> -            else
>> -                    result += what.str(1) + "$" + what.str(2);
>> -            remaining = what.str(3);
>> +            result = what.str(1) + env_var + what.str(3);
>>      }
>>      return result;
>> }
> 

Reply via email to