[Coldstuff] Bugs in Genesis...

Bruce Mitchener coldstuff@cold.org
Thu, 28 Mar 2002 00:58:14 -0600


How about someone send me a tested patch along with a patch for the 
tests to help prevent this sort of thing from happening again?

(And really, these days, all patches should have accompanying tests for 
the test suite or I'm significantly less inclined to accept them. 
Patches to add tests are ALWAYS welcome and would be a great way to get 
used to the idea that you can and should contribute to the Cold 
community. :) )

Thanks,

  - Bruce

Allen Noe wrote:
> Michael Mudge wrote:
> 
>>Can anyone else reproduce this bug?
>>
>>;`[a,b] in `[anythings, a, a]
>>=> Some very large number (or a driver crash)
>>
> 
> Looks like this is the bufidx bug fixed in 1.1.8.
> 
> Here's a patch to make op_in use buffer_index instead of reimplementing the old
> version of it. Should work, but untested.
> 
> 
> ------------------------------------------------------------------------
> 
> --- Genesis-1.1.10-STABLE/src/ops/operators.c	Wed Jan  9 23:30:11 2002
> +++ Genesis-1.1.10-STABLE/src/ops/operators.c.new	Wed Mar 27 21:27:11 2002
> @@ -2276,26 +2276,11 @@
>                  if (s)
>                      pos = s - buf->s;
>              } else if (d1->type == BUFFER) {
> -                uchar * p,
> -                      * ss = d1->u.buffer->s;
> -                int     slen = d1->u.buffer->len,
> -                        len = buf->len;
> +                uchar * ss = d1->u.buffer->s;
> +                int     slen = d1->u.buffer->len;
> +
> +                pos = buffer_index(buf, ss, slen, 1) - 1;
>  
> -                s = buf->s;
> -                p = (uchar *) memchr(s, *ss, len); 
> -                if (slen == 1) {
> -                    pos = p ? (p - s) : -1;
> -                } else {
> -                    slen--;
> -                    while (p) {
> -                        if (MEMCMP(p + 1, ss + 1, slen) == 0) {
> -                            pos = (p - s);
> -                            break;
> -                        }
> -                        len -= (p - s) + 1;
> -                        p = (uchar *) memchr(p + 1, *ss, len);
> -                    }
> -                }
>              } else
>                  goto error;
>  
>