svn commit: r224869 - user/gabor/tre-integration/contrib/tre/lib
Gabor Kovesdan
gabor at FreeBSD.org
Sun Aug 14 20:54:14 UTC 2011
Author: gabor
Date: Sun Aug 14 20:54:13 2011
New Revision: 224869
URL: http://svn.freebsd.org/changeset/base/224869
Log:
- Fix word boundary matching for the remaining case
Modified:
user/gabor/tre-integration/contrib/tre/lib/fastmatch.c
Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c
==============================================================================
--- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Sun Aug 14 16:17:00 2011 (r224868)
+++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Sun Aug 14 20:54:13 2011 (r224869)
@@ -459,29 +459,26 @@ tre_fastcomp(fastmatch_t *fg, const tre_
continue; \
}
+#define _BBOUND_COND \
+ ((type == STR_WIDE) ? \
+ ((j == 0) || !(tre_isalnum(str_wide[j - 1]) || \
+ (str_wide[j - 1] == TRE_CHAR('_')))) : \
+ ((j == 0) || !(tre_isalnum(str_byte[j - 1]) || \
+ (str_byte[j - 1] == '_'))))
+
+#define _EBOUND_COND \
+ ((type == STR_WIDE) ? \
+ ((j + fg->wlen == len) || !(tre_isalnum(str_wide[j + fg->wlen]) || \
+ (str_wide[j + fg->wlen] == TRE_CHAR('_')))) : \
+ ((j + fg->len == len) || !(tre_isalnum(str_byte[j + fg->len]) || \
+ (str_byte[j + fg->len] == '_'))))
+
+#define IS_ON_WORD_BOUNDARY \
+ (_BBOUND_COND && _EBOUND_COND)
+
#define CHECK_WORD_BOUNDARY \
- { \
- bool bbound, ebound; \
- \
- switch (type) \
- { \
- case STR_WIDE: \
- bbound = (j == 0) || !(tre_isalnum(str_wide[j - 1]) || \
- (str_wide[j - 1] == TRE_CHAR('_'))); \
- ebound = (j + fg->wlen == len) || \
- !(tre_isalnum(str_wide[j + fg->wlen]) || \
- (str_wide[j + fg->wlen] == TRE_CHAR('_'))); \
- break; \
- default: \
- bbound = (j == 0) || !(tre_isalnum(str_byte[j - 1]) || \
- (str_byte[j - 1] == '_')); \
- ebound = (j + fg->len == len) || \
- !(tre_isalnum(str_byte[j + fg->len]) || \
- (str_byte[j + fg->len] == '_')); \
- } \
- if (!bbound || !ebound) \
- _SHIFT_ONE; \
- }
+ if (!IS_ON_WORD_BOUNDARY) \
+ _SHIFT_ONE;
#define _BOL_COND \
((j == 0) || ((type == STR_WIDE) ? tre_isspace(str_wide[j - 1]) : \
@@ -540,7 +537,6 @@ tre_fastexec(const fastmatch_t *fg, cons
shift = fg->len;
}
- /* XXX: Fix with word boundaries */
/* Only try once at the beginning or ending of the line. */
if (!fg->newline && (fg->bol || fg->eol))
{
@@ -554,6 +550,8 @@ tre_fastexec(const fastmatch_t *fg, cons
COMPARE;
if (mismatch == REG_OK)
{
+ if (fg->word && !IS_ON_WORD_BOUNDARY)
+ return ret;
pmatch[0].rm_so = j;
pmatch[0].rm_eo = j + (type == STR_WIDE ? fg->wlen : fg->len);
return REG_OK;
More information about the svn-src-user
mailing list