@matheusbsbs / matheus-bagliano / commits / 2832114532
Fork 0

Fix some "comparison is always true/false" warnings.

On Cygwin the wchar_t type is an unsigned short (16-bit) int. This results in the above warnings from the return statement in the wcwidth() function (in particular, the expressions involving constants with values larger than 0xffff). Simply replace the use of wchar_t with an unsigned int, typedef-ed as ucs_char_t. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <junkio@cox.net>

Ramsay Jones committed Mar 3, 2007 at 18:28 UTC 2832114532d92bdd533f84fa520050c5de95c012
1 file changed +6 -4
utf8.c
+6 -4
@@ -3,13 +3,15 @@
3
4 /* This code is originally from http://www.cl.cam.ac.uk/~mgk25/ucs/ */
5
6 +typedef unsigned int ucs_char_t; /* assuming 32bit int */
7 +
8 struct interval {
9 int first;
10 int last;
11 };
12
13 /* auxiliary function for binary search in interval table */
12 -static int bisearch(wchar_t ucs, const struct interval *table, int max) {
14 +static int bisearch(ucs_char_t ucs, const struct interval *table, int max) {
15 int min = 0;
16 int mid;
17
@@ -56,11 +58,11 @@ static int bisearch(wchar_t ucs, const struct interval *table, int max) {
58 * ISO 8859-1 and WGL4 characters, Unicode control characters,
59 * etc.) have a column width of 1.
60 *
59 - * This implementation assumes that wchar_t characters are encoded
61 + * This implementation assumes that ucs_char_t characters are encoded
62 * in ISO 10646.
63 */
64
63 -static int wcwidth(wchar_t ch)
65 +static int wcwidth(ucs_char_t ch)
66 {
67 /*
68 * Sorted list of non-overlapping intervals of non-spacing characters,
@@ -157,7 +159,7 @@ static int wcwidth(wchar_t ch)
159 int utf8_width(const char **start)
160 {
161 unsigned char *s = (unsigned char *)*start;
160 - wchar_t ch;
162 + ucs_char_t ch;
163
164 if (*s < 0x80) {
165 /* 0xxxxxxx */