tweaks: rename a variable, and reshuffle a declaration
parent
be7e000389
commit
51913542f4
55
src/color.c
55
src/color.c
|
@ -40,13 +40,13 @@
|
||||||
|
|
||||||
/* Assign pair numbers for the colors in the given syntax, giving identical
|
/* Assign pair numbers for the colors in the given syntax, giving identical
|
||||||
* color pairs the same number. */
|
* color pairs the same number. */
|
||||||
void set_syntax_colorpairs(syntaxtype *sint)
|
void set_syntax_colorpairs(syntaxtype *sntx)
|
||||||
{
|
{
|
||||||
int new_number = NUMBER_OF_ELEMENTS + 1;
|
int new_number = NUMBER_OF_ELEMENTS + 1;
|
||||||
colortype *ink;
|
colortype *ink;
|
||||||
|
|
||||||
for (ink = sint->color; ink != NULL; ink = ink->next) {
|
for (ink = sntx->color; ink != NULL; ink = ink->next) {
|
||||||
const colortype *beforenow = sint->color;
|
const colortype *beforenow = sntx->color;
|
||||||
|
|
||||||
while (beforenow != ink && (beforenow->fg != ink->fg ||
|
while (beforenow != ink && (beforenow->fg != ink->fg ||
|
||||||
beforenow->bg != ink->bg))
|
beforenow->bg != ink->bg))
|
||||||
|
@ -65,7 +65,6 @@ void set_syntax_colorpairs(syntaxtype *sint)
|
||||||
* for the colors in each loaded syntax. */
|
* for the colors in each loaded syntax. */
|
||||||
void set_colorpairs(void)
|
void set_colorpairs(void)
|
||||||
{
|
{
|
||||||
syntaxtype *sint;
|
|
||||||
bool using_defaults = FALSE;
|
bool using_defaults = FALSE;
|
||||||
|
|
||||||
/* Tell ncurses to enable colors. */
|
/* Tell ncurses to enable colors. */
|
||||||
|
@ -105,9 +104,9 @@ void set_colorpairs(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For each loaded syntax, assign pair numbers to color combinations. */
|
/* For each loaded syntax, assign pair numbers to color combinations. */
|
||||||
for (sint = syntaxes; sint != NULL; sint = sint->next)
|
for (syntaxtype *sntx = syntaxes; sntx != NULL; sntx = sntx->next)
|
||||||
if (sint->filename == NULL)
|
if (sntx->filename == NULL)
|
||||||
set_syntax_colorpairs(sint);
|
set_syntax_colorpairs(sntx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the color information. */
|
/* Initialize the color information. */
|
||||||
|
@ -167,7 +166,7 @@ bool found_in_list(regexlisttype *head, const char *shibboleth)
|
||||||
/* Update the color information based on the current filename and content. */
|
/* Update the color information based on the current filename and content. */
|
||||||
void color_update(void)
|
void color_update(void)
|
||||||
{
|
{
|
||||||
syntaxtype *sint = NULL;
|
syntaxtype *sntx = NULL;
|
||||||
|
|
||||||
/* If the rcfiles were not read, or contained no syntaxes, get out. */
|
/* If the rcfiles were not read, or contained no syntaxes, get out. */
|
||||||
if (syntaxes == NULL)
|
if (syntaxes == NULL)
|
||||||
|
@ -179,25 +178,25 @@ void color_update(void)
|
||||||
if (strcmp(syntaxstr, "none") == 0)
|
if (strcmp(syntaxstr, "none") == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (sint = syntaxes; sint != NULL; sint = sint->next) {
|
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next) {
|
||||||
if (strcmp(sint->name, syntaxstr) == 0)
|
if (strcmp(sntx->name, syntaxstr) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sint == NULL && !inhelp)
|
if (sntx == NULL && !inhelp)
|
||||||
statusline(ALERT, _("Unknown syntax name: %s"), syntaxstr);
|
statusline(ALERT, _("Unknown syntax name: %s"), syntaxstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If no syntax-override string was specified, or it didn't match,
|
/* If no syntax-override string was specified, or it didn't match,
|
||||||
* try finding a syntax based on the filename (extension). */
|
* try finding a syntax based on the filename (extension). */
|
||||||
if (sint == NULL && !inhelp) {
|
if (sntx == NULL && !inhelp) {
|
||||||
char *fullname = get_full_path(openfile->filename);
|
char *fullname = get_full_path(openfile->filename);
|
||||||
|
|
||||||
if (fullname == NULL)
|
if (fullname == NULL)
|
||||||
fullname = mallocstrcpy(fullname, openfile->filename);
|
fullname = mallocstrcpy(fullname, openfile->filename);
|
||||||
|
|
||||||
for (sint = syntaxes; sint != NULL; sint = sint->next) {
|
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next) {
|
||||||
if (found_in_list(sint->extensions, fullname))
|
if (found_in_list(sntx->extensions, fullname))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,16 +204,16 @@ void color_update(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the filename didn't match anything, try the first line. */
|
/* If the filename didn't match anything, try the first line. */
|
||||||
if (sint == NULL && !inhelp) {
|
if (sntx == NULL && !inhelp) {
|
||||||
for (sint = syntaxes; sint != NULL; sint = sint->next) {
|
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next) {
|
||||||
if (found_in_list(sint->headers, openfile->filetop->data))
|
if (found_in_list(sntx->headers, openfile->filetop->data))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBMAGIC
|
#ifdef HAVE_LIBMAGIC
|
||||||
/* If we still don't have an answer, try using magic. */
|
/* If we still don't have an answer, try using magic. */
|
||||||
if (sint == NULL && !inhelp) {
|
if (sntx == NULL && !inhelp) {
|
||||||
struct stat fileinfo;
|
struct stat fileinfo;
|
||||||
magic_t cookie = NULL;
|
magic_t cookie = NULL;
|
||||||
const char *magicstring = NULL;
|
const char *magicstring = NULL;
|
||||||
|
@ -238,8 +237,8 @@ void color_update(void)
|
||||||
|
|
||||||
/* Now try and find a syntax that matches the magic string. */
|
/* Now try and find a syntax that matches the magic string. */
|
||||||
if (magicstring != NULL) {
|
if (magicstring != NULL) {
|
||||||
for (sint = syntaxes; sint != NULL; sint = sint->next) {
|
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next) {
|
||||||
if (found_in_list(sint->magics, magicstring))
|
if (found_in_list(sntx->magics, magicstring))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,21 +249,21 @@ void color_update(void)
|
||||||
#endif /* HAVE_LIBMAGIC */
|
#endif /* HAVE_LIBMAGIC */
|
||||||
|
|
||||||
/* If nothing at all matched, see if there is a default syntax. */
|
/* If nothing at all matched, see if there is a default syntax. */
|
||||||
if (sint == NULL && !inhelp) {
|
if (sntx == NULL && !inhelp) {
|
||||||
for (sint = syntaxes; sint != NULL; sint = sint->next) {
|
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next) {
|
||||||
if (strcmp(sint->name, "default") == 0)
|
if (strcmp(sntx->name, "default") == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When the syntax isn't loaded yet, parse it and initialize its colors. */
|
/* When the syntax isn't loaded yet, parse it and initialize its colors. */
|
||||||
if (sint != NULL && sint->filename != NULL) {
|
if (sntx != NULL && sntx->filename != NULL) {
|
||||||
parse_one_include(sint->filename, sint);
|
parse_one_include(sntx->filename, sntx);
|
||||||
set_syntax_colorpairs(sint);
|
set_syntax_colorpairs(sntx);
|
||||||
}
|
}
|
||||||
|
|
||||||
openfile->syntax = sint;
|
openfile->syntax = sntx;
|
||||||
openfile->colorstrings = (sint == NULL ? NULL : sint->color);
|
openfile->colorstrings = (sntx == NULL ? NULL : sntx->color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate and initialize (for the given line) the cache for multiline info. */
|
/* Allocate and initialize (for the given line) the cache for multiline info. */
|
||||||
|
|
16
src/rcfile.c
16
src/rcfile.c
|
@ -1340,17 +1340,17 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
|
||||||
if (!just_syntax && strcmp(keyword, "extendsyntax") == 0) {
|
if (!just_syntax && strcmp(keyword, "extendsyntax") == 0) {
|
||||||
augmentstruct *newitem, *extra;
|
augmentstruct *newitem, *extra;
|
||||||
char *syntaxname = ptr;
|
char *syntaxname = ptr;
|
||||||
syntaxtype *sint;
|
syntaxtype *sntx;
|
||||||
|
|
||||||
check_for_nonempty_syntax();
|
check_for_nonempty_syntax();
|
||||||
|
|
||||||
ptr = parse_next_word(ptr);
|
ptr = parse_next_word(ptr);
|
||||||
|
|
||||||
for (sint = syntaxes; sint != NULL; sint = sint->next)
|
for (sntx = syntaxes; sntx != NULL; sntx = sntx->next)
|
||||||
if (!strcmp(sint->name, syntaxname))
|
if (!strcmp(sntx->name, syntaxname))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (sint == NULL) {
|
if (sntx == NULL) {
|
||||||
jot_error(N_("Could not find syntax \"%s\" to extend"), syntaxname);
|
jot_error(N_("Could not find syntax \"%s\" to extend"), syntaxname);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1363,7 +1363,7 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
|
||||||
* other commands are stored for possible later processing. */
|
* other commands are stored for possible later processing. */
|
||||||
if (strcmp(keyword, "header") == 0 || strcmp(keyword, "magic") == 0) {
|
if (strcmp(keyword, "header") == 0 || strcmp(keyword, "magic") == 0) {
|
||||||
free(argument);
|
free(argument);
|
||||||
live_syntax = sint;
|
live_syntax = sntx;
|
||||||
opensyntax = TRUE;
|
opensyntax = TRUE;
|
||||||
drop_open = TRUE;
|
drop_open = TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1374,13 +1374,13 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
|
||||||
newitem->data = argument;
|
newitem->data = argument;
|
||||||
newitem->next = NULL;
|
newitem->next = NULL;
|
||||||
|
|
||||||
if (sint->augmentations != NULL) {
|
if (sntx->augmentations != NULL) {
|
||||||
extra = sint->augmentations;
|
extra = sntx->augmentations;
|
||||||
while (extra->next != NULL)
|
while (extra->next != NULL)
|
||||||
extra = extra->next;
|
extra = extra->next;
|
||||||
extra->next = newitem;
|
extra->next = newitem;
|
||||||
} else
|
} else
|
||||||
sint->augmentations = newitem;
|
sntx->augmentations = newitem;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue