From: Gilles Detillieux <[EMAIL PROTECTED]>
Subject: Re: [htdig-dev] 3 small patches for htdig-3.2.0b4
To: [EMAIL PROTECTED]
Date sent: Fri, 22 Jun 2001 16:20:06 -0500 (CDT)
Copies to: [EMAIL PROTECTED]
Hi Gilles,
my patch for the url-construction was only a first shot. i think a
much better solution is, to have a private property _isempty and a
method empty() in the URL class.
_isempty is true if the URL is constructed with the default
constructor or an empty string.
the advantage of this solution is, that a code fragment like
(from Retriever.cc Retriever::got_href())
//
// Let's just be sure we're not pushing an empty URL
//
if (strlen(url.get())
...
seems to be much clearer, if you write
if (!url.empty())
....
i'm not a c++ expert, but if you are interested i would code this and
try to identify possible places for the new empty() method.
regards
marc
>
> > if you init a URL with a empty string "" then the result of _url is
> > "http:///". this happens for example while constructing http-referer
> > headers for update-digs. the patch is to ensure that the _host is
> > set if we are constructing non-file urls.
> >
> > diff -ur htdig-3.2.0b4-061701-orig/htcommon/URL.cc htdig-3.2.0b4-
> > 061701/htcommon/URL.cc
> > htdig-3.2.0b4-061701-orig/htcommon/URL.cc Sun May 20 09:13:46 2001
> > +++ htdig-3.2.0b4-061701/htcommon/URL.cc Thu Jun 21 07:44:59 2001
> > @@ -701,7 +701,12 @@
> > // Also ensures the port number is correct for the service
> > //
> > void URL::constructURL()
> > -{
> > +{
> > + if (strcmp((char*)_service, "file") != 0 && _host.length() == 0) {
> > + _url = "";
> > + return;
> > + }
> > +
> > _url = _service;
> > _url << ":";
> >
>
> I'm a little bit concerned about this patch, though. What happens if
> the _host is an empty string, but _path, or _user, or _port aren't empty
> strings. In these cases, shouldn't constructURL() set _url to something
> more than just an empty string? I've committed your patch to CVS already,
> but it occurred to me when looking at the 3.1.5 code for similar problems
> that this patch may introduce a problem. Can anyone more familiar with
> this code comment?
>
--------------------------------------------------------------
Marc Pohl
WWF Wort + Ton GmbH e-media
Tel.: +49 221 6900 112 Kolumbastrasse 3
FAX: +49 221 6900 150 D-50667 Koeln
Email: [EMAIL PROTECTED]
Privat: [EMAIL PROTECTED]
_______________________________________________
htdig-dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/htdig-dev