From 00e856c9310a219d8df2126d9598f75d0fa3fc6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=BF=97=E6=B6=9B?= Date: Sun, 16 Oct 2022 08:22:51 +0000 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BA=86=E5=8E=9F=E6=9C=AC?= =?UTF-8?q?=E7=9A=84goto=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘志涛 --- re2/re2.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/re2/re2.cc b/re2/re2.cc index 3285dc0..2ec283d 100644 --- a/re2/re2.cc +++ b/re2/re2.cc @@ -760,6 +760,7 @@ namespace re2 { std::string strs = haystack + '\n'; size_t pos = strs.find('\n'); + bool flag = false; while(pos != strs.npos) { std::string temp = strs.substr(0, pos); @@ -770,12 +771,13 @@ namespace re2 if(matched && nsubmatch){ haystack = temp; length = strlen(haystack.c_str()); - goto L1; + flag = true; + break; } strs = strs.substr(pos + 1, length + 1); pos = strs.find('\n'); } - return false; + if(!flag){return false;} } // bool matched = rure_find(re, (const uint8_t *)haystack, strlen(haystack), 0, &match); // 这里没有 if(re_anchor == ANCHOR_START)原因是因为: @@ -819,7 +821,6 @@ namespace re2 } // Demo 获取捕获组内容,存储到submatch数组中 - L1: rure_captures *caps = rure_captures_new(re); rure_find_captures(re, (const uint8_t *)haystack.c_str(), length, 0, caps); -- Gitee