[Coldstuff] Bugs in Genesis...

Allen Noe coldstuff@cold.org
Wed, 27 Mar 2002 21:34:03 -0600


This is a multi-part message in MIME format.
--------------99FDBD3E41C7844E9E401668
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

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.
--------------99FDBD3E41C7844E9E401668
Content-Type: text/plain; charset=us-ascii;
 name="in.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="in.patch"

--- 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;
 

--------------99FDBD3E41C7844E9E401668--