implement character ranges
This commit is contained in:
parent
2d191fbf94
commit
4678c619a2
1 changed files with 10 additions and 0 deletions
10
regex.c
10
regex.c
|
@ -11,6 +11,7 @@ bool char_match(char c, char *needle, char **nneedl)
|
|||
int db;
|
||||
bool neg;
|
||||
bool m;
|
||||
char rc;
|
||||
m = false;
|
||||
if (*needle == '[')
|
||||
{
|
||||
|
@ -23,6 +24,15 @@ bool char_match(char c, char *needle, char **nneedl)
|
|||
{
|
||||
if ((*needle == c) != neg)
|
||||
m = true;
|
||||
if (needle[1] == '-' && needle[2] && needle[2] != ']')
|
||||
{
|
||||
// match range
|
||||
for (rc = *needle; rc <= needle[2]; rc++)
|
||||
if ((rc == c) != neg)
|
||||
m = true;
|
||||
needle++;
|
||||
needle++;
|
||||
}
|
||||
if (db)
|
||||
db--;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue