nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] patch: improved duplicate syntax handling in 1.3.11


From: David Lawrence Ramsey
Subject: [Nano-devel] patch: improved duplicate syntax handling in 1.3.11
Date: Sat, 15 Apr 2006 12:49:20 -0400
User-agent: Thunderbird 1.5 (X11/20051201)

I've recently figured out that nano's current handling of duplicate
syntax names can lead to problems when e.g. trying to override the
global nanorc with the local nanorc.  The attached patch against 1.3.11,
which is already in CVS, should fix it, if anyone's interested.

diff -ur nano-1.3.11/src/rcfile.c nano-1.3.11-fixed/src/rcfile.c
--- nano-1.3.11/src/rcfile.c    2006-01-06 17:04:38.000000000 -0500
+++ nano-1.3.11-fixed/src/rcfile.c      2006-04-15 12:43:25.000000000 -0400
@@ -275,7 +275,7 @@
 void parse_syntax(char *ptr)
 {
     const char *fileregptr = NULL, *nameptr = NULL;
-    const syntaxtype *tmpsyntax;
+    syntaxtype *tmpsyntax;
     exttype *endext = NULL;
        /* The end of the extensions list for this syntax. */
 
@@ -300,11 +300,16 @@
     if (ptr == NULL)
        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. */
     for (tmpsyntax = syntaxes; tmpsyntax != NULL;
        tmpsyntax = tmpsyntax->next) {
        if (strcmp(nameptr, tmpsyntax->desc) == 0) {
-           rcfile_error(N_("Duplicate syntax name %s"), nameptr);
-           return;
+           syntaxtype *prev_syntax = tmpsyntax;
+
+           tmpsyntax = tmpsyntax->next;
+           free(prev_syntax);
+           break;
        }
     }
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]