aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2018-03-20 19:19:56 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2018-03-20 19:19:56 +0100
commitc278e2da0cf9aee161e23771125629bdfe8d5d89 (patch)
treed133edccf32c7a260c534e22325ce671b5023421
parent93fc79a5b2826bcddd617e5180d5513dc3cdc67c (diff)
downloadblogc-c278e2da0cf9aee161e23771125629bdfe8d5d89.tar.gz
blogc-c278e2da0cf9aee161e23771125629bdfe8d5d89.tar.bz2
blogc-c278e2da0cf9aee161e23771125629bdfe8d5d89.zip
blogc: common: replace unsigned int with size_t
-rw-r--r--src/blogc-git-receiver/pre-receive.c4
-rw-r--r--src/blogc-make/main.c2
-rw-r--r--src/blogc-runserver/httpd-utils.c2
-rw-r--r--src/blogc-runserver/main.c4
-rw-r--r--src/blogc/content-parser.c2
-rw-r--r--src/blogc/datetime-parser.c2
-rw-r--r--src/blogc/loader.c12
-rw-r--r--src/blogc/main.c4
-rw-r--r--src/blogc/renderer.c4
-rw-r--r--src/blogc/template-parser.c4
-rw-r--r--src/common/utils.c4
-rw-r--r--src/common/utils.h2
-rw-r--r--tests/blogc/check_renderer.c4
-rw-r--r--tests/common/check_utils.c2
14 files changed, 26 insertions, 26 deletions
diff --git a/src/blogc-git-receiver/pre-receive.c b/src/blogc-git-receiver/pre-receive.c
index c2fe080..e8ac1d3 100644
--- a/src/blogc-git-receiver/pre-receive.c
+++ b/src/blogc-git-receiver/pre-receive.c
@@ -21,13 +21,13 @@
#include "pre-receive.h"
-static unsigned int
+static size_t
cpu_count(void)
{
#ifdef _SC_NPROCESSORS_ONLN
long num = sysconf(_SC_NPROCESSORS_ONLN);
if (num >= 1)
- return (unsigned int) num;
+ return (size_t) num;
#endif
return 1;
}
diff --git a/src/blogc-make/main.c b/src/blogc-make/main.c
index 96a145b..3ce1f8a 100644
--- a/src/blogc-make/main.c
+++ b/src/blogc-make/main.c
@@ -68,7 +68,7 @@ main(int argc, char **argv)
char *blogcfile = NULL;
bm_ctx_t *ctx = NULL;
- for (unsigned int i = 1; i < argc; i++) {
+ for (size_t i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
switch (argv[i][1]) {
case 'h':
diff --git a/src/blogc-runserver/httpd-utils.c b/src/blogc-runserver/httpd-utils.c
index e67afb1..7a49bf2 100644
--- a/src/blogc-runserver/httpd-utils.c
+++ b/src/blogc-runserver/httpd-utils.c
@@ -90,7 +90,7 @@ const char*
br_get_extension(const char *filename)
{
const char *ext = NULL;
- unsigned int i;
+ size_t i;
for (i = strlen(filename); i > 0; i--) {
if (filename[i] == '.') {
ext = filename + i + 1;
diff --git a/src/blogc-runserver/main.c b/src/blogc-runserver/main.c
index 15942ac..b9b831a 100644
--- a/src/blogc-runserver/main.c
+++ b/src/blogc-runserver/main.c
@@ -70,9 +70,9 @@ main(int argc, char **argv)
char *tmp_port = getenv("BLOGC_RUNSERVER_DEFAULT_PORT");
char *default_port = bc_strdup(tmp_port != NULL ? tmp_port : "8080");
- unsigned int args = 0;
+ size_t args = 0;
- for (unsigned int i = 1; i < argc; i++) {
+ for (size_t i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
switch (argv[i][1]) {
case 'h':
diff --git a/src/blogc/content-parser.c b/src/blogc/content-parser.c
index e971296..106e3c8 100644
--- a/src/blogc/content-parser.c
+++ b/src/blogc/content-parser.c
@@ -688,7 +688,7 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **first_header,
size_t eend = 0;
size_t real_end = 0;
- unsigned int header_level = 0;
+ size_t header_level = 0;
char *prefix = NULL;
size_t prefix_len = 0;
char *tmp = NULL;
diff --git a/src/blogc/datetime-parser.c b/src/blogc/datetime-parser.c
index f915501..b7f26e5 100644
--- a/src/blogc/datetime-parser.c
+++ b/src/blogc/datetime-parser.c
@@ -69,7 +69,7 @@ blogc_convert_datetime(const char *orig, const char *format,
int tmp = 0;
int diff = '0';
- for (unsigned int i = 0; orig[i] != '\0'; i++) {
+ for (size_t i = 0; orig[i] != '\0'; i++) {
char c = orig[i];
switch (state) {
diff --git a/src/blogc/loader.c b/src/blogc/loader.c
index c54b285..0525198 100644
--- a/src/blogc/loader.c
+++ b/src/blogc/loader.c
@@ -116,7 +116,7 @@ blogc_source_parse_from_files(bc_trie_t *conf, bc_slist_t *l, bc_error_t **err)
bc_error_t *tmp_err = NULL;
bc_slist_t *rv = NULL;
- unsigned int with_date = 0;
+ size_t with_date = 0;
const char *filter_tag = bc_trie_lookup(conf, "FILTER_TAG");
const char *filter_page = bc_trie_lookup(conf, "FILTER_PAGE");
@@ -142,9 +142,9 @@ blogc_source_parse_from_files(bc_trie_t *conf, bc_slist_t *l, bc_error_t **err)
per_page = 0;
// poor man's pagination
- unsigned int start = (page - 1) * per_page;
- unsigned int end = start + per_page;
- unsigned int counter = 0;
+ size_t start = (page - 1) * per_page;
+ size_t end = start + per_page;
+ size_t counter = 0;
for (bc_slist_t *tmp = sources; tmp != NULL; tmp = tmp->next) {
char *f = tmp->data;
@@ -168,7 +168,7 @@ blogc_source_parse_from_files(bc_trie_t *conf, bc_slist_t *l, bc_error_t **err)
}
char **tags = bc_str_split(tags_str, ' ', 0);
bool found = false;
- for (unsigned int i = 0; tags[i] != NULL; i++) {
+ for (size_t i = 0; tags[i] != NULL; i++) {
if (tags[i][0] == '\0')
continue;
if (0 == strcmp(tags[i], filter_tag))
@@ -226,7 +226,7 @@ blogc_source_parse_from_files(bc_trie_t *conf, bc_slist_t *l, bc_error_t **err)
}
if (filter_page != NULL) {
- unsigned int last_page = ceilf(((float) counter) / per_page);
+ size_t last_page = ceilf(((float) counter) / per_page);
bc_trie_insert(conf, "CURRENT_PAGE", bc_strdup_printf("%ld", page));
if (page > 1)
bc_trie_insert(conf, "PREVIOUS_PAGE", bc_strdup_printf("%ld", page - 1));
diff --git a/src/blogc/main.c b/src/blogc/main.c
index d72091e..0b7c1ad 100644
--- a/src/blogc/main.c
+++ b/src/blogc/main.c
@@ -165,7 +165,7 @@ main(int argc, char **argv)
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++) {
+ for (size_t i = 1; i < argc; i++) {
tmp = NULL;
if (argv[i][0] == '-') {
switch (argv[i][1]) {
@@ -221,7 +221,7 @@ main(int argc, char **argv)
rv = 3;
goto cleanup;
}
- for (unsigned int j = 0; pieces[0][j] != '\0'; j++) {
+ for (size_t j = 0; pieces[0][j] != '\0'; j++) {
if (!((pieces[0][j] >= 'A' && pieces[0][j] <= 'Z') ||
pieces[0][j] == '_'))
{
diff --git a/src/blogc/renderer.c b/src/blogc/renderer.c
index a49e87d..73edf9a 100644
--- a/src/blogc/renderer.c
+++ b/src/blogc/renderer.c
@@ -149,7 +149,7 @@ blogc_split_list_variable(const char *name, bc_trie_t *global, bc_trie_t *local)
bc_slist_t *rv = NULL;
char **tmp = bc_str_split(value, ' ', 0);
- for (unsigned int i = 0; tmp[i] != NULL; i++) {
+ for (size_t i = 0; tmp[i] != NULL; i++) {
if (tmp[i][0] != '\0') // ignore empty strings
rv = bc_slist_append(rv, tmp[i]);
else
@@ -176,7 +176,7 @@ blogc_render(bc_slist_t *tmpl, bc_slist_t *sources, bc_trie_t *config, bool list
char *config_value = NULL;
char *defined = NULL;
- unsigned int if_count = 0;
+ size_t if_count = 0;
bc_slist_t *foreach_var = NULL;
bc_slist_t *foreach_var_start = NULL;
diff --git a/src/blogc/template-parser.c b/src/blogc/template-parser.c
index 4d2cb3c..b085a33 100644
--- a/src/blogc/template-parser.c
+++ b/src/blogc/template-parser.c
@@ -57,8 +57,8 @@ blogc_template_parse(const char *src, size_t src_len, bc_error_t **err)
blogc_template_operator_t tmp_op = 0;
- unsigned int if_count = 0;
- unsigned int block_if_count = 0;
+ size_t if_count = 0;
+ size_t block_if_count = 0;
bool else_open = false;
bool foreach_open = false;
bool block_foreach_open = false;
diff --git a/src/common/utils.c b/src/common/utils.c
index 97fa671..563d8ab 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -244,12 +244,12 @@ bc_str_strip(char *str)
char**
-bc_str_split(const char *str, char c, unsigned int max_pieces)
+bc_str_split(const char *str, char c, size_t max_pieces)
{
if (str == NULL)
return NULL;
char **rv = bc_malloc(sizeof(char*));
- unsigned int i, start = 0, count = 0;
+ size_t i, start = 0, count = 0;
for (i = 0; i < strlen(str) + 1; i++) {
if (str[0] == '\0')
break;
diff --git a/src/common/utils.h b/src/common/utils.h
index b0388b3..0f05c96 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -47,7 +47,7 @@ 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_split(const char *str, char c, size_t 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);
diff --git a/tests/blogc/check_renderer.c b/tests/blogc/check_renderer.c
index b0fbb94..369ba3d 100644
--- a/tests/blogc/check_renderer.c
+++ b/tests/blogc/check_renderer.c
@@ -21,7 +21,7 @@
static bc_slist_t*
-create_sources(unsigned int count)
+create_sources(size_t count)
{
const char *s[] = {
"BOLA: asd\n"
@@ -46,7 +46,7 @@ create_sources(unsigned int count)
assert_false(count > 3);
bc_error_t *err = NULL;
bc_slist_t *l = NULL;
- for (unsigned int i = 0; i < count; i++) {
+ for (size_t i = 0; i < count; i++) {
l = bc_slist_append(l, blogc_source_parse(s[i], strlen(s[i]), &err));
assert_null(err);
}
diff --git a/tests/common/check_utils.c b/tests/common/check_utils.c
index dc1eadd..12ef921 100644
--- a/tests/common/check_utils.c
+++ b/tests/common/check_utils.c
@@ -906,7 +906,7 @@ test_trie_size(void **state)
}
-static unsigned int counter;
+static size_t counter;
static char *expected_keys[] = {"chu", "copa", "bola", "bote", "bo", "b", "test", "testa"};
static char *expected_datas[] = {"nda", "bu", "guda", "aba", "haha", "c", "asd", "lol"};