[Xfce4-commits] <midori:master> Handle long lines when importing Opera bookmarks

Christian Dywan noreply at xfce.org
Wed Dec 2 23:50:04 CET 2009


Updating branch refs/heads/master
         to ded15730549e3f30c43191764206193caf9ccb45 (commit)
       from 8c2d74c96611670bb7ae40232c52ab498383873e (commit)

commit ded15730549e3f30c43191764206193caf9ccb45
Author: Christian Dywan <christian at twotoasts.de>
Date:   Wed Dec 2 23:46:34 2009 +0100

    Handle long lines when importing Opera bookmarks

 midori/midori-array.c |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/midori/midori-array.c b/midori/midori-array.c
index e769181..942616c 100644
--- a/midori/midori-array.c
+++ b/midori/midori-array.c
@@ -245,11 +245,13 @@ katze_array_from_opera_file (KatzeArray* array,
                              FILE*       file)
 {
     gchar line[200];
+    gchar* partial_line = NULL;
     KatzeArray* folder = array;
     KatzeItem* item = NULL;
 
     while (fgets (line, 200, file))
     {
+        gboolean incomplete_line = (strlen (line) == 199);
         g_strstrip (line);
         if (line[0] == '\0')
         {
@@ -285,7 +287,31 @@ katze_array_from_opera_file (KatzeArray* array,
         }
         else if (item)
         {
-            gchar** parts = g_strsplit (line, "=", 2);
+            gchar** parts;
+
+            /* Handle lines longer than 200 characters */
+            if (incomplete_line)
+            {
+                if (partial_line)
+                {
+                    gchar* chunk = g_strconcat (partial_line, line, NULL);
+                    katze_assign (partial_line, chunk);
+                }
+                else
+                    partial_line = g_strdup (line);
+                continue;
+            }
+
+            if (partial_line)
+            {
+                gchar* full_line = g_strconcat (partial_line, line, NULL);
+                katze_assign (partial_line, NULL);
+                parts = g_strsplit (full_line, "=", 2);
+                g_free (full_line);
+            }
+            else
+                parts = g_strsplit (line, "=", 2);
+
             if (parts && parts[0] && parts[1])
             {
                 if (katze_str_equal (parts[0], "NAME"))



More information about the Xfce4-commits mailing list