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;
|
int db;
|
||||||
bool neg;
|
bool neg;
|
||||||
bool m;
|
bool m;
|
||||||
|
char rc;
|
||||||
m = false;
|
m = false;
|
||||||
if (*needle == '[')
|
if (*needle == '[')
|
||||||
{
|
{
|
||||||
|
@ -23,6 +24,15 @@ bool char_match(char c, char *needle, char **nneedl)
|
||||||
{
|
{
|
||||||
if ((*needle == c) != neg)
|
if ((*needle == c) != neg)
|
||||||
m = true;
|
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)
|
if (db)
|
||||||
db--;
|
db--;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue