[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: string.gsub (Lua 5.1.1)
- From: Nick Gammon <nick@...>
- Date: Tue, 7 Nov 2006 07:47:48 +1100
On 06/11/2006, at 6:33 PM, Shmuel Zeigerman wrote:
Nick Gammon wrote:
Probably the manual should be reworded as:
"gsub also returns, as its second value, the total number of
matches made."
But this would be, in fact, an API alteration, and API is not
allowed to change after the Lua version is officially out.
No, that is a clarification of what it currently does. It currently
returns the number of times it matched, regardless of what happens
when it matches.
Thus, if the API is not allowed to change, the manual rewording is
what is required.
From the source:
e = match(&ms, src, p);
if (e) {
n++;
add_value(&ms, &b, src, e);
}
The number n is what is returned as the count. It is incremented on a
match, regardless of what add_value does with the match.
- Nick