Renaming a variable for conciseness.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5687 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2016-02-26 17:11:35 +00:00
parent 4d53694a27
commit e74a4c26c0
2 changed files with 22 additions and 28 deletions

View File

@ -6,6 +6,7 @@
all else failed -- forego the small, complicating optimization. all else failed -- forego the small, complicating optimization.
* src/color.c (color_update): Strip things bare to see the sameness. * src/color.c (color_update): Strip things bare to see the sameness.
* src/color.c (found_in_list): Factor out this triple repetition. * src/color.c (found_in_list): Factor out this triple repetition.
* src/color.c (color_update): Rename a variable for conciseness.
GNU nano 2.5.3 - 2016.02.25 GNU nano 2.5.3 - 2016.02.25

View File

@ -177,7 +177,7 @@ bool found_in_list(regexlisttype *head, const char *shibboleth)
/* Update the color information based on the current filename. */ /* Update the color information based on the current filename. */
void color_update(void) void color_update(void)
{ {
syntaxtype *tmpsyntax; syntaxtype *sint;
colortype *tmpcolor; colortype *tmpcolor;
assert(openfile != NULL); assert(openfile != NULL);
@ -196,11 +196,10 @@ void color_update(void)
if (strcmp(syntaxstr, "none") == 0) if (strcmp(syntaxstr, "none") == 0)
return; return;
for (tmpsyntax = syntaxes; tmpsyntax != NULL; for (sint = syntaxes; sint != NULL; sint = sint->next) {
tmpsyntax = tmpsyntax->next) { if (strcmp(sint->desc, syntaxstr) == 0) {
if (strcmp(tmpsyntax->desc, syntaxstr) == 0) { openfile->syntax = sint;
openfile->syntax = tmpsyntax; openfile->colorstrings = sint->color;
openfile->colorstrings = tmpsyntax->color;
} }
if (openfile->colorstrings != NULL) if (openfile->colorstrings != NULL)
@ -230,12 +229,10 @@ void color_update(void)
if (fullname == NULL) if (fullname == NULL)
fullname = mallocstrcpy(fullname, openfile->filename); fullname = mallocstrcpy(fullname, openfile->filename);
for (tmpsyntax = syntaxes; tmpsyntax != NULL; for (sint = syntaxes; sint != NULL; sint = sint->next) {
tmpsyntax = tmpsyntax->next) { if (found_in_list(sint->extensions, fullname)) {
openfile->syntax = sint;
if (found_in_list(tmpsyntax->extensions, fullname)) { openfile->colorstrings = sint->color;
openfile->syntax = tmpsyntax;
openfile->colorstrings = tmpsyntax->color;
} }
} }
@ -247,12 +244,10 @@ void color_update(void)
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "No result from file extension, trying headerline...\n"); fprintf(stderr, "No result from file extension, trying headerline...\n");
#endif #endif
for (tmpsyntax = syntaxes; tmpsyntax != NULL; for (sint = syntaxes; sint != NULL; sint = sint->next) {
tmpsyntax = tmpsyntax->next) { if (found_in_list(sint->headers, openfile->fileage->data)) {
openfile->syntax = sint;
if (found_in_list(tmpsyntax->headers, openfile->fileage->data)) { openfile->colorstrings = sint->color;
openfile->syntax = tmpsyntax;
openfile->colorstrings = tmpsyntax->color;
} }
} }
} }
@ -289,11 +284,10 @@ void color_update(void)
/* Now try and find a syntax that matches the magicstring. */ /* Now try and find a syntax that matches the magicstring. */
if (magicstring != NULL) { if (magicstring != NULL) {
for (tmpsyntax = syntaxes; tmpsyntax != NULL; for (sint = syntaxes; sint != NULL; sint = sint->next) {
tmpsyntax = tmpsyntax->next) { if (found_in_list(sint->magics, magicstring)) {
if (found_in_list(tmpsyntax->magics, magicstring)) { openfile->syntax = sint;
openfile->syntax = tmpsyntax; openfile->colorstrings = sint->color;
openfile->colorstrings = tmpsyntax->color;
break; break;
} }
} }
@ -307,11 +301,10 @@ void color_update(void)
/* If we didn't find any syntax yet, see if there is a default one. */ /* If we didn't find any syntax yet, see if there is a default one. */
if (openfile->colorstrings == NULL) { if (openfile->colorstrings == NULL) {
for (tmpsyntax = syntaxes; tmpsyntax != NULL; for (sint = syntaxes; sint != NULL; sint = sint->next) {
tmpsyntax = tmpsyntax->next) { if (strcmp(sint->desc, "default") == 0) {
if (strcmp(tmpsyntax->desc, "default") == 0) { openfile->syntax = sint;
openfile->syntax = tmpsyntax; openfile->colorstrings = sint->color;
openfile->colorstrings = tmpsyntax->color;
break; break;
} }
} }