Re: src/util.cpp substitute semantics ?

Dimitri Van Heesch <[email protected]>
Newsgroups gmane.text.doxygen.devel
Message-ID <[email protected]>
Hi Robbe,

You are right. I'll include your patch.

Regards,
   Dimitri

On 16 okt 2008, at 05:16, Robbie Gates wrote:

> Hi All,
>
>  it looks to me like the reimplemented subsitute in src/util.cpp in
> the 1.5.7.1 release has different semantics to the original when
> passed a null string (i.e. 0 ptr) for the dst argument. It now returns
> the string unchanged, whereas previously it treated it as if dst was
> the empty string. The patch below restores the old behaviour. It's a
> bit of a hack, but its as local a change as i could make.
>
>  I noticed this because our header.html uses relpath, and the
> relativePathToRoot function in src/util.cpp returns a null string,
> rather than an empty string, when the relative path is empty.
>
>  Hope this helps,
>
> - robbie
>
> @@ -4447,10 +4447,10 @@
>
> QCString substitute(const char *s,const char *src,const char *dst)
> {
> -  if (s==0 || src==0 || dst==0) return s;
> +  if (s==0 || src==0) return s;
>   const char *p, *q;
>   int srcLen = strlen(src);
> -  int dstLen = strlen(dst);
> +  int dstLen = dst ? strlen(dst) : 0;
>   int resLen;
>   if (srcLen!=dstLen)
>   {
> @@ -4469,7 +4469,10 @@
>     int l = (int)(q-p);
>     memcpy(r,p,l);
>     r+=l;
> -    memcpy(r,dst,dstLen);
> +    if (dst)
> +    {
> +      memcpy(r,dst,dstLen);
> +    }
>     r+=dstLen;
>   }
>   strcpy(r,p);
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's  
> challenge
> Build the coolest Linux based applications with Moblin SDK & win  
> great prizes
> Grand prize is a trip for two to an Open Source event anywhere in  
> the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Doxygen-develop mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/doxygen-develop


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.