/*
* I18N/language support for CUPS.
*
- * Copyright © 2020-2024 by OpenPrinting.
- * Copyright 2007-2017 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright © 2020-2025 by OpenPrinting.
+ * Copyright © 2007-2017 by Apple Inc.
+ * Copyright © 1997-2007 by Easy Software Products.
*
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
- */
-
-/*
- * Include necessary headers...
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more
+ * information.
*/
#include "cups-private.h"
#else
# include <unistd.h>
#endif /* _WIN32 */
-#ifdef HAVE_COREFOUNDATION_H
-# include <CoreFoundation/CoreFoundation.h>
-#endif /* HAVE_COREFOUNDATION_H */
/*
* Local functions...
*/
-
static cups_lang_t *cups_cache_lookup(const char *name, cups_encoding_t encoding);
-static int cups_message_compare(_cups_message_t *m1, _cups_message_t *m2,
- void *data);
+static int cups_message_compare(_cups_message_t *m1, _cups_message_t *m2, void *data);
static _cups_message_t *cups_message_copy(_cups_message_t *m, void *data);
static void cups_message_free(_cups_message_t *m, void *data);
static void cups_message_load(cups_lang_t *lang);
country[0] = '\0';
- if (language == NULL || !language[0] ||
- !strcmp(language, "POSIX"))
+ if (language == NULL || !language[0] || !strcmp(language, "POSIX"))
+ {
cupsCopyString(langname, "C", sizeof(langname));
+ }
else
{
/*
*/
for (ptr = langname; *language; language ++)
+ {
if (*language == '_' || *language == '-' || *language == '.')
break;
else if (ptr < (langname + sizeof(langname) - 1))
*ptr++ = (char)tolower(*language & 255);
+ }
*ptr = '\0';
*/
for (language ++, ptr = country; *language; language ++)
+ {
if (*language == '.')
break;
else if (ptr < (country + sizeof(country) - 1))
*ptr++ = (char)toupper(*language & 255);
+ }
*ptr = '\0';
*/
for (language ++, ptr = charset; *language; language ++)
+ {
if (_cups_isalnum(*language) && ptr < (charset + sizeof(charset) - 1))
*ptr++ = (char)toupper(*language & 255);
+ }
*ptr = '\0';
}
if (charset[0])
{
- for (i = 0;
- i < (int)(sizeof(locale_encodings) / sizeof(locale_encodings[0]));
- i ++)
+ for (i = 0; i < (int)(sizeof(locale_encodings) / sizeof(locale_encodings[0])); i ++)
+ {
if (!_cups_strcasecmp(charset, locale_encodings[i]))
{
encoding = (cups_encoding_t)i;
break;
}
+ }
if (encoding == CUPS_AUTO_ENCODING)
{
*/
for (lang = lang_cache; lang != NULL; lang = lang->next)
+ {
if (lang->used == 0)
break;
+ }
if (lang == NULL)
{
*
* ./testlang [-l locale] [-p ppd] ["String to localize"]
*
- * Copyright © 2020-2024 by OpenPrinting.
+ * Copyright © 2020-2025 by OpenPrinting.
* Copyright © 2007-2017 by Apple Inc.
* Copyright © 1997-2006 by Easy Software Products.
*
printf("language->language: \"%s\"\n", language ? language->language : NULL);
printf("_cupsEncodingName(language): \"%s\"\n", language ? _cupsEncodingName(language->encoding) : NULL);
-#ifndef __APPLE__
errors += test_string(language, "No");
errors += test_string(language, "Yes");
-#endif // !__APPLE__
if (language != language2)
{