Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 22948 invoked by uid 500); 3 Jun 2002 00:15:18 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 22937 invoked from network); 3 Jun 2002 00:15:17 -0000 Message-ID: <3CFAC327.FFE1C903@p16.pub.ro> Date: Mon, 03 Jun 2002 03:15:19 +0200 From: Paul Marculescu X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: dev@apr.apache.org Subject: [PATCH] apr_uri Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-RAVMilter-Version: 8.3.3(snapshot 20020312) (compaq) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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) {