/*
- * "$Id: testi18n.c 7560 2008-05-13 06:34:04Z mike $"
+ * Internationalization test for CUPS.
*
- * Internationalization test for CUPS.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * Copyright 2007-2010 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() - Main entry for internationalization test module.
- * print_utf8() - Print UTF-8 string with (optional) message.
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
*/
/*
for (i = 0, encoding = CUPS_AUTO_ENCODING;
i < (int)(sizeof(lang_encodings) / sizeof(lang_encodings[0]));
i ++)
- if (!strcasecmp(lang_encodings[i], argv[2]))
+ if (!_cups_strcasecmp(lang_encodings[i], argv[2]))
{
encoding = (cups_encoding_t)i;
break;
return (0);
}
- /*
- * Make sure we have a symbolic link from the data directory to a
- * "charmaps" directory, and then point the library at it...
- */
-
- if (access("charmaps", 0))
- symlink("../data", "charmaps");
-
- putenv("CUPS_DATADIR=.");
-
/*
* Start with some conversion tests from a UTF-8 test file.
*/
fclose(fp);
- /*
- * Test charmap load for ISO-8859-1...
- */
-
- fputs("_cupsCharmapGet(CUPS_ISO8859_1): ", stdout);
-
- if (!_cupsCharmapGet(CUPS_ISO8859_1))
- {
- errors ++;
- puts("FAIL");
- }
- else
- puts("PASS");
-
- /*
- * Test charmap load for Windows-932 (Shift-JIS)...
- */
-
- fputs("_cupsCharmapGet(CUPS_WINDOWS_932): ", stdout);
-
- if (!_cupsCharmapGet(CUPS_WINDOWS_932))
- {
- errors ++;
- puts("FAIL");
- }
- else
- puts("PASS");
-
- /*
- * Test VBCS charmap load for EUC-JP...
- */
-
- fputs("_cupsCharmapGet(CUPS_EUC_JP): ", stdout);
-
- if (!_cupsCharmapGet(CUPS_EUC_JP))
- {
- errors ++;
- puts("FAIL");
- }
- else
- puts("PASS");
-
- /*
- * Test VBCS charmap load for EUC-TW...
- */
-
- fputs("_cupsCharmapGet(CUPS_EUC_TW): ", stdout);
-
- if (!_cupsCharmapGet(CUPS_EUC_TW))
- {
- errors ++;
- puts("FAIL");
- }
- else
- puts("PASS");
-
/*
* Test UTF-8 to legacy charset (ISO 8859-1)...
*/
fputs("cupsCharsetToUTF8(CUPS_ISO8859_1): ", stdout);
- strcpy(legsrc, legdest);
+ strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_ISO8859_1);
- if (len != strlen((char *)utf8latin))
+ if ((size_t)len != strlen((char *)utf8latin))
{
printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8latin));
print_utf8(" utf8latin", utf8latin);
print_utf8(" utf8dest", utf8dest);
errors ++;
}
- else if (memcmp(utf8latin, utf8dest, len))
+ else if (memcmp(utf8latin, utf8dest, (size_t)len))
{
puts("FAIL (results do not match)");
print_utf8(" utf8latin", utf8latin);
fputs("cupsCharsetToUTF8(CUPS_ISO8859_7): ", stdout);
- strcpy(legsrc, legdest);
+ strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_ISO8859_7);
- if (len != strlen((char *)utf8greek))
+ if ((size_t)len != strlen((char *)utf8greek))
{
printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8greek));
print_utf8(" utf8greek", utf8greek);
print_utf8(" utf8dest", utf8dest);
errors ++;
}
- else if (memcmp(utf8greek, utf8dest, len))
+ else if (memcmp(utf8greek, utf8dest, (size_t)len))
{
puts("FAIL (results do not match)");
print_utf8(" utf8greek", utf8greek);
fputs("cupsCharsetToUTF8(CUPS_WINDOWS_932): ", stdout);
- strcpy(legsrc, legdest);
+ strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_WINDOWS_932);
- if (len != strlen((char *)utf8japan))
+ if ((size_t)len != strlen((char *)utf8japan))
{
printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8japan));
print_utf8(" utf8japan", utf8japan);
print_utf8(" utf8dest", utf8dest);
errors ++;
}
- else if (memcmp(utf8japan, utf8dest, len))
+ else if (memcmp(utf8japan, utf8dest, (size_t)len))
{
puts("FAIL (results do not match)");
print_utf8(" utf8japan", utf8japan);
puts("PASS");
}
+#ifndef __linux
fputs("cupsCharsetToUTF8(CUPS_EUC_JP): ", stdout);
- strcpy(legsrc, legdest);
+ strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_EUC_JP);
- if (len != strlen((char *)utf8japan))
+ if ((size_t)len != strlen((char *)utf8japan))
{
printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8japan));
print_utf8(" utf8japan", utf8japan);
print_utf8(" utf8dest", utf8dest);
errors ++;
}
- else if (memcmp(utf8japan, utf8dest, len))
+ else if (memcmp(utf8japan, utf8dest, (size_t)len))
{
puts("FAIL (results do not match)");
print_utf8(" utf8japan", utf8japan);
}
else
puts("PASS");
+#endif /* !__linux */
/*
* Test UTF-8 to/from legacy charset (Windows 950)...
fputs("cupsCharsetToUTF8(CUPS_WINDOWS_950): ", stdout);
- strcpy(legsrc, legdest);
+ strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_WINDOWS_950);
- if (len != strlen((char *)utf8taiwan))
+ if ((size_t)len != strlen((char *)utf8taiwan))
{
printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8taiwan));
print_utf8(" utf8taiwan", utf8taiwan);
print_utf8(" utf8dest", utf8dest);
errors ++;
}
- else if (memcmp(utf8taiwan, utf8dest, len))
+ else if (memcmp(utf8taiwan, utf8dest, (size_t)len))
{
puts("FAIL (results do not match)");
print_utf8(" utf8taiwan", utf8taiwan);
fputs("cupsCharsetToUTF8(CUPS_EUC_TW): ", stdout);
- strcpy(legsrc, legdest);
+ strlcpy(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_EUC_TW);
- if (len != strlen((char *)utf8taiwan))
+ if ((size_t)len != strlen((char *)utf8taiwan))
{
printf("FAIL (len=%d, expected %d)\n", len, (int)strlen((char *)utf8taiwan));
print_utf8(" utf8taiwan", utf8taiwan);
print_utf8(" utf8dest", utf8dest);
errors ++;
}
- else if (memcmp(utf8taiwan, utf8dest, len))
+ else if (memcmp(utf8taiwan, utf8dest, (size_t)len))
{
puts("FAIL (results do not match)");
print_utf8(" utf8taiwan", utf8taiwan);
print_utf8(" utf8good ", utf8good);
print_utf32(" utf32dest", utf32dest);
}
- memcpy (utf32src, utf32dest, (len + 1) * sizeof(cups_utf32_t));
+ memcpy(utf32src, utf32dest, (len + 1) * sizeof(cups_utf32_t));
len = cupsUTF32ToUTF8(utf8dest, utf32src, 1024);
if (len < 0)
return (1);
putchar('\n');
}
-
-
-/*
- * End of "$Id: testi18n.c 7560 2008-05-13 06:34:04Z mike $"
- */