summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrofl0r <retnyg@gmx.net>2015-09-17 15:18:26 +0100
committerrofl0r <retnyg@gmx.net>2017-03-26 04:57:28 +0100
commit24d6dc9364897de952c1baedb213e4960070bf13 (patch)
treedd81b9e5d58149c01cfedf59268fd08d220cd880
parent438a47cf6da6dba04b04fee983c247cc13430b6c (diff)
downloadgettext-tiny-24d6dc9364897de952c1baedb213e4960070bf13.tar.gz
msgfmt: fix assertion error when msgid_plural is used after msgid
-rw-r--r--src/msgfmt.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/msgfmt.c b/src/msgfmt.c
index 627e106..694b556 100644
--- a/src/msgfmt.c
+++ b/src/msgfmt.c
@@ -179,6 +179,11 @@ static char** sysdep_transform(const char* text, unsigned textlen, unsigned *len
return out;
}
+static void error(const char* msg) {
+ fprintf(stderr, msg);
+ exit(1);
+}
+
int process_line_callback(struct po_info* info, void* user) {
struct callbackdata *d = (struct callbackdata *) user;
assert(info->type == pe_msgid || info->type == pe_msgstr);
@@ -192,13 +197,17 @@ int process_line_callback(struct po_info* info, void* user) {
break;
case pass_second:
sysdeps = sysdep_transform(info->text, info->textlen, &len, &count, 0);
+ if(info->type == pe_msgstr) {
+ // a mismatch of one is allowed, as there may be msgid followed by msgid_plural
+ if((unsigned)(d->curr[pe_msgid] - (d->curr[pe_msgstr] + count)) > 1)
+ error("count of msgid/msgstr mismatch\n");
+ }
for(i=0;i<count;i++) {
l = strlen(sysdeps[i]);
memcpy(d->strbuffer[info->type] + d->stroff[info->type], sysdeps[i], l+1);
if(info->type == pe_msgid)
d->strlist[d->curr[info->type]].str = (struct strtbl){.len=l, .off=d->stroff[info->type]};
else {
- if(!i) assert(d->curr[pe_msgid] == d->curr[pe_msgstr] + count);
d->translist[d->curr[info->type]] = (struct strtbl){.len=l, .off=d->stroff[info->type]};
d->strlist[d->curr[info->type]].trans = &d->translist[d->curr[info->type]];
}