aboutsummaryrefslogtreecommitdiffstats
path: root/src/uri.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/uri.c')
-rw-r--r--src/uri.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/uri.c b/src/uri.c
index 71cf3bcb..1e39cd33 100644
--- a/src/uri.c
+++ b/src/uri.c
@@ -37,8 +37,9 @@ serd_file_uri_parse(const char* uri, char** hostname)
return NULL;
}
if (hostname) {
- *hostname = (char*)calloc(path - auth + 1, 1);
- memcpy(*hostname, auth, path - auth);
+ const size_t len = (size_t)(path - auth);
+ *hostname = (char*)calloc(len + 1, 1);
+ memcpy(*hostname, auth, len);
}
}
}
@@ -48,14 +49,14 @@ serd_file_uri_parse(const char* uri, char** hostname)
}
SerdBuffer buffer = { NULL, 0 };
- for (const char* s = path; *s; ++s) {
+ for (const uint8_t* s = (const uint8_t*)path; *s; ++s) {
if (*s == '%') {
if (*(s + 1) == '%') {
serd_buffer_sink("%", 1, 1, &buffer);
++s;
} else if (is_hexdig(*(s + 1)) && is_hexdig(*(s + 2))) {
- const char code[3] = {*(s + 1), *(s + 2), 0};
- const char c = (char)strtoul((const char*)code, NULL, 16);
+ const uint8_t code[3] = {*(s + 1), *(s + 2), 0};
+ const uint8_t c = (uint8_t)strtoul((const char*)code, NULL, 16);
serd_buffer_sink(&c, 1, 1, &buffer);
s += 2;
} else {
@@ -72,12 +73,12 @@ bool
serd_uri_string_has_scheme(const char* utf8)
{
// RFC3986: scheme ::= ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
- if (!utf8 || !is_alpha(utf8[0])) {
+ if (!utf8 || !is_alpha((uint8_t)utf8[0])) {
return false; // Invalid scheme initial character, URI is relative
}
for (char c; (c = *++utf8) != '\0';) {
- if (!is_uri_scheme_char(c)) {
+ if (!is_uri_scheme_char((uint8_t)c)) {
return false;
} else if (c == ':') {
return true; // End of scheme
@@ -99,7 +100,7 @@ serd_uri_parse(const char* utf8, SerdURI* out)
*/
/* S3.1: scheme ::= ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) */
- if (is_alpha(*ptr)) {
+ if (is_alpha((uint8_t)*ptr)) {
for (char c = *++ptr; true; c = *++ptr) {
switch (c) {
case '\0': case '/': case '?': case '#':
@@ -107,12 +108,12 @@ serd_uri_parse(const char* utf8, SerdURI* out)
goto path; // Relative URI (starts with path by definition)
case ':':
out->scheme.buf = utf8;
- out->scheme.len = (ptr++) - utf8;
+ out->scheme.len = (size_t)((ptr++) - utf8);
goto maybe_authority; // URI with scheme
case '+': case '-': case '.':
continue;
default:
- if (is_alpha(c) || is_digit(c)) {
+ if (is_alpha((uint8_t)c) || is_digit((uint8_t)c)) {
continue;
}
}
@@ -276,12 +277,12 @@ merge(SerdSlice* base, SerdSlice* path)
} while (up > 0 && (--base_last > base->buf));
// Set path prefix
- base->len = base_last - base->buf + 1;
+ base->len = (size_t)(base_last - base->buf + 1);
}
// Set path suffix
path->buf = begin;
- path->len = end - begin;
+ path->len = (size_t)(end - begin);
}
/// See http://tools.ietf.org/html/rfc3986#section-5.2.2