From a96360ad68405304f60636f6048aa2bdf268066d Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Mon, 19 Apr 2010 15:48:30 +0300 Subject: [PATCH] Avoid non-portable API And thus we can build gschema-compile on all platforms, and run it in tests. --- gio/Makefile.am | 6 +----- gio/gschema-compile.c | 34 +++++++++++++++++----------------- gio/tests/Makefile.am | 6 +----- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/gio/Makefile.am b/gio/Makefile.am index 4260900..0c3cace 100644 --- a/gio/Makefile.am +++ b/gio/Makefile.am @@ -495,11 +495,7 @@ gioenumtypes.c: $(gio_headers) gioenumtypes.c.template gio-2.0.lib: libgio-2.0.la gio.def lib -machine:@LIB_EXE_MACHINE_FLAG@ -name:libgio-2.0-$(LT_CURRENT_MINUS_AGE).dll -def:gio.def -out:$@ -bin_PROGRAMS = gio-querymodules - -if OS_UNIX -bin_PROGRAMS += gschema-compile -endif +bin_PROGRAMS = gio-querymodules gschema-compile gio_querymodules_SOURCES = gio-querymodules.c gio_querymodules_LDADD = \ diff --git a/gio/gschema-compile.c b/gio/gschema-compile.c index 1cf51b8..da86106 100644 --- a/gio/gschema-compile.c +++ b/gio/gschema-compile.c @@ -22,7 +22,6 @@ #include #include #include -#include #include "gvdb/gvdb-builder.h" @@ -471,8 +470,9 @@ main (int argc, char **argv) gboolean byteswap = G_BYTE_ORDER != G_LITTLE_ENDIAN; GError *error = NULL; GHashTable *table; - glob_t matched; - gint status; + GDir *dir; + const gchar *file; + GPtrArray *files; gchar *srcdir; gchar *targetdir = NULL; gchar *target; @@ -509,31 +509,31 @@ main (int argc, char **argv) else target = "gschemas.compiled"; - if (chdir (srcdir)) + dir = g_dir_open (srcdir, 0, &error); + if (dir == NULL) { - perror ("chdir"); + fprintf (stderr, "%s\n", error->message); return 1; } - status = glob ("*.gschema.xml", 0, NULL, &matched); - - if (status == GLOB_ABORTED) + files = g_ptr_array_new (); + while ((file = g_dir_read_name (dir)) != NULL) { - perror ("glob"); - return 1; + if (g_str_has_suffix (file, ".gschema.xml")) + { + g_ptr_array_add (files, g_strdup (file)); + } } - else if (status == GLOB_NOMATCH) + + if (files->len == 0) { fprintf (stderr, "no schema files found\n"); return 1; } - else if (status != 0) - { - fprintf (stderr, "unknown glob error\n"); - return 1; - } - if (!(table = parse_gschema_files (matched.gl_pathv, byteswap, &error)) || + g_ptr_array_add (files, NULL); + + if (!(table = parse_gschema_files ((gchar **) files->pdata, byteswap, &error)) || !gvdb_table_write_contents (table, target, byteswap, &error)) { fprintf (stderr, "%s\n", error->message); diff --git a/gio/tests/Makefile.am b/gio/tests/Makefile.am index a0c1499..ae3d110 100644 --- a/gio/tests/Makefile.am +++ b/gio/tests/Makefile.am @@ -148,11 +148,7 @@ gsettings_LDADD = $(progs_ldadd) EXTRA_DIST += org.gtk.test.gschema org.gtk.test.gschema.xml de.po -MISC_STUFF = test.mo - -if OS_UNIX -MISC_STUFF += gschemas.compiled -endif +MISC_STUFF = gschemas.compiled test.mo test.mo: de.po $(MSGFMT) -o test.mo $(srcdir)/de.po; \ -- 2.7.4