From 717e697e0b77a7ea008b64271b0a1184aed58b3b Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 29 Feb 2016 10:29:52 +0000
Subject: [PATCH] Not allocating a struct for the "none" syntax -- it doesn't
 need any.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5698 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog    |  1 +
 src/rcfile.c | 18 +++++++-----------
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d4fa8167..8078dbbd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2016-02-28  Benno Schulenberg  <bensberg@justemail.net>
 	* src/nano.h, src/rcfile.c, src/color.c: Rename a struct member.
+	* src/rcfile.c (parse_rcfile): Don't allocate struct for none syntax.
 
 2016-02-28  Benno Schulenberg  <bensberg@justemail.net>
 	* src/rcfile.c (parse_header_exp): Don't continue when something is
diff --git a/src/rcfile.c b/src/rcfile.c
index bf3bc9de..ce770aa9 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -286,14 +286,17 @@ void parse_syntax(char *ptr)
 	return;
     }
 
-    ptr++;
-
-    nameptr = ptr;
+    nameptr = ++ptr;
     ptr = parse_next_regex(ptr);
-
     if (ptr == NULL)
 	return;
 
+    /* Redefining the "none" syntax is not allowed. */
+    if (strcmp(nameptr, "none") == 0) {
+	rcfile_error(N_("The \"none\" syntax is reserved"));
+	return;
+    }
+
     /* Search for a duplicate syntax name.  If we find one, free it, so
      * that we always use the last syntax with a given name. */
     prev_syntax = NULL;
@@ -346,13 +349,6 @@ void parse_syntax(char *ptr)
     fprintf(stderr, "Starting a new syntax type: \"%s\"\n", nameptr);
 #endif
 
-    /* The "none" syntax is the same as not having a syntax at all, so
-     * we can't assign any extensions or colors to it. */
-    if (strcmp(endsyntax->name, "none") == 0) {
-	rcfile_error(N_("The \"none\" syntax is reserved"));
-	return;
-    }
-
     /* The default syntax should have no associated extensions. */
     if (strcmp(endsyntax->name, "default") == 0 && *ptr != '\0') {
 	rcfile_error(
-- 
GitLab