diff options
| -rw-r--r-- | src/blogc-git-receiver/main.c | 18 | ||||
| -rw-r--r-- | src/blogc-runserver/main.c | 26 | ||||
| -rw-r--r-- | src/blogc/content-parser.c | 334 | ||||
| -rw-r--r-- | src/blogc/datetime-parser.c | 2 | ||||
| -rw-r--r-- | src/blogc/debug.c | 4 | ||||
| -rw-r--r-- | src/blogc/debug.h | 2 | ||||
| -rw-r--r-- | src/blogc/error.c | 10 | ||||
| -rw-r--r-- | src/blogc/file.c | 8 | ||||
| -rw-r--r-- | src/blogc/loader.c | 82 | ||||
| -rw-r--r-- | src/blogc/loader.h | 6 | ||||
| -rw-r--r-- | src/blogc/main.c | 50 | ||||
| -rw-r--r-- | src/blogc/renderer.c | 70 | ||||
| -rw-r--r-- | src/blogc/renderer.h | 14 | ||||
| -rw-r--r-- | src/blogc/source-parser.c | 28 | ||||
| -rw-r--r-- | src/blogc/source-parser.h | 2 | ||||
| -rw-r--r-- | src/blogc/template-parser.c | 40 | ||||
| -rw-r--r-- | src/blogc/template-parser.h | 4 | ||||
| -rw-r--r-- | src/common/utf8.c | 2 | ||||
| -rw-r--r-- | src/common/utf8.h | 2 | ||||
| -rw-r--r-- | src/common/utils.c | 206 | ||||
| -rw-r--r-- | src/common/utils.h | 98 | ||||
| -rw-r--r-- | tests/blogc/check_loader.c | 544 | ||||
| -rw-r--r-- | tests/blogc/check_renderer.c | 320 | ||||
| -rw-r--r-- | tests/blogc/check_source_parser.c | 166 | ||||
| -rw-r--r-- | tests/blogc/check_template_parser.c | 104 | ||||
| -rw-r--r-- | tests/common/check_utf8.c | 24 | ||||
| -rw-r--r-- | tests/common/check_utils.c | 498 | 
27 files changed, 1332 insertions, 1332 deletions
| 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, "<em>%s</em>", tmp2); +                bc_string_append_printf(rv, "<em>%s</em>", 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, "<strong>%s</strong>", tmp2); +                bc_string_append_printf(rv, "<strong>%s</strong>", 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, "<em>%s</em>", tmp2); +                bc_string_append_printf(rv, "<em>%s</em>", 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, "<strong>%s</strong>", tmp2); +                bc_string_append_printf(rv, "<strong>%s</strong>", 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, "<code>"); -                sb_string_append_escaped(rv, tmp2); -                sb_string_append(rv, "</code>"); +                bc_string_append(rv, "<code>"); +                bc_string_append_escaped(rv, tmp2); +                bc_string_append(rv, "</code>");                  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, "<code>"); -                sb_string_append_escaped(rv, tmp2); -                sb_string_append(rv, "</code>"); +                bc_string_append(rv, "<code>"); +                bc_string_append_escaped(rv, tmp2); +                bc_string_append(rv, "</code>");                  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, "<a href=\""); -                sb_string_append_escaped(rv, tmp2); -                sb_string_append(rv, "\">"); -                sb_string_append_escaped(rv, tmp2); -                sb_string_append(rv, "</a>"); +                tmp2 = bc_strndup(src + current, (tmp - src) - current); +                bc_string_append(rv, "<a href=\""); +                bc_string_append_escaped(rv, tmp2); +                bc_string_append(rv, "\">"); +                bc_string_append_escaped(rv, tmp2); +                bc_string_append(rv, "</a>");                  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, "<a href=\""); -                    sb_string_append_escaped(rv, tmp2); -                    sb_string_append_printf(rv, "\">%s</a>", tmp3); +                    bc_string_append(rv, "<a href=\""); +                    bc_string_append_escaped(rv, tmp2); +                    bc_string_append_printf(rv, "\">%s</a>", 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, "<img src=\""); -                    sb_string_append_escaped(rv, tmp2); -                    sb_string_append(rv, "\" alt=\""); -                    sb_string_append_escaped(rv, link1); -                    sb_string_append(rv, "\">"); +                    tmp2 = bc_strndup(src + start, current - start); +                    bc_string_append(rv, "<img src=\""); +                    bc_string_append_escaped(rv, tmp2); +                    bc_string_append(rv, "\" alt=\""); +                    bc_string_append_escaped(rv, link1); +                    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, "<br />"); +                        bc_string_append(rv, "<br />");                          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, "<br />"); +                        bc_string_append(rv, "<br />");                          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, "<br />%c", c); +                    bc_string_append_printf(rv, "<br />%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, "<h%d>%s</h%d>%s", +                        bc_string_append_printf(rv, "<h%d>%s</h%d>%s",                              header_level, parsed, header_level, line_ending);                      else -                        sb_string_append_printf(rv, "<h%d id=\"%s\">%s</h%d>%s", +                        bc_string_append_printf(rv, "<h%d id=\"%s\">%s</h%d>%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, "<blockquote>%s</blockquote>%s", +                    bc_string_append_printf(rv, "<blockquote>%s</blockquote>%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, "<pre><code>"); -                    for (sb_slist_t *l = lines; l != NULL; l = l->next) { +                    bc_string_append(rv, "<pre><code>"); +                    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, "</code></pre>%s", line_ending); -                    sb_slist_free_full(lines, free); +                    bc_string_append_printf(rv, "</code></pre>%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, "<hr />%s", line_ending); +                    bc_string_append_printf(rv, "<hr />%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, "<ul>%s", line_ending); -                    for (sb_slist_t *l = lines; l != NULL; l = l->next) -                        sb_string_append_printf(rv, "<li>%s</li>%s", l->data, +                    bc_string_append_printf(rv, "<ul>%s", line_ending); +                    for (bc_slist_t *l = lines; l != NULL; l = l->next) +                        bc_string_append_printf(rv, "<li>%s</li>%s", l->data,                              line_ending); -                    sb_string_append_printf(rv, "</ul>%s", line_ending); -                    sb_slist_free_full(lines, free); +                    bc_string_append_printf(rv, "</ul>%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, "<ol>%s", line_ending); -                    for (sb_slist_t *l = lines; l != NULL; l = l->next) -                        sb_string_append_printf(rv, "<li>%s</li>%s", l->data, +                    bc_string_append_printf(rv, "<ol>%s", line_ending); +                    for (bc_slist_t *l = lines; l != NULL; l = l->next) +                        bc_string_append_printf(rv, "<li>%s</li>%s", l->data,                              line_ending); -                    sb_string_append_printf(rv, "</ol>%s", line_ending); -                    sb_slist_free_full(lines, free); +                    bc_string_append_printf(rv, "</ol>%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, "<p>%s</p>%s", parsed, +                    bc_string_append_printf(rv, "<p>%s</p>%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: <TEMPLATE ");          switch (data->type) { diff --git a/src/blogc/debug.h b/src/blogc/debug.h index eb4e2c1..1a4a257 100644 --- a/src/blogc/debug.h +++ b/src/blogc/debug.h @@ -11,6 +11,6 @@  #include "../common/utils.h" -void blogc_debug_template(sb_slist_t *stmts); +void blogc_debug_template(bc_slist_t *stmts);  #endif /* ___DEBUG_H */ diff --git a/src/blogc/error.c b/src/blogc/error.c index 41f4cd0..cca8c03 100644 --- a/src/blogc/error.c +++ b/src/blogc/error.c @@ -16,9 +16,9 @@  blogc_error_t*  blogc_error_new(blogc_error_type_t type, const char *msg)  { -    blogc_error_t *err = sb_malloc(sizeof(blogc_error_t)); +    blogc_error_t *err = bc_malloc(sizeof(blogc_error_t));      err->type = type; -    err->msg = sb_strdup(msg); +    err->msg = bc_strdup(msg);      return err;  } @@ -28,7 +28,7 @@ blogc_error_new_printf(blogc_error_type_t type, const char *format, ...)  {      va_list ap;      va_start(ap, format); -    char *tmp = sb_strdup_vprintf(format, ap); +    char *tmp = bc_strdup_vprintf(format, ap);      va_end(ap);      blogc_error_t *rv = blogc_error_new(type, tmp);      free(tmp); @@ -42,7 +42,7 @@ blogc_error_parser(blogc_error_type_t type, const char *src, size_t src_len,  {      va_list ap;      va_start(ap, format); -    char *msg = sb_strdup_vprintf(format, ap); +    char *msg = bc_strdup_vprintf(format, ap);      va_end(ap);      size_t lineno = 1; @@ -83,7 +83,7 @@ blogc_error_parser(blogc_error_type_t type, const char *src, size_t src_len,      if (lineend <= linestart && src_len >= linestart)          lineend = src_len; -    char *line = sb_strndup(src + linestart, lineend - linestart); +    char *line = bc_strndup(src + linestart, lineend - linestart);      blogc_error_t *rv = NULL; diff --git a/src/blogc/file.c b/src/blogc/file.c index b3b0c5b..cdd6df4 100644 --- a/src/blogc/file.c +++ b/src/blogc/file.c @@ -37,7 +37,7 @@ blogc_file_get_contents(const char *path, size_t *len, blogc_error_t **err)          return NULL;      } -    sb_string_t *str = sb_string_new(); +    bc_string_t *str = bc_string_new();      char buffer[BLOGC_FILE_CHUNK_SIZE];      char *tmp; @@ -55,18 +55,18 @@ blogc_file_get_contents(const char *path, size_t *len, blogc_error_t **err)          }          *len += read_len; -        sb_string_append_len(str, tmp, read_len); +        bc_string_append_len(str, tmp, read_len);      }      fclose(fp);      if (!blogc_utf8_validate_str(str)) {          *err = blogc_error_new_printf(BLOGC_ERROR_FILE,              "File content is not valid UTF-8: %s", path); -        sb_string_free(str, true); +        bc_string_free(str, true);          return NULL;      } -    return sb_string_free(str, false); +    return bc_string_free(str, false);  } diff --git a/src/blogc/loader.c b/src/blogc/loader.c index 90f2401..914f07f 100644 --- a/src/blogc/loader.c +++ b/src/blogc/loader.c @@ -29,7 +29,7 @@ blogc_get_filename(const char *f)      if (strlen(f) == 0)          return NULL; -    char *filename = sb_strdup(f); +    char *filename = bc_strdup(f);      // keep a pointer to original string      char *tmp = filename; @@ -50,14 +50,14 @@ blogc_get_filename(const char *f)          }      } -    char *final_filename = sb_strdup(tmp); +    char *final_filename = bc_strdup(tmp);      free(filename);      return final_filename;  } -sb_slist_t* +bc_slist_t*  blogc_template_parse_from_file(const char *f, blogc_error_t **err)  {      if (err == NULL || *err != NULL) @@ -66,13 +66,13 @@ blogc_template_parse_from_file(const char *f, blogc_error_t **err)      char *s = blogc_file_get_contents(f, &len, err);      if (s == NULL)          return NULL; -    sb_slist_t *rv = blogc_template_parse(s, len, err); +    bc_slist_t *rv = blogc_template_parse(s, len, err);      free(s);      return rv;  } -sb_trie_t* +bc_trie_t*  blogc_source_parse_from_file(const char *f, blogc_error_t **err)  {      if (err == NULL || *err != NULL) @@ -81,13 +81,13 @@ blogc_source_parse_from_file(const char *f, blogc_error_t **err)      char *s = blogc_file_get_contents(f, &len, err);      if (s == NULL)          return NULL; -    sb_trie_t *rv = blogc_source_parse(s, len, err); +    bc_trie_t *rv = blogc_source_parse(s, len, err);      // set FILENAME variable      if (rv != NULL) {          char *filename = blogc_get_filename(f);          if (filename != NULL) -            sb_trie_insert(rv, "FILENAME", filename); +            bc_trie_insert(rv, "FILENAME", filename);      }      free(s); @@ -95,16 +95,16 @@ blogc_source_parse_from_file(const char *f, blogc_error_t **err)  } -sb_slist_t* -blogc_source_parse_from_files(sb_trie_t *conf, sb_slist_t *l, blogc_error_t **err) +bc_slist_t* +blogc_source_parse_from_files(bc_trie_t *conf, bc_slist_t *l, blogc_error_t **err)  {      blogc_error_t *tmp_err = NULL; -    sb_slist_t *rv = NULL; +    bc_slist_t *rv = NULL;      unsigned int with_date = 0; -    const char *filter_tag = sb_trie_lookup(conf, "FILTER_TAG"); -    const char *filter_page = sb_trie_lookup(conf, "FILTER_PAGE"); -    const char *filter_per_page = sb_trie_lookup(conf, "FILTER_PER_PAGE"); +    const char *filter_tag = bc_trie_lookup(conf, "FILTER_TAG"); +    const char *filter_page = bc_trie_lookup(conf, "FILTER_PAGE"); +    const char *filter_per_page = bc_trie_lookup(conf, "FILTER_PER_PAGE");      long page = strtol(filter_page != NULL ? filter_page : "", NULL, 10);      if (page <= 0) @@ -119,27 +119,27 @@ blogc_source_parse_from_files(sb_trie_t *conf, sb_slist_t *l, blogc_error_t **er      unsigned int end = start + per_page;      unsigned int counter = 0; -    for (sb_slist_t *tmp = l; tmp != NULL; tmp = tmp->next) { +    for (bc_slist_t *tmp = l; tmp != NULL; tmp = tmp->next) {          char *f = tmp->data; -        sb_trie_t *s = blogc_source_parse_from_file(f, &tmp_err); +        bc_trie_t *s = blogc_source_parse_from_file(f, &tmp_err);          if (s == NULL) {              *err = blogc_error_new_printf(BLOGC_ERROR_LOADER,                  "An error occurred while parsing source file: %s\n\n%s",                  f, tmp_err->msg);              blogc_error_free(tmp_err);              tmp_err = NULL; -            sb_slist_free_full(rv, (sb_free_func_t) sb_trie_free); +            bc_slist_free_full(rv, (bc_free_func_t) bc_trie_free);              rv = NULL;              break;          }          if (filter_tag != NULL) { -            const char *tags_str = sb_trie_lookup(s, "TAGS"); +            const char *tags_str = bc_trie_lookup(s, "TAGS");              // if user wants to filter by tag and no tag is provided, skip it              if (tags_str == NULL) { -                sb_trie_free(s); +                bc_trie_free(s);                  continue;              } -            char **tags = sb_str_split(tags_str, ' ', 0); +            char **tags = bc_str_split(tags_str, ' ', 0);              bool found = false;              for (unsigned int i = 0; tags[i] != NULL; i++) {                  if (tags[i][0] == '\0') @@ -147,26 +147,26 @@ blogc_source_parse_from_files(sb_trie_t *conf, sb_slist_t *l, blogc_error_t **er                  if (0 == strcmp(tags[i], filter_tag))                      found = true;              } -            sb_strv_free(tags); +            bc_strv_free(tags);              if (!found) { -                sb_trie_free(s); +                bc_trie_free(s);                  continue;              }          }          if (filter_page != NULL) {              if (counter < start || counter >= end) {                  counter++; -                sb_trie_free(s); +                bc_trie_free(s);                  continue;              }              counter++;          } -        if (sb_trie_lookup(s, "DATE") != NULL) +        if (bc_trie_lookup(s, "DATE") != NULL)              with_date++; -        rv = sb_slist_append(rv, s); +        rv = bc_slist_append(rv, s);      } -    if (with_date > 0 && with_date < sb_slist_length(rv)) +    if (with_date > 0 && with_date < bc_slist_length(rv))          // fatal error, maybe?          blogc_fprintf(stderr,              "blogc: warning: 'DATE' variable provided for at least one source " @@ -174,38 +174,38 @@ blogc_source_parse_from_files(sb_trie_t *conf, sb_slist_t *l, blogc_error_t **er              "wrong values for 'DATE_FIRST' and 'DATE_LAST' variables.\n");      bool first = true; -    for (sb_slist_t *tmp = rv; tmp != NULL; tmp = tmp->next) { -        sb_trie_t *s = tmp->data; +    for (bc_slist_t *tmp = rv; tmp != NULL; tmp = tmp->next) { +        bc_trie_t *s = tmp->data;          if (first) { -            const char *val = sb_trie_lookup(s, "DATE"); +            const char *val = bc_trie_lookup(s, "DATE");              if (val != NULL) -                sb_trie_insert(conf, "DATE_FIRST", sb_strdup(val)); -            val = sb_trie_lookup(s, "FILENAME"); +                bc_trie_insert(conf, "DATE_FIRST", bc_strdup(val)); +            val = bc_trie_lookup(s, "FILENAME");              if (val != NULL) -                sb_trie_insert(conf, "FILENAME_FIRST", sb_strdup(val)); +                bc_trie_insert(conf, "FILENAME_FIRST", bc_strdup(val));              first = false;          }          if (tmp->next == NULL) {  // last -            const char *val = sb_trie_lookup(s, "DATE"); +            const char *val = bc_trie_lookup(s, "DATE");              if (val != NULL) -                sb_trie_insert(conf, "DATE_LAST", sb_strdup(val)); -            val = sb_trie_lookup(s, "FILENAME"); +                bc_trie_insert(conf, "DATE_LAST", bc_strdup(val)); +            val = bc_trie_lookup(s, "FILENAME");              if (val != NULL) -                sb_trie_insert(conf, "FILENAME_LAST", sb_strdup(val)); +                bc_trie_insert(conf, "FILENAME_LAST", bc_strdup(val));          }      }      if (filter_page != NULL) {          unsigned int last_page = ceilf(((float) counter) / per_page); -        sb_trie_insert(conf, "CURRENT_PAGE", sb_strdup_printf("%ld", page)); +        bc_trie_insert(conf, "CURRENT_PAGE", bc_strdup_printf("%ld", page));          if (page > 1) -            sb_trie_insert(conf, "PREVIOUS_PAGE", sb_strdup_printf("%ld", page - 1)); +            bc_trie_insert(conf, "PREVIOUS_PAGE", bc_strdup_printf("%ld", page - 1));          if (page < last_page) -            sb_trie_insert(conf, "NEXT_PAGE", sb_strdup_printf("%ld", page + 1)); -        if (sb_slist_length(rv) > 0) -            sb_trie_insert(conf, "FIRST_PAGE", sb_strdup("1")); +            bc_trie_insert(conf, "NEXT_PAGE", bc_strdup_printf("%ld", page + 1)); +        if (bc_slist_length(rv) > 0) +            bc_trie_insert(conf, "FIRST_PAGE", bc_strdup("1"));          if (last_page > 0) -            sb_trie_insert(conf, "LAST_PAGE", sb_strdup_printf("%d", last_page)); +            bc_trie_insert(conf, "LAST_PAGE", bc_strdup_printf("%d", last_page));      }      return rv; diff --git a/src/blogc/loader.h b/src/blogc/loader.h index c54d11a..97286a0 100644 --- a/src/blogc/loader.h +++ b/src/blogc/loader.h @@ -13,9 +13,9 @@  #include "../common/utils.h"  char* blogc_get_filename(const char *f); -sb_slist_t* blogc_template_parse_from_file(const char *f, blogc_error_t **err); -sb_trie_t* blogc_source_parse_from_file(const char *f, blogc_error_t **err); -sb_slist_t* blogc_source_parse_from_files(sb_trie_t *conf, sb_slist_t *l, +bc_slist_t* blogc_template_parse_from_file(const char *f, blogc_error_t **err); +bc_trie_t* blogc_source_parse_from_file(const char *f, blogc_error_t **err); +bc_slist_t* blogc_source_parse_from_files(bc_trie_t *conf, bc_slist_t *l,      blogc_error_t **err);  #endif /* _LOADER_H */ diff --git a/src/blogc/main.c b/src/blogc/main.c index 03f43ae..0f174d4 100644 --- a/src/blogc/main.c +++ b/src/blogc/main.c @@ -71,7 +71,7 @@ blogc_print_usage(void)  static void  blogc_mkdir_recursive(const char *filename)  { -    char *fname = sb_strdup(filename); +    char *fname = bc_strdup(filename);      for (char *tmp = fname; *tmp != '\0'; tmp++) {          if (*tmp != '/' && *tmp != '\\')              continue; @@ -118,9 +118,9 @@ main(int argc, char **argv)      char *tmp = NULL;      char **pieces = NULL; -    sb_slist_t *sources = NULL; -    sb_trie_t *config = sb_trie_new(free); -    sb_trie_insert(config, "BLOGC_VERSION", sb_strdup(PACKAGE_VERSION)); +    bc_slist_t *sources = NULL; +    bc_trie_t *config = bc_trie_new(free); +    bc_trie_insert(config, "BLOGC_VERSION", bc_strdup(PACKAGE_VERSION));      for (unsigned int i = 1; i < argc; i++) {          tmp = NULL; @@ -140,21 +140,21 @@ main(int argc, char **argv)                      break;                  case 't':                      if (argv[i][2] != '\0') -                        template = sb_strdup(argv[i] + 2); +                        template = bc_strdup(argv[i] + 2);                      else if (i + 1 < argc) -                        template = sb_strdup(argv[++i]); +                        template = bc_strdup(argv[++i]);                      break;                  case 'o':                      if (argv[i][2] != '\0') -                        output = sb_strdup(argv[i] + 2); +                        output = bc_strdup(argv[i] + 2);                      else if (i + 1 < argc) -                        output = sb_strdup(argv[++i]); +                        output = bc_strdup(argv[++i]);                      break;                  case 'p':                      if (argv[i][2] != '\0') -                        print = sb_strdup(argv[i] + 2); +                        print = bc_strdup(argv[i] + 2);                      else if (i + 1 < argc) -                        print = sb_strdup(argv[++i]); +                        print = bc_strdup(argv[++i]);                      break;                  case 'D':                      if (argv[i][2] != '\0') @@ -167,11 +167,11 @@ main(int argc, char **argv)                                  "-D (must be valid UTF-8 string): %s\n", tmp);                              goto cleanup;                          } -                        pieces = sb_str_split(tmp, '=', 2); -                        if (sb_strv_length(pieces) != 2) { +                        pieces = bc_str_split(tmp, '=', 2); +                        if (bc_strv_length(pieces) != 2) {                              fprintf(stderr, "blogc: error: invalid value for "                                  "-D (must have an '='): %s\n", tmp); -                            sb_strv_free(pieces); +                            bc_strv_free(pieces);                              rv = 2;                              goto cleanup;                          } @@ -182,13 +182,13 @@ main(int argc, char **argv)                                  fprintf(stderr, "blogc: error: invalid value "                                      "for -D (configuration key must be uppercase "                                      "with '_'): %s\n", pieces[0]); -                                sb_strv_free(pieces); +                                bc_strv_free(pieces);                                  rv = 2;                                  goto cleanup;                              }                          } -                        sb_trie_insert(config, pieces[0], sb_strdup(pieces[1])); -                        sb_strv_free(pieces); +                        bc_trie_insert(config, pieces[0], bc_strdup(pieces[1])); +                        bc_strv_free(pieces);                          pieces = NULL;                      }                      break; @@ -201,17 +201,17 @@ main(int argc, char **argv)              }          }          else -            sources = sb_slist_append(sources, sb_strdup(argv[i])); +            sources = bc_slist_append(sources, bc_strdup(argv[i]));      } -    if (!listing && sb_slist_length(sources) == 0) { +    if (!listing && bc_slist_length(sources) == 0) {          blogc_print_usage();          fprintf(stderr, "blogc: error: one source file is required\n");          rv = 2;          goto cleanup;      } -    if (!listing && sb_slist_length(sources) > 1) { +    if (!listing && bc_slist_length(sources) > 1) {          blogc_print_usage();          fprintf(stderr, "blogc: error: only one source file should be provided, "              "if running without '-l'\n"); @@ -221,7 +221,7 @@ main(int argc, char **argv)      blogc_error_t *err = NULL; -    sb_slist_t *s = blogc_source_parse_from_files(config, sources, &err); +    bc_slist_t *s = blogc_source_parse_from_files(config, sources, &err);      if (err != NULL) {          blogc_error_print(err);          rv = 2; @@ -229,7 +229,7 @@ main(int argc, char **argv)      }      if (print != NULL) { -        const char *val = sb_trie_lookup(config, print); +        const char *val = bc_trie_lookup(config, print);          if (val == NULL) {              fprintf(stderr, "blogc: error: configuration variable not found: %s\n",                  print); @@ -248,7 +248,7 @@ main(int argc, char **argv)          goto cleanup2;      } -    sb_slist_t* l = blogc_template_parse_from_file(template, &err); +    bc_slist_t* l = blogc_template_parse_from_file(template, &err);      if (err != NULL) {          blogc_error_print(err);          rv = 2; @@ -285,13 +285,13 @@ cleanup4:  cleanup3:      blogc_template_free_stmts(l);  cleanup2: -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      blogc_error_free(err);  cleanup: -    sb_trie_free(config); +    bc_trie_free(config);      free(template);      free(output);      free(print); -    sb_slist_free_full(sources, free); +    bc_slist_free_full(sources, free);      return rv;  } 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);  } diff --git a/src/blogc/renderer.h b/src/blogc/renderer.h index f7f5328..cf6849b 100644 --- a/src/blogc/renderer.h +++ b/src/blogc/renderer.h @@ -12,13 +12,13 @@  #include <stdbool.h>  #include "../common/utils.h" -const char* blogc_get_variable(const char *name, sb_trie_t *global, sb_trie_t *local); -char* blogc_format_date(const char *date, sb_trie_t *global, sb_trie_t *local); -char* blogc_format_variable(const char *name, sb_trie_t *global, sb_trie_t *local, -    sb_slist_t *foreach_var); -sb_slist_t* 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, +const char* blogc_get_variable(const char *name, bc_trie_t *global, bc_trie_t *local); +char* blogc_format_date(const char *date, bc_trie_t *global, bc_trie_t *local); +char* blogc_format_variable(const char *name, bc_trie_t *global, bc_trie_t *local, +    bc_slist_t *foreach_var); +bc_slist_t* blogc_split_list_variable(const char *name, bc_trie_t *global, +    bc_trie_t *local); +char* blogc_render(bc_slist_t *tmpl, bc_slist_t *sources, bc_trie_t *config,      bool listing);  #endif /* _RENDERER_H */ diff --git a/src/blogc/source-parser.c b/src/blogc/source-parser.c index 4472096..dc39760 100644 --- a/src/blogc/source-parser.c +++ b/src/blogc/source-parser.c @@ -26,7 +26,7 @@ typedef enum {  } blogc_source_parser_state_t; -sb_trie_t* +bc_trie_t*  blogc_source_parse(const char *src, size_t src_len, blogc_error_t **err)  {      if (err == NULL || *err != NULL) @@ -39,7 +39,7 @@ blogc_source_parse(const char *src, size_t src_len, blogc_error_t **err)      char *key = NULL;      char *tmp = NULL;      char *content = NULL; -    sb_trie_t *rv = sb_trie_new(free); +    bc_trie_t *rv = bc_trie_new(free);      blogc_source_parser_state_t state = SOURCE_START; @@ -69,7 +69,7 @@ blogc_source_parse(const char *src, size_t src_len, blogc_error_t **err)                  if ((c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_')                      break;                  if (c == ':') { -                    key = sb_strndup(src + start, current - start); +                    key = bc_strndup(src + start, current - start);                      if (((current - start == 8) &&                           (0 == strncmp("FILENAME", src + start, 8))) ||                          ((current - start == 7) && @@ -118,8 +118,8 @@ blogc_source_parse(const char *src, size_t src_len, blogc_error_t **err)              case SOURCE_CONFIG_VALUE:                  if (c == '\n' || c == '\r') { -                    tmp = sb_strndup(src + start, current - start); -                    sb_trie_insert(rv, key, sb_strdup(sb_str_strip(tmp))); +                    tmp = bc_strndup(src + start, current - start); +                    bc_trie_insert(rv, key, bc_strdup(bc_str_strip(tmp)));                      free(tmp);                      free(key);                      key = NULL; @@ -148,24 +148,24 @@ blogc_source_parse(const char *src, size_t src_len, blogc_error_t **err)              case SOURCE_CONTENT:                  if (current == (src_len - 1)) { -                    tmp = sb_strndup(src + start, src_len - start); -                    sb_trie_insert(rv, "RAW_CONTENT", tmp); +                    tmp = bc_strndup(src + start, src_len - start); +                    bc_trie_insert(rv, "RAW_CONTENT", tmp);                      char *description = NULL;                      content = blogc_content_parse(tmp, &end_excerpt, &description);                      if (description != NULL) {                          // do not override source-provided description. -                        if (NULL == sb_trie_lookup(rv, "DESCRIPTION")) { +                        if (NULL == bc_trie_lookup(rv, "DESCRIPTION")) {                              // no need to free, because we are transfering memory                              // ownership to the trie. -                            sb_trie_insert(rv, "DESCRIPTION", description); +                            bc_trie_insert(rv, "DESCRIPTION", description);                          }                          else {                              free(description);                          }                      } -                    sb_trie_insert(rv, "CONTENT", content); -                    sb_trie_insert(rv, "EXCERPT", end_excerpt == 0 ? -                        sb_strdup(content) : sb_strndup(content, end_excerpt)); +                    bc_trie_insert(rv, "CONTENT", content); +                    bc_trie_insert(rv, "EXCERPT", end_excerpt == 0 ? +                        bc_strdup(content) : bc_strndup(content, end_excerpt));                  }                  break;          } @@ -176,7 +176,7 @@ blogc_source_parse(const char *src, size_t src_len, blogc_error_t **err)          current++;      } -    if (*err == NULL && sb_trie_size(rv) == 0) { +    if (*err == NULL && bc_trie_size(rv) == 0) {          // ok, nothing found in the config trie, but no error set either.          // let's try to be nice with the users and provide some reasonable @@ -210,7 +210,7 @@ blogc_source_parse(const char *src, size_t src_len, blogc_error_t **err)      if (*err != NULL) {          free(key); -        sb_trie_free(rv); +        bc_trie_free(rv);          return NULL;      } diff --git a/src/blogc/source-parser.h b/src/blogc/source-parser.h index 895cb1b..d135f23 100644 --- a/src/blogc/source-parser.h +++ b/src/blogc/source-parser.h @@ -13,7 +13,7 @@  #include "error.h"  #include "../common/utils.h" -sb_trie_t* blogc_source_parse(const char *src, size_t src_len, +bc_trie_t* blogc_source_parse(const char *src, size_t src_len,      blogc_error_t **err);  #endif /* _SOURCE_PARSER_H */ diff --git a/src/blogc/template-parser.c b/src/blogc/template-parser.c index 15750f1..1cca885 100644 --- a/src/blogc/template-parser.c +++ b/src/blogc/template-parser.c @@ -41,7 +41,7 @@ typedef enum {  } blogc_template_parser_state_t; -sb_slist_t* +bc_slist_t*  blogc_template_parse(const char *src, size_t src_len, blogc_error_t **err)  {      if (err == NULL || *err != NULL) @@ -63,7 +63,7 @@ blogc_template_parse(const char *src, size_t src_len, blogc_error_t **err)      bool foreach_open = false;      bool block_foreach_open = false; -    sb_slist_t *stmts = NULL; +    bc_slist_t *stmts = NULL;      blogc_template_stmt_t *stmt = NULL;      /* @@ -94,21 +94,21 @@ blogc_template_parse(const char *src, size_t src_len, blogc_error_t **err)              case TEMPLATE_START:                  if (last) { -                    stmt = sb_malloc(sizeof(blogc_template_stmt_t)); +                    stmt = bc_malloc(sizeof(blogc_template_stmt_t));                      stmt->type = type;                      if (lstrip_next) { -                        tmp = sb_strndup(src + start, src_len - start); -                        stmt->value = sb_strdup(sb_str_lstrip(tmp)); +                        tmp = bc_strndup(src + start, src_len - start); +                        stmt->value = bc_strdup(bc_str_lstrip(tmp));                          free(tmp);                          tmp = NULL;                          lstrip_next = false;                      }                      else { -                        stmt->value = sb_strndup(src + start, src_len - start); +                        stmt->value = bc_strndup(src + start, src_len - start);                      }                      stmt->op = 0;                      stmt->value2 = NULL; -                    stmts = sb_slist_append(stmts, stmt); +                    stmts = bc_slist_append(stmts, stmt);                      previous = stmt;                      stmt = NULL;                  } @@ -125,21 +125,21 @@ blogc_template_parse(const char *src, size_t src_len, blogc_error_t **err)                      else                          state = TEMPLATE_VARIABLE_START;                      if (end > start) { -                        stmt = sb_malloc(sizeof(blogc_template_stmt_t)); +                        stmt = bc_malloc(sizeof(blogc_template_stmt_t));                          stmt->type = type;                          if (lstrip_next) { -                            tmp = sb_strndup(src + start, end - start); -                            stmt->value = sb_strdup(sb_str_lstrip(tmp)); +                            tmp = bc_strndup(src + start, end - start); +                            stmt->value = bc_strdup(bc_str_lstrip(tmp));                              free(tmp);                              tmp = NULL;                              lstrip_next = false;                          }                          else { -                            stmt->value = sb_strndup(src + start, end - start); +                            stmt->value = bc_strndup(src + start, end - start);                          }                          stmt->op = 0;                          stmt->value2 = NULL; -                        stmts = sb_slist_append(stmts, stmt); +                        stmts = bc_slist_append(stmts, stmt);                          previous = stmt;                          stmt = NULL;                      } @@ -153,7 +153,7 @@ blogc_template_parse(const char *src, size_t src_len, blogc_error_t **err)                      if ((previous != NULL) &&                          (previous->type == BLOGC_TEMPLATE_CONTENT_STMT))                      { -                        previous->value = sb_str_rstrip(previous->value);  // does not need copy +                        previous->value = bc_str_rstrip(previous->value);  // does not need copy                      }                      state = TEMPLATE_BLOCK_START;                      break; @@ -600,21 +600,21 @@ blogc_template_parse(const char *src, size_t src_len, blogc_error_t **err)                          op_start = 0;                          op_end = 0;                      } -                    stmt = sb_malloc(sizeof(blogc_template_stmt_t)); +                    stmt = bc_malloc(sizeof(blogc_template_stmt_t));                      stmt->type = type;                      stmt->value = NULL;                      stmt->op = tmp_op;                      stmt->value2 = NULL;                      if (end > start) -                        stmt->value = sb_strndup(src + start, end - start); +                        stmt->value = bc_strndup(src + start, end - start);                      if (end2 > start2) { -                        stmt->value2 = sb_strndup(src + start2, end2 - start2); +                        stmt->value2 = bc_strndup(src + start2, end2 - start2);                          start2 = 0;                          end2 = 0;                      }                      if (type == BLOGC_TEMPLATE_BLOCK_STMT)                          block_type = stmt->value; -                    stmts = sb_slist_append(stmts, stmt); +                    stmts = bc_slist_append(stmts, stmt);                      previous = stmt;                      stmt = NULL;                      state = TEMPLATE_START; @@ -665,9 +665,9 @@ blogc_template_parse(const char *src, size_t src_len, blogc_error_t **err)  void -blogc_template_free_stmts(sb_slist_t *stmts) +blogc_template_free_stmts(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;          if (data == NULL)              continue; @@ -675,5 +675,5 @@ blogc_template_free_stmts(sb_slist_t *stmts)          free(data->value2);          free(data);      } -    sb_slist_free(stmts); +    bc_slist_free(stmts);  } diff --git a/src/blogc/template-parser.h b/src/blogc/template-parser.h index 41a2b3a..b22c2e7 100644 --- a/src/blogc/template-parser.h +++ b/src/blogc/template-parser.h @@ -46,8 +46,8 @@ typedef struct {      blogc_template_stmt_operator_t op;  } blogc_template_stmt_t; -sb_slist_t* blogc_template_parse(const char *src, size_t src_len, +bc_slist_t* blogc_template_parse(const char *src, size_t src_len,      blogc_error_t **err); -void blogc_template_free_stmts(sb_slist_t *stmts); +void blogc_template_free_stmts(bc_slist_t *stmts);  #endif /* _TEMPLATE_PARSER_H */ diff --git a/src/common/utf8.c b/src/common/utf8.c index a2f4fdd..ddd51ee 100644 --- a/src/common/utf8.c +++ b/src/common/utf8.c @@ -83,7 +83,7 @@ blogc_utf8_validate(const uint8_t *str, size_t len)  bool -blogc_utf8_validate_str(sb_string_t *str) +blogc_utf8_validate_str(bc_string_t *str)  {      return blogc_utf8_validate((uint8_t*) str->str, str->len);  } diff --git a/src/common/utf8.h b/src/common/utf8.h index 06fe07e..b37a97d 100644 --- a/src/common/utf8.h +++ b/src/common/utf8.h @@ -15,7 +15,7 @@  #include "utils.h"  bool blogc_utf8_validate(const uint8_t *str, size_t len); -bool blogc_utf8_validate_str(sb_string_t *str); +bool blogc_utf8_validate_str(bc_string_t *str);  size_t blogc_utf8_skip_bom(const uint8_t *str, size_t len);  #endif /* _UTF_8_H */ diff --git a/src/common/utils.c b/src/common/utils.c index b42ae4e..8397419 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -18,7 +18,7 @@  void* -sb_malloc(size_t size) +bc_malloc(size_t size)  {      // simple things simple!      void *rv = malloc(size); @@ -31,7 +31,7 @@ sb_malloc(size_t size)  void* -sb_realloc(void *ptr, size_t size) +bc_realloc(void *ptr, size_t size)  {      // simple things even simpler :P      void *rv = realloc(ptr, size); @@ -44,17 +44,17 @@ sb_realloc(void *ptr, size_t size)  } -sb_slist_t* -sb_slist_append(sb_slist_t *l, void *data) +bc_slist_t* +bc_slist_append(bc_slist_t *l, void *data)  { -    sb_slist_t *node = sb_malloc(sizeof(sb_slist_t)); +    bc_slist_t *node = bc_malloc(sizeof(bc_slist_t));      node->data = data;      node->next = NULL;      if (l == NULL) {          l = node;      }      else { -        sb_slist_t *tmp; +        bc_slist_t *tmp;          for (tmp = l; tmp->next != NULL; tmp = tmp->next);          tmp->next = node;      } @@ -62,10 +62,10 @@ sb_slist_append(sb_slist_t *l, void *data)  } -sb_slist_t* -sb_slist_prepend(sb_slist_t *l, void *data) +bc_slist_t* +bc_slist_prepend(bc_slist_t *l, void *data)  { -    sb_slist_t *node = sb_malloc(sizeof(sb_slist_t)); +    bc_slist_t *node = bc_malloc(sizeof(bc_slist_t));      node->data = data;      node->next = l;      l = node; @@ -74,10 +74,10 @@ sb_slist_prepend(sb_slist_t *l, void *data)  void -sb_slist_free_full(sb_slist_t *l, sb_free_func_t free_func) +bc_slist_free_full(bc_slist_t *l, bc_free_func_t free_func)  {      while (l != NULL) { -        sb_slist_t *tmp = l->next; +        bc_slist_t *tmp = l->next;          if ((free_func != NULL) && (l->data != NULL))              free_func(l->data);          free(l); @@ -87,26 +87,26 @@ sb_slist_free_full(sb_slist_t *l, sb_free_func_t free_func)  void -sb_slist_free(sb_slist_t *l) +bc_slist_free(bc_slist_t *l)  { -    sb_slist_free_full(l, NULL); +    bc_slist_free_full(l, NULL);  }  size_t -sb_slist_length(sb_slist_t *l) +bc_slist_length(bc_slist_t *l)  {      if (l == NULL)          return 0;      size_t i; -    sb_slist_t *tmp; +    bc_slist_t *tmp;      for (tmp = l, i = 0; tmp != NULL; tmp = tmp->next, i++);      return i;  }  char* -sb_strdup(const char *s) +bc_strdup(const char *s)  {      if (s == NULL)          return NULL; @@ -120,7 +120,7 @@ sb_strdup(const char *s)  char* -sb_strndup(const char *s, size_t n) +bc_strndup(const char *s, size_t n)  {      if (s == NULL)          return NULL; @@ -135,7 +135,7 @@ sb_strndup(const char *s, size_t n)  char* -sb_strdup_vprintf(const char *format, va_list ap) +bc_strdup_vprintf(const char *format, va_list ap)  {      va_list ap2;      va_copy(ap2, ap); @@ -156,18 +156,18 @@ sb_strdup_vprintf(const char *format, va_list ap)  char* -sb_strdup_printf(const char *format, ...) +bc_strdup_printf(const char *format, ...)  {      va_list ap;      va_start(ap, format); -    char *tmp = sb_strdup_vprintf(format, ap); +    char *tmp = bc_strdup_vprintf(format, ap);      va_end(ap);      return tmp;  }  bool -sb_str_starts_with(const char *str, const char *prefix) +bc_str_starts_with(const char *str, const char *prefix)  {      int str_l = strlen(str);      int str_lp = strlen(prefix); @@ -178,7 +178,7 @@ sb_str_starts_with(const char *str, const char *prefix)  bool -sb_str_ends_with(const char *str, const char *suffix) +bc_str_ends_with(const char *str, const char *suffix)  {      int str_l = strlen(str);      int str_ls = strlen(suffix); @@ -189,7 +189,7 @@ sb_str_ends_with(const char *str, const char *suffix)  char* -sb_str_lstrip(char *str) +bc_str_lstrip(char *str)  {      if (str == NULL)          return NULL; @@ -213,7 +213,7 @@ sb_str_lstrip(char *str)  char* -sb_str_rstrip(char *str) +bc_str_rstrip(char *str)  {      if (str == NULL)          return NULL; @@ -237,52 +237,52 @@ sb_str_rstrip(char *str)  char* -sb_str_strip(char *str) +bc_str_strip(char *str)  { -    return sb_str_lstrip(sb_str_rstrip(str)); +    return bc_str_lstrip(bc_str_rstrip(str));  }  char** -sb_str_split(const char *str, char c, unsigned int max_pieces) +bc_str_split(const char *str, char c, unsigned int max_pieces)  {      if (str == NULL)          return NULL; -    char **rv = sb_malloc(sizeof(char*)); +    char **rv = bc_malloc(sizeof(char*));      unsigned int i, start = 0, count = 0;      for (i = 0; i < strlen(str) + 1; i++) {          if (str[0] == '\0')              break;          if ((str[i] == c && (!max_pieces || count + 1 < max_pieces)) || str[i] == '\0') { -            rv = sb_realloc(rv, (count + 1) * sizeof(char*)); -            rv[count] = sb_malloc(i - start + 1); +            rv = bc_realloc(rv, (count + 1) * sizeof(char*)); +            rv[count] = bc_malloc(i - start + 1);              memcpy(rv[count], str + start, i - start);              rv[count++][i - start] = '\0';              start = i + 1;          }      } -    rv = sb_realloc(rv, (count + 1) * sizeof(char*)); +    rv = bc_realloc(rv, (count + 1) * sizeof(char*));      rv[count] = NULL;      return rv;  }  char* -sb_str_replace(const char *str, const char search, const char *replace) +bc_str_replace(const char *str, const char search, const char *replace)  { -    char **pieces = sb_str_split(str, search, 0); +    char **pieces = bc_str_split(str, search, 0);      if (pieces == NULL)          return NULL; -    char* rv = sb_strv_join(pieces, replace); -    sb_strv_free(pieces); +    char* rv = bc_strv_join(pieces, replace); +    bc_strv_free(pieces);      if (rv == NULL) -        return sb_strdup(str); +        return bc_strdup(str);      return rv;  }  char* -sb_str_find(const char *str, char c) +bc_str_find(const char *str, char c)  {      // this is somewhat similar to strchr, but respects '\' escaping.      if (str == NULL) @@ -303,7 +303,7 @@ sb_str_find(const char *str, char c)  void -sb_strv_free(char **strv) +bc_strv_free(char **strv)  {      if (strv == NULL)          return; @@ -314,22 +314,22 @@ sb_strv_free(char **strv)  char* -sb_strv_join(char **strv, const char *separator) +bc_strv_join(char **strv, const char *separator)  {      if (strv == NULL || separator == NULL)          return NULL; -    sb_string_t *str = sb_string_new(); +    bc_string_t *str = bc_string_new();      for (size_t i = 0; strv[i] != NULL; i++) { -        str = sb_string_append(str, strv[i]); +        str = bc_string_append(str, strv[i]);          if (strv[i + 1] != NULL) -            str = sb_string_append(str, separator); +            str = bc_string_append(str, separator);      } -    return sb_string_free(str, false); +    return bc_string_free(str, false);  }  size_t -sb_strv_length(char **strv) +bc_strv_length(char **strv)  {      if (strv == NULL)          return 0; @@ -339,23 +339,23 @@ sb_strv_length(char **strv)  } -sb_string_t* -sb_string_new(void) +bc_string_t* +bc_string_new(void)  { -    sb_string_t* rv = sb_malloc(sizeof(sb_string_t)); +    bc_string_t* rv = bc_malloc(sizeof(bc_string_t));      rv->str = NULL;      rv->len = 0;      rv->allocated_len = 0;      // initialize with empty string -    rv = sb_string_append(rv, ""); +    rv = bc_string_append(rv, "");      return rv;  }  char* -sb_string_free(sb_string_t *str, bool free_str) +bc_string_free(bc_string_t *str, bool free_str)  {      if (str == NULL)          return NULL; @@ -369,18 +369,18 @@ sb_string_free(sb_string_t *str, bool free_str)  } -sb_string_t* -sb_string_dup(sb_string_t *str) +bc_string_t* +bc_string_dup(bc_string_t *str)  {      if (str == NULL)          return NULL; -    sb_string_t* new = sb_string_new(); -    return sb_string_append_len(new, str->str, str->len); +    bc_string_t* new = bc_string_new(); +    return bc_string_append_len(new, str->str, str->len);  } -sb_string_t* -sb_string_append_len(sb_string_t *str, const char *suffix, size_t len) +bc_string_t* +bc_string_append_len(bc_string_t *str, const char *suffix, size_t len)  {      if (str == NULL)          return NULL; @@ -390,7 +390,7 @@ sb_string_append_len(sb_string_t *str, const char *suffix, size_t len)      str->len += len;      if (str->len + 1 > str->allocated_len) {          str->allocated_len = (((str->len + 1) / SB_STRING_CHUNK_SIZE) + 1) * SB_STRING_CHUNK_SIZE; -        str->str = sb_realloc(str->str, str->allocated_len); +        str->str = bc_realloc(str->str, str->allocated_len);      }      memcpy(str->str + old_len, suffix, len);      str->str[str->len] = '\0'; @@ -398,18 +398,18 @@ sb_string_append_len(sb_string_t *str, const char *suffix, size_t len)  } -sb_string_t* -sb_string_append(sb_string_t *str, const char *suffix) +bc_string_t* +bc_string_append(bc_string_t *str, const char *suffix)  {      if (str == NULL)          return NULL;      const char *my_suffix = suffix == NULL ? "" : suffix; -    return sb_string_append_len(str, my_suffix, strlen(my_suffix)); +    return bc_string_append_len(str, my_suffix, strlen(my_suffix));  } -sb_string_t* -sb_string_append_c(sb_string_t *str, char c) +bc_string_t* +bc_string_append_c(bc_string_t *str, char c)  {      if (str == NULL)          return NULL; @@ -417,7 +417,7 @@ sb_string_append_c(sb_string_t *str, char c)      str->len += 1;      if (str->len + 1 > str->allocated_len) {          str->allocated_len = (((str->len + 1) / SB_STRING_CHUNK_SIZE) + 1) * SB_STRING_CHUNK_SIZE; -        str->str = sb_realloc(str->str, str->allocated_len); +        str->str = bc_realloc(str->str, str->allocated_len);      }      str->str[old_len] = c;      str->str[str->len] = '\0'; @@ -425,23 +425,23 @@ sb_string_append_c(sb_string_t *str, char c)  } -sb_string_t* -sb_string_append_printf(sb_string_t *str, const char *format, ...) +bc_string_t* +bc_string_append_printf(bc_string_t *str, const char *format, ...)  {      if (str == NULL)          return NULL;      va_list ap;      va_start(ap, format); -    char *tmp = sb_strdup_vprintf(format, ap); +    char *tmp = bc_strdup_vprintf(format, ap);      va_end(ap); -    str = sb_string_append(str, tmp); +    str = bc_string_append(str, tmp);      free(tmp);      return str;  } -sb_string_t* -sb_string_append_escaped(sb_string_t *str, const char *suffix) +bc_string_t* +bc_string_append_escaped(bc_string_t *str, const char *suffix)  {      if (str == NULL)          return NULL; @@ -454,16 +454,16 @@ sb_string_append_escaped(sb_string_t *str, const char *suffix)              continue;          }          escaped = false; -        str = sb_string_append_c(str, suffix[i]); +        str = bc_string_append_c(str, suffix[i]);      }      return str;  } -sb_trie_t* -sb_trie_new(sb_free_func_t free_func) +bc_trie_t* +bc_trie_new(bc_free_func_t free_func)  { -    sb_trie_t *trie = sb_malloc(sizeof(sb_trie_t)); +    bc_trie_t *trie = bc_malloc(sizeof(bc_trie_t));      trie->root = NULL;      trie->free_func = free_func;      return trie; @@ -471,43 +471,43 @@ sb_trie_new(sb_free_func_t free_func)  static void -sb_trie_free_node(sb_trie_t *trie, sb_trie_node_t *node) +bc_trie_free_node(bc_trie_t *trie, bc_trie_node_t *node)  {      if (trie == NULL || node == NULL)          return;      if (node->data != NULL && trie->free_func != NULL)          trie->free_func(node->data); -    sb_trie_free_node(trie, node->next); -    sb_trie_free_node(trie, node->child); +    bc_trie_free_node(trie, node->next); +    bc_trie_free_node(trie, node->child);      free(node);  }  void -sb_trie_free(sb_trie_t *trie) +bc_trie_free(bc_trie_t *trie)  {      if (trie == NULL)          return; -    sb_trie_free_node(trie, trie->root); +    bc_trie_free_node(trie, trie->root);      free(trie);  }  void -sb_trie_insert(sb_trie_t *trie, const char *key, void *data) +bc_trie_insert(bc_trie_t *trie, const char *key, void *data)  {      if (trie == NULL || key == NULL || data == NULL)          return; -    sb_trie_node_t *parent = NULL; -    sb_trie_node_t *previous; -    sb_trie_node_t *current; -    sb_trie_node_t *tmp; +    bc_trie_node_t *parent = NULL; +    bc_trie_node_t *previous; +    bc_trie_node_t *current; +    bc_trie_node_t *tmp;      while (1) {          if (trie->root == NULL || (parent != NULL && parent->child == NULL)) { -            current = sb_malloc(sizeof(sb_trie_node_t)); +            current = bc_malloc(sizeof(bc_trie_node_t));              current->key = *key;              current->data = NULL;              current->next = NULL; @@ -533,7 +533,7 @@ sb_trie_insert(sb_trie_t *trie, const char *key, void *data)          if (previous == NULL || parent != NULL)              goto clean; -        current = sb_malloc(sizeof(sb_trie_node_t)); +        current = bc_malloc(sizeof(bc_trie_node_t));          current->key = *key;          current->data = NULL;          current->next = NULL; @@ -554,13 +554,13 @@ clean:  void* -sb_trie_lookup(sb_trie_t *trie, const char *key) +bc_trie_lookup(bc_trie_t *trie, const char *key)  {      if (trie == NULL || trie->root == NULL || key == NULL)          return NULL; -    sb_trie_node_t *parent = trie->root; -    sb_trie_node_t *tmp; +    bc_trie_node_t *parent = trie->root; +    bc_trie_node_t *tmp;      while (1) {          for (tmp = parent; tmp != NULL; tmp = tmp->next) { @@ -583,7 +583,7 @@ sb_trie_lookup(sb_trie_t *trie, const char *key)  static void -sb_trie_size_node(sb_trie_node_t *node, size_t *count) +bc_trie_size_node(bc_trie_node_t *node, size_t *count)  {      if (node == NULL || count == NULL)          return; @@ -591,26 +591,26 @@ sb_trie_size_node(sb_trie_node_t *node, size_t *count)      if (node->key == '\0')          (*count)++; -    sb_trie_size_node(node->next, count); -    sb_trie_size_node(node->child, count); +    bc_trie_size_node(node->next, count); +    bc_trie_size_node(node->child, count);  }  size_t -sb_trie_size(sb_trie_t *trie) +bc_trie_size(bc_trie_t *trie)  {      if (trie == NULL)          return 0;      size_t count = 0; -    sb_trie_size_node(trie->root, &count); +    bc_trie_size_node(trie->root, &count);      return count;  }  static void -sb_trie_foreach_node(sb_trie_node_t *node, sb_string_t *str, -    sb_trie_foreach_func_t func, void *user_data) +bc_trie_foreach_node(bc_trie_node_t *node, bc_string_t *str, +    bc_trie_foreach_func_t func, void *user_data)  {      if (node == NULL || str == NULL || func == NULL)          return; @@ -621,25 +621,25 @@ sb_trie_foreach_node(sb_trie_node_t *node, sb_string_t *str,      }      if (node->child != NULL) { -        sb_string_t *child = sb_string_dup(str); -        child = sb_string_append_c(child, node->key); -        sb_trie_foreach_node(node->child, child, func, user_data); -        sb_string_free(child, true); +        bc_string_t *child = bc_string_dup(str); +        child = bc_string_append_c(child, node->key); +        bc_trie_foreach_node(node->child, child, func, user_data); +        bc_string_free(child, true);      }      if (node->next != NULL) -        sb_trie_foreach_node(node->next, str, func, user_data); +        bc_trie_foreach_node(node->next, str, func, user_data);  }  void -sb_trie_foreach(sb_trie_t *trie, sb_trie_foreach_func_t func, +bc_trie_foreach(bc_trie_t *trie, bc_trie_foreach_func_t func,      void *user_data)  {      if (trie == NULL || trie->root == NULL || func == NULL)          return; -    sb_string_t *str = sb_string_new(); -    sb_trie_foreach_node(trie->root, str, func, user_data); -    sb_string_free(str, true); +    bc_string_t *str = bc_string_new(); +    bc_trie_foreach_node(trie->root, str, func, user_data); +    bc_string_free(str, true);  } diff --git a/src/common/utils.h b/src/common/utils.h index aca02c0..020f243 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -16,43 +16,43 @@  // memory -typedef void (*sb_free_func_t) (void *ptr); +typedef void (*bc_free_func_t) (void *ptr); -void* sb_malloc(size_t size); -void* sb_realloc(void *ptr, size_t size); +void* bc_malloc(size_t size); +void* bc_realloc(void *ptr, size_t size);  // slist -typedef struct _sb_slist_t { -    struct _sb_slist_t *next; +typedef struct _bc_slist_t { +    struct _bc_slist_t *next;      void *data; -} sb_slist_t; +} bc_slist_t; -sb_slist_t* sb_slist_append(sb_slist_t *l, void *data); -sb_slist_t* sb_slist_prepend(sb_slist_t *l, void *data); -void sb_slist_free(sb_slist_t *l); -void sb_slist_free_full(sb_slist_t *l, sb_free_func_t free_func); -size_t sb_slist_length(sb_slist_t *l); +bc_slist_t* bc_slist_append(bc_slist_t *l, void *data); +bc_slist_t* bc_slist_prepend(bc_slist_t *l, void *data); +void bc_slist_free(bc_slist_t *l); +void bc_slist_free_full(bc_slist_t *l, bc_free_func_t free_func); +size_t bc_slist_length(bc_slist_t *l);  // strfuncs -char* sb_strdup(const char *s); -char* sb_strndup(const char *s, size_t n); -char* sb_strdup_vprintf(const char *format, va_list ap); -char* sb_strdup_printf(const char *format, ...); -bool sb_str_starts_with(const char *str, const char *prefix); -bool sb_str_ends_with(const char *str, const char *suffix); -char* sb_str_lstrip(char *str); -char* sb_str_rstrip(char *str); -char* sb_str_strip(char *str); -char** sb_str_split(const char *str, char c, unsigned int max_pieces); -char* sb_str_replace(const char *str, const char search, const char *replace); -char* sb_str_find(const char *str, char c); -void sb_strv_free(char **strv); -char* sb_strv_join(char **strv, const char *separator); -size_t sb_strv_length(char **strv); +char* bc_strdup(const char *s); +char* bc_strndup(const char *s, size_t n); +char* bc_strdup_vprintf(const char *format, va_list ap); +char* bc_strdup_printf(const char *format, ...); +bool bc_str_starts_with(const char *str, const char *prefix); +bool bc_str_ends_with(const char *str, const char *suffix); +char* bc_str_lstrip(char *str); +char* bc_str_rstrip(char *str); +char* bc_str_strip(char *str); +char** bc_str_split(const char *str, char c, unsigned int max_pieces); +char* bc_str_replace(const char *str, const char search, const char *replace); +char* bc_str_find(const char *str, char c); +void bc_strv_free(char **strv); +char* bc_strv_join(char **strv, const char *separator); +size_t bc_strv_length(char **strv);  // string @@ -61,42 +61,42 @@ typedef struct {      char *str;      size_t len;      size_t allocated_len; -} sb_string_t; +} bc_string_t; -sb_string_t* sb_string_new(void); -char* sb_string_free(sb_string_t *str, bool free_str); -sb_string_t* sb_string_dup(sb_string_t *str); -sb_string_t* sb_string_append_len(sb_string_t *str, const char *suffix, size_t len); -sb_string_t* sb_string_append(sb_string_t *str, const char *suffix); -sb_string_t* sb_string_append_c(sb_string_t *str, char c); -sb_string_t* sb_string_append_printf(sb_string_t *str, const char *format, ...); -sb_string_t* sb_string_append_escaped(sb_string_t *str, const char *suffix); +bc_string_t* bc_string_new(void); +char* bc_string_free(bc_string_t *str, bool free_str); +bc_string_t* bc_string_dup(bc_string_t *str); +bc_string_t* bc_string_append_len(bc_string_t *str, const char *suffix, size_t len); +bc_string_t* bc_string_append(bc_string_t *str, const char *suffix); +bc_string_t* bc_string_append_c(bc_string_t *str, char c); +bc_string_t* bc_string_append_printf(bc_string_t *str, const char *format, ...); +bc_string_t* bc_string_append_escaped(bc_string_t *str, const char *suffix);  // trie -typedef struct _sb_trie_node_t { +typedef struct _bc_trie_node_t {      char key;      void *data; -    struct _sb_trie_node_t *next, *child; -} sb_trie_node_t; +    struct _bc_trie_node_t *next, *child; +} bc_trie_node_t; -struct _sb_trie_t { -    sb_trie_node_t *root; -    sb_free_func_t free_func; +struct _bc_trie_t { +    bc_trie_node_t *root; +    bc_free_func_t free_func;  }; -typedef struct _sb_trie_t sb_trie_t; +typedef struct _bc_trie_t bc_trie_t; -typedef void (*sb_trie_foreach_func_t)(const char *key, void *data, +typedef void (*bc_trie_foreach_func_t)(const char *key, void *data,      void *user_data); -sb_trie_t* sb_trie_new(sb_free_func_t free_func); -void sb_trie_free(sb_trie_t *trie); -void sb_trie_insert(sb_trie_t *trie, const char *key, void *data); -void* sb_trie_lookup(sb_trie_t *trie, const char *key); -size_t sb_trie_size(sb_trie_t *trie); -void sb_trie_foreach(sb_trie_t *trie, sb_trie_foreach_func_t func, +bc_trie_t* bc_trie_new(bc_free_func_t free_func); +void bc_trie_free(bc_trie_t *trie); +void bc_trie_insert(bc_trie_t *trie, const char *key, void *data); +void* bc_trie_lookup(bc_trie_t *trie, const char *key); +size_t bc_trie_size(bc_trie_t *trie); +void bc_trie_foreach(bc_trie_t *trie, bc_trie_foreach_func_t func,      void *user_data);  #endif /* _UTILS_H */ diff --git a/tests/blogc/check_loader.c b/tests/blogc/check_loader.c index 8d3d9d6..abe1f29 100644 --- a/tests/blogc/check_loader.c +++ b/tests/blogc/check_loader.c @@ -78,11 +78,11 @@ test_template_parse_from_file(void **state)  {      blogc_error_t *err = NULL;      will_return(__wrap_blogc_file_get_contents, "bola"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup("{{ BOLA }}\n")); -    sb_slist_t *l = blogc_template_parse_from_file("bola", &err); +    will_return(__wrap_blogc_file_get_contents, bc_strdup("{{ BOLA }}\n")); +    bc_slist_t *l = blogc_template_parse_from_file("bola", &err);      assert_null(err);      assert_non_null(l); -    assert_int_equal(sb_slist_length(l), 2); +    assert_int_equal(bc_slist_length(l), 2);      blogc_template_free_stmts(l);  } @@ -93,7 +93,7 @@ test_template_parse_from_file_null(void **state)      blogc_error_t *err = NULL;      will_return(__wrap_blogc_file_get_contents, "bola");      will_return(__wrap_blogc_file_get_contents, NULL); -    sb_slist_t *l = blogc_template_parse_from_file("bola", &err); +    bc_slist_t *l = blogc_template_parse_from_file("bola", &err);      assert_null(err);      assert_null(l);  } @@ -104,21 +104,21 @@ test_source_parse_from_file(void **state)  {      blogc_error_t *err = NULL;      will_return(__wrap_blogc_file_get_contents, "bola.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 123\n"          "--------\n"          "bola")); -    sb_trie_t *t = blogc_source_parse_from_file("bola.txt", &err); +    bc_trie_t *t = blogc_source_parse_from_file("bola.txt", &err);      assert_null(err);      assert_non_null(t); -    assert_int_equal(sb_trie_size(t), 6); -    assert_string_equal(sb_trie_lookup(t, "ASD"), "123"); -    assert_string_equal(sb_trie_lookup(t, "FILENAME"), "bola"); -    assert_string_equal(sb_trie_lookup(t, "EXCERPT"), "<p>bola</p>\n"); -    assert_string_equal(sb_trie_lookup(t, "CONTENT"), "<p>bola</p>\n"); -    assert_string_equal(sb_trie_lookup(t, "RAW_CONTENT"), "bola"); -    assert_string_equal(sb_trie_lookup(t, "DESCRIPTION"), "bola"); -    sb_trie_free(t); +    assert_int_equal(bc_trie_size(t), 6); +    assert_string_equal(bc_trie_lookup(t, "ASD"), "123"); +    assert_string_equal(bc_trie_lookup(t, "FILENAME"), "bola"); +    assert_string_equal(bc_trie_lookup(t, "EXCERPT"), "<p>bola</p>\n"); +    assert_string_equal(bc_trie_lookup(t, "CONTENT"), "<p>bola</p>\n"); +    assert_string_equal(bc_trie_lookup(t, "RAW_CONTENT"), "bola"); +    assert_string_equal(bc_trie_lookup(t, "DESCRIPTION"), "bola"); +    bc_trie_free(t);  } @@ -128,7 +128,7 @@ test_source_parse_from_file_null(void **state)      blogc_error_t *err = NULL;      will_return(__wrap_blogc_file_get_contents, "bola.txt");      will_return(__wrap_blogc_file_get_contents, NULL); -    sb_trie_t *t = blogc_source_parse_from_file("bola.txt", &err); +    bc_trie_t *t = blogc_source_parse_from_file("bola.txt", &err);      assert_null(err);      assert_null(t);  } @@ -138,41 +138,41 @@ static void  test_source_parse_from_files(void **state)  {      will_return(__wrap_blogc_file_get_contents, "bola1.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 123\n"          "DATE: 2001-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola2.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 456\n"          "DATE: 2002-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola3.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 789\n"          "DATE: 2003-02-03 04:05:06\n"          "--------\n"          "bola"));      blogc_error_t *err = NULL; -    sb_slist_t *s = NULL; -    s = sb_slist_append(s, sb_strdup("bola1.txt")); -    s = sb_slist_append(s, sb_strdup("bola2.txt")); -    s = sb_slist_append(s, sb_strdup("bola3.txt")); -    sb_trie_t *c = sb_trie_new(free); -    sb_slist_t *t = blogc_source_parse_from_files(c, s, &err); +    bc_slist_t *s = NULL; +    s = bc_slist_append(s, bc_strdup("bola1.txt")); +    s = bc_slist_append(s, bc_strdup("bola2.txt")); +    s = bc_slist_append(s, bc_strdup("bola3.txt")); +    bc_trie_t *c = bc_trie_new(free); +    bc_slist_t *t = blogc_source_parse_from_files(c, s, &err);      assert_null(err);      assert_non_null(t); -    assert_int_equal(sb_slist_length(t), 3);  // it is enough, no need to look at the items -    assert_int_equal(sb_trie_size(c), 4); -    assert_string_equal(sb_trie_lookup(c, "FILENAME_FIRST"), "bola1"); -    assert_string_equal(sb_trie_lookup(c, "FILENAME_LAST"), "bola3"); -    assert_string_equal(sb_trie_lookup(c, "DATE_FIRST"), "2001-02-03 04:05:06"); -    assert_string_equal(sb_trie_lookup(c, "DATE_LAST"), "2003-02-03 04:05:06"); -    sb_trie_free(c); -    sb_slist_free_full(s, free); -    sb_slist_free_full(t, (sb_free_func_t) sb_trie_free); +    assert_int_equal(bc_slist_length(t), 3);  // it is enough, no need to look at the items +    assert_int_equal(bc_trie_size(c), 4); +    assert_string_equal(bc_trie_lookup(c, "FILENAME_FIRST"), "bola1"); +    assert_string_equal(bc_trie_lookup(c, "FILENAME_LAST"), "bola3"); +    assert_string_equal(bc_trie_lookup(c, "DATE_FIRST"), "2001-02-03 04:05:06"); +    assert_string_equal(bc_trie_lookup(c, "DATE_LAST"), "2003-02-03 04:05:06"); +    bc_trie_free(c); +    bc_slist_free_full(s, free); +    bc_slist_free_full(t, (bc_free_func_t) bc_trie_free);  } @@ -180,45 +180,45 @@ static void  test_source_parse_from_files_filter_by_tag(void **state)  {      will_return(__wrap_blogc_file_get_contents, "bola1.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 123\n"          "DATE: 2001-02-03 04:05:06\n"          "TAGS: chunda\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola2.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 456\n"          "DATE: 2002-02-03 04:05:06\n"          "TAGS: bola, chunda\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola3.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 789\n"          "DATE: 2003-02-03 04:05:06\n"          "--------\n"          "bola"));      blogc_error_t *err = NULL; -    sb_slist_t *s = NULL; -    s = sb_slist_append(s, sb_strdup("bola1.txt")); -    s = sb_slist_append(s, sb_strdup("bola2.txt")); -    s = sb_slist_append(s, sb_strdup("bola3.txt")); -    sb_trie_t *c = sb_trie_new(free); -    sb_trie_insert(c, "FILTER_TAG", sb_strdup("chunda")); -    sb_slist_t *t = blogc_source_parse_from_files(c, s, &err); +    bc_slist_t *s = NULL; +    s = bc_slist_append(s, bc_strdup("bola1.txt")); +    s = bc_slist_append(s, bc_strdup("bola2.txt")); +    s = bc_slist_append(s, bc_strdup("bola3.txt")); +    bc_trie_t *c = bc_trie_new(free); +    bc_trie_insert(c, "FILTER_TAG", bc_strdup("chunda")); +    bc_slist_t *t = blogc_source_parse_from_files(c, s, &err);      assert_null(err);      assert_non_null(t); -    assert_int_equal(sb_slist_length(t), 2);  // it is enough, no need to look at the items -    assert_int_equal(sb_trie_size(c), 5); -    assert_string_equal(sb_trie_lookup(c, "FILENAME_FIRST"), "bola1"); -    assert_string_equal(sb_trie_lookup(c, "FILENAME_LAST"), "bola2"); -    assert_string_equal(sb_trie_lookup(c, "DATE_FIRST"), "2001-02-03 04:05:06"); -    assert_string_equal(sb_trie_lookup(c, "DATE_LAST"), "2002-02-03 04:05:06"); -    assert_string_equal(sb_trie_lookup(c, "FILTER_TAG"), "chunda"); -    sb_trie_free(c); -    sb_slist_free_full(s, free); -    sb_slist_free_full(t, (sb_free_func_t) sb_trie_free); +    assert_int_equal(bc_slist_length(t), 2);  // it is enough, no need to look at the items +    assert_int_equal(bc_trie_size(c), 5); +    assert_string_equal(bc_trie_lookup(c, "FILENAME_FIRST"), "bola1"); +    assert_string_equal(bc_trie_lookup(c, "FILENAME_LAST"), "bola2"); +    assert_string_equal(bc_trie_lookup(c, "DATE_FIRST"), "2001-02-03 04:05:06"); +    assert_string_equal(bc_trie_lookup(c, "DATE_LAST"), "2002-02-03 04:05:06"); +    assert_string_equal(bc_trie_lookup(c, "FILTER_TAG"), "chunda"); +    bc_trie_free(c); +    bc_slist_free_full(s, free); +    bc_slist_free_full(t, (bc_free_func_t) bc_trie_free);  } @@ -226,77 +226,77 @@ static void  test_source_parse_from_files_filter_by_page(void **state)  {      will_return(__wrap_blogc_file_get_contents, "bola1.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 123\n"          "DATE: 2001-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola2.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 456\n"          "DATE: 2002-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola3.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 789\n"          "DATE: 2003-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola4.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7891\n"          "DATE: 2004-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola5.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7892\n"          "DATE: 2005-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola6.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7893\n"          "DATE: 2006-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola7.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7894\n"          "DATE: 2007-02-03 04:05:06\n"          "--------\n"          "bola"));      blogc_error_t *err = NULL; -    sb_slist_t *s = NULL; -    s = sb_slist_append(s, sb_strdup("bola1.txt")); -    s = sb_slist_append(s, sb_strdup("bola2.txt")); -    s = sb_slist_append(s, sb_strdup("bola3.txt")); -    s = sb_slist_append(s, sb_strdup("bola4.txt")); -    s = sb_slist_append(s, sb_strdup("bola5.txt")); -    s = sb_slist_append(s, sb_strdup("bola6.txt")); -    s = sb_slist_append(s, sb_strdup("bola7.txt")); -    sb_trie_t *c = sb_trie_new(free); -    sb_trie_insert(c, "FILTER_PAGE", sb_strdup("1")); -    sb_trie_insert(c, "FILTER_PER_PAGE", sb_strdup("2")); -    sb_slist_t *t = blogc_source_parse_from_files(c, s, &err); +    bc_slist_t *s = NULL; +    s = bc_slist_append(s, bc_strdup("bola1.txt")); +    s = bc_slist_append(s, bc_strdup("bola2.txt")); +    s = bc_slist_append(s, bc_strdup("bola3.txt")); +    s = bc_slist_append(s, bc_strdup("bola4.txt")); +    s = bc_slist_append(s, bc_strdup("bola5.txt")); +    s = bc_slist_append(s, bc_strdup("bola6.txt")); +    s = bc_slist_append(s, bc_strdup("bola7.txt")); +    bc_trie_t *c = bc_trie_new(free); +    bc_trie_insert(c, "FILTER_PAGE", bc_strdup("1")); +    bc_trie_insert(c, "FILTER_PER_PAGE", bc_strdup("2")); +    bc_slist_t *t = blogc_source_parse_from_files(c, s, &err);      assert_null(err);      assert_non_null(t); -    assert_int_equal(sb_slist_length(t), 2);  // it is enough, no need to look at the items -    assert_int_equal(sb_trie_size(c), 10); -    assert_string_equal(sb_trie_lookup(c, "FILENAME_FIRST"), "bola1"); -    assert_string_equal(sb_trie_lookup(c, "FILENAME_LAST"), "bola2"); -    assert_string_equal(sb_trie_lookup(c, "DATE_FIRST"), "2001-02-03 04:05:06"); -    assert_string_equal(sb_trie_lookup(c, "DATE_LAST"), "2002-02-03 04:05:06"); -    assert_string_equal(sb_trie_lookup(c, "FILTER_PAGE"), "1"); -    assert_string_equal(sb_trie_lookup(c, "FILTER_PER_PAGE"), "2"); -    assert_string_equal(sb_trie_lookup(c, "CURRENT_PAGE"), "1"); -    assert_string_equal(sb_trie_lookup(c, "NEXT_PAGE"), "2"); -    assert_string_equal(sb_trie_lookup(c, "FIRST_PAGE"), "1"); -    assert_string_equal(sb_trie_lookup(c, "LAST_PAGE"), "4"); -    sb_trie_free(c); -    sb_slist_free_full(s, free); -    sb_slist_free_full(t, (sb_free_func_t) sb_trie_free); +    assert_int_equal(bc_slist_length(t), 2);  // it is enough, no need to look at the items +    assert_int_equal(bc_trie_size(c), 10); +    assert_string_equal(bc_trie_lookup(c, "FILENAME_FIRST"), "bola1"); +    assert_string_equal(bc_trie_lookup(c, "FILENAME_LAST"), "bola2"); +    assert_string_equal(bc_trie_lookup(c, "DATE_FIRST"), "2001-02-03 04:05:06"); +    assert_string_equal(bc_trie_lookup(c, "DATE_LAST"), "2002-02-03 04:05:06"); +    assert_string_equal(bc_trie_lookup(c, "FILTER_PAGE"), "1"); +    assert_string_equal(bc_trie_lookup(c, "FILTER_PER_PAGE"), "2"); +    assert_string_equal(bc_trie_lookup(c, "CURRENT_PAGE"), "1"); +    assert_string_equal(bc_trie_lookup(c, "NEXT_PAGE"), "2"); +    assert_string_equal(bc_trie_lookup(c, "FIRST_PAGE"), "1"); +    assert_string_equal(bc_trie_lookup(c, "LAST_PAGE"), "4"); +    bc_trie_free(c); +    bc_slist_free_full(s, free); +    bc_slist_free_full(t, (bc_free_func_t) bc_trie_free);  } @@ -304,78 +304,78 @@ static void  test_source_parse_from_files_filter_by_page2(void **state)  {      will_return(__wrap_blogc_file_get_contents, "bola1.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 123\n"          "DATE: 2001-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola2.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 456\n"          "DATE: 2002-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola3.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 789\n"          "DATE: 2003-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola4.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7891\n"          "DATE: 2004-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola5.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7892\n"          "DATE: 2005-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola6.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7893\n"          "DATE: 2006-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola7.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7894\n"          "DATE: 2007-02-03 04:05:06\n"          "--------\n"          "bola"));      blogc_error_t *err = NULL; -    sb_slist_t *s = NULL; -    s = sb_slist_append(s, sb_strdup("bola1.txt")); -    s = sb_slist_append(s, sb_strdup("bola2.txt")); -    s = sb_slist_append(s, sb_strdup("bola3.txt")); -    s = sb_slist_append(s, sb_strdup("bola4.txt")); -    s = sb_slist_append(s, sb_strdup("bola5.txt")); -    s = sb_slist_append(s, sb_strdup("bola6.txt")); -    s = sb_slist_append(s, sb_strdup("bola7.txt")); -    sb_trie_t *c = sb_trie_new(free); -    sb_trie_insert(c, "FILTER_PAGE", sb_strdup("3")); -    sb_trie_insert(c, "FILTER_PER_PAGE", sb_strdup("2")); -    sb_slist_t *t = blogc_source_parse_from_files(c, s, &err); +    bc_slist_t *s = NULL; +    s = bc_slist_append(s, bc_strdup("bola1.txt")); +    s = bc_slist_append(s, bc_strdup("bola2.txt")); +    s = bc_slist_append(s, bc_strdup("bola3.txt")); +    s = bc_slist_append(s, bc_strdup("bola4.txt")); +    s = bc_slist_append(s, bc_strdup("bola5.txt")); +    s = bc_slist_append(s, bc_strdup("bola6.txt")); +    s = bc_slist_append(s, bc_strdup("bola7.txt")); +    bc_trie_t *c = bc_trie_new(free); +    bc_trie_insert(c, "FILTER_PAGE", bc_strdup("3")); +    bc_trie_insert(c, "FILTER_PER_PAGE", bc_strdup("2")); +    bc_slist_t *t = blogc_source_parse_from_files(c, s, &err);      assert_null(err);      assert_non_null(t); -    assert_int_equal(sb_slist_length(t), 2);  // it is enough, no need to look at the items -    assert_int_equal(sb_trie_size(c), 11); -    assert_string_equal(sb_trie_lookup(c, "FILENAME_FIRST"), "bola5"); -    assert_string_equal(sb_trie_lookup(c, "FILENAME_LAST"), "bola6"); -    assert_string_equal(sb_trie_lookup(c, "DATE_FIRST"), "2005-02-03 04:05:06"); -    assert_string_equal(sb_trie_lookup(c, "DATE_LAST"), "2006-02-03 04:05:06"); -    assert_string_equal(sb_trie_lookup(c, "FILTER_PAGE"), "3"); -    assert_string_equal(sb_trie_lookup(c, "FILTER_PER_PAGE"), "2"); -    assert_string_equal(sb_trie_lookup(c, "CURRENT_PAGE"), "3"); -    assert_string_equal(sb_trie_lookup(c, "PREVIOUS_PAGE"), "2"); -    assert_string_equal(sb_trie_lookup(c, "NEXT_PAGE"), "4"); -    assert_string_equal(sb_trie_lookup(c, "FIRST_PAGE"), "1"); -    assert_string_equal(sb_trie_lookup(c, "LAST_PAGE"), "4"); -    sb_trie_free(c); -    sb_slist_free_full(s, free); -    sb_slist_free_full(t, (sb_free_func_t) sb_trie_free); +    assert_int_equal(bc_slist_length(t), 2);  // it is enough, no need to look at the items +    assert_int_equal(bc_trie_size(c), 11); +    assert_string_equal(bc_trie_lookup(c, "FILENAME_FIRST"), "bola5"); +    assert_string_equal(bc_trie_lookup(c, "FILENAME_LAST"), "bola6"); +    assert_string_equal(bc_trie_lookup(c, "DATE_FIRST"), "2005-02-03 04:05:06"); +    assert_string_equal(bc_trie_lookup(c, "DATE_LAST"), "2006-02-03 04:05:06"); +    assert_string_equal(bc_trie_lookup(c, "FILTER_PAGE"), "3"); +    assert_string_equal(bc_trie_lookup(c, "FILTER_PER_PAGE"), "2"); +    assert_string_equal(bc_trie_lookup(c, "CURRENT_PAGE"), "3"); +    assert_string_equal(bc_trie_lookup(c, "PREVIOUS_PAGE"), "2"); +    assert_string_equal(bc_trie_lookup(c, "NEXT_PAGE"), "4"); +    assert_string_equal(bc_trie_lookup(c, "FIRST_PAGE"), "1"); +    assert_string_equal(bc_trie_lookup(c, "LAST_PAGE"), "4"); +    bc_trie_free(c); +    bc_slist_free_full(s, free); +    bc_slist_free_full(t, (bc_free_func_t) bc_trie_free);  } @@ -383,77 +383,77 @@ static void  test_source_parse_from_files_filter_by_page3(void **state)  {      will_return(__wrap_blogc_file_get_contents, "bola1.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 123\n"          "DATE: 2001-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola2.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 456\n"          "DATE: 2002-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola3.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 789\n"          "DATE: 2003-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola4.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7891\n"          "DATE: 2004-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola5.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7892\n"          "DATE: 2005-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola6.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7893\n"          "DATE: 2006-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola7.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7894\n"          "DATE: 2007-02-03 04:05:06\n"          "--------\n"          "bola"));      blogc_error_t *err = NULL; -    sb_slist_t *s = NULL; -    s = sb_slist_append(s, sb_strdup("bola1.txt")); -    s = sb_slist_append(s, sb_strdup("bola2.txt")); -    s = sb_slist_append(s, sb_strdup("bola3.txt")); -    s = sb_slist_append(s, sb_strdup("bola4.txt")); -    s = sb_slist_append(s, sb_strdup("bola5.txt")); -    s = sb_slist_append(s, sb_strdup("bola6.txt")); -    s = sb_slist_append(s, sb_strdup("bola7.txt")); -    sb_trie_t *c = sb_trie_new(free); -    sb_trie_insert(c, "FILTER_PAGE", sb_strdup("1")); -    sb_trie_insert(c, "FILTER_PER_PAGE", sb_strdup("2")); -    sb_slist_t *t = blogc_source_parse_from_files(c, s, &err); +    bc_slist_t *s = NULL; +    s = bc_slist_append(s, bc_strdup("bola1.txt")); +    s = bc_slist_append(s, bc_strdup("bola2.txt")); +    s = bc_slist_append(s, bc_strdup("bola3.txt")); +    s = bc_slist_append(s, bc_strdup("bola4.txt")); +    s = bc_slist_append(s, bc_strdup("bola5.txt")); +    s = bc_slist_append(s, bc_strdup("bola6.txt")); +    s = bc_slist_append(s, bc_strdup("bola7.txt")); +    bc_trie_t *c = bc_trie_new(free); +    bc_trie_insert(c, "FILTER_PAGE", bc_strdup("1")); +    bc_trie_insert(c, "FILTER_PER_PAGE", bc_strdup("2")); +    bc_slist_t *t = blogc_source_parse_from_files(c, s, &err);      assert_null(err);      assert_non_null(t); -    assert_int_equal(sb_slist_length(t), 2);  // it is enough, no need to look at the items -    assert_int_equal(sb_trie_size(c), 10); -    assert_string_equal(sb_trie_lookup(c, "FILENAME_FIRST"), "bola1"); -    assert_string_equal(sb_trie_lookup(c, "FILENAME_LAST"), "bola2"); -    assert_string_equal(sb_trie_lookup(c, "DATE_FIRST"), "2001-02-03 04:05:06"); -    assert_string_equal(sb_trie_lookup(c, "DATE_LAST"), "2002-02-03 04:05:06"); -    assert_string_equal(sb_trie_lookup(c, "FILTER_PAGE"), "1"); -    assert_string_equal(sb_trie_lookup(c, "FILTER_PER_PAGE"), "2"); -    assert_string_equal(sb_trie_lookup(c, "CURRENT_PAGE"), "1"); -    assert_string_equal(sb_trie_lookup(c, "NEXT_PAGE"), "2"); -    assert_string_equal(sb_trie_lookup(c, "FIRST_PAGE"), "1"); -    assert_string_equal(sb_trie_lookup(c, "LAST_PAGE"), "4"); -    sb_trie_free(c); -    sb_slist_free_full(s, free); -    sb_slist_free_full(t, (sb_free_func_t) sb_trie_free); +    assert_int_equal(bc_slist_length(t), 2);  // it is enough, no need to look at the items +    assert_int_equal(bc_trie_size(c), 10); +    assert_string_equal(bc_trie_lookup(c, "FILENAME_FIRST"), "bola1"); +    assert_string_equal(bc_trie_lookup(c, "FILENAME_LAST"), "bola2"); +    assert_string_equal(bc_trie_lookup(c, "DATE_FIRST"), "2001-02-03 04:05:06"); +    assert_string_equal(bc_trie_lookup(c, "DATE_LAST"), "2002-02-03 04:05:06"); +    assert_string_equal(bc_trie_lookup(c, "FILTER_PAGE"), "1"); +    assert_string_equal(bc_trie_lookup(c, "FILTER_PER_PAGE"), "2"); +    assert_string_equal(bc_trie_lookup(c, "CURRENT_PAGE"), "1"); +    assert_string_equal(bc_trie_lookup(c, "NEXT_PAGE"), "2"); +    assert_string_equal(bc_trie_lookup(c, "FIRST_PAGE"), "1"); +    assert_string_equal(bc_trie_lookup(c, "LAST_PAGE"), "4"); +    bc_trie_free(c); +    bc_slist_free_full(s, free); +    bc_slist_free_full(t, (bc_free_func_t) bc_trie_free);  } @@ -461,84 +461,84 @@ static void  test_source_parse_from_files_filter_by_page_and_tag(void **state)  {      will_return(__wrap_blogc_file_get_contents, "bola1.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 123\n"          "DATE: 2001-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola2.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 456\n"          "DATE: 2002-02-03 04:05:06\n"          "TAGS: chunda\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola3.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 789\n"          "DATE: 2003-02-03 04:05:06\n"          "TAGS: chunda bola\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola4.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7891\n"          "DATE: 2004-02-03 04:05:06\n"          "TAGS: bola\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola5.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7892\n"          "DATE: 2005-02-03 04:05:06\n"          "TAGS: chunda\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola6.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7893\n"          "DATE: 2006-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola7.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7894\n"          "DATE: 2007-02-03 04:05:06\n"          "TAGS: yay chunda\n"          "--------\n"          "bola"));      blogc_error_t *err = NULL; -    sb_slist_t *s = NULL; -    s = sb_slist_append(s, sb_strdup("bola1.txt")); -    s = sb_slist_append(s, sb_strdup("bola2.txt")); -    s = sb_slist_append(s, sb_strdup("bola3.txt")); -    s = sb_slist_append(s, sb_strdup("bola4.txt")); -    s = sb_slist_append(s, sb_strdup("bola5.txt")); -    s = sb_slist_append(s, sb_strdup("bola6.txt")); -    s = sb_slist_append(s, sb_strdup("bola7.txt")); -    sb_trie_t *c = sb_trie_new(free); -    sb_trie_insert(c, "FILTER_TAG", sb_strdup("chunda")); -    sb_trie_insert(c, "FILTER_PAGE", sb_strdup("2")); -    sb_trie_insert(c, "FILTER_PER_PAGE", sb_strdup("2")); -    sb_slist_t *t = blogc_source_parse_from_files(c, s, &err); +    bc_slist_t *s = NULL; +    s = bc_slist_append(s, bc_strdup("bola1.txt")); +    s = bc_slist_append(s, bc_strdup("bola2.txt")); +    s = bc_slist_append(s, bc_strdup("bola3.txt")); +    s = bc_slist_append(s, bc_strdup("bola4.txt")); +    s = bc_slist_append(s, bc_strdup("bola5.txt")); +    s = bc_slist_append(s, bc_strdup("bola6.txt")); +    s = bc_slist_append(s, bc_strdup("bola7.txt")); +    bc_trie_t *c = bc_trie_new(free); +    bc_trie_insert(c, "FILTER_TAG", bc_strdup("chunda")); +    bc_trie_insert(c, "FILTER_PAGE", bc_strdup("2")); +    bc_trie_insert(c, "FILTER_PER_PAGE", bc_strdup("2")); +    bc_slist_t *t = blogc_source_parse_from_files(c, s, &err);      assert_null(err);      assert_non_null(t); -    assert_int_equal(sb_slist_length(t), 2);  // it is enough, no need to look at the items -    assert_int_equal(sb_trie_size(c), 11); -    assert_string_equal(sb_trie_lookup(c, "FILENAME_FIRST"), "bola5"); -    assert_string_equal(sb_trie_lookup(c, "FILENAME_LAST"), "bola7"); -    assert_string_equal(sb_trie_lookup(c, "DATE_FIRST"), "2005-02-03 04:05:06"); -    assert_string_equal(sb_trie_lookup(c, "DATE_LAST"), "2007-02-03 04:05:06"); -    assert_string_equal(sb_trie_lookup(c, "FILTER_TAG"), "chunda"); -    assert_string_equal(sb_trie_lookup(c, "FILTER_PAGE"), "2"); -    assert_string_equal(sb_trie_lookup(c, "FILTER_PER_PAGE"), "2"); -    assert_string_equal(sb_trie_lookup(c, "CURRENT_PAGE"), "2"); -    assert_string_equal(sb_trie_lookup(c, "PREVIOUS_PAGE"), "1"); -    assert_string_equal(sb_trie_lookup(c, "FIRST_PAGE"), "1"); -    assert_string_equal(sb_trie_lookup(c, "LAST_PAGE"), "2"); -    sb_trie_free(c); -    sb_slist_free_full(s, free); -    sb_slist_free_full(t, (sb_free_func_t) sb_trie_free); +    assert_int_equal(bc_slist_length(t), 2);  // it is enough, no need to look at the items +    assert_int_equal(bc_trie_size(c), 11); +    assert_string_equal(bc_trie_lookup(c, "FILENAME_FIRST"), "bola5"); +    assert_string_equal(bc_trie_lookup(c, "FILENAME_LAST"), "bola7"); +    assert_string_equal(bc_trie_lookup(c, "DATE_FIRST"), "2005-02-03 04:05:06"); +    assert_string_equal(bc_trie_lookup(c, "DATE_LAST"), "2007-02-03 04:05:06"); +    assert_string_equal(bc_trie_lookup(c, "FILTER_TAG"), "chunda"); +    assert_string_equal(bc_trie_lookup(c, "FILTER_PAGE"), "2"); +    assert_string_equal(bc_trie_lookup(c, "FILTER_PER_PAGE"), "2"); +    assert_string_equal(bc_trie_lookup(c, "CURRENT_PAGE"), "2"); +    assert_string_equal(bc_trie_lookup(c, "PREVIOUS_PAGE"), "1"); +    assert_string_equal(bc_trie_lookup(c, "FIRST_PAGE"), "1"); +    assert_string_equal(bc_trie_lookup(c, "LAST_PAGE"), "2"); +    bc_trie_free(c); +    bc_slist_free_full(s, free); +    bc_slist_free_full(t, (bc_free_func_t) bc_trie_free);  } @@ -546,77 +546,77 @@ static void  test_source_parse_from_files_filter_by_page_invalid(void **state)  {      will_return(__wrap_blogc_file_get_contents, "bola1.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 123\n"          "DATE: 2001-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola2.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 456\n"          "DATE: 2002-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola3.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 789\n"          "DATE: 2003-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola4.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7891\n"          "DATE: 2004-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola5.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7892\n"          "DATE: 2005-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola6.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7893\n"          "DATE: 2006-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola7.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7894\n"          "DATE: 2007-02-03 04:05:06\n"          "--------\n"          "bola"));      blogc_error_t *err = NULL; -    sb_slist_t *s = NULL; -    s = sb_slist_append(s, sb_strdup("bola1.txt")); -    s = sb_slist_append(s, sb_strdup("bola2.txt")); -    s = sb_slist_append(s, sb_strdup("bola3.txt")); -    s = sb_slist_append(s, sb_strdup("bola4.txt")); -    s = sb_slist_append(s, sb_strdup("bola5.txt")); -    s = sb_slist_append(s, sb_strdup("bola6.txt")); -    s = sb_slist_append(s, sb_strdup("bola7.txt")); -    sb_trie_t *c = sb_trie_new(free); -    sb_trie_insert(c, "FILTER_PAGE", sb_strdup("-1")); -    sb_trie_insert(c, "FILTER_PER_PAGE", sb_strdup("2")); -    sb_slist_t *t = blogc_source_parse_from_files(c, s, &err); +    bc_slist_t *s = NULL; +    s = bc_slist_append(s, bc_strdup("bola1.txt")); +    s = bc_slist_append(s, bc_strdup("bola2.txt")); +    s = bc_slist_append(s, bc_strdup("bola3.txt")); +    s = bc_slist_append(s, bc_strdup("bola4.txt")); +    s = bc_slist_append(s, bc_strdup("bola5.txt")); +    s = bc_slist_append(s, bc_strdup("bola6.txt")); +    s = bc_slist_append(s, bc_strdup("bola7.txt")); +    bc_trie_t *c = bc_trie_new(free); +    bc_trie_insert(c, "FILTER_PAGE", bc_strdup("-1")); +    bc_trie_insert(c, "FILTER_PER_PAGE", bc_strdup("2")); +    bc_slist_t *t = blogc_source_parse_from_files(c, s, &err);      assert_null(err);      assert_non_null(t); -    assert_int_equal(sb_slist_length(t), 2);  // it is enough, no need to look at the items -    assert_int_equal(sb_trie_size(c), 10); -    assert_string_equal(sb_trie_lookup(c, "FILENAME_FIRST"), "bola1"); -    assert_string_equal(sb_trie_lookup(c, "FILENAME_LAST"), "bola2"); -    assert_string_equal(sb_trie_lookup(c, "DATE_FIRST"), "2001-02-03 04:05:06"); -    assert_string_equal(sb_trie_lookup(c, "DATE_LAST"), "2002-02-03 04:05:06"); -    assert_string_equal(sb_trie_lookup(c, "FILTER_PAGE"), "-1"); -    assert_string_equal(sb_trie_lookup(c, "FILTER_PER_PAGE"), "2"); -    assert_string_equal(sb_trie_lookup(c, "CURRENT_PAGE"), "1"); -    assert_string_equal(sb_trie_lookup(c, "NEXT_PAGE"), "2"); -    assert_string_equal(sb_trie_lookup(c, "FIRST_PAGE"), "1"); -    assert_string_equal(sb_trie_lookup(c, "LAST_PAGE"), "4"); -    sb_trie_free(c); -    sb_slist_free_full(s, free); -    sb_slist_free_full(t, (sb_free_func_t) sb_trie_free); +    assert_int_equal(bc_slist_length(t), 2);  // it is enough, no need to look at the items +    assert_int_equal(bc_trie_size(c), 10); +    assert_string_equal(bc_trie_lookup(c, "FILENAME_FIRST"), "bola1"); +    assert_string_equal(bc_trie_lookup(c, "FILENAME_LAST"), "bola2"); +    assert_string_equal(bc_trie_lookup(c, "DATE_FIRST"), "2001-02-03 04:05:06"); +    assert_string_equal(bc_trie_lookup(c, "DATE_LAST"), "2002-02-03 04:05:06"); +    assert_string_equal(bc_trie_lookup(c, "FILTER_PAGE"), "-1"); +    assert_string_equal(bc_trie_lookup(c, "FILTER_PER_PAGE"), "2"); +    assert_string_equal(bc_trie_lookup(c, "CURRENT_PAGE"), "1"); +    assert_string_equal(bc_trie_lookup(c, "NEXT_PAGE"), "2"); +    assert_string_equal(bc_trie_lookup(c, "FIRST_PAGE"), "1"); +    assert_string_equal(bc_trie_lookup(c, "LAST_PAGE"), "4"); +    bc_trie_free(c); +    bc_slist_free_full(s, free); +    bc_slist_free_full(t, (bc_free_func_t) bc_trie_free);  } @@ -624,64 +624,64 @@ static void  test_source_parse_from_files_filter_by_page_invalid2(void **state)  {      will_return(__wrap_blogc_file_get_contents, "bola1.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 123\n"          "DATE: 2001-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola2.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 456\n"          "DATE: 2002-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola3.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 789\n"          "DATE: 2003-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola4.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7891\n"          "DATE: 2004-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola5.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7892\n"          "DATE: 2005-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola6.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7893\n"          "DATE: 2006-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola7.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 7894\n"          "DATE: 2007-02-03 04:05:06\n"          "--------\n"          "bola"));      blogc_error_t *err = NULL; -    sb_slist_t *s = NULL; -    s = sb_slist_append(s, sb_strdup("bola1.txt")); -    s = sb_slist_append(s, sb_strdup("bola2.txt")); -    s = sb_slist_append(s, sb_strdup("bola3.txt")); -    s = sb_slist_append(s, sb_strdup("bola4.txt")); -    s = sb_slist_append(s, sb_strdup("bola5.txt")); -    s = sb_slist_append(s, sb_strdup("bola6.txt")); -    s = sb_slist_append(s, sb_strdup("bola7.txt")); -    sb_trie_t *c = sb_trie_new(free); -    sb_trie_insert(c, "FILTER_PAGE", sb_strdup("5")); -    sb_trie_insert(c, "FILTER_PER_PAGE", sb_strdup("2")); -    sb_slist_t *t = blogc_source_parse_from_files(c, s, &err); +    bc_slist_t *s = NULL; +    s = bc_slist_append(s, bc_strdup("bola1.txt")); +    s = bc_slist_append(s, bc_strdup("bola2.txt")); +    s = bc_slist_append(s, bc_strdup("bola3.txt")); +    s = bc_slist_append(s, bc_strdup("bola4.txt")); +    s = bc_slist_append(s, bc_strdup("bola5.txt")); +    s = bc_slist_append(s, bc_strdup("bola6.txt")); +    s = bc_slist_append(s, bc_strdup("bola7.txt")); +    bc_trie_t *c = bc_trie_new(free); +    bc_trie_insert(c, "FILTER_PAGE", bc_strdup("5")); +    bc_trie_insert(c, "FILTER_PER_PAGE", bc_strdup("2")); +    bc_slist_t *t = blogc_source_parse_from_files(c, s, &err);      assert_null(err);      assert_null(t); -    sb_trie_free(c); -    sb_slist_free_full(s, free); +    bc_trie_free(c); +    bc_slist_free_full(s, free);  } @@ -694,39 +694,39 @@ test_source_parse_from_files_without_all_dates(void **state)          "file, but not for all source files. This means that you may get wrong "          "values for 'DATE_FIRST' and 'DATE_LAST' variables.\n");      will_return(__wrap_blogc_file_get_contents, "bola1.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 123\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola2.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 456\n"          "DATE: 2002-02-03 04:05:06\n"          "--------\n"          "bola"));      will_return(__wrap_blogc_file_get_contents, "bola3.txt"); -    will_return(__wrap_blogc_file_get_contents, sb_strdup( +    will_return(__wrap_blogc_file_get_contents, bc_strdup(          "ASD: 789\n"          "DATE: 2003-02-03 04:05:06\n"          "--------\n"          "bola"));      blogc_error_t *err = NULL; -    sb_slist_t *s = NULL; -    s = sb_slist_append(s, sb_strdup("bola1.txt")); -    s = sb_slist_append(s, sb_strdup("bola2.txt")); -    s = sb_slist_append(s, sb_strdup("bola3.txt")); -    sb_trie_t *c = sb_trie_new(free); -    sb_slist_t *t = blogc_source_parse_from_files(c, s, &err); +    bc_slist_t *s = NULL; +    s = bc_slist_append(s, bc_strdup("bola1.txt")); +    s = bc_slist_append(s, bc_strdup("bola2.txt")); +    s = bc_slist_append(s, bc_strdup("bola3.txt")); +    bc_trie_t *c = bc_trie_new(free); +    bc_slist_t *t = blogc_source_parse_from_files(c, s, &err);      assert_null(err);      assert_non_null(t); -    assert_int_equal(sb_slist_length(t), 3);  // it is enough, no need to look at the items -    assert_int_equal(sb_trie_size(c), 3); -    assert_string_equal(sb_trie_lookup(c, "FILENAME_FIRST"), "bola1"); -    assert_string_equal(sb_trie_lookup(c, "FILENAME_LAST"), "bola3"); -    assert_string_equal(sb_trie_lookup(c, "DATE_LAST"), "2003-02-03 04:05:06"); -    sb_trie_free(c); -    sb_slist_free_full(s, free); -    sb_slist_free_full(t, (sb_free_func_t) sb_trie_free); +    assert_int_equal(bc_slist_length(t), 3);  // it is enough, no need to look at the items +    assert_int_equal(bc_trie_size(c), 3); +    assert_string_equal(bc_trie_lookup(c, "FILENAME_FIRST"), "bola1"); +    assert_string_equal(bc_trie_lookup(c, "FILENAME_LAST"), "bola3"); +    assert_string_equal(bc_trie_lookup(c, "DATE_LAST"), "2003-02-03 04:05:06"); +    bc_trie_free(c); +    bc_slist_free_full(s, free); +    bc_slist_free_full(t, (bc_free_func_t) bc_trie_free);  } @@ -734,16 +734,16 @@ static void  test_source_parse_from_files_null(void **state)  {      blogc_error_t *err = NULL; -    sb_slist_t *s = NULL; -    sb_trie_t *c = sb_trie_new(free); -    sb_slist_t *t = blogc_source_parse_from_files(c, s, &err); +    bc_slist_t *s = NULL; +    bc_trie_t *c = bc_trie_new(free); +    bc_slist_t *t = blogc_source_parse_from_files(c, s, &err);      assert_null(err);      assert_null(t); -    assert_int_equal(sb_slist_length(t), 0); -    assert_int_equal(sb_trie_size(c), 0); -    sb_trie_free(c); -    sb_slist_free_full(s, free); -    sb_slist_free_full(t, (sb_free_func_t) sb_trie_free); +    assert_int_equal(bc_slist_length(t), 0); +    assert_int_equal(bc_trie_size(c), 0); +    bc_trie_free(c); +    bc_slist_free_full(s, free); +    bc_slist_free_full(t, (bc_free_func_t) bc_trie_free);  } diff --git a/tests/blogc/check_renderer.c b/tests/blogc/check_renderer.c index c058788..fa50601 100644 --- a/tests/blogc/check_renderer.c +++ b/tests/blogc/check_renderer.c @@ -20,7 +20,7 @@  #include "../../src/common/utils.h" -static sb_slist_t* +static bc_slist_t*  create_sources(unsigned int count)  {      const char *s[] = { @@ -45,12 +45,12 @@ create_sources(unsigned int count)      };      assert_false(count > 3);      blogc_error_t *err = NULL; -    sb_slist_t *l = NULL; +    bc_slist_t *l = NULL;      for (unsigned int i = 0; i < count; i++) { -        l = sb_slist_append(l, blogc_source_parse(s[i], strlen(s[i]), &err)); +        l = bc_slist_append(l, blogc_source_parse(s[i], strlen(s[i]), &err));          assert_null(err);      } -    assert_int_equal(sb_slist_length(l), count); +    assert_int_equal(bc_slist_length(l), count);      return l;  } @@ -77,10 +77,10 @@ test_render_entry(void **state)          "{% foreach TAGS %}lol {{ FOREACH_ITEM }} haha {% endforeach %}\n"          "{% foreach TAGS_ASD %}yay{% endforeach %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -102,7 +102,7 @@ test_render_entry(void **state)          "lol foo haha lol bar haha lol baz haha \n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -124,10 +124,10 @@ test_render_listing(void **state)          "{% foreach TAGS_ASD %}yay{% endforeach %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(3); +    bc_slist_t *s = create_sources(3);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, true);      assert_string_equal(out, @@ -151,7 +151,7 @@ test_render_listing(void **state)          "\n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -172,7 +172,7 @@ test_render_listing_empty(void **state)          "{% foreach TAGS %}lol {{ FOREACH_ITEM }} haha {% endforeach %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err);      char *out = blogc_render(l, NULL, NULL, true); @@ -199,10 +199,10 @@ test_render_ifdef(void **state)          "{% endif %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -210,7 +210,7 @@ test_render_ifdef(void **state)          "\n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -228,10 +228,10 @@ test_render_ifdef2(void **state)          "{% endif %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -241,7 +241,7 @@ test_render_ifdef2(void **state)          "\n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -259,10 +259,10 @@ test_render_ifdef3(void **state)          "{% endif %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -274,7 +274,7 @@ test_render_ifdef3(void **state)          "\n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -294,10 +294,10 @@ test_render_ifdef4(void **state)          "{% endif %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -310,7 +310,7 @@ test_render_ifdef4(void **state)          "\n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -330,10 +330,10 @@ test_render_ifdef5(void **state)          "{% endif %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -344,7 +344,7 @@ test_render_ifdef5(void **state)          "\n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -364,10 +364,10 @@ test_render_ifdef6(void **state)          "{% endif %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -376,7 +376,7 @@ test_render_ifdef6(void **state)          "\n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -397,10 +397,10 @@ test_render_ifdef7(void **state)          "{% endif %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -414,7 +414,7 @@ test_render_ifdef7(void **state)          "\n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -433,10 +433,10 @@ test_render_ifndef(void **state)          "{% endif %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -449,7 +449,7 @@ test_render_ifndef(void **state)          "\n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -469,10 +469,10 @@ test_render_if_eq(void **state)          "{% endif %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -486,7 +486,7 @@ test_render_if_eq(void **state)          "\n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -506,10 +506,10 @@ test_render_if_neq(void **state)          "{% endif %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -523,7 +523,7 @@ test_render_if_neq(void **state)          "\n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -543,10 +543,10 @@ test_render_if_lt(void **state)          "{% endif %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -560,7 +560,7 @@ test_render_if_lt(void **state)          "\n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -580,10 +580,10 @@ test_render_if_gt(void **state)          "{% endif %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -597,7 +597,7 @@ test_render_if_gt(void **state)          "\n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -619,10 +619,10 @@ test_render_if_lt_eq(void **state)          "{% endif %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -638,7 +638,7 @@ test_render_if_lt_eq(void **state)          "\n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -660,10 +660,10 @@ test_render_if_gt_eq(void **state)          "{% endif %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -679,7 +679,7 @@ test_render_if_gt_eq(void **state)          "\n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -692,10 +692,10 @@ test_render_foreach(void **state)          "{% foreach TAGS %} {{ FOREACH_ITEM }} {% endforeach %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -703,7 +703,7 @@ test_render_foreach(void **state)          " foo  bar  baz \n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -717,10 +717,10 @@ test_render_foreach_if(void **state)          "{% endif %} {% endforeach %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -728,7 +728,7 @@ test_render_foreach_if(void **state)          "   bar   \n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -743,10 +743,10 @@ test_render_foreach_if_else(void **state)          "{% endif %} {% endforeach %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s);      char *out = blogc_render(l, s, NULL, false);      assert_string_equal(out, @@ -754,7 +754,7 @@ test_render_foreach_if_else(void **state)          "foo yay baz \n"          "\n");      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -774,21 +774,21 @@ test_render_outside_block(void **state)          "{{ BOLA }}\n"          "{% ifndef CHUNDA %}lol{% endif %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s); -    sb_trie_t *c = sb_trie_new(free); -    sb_trie_insert(c, "GUDA", sb_strdup("asd")); +    bc_trie_t *c = bc_trie_new(free); +    bc_trie_insert(c, "GUDA", bc_strdup("asd"));      char *out = blogc_render(l, s, c, false);      assert_string_equal(out,          "bola\n"          "\n"          "lol\n"); -    sb_trie_free(c); +    bc_trie_free(c);      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -807,14 +807,14 @@ test_render_prefer_local_variable(void **state)          "{% endif %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s); -    sb_trie_t *c = sb_trie_new(free); -    sb_trie_insert(c, "GUDA", sb_strdup("hehe")); -    sb_trie_insert(c, "LOL", sb_strdup("hmm")); +    bc_trie_t *c = bc_trie_new(free); +    bc_trie_insert(c, "GUDA", bc_strdup("hehe")); +    bc_trie_insert(c, "LOL", bc_strdup("hmm"));      char *out = blogc_render(l, s, c, false);      assert_string_equal(out,          "\n" @@ -825,9 +825,9 @@ test_render_prefer_local_variable(void **state)          "\n"          "\n"          "\n"); -    sb_trie_free(c); +    bc_trie_free(c);      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -843,12 +843,12 @@ test_render_respect_variable_scope(void **state)          "{% ifdef BOLA %}{{ BOLA }}{% endif %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = create_sources(1); +    bc_slist_t *s = create_sources(1);      assert_non_null(s); -    sb_trie_t *c = sb_trie_new(free); +    bc_trie_t *c = bc_trie_new(free);      char *out = blogc_render(l, s, c, false);      assert_string_equal(out,          "\n" @@ -857,9 +857,9 @@ test_render_respect_variable_scope(void **state)          "\n"          "asd\n"          "\n"); -    sb_trie_free(c); +    bc_trie_free(c);      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -875,22 +875,22 @@ test_render_ifcount_bug(void **state)          "{% endif %}\n"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); +    bc_slist_t *l = blogc_template_parse(str, strlen(str), &err);      assert_non_null(l);      assert_null(err); -    sb_slist_t *s = NULL; -    s = sb_slist_append(s, sb_trie_new(free)); -    sb_trie_insert(s->data, "TITLE", sb_strdup("bola")); -    sb_trie_t *c = sb_trie_new(free); +    bc_slist_t *s = NULL; +    s = bc_slist_append(s, bc_trie_new(free)); +    bc_trie_insert(s->data, "TITLE", bc_strdup("bola")); +    bc_trie_t *c = bc_trie_new(free);      char *out = blogc_render(l, s, c, false);      assert_string_equal(out,          "\n"          "<h3>bola</h3>\n"          "\n"          "\n"); -    sb_trie_free(c); +    bc_trie_free(c);      blogc_template_free_stmts(l); -    sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); +    bc_slist_free_full(s, (bc_free_func_t) bc_trie_free);      free(out);  } @@ -898,100 +898,100 @@ test_render_ifcount_bug(void **state)  static void  test_get_variable(void **state)  { -    sb_trie_t *g = sb_trie_new(free); -    sb_trie_insert(g, "NAME", sb_strdup("bola")); -    sb_trie_insert(g, "TITLE", sb_strdup("bola2")); -    sb_trie_t *l = sb_trie_new(free); -    sb_trie_insert(l, "NAME", sb_strdup("chunda")); -    sb_trie_insert(l, "TITLE", sb_strdup("chunda2")); +    bc_trie_t *g = bc_trie_new(free); +    bc_trie_insert(g, "NAME", bc_strdup("bola")); +    bc_trie_insert(g, "TITLE", bc_strdup("bola2")); +    bc_trie_t *l = bc_trie_new(free); +    bc_trie_insert(l, "NAME", bc_strdup("chunda")); +    bc_trie_insert(l, "TITLE", bc_strdup("chunda2"));      assert_string_equal(blogc_get_variable("NAME", g, l), "chunda");      assert_string_equal(blogc_get_variable("TITLE", g, l), "chunda2");      assert_null(blogc_get_variable("BOLA", g, l)); -    sb_trie_free(g); -    sb_trie_free(l); +    bc_trie_free(g); +    bc_trie_free(l);  }  static void  test_get_variable_only_local(void **state)  { -    sb_trie_t *g = NULL; -    sb_trie_t *l = sb_trie_new(free); -    sb_trie_insert(l, "NAME", sb_strdup("chunda")); -    sb_trie_insert(l, "TITLE", sb_strdup("chunda2")); +    bc_trie_t *g = NULL; +    bc_trie_t *l = bc_trie_new(free); +    bc_trie_insert(l, "NAME", bc_strdup("chunda")); +    bc_trie_insert(l, "TITLE", bc_strdup("chunda2"));      assert_string_equal(blogc_get_variable("NAME", g, l), "chunda");      assert_string_equal(blogc_get_variable("TITLE", g, l), "chunda2");      assert_null(blogc_get_variable("BOLA", g, l)); -    sb_trie_free(l); +    bc_trie_free(l);  }  static void  test_get_variable_only_global(void **state)  { -    sb_trie_t *g = sb_trie_new(free); -    sb_trie_insert(g, "NAME", sb_strdup("bola")); -    sb_trie_insert(g, "TITLE", sb_strdup("bola2")); -    sb_trie_t *l = NULL; +    bc_trie_t *g = bc_trie_new(free); +    bc_trie_insert(g, "NAME", bc_strdup("bola")); +    bc_trie_insert(g, "TITLE", bc_strdup("bola2")); +    bc_trie_t *l = NULL;      assert_string_equal(blogc_get_variable("NAME", g, l), "bola");      assert_string_equal(blogc_get_variable("TITLE", g, l), "bola2");      assert_null(blogc_get_variable("BOLA", g, l)); -    sb_trie_free(g); +    bc_trie_free(g);  }  static void  test_format_date(void **state)  { -    sb_trie_t *g = sb_trie_new(free); -    sb_trie_insert(g, "DATE_FORMAT", sb_strdup("%H -- %M")); -    sb_trie_t *l = sb_trie_new(free); -    sb_trie_insert(l, "DATE_FORMAT", sb_strdup("%R")); +    bc_trie_t *g = bc_trie_new(free); +    bc_trie_insert(g, "DATE_FORMAT", bc_strdup("%H -- %M")); +    bc_trie_t *l = bc_trie_new(free); +    bc_trie_insert(l, "DATE_FORMAT", bc_strdup("%R"));      char *date = blogc_format_date("2015-01-02 03:04:05", g, l);      assert_string_equal(date, "03:04");      free(date); -    sb_trie_free(g); -    sb_trie_free(l); +    bc_trie_free(g); +    bc_trie_free(l);  }  static void  test_format_date_with_global_format(void **state)  { -    sb_trie_t *g = sb_trie_new(free); -    sb_trie_insert(g, "DATE_FORMAT", sb_strdup("%H -- %M")); -    sb_trie_t *l = sb_trie_new(free); +    bc_trie_t *g = bc_trie_new(free); +    bc_trie_insert(g, "DATE_FORMAT", bc_strdup("%H -- %M")); +    bc_trie_t *l = bc_trie_new(free);      char *date = blogc_format_date("2015-01-02 03:04:05", g, l);      assert_string_equal(date, "03 -- 04");      free(date); -    sb_trie_free(g); -    sb_trie_free(l); +    bc_trie_free(g); +    bc_trie_free(l);  }  static void  test_format_date_without_format(void **state)  { -    sb_trie_t *g = sb_trie_new(free); -    sb_trie_t *l = sb_trie_new(free); +    bc_trie_t *g = bc_trie_new(free); +    bc_trie_t *l = bc_trie_new(free);      char *date = blogc_format_date("2015-01-02 03:04:05", g, l);      assert_string_equal(date, "2015-01-02 03:04:05");      free(date); -    sb_trie_free(g); -    sb_trie_free(l); +    bc_trie_free(g); +    bc_trie_free(l);  }  static void  test_format_date_without_date(void **state)  { -    sb_trie_t *g = sb_trie_new(free); -    sb_trie_t *l = sb_trie_new(free); +    bc_trie_t *g = bc_trie_new(free); +    bc_trie_t *l = bc_trie_new(free);      char *date = blogc_format_date(NULL, g, l);      assert_null(date);      free(date); -    sb_trie_free(g); -    sb_trie_free(l); +    bc_trie_free(g); +    bc_trie_free(l);  } @@ -999,13 +999,13 @@ static void  test_format_variable(void **state)  {      // FIXME: test warnings -    sb_trie_t *g = sb_trie_new(free); -    sb_trie_insert(g, "NAME", sb_strdup("bola")); -    sb_trie_insert(g, "TITLE", sb_strdup("bola2")); -    sb_trie_t *l = sb_trie_new(free); -    sb_trie_insert(l, "NAME", sb_strdup("chunda")); -    sb_trie_insert(l, "TITLE", sb_strdup("chunda2")); -    sb_trie_insert(l, "SIZE", sb_strdup("1234567890987654321")); +    bc_trie_t *g = bc_trie_new(free); +    bc_trie_insert(g, "NAME", bc_strdup("bola")); +    bc_trie_insert(g, "TITLE", bc_strdup("bola2")); +    bc_trie_t *l = bc_trie_new(free); +    bc_trie_insert(l, "NAME", bc_strdup("chunda")); +    bc_trie_insert(l, "TITLE", bc_strdup("chunda2")); +    bc_trie_insert(l, "SIZE", bc_strdup("1234567890987654321"));      char *tmp = blogc_format_variable("NAME", g, l, NULL);      assert_string_equal(tmp, "chunda");      free(tmp); @@ -1023,19 +1023,19 @@ test_format_variable(void **state)      free(tmp);      assert_null(blogc_format_variable("SIZE_", g, l, NULL));      assert_null(blogc_format_variable("BOLA", g, l, NULL)); -    sb_trie_free(g); -    sb_trie_free(l); +    bc_trie_free(g); +    bc_trie_free(l);  }  static void  test_format_variable_with_date(void **state)  { -    sb_trie_t *g = sb_trie_new(free); -    sb_trie_insert(g, "DATE", sb_strdup("2010-11-12 13:14:15")); -    sb_trie_insert(g, "DATE_FORMAT", sb_strdup("%R")); -    sb_trie_t *l = sb_trie_new(free); -    sb_trie_insert(l, "DATE", sb_strdup("2011-12-13 14:15:16")); +    bc_trie_t *g = bc_trie_new(free); +    bc_trie_insert(g, "DATE", bc_strdup("2010-11-12 13:14:15")); +    bc_trie_insert(g, "DATE_FORMAT", bc_strdup("%R")); +    bc_trie_t *l = bc_trie_new(free); +    bc_trie_insert(l, "DATE", bc_strdup("2011-12-13 14:15:16"));      char *tmp = blogc_format_variable("DATE_FORMATTED", g, l, NULL);      assert_string_equal(tmp, "14:15");      free(tmp); @@ -1045,18 +1045,18 @@ test_format_variable_with_date(void **state)      tmp = blogc_format_variable("DATE_FORMATTED_10", g, l, NULL);      assert_string_equal(tmp, "14:15");      free(tmp); -    sb_trie_free(g); -    sb_trie_free(l); +    bc_trie_free(g); +    bc_trie_free(l);  }  static void  test_format_variable_foreach(void **state)  { -    sb_slist_t *l = NULL; -    l = sb_slist_append(l, sb_strdup("asd")); -    l = sb_slist_append(l, sb_strdup("qwe")); -    l = sb_slist_append(l, sb_strdup("zxcvbn")); +    bc_slist_t *l = NULL; +    l = bc_slist_append(l, bc_strdup("asd")); +    l = bc_slist_append(l, bc_strdup("qwe")); +    l = bc_slist_append(l, bc_strdup("zxcvbn"));      char *tmp = blogc_format_variable("FOREACH_ITEM", NULL, NULL, l->next);      assert_string_equal(tmp, "qwe");      free(tmp); @@ -1068,7 +1068,7 @@ test_format_variable_foreach(void **state)          l->next->next);      assert_string_equal(tmp, "zxcvbn");      free(tmp); -    sb_slist_free_full(l, free); +    bc_slist_free_full(l, free);  } @@ -1083,31 +1083,31 @@ test_format_variable_foreach_empty(void **state)  static void  test_split_list_variable(void **state)  { -    sb_trie_t *g = sb_trie_new(free); -    sb_trie_insert(g, "TAGS", sb_strdup("asd  lol hehe")); -    sb_trie_t *l = sb_trie_new(free); -    sb_trie_insert(l, "TAGS", sb_strdup("asd  lol XD")); -    sb_slist_t *tmp = blogc_split_list_variable("TAGS", g, l); +    bc_trie_t *g = bc_trie_new(free); +    bc_trie_insert(g, "TAGS", bc_strdup("asd  lol hehe")); +    bc_trie_t *l = bc_trie_new(free); +    bc_trie_insert(l, "TAGS", bc_strdup("asd  lol XD")); +    bc_slist_t *tmp = blogc_split_list_variable("TAGS", g, l);      assert_string_equal(tmp->data, "asd");      assert_string_equal(tmp->next->data, "lol");      assert_string_equal(tmp->next->next->data, "XD"); -    sb_slist_free_full(tmp, free); -    sb_trie_free(g); -    sb_trie_free(l); +    bc_slist_free_full(tmp, free); +    bc_trie_free(g); +    bc_trie_free(l);  }  static void  test_split_list_variable_not_found(void **state)  { -    sb_trie_t *g = sb_trie_new(free); -    sb_trie_insert(g, "TAGS", sb_strdup("asd  lol hehe")); -    sb_trie_t *l = sb_trie_new(free); -    sb_trie_insert(l, "TAGS", sb_strdup("asd  lol XD")); -    sb_slist_t *tmp = blogc_split_list_variable("TAG", g, l); +    bc_trie_t *g = bc_trie_new(free); +    bc_trie_insert(g, "TAGS", bc_strdup("asd  lol hehe")); +    bc_trie_t *l = bc_trie_new(free); +    bc_trie_insert(l, "TAGS", bc_strdup("asd  lol XD")); +    bc_slist_t *tmp = blogc_split_list_variable("TAG", g, l);      assert_null(tmp); -    sb_trie_free(g); -    sb_trie_free(l); +    bc_trie_free(g); +    bc_trie_free(l);  } diff --git a/tests/blogc/check_source_parser.c b/tests/blogc/check_source_parser.c index a1849eb..4606673 100644 --- a/tests/blogc/check_source_parser.c +++ b/tests/blogc/check_source_parser.c @@ -27,24 +27,24 @@ test_source_parse(void **state)          "\n"          "bola\n";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(err);      assert_non_null(source); -    assert_int_equal(sb_trie_size(source), 6); -    assert_string_equal(sb_trie_lookup(source, "VAR1"), "asd asd"); -    assert_string_equal(sb_trie_lookup(source, "VAR2"), "123chunda"); -    assert_string_equal(sb_trie_lookup(source, "EXCERPT"), +    assert_int_equal(bc_trie_size(source), 6); +    assert_string_equal(bc_trie_lookup(source, "VAR1"), "asd asd"); +    assert_string_equal(bc_trie_lookup(source, "VAR2"), "123chunda"); +    assert_string_equal(bc_trie_lookup(source, "EXCERPT"),          "<h1 id=\"this-is-a-test\">This is a test</h1>\n"          "<p>bola</p>\n"); -    assert_string_equal(sb_trie_lookup(source, "CONTENT"), +    assert_string_equal(bc_trie_lookup(source, "CONTENT"),          "<h1 id=\"this-is-a-test\">This is a test</h1>\n"          "<p>bola</p>\n"); -    assert_string_equal(sb_trie_lookup(source, "RAW_CONTENT"), +    assert_string_equal(bc_trie_lookup(source, "RAW_CONTENT"),          "# This is a test\n"          "\n"          "bola\n"); -    assert_string_equal(sb_trie_lookup(source, "DESCRIPTION"), "bola"); -    sb_trie_free(source); +    assert_string_equal(bc_trie_lookup(source, "DESCRIPTION"), "bola"); +    bc_trie_free(source);  } @@ -59,24 +59,24 @@ test_source_parse_crlf(void **state)          "\r\n"          "bola\r\n";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(err);      assert_non_null(source); -    assert_int_equal(sb_trie_size(source), 6); -    assert_string_equal(sb_trie_lookup(source, "VAR1"), "asd asd"); -    assert_string_equal(sb_trie_lookup(source, "VAR2"), "123chunda"); -    assert_string_equal(sb_trie_lookup(source, "EXCERPT"), +    assert_int_equal(bc_trie_size(source), 6); +    assert_string_equal(bc_trie_lookup(source, "VAR1"), "asd asd"); +    assert_string_equal(bc_trie_lookup(source, "VAR2"), "123chunda"); +    assert_string_equal(bc_trie_lookup(source, "EXCERPT"),          "<h1 id=\"this-is-a-test\">This is a test</h1>\r\n"          "<p>bola</p>\r\n"); -    assert_string_equal(sb_trie_lookup(source, "CONTENT"), +    assert_string_equal(bc_trie_lookup(source, "CONTENT"),          "<h1 id=\"this-is-a-test\">This is a test</h1>\r\n"          "<p>bola</p>\r\n"); -    assert_string_equal(sb_trie_lookup(source, "RAW_CONTENT"), +    assert_string_equal(bc_trie_lookup(source, "RAW_CONTENT"),          "# This is a test\r\n"          "\r\n"          "bola\r\n"); -    assert_string_equal(sb_trie_lookup(source, "DESCRIPTION"), "bola"); -    sb_trie_free(source); +    assert_string_equal(bc_trie_lookup(source, "DESCRIPTION"), "bola"); +    bc_trie_free(source);  } @@ -93,24 +93,24 @@ test_source_parse_with_spaces(void **state)          "\n"          "bola\n";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(err);      assert_non_null(source); -    assert_int_equal(sb_trie_size(source), 6); -    assert_string_equal(sb_trie_lookup(source, "VAR1"), "chunda"); -    assert_string_equal(sb_trie_lookup(source, "BOLA"), "guda"); -    assert_string_equal(sb_trie_lookup(source, "EXCERPT"), +    assert_int_equal(bc_trie_size(source), 6); +    assert_string_equal(bc_trie_lookup(source, "VAR1"), "chunda"); +    assert_string_equal(bc_trie_lookup(source, "BOLA"), "guda"); +    assert_string_equal(bc_trie_lookup(source, "EXCERPT"),          "<h1 id=\"this-is-a-test\">This is a test</h1>\n"          "<p>bola</p>\n"); -    assert_string_equal(sb_trie_lookup(source, "CONTENT"), +    assert_string_equal(bc_trie_lookup(source, "CONTENT"),          "<h1 id=\"this-is-a-test\">This is a test</h1>\n"          "<p>bola</p>\n"); -    assert_string_equal(sb_trie_lookup(source, "RAW_CONTENT"), +    assert_string_equal(bc_trie_lookup(source, "RAW_CONTENT"),          "# This is a test\n"          "\n"          "bola\n"); -    assert_string_equal(sb_trie_lookup(source, "DESCRIPTION"), "bola"); -    sb_trie_free(source); +    assert_string_equal(bc_trie_lookup(source, "DESCRIPTION"), "bola"); +    bc_trie_free(source);  } @@ -130,21 +130,21 @@ test_source_parse_with_excerpt(void **state)          "guda\n"          "yay";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(err);      assert_non_null(source); -    assert_int_equal(sb_trie_size(source), 6); -    assert_string_equal(sb_trie_lookup(source, "VAR1"), "asd asd"); -    assert_string_equal(sb_trie_lookup(source, "VAR2"), "123chunda"); -    assert_string_equal(sb_trie_lookup(source, "EXCERPT"), +    assert_int_equal(bc_trie_size(source), 6); +    assert_string_equal(bc_trie_lookup(source, "VAR1"), "asd asd"); +    assert_string_equal(bc_trie_lookup(source, "VAR2"), "123chunda"); +    assert_string_equal(bc_trie_lookup(source, "EXCERPT"),          "<h1 id=\"this-is-a-test\">This is a test</h1>\n"          "<p>bola</p>\n"); -    assert_string_equal(sb_trie_lookup(source, "CONTENT"), +    assert_string_equal(bc_trie_lookup(source, "CONTENT"),          "<h1 id=\"this-is-a-test\">This is a test</h1>\n"          "<p>bola</p>\n"          "<p>guda\n"          "yay</p>\n"); -    assert_string_equal(sb_trie_lookup(source, "RAW_CONTENT"), +    assert_string_equal(bc_trie_lookup(source, "RAW_CONTENT"),          "# This is a test\n"          "\n"          "bola\n" @@ -153,8 +153,8 @@ test_source_parse_with_excerpt(void **state)          "\n"          "guda\n"          "yay"); -    assert_string_equal(sb_trie_lookup(source, "DESCRIPTION"), "bola"); -    sb_trie_free(source); +    assert_string_equal(bc_trie_lookup(source, "DESCRIPTION"), "bola"); +    bc_trie_free(source);  } @@ -170,24 +170,24 @@ test_source_parse_with_description(void **state)          "\n"          "bola\n";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(err);      assert_non_null(source); -    assert_int_equal(sb_trie_size(source), 6); -    assert_string_equal(sb_trie_lookup(source, "VAR1"), "asd asd"); -    assert_string_equal(sb_trie_lookup(source, "VAR2"), "123chunda"); -    assert_string_equal(sb_trie_lookup(source, "EXCERPT"), +    assert_int_equal(bc_trie_size(source), 6); +    assert_string_equal(bc_trie_lookup(source, "VAR1"), "asd asd"); +    assert_string_equal(bc_trie_lookup(source, "VAR2"), "123chunda"); +    assert_string_equal(bc_trie_lookup(source, "EXCERPT"),          "<h1 id=\"this-is-a-test\">This is a test</h1>\n"          "<p>bola</p>\n"); -    assert_string_equal(sb_trie_lookup(source, "CONTENT"), +    assert_string_equal(bc_trie_lookup(source, "CONTENT"),          "<h1 id=\"this-is-a-test\">This is a test</h1>\n"          "<p>bola</p>\n"); -    assert_string_equal(sb_trie_lookup(source, "RAW_CONTENT"), +    assert_string_equal(bc_trie_lookup(source, "RAW_CONTENT"),          "# This is a test\n"          "\n"          "bola\n"); -    assert_string_equal(sb_trie_lookup(source, "DESCRIPTION"), "huehuehuebrbr"); -    sb_trie_free(source); +    assert_string_equal(bc_trie_lookup(source, "DESCRIPTION"), "huehuehuebrbr"); +    bc_trie_free(source);  } @@ -196,13 +196,13 @@ test_source_parse_config_empty(void **state)  {      const char *a = "";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(source);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);      assert_string_equal(err->msg, "Your source file is empty.");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -211,14 +211,14 @@ test_source_parse_config_invalid_key(void **state)  {      const char *a = "bola: guda";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);      assert_string_equal(err->msg,          "Can't find a configuration key or the content separator.\n"          "Error occurred near line 1, position 1: bola: guda");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -227,14 +227,14 @@ test_source_parse_config_no_key(void **state)  {      const char *a = "BOLa";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);      assert_string_equal(err->msg,          "Invalid configuration key.\n"          "Error occurred near line 1, position 4: BOLa");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -243,14 +243,14 @@ test_source_parse_config_no_key2(void **state)  {      const char *a = "BOLA";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER);      assert_string_equal(err->msg,          "Your last configuration key is missing ':' and the value\n"          "Error occurred near line 1, position 5: BOLA");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -259,7 +259,7 @@ test_source_parse_config_no_value(void **state)  {      const char *a = "BOLA:\r\n";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(source);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); @@ -267,7 +267,7 @@ test_source_parse_config_no_value(void **state)          "Configuration value not provided for 'BOLA'.\n"          "Error occurred near line 1, position 6: BOLA:");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -276,7 +276,7 @@ test_source_parse_config_no_value2(void **state)  {      const char *a = "BOLA:";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(source);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); @@ -284,7 +284,7 @@ test_source_parse_config_no_value2(void **state)          "Configuration value not provided for 'BOLA'.\n"          "Error occurred near line 1, position 6: BOLA:");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -293,7 +293,7 @@ test_source_parse_config_reserved_name(void **state)  {      const char *a = "FILENAME: asd\r\n";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(source);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); @@ -301,7 +301,7 @@ test_source_parse_config_reserved_name(void **state)          "'FILENAME' variable is forbidden in source files. It will be set "          "for you by the compiler.");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -310,7 +310,7 @@ test_source_parse_config_reserved_name2(void **state)  {      const char *a = "CONTENT: asd\r\n";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(source);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); @@ -318,7 +318,7 @@ test_source_parse_config_reserved_name2(void **state)          "'CONTENT' variable is forbidden in source files. It will be set "          "for you by the compiler.");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -327,7 +327,7 @@ test_source_parse_config_reserved_name3(void **state)  {      const char *a = "DATE_FORMATTED: asd\r\n";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(source);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); @@ -335,7 +335,7 @@ test_source_parse_config_reserved_name3(void **state)          "'DATE_FORMATTED' variable is forbidden in source files. It will be set "          "for you by the compiler.");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -344,7 +344,7 @@ test_source_parse_config_reserved_name4(void **state)  {      const char *a = "DATE_FIRST_FORMATTED: asd\r\n";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(source);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); @@ -352,7 +352,7 @@ test_source_parse_config_reserved_name4(void **state)          "'DATE_FIRST_FORMATTED' variable is forbidden in source files. It will be set "          "for you by the compiler.");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -361,7 +361,7 @@ test_source_parse_config_reserved_name5(void **state)  {      const char *a = "DATE_LAST_FORMATTED: asd\r\n";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(source);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); @@ -369,7 +369,7 @@ test_source_parse_config_reserved_name5(void **state)          "'DATE_LAST_FORMATTED' variable is forbidden in source files. It will be set "          "for you by the compiler.");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -378,7 +378,7 @@ test_source_parse_config_reserved_name6(void **state)  {      const char *a = "PAGE_FIRST: asd\r\n";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(source);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); @@ -386,7 +386,7 @@ test_source_parse_config_reserved_name6(void **state)          "'PAGE_FIRST' variable is forbidden in source files. It will be set "          "for you by the compiler.");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -395,7 +395,7 @@ test_source_parse_config_reserved_name7(void **state)  {      const char *a = "PAGE_PREVIOUS: asd\r\n";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(source);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); @@ -403,7 +403,7 @@ test_source_parse_config_reserved_name7(void **state)          "'PAGE_PREVIOUS' variable is forbidden in source files. It will be set "          "for you by the compiler.");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -412,7 +412,7 @@ test_source_parse_config_reserved_name8(void **state)  {      const char *a = "PAGE_CURRENT: asd\r\n";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(source);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); @@ -420,7 +420,7 @@ test_source_parse_config_reserved_name8(void **state)          "'PAGE_CURRENT' variable is forbidden in source files. It will be set "          "for you by the compiler.");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -429,7 +429,7 @@ test_source_parse_config_reserved_name9(void **state)  {      const char *a = "PAGE_NEXT: asd\r\n";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(source);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); @@ -437,7 +437,7 @@ test_source_parse_config_reserved_name9(void **state)          "'PAGE_NEXT' variable is forbidden in source files. It will be set "          "for you by the compiler.");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -446,7 +446,7 @@ test_source_parse_config_reserved_name10(void **state)  {      const char *a = "PAGE_LAST: asd\r\n";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(source);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); @@ -454,7 +454,7 @@ test_source_parse_config_reserved_name10(void **state)          "'PAGE_LAST' variable is forbidden in source files. It will be set "          "for you by the compiler.");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -463,7 +463,7 @@ test_source_parse_config_reserved_name11(void **state)  {      const char *a = "BLOGC_VERSION: 1.0\r\n";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(source);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); @@ -471,7 +471,7 @@ test_source_parse_config_reserved_name11(void **state)          "'BLOGC_VERSION' variable is forbidden in source files. It will be set "          "for you by the compiler.");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -480,7 +480,7 @@ test_source_parse_config_value_no_line_ending(void **state)  {      const char *a = "BOLA: asd";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(source);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); @@ -488,7 +488,7 @@ test_source_parse_config_value_no_line_ending(void **state)          "No line ending after the configuration value for 'BOLA'.\n"          "Error occurred near line 1, position 10: BOLA: asd");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } @@ -497,7 +497,7 @@ test_source_parse_invalid_separator(void **state)  {      const char *a = "BOLA: asd\n---#";      blogc_error_t *err = NULL; -    sb_trie_t *source = blogc_source_parse(a, strlen(a), &err); +    bc_trie_t *source = blogc_source_parse(a, strlen(a), &err);      assert_null(source);      assert_non_null(err);      assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); @@ -505,7 +505,7 @@ test_source_parse_invalid_separator(void **state)          "Invalid content separator. Must be more than one '-' characters.\n"          "Error occurred near line 2, position 4: ---#");      blogc_error_free(err); -    sb_trie_free(source); +    bc_trie_free(source);  } diff --git a/tests/blogc/check_template_parser.c b/tests/blogc/check_template_parser.c index 3c88fe4..b4c978f 100644 --- a/tests/blogc/check_template_parser.c +++ b/tests/blogc/check_template_parser.c @@ -17,7 +17,7 @@  static void -blogc_assert_template_stmt(sb_slist_t *l, const char *value, +blogc_assert_template_stmt(bc_slist_t *l, const char *value,      const blogc_template_stmt_type_t type)  {      blogc_template_stmt_t *stmt = l->data; @@ -30,7 +30,7 @@ blogc_assert_template_stmt(sb_slist_t *l, const char *value,  static void -blogc_assert_template_if_stmt(sb_slist_t *l, const char *variable, +blogc_assert_template_if_stmt(bc_slist_t *l, const char *variable,      blogc_template_stmt_operator_t operator, const char *operand)  {      blogc_template_stmt_t *stmt = l->data; @@ -60,7 +60,7 @@ test_template_parse(void **state)          "{%- foreach BOLA %}hahaha{% endforeach %}\n"          "{% if BOLA == \"1\\\"0\" %}aee{% else %}fffuuuuuuu{% endif %}";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_null(err);      assert_non_null(stmts);      blogc_assert_template_stmt(stmts, "Test", @@ -77,7 +77,7 @@ test_template_parse(void **state)          BLOGC_TEMPLATE_ENDIF_STMT);      blogc_assert_template_stmt(stmts->next->next->next->next->next->next, "\n",          BLOGC_TEMPLATE_CONTENT_STMT); -    sb_slist_t *tmp = stmts->next->next->next->next->next->next->next; +    bc_slist_t *tmp = stmts->next->next->next->next->next->next->next;      blogc_assert_template_stmt(tmp, "BOLA", BLOGC_TEMPLATE_IFNDEF_STMT);      blogc_assert_template_stmt(tmp->next, "\nbolao", BLOGC_TEMPLATE_CONTENT_STMT);      blogc_assert_template_stmt(tmp->next->next, NULL, BLOGC_TEMPLATE_ENDIF_STMT); @@ -144,7 +144,7 @@ test_template_parse_crlf(void **state)          "{%- foreach BOLA %}hahaha{% endforeach %}\r\n"          "{% if BOLA == \"1\\\"0\" %}aee{% else %}fffuuuuuuu{% endif %}";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_null(err);      assert_non_null(stmts);      blogc_assert_template_stmt(stmts, "Test", @@ -161,7 +161,7 @@ test_template_parse_crlf(void **state)          BLOGC_TEMPLATE_ENDIF_STMT);      blogc_assert_template_stmt(stmts->next->next->next->next->next->next, "\r\n",          BLOGC_TEMPLATE_CONTENT_STMT); -    sb_slist_t *tmp = stmts->next->next->next->next->next->next->next; +    bc_slist_t *tmp = stmts->next->next->next->next->next->next->next;      blogc_assert_template_stmt(tmp, "BOLA", BLOGC_TEMPLATE_IFNDEF_STMT);      blogc_assert_template_stmt(tmp->next, "\r\nbolao", BLOGC_TEMPLATE_CONTENT_STMT);      blogc_assert_template_stmt(tmp->next->next, NULL, BLOGC_TEMPLATE_ENDIF_STMT); @@ -236,7 +236,7 @@ test_template_parse_html(void **state)          "    </body>\n"          "</html>\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_null(err);      assert_non_null(stmts);      blogc_assert_template_stmt(stmts, "<html>\n    <head>\n        ", @@ -255,7 +255,7 @@ test_template_parse_html(void **state)          "\n        ", BLOGC_TEMPLATE_CONTENT_STMT);      blogc_assert_template_stmt(stmts->next->next->next->next->next->next->next,          "listing_once", BLOGC_TEMPLATE_BLOCK_STMT); -    sb_slist_t *tmp = stmts->next->next->next->next->next->next->next->next; +    bc_slist_t *tmp = stmts->next->next->next->next->next->next->next->next;      blogc_assert_template_stmt(tmp,          "\n        <title>My cool blog - Main page</title>\n        ",          BLOGC_TEMPLATE_CONTENT_STMT); @@ -346,7 +346,7 @@ test_template_parse_ifdef_and_var_outside_block(void **state)          "{{ BOLA }}\n"          "{% ifndef CHUNDA %}{{ CHUNDA }}{% endif %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_null(err);      assert_non_null(stmts);      blogc_assert_template_stmt(stmts, "GUDA", BLOGC_TEMPLATE_IFDEF_STMT); @@ -362,7 +362,7 @@ test_template_parse_ifdef_and_var_outside_block(void **state)          BLOGC_TEMPLATE_CONTENT_STMT);      blogc_assert_template_stmt(stmts->next->next->next->next->next->next,          "CHUNDA", BLOGC_TEMPLATE_IFNDEF_STMT); -    sb_slist_t *tmp = stmts->next->next->next->next->next->next->next; +    bc_slist_t *tmp = stmts->next->next->next->next->next->next->next;      blogc_assert_template_stmt(tmp, "CHUNDA", BLOGC_TEMPLATE_VARIABLE_STMT);      blogc_assert_template_stmt(tmp->next, NULL, BLOGC_TEMPLATE_ENDIF_STMT);      blogc_assert_template_stmt(tmp->next->next, "\n", @@ -393,7 +393,7 @@ test_template_parse_nested_else(void **state)          "{% endif %}\n"          "{% endif %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_null(err);      assert_non_null(stmts);      blogc_assert_template_stmt(stmts, "GUDA", BLOGC_TEMPLATE_IFDEF_STMT); @@ -409,7 +409,7 @@ test_template_parse_nested_else(void **state)          "CHUNDA", BLOGC_TEMPLATE_IFDEF_STMT);      blogc_assert_template_stmt(stmts->next->next->next->next->next->next->next,          "\nqwe\n", BLOGC_TEMPLATE_CONTENT_STMT); -    sb_slist_t *tmp = stmts->next->next->next->next->next->next->next->next; +    bc_slist_t *tmp = stmts->next->next->next->next->next->next->next->next;      blogc_assert_template_stmt(tmp, NULL, BLOGC_TEMPLATE_ELSE_STMT);      blogc_assert_template_stmt(tmp->next, "\nrty\n", BLOGC_TEMPLATE_CONTENT_STMT);      blogc_assert_template_stmt(tmp->next->next, NULL, @@ -445,7 +445,7 @@ test_template_parse_invalid_block_start(void **state)  {      const char *a = "{% ASD %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -483,7 +483,7 @@ test_template_parse_invalid_block_nested(void **state)          "{% block entry %}\n"          "{% block listing %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -501,7 +501,7 @@ test_template_parse_invalid_foreach_nested(void **state)          "{% foreach A %}\n"          "{% foreach B %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -517,7 +517,7 @@ test_template_parse_invalid_block_not_open(void **state)  {      const char *a = "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -533,7 +533,7 @@ test_template_parse_invalid_endif_not_open(void **state)  {      const char *a = "{% block listing %}{% endif %}{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -550,7 +550,7 @@ test_template_parse_invalid_endif_not_open_inside_block(void **state)  {      const char *a = "{% ifdef BOLA %}{% block listing %}{% endif %}{% endblock %}";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -567,7 +567,7 @@ test_template_parse_invalid_else_not_open_inside_block(void **state)  {      const char *a = "{% ifdef BOLA %}{% block listing %}{% else %}{% endif %}{% endblock %}";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -584,7 +584,7 @@ test_template_parse_invalid_endforeach_not_open(void **state)  {      const char *a = "{% endforeach %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -601,7 +601,7 @@ test_template_parse_invalid_endforeach_not_open_inside_block(void **state)      const char *a = "{% foreach TAGS %}{% block entry %}{% endforeach %}"          "{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -619,7 +619,7 @@ test_template_parse_invalid_endforeach_not_open_inside_block2(void **state)      const char *a = "{% block entry %}{% foreach TAGS %}"          "{% endforeach %}{% endforeach %}{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -637,7 +637,7 @@ test_template_parse_invalid_endforeach_not_closed_inside_block(void **state)      const char *a = "{% block entry %}{% foreach TAGS %}{% endblock %}"          "{% endforeach %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -653,7 +653,7 @@ test_template_parse_invalid_endforeach_not_closed_inside_block2(void **state)      const char *a = "{% block entry %}{% foreach TAGS %}{% endforeach %}"          "{% foreach TAGS %}{% endblock %}{% endforeach %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -668,7 +668,7 @@ test_template_parse_invalid_block_name(void **state)  {      const char *a = "{% chunda %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -685,7 +685,7 @@ test_template_parse_invalid_block_type_start(void **state)  {      const char *a = "{% block ENTRY %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -701,7 +701,7 @@ test_template_parse_invalid_block_type(void **state)  {      const char *a = "{% block chunda %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -717,7 +717,7 @@ test_template_parse_invalid_ifdef_start(void **state)  {      const char *a = "{% block entry %}{% ifdef guda %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -734,7 +734,7 @@ test_template_parse_invalid_foreach_start(void **state)  {      const char *a = "{% block entry %}{% foreach guda %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -751,7 +751,7 @@ test_template_parse_invalid_ifdef_variable(void **state)  {      const char *a = "{% block entry %}{% ifdef BoLA %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -768,7 +768,7 @@ test_template_parse_invalid_ifdef_variable2(void **state)  {      const char *a = "{% block entry %}{% ifdef 0123 %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -785,7 +785,7 @@ test_template_parse_invalid_foreach_variable(void **state)  {      const char *a = "{% block entry %}{% foreach BoLA %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -802,7 +802,7 @@ test_template_parse_invalid_foreach_variable2(void **state)  {      const char *a = "{% block entry %}{% foreach 0123 %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -819,7 +819,7 @@ test_template_parse_invalid_if_operator(void **state)  {      const char *a = "{% block entry %}{% if BOLA = \"asd\" %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -836,7 +836,7 @@ test_template_parse_invalid_if_operand(void **state)  {      const char *a = "{% block entry %}{% if BOLA == asd %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -853,7 +853,7 @@ test_template_parse_invalid_if_operand2(void **state)  {      const char *a = "{% block entry %}{% if BOLA == \"asd %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -870,7 +870,7 @@ test_template_parse_invalid_if_operand3(void **state)  {      const char *a = "{% block entry %}{% if BOLA == 0123 %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -887,7 +887,7 @@ test_template_parse_invalid_else1(void **state)  {      const char *a = "{% else %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -903,7 +903,7 @@ test_template_parse_invalid_else2(void **state)  {      const char *a = "{% if BOLA == \"123\" %}{% if GUDA == \"1\" %}{% else %}{% else %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -927,7 +927,7 @@ test_template_parse_invalid_else3(void **state)          "{% else %}\n"          "{% else %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -943,7 +943,7 @@ test_template_parse_invalid_block_end(void **state)  {      const char *a = "{% block entry }}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -959,7 +959,7 @@ test_template_parse_invalid_variable_name(void **state)  {      const char *a = "{% block entry %}{{ bola }}{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -976,7 +976,7 @@ test_template_parse_invalid_variable_name2(void **state)  {      const char *a = "{% block entry %}{{ Bola }}{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -993,7 +993,7 @@ test_template_parse_invalid_variable_name3(void **state)  {      const char *a = "{% block entry %}{{ 0123 }}{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -1010,7 +1010,7 @@ test_template_parse_invalid_variable_end(void **state)  {      const char *a = "{% block entry %}{{ BOLA %}{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -1027,7 +1027,7 @@ test_template_parse_invalid_close(void **state)  {      const char *a = "{% block entry %%\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -1043,7 +1043,7 @@ test_template_parse_invalid_close2(void **state)  {      const char *a = "{% block entry %}{{ BOLA }%{% endblock %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -1060,7 +1060,7 @@ test_template_parse_invalid_endif_not_closed(void **state)  {      const char *a = "{% block entry %}{% endblock %}{% ifdef BOLA %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -1075,7 +1075,7 @@ test_template_parse_invalid_endif_not_closed_inside_block(void **state)  {      const char *a = "{% block listing %}{% ifdef BOLA %}{% endblock %}{% endif %}";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -1091,7 +1091,7 @@ test_template_parse_invalid_else_not_closed_inside_block(void **state)  {      const char *a = "{% block listing %}{% ifdef BOLA %}{% else %}{% endblock %}{% endif %}";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -1107,7 +1107,7 @@ test_template_parse_invalid_block_not_closed(void **state)  {      const char *a = "{% block entry %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); @@ -1121,7 +1121,7 @@ test_template_parse_invalid_foreach_not_closed(void **state)  {      const char *a = "{% foreach ASD %}\n";      blogc_error_t *err = NULL; -    sb_slist_t *stmts = blogc_template_parse(a, strlen(a), &err); +    bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);      assert_non_null(err);      assert_null(stmts);      assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER); diff --git a/tests/common/check_utf8.c b/tests/common/check_utf8.c index d104265..f4c7f32 100644 --- a/tests/common/check_utf8.c +++ b/tests/common/check_utf8.c @@ -45,30 +45,30 @@ test_utf8_invalid(void **state)  static void  test_utf8_valid_str(void **state)  { -    sb_string_t *s = sb_string_new(); -    sb_string_append(s, +    bc_string_t *s = bc_string_new(); +    bc_string_append(s,          "<a href=\"{{ BASE_URL }}/page/{{ PREVIOUS_PAGE }}/\">\xc2\xab Newer "          "posts</a>");      assert_true(blogc_utf8_validate_str(s)); -    sb_string_free(s, true); -    s = sb_string_new(); -    sb_string_append(s, "\xe2\x82\xac"); +    bc_string_free(s, true); +    s = bc_string_new(); +    bc_string_append(s, "\xe2\x82\xac");      assert_true(blogc_utf8_validate_str(s)); -    sb_string_free(s, true); +    bc_string_free(s, true);  }  static void  test_utf8_invalid_str(void **state)  { -    sb_string_t *s = sb_string_new(); -    sb_string_append(s, "\xff\xfe\xac\x20");  // utf-16 +    bc_string_t *s = bc_string_new(); +    bc_string_append(s, "\xff\xfe\xac\x20");  // utf-16      assert_false(blogc_utf8_validate_str(s)); -    sb_string_free(s, true); -    s = sb_string_new(); -    sb_string_append(s, "\xff\xfe\x00\x00\xac\x20\x00\x00");  // utf-32 +    bc_string_free(s, true); +    s = bc_string_new(); +    bc_string_append(s, "\xff\xfe\x00\x00\xac\x20\x00\x00");  // utf-32      assert_false(blogc_utf8_validate_str(s)); -    sb_string_free(s, true); +    bc_string_free(s, true);  } diff --git a/tests/common/check_utils.c b/tests/common/check_utils.c index a9ec316..9d49434 100644 --- a/tests/common/check_utils.c +++ b/tests/common/check_utils.c @@ -20,50 +20,50 @@  static void  test_slist_append(void **state)  { -    sb_slist_t *l = NULL; -    l = sb_slist_append(l, (void*) sb_strdup("bola")); +    bc_slist_t *l = NULL; +    l = bc_slist_append(l, (void*) bc_strdup("bola"));      assert_non_null(l);      assert_string_equal(l->data, "bola");      assert_null(l->next); -    l = sb_slist_append(l, (void*) sb_strdup("guda")); +    l = bc_slist_append(l, (void*) bc_strdup("guda"));      assert_non_null(l);      assert_string_equal(l->data, "bola");      assert_non_null(l->next);      assert_string_equal(l->next->data, "guda");      assert_null(l->next->next); -    sb_slist_free_full(l, free); +    bc_slist_free_full(l, free);  }  static void  test_slist_prepend(void **state)  { -    sb_slist_t *l = NULL; -    l = sb_slist_prepend(l, (void*) sb_strdup("bola")); +    bc_slist_t *l = NULL; +    l = bc_slist_prepend(l, (void*) bc_strdup("bola"));      assert_non_null(l);      assert_string_equal(l->data, "bola");      assert_null(l->next); -    l = sb_slist_prepend(l, (void*) sb_strdup("guda")); +    l = bc_slist_prepend(l, (void*) bc_strdup("guda"));      assert_non_null(l);      assert_string_equal(l->data, "guda");      assert_non_null(l->next);      assert_string_equal(l->next->data, "bola");      assert_null(l->next->next); -    sb_slist_free_full(l, free); +    bc_slist_free_full(l, free);  }  static void  test_slist_free(void **state)  { -    sb_slist_t *l = NULL; -    char *t1 = sb_strdup("bola"); -    char *t2 = sb_strdup("guda"); -    char *t3 = sb_strdup("chunda"); -    l = sb_slist_append(l, (void*) t1); -    l = sb_slist_append(l, (void*) t2); -    l = sb_slist_append(l, (void*) t3); -    sb_slist_free(l); +    bc_slist_t *l = NULL; +    char *t1 = bc_strdup("bola"); +    char *t2 = bc_strdup("guda"); +    char *t3 = bc_strdup("chunda"); +    l = bc_slist_append(l, (void*) t1); +    l = bc_slist_append(l, (void*) t2); +    l = bc_slist_append(l, (void*) t3); +    bc_slist_free(l);      assert_string_equal(t1, "bola");      assert_string_equal(t2, "guda");      assert_string_equal(t3, "chunda"); @@ -76,23 +76,23 @@ test_slist_free(void **state)  static void  test_slist_length(void **state)  { -    sb_slist_t *l = NULL; -    l = sb_slist_append(l, (void*) sb_strdup("bola")); -    l = sb_slist_append(l, (void*) sb_strdup("guda")); -    l = sb_slist_append(l, (void*) sb_strdup("chunda")); -    assert_int_equal(sb_slist_length(l), 3); -    sb_slist_free_full(l, free); -    assert_int_equal(sb_slist_length(NULL), 0); +    bc_slist_t *l = NULL; +    l = bc_slist_append(l, (void*) bc_strdup("bola")); +    l = bc_slist_append(l, (void*) bc_strdup("guda")); +    l = bc_slist_append(l, (void*) bc_strdup("chunda")); +    assert_int_equal(bc_slist_length(l), 3); +    bc_slist_free_full(l, free); +    assert_int_equal(bc_slist_length(NULL), 0);  }  static void  test_strdup(void **state)  { -    char *str = sb_strdup("bola"); +    char *str = bc_strdup("bola");      assert_string_equal(str, "bola");      free(str); -    str = sb_strdup(NULL); +    str = bc_strdup(NULL);      assert_null(str);  } @@ -100,16 +100,16 @@ test_strdup(void **state)  static void  test_strndup(void **state)  { -    char *str = sb_strndup("bolaguda", 4); +    char *str = bc_strndup("bolaguda", 4);      assert_string_equal(str, "bola");      free(str); -    str = sb_strndup("bolaguda", 30); +    str = bc_strndup("bolaguda", 30);      assert_string_equal(str, "bolaguda");      free(str); -    str = sb_strndup("bolaguda", 8); +    str = bc_strndup("bolaguda", 8);      assert_string_equal(str, "bolaguda");      free(str); -    str = sb_strdup(NULL); +    str = bc_strdup(NULL);      assert_null(str);  } @@ -117,10 +117,10 @@ test_strndup(void **state)  static void  test_strdup_printf(void **state)  { -    char *str = sb_strdup_printf("bola"); +    char *str = bc_strdup_printf("bola");      assert_string_equal(str, "bola");      free(str); -    str = sb_strdup_printf("bola, %s", "guda"); +    str = bc_strdup_printf("bola, %s", "guda");      assert_string_equal(str, "bola, guda");      free(str);  } @@ -129,141 +129,141 @@ test_strdup_printf(void **state)  static void  test_str_starts_with(void **state)  { -    assert_true(sb_str_starts_with("bolaguda", "bola")); -    assert_true(sb_str_starts_with("bola", "bola")); -    assert_false(sb_str_starts_with("gudabola", "bola")); -    assert_false(sb_str_starts_with("guda", "bola")); -    assert_false(sb_str_starts_with("bola", "bolaguda")); +    assert_true(bc_str_starts_with("bolaguda", "bola")); +    assert_true(bc_str_starts_with("bola", "bola")); +    assert_false(bc_str_starts_with("gudabola", "bola")); +    assert_false(bc_str_starts_with("guda", "bola")); +    assert_false(bc_str_starts_with("bola", "bolaguda"));  }  static void  test_str_ends_with(void **state)  { -    assert_true(sb_str_ends_with("bolaguda", "guda")); -    assert_true(sb_str_ends_with("bola", "bola")); -    assert_false(sb_str_ends_with("gudabola", "guda")); -    assert_false(sb_str_ends_with("guda", "bola")); -    assert_false(sb_str_ends_with("bola", "gudabola")); +    assert_true(bc_str_ends_with("bolaguda", "guda")); +    assert_true(bc_str_ends_with("bola", "bola")); +    assert_false(bc_str_ends_with("gudabola", "guda")); +    assert_false(bc_str_ends_with("guda", "bola")); +    assert_false(bc_str_ends_with("bola", "gudabola"));  }  static void  test_str_lstrip(void **state)  { -    char *str = sb_strdup("  \tbola\n  \t"); -    assert_string_equal(sb_str_lstrip(str), "bola\n  \t"); +    char *str = bc_strdup("  \tbola\n  \t"); +    assert_string_equal(bc_str_lstrip(str), "bola\n  \t");      free(str); -    str = sb_strdup("guda"); -    assert_string_equal(sb_str_lstrip(str), "guda"); +    str = bc_strdup("guda"); +    assert_string_equal(bc_str_lstrip(str), "guda");      free(str); -    str = sb_strdup("\n"); -    assert_string_equal(sb_str_lstrip(str), ""); +    str = bc_strdup("\n"); +    assert_string_equal(bc_str_lstrip(str), "");      free(str); -    str = sb_strdup("\t \n"); -    assert_string_equal(sb_str_lstrip(str), ""); +    str = bc_strdup("\t \n"); +    assert_string_equal(bc_str_lstrip(str), "");      free(str); -    str = sb_strdup(""); -    assert_string_equal(sb_str_lstrip(str), ""); +    str = bc_strdup(""); +    assert_string_equal(bc_str_lstrip(str), "");      free(str); -    assert_null(sb_str_lstrip(NULL)); +    assert_null(bc_str_lstrip(NULL));  }  static void  test_str_rstrip(void **state)  { -    char *str = sb_strdup("  \tbola\n  \t"); -    assert_string_equal(sb_str_rstrip(str), "  \tbola"); +    char *str = bc_strdup("  \tbola\n  \t"); +    assert_string_equal(bc_str_rstrip(str), "  \tbola");      free(str); -    str = sb_strdup("guda"); -    assert_string_equal(sb_str_rstrip(str), "guda"); +    str = bc_strdup("guda"); +    assert_string_equal(bc_str_rstrip(str), "guda");      free(str); -    str = sb_strdup("\n"); -    assert_string_equal(sb_str_rstrip(str), ""); +    str = bc_strdup("\n"); +    assert_string_equal(bc_str_rstrip(str), "");      free(str); -    str = sb_strdup("\t \n"); -    assert_string_equal(sb_str_rstrip(str), ""); +    str = bc_strdup("\t \n"); +    assert_string_equal(bc_str_rstrip(str), "");      free(str); -    str = sb_strdup(""); -    assert_string_equal(sb_str_rstrip(str), ""); +    str = bc_strdup(""); +    assert_string_equal(bc_str_rstrip(str), "");      free(str); -    assert_null(sb_str_rstrip(NULL)); +    assert_null(bc_str_rstrip(NULL));  }  static void  test_str_strip(void **state)  { -    char *str = sb_strdup("  \tbola\n  \t"); -    assert_string_equal(sb_str_strip(str), "bola"); +    char *str = bc_strdup("  \tbola\n  \t"); +    assert_string_equal(bc_str_strip(str), "bola");      free(str); -    str = sb_strdup("guda"); -    assert_string_equal(sb_str_strip(str), "guda"); +    str = bc_strdup("guda"); +    assert_string_equal(bc_str_strip(str), "guda");      free(str); -    str = sb_strdup("\n"); -    assert_string_equal(sb_str_strip(str), ""); +    str = bc_strdup("\n"); +    assert_string_equal(bc_str_strip(str), "");      free(str); -    str = sb_strdup("\t \n"); -    assert_string_equal(sb_str_strip(str), ""); +    str = bc_strdup("\t \n"); +    assert_string_equal(bc_str_strip(str), "");      free(str); -    str = sb_strdup(""); -    assert_string_equal(sb_str_strip(str), ""); +    str = bc_strdup(""); +    assert_string_equal(bc_str_strip(str), "");      free(str); -    assert_null(sb_str_strip(NULL)); +    assert_null(bc_str_strip(NULL));  }  static void  test_str_split(void **state)  { -    char **strv = sb_str_split("bola:guda:chunda", ':', 0); +    char **strv = bc_str_split("bola:guda:chunda", ':', 0);      assert_string_equal(strv[0], "bola");      assert_string_equal(strv[1], "guda");      assert_string_equal(strv[2], "chunda");      assert_null(strv[3]); -    sb_strv_free(strv); -    strv = sb_str_split("bola:guda:chunda", ':', 2); +    bc_strv_free(strv); +    strv = bc_str_split("bola:guda:chunda", ':', 2);      assert_string_equal(strv[0], "bola");      assert_string_equal(strv[1], "guda:chunda");      assert_null(strv[2]); -    sb_strv_free(strv); -    strv = sb_str_split("bola:guda:chunda", ':', 1); +    bc_strv_free(strv); +    strv = bc_str_split("bola:guda:chunda", ':', 1);      assert_string_equal(strv[0], "bola:guda:chunda");      assert_null(strv[1]); -    sb_strv_free(strv); -    strv = sb_str_split("", ':', 1); +    bc_strv_free(strv); +    strv = bc_str_split("", ':', 1);      assert_null(strv[0]); -    sb_strv_free(strv); -    assert_null(sb_str_split(NULL, ':', 0)); +    bc_strv_free(strv); +    assert_null(bc_str_split(NULL, ':', 0));  }  static void  test_str_replace(void **state)  { -    char *str = sb_str_replace("bolao", 'o', "zaz"); +    char *str = bc_str_replace("bolao", 'o', "zaz");      assert_string_equal(str, "bzazlazaz");      free(str); -    str = sb_str_replace("bolao", 'b', "zaz"); +    str = bc_str_replace("bolao", 'b', "zaz");      assert_string_equal(str, "zazolao");      free(str); -    str = sb_str_replace("bolao", 'b', NULL); +    str = bc_str_replace("bolao", 'b', NULL);      assert_string_equal(str, "bolao");      free(str); -    assert_null(sb_str_replace(NULL, 'b', "zaz")); +    assert_null(bc_str_replace(NULL, 'b', "zaz"));  }  static void  test_str_find(void **state)  { -    assert_null(sb_str_find(NULL, 'c')); -    assert_string_equal(sb_str_find("bola", 'l'), "la"); -    assert_string_equal(sb_str_find("bo\\lalala", 'l'), "lala"); -    assert_string_equal(sb_str_find("bola", '\0'), ""); -    assert_null(sb_str_find("bola", 'g')); -    assert_null(sb_str_find("bo\\la", 'l')); +    assert_null(bc_str_find(NULL, 'c')); +    assert_string_equal(bc_str_find("bola", 'l'), "la"); +    assert_string_equal(bc_str_find("bo\\lalala", 'l'), "lala"); +    assert_string_equal(bc_str_find("bola", '\0'), ""); +    assert_null(bc_str_find("bola", 'g')); +    assert_null(bc_str_find("bo\\la", 'l'));  } @@ -271,16 +271,16 @@ static void  test_strv_join(void **state)  {      char *pieces[] = {"guda","bola", "chunda", NULL}; -    char *str = sb_strv_join(pieces, ":"); +    char *str = bc_strv_join(pieces, ":");      assert_string_equal(str, "guda:bola:chunda");      free(str);      char *pieces2[] = {NULL}; -    str = sb_strv_join(pieces2, ":"); +    str = bc_strv_join(pieces2, ":");      assert_string_equal(str, "");      free(str); -    assert_null(sb_strv_join(pieces, NULL)); -    assert_null(sb_strv_join(NULL, ":")); -    assert_null(sb_strv_join(NULL, NULL)); +    assert_null(bc_strv_join(pieces, NULL)); +    assert_null(bc_strv_join(NULL, ":")); +    assert_null(bc_strv_join(NULL, NULL));  } @@ -288,88 +288,88 @@ static void  test_strv_length(void **state)  {      char *pieces[] = {"guda","bola", "chunda", NULL}; -    assert_int_equal(sb_strv_length(pieces), 3); +    assert_int_equal(bc_strv_length(pieces), 3);      char *pieces2[] = {NULL}; -    assert_int_equal(sb_strv_length(pieces2), 0); -    assert_int_equal(sb_strv_length(NULL), 0); +    assert_int_equal(bc_strv_length(pieces2), 0); +    assert_int_equal(bc_strv_length(NULL), 0);  }  static void  test_string_new(void **state)  { -    sb_string_t *str = sb_string_new(); +    bc_string_t *str = bc_string_new();      assert_non_null(str);      assert_string_equal(str->str, "");      assert_int_equal(str->len, 0);      assert_int_equal(str->allocated_len, SB_STRING_CHUNK_SIZE); -    assert_null(sb_string_free(str, true)); +    assert_null(bc_string_free(str, true));  }  static void  test_string_free(void **state)  { -    sb_string_t *str = sb_string_new(); +    bc_string_t *str = bc_string_new();      free(str->str); -    str->str = sb_strdup("bola"); +    str->str = bc_strdup("bola");      str->len = 4;      str->allocated_len = SB_STRING_CHUNK_SIZE; -    char *tmp = sb_string_free(str, false); +    char *tmp = bc_string_free(str, false);      assert_string_equal(tmp, "bola");      free(tmp); -    assert_null(sb_string_free(NULL, false)); +    assert_null(bc_string_free(NULL, false));  }  static void  test_string_dup(void **state)  { -    sb_string_t *str = sb_string_new(); +    bc_string_t *str = bc_string_new();      free(str->str); -    str->str = sb_strdup("bola"); +    str->str = bc_strdup("bola");      str->len = 4;      str->allocated_len = SB_STRING_CHUNK_SIZE; -    sb_string_t *new = sb_string_dup(str); +    bc_string_t *new = bc_string_dup(str);      assert_non_null(new);      assert_string_equal(new->str, "bola");      assert_int_equal(new->len, 4);      assert_int_equal(new->allocated_len, SB_STRING_CHUNK_SIZE); -    assert_null(sb_string_free(new, true)); -    assert_null(sb_string_free(str, true)); -    assert_null(sb_string_dup(NULL)); +    assert_null(bc_string_free(new, true)); +    assert_null(bc_string_free(str, true)); +    assert_null(bc_string_dup(NULL));  }  static void  test_string_append_len(void **state)  { -    sb_string_t *str = sb_string_new(); -    str = sb_string_append_len(str, "guda", 4); +    bc_string_t *str = bc_string_new(); +    str = bc_string_append_len(str, "guda", 4);      assert_non_null(str);      assert_string_equal(str->str, "guda");      assert_int_equal(str->len, 4);      assert_int_equal(str->allocated_len, SB_STRING_CHUNK_SIZE); -    assert_null(sb_string_free(str, true)); -    str = sb_string_new(); -    str = sb_string_append_len(str, "guda", 4); -    str = sb_string_append_len(str, "bola", 4); +    assert_null(bc_string_free(str, true)); +    str = bc_string_new(); +    str = bc_string_append_len(str, "guda", 4); +    str = bc_string_append_len(str, "bola", 4);      assert_non_null(str);      assert_string_equal(str->str, "gudabola");      assert_int_equal(str->len, 8);      assert_int_equal(str->allocated_len, SB_STRING_CHUNK_SIZE); -    assert_null(sb_string_free(str, true)); -    str = sb_string_new(); -    str = sb_string_append_len(str, "guda", 3); -    str = sb_string_append_len(str, "bola", 4); +    assert_null(bc_string_free(str, true)); +    str = bc_string_new(); +    str = bc_string_append_len(str, "guda", 3); +    str = bc_string_append_len(str, "bola", 4);      assert_non_null(str);      assert_string_equal(str->str, "gudbola");      assert_int_equal(str->len, 7);      assert_int_equal(str->allocated_len, SB_STRING_CHUNK_SIZE); -    assert_null(sb_string_free(str, true)); -    str = sb_string_new(); -    str = sb_string_append_len(str, "guda", 4); -    str = sb_string_append_len(str, +    assert_null(bc_string_free(str, true)); +    str = bc_string_new(); +    str = bc_string_append_len(str, "guda", 4); +    str = bc_string_append_len(str,          "cwlwmwxxmvjnwtidmjehzdeexbxjnjowruxjrqpgpfhmvwgqeacdjissntmbtsjidzkcw"          "nnqhxhneolbwqlctcxmrsutolrjikpavxombpfpjyaqltgvzrjidotalcuwrwxtaxjiwa"          "xfhfyzymtffusoqywaruxpybwggukltspqqmghzpqstvcvlqbkhquihzndnrvkaqvevaz" @@ -379,8 +379,8 @@ test_string_append_len(void **state)          "dxntikgoqlidfnmdhxzevqzlzubvyleeksdirmmttqthhkvfjggznpmarcamacpvwsrnr"          "ftzfeyasjpxoevyptpdnqokswiondusnuymqwaryrmdgscbnuilxtypuynckancsfnwtg"          "okxhegoifakimxbbafkeannglvsxprqzfekdinssqymtfexf", 600); -    str = sb_string_append_len(str, NULL, 0); -    str = sb_string_append_len(str, +    str = bc_string_append_len(str, NULL, 0); +    str = bc_string_append_len(str,          "cwlwmwxxmvjnwtidmjehzdeexbxjnjowruxjrqpgpfhmvwgqeacdjissntmbtsjidzkcw"          "nnqhxhneolbwqlctcxmrsutolrjikpavxombpfpjyaqltgvzrjidotalcuwrwxtaxjiwa"          "xfhfyzymtffusoqywaruxpybwggukltspqqmghzpqstvcvlqbkhquihzndnrvkaqvevaz" @@ -412,39 +412,39 @@ test_string_append_len(void **state)          "fkeannglvsxprqzfekdinssqymtfexf");      assert_int_equal(str->len, 1204);      assert_int_equal(str->allocated_len, SB_STRING_CHUNK_SIZE * 10); -    assert_null(sb_string_free(str, true)); -    str = sb_string_new(); -    str = sb_string_append_len(str, NULL, 0); +    assert_null(bc_string_free(str, true)); +    str = bc_string_new(); +    str = bc_string_append_len(str, NULL, 0);      assert_non_null(str);      assert_string_equal(str->str, "");      assert_int_equal(str->len, 0);      assert_int_equal(str->allocated_len, SB_STRING_CHUNK_SIZE); -    assert_null(sb_string_free(str, true)); -    assert_null(sb_string_append_len(NULL, "foo", 3)); +    assert_null(bc_string_free(str, true)); +    assert_null(bc_string_append_len(NULL, "foo", 3));  }  static void  test_string_append(void **state)  { -    sb_string_t *str = sb_string_new(); -    str = sb_string_append(str, "guda"); +    bc_string_t *str = bc_string_new(); +    str = bc_string_append(str, "guda");      assert_non_null(str);      assert_string_equal(str->str, "guda");      assert_int_equal(str->len, 4);      assert_int_equal(str->allocated_len, SB_STRING_CHUNK_SIZE); -    assert_null(sb_string_free(str, true)); -    str = sb_string_new(); -    str = sb_string_append(str, "guda"); -    str = sb_string_append(str, "bola"); +    assert_null(bc_string_free(str, true)); +    str = bc_string_new(); +    str = bc_string_append(str, "guda"); +    str = bc_string_append(str, "bola");      assert_non_null(str);      assert_string_equal(str->str, "gudabola");      assert_int_equal(str->len, 8);      assert_int_equal(str->allocated_len, SB_STRING_CHUNK_SIZE); -    assert_null(sb_string_free(str, true)); -    str = sb_string_new(); -    str = sb_string_append(str, "guda"); -    str = sb_string_append(str, +    assert_null(bc_string_free(str, true)); +    str = bc_string_new(); +    str = bc_string_append(str, "guda"); +    str = bc_string_append(str,          "cwlwmwxxmvjnwtidmjehzdeexbxjnjowruxjrqpgpfhmvwgqeacdjissntmbtsjidzkcw"          "nnqhxhneolbwqlctcxmrsutolrjikpavxombpfpjyaqltgvzrjidotalcuwrwxtaxjiwa"          "xfhfyzymtffusoqywaruxpybwggukltspqqmghzpqstvcvlqbkhquihzndnrvkaqvevaz" @@ -454,8 +454,8 @@ test_string_append(void **state)          "dxntikgoqlidfnmdhxzevqzlzubvyleeksdirmmttqthhkvfjggznpmarcamacpvwsrnr"          "ftzfeyasjpxoevyptpdnqokswiondusnuymqwaryrmdgscbnuilxtypuynckancsfnwtg"          "okxhegoifakimxbbafkeannglvsxprqzfekdinssqymtfexf"); -    str = sb_string_append(str, NULL); -    str = sb_string_append(str, +    str = bc_string_append(str, NULL); +    str = bc_string_append(str,          "cwlwmwxxmvjnwtidmjehzdeexbxjnjowruxjrqpgpfhmvwgqeacdjissntmbtsjidzkcw"          "nnqhxhneolbwqlctcxmrsutolrjikpavxombpfpjyaqltgvzrjidotalcuwrwxtaxjiwa"          "xfhfyzymtffusoqywaruxpybwggukltspqqmghzpqstvcvlqbkhquihzndnrvkaqvevaz" @@ -487,26 +487,26 @@ test_string_append(void **state)          "fkeannglvsxprqzfekdinssqymtfexf");      assert_int_equal(str->len, 1204);      assert_int_equal(str->allocated_len, SB_STRING_CHUNK_SIZE * 10); -    assert_null(sb_string_free(str, true)); -    str = sb_string_new(); -    str = sb_string_append(str, NULL); +    assert_null(bc_string_free(str, true)); +    str = bc_string_new(); +    str = bc_string_append(str, NULL);      assert_non_null(str);      assert_string_equal(str->str, "");      assert_int_equal(str->len, 0);      assert_int_equal(str->allocated_len, SB_STRING_CHUNK_SIZE); -    assert_null(sb_string_free(str, true)); -    assert_null(sb_string_append(NULL, "asd")); -    assert_null(sb_string_append(NULL, NULL)); +    assert_null(bc_string_free(str, true)); +    assert_null(bc_string_append(NULL, "asd")); +    assert_null(bc_string_append(NULL, NULL));  }  static void  test_string_append_c(void **state)  { -    sb_string_t *str = sb_string_new(); -    str = sb_string_append_len(str, "guda", 4); +    bc_string_t *str = bc_string_new(); +    str = bc_string_append_len(str, "guda", 4);      for (int i = 0; i < 600; i++) -        str = sb_string_append_c(str, 'c'); +        str = bc_string_append_c(str, 'c');      assert_non_null(str);      assert_string_equal(str->str,          "gudaccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" @@ -520,61 +520,61 @@ test_string_append_c(void **state)          "cccccccccccccccccccccccccccccccccccccccccccccccccccc");      assert_int_equal(str->len, 604);      assert_int_equal(str->allocated_len, SB_STRING_CHUNK_SIZE * 5); -    assert_null(sb_string_free(str, true)); -    assert_null(sb_string_append_c(NULL, 0)); +    assert_null(bc_string_free(str, true)); +    assert_null(bc_string_append_c(NULL, 0));  }  static void  test_string_append_printf(void **state)  { -    sb_string_t *str = sb_string_new(); -    str = sb_string_append_printf(str, "guda: %s %d", "bola", 1); +    bc_string_t *str = bc_string_new(); +    str = bc_string_append_printf(str, "guda: %s %d", "bola", 1);      assert_non_null(str);      assert_string_equal(str->str, "guda: bola 1");      assert_int_equal(str->len, 12);      assert_int_equal(str->allocated_len, SB_STRING_CHUNK_SIZE); -    assert_null(sb_string_free(str, true)); -    assert_null(sb_string_append_printf(NULL, "asd")); +    assert_null(bc_string_free(str, true)); +    assert_null(bc_string_append_printf(NULL, "asd"));  }  static void  test_string_append_escaped(void **state)  { -    sb_string_t *str = sb_string_new(); -    str = sb_string_append_escaped(str, NULL); +    bc_string_t *str = bc_string_new(); +    str = bc_string_append_escaped(str, NULL);      assert_non_null(str);      assert_string_equal(str->str, "");      assert_int_equal(str->len, 0);      assert_int_equal(str->allocated_len, SB_STRING_CHUNK_SIZE); -    str = sb_string_append_escaped(str, "foo \\a bar \\\\ lol"); +    str = bc_string_append_escaped(str, "foo \\a bar \\\\ lol");      assert_non_null(str);      assert_string_equal(str->str, "foo a bar \\ lol");      assert_int_equal(str->len, 15);      assert_int_equal(str->allocated_len, SB_STRING_CHUNK_SIZE); -    assert_null(sb_string_free(str, true)); -    assert_null(sb_string_append_escaped(NULL, "asd")); +    assert_null(bc_string_free(str, true)); +    assert_null(bc_string_append_escaped(NULL, "asd"));  }  static void  test_trie_new(void **state)  { -    sb_trie_t *trie = sb_trie_new(free); +    bc_trie_t *trie = bc_trie_new(free);      assert_non_null(trie);      assert_null(trie->root);      assert_true(trie->free_func == free); -    sb_trie_free(trie); +    bc_trie_free(trie);  }  static void  test_trie_insert(void **state)  { -    sb_trie_t *trie = sb_trie_new(free); +    bc_trie_t *trie = bc_trie_new(free); -    sb_trie_insert(trie, "bola", sb_strdup("guda")); +    bc_trie_insert(trie, "bola", bc_strdup("guda"));      assert_true(trie->root->key == 'b');      assert_null(trie->root->data);      assert_true(trie->root->child->key == 'o'); @@ -587,7 +587,7 @@ test_trie_insert(void **state)      assert_string_equal(trie->root->child->child->child->child->data, "guda"); -    sb_trie_insert(trie, "chu", sb_strdup("nda")); +    bc_trie_insert(trie, "chu", bc_strdup("nda"));      assert_true(trie->root->key == 'b');      assert_null(trie->root->data);      assert_true(trie->root->child->key == 'o'); @@ -609,7 +609,7 @@ test_trie_insert(void **state)      assert_string_equal(trie->root->next->child->child->child->data, "nda"); -    sb_trie_insert(trie, "bote", sb_strdup("aba")); +    bc_trie_insert(trie, "bote", bc_strdup("aba"));      assert_true(trie->root->key == 'b');      assert_null(trie->root->data);      assert_true(trie->root->child->key == 'o'); @@ -638,7 +638,7 @@ test_trie_insert(void **state)      assert_string_equal(trie->root->child->child->next->child->child->data, "aba"); -    sb_trie_insert(trie, "bo", sb_strdup("haha")); +    bc_trie_insert(trie, "bo", bc_strdup("haha"));      assert_true(trie->root->key == 'b');      assert_null(trie->root->data);      assert_true(trie->root->child->key == 'o'); @@ -669,12 +669,12 @@ test_trie_insert(void **state)      assert_true(trie->root->child->child->next->next->key == '\0');      assert_string_equal(trie->root->child->child->next->next->data, "haha"); -    sb_trie_free(trie); +    bc_trie_free(trie); -    trie = sb_trie_new(free); +    trie = bc_trie_new(free); -    sb_trie_insert(trie, "chu", sb_strdup("nda")); +    bc_trie_insert(trie, "chu", bc_strdup("nda"));      assert_true(trie->root->key == 'c');      assert_null(trie->root->data);      assert_true(trie->root->child->key == 'h'); @@ -685,7 +685,7 @@ test_trie_insert(void **state)      assert_string_equal(trie->root->child->child->child->data, "nda"); -    sb_trie_insert(trie, "bola", sb_strdup("guda")); +    bc_trie_insert(trie, "bola", bc_strdup("guda"));      assert_true(trie->root->key == 'c');      assert_null(trie->root->data);      assert_true(trie->root->child->key == 'h'); @@ -707,7 +707,7 @@ test_trie_insert(void **state)      assert_string_equal(trie->root->next->child->child->child->child->data, "guda"); -    sb_trie_insert(trie, "bote", sb_strdup("aba")); +    bc_trie_insert(trie, "bote", bc_strdup("aba"));      assert_true(trie->root->key == 'c');      assert_null(trie->root->data);      assert_true(trie->root->child->key == 'h'); @@ -736,7 +736,7 @@ test_trie_insert(void **state)      assert_string_equal(trie->root->next->child->child->next->child->child->data, "aba"); -    sb_trie_insert(trie, "bo", sb_strdup("haha")); +    bc_trie_insert(trie, "bo", bc_strdup("haha"));      assert_true(trie->root->key == 'c');      assert_null(trie->root->data);      assert_true(trie->root->child->key == 'h'); @@ -767,16 +767,16 @@ test_trie_insert(void **state)      assert_true(trie->root->next->child->child->next->next->key == '\0');      assert_string_equal(trie->root->next->child->child->next->next->data, "haha"); -    sb_trie_free(trie); +    bc_trie_free(trie);  }  static void  test_trie_insert_duplicated(void **state)  { -    sb_trie_t *trie = sb_trie_new(free); +    bc_trie_t *trie = bc_trie_new(free); -    sb_trie_insert(trie, "bola", sb_strdup("guda")); +    bc_trie_insert(trie, "bola", bc_strdup("guda"));      assert_true(trie->root->key == 'b');      assert_null(trie->root->data);      assert_true(trie->root->child->key == 'o'); @@ -788,7 +788,7 @@ test_trie_insert_duplicated(void **state)      assert_true(trie->root->child->child->child->child->key == '\0');      assert_string_equal(trie->root->child->child->child->child->data, "guda"); -    sb_trie_insert(trie, "bola", sb_strdup("asdf")); +    bc_trie_insert(trie, "bola", bc_strdup("asdf"));      assert_true(trie->root->key == 'b');      assert_null(trie->root->data);      assert_true(trie->root->child->key == 'o'); @@ -800,10 +800,10 @@ test_trie_insert_duplicated(void **state)      assert_true(trie->root->child->child->child->child->key == '\0');      assert_string_equal(trie->root->child->child->child->child->data, "asdf"); -    sb_trie_free(trie); +    bc_trie_free(trie);      trie = NULL; -    sb_trie_insert(trie, "bola", NULL); +    bc_trie_insert(trie, "bola", NULL);      assert_null(trie);  } @@ -811,19 +811,19 @@ test_trie_insert_duplicated(void **state)  static void  test_trie_keep_data(void **state)  { -    sb_trie_t *trie = sb_trie_new(NULL); +    bc_trie_t *trie = bc_trie_new(NULL);      char *t1 = "guda";      char *t2 = "nda";      char *t3 = "aba";      char *t4 = "haha"; -    sb_trie_insert(trie, "bola", t1); -    sb_trie_insert(trie, "chu", t2); -    sb_trie_insert(trie, "bote", t3); -    sb_trie_insert(trie, "bo", t4); +    bc_trie_insert(trie, "bola", t1); +    bc_trie_insert(trie, "chu", t2); +    bc_trie_insert(trie, "bote", t3); +    bc_trie_insert(trie, "bo", t4); -    sb_trie_free(trie); +    bc_trie_free(trie);      assert_string_equal(t1, "guda");      assert_string_equal(t2, "nda"); @@ -835,74 +835,74 @@ test_trie_keep_data(void **state)  static void  test_trie_lookup(void **state)  { -    sb_trie_t *trie = sb_trie_new(free); +    bc_trie_t *trie = bc_trie_new(free); -    sb_trie_insert(trie, "bola", sb_strdup("guda")); -    sb_trie_insert(trie, "chu", sb_strdup("nda")); -    sb_trie_insert(trie, "bote", sb_strdup("aba")); -    sb_trie_insert(trie, "bo", sb_strdup("haha")); +    bc_trie_insert(trie, "bola", bc_strdup("guda")); +    bc_trie_insert(trie, "chu", bc_strdup("nda")); +    bc_trie_insert(trie, "bote", bc_strdup("aba")); +    bc_trie_insert(trie, "bo", bc_strdup("haha")); -    assert_string_equal(sb_trie_lookup(trie, "bola"), "guda"); -    assert_string_equal(sb_trie_lookup(trie, "chu"), "nda"); -    assert_string_equal(sb_trie_lookup(trie, "bote"), "aba"); -    assert_string_equal(sb_trie_lookup(trie, "bo"), "haha"); +    assert_string_equal(bc_trie_lookup(trie, "bola"), "guda"); +    assert_string_equal(bc_trie_lookup(trie, "chu"), "nda"); +    assert_string_equal(bc_trie_lookup(trie, "bote"), "aba"); +    assert_string_equal(bc_trie_lookup(trie, "bo"), "haha"); -    assert_null(sb_trie_lookup(trie, "arcoiro")); +    assert_null(bc_trie_lookup(trie, "arcoiro")); -    sb_trie_free(trie); +    bc_trie_free(trie); -    trie = sb_trie_new(free); +    trie = bc_trie_new(free); -    sb_trie_insert(trie, "chu", sb_strdup("nda")); -    sb_trie_insert(trie, "bola", sb_strdup("guda")); -    sb_trie_insert(trie, "bote", sb_strdup("aba")); -    sb_trie_insert(trie, "bo", sb_strdup("haha")); -    sb_trie_insert(trie, "copa", sb_strdup("bu")); -    sb_trie_insert(trie, "b", sb_strdup("c")); -    sb_trie_insert(trie, "test", sb_strdup("asd")); +    bc_trie_insert(trie, "chu", bc_strdup("nda")); +    bc_trie_insert(trie, "bola", bc_strdup("guda")); +    bc_trie_insert(trie, "bote", bc_strdup("aba")); +    bc_trie_insert(trie, "bo", bc_strdup("haha")); +    bc_trie_insert(trie, "copa", bc_strdup("bu")); +    bc_trie_insert(trie, "b", bc_strdup("c")); +    bc_trie_insert(trie, "test", bc_strdup("asd")); -    assert_string_equal(sb_trie_lookup(trie, "bola"), "guda"); -    assert_string_equal(sb_trie_lookup(trie, "chu"), "nda"); -    assert_string_equal(sb_trie_lookup(trie, "bote"), "aba"); -    assert_string_equal(sb_trie_lookup(trie, "bo"), "haha"); +    assert_string_equal(bc_trie_lookup(trie, "bola"), "guda"); +    assert_string_equal(bc_trie_lookup(trie, "chu"), "nda"); +    assert_string_equal(bc_trie_lookup(trie, "bote"), "aba"); +    assert_string_equal(bc_trie_lookup(trie, "bo"), "haha"); -    assert_null(sb_trie_lookup(trie, "arcoiro")); +    assert_null(bc_trie_lookup(trie, "arcoiro")); -    sb_trie_free(trie); +    bc_trie_free(trie); -    assert_null(sb_trie_lookup(NULL, "bola")); +    assert_null(bc_trie_lookup(NULL, "bola"));  }  static void  test_trie_size(void **state)  { -    sb_trie_t *trie = sb_trie_new(free); +    bc_trie_t *trie = bc_trie_new(free); -    sb_trie_insert(trie, "bola", sb_strdup("guda")); -    sb_trie_insert(trie, "chu", sb_strdup("nda")); -    sb_trie_insert(trie, "bote", sb_strdup("aba")); -    sb_trie_insert(trie, "bo", sb_strdup("haha")); +    bc_trie_insert(trie, "bola", bc_strdup("guda")); +    bc_trie_insert(trie, "chu", bc_strdup("nda")); +    bc_trie_insert(trie, "bote", bc_strdup("aba")); +    bc_trie_insert(trie, "bo", bc_strdup("haha")); -    assert_int_equal(sb_trie_size(trie), 4); -    assert_int_equal(sb_trie_size(NULL), 0); +    assert_int_equal(bc_trie_size(trie), 4); +    assert_int_equal(bc_trie_size(NULL), 0); -    sb_trie_free(trie); +    bc_trie_free(trie); -    trie = sb_trie_new(free); +    trie = bc_trie_new(free); -    sb_trie_insert(trie, "chu", sb_strdup("nda")); -    sb_trie_insert(trie, "bola", sb_strdup("guda")); -    sb_trie_insert(trie, "bote", sb_strdup("aba")); -    sb_trie_insert(trie, "bo", sb_strdup("haha")); -    sb_trie_insert(trie, "copa", sb_strdup("bu")); -    sb_trie_insert(trie, "b", sb_strdup("c")); -    sb_trie_insert(trie, "test", sb_strdup("asd")); +    bc_trie_insert(trie, "chu", bc_strdup("nda")); +    bc_trie_insert(trie, "bola", bc_strdup("guda")); +    bc_trie_insert(trie, "bote", bc_strdup("aba")); +    bc_trie_insert(trie, "bo", bc_strdup("haha")); +    bc_trie_insert(trie, "copa", bc_strdup("bu")); +    bc_trie_insert(trie, "b", bc_strdup("c")); +    bc_trie_insert(trie, "test", bc_strdup("asd")); -    assert_int_equal(sb_trie_size(trie), 7); -    assert_int_equal(sb_trie_size(NULL), 0); +    assert_int_equal(bc_trie_size(trie), 7); +    assert_int_equal(bc_trie_size(NULL), 0); -    sb_trie_free(trie); +    bc_trie_free(trie);  } @@ -922,24 +922,24 @@ mock_foreach(const char *key, void *data, void *user_data)  static void  test_trie_foreach(void **state)  { -    sb_trie_t *trie = sb_trie_new(free); +    bc_trie_t *trie = bc_trie_new(free); -    sb_trie_insert(trie, "chu", sb_strdup("nda")); -    sb_trie_insert(trie, "bola", sb_strdup("guda")); -    sb_trie_insert(trie, "bote", sb_strdup("aba")); -    sb_trie_insert(trie, "bo", sb_strdup("haha")); -    sb_trie_insert(trie, "copa", sb_strdup("bu")); -    sb_trie_insert(trie, "b", sb_strdup("c")); -    sb_trie_insert(trie, "test", sb_strdup("asd")); +    bc_trie_insert(trie, "chu", bc_strdup("nda")); +    bc_trie_insert(trie, "bola", bc_strdup("guda")); +    bc_trie_insert(trie, "bote", bc_strdup("aba")); +    bc_trie_insert(trie, "bo", bc_strdup("haha")); +    bc_trie_insert(trie, "copa", bc_strdup("bu")); +    bc_trie_insert(trie, "b", bc_strdup("c")); +    bc_trie_insert(trie, "test", bc_strdup("asd"));      counter = 0; -    sb_trie_foreach(trie, mock_foreach, "foo"); -    sb_trie_foreach(NULL, mock_foreach, "foo"); -    sb_trie_foreach(trie, NULL, "foo"); -    sb_trie_foreach(NULL, NULL, "foo"); +    bc_trie_foreach(trie, mock_foreach, "foo"); +    bc_trie_foreach(NULL, mock_foreach, "foo"); +    bc_trie_foreach(trie, NULL, "foo"); +    bc_trie_foreach(NULL, NULL, "foo");      assert_int_equal(counter, 7); -    sb_trie_free(trie); +    bc_trie_free(trie);  } | 
