From: Michael Sweet Date: Wed, 9 Aug 2017 17:43:08 +0000 (-0400) Subject: Fix the localization fallback code on macOS (rdar://33583699) X-Git-Tag: v2.2.5~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=997db40489fbcc345cc2165af859c07fbc3e5d46;p=thirdparty%2Fcups.git Fix the localization fallback code on macOS (rdar://33583699) --- diff --git a/CHANGES.md b/CHANGES.md index 62a8b81a99..e88df3b20f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -38,6 +38,7 @@ CHANGES IN CUPS V2.2.5 - CUPS now sends the `Date` HTTP header in IPP requests (rdar://33302034) - The `ippCopyAttribute` function did not copy out-of-band values correctly (rdar://33688003) +- Fixed the localization fallback code on macOS (rdar://33583699) - The `ipptool` program now offers an option to validate response headers. diff --git a/cups/language.c b/cups/language.c index ec10fc77c7..626c1316a1 100644 --- a/cups/language.c +++ b/cups/language.c @@ -1468,8 +1468,8 @@ appleMessageLoad(const char *locale) /* I - Locale ID */ */ strlcpy(baselang, locale, sizeof(baselang)); - if (baselang[3] == '-' || baselang[3] == '_') - baselang[3] = '\0'; + if (baselang[2] == '-' || baselang[2] == '_') + baselang[2] = '\0'; locale = baselang; } diff --git a/cups/testlang.c b/cups/testlang.c index d6c9fddaa6..e205711e63 100644 --- a/cups/testlang.c +++ b/cups/testlang.c @@ -37,6 +37,8 @@ main(int argc, /* I - Number of command-line arguments */ cups_lang_t *language; /* Message catalog */ cups_lang_t *language2; /* Message catalog */ struct lconv *loc; /* Locale data */ + const char *msgid, /* String identifier */ + *msgstr; /* Localized string */ char buffer[1024]; /* String buffer */ double number; /* Number */ static const char * const tests[] = /* Test strings */ @@ -74,8 +76,26 @@ main(int argc, /* I - Number of command-line arguments */ printf("Language = \"%s\"\n", language->language); printf("Encoding = \"%s\"\n", _cupsEncodingName(language->encoding)); - printf("No = \"%s\"\n", _cupsLangString(language, "No")); - printf("Yes = \"%s\"\n", _cupsLangString(language, "Yes")); + + msgid = "No"; + msgstr = _cupsLangString(language, msgid); + if (msgid == msgstr) + { + printf("%-8s = \"%s\" (FAIL)\n", msgid, msgstr); + errors ++; + } + else + printf("%-8s = \"%s\" (PASS)\n", msgid, msgstr); + + msgid = "Yes"; + msgstr = _cupsLangString(language, msgid); + if (msgid == msgstr) + { + printf("%-8s = \"%s\" (FAIL)\n", msgid, msgstr); + errors ++; + } + else + printf("%-8s = \"%s\" (PASS)\n", msgid, msgstr); if (language != language2) {