Revision: 1118
http://geeqie.svn.sourceforge.net/geeqie/?rev=1118&view=rev
Author: zas_
Date: 2008-08-31 11:27:24 +0000 (Sun, 31 Aug 2008)
Log Message:
-----------
Move quoted_value() and escquote_value() to misc.[ch].
Modified Paths:
--------------
trunk/src/collect-io.c
trunk/src/filedata.c
trunk/src/filefilter.c
trunk/src/misc.c
trunk/src/misc.h
trunk/src/rcfile.c
trunk/src/rcfile.h
Modified: trunk/src/collect-io.c
===================================================================
--- trunk/src/collect-io.c 2008-08-31 10:51:41 UTC (rev 1117)
+++ trunk/src/collect-io.c 2008-08-31 11:27:24 UTC (rev 1118)
@@ -17,12 +17,11 @@
#include "collect.h"
#include "filedata.h"
#include "layout_util.h"
-#include "rcfile.h"
+#include "misc.h"
#include "secure_save.h"
#include "thumb.h"
#include "ui_fileops.h"
-
#define GQ_COLLECTION_MARKER "#" GQ_APPNAME
#define GQ_COLLECTION_FAIL_MIN 300
Modified: trunk/src/filedata.c
===================================================================
--- trunk/src/filedata.c 2008-08-31 10:51:41 UTC (rev 1117)
+++ trunk/src/filedata.c 2008-08-31 11:27:24 UTC (rev 1118)
@@ -16,8 +16,6 @@
#include "filefilter.h"
#include "cache.h"
-#include "rcfile.h"
-#include "secure_save.h"
#include "thumb_standard.h"
#include "ui_fileops.h"
Modified: trunk/src/filefilter.c
===================================================================
--- trunk/src/filefilter.c 2008-08-31 10:51:41 UTC (rev 1117)
+++ trunk/src/filefilter.c 2008-08-31 11:27:24 UTC (rev 1118)
@@ -15,12 +15,11 @@
#include "filefilter.h"
#include "cache.h"
-#include "rcfile.h"
+#include "misc.h"
#include "secure_save.h"
#include "thumb_standard.h"
#include "ui_fileops.h"
-
/*
*-----------------------------------------------------------------------------
* file filtering
Modified: trunk/src/misc.c
===================================================================
--- trunk/src/misc.c 2008-08-31 10:51:41 UTC (rev 1117)
+++ trunk/src/misc.c 2008-08-31 11:27:24 UTC (rev 1118)
@@ -108,3 +108,81 @@
return g_build_filename(home, G_DIR_SEPARATOR_S, NULL);
#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("\"\"");
+}
Modified: trunk/src/misc.h
===================================================================
--- trunk/src/misc.h 2008-08-31 10:51:41 UTC (rev 1117)
+++ trunk/src/misc.h 2008-08-31 11:27:24 UTC (rev 1118)
@@ -17,5 +17,7 @@
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);
#endif /* MISC_H */
Modified: trunk/src/rcfile.c
===================================================================
--- trunk/src/rcfile.c 2008-08-31 10:51:41 UTC (rev 1117)
+++ trunk/src/rcfile.c 2008-08-31 11:27:24 UTC (rev 1118)
@@ -19,96 +19,19 @@
#include "bar_exif.h"
#include "editors.h"
#include "filefilter.h"
+#include "misc.h"
#include "pixbuf-renderer.h"
#include "secure_save.h"
#include "slideshow.h"
#include "ui_fileops.h"
-
/*
*-----------------------------------------------------------------------------
* line write/parse routines (private)
*-----------------------------------------------------------------------------
*/
-/*
- 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("\"\"");
-}
-
static void write_char_option(SecureSaveInfo *ssi, gchar *label, gchar *text)
{
gchar *escval = escquote_value(text);
Modified: trunk/src/rcfile.h
===================================================================
--- trunk/src/rcfile.h 2008-08-31 10:51:41 UTC (rev 1117)
+++ trunk/src/rcfile.h 2008-08-31 11:27:24 UTC (rev 1118)
@@ -14,9 +14,6 @@
#ifndef RCFILE_H
#define RCFILE_H
-gchar *quoted_value(const gchar *text, const gchar **tail);
-gchar *escquote_value(const gchar *text);
-
gboolean save_options_to(const gchar *utf8_path, ConfOptions *options);
gboolean load_options_from(const gchar *utf8_path, ConfOptions *options);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geeqie-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geeqie-svn