Skip to content

Commit

Permalink
msgmerge: avoid printing too long line
Browse files Browse the repository at this point in the history
this is one reason of #50.

One line is generally short, and [8192] is big enough for our usage. But
after cmake invokes msgmerge, lines are joined. So we printf some super
long lines into po files.

And again, cmake invokes msgfmt to use these updated po files. So we
meet these super long lines.
  • Loading branch information
xhebox committed Jan 22, 2020
1 parent fa416e2 commit 2493922
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/msgmerge.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct fiLes {
* i.e. there is no translation lookup at all */
int process_line_callback(po_message_t msg, void* user) {
struct fiLes* file = (struct fiLes*) user;
int i;
int i, j, k;
switch (file->stage) {
case ps_size:
if (msg->ctxt_len > file->len)
Expand All @@ -68,25 +68,40 @@ int process_line_callback(po_message_t msg, void* user) {
case ps_parse:
if (msg->ctxt_len) {
escape(msg->ctxt, file->buf, file->len);
fprintf(file->out, "msgctxt \"%s\"\n", file->buf);
fprintf(file->out, "msgctxt \"%.1024s\"\n", file->buf);
k = strlen(file->buf);
for (j = 1024; j < k; j += 1024)
fprintf(file->out, "\"%.1024s\"\n", &file->buf[j]);
}

escape(msg->id, file->buf, file->len);
fprintf(file->out, "msgid \"%s\"\n", file->buf);
fprintf(file->out, "msgid \"%.1024s\"\n", file->buf);
k = strlen(file->buf);
for (j = 1024; j < k; j += 1024)
fprintf(file->out, "\"%.1024s\"\n", &file->buf[j]);

if (msg->plural_len) {
escape(msg->plural, file->buf, file->len);
fprintf(file->out, "msgid_plural \"%s\"\n", file->buf);
fprintf(file->out, "msgid_plural \"%.1024s\"\n", file->buf);
k = strlen(file->buf);
for (j = 1024; j < k; j += 1024)
fprintf(file->out, "\"%.1024s\"\n", &file->buf[j]);
}

if (msg->plural_len) {
for (i=0; i < MAX_NPLURALS && msg->strlen[i]; i++) {
escape(msg->str[i], file->buf, file->len);
fprintf(file->out, "msgstr[%d] \"%s\"\n", i, file->buf);
fprintf(file->out, "msgstr[%d] \"%.1024s\"\n", i, file->buf);
k = strlen(file->buf);
for (j = 1024; j < k; j += 1024)
fprintf(file->out, "\"%.1024s\"\n", &file->buf[j]);
}
} else {
escape(msg->str[0], file->buf, file->len);
fprintf(file->out, "msgstr \"%s\"\n", file->buf);
fprintf(file->out, "msgstr \"%.1024s\"\n", file->buf);
k = strlen(file->buf);
for (j = 1024; j < k; j += 1024)
fprintf(file->out, "\"%.1024s\"\n", &file->buf[j]);
}

fputc('\n', file->out);
Expand Down

0 comments on commit 2493922

Please sign in to comment.