Skip to content

Commit 68f05b8

Browse files
committed
msgmerge: avoid printing too long line
this is the cause 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.
1 parent adaa9c6 commit 68f05b8

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/msgmerge.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct fiLes {
4747
* i.e. there is no translation lookup at all */
4848
int process_line_callback(po_message_t msg, void* user) {
4949
struct fiLes* file = (struct fiLes*) user;
50-
int i;
50+
int i, j, k;
5151
switch (file->stage) {
5252
case ps_size:
5353
if (msg->ctxt_len > file->len)
@@ -68,25 +68,40 @@ int process_line_callback(po_message_t msg, void* user) {
6868
case ps_parse:
6969
if (msg->ctxt_len) {
7070
escape(msg->ctxt, file->buf, file->len);
71-
fprintf(file->out, "msgctxt \"%s\"\n", file->buf);
71+
fprintf(file->out, "msgctxt \"%.1024s\"\n", file->buf);
72+
k = strlen(file->buf);
73+
for (j = 1024; j < k; j += 1024)
74+
fprintf(file->out, "\"%.1024s\"\n", &file->buf[j]);
7275
}
7376

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

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

8291
if (msg->plural_len) {
8392
for (i=0; i < MAX_NPLURALS && msg->strlen[i]; i++) {
8493
escape(msg->str[i], file->buf, file->len);
85-
fprintf(file->out, "msgstr[%d] \"%s\"\n", i, file->buf);
94+
fprintf(file->out, "msgstr[%d] \"%.1024s\"\n", i, file->buf);
95+
k = strlen(file->buf);
96+
for (j = 1024; j < k; j += 1024)
97+
fprintf(file->out, "\"%.1024s\"\n", &file->buf[j]);
8698
}
8799
} else {
88100
escape(msg->str[0], file->buf, file->len);
89-
fprintf(file->out, "msgstr \"%s\"\n", file->buf);
101+
fprintf(file->out, "msgstr \"%.1024s\"\n", file->buf);
102+
k = strlen(file->buf);
103+
for (j = 1024; j < k; j += 1024)
104+
fprintf(file->out, "\"%.1024s\"\n", &file->buf[j]);
90105
}
91106

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

0 commit comments

Comments
 (0)