mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-22 09:24:54 +01:00
xregcomp: don't consider every regex compilation failure an internal error.
This pushes the error handling up one step, but makes the function more flexible. Running out of memory still triggers an internal error, in the spirit of other xutils functions.
This commit is contained in:
parent
1dedfc90f6
commit
7a87830f5e
3 changed files with 11 additions and 6 deletions
|
@ -88,9 +88,10 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
|
|||
* non-space characters for the message-id, then one or more
|
||||
* spaces, then a list of space-separated tags as a sequence of
|
||||
* characters within literal '(' and ')'. */
|
||||
xregcomp (®ex,
|
||||
"^([^ ]+) \\(([^)]*)\\)$",
|
||||
REG_EXTENDED);
|
||||
if ( xregcomp (®ex,
|
||||
"^([^ ]+) \\(([^)]*)\\)$",
|
||||
REG_EXTENDED) )
|
||||
INTERNAL_ERROR("compile time constant regex failed.");
|
||||
|
||||
while ((line_len = getline (&line, &line_size, input)) != -1) {
|
||||
regmatch_t match[3];
|
||||
|
|
|
@ -99,7 +99,7 @@ xstrndup (const char *s, size_t n)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
xregcomp (regex_t *preg, const char *regex, int cflags)
|
||||
{
|
||||
int rerr;
|
||||
|
@ -110,9 +110,12 @@ xregcomp (regex_t *preg, const char *regex, int cflags)
|
|||
char *error = xmalloc (error_size);
|
||||
|
||||
regerror (rerr, preg, error, error_size);
|
||||
INTERNAL_ERROR ("compiling regex %s: %s\n",
|
||||
fprintf (stderr, "compiling regex %s: %s\n",
|
||||
regex, error);
|
||||
free (error);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -43,7 +43,8 @@ xstrdup (const char *s);
|
|||
char *
|
||||
xstrndup (const char *s, size_t n);
|
||||
|
||||
void
|
||||
/* Returns 0 for successful compilation, 1 otherwise */
|
||||
int
|
||||
xregcomp (regex_t *preg, const char *regex, int cflags);
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in a new issue