* character data, and definitions for the builtin compose table of GTK.
* Run it like this:
*
- * compose-parse Compose sequences chars gtkcomposedata.h
+ * compose-parse Compose sequences-little-endian sequences-big-endian chars gtkcomposedata.h
*
* The GTK build expects the output files to be in the source tree, in
* the gtk/compose directory.
int
main (int argc, char *argv[])
{
+ const guint16 *sequences_le;
+ const guint16 *sequences_be;
+ guint16 *other_sequences;
GtkComposeTable *table;
GError *error = NULL;
GString *str;
+ gsize i;
setlocale (LC_ALL, "");
if (argc < 5)
{
- g_print ("Usage: compose-parse INPUT OUTPUT1 OUTPUT2 OUTPUT3\n");
+ g_print ("Usage: compose-parse INPUT SEQUENCES-LE SEQUENCES-BE CHARS HEADER\n");
exit (1);
}
if (!table)
g_error ("Failed to parse %s", argv[1]);
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+ sequences_le = other_sequences = g_new0 (guint16, table->data_size);
+ sequences_be = (const guint16 *) table->data;
+#else
+ sequences_le = (const guint16 *) table->data;
+ sequences_be = other_sequences = g_new0 (guint16, table->data_size);
+#endif
+
+ for (i = 0; i < table->data_size; i++)
+ other_sequences[i] = GUINT16_SWAP_LE_BE (table->data[i]);
+
+ /* data_size is the size in guint16 */
+ if (!g_file_set_contents (argv[2], (char *) sequences_le, 2 * table->data_size, &error))
+ g_error ("%s", error->message);
+
/* data_size is the size in guint16 */
- if (!g_file_set_contents (argv[2], (char *)table->data, 2 * table->data_size, &error))
+ if (!g_file_set_contents (argv[3], (char *) sequences_be, 2 * table->data_size, &error))
g_error ("%s", error->message);
- if (!g_file_set_contents (argv[3], table->char_data, table->n_chars + 1, &error))
+ if (!g_file_set_contents (argv[4], table->char_data, table->n_chars + 1, &error))
g_error ("%s", error->message);
str = g_string_new ("");
"\n"
"#endif\n");
- if (!g_file_set_contents (argv[4], str->str, str->len, &error))
+ if (!g_file_set_contents (argv[5], str->str, str->len, &error))
g_error ("%s", error->message);
g_string_free (str, TRUE);
+ g_free (other_sequences);
return 0;
}