[haiku-bugs] Re: [Haiku] #14730: towlower() and towupper() should check the character range when gLocaleBackend is NULL.

  • From: "Haiku" <trac@xxxxxxxxxxxx>
  • To: undisclosed-recipients: ;
  • Date: Thu, 29 Nov 2018 10:02:41 -0000

#14730: towlower() and towupper() should check the character range when
gLocaleBackend is NULL.
----------------------------+----------------------------
   Reporter:  korli         |      Owner:  nobody
       Type:  bug           |     Status:  new
   Priority:  normal        |  Milestone:  Unscheduled
  Component:  System/POSIX  |    Version:  R1/Development
 Resolution:                |   Keywords:
 Blocked By:                |   Blocking:
Has a Patch:  0             |   Platform:  All
----------------------------+----------------------------

Comment (by pulkomandy):

 It should return wc rather than returning 0, for out of range characters.

 http://pubs.opengroup.org/onlinepubs/9699919799/functions/towlower.html

Upon successful completion, functions shall return the lowercase letter
 corresponding to the argument passed; otherwise, they shall return **the
 argument unchanged**.

 Current implementation: https://git.haiku-
 os.org/haiku/tree/src/system/libroot/posix/locale/wctype.cpp#n124

 It would be nice if tolower/toupper did not crash for out of range
 characters, however. Maybe we should put the range check there instead?
 However I see tolower/toupper are gcc builtins, so it's possible it knows
 the expected input ranges and will optimize away attempts to check it
 (already happened to us in other cases, leading to disabling the tree-vrp
 optimization back then).

-- 
Ticket URL: <https://dev.haiku-os.org/ticket/14730#comment:1>
Haiku <https://dev.haiku-os.org>
The Haiku operating system.

Other related posts: