]> git.wh0rd.org Git - nano.git/commitdiff
Rearranging a few things in my style.
authorBenno Schulenberg <bensberg@justemail.net>
Sun, 28 Feb 2016 17:16:39 +0000 (17:16 +0000)
committerBenno Schulenberg <bensberg@justemail.net>
Sun, 28 Feb 2016 17:16:39 +0000 (17:16 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5695 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/rcfile.c

index dd13ca30647ad36606d972d89f4361dcc5af8df2..9676b1597dd76fee6f50caff2d0dd13e41d7d00f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@
        * src/rcfile.c (grab_and_store): Rename a variable and densify.
        * src/rcfile.c (grab_and_store): Do not drop regexes that were
        gathered earlier.  This fixes Savannah bug #47285.
+       * src/rcfile.c (grab_and_store): Rearrange things in my style.
 
 2016-02-26  Benno Schulenberg  <bensberg@justemail.net>
        * doc/man/nanorc.5, doc/texinfo/nano.texi, doc/syntax/nanorc.nanorc,
index fd747c60f0b5715807e3229cf508e65c2b6ec42a..f8b19419f5dbd1d68cbd7cbbd4b0805ee216221c 100644 (file)
@@ -879,7 +879,7 @@ void grab_and_store(char *ptr, const char *kind, regexlisttype **storage)
     while (lastthing != NULL && lastthing->next != NULL)
        lastthing = lastthing->next;
 
-    /* Now load the regexes into their part of the struct. */
+    /* Now gather any valid regexes and add them to the linked list. */
     while (*ptr != '\0') {
        const char *regexstring;
        regexlisttype *newthing;
@@ -895,22 +895,22 @@ void grab_and_store(char *ptr, const char *kind, regexlisttype **storage)
        if (ptr == NULL)
            return;
 
-       newthing = (regexlisttype *)nmalloc(sizeof(regexlisttype));
+       /* If the regex string is malformed, skip it. */
+       if (nregcomp(regexstring, REG_NOSUB) != 0)
+           continue;
 
-       /* Save the regex string if it's valid. */
-       if (nregcomp(regexstring, REG_NOSUB)) {
-           newthing->full_regex = mallocstrcpy(NULL, regexstring);
-           newthing->rgx = NULL;
+       /* Copy the regex into a struct, and hook this in at the end. */
+       newthing = (regexlisttype *)nmalloc(sizeof(regexlisttype));
+       newthing->full_regex = mallocstrcpy(NULL, regexstring);
+       newthing->rgx = NULL;
+       newthing->next = NULL;
 
-           if (lastthing == NULL)
-               *storage = newthing;
-           else
-               lastthing->next = newthing;
+       if (lastthing == NULL)
+           *storage = newthing;
+       else
+           lastthing->next = newthing;
 
-           lastthing = newthing;
-           lastthing->next = NULL;
-       } else
-           free(newthing);
+       lastthing = newthing;
     }
 }