static double FcCompareLang (FcValue *v1, FcValue *v2) { FcLangResult result; FcValue value1 = FcValueCanonicalize(v1), value2 = FcValueCanonicalize(v2); switch (value1.type) { case FcTypeLangSet: switch (value2.type) { case FcTypeLangSet: result = FcLangSetCompare (value1.u.l, value2.u.l); break; case FcTypeString: result = FcLangSetHasLang (value1.u.l, value2.u.s); break; default: return -1.0; } break; case FcTypeString: switch (value2.type) { case FcTypeLangSet: result = FcLangSetHasLang (value2.u.l, value1.u.s); break; case FcTypeString: result = FcLangCompare (value1.u.s, value2.u.s); break; default: return -1.0; } break; default: return -1.0; } switch (result) { case FcLangEqual: return 0; case FcLangDifferentCountry: return 1; case FcLangDifferentLang: default: return 2; } }
static double FcCompareLang (char *object, FcValue value1, FcValue value2) { FcLangResult result; switch (value1.type) { case FcTypeLangSet: switch (value2.type) { case FcTypeLangSet: result = FcLangSetCompare (value1.u.l, value2.u.l); break; case FcTypeString: result = FcLangSetHasLang (value1.u.l, value2.u.s); break; default: return -1.0; } break; case FcTypeString: switch (value2.type) { case FcTypeLangSet: result = FcLangSetHasLang (value2.u.l, value1.u.s); break; case FcTypeString: result = FcLangCompare (value1.u.s, value2.u.s); break; default: return -1.0; } break; default: return -1.0; } switch (result) { case FcLangEqual: return 0; case FcLangDifferentCountry: return 1; case FcLangDifferentLang: default: return 2; } }