1 #undef G_DISABLE_ASSERT
10 int main (int argc
, char **argv
)
15 char *srcdir
= getenv ("srcdir");
21 char *current_locale
= setlocale (LC_CTYPE
, NULL
);
26 filename
= g_strconcat (srcdir
, G_DIR_SEPARATOR_S
, "casemap.txt", NULL
);
28 infile
= fopen (filename
, "r");
31 fprintf (stderr
, "Failed to open %s\n", filename
);
35 while (fgets (buffer
, sizeof(buffer
), infile
))
40 strings
= g_strsplit (buffer
, "\t", -1);
47 if (strcmp (locale
, current_locale
) != 0)
49 setlocale (LC_CTYPE
, locale
);
50 current_locale
= setlocale (LC_CTYPE
, NULL
);
52 if (strncmp (current_locale
, locale
, 2) != 0)
54 fprintf (stderr
, "Cannot set locale to %s, skipping\n", locale
);
61 /* gen-casemap-txt.pl uses an empty string when a single character
62 * doesn't have an equivalent in a particular case; since that behavior
63 * is nonsense for multicharacter strings, it would make more sense
64 * to put the expected result .. the original character unchanged. But
65 * for now, we just work around it here and take the empty string to mean
69 convert
= g_utf8_strup (test
, -1);
70 expected
= strings
[4][0] ? strings
[4] : test
;
71 if (strcmp (convert
, expected
) != 0)
73 fprintf (stderr
, "Failure: toupper(%s) == %s, should have been %s\n",
74 test
, convert
, expected
);
79 convert
= g_utf8_strdown (test
, -1);
80 expected
= strings
[2][0] ? strings
[2] : test
;
81 if (strcmp (convert
, expected
) != 0)
83 fprintf (stderr
, "Failure: tolower(%s) == %s, should have been %s\n",
84 test
, convert
, expected
);
96 filename
= g_strconcat (srcdir
, G_DIR_SEPARATOR_S
, "casefold.txt", NULL
);
98 infile
= fopen (filename
, "r");
101 fprintf (stderr
, "Failed to open %s\n", filename
);
106 while (fgets (buffer
, sizeof(buffer
), infile
))
108 if (buffer
[0] == '#')
111 buffer
[strlen(buffer
) - 1] = '\0';
112 strings
= g_strsplit (buffer
, "\t", -1);
116 convert
= g_utf8_casefold (test
, -1);
117 if (strcmp (convert
, strings
[1]) != 0)
119 fprintf (stderr
, "Failure: casefold(%s) == '%s', should have been '%s'\n",
120 test
, convert
, strings
[1]);
125 g_strfreev (strings
);