From: Joel Rosdahl Date: Fri, 29 Jul 2011 14:01:48 +0000 (+0200) Subject: config: Use code generated by gperf for looking up configuration items X-Git-Tag: v3.2~186 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8025a674ba519c21cf0b1ac327992720eebf8d57;p=thirdparty%2Fccache.git config: Use code generated by gperf for looking up configuration items --- diff --git a/Makefile.in b/Makefile.in index 54bceb2e3..dae1bf300 100644 --- a/Makefile.in +++ b/Makefile.in @@ -62,6 +62,8 @@ install: all clean: rm -f $(files_to_clean) +conf.c: confitems_lookup.c envtoconfitems_lookup.c + zlib/libz.a: $(zlib_objs) $(AR) cr $@ $(zlib_objs) $(RANLIB) $@ diff --git a/conf.c b/conf.c index a79001bb0..10e29768b 100644 --- a/conf.c +++ b/conf.c @@ -181,108 +181,23 @@ verify_dir_levels(void *value, char **errmsg) } #define ITEM(name, type) \ - {#name, parse_##type, offsetof(struct conf, name), NULL} + parse_##type, offsetof(struct conf, name), NULL #define ITEM_V(name, type, verification) \ - {#name, parse_##type, offsetof(struct conf, name), verify_##verification} - -static const struct conf_item conf_items[] = { - ITEM_V(base_dir, env_string, absolute_path), - ITEM(cache_dir, env_string), - ITEM_V(cache_dir_levels, unsigned, dir_levels), - ITEM(compiler, string), - ITEM(compiler_check, string), - ITEM(compression, bool), - ITEM(cpp_extension, string), - ITEM(detect_shebang, bool), - ITEM(direct_mode, bool), - ITEM(disable, bool), - ITEM(extra_files_to_hash, env_string), - ITEM(hard_link, bool), - ITEM(hash_dir, bool), - ITEM(log_file, env_string), - ITEM(max_files, unsigned), - ITEM(max_size, size), - ITEM(path, env_string), - ITEM(prefix_command, env_string), - ITEM(read_only, bool), - ITEM(recache, bool), - ITEM(run_second_cpp, bool), - ITEM(sloppiness, sloppiness), - ITEM(stats, bool), - ITEM(temporary_dir, env_string), - ITEM(umask, umask), - ITEM(unify, bool) -}; + parse_##type, offsetof(struct conf, name), verify_##verification -#define ENV_TO_CONF(env_name, conf_name) \ - {#env_name, #conf_name} - -static const struct env_to_conf_item env_to_conf_items[] = { - ENV_TO_CONF(BASEDIR, base_dir), - ENV_TO_CONF(CC, compiler), - ENV_TO_CONF(COMPILERCHECK, compiler_check), - ENV_TO_CONF(COMPRESS, compression), - ENV_TO_CONF(CPP2, run_second_cpp), - ENV_TO_CONF(DETECT_SHEBANG, detect_shebang), - ENV_TO_CONF(DIR, cache_dir), - ENV_TO_CONF(DIRECT, direct_mode), - ENV_TO_CONF(DISABLE, disable), - ENV_TO_CONF(EXTENSION, cpp_extension), - ENV_TO_CONF(EXTRAFILES, extra_files_to_hash), - ENV_TO_CONF(HARDLINK, hard_link), - ENV_TO_CONF(HASHDIR, hash_dir), - ENV_TO_CONF(LOGFILE, log_file), - ENV_TO_CONF(MAXFILES, max_files), - ENV_TO_CONF(MAXSIZE, max_size), - ENV_TO_CONF(NLEVELS, cache_dir_levels), - ENV_TO_CONF(PATH, path), - ENV_TO_CONF(PREFIX, prefix_command), - ENV_TO_CONF(READONLY, read_only), - ENV_TO_CONF(RECACHE, recache), - ENV_TO_CONF(SLOPPINESS, sloppiness), - ENV_TO_CONF(STATS, stats), - ENV_TO_CONF(TEMPDIR, temporary_dir), - ENV_TO_CONF(UMASK, umask), - ENV_TO_CONF(UNIFY, unify) -}; - -static int -compare_conf_items(const void *key1, const void *key2) -{ - const struct conf_item *conf1 = (const struct conf_item *)key1; - const struct conf_item *conf2 = (const struct conf_item *)key2; - return strcmp(conf1->name, conf2->name); -} +#include "confitems_lookup.c" +#include "envtoconfitems_lookup.c" static const struct conf_item * find_conf(const char *name) { - struct conf_item key; - key.name = name; - return bsearch( - &key, conf_items, sizeof(conf_items) / sizeof(conf_items[0]), - sizeof(conf_items[0]), compare_conf_items); -} - -static int -compare_env_to_conf_items(const void *key1, const void *key2) -{ - const struct env_to_conf_item *conf1 = (const struct env_to_conf_item *)key1; - const struct env_to_conf_item *conf2 = (const struct env_to_conf_item *)key2; - return strcmp(conf1->env_name, conf2->env_name); + return confitems_get(name, strlen(name)); } static const struct env_to_conf_item * find_env_to_conf(const char *name) { - struct env_to_conf_item key; - key.env_name = name; - return bsearch( - &key, - env_to_conf_items, - sizeof(env_to_conf_items) / sizeof(env_to_conf_items[0]), - sizeof(env_to_conf_items[0]), - compare_env_to_conf_items); + return envtoconfitems_get(name, strlen(name)); } static bool @@ -364,52 +279,6 @@ parse_line(const char *line, char **key, char **value, char **errmsg) #undef SKIP_WS } -/* For test purposes. */ -bool -conf_verify_sortedness(void) -{ - size_t i; - for (i = 1; i < sizeof(conf_items)/sizeof(conf_items[0]); i++) { - if (strcmp(conf_items[i-1].name, conf_items[i].name) >= 0) { - fprintf(stderr, - "conf_verify_sortedness: %s >= %s\n", - conf_items[i-1].name, - conf_items[i].name); - return false; - } - } - return true; -} - -/* For test purposes. */ -bool -conf_verify_env_table_correctness(void) -{ - size_t i; - for (i = 0; - i < sizeof(env_to_conf_items) / sizeof(env_to_conf_items[0]); - i++) { - if (i > 0 - && strcmp(env_to_conf_items[i-1].env_name, - env_to_conf_items[i].env_name) >= 0) { - fprintf(stderr, - "conf_verify_env_table_correctness: %s >= %s\n", - env_to_conf_items[i-1].env_name, - env_to_conf_items[i].env_name); - return false; - } - if (!find_conf(env_to_conf_items[i].conf_name)) { - fprintf(stderr, - "conf_verify_env_table_correctness: %s -> %s," - " which doesn't exist\n", - env_to_conf_items[i].env_name, - env_to_conf_items[i].conf_name); - return false; - } - } - return true; -} - /* Create a conf struct with default values. */ struct conf * conf_create(void) diff --git a/confitems.gperf b/confitems.gperf new file mode 100644 index 000000000..353ff6530 --- /dev/null +++ b/confitems.gperf @@ -0,0 +1,35 @@ +%language=ANSI-C +%enum +%struct-type +%readonly-tables +%define hash-function-name confitems_hash +%define lookup-function-name confitems_get +%define initializer-suffix ,NULL,0,NULL +struct conf_item; +%% +base_dir, ITEM_V(base_dir, env_string, absolute_path) +cache_dir, ITEM(cache_dir, env_string) +cache_dir_levels, ITEM_V(cache_dir_levels, unsigned, dir_levels) +compiler, ITEM(compiler, string) +compiler_check, ITEM(compiler_check, string) +compression, ITEM(compression, bool) +cpp_extension, ITEM(cpp_extension, string) +detect_shebang, ITEM(detect_shebang, bool) +direct_mode, ITEM(direct_mode, bool) +disable, ITEM(disable, bool) +extra_files_to_hash, ITEM(extra_files_to_hash, env_string) +hard_link, ITEM(hard_link, bool) +hash_dir, ITEM(hash_dir, bool) +log_file, ITEM(log_file, env_string) +max_files, ITEM(max_files, unsigned) +max_size, ITEM(max_size, size) +path, ITEM(path, env_string) +prefix_command, ITEM(prefix_command, env_string) +read_only, ITEM(read_only, bool) +recache, ITEM(recache, bool) +run_second_cpp, ITEM(run_second_cpp, bool) +sloppiness, ITEM(sloppiness, sloppiness) +stats, ITEM(stats, bool) +temporary_dir, ITEM(temporary_dir, env_string) +umask, ITEM(umask, umask) +unify, ITEM(unify, bool) diff --git a/confitems_lookup.c b/confitems_lookup.c new file mode 100644 index 000000000..9635e592e --- /dev/null +++ b/confitems_lookup.c @@ -0,0 +1,176 @@ +/* ANSI-C code produced by gperf version 3.0.3 */ +/* Command-line: gperf confitems.gperf */ +/* Computed positions: -k'1-2' */ + +#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ + && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ + && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ + && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ + && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ + && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ + && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ + && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ + && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ + && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ + && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ + && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ + && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ + && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ + && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ + && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ + && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ + && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ + && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ + && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ + && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ + && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ + && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) +/* The character set is not based on ISO-646. */ +#error "gperf generated tables don't work with this execution character set. Please report a bug to ." +#endif + +#line 8 "confitems.gperf" +struct conf_item; +/* maximum key range = 41, duplicates = 0 */ + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static unsigned int +confitems_hash (register const char *str, register unsigned int len) +{ + static const unsigned char asso_values[] = + { + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 0, 25, 0, + 10, 15, 45, 45, 18, 0, 45, 45, 15, 10, + 0, 0, 0, 45, 10, 0, 0, 5, 45, 45, + 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45 + }; + return len + asso_values[(unsigned char)str[1]] + asso_values[(unsigned char)str[0]]; +} + +#ifdef __GNUC__ +__inline +#ifdef __GNUC_STDC_INLINE__ +__attribute__ ((__gnu_inline__)) +#endif +#endif +const struct conf_item * +confitems_get (register const char *str, register unsigned int len) +{ + enum + { + TOTAL_KEYWORDS = 26, + MIN_WORD_LENGTH = 4, + MAX_WORD_LENGTH = 19, + MIN_HASH_VALUE = 4, + MAX_HASH_VALUE = 44 + }; + + static const struct conf_item wordlist[] = + { + {"",NULL,0,NULL}, {"",NULL,0,NULL}, {"",NULL,0,NULL}, + {"",NULL,0,NULL}, +#line 26 "confitems.gperf" + {"path", ITEM(path, env_string)}, +#line 32 "confitems.gperf" + {"stats", ITEM(stats, bool)}, + {"",NULL,0,NULL}, {"",NULL,0,NULL}, +#line 13 "confitems.gperf" + {"compiler", ITEM(compiler, string)}, +#line 11 "confitems.gperf" + {"cache_dir", ITEM(cache_dir, env_string)}, +#line 35 "confitems.gperf" + {"unify", ITEM(unify, bool)}, +#line 15 "confitems.gperf" + {"compression", ITEM(compression, bool)}, + {"",NULL,0,NULL}, +#line 16 "confitems.gperf" + {"cpp_extension", ITEM(cpp_extension, string)}, +#line 14 "confitems.gperf" + {"compiler_check", ITEM(compiler_check, string)}, + {"",NULL,0,NULL}, +#line 12 "confitems.gperf" + {"cache_dir_levels", ITEM_V(cache_dir_levels, unsigned, dir_levels)}, +#line 19 "confitems.gperf" + {"disable", ITEM(disable, bool)}, +#line 25 "confitems.gperf" + {"max_size", ITEM(max_size, size)}, +#line 24 "confitems.gperf" + {"max_files", ITEM(max_files, unsigned)}, +#line 34 "confitems.gperf" + {"umask", ITEM(umask, umask)}, +#line 18 "confitems.gperf" + {"direct_mode", ITEM(direct_mode, bool)}, + {"",NULL,0,NULL}, +#line 23 "confitems.gperf" + {"log_file", ITEM(log_file, env_string)}, +#line 27 "confitems.gperf" + {"prefix_command", ITEM(prefix_command, env_string)}, +#line 31 "confitems.gperf" + {"sloppiness", ITEM(sloppiness, sloppiness)}, +#line 22 "confitems.gperf" + {"hash_dir", ITEM(hash_dir, bool)}, +#line 21 "confitems.gperf" + {"hard_link", ITEM(hard_link, bool)}, +#line 33 "confitems.gperf" + {"temporary_dir", ITEM(temporary_dir, env_string)}, +#line 30 "confitems.gperf" + {"run_second_cpp", ITEM(run_second_cpp, bool)}, + {"",NULL,0,NULL}, {"",NULL,0,NULL}, +#line 29 "confitems.gperf" + {"recache", ITEM(recache, bool)}, +#line 10 "confitems.gperf" + {"base_dir", ITEM_V(base_dir, env_string, absolute_path)}, +#line 28 "confitems.gperf" + {"read_only", ITEM(read_only, bool)}, + {"",NULL,0,NULL}, {"",NULL,0,NULL}, {"",NULL,0,NULL}, + {"",NULL,0,NULL}, +#line 17 "confitems.gperf" + {"detect_shebang", ITEM(detect_shebang, bool)}, + {"",NULL,0,NULL}, {"",NULL,0,NULL}, {"",NULL,0,NULL}, + {"",NULL,0,NULL}, +#line 20 "confitems.gperf" + {"extra_files_to_hash", ITEM(extra_files_to_hash, env_string)} + }; + + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) + { + register int key = confitems_hash (str, len); + + if (key <= MAX_HASH_VALUE && key >= 0) + { + register const char *s = wordlist[key].name; + + if (*str == *s && !strcmp (str + 1, s + 1)) + return &wordlist[key]; + } + } + return 0; +} diff --git a/dev.mk.in b/dev.mk.in index 70af79161..cd4874b28 100644 --- a/dev.mk.in +++ b/dev.mk.in @@ -4,6 +4,7 @@ CFLAGS += -Werror CPPFLAGS += -MD -MP -MF .deps/$(subst .._,,$(subst /,_,$<)).d ASCIIDOC = asciidoc +GPERF = gperf XSLTPROC = xsltproc MANPAGE_XSL = /etc/asciidoc/docbook-xsl/manpage.xsl @@ -34,6 +35,7 @@ files_to_distclean += .deps version.c dev.mk source_dist_files = \ main.c $(base_sources) $(test_sources) $(headers) zlib/*.c zlib/*.h \ + confitems_lookup.c envtoconfitems_lookup.c \ config.h.in configure install-sh Makefile.in test.sh GPL-3.0.txt \ AUTHORS.txt INSTALL.txt LICENSE.txt MANUAL.txt NEWS.txt README.txt dist_files = \ @@ -45,6 +47,9 @@ ifneq ($(shell sed 's/.*"\(.*\)".*/\1/' version.c 2>/dev/null),$(version)) endif version.o: version.c +%_lookup.c: %.gperf + $(GPERF) $< >$@ + .PHONY: dist dist: $(dist_archives) diff --git a/envtoconfitems.gperf b/envtoconfitems.gperf new file mode 100644 index 000000000..d4ae4301b --- /dev/null +++ b/envtoconfitems.gperf @@ -0,0 +1,36 @@ +%language=ANSI-C +%enum +%struct-type +%readonly-tables +%define hash-function-name envtoconfitems_hash +%define lookup-function-name envtoconfitems_get +%define slot-name env_name +%define initializer-suffix ,"" +struct env_to_conf_item; +%% +BASEDIR, "base_dir" +CC, "compiler" +COMPILERCHECK, "compiler_check" +COMPRESS, "compression" +CPP2, "run_second_cpp" +DETECT_SHEBANG, "detect_shebang" +DIR, "cache_dir" +DIRECT, "direct_mode" +DISABLE, "disable" +EXTENSION, "cpp_extension" +EXTRAFILES, "extra_files_to_hash" +HARDLINK, "hard_link" +HASHDIR, "hash_dir" +LOGFILE, "log_file" +MAXFILES, "max_files" +MAXSIZE, "max_size" +NLEVELS, "cache_dir_levels" +PATH, "path" +PREFIX, "prefix_command" +READONLY, "read_only" +RECACHE, "recache" +SLOPPINESS, "sloppiness" +STATS, "stats" +TEMPDIR, "temporary_dir" +UMASK, "umask" +UNIFY, "unify" diff --git a/envtoconfitems_lookup.c b/envtoconfitems_lookup.c new file mode 100644 index 000000000..5121f8ef8 --- /dev/null +++ b/envtoconfitems_lookup.c @@ -0,0 +1,176 @@ +/* ANSI-C code produced by gperf version 3.0.3 */ +/* Command-line: gperf envtoconfitems.gperf */ +/* Computed positions: -k'1-2' */ + +#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ + && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ + && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ + && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ + && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ + && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ + && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ + && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ + && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ + && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ + && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ + && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ + && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ + && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ + && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ + && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ + && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ + && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ + && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ + && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ + && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ + && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ + && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) +/* The character set is not based on ISO-646. */ +#error "gperf generated tables don't work with this execution character set. Please report a bug to ." +#endif + +#line 9 "envtoconfitems.gperf" +struct env_to_conf_item; +/* maximum key range = 42, duplicates = 0 */ + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static unsigned int +envtoconfitems_hash (register const char *str, register unsigned int len) +{ + static const unsigned char asso_values[] = + { + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 15, 0, 0, 0, 0, + 44, 44, 20, 0, 44, 44, 15, 5, 15, 10, + 0, 44, 5, 0, 10, 10, 44, 44, 0, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44 + }; + return len + asso_values[(unsigned char)str[1]] + asso_values[(unsigned char)str[0]]; +} + +#ifdef __GNUC__ +__inline +#ifdef __GNUC_STDC_INLINE__ +__attribute__ ((__gnu_inline__)) +#endif +#endif +const struct env_to_conf_item * +envtoconfitems_get (register const char *str, register unsigned int len) +{ + enum + { + TOTAL_KEYWORDS = 26, + MIN_WORD_LENGTH = 2, + MAX_WORD_LENGTH = 14, + MIN_HASH_VALUE = 2, + MAX_HASH_VALUE = 43 + }; + + static const struct env_to_conf_item wordlist[] = + { + {"",""}, {"",""}, +#line 12 "envtoconfitems.gperf" + {"CC", "compiler"}, +#line 17 "envtoconfitems.gperf" + {"DIR", "cache_dir"}, +#line 15 "envtoconfitems.gperf" + {"CPP2", "run_second_cpp"}, + {"",""}, +#line 18 "envtoconfitems.gperf" + {"DIRECT", "direct_mode"}, +#line 19 "envtoconfitems.gperf" + {"DISABLE", "disable"}, + {"",""}, +#line 20 "envtoconfitems.gperf" + {"EXTENSION", "cpp_extension"}, +#line 21 "envtoconfitems.gperf" + {"EXTRAFILES", "extra_files_to_hash"}, +#line 29 "envtoconfitems.gperf" + {"PREFIX", "prefix_command"}, +#line 31 "envtoconfitems.gperf" + {"RECACHE", "recache"}, +#line 30 "envtoconfitems.gperf" + {"READONLY", "read_only"}, +#line 16 "envtoconfitems.gperf" + {"DETECT_SHEBANG", "detect_shebang"}, +#line 33 "envtoconfitems.gperf" + {"STATS", "stats"}, + {"",""}, +#line 34 "envtoconfitems.gperf" + {"TEMPDIR", "temporary_dir"}, +#line 14 "envtoconfitems.gperf" + {"COMPRESS", "compression"}, +#line 28 "envtoconfitems.gperf" + {"PATH", "path"}, +#line 35 "envtoconfitems.gperf" + {"UMASK", "umask"}, + {"",""}, +#line 11 "envtoconfitems.gperf" + {"BASEDIR", "base_dir"}, +#line 13 "envtoconfitems.gperf" + {"COMPILERCHECK", "compiler_check"}, + {"",""}, +#line 32 "envtoconfitems.gperf" + {"SLOPPINESS", "sloppiness"}, + {"",""}, +#line 26 "envtoconfitems.gperf" + {"MAXSIZE", "max_size"}, +#line 25 "envtoconfitems.gperf" + {"MAXFILES", "max_files"}, + {"",""}, +#line 36 "envtoconfitems.gperf" + {"UNIFY", "unify"}, + {"",""}, +#line 24 "envtoconfitems.gperf" + {"LOGFILE", "log_file"}, + {"",""}, {"",""}, {"",""}, {"",""}, +#line 27 "envtoconfitems.gperf" + {"NLEVELS", "cache_dir_levels"}, + {"",""}, {"",""}, {"",""}, {"",""}, +#line 23 "envtoconfitems.gperf" + {"HASHDIR", "hash_dir"}, +#line 22 "envtoconfitems.gperf" + {"HARDLINK", "hard_link"} + }; + + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) + { + register int key = envtoconfitems_hash (str, len); + + if (key <= MAX_HASH_VALUE && key >= 0) + { + register const char *s = wordlist[key].env_name; + + if (*str == *s && !strcmp (str + 1, s + 1)) + return &wordlist[key]; + } + } + return 0; +} diff --git a/test/test_conf.c b/test/test_conf.c index f2f4e5ae7..cf6a61877 100644 --- a/test/test_conf.c +++ b/test/test_conf.c @@ -42,18 +42,6 @@ free_received_conf_items(void) TEST_SUITE(conf) -TEST(conf_item_table_should_be_sorted) -{ - bool conf_verify_sortedness(); - CHECK(conf_verify_sortedness()); -} - -TEST(conf_env_item_table_should_be_sorted_and_otherwise_correct) -{ - bool conf_verify_env_table_correctness(); - CHECK(conf_verify_env_table_correctness()); -} - TEST(conf_create) { struct conf *conf = conf_create();