for (ink = sint->color; ink != NULL; ink = ink->next) {
if (ink->start == NULL) {
ink->start = (regex_t *)nmalloc(sizeof(regex_t));
- regcomp(ink->start, fixbounds(ink->start_regex),
- REG_EXTENDED | (ink->icase ? REG_ICASE : 0));
+ regcomp(ink->start, fixbounds(ink->start_regex), ink->rex_flags);
}
if (ink->end_regex != NULL && ink->end == NULL) {
ink->end = (regex_t *)nmalloc(sizeof(regex_t));
- regcomp(ink->end, fixbounds(ink->end_regex),
- REG_EXTENDED | (ink->icase ? REG_ICASE : 0));
+ regcomp(ink->end, fixbounds(ink->end_regex), ink->rex_flags);
}
}
}
char *parse_argument(char *ptr);
#ifndef DISABLE_COLOR
char *parse_next_regex(char *ptr);
-bool nregcomp(const char *regex, int eflags);
void parse_syntax(char *ptr);
void parse_includes(char *ptr);
short color_to_short(const char *colorname, bool *bright);
-void parse_colors(char *ptr, bool icase);
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright);
void grab_and_store(const char *kind, char *ptr, regexlisttype **storage);
#endif
/* Compile the regular expression regex to see if it's valid. Return
* TRUE if it is, and FALSE otherwise. */
-bool nregcomp(const char *regex, int eflags)
+bool nregcomp(const char *regex, int compile_flags)
{
regex_t preg;
const char *r = fixbounds(regex);
- int rc = regcomp(&preg, r, REG_EXTENDED | eflags);
+ int rc = regcomp(&preg, r, compile_flags);
if (rc != 0) {
size_t len = regerror(rc, &preg, NULL, 0);
}
/* Parse the color string in the line at ptr, and add it to the current
- * file's associated colors. If icase is TRUE, treat the color string
- * as case insensitive. */
-void parse_colors(char *ptr, bool icase)
+ * file's associated colors. rex_flags are the regex compilation flags
+ * to use, excluding or including REG_ICASE for case (in)sensitivity. */
+void parse_colors(char *ptr, int rex_flags)
{
short fg, bg;
bool bright = FALSE;
if (ptr == NULL)
break;
- goodstart = nregcomp(fgstr, icase ? REG_ICASE : 0);
+ goodstart = nregcomp(fgstr, rex_flags);
/* If the starting regex is valid, initialize a new color struct,
* and hook it in at the tail of the linked list. */
newcolor->fg = fg;
newcolor->bg = bg;
newcolor->bright = bright;
- newcolor->icase = icase;
+ newcolor->rex_flags = rex_flags;
newcolor->start_regex = mallocstrcpy(NULL, fgstr);
newcolor->start = NULL;
continue;
/* If it's valid, save the ending regex string. */
- if (nregcomp(fgstr, icase ? REG_ICASE : 0))
+ if (nregcomp(fgstr, rex_flags))
newcolor->end_regex = mallocstrcpy(NULL, fgstr);
/* Lame way to skip another static counter. */
return;
/* If the regex string is malformed, skip it. */
- if (!nregcomp(regexstring, REG_NOSUB))
+ if (!nregcomp(regexstring, REG_EXTENDED | REG_NOSUB))
continue;
/* Copy the regex into a struct, and hook this in at the end. */
;
#endif
else if (strcasecmp(keyword, "color") == 0)
- parse_colors(ptr, FALSE);
+ parse_colors(ptr, REG_EXTENDED);
else if (strcasecmp(keyword, "icolor") == 0)
- parse_colors(ptr, TRUE);
+ parse_colors(ptr, REG_EXTENDED | REG_ICASE);
else if (strcasecmp(keyword, "linter") == 0)
pick_up_name("linter", ptr, &live_syntax->linter);
else if (strcasecmp(keyword, "formatter") == 0)