diff options
-rw-r--r-- | src/blogc-make/exec.c | 2 | ||||
-rw-r--r-- | src/blogc-make/settings.c | 32 | ||||
-rw-r--r-- | src/blogc-make/settings.h | 2 | ||||
-rw-r--r-- | tests/blogc-make/check_exec.c | 8 | ||||
-rw-r--r-- | tests/blogc-make/check_settings.c | 48 |
5 files changed, 46 insertions, 46 deletions
diff --git a/src/blogc-make/exec.c b/src/blogc-make/exec.c index 5f508e6..df028c2 100644 --- a/src/blogc-make/exec.c +++ b/src/blogc-make/exec.c @@ -222,7 +222,7 @@ bm_exec_build_blogc_cmd(const char *blogc_bin, bm_settings_t *settings, bc_string_append(rv, blogc_bin); if (settings != NULL) { - bc_trie_foreach(settings->env, + bc_trie_foreach(settings->global, (bc_trie_foreach_func_t) list_variables, rv); } diff --git a/src/blogc-make/settings.c b/src/blogc-make/settings.c index 50092ac..320c50d 100644 --- a/src/blogc-make/settings.c +++ b/src/blogc-make/settings.c @@ -94,7 +94,7 @@ bm_settings_parse(const char *content, size_t content_len, bc_error_t **err) bm_settings_t *rv = bc_malloc(sizeof(bm_settings_t)); rv->root_dir = NULL; - rv->env = bc_trie_new(free); + rv->global = bc_trie_new(free); rv->settings = bc_trie_new(free); rv->posts = NULL; rv->pages = NULL; @@ -105,13 +105,13 @@ bm_settings_parse(const char *content, size_t content_len, bc_error_t **err) // even if I never released a version with it, but some people is using // it already. const char *section = NULL; - char **env = bc_config_list_keys(config, "global"); - if (env != NULL) { + char **global = bc_config_list_keys(config, "global"); + if (global != NULL) { section = "global"; } else { - env = bc_config_list_keys(config, "environment"); - if (env != NULL) { + global = bc_config_list_keys(config, "environment"); + if (global != NULL) { section = "environment"; } else { @@ -119,26 +119,26 @@ bm_settings_parse(const char *content, size_t content_len, bc_error_t **err) } } - if (env != NULL) { - for (size_t i = 0; env[i] != NULL; i++) { - for (size_t j = 0; env[i][j] != '\0'; j++) { - if (!((env[i][j] >= 'A' && env[i][j] <= 'Z') || env[i][j] == '_')) { + if (global != NULL) { + for (size_t i = 0; global[i] != NULL; i++) { + for (size_t j = 0; global[i][j] != '\0'; j++) { + if (!((global[i][j] >= 'A' && global[i][j] <= 'Z') || global[i][j] == '_')) { *err = bc_error_new_printf(BLOGC_MAKE_ERROR_SETTINGS, - "Invalid [%s] key: %s", section, env[i]); - bc_strv_free(env); + "Invalid [%s] key: %s", section, global[i]); + bc_strv_free(global); bm_settings_free(rv); rv = NULL; goto cleanup; } } - bc_trie_insert(rv->env, env[i], - bc_strdup(bc_config_get(config, section, env[i]))); + bc_trie_insert(rv->global, global[i], + bc_strdup(bc_config_get(config, section, global[i]))); } } - bc_strv_free(env); + bc_strv_free(global); for (size_t i = 0; required_global[i] != NULL; i++) { - const char *value = bc_trie_lookup(rv->env, required_global[i]); + const char *value = bc_trie_lookup(rv->global, required_global[i]); if (value == NULL || value[0] == '\0') { *err = bc_error_new_printf(BLOGC_MAKE_ERROR_SETTINGS, "[%s] key required but not found or empty: %s", section, @@ -202,7 +202,7 @@ bm_settings_free(bm_settings_t *settings) if (settings == NULL) return; free(settings->root_dir); - bc_trie_free(settings->env); + bc_trie_free(settings->global); bc_trie_free(settings->settings); bc_strv_free(settings->posts); bc_strv_free(settings->pages); diff --git a/src/blogc-make/settings.h b/src/blogc-make/settings.h index bfd66e0..b1ea117 100644 --- a/src/blogc-make/settings.h +++ b/src/blogc-make/settings.h @@ -15,7 +15,7 @@ typedef struct { char *root_dir; - bc_trie_t *env; + bc_trie_t *global; bc_trie_t *settings; char **posts; char **pages; diff --git a/tests/blogc-make/check_exec.c b/tests/blogc-make/check_exec.c index 681e443..506c5f6 100644 --- a/tests/blogc-make/check_exec.c +++ b/tests/blogc-make/check_exec.c @@ -74,9 +74,9 @@ test_build_blogc_cmd_with_settings(void **state) bm_settings_t *settings = bc_malloc(sizeof(bm_settings_t)); settings->settings = bc_trie_new(free); bc_trie_insert(settings->settings, "locale", bc_strdup("en_US.utf8")); - settings->env = bc_trie_new(free); - bc_trie_insert(settings->env, "FOO", bc_strdup("BAR")); - bc_trie_insert(settings->env, "BAR", bc_strdup("BAZ")); + settings->global = bc_trie_new(free); + bc_trie_insert(settings->global, "FOO", bc_strdup("BAR")); + bc_trie_insert(settings->global, "BAR", bc_strdup("BAZ")); bc_trie_t *variables = bc_trie_new(free); bc_trie_insert(variables, "LOL", bc_strdup("HEHE")); @@ -101,7 +101,7 @@ test_build_blogc_cmd_with_settings(void **state) bc_trie_free(variables); bc_trie_free(settings->settings); - bc_trie_free(settings->env); + bc_trie_free(settings->global); free(settings); } diff --git a/tests/blogc-make/check_settings.c b/tests/blogc-make/check_settings.c index 93aed59..6f90291 100644 --- a/tests/blogc-make/check_settings.c +++ b/tests/blogc-make/check_settings.c @@ -121,14 +121,14 @@ test_settings2(void **state) assert_null(err); assert_non_null(s); assert_null(s->root_dir); - assert_int_equal(bc_trie_size(s->env), 7); - assert_string_equal(bc_trie_lookup(s->env, "BOLA"), "asd"); - assert_string_equal(bc_trie_lookup(s->env, "GUDA"), "qwe"); - assert_string_equal(bc_trie_lookup(s->env, "AUTHOR_NAME"), "chunda"); - assert_string_equal(bc_trie_lookup(s->env, "AUTHOR_EMAIL"), "chunda@example.com"); - assert_string_equal(bc_trie_lookup(s->env, "SITE_TITLE"), "Fuuuuuuuuu"); - assert_string_equal(bc_trie_lookup(s->env, "SITE_TAGLINE"), "My cool tagline"); - assert_string_equal(bc_trie_lookup(s->env, "BASE_DOMAIN"), "http://example.com"); + assert_int_equal(bc_trie_size(s->global), 7); + assert_string_equal(bc_trie_lookup(s->global, "BOLA"), "asd"); + assert_string_equal(bc_trie_lookup(s->global, "GUDA"), "qwe"); + assert_string_equal(bc_trie_lookup(s->global, "AUTHOR_NAME"), "chunda"); + assert_string_equal(bc_trie_lookup(s->global, "AUTHOR_EMAIL"), "chunda@example.com"); + assert_string_equal(bc_trie_lookup(s->global, "SITE_TITLE"), "Fuuuuuuuuu"); + assert_string_equal(bc_trie_lookup(s->global, "SITE_TAGLINE"), "My cool tagline"); + assert_string_equal(bc_trie_lookup(s->global, "BASE_DOMAIN"), "http://example.com"); assert_int_equal(bc_trie_size(s->settings), 17); assert_string_equal(bc_trie_lookup(s->settings, "source_ext"), ".txt"); assert_string_equal(bc_trie_lookup(s->settings, "html_ext"), "/index.html"); @@ -213,14 +213,14 @@ test_settings_env2(void **state) assert_null(err); assert_non_null(s); assert_null(s->root_dir); - assert_int_equal(bc_trie_size(s->env), 7); - assert_string_equal(bc_trie_lookup(s->env, "BOLA"), "asd"); - assert_string_equal(bc_trie_lookup(s->env, "GUDA"), "qwe"); - assert_string_equal(bc_trie_lookup(s->env, "AUTHOR_NAME"), "chunda"); - assert_string_equal(bc_trie_lookup(s->env, "AUTHOR_EMAIL"), "chunda@example.com"); - assert_string_equal(bc_trie_lookup(s->env, "SITE_TITLE"), "Fuuuuuuuuu"); - assert_string_equal(bc_trie_lookup(s->env, "SITE_TAGLINE"), "My cool tagline"); - assert_string_equal(bc_trie_lookup(s->env, "BASE_DOMAIN"), "http://example.com"); + assert_int_equal(bc_trie_size(s->global), 7); + assert_string_equal(bc_trie_lookup(s->global, "BOLA"), "asd"); + assert_string_equal(bc_trie_lookup(s->global, "GUDA"), "qwe"); + assert_string_equal(bc_trie_lookup(s->global, "AUTHOR_NAME"), "chunda"); + assert_string_equal(bc_trie_lookup(s->global, "AUTHOR_EMAIL"), "chunda@example.com"); + assert_string_equal(bc_trie_lookup(s->global, "SITE_TITLE"), "Fuuuuuuuuu"); + assert_string_equal(bc_trie_lookup(s->global, "SITE_TAGLINE"), "My cool tagline"); + assert_string_equal(bc_trie_lookup(s->global, "BASE_DOMAIN"), "http://example.com"); assert_int_equal(bc_trie_size(s->settings), 17); assert_string_equal(bc_trie_lookup(s->settings, "source_ext"), ".txt"); assert_string_equal(bc_trie_lookup(s->settings, "html_ext"), "/index.html"); @@ -305,14 +305,14 @@ test_settings_copy_files(void **state) assert_null(err); assert_non_null(s); assert_null(s->root_dir); - assert_int_equal(bc_trie_size(s->env), 7); - assert_string_equal(bc_trie_lookup(s->env, "BOLA"), "asd"); - assert_string_equal(bc_trie_lookup(s->env, "GUDA"), "qwe"); - assert_string_equal(bc_trie_lookup(s->env, "AUTHOR_NAME"), "chunda"); - assert_string_equal(bc_trie_lookup(s->env, "AUTHOR_EMAIL"), "chunda@example.com"); - assert_string_equal(bc_trie_lookup(s->env, "SITE_TITLE"), "Fuuuuuuuuu"); - assert_string_equal(bc_trie_lookup(s->env, "SITE_TAGLINE"), "My cool tagline"); - assert_string_equal(bc_trie_lookup(s->env, "BASE_DOMAIN"), "http://example.com"); + assert_int_equal(bc_trie_size(s->global), 7); + assert_string_equal(bc_trie_lookup(s->global, "BOLA"), "asd"); + assert_string_equal(bc_trie_lookup(s->global, "GUDA"), "qwe"); + assert_string_equal(bc_trie_lookup(s->global, "AUTHOR_NAME"), "chunda"); + assert_string_equal(bc_trie_lookup(s->global, "AUTHOR_EMAIL"), "chunda@example.com"); + assert_string_equal(bc_trie_lookup(s->global, "SITE_TITLE"), "Fuuuuuuuuu"); + assert_string_equal(bc_trie_lookup(s->global, "SITE_TAGLINE"), "My cool tagline"); + assert_string_equal(bc_trie_lookup(s->global, "BASE_DOMAIN"), "http://example.com"); assert_int_equal(bc_trie_size(s->settings), 17); assert_string_equal(bc_trie_lookup(s->settings, "source_ext"), ".txt"); assert_string_equal(bc_trie_lookup(s->settings, "html_ext"), "/index.html"); |