Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F142109919
D10098.id27944.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D10098.id27944.diff
View Options
Index: head/usr.bin/grep/regex/tre-fastmatch.c
===================================================================
--- head/usr.bin/grep/regex/tre-fastmatch.c
+++ head/usr.bin/grep/regex/tre-fastmatch.c
@@ -98,6 +98,18 @@
fg->pattern[siz] = '\0'; \
} \
+#define CONV_MBS_PAT(src, dest, destsz) \
+ { \
+ destsz = wcstombs(NULL, src, 0); \
+ if (destsz == (size_t)-1) \
+ return REG_BADPAT; \
+ dest = malloc(destsz + 1); \
+ if (dest == NULL) \
+ return REG_ESPACE; \
+ wcstombs(dest, src, destsz); \
+ dest[destsz] = '\0'; \
+ } \
+
#define IS_OUT_OF_BOUNDS \
((!fg->reversed \
? ((type == STR_WIDE) ? ((j + fg->wlen) > len) \
@@ -723,15 +735,29 @@
}
escaped = false;
- for (unsigned int i = 0; i < fg->len; i++)
- if (fg->pattern[i] == '\\')
- escaped = !escaped;
- else if (fg->pattern[i] == '.' && fg->escmap && escaped)
+ char *_checkpat = NULL;
+ size_t _checklen = 0;
+ unsigned int escofs = 0;
+ /*
+ * Make a copy here of the original pattern, because fg->pattern has
+ * already been stripped of all escape sequences in the above processing.
+ * This is necessary if we wish to later treat fg->escmap as an actual,
+ * functional replacement of fg->wescmap.
+ */
+ CONV_MBS_PAT(pat, _checkpat, _checklen);
+ for (unsigned int i = 0; i < n; i++)
+ if (_checkpat[i] == '\\')
+ {
+ escaped = !escaped;
+ if (escaped)
+ ++escofs;
+ }
+ else if (_checkpat[i] == '.' && fg->escmap != NULL && escaped)
{
- fg->escmap[i] = true;
+ fg->escmap[i - escofs] = true;
escaped = false;
}
- else if (fg->pattern[i] == '.' && !escaped)
+ else if (_checkpat[i] == '.' && !escaped)
{
hasdot = i;
if (firstdot == -1)
@@ -739,6 +765,7 @@
}
else
escaped = false;
+ free(_checkpat);
}
#else
SAVE_PATTERN(tmp, pos, fg->pattern, fg->len);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 17, 2:33 AM (11 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27677777
Default Alt Text
D10098.id27944.diff (1 KB)
Attached To
Mode
D10098: bsdgrep(1): Fix escape map building for multibyte strings
Attached
Detach File
Event Timeline
Log In to Comment