On 29/08/15 17:44, [email protected] wrote: > This patch is incorrect. You must guard toupper(), it is not guaranteed not to > distort non-lowercase characters.
Yes it is - for values in the range of unsigned char and EOF. Behavior is undefined for other values. The bug is failing to cast a char arguments to <ctype.h> functions to unsigned char. It's a common bug, so some implementations support char args. They cannot support that fully for (char)EOF, though. > if (islower(x)) x = toupper(x) That might hide the bug at times, maybe that's why you use it. But it's not reliable, islower too expects EOF or unsigned char. Use x = toupper((unsigned char)x).
