diff options
author | Diego Escalante Urrelo <diegoe@src.gnome.org> | 2008-07-25 04:42:12 +0800 |
---|---|---|
committer | Diego Escalante Urrelo <diegoe@src.gnome.org> | 2008-07-25 04:42:12 +0800 |
commit | e02839c7d5e7aca51b8ab3f1459158731556cf03 (patch) | |
tree | 1e4943bafd81400b911c36c0d1da5ec2c4b21ac6 | |
parent | 4b20227170765a0cc0ccebe51978a831d327f340 (diff) | |
download | gsoc2013-epiphany-e02839c7d5e7aca51b8ab3f1459158731556cf03.tar gsoc2013-epiphany-e02839c7d5e7aca51b8ab3f1459158731556cf03.tar.gz gsoc2013-epiphany-e02839c7d5e7aca51b8ab3f1459158731556cf03.tar.bz2 gsoc2013-epiphany-e02839c7d5e7aca51b8ab3f1459158731556cf03.tar.lz gsoc2013-epiphany-e02839c7d5e7aca51b8ab3f1459158731556cf03.tar.xz gsoc2013-epiphany-e02839c7d5e7aca51b8ab3f1459158731556cf03.tar.zst gsoc2013-epiphany-e02839c7d5e7aca51b8ab3f1459158731556cf03.zip |
Regex instead of pointer voodoo in is_base_address.
svn path=/branches/gnome-2-24/; revision=8359
-rw-r--r-- | src/ephy-completion-model.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/src/ephy-completion-model.c b/src/ephy-completion-model.c index 72ba6494e..d5581ed71 100644 --- a/src/ephy-completion-model.c +++ b/src/ephy-completion-model.c @@ -355,27 +355,16 @@ init_favicon_col (EphyCompletionModel *model, GValue *value, 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 |