This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] Fix empty grouping problem in regex


On Mon, Aug 19, 2013 at 06:07:10PM +0800, Tim Shen wrote:
> Before this patch, it causes the executor into infinite loop.
>
> Tested under x86_64. I'll test -m32 and check-debug before committing.

@@ -2371,8 +2372,10 @@
       if (__re._M_automaton == nullptr)
         return false;
       for (auto __cur = __first; __cur != __last; ++__cur) // Any KMP-like algo?
-        if (__detail::__get_executor(__cur, __last, __m, __re, __flags)
-              ->_M_search_from_first())
+        {
+          __detail::__get_executor(__cur, __last, __m, __re, __flags)
+            ->_M_search_from_first();
+          if (__m.size() > 0 && __m[0].matched)
           {
             for (auto __it : __m)
               if (!__it.matched)
@@ -2387,6 +2390,7 @@
               (__m.suffix().first != __m.suffix().second);
             return true;
           }

Doesn't everything in between the last added line above and the first added
line below need reindenting by 2 spaces (plus of course transforming any 8
consecutive spaces into tabs)?

+        }
       return false;
     }

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]