I made a little patch for apr-util's apr_uri.c to handle win32 absolute
paths under file:// schema.
Index: uri/apr_uri.c
===================================================================
RCS file: /home/cvspublic/apr-util/uri/apr_uri.c,v
retrieving revision 1.12
diff -u -r1.12 apr_uri.c
--- uri/apr_uri.c 13 Mar 2002 20:40:49 -0000 1.12
+++ uri/apr_uri.c 2 Jun 2002 23:25:08 -0000
@@ -127,6 +127,7 @@
unsigned flags)
{
char *ret = "";
+ char *slsh = "";
/* If suppressing the site part, omit both user name &
scheme://hostname */
if (!(flags & APR_URI_UNP_OMITSITEPART)) {
@@ -163,9 +164,23 @@
/* Should we suppress all path info? */
if (!(flags & APR_URI_UNP_OMITPATHINFO)) {
+ /* If this is a WIN32 platform and the uri schema is file://,
+ * we should add the '/' starting the path if there is an
absolute
WIN32 path
+ * (including the drive letter)
+ */
+#ifdef WIN32
+ if (uptr->scheme && strcasecmp("file", uptr->scheme) == 0) {
+ /* see if there is enough room to chech for a drive
letter and a ':'
*/
+ if ( uptr->path && strlen(uptr->path) > 1) {
+ if (uptr->path[1] == ':')
+ slsh = apr_pstrcat (p, slsh, "/", NULL
) ;
+ }
+ }
+#endif
/* Append path, query and fragment strings: */
ret = apr_pstrcat (p,
ret,
+ slsh,
uptr->path ? uptr->path : "",
(uptr->query && !(flags & APR_URI_UNP_OMITQUERY)) ? "?" : "",
(uptr->query && !(flags & APR_URI_UNP_OMITQUERY)) ?
uptr->query :
"",
@@ -246,6 +261,19 @@
++s;
}
if (s != uri) {
+ /* If this is a WIN32 platform and the uri schema is file://,
+ * we skip the '/' starting the path if there is an absolute
WIN32
path
+ * (including the drive letter)
+ */
+#ifdef WIN32
+ if (uptr->scheme && strcasecmp("file", uptr->scheme) == 0) {
+ /* see if there is enough room to chech for a drive
letter and a ':'
*/
+ if (s - uri > 2) {
+ if (uri_delims[*(unsigned char*)(uri + 2)] &
T_COLON)
+ uri++;
+ }
+ }
+#endif
uptr->path = apr_pstrmemdup(p, uri, s - uri);
}
if (*s == 0) {