gallium/swr: simplify environmental variabled expansion code
authorKrzysztof Raszkowski <krzysztof.raszkowski@intel.com>
Mon, 10 Feb 2020 15:24:10 +0000 (16:24 +0100)
committerKrzysztof Raszkowski <krzysztof.raszkowski@intel.com>
Mon, 10 Feb 2020 16:10:47 +0000 (17:10 +0100)
There were 2 versions of code doing the same thing.
Since std::regexp are locale-sensitive better is to leave old
good way to do this.

Reviewed-by: Jan Zielinski <jan.zielinski@intel.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3761>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3761>

src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.cpp

index b073f73e3a0169a378ecabd5008b28825a8391c6..194499aa1e0f0d6ae996bf8c92657cd41afb7131 100644 (file)
@@ -43,9 +43,6 @@
 //========================================================
 void KnobBase::autoExpandEnvironmentVariables(std::string& text)
 {
-#if (__GNUC__) && (GCC_VERSION < 40900)
-    // <regex> isn't implemented prior to gcc-4.9.0
-    // unix style variable replacement
     size_t start;
     while ((start = text.find("${'${'}")) != std::string::npos)
     {
@@ -64,32 +61,6 @@ void KnobBase::autoExpandEnvironmentVariables(std::string& text)
         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("\\$\\{([^}]+?)\\}");
-        std::smatch       match;
-        while (std::regex_search(text, match, env))
-        {
-            const std::string var = GetEnv(match[1].str());
-            // certain combinations of gcc/libstd++ have problems with this
-            // text.replace(match[0].first, match[0].second, var);
-            text.replace(match.prefix().length(), match[0].length(), var);
-        }
-    }
-    {
-        // win32 style variable replacement
-        static std::regex env("%([^%]+?)%");
-        std::smatch       match;
-        while (std::regex_search(text, match, env))
-        {
-            const std::string var = GetEnv(match[1].str());
-            // certain combinations of gcc/libstd++ have problems with this
-            // text.replace(match[0].first, match[0].second, var);
-            text.replace(match.prefix().length(), match[0].length(), var);
-        }
-    }
-#endif
 }
 
 //========================================================