> From: Jim Meyering [mailto:[email protected]]
> Sent: Tuesday, January 12, 2010 2:53 AM
> To: Yuxi Zhang
> Cc: Alain Magloire; [email protected]
> Subject: Re: gzip use of memcpy
>
Bonjour,
> Yuxi Zhang wrote:
> > It would be nice to declare the delta inside the function scope.
>
> Why?
> I find it less readable and less maintainable.
> Do you have to use a compiler for which that is required?
> If so, please give its name and version number.
>
Ouch! You are a hard man to please 8-).
We were using the watcom cc, but we stop its use, now out of (bad)
habit, the testers/developers still do the declaration at the beginning
of the block. But you are right it should not be a problem.
You're patch was tested on a SH4a and it seems to be fine.
> > Index: inflate.c
> > ===================================================================
> > --- inflate.c (revision 248271)
> > +++ inflate.c (working copy)
> > @@ -526,6 +526,7 @@
> > register unsigned e; /* table entry flag/number of extra bits */
> > unsigned n, d; /* length and index for copy */
> > unsigned w; /* current window position */
> > + unsigned delta; /* delta between slide+w and slide+d */
> > struct huft *t; /* pointer to table entry */
> > unsigned ml, md; /* masks for bl and bd bits */
> > register ulg b; /* bit buffer */
> > @@ -593,7 +594,9 @@
> > do {
> > n -= (e = (e = WSIZE - ((d &= WSIZE-1) > w ? d : w)) > n ?
n :
> > e);
> > #if !defined(NOMEMCPY) && !defined(DEBUG)
> > - if (w - d >= e) /* (this test assumes unsigned
> > comparison) */
> > + /* make the unsigned comparision in positive range. */
> > + delta = w > d ? w - d : d - w;
> > + if (delta >= e) /* (this test assumes unsigned
> > comparison) */
>
> I know it is line with the style of the existing code,
> but that code certainly does not qualify as a role model.