regexp.c (8dba275b) regexp.c (3e2d6582)
1/*
2 * Copyright 2008 Jacek Caban for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *

--- 1128 unchanged lines hidden (view full) ---

1137 }
1138
1139 if (state->flags & REG_FOLD) {
1140 WCHAR maxch = localMax;
1141
1142 for (i = rangeStart; i <= localMax; i++) {
1143 WCHAR uch, dch;
1144
1/*
2 * Copyright 2008 Jacek Caban for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *

--- 1128 unchanged lines hidden (view full) ---

1137 }
1138
1139 if (state->flags & REG_FOLD) {
1140 WCHAR maxch = localMax;
1141
1142 for (i = rangeStart; i <= localMax; i++) {
1143 WCHAR uch, dch;
1144
1145 uch = toupperW(i);
1146 dch = tolowerW(i);
1145 uch = towupper(i);
1146 dch = towlower(i);
1147 if(maxch < uch)
1148 maxch = uch;
1149 if(maxch < dch)
1150 maxch = dch;
1151 }
1152 localMax = maxch;
1153 }
1154

--- 828 unchanged lines hidden (view full) ---

1983FlatNIMatcher(REGlobalData *gData, match_state_t *x, const WCHAR *matchChars,
1984 size_t length)
1985{
1986 size_t i;
1987 assert(gData->cpend >= x->cp);
1988 if (length > (size_t)(gData->cpend - x->cp))
1989 return NULL;
1990 for (i = 0; i != length; i++) {
1147 if(maxch < uch)
1148 maxch = uch;
1149 if(maxch < dch)
1150 maxch = dch;
1151 }
1152 localMax = maxch;
1153 }
1154

--- 828 unchanged lines hidden (view full) ---

1983FlatNIMatcher(REGlobalData *gData, match_state_t *x, const WCHAR *matchChars,
1984 size_t length)
1985{
1986 size_t i;
1987 assert(gData->cpend >= x->cp);
1988 if (length > (size_t)(gData->cpend - x->cp))
1989 return NULL;
1990 for (i = 0; i != length; i++) {
1991 if (toupperW(matchChars[i]) != toupperW(x->cp[i]))
1991 if (towupper(matchChars[i]) != towupper(x->cp[i]))
1992 return NULL;
1993 }
1994 x->cp += length;
1995 return x;
1996}
1997
1998/*
1999 * 1. Evaluate DecimalEscape to obtain an EscapeValue E.

--- 30 unchanged lines hidden (view full) ---

2030
2031 len = cap->length;
2032 if (x->cp + len > gData->cpend)
2033 return NULL;
2034
2035 parenContent = &gData->cpbegin[cap->index];
2036 if (gData->regexp->flags & REG_FOLD) {
2037 for (i = 0; i < len; i++) {
1992 return NULL;
1993 }
1994 x->cp += length;
1995 return x;
1996}
1997
1998/*
1999 * 1. Evaluate DecimalEscape to obtain an EscapeValue E.

--- 30 unchanged lines hidden (view full) ---

2030
2031 len = cap->length;
2032 if (x->cp + len > gData->cpend)
2033 return NULL;
2034
2035 parenContent = &gData->cpbegin[cap->index];
2036 if (gData->regexp->flags & REG_FOLD) {
2037 for (i = 0; i < len; i++) {
2038 if (toupperW(parenContent[i]) != toupperW(x->cp[i]))
2038 if (towupper(parenContent[i]) != towupper(x->cp[i]))
2039 return NULL;
2040 }
2041 } else {
2042 for (i = 0; i < len; i++) {
2043 if (parenContent[i] != x->cp[i])
2044 return NULL;
2045 }
2046 }

--- 174 unchanged lines hidden (view full) ---

2221 case 'D':
2222 AddCharacterRangeToCharSet(charSet, 0, '0' - 1);
2223 AddCharacterRangeToCharSet(charSet,
2224 (WCHAR)('9' + 1),
2225 (WCHAR)charSet->length);
2226 continue;
2227 case 's':
2228 for (i = (INT)charSet->length; i >= 0; i--)
2039 return NULL;
2040 }
2041 } else {
2042 for (i = 0; i < len; i++) {
2043 if (parenContent[i] != x->cp[i])
2044 return NULL;
2045 }
2046 }

--- 174 unchanged lines hidden (view full) ---

2221 case 'D':
2222 AddCharacterRangeToCharSet(charSet, 0, '0' - 1);
2223 AddCharacterRangeToCharSet(charSet,
2224 (WCHAR)('9' + 1),
2225 (WCHAR)charSet->length);
2226 continue;
2227 case 's':
2228 for (i = (INT)charSet->length; i >= 0; i--)
2229 if (isspaceW(i))
2229 if (iswspace(i))
2230 AddCharacterToCharSet(charSet, (WCHAR)i);
2231 continue;
2232 case 'S':
2233 for (i = (INT)charSet->length; i >= 0; i--)
2230 AddCharacterToCharSet(charSet, (WCHAR)i);
2231 continue;
2232 case 'S':
2233 for (i = (INT)charSet->length; i >= 0; i--)
2234 if (!isspaceW(i))
2234 if (!iswspace(i))
2235 AddCharacterToCharSet(charSet, (WCHAR)i);
2236 continue;
2237 case 'w':
2238 for (i = (INT)charSet->length; i >= 0; i--)
2239 if (JS_ISWORD(i))
2240 AddCharacterToCharSet(charSet, (WCHAR)i);
2241 continue;
2242 case 'W':

--- 15 unchanged lines hidden (view full) ---

2258 }
2259 if (inRange) {
2260 if (gData->regexp->flags & REG_FOLD) {
2261 assert(rangeStart <= thisCh);
2262 for (i = rangeStart; i <= thisCh; i++) {
2263 WCHAR uch, dch;
2264
2265 AddCharacterToCharSet(charSet, i);
2235 AddCharacterToCharSet(charSet, (WCHAR)i);
2236 continue;
2237 case 'w':
2238 for (i = (INT)charSet->length; i >= 0; i--)
2239 if (JS_ISWORD(i))
2240 AddCharacterToCharSet(charSet, (WCHAR)i);
2241 continue;
2242 case 'W':

--- 15 unchanged lines hidden (view full) ---

2258 }
2259 if (inRange) {
2260 if (gData->regexp->flags & REG_FOLD) {
2261 assert(rangeStart <= thisCh);
2262 for (i = rangeStart; i <= thisCh; i++) {
2263 WCHAR uch, dch;
2264
2265 AddCharacterToCharSet(charSet, i);
2266 uch = toupperW(i);
2267 dch = tolowerW(i);
2266 uch = towupper(i);
2267 dch = towlower(i);
2268 if (i != uch)
2269 AddCharacterToCharSet(charSet, uch);
2270 if (i != dch)
2271 AddCharacterToCharSet(charSet, dch);
2272 }
2273 } else {
2274 AddCharacterRangeToCharSet(charSet, rangeStart, thisCh);
2275 }
2276 inRange = FALSE;
2277 } else {
2278 if (gData->regexp->flags & REG_FOLD) {
2268 if (i != uch)
2269 AddCharacterToCharSet(charSet, uch);
2270 if (i != dch)
2271 AddCharacterToCharSet(charSet, dch);
2272 }
2273 } else {
2274 AddCharacterRangeToCharSet(charSet, rangeStart, thisCh);
2275 }
2276 inRange = FALSE;
2277 } else {
2278 if (gData->regexp->flags & REG_FOLD) {
2279 AddCharacterToCharSet(charSet, toupperW(thisCh));
2280 AddCharacterToCharSet(charSet, tolowerW(thisCh));
2279 AddCharacterToCharSet(charSet, towupper(thisCh));
2280 AddCharacterToCharSet(charSet, towlower(thisCh));
2281 } else {
2282 AddCharacterToCharSet(charSet, thisCh);
2283 }
2284 if (src < end - 1) {
2285 if (*src == '-') {
2286 ++src;
2287 inRange = TRUE;
2288 rangeStart = thisCh;

--- 117 unchanged lines hidden (view full) ---

2406 break;
2407 case REOP_NONALNUM:
2408 if (x->cp != gData->cpend && !JS_ISWORD(*x->cp)) {
2409 result = x;
2410 result->cp++;
2411 }
2412 break;
2413 case REOP_SPACE:
2281 } else {
2282 AddCharacterToCharSet(charSet, thisCh);
2283 }
2284 if (src < end - 1) {
2285 if (*src == '-') {
2286 ++src;
2287 inRange = TRUE;
2288 rangeStart = thisCh;

--- 117 unchanged lines hidden (view full) ---

2406 break;
2407 case REOP_NONALNUM:
2408 if (x->cp != gData->cpend && !JS_ISWORD(*x->cp)) {
2409 result = x;
2410 result->cp++;
2411 }
2412 break;
2413 case REOP_SPACE:
2414 if (x->cp != gData->cpend && isspaceW(*x->cp)) {
2414 if (x->cp != gData->cpend && iswspace(*x->cp)) {
2415 result = x;
2416 result->cp++;
2417 }
2418 break;
2419 case REOP_NONSPACE:
2415 result = x;
2416 result->cp++;
2417 }
2418 break;
2419 case REOP_NONSPACE:
2420 if (x->cp != gData->cpend && !isspaceW(*x->cp)) {
2420 if (x->cp != gData->cpend && !iswspace(*x->cp)) {
2421 result = x;
2422 result->cp++;
2423 }
2424 break;
2425 case REOP_BACKREF:
2426 pc = ReadCompactIndex(pc, &parenIndex);
2427 assert(parenIndex < gData->regexp->parenCount);
2428 result = BackrefMatcher(gData, x, parenIndex);

--- 29 unchanged lines hidden (view full) ---

2458 pc = ReadCompactIndex(pc, &length);
2459 assert(1 <= length);
2460 assert(length <= gData->regexp->source_len - offset);
2461 source = gData->regexp->source;
2462 result = FlatNIMatcher(gData, x, source + offset, length);
2463 break;
2464 case REOP_FLAT1i:
2465 matchCh = *pc++;
2421 result = x;
2422 result->cp++;
2423 }
2424 break;
2425 case REOP_BACKREF:
2426 pc = ReadCompactIndex(pc, &parenIndex);
2427 assert(parenIndex < gData->regexp->parenCount);
2428 result = BackrefMatcher(gData, x, parenIndex);

--- 29 unchanged lines hidden (view full) ---

2458 pc = ReadCompactIndex(pc, &length);
2459 assert(1 <= length);
2460 assert(length <= gData->regexp->source_len - offset);
2461 source = gData->regexp->source;
2462 result = FlatNIMatcher(gData, x, source + offset, length);
2463 break;
2464 case REOP_FLAT1i:
2465 matchCh = *pc++;
2466 if (x->cp != gData->cpend && toupperW(*x->cp) == toupperW(matchCh)) {
2466 if (x->cp != gData->cpend && towupper(*x->cp) == towupper(matchCh)) {
2467 result = x;
2468 result->cp++;
2469 }
2470 break;
2471 case REOP_UCFLAT1:
2472 matchCh = GET_ARG(pc);
2473 TRACE(" '%c' == '%c'\n", (char)matchCh, (char)*x->cp);
2474 pc += ARG_LEN;
2475 if (x->cp != gData->cpend && *x->cp == matchCh) {
2476 result = x;
2477 result->cp++;
2478 }
2479 break;
2480 case REOP_UCFLAT1i:
2481 matchCh = GET_ARG(pc);
2482 pc += ARG_LEN;
2467 result = x;
2468 result->cp++;
2469 }
2470 break;
2471 case REOP_UCFLAT1:
2472 matchCh = GET_ARG(pc);
2473 TRACE(" '%c' == '%c'\n", (char)matchCh, (char)*x->cp);
2474 pc += ARG_LEN;
2475 if (x->cp != gData->cpend && *x->cp == matchCh) {
2476 result = x;
2477 result->cp++;
2478 }
2479 break;
2480 case REOP_UCFLAT1i:
2481 matchCh = GET_ARG(pc);
2482 pc += ARG_LEN;
2483 if (x->cp != gData->cpend && toupperW(*x->cp) == toupperW(matchCh)) {
2483 if (x->cp != gData->cpend && towupper(*x->cp) == towupper(matchCh)) {
2484 result = x;
2485 result->cp++;
2486 }
2487 break;
2488 case REOP_CLASS:
2489 pc = ReadCompactIndex(pc, &index);
2490 assert(index < gData->regexp->classCount);
2491 if (x->cp != gData->cpend) {

--- 797 unchanged lines hidden ---
2484 result = x;
2485 result->cp++;
2486 }
2487 break;
2488 case REOP_CLASS:
2489 pc = ReadCompactIndex(pc, &index);
2490 assert(index < gData->regexp->classCount);
2491 if (x->cp != gData->cpend) {

--- 797 unchanged lines hidden ---