-struct ovsdb_error *
-ovsdb_base_type_set_regex(struct ovsdb_base_type *base,
- const char *reMatch, const char *reComment)
-{
-#ifdef HAVE_PCRE
- const char *errorString;
- const char *pattern;
- int errorOffset;
-
- /* Compile pattern, anchoring it at both ends. */
- pattern = reMatch;
- if (pattern[0] == '\0' || strchr(pattern, '\0')[-1] != '$') {
- pattern = xasprintf("%s$", pattern);
- }
-
-#ifndef PCRE_JAVASCRIPT_COMPAT /* Added in PCRE 7.7. */
-#define PCRE_JAVASCRIPT_COMPAT 0
-#endif
- base->u.string.re = pcre_compile(pattern, (PCRE_ANCHORED | PCRE_UTF8
- | PCRE_JAVASCRIPT_COMPAT),
- &errorString, &errorOffset, NULL);
- if (pattern != reMatch) {
- free((char *) pattern);
- }
- if (!base->u.string.re) {
- return ovsdb_syntax_error(NULL, "invalid regular expression",
- "\"%s\" is not a valid regular "
- "expression: %s", reMatch, errorString);
- }
- pcre_refcount(base->u.string.re, 1);
-#endif
-
- /* Save regular expression. */
- base->u.string.reMatch = xstrdup(reMatch);
- base->u.string.reComment = reComment ? xstrdup(reComment) : NULL;
- return NULL;
-}
-