[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
There is a bug in $buffer.bufsub(), which I think I have fixed.  Here is an updated copy:


@program $buffer.bufsub() -e=0 +access=pub
  arg buf, a, b;
  var i, la, lb, lt;
  
  // do we need a builtin for this?
  // from Kipp's core (until I write a builtin--optimized by Brandon) 
  if (a == b || buflen(a) > buflen(buf) || !a || !buf)
      return buf;
  la = buflen(a);
  lb = buflen(b);
  lt = buflen(buf);
  i = 1;
  anticipate_assignment();
  while (i <= buflen(buf) && (i = bufidx(buf, a, i))) {
      buf = subbuf(buf, 1, i - 1) + b + subbuf(buf, i + la);
      i += lb;
  }   
  return buf;
.

Let me know if this fixes some of the problems people have been reporting lately.

-Brandon