quoted_value is no longer needed
authorVladimir Nadvornik <nadvornik@suse.cz>
Thu, 26 Feb 2009 08:04:52 +0000 (08:04 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Thu, 26 Feb 2009 08:04:52 +0000 (08:04 +0000)
src/collect-io.c
src/filefilter.c
src/filefilter.h
src/misc.c
src/misc.h
src/preferences.c

index 4662d22..74279ab 100644 (file)
@@ -148,8 +148,12 @@ static gint collection_load_private(CollectionData *cd, const gchar *path, Colle
                if (only_geometry) continue;
 
                /* Read filenames */
-               buf = quoted_value(p, NULL);
-               if (buf)
+               while (*p && *p != '"') p++;
+               if (*p) p++;
+               buf = p;
+               while (*p && *p != '"') p++;
+               *p = 0;
+               if (*buf)
                        {
                        gint valid;
 
@@ -158,7 +162,6 @@ static gint collection_load_private(CollectionData *cd, const gchar *path, Colle
 
                        valid = (buf[0] == G_DIR_SEPARATOR && collection_add_check(cd, file_data_new_simple(buf), FALSE, TRUE));
                        if (!valid) DEBUG_1("collection invalid file: %s", buf);
-                       g_free(buf);
 
                        total++;
                        if (!valid)
index 2cd5145..604238a 100644 (file)
@@ -366,7 +366,7 @@ void filter_rebuild(void)
                        }
                }
 
-       sidecar_ext_parse(options->sidecar.ext, FALSE); /* this must be updated after changed file extensions */
+       sidecar_ext_parse(options->sidecar.ext); /* this must be updated after changed file extensions */
 }
 
 static gboolean filter_name_find(GList *filter, const gchar *name)
@@ -511,22 +511,12 @@ static void sidecar_ext_free_list(void)
        sidecar_ext_list = NULL;
 }
 
-void sidecar_ext_parse(const gchar *text, gboolean quoted)
+void sidecar_ext_parse(const gchar *text)
 {
-       gchar *value;
-
        sidecar_ext_free_list();
+       if (text == NULL) return;
 
-       if (quoted)
-               value = quoted_value(text, NULL);
-       else
-               value = (gchar *) text;
-
-       if (value == NULL) return;
-
-       sidecar_ext_list = filter_to_list(value);
-
-       if (quoted) g_free(value);
+       sidecar_ext_list = filter_to_list(text);
 }
 
 
index d783ea8..e1e109c 100644 (file)
@@ -46,7 +46,7 @@ void filter_write_list(GString *outstr, gint indent);
 void filter_load_file_type(const gchar **attribute_names, const gchar **attribute_values);
 
 
-void sidecar_ext_parse(const gchar *text, gboolean quoted);
+void sidecar_ext_parse(const gchar *text);
 gchar *sidecar_ext_to_string(void);
 GList *sidecar_ext_get_list(void);
 
index 79de8b0..dcb4653 100644 (file)
@@ -114,83 +114,6 @@ gchar *expand_tilde(const gchar *filename)
 #endif
 }
 
-/*
-   returns text without quotes or NULL for empty or broken string
-   any text up to first '"' is skipped
-   tail is set to point at the char after the second '"'
-   or at the ending \0
-
-*/
-
-gchar *quoted_value(const gchar *text, const gchar **tail)
-{
-       const gchar *ptr;
-       gint c = 0;
-       gint l = strlen(text);
-       gchar *retval = NULL;
-
-       if (tail) *tail = text;
-
-       if (l == 0) return retval;
-
-       while (c < l && text[c] != '"') c++;
-       if (text[c] == '"')
-               {
-               gint e;
-               c++;
-               ptr = text + c;
-               e = c;
-               while (e < l)
-                       {
-                       if (text[e-1] != '\\' && text[e] == '"') break;
-                       e++;
-                       }
-               if (text[e] == '"')
-                       {
-                       if (e - c > 0)
-                               {
-                               gchar *substring = g_strndup(ptr, e - c);
-
-                               if (substring)
-                                       {
-                                       retval = g_strcompress(substring);
-                                       g_free(substring);
-                                       }
-                               }
-                       }
-               if (tail) *tail = text + e + 1;
-               }
-       else
-               /* for compatibility with older formats (<0.3.7)
-                * read a line without quotes too */
-               {
-               c = 0;
-               while (c < l && text[c] != '\n' && !g_ascii_isspace(text[c])) c++;
-               if (c != 0)
-                       {
-                       retval = g_strndup(text, c);
-                       }
-               if (tail) *tail = text + c;
-               }
-
-       return retval;
-}
-
-gchar *escquote_value(const gchar *text)
-{
-       gchar *e;
-
-       if (!text) return g_strdup("\"\"");
-
-       e = g_strescape(text, "");
-       if (e)
-               {
-               gchar *retval = g_strdup_printf("\"%s\"", e);
-               g_free(e);
-               return retval;
-               }
-       return g_strdup("\"\"");
-}
 
 /* Run a command like system() but may output debug messages. */
 int runcmd(gchar *cmd)
index c4a647b..7c687d5 100644 (file)
@@ -17,8 +17,6 @@ gdouble get_zoom_increment(void);
 gchar *utf8_validate_or_convert(const gchar *text);
 gint utf8_compare(const gchar *s1, const gchar *s2, gboolean case_sensitive);
 gchar *expand_tilde(const gchar *filename);
-gchar *quoted_value(const gchar *text, const gchar **tail);
-gchar *escquote_value(const gchar *text);
 int runcmd(gchar *cmd);
 
 #endif /* MISC_H */
index 0b247f6..83eb389 100644 (file)
@@ -279,7 +279,7 @@ static void config_window_apply(void)
        options->file_filter.disable = c_options->file_filter.disable;
 
        config_entry_to_option(sidecar_ext_entry, &options->sidecar.ext, NULL);
-       sidecar_ext_parse(options->sidecar.ext, FALSE);
+       sidecar_ext_parse(options->sidecar.ext);
 
        options->slideshow.random = c_options->slideshow.random;
        options->slideshow.repeat = c_options->slideshow.repeat;