Using the grab_and_store() function also for gathering up extension regexes.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5712 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Benno Schulenberg 2016-03-09 21:00:42 +00:00
parent b0bdfbb0f7
commit 2f63e8dfc1
3 changed files with 8 additions and 36 deletions

View File

@ -1,6 +1,8 @@
2016-03-09 Benno Schulenberg <bensberg@justemail.net>
* src/rcfile.c (parse_syntax): Produce an adequate error message
when the syntax name is unquoted. This fixes Savannah bug #47324.
* src/rcfile.c (parse_syntax): Use the grab_and_store() function
also for gathering up extension regexes.
2016-03-04 Benno Schulenberg <bensberg@justemail.net>
* src/color.c (found_in_list): Don't bother keeping the compiled

View File

@ -567,6 +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);
#endif
void parse_rcfile(FILE *rcstream
#ifndef DISABLE_COLOR

View File

@ -266,9 +266,8 @@ bool nregcomp(const char *regex, int eflags)
* global list of color syntaxes. */
void parse_syntax(char *ptr)
{
char *fileregptr, *nameptr;
regexlisttype *endext = NULL;
/* The end of the extensions list for this syntax. */
char *nameptr;
/* A pointer to what should be the name of the syntax. */
opensyntax = FALSE;
@ -334,38 +333,9 @@ void parse_syntax(char *ptr)
return;
}
/* Now load the extension regexes into their part of the struct. */
while (*ptr != '\0') {
regexlisttype *newext;
while (*ptr != '"' && *ptr != '\0')
ptr++;
if (*ptr == '\0')
return;
ptr++;
fileregptr = ptr;
ptr = parse_next_regex(ptr);
if (ptr == NULL)
break;
newext = (regexlisttype *)nmalloc(sizeof(regexlisttype));
/* Save the extension regex if it's valid. */
if (nregcomp(fileregptr, REG_NOSUB)) {
newext->full_regex = mallocstrcpy(NULL, fileregptr);
if (endext == NULL)
endsyntax->extensions = newext;
else
endext->next = newext;
endext = newext;
endext->next = NULL;
} else
free(newext);
}
/* If there seem to be extension regexes, pick them up. */
if (*ptr != '\0')
grab_and_store(ptr, "extension", &endsyntax->extensions);
}
#endif /* !DISABLE_COLOR */
@ -829,7 +799,6 @@ bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
return TRUE;
}
/* 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)