From 9f4b382338406973304c65bbb2e88334589b0075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Thu, 29 Nov 2018 18:25:44 +0100 Subject: [PATCH] wctype: have towlower and towupper check char ranges with no locale backend. Change-Id: Ie63977bcf54ce9b0a2fa542ba5327c8e8b050e2e Reviewed-on: https://review.haiku-os.org/740 Reviewed-by: Adrien Destugues --- src/system/libroot/posix/locale/wctype.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/system/libroot/posix/locale/wctype.cpp b/src/system/libroot/posix/locale/wctype.cpp index d2d225647c..8534aaa28f 100644 --- a/src/system/libroot/posix/locale/wctype.cpp +++ b/src/system/libroot/posix/locale/wctype.cpp @@ -123,8 +123,11 @@ iswxdigit(wint_t wc) wint_t towlower(wint_t wc) { - if (gLocaleBackend == NULL) + if (gLocaleBackend == NULL) { + if (wc < 0 || wc > 127) + return wc; return tolower(wc); + } wint_t result = wc; gLocaleBackend->ToWCTrans(wc, _ISlower, result); @@ -136,8 +139,11 @@ towlower(wint_t wc) wint_t towupper(wint_t wc) { - if (gLocaleBackend == NULL) + if (gLocaleBackend == NULL) { + if (wc < 0 || wc > 127) + return wc; return toupper(wc); + } wint_t result = wc; gLocaleBackend->ToWCTrans(wc, _ISupper, result);