diff options
Diffstat (limited to 'src/common/url.c')
-rw-r--r-- | src/common/url.c | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/src/common/url.c b/src/common/url.c index 1321374f..0354d98c 100644 --- a/src/common/url.c +++ b/src/common/url.c @@ -53,7 +53,7 @@ static gboolean match_path (const char *word, int *start, int *end); static int url_free (char *url, void *data) { - free (url); + g_free (url); return TRUE; } @@ -124,13 +124,7 @@ url_add (char *urltext, int len) return; } - data = malloc (len + 1); - if (!data) - { - return; - } - memcpy (data, urltext, len); - data[len] = 0; + data = g_strndup (urltext, len); if (data[len - 1] == '.') /* chop trailing dot */ { @@ -151,7 +145,7 @@ url_add (char *urltext, int len) /* the URL is saved already, only continue if we need the URL grabber too */ if (!prefs.hex_url_grabber) { - free (data); + g_free (data); return; } @@ -163,7 +157,7 @@ url_add (char *urltext, int len) if (url_find (data)) { - free (data); + g_free (data); return; } @@ -180,7 +174,7 @@ url_add (char *urltext, int len) pos = tree_remove_at_pos (url_tree, 0); g_tree_remove (url_btree, pos); - free (pos); + g_free (pos); } } @@ -332,7 +326,7 @@ static char *commands[] = { #define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) void -url_check_line (char *buf, int len) +url_check_line (char *buf) { GRegex *re(void); GMatchInfo *gmi; @@ -415,7 +409,7 @@ regex_match (const GRegex *re, const char *word, int *start, int *end) } /* Miscellaneous description --- */ -#define DOMAIN "[_\\pL\\pN][-_\\pL\\pN]*(\\.[-_\\pL\\pN]+)*" +#define DOMAIN "[_\\pL\\pN\\pS][-_\\pL\\pN\\pS]*(\\.[-_\\pL\\pN\\pS]+)*" #define TLD "\\.[\\pL][-\\pL\\pN]*[\\pL]" #define IPADDR "[0-9]{1,3}(\\.[0-9]{1,3}){3}" #define IPV6GROUP "([0-9a-f]{0,4})" @@ -429,7 +423,7 @@ regex_match (const GRegex *re, const char *word, int *start, int *end) #define OPT_PORT "(" PORT ")?" static GRegex * -make_re (char *grist) +make_re (const char *grist) { GRegex *ret; GError *err = NULL; @@ -587,18 +581,14 @@ re_url (void) if (uri[i].flags & URI_PATH) { - char *sep_escaped; - - sep_escaped = g_regex_escape_string (uri[i].path_sep, - strlen(uri[i].path_sep)); + char *sep_escaped = g_regex_escape_string (uri[i].path_sep, strlen(uri[i].path_sep)); - g_string_append_printf(grist_gstr, "(" "%s" PATH ")?", - sep_escaped); + g_string_append_printf (grist_gstr, "(" "%s" PATH ")?", sep_escaped); - g_free(sep_escaped); + g_free (sep_escaped); } - g_string_append(grist_gstr, ")"); + g_string_append (grist_gstr, ")"); } grist = g_string_free (grist_gstr, FALSE); |