From 2f63e8dfc157cbc3d83dec975c0c161dba0aaee3 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 9 Mar 2016 21:00:42 +0000 Subject: [PATCH] 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 --- ChangeLog | 2 ++ src/proto.h | 1 + src/rcfile.c | 41 +++++------------------------------------ 3 files changed, 8 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index 970f44a0..e72874df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2016-03-09 Benno Schulenberg * 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 * src/color.c (found_in_list): Don't bother keeping the compiled diff --git a/src/proto.h b/src/proto.h index e370f551..899ca1ef 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 7e634312..fb1fe4b7 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) -- 2.39.5