Skip to content
Snippets Groups Projects
Commit e1b3b6b4 authored by Nadav Har'El's avatar Nadav Har'El Committed by Pekka Enberg
Browse files

locale: fix shifted ctype array


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>
parent 669f657f
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,7 @@ namespace {
int main(int ac, char **av)
{
for (int i = -127; i < 256; ++i) {
for (int i = -128; i < 256; ++i) {
std::cout << "0";
DO(alnum);
DO(alpha);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment