Commit b9affa329a18d076094442d5af30e294c8fe8722

Patrick Steinhardt 2018-08-10T19:23:00

config_parse: avoid unused static declared values The variables `git_config_escaped` and `git_config_escapes` are both defined as static const character pointers in "config_parse.h". In case where "config_parse.h" is included but those two variables are not being used, the compiler will thus complain about defined but unused variables. Fix this by declaring them as external and moving the actual initialization to the C file. Note that it is not possible to simply make this a #define, as we are indexing into those arrays.

diff --git a/src/config_parse.c b/src/config_parse.c
index 282aabe..6e85bbe 100644
--- a/src/config_parse.c
+++ b/src/config_parse.c
@@ -11,6 +11,9 @@
 
 #include <ctype.h>
 
+const char *git_config_escapes = "ntb\"\\";
+const char *git_config_escaped = "\n\t\b\"\\";
+
 static void set_parse_error(git_config_parser *reader, int col, const char *error_str)
 {
 	giterr_set(GITERR_CONFIG, "failed to parse config file: %s (in %s:%"PRIuZ", column %d)",
diff --git a/src/config_parse.h b/src/config_parse.h
index 6650b87..81a13fc 100644
--- a/src/config_parse.h
+++ b/src/config_parse.h
@@ -12,8 +12,8 @@
 #include "oid.h"
 #include "parse.h"
 
-static const char *git_config_escapes = "ntb\"\\";
-static const char *git_config_escaped = "\n\t\b\"\\";
+extern const char *git_config_escapes;
+extern const char *git_config_escaped;
 
 typedef struct config_file {
 	git_oid checksum;