changeset 1327:15208b140481

quoted_value is no longer needed
author nadvornik
date Thu, 26 Feb 2009 08:04:52 +0000
parents 2b78c7198fbf
children fb7708d359ea
files src/collect-io.c src/filefilter.c src/filefilter.h src/misc.c src/misc.h src/preferences.c
diffstat 6 files changed, 12 insertions(+), 98 deletions(-) [+]
line wrap: on
line diff
--- a/src/collect-io.c	Wed Feb 25 23:04:08 2009 +0000
+++ b/src/collect-io.c	Thu Feb 26 08:04:52 2009 +0000
@@ -148,8 +148,12 @@
 		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 @@
 
 			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)
--- a/src/filefilter.c	Wed Feb 25 23:04:08 2009 +0000
+++ b/src/filefilter.c	Thu Feb 26 08:04:52 2009 +0000
@@ -366,7 +366,7 @@
 			}
 		}
 
-	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 @@
 	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);
 }
 
 
--- a/src/filefilter.h	Wed Feb 25 23:04:08 2009 +0000
+++ b/src/filefilter.h	Thu Feb 26 08:04:52 2009 +0000
@@ -46,7 +46,7 @@
 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);
 
--- a/src/misc.c	Wed Feb 25 23:04:08 2009 +0000
+++ b/src/misc.c	Thu Feb 26 08:04:52 2009 +0000
@@ -114,83 +114,6 @@
 #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)
--- a/src/misc.h	Wed Feb 25 23:04:08 2009 +0000
+++ b/src/misc.h	Thu Feb 26 08:04:52 2009 +0000
@@ -17,8 +17,6 @@
 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 */
--- a/src/preferences.c	Wed Feb 25 23:04:08 2009 +0000
+++ b/src/preferences.c	Thu Feb 26 08:04:52 2009 +0000
@@ -279,7 +279,7 @@
 	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;