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
master
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/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

View File

@ -164,7 +164,7 @@ bool found_in_list(regexlisttype *head, const char *shibboleth)
void color_update(void)
{
syntaxtype *sint;
colortype *tmpcolor;
colortype *ink;
assert(openfile != NULL);
@ -291,21 +291,19 @@ void color_update(void)
}
}
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));
}
}
}

View File

@ -711,18 +711,16 @@ void parse_colors(char *ptr, bool icase)
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;
@ -747,16 +745,14 @@ void parse_colors(char *ptr, bool icase)
#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) {
@ -771,9 +767,7 @@ void parse_colors(char *ptr, bool icase)
continue;
}
ptr++;
fgstr = ptr;
fgstr = ++ptr;
ptr = parse_next_regex(ptr);
if (ptr == NULL)
break;
@ -783,9 +777,9 @@ void parse_colors(char *ptr, bool icase)
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;