1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*
* "$Id: testlang.c 6649 2007-07-11 21:46:42Z mike $"
*
* Localization test program for the Common UNIX Printing System (CUPS).
*
* Copyright 2007 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
* property of Apple Inc. and are protected by Federal copyright
* law. Distribution and use rights are outlined in the file "LICENSE.txt"
* which should have been included with this file. If this file is
* file is missing or damaged, see the license at "http://www.cups.org/".
*
* This file is subject to the Apple OS-Developed Software exception.
*
* Contents:
*
* main() - Load the specified language and show the strings for yes and no.
*/
/*
* Include necessary headers...
*/
#include <stdio.h>
#include "i18n.h"
#include "string.h"
/*
* 'main()' - Load the specified language and show the strings for yes and no.
*/
int /* O - Exit status */
main(int argc, /* I - Number of command-line arguments */
char *argv[]) /* I - Command-line arguments */
{
int i; /* Looping var */
int errors = 0; /* Number of errors */
cups_lang_t *language; /* Message catalog */
cups_lang_t *language2; /* Message catalog */
struct lconv *loc; /* Locale data */
char buffer[1024]; /* String buffer */
double number; /* Number */
static const char * const tests[] = /* Test strings */
{
"1",
"-1",
"3",
"5.125"
};
_cupsSetLocale(argv);
if (argc == 1)
{
language = cupsLangDefault();
language2 = cupsLangDefault();
}
else
{
language = cupsLangGet(argv[1]);
language2 = cupsLangGet(argv[1]);
}
if (language != language2)
{
errors ++;
puts("**** ERROR: Language cache did not work! ****");
puts("First result from cupsLangGet:");
}
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"));
if (language != language2)
{
puts("Second result from cupsLangGet:");
printf("Language = \"%s\"\n", language2->language);
printf("Encoding = \"%s\"\n", _cupsEncodingName(language2->encoding));
printf("No = \"%s\"\n", _cupsLangString(language2, "No"));
printf("Yes = \"%s\"\n", _cupsLangString(language2, "Yes"));
}
loc = localeconv();
for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i ++)
{
number = _cupsStrScand(tests[i], NULL, loc);
printf("_cupsStrScand(\"%s\") number=%f\n", tests[i], number);
_cupsStrFormatd(buffer, buffer + sizeof(buffer), number, loc);
printf("_cupsStrFormatd(%f) buffer=\"%s\"\n", number, buffer);
if (strcmp(buffer, tests[i]))
{
errors ++;
puts("**** ERROR: Bad formatted number! ****");
}
}
return (errors > 0);
}
/*
* End of "$Id: testlang.c 6649 2007-07-11 21:46:42Z mike $".
*/
|