Commit 544cda6a authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

rcfile: allow a syntax name to be unquoted

No related merge requests found
Showing with 9 additions and 8 deletions
+9 -8
...@@ -258,8 +258,7 @@ bool nregcomp(const char *regex, int compile_flags) ...@@ -258,8 +258,7 @@ bool nregcomp(const char *regex, int compile_flags)
* line at ptr, and add it to the global linked list of color syntaxes. */ * line at ptr, and add it to the global linked list of color syntaxes. */
void parse_syntax(char *ptr) void parse_syntax(char *ptr)
{ {
char *nameptr; char *nameptr = ptr;
/* A pointer to what should be the name of the syntax. */
opensyntax = FALSE; opensyntax = FALSE;
...@@ -270,17 +269,19 @@ void parse_syntax(char *ptr) ...@@ -270,17 +269,19 @@ void parse_syntax(char *ptr)
return; return;
} }
nameptr = ++ptr;
ptr = parse_next_word(ptr); ptr = parse_next_word(ptr);
/* Check that the name starts and ends with a double quote. */ /* Check that there are no quotes or that they are paired. */
if (*(nameptr - 1) != '\x22' || nameptr[strlen(nameptr) - 1] != '\x22') { if ((*nameptr == '\x22') ^ (nameptr[strlen(nameptr) - 1] == '\x22')) {
rcfile_error(N_("A syntax name must be quoted")); rcfile_error(N_("Unpaired quote in syntax name"));
return; return;
} }
/* Strip the end quote. */ /* If the name is quoted, strip the quotes. */
if (*nameptr == '\x22') {
nameptr++;
nameptr[strlen(nameptr) - 1] = '\0'; nameptr[strlen(nameptr) - 1] = '\0';
}
/* Redefining the "none" syntax is not allowed. */ /* Redefining the "none" syntax is not allowed. */
if (strcmp(nameptr, "none") == 0) { if (strcmp(nameptr, "none") == 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment