X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fglib-compile-schemas.c;h=e42949b85d540ba7c52c264faacce3bdee7da5d8;hb=4482977238ae80f64c2fe318d1500f4662c73980;hp=48674742186943626e7d174a1a209eb30d6194e3;hpb=f8cb2a60b9fb79f4d3719f842d71245d844ee9c0;p=platform%2Fupstream%2Fglib.git diff --git a/gio/glib-compile-schemas.c b/gio/glib-compile-schemas.c index 4867474..e42949b 100644 --- a/gio/glib-compile-schemas.c +++ b/gio/glib-compile-schemas.c @@ -12,28 +12,44 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * License along with this library; if not, see . * * Author: Ryan Lortie */ /* Prologue {{{1 */ -#define _GNU_SOURCE #include "config.h" #include -#include +#include + #include -#include #include - -#include +#include #include "gvdb/gvdb-builder.h" #include "strinfo.c" +#ifdef G_OS_WIN32 +#include "glib/glib-private.h" +#endif + +static void +strip_string (GString *string) +{ + gint i; + + for (i = 0; g_ascii_isspace (string->str[i]); i++); + g_string_erase (string, 0, i); + + if (string->len > 0) + { + /* len > 0, so there must be at least one non-whitespace character */ + for (i = string->len - 1; g_ascii_isspace (string->str[i]); i--); + g_string_truncate (string, i + 1); + } +} + /* Handling of {{{1 */ typedef struct { @@ -51,7 +67,7 @@ enum_state_free (gpointer data) g_slice_free (EnumState, state); } -EnumState * +static EnumState * enum_state_new (gboolean is_flags) { EnumState *state; @@ -107,6 +123,12 @@ enum_state_add_value (EnumState *state, return; } + /* Silently drop the null case if it is mentioned. + * It is properly denoted with an empty array. + */ + if (state->is_flags && value == 0) + return; + if (state->is_flags && (value & (value - 1))) { g_set_error (error, G_MARKUP_ERROR, @@ -121,7 +143,6 @@ enum_state_add_value (EnumState *state, * If we loosen the one-bit-set restriction we need an overlap check. */ - strinfo_builder_append_item (state->strinfo, nick, value); } @@ -135,9 +156,10 @@ enum_state_end (EnumState **state_ptr, *state_ptr = NULL; if (state->strinfo->len == 0) - g_set_error_literal (error, - G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, - " must contain at least one "); + g_set_error (error, + G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, + "<%s> must contain at least one ", + state->is_flags ? "flags" : "enum"); } /* Handling of {{{1 */ @@ -322,6 +344,23 @@ key_state_set_range (KeyState *state, const gchar *max_str, GError **error) { + const struct { + const gchar type; + const gchar *min; + const gchar *max; + } table[] = { + { 'y', "0", "255" }, + { 'n', "-32768", "32767" }, + { 'q', "0", "65535" }, + { 'i', "-2147483648", "2147483647" }, + { 'u', "0", "4294967295" }, + { 'x', "-9223372036854775808", "9223372036854775807" }, + { 't', "0", "18446744073709551615" }, + { 'd', "-inf", "inf" }, + }; + gboolean type_ok = FALSE; + gint i; + if (state->minimum) { g_set_error_literal (error, G_MARKUP_ERROR, @@ -330,7 +369,16 @@ key_state_set_range (KeyState *state, return; } - if (strchr ("ynqiuxtd", *(char *) state->type) == NULL) + for (i = 0; i < G_N_ELEMENTS (table); i++) + if (*(char *) state->type == table[i].type) + { + min_str = min_str ? min_str : table[i].min; + max_str = max_str ? max_str : table[i].max; + type_ok = TRUE; + break; + } + + if (!type_ok) { gchar *type = g_variant_type_dup_string (state->type); g_set_error (error, G_MARKUP_ERROR, @@ -429,7 +477,7 @@ key_state_start_choices (KeyState *state, { g_set_error_literal (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, - " can not be specified for keys " + " cannot be specified for keys " "tagged as having an enumerated type"); return; } @@ -496,8 +544,7 @@ key_state_start_aliases (KeyState *state, g_set_error_literal (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, " already specified for this key"); - - if (!state->is_flags && !state->is_enum && !state->has_choices) + else if (!state->is_flags && !state->is_enum && !state->has_choices) g_set_error_literal (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, " can only be specified for keys with " @@ -596,6 +643,23 @@ key_state_serialise (KeyState *state) /* translation */ if (state->l10n) { + /* We are going to store the untranslated default for + * runtime translation according to the current locale. + * We need to strip leading and trailing whitespace from + * the string so that it's exactly the same as the one + * that ended up in the .po file for translation. + * + * We want to do this so that + * + * + * ['a', 'b', 'c'] + * + * + * ends up in the .po file like "['a', 'b', 'c']", + * omitting the extra whitespace at the start and end. + */ + strip_string (state->unparsed_default_value); + if (state->l10n_context) { gint len; @@ -623,12 +687,18 @@ key_state_serialise (KeyState *state) if (state->strinfo->len) { GVariant *array; + guint32 *words; gpointer data; gsize size; + gint i; data = state->strinfo->str; size = state->strinfo->len; + words = data; + for (i = 0; i < size / sizeof (guint32); i++) + words[i] = GUINT32_TO_LE (words[i]); + array = g_variant_new_from_data (G_VARIANT_TYPE ("au"), data, size, TRUE, g_free, data); @@ -722,7 +792,7 @@ is_valid_keyname (const gchar *key, { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, _("invalid name '%s': invalid character '%c'; " - "only lowercase letters, numbers and dash ('-') " + "only lowercase letters, numbers and hyphen ('-') " "are permitted."), key, key[i]); return FALSE; } @@ -730,7 +800,7 @@ is_valid_keyname (const gchar *key, if (key[i] == '-' && key[i + 1] == '-') { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, - _("invalid name '%s': two successive dashes ('--') " + _("invalid name '%s': two successive hyphens ('--') " "are not permitted."), key); return FALSE; } @@ -740,14 +810,14 @@ is_valid_keyname (const gchar *key, { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, _("invalid name '%s': the last character may not be a " - "dash ('-')."), key); + "hyphen ('-')."), key); return FALSE; } - if (i > 32) + if (i > 1024) { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, - _("invalid name '%s': maximum length is 32"), key); + _("invalid name '%s': maximum length is 1024"), key); return FALSE; } @@ -842,7 +912,7 @@ schema_state_add_key (SchemaState *state, { g_set_error_literal (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, - _("can not add keys to a 'list-of' schema")); + _("cannot add keys to a 'list-of' schema")); return NULL; } @@ -992,6 +1062,10 @@ typedef struct GHashTable *flags_table; /* string -> EnumState */ GHashTable *enum_table; /* string -> EnumState */ + GSList *this_file_schemas; /* strings: s in this file */ + GSList *this_file_flagss; /* strings: s in this file */ + GSList *this_file_enums; /* strings: s in this file */ + gchar *schemalist_domain; /* the gettext domain */ SchemaState *schema_state; /* non-NULL when inside */ @@ -1028,6 +1102,7 @@ parse_state_start_schema (ParseState *state, GError **error) { SchemaState *extends; + gchar *my_id; if (g_hash_table_lookup (state->schema_table, id)) { @@ -1045,8 +1120,8 @@ parse_state_start_schema (ParseState *state, { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, - _(" extends not yet " - "existing schema '%s'"), id, extends_name); + _(" extends not yet existing " + "schema '%s'"), id, extends_name); return; } } @@ -1061,8 +1136,8 @@ parse_state_start_schema (ParseState *state, { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, - _(" is list of not yet " - "existing schema '%s'"), id, list_of); + _(" is list of not yet existing " + "schema '%s'"), id, list_of); return; } @@ -1127,10 +1202,18 @@ parse_state_start_schema (ParseState *state, return; } + if (path && (g_str_has_prefix (path, "/apps/") || + g_str_has_prefix (path, "/desktop/") || + g_str_has_prefix (path, "/system/"))) + g_printerr ("warning: Schema '%s' has path '%s'. Paths starting with " + "'/apps/', '/desktop/' or '/system/' are deprecated.\n", id, path); + state->schema_state = schema_state_new (path, gettext_domain, extends, extends_name, list_of); - g_hash_table_insert (state->schema_table, g_strdup (id), - state->schema_state); + + my_id = g_strdup (id); + state->this_file_schemas = g_slist_prepend (state->this_file_schemas, my_id); + g_hash_table_insert (state->schema_table, my_id, state->schema_state); } static void @@ -1139,7 +1222,9 @@ parse_state_start_enum (ParseState *state, gboolean is_flags, GError **error) { + GSList **list = is_flags ? &state->this_file_flagss : &state->this_file_enums; GHashTable *table = is_flags ? state->flags_table : state->enum_table; + gchar *my_id; if (g_hash_table_lookup (table, id)) { @@ -1151,7 +1236,10 @@ parse_state_start_enum (ParseState *state, } state->enum_state = enum_state_new (is_flags); - g_hash_table_insert (table, g_strdup (id), state->enum_state); + + my_id = g_strdup (id); + *list = g_slist_prepend (*list, my_id); + g_hash_table_insert (table, my_id, state->enum_state); } /* GMarkup Parser Functions {{{1 */ @@ -1205,7 +1293,9 @@ start_element (GMarkupParseContext *context, OPTIONAL | STRING, "gettext-domain", &gettext_domain, OPTIONAL | STRING, "extends", &extends, OPTIONAL | STRING, "list-of", &list_of)) - parse_state_start_schema (state, id, path, gettext_domain, + parse_state_start_schema (state, id, path, + gettext_domain ? gettext_domain + : state->schemalist_domain, extends, list_of, error); return; } @@ -1295,7 +1385,8 @@ start_element (GMarkupParseContext *context, else if (strcmp (element_name, "range") == 0) { const gchar *min, *max; - if (COLLECT (STRING, "min", &min, STRING, "max", &max)) + if (COLLECT (STRING | OPTIONAL, "min", &min, + STRING | OPTIONAL, "max", &max)) key_state_set_range (state->key_state, min, max, error); return; } @@ -1363,7 +1454,7 @@ start_element (GMarkupParseContext *context, element_name, container); else g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ELEMENT, - _("Element <%s> not allowed at toplevel"), element_name); + _("Element <%s> not allowed at the top level"), element_name); } /* 2}}} */ /* End element {{{2 */ @@ -1390,9 +1481,6 @@ static void schema_state_end (SchemaState **state_ptr, GError **error) { - SchemaState *state; - - state = *state_ptr; *state_ptr = NULL; } @@ -1447,21 +1535,38 @@ text (GMarkupParseContext *context, GError **error) { ParseState *state = user_data; - gsize i; - for (i = 0; i < text_len; i++) - if (!g_ascii_isspace (text[i])) - { - if (state->string) - g_string_append_len (state->string, text, text_len); - - else - g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, - _("text may not appear inside <%s>"), - g_markup_parse_context_get_element (context)); + if (state->string) + { + /* we are expecting a string, so store the text data. + * + * we store the data verbatim here and deal with whitespace + * later on. there are two reasons for that: + * + * 1) whitespace is handled differently depending on the tag + * type. + * + * 2) we could do leading whitespace removal by refusing to + * insert it into state->string if it's at the start, but for + * trailing whitespace, we have no idea if there is another + * text() call coming or not. + */ + g_string_append_len (state->string, text, text_len); + } + else + { + /* string is not expected: accept (and ignore) pure whitespace */ + gsize i; - break; - } + for (i = 0; i < text_len; i++) + if (!g_ascii_isspace (text[i])) + { + g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, + _("text may not appear inside <%s>"), + g_markup_parse_context_get_element (context)); + break; + } + } } /* Write to GVDB {{{1 */ @@ -1480,6 +1585,13 @@ gvdb_pair_init (GvdbPair *pair) typedef struct { + GHashTable *schema_table; + GvdbPair root_pair; +} WriteToFileData; + +typedef struct +{ + GHashTable *schema_table; GvdbPair pair; gboolean l10n; } OutputSchemaData; @@ -1504,6 +1616,11 @@ output_key (gpointer key, if (state->l10n) data->l10n = TRUE; + + if (state->child_schema && + !g_hash_table_lookup (data->schema_table, state->child_schema)) + g_printerr ("warning: undefined reference to \n", + state->child_schema); } static void @@ -1511,6 +1628,7 @@ output_schema (gpointer key, gpointer value, gpointer user_data) { + WriteToFileData *wtf_data = user_data; OutputSchemaData data; GvdbPair *root_pair; SchemaState *state; @@ -1519,8 +1637,9 @@ output_schema (gpointer key, id = key; state = value; - root_pair = user_data; + root_pair = &wtf_data->root_pair; + data.schema_table = wtf_data->schema_table; gvdb_pair_init (&data.pair); data.l10n = FALSE; @@ -1539,7 +1658,7 @@ output_schema (gpointer key, if (state->list_of) gvdb_hash_table_insert_string (data.pair.table, ".list-of", - state->extends_name); + state->list_of); if (data.l10n) gvdb_hash_table_insert_string (data.pair.table, @@ -1552,29 +1671,32 @@ write_to_file (GHashTable *schema_table, const gchar *filename, GError **error) { + WriteToFileData data; gboolean success; - GvdbPair pair; - gvdb_pair_init (&pair); + data.schema_table = schema_table; + + gvdb_pair_init (&data.root_pair); - g_hash_table_foreach (schema_table, output_schema, &pair); + g_hash_table_foreach (schema_table, output_schema, &data); - success = gvdb_table_write_contents (pair.table, filename, + success = gvdb_table_write_contents (data.root_pair.table, filename, G_BYTE_ORDER != G_LITTLE_ENDIAN, error); - g_hash_table_unref (pair.table); + g_hash_table_unref (data.root_pair.table); return success; } /* Parser driver {{{1 */ static GHashTable * -parse_gschema_files (gchar **files, - GError **error) +parse_gschema_files (gchar **files, + gboolean strict) { GMarkupParser parser = { start_element, end_element, text }; ParseState state = { 0, }; const gchar *filename; + GError *error = NULL; state.enum_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, enum_state_free); @@ -1591,28 +1713,64 @@ parse_gschema_files (gchar **files, gchar *contents; gsize size; + if (!g_file_get_contents (filename, &contents, &size, &error)) + { + fprintf (stderr, "%s\n", error->message); + g_clear_error (&error); + continue; + } + context = g_markup_parse_context_new (&parser, - G_MARKUP_PREFIX_ERROR_POSITION, + G_MARKUP_TREAT_CDATA_AS_TEXT | + G_MARKUP_PREFIX_ERROR_POSITION | + G_MARKUP_IGNORE_QUALIFIED, &state, NULL); - if (!g_file_get_contents (filename, &contents, &size, error)) - return NULL; - if (!g_markup_parse_context_parse (context, contents, size, error)) + if (!g_markup_parse_context_parse (context, contents, size, &error) || + !g_markup_parse_context_end_parse (context, &error)) { - g_prefix_error (error, "%s: ", filename); - return NULL; - } + GSList *item; - if (!g_markup_parse_context_end_parse (context, error)) - { - g_prefix_error (error, "%s: ", filename); - return NULL; + /* back out any changes from this file */ + for (item = state.this_file_schemas; item; item = item->next) + g_hash_table_remove (state.schema_table, item->data); + + for (item = state.this_file_flagss; item; item = item->next) + g_hash_table_remove (state.flags_table, item->data); + + for (item = state.this_file_enums; item; item = item->next) + g_hash_table_remove (state.enum_table, item->data); + + /* let them know */ + fprintf (stderr, "%s: %s. ", filename, error->message); + g_clear_error (&error); + + if (strict) + { + /* Translators: Do not translate "--strict". */ + fprintf (stderr, _("--strict was specified; exiting.\n")); + g_hash_table_unref (state.schema_table); + g_hash_table_unref (state.flags_table); + g_hash_table_unref (state.enum_table); + + return NULL; + } + else + fprintf (stderr, _("This entire file has been ignored.\n")); } + /* cleanup */ g_markup_parse_context_free (context); + g_slist_free (state.this_file_schemas); + g_slist_free (state.this_file_flagss); + g_slist_free (state.this_file_enums); + state.this_file_schemas = NULL; + state.this_file_flagss = NULL; + state.this_file_enums = NULL; } + g_hash_table_unref (state.flags_table); g_hash_table_unref (state.enum_table); return state.schema_table; @@ -1638,9 +1796,10 @@ compare_strings (gconstpointer a, static gboolean set_overrides (GHashTable *schema_table, gchar **files, - GError **error) + gboolean strict) { const gchar *filename; + GError *error = NULL; while ((filename = *files++)) { @@ -1649,10 +1808,19 @@ set_overrides (GHashTable *schema_table, gint i; key_file = g_key_file_new (); - if (!g_key_file_load_from_file (key_file, filename, 0, error)) + if (!g_key_file_load_from_file (key_file, filename, 0, &error)) { + fprintf (stderr, "%s: %s. ", filename, error->message); g_key_file_free (key_file); + g_clear_error (&error); + if (!strict) + { + fprintf (stderr, _("Ignoring this file.\n")); + continue; + } + + fprintf (stderr, _("--strict was specified; exiting.\n")); return FALSE; } @@ -1668,16 +1836,11 @@ set_overrides (GHashTable *schema_table, schema = g_hash_table_lookup (schema_table, group); if (schema == NULL) - { - g_set_error (error, G_KEY_FILE_ERROR, - G_KEY_FILE_ERROR_GROUP_NOT_FOUND, - _("No such schema `%s' specified in " - "override file `%s'"), group, filename); - g_key_file_free (key_file); - g_strfreev (groups); - - return FALSE; - } + /* Having the schema not be installed is expected to be a + * common case. Don't even emit an error message about + * that. + */ + continue; keys = g_key_file_get_keys (key_file, group, NULL, NULL); g_assert (keys != NULL); @@ -1693,11 +1856,17 @@ set_overrides (GHashTable *schema_table, if (state == NULL) { - g_set_error (error, G_KEY_FILE_ERROR, - G_KEY_FILE_ERROR_KEY_NOT_FOUND, - _("No such key `%s' in schema `%s' as " - "specified in override file `%s'"), - key, group, filename); + fprintf (stderr, _("No such key '%s' in schema '%s' as " + "specified in override file '%s'"), + key, group, filename); + + if (!strict) + { + fprintf (stderr, _("; ignoring override for this key.\n")); + continue; + } + + fprintf (stderr, _(" and --strict was specified; exiting.\n")); g_key_file_free (key_file); g_strfreev (groups); g_strfreev (keys); @@ -1709,14 +1878,28 @@ set_overrides (GHashTable *schema_table, g_assert (string != NULL); value = g_variant_parse (state->type, string, - NULL, NULL, error); + NULL, NULL, &error); if (value == NULL) { + fprintf (stderr, _("error parsing key '%s' in schema '%s' " + "as specified in override file '%s': " + "%s."), + key, group, filename, error->message); + + g_clear_error (&error); + g_free (string); + + if (!strict) + { + fprintf (stderr, _("Ignoring override for this key.\n")); + continue; + } + + fprintf (stderr, _("--strict was specified; exiting.\n")); g_key_file_free (key_file); g_strfreev (groups); g_strfreev (keys); - g_free (string); return FALSE; } @@ -1726,18 +1909,25 @@ set_overrides (GHashTable *schema_table, if (g_variant_compare (value, state->minimum) < 0 || g_variant_compare (value, state->maximum) > 0) { - g_set_error (error, G_MARKUP_ERROR, - G_MARKUP_ERROR_INVALID_CONTENT, - _("override for key `%s' in schema `%s' in " - "override file `%s' is out of the range " - "given in the schema"), - key, group, filename); + fprintf (stderr, + _("override for key '%s' in schema '%s' in " + "override file '%s' is outside the range " + "given in the schema"), + key, group, filename); - g_key_file_free (key_file); g_variant_unref (value); + g_free (string); + + if (!strict) + { + fprintf (stderr, _("; ignoring override for this key.\n")); + continue; + } + + fprintf (stderr, _(" and --strict was specified; exiting.\n")); + g_key_file_free (key_file); g_strfreev (groups); g_strfreev (keys); - g_free (string); return FALSE; } @@ -1747,18 +1937,25 @@ set_overrides (GHashTable *schema_table, { if (!is_valid_choices (value, state->strinfo)) { - g_set_error (error, G_MARKUP_ERROR, - G_MARKUP_ERROR_INVALID_CONTENT, - _("override for key `%s' in schema `%s' in " - "override file `%s' is not in the list " - "of valid choices"), - key, group, filename); + fprintf (stderr, + _("override for key '%s' in schema '%s' in " + "override file '%s' is not in the list " + "of valid choices"), + key, group, filename); - g_key_file_free (key_file); g_variant_unref (value); + g_free (string); + + if (!strict) + { + fprintf (stderr, _("; ignoring override for this key.\n")); + continue; + } + + fprintf (stderr, _(" and --strict was specified; exiting.\n")); + g_key_file_free (key_file); g_strfreev (groups); g_strfreev (keys); - g_free (string); return FALSE; } @@ -1766,9 +1963,9 @@ set_overrides (GHashTable *schema_table, g_variant_unref (state->default_value); state->default_value = value; + g_free (string); } - g_strfreev (keys); } @@ -1788,15 +1985,15 @@ main (int argc, char **argv) gchar *srcdir; gchar *targetdir = NULL; gchar *target; - gboolean uninstall = FALSE; gboolean dry_run = FALSE; + gboolean strict = FALSE; gchar **schema_files = NULL; gchar **override_files = NULL; GOptionContext *context; GOptionEntry entries[] = { { "targetdir", 0, 0, G_OPTION_ARG_FILENAME, &targetdir, N_("where to store the gschemas.compiled file"), N_("DIRECTORY") }, + { "strict", 0, 0, G_OPTION_ARG_NONE, &strict, N_("Abort on any errors in schemas"), NULL }, { "dry-run", 0, 0, G_OPTION_ARG_NONE, &dry_run, N_("Do not write the gschema.compiled file"), NULL }, - { "uninstall", 0, 0, G_OPTION_ARG_NONE, &uninstall, N_("This option will be removed soon.") }, { "allow-any-name", 0, 0, G_OPTION_ARG_NONE, &allow_any_name, N_("Do not enforce key name restrictions") }, /* These options are only for use in the gschema-compile tests */ @@ -1804,7 +2001,24 @@ main (int argc, char **argv) { NULL } }; +#ifdef G_OS_WIN32 + gchar *tmp; +#endif + setlocale (LC_ALL, ""); + textdomain (GETTEXT_PACKAGE); + +#ifdef G_OS_WIN32 + tmp = _glib_get_locale_dir (); + bindtextdomain (GETTEXT_PACKAGE, tmp); + g_free (tmp); +#else + bindtextdomain (GETTEXT_PACKAGE, GLIB_LOCALE_DIR); +#endif + +#ifdef HAVE_BIND_TEXTDOMAIN_CODESET + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); +#endif context = g_option_context_new (N_("DIRECTORY")); g_option_context_set_translation_domain (context, GETTEXT_PACKAGE); @@ -1817,7 +2031,7 @@ main (int argc, char **argv) error = NULL; if (!g_option_context_parse (context, &argc, &argv, &error)) { - fprintf (stderr, "%s", error->message); + fprintf (stderr, "%s\n", error->message); return 1; } @@ -1864,13 +2078,13 @@ main (int argc, char **argv) if (files->len == 0) { - fprintf (stderr, _("No schema files found: ")); + fprintf (stdout, _("No schema files found: ")); if (g_unlink (target)) - fprintf (stderr, _("doing nothing.\n")); + fprintf (stdout, _("doing nothing.\n")); else - fprintf (stderr, _("removed existing output file.\n")); + fprintf (stdout, _("removed existing output file.\n")); return 0; } @@ -1884,12 +2098,23 @@ main (int argc, char **argv) override_files = (gchar **) g_ptr_array_free (overrides, FALSE); } + if ((table = parse_gschema_files (schema_files, strict)) == NULL) + { + g_free (target); + return 1; + } + + if (override_files != NULL && + !set_overrides (table, override_files, strict)) + { + g_free (target); + return 1; + } - if (!(table = parse_gschema_files (schema_files, &error)) || - (override_files != NULL && !set_overrides (table, override_files, &error)) || - (!dry_run && !write_to_file (table, target, &error))) + if (!dry_run && !write_to_file (table, target, &error)) { fprintf (stderr, "%s\n", error->message); + g_free (target); return 1; }