swr/rast: adjust std::string usage to fix build
authorTim Rowley <timothy.o.rowley@intel.com>
Mon, 26 Jun 2017 13:57:38 +0000 (08:57 -0500)
committerTim Rowley <timothy.o.rowley@intel.com>
Mon, 26 Jun 2017 16:29:27 +0000 (11:29 -0500)
Some combinations of c++ compilers and standard libraries had problems
with the string::replace code we were using previously.

This should fix the travis-ci system.

Tested-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/codegen/templates/gen_knobs.cpp

index 0527bf3b31042437210d414d43c5ad1c67da0af5..e109fd26597511d4a86cc39f626340c32d315031 100644 (file)
@@ -141,21 +141,27 @@ extern GlobalKnobs g_GlobalKnobs;
 void KnobBase::autoExpandEnvironmentVariables(std::string &text)
 {
     {
+        // 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());
-            text.replace(match[0].first, match[0].second, var);
+            // 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());
-            text.replace(match[0].first, match[0].second, var);
+            // 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);
         }
     }
 }
@@ -232,4 +238,4 @@ std::string GlobalKnobs::ToString(const char* optPerLinePrefix)
         return ' '*(max_len - name_len)
 
 
-%>
\ No newline at end of file
+%>