Merge branch 'wip/smcv/compose-files' into 'master'

Fix Compose handling on big-endian host architectures

Closes #4217

See merge request GNOME/gtk!3902
This commit is contained in:
Matthias Clasen
2021-08-30 12:52:54 +00:00
7 changed files with 45 additions and 12 deletions

View File

@@ -7,7 +7,8 @@
* character data, and definitions for the builtin compose table of GTK.
* Run it like this:
*
* compose-parse Compose sequences chars gtkcomposedata.h
* cpp -DXCOMM='#' Compose.pre | sed -e 's/^ *#/#/' > Compose
* 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.
@@ -15,15 +16,19 @@
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);
}
@@ -31,11 +36,26 @@ main (int argc, char *argv[])
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 *)table->data, 2 * table->data_size, &error))
if (!g_file_set_contents (argv[2], (char *) sequences_le, 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))
/* data_size is the size in guint16 */
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[4], table->char_data, table->n_chars + 1, &error))
g_error ("%s", error->message);
str = g_string_new ("");
@@ -55,10 +75,11 @@ main (int argc, char *argv[])
"\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;
}

View File

@@ -3,7 +3,7 @@
#define MAX_SEQ_LEN 5
#define N_INDEX_SIZE 30
#define DATA_SIZE 16447
#define DATA_SIZE 16477
#define N_CHARS 1241
#endif

Binary file not shown.

View File

@@ -21,6 +21,7 @@ def replace_if_changed(new, old):
os.remove(new)
srcdir = sys.argv[1]
endian = sys.argv[2]
xml = '''<?xml version='1.0' encoding='UTF-8'?>
<gresources>
@@ -84,13 +85,13 @@ for f in get_files('inspector', '.ui'):
xml += '''
<file>inspector/inspector.css</file>
<file>emoji/en.data</file>
<file>compose/sequences</file>
<file alias="compose/sequences">compose/sequences-{0}-endian</file>
<file>compose/chars</file>
</gresource>
</gresources>'''
</gresources>'''.format(endian)
if len(sys.argv) > 2:
outfile = sys.argv[2]
if len(sys.argv) > 3:
outfile = sys.argv[3]
tmpfile = outfile + '~'
with open(tmpfile, 'w') as f:
f.write(xml)

View File

@@ -838,6 +838,7 @@ gtk_gresources_xml = configure_file(output: 'gtk.gresources.xml',
command: [
gen_gtk_gresources_xml,
meson.current_source_dir(),
host_machine.endian(),
'@OUTPUT@'
],
)

View File

@@ -1,7 +1,7 @@
# n_sequences: 4874
# n_sequences: 4884
# max_seq_len: 5
# n_index_size: 30
# data_size: 16447
# data_size: 16477
# n_chars: 1241
<U7ae> <U7e9> : "ΐ" # U390
<U7ae> <U7f5> : "ΰ" # U3b0
@@ -1959,6 +1959,7 @@
<Uff20> <U47> <U2e> : "Ġ" # U120
<Uff20> <U47> <U54> : ">" # U3e
<Uff20> <U47> <U55> : "Ğ" # U11e
<Uff20> <U47> <U75> : "Ğ" # U11e
<Uff20> <U47> <U1a2> : "Ğ" # U11e
<Uff20> <U48> <U2c> : "Ḩ" # U1e28
<Uff20> <U49> <U22> : "Ï" # Ucf
@@ -2512,6 +2513,7 @@
<Uff20> <U67> <U2e> : "ġ" # U121
<Uff20> <U67> <U55> : "ğ" # U11f
<Uff20> <U67> <U74> : ">" # U3e
<Uff20> <U67> <U75> : "ğ" # U11f
<Uff20> <U67> <U1a2> : "ğ" # U11f
<Uff20> <U68> <U2c> : "ḩ" # U1e29
<Uff20> <U69> <U22> : "ï" # Uef
@@ -2611,11 +2613,19 @@
<Uff20> <U75> <U3b> : "ų" # U173
<Uff20> <U75> <U3e> : "û" # Ufb
<Uff20> <U75> <U41> : "Ă" # U102
<Uff20> <U75> <U45> : "Ĕ" # U114
<Uff20> <U75> <U47> : "Ğ" # U11e
<Uff20> <U75> <U49> : "Ĭ" # U12c
<Uff20> <U75> <U4f> : "Ŏ" # U14e
<Uff20> <U75> <U55> : "Ŭ" # U16c
<Uff20> <U75> <U5e> : "û" # Ufb
<Uff20> <U75> <U5f> : "ū" # U16b
<Uff20> <U75> <U60> : "ù" # Uf9
<Uff20> <U75> <U61> : "ă" # U103
<Uff20> <U75> <U65> : "ĕ" # U115
<Uff20> <U75> <U67> : "ğ" # U11f
<Uff20> <U75> <U69> : "ĭ" # U12d
<Uff20> <U75> <U6f> : "ŏ" # U14f
<Uff20> <U75> <U75> : "ŭ" # U16d
<Uff20> <U75> <U7e> : "ũ" # U169
<Uff20> <U75> <Ua8> : "ü" # Ufc