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-git-receiver/main.c | 18 +-- src/blogc-runserver/main.c | 26 ++-- src/blogc/content-parser.c | 334 +++++++++++++++++++++--------------------- src/blogc/datetime-parser.c | 2 +- src/blogc/debug.c | 4 +- src/blogc/debug.h | 2 +- src/blogc/error.c | 10 +- src/blogc/file.c | 8 +- src/blogc/loader.c | 82 +++++------ src/blogc/loader.h | 6 +- src/blogc/main.c | 50 +++---- src/blogc/renderer.c | 70 ++++----- src/blogc/renderer.h | 14 +- src/blogc/source-parser.c | 28 ++-- src/blogc/source-parser.h | 2 +- src/blogc/template-parser.c | 40 ++--- src/blogc/template-parser.h | 4 +- src/common/utf8.c | 2 +- src/common/utf8.h | 2 +- src/common/utils.c | 206 +++++++++++++------------- src/common/utils.h | 98 ++++++------- 21 files changed, 504 insertions(+), 504 deletions(-) (limited to 'src') diff --git a/src/blogc-git-receiver/main.c b/src/blogc-git-receiver/main.c index 554ec0c..86e1027 100644 --- a/src/blogc-git-receiver/main.c +++ b/src/blogc-git-receiver/main.c @@ -60,7 +60,7 @@ rmdir_recursive(const char *dir) while (NULL != (e = readdir(d))) { if ((0 == strcmp(e->d_name, ".")) || (0 == strcmp(e->d_name, ".."))) continue; - char *f = sb_strdup_printf("%s/%s", dir, e->d_name); + char *f = bc_strdup_printf("%s/%s", dir, e->d_name); if (0 != stat(f, &buf)) { fprintf(stderr, "error: failed to stat directory entry (%s): %s\n", e->d_name, strerror(errno)); @@ -131,7 +131,7 @@ git_shell(int argc, char *argv[]) } // get git repository - command_orig = sb_strdup(argv[2]); + command_orig = bc_strdup(argv[2]); char *p, *r; for (p = command_orig; *p != ' ' && *p != '\0'; p++); if (*p == ' ') @@ -146,7 +146,7 @@ git_shell(int argc, char *argv[]) if (*--p == '/') *p = '\0'; - repo = sb_strdup_printf("repos/%s", r); + repo = bc_strdup_printf("repos/%s", r); // check if repository is sane if (0 == strlen(repo)) { @@ -166,7 +166,7 @@ git_shell(int argc, char *argv[]) } if (0 != access(repo, F_OK)) { - char *git_init_cmd = sb_strdup_printf( + char *git_init_cmd = bc_strdup_printf( "git init --bare \"%s\" > /dev/null", repo); if (0 != system(git_init_cmd)) { fprintf(stderr, "error: failed to create git repository: %s\n", @@ -243,7 +243,7 @@ git_shell(int argc, char *argv[]) } git_exec: - command_name = sb_strdup(argv[2]); + command_name = bc_strdup(argv[2]); for (p = command_name; *p != ' ' && *p != '\0'; p++); if (*p == ' ') *p = '\0'; @@ -386,7 +386,7 @@ git_pre_receive_hook(int argc, char *argv[]) goto cleanup; } - repo_dir = sb_strdup(buffer); + repo_dir = bc_strdup(buffer); char dir[] = "/tmp/blogc_XXXXXX"; if (NULL == mkdtemp(dir)) { @@ -394,7 +394,7 @@ git_pre_receive_hook(int argc, char *argv[]) goto cleanup; } - char *git_archive_cmd = sb_strdup_printf( + char *git_archive_cmd = bc_strdup_printf( "git archive \"%s\" | tar -x -C \"%s\" -f -", master, dir); if (0 != system(git_archive_cmd)) { fprintf(stderr, "error: failed to extract git content to temporary " @@ -425,8 +425,8 @@ git_pre_receive_hook(int argc, char *argv[]) } unsigned long epoch = time(NULL); - output_dir = sb_strdup_printf("%s/builds/%s-%lu", home, master, epoch); - char *gmake_cmd = sb_strdup_printf( + output_dir = bc_strdup_printf("%s/builds/%s-%lu", home, master, epoch); + char *gmake_cmd = bc_strdup_printf( "gmake -j%d OUTPUT_DIR=\"%s\" BLOGC_GIT_RECEIVER=1", cpu_count(), output_dir); fprintf(stdout, "running command: %s\n\n", gmake_cmd); diff --git a/src/blogc-runserver/main.c b/src/blogc-runserver/main.c index 2a756f1..93f404a 100644 --- a/src/blogc-runserver/main.c +++ b/src/blogc-runserver/main.c @@ -87,9 +87,9 @@ guess_content_type(const char *filename, int fd) const char* charset = magic_descriptor(magic_charset, newfd); close(newfd); if (charset != NULL) - return sb_strdup_printf("%s; charset=%s", supported, charset); + return bc_strdup_printf("%s; charset=%s", supported, charset); } - return sb_strdup(supported); + return bc_strdup(supported); } libmagic: @@ -100,9 +100,9 @@ libmagic: const char* content_type = magic_descriptor(magic_all, newfd); close(newfd); if (content_type != NULL) - return sb_strdup(content_type); + return bc_strdup(content_type); } - return sb_strdup("application/octet-stream"); + return bc_strdup("application/octet-stream"); } @@ -128,7 +128,7 @@ handler(struct evhttp_request *request, void *ptr) goto point1; } - char *abs_path = sb_strdup_printf("%s/%s", root, decoded_path); + char *abs_path = bc_strdup_printf("%s/%s", root, decoded_path); char *real_path = realpath(abs_path, NULL); free(abs_path); @@ -162,10 +162,10 @@ handler(struct evhttp_request *request, void *ptr) for (unsigned int i = 0; content_types[i].mimetype != NULL; i++) { if (content_types[i].index == NULL) continue; - char *f = sb_strdup_printf("%s/%s", real_path, + char *f = bc_strdup_printf("%s/%s", real_path, content_types[i].index); if (0 == access(f, F_OK)) { - found = sb_strdup(f); + found = bc_strdup(f); break; } free(f); @@ -200,7 +200,7 @@ handler(struct evhttp_request *request, void *ptr) struct evkeyvalq *headers = evhttp_request_get_output_headers(request); if (add_slash) { - char *tmp = sb_strdup_printf("%s/", path); + char *tmp = bc_strdup_printf("%s/", path); evhttp_add_header(headers, "Location", tmp); free(tmp); // production webservers usually returns 301 in such cases, but 302 is @@ -210,7 +210,7 @@ handler(struct evhttp_request *request, void *ptr) } evhttp_add_header(headers, "Content-Type", type); - char *content_length = sb_strdup_printf("%zu", st.st_size); + char *content_length = bc_strdup_printf("%zu", st.st_size); evhttp_add_header(headers, "Content-Length", content_length); free(content_length); @@ -313,9 +313,9 @@ main(int argc, char **argv) goto cleanup; case 't': if (argv[i][2] != '\0') - host = sb_strdup(argv[i] + 2); + host = bc_strdup(argv[i] + 2); else - host = sb_strdup(argv[++i]); + host = bc_strdup(argv[++i]); break; case 'p': if (argv[i][2] != '\0') @@ -340,7 +340,7 @@ main(int argc, char **argv) goto cleanup; } args++; - docroot = sb_strdup(argv[i]); + docroot = bc_strdup(argv[i]); } } @@ -353,7 +353,7 @@ main(int argc, char **argv) } if (host == NULL) - host = sb_strdup("127.0.0.1"); + host = bc_strdup("127.0.0.1"); magic_all = magic_open(MAGIC_MIME); magic_charset = magic_open(MAGIC_MIME_ENCODING); diff --git a/src/blogc/content-parser.c b/src/blogc/content-parser.c index e751548..23586bb 100644 --- a/src/blogc/content-parser.c +++ b/src/blogc/content-parser.c @@ -22,7 +22,7 @@ blogc_slugify(const char *str) { if (str == NULL) return NULL; - char *new_str = sb_strdup(str); + char *new_str = bc_strdup(str); int diff = 'a' - 'A'; // just to avoid magic numbers for (size_t i = 0; new_str[i] != '\0'; i++) { if (new_str[i] >= 'a' && new_str[i] <= 'z') @@ -60,13 +60,13 @@ htmlentities(char c) static void -htmlentities_append(sb_string_t *str, char c) +htmlentities_append(bc_string_t *str, char c) { const char *e = htmlentities(c); if (e == NULL) - sb_string_append_c(str, c); + bc_string_append_c(str, c); else - sb_string_append(str, e); + bc_string_append(str, e); } @@ -75,10 +75,10 @@ blogc_htmlentities(const char *str) { if (str == NULL) return NULL; - sb_string_t *rv = sb_string_new(); + bc_string_t *rv = bc_string_new(); for (size_t i = 0; str[i] != '\0'; i++) htmlentities_append(rv, str[i]); - return sb_string_free(rv, false); + return bc_string_free(rv, false); } @@ -87,7 +87,7 @@ blogc_fix_description(const char *paragraph) { if (paragraph == NULL) return NULL; - sb_string_t *rv = sb_string_new(); + bc_string_t *rv = bc_string_new(); bool last = false; bool newline = false; char *tmp = NULL; @@ -101,12 +101,12 @@ blogc_fix_description(const char *paragraph) case '\n': if (newline) break; - tmp = sb_strndup(paragraph + start, current - start); - sb_string_append(rv, sb_str_strip(tmp)); + tmp = bc_strndup(paragraph + start, current - start); + bc_string_append(rv, bc_str_strip(tmp)); free(tmp); tmp = NULL; if (!last) - sb_string_append_c(rv, ' '); + bc_string_append_c(rv, ' '); start = current + 1; newline = true; break; @@ -117,8 +117,8 @@ blogc_fix_description(const char *paragraph) break; current++; } - tmp = blogc_htmlentities(sb_str_strip(rv->str)); - sb_string_free(rv, true); + tmp = blogc_htmlentities(bc_str_strip(rv->str)); + bc_string_free(rv, true); return tmp; } @@ -189,7 +189,7 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) size_t start_link = 0; char *link1 = NULL; - sb_string_t *rv = sb_string_new(); + bc_string_t *rv = bc_string_new(); blogc_content_parser_inline_state_t state = CONTENT_INLINE_START; @@ -243,15 +243,15 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) state = CONTENT_INLINE_ASTERISK_DOUBLE; break; } - tmp = sb_str_find(src + current, '*'); + tmp = bc_str_find(src + current, '*'); if (tmp == NULL || ((tmp - src) >= src_len)) { - sb_string_append_c(rv, '*'); + bc_string_append_c(rv, '*'); state = CONTENT_INLINE_START; continue; } tmp2 = blogc_content_parse_inline_internal( src + current, (tmp - src) - current); - sb_string_append_printf(rv, "%s", tmp2); + bc_string_append_printf(rv, "%s", tmp2); current = tmp - src; tmp = NULL; free(tmp2); @@ -262,21 +262,21 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) case CONTENT_INLINE_ASTERISK_DOUBLE: tmp = src + current; do { - tmp = sb_str_find(tmp, '*'); + tmp = bc_str_find(tmp, '*'); if (((tmp - src) < src_len) && *(tmp + 1) == '*') { break; } tmp++; } while (tmp != NULL && (tmp - src) < src_len); if (tmp == NULL || ((tmp - src) >= src_len)) { - sb_string_append_c(rv, '*'); - sb_string_append_c(rv, '*'); + bc_string_append_c(rv, '*'); + bc_string_append_c(rv, '*'); state = CONTENT_INLINE_START; continue; } tmp2 = blogc_content_parse_inline_internal( src + current, (tmp - src) - current); - sb_string_append_printf(rv, "%s", tmp2); + bc_string_append_printf(rv, "%s", tmp2); current = tmp - src + 1; tmp = NULL; free(tmp2); @@ -289,15 +289,15 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) state = CONTENT_INLINE_UNDERSCORE_DOUBLE; break; } - tmp = sb_str_find(src + current, '_'); + tmp = bc_str_find(src + current, '_'); if (tmp == NULL || ((tmp - src) >= src_len)) { - sb_string_append_c(rv, '_'); + bc_string_append_c(rv, '_'); state = CONTENT_INLINE_START; continue; } tmp2 = blogc_content_parse_inline_internal( src + current, (tmp - src) - current); - sb_string_append_printf(rv, "%s", tmp2); + bc_string_append_printf(rv, "%s", tmp2); current = tmp - src; tmp = NULL; free(tmp2); @@ -308,21 +308,21 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) case CONTENT_INLINE_UNDERSCORE_DOUBLE: tmp = src + current; do { - tmp = sb_str_find(tmp, '_'); + tmp = bc_str_find(tmp, '_'); if (((tmp - src) < src_len) && *(tmp + 1) == '_') { break; } tmp++; } while (tmp != NULL && (tmp - src) < src_len); if (tmp == NULL || ((tmp - src) >= src_len)) { - sb_string_append_c(rv, '_'); - sb_string_append_c(rv, '_'); + bc_string_append_c(rv, '_'); + bc_string_append_c(rv, '_'); state = CONTENT_INLINE_START; continue; } tmp2 = blogc_content_parse_inline_internal( src + current, (tmp - src) - current); - sb_string_append_printf(rv, "%s", tmp2); + bc_string_append_printf(rv, "%s", tmp2); current = tmp - src + 1; tmp = NULL; free(tmp2); @@ -335,19 +335,19 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) state = CONTENT_INLINE_BACKTICKS_DOUBLE; break; } - tmp = sb_str_find(src + current, '`'); + tmp = bc_str_find(src + current, '`'); if (tmp == NULL || ((tmp - src) >= src_len)) { - sb_string_append_c(rv, '`'); + bc_string_append_c(rv, '`'); state = CONTENT_INLINE_START; continue; } - tmp3 = sb_strndup(src + current, (tmp - src) - current); + tmp3 = bc_strndup(src + current, (tmp - src) - current); tmp2 = blogc_htmlentities(tmp3); free(tmp3); tmp3 = NULL; - sb_string_append(rv, ""); - sb_string_append_escaped(rv, tmp2); - sb_string_append(rv, ""); + bc_string_append(rv, ""); + bc_string_append_escaped(rv, tmp2); + bc_string_append(rv, ""); current = tmp - src; tmp = NULL; free(tmp2); @@ -358,25 +358,25 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) case CONTENT_INLINE_BACKTICKS_DOUBLE: tmp = src + current; do { - tmp = sb_str_find(tmp, '`'); + tmp = bc_str_find(tmp, '`'); if (((tmp - src) < src_len) && *(tmp + 1) == '`') { break; } tmp++; } while (tmp != NULL && (tmp - src) < src_len); if (tmp == NULL || ((tmp - src) >= src_len)) { - sb_string_append_c(rv, '`'); - sb_string_append_c(rv, '`'); + bc_string_append_c(rv, '`'); + bc_string_append_c(rv, '`'); state = CONTENT_INLINE_START; continue; } - tmp3 = sb_strndup(src + current, (tmp - src) - current); + tmp3 = bc_strndup(src + current, (tmp - src) - current); tmp2 = blogc_htmlentities(tmp3); free(tmp3); tmp3 = NULL; - sb_string_append(rv, ""); - sb_string_append_escaped(rv, tmp2); - sb_string_append(rv, ""); + bc_string_append(rv, ""); + bc_string_append_escaped(rv, tmp2); + bc_string_append(rv, ""); current = tmp - src + 1; tmp = NULL; free(tmp2); @@ -397,24 +397,24 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) case CONTENT_INLINE_LINK_AUTO: tmp = src + current; do { - tmp = sb_str_find(tmp, ']'); + tmp = bc_str_find(tmp, ']'); if (((tmp - src) < src_len) && *(tmp + 1) == ']') { break; } tmp++; } while (tmp != NULL && (tmp - src) < src_len); if (tmp == NULL || ((tmp - src) >= src_len)) { - sb_string_append_c(rv, '['); - sb_string_append_c(rv, '['); + bc_string_append_c(rv, '['); + bc_string_append_c(rv, '['); state = CONTENT_INLINE_START; continue; } - tmp2 = sb_strndup(src + current, (tmp - src) - current); - sb_string_append(rv, ""); - sb_string_append_escaped(rv, tmp2); - sb_string_append(rv, ""); + tmp2 = bc_strndup(src + current, (tmp - src) - current); + bc_string_append(rv, ""); + bc_string_append_escaped(rv, tmp2); + bc_string_append(rv, ""); current = tmp - src + 1; tmp = NULL; free(tmp2); @@ -433,7 +433,7 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) } if (c == ']') { if (--count == 0) { - link1 = sb_strndup(src + start_link, current - start_link); + link1 = bc_strndup(src + start_link, current - start_link); state = CONTENT_INLINE_LINK_URL_START; } } @@ -447,7 +447,7 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) start = current + 1; break; } - sb_string_append_c(rv, '['); + bc_string_append_c(rv, '['); state = CONTENT_INLINE_START; current = start_link; start_link = 0; @@ -459,13 +459,13 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) break; } if (c == ')') { - tmp2 = sb_strndup(src + start, current - start); + tmp2 = bc_strndup(src + start, current - start); tmp3 = blogc_content_parse_inline(link1); free(link1); link1 = NULL; - sb_string_append(rv, "%s", tmp3); + bc_string_append(rv, "%s", tmp3); free(tmp2); tmp2 = NULL; free(tmp3); @@ -482,7 +482,7 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) start_link = current + 1; break; } - sb_string_append_c(rv, '!'); + bc_string_append_c(rv, '!'); state = CONTENT_INLINE_START; continue; @@ -492,7 +492,7 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) break; } if (c == ']') { - link1 = sb_strndup(src + start_link, current - start_link); + link1 = bc_strndup(src + start_link, current - start_link); state = CONTENT_INLINE_IMAGE_URL_START; } break; @@ -505,8 +505,8 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) start = current + 1; break; } - sb_string_append_c(rv, '!'); - sb_string_append_c(rv, '['); + bc_string_append_c(rv, '!'); + bc_string_append_c(rv, '['); state = CONTENT_INLINE_START; current = start_link; start_link = 0; @@ -518,12 +518,12 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) break; } if (c == ')') { - tmp2 = sb_strndup(src + start, current - start); - sb_string_append(rv, "\"");"); + tmp2 = bc_strndup(src + start, current - start); + bc_string_append(rv, "\"");"); free(tmp2); tmp2 = NULL; free(link1); @@ -536,31 +536,31 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) case CONTENT_INLINE_ENDASH: if (c == '-') { if (is_last) { - sb_string_append(rv, "–"); + bc_string_append(rv, "–"); state = CONTENT_INLINE_START; // wat break; } state = CONTENT_INLINE_EMDASH; break; } - sb_string_append_c(rv, '-'); + bc_string_append_c(rv, '-'); state = CONTENT_INLINE_START; continue; case CONTENT_INLINE_EMDASH: if (c == '-') { - sb_string_append(rv, "—"); + bc_string_append(rv, "—"); state = CONTENT_INLINE_START; break; } - sb_string_append(rv, "–"); + bc_string_append(rv, "–"); state = CONTENT_INLINE_START; continue; case CONTENT_INLINE_LINE_BREAK_START: if (c == ' ') { if (is_last) { - sb_string_append(rv, "
"); + bc_string_append(rv, "
"); state = CONTENT_INLINE_START; // wat break; } @@ -568,14 +568,14 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) state = CONTENT_INLINE_LINE_BREAK; break; } - sb_string_append_c(rv, ' '); + bc_string_append_c(rv, ' '); state = CONTENT_INLINE_START; continue; case CONTENT_INLINE_LINE_BREAK: if (c == ' ') { if (is_last) { - sb_string_append(rv, "
"); + bc_string_append(rv, "
"); state = CONTENT_INLINE_START; // wat break; } @@ -583,12 +583,12 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) break; } if (c == '\n' || c == '\r') { - sb_string_append_printf(rv, "
%c", c); + bc_string_append_printf(rv, "
%c", c); state = CONTENT_INLINE_START; break; } for (size_t i = 0; i < count; i++) - sb_string_append_c(rv, ' '); + bc_string_append_c(rv, ' '); state = CONTENT_INLINE_START; continue; } @@ -603,14 +603,14 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) case CONTENT_INLINE_IMAGE_ALT: case CONTENT_INLINE_IMAGE_URL_START: case CONTENT_INLINE_IMAGE_URL: - sb_string_append_c(rv, '!'); + bc_string_append_c(rv, '!'); case CONTENT_INLINE_LINK_CONTENT: case CONTENT_INLINE_LINK_URL_START: case CONTENT_INLINE_LINK_URL: tmp2 = blogc_content_parse_inline(src + start_link); - sb_string_append_c(rv, '['); - sb_string_append_escaped(rv, tmp2); // no need to free, as it wil be done below. + bc_string_append_c(rv, '['); + bc_string_append_escaped(rv, tmp2); // no need to free, as it wil be done below. break; // add all the other states here explicitly, so the compiler helps us @@ -635,7 +635,7 @@ blogc_content_parse_inline_internal(const char *src, size_t src_len) free(tmp3); free(link1); - return sb_string_free(rv, false); + return bc_string_free(rv, false); } @@ -702,11 +702,11 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) char d = '\0'; - sb_slist_t *lines = NULL; - sb_slist_t *lines2 = NULL; + bc_slist_t *lines = NULL; + bc_slist_t *lines2 = NULL; - sb_string_t *rv = sb_string_new(); - sb_string_t *tmp_str = NULL; + bc_string_t *rv = bc_string_new(); + bc_string_t *tmp_str = NULL; blogc_content_parser_state_t state = CONTENT_START_LINE; @@ -833,14 +833,14 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) if (c == '\n' || c == '\r' || is_last) { end = is_last && c != '\n' && c != '\r' ? src_len : (real_end != 0 ? real_end : current); - tmp = sb_strndup(src + start, end - start); + tmp = bc_strndup(src + start, end - start); parsed = blogc_content_parse_inline(tmp); slug = blogc_slugify(tmp); if (slug == NULL) - sb_string_append_printf(rv, "%s%s", + bc_string_append_printf(rv, "%s%s", header_level, parsed, header_level, line_ending); else - sb_string_append_printf(rv, "%s%s", + bc_string_append_printf(rv, "%s%s", header_level, slug, parsed, header_level, line_ending); free(slug); @@ -864,8 +864,8 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) case CONTENT_HTML_END: if (c == '\n' || c == '\r' || is_last) { - tmp = sb_strndup(src + start, end - start); - sb_string_append_printf(rv, "%s%s", tmp, line_ending); + tmp = bc_strndup(src + start, end - start); + bc_string_append_printf(rv, "%s%s", tmp, line_ending); free(tmp); tmp = NULL; state = CONTENT_START_LINE; @@ -878,7 +878,7 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) case CONTENT_BLOCKQUOTE: if (c == ' ' || c == '\t') break; - prefix = sb_strndup(src + start, current - start); + prefix = bc_strndup(src + start, current - start); state = CONTENT_BLOCKQUOTE_START; break; @@ -886,16 +886,16 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) if (c == '\n' || c == '\r' || is_last) { end = is_last && c != '\n' && c != '\r' ? src_len : (real_end != 0 ? real_end : current); - tmp = sb_strndup(src + start2, end - start2); - if (sb_str_starts_with(tmp, prefix)) { - lines = sb_slist_append(lines, sb_strdup(tmp + strlen(prefix))); + tmp = bc_strndup(src + start2, end - start2); + if (bc_str_starts_with(tmp, prefix)) { + lines = bc_slist_append(lines, bc_strdup(tmp + strlen(prefix))); state = CONTENT_BLOCKQUOTE_END; } else { state = CONTENT_PARAGRAPH; free(prefix); prefix = NULL; - sb_slist_free_full(lines, free); + bc_slist_free_full(lines, free); lines = NULL; if (is_last) { free(tmp); @@ -911,21 +911,21 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) case CONTENT_BLOCKQUOTE_END: if (c == '\n' || c == '\r' || is_last) { - tmp_str = sb_string_new(); - for (sb_slist_t *l = lines; l != NULL; l = l->next) - sb_string_append_printf(tmp_str, "%s%s", l->data, + tmp_str = bc_string_new(); + for (bc_slist_t *l = lines; l != NULL; l = l->next) + bc_string_append_printf(tmp_str, "%s%s", l->data, line_ending); // do not propagate description to blockquote parsing, // because we just want paragraphs from first level of // content. tmp = blogc_content_parse(tmp_str->str, NULL, NULL); - sb_string_append_printf(rv, "
%s
%s", + bc_string_append_printf(rv, "
%s
%s", tmp, line_ending); free(tmp); tmp = NULL; - sb_string_free(tmp_str, true); + bc_string_free(tmp_str, true); tmp_str = NULL; - sb_slist_free_full(lines, free); + bc_slist_free_full(lines, free); lines = NULL; free(prefix); prefix = NULL; @@ -941,7 +941,7 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) case CONTENT_CODE: if (c == ' ' || c == '\t') break; - prefix = sb_strndup(src + start, current - start); + prefix = bc_strndup(src + start, current - start); state = CONTENT_CODE_START; break; @@ -949,16 +949,16 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) if (c == '\n' || c == '\r' || is_last) { end = is_last && c != '\n' && c != '\r' ? src_len : (real_end != 0 ? real_end : current); - tmp = sb_strndup(src + start2, end - start2); - if (sb_str_starts_with(tmp, prefix)) { - lines = sb_slist_append(lines, sb_strdup(tmp + strlen(prefix))); + tmp = bc_strndup(src + start2, end - start2); + if (bc_str_starts_with(tmp, prefix)) { + lines = bc_slist_append(lines, bc_strdup(tmp + strlen(prefix))); state = CONTENT_CODE_END; } else { state = CONTENT_PARAGRAPH; free(prefix); prefix = NULL; - sb_slist_free_full(lines, free); + bc_slist_free_full(lines, free); lines = NULL; free(tmp); tmp = NULL; @@ -974,18 +974,18 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) case CONTENT_CODE_END: if (c == '\n' || c == '\r' || is_last) { - sb_string_append(rv, "
");
-                    for (sb_slist_t *l = lines; l != NULL; l = l->next) {
+                    bc_string_append(rv, "
");
+                    for (bc_slist_t *l = lines; l != NULL; l = l->next) {
                         char *tmp_line = blogc_htmlentities(l->data);
                         if (l->next == NULL)
-                            sb_string_append_printf(rv, "%s", tmp_line);
+                            bc_string_append_printf(rv, "%s", tmp_line);
                         else
-                            sb_string_append_printf(rv, "%s%s", tmp_line,
+                            bc_string_append_printf(rv, "%s%s", tmp_line,
                                 line_ending);
                         free(tmp_line);
                     }
-                    sb_string_append_printf(rv, "
%s", line_ending); - sb_slist_free_full(lines, free); + bc_string_append_printf(rv, "
%s", line_ending); + bc_slist_free_full(lines, free); lines = NULL; free(prefix); prefix = NULL; @@ -1007,7 +1007,7 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) } if (c == ' ' || c == '\t') break; - prefix = sb_strndup(src + start, current - start); + prefix = bc_strndup(src + start, current - start); state = CONTENT_UNORDERED_LIST_START; break; @@ -1016,7 +1016,7 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) break; } if (c == '\n' || c == '\r' || is_last) { - sb_string_append_printf(rv, "
%s", line_ending); + bc_string_append_printf(rv, "
%s", line_ending); state = CONTENT_START_LINE; start = current; d = '\0'; @@ -1029,30 +1029,30 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) if (c == '\n' || c == '\r' || is_last) { end = is_last && c != '\n' && c != '\r' ? src_len : (real_end != 0 ? real_end : current); - tmp = sb_strndup(src + start2, end - start2); - tmp2 = sb_strdup_printf("%-*s", strlen(prefix), ""); - if (sb_str_starts_with(tmp, prefix)) { + tmp = bc_strndup(src + start2, end - start2); + tmp2 = bc_strdup_printf("%-*s", strlen(prefix), ""); + if (bc_str_starts_with(tmp, prefix)) { if (lines2 != NULL) { - tmp_str = sb_string_new(); - for (sb_slist_t *l = lines2; l != NULL; l = l->next) { + tmp_str = bc_string_new(); + for (bc_slist_t *l = lines2; l != NULL; l = l->next) { if (l->next == NULL) - sb_string_append_printf(tmp_str, "%s", l->data); + bc_string_append_printf(tmp_str, "%s", l->data); else - sb_string_append_printf(tmp_str, "%s%s", l->data, + bc_string_append_printf(tmp_str, "%s%s", l->data, line_ending); } - sb_slist_free_full(lines2, free); + bc_slist_free_full(lines2, free); lines2 = NULL; parsed = blogc_content_parse_inline(tmp_str->str); - sb_string_free(tmp_str, true); - lines = sb_slist_append(lines, sb_strdup(parsed)); + bc_string_free(tmp_str, true); + lines = bc_slist_append(lines, bc_strdup(parsed)); free(parsed); parsed = NULL; } - lines2 = sb_slist_append(lines2, sb_strdup(tmp + strlen(prefix))); + lines2 = bc_slist_append(lines2, bc_strdup(tmp + strlen(prefix))); } - else if (sb_str_starts_with(tmp, tmp2)) { - lines2 = sb_slist_append(lines2, sb_strdup(tmp + strlen(prefix))); + else if (bc_str_starts_with(tmp, tmp2)) { + lines2 = bc_slist_append(lines2, bc_strdup(tmp + strlen(prefix))); } else { state = CONTENT_PARAGRAPH_END; @@ -1062,8 +1062,8 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) tmp2 = NULL; free(prefix); prefix = NULL; - sb_slist_free_full(lines, free); - sb_slist_free_full(lines2, free); + bc_slist_free_full(lines, free); + bc_slist_free_full(lines2, free); lines = NULL; if (is_last) continue; @@ -1082,28 +1082,28 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) if (c == '\n' || c == '\r' || is_last) { if (lines2 != NULL) { // FIXME: avoid repeting the code below - tmp_str = sb_string_new(); - for (sb_slist_t *l = lines2; l != NULL; l = l->next) { + tmp_str = bc_string_new(); + for (bc_slist_t *l = lines2; l != NULL; l = l->next) { if (l->next == NULL) - sb_string_append_printf(tmp_str, "%s", l->data); + bc_string_append_printf(tmp_str, "%s", l->data); else - sb_string_append_printf(tmp_str, "%s%s", l->data, + bc_string_append_printf(tmp_str, "%s%s", l->data, line_ending); } - sb_slist_free_full(lines2, free); + bc_slist_free_full(lines2, free); lines2 = NULL; parsed = blogc_content_parse_inline(tmp_str->str); - sb_string_free(tmp_str, true); - lines = sb_slist_append(lines, sb_strdup(parsed)); + bc_string_free(tmp_str, true); + lines = bc_slist_append(lines, bc_strdup(parsed)); free(parsed); parsed = NULL; } - sb_string_append_printf(rv, "%s", line_ending); + bc_slist_free_full(lines, free); lines = NULL; free(prefix); prefix = NULL; @@ -1140,30 +1140,30 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) if (c == '\n' || c == '\r' || is_last) { end = is_last && c != '\n' && c != '\r' ? src_len : (real_end != 0 ? real_end : current); - tmp = sb_strndup(src + start2, end - start2); - tmp2 = sb_strdup_printf("%-*s", prefix_len, ""); + tmp = bc_strndup(src + start2, end - start2); + tmp2 = bc_strdup_printf("%-*s", prefix_len, ""); if (blogc_is_ordered_list_item(tmp, prefix_len)) { if (lines2 != NULL) { - tmp_str = sb_string_new(); - for (sb_slist_t *l = lines2; l != NULL; l = l->next) { + tmp_str = bc_string_new(); + for (bc_slist_t *l = lines2; l != NULL; l = l->next) { if (l->next == NULL) - sb_string_append_printf(tmp_str, "%s", l->data); + bc_string_append_printf(tmp_str, "%s", l->data); else - sb_string_append_printf(tmp_str, "%s%s", l->data, + bc_string_append_printf(tmp_str, "%s%s", l->data, line_ending); } - sb_slist_free_full(lines2, free); + bc_slist_free_full(lines2, free); lines2 = NULL; parsed = blogc_content_parse_inline(tmp_str->str); - sb_string_free(tmp_str, true); - lines = sb_slist_append(lines, sb_strdup(parsed)); + bc_string_free(tmp_str, true); + lines = bc_slist_append(lines, bc_strdup(parsed)); free(parsed); parsed = NULL; } - lines2 = sb_slist_append(lines2, sb_strdup(tmp + prefix_len)); + lines2 = bc_slist_append(lines2, bc_strdup(tmp + prefix_len)); } - else if (sb_str_starts_with(tmp, tmp2)) { - lines2 = sb_slist_append(lines2, sb_strdup(tmp + prefix_len)); + else if (bc_str_starts_with(tmp, tmp2)) { + lines2 = bc_slist_append(lines2, bc_strdup(tmp + prefix_len)); } else { state = CONTENT_PARAGRAPH_END; @@ -1173,8 +1173,8 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) tmp2 = NULL; free(parsed); parsed = NULL; - sb_slist_free_full(lines, free); - sb_slist_free_full(lines2, free); + bc_slist_free_full(lines, free); + bc_slist_free_full(lines2, free); lines = NULL; if (is_last) continue; @@ -1193,28 +1193,28 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) if (c == '\n' || c == '\r' || is_last) { if (lines2 != NULL) { // FIXME: avoid repeting the code below - tmp_str = sb_string_new(); - for (sb_slist_t *l = lines2; l != NULL; l = l->next) { + tmp_str = bc_string_new(); + for (bc_slist_t *l = lines2; l != NULL; l = l->next) { if (l->next == NULL) - sb_string_append_printf(tmp_str, "%s", l->data); + bc_string_append_printf(tmp_str, "%s", l->data); else - sb_string_append_printf(tmp_str, "%s%s", l->data, + bc_string_append_printf(tmp_str, "%s%s", l->data, line_ending); } - sb_slist_free_full(lines2, free); + bc_slist_free_full(lines2, free); lines2 = NULL; parsed = blogc_content_parse_inline(tmp_str->str); - sb_string_free(tmp_str, true); - lines = sb_slist_append(lines, sb_strdup(parsed)); + bc_string_free(tmp_str, true); + lines = bc_slist_append(lines, bc_strdup(parsed)); free(parsed); parsed = NULL; } - sb_string_append_printf(rv, "
    %s", line_ending); - for (sb_slist_t *l = lines; l != NULL; l = l->next) - sb_string_append_printf(rv, "
  1. %s
  2. %s", l->data, + bc_string_append_printf(rv, "
      %s", line_ending); + for (bc_slist_t *l = lines; l != NULL; l = l->next) + bc_string_append_printf(rv, "
    1. %s
    2. %s", l->data, line_ending); - sb_string_append_printf(rv, "
    %s", line_ending); - sb_slist_free_full(lines, free); + bc_string_append_printf(rv, "
%s", line_ending); + bc_slist_free_full(lines, free); lines = NULL; free(prefix); prefix = NULL; @@ -1238,11 +1238,11 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) case CONTENT_PARAGRAPH_END: if (c == '\n' || c == '\r' || is_last) { - tmp = sb_strndup(src + start, end - start); + tmp = bc_strndup(src + start, end - start); if (description != NULL && *description == NULL) *description = blogc_fix_description(tmp); parsed = blogc_content_parse_inline(tmp); - sb_string_append_printf(rv, "

%s

%s", parsed, + bc_string_append_printf(rv, "

%s

%s", parsed, line_ending); free(parsed); parsed = NULL; @@ -1260,5 +1260,5 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description) current++; } - return sb_string_free(rv, false); + return bc_string_free(rv, false); } diff --git a/src/blogc/datetime-parser.c b/src/blogc/datetime-parser.c index 28efb74..a685c77 100644 --- a/src/blogc/datetime-parser.c +++ b/src/blogc/datetime-parser.c @@ -380,7 +380,7 @@ blogc_convert_datetime(const char *orig, const char *format, return NULL; } - return sb_strdup(buf); + return bc_strdup(buf); #endif } diff --git a/src/blogc/debug.c b/src/blogc/debug.c index 2840f60..0a50f52 100644 --- a/src/blogc/debug.c +++ b/src/blogc/debug.c @@ -34,9 +34,9 @@ get_operator(blogc_template_stmt_operator_t op) void -blogc_debug_template(sb_slist_t *stmts) +blogc_debug_template(bc_slist_t *stmts) { - for (sb_slist_t *tmp = stmts; tmp != NULL; tmp = tmp->next) { + for (bc_slist_t *tmp = stmts; tmp != NULL; tmp = tmp->next) { blogc_template_stmt_t *data = tmp->data; fprintf(stderr, "DEBUG: