summaryrefslogtreecommitdiff
path: root/gtk/queryimmodules.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-07-31 16:54:46 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-07-31 16:54:46 +0000
commit30f84bb85639d9d72a894b4494501a805a86ef6f (patch)
tree880edd76bbf364fbf7fc9a3bf5ce42509f90c396 /gtk/queryimmodules.c
parent0a786328d28c967cf2d2843fd552c664aec2f821 (diff)
downloadgtk+-30f84bb85639d9d72a894b4494501a805a86ef6f.tar.gz
Avoid using g_strescape(), since it mangles UTF-8, (#89479, Yao Zhang.)
Wed Jul 31 12:50:51 2002 Owen Taylor <otaylor@redhat.com> * gtk/queryimmodules.c: Avoid using g_strescape(), since it mangles UTF-8, (#89479, Yao Zhang.)
Diffstat (limited to 'gtk/queryimmodules.c')
-rw-r--r--gtk/queryimmodules.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/gtk/queryimmodules.c b/gtk/queryimmodules.c
index defdb8faf3..1a0f063705 100644
--- a/gtk/queryimmodules.c
+++ b/gtk/queryimmodules.c
@@ -41,10 +41,38 @@
#include "gtk/gtkrc.h"
#include "gtk/gtkimmodule.h"
+static char *
+escape_string (const char *str)
+{
+ GString *result = g_string_new ("");
+
+ while (TRUE)
+ {
+ char c = *str++;
+
+ switch (c)
+ {
+ case '\0':
+ goto done;
+ case '\n':
+ g_string_append (result, "\\n");
+ break;
+ case '\"':
+ g_string_append (result, "\\\"");
+ break;
+ default:
+ g_string_append_c (result, c);
+ }
+ }
+
+ done:
+ return g_string_free (result, FALSE);
+}
+
static void
print_escaped (const char *str)
{
- char *tmp = g_strescape (str, NULL);
+ char *tmp = escape_string (str, NULL);
printf ("\"%s\" ", tmp);
g_free (tmp);
}