diff options
author | xhe <xw897002528@gmail.com> | 2018-12-28 07:21:19 +0800 |
---|---|---|
committer | rofl0r <retnyg@gmx.net> | 2019-01-16 02:38:18 +0000 |
commit | 1d3a2f3b244405b2202cb4571ba7d054ca0ee661 (patch) | |
tree | 909359e431835b49628bece7850d0416c848bf06 | |
parent | 126df240b111944a665d769aca92cab7bccf85ef (diff) | |
download | gettext-tiny-1d3a2f3b244405b2202cb4571ba7d054ca0ee661.tar.gz |
poparser: convert codecs at both two stages
following
https://github.com/sabotage-linux/gettext-tiny/commit/5539eff5d507c619735156fa9e44e0bcf1436695#diff-9657ea17ae7a6e3b985dc974d613664e.
the previous commit did not fix the issue. because the stage one will
not copy anything into message_t. so this time, raw strings are directly
passed to feed_hdr().
-rw-r--r-- | src/poparser.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/poparser.c b/src/poparser.c index 817bf76..831efa3 100644 --- a/src/poparser.c +++ b/src/poparser.c @@ -48,13 +48,10 @@ void poparser_init(struct po_parser *p, char* workbuf, size_t bufsize, poparser_ p->first = true; } -static inline enum po_error poparser_feed_hdr(struct po_parser *p, po_message_t msg) { +static inline enum po_error poparser_feed_hdr(struct po_parser *p, char* msg) { char *x, *y; - if (p->stage == ps_parse && p->first) { - if (msg->id_len) - return -po_invalid_entry; - - if ((x = strstr(msg->str[0], "charset="))) { + if (p->first && msg) { + if ((x = strstr(msg, "charset="))) { for (y = x; *y && !isspace(*y); y++); if ((uintptr_t)(y-x-7) > sizeof(p->hdr.charset)) @@ -70,7 +67,7 @@ static inline enum po_error poparser_feed_hdr(struct po_parser *p, po_message_t } } - if ((x = strstr(msg->str[0], "nplurals="))) { + if ((x = strstr(msg, "nplurals="))) { p->hdr.nplurals = *(x+9) - '0'; } } @@ -79,12 +76,6 @@ static inline enum po_error poparser_feed_hdr(struct po_parser *p, po_message_t } static inline enum po_error poparser_clean(struct po_parser *p, po_message_t msg) { - enum po_error t; - - if ((t = poparser_feed_hdr(p, msg)) != po_success) { - return t; - } - if (p->strcnt) { if (p->first) p->first = false; @@ -187,6 +178,10 @@ enum po_error poparser_feed_line(struct po_parser *p, char* in, size_t in_len) { switch (p->previous) { case po_str: + if ((t = poparser_feed_hdr(p, x)) != po_success) { + return t; + } + cnt = p->strcnt - 1; if (p->stage == ps_parse) { len = unescape(x, &msg->str[cnt][msg->strlen[cnt]], p->max_strlen[cnt]); @@ -328,6 +323,10 @@ enum po_error poparser_feed_line(struct po_parser *p, char* in, size_t in_len) { return -po_excepted_token; } + if ((t = poparser_feed_hdr(p, x)) != po_success) { + return t; + } + if (p->stage == ps_parse) { if (msg->str[cnt] == NULL) { return -po_internal; |