summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorxhe <xw897002528@gmail.com>2018-12-07 21:57:23 +0800
committerrofl0r <retnyg@gmx.net>2019-01-16 02:38:18 +0000
commitb4c057ed629ecfb4973769b45b9ab7a9af3224ca (patch)
tree3763c79e7d0b04c7b76111ade98d6d6f2aaeec2b /src
parent29baed6eb3242e88465ac61b908ee4cac93d5cdc (diff)
downloadgettext-tiny-b4c057ed629ecfb4973769b45b9ab7a9af3224ca.tar.gz
msgfmt&poparser: correct length at str table
then length of str table does not include the NULL terminator while translation includes.
Diffstat (limited to 'src')
-rw-r--r--src/msgfmt.c18
-rw-r--r--src/poparser.c2
-rw-r--r--src/poparser.h1
3 files changed, 11 insertions, 10 deletions
diff --git a/src/msgfmt.c b/src/msgfmt.c
index c464620..b4c3633 100644
--- a/src/msgfmt.c
+++ b/src/msgfmt.c
@@ -113,27 +113,27 @@ int process_line_callback(po_message_t msg, void* user) {
if (msg->ctxt_len) {
m = poparser_sysdep(msg->ctxt, &d->buf[0][d->len[0]], j);
- str->len += m;
- d->buf[0][d->len[0]+m-1] = 0x4;
- d->len[0] += m;
+ str->len += m + 1;
+ d->buf[0][d->len[0]+m] = 0x4;
+ d->len[0] += m + 1;
}
m = poparser_sysdep(msg->id, &d->buf[0][d->len[0]], j);
str->len += m;
- d->len[0] += m;
+ d->len[0] += m + 1;
if (msg->plural_len) {
m = poparser_sysdep(msg->plural, &d->buf[0][d->len[0]], j);
- str->len += m;
- d->len[0] += m;
+ str->len += m + 1;
+ d->len[0] += m + 1;
}
trans->off = d->len[1];
- trans->len = 0;
+ trans->len = -1;
for (i=0; msg->strlen[i]; i++) {
m = poparser_sysdep(msg->str[i], &d->buf[1][d->len[1]], j);
- trans->len += m;
- d->len[1] += m;
+ trans->len += m + 1;
+ d->len[1] += m + 1;
}
d->cnt++;
diff --git a/src/poparser.c b/src/poparser.c
index 978f262..7ed00d7 100644
--- a/src/poparser.c
+++ b/src/poparser.c
@@ -407,6 +407,6 @@ size_t poparser_sysdep(const char *in, char *out, int num) {
m = strlen(x);
if (outs)
memcpy(out, x, m+1);
- out += m + 1;
+ out += m;
return out - outs;
}
diff --git a/src/poparser.h b/src/poparser.h
index a4409d3..7d7b419 100644
--- a/src/poparser.h
+++ b/src/poparser.h
@@ -15,6 +15,7 @@ enum sysdep_types {
};
// make sure out has equal or more space than in
+// this add the NULL terminator, but do not count it in size
size_t poparser_sysdep(const char *in, char *out, int num);
struct po_header {