diff --git a/ChangeLog b/ChangeLog index 970f44a05579cffa1d0309417fb79ec8f525a4aa..e72874dfc2462963eceffa9c22fdec3001348eb5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/proto.h b/src/proto.h index e370f5510bc4c88403d28aaca7d87353e58ca36f..899ca1ef7d2bb8a10fdc281b5e008cd072ef4776 100644 --- a/src/proto.h +++ b/src/proto.h @@ -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 diff --git a/src/rcfile.c b/src/rcfile.c index 7e6343124b26e98f323c5f73b563f15dbb4c3fbe..fb1fe4b784cb95d5b89f0d6213cd4f7babe4a3a2 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -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)