You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Jon Travis <jt...@covalent.net> on 2001/07/19 02:22:13 UTC
[PATCH] apr_uri_unparse_components
It is possible unparse a URI into something like:
"http://@foo.bar.com", if a username or password is given, and
the OMITUSER and OMITPASSWORD fields are blank. This should
do the job (though that section of the code is particularly
ugly).
-- Jon
Index: apr_uri.c
===================================================================
RCS file: /home/cvspublic/apr-util/uri/apr_uri.c,v
retrieving revision 1.6
diff -u -u -r1.6 apr_uri.c
--- apr_uri.c 2001/06/13 22:56:23 1.6
+++ apr_uri.c 2001/07/19 00:14:53
@@ -139,7 +139,9 @@
(uptr->password && !(flags & UNP_OMITPASSWORD))
? ((flags & UNP_REVEALPASSWORD) ? uptr->password : "XXXXXXXX")
: "",
- "@", NULL);
+ (uptr->user && !(flags & UNP_OMITUSER) ||
+ uptr->password && !(flags & UNP_OMITPASSWORD)) ? "@"
+ : "", NULL);
/* Construct scheme://site string */
if (uptr->hostname) {
Re: [PATCH] apr_uri_unparse_components
Posted by Jon Travis <jt...@covalent.net>.
On Wed, Jul 18, 2001 at 05:22:13PM -0700, Jon Travis wrote:
> It is possible unparse a URI into something like:
> "http://@foo.bar.com", if a username or password is given, and
> the OMITUSER and OMITPASSWORD fields are blank. This should
> do the job (though that section of the code is particularly
> ugly).
>
>
> -- Jon
Dean pointed out a compiler warning that -Wall gives in the original
patch, so here's an update. Why is -Wall not the default, anyway?
Index: apr_uri.c
===================================================================
RCS file: /home/cvspublic/apr-util/uri/apr_uri.c,v
retrieving revision 1.6
diff -u -u -r1.6 apr_uri.c
--- apr_uri.c 2001/06/13 22:56:23 1.6
+++ apr_uri.c 2001/07/19 22:41:21
@@ -139,7 +139,9 @@
(uptr->password && !(flags & UNP_OMITPASSWORD))
? ((flags & UNP_REVEALPASSWORD) ? uptr->password : "XXXXXXXX")
: "",
- "@", NULL);
+ ((uptr->user && !(flags & UNP_OMITUSER)) ||
+ (uptr->password && !(flags & UNP_OMITPASSWORD))) ? "@"
+ : "", NULL);
/* Construct scheme://site string */
if (uptr->hostname) {