summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2007-07-31 18:28:30 +0000
committerjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2007-07-31 18:28:30 +0000
commit9c82581051430a06c7ec1b9d255a6fe9b86c7a27 (patch)
treec6f807ef45c71ac074a1a4cd601f388540085388
parent89bd94c0a9d4ba685b46629d2813a7314c4df47a (diff)
downloadneon-9c82581051430a06c7ec1b9d255a6fe9b86c7a27.tar.gz
* src/ne_uri.c (URI_FRAGMENT): Add macro.
(ne_uri_parse): Add comments and use URI_FRAGMENT; no functional change. git-svn-id: http://svn.webdav.org/repos/projects/neon/trunk@1216 61a7d7f5-40b7-0310-9c16-bb0ea8cb1845
-rw-r--r--src/ne_uri.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/ne_uri.c b/src/ne_uri.c
index 669e70b..681a476 100644
--- a/src/ne_uri.c
+++ b/src/ne_uri.c
@@ -84,8 +84,10 @@
#define URI_PCHAR (URI_UNRESERVED | PC | URI_SUBDELIM | CL | AT)
/* invented: segchar = pchar / "/" */
#define URI_SEGCHAR (URI_PCHAR | FS)
-/* query = fragment = *( pchar / "/" / "?" ) */
+/* query = *( pchar / "/" / "?" ) */
#define URI_QUERY (URI_PCHAR | FS | QU)
+/* fragment == query */
+#define URI_FRAGMENT URI_QUERY
/* any characters which should be path-escaped: */
#define URI_ESCAPE ((URI_GENDELIM & ~(FS)) | URI_SUBDELIM | OT | PC)
@@ -153,6 +155,8 @@ int ne_uri_parse(const char *uri, ne_uri *parsed)
p = s = uri;
+ /* => s = p = URI-reference */
+
if (uri_lookup(*p) & URI_ALPHA) {
while (uri_lookup(*p) & URI_SCHEME)
p++;
@@ -163,11 +167,15 @@ int ne_uri_parse(const char *uri, ne_uri *parsed)
}
}
+ /* => s = heir-part, or s = relative-part */
+
if (s[0] == '/' && s[1] == '/') {
const char *pa;
- /* hier-part = "//" authority path-abempty
- * authority = [ userinfo "@" ] host [ ":" port ] */
+ /* => s = "//" authority path-abempty (from expansion of
+ * either heir-part of relative-part) */
+
+ /* authority = [ userinfo "@" ] host [ ":" port ] */
s = pa = s + 2; /* => s = authority */
@@ -218,14 +226,18 @@ int ne_uri_parse(const char *uri, ne_uri *parsed)
if (*s == '\0') {
s = "/"; /* FIXME: scheme-specific. */
}
- }
- /* else, the path begins at s */
+ }
+
+ /* => s = path-abempty / path-absolute / path-rootless
+ * / path-empty / path-noscheme */
p = s;
while (uri_lookup(*p) & URI_SEGCHAR)
p++;
+ /* => p = [ "?" query ] [ "#" fragment ] */
+
parsed->path = ne_strndup(s, p - s);
if (*p != '\0') {
@@ -234,17 +246,22 @@ int ne_uri_parse(const char *uri, ne_uri *parsed)
while (uri_lookup(*p) & URI_QUERY)
p++;
+ /* => p = [ "#" fragment ] */
+ /* => s = [ "?" query ] [ "#" fragment ] */
+
if (*s == '?') {
parsed->query = ne_strndup(s + 1, p - s - 1);
if (*p != '\0') {
s = p++;
- while (uri_lookup(*p) & URI_QUERY)
+ while (uri_lookup(*p) & URI_FRAGMENT)
p++;
}
}
- /* p must now point to the end of the input string */
+
+ /* => p now points to the next character after the
+ * URI-reference; which should be the NUL byte. */
if (*s == '#') {
parsed->fragment = ne_strndup(s + 1, p - s - 1);