62,10 → 62,10 |
* the NULL-terminator), size_t |
* |
* [wide] string length number of CHARACTERS in a [wide] string (excluding |
* the NULL-terminator), count_t |
* the NULL-terminator), size_t |
* |
* [wide] string width number of display cells on a monospace display taken |
* by a [wide] string, count_t |
* by a [wide] string, size_t |
* |
* |
* Overview of string metrics:@n |
75,10 → 75,10 |
* size n size_t number of BYTES in a string (excluding the |
* NULL-terminator) |
* |
* length l count_t number of CHARACTERS in a string (excluding the |
* length l size_t number of CHARACTERS in a string (excluding the |
* null terminator) |
* |
* width w count_t number of display cells on a monospace display |
* width w size_t number of display cells on a monospace display |
* taken by a string |
* |
* |
97,7 → 97,7 |
* |
* pointer (char *, wchar_t *) |
* byte offset (size_t) |
* character index (count_t) |
* character index (size_t) |
* |
*/ |
|
309,9 → 309,9 |
* @return Number of bytes used by the characters. |
* |
*/ |
size_t str_lsize(const char *str, count_t max_len) |
size_t str_lsize(const char *str, size_t max_len) |
{ |
count_t len = 0; |
size_t len = 0; |
size_t offset = 0; |
|
while (len < max_len) { |
337,7 → 337,7 |
* @return Number of bytes used by the wide characters. |
* |
*/ |
size_t wstr_lsize(const wchar_t *str, count_t max_len) |
size_t wstr_lsize(const wchar_t *str, size_t max_len) |
{ |
return (wstr_nlength(str, max_len * sizeof(wchar_t)) * sizeof(wchar_t)); |
} |
349,9 → 349,9 |
* @return Number of characters in string. |
* |
*/ |
count_t str_length(const char *str) |
size_t str_length(const char *str) |
{ |
count_t len = 0; |
size_t len = 0; |
size_t offset = 0; |
|
while (str_decode(str, &offset, STR_NO_LIMIT) != 0) |
367,9 → 367,9 |
* @return Number of characters in @a str. |
* |
*/ |
count_t wstr_length(const wchar_t *wstr) |
size_t wstr_length(const wchar_t *wstr) |
{ |
count_t len = 0; |
size_t len = 0; |
|
while (*wstr++ != 0) |
len++; |
385,9 → 385,9 |
* @return Number of characters in string. |
* |
*/ |
count_t str_nlength(const char *str, size_t size) |
size_t str_nlength(const char *str, size_t size) |
{ |
count_t len = 0; |
size_t len = 0; |
size_t offset = 0; |
|
while (str_decode(str, &offset, size) != 0) |
404,11 → 404,11 |
* @return Number of characters in string. |
* |
*/ |
count_t wstr_nlength(const wchar_t *str, size_t size) |
size_t wstr_nlength(const wchar_t *str, size_t size) |
{ |
count_t len = 0; |
count_t limit = ALIGN_DOWN(size, sizeof(wchar_t)); |
count_t offset = 0; |
size_t len = 0; |
size_t limit = ALIGN_DOWN(size, sizeof(wchar_t)); |
size_t offset = 0; |
|
while ((offset < limit) && (*str++ != 0)) { |
len++; |
496,7 → 496,7 |
* 1 if second smaller. |
* |
*/ |
int str_lcmp(const char *s1, const char *s2, count_t max_len) |
int str_lcmp(const char *s1, const char *s2, size_t max_len) |
{ |
wchar_t c1 = 0; |
wchar_t c2 = 0; |
504,7 → 504,7 |
size_t off1 = 0; |
size_t off2 = 0; |
|
count_t len = 0; |
size_t len = 0; |
|
while (true) { |
if (len >= max_len) |
615,7 → 615,7 |
return; |
|
wchar_t ch; |
count_t src_idx = 0; |
size_t src_idx = 0; |
size_t dst_off = 0; |
|
while ((ch = src[src_idx++]) != 0) { |
666,14 → 666,14 |
* is out of bounds. |
* |
*/ |
bool wstr_linsert(wchar_t *str, wchar_t ch, count_t pos, count_t max_pos) |
bool wstr_linsert(wchar_t *str, wchar_t ch, size_t pos, size_t max_pos) |
{ |
count_t len = wstr_length(str); |
size_t len = wstr_length(str); |
|
if ((pos > len) || (pos + 1 > max_pos)) |
return false; |
|
count_t i; |
size_t i; |
for (i = len; i + 1 > pos; i--) |
str[i + 1] = str[i]; |
|
694,14 → 694,14 |
* is out of bounds. |
* |
*/ |
bool wstr_remove(wchar_t *str, count_t pos) |
bool wstr_remove(wchar_t *str, size_t pos) |
{ |
count_t len = wstr_length(str); |
size_t len = wstr_length(str); |
|
if (pos >= len) |
return false; |
|
count_t i; |
size_t i; |
for (i = pos + 1; i <= len; i++) |
str[i - 1] = str[i]; |
|