Skip to content
Snippets Groups Projects
  • Nadav Har'El's avatar
    e1b3b6b4
    locale: fix shifted ctype array · e1b3b6b4
    Nadav Har'El authored
    
    Fixes #314.
    
    In two's complement, the lowest signed 8-bit number is -128, not -127.
    By wrongly starting to generate the ctype array starting with -127 instead
    of -128, we got all the locale ctype questions shifted by one character;
    For example character 32 (' ') was not considered a space, but 31 was!
    
    We didn't see this bug because our C library isspace() and friends are
    currently implemented without using the locale framework (which is fine,
    as we only support the "C" locale anyway). However, this bug is
    apparent in C++, as explained in issue #314: std::isspace() returns the
    wrong answer, and C++ facilities which use this under the hood - such
    as reading from an istream which is supposed to stop at a space - also
    got broken.
    
    Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
    Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
    e1b3b6b4
    History
    locale: fix shifted ctype array
    Nadav Har'El authored
    
    Fixes #314.
    
    In two's complement, the lowest signed 8-bit number is -128, not -127.
    By wrongly starting to generate the ctype array starting with -127 instead
    of -128, we got all the locale ctype questions shifted by one character;
    For example character 32 (' ') was not considered a space, but 31 was!
    
    We didn't see this bug because our C library isspace() and friends are
    currently implemented without using the locale framework (which is fine,
    as we only support the "C" locale anyway). However, this bug is
    apparent in C++, as explained in issue #314: std::isspace() returns the
    wrong answer, and C++ facilities which use this under the hood - such
    as reading from an istream which is supposed to stop at a space - also
    got broken.
    
    Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
    Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>