чување 90bd195a8ebacf187745c47893f886b040884cf6
родитељ 7e0b6ab23352d7b5fca4df0f4f4381b66a5df823
Аутор: Страхиња Радић <sr@strahinja.org>
Датум: Sat, 21 Feb 2026 12:03:17 +0100
poe.c(quit_callback): Save msgstr prior to saving file if msgstr was changed; poe.1.in,po.c: Fix typo
Diffstat:
измењених датотека: 3, додавања: 14(+), брисања: 9(-)
diff --git a/po.c b/po.c
@@ -987,7 +987,7 @@ save_msgid(FILE* output, struct DrawState* state, const struct PoEntry* current)
}
num_lines = u32_lines_in_string(current->msgid, 1, wrap_width);
if ((num_lines > 1)
- || u32_strlen(current->msgid) + strlen("msgid: \"") + 1
+ || u32_strlen(current->msgid) + strlen("msgid \"") + 1
> (size_t)literal_break_threshold)
{
pumsgid = current->msgid;
@@ -1050,7 +1050,7 @@ save_msgid_plural(FILE* output, struct DrawState* state,
num_lines = u32_lines_in_string(current->msgid_plural, 1, wrap_width);
if ((num_lines > 1)
|| u32_strlen(current->msgid_plural)
- + strlen("msgid_plural: \"") + 1
+ + strlen("msgid_plural \"") + 1
> (size_t)literal_break_threshold)
{
pumsgid = current->msgid_plural;
@@ -1141,8 +1141,8 @@ save_msgstrs(FILE* output, struct DrawState* state,
num_lines = u32_lines_in_string(current->msgstr[m], 1,
wrap_width);
- llen = (current->msgstr_count == 1 ? strlen("msgstr: \"")
- : strlen("msgstr[ ]: \""))
+ llen = (current->msgstr_count == 1 ? strlen("msgstr \"")
+ : strlen("msgstr[ ] \""))
+ u32_strlen(current->msgstr[m]) + 1;
if ((num_lines > 1) || llen > (size_t)literal_break_threshold)
{
diff --git a/poe.1.in b/poe.1.in
@@ -37,23 +37,23 @@ By default (unless changed in
.Pa config.h Ns ),
if the length of the text
.Bd -literal -offset indent
-msgid: \(dq
+msgid \(dq
.Ed
.Pp
(or
-.Ic "msgid_plural:" ,
-.Ic "msgstr:" ,
+.Ic msgid_plural ,
+.Ic msgstr ,
etc) plus the length of the literal, plus one (for the closing quote) is greater
than
.Va literal_break_threshold ,
a line of the form
.Bd -literal -offset indent
-msgid: \(dqSome really long literal string\(dq
+msgid \(dqSome really long literal string\(dq
.Ed
.Pp
will be broken into two lines:
.Bd -literal -offset indent
-msgid: \(dq\(dq
+msgid \(dq\(dq
\(dqSome really long literal string\(dq
.Ed
.Pp
diff --git a/poe.c b/poe.c
@@ -2252,7 +2252,12 @@ quit_callback(struct DrawState* state, struct tb_event* ev)
int result = 0;
assert((state != NULL) && (ev != NULL));
if (strchr("Yy", ev->ch))
+ {
+ state->reshow_edit = 0;
+ if (state->edit_dirty)
+ save_msgstr(state);
result = write_file(state);
+ }
state->prompt_callback = NULL;
state->running = 0;
return result;