mirror of https://github.com/GNOME/gimp.git
app/config/gimpconfig-deserialize.c stricter parsing.
2001-12-10 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-deserialize.c * app/config/gimpconfig.c: stricter parsing. * app/config/test-config.c: more output.
This commit is contained in:
parent
b6461c996c
commit
69ec8e3bd4
|
@ -1,3 +1,10 @@
|
|||
2001-12-10 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/config/gimpconfig-deserialize.c
|
||||
* app/config/gimpconfig.c: stricter parsing.
|
||||
|
||||
* app/config/test-config.c: more output.
|
||||
|
||||
2001-12-09 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* autogen.sh: check for pkg.m4.
|
||||
|
|
|
@ -140,7 +140,7 @@ gimp_config_deserialize_properties (GObject *object,
|
|||
{
|
||||
g_scanner_get_next_token (scanner);
|
||||
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
|
||||
"parse error", TRUE);
|
||||
"Fatal parse error; I'm giving up.", TRUE);
|
||||
}
|
||||
|
||||
if (property_specs)
|
||||
|
@ -204,13 +204,18 @@ gimp_config_deserialize_property (GObject *object,
|
|||
token = gimp_config_deserialize_any (&value, prop_spec, scanner);
|
||||
}
|
||||
|
||||
if (token == G_TOKEN_RIGHT_PAREN)
|
||||
g_object_set_property (object, prop_spec->name, &value);
|
||||
if (token == G_TOKEN_RIGHT_PAREN &&
|
||||
g_scanner_peek_next_token (scanner) == token)
|
||||
{
|
||||
g_object_set_property (object, prop_spec->name, &value);
|
||||
}
|
||||
else
|
||||
g_warning ("Couldn't deserialize property %s::%s of type %s.",
|
||||
g_type_name (G_TYPE_FROM_INSTANCE (object)),
|
||||
prop_spec->name,
|
||||
g_type_name (prop_spec->value_type));
|
||||
{
|
||||
g_warning ("Couldn't deserialize property %s::%s of type %s.",
|
||||
g_type_name (G_TYPE_FROM_INSTANCE (object)),
|
||||
prop_spec->name,
|
||||
g_type_name (prop_spec->value_type));
|
||||
}
|
||||
|
||||
g_value_unset (&value);
|
||||
|
||||
|
|
|
@ -144,8 +144,8 @@ gimp_config_deserialize (GObject *object,
|
|||
|
||||
scanner = g_scanner_new (NULL);
|
||||
|
||||
scanner->config->cset_identifier_first = ( G_CSET_a_2_z "-" G_CSET_A_2_Z );
|
||||
scanner->config->cset_identifier_nth = ( G_CSET_a_2_z "-" G_CSET_A_2_Z );
|
||||
scanner->config->cset_identifier_first = ( G_CSET_a_2_z );
|
||||
scanner->config->cset_identifier_nth = ( G_CSET_a_2_z "-_" );
|
||||
|
||||
g_scanner_input_file (scanner, fd);
|
||||
scanner->input_name = filename;
|
||||
|
|
|
@ -28,8 +28,11 @@
|
|||
|
||||
#define FILENAME "foorc"
|
||||
|
||||
static void notify_callback (GObject *object,
|
||||
GParamSpec *pspec);
|
||||
static void notify_callback (GObject *object,
|
||||
GParamSpec *pspec);
|
||||
static void output_unknown_token (const gchar *key,
|
||||
const gchar *value,
|
||||
gpointer data);
|
||||
|
||||
|
||||
int
|
||||
|
@ -37,6 +40,7 @@ main (int argc,
|
|||
char *argv[])
|
||||
{
|
||||
GimpBaseConfig *config;
|
||||
gboolean header = TRUE;
|
||||
|
||||
g_type_init ();
|
||||
|
||||
|
@ -54,8 +58,11 @@ main (int argc,
|
|||
g_signal_connect (G_OBJECT (config), "notify",
|
||||
G_CALLBACK (notify_callback),
|
||||
NULL);
|
||||
gimp_config_deserialize (G_OBJECT (config), "foorc", TRUE);
|
||||
gimp_config_deserialize (G_OBJECT (config), FILENAME, TRUE);
|
||||
|
||||
gimp_config_foreach_unknown_token (G_OBJECT (config),
|
||||
output_unknown_token, &header);
|
||||
|
||||
g_object_unref (config);
|
||||
|
||||
g_print ("Done.\n");
|
||||
|
@ -95,3 +102,21 @@ notify_callback (GObject *object,
|
|||
g_type_name (G_TYPE_FROM_INSTANCE (object)), pspec->name);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
output_unknown_token (const gchar *key,
|
||||
const gchar *value,
|
||||
gpointer data)
|
||||
{
|
||||
gboolean *header = (gboolean *) data;
|
||||
gchar *escaped = g_strescape (value, NULL);
|
||||
|
||||
if (*header)
|
||||
{
|
||||
g_print (" Unknown string tokens:\n");
|
||||
*header = FALSE;
|
||||
}
|
||||
|
||||
g_print (" %s \"%s\"\n", key, value);
|
||||
g_free (escaped);
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ gimp_config_deserialize_properties (GObject *object,
|
|||
{
|
||||
g_scanner_get_next_token (scanner);
|
||||
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
|
||||
"parse error", TRUE);
|
||||
"Fatal parse error; I'm giving up.", TRUE);
|
||||
}
|
||||
|
||||
if (property_specs)
|
||||
|
@ -204,13 +204,18 @@ gimp_config_deserialize_property (GObject *object,
|
|||
token = gimp_config_deserialize_any (&value, prop_spec, scanner);
|
||||
}
|
||||
|
||||
if (token == G_TOKEN_RIGHT_PAREN)
|
||||
g_object_set_property (object, prop_spec->name, &value);
|
||||
if (token == G_TOKEN_RIGHT_PAREN &&
|
||||
g_scanner_peek_next_token (scanner) == token)
|
||||
{
|
||||
g_object_set_property (object, prop_spec->name, &value);
|
||||
}
|
||||
else
|
||||
g_warning ("Couldn't deserialize property %s::%s of type %s.",
|
||||
g_type_name (G_TYPE_FROM_INSTANCE (object)),
|
||||
prop_spec->name,
|
||||
g_type_name (prop_spec->value_type));
|
||||
{
|
||||
g_warning ("Couldn't deserialize property %s::%s of type %s.",
|
||||
g_type_name (G_TYPE_FROM_INSTANCE (object)),
|
||||
prop_spec->name,
|
||||
g_type_name (prop_spec->value_type));
|
||||
}
|
||||
|
||||
g_value_unset (&value);
|
||||
|
||||
|
|
|
@ -144,8 +144,8 @@ gimp_config_deserialize (GObject *object,
|
|||
|
||||
scanner = g_scanner_new (NULL);
|
||||
|
||||
scanner->config->cset_identifier_first = ( G_CSET_a_2_z "-" G_CSET_A_2_Z );
|
||||
scanner->config->cset_identifier_nth = ( G_CSET_a_2_z "-" G_CSET_A_2_Z );
|
||||
scanner->config->cset_identifier_first = ( G_CSET_a_2_z );
|
||||
scanner->config->cset_identifier_nth = ( G_CSET_a_2_z "-_" );
|
||||
|
||||
g_scanner_input_file (scanner, fd);
|
||||
scanner->input_name = filename;
|
||||
|
|
Loading…
Reference in New Issue