diff options
author | Carl Worth <cworth@cworth.org> | 2009-10-25 10:22:41 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2009-10-25 10:54:49 -0700 |
commit | 7b227a6bf7eb409b4353adc430b2545166e0c4cd (patch) | |
tree | 9b82d6e3bec4596fdbbec6a7c449e00e3e19ad03 /xutil.c | |
parent | 3b8e3ab666a54407f9596a53c66ba8ce623ac91d (diff) |
Add an INTERNAL_ERROR macro and use it for all internal errors.
We were previously just doing fprintf;exit at each point, but I
wanted to add file and line-number details to all messages, so it
makes sense to use a single macro for that.
Diffstat (limited to 'xutil.c')
-rw-r--r-- | xutil.c | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -104,10 +104,8 @@ xregcomp (regex_t *preg, const char *regex, int cflags) char *error = xmalloc (error_size); regerror (rerr, preg, error, error_size); - fprintf (stderr, "Internal error compiling regex %s: %s\n", - regex, error); - free (error); - exit (1); + INTERNAL_ERROR ("compiling regex %s: %s\n", + regex, error); } } @@ -122,11 +120,9 @@ xregexec (const regex_t *preg, const char *string, return rerr; for (i = 0; i < nmatch; i++) { - if (pmatch[i].rm_so == -1) { - fprintf (stderr, "Internal error matching regex against %s: Sub-match %d not found\n", - string, i); - exit (1); - } + if (pmatch[i].rm_so == -1) + INTERNAL_ERROR ("matching regex against %s: Sub-match %d not found\n", + string, i); } return 0; |