View Single Post
Old May 28, 2009, 14:58   #7
zaimoni
Knight
 
zaimoni's Avatar
 
Join Date: Apr 2007
Posts: 590
zaimoni is on a distinguished road
Quote:
Originally Posted by PaulBlay View Post
And the question is ... what's this bit in aid of?

Code:
	if ((n > 0) && (scr_cc[x] == (char) -1) && (scr_aa[x] == 255))
	{
		x--;
		n++;
	}
Apart from not understanding it and wanting to my problem is that I am using wchar_t not char for text so that "(char) -1" and "255" might well not be compatible with the rest of the code now.
(char)(-1) is just plain living dangerously. It's a warning silencer because char isn't guaranteed to be equivalent to signed char.

scr_aa originally was unsigned char; 255 is UCHAR_MAX assuming CHAR_BIT is 8 (which the entire V codebase does, I put a preprocessor test for this into Zaiband to trigger a preprocessing error on such unsupported systems).

If you're not using a proper UNICODE library, try WCHAR_MAX (C++) or WINT_MAX (C) in place of 255/UCHAR_MAX. [Note that the standards do *not* guarantee any particular encoding for wchar_t/wint_t . As usual, Solaris will give you a porting sunburn.] Note that you will want to use a proper UNICODE library, because Linux will railroad you into UTF-8 while Windows demands you use UCS-2 in practice.
zaimoni is offline   Reply With Quote