From a319fe44f6d50d25f546e17ad9907eedd9a358a0 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Sat, 3 Sep 2016 20:42:17 +0200 Subject: *: s/sb_/bc_/g --- src/blogc/renderer.c | 70 ++++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'src/blogc/renderer.c') diff --git a/src/blogc/renderer.c b/src/blogc/renderer.c index 97a226e..409c75e 100644 --- a/src/blogc/renderer.c +++ b/src/blogc/renderer.c @@ -20,58 +20,58 @@ const char* -blogc_get_variable(const char *name, sb_trie_t *global, sb_trie_t *local) +blogc_get_variable(const char *name, bc_trie_t *global, bc_trie_t *local) { const char *rv = NULL; if (local != NULL) { - rv = sb_trie_lookup(local, name); + rv = bc_trie_lookup(local, name); if (rv != NULL) return rv; } if (global != NULL) - rv = sb_trie_lookup(global, name); + rv = bc_trie_lookup(global, name); return rv; } char* -blogc_format_date(const char *date, sb_trie_t *global, sb_trie_t *local) +blogc_format_date(const char *date, bc_trie_t *global, bc_trie_t *local) { const char *date_format = blogc_get_variable("DATE_FORMAT", global, local); if (date == NULL) return NULL; if (date_format == NULL) - return sb_strdup(date); + return bc_strdup(date); blogc_error_t *err = NULL; char *rv = blogc_convert_datetime(date, date_format, &err); if (err != NULL) { blogc_error_print(err); blogc_error_free(err); - return sb_strdup(date); + return bc_strdup(date); } return rv; } char* -blogc_format_variable(const char *name, sb_trie_t *global, sb_trie_t *local, - sb_slist_t *foreach_var) +blogc_format_variable(const char *name, bc_trie_t *global, bc_trie_t *local, + bc_slist_t *foreach_var) { // if used asked for a variable that exists, just return it right away const char *value = blogc_get_variable(name, global, local); if (value != NULL) - return sb_strdup(value); + return bc_strdup(value); // do the same for special variable 'FOREACH_ITEM' if (0 == strcmp(name, "FOREACH_ITEM")) { if (foreach_var != NULL && foreach_var->data != NULL) { - return sb_strdup(foreach_var->data); + return bc_strdup(foreach_var->data); } return NULL; } - char *var = sb_strdup(name); + char *var = bc_strdup(name); size_t i; size_t last = strlen(var); @@ -96,7 +96,7 @@ blogc_format_variable(const char *name, sb_trie_t *global, sb_trie_t *local, bool must_format = false; - if (sb_str_ends_with(var, "_FORMATTED")) { + if (bc_str_ends_with(var, "_FORMATTED")) { var[strlen(var) - 10] = '\0'; must_format = true; } @@ -115,23 +115,23 @@ blogc_format_variable(const char *name, sb_trie_t *global, sb_trie_t *local, char *rv = NULL; if (must_format) { - if (sb_str_starts_with(name, "DATE_")) { + if (bc_str_starts_with(name, "DATE_")) { rv = blogc_format_date(value, global, local); } else { fprintf(stderr, "warning: no formatter found for '%s', " "ignoring.\n", var); - rv = sb_strdup(value); + rv = bc_strdup(value); } } else { - rv = sb_strdup(value); + rv = bc_strdup(value); } free(var); if (len > 0) { - char *tmp = sb_strndup(rv, len); + char *tmp = bc_strndup(rv, len); free(rv); rv = tmp; } @@ -140,19 +140,19 @@ blogc_format_variable(const char *name, sb_trie_t *global, sb_trie_t *local, } -sb_slist_t* -blogc_split_list_variable(const char *name, sb_trie_t *global, sb_trie_t *local) +bc_slist_t* +blogc_split_list_variable(const char *name, bc_trie_t *global, bc_trie_t *local) { const char *value = blogc_get_variable(name, global, local); if (value == NULL) return NULL; - sb_slist_t *rv = NULL; + bc_slist_t *rv = NULL; - char **tmp = sb_str_split(value, ' ', 0); + char **tmp = bc_str_split(value, ' ', 0); for (unsigned int i = 0; tmp[i] != NULL; i++) { if (tmp[i][0] != '\0') // ignore empty strings - rv = sb_slist_append(rv, tmp[i]); + rv = bc_slist_append(rv, tmp[i]); else free(tmp[i]); } @@ -163,25 +163,25 @@ blogc_split_list_variable(const char *name, sb_trie_t *global, sb_trie_t *local) char* -blogc_render(sb_slist_t *tmpl, sb_slist_t *sources, sb_trie_t *config, bool listing) +blogc_render(bc_slist_t *tmpl, bc_slist_t *sources, bc_trie_t *config, bool listing) { if (tmpl == NULL) return NULL; - sb_slist_t *current_source = NULL; - sb_slist_t *listing_start = NULL; + bc_slist_t *current_source = NULL; + bc_slist_t *listing_start = NULL; - sb_string_t *str = sb_string_new(); + bc_string_t *str = bc_string_new(); - sb_trie_t *tmp_source = NULL; + bc_trie_t *tmp_source = NULL; char *config_value = NULL; char *defined = NULL; unsigned int if_count = 0; - sb_slist_t *foreach_var = NULL; - sb_slist_t *foreach_var_start = NULL; - sb_slist_t *foreach_start = NULL; + bc_slist_t *foreach_var = NULL; + bc_slist_t *foreach_var_start = NULL; + bc_slist_t *foreach_start = NULL; bool if_not = false; bool inside_block = false; @@ -190,7 +190,7 @@ blogc_render(sb_slist_t *tmpl, sb_slist_t *sources, sb_trie_t *config, bool list int cmp = 0; - sb_slist_t *tmp = tmpl; + bc_slist_t *tmp = tmpl; while (tmp != NULL) { blogc_template_stmt_t *stmt = tmp->data; @@ -198,7 +198,7 @@ blogc_render(sb_slist_t *tmpl, sb_slist_t *sources, sb_trie_t *config, bool list case BLOGC_TEMPLATE_CONTENT_STMT: if (stmt->value != NULL) - sb_string_append(str, stmt->value); + bc_string_append(str, stmt->value); break; case BLOGC_TEMPLATE_BLOCK_STMT: @@ -255,7 +255,7 @@ blogc_render(sb_slist_t *tmpl, sb_slist_t *sources, sb_trie_t *config, bool list config_value = blogc_format_variable(stmt->value, config, inside_block ? tmp_source : NULL, foreach_var); if (config_value != NULL) { - sb_string_append(str, config_value); + bc_string_append(str, config_value); free(config_value); config_value = NULL; break; @@ -297,7 +297,7 @@ blogc_render(sb_slist_t *tmpl, sb_slist_t *sources, sb_trie_t *config, bool list (stmt->value2[0] == '"') && (stmt->value2[strlen(stmt->value2) - 1] == '"')) { - defined2 = sb_strndup(stmt->value2 + 1, + defined2 = bc_strndup(stmt->value2 + 1, strlen(stmt->value2) - 2); } else { @@ -443,7 +443,7 @@ blogc_render(sb_slist_t *tmpl, sb_slist_t *sources, sb_trie_t *config, bool list } } foreach_start = NULL; - sb_slist_free_full(foreach_var_start, free); + bc_slist_free_full(foreach_var_start, free); foreach_var_start = NULL; break; } @@ -453,5 +453,5 @@ blogc_render(sb_slist_t *tmpl, sb_slist_t *sources, sb_trie_t *config, bool list // no need to free temporary variables here. the template parser makes sure // that templates are sane and statements are closed. - return sb_string_free(str, false); + return bc_string_free(str, false); } -- cgit v1.2.3-18-g5258