[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nano-devel] [PATCH 1/2] rcfile: allow a syntax name to be unquoted
From: |
Benno Schulenberg |
Subject: |
[Nano-devel] [PATCH 1/2] rcfile: allow a syntax name to be unquoted |
Date: |
Wed, 7 Feb 2018 11:36:27 +0100 |
---
src/rcfile.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/rcfile.c b/src/rcfile.c
index b14192d5..168f4140 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -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. */
void parse_syntax(char *ptr)
{
- char *nameptr;
- /* A pointer to what should be the name of the syntax. */
+ char *nameptr = ptr;
opensyntax = FALSE;
@@ -270,17 +269,19 @@ void parse_syntax(char *ptr)
return;
}
- nameptr = ++ptr;
ptr = parse_next_word(ptr);
- /* Check that the name starts and ends with a double quote. */
- if (*(nameptr - 1) != '\x22' || nameptr[strlen(nameptr) - 1] != '\x22')
{
- rcfile_error(N_("A syntax name must be quoted"));
+ /* Check that there are no quotes or that they are paired. */
+ if ((*nameptr == '\x22') ^ (nameptr[strlen(nameptr) - 1] == '\x22')) {
+ rcfile_error(N_("Unpaired quote in syntax name"));
return;
}
- /* Strip the end quote. */
- nameptr[strlen(nameptr) - 1] = '\0';
+ /* If the name is quoted, strip the quotes. */
+ if (*nameptr == '\x22') {
+ nameptr++;
+ nameptr[strlen(nameptr) - 1] = '\0';
+ }
/* Redefining the "none" syntax is not allowed. */
if (strcmp(nameptr, "none") == 0) {
--
2.14.3
- [Nano-devel] [PATCH 1/2] rcfile: allow a syntax name to be unquoted,
Benno Schulenberg <=