mirror of
https://github.com/lua/lua
synced 2025-02-16 21:23:58 +03:00
singlematch and item_end are used by "read", in iolib.
This commit is contained in:
parent
1630c2533a
commit
25b6dae7c0
5
lualib.h
5
lualib.h
@ -2,7 +2,7 @@
|
||||
** Libraries to be used in LUA programs
|
||||
** Grupo de Tecnologia em Computacao Grafica
|
||||
** TeCGraf - PUC-Rio
|
||||
** $Id: lualib.h,v 1.8 1996/04/30 21:13:55 roberto Exp roberto $
|
||||
** $Id: lualib.h,v 1.9 1996/08/01 14:55:33 roberto Exp roberto $
|
||||
*/
|
||||
|
||||
#ifndef lualib_h
|
||||
@ -31,5 +31,8 @@ long lua_opt_number (int numArg, long def, char *funcname);
|
||||
char *luaI_addchar (int c);
|
||||
void luaI_addquoted (char *s);
|
||||
|
||||
char *item_end (char *p);
|
||||
int singlematch (int c, char *p);
|
||||
|
||||
#endif
|
||||
|
||||
|
14
strlib.c
14
strlib.c
@ -3,7 +3,7 @@
|
||||
** String library to LUA
|
||||
*/
|
||||
|
||||
char *rcs_strlib="$Id: strlib.c,v 1.24 1996/05/22 21:59:07 roberto Exp roberto $";
|
||||
char *rcs_strlib="$Id: strlib.c,v 1.25 1996/08/01 14:55:33 roberto Exp roberto $";
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
@ -178,7 +178,7 @@ static void str_ascii (void)
|
||||
#define ESC '%'
|
||||
#define SPECIALS "^$*?.([%"
|
||||
|
||||
static char *item_end (char *p)
|
||||
char *item_end (char *p)
|
||||
{
|
||||
switch (*p) {
|
||||
case '\0': return p;
|
||||
@ -212,9 +212,9 @@ static int matchclass (int c, int cl)
|
||||
return (islower(cl) ? res : !res);
|
||||
}
|
||||
|
||||
static int singlematch (int c, char *p)
|
||||
int singlematch (int c, char *p)
|
||||
{
|
||||
if (c == 0) return 0;
|
||||
if (c <= 0) return 0; /* \0, EOF or other strange flags */
|
||||
switch (*p) {
|
||||
case '.': return 1;
|
||||
case ESC: return matchclass(c, *(p+1));
|
||||
@ -323,13 +323,13 @@ static char *match (char *s, char *p, int level)
|
||||
int m = singlematch(*s, p);
|
||||
char *ep = item_end(p); /* get what is next */
|
||||
switch (*ep) {
|
||||
case '*': { /* repetition? */
|
||||
case '*': { /* repetition */
|
||||
char *res;
|
||||
if (m && (res = match(s+1, p, level)))
|
||||
return res;
|
||||
p=ep+1; goto init; /* else return match(s, ep+1, level); */
|
||||
}
|
||||
case '?': { /* optional? */
|
||||
case '?': { /* optional */
|
||||
char *res;
|
||||
if (m && (res = match(s+1, ep+1, level)))
|
||||
return res;
|
||||
@ -487,7 +487,7 @@ static struct lua_reg strlib[] = {
|
||||
{"ascii", str_ascii},
|
||||
{"format", str_format},
|
||||
{"strfind", str_find},
|
||||
{"s", str_s}
|
||||
{"gsub", str_s}
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user