aboutsummaryrefslogtreecommitdiffhomepage
path: root/mimedb.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2007-05-16 05:37:51 +1000
committerGravatar axel <axel@liljencrantz.se>2007-05-16 05:37:51 +1000
commitc1b4fa847f626b3e4fc2b2393dfba1e1c1f446c3 (patch)
treed4e8c40678278a65406bbdec080b7aa9a2292c97 /mimedb.c
parenta6644631d9326bb00bd9631fccef7bae9f5f8547 (diff)
Improved error reporting in mimedb for failed regexps. This patch was written by Claes Nästén.
darcs-hash:20070515193751-ac50b-8221971ea524cddaba3e8e72a61b151b399ea7b6.gz
Diffstat (limited to 'mimedb.c')
-rw-r--r--mimedb.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/mimedb.c b/mimedb.c
index 7add90db..9b15a9c6 100644
--- a/mimedb.c
+++ b/mimedb.c
@@ -418,7 +418,7 @@ static char *get_lang_re()
const char *lang = setlocale( LC_MESSAGES, 0 );
int close=0;
char *out=buff;
-
+
if( (1+strlen(lang)*4) >= BUFF_SIZE )
{
fprintf( stderr, _( "%s: Locale string too long\n"), MIMEDB );
@@ -450,6 +450,7 @@ static char *get_lang_re()
if( close )
*out++ = ')';
*out++=0;
+
return buff;
}
@@ -480,18 +481,32 @@ static char *get_description( const char *mimetype )
start_re = my_malloc( sizeof(regex_t));
stop_re = my_malloc( sizeof(regex_t));
- if( regcomp( start_re, buff, REG_EXTENDED ) ||
- regcomp( stop_re, STOP_TAG, REG_EXTENDED ) )
+ int reg_status;
+ if( ( reg_status = regcomp( start_re, buff, REG_EXTENDED ) ) )
+ {
+ char regerrbuf[BUFF_SIZE];
+ regerror(reg_status, start_re, regerrbuf, BUFF_SIZE);
+ fprintf( stderr, _( "%s: Could not compile regular expressions %s with error %s\n"), MIMEDB, buff, regerrbuf);
+ error=1;
+
+ }
+ else if ( ( reg_status = regcomp( stop_re, STOP_TAG, REG_EXTENDED ) ) )
{
- fprintf( stderr, _( "%s: Could not compile regular expressions\n"), MIMEDB );
+ char regerrbuf[BUFF_SIZE];
+ regerror(reg_status, stop_re, regerrbuf, BUFF_SIZE);
+ fprintf( stderr, _( "%s: Could not compile regular expressions %s with error %s\n"), MIMEDB, buff, regerrbuf);
error=1;
+
+ }
+ if( error )
+ {
free( start_re );
free( stop_re );
start_re = stop_re = 0;
return 0;
- }
+ }
}
fn_part = my_malloc( strlen(MIME_DIR) + strlen( mimetype) + strlen(MIME_SUFFIX) + 1 );