]> granicus.if.org Git - re2c/commitdiff
Don't hang forever trying to replace empty configuration arguments.
authorUlya Trofimovich <skvadrik@gmail.com>
Sun, 27 Sep 2015 11:03:03 +0000 (12:03 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Sun, 27 Sep 2015 11:03:03 +0000 (12:03 +0100)
re2c/src/codegen/emit.h

index 854edaab5463a065a57509a1854c8f78bc0700db..f3b4cff188d7cfb0444fb9dc21862fc2e7d30ac6 100644 (file)
@@ -25,12 +25,15 @@ void genGoTo (OutputFile & o, uint32_t ind, const State * from, const State * to
 
 template<typename _Ty> std::string replaceParam (std::string str, const std::string & param, const _Ty & value)
 {
-       std::ostringstream strValue;
-       strValue << value;
-       std::string::size_type pos;
-       while((pos = str.find(param)) != std::string::npos)
+       if (!param.empty ())
        {
-               str.replace(pos, param.length(), strValue.str());
+               std::ostringstream strValue;
+               strValue << value;
+               std::string::size_type pos;
+               while((pos = str.find(param)) != std::string::npos)
+               {
+                       str.replace(pos, param.length(), strValue.str());
+               }
        }
        return str;
 }