* src/nano.h: Delete a now-unused struct member.
* src/global.c (free_list_item): Elide this now too tiny function.
* scr/global.c (thanks_for_all_the_fish): Rename three variables.
+ * src/rcfile.c (parse_colors): Tweak a few things.
+ * src/color.c (color_update): Rename a variable.
2016-03-01 Benno Schulenberg <bensberg@justemail.net>
* src/rcfile.c (parse_syntax), src/color.c (color_update): Don't
void color_update(void)
{
syntaxtype *sint;
- colortype *tmpcolor;
+ colortype *ink;
assert(openfile != NULL);
}
}
- for (tmpcolor = openfile->colorstrings; tmpcolor != NULL;
- tmpcolor = tmpcolor->next) {
- /* tmpcolor->start_regex and tmpcolor->end_regex have already
- * been checked for validity elsewhere. Compile their specified
- * regexes if we haven't already. */
- if (tmpcolor->start == NULL) {
- tmpcolor->start = (regex_t *)nmalloc(sizeof(regex_t));
- regcomp(tmpcolor->start, fixbounds(tmpcolor->start_regex),
- REG_EXTENDED | (tmpcolor->icase ? REG_ICASE : 0));
+ /* If a syntax was found, compile its specified regexes, which have
+ * already been checked for validity when they were read in. */
+ for (ink = openfile->colorstrings; 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));
}
- if (tmpcolor->end_regex != NULL && tmpcolor->end == NULL) {
- tmpcolor->end = (regex_t *)nmalloc(sizeof(regex_t));
- regcomp(tmpcolor->end, fixbounds(tmpcolor->end_regex),
- REG_EXTENDED | (tmpcolor->icase ? REG_ICASE : 0));
+ 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));
}
}
}
continue;
}
- ptr++;
-
- fgstr = ptr;
+ fgstr = ++ptr;
ptr = parse_next_regex(ptr);
if (ptr == NULL)
break;
- newcolor = (colortype *)nmalloc(sizeof(colortype));
-
/* Save the starting regex string if it's valid, and set up the
* color information. */
if (nregcomp(fgstr, icase ? REG_ICASE : 0)) {
+ newcolor = (colortype *)nmalloc(sizeof(colortype));
+
newcolor->fg = fg;
newcolor->bg = bg;
newcolor->bright = bright;
#endif
/* Need to recompute endcolor now so we can extend
* colors to syntaxes. */
- for (endcolor = endsyntax->color; endcolor->next != NULL; endcolor = endcolor->next)
- ;
+ for (endcolor = endsyntax->color; endcolor->next != NULL;)
+ endcolor = endcolor->next;
endcolor->next = newcolor;
}
endcolor = newcolor;
- } else {
- free(newcolor);
+ } else
cancelled = TRUE;
- }
if (expectend) {
if (ptr == NULL || strncasecmp(ptr, "end=", 4) != 0) {
continue;
}
- ptr++;
-
- fgstr = ptr;
+ fgstr = ++ptr;
ptr = parse_next_regex(ptr);
if (ptr == NULL)
break;
if (cancelled)
continue;
- /* Save the ending regex string if it's valid. */
- newcolor->end_regex = (nregcomp(fgstr, icase ? REG_ICASE :
- 0)) ? mallocstrcpy(NULL, fgstr) : NULL;
+ /* If it's valid, save the ending regex string. */
+ if (nregcomp(fgstr, icase ? REG_ICASE : 0))
+ newcolor->end_regex = mallocstrcpy(NULL, fgstr);
/* Lame way to skip another static counter. */
newcolor->id = endsyntax->nmultis;