diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/n3.c | 10 | ||||
-rw-r--r-- | src/node.c | 11 | ||||
-rw-r--r-- | src/stack.h | 2 | ||||
-rw-r--r-- | src/string_utils.h | 8 | ||||
-rw-r--r-- | src/uri.c | 7 |
5 files changed, 18 insertions, 20 deletions
@@ -65,7 +65,7 @@ read_HEX(SerdReader* reader) } // Read UCHAR escape, initial \ is already eaten by caller -static inline SerdStatus +static SerdStatus read_UCHAR(SerdReader* reader, SerdNode* dest, uint32_t* char_code) { const int b = peek_byte(reader); @@ -143,7 +143,7 @@ read_UCHAR(SerdReader* reader, SerdNode* dest, uint32_t* char_code) } // Read ECHAR escape, initial \ is already eaten by caller -static inline SerdStatus +static SerdStatus read_ECHAR(SerdReader* reader, SerdNode* dest) { const int c = peek_byte(reader); @@ -279,7 +279,7 @@ read_comment(SerdReader* reader) } // [24] ws ::= #x9 | #xA | #xD | #x20 | comment -static inline bool +static bool read_ws(SerdReader* reader) { const int c = peek_byte(reader); @@ -308,14 +308,14 @@ read_ws_star(SerdReader* reader) } static inline bool -peek_delim(SerdReader* reader, const char delim) +peek_delim(SerdReader* reader, const uint8_t delim) { read_ws_star(reader); return peek_byte(reader) == delim; } static inline bool -eat_delim(SerdReader* reader, const char delim) +eat_delim(SerdReader* reader, const uint8_t delim) { if (peek_delim(reader, delim)) { eat_byte_safe(reader, delim); @@ -530,17 +530,14 @@ is_uri_path_char(const char c) } switch (c) { - // unreserved: case '-': case '.': case '_': - case '~': - // pchar: + case '~': // unreserved case ':': - case '@': - // separator: - case '/': - // sub-delimeters: + case '@': // pchar + case '/': // separator + // sub-delims case '!': case '$': case '&': diff --git a/src/stack.h b/src/stack.h index 0eae1b75..273bf2a5 100644 --- a/src/stack.h +++ b/src/stack.h @@ -57,7 +57,7 @@ serd_stack_clear(SerdStack* stack) } static inline bool -serd_stack_is_empty(SerdStack* stack) +serd_stack_is_empty(const SerdStack* stack) { return stack->size <= SERD_STACK_BOTTOM; } diff --git a/src/string_utils.h b/src/string_utils.h index 08ba530c..0e9eee43 100644 --- a/src/string_utils.h +++ b/src/string_utils.h @@ -84,7 +84,7 @@ is_print(const int c) } static inline bool -is_base64(const char c) +is_base64(const int c) { return is_alpha(c) || is_digit(c) || c == '+' || c == '/' || c == '='; } @@ -143,9 +143,9 @@ utf8_num_bytes(const uint8_t c) static inline uint32_t parse_counted_utf8_char(const uint8_t* utf8, size_t size) { - uint32_t c = utf8[0] & ((1u << (8 - size)) - 1); + uint32_t c = utf8[0] & ((1u << (8u - size)) - 1u); for (size_t i = 1; i < size; ++i) { - const uint8_t in = utf8[i] & 0x3F; + const uint8_t in = utf8[i] & 0x3Fu; c = (c << 6) | in; } return c; @@ -163,7 +163,7 @@ parse_utf8_char(const uint8_t* utf8, size_t* size) return parse_counted_utf8_char(utf8, *size); default: *size = 0; - return 0; + return 0u; } } @@ -43,8 +43,9 @@ serd_parse_file_uri(const char* uri, char** hostname) } if (hostname) { - *hostname = (char*)calloc((size_t)(path - auth + 1), 1); - memcpy(*hostname, auth, (size_t)(path - auth)); + const size_t len = (size_t)(path - auth); + *hostname = (char*)calloc(len + 1, 1); + memcpy(*hostname, auth, len); } } } @@ -61,7 +62,7 @@ serd_parse_file_uri(const char* uri, char** hostname) ++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 char c = (char)strtoul(code, NULL, 16); serd_buffer_sink(&c, 1, 1, &buffer); s += 2; } else { |