diff options
author | xhe <xw897002528@gmail.com> | 2017-05-19 23:05:55 +0800 |
---|---|---|
committer | xhe <xw897002528@gmail.com> | 2017-05-19 23:36:43 +0800 |
commit | 06ddb2e43589b91da2117a32ca92f3277d3f748e (patch) | |
tree | e23696385005d6bbb72417371283f471f6b62a72 | |
parent | da61df16f67273c1f1a9aac8b3f9fc7127d62e44 (diff) | |
download | gettext-tiny-06ddb2e43589b91da2117a32ca92f3277d3f748e.tar.gz |
be more sensitive on abort:
here the input, msgid foo; #xxx ; msgid foo2
exception: switch(msgid, msgid) == abort
reality: after go through #xxx, it's now switch(invalid, msgid) == la_incr
so one more value, prev_rtype is here to fix the issue
-rw-r--r-- | src/poparser.c | 5 | ||||
-rw-r--r-- | src/poparser.h | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/poparser.c b/src/poparser.c index 23cf509..5a2f9b2 100644 --- a/src/poparser.c +++ b/src/poparser.c @@ -96,6 +96,7 @@ void poparser_init(struct po_parser *p, char* workbuf, size_t bufsize, poparser_ p->bufsize = bufsize; p->cb = cb; p->prev_type = pe_invalid; + p->prev_rtype = pe_invalid; p->curr_len = 0; p->cbdata = cbdata; *(p->info.charset) = 0; @@ -173,6 +174,10 @@ int poparser_feed_line(struct po_parser *p, char* line, size_t buflen) { enum po_entry type; type = get_type_and_start(&p->info, line, line + buflen, &strstart); + if(p->prev_rtype != pe_invalid && action_tbl[p->prev_rtype][type] == la_abort) + abort(); + if(type != pe_invalid && type != pe_str) + p->prev_rtype = type; if(fuzzymark) { if(type == pe_ctxt && fuzzymark == 1) fuzzymark--; if(type == pe_msgid) fuzzymark--; diff --git a/src/poparser.h b/src/poparser.h index dfe6107..29b7b16 100644 --- a/src/poparser.h +++ b/src/poparser.h @@ -28,6 +28,7 @@ struct po_parser { char *buf; size_t bufsize; enum po_entry prev_type; + enum po_entry prev_rtype; unsigned curr_len; poparser_callback cb; void *cbdata; |