mirror of
https://github.com/cesanta/slre.git
synced 2024-11-24 11:25:30 +00:00
Fix SLRE_IGNORE_CASE handling
This commit is contained in:
parent
0419690215
commit
ace9f34999
4
slre.c
4
slre.c
@ -167,8 +167,8 @@ static int match_set(const char *re, int re_len, const char *s,
|
|||||||
if (re[len] != '-' && re[len + 1] == '-' && re[len + 2] != ']' &&
|
if (re[len] != '-' && re[len + 1] == '-' && re[len + 2] != ']' &&
|
||||||
re[len + 2] != '\0') {
|
re[len + 2] != '\0') {
|
||||||
result = info->flags && SLRE_IGNORE_CASE ?
|
result = info->flags && SLRE_IGNORE_CASE ?
|
||||||
*s >= re[len] && *s <= re[len + 2] :
|
tolower(*s) >= tolower(re[len]) && tolower(*s) <= tolower(re[len + 2]) :
|
||||||
tolower(*s) >= tolower(re[len]) && tolower(*s) <= tolower(re[len + 2]);
|
*s >= re[len] && *s <= re[len + 2];
|
||||||
len += 3;
|
len += 3;
|
||||||
} else {
|
} else {
|
||||||
result = match_op((unsigned char *) re + len, (unsigned char *) s, info);
|
result = match_op((unsigned char *) re + len, (unsigned char *) s, info);
|
||||||
|
@ -213,6 +213,14 @@ int main(void) {
|
|||||||
ASSERT(slre_match( "a+$" ,"Xaa", 3, NULL, 0, 0) == 3);
|
ASSERT(slre_match( "a+$" ,"Xaa", 3, NULL, 0, 0) == 3);
|
||||||
ASSERT(slre_match( "a*$" ,"Xaa", 3, NULL, 0, 0) == 3);
|
ASSERT(slre_match( "a*$" ,"Xaa", 3, NULL, 0, 0) == 3);
|
||||||
|
|
||||||
|
/* Ignore case flag */
|
||||||
|
ASSERT(slre_match("[a-h]+", "abcdefghxxx", 11, NULL, 0, 0) == 8);
|
||||||
|
ASSERT(slre_match("[A-H]+", "ABCDEFGHyyy", 11, NULL, 0, 0) == 8);
|
||||||
|
ASSERT(slre_match("[a-h]+", "ABCDEFGHyyy", 11, NULL, 0, 0) == SLRE_NO_MATCH);
|
||||||
|
ASSERT(slre_match("[A-H]+", "abcdefghyyy", 11, NULL, 0, 0) == SLRE_NO_MATCH);
|
||||||
|
ASSERT(slre_match("[a-h]+", "ABCDEFGHyyy", 11, NULL, 0, SLRE_IGNORE_CASE) == 8);
|
||||||
|
ASSERT(slre_match("[A-H]+", "abcdefghyyy", 11, NULL, 0, SLRE_IGNORE_CASE) == 8);
|
||||||
|
|
||||||
{
|
{
|
||||||
/* Example: HTTP request */
|
/* Example: HTTP request */
|
||||||
const char *request = " GET /index.html HTTP/1.0\r\n\r\n";
|
const char *request = " GET /index.html HTTP/1.0\r\n\r\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user