Re: Lua 4.0 (alpha), strfind-bug?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Lua 4.0 (alpha), strfind-bug?
- From: Roberto Ierusalimschy <roberto@...>
- Date: 2000年5月02日 15:27:38 -0300
> 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:
408c408
< 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