15 #define ISWHITE(c) ((c) == 9 || (c) == 32) // TAB or SPACE
16 #define NOTWHITE(c) ((c) != 9 && (c) != 32) // neither TAB nor SPACE
22 bool strew(
const char *str,
const char *what);
23 bool strsw(
const char *str,
const char *what);
24 bool streq(
const char *str,
const char *what);
25 bool streq_ic(
const char *str,
const char *what);
26 bool wstrsw_ic(
const wchar_t *str,
const wchar_t *what);
27 bool wstrew(
const wchar_t *str,
const wchar_t *what);
28 const char *
strstr_ic(
const char *haystack,
const char *needle);
29 int rtrim_len(
const char *s,
size_t *len);
30 int ltrim_ofs(
const char *s,
size_t *len);
37 bool is_ascii(
unsigned char *data,
int min_len);
38 bool is_utf16(
wchar_t *data,
int min_len);
43 int32_t
hash_str_djb(
const char *key,
size_t length,
size_t step);
44 int32_t
hash_wstr_djb(
const wchar_t *key,
size_t length,
size_t step);
45 int32_t
hash_str_sdbm(
const char *key,
size_t length,
size_t step);
46 int32_t
hash_wstr_sdbm(
const wchar_t *key,
size_t length,
size_t step);
47 int32_t
hash_str_elf(
const char *key,
size_t length,
size_t step);
48 int32_t
hash_wstr_elf(
const wchar_t *key,
size_t length,
size_t step);
49 int32_t
hash_str_mulAdd(int32_t init, int32_t factor,
const char *key,
size_t length,
size_t step);
50 int32_t
hash_wstr_mulAdd(int32_t init, int32_t factor,
const wchar_t *key,
size_t length,
size_t step);
51 int32_t
hash_str_mulXor(int32_t init, int32_t factor,
const char *key,
size_t length,
size_t step);
52 int32_t
hash_wstr_mulXor(int32_t init, int32_t factor,
const wchar_t *key,
size_t length,
size_t step);
53 int32_t
hash_str_xorMul(int32_t init, int32_t factor,
const char *key,
size_t length,
size_t step);
54 int32_t
hash_wstr_xorMul(int32_t init, int32_t factor,
const wchar_t *key,
size_t length,
size_t step);
59 int hextoi(
const char *str);
int32_t hash_wstr_xorMul(int32_t init, int32_t factor, const wchar_t *key, size_t length, size_t step)
wide string hash functions, using (FNV-1a style) "xor before mul"
Definition: strutils.c:377
bool wstrew(const wchar_t *str, const wchar_t *what)
wide string ends with
Definition: strutils.c:31
bool streq_ic(const char *str, const char *what)
case-insensitive string equals
Definition: strutils.c:69
char * vformatmsg(const char *fmt, va_list ap)
Return a string according to format string fmt, using arguments from vararg list ap.
Definition: strutils.c:451
char * repeat_char(const char c, int n)
construct a string that repeats a char n times.
Definition: strutils.c:154
int32_t hash_str_xorMul(int32_t init, int32_t factor, const char *key, size_t length, size_t step)
string hash functions, using (FNV-1a style) "xor before mul"
Definition: strutils.c:367
bool strew(const char *str, const char *what)
string ends with
Definition: strutils.c:22
bool wstrsw_ic(const wchar_t *str, const wchar_t *what)
wide string starts with
Definition: strutils.c:49
int32_t hash_str_elf(const char *key, size_t length, size_t step)
ELF hash.
Definition: strutils.c:284
int32_t hash_wstr_mulAdd(int32_t init, int32_t factor, const wchar_t *key, size_t length, size_t step)
multiplicative wide string hash functions, using "add" operation
Definition: strutils.c:331
int rtrim_len(const char *s, size_t *len)
A helper function for "right trim" (removal of trailing whitepace).
Definition: strutils.c:108
bool is_ascii(unsigned char *data, int min_len)
test for valid strings (consisting only of ASCII chars) with a given minimum length ...
Definition: strutils.c:191
int32_t hash_str_mulXor(int32_t init, int32_t factor, const char *key, size_t length, size_t step)
multiplicative string hash functions, using "xor" operation
Definition: strutils.c:341
int32_t hash_wstr_djb(const wchar_t *key, size_t length, size_t step)
DJB hash function for wide strings.
Definition: strutils.c:249
int strcmp_safe(const char *a, const char *b)
"Lua-safe" string comparison (strcmp wrapper), protects against NULL pointers
Definition: strutils.c:133
int32_t hash_wstr_elf(const wchar_t *key, size_t length, size_t step)
ELF hash function for wide strings.
Definition: strutils.c:303
char * repeat_string(const char *str, int n)
construct a string that repeats another string n times.
Definition: strutils.c:165
const char * strstr_ic(const char *haystack, const char *needle)
case-insensitive substring match
Definition: strutils.c:83
int32_t hash_str_djb(const char *key, size_t length, size_t step)
DJB string hash function.
Definition: strutils.c:241
bool streq(const char *str, const char *what)
string equals
Definition: strutils.c:61
bool strsw(const char *str, const char *what)
string starts with
Definition: strutils.c:41
int strcasecmp_safe(const char *a, const char *b)
"Lua-safe" string comparison, ignores case (strcasecmp wrapper)
Definition: strutils.c:142
int vformatmsg_len(char **msg, const char *fmt, va_list ap)
Function to create a string according to format string fmt while using arguments from vararg list ap...
Definition: strutils.c:407
char * formatmsg(const char *fmt,...)
Vararg wrapper for vformatmsg(). Returns formatted string.
Definition: strutils.c:469
int ltrim_ofs(const char *s, size_t *len)
A helper function for "left trim" (removal of leading whitepace).
Definition: strutils.c:122
int32_t hash_wstr_sdbm(const wchar_t *key, size_t length, size_t step)
sdbm hash function for wide strings
Definition: strutils.c:269
bool is_utf16(wchar_t *data, int min_len)
test for valid wide strings (consisting only of ASCII wide chars)
Definition: strutils.c:204
int hextoi(const char *str)
A primitive version of "hex to integer", similar to strtol(str, NULL, 16).
Definition: strutils.c:217
boolean data type and constants/macros
int formatmsg_len(char **msg, const char *fmt,...)
Vararg wrapper for vformatmsg_len().
Definition: strutils.c:459
int32_t hash_str_mulAdd(int32_t init, int32_t factor, const char *key, size_t length, size_t step)
multiplicative string hash functions, using "add" operation
Definition: strutils.c:321
int32_t hash_wstr_mulXor(int32_t init, int32_t factor, const wchar_t *key, size_t length, size_t step)
multiplicative wide string hash functions, using "xor" operation
Definition: strutils.c:353
int32_t hash_str_sdbm(const char *key, size_t length, size_t step)
sdbm string hash function.
Definition: strutils.c:261