reg_expr.c
1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 3 #include <stdarg.h> 4 #include "common.h" 5 #include "reg_expr.h" 6 7 /**************************************************************************** 8 * compile_reg_expr 9 * 10 * Compile a regular expression. 11 ****************************************************************************/ 12 void compile_reg_expr(int cflags, const char *expr, regex_t *reg) 13 { 14 static const size_t ERROR_BUF_SIZE = 256; 15 char error_msg[ERROR_BUF_SIZE]; 16 int result; 17 18 if ((result = regcomp(reg, expr, cflags)) != 0) { 19 regerror(result, reg, error_msg, ERROR_BUF_SIZE); 20 fprintf(stderr, "%s: %s\n", prog_name, error_msg); 21 exit(1); 22 } 23 }