summaryrefslogtreecommitdiffstats
path: root/Src/pattern.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/pattern.c')
-rw-r--r--Src/pattern.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/Src/pattern.c b/Src/pattern.c
index 1e0ae88d9..017c20a1e 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -1369,6 +1369,11 @@ patcomppiece(int *flagp, int paren)
}
}
slen = (patparse - str0) - nmeta;
+#ifdef MULTIBYTE_SUPPORT
+ if ((patglobflags & GF_MULTIBYTE) && slen > 1)
+ /* for multibyte single characters, treat x# as (x)# */
+ flags &= ~P_SIMPLE;
+#endif
/* First add length, which is a long */
patadd((char *)&slen, 0, sizeof(long), 0);
/*
@@ -3348,10 +3353,14 @@ patmatch(Upat prog)
return 0;
/* Yes, just position appropriately and test. */
patinput += ptlen - P_LS_LEN(next);
- /*
- * Here we will need to be careful that patinput is not
- * in the middle of a multibyte character.
- */
+#ifdef MULTIBYTE_SUPPORT
+ /* Make sure we aren't in the middle of
+ * a multibyte character */
+ if ((patglobflags & GF_MULTIBYTE) &&
+ ptlen < P_LS_LEN(next) &&
+ !charstart[patinput - start])
+ return 0;
+#endif
/* Continue loop with P_EXACTLY test. */
break;
}