[Mesa-stable] [Mesa-dev] [PATCH] swr/rast: non-regex fallback code for gcc < 4.9
Cherniak, Bruce
bruce.cherniak at intel.com
Thu Jul 27 00:31:31 UTC 2017
Reviewed-by: Bruce Cherniak <bruce.cherniak at intel.com>
> On Jul 26, 2017, at 4:38 PM, Tim Rowley <timothy.o.rowley at intel.com> wrote:
>
> gcc prior to 4.9 didn't implement <regex>, causing a startup crash
> in the swr knob parameter reading code.
>
> CC: <mesa-stable at lists.freedesktop.org>
> ---
> .../swr/rasterizer/codegen/templates/gen_knobs.cpp | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.cpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.cpp
> index e109fd2..06b93bd 100644
> --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.cpp
> +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.cpp
> @@ -140,6 +140,26 @@ extern GlobalKnobs g_GlobalKnobs;
> //========================================================
> void KnobBase::autoExpandEnvironmentVariables(std::string &text)
> {
> +#if (__GNUC__) && (GCC_VERSION < 409000)
> + // <regex> isn't implemented prior to gcc-4.9.0
> + // unix style variable replacement
> + size_t start;
> + while ((start = text.find("${'${'}")) != std::string::npos) {
> + size_t end = text.find("}");
> + if (end == std::string::npos)
> + break;
> + const std::string var = GetEnv(text.substr(start + 2, end - start - 2));
> + text.replace(start, end - start + 1, var);
> + }
> + // win32 style variable replacement
> + while ((start = text.find("%")) != std::string::npos) {
> + size_t end = text.find("%", start + 1);
> + if (end == std::string::npos)
> + break;
> + const std::string var = GetEnv(text.substr(start + 1, end - start - 1));
> + text.replace(start, end - start + 1, var);
> + }
> +#else
> {
> // unix style variable replacement
> static std::regex env("\\$\\{([^}]+)\\}");
> @@ -164,6 +184,7 @@ void KnobBase::autoExpandEnvironmentVariables(std::string &text)
> text.replace(match.prefix().length(), match[0].length(), var);
> }
> }
> +#endif
> }
>
>
> --
> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-stable
mailing list