Skip to content

Commit

Permalink
locale.c: Add debugging check
Browse files Browse the repository at this point in the history
If we run across the REPLACEMENT CHARACTER, its likely a mismatch
between LC_CTYPE and another category.  This panics on debugging builds.
  • Loading branch information
khwilliamson committed May 5, 2021
1 parent 636e3da commit 52b7032
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions locale.c
Expand Up @@ -2811,6 +2811,20 @@ S_save_to_buffer(const char * string, const char **buf, Size_t *buf_size)
"Copying '%s' to %p\n", string, *buf));
}

# ifdef DEBUGGING

/* Catch glitches. Usually this is because LC_CTYPE needs to be the same
* locale as whatever is being worked on */
if (UNLIKELY(instr(string, REPLACEMENT_CHARACTER_UTF8))) {
dTHX_DEBUGGING;

locale_panic_(Perl_form(aTHX_
"Unexpected REPLACEMENT_CHARACTER in '%s'\n%s",
string, get_LC_ALL_display()));
}

# endif

Copy(string, *buf, string_size, char);
return *buf;
}
Expand Down

0 comments on commit 52b7032

Please sign in to comment.