mirror of https://github.com/rusefi/lua.git
char-set may contain '%]'
This commit is contained in:
parent
a82c8185bc
commit
900257e814
22
lstrlib.c
22
lstrlib.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lstrlib.c,v 1.31 1999/05/14 12:24:04 roberto Exp roberto $
|
** $Id: lstrlib.c,v 1.32 1999/06/17 17:04:03 roberto Exp roberto $
|
||||||
** Standard library for strings and pattern-matching
|
** Standard library for strings and pattern-matching
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -102,7 +102,7 @@ static void str_char (void) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
luaL_resetbuffer();
|
luaL_resetbuffer();
|
||||||
while (lua_getparam(++i) != LUA_NOOBJECT) {
|
while (lua_getparam(++i) != LUA_NOOBJECT) {
|
||||||
double c = luaL_check_number(i);
|
int c = luaL_check_int(i);
|
||||||
luaL_arg_check((unsigned char)c == c, i, "invalid value");
|
luaL_arg_check((unsigned char)c == c, i, "invalid value");
|
||||||
luaL_addchar((unsigned char)c);
|
luaL_addchar((unsigned char)c);
|
||||||
}
|
}
|
||||||
|
@ -166,14 +166,14 @@ static int capture_to_close (struct Capture *cap) {
|
||||||
char *luaI_classend (char *p) {
|
char *luaI_classend (char *p) {
|
||||||
switch (*p++) {
|
switch (*p++) {
|
||||||
case ESC:
|
case ESC:
|
||||||
if (*p == '\0')
|
if (*p == '\0') lua_error("incorrect pattern (ends with `%')");
|
||||||
luaL_verror("incorrect pattern (ends with `%c')", ESC);
|
|
||||||
return p+1;
|
return p+1;
|
||||||
case '[':
|
case '[':
|
||||||
if (*p == '^') p++;
|
if (*p == '^') p++;
|
||||||
if (*p == ']') p++;
|
do { /* look for a ']' */
|
||||||
p = strchr(p, ']');
|
if (*p == '\0') lua_error("incorrect pattern (missing `]')");
|
||||||
if (!p) lua_error("incorrect pattern (missing `]')");
|
if (*(p++) == ESC && *p != '\0') p++; /* skip escapes (e.g. '%]') */
|
||||||
|
} while (*p != ']');
|
||||||
return p+1;
|
return p+1;
|
||||||
default:
|
default:
|
||||||
return p;
|
return p;
|
||||||
|
@ -201,19 +201,19 @@ static int matchclass (int c, int cl) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int matchbracketclass (int c, char *p, char *end) {
|
static int matchbracketclass (int c, char *p, char *endclass) {
|
||||||
int sig = 1;
|
int sig = 1;
|
||||||
if (*(p+1) == '^') {
|
if (*(p+1) == '^') {
|
||||||
sig = 0;
|
sig = 0;
|
||||||
p++; /* skip the '^' */
|
p++; /* skip the '^' */
|
||||||
}
|
}
|
||||||
while (++p < end) {
|
while (++p < endclass) {
|
||||||
if (*p == ESC) {
|
if (*p == ESC) {
|
||||||
p++;
|
p++;
|
||||||
if ((p < end) && matchclass(c, (unsigned char)*p))
|
if (matchclass(c, (unsigned char)*p))
|
||||||
return sig;
|
return sig;
|
||||||
}
|
}
|
||||||
else if ((*(p+1) == '-') && (p+2 < end)) {
|
else if ((*(p+1) == '-') && (p+2 < endclass)) {
|
||||||
p+=2;
|
p+=2;
|
||||||
if ((int)(unsigned char)*(p-2) <= c && c <= (int)(unsigned char)*p)
|
if ((int)(unsigned char)*(p-2) <= c && c <= (int)(unsigned char)*p)
|
||||||
return sig;
|
return sig;
|
||||||
|
|
Loading…
Reference in New Issue