bryancall commented on code in PR #12574:
URL: https://github.com/apache/trafficserver/pull/12574#discussion_r2449249135


##########
plugins/regex_revalidate/regex_revalidate.cc:
##########
@@ -296,43 +286,46 @@ load_state(plugin_state_t *pstate, invalidate_t **ilist)
 
   time_t const now = time(nullptr);
 
-  const char *errptr;
-  int         erroffset;
-  int         ovector[OVECTOR_SIZE];
-  pcre *const config_re = 
pcre_compile("^([^#].+?)\\s+(\\d+)\\s+(\\d+)\\s+(\\w+)\\s*$", 0, &errptr, 
&erroffset, nullptr);
-  TSReleaseAssert(nullptr != config_re);
+  Regex      config_re;
+  bool const re_stat = 
config_re.compile("^([^#].+?)\\s+(\\d+)\\s+(\\d+)\\s+(\\w+)\\s*$");
+  TSReleaseAssert(true == re_stat);
 
   char line[LINE_MAX];
   int  ln = 0;
   while (fgets(line, LINE_MAX, fs) != nullptr) {
     Dbg(dbg_ctl, "state: processing: %d %s", ln, line);
     ++ln;
-    int const rc = pcre_exec(config_re, nullptr, line, strlen(line), 0, 0, 
ovector, OVECTOR_SIZE);
+
+    RegexMatches matches;
+    int const    rc = config_re.exec(line, matches, 0);
 
     if (5 == rc) {
       invalidate_t *const inv = (invalidate_t *)TSmalloc(sizeof(invalidate_t));
       init_invalidate_t(inv);
 
-      pcre_get_substring(line, ovector, rc, 1, &(inv->regex_text));
-      inv->epoch  = atoi(line + ovector[4]);
-      inv->expiry = atoi(line + ovector[6]);
+      auto const regv = matches[1];
+      inv->regex_text = TSstrndup(regv.data(), regv.length());
+      Dbg(dbg_ctl, "regex_tex: %s", inv->regex_text);

Review Comment:
   Typo, should be regex_text.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to