I want to send support for LC_NUMERIC adapted from FreeBSD. Will try to
do it in small diffs in several emails.
Before that, I prefer to send first patch with an updated fix for
regress/lib/libc/locale/check_isw, the commentaries of
http://openbsd.7691.n7.nabble.com/Fix-for-regress-lib-libc-locale-check-isw-td225266.html
still apply.

Second patch are additional cases.

--
Dios, gracias por tu amor infinito.
-- Vladimir Támara Patiño. http://vtamara.pasosdeJesus.org/
 http://www.pasosdejesus.org/dominio_publico_colombia.html

diff -ruN src55-orig/regress/lib/libc/locale/check_isw/check_isw.c 
src/regress/lib/libc/locale/check_isw/check_isw.c
--- src55-orig/regress/lib/libc/locale/check_isw/check_isw.c    Thu Aug 11 
16:57:02 2005
+++ src/regress/lib/libc/locale/check_isw/check_isw.c   Sun Nov 10 07:22:38 2013
@@ -19,9 +19,10 @@
  * functions.
  */
 
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <ctype.h>
+#include <string.h>
 #include <wchar.h>
 #include <wctype.h>
 
@@ -50,7 +51,7 @@
 {
        int i;
 
-       for (i = 0; i < 256; i++) {
+       for (i = 0; i < 128; i++) {
                printf(" %02x: ", i);
                check_bool(isalnum(i), iswalnum(i), '1');
                check_bool(isalpha(i), iswalpha(i), '2');
@@ -69,7 +70,7 @@
                if (i % 8 == 7)
                        printf("\n");
        }
-       printf("%\n");
+       printf("\n");
 }
 
 void
@@ -82,7 +83,7 @@
        wchar_t c, d;
        mbstate_t state;
 
-       s = malloc(256);
+       s = malloc(128);
        if (!s) {
                bad++;
                return;
@@ -93,14 +94,15 @@
                free(s);
                return;
        }
-       for (i = 0; i < 256; i++)
+       for (i = 0; i < 127; i++)
                s[i] = i+1;
 
        j = 0;
+       memset(&state, 0, sizeof(state));
        mbrtowc(NULL, NULL, 1, &state);
        printf(" %02x: ", 0);
 
-       while ((n = mbrtowc(&c, s+j, 256-j, &state)) == 1) {
+       while (j < 127 && (n = mbrtowc(&c, s+j, 256-j, &state)) == 1) {
                printf(" %02x: ", s[j]);
                check_bool(isalnum(s[j]), iswalnum(c), '1');
                check_bool(isalpha(s[j]), iswalpha(c), '2');
@@ -129,9 +131,6 @@
                if (s[j] % 8 == 7)
                        printf("\n");
                j++;
-       }
-       if (n != 0 || j != 255) {
-               bad++;
        }
        free(s);
        free(buf);

diff -ruN src55-p1/regress/lib/libc/locale/check_isw/check_isw.c 
src/regress/lib/libc/locale/check_isw/check_isw.c
--- src55-p1/regress/lib/libc/locale/check_isw/check_isw.c.orig Sun Nov 10 
07:31:25 2013
+++ src/regress/lib/libc/locale/check_isw/check_isw.c   Sun Nov 10 07:32:21 2013
@@ -20,6 +20,7 @@
  */
 
 #include <ctype.h>
+#include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -28,6 +29,14 @@
 
 int bad = 0;
 
+#define p(t) printf("%s:\t ",#t); \
+       if (t) { \
+               printf("\x1b[38;5;2mOK\x1b[0m\n"); \
+       } else { \
+               bad++; \
+               printf("\x1b[38;5;1mERROR\x1b[0m\n"); \
+       }
+
 void
 check_bool(int v1, int v2, char msg)
 {
@@ -136,11 +145,87 @@
        free(buf);
 }
 
+void
+test3()
+{
+       /** toupper, tolower single byte encoding */
+       char *nl = setlocale(LC_ALL, "es_CO.ISO8859-1");
+       printf("locale %s\n", nl);
+       /* À -> 0xc0, à -> 0xe0 */
+       int c;
+       for(c = 0xc0; c < 0xde; c++) {
+               if (c != 0xd7) { // 0xd7 -> ×, 0xF7 -> ÷
+                       printf("c=%x ", c);
+                       p(tolower(c) == c+0x20); 
+                       p(toupper(c+0x20) == c); 
+               }
+       }
+       /* http://en.wikipedia.org/w/index.php?title=ISO/IEC_8859-1 */
+       for (c = 0x21; c < 0x2F; c++) {
+               printf("c=%x ", c);
+               p(ispunct(c));
+       }
+       for (c = 0x30; c < 0x39; c++) {
+               printf("c=%x ", c);
+               p(isdigit(c));
+       }
+       for (c = 0x3A; c < 0x40; c++) {
+               printf("c=%x ", c);
+               p(ispunct(c));
+       }
+       for (c = 0x41; c < 0x5A; c++) {
+               printf("c=%x ", c);
+               p(isalpha(c));
+               p(isalpha(c+0x20));
+       }
+       for (c = 0x5B; c < 0x60; c++) {
+               printf("c=%x ", c);
+               p(ispunct(c));
+       }
+       p(ispunct(0x7B));
+       p(ispunct(0x7C));
+       p(ispunct(0x7D));
+       p(ispunct(0x7E));
+       for (c = 0xA1; c < 0xBF; c++) {
+               printf("c=%x ", c);
+               p(ispunct(c));
+       }
+       for (c = 0xC0; c < 0xFF; c++) {
+               if (c != 0xD7 && c != 0xF7) {
+                       printf("c=%x ", c);
+                       p(isalpha(c));
+               }
+       }
+       
+       nl = setlocale(LC_ALL, "ru_RU.KOI8-R");
+       printf("locale %s\n", nl);
+       /* a -> 0xc0, A -> 0xe0 */
+       for(c = 0xc0; c < 0xdf; c++) {
+               printf("c=%x ", c);
+               p(islower(c));
+               p(isupper(c+0x20));
+               p(toupper(c) == c+0x20); 
+               p(tolower(c+0x20) == c); 
+       }
+       
+       /** multi-byte encoding */
+       nl = setlocale(LC_ALL, "es_CO.UTF-8");
+       printf("locale %s\n", nl);
+       for(c = 0x41; c < 0x5A; c++) {
+               printf("c=%x ", c);
+               p(tolower(c) == c+0x20); 
+               p(toupper(c+0x20) == c); 
+               p(isalpha(c));
+               p(isalpha(c+0x20));
+       }
 
+}
+
 int
 main()
 {
        test1();
        test2();
+       test3();
        return bad !=0;
 }

Reply via email to