Skip to content

Commit 005b460

Browse files
committed
Fix language tests on macOS.
1 parent d81b4a5 commit 005b460

2 files changed

Lines changed: 21 additions & 22 deletions

File tree

cups/language.c

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
/*
22
* I18N/language support for CUPS.
33
*
4-
* Copyright © 2020-2024 by OpenPrinting.
5-
* Copyright 2007-2017 by Apple Inc.
6-
* Copyright 1997-2007 by Easy Software Products.
4+
* Copyright © 2020-2025 by OpenPrinting.
5+
* Copyright © 2007-2017 by Apple Inc.
6+
* Copyright © 1997-2007 by Easy Software Products.
77
*
8-
* Licensed under Apache License v2.0. See the file "LICENSE" for more information.
9-
*/
10-
11-
/*
12-
* Include necessary headers...
8+
* Licensed under Apache License v2.0. See the file "LICENSE" for more
9+
* information.
1310
*/
1411

1512
#include "cups-private.h"
@@ -22,9 +19,6 @@
2219
#else
2320
# include <unistd.h>
2421
#endif /* _WIN32 */
25-
#ifdef HAVE_COREFOUNDATION_H
26-
# include <CoreFoundation/CoreFoundation.h>
27-
#endif /* HAVE_COREFOUNDATION_H */
2822

2923

3024
/*
@@ -111,10 +105,8 @@ static const char * const lang_encodings[] =
111105
* Local functions...
112106
*/
113107

114-
115108
static cups_lang_t *cups_cache_lookup(const char *name, cups_encoding_t encoding);
116-
static int cups_message_compare(_cups_message_t *m1, _cups_message_t *m2,
117-
void *data);
109+
static int cups_message_compare(_cups_message_t *m1, _cups_message_t *m2, void *data);
118110
static _cups_message_t *cups_message_copy(_cups_message_t *m, void *data);
119111
static void cups_message_free(_cups_message_t *m, void *data);
120112
static void cups_message_load(cups_lang_t *lang);
@@ -422,20 +414,23 @@ cupsLangGet(const char *language) /* I - Language or locale */
422414

423415
country[0] = '\0';
424416

425-
if (language == NULL || !language[0] ||
426-
!strcmp(language, "POSIX"))
417+
if (language == NULL || !language[0] || !strcmp(language, "POSIX"))
418+
{
427419
cupsCopyString(langname, "C", sizeof(langname));
420+
}
428421
else
429422
{
430423
/*
431424
* Copy the parts of the locale string over safely...
432425
*/
433426

434427
for (ptr = langname; *language; language ++)
428+
{
435429
if (*language == '_' || *language == '-' || *language == '.')
436430
break;
437431
else if (ptr < (langname + sizeof(langname) - 1))
438432
*ptr++ = (char)tolower(*language & 255);
433+
}
439434

440435
*ptr = '\0';
441436

@@ -446,10 +441,12 @@ cupsLangGet(const char *language) /* I - Language or locale */
446441
*/
447442

448443
for (language ++, ptr = country; *language; language ++)
444+
{
449445
if (*language == '.')
450446
break;
451447
else if (ptr < (country + sizeof(country) - 1))
452448
*ptr++ = (char)toupper(*language & 255);
449+
}
453450

454451
*ptr = '\0';
455452

@@ -470,8 +467,10 @@ cupsLangGet(const char *language) /* I - Language or locale */
470467
*/
471468

472469
for (language ++, ptr = charset; *language; language ++)
470+
{
473471
if (_cups_isalnum(*language) && ptr < (charset + sizeof(charset) - 1))
474472
*ptr++ = (char)toupper(*language & 255);
473+
}
475474

476475
*ptr = '\0';
477476
}
@@ -498,14 +497,14 @@ cupsLangGet(const char *language) /* I - Language or locale */
498497

499498
if (charset[0])
500499
{
501-
for (i = 0;
502-
i < (int)(sizeof(locale_encodings) / sizeof(locale_encodings[0]));
503-
i ++)
500+
for (i = 0; i < (int)(sizeof(locale_encodings) / sizeof(locale_encodings[0])); i ++)
501+
{
504502
if (!_cups_strcasecmp(charset, locale_encodings[i]))
505503
{
506504
encoding = (cups_encoding_t)i;
507505
break;
508506
}
507+
}
509508

510509
if (encoding == CUPS_AUTO_ENCODING)
511510
{
@@ -553,8 +552,10 @@ cupsLangGet(const char *language) /* I - Language or locale */
553552
*/
554553

555554
for (lang = lang_cache; lang != NULL; lang = lang->next)
555+
{
556556
if (lang->used == 0)
557557
break;
558+
}
558559

559560
if (lang == NULL)
560561
{

cups/testlang.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* ./testlang [-l locale] [-p ppd] ["String to localize"]
77
*
8-
* Copyright © 2020-2024 by OpenPrinting.
8+
* Copyright © 2020-2025 by OpenPrinting.
99
* Copyright © 2007-2017 by Apple Inc.
1010
* Copyright © 1997-2006 by Easy Software Products.
1111
*
@@ -293,10 +293,8 @@ test_language(const char *lang) /* I - Locale language code, NULL for default *
293293
printf("language->language: \"%s\"\n", language ? language->language : NULL);
294294
printf("_cupsEncodingName(language): \"%s\"\n", language ? _cupsEncodingName(language->encoding) : NULL);
295295

296-
#ifndef __APPLE__
297296
errors += test_string(language, "No");
298297
errors += test_string(language, "Yes");
299-
#endif // !__APPLE__
300298

301299
if (language != language2)
302300
{

0 commit comments

Comments
 (0)