aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-09-09 03:03:57 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-09-09 03:03:57 +0200
commitd66ebfab3458172bd435b00c51e8b09e2510b4d4 (patch)
tree157220d08f8005a7f91e321394d5f10d97ffb693
parentba38817ab8dd3606de9e5d40c83c8f8d185f671b (diff)
downloadblogc-d66ebfab3458172bd435b00c51e8b09e2510b4d4.tar.gz
blogc-d66ebfab3458172bd435b00c51e8b09e2510b4d4.tar.bz2
blogc-d66ebfab3458172bd435b00c51e8b09e2510b4d4.zip
s/blogc_utf8_/bc_utf8_/g
-rw-r--r--src/blogc/file.c4
-rw-r--r--src/blogc/main.c2
-rw-r--r--src/common/utf8.c8
-rw-r--r--src/common/utf8.h6
-rw-r--r--tests/common/check_utf8.c26
5 files changed, 23 insertions, 23 deletions
diff --git a/src/blogc/file.c b/src/blogc/file.c
index cede962..71598b8 100644
--- a/src/blogc/file.c
+++ b/src/blogc/file.c
@@ -49,7 +49,7 @@ blogc_file_get_contents(const char *path, size_t *len, bc_error_t **err)
if (str->len == 0 && read_len > 0) {
// skipping BOM before validation, for performance. should be safe
// enough
- size_t skip = blogc_utf8_skip_bom((uint8_t*) buffer, read_len);
+ size_t skip = bc_utf8_skip_bom((uint8_t*) buffer, read_len);
read_len -= skip;
tmp += skip;
}
@@ -59,7 +59,7 @@ blogc_file_get_contents(const char *path, size_t *len, bc_error_t **err)
}
fclose(fp);
- if (!blogc_utf8_validate_str(str)) {
+ if (!bc_utf8_validate_str(str)) {
*err = bc_error_new_printf(BLOGC_ERROR_FILE,
"File content is not valid UTF-8: %s", path);
bc_string_free(str, true);
diff --git a/src/blogc/main.c b/src/blogc/main.c
index beb67d6..992b9e7 100644
--- a/src/blogc/main.c
+++ b/src/blogc/main.c
@@ -162,7 +162,7 @@ main(int argc, char **argv)
else if (i + 1 < argc)
tmp = argv[++i];
if (tmp != NULL) {
- if (!blogc_utf8_validate((uint8_t*) tmp, strlen(tmp))) {
+ if (!bc_utf8_validate((uint8_t*) tmp, strlen(tmp))) {
fprintf(stderr, "blogc: error: invalid value for "
"-D (must be valid UTF-8 string): %s\n", tmp);
goto cleanup;
diff --git a/src/common/utf8.c b/src/common/utf8.c
index ddd51ee..625f705 100644
--- a/src/common/utf8.c
+++ b/src/common/utf8.c
@@ -70,7 +70,7 @@ decode(uint32_t* state, uint32_t* codep, uint32_t byte) {
bool
-blogc_utf8_validate(const uint8_t *str, size_t len)
+bc_utf8_validate(const uint8_t *str, size_t len)
{
uint32_t codepoint;
uint32_t state = 0;
@@ -83,14 +83,14 @@ blogc_utf8_validate(const uint8_t *str, size_t len)
bool
-blogc_utf8_validate_str(bc_string_t *str)
+bc_utf8_validate_str(bc_string_t *str)
{
- return blogc_utf8_validate((uint8_t*) str->str, str->len);
+ return bc_utf8_validate((uint8_t*) str->str, str->len);
}
size_t
-blogc_utf8_skip_bom(const uint8_t *str, size_t len)
+bc_utf8_skip_bom(const uint8_t *str, size_t len)
{
if (len < 3)
return 0;
diff --git a/src/common/utf8.h b/src/common/utf8.h
index b37a97d..206b3a9 100644
--- a/src/common/utf8.h
+++ b/src/common/utf8.h
@@ -14,8 +14,8 @@
#include <stdint.h>
#include "utils.h"
-bool blogc_utf8_validate(const uint8_t *str, size_t len);
-bool blogc_utf8_validate_str(bc_string_t *str);
-size_t blogc_utf8_skip_bom(const uint8_t *str, size_t len);
+bool bc_utf8_validate(const uint8_t *str, size_t len);
+bool bc_utf8_validate_str(bc_string_t *str);
+size_t bc_utf8_skip_bom(const uint8_t *str, size_t len);
#endif /* _UTF_8_H */
diff --git a/tests/common/check_utf8.c b/tests/common/check_utf8.c
index f4c7f32..56953f1 100644
--- a/tests/common/check_utf8.c
+++ b/tests/common/check_utf8.c
@@ -24,11 +24,11 @@ test_utf8_valid(void **state)
{
const char *c = "<a href=\"{{ BASE_URL }}/page/{{ PREVIOUS_PAGE }}/\">"
"\xc2\xab Newer posts</a>";
- assert_true(blogc_utf8_validate((uint8_t*) c, strlen(c)));
+ assert_true(bc_utf8_validate((uint8_t*) c, strlen(c)));
const uint8_t d[3] = {0xe2, 0x82, 0xac}; // euro sign
- assert_true(blogc_utf8_validate(d, 3));
+ assert_true(bc_utf8_validate(d, 3));
const uint8_t e[3] = {0xef, 0xbb, 0xbf}; // utf-8 bom
- assert_true(blogc_utf8_validate(e, 3));
+ assert_true(bc_utf8_validate(e, 3));
}
@@ -36,9 +36,9 @@ static void
test_utf8_invalid(void **state)
{
const uint8_t c[4] = {0xff, 0xfe, 0xac, 0x20}; // utf-16
- assert_false(blogc_utf8_validate(c, 4));
+ assert_false(bc_utf8_validate(c, 4));
const uint8_t d[8] = {0xff, 0xfe, 0x00, 0x00, 0xac, 0x20, 0x00, 0x00}; // utf-32
- assert_false(blogc_utf8_validate(d, 8));
+ assert_false(bc_utf8_validate(d, 8));
}
@@ -49,11 +49,11 @@ test_utf8_valid_str(void **state)
bc_string_append(s,
"<a href=\"{{ BASE_URL }}/page/{{ PREVIOUS_PAGE }}/\">\xc2\xab Newer "
"posts</a>");
- assert_true(blogc_utf8_validate_str(s));
+ assert_true(bc_utf8_validate_str(s));
bc_string_free(s, true);
s = bc_string_new();
bc_string_append(s, "\xe2\x82\xac");
- assert_true(blogc_utf8_validate_str(s));
+ assert_true(bc_utf8_validate_str(s));
bc_string_free(s, true);
}
@@ -63,11 +63,11 @@ test_utf8_invalid_str(void **state)
{
bc_string_t *s = bc_string_new();
bc_string_append(s, "\xff\xfe\xac\x20"); // utf-16
- assert_false(blogc_utf8_validate_str(s));
+ assert_false(bc_utf8_validate_str(s));
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));
+ assert_false(bc_utf8_validate_str(s));
bc_string_free(s, true);
}
@@ -76,14 +76,14 @@ static void
test_utf8_skip_bom(void **state)
{
const uint8_t c[4] = {0xef, 0xbb, 0xbf, 0};
- assert_int_equal(blogc_utf8_skip_bom(c, 2), 0);
- assert_int_equal(blogc_utf8_skip_bom(c, 3), 3);
+ assert_int_equal(bc_utf8_skip_bom(c, 2), 0);
+ assert_int_equal(bc_utf8_skip_bom(c, 3), 3);
assert_string_equal(c + 3, "");
const uint8_t d[8] = {0xef, 0xbb, 0xbf, 'b', 'o', 'l', 'a', 0};
- assert_int_equal(blogc_utf8_skip_bom(d, 7), 3);
+ assert_int_equal(bc_utf8_skip_bom(d, 7), 3);
assert_string_equal(d + 3, "bola");
const uint8_t e[5] = "bola";
- assert_int_equal(blogc_utf8_skip_bom(e, 4), 0);
+ assert_int_equal(bc_utf8_skip_bom(e, 4), 0);
}