+#ifdef HAVE_RE_SEARCH
+
+// On GNU, regexec is implemented as a wrapper around re_search. re_search
+// requires a length parameter which the POSIX regexec does not have,
+// therefore regexec must do a strlen on the search text each time it is
+// called. This can drastically affect performance when matching is done in
+// a loop along a string, such as during a search and replace. Therefore if
+// re_search is detected by configure, it is used directly.
+//
+static int ReSearch(const regex_t *preg,
+ const char *text,
+ size_t len,
+ re_registers *matches,
+ int eflags)
+{
+ regex_t *pattern = wx_const_cast(regex_t*, preg);
+
+ pattern->not_bol = (eflags & REG_NOTBOL) != 0;
+ pattern->not_eol = (eflags & REG_NOTEOL) != 0;
+ pattern->regs_allocated = REGS_FIXED;
+
+ int ret = re_search(pattern, text, len, 0, len, matches);
+ return ret >= 0 ? 0 : REG_NOMATCH;
+}
+
+#endif // HAVE_RE_SEARCH
+
+bool wxRegExImpl::Matches(const wxRegChar *str,
+ int flags
+ WXREGEX_IF_NEED_LEN(size_t len)) const