чување af91c2fc747f16c01a05dc26c354803b3f994230
родитељ c324ce493530ab1318300459dd3dc1e562ce020d
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Tue, 8 Feb 2022 20:03:55 +0100
util.{h,c}: Start work on heuristics matching the ends of msgid/msgstr
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 2, додавања: 20(+), брисања: 9(-)
diff --git a/util.c b/util.c
@@ -58,6 +58,14 @@ unicode_string_to_u8(char* s, const uint32_t* us, const size_t max)
}
size_t
+u32_match_msgid_ending(const uint32_t* msgid, uint32_t* msgstr, size_t max)
+{
+ size_t newlen = 0;
+ /*TODO: WIP*/
+ return newlen;
+}
+
+size_t
u32_encode_tabs(uint32_t* s, size_t max)
{
uint32_t* buf = calloc(max + 1, sizeof(uint32_t));
@@ -225,7 +233,7 @@ u32_lines_in_string(const uint32_t* s, const int include_eol, const size_t wrap)
{
size_t result = 1;
const uint32_t* ps = NULL;
- int last_empty = 0;
+ int last_empty = 0;
if (!s)
return result;
@@ -237,7 +245,7 @@ u32_lines_in_string(const uint32_t* s, const int include_eol, const size_t wrap)
if (*ps)
result++;
}
- if (ps > s + 1 && *(ps-2) == '\\' && *(ps-1) == 'n')
+ if (ps > s + 1 && *(ps - 2) == '\\' && *(ps - 1) == 'n')
last_empty = 1;
return result + last_empty;
}
diff --git a/util.h b/util.h
@@ -18,17 +18,19 @@ enum {
ERR_NO_PLURAL_FORMS
};
-#define MAXBUFLINE 4096
-#define MAXDATEBUF 80
-#define MAXFLAGSBUF (4 + 1)
-#define MAXMSGLINE 1024
-#define MSGDELTA 1024
-#define MAXPATH 1024
+#define MAXBUFLINE 4096
+#define MAXDATEBUF 80
+#define MAXFLAGSBUF (4 + 1)
+#define MAXMSGLINE 1024
+#define MSGDELTA 1024
+#define MAXPATH 1024
/* maximum chars for UTF-8 representations of Unicode chars, per Unicode char */
#define UTF8REPMAX 6
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);
+size_t u32_match_msgid_ending(const uint32_t* msgid, uint32_t* msgstr,
+ size_t max);
size_t u32_encode_tabs(uint32_t* s, size_t max);
size_t u32_decode_tabs(uint32_t* s, size_t max);
size_t u32_strlen(const uint32_t* s);
@@ -38,7 +40,8 @@ size_t u32_strncpy(uint32_t* to, const uint32_t* from, size_t max);
size_t u32_strncat(uint32_t* to, const uint32_t* from, size_t max);
size_t u32_u8_strncpy(uint32_t* to, const char* from, size_t max);
size_t u8_u32_strncpy(char* to, const uint32_t* from, size_t max);
-size_t u32_lines_in_string(const uint32_t* s, const int include_eol, const size_t wrap);
+size_t u32_lines_in_string(const uint32_t* s, const int include_eol,
+ const size_t wrap);
size_t u32_next_line(const uint32_t* s, const uint32_t** sptr,
const int include_eol, const size_t wrap);
int u32_is_word_boundary(const uint32_t ch, const int strictly_whitespace);