Eliding the functions parse_header_exp() and parse_magic_exp(),

and reshuffling the parameters in grab_and_store().


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5715 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Benno Schulenberg 2016-03-10 11:00:59 +00:00
parent 837b4e66e2
commit ed296525f4
3 changed files with 7 additions and 19 deletions

View File

@ -3,6 +3,8 @@
commands for the default syntax. This fixes Savannah bug #47323.
* src/rcfile.c (pick_up_name): Fold the parsing of a linter and
formatter command into a single routine.
* src/rcfile.c (parse_header_exp, parse_magic_exp, grab_and_store):
Elide the first two functions, and reshuffle parameters in the last.
2016-03-09 Benno Schulenberg <bensberg@justemail.net>
* src/rcfile.c (parse_syntax): Produce an adequate error message

View File

@ -567,7 +567,7 @@ void parse_include(char *ptr);
short color_to_short(const char *colorname, bool *bright);
void parse_colors(char *ptr, bool icase);
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright);
void grab_and_store(char *ptr, const char *kind, regexlisttype **storage);
void grab_and_store(const char *kind, char *ptr, regexlisttype **storage);
#endif
void parse_rcfile(FILE *rcstream
#ifndef DISABLE_COLOR

View File

@ -335,7 +335,7 @@ void parse_syntax(char *ptr)
/* If there seem to be extension regexes, pick them up. */
if (*ptr != '\0')
grab_and_store(ptr, "extension", &endsyntax->extensions);
grab_and_store("extension", ptr, &endsyntax->extensions);
}
#endif /* !DISABLE_COLOR */
@ -801,7 +801,7 @@ bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
/* Read regex strings enclosed in double quotes from the line pointed at
* by ptr, and store them quoteless in the passed storage place. */
void grab_and_store(char *ptr, const char *kind, regexlisttype **storage)
void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
{
regexlisttype *lastthing;
@ -863,20 +863,6 @@ void grab_and_store(char *ptr, const char *kind, regexlisttype **storage)
}
}
/* Parse the header-line regexes that may influence the choice of syntax. */
void parse_header_exp(char *ptr)
{
grab_and_store(ptr, "header", &endsyntax->headers);
}
#ifdef HAVE_LIBMAGIC
/* Parse the magic regexes that may influence the choice of syntax. */
void parse_magic_exp(char *ptr)
{
grab_and_store(ptr, "magic", &endsyntax->magics);
}
#endif /* HAVE_LIBMAGIC */
/* Parse and store the name given after a linter/formatter command. */
void pick_up_name(const char *kind, char *ptr, char **storage)
{
@ -1032,12 +1018,12 @@ void parse_rcfile(FILE *rcstream
}
else if (strcasecmp(keyword, "magic") == 0)
#ifdef HAVE_LIBMAGIC
parse_magic_exp(ptr);
grab_and_store("magic", ptr, &endsyntax->magics);
#else
;
#endif
else if (strcasecmp(keyword, "header") == 0)
parse_header_exp(ptr);
grab_and_store("header", ptr, &endsyntax->headers);
else if (strcasecmp(keyword, "color") == 0)
parse_colors(ptr, FALSE);
else if (strcasecmp(keyword, "icolor") == 0)