Stephan Witt wrote:
> Am 16.01.2011 um 14:25 schrieb Peter Kümmel:
> 
> > On 15.01.2011 20:31, Joost Verburg wrote:
> >> On 1/14/2011 11:23 PM, Pavel Sanda wrote:
> >>> unless somebody is going to make detail review, this is too late for 2.0.
> >>> it can bring regressions since the code touches common routine...
> >> 
> >> Some time ago I mentioned this exact same issue on the devel list. It
> >> would make the development of a Windows installer a lot easier if it
> >> could be fixed in 2.0. If you can find some time to review this patch
> >> I'd really appreciate that.
> > 
> > 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.
pavel

> 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