From cb1658f3994ffaecf2ab5f612ca800a3773556b4 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 17 Jun 2007 19:50:05 +0300 Subject: [PATCH] URI: Inline check_uri_file. And reorder the characters in the string given to strcspn(), to match their expected order in the URI. This is also how strcspn() is called elsewhere in uri.c. --- src/protocol/uri.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/protocol/uri.c b/src/protocol/uri.c index b92c448c..7dca889d 100644 --- a/src/protocol/uri.c +++ b/src/protocol/uri.c @@ -145,15 +145,6 @@ check_whether_file_exists(unsigned char *name) return -1; } -static int -check_uri_file(const unsigned char *name) -{ - /* Check POST_CHAR etc ... */ - static const unsigned char chars[] = POST_CHAR_S "#"; - - return strcspn(name, chars); -} - /* Encodes URIs without encoding stuff like fragments and query separators. */ static void encode_file_uri_string(struct string *string, unsigned char *uristring) @@ -240,7 +231,7 @@ parse_uri(struct uri *uri, unsigned char *uristring) return URI_ERRNO_OK; } else if (uri->protocol == PROTOCOL_FILE) { - int datalen = check_uri_file(prefix_end); + int datalen = strcspn(prefix_end, "#" POST_CHAR_S); unsigned char *frag_or_post = prefix_end + datalen; /* Extract the fragment part. */ @@ -256,6 +247,7 @@ parse_uri(struct uri *uri, unsigned char *uristring) } else { datalen = strlen(prefix_end); } + /* A bit of a special case, but using the "normal" host * parsing seems a bit scary at this point. (see bug 107). */ if (datalen > 9 && !strncasecmp(prefix_end, "localhost/", 10)) {