New tests.
[mono.git] / eglib / src / gshell.c
index 0a180acbef9c8ab70c1ed719e0f47c33060aac3f..1d0c956d17d3fab14b63f70677c27cc4a38f0d90 100644 (file)
@@ -155,6 +155,9 @@ g_shell_unquote (const gchar *quoted_string, GError **error)
        const char *p;
        int do_unquote = 0;
 
+       if (quoted_string == NULL)
+               return NULL;
+       
        /* Quickly try to determine if we need to unquote or not */
        for (p = quoted_string; *p; p++){
                if (*p == '\'' || *p == '"' || *p == '\\'){
@@ -192,7 +195,6 @@ g_shell_unquote (const gchar *quoted_string, GError **error)
                                                g_set_error (error, 0, 0, "Open quote");
                                                return NULL;
                                        }
-                                       int append = -1;
                                        switch (*p){
                                        case '$':
                                        case '"':
@@ -211,8 +213,7 @@ g_shell_unquote (const gchar *quoted_string, GError **error)
                                return NULL;
                        }
                } else if (*p == '\\'){
-                       p++;
-                       char c = *p;
+                       char c = *(++p);
                        if (!(c == '$' || c == '"' || c == '\\' || c == '`' || c == 0))
                                g_string_append_c (result, '\\');
                        if (c == 0)