|
From: stephan b. <st...@s1...> - 2005-02-26 16:55:27
|
Hiya!
g++ -pipe -Wall -Werror -g -DDEBUG -D_DEBUG -fPIC -I. -I../../include
-c -o URL.o URL.cpp
URL.cpp: In function `bool P::IO::charNeedEncode(unsigned char)':
URL.cpp:576: warning: comparison is always true due to limited range of
data
type
Code is pretty detailed, and i'm afraid to just change it:
bool charNeedEncode(unsigned char ch)
{
bool ret = false;
if((ch <= 0x1f) || (ch == 0x7f) || // ASCII control characters...
(ch >= 0x80 && ch <= 0xff) || // non-ASCII characters ...
(ch == 0x24) || (ch == 0x26) || // reserved characters...
(ch == 0x2b) || (ch == 0x2c) ||
(ch == 0x2f) || (ch == 0x3a) ||
(ch == 0x3b) || (ch == 0x3d) ||
(ch == 0x3f) || (ch == 0x40) ||
(ch == 0x20) || (ch == 0x22) || // unsafe characters ...
(ch == 0x3c) || (ch == 0x3e) ||
(ch == 0x23) || (ch == 0x25) ||
(ch == 0x7b) || (ch == 0x7d) ||
(ch == 0x7c) || (ch == 0x5c) ||
(ch == 0x5e) || (ch == 0x7e) ||
(ch == 0x5b) || (ch == 0x5d) ||
(ch == 0x60))
ret = true;
return ret;
}
Line 576 is the 'non-ASCII' line. It only shows up with -Wall -Werror
(which i -Walways use ;). The warning is correct, as 0xff requires 16
bits, whereas sizeof(char) is normaly 1 byte.
--
----- st...@s1... http://s11n.net
"...pleasure is a grace and is not obedient to the commands
of the will." -- Alan W. Watts
|