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
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
* 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;
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 */
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)