Browse Source

Fix wcswidth function when LOCALE support is disabled
while keeping WCHAR support enabled. This solves two
testcases: tst_wcwidth and tst_wcswidth.

Fix dat_iswctype.c fiinput file: character 0x80 is not
a control character: it fixes tst_iswctype test.

Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com>

Carmelo Amoroso 15 years ago
parent
commit
8596cf8846
2 changed files with 8 additions and 1 deletions
  1. 7 0
      libc/misc/wchar/wchar.c
  2. 1 1
      test/locale-mbwc/dat_iswctype.c

+ 7 - 0
libc/misc/wchar/wchar.c

@@ -1143,6 +1143,13 @@ int wcswidth(const wchar_t *pwcs, size_t n)
 {
 	int count;
 	wchar_t wc;
+	size_t i;
+
+	for (i = 0 ; (i < n) && pwcs[i] ; i++) {
+		if (pwcs[i] != (pwcs[i] & 0x7f)) {
+			return -1;
+		}
+	}
 
     for (count = 0 ; n && (wc = *pwcs++) ; n--) {
 		if (wc <= 0xff) {

+ 1 - 1
test/locale-mbwc/dat_iswctype.c

@@ -240,7 +240,7 @@ TST_ISWCTYPE tst_iswctype_loc [] = {
       {	 { 0x007B, "cntrl"  }, { 0,1,0 }  },
       {	 { 0x007E, "cntrl"  }, { 0,1,0 }  },
       {	 { 0x007F, "cntrl"  }, { 0,0,0 }  },
-      {	 { 0x0080, "cntrl"  }, { 0,0,0 }  },
+      {	 { 0x0080, "cntrl"  }, { 0,1,0 }  },
       {	 { 0x0000, "digit"  }, { 0,1,0 }  },
       {	 { 0x001F, "digit"  }, { 0,1,0 }  },
       {	 { 0x0020, "digit"  }, { 0,1,0 }  },