aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--src/bookmarks/ephy-bookmarks.c37
2 files changed, 23 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index e45ef60b4..06ee364e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-02-04 Peter Harvey <peter.a.harvey@gmail.com>
+
+ * src/bookmarks/ephy-bookmarks.c
+
+ Improve code quality of function to determine similar bookmarks.
+
2006-02-03 Christian Persch <chpe@cvs.gnome.org>
* src/ephy-main.c: (main):
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 36a3455d5..35c9e7eab 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -1189,26 +1189,23 @@ ephy_bookmarks_find_bookmark (EphyBookmarks *eb,
static gboolean
is_similar (const char *url1, const char *url2)
{
- while(*url1 == *url2 && *url1 != '\0' &&
- *url1 != '#' && *url1 != '?')
- {
- url1++;
- url2++;
- }
- if(*url1 == *url2) return TRUE;
- if(*url1 == '\0')
- {
- if(*url2 == '#') return TRUE;
- if(*url2 == '?') return TRUE;
- if(*url2 == '/' && *(url2+1) == '\0') return TRUE;
- }
- if(*url2 == '\0')
- {
- if(*url1 == '#') return TRUE;
- if(*url1 == '?') return TRUE;
- if(*url1 == '/' && *(url1+1) == '\0') return TRUE;
- }
- return FALSE;
+ int i, j;
+
+ for (i = 0; url1[i]; i++)
+ if (url1[i] == '#' || url1[i] == '?')
+ break;
+ while(i>0 && url1[i] == '/')
+ i--;
+
+ for (j = 0; url2[j]; j++)
+ if (url2[j] == '#' || url2[j] == '?')
+ break;
+ while(j>0 && url2[j] == '/')
+ j--;
+
+ if (i != j) return FALSE;
+ if (strncmp (url1, url2, i) != 0) return FALSE;
+ return TRUE;
}
gint