[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: A Lua pattern question about optional patterns
- From: Thorkil Naur <naur@...>
- Date: Wed, 11 Sep 2019 20:54:50 +0200
Hello Phil,
On Wed, Sep 11, 2019 at 05:49:01PM +0000, Phil Leblanc wrote:
> I looked for the %z pattern in the manual (Lua 5.3, 5.4-alpha-rc2) but
> didn't find it.
In
https://www.lua.org/manual/5.2/manual.html
8.2 – Changes in the Libraries
you'll find
Character class %z in patterns is deprecated, as now patterns may
contain '\0' as a regular character.
Nevertheless, %z is still supported by at least the Lua 5.3.4 I checked:
> $ awk '/static int match_class/,/^}/' lstrlib.c
> static int match_class (int c, int cl) {
> int res;
> switch (tolower(cl)) {
> case 'a' : res = isalpha(c); break;
> case 'c' : res = iscntrl(c); break;
> case 'd' : res = isdigit(c); break;
> case 'g' : res = isgraph(c); break;
> case 'l' : res = islower(c); break;
> case 'p' : res = ispunct(c); break;
> case 's' : res = isspace(c); break;
> case 'u' : res = isupper(c); break;
> case 'w' : res = isalnum(c); break;
> case 'x' : res = isxdigit(c); break;
> case 'z' : res = (c == 0); break; /* deprecated option */
> default: return (cl == c);
> }
> return (islower(cl) ? res : !res);
> }
>
> $
Best regards
Thorkil