summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxhe <xw897002528@gmail.com>2017-04-02 20:22:06 +0800
committerxhe <xw897002528@gmail.com>2017-05-06 13:03:23 +0800
commitffa22a010fbbf330c5c8de41077f36415c16d38a (patch)
tree95deb59fd65468a0354b245b136b5ca1f5e39524
parentbc609db0f9d7f35a4967cac0f34590ea5f9ada3c (diff)
downloadgettext-tiny-ffa22a010fbbf330c5c8de41077f36415c16d38a.tar.gz
skip fuzzy marked strings
-rw-r--r--src/poparser.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/poparser.c b/src/poparser.c
index 5efa5d8..3e257eb 100644
--- a/src/poparser.c
+++ b/src/poparser.c
@@ -9,12 +9,18 @@
#define streq(A, B) (!strcmp(A, B))
#define strstarts(S, W) (memcmp(S, W, sizeof(W) - 1) ? NULL : (S + (sizeof(W) - 1)))
+static unsigned fuzzymark = 0;
static enum po_entry get_type_and_start(struct po_info *info, char* lp, char* end, size_t *stringstart) {
enum po_entry result_type;
char *x, *y;
size_t start = (size_t) lp;
while(isspace(*lp) && lp < end) lp++;
if(lp[0] == '#') {
+ char *s;
+ if(s = strstr(lp, "fuzzy")) {
+ if(fuzzymark != 0) fuzzymark++;
+ else fuzzymark=2;
+ }
inv:
*stringstart = 0;
return pe_invalid;
@@ -93,6 +99,7 @@ void poparser_init(struct po_parser *p, char* workbuf, size_t bufsize, poparser_
*(p->info.charset) = 0;
// nplurals = 2 by default
p->info.nplurals = 50;
+ fuzzymark = 0;
}
enum lineactions {
@@ -151,6 +158,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(fuzzymark) {
+ if(type == pe_msgid) fuzzymark--;
+ if(fuzzymark > 0) return 0;
+ }
switch(action_tbl[p->prev_type][type]) {
case la_incr:
assert(type == pe_msgid || type == pe_msgstr || type == pe_str || type == pe_plural);