Fix behaviour of towlower(), towupper() and towctrans():
* all those functions need to return the given wc unchanged in case of error, not 0 * towctrans() didn't actually look at the requested transition, but always acted as if _ISlower was given
This commit is contained in:
@@ -159,7 +159,7 @@ towlower(wint_t wc)
|
|||||||
if (gLocaleBackend == NULL)
|
if (gLocaleBackend == NULL)
|
||||||
return tolower(wc);
|
return tolower(wc);
|
||||||
|
|
||||||
wint_t result = 0;
|
wint_t result = wc;
|
||||||
gLocaleBackend->ToWCTrans(wc, _ISlower, result);
|
gLocaleBackend->ToWCTrans(wc, _ISlower, result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -172,7 +172,7 @@ towupper(wint_t wc)
|
|||||||
if (gLocaleBackend == NULL)
|
if (gLocaleBackend == NULL)
|
||||||
return toupper(wc);
|
return toupper(wc);
|
||||||
|
|
||||||
wint_t result = 0;
|
wint_t result = wc;
|
||||||
gLocaleBackend->ToWCTrans(wc, _ISupper, result);
|
gLocaleBackend->ToWCTrans(wc, _ISupper, result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -182,12 +182,18 @@ towupper(wint_t wc)
|
|||||||
wint_t
|
wint_t
|
||||||
towctrans(wint_t wc, wctrans_t transition)
|
towctrans(wint_t wc, wctrans_t transition)
|
||||||
{
|
{
|
||||||
if (gLocaleBackend == NULL)
|
if (gLocaleBackend == NULL) {
|
||||||
|
if (transition == _ISlower)
|
||||||
return tolower(wc);
|
return tolower(wc);
|
||||||
|
if (transition == _ISupper)
|
||||||
|
return toupper(wc);
|
||||||
|
|
||||||
wint_t result = 0;
|
__set_errno(EINVAL);
|
||||||
|
return wc;
|
||||||
|
}
|
||||||
|
|
||||||
|
wint_t result = wc;
|
||||||
status_t status = gLocaleBackend->ToWCTrans(wc, transition, result);
|
status_t status = gLocaleBackend->ToWCTrans(wc, transition, result);
|
||||||
|
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
__set_errno(EINVAL);
|
__set_errno(EINVAL);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user