fixed typo.

2002-05-06  Sven Neumann  <sven@gimp.org>

	* autogen.sh: fixed typo.

	* app/config/gimpconfig-serialize.[ch] (gimp_config_serialize_value):
	allow to specify whether strings should be escaped.

	* app/config/gimprc.c (gimp_rc_query): don't escape string values.

	* app/config/test-config.c: changed accordingly.
This commit is contained in:
Sven Neumann 2002-05-06 11:04:39 +00:00 committed by Sven Neumann
parent 8eef831956
commit 6747ea3f1f
8 changed files with 74 additions and 30 deletions

View File

@ -1,3 +1,14 @@
2002-05-06 Sven Neumann <sven@gimp.org>
* autogen.sh: fixed typo.
* app/config/gimpconfig-serialize.[ch] (gimp_config_serialize_value):
allow to specify whether strings should be escaped.
* app/config/gimprc.c (gimp_rc_query): don't escape string values.
* app/config/test-config.c: changed accordingly.
2002-05-06 Nathan Summers <rock@gimp.org>
* tools/gimp-mkproxy: added proxy-subst command, which substitutes its

View File

@ -89,7 +89,7 @@ gimp_config_serialize_properties (GObject *object,
g_string_append (str, prop_spec->name);
g_string_append_c (str, ' ');
if (gimp_config_serialize_value (&value, str))
if (gimp_config_serialize_value (&value, str, TRUE))
{
g_string_append (str, ")\n");
write (fd, str->str, str->len);
@ -165,7 +165,7 @@ gimp_config_serialize_changed_properties (GObject *new,
g_string_append (str, prop_spec->name);
g_string_append_c (str, ' ');
if (gimp_config_serialize_value (&new_value, str))
if (gimp_config_serialize_value (&new_value, str, TRUE))
{
g_string_append (str, ")\n");
write (fd, str->str, str->len);
@ -191,6 +191,7 @@ gimp_config_serialize_changed_properties (GObject *new,
* gimp_config_serialize_value:
* @value: a #GValue.
* @str: a #Gstring.
* @escaped: whether to escape string values.
*
* This utility function appends a string representation of #GValue to @str.
*
@ -198,7 +199,8 @@ gimp_config_serialize_changed_properties (GObject *new,
**/
gboolean
gimp_config_serialize_value (const GValue *value,
GString *str)
GString *str,
gboolean escaped)
{
if (G_VALUE_HOLDS_BOOLEAN (value))
{
@ -233,15 +235,22 @@ gimp_config_serialize_value (const GValue *value,
if (G_VALUE_HOLDS_STRING (value))
{
gchar *escaped;
gchar *esc;
const gchar *cstr = g_value_get_string (value);
if (!cstr)
return FALSE;
escaped = g_strescape (cstr, NULL);
g_string_append_printf (str, "\"%s\"", escaped);
g_free (escaped);
if (escaped)
{
esc = g_strescape (cstr, NULL);
g_string_append_printf (str, "\"%s\"", esc);
g_free (esc);
}
else
{
g_string_append (str, cstr);
}
return TRUE;
}

View File

@ -31,6 +31,7 @@ void gimp_config_serialize_changed_properties (GObject *new,
void gimp_config_serialize_unknown_tokens (GObject *object,
gint fd);
gboolean gimp_config_serialize_value (const GValue *value,
GString *str);
GString *str,
gboolean escaped);
#endif /* __GIMP_CONFIG_SERIALIZE_H__ */

View File

@ -208,7 +208,7 @@ gimp_rc_query (GimpRc *rc,
g_value_init (&value, prop_spec->value_type);
g_object_get_property (G_OBJECT (rc), prop_spec->name, &value);
if (gimp_config_serialize_value (&value, str))
if (gimp_config_serialize_value (&value, str, FALSE))
retval = g_string_free (str, FALSE);
else
g_string_free (str, TRUE);

View File

@ -21,6 +21,9 @@
#include "config.h"
#include "stdlib.h"
#include "string.h"
#include <glib-object.h>
#include "libgimpbase/gimplimits.h"
@ -82,7 +85,7 @@ main (int argc,
if (! gimp_config_serialize (G_OBJECT (gimprc), filename, &error))
{
g_print ("%s\n", error->message);
return -1;
return EXIT_FAILURE;
}
g_print (" done.\n\n");
@ -94,7 +97,7 @@ main (int argc,
if (! gimp_config_deserialize (G_OBJECT (gimprc), filename, &error))
{
g_print ("%s\n", error->message);
return -1;
return EXIT_FAILURE;
}
header = "\n Unknown string tokens:\n";
gimp_config_foreach_unknown_token (G_OBJECT (gimprc),
@ -118,7 +121,7 @@ main (int argc,
g_print ("\n Testing gimp_rc_write_changes() ... \n\n");
if (! gimp_rc_write_changes (gimprc2, gimprc, NULL))
return -1;
return EXIT_FAILURE;
g_print ("\n done.\n");
@ -133,26 +136,35 @@ main (int argc,
else
{
g_print ("This test should have failed :-(\n");
return -1;
return EXIT_FAILURE;
}
g_print ("\n Querying for default-comment ... ");
g_print ("\n Querying for \"default-comment\" ... ");
result = gimp_rc_query (gimprc, "default-comment");
if (result)
g_print ("OK, found %s.\n", result);
{
g_print ("OK, found \"%s\".\n", result);
}
else
{
g_print ("failed!\n");
return EXIT_FAILURE;
}
g_free (result);
g_print (" Querying for foobar ... ");
g_print (" Querying for \"foobar\" ... ");
result = gimp_rc_query (gimprc, "foobar");
if (result && strcmp (result, "hadjaha") == 0)
g_print ("OK, found %s.\n", result);
{
g_print ("OK, found \"%s\".\n", result);
}
else
{
g_print ("failed!\n");
return EXIT_FAILURE;
}
g_free (result);
@ -160,7 +172,7 @@ main (int argc,
g_print ("\nFinished test of GimpConfig.\n\n");
return 0;
return EXIT_SUCCESS;
}

View File

@ -37,7 +37,7 @@ DIE=0
echo
echo "You must have glib-gettextize installed to compile $PROJECT."
echo "glib-gettextize is part of glib-2.0, so you should already"
echo "have it. Make sure it is in your PATH".
echo "have it. Make sure it is in your PATH."
DIE=1
}
(intltoolize --version) < /dev/null > /dev/null 2>&1 || {
@ -101,6 +101,7 @@ else
echo "too old! (Need 0.17, have $VER)"
DIE=1
fi
echo
if test "$DIE" -eq 1; then

View File

@ -89,7 +89,7 @@ gimp_config_serialize_properties (GObject *object,
g_string_append (str, prop_spec->name);
g_string_append_c (str, ' ');
if (gimp_config_serialize_value (&value, str))
if (gimp_config_serialize_value (&value, str, TRUE))
{
g_string_append (str, ")\n");
write (fd, str->str, str->len);
@ -165,7 +165,7 @@ gimp_config_serialize_changed_properties (GObject *new,
g_string_append (str, prop_spec->name);
g_string_append_c (str, ' ');
if (gimp_config_serialize_value (&new_value, str))
if (gimp_config_serialize_value (&new_value, str, TRUE))
{
g_string_append (str, ")\n");
write (fd, str->str, str->len);
@ -191,6 +191,7 @@ gimp_config_serialize_changed_properties (GObject *new,
* gimp_config_serialize_value:
* @value: a #GValue.
* @str: a #Gstring.
* @escaped: whether to escape string values.
*
* This utility function appends a string representation of #GValue to @str.
*
@ -198,7 +199,8 @@ gimp_config_serialize_changed_properties (GObject *new,
**/
gboolean
gimp_config_serialize_value (const GValue *value,
GString *str)
GString *str,
gboolean escaped)
{
if (G_VALUE_HOLDS_BOOLEAN (value))
{
@ -233,15 +235,22 @@ gimp_config_serialize_value (const GValue *value,
if (G_VALUE_HOLDS_STRING (value))
{
gchar *escaped;
gchar *esc;
const gchar *cstr = g_value_get_string (value);
if (!cstr)
return FALSE;
escaped = g_strescape (cstr, NULL);
g_string_append_printf (str, "\"%s\"", escaped);
g_free (escaped);
if (escaped)
{
esc = g_strescape (cstr, NULL);
g_string_append_printf (str, "\"%s\"", esc);
g_free (esc);
}
else
{
g_string_append (str, cstr);
}
return TRUE;
}

View File

@ -31,6 +31,7 @@ void gimp_config_serialize_changed_properties (GObject *new,
void gimp_config_serialize_unknown_tokens (GObject *object,
gint fd);
gboolean gimp_config_serialize_value (const GValue *value,
GString *str);
GString *str,
gboolean escaped);
#endif /* __GIMP_CONFIG_SERIALIZE_H__ */