чување 34b92f409efe801849b1473ad0cdd27318782ac3
родитељ 54b7ad4b24aec20a45256a1c1b943418b10fed7b
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Sat, 11 Mar 2023 19:51:54 +0100
Bugfix: replace macro u32_is_word_boundary with proper function
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 3, додавања: 10(+), брисања: 3(-)
diff --git a/TODO b/TODO
@@ -3,7 +3,7 @@
[x] Bug: C-C/C-V don't work until the msgstr is saved (they should)
- [ ] Bug: C-T behavior? Cross-check with sled's routines
+ [x] Bug: C-T behavior? Cross-check with sled's routines
[ ] Replace strn* -> strc*: like str[^n]*, but with configurable string
ending character (for msgstr, which has multiple lines delimited
diff --git a/util.c b/util.c
@@ -414,6 +414,14 @@ is_word_boundary(const char ch, const int strictly_whitespace)
}
const int
+u32_is_word_boundary(const uint32_t ch, const int strictly_whitespace)
+{
+ return strictly_whitespace
+ ? u32_strchr((uint32_t*)L" \v\t", ch) != NULL
+ : u32_strchr((uint32_t*)L" \v\t()[]{},.;:/\\", ch) != NULL;
+}
+
+const int
starts_with(const char* s, const char* with)
{
while (*s && *s == *with)
diff --git a/util.h b/util.h
@@ -26,8 +26,6 @@ enum {
#define MAXPATH 1024
/* maximum chars for UTF-8 representations of Unicode chars, per Unicode char */
#define UTF8REPMAX 6
-#define u32_is_word_boundary(ch, strictly_whitespace) \
- (is_word_boundary((char)(ch), strictly_whitespace))
size_t u8_string_to_unicode(uint32_t* us, const char* s, const size_t max);
size_t unicode_string_to_u8(char* s, const uint32_t* us, const size_t max);
@@ -50,6 +48,7 @@ size_t u32_lines_in_string(const uint32_t* s, const int include_eol,
size_t u32_next_line(const uint32_t* s, const uint32_t** sptr,
const int include_eol, const size_t wrap);
const int is_word_boundary(const char ch, const int strictly_whitespace);
+const int u32_is_word_boundary(const uint32_t ch, const int strictly_whitespace);
const int starts_with(const char* s, const char* with);
const int u32_starts_with(const uint32_t* s, const uint32_t* with);
const char* u8_basename(const char* path);