+ /* Non-plural-processing gettext forms pass a null pointer as
+ * msgid2 to request that dcngettext suppress plural processing. */
+ if (!msgid2) return (char *)trans;
+
+ if (!p->plural_rule) {
+ const char *rule = "n!=1;";
+ unsigned long np = 2;
+ const char *r = __mo_lookup(p->map, p->map_size, "");
+ char *z;
+ while (r && strncmp(r, "Plural-Forms:", 13)) {
+ z = strchr(r, '\n');
+ r = z ? z+1 : 0;
+ }
+ if (r) {
+ r += 13;
+ while (isspace(*r)) r++;
+ if (!strncmp(r, "nplurals=", 9)) {
+ np = strtoul(r+9, &z, 10);
+ r = z;
+ }
+ while (*r && *r != ';') r++;
+ if (*r) {
+ r++;
+ while (isspace(*r)) r++;
+ if (!strncmp(r, "plural=", 7))
+ rule = r+7;
+ }
+ }
+ a_store(&p->nplurals, np);
+ a_cas_p(&p->plural_rule, 0, (void *)rule);
+ }
+ if (p->nplurals) {
+ unsigned long plural = __pleval(p->plural_rule, n);
+ if (plural > p->nplurals) goto notrans;
+ while (plural--) {
+ size_t rem = p->map_size - (trans - (char *)p->map);
+ size_t l = strnlen(trans, rem);
+ if (l+1 >= rem)
+ goto notrans;
+ trans += l+1;
+ }