poe

Уређивач .po фајлова
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 48f0e736aa6293f940ebe9f66689bcf8802f1784
родитељ 1f716ca719f0d9331ba04a6842456f33dadad82e
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Thu, 10 Feb 2022 15:06:18 +0100

Experimental wrapping logic

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
Mconfig.h | 2+-
Mpo.c | 56+++++++++++++++++++++++++++++++++++---------------------
измењених датотека: 2, додавања: 36(+), брисања: 22(-)

diff --git a/config.h b/config.h @@ -1,6 +1,6 @@ /* See the file LICENSE for copyright and license details. */ -#define SAVE_WRAP_WIDTH 70 +#define SAVE_WRAP_WIDTH 0 #define WRAP_FIRST_MSGSTR 0 #define WARN_COUNT_DOTS 0 diff --git a/po.c b/po.c @@ -603,18 +603,22 @@ save_loop_entries_start: if (current->msgid) { - size_t msgid_size = current->msgid_size * UTF8REPMAX; - size_t num_lines = u32_lines_in_string(current->msgid, 1, - SAVE_WRAP_WIDTH); - if (num_lines > 1) - { - const uint32_t* pumsgid = current->msgid; + size_t msgid_size = current->msgid_size * UTF8REPMAX; + size_t num_lines = u32_lines_in_string(current->msgid, 1, + SAVE_WRAP_WIDTH); + const uint32_t* pumsgid = current->msgid; + size_t len = 0; + + len = u32_next_line(current->msgid, &pumsgid, 1, 0); + if (num_lines > 1 && SAVE_WRAP_WIDTH > 0 + && len > SAVE_WRAP_WIDTH) + { fprintf(output, "msgid \"\"\n"); + pumsgid = current->msgid; while (*pumsgid) { - size_t len = 0; char* u8_msgid = NULL; const uint32_t* old_pumsgid = pumsgid; @@ -653,15 +657,19 @@ save_loop_entries_start: = current->msgid_plural_size * UTF8REPMAX; size_t num_lines = u32_lines_in_string(current->msgid_plural, 1, SAVE_WRAP_WIDTH); - if (num_lines > 1) - { - const uint32_t* pumsgid = current->msgid_plural; + const uint32_t* pumsgid = current->msgid_plural; + size_t len = 0; + + len = u32_next_line(current->msgid_plural, &pumsgid, 1, 0); + if (num_lines > 1 && SAVE_WRAP_WIDTH > 0 + && len > SAVE_WRAP_WIDTH) + { fprintf(output, "msgid_plural \"\"\n"); + pumsgid = current->msgid_plural; while (*pumsgid) { - size_t len = 0; char* u8_msgid = NULL; const uint32_t* old_pumsgid = pumsgid; @@ -696,22 +704,27 @@ save_loop_entries_start: { size_t num_lines = u32_lines_in_string(*current->msgstr, 1, SAVE_WRAP_WIDTH); - if (num_lines > 1) + const uint32_t* pumsgstr = *current->msgstr; + size_t len = 0; + int first_entry = current == entries && !current->msgid; + + len = u32_next_line(*current->msgstr, &pumsgstr, 1, 0); + + if (num_lines > 1 && (first_entry && WRAP_FIRST_MSGSTR) + || (!first_entry && SAVE_WRAP_WIDTH > 0 + && len > SAVE_WRAP_WIDTH)) { - int first_entry = current == entries && !current->msgid; int seen_generator = 0; char now[MAXDATEBUF]; time_t t = time(NULL); struct tm* now_tm = localtime(&t); strftime(now, MAXDATEBUF, "%F %H:%M%z", now_tm); - const uint32_t* pumsgstr = *current->msgstr; - fprintf(output, "msgstr \"\"\n"); + pumsgstr = *current->msgstr; while (*pumsgstr) { - size_t len = 0; char* u8_msgstr = NULL; const uint32_t* old_pumsgstr = pumsgstr; @@ -772,16 +785,17 @@ save_loop_entries_start: { size_t num_lines = u32_lines_in_string(*current->msgstr, 1, SAVE_WRAP_WIDTH); - if (num_lines > 1) - { - const uint32_t* pumsgstr - = *(current->msgstr + m); + const uint32_t* pumsgstr = *(current->msgstr + m); + size_t len = 0; + if (num_lines > 1 && SAVE_WRAP_WIDTH > 0 + && len > SAVE_WRAP_WIDTH) + { fprintf(output, "msgstr[%ld] \"\"\n", m); + pumsgstr = *(current->msgstr + m); while (*pumsgstr) { - size_t len = 0; char* u8_msgstr = NULL; const uint32_t* old_pumsgstr = pumsgstr;