summaryrefslogtreecommitdiff
path: root/Src/pattern.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/pattern.c')
-rw-r--r--Src/pattern.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/Src/pattern.c b/Src/pattern.c
index c0e31b78e..e947d1216 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -320,6 +320,14 @@ typedef wint_t patint_t;
*/
static mbstate_t shiftstate;
+/* See clear_mbstate() in params.c for the use of clear_shiftstate() */
+
+/**/
+mod_export void
+clear_shiftstate(void) {
+ memset(&shiftstate, 0, sizeof(shiftstate));
+}
+
/*
* Multibyte version: it's (almost) as easy to return the
* value as not, so do so since we sometimes need it..
@@ -1999,6 +2007,8 @@ charsub(char *x, char *y)
if (ret == MB_INVALID || ret == MB_INCOMPLETE) {
/* Error. Treat remainder as single characters */
+ /* Reset the shift state for next time. */
+ memset(&shiftstate, 0, sizeof(shiftstate));
return res + (y - x);
}