screen when color support is enabled if there's no regex
associated with the current file. Changes to update_color()
(renamed color_update()), thanks_for_all_the_fish(),
- do_input(), and do_output(), (DLR)
+ do_input(), and do_output(). (Brand Huntsman and DLR)
- files.c:
open_file()
- Assert that filename isn't NULL, and don't do anything special
}
}
- /* tmpcolor->startstr and tmpcolor->endstr have already been checked
- * for validity elsewhere. Compile their associated regexes if we
- * haven't already. */
+ /* tmpcolor->start_regex and tmpcolor->end_regex have already been
+ * checked for validity elsewhere. Compile their associated regexes
+ * if we haven't already. */
for (tmpcolor = openfile->colorstrings; tmpcolor != NULL;
tmpcolor = tmpcolor->next) {
- if (tmpcolor->startstr != NULL) {
+ if (tmpcolor->start_regex != NULL) {
tmpcolor->start = (regex_t *)nmalloc(sizeof(regex_t));
- nregcomp(tmpcolor->start, tmpcolor->startstr,
- tmpcolor->icase ? REG_ICASE : 0);
+ regcomp(tmpcolor->start, tmpcolor->start_regex,
+ REG_EXTENDED | (tmpcolor->icase ? REG_ICASE : 0));
}
- if (tmpcolor->endstr != NULL) {
+
+ if (tmpcolor->end_regex != NULL) {
tmpcolor->end = (regex_t *)nmalloc(sizeof(regex_t));
- nregcomp(tmpcolor->end, tmpcolor->endstr,
- tmpcolor->icase ? REG_ICASE : 0);
+ regcomp(tmpcolor->end, tmpcolor->end_regex,
+ REG_EXTENDED | (tmpcolor->icase ? REG_ICASE : 0));
}
}
colortype *bob = syntaxes->color;
syntaxes->color = bob->next;
- if (bob->startstr != NULL)
- free(bob->startstr);
+ if (bob->start_regex != NULL)
+ free(bob->start_regex);
if (bob->start != NULL) {
regfree(bob->start);
free(bob->start);
}
- if (bob->endstr != NULL)
- free(bob->endstr);
+ if (bob->end_regex != NULL)
+ free(bob->end_regex);
if (bob->end != NULL) {
regfree(bob->end);
free(bob->end);
* insensitive? */
int pairnum; /* Color pair number used for this
* foreground/background. */
- char *startstr; /* Start (or all) of the regex
+ char *start_regex; /* Start (or all) of the regex
* string. */
regex_t *start; /* Compiled start (or all) of the regex
* string. */
- char *endstr; /* End (if any) of the regex string. */
+ char *end_regex; /* End (if any) of the regex string. */
regex_t *end; /* Compiled end (if any) of the regex
* string. */
struct colortype *next;
break;
newext = (exttype *)nmalloc(sizeof(exttype));
- if (!nregcomp(&newext->val, fileregptr, REG_NOSUB))
- free(newext);
- else {
+ if (nregcomp(&newext->val, fileregptr, REG_NOSUB)) {
if (endext == NULL)
endsyntax->extensions = newext;
else
endext->next = newext;
endext = newext;
endext->next = NULL;
- }
+ } else
+ free(newext);
}
}
/* Free this regex, now that we know it's valid, and save
* the original string, so that we can recompile this regex
* later as needed. */
- newcolor->startstr = mallocstrcpy(NULL, fgstr);
+ newcolor->start_regex = mallocstrcpy(NULL, fgstr);
regfree(newcolor->start);
free(newcolor->start);
newcolor->start = NULL;
newcolor->bg = bg;
newcolor->bright = bright;
newcolor->icase = icase;
- newcolor->endstr = NULL;
+ newcolor->end_regex = NULL;
newcolor->end = NULL;
newcolor->next = NULL;
/* Free this regex, now that we know it's valid, and
* save the original string, so that we can recompile
* this regex later as needed. */
- newcolor->endstr = mallocstrcpy(NULL, fgstr);
+ newcolor->end_regex = mallocstrcpy(NULL, fgstr);
regfree(newcolor->end);
}