summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxhe <xw897002528@gmail.com>2020-01-22 21:59:41 +0800
committerxhe <xw897002528@gmail.com>2020-01-23 00:07:48 +0800
commit249392297d1537438118c8bc5039bd59a699a79d (patch)
tree84461fe348ab7c2a3186a580225a703017e35450
parentfa416e2e897614314abcb711069ad19af2a44354 (diff)
downloadgettext-tiny-249392297d1537438118c8bc5039bd59a699a79d.tar.gz
msgmerge: avoid printing too long line
this is one reason of https://github.com/sabotage-linux/gettext-tiny/issues/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.
-rw-r--r--src/msgmerge.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/msgmerge.c b/src/msgmerge.c
index 36420e7..c05412e 100644
--- a/src/msgmerge.c
+++ b/src/msgmerge.c
@@ -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)
@@ -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);