/* Regular expression to match, if any. COMPILED is only valid when
REGEX is non-NULL. */
char *regex;
- regex_t compiled;
+ std::unique_ptr<compiled_regex> compiled;
};
solib_catchpoint::~solib_catchpoint ()
{
- if (this->regex)
- regfree (&this->compiled);
xfree (this->regex);
}
++ix)
{
if (!self->regex
- || regexec (&self->compiled, iter->so_name, 0, NULL, 0) == 0)
+ || self->compiled->exec (iter->so_name, 0, NULL, 0) == 0)
return;
}
}
++ix)
{
if (!self->regex
- || regexec (&self->compiled, iter, 0, NULL, 0) == 0)
+ || self->compiled->exec (iter, 0, NULL, 0) == 0)
return;
}
}
if (*arg != '\0')
{
- int errcode;
-
- errcode = regcomp (&c->compiled, arg, REG_NOSUB);
- if (errcode != 0)
- {
- char *err = get_regcomp_error (errcode, &c->compiled);
-
- make_cleanup (xfree, err);
- error (_("Invalid regexp (%s): %s"), err, arg);
- }
+ c->compiled.reset (new compiled_regex (arg, REG_NOSUB,
+ _("Invalid regexp")));
c->regex = xstrdup (arg);
}