Skip to content

Commit 1e0136e

Browse files
committed
Handle 8-bit characters under LOCALE=C
Even when the character set is specified as ASCII, we should handle data outside the 7-bit range gracefully by simply copying it, even if it is technically no longer ASCII. This fixes several of Git for Windows' tests, e.g. t7400. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 3e9c003 commit 1e0136e

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

newlib/libc/stdlib/mbtowc_r.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ __ascii_mbtowc (struct _reent *r,
3636
if (n == 0)
3737
return -2;
3838

39-
#ifdef __CYGWIN__
39+
#ifdef STRICTLY_7BIT_ASCII
4040
if ((wchar_t)*t >= 0x80)
4141
{
4242
r->_errno = EILSEQ;

newlib/libc/stdlib/wctomb_r.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ __ascii_wctomb (struct _reent *r,
2929
if (s == NULL)
3030
return 0;
3131

32-
#ifdef __CYGWIN__
32+
#ifdef STRICTLY_7BIT_ASCII
3333
if ((size_t)wchar >= 0x80)
3434
#else
3535
if ((size_t)wchar >= 0x100)

winsup/cygwin/strfuncs.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,11 @@ _sys_mbstowcs (mbtowc_p f_mbtowc, wchar_t *dst, size_t dlen, const char *src,
616616
to store them in a symmetric way. */
617617
bytes = 1;
618618
if (dst)
619+
#ifdef STRICTLY_7BIT_ASCII
619620
*ptr = L'\xf000' | *pmbs;
621+
#else
622+
*ptr = *pmbs;
623+
#endif
620624
memset (&ps, 0, sizeof ps);
621625
}
622626

0 commit comments

Comments
 (0)