[vlc-commits] uri: factor alphanumeric test
Rémi Denis-Courmont
git at videolan.org
Sun Jul 8 16:57:45 CEST 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jul 8 16:16:38 2018 +0300| [f66dcd6781dce666b464f591f97f2cd5f55c9376] | committer: Rémi Denis-Courmont
uri: factor alphanumeric test
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f66dcd6781dce666b464f591f97f2cd5f55c9376
---
src/text/url.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/text/url.c b/src/text/url.c
index 1c86bedb58..6089c6802d 100644
--- a/src/text/url.c
+++ b/src/text/url.c
@@ -76,13 +76,17 @@ char *vlc_uri_decode (char *str)
return str;
}
-static bool isurisafe (int c)
+static bool isurialnum(int c)
{
- /* These are the _unreserved_ URI characters (RFC3986 §2.3) */
return ((unsigned char)(c - 'a') < 26)
|| ((unsigned char)(c - 'A') < 26)
- || ((unsigned char)(c - '0') < 10)
- || (strchr ("-._~", c) != NULL);
+ || ((unsigned char)(c - '0') < 10);
+}
+
+static bool isurisafe(int c)
+{
+ /* These are the _unreserved_ URI characters (RFC3986 §2.3) */
+ return isurialnum(c) || (strchr ("-._~", c) != NULL);
}
static bool isurisubdelim(int c)
@@ -429,8 +433,7 @@ static int vlc_UrlParseInner(vlc_url_t *restrict url, const char *str)
/* URI scheme */
next = buf;
- while ((*next >= 'A' && *next <= 'Z') || (*next >= 'a' && *next <= 'z')
- || (*next >= '0' && *next <= '9') || memchr ("+-.", *next, 3) != NULL)
+ while (isurialnum(*next) || memchr ("+-.", *next, 3) != NULL)
next++;
if (*next == ':')
More information about the vlc-commits
mailing list