aboutsummaryrefslogtreecommitdiffstats
path: root/src/string_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/string_utils.h')
-rw-r--r--src/string_utils.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/string_utils.h b/src/string_utils.h
index 2ce90ac9..f4b27bcc 100644
--- a/src/string_utils.h
+++ b/src/string_utils.h
@@ -4,7 +4,7 @@
#ifndef SERD_SRC_STRING_UTILS_H
#define SERD_SRC_STRING_UTILS_H
-#include "serd/serd.h"
+#include <serd/serd.h>
#include <stdbool.h>
#include <stddef.h>
@@ -51,13 +51,13 @@ is_xdigit(const int c)
static inline bool
is_space(const char c)
{
- return c == ' ' || (c >= '\t' && c <= '\r');
+ return c == ' ' || in_range(c, '\t', '\r');
}
static inline bool
is_print(const int c)
{
- return c >= 0x20 && c <= 0x7E;
+ return in_range(c, 0x20, 0x7E);
}
static inline bool
@@ -88,7 +88,7 @@ hex_digit_value(const uint8_t c)
static inline char
serd_to_upper(const char c)
{
- return (char)((c >= 'a' && c <= 'z') ? c - 32 : c);
+ return (char)(in_range(c, 'a', 'z') ? (c - 32) : c);
}
SERD_PURE_FUNC static inline int
@@ -107,7 +107,7 @@ serd_strcasecmp(const char* s1, const char* s2)
return (c1 == c2) ? 0 : (c1 < c2) ? -1 : +1;
}
-static inline uint32_t
+static inline uint8_t
utf8_num_bytes(const uint8_t leading)
{
return ((leading & 0x80U) == 0x00U) ? 1U // Starts with `0'
@@ -119,18 +119,18 @@ utf8_num_bytes(const uint8_t leading)
/// Return the code point of a UTF-8 character with known length
static inline uint32_t
-parse_counted_utf8_char(const uint8_t* utf8, size_t size)
+parse_counted_utf8_char(const uint8_t* const utf8, const uint8_t size)
{
uint32_t c = utf8[0] & ((1U << (8U - size)) - 1U);
for (size_t i = 1; i < size; ++i) {
- c = (c << 6) | (utf8[i] & 0x3FU);
+ c = (c << 6U) | (utf8[i] & 0x3FU);
}
return c;
}
/// Parse a UTF-8 character, set *size to the length, and return the code point
static inline uint32_t
-parse_utf8_char(const uint8_t* utf8, size_t* size)
+parse_utf8_char(const uint8_t* const utf8, uint8_t* const size)
{
switch (*size = utf8_num_bytes(utf8[0])) {
case 1: