static char * handle_gnu_mo(struct cache_pack *cp, struct msg_pack *mp, Gettext_t *gt) { char *result; char *codeset = get_codeset(mp->domain); result = gnu_key_2_text(cp->mnp->msg.gnumsg, codeset, mp); if (mp->plural) { if (((result == mp->msgid1) && (mp->n == 1)) || ((result == mp->msgid2) && (mp->n != 1))) { return (NULL); } } else { if (result == mp->msgid1) { return (NULL); } } gt->c_m_node = cp->mnp; if (!cp->mnp->trusted) { result = check_format(mp->msgid1, result, 0); if (result == mp->msgid1) { DFLTMSG(result, mp->msgid1, mp->msgid2, mp->n, mp->plural); } } return (result); }
static char * handle_type_mo(Msg_node *mnp, struct msg_pack *mp) { char *result; switch (mnp->type) { case T_ILL_MO: /* invalid MO */ return (NULL); case T_SUN_MO: /* Sun MO found */ mp->status |= ST_SUN_MO_FOUND; if (mp->plural) { /* * *ngettext is called against * Sun MO file */ int exp = (mp->n == 1); result = (char *)mp->msgid1; if (!exp) result = (char *)mp->msgid2; return (result); } result = key_2_text(mnp->msg.sunmsg, mp->msgid1); if (!mnp->trusted) { result = check_format(mp->msgid1, result, 0); } return (result); case T_GNU_MO: /* GNU MO found */ mp->status |= ST_GNU_MO_FOUND; result = gnu_key_2_text(mnp->msg.gnumsg, get_codeset(mp->domain), mp); if (result == mp->msgid1 || result == mp->msgid2) { /* no valid msg found */ return (result); } /* valid msg found */ mp->status |= ST_GNU_MSG_FOUND; if (!mnp->trusted) { result = check_format(mp->msgid1, result, 0); if (result == mp->msgid1) { DFLTMSG(result, mp->msgid1, mp->msgid2, mp->n, mp->plural); } } return (result); default: /* this should never happen */ DFLTMSG(result, mp->msgid1, mp->msgid2, mp->n, mp->plural); return (result); } /* NOTREACHED */ }
gboolean is_utf8_native(void) { static gboolean has_run = FALSE; static gboolean is_utf8 = TRUE; const char *codeset; if(has_run) return is_utf8; has_run = TRUE; codeset = get_codeset(); is_utf8 = codeset ? (strcmp(codeset,"UTF-8") == 0||strcmp(codeset,"utf8") == 0):FALSE; return is_utf8; }