- char *tmp = g_strescape (str, NULL);
- printf ("\"%s\" ", tmp);
- g_free (tmp);
+ while (TRUE)
+ {
+ char c = *str++;
+
+ switch (c)
+ {
+ case '\0':
+ goto done;
+ case '\n':
+ g_string_append (contents, "\\n");
+ break;
+ case '\"':
+ g_string_append (contents, "\\\"");
+ break;
+#ifdef G_OS_WIN32
+ /* Replace backslashes in path with forward slashes, so that
+ * it reads in without problems.
+ */
+ case '\\':
+ g_string_append (contents, "/");
+ break;
+#endif
+ default:
+ g_string_append_c (contents, c);
+ }
+ }
+
+ done:;
+}
+
+static void
+print_escaped (GString *contents, const char *str)
+{
+ g_string_append_c (contents, '"');
+ escape_string (contents, str);
+ g_string_append_c (contents, '"');
+ g_string_append_c (contents, ' ');