epiphany r8359 - branches/gnome-2-24/src



Author: diegoe
Date: Thu Jul 24 20:42:12 2008
New Revision: 8359
URL: http://svn.gnome.org/viewvc/epiphany?rev=8359&view=rev

Log:
Regex instead of pointer voodoo in is_base_address.


Modified:
   branches/gnome-2-24/src/ephy-completion-model.c

Modified: branches/gnome-2-24/src/ephy-completion-model.c
==============================================================================
--- branches/gnome-2-24/src/ephy-completion-model.c	(original)
+++ branches/gnome-2-24/src/ephy-completion-model.c	Thu Jul 24 20:42:12 2008
@@ -355,27 +355,16 @@
 	g_value_take_object (value, pixbuf);
 }
 
+const GRegex *base_address_regex = NULL;
+
 static gboolean
 is_base_address (const char *address)
 {
-	int slashes = 0;
-
-	if (address == NULL) return FALSE;
-
-	while (*address != '\0')
-	{
-		if (*address == '/') slashes++;
-
-		address++;
+    if (base_address_regex == NULL) {
+        base_address_regex = g_regex_new ("//.*/$", G_REGEX_OPTIMIZE, G_REGEX_MATCH_NOTEMPTY, NULL);
+    }
 
-		/* Base uris has 3 slashes like http://www.gnome.org/ */
-		if (slashes == 3)
-		{
-			return (*address == '\0');
-		}
-	}
-
-	return FALSE;
+    return g_regex_match (base_address_regex, address, G_REGEX_MATCH_NOTEMPTY, NULL);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]