--- sandy.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sandy.c b/sandy.c index 5e519b7..05851a5 100644 --- a/sandy.c +++ b/sandy.c _AT_@ -276,6 +276,16 @@ static regex_t *cmd_res[LENGTH(cmds)]; static regex_t *syntax_file_res[LENGTH(syntaxes)]; static regex_t *syntax_res[LENGTH(syntaxes)][SYN_COLORS]; +static int +xregcomp(regex_t *p_re, const char *s, int flags) { + int c=regcomp(p_re, s, flags); + if(c != 0) { + uint8_t msg[4096]; + regerror(c, p_re, msg, 4096); + i_die(msg); + } +} + /* F_* FUNCTIONS Can be linked to an action or keybinding. Always return void and take const Arg* */ _AT_@ -485,7 +495,7 @@ f_syntax(const Arg *arg) { : !regexec(syntax_file_res[i], filename, 1, NULL, 0)) { for(j=0; j<SYN_COLORS; j++) { if((syntx >= 0) && syntax_res[syntx][j]) regfree(syntax_res[syntx][j]); - if(syntaxes[i].re_text[j] && regcomp(syntax_res[i][j], syntaxes[i].re_text[j], REG_EXTENDED|REG_NEWLINE)) i_die("Faulty regex.\n"); + xregcomp(syntax_res[i][j], syntaxes[i].re_text[j], REG_EXTENDED|REG_NEWLINE); } syntx=i; setenv(envs[EnvSyntax], syntaxes[syntx].name, 1); _AT_@ -1182,12 +1192,12 @@ i_setup(void){ for(i=0; i<LENGTH(cmds); i++) { if((cmd_res[i]=(regex_t*)calloc(1, sizeof (regex_t))) == NULL) i_die("Can't malloc.\n"); - if(regcomp(cmd_res[i], cmds[i].re_text, REG_EXTENDED|REG_ICASE|REG_NEWLINE)) i_die("Faulty regex.\n"); + xregcomp(cmd_res[i], cmds[i].re_text, REG_EXTENDED|REG_ICASE|REG_NEWLINE); } for(i=0; i<LENGTH(syntaxes); i++) { if((syntax_file_res[i]=(regex_t*)calloc(1, sizeof (regex_t))) == NULL) i_die("Can't malloc.\n"); - if(regcomp(syntax_file_res[i], syntaxes[i].file_re_text, REG_EXTENDED|REG_NOSUB|REG_ICASE|REG_NEWLINE)) i_die("Faulty regex.\n"); + xregcomp(syntax_file_res[i], syntaxes[i].file_re_text, REG_EXTENDED|REG_NOSUB|REG_ICASE|REG_NEWLINE); for(j=0; j<SYN_COLORS; j++) if((syntax_res[i][j]=(regex_t*)calloc(1, sizeof (regex_t))) == NULL) i_die("Can't malloc.\n"); } -- 2.0.0Received on Mon Sep 17 2001 - 00:00:00 CEST
This archive was generated by hypermail 2.3.0 : Mon Jun 30 2014 - 08:00:05 CEST