diff options
author | xhe <xw897002528@gmail.com> | 2017-05-19 22:59:22 +0800 |
---|---|---|
committer | xhe <xw897002528@gmail.com> | 2017-05-19 23:06:20 +0800 |
commit | 7409501c4cdd4c8d89e6898405816c636a129dc7 (patch) | |
tree | 4ca9f4a87e1c4bddbab54b64fb245cb2a45435d4 | |
parent | e51959b3ea5bedb684b394e37d68d2b916742836 (diff) | |
download | gettext-tiny-7409501c4cdd4c8d89e6898405816c636a129dc7.tar.gz |
fix for nplurals:
do not assign 0 to nplurals, since it's used as a divisor, avoid arithmetical exceptions
-rw-r--r-- | src/poparser.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/poparser.c b/src/poparser.c index bb81d8c..d3314be 100644 --- a/src/poparser.c +++ b/src/poparser.c @@ -24,8 +24,7 @@ static enum po_entry get_type_and_start(struct po_info *info, char* lp, char* en inv: *stringstart = 0; return pe_invalid; - } - if((y = strstarts(lp, "msg"))) { + } else if((y = strstarts(lp, "msg"))) { if((x = strstarts(y, "id")) && isspace(*x)) result_type = pe_msgid; else if ((x = strstarts(y, "id_plural")) && isspace(*x)) @@ -41,7 +40,7 @@ static enum po_entry get_type_and_start(struct po_info *info, char* lp, char* en if(*x != '"') abort(); conv: *stringstart = ((size_t) x - start) + 1; - } else if(*lp == '"') { + } else if(lp[0] == '"') { if(!(*info->charset)) { if(x = strstr(lp, "charset=")) { // charset=xxx\\n @@ -54,7 +53,8 @@ static enum po_entry get_type_and_start(struct po_info *info, char* lp, char* en } } if(x = strstr(lp, "nplurals=")) - info->nplurals = *(x+9) - 0x30; + if(*(x+9) - 0x30) + info->nplurals = *(x+9) - 0x30; result_type = pe_str; x = lp; goto conv; |