Using regex_t regex_blank_line is *slow*.
static bool is_blank_line (const char *str)
{
- return (regexec (®ex_blank_line, str, 0, NULL, 0) == 0);
+ while (isspace(*str))
+ str++;
+ return (*str == '\0');
}
/** Adjust the line numbers in the #line directives of the generated scanner.
* From "regex.c"
*/
-extern regex_t regex_linedir, regex_blank_line;
+extern regex_t regex_linedir;
bool flex_init_regex(void);
void flex_regcomp(regex_t *preg, const char *regex, int cflags);
char *regmatch_dup (regmatch_t * m, const char *src);
static const char* REGEXP_LINEDIR = "^#line ([[:digit:]]+) \"(.*)\"";
-static const char* REGEXP_BLANK_LINE = "^[[:space:]]*$";
regex_t regex_linedir; /**< matches line directives */
-regex_t regex_blank_line; /**< matches blank lines */
/** Initialize the regular expressions.
bool flex_init_regex(void)
{
flex_regcomp(®ex_linedir, REGEXP_LINEDIR, REG_EXTENDED);
- flex_regcomp(®ex_blank_line, REGEXP_BLANK_LINE, REG_EXTENDED);
-
return true;
}