From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 4C0B7385B519; Sat, 25 Feb 2023 15:24:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C0B7385B519 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677338689; bh=wRXoV3kK+TSXup1cH6NfPetTJdxxTBRBM5BHjYjyw4E=; h=From:To:Subject:Date:From; b=UtmzllCYXWklyBMxEzOgi1+m8RF8BOiTb3asbRdgLPmvivQc5aWZIE6bbkwSH2XuN sT2YyLF77d5yzIUd126EUx79nCWra3bRsFaqwLYVq2m8HFMt6Qu1sp95iL3rjeQRqY o12kIlmzc5uOlqcuGUJ49MJ7Li4eli2e04d003+M= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org, newlib-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: fully support KOI8-T codeset X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: 98aed7943ee3000281b1226e5a68152a3da7358f X-Git-Newrev: 2b052b3c5080c1b601129fcceda5f6537a442c87 Message-Id: <20230225152449.4C0B7385B519@sourceware.org> Date: Sat, 25 Feb 2023 15:24:49 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D2b052b3c508= 0c1b601129fcceda5f6537a442c87 commit 2b052b3c5080c1b601129fcceda5f6537a442c87 Author: Corinna Vinschen AuthorDate: Sat Feb 25 13:19:27 2023 +0100 Commit: Corinna Vinschen CommitDate: Sat Feb 25 16:12:51 2023 +0100 Cygwin: fully support KOI8-T codeset =20 Commit 89eb4bce152f was pretty half-hearted, missing the codepage character type tables and wctomb/mbtowc mappings. =20 Fixes: 89eb4bce152f ("Cygwin: support KOI8-T codeset") Signed-off-by: Corinna Vinschen Diff: --- newlib/libc/ctype/ctype_cp.h | 33 +++++++++++++++++++++++++++++++-- newlib/libc/stdlib/mbtowc_r.c | 12 ++++++++++-- newlib/libc/stdlib/wctomb_r.c | 11 +++++++++-- winsup/cygwin/ctype.cc | 2 +- 4 files changed, 51 insertions(+), 7 deletions(-) diff --git a/newlib/libc/ctype/ctype_cp.h b/newlib/libc/ctype/ctype_cp.h index 9370778a2891..192cfa43decb 100644 --- a/newlib/libc/ctype/ctype_cp.h +++ b/newlib/libc/ctype/ctype_cp.h @@ -469,13 +469,31 @@ _L, _L, _L, _L, _L, _L, _L, _L, \ _L, _L, _L, _L, _L, _L, _L #define _CTYPE_PT154_255 _L +#define _CTYPE_CP103_128_254 \ + _L, _L, _P, _U, _P, _P, _P, _P, \ + 0, _P, _L, _P, _U, _L, _U, 0, \ + _U, _P, _P, _P, _P, _P, _P, _P, \ + 0, _P, 0, _P, 0, 0, 0, 0, \ + 0, _L, _U, _L, _P, _L, _P, _P, \ + 0, 0, 0, _P, _P, _P, _P, 0, \ + _P, _P, _P, _U, 0, _U, _P, _P, \ + 0, _P, 0, _P, 0, 0, 0, _P, \ + _L, _L, _L, _L, _L, _L, _L, _L, \ + _L, _L, _L, _L, _L, _L, _L, _L, \ + _L, _L, _L, _L, _L, _L, _L, _L, \ + _L, _L, _L, _L, _L, _L, _L, _L, \ + _U, _U, _U, _U, _U, _U, _U, _U, \ + _U, _U, _U, _U, _U, _U, _U, _U, \ + _U, _U, _U, _U, _U, _U, _U, _U, \ + _U, _U, _U, _U, _U, _U, _U +#define _CTYPE_CP103_255 _U =20 #if defined(ALLOW_NEGATIVE_CTYPE_INDEX) =20 #ifndef __CYGWIN__ static const #endif -char __ctype_cp[26][128 + 256] =3D { +char __ctype_cp[27][128 + 256] =3D { { _CTYPE_CP437_128_254, 0, _CTYPE_DATA_0_127, @@ -632,11 +650,17 @@ char __ctype_cp[26][128 + 256] =3D { _CTYPE_PT154_128_254, _CTYPE_PT154_255 }, + { _CTYPE_CP103_128_254, + 0, + _CTYPE_DATA_0_127, + _CTYPE_CP103_128_254, + _CTYPE_CP103_255 + }, }; =20 #else /* !defined(ALLOW_NEGATIVE_CTYPE_INDEX) */ =20 -static const char __ctype_cp[26][1 + 256] =3D { +static const char __ctype_cp[27][1 + 256] =3D { { 0, _CTYPE_DATA_0_127, _CTYPE_CP437_128_254, @@ -767,6 +791,11 @@ static const char __ctype_cp[26][1 + 256] =3D { _CTYPE_PT154_128_254, _CTYPE_PT154_255 }, + { 0, + _CTYPE_DATA_0_127, + _CTYPE_CP103_128_254, + _CTYPE_CP103_255 + }, }; =20 #endif /* ALLOW_NEGATIVE_CTYPE_INDEX */ diff --git a/newlib/libc/stdlib/mbtowc_r.c b/newlib/libc/stdlib/mbtowc_r.c index ca876f9a0218..01e596db8bde 100644 --- a/newlib/libc/stdlib/mbtowc_r.c +++ b/newlib/libc/stdlib/mbtowc_r.c @@ -487,7 +487,14 @@ __cp_102_mbtowc (struct _reent *r, wchar_t *pwc, const= char *s, size_t n, return ___cp_mbtowc (r, pwc, s, n, 25, state); } =20 -static mbtowc_p __cp_xxx_mbtowc[26] =3D { +static int +__cp_103_mbtowc (struct _reent *r, wchar_t *pwc, const char *s, size_t n, + mbstate_t *state) +{ + return ___cp_mbtowc (r, pwc, s, n, 26, state); +} + +static mbtowc_p __cp_xxx_mbtowc[27] =3D { __cp_437_mbtowc, __cp_720_mbtowc, __cp_737_mbtowc, @@ -513,7 +520,8 @@ static mbtowc_p __cp_xxx_mbtowc[26] =3D { __cp_20866_mbtowc, __cp_21866_mbtowc, __cp_101_mbtowc, - __cp_102_mbtowc + __cp_102_mbtowc, + __cp_103_mbtowc, }; =20 /* val *MUST* be valid! All checks for validity are supposed to be diff --git a/newlib/libc/stdlib/wctomb_r.c b/newlib/libc/stdlib/wctomb_r.c index a7f87cd9e22e..3081e9370271 100644 --- a/newlib/libc/stdlib/wctomb_r.c +++ b/newlib/libc/stdlib/wctomb_r.c @@ -611,7 +611,13 @@ __cp_102_wctomb (struct _reent *r, char *s, wchar_t _w= char, mbstate_t *state) return ___cp_wctomb (r, s, _wchar, 25, state); } =20 -static wctomb_p __cp_xxx_wctomb[26] =3D { +static int +__cp_103_wctomb (struct _reent *r, char *s, wchar_t _wchar, mbstate_t *sta= te) +{ + return ___cp_wctomb (r, s, _wchar, 26, state); +} + +static wctomb_p __cp_xxx_wctomb[27] =3D { __cp_437_wctomb, __cp_720_wctomb, __cp_737_wctomb, @@ -637,7 +643,8 @@ static wctomb_p __cp_xxx_wctomb[26] =3D { __cp_20866_wctomb, __cp_21866_wctomb, __cp_101_wctomb, - __cp_102_wctomb + __cp_102_wctomb, + __cp_103_wctomb, }; =20 /* val *MUST* be valid! All checks for validity are supposed to be diff --git a/winsup/cygwin/ctype.cc b/winsup/cygwin/ctype.cc index 7bdc78edf0e0..d99e331baa57 100644 --- a/winsup/cygwin/ctype.cc +++ b/winsup/cygwin/ctype.cc @@ -16,7 +16,7 @@ extern char _ctype_b[128 + 256]; time-critical anyway. */ extern int __iso_8859_index (const char *charset_ext); /* Newlib */ extern int __cp_index (const char *charset_ext); /* Newlib */ -extern const char __ctype_cp[22][128 + 256]; /* Newlib */ +extern const char __ctype_cp[27][128 + 256]; /* Newlib */ extern const char __ctype_iso[15][128 + 256]; /* Newlib */ =20 void