diff --git a/src/files.c b/src/files.c index 7e8ffdc2c..56978e469 100644 --- a/src/files.c +++ b/src/files.c @@ -2777,8 +2777,11 @@ VA_DECL(const char *, str) Vsprintf(buf, str, VA_ARGS); - if (!config_error_data) + if (!config_error_data) { + pline("%s.", *buf ? buf : "Unknown error"); + wait_synch(); return; + } config_error_data->num_errors++; if (!config_error_data->origline_shown diff --git a/src/options.c b/src/options.c index 827e885ca..6e426982e 100644 --- a/src/options.c +++ b/src/options.c @@ -524,6 +524,7 @@ STATIC_DCL int NDECL(query_msgtype); STATIC_DCL boolean FDECL(msgtype_add, (int, char *)); STATIC_DCL void FDECL(free_one_msgtype, (int)); STATIC_DCL int NDECL(msgtype_count); +STATIC_DCL boolean FDECL(test_regex_pattern, (const char *, const char *)); STATIC_DCL boolean FDECL(add_menu_coloring_parsed, (char *, int, int)); STATIC_DCL void FDECL(free_one_menu_coloring, (int)); STATIC_DCL int NDECL(count_menucolors); @@ -1629,6 +1630,32 @@ char *str; return FALSE; } +STATIC_OVL boolean +test_regex_pattern(str, errmsg) +const char *str; +const char *errmsg; +{ + static const char re_error[] = "Regex error"; + struct nhregex *match; + boolean retval = TRUE; + + if (!str) + return FALSE; + + match = regex_init(); + if (!match) { + config_error_add("NHregex error"); + return FALSE; + } + + if (!regex_compile(str, match)) { + config_error_add("%s: %s", errmsg ? errmsg : re_error, regex_error_desc(match)); + retval = FALSE; + } + regex_free(match); + return retval; +} + boolean add_menu_coloring_parsed(str, c, a) char *str; @@ -4707,6 +4734,7 @@ boolean setinitial, setfromfile; if (*mcbuf == '\033') return TRUE; if (*mcbuf + && test_regex_pattern(mcbuf, (const char *)0) && (mcclr = query_color()) != -1 && (mcattr = query_attr((char *) 0)) != -1 && !add_menu_coloring_parsed(mcbuf, mcclr, mcattr)) {