Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2018-05-26 16:55:21 +0300
committerJunio C Hamano <gitster@pobox.com>2018-05-29 08:51:28 +0300
commita73b3680c4910866e3e215c3927a0c71f0b9229d (patch)
tree4c48aca0f71bba28888b19f3dec47088334ea7d1 /config.c
parent17b3e5150506281fd2d675c150cf1e71f914ad54 (diff)
Add and use generic name->id mapping code for color slot parsing
Instead of hard coding the name-to-id mapping in C code, keep it in an array and use a common function to do the parsing. This reduces code and also allows us to list all possible color slots later. This starts using C99 designated initializers more for convenience (the first designated initializers have been introduced in builtin/clean.c for some time without complaints) Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/config.c b/config.c
index 6f8f1d8c11..d9ff3cb38c 100644
--- a/config.c
+++ b/config.c
@@ -3245,3 +3245,16 @@ enum config_scope current_config_scope(void)
else
return current_parsing_scope;
}
+
+int lookup_config(const char **mapping, int nr_mapping, const char *var)
+{
+ int i;
+
+ for (i = 0; i < nr_mapping; i++) {
+ const char *name = mapping[i];
+
+ if (name && !strcasecmp(var, name))
+ return i;
+ }
+ return -1;
+}