From 805b33552bcf0a70abe57e7d508731353ec8e385 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sun, 16 Jun 2013 15:36:52 +0100 Subject: [PATCH] Rework url matching to make it easier to add schemes. The new way allows great control of what a url is composed of. Added a bunch of new schemes. --- src/common/url.c | 161 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 112 insertions(+), 49 deletions(-) diff --git a/src/common/url.c b/src/common/url.c index 84c112d1..def77628 100644 --- a/src/common/url.c +++ b/src/common/url.c @@ -314,8 +314,8 @@ do_an_re(const char *word,int *start, int *end, int *type) } func_t; func_t funcs[] = { - { re_email, WORD_EMAIL }, { re_url, WORD_URL }, + { re_email, WORD_EMAIL }, { re_channel, WORD_CHANNEL }, { re_host, WORD_HOST }, { re_path, WORD_PATH }, @@ -360,7 +360,7 @@ make_re(char *grist, char *type) GRegex *ret; GError *err = NULL; - ret = g_regex_new (grist, G_REGEX_CASELESS + G_REGEX_OPTIMIZE, 0, &err); + ret = g_regex_new (grist, G_REGEX_CASELESS | G_REGEX_OPTIMIZE, 0, &err); g_free (grist); return ret; } @@ -389,60 +389,123 @@ re_host (void) #define LPAR "\\(" #define RPAR "\\)" #define NOPARENS "[^() \t]*" +#define PATH \ + "(" \ + "(" LPAR NOPARENS RPAR ")" \ + "|" \ + "(" NOPARENS ")" \ + ")*" /* Zero or more occurrences of either of these */ \ + "(?