[Xfce4-commits] <midori:master> katze_array_find_token may yield token without keywords

Christian Dywan noreply at xfce.org
Thu Mar 1 20:20:02 CET 2012


Updating branch refs/heads/master
         to 7e61fce9caa0a81782dc9b3f8f2bc089da34c034 (commit)
       from df8284f6500d09fa2d0b741a7003f6065cb7cbe6 (commit)

commit 7e61fce9caa0a81782dc9b3f8f2bc089da34c034
Author: Christian Dywan <christian at twotoasts.de>
Date:   Wed Feb 29 22:58:16 2012 +0100

    katze_array_find_token may yield token without keywords
    
    Also adapt the magic uri test.

 midori/midori-browser.c |    6 +++++-
 tests/magic-uri.c       |   24 ++++++++++--------------
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index a121689..c1e90c8 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -3676,7 +3676,11 @@ _action_location_submit_uri (GtkAction*     action,
         if (browser->search_engines
          && (item = katze_array_find_token (browser->search_engines, uri)))
         {
-            keywords = strchr (uri, ' ') + 1;
+            keywords = strchr (uri, ' ');
+            if (keywords != NULL)
+                keywords++;
+            else
+                keywords = "";
             search_uri = katze_item_get_uri (item);
         }
 
diff --git a/tests/magic-uri.c b/tests/magic-uri.c
index d596dd5..46dbdda 100644
--- a/tests/magic-uri.c
+++ b/tests/magic-uri.c
@@ -41,26 +41,22 @@ test_input (const gchar* input,
     uri = sokoke_magic_uri (input);
     if (!uri)
     {
-        gchar** parts;
-        gchar* keywords = NULL;
+        const gchar* keywords = NULL;
         const gchar* search_uri = NULL;
+        KatzeItem* item;
 
         /* Do we have a keyword and a string? */
-        parts = g_strsplit (input, " ", 2);
-        if (parts[0])
+        if ((item = katze_array_find_token (search_engines, input)))
         {
-            KatzeItem* item;
-            if ((item = katze_array_find_token (search_engines, parts[0])))
-            {
-                keywords = g_strdup (parts[1] ? parts[1] : "");
-                search_uri = katze_item_get_uri (item);
-            }
+            keywords = strchr (input, ' ');
+            if (keywords != NULL)
+                keywords++;
+            else
+                keywords = "";
+            search_uri = katze_item_get_uri (item);
         }
-        g_strfreev (parts);
-
-        uri = keywords ? midori_uri_for_search (search_uri, keywords) : NULL;
 
-        g_free (keywords);
+        uri = search_uri ? midori_uri_for_search (search_uri, keywords) : NULL;
     }
     katze_assert_str_equal (input, uri, expected);
     g_free (uri);


More information about the Xfce4-commits mailing list