From ed296525f49fa42d992330d7db730980bd966f7a Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Thu, 10 Mar 2016 11:00:59 +0000
Subject: [PATCH] Eliding the functions parse_header_exp() and
 parse_magic_exp(), and reshuffling the parameters in grab_and_store().

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5715 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog    |  2 ++
 src/proto.h  |  2 +-
 src/rcfile.c | 22 ++++------------------
 3 files changed, 7 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cb018a1c..8555cd18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,8 @@
 	commands for the default syntax.  This fixes Savannah bug #47323.
 	* src/rcfile.c (pick_up_name): Fold the parsing of a linter and
 	formatter command into a single routine.
+	* src/rcfile.c (parse_header_exp, parse_magic_exp, grab_and_store):
+	Elide the first two functions, and reshuffle parameters in the last.
 
 2016-03-09  Benno Schulenberg  <bensberg@justemail.net>
 	* src/rcfile.c (parse_syntax): Produce an adequate error message
diff --git a/src/proto.h b/src/proto.h
index 899ca1ef..39ab19f1 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -567,7 +567,7 @@ void parse_include(char *ptr);
 short color_to_short(const char *colorname, bool *bright);
 void parse_colors(char *ptr, bool icase);
 bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright);
-void grab_and_store(char *ptr, const char *kind, regexlisttype **storage);
+void grab_and_store(const char *kind, char *ptr, regexlisttype **storage);
 #endif
 void parse_rcfile(FILE *rcstream
 #ifndef DISABLE_COLOR
diff --git a/src/rcfile.c b/src/rcfile.c
index 801a1623..cf7aea50 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -335,7 +335,7 @@ void parse_syntax(char *ptr)
 
     /* If there seem to be extension regexes, pick them up. */
     if (*ptr != '\0')
-	grab_and_store(ptr, "extension", &endsyntax->extensions);
+	grab_and_store("extension", ptr, &endsyntax->extensions);
 }
 #endif /* !DISABLE_COLOR */
 
@@ -801,7 +801,7 @@ bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
 
 /* Read regex strings enclosed in double quotes from the line pointed at
  * by ptr, and store them quoteless in the passed storage place. */
-void grab_and_store(char *ptr, const char *kind, regexlisttype **storage)
+void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
 {
     regexlisttype *lastthing;
 
@@ -863,20 +863,6 @@ void grab_and_store(char *ptr, const char *kind, regexlisttype **storage)
     }
 }
 
-/* Parse the header-line regexes that may influence the choice of syntax. */
-void parse_header_exp(char *ptr)
-{
-    grab_and_store(ptr, "header", &endsyntax->headers);
-}
-
-#ifdef HAVE_LIBMAGIC
-/* Parse the magic regexes that may influence the choice of syntax. */
-void parse_magic_exp(char *ptr)
-{
-    grab_and_store(ptr, "magic", &endsyntax->magics);
-}
-#endif /* HAVE_LIBMAGIC */
-
 /* Parse and store the name given after a linter/formatter command. */
 void pick_up_name(const char *kind, char *ptr, char **storage)
 {
@@ -1032,12 +1018,12 @@ void parse_rcfile(FILE *rcstream
 	}
 	else if (strcasecmp(keyword, "magic") == 0)
 #ifdef HAVE_LIBMAGIC
-	    parse_magic_exp(ptr);
+	    grab_and_store("magic", ptr, &endsyntax->magics);
 #else
 	    ;
 #endif
 	else if (strcasecmp(keyword, "header") == 0)
-	    parse_header_exp(ptr);
+	    grab_and_store("header", ptr, &endsyntax->headers);
 	else if (strcasecmp(keyword, "color") == 0)
 	    parse_colors(ptr, FALSE);
 	else if (strcasecmp(keyword, "icolor") == 0)
-- 
GitLab