poe

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

чување be4633e3e20bb1ef42448ff9d2356782d45c3276
родитељ 77b9f2fc9f74cb312eafcb643761398d2d8bb4be
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Sat,  3 Jul 2021 19:32:12 +0200

Fixed a bug in parsing msgstr[] when there are multiple line plural msgstr forms

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

Diffstat:
Mpo.c | 11+++++++----
Mpo.h | 3++-
измењених датотека: 2, додавања: 9(+), брисања: 5(-)

diff --git a/po.c b/po.c @@ -185,6 +185,7 @@ load_file(struct PoEntry** entries, size_t* entries_size, char input_line[MAXBUFLINE]; /* lines to tolerate the lack of msgid */ int msgid_counter = PO_DETECTION_LINES; + int msgstr_index = -1; while (!feof(input)) { if (!fgets(input_line, MAXBUFLINE, input)) @@ -197,7 +198,8 @@ load_file(struct PoEntry** entries, size_t* entries_size, int result; if ((result = parse_po_line(input_line, entries, entries_size, entries_count, &entry, &state, - col)) == PARSE_ERR_NONE) + col, &msgstr_index)) == + PARSE_ERR_NONE) { if (state & PS_MSGID) msgid_counter = -1; @@ -233,7 +235,7 @@ save_file(const struct PoEntry* entries, const char* filename) int parse_po_line(const char* line, struct PoEntry** entries, size_t* entries_size, size_t* entries_count, struct PoEntry** current_entry, - ParseState* state, long* col) + ParseState* state, long* col, int* msgstr_index) { size_t i = 0; *col = 1; @@ -275,6 +277,7 @@ parse_po_line(const char* line, struct PoEntry** entries, size_t* entries_size, *state &= ~PS_MSGID; *state &= ~PS_MSGID_PLURAL; *state |= PS_MSGSTR_ARRAY; + (*msgstr_index)++; pline += len; *col += len; @@ -368,6 +371,7 @@ parse_po_line(const char* line, struct PoEntry** entries, size_t* entries_size, ALLOC_DELTA; } init_po_entry(*current_entry); + *msgstr_index = -1; } if (*token) { @@ -378,8 +382,7 @@ parse_po_line(const char* line, struct PoEntry** entries, size_t* entries_size, else if (*state & PS_MSGSTR) set_msgstr(*current_entry, token, 0, 1); else if (*state & PS_MSGSTR_ARRAY) - set_msgstr(*current_entry, token, - (*current_entry)->msgstr_count, 1); + set_msgstr(*current_entry, token, *msgstr_index, 1); else if (*state & PS_COMMENT_DESC) { uint32_t u32_token[MAXCOMMENTLINE]; diff --git a/po.h b/po.h @@ -78,5 +78,6 @@ int load_file(struct PoEntry** entries, size_t* entries_size, int save_file(const struct PoEntry* entries, const char* filename); int parse_po_line(const char* line, struct PoEntry** entries, size_t* entries_size, size_t* entries_count, - struct PoEntry** current_entry, ParseState* state, long* col); + struct PoEntry** current_entry, ParseState* state, long* col, + int* msgstr_index);