lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> With my PowerMac Lua 4.0 I have discovered something that seems like 
> a bug in "strfind".

It is a bug, and a silly one :-(  In my machine, you can get the bug with
the following little chunk:

  a = "abc  "
  print(strlen(a), strfind(a, "\0", strlen(a)-2, 1))

To fix it, you have to change one single line in lstrlib.c:

  <     const char *s2 = memfind(s+init, l1, p, l2);
  >     const char *s2 = memfind(s+init, l1-init, p, l2);

(In words, when you start the search with an offset, you must subtract the
offset from the total length of the subject.)

It will be fixed in next version.

-- Roberto