Tweaking a few things and renaming a variable.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5710 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Benno Schulenberg 2016-03-04 20:50:38 +00:00
parent 8a244c607a
commit 6a4d3aad80
3 changed files with 24 additions and 30 deletions

View File

@ -5,6 +5,8 @@
* src/nano.h: Delete a now-unused struct member. * src/nano.h: Delete a now-unused struct member.
* src/global.c (free_list_item): Elide this now too tiny function. * src/global.c (free_list_item): Elide this now too tiny function.
* scr/global.c (thanks_for_all_the_fish): Rename three variables. * 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> 2016-03-01 Benno Schulenberg <bensberg@justemail.net>
* src/rcfile.c (parse_syntax), src/color.c (color_update): Don't * src/rcfile.c (parse_syntax), src/color.c (color_update): Don't

View File

@ -164,7 +164,7 @@ bool found_in_list(regexlisttype *head, const char *shibboleth)
void color_update(void) void color_update(void)
{ {
syntaxtype *sint; syntaxtype *sint;
colortype *tmpcolor; colortype *ink;
assert(openfile != NULL); assert(openfile != NULL);
@ -291,21 +291,19 @@ void color_update(void)
} }
} }
for (tmpcolor = openfile->colorstrings; tmpcolor != NULL; /* If a syntax was found, compile its specified regexes, which have
tmpcolor = tmpcolor->next) { * already been checked for validity when they were read in. */
/* tmpcolor->start_regex and tmpcolor->end_regex have already for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
* been checked for validity elsewhere. Compile their specified if (ink->start == NULL) {
* regexes if we haven't already. */ ink->start = (regex_t *)nmalloc(sizeof(regex_t));
if (tmpcolor->start == NULL) { regcomp(ink->start, fixbounds(ink->start_regex),
tmpcolor->start = (regex_t *)nmalloc(sizeof(regex_t)); REG_EXTENDED | (ink->icase ? REG_ICASE : 0));
regcomp(tmpcolor->start, fixbounds(tmpcolor->start_regex),
REG_EXTENDED | (tmpcolor->icase ? REG_ICASE : 0));
} }
if (tmpcolor->end_regex != NULL && tmpcolor->end == NULL) { if (ink->end_regex != NULL && ink->end == NULL) {
tmpcolor->end = (regex_t *)nmalloc(sizeof(regex_t)); ink->end = (regex_t *)nmalloc(sizeof(regex_t));
regcomp(tmpcolor->end, fixbounds(tmpcolor->end_regex), regcomp(ink->end, fixbounds(ink->end_regex),
REG_EXTENDED | (tmpcolor->icase ? REG_ICASE : 0)); REG_EXTENDED | (ink->icase ? REG_ICASE : 0));
} }
} }
} }

View File

@ -711,18 +711,16 @@ void parse_colors(char *ptr, bool icase)
continue; continue;
} }
ptr++; fgstr = ++ptr;
fgstr = ptr;
ptr = parse_next_regex(ptr); ptr = parse_next_regex(ptr);
if (ptr == NULL) if (ptr == NULL)
break; break;
newcolor = (colortype *)nmalloc(sizeof(colortype));
/* Save the starting regex string if it's valid, and set up the /* Save the starting regex string if it's valid, and set up the
* color information. */ * color information. */
if (nregcomp(fgstr, icase ? REG_ICASE : 0)) { if (nregcomp(fgstr, icase ? REG_ICASE : 0)) {
newcolor = (colortype *)nmalloc(sizeof(colortype));
newcolor->fg = fg; newcolor->fg = fg;
newcolor->bg = bg; newcolor->bg = bg;
newcolor->bright = bright; newcolor->bright = bright;
@ -747,16 +745,14 @@ void parse_colors(char *ptr, bool icase)
#endif #endif
/* Need to recompute endcolor now so we can extend /* Need to recompute endcolor now so we can extend
* colors to syntaxes. */ * 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->next = newcolor;
} }
endcolor = newcolor; endcolor = newcolor;
} else { } else
free(newcolor);
cancelled = TRUE; cancelled = TRUE;
}
if (expectend) { if (expectend) {
if (ptr == NULL || strncasecmp(ptr, "end=", 4) != 0) { if (ptr == NULL || strncasecmp(ptr, "end=", 4) != 0) {
@ -771,9 +767,7 @@ void parse_colors(char *ptr, bool icase)
continue; continue;
} }
ptr++; fgstr = ++ptr;
fgstr = ptr;
ptr = parse_next_regex(ptr); ptr = parse_next_regex(ptr);
if (ptr == NULL) if (ptr == NULL)
break; break;
@ -783,9 +777,9 @@ void parse_colors(char *ptr, bool icase)
if (cancelled) if (cancelled)
continue; continue;
/* Save the ending regex string if it's valid. */ /* If it's valid, save the ending regex string. */
newcolor->end_regex = (nregcomp(fgstr, icase ? REG_ICASE : if (nregcomp(fgstr, icase ? REG_ICASE : 0))
0)) ? mallocstrcpy(NULL, fgstr) : NULL; newcolor->end_regex = mallocstrcpy(NULL, fgstr);
/* Lame way to skip another static counter. */ /* Lame way to skip another static counter. */
newcolor->id = endsyntax->nmultis; newcolor->id = endsyntax->nmultis;