summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauri Tirkkonen <lotheac@iki.fi>2014-10-21 23:21:04 +0300
committerDan McDonald <danmcd@omniti.com>2014-10-24 10:41:34 -0400
commit81cc999477f2f5f0896ee349f6ec8fc2f804ece3 (patch)
tree72a8b90f441e6d253ac6d8ba776268305f73fa9d
parentc375047346b15ac13f787bc562bb7e724c97baf5 (diff)
downloadillumos-joyent-81cc999477f2f5f0896ee349f6ec8fc2f804ece3.tar.gz
5238 iswgraph(L'a') returns 0, but iswctype(L'a', wctype("graph")) nonzero
Reviewed by: Garrett D'Amore <garrett@damore.org> Reviewed by: David Höppner <0xffea@gmail.com> Approved by: Dan McDonald <danmcd@omniti.com>
-rw-r--r--usr/src/lib/libc/port/locale/iswctype.c2
-rw-r--r--usr/src/pkg/manifests/system-test-libctest.mf5
-rw-r--r--usr/src/test/libc-tests/runfiles/default.run2
-rw-r--r--usr/src/test/libc-tests/tests/Makefile2
-rw-r--r--usr/src/test/libc-tests/tests/wctype/Makefile21
-rw-r--r--usr/src/test/libc-tests/tests/wctype/wctype_test.c85
6 files changed, 115 insertions, 2 deletions
diff --git a/usr/src/lib/libc/port/locale/iswctype.c b/usr/src/lib/libc/port/locale/iswctype.c
index 1698113ace..25d3c6dc34 100644
--- a/usr/src/lib/libc/port/locale/iswctype.c
+++ b/usr/src/lib/libc/port/locale/iswctype.c
@@ -138,7 +138,7 @@ DEFN_ISWTYPE(alpha, _CTYPE_A)
DEFN_ISWTYPE(blank, _CTYPE_B)
DEFN_ISWTYPE(cntrl, _CTYPE_C)
DEFN_ISWTYPE(digit, _CTYPE_D)
-DEFN_ISWTYPE(graph, _CTYPE_D)
+DEFN_ISWTYPE(graph, _CTYPE_G)
DEFN_ISWTYPE(lower, _CTYPE_L)
DEFN_ISWTYPE(upper, _CTYPE_U)
DEFN_ISWTYPE(print, _CTYPE_R)
diff --git a/usr/src/pkg/manifests/system-test-libctest.mf b/usr/src/pkg/manifests/system-test-libctest.mf
index c65250d7a5..bfb547a911 100644
--- a/usr/src/pkg/manifests/system-test-libctest.mf
+++ b/usr/src/pkg/manifests/system-test-libctest.mf
@@ -43,6 +43,11 @@ $(i386_ONLY)file path=opt/libc-tests/tests/wcsrtombs_test.amd64 mode=0555
$(i386_ONLY)file path=opt/libc-tests/tests/wcsrtombs_test.i386 mode=0555
$(sparc_ONLY)file path=opt/libc-tests/tests/wcsrtombs_test.sparc mode=0555
$(sparc_ONLY)file path=opt/libc-tests/tests/wcsrtombs_test.sparcv9 mode=0555
+file path=opt/libc-tests/tests/wctype_test mode=0555
+$(i386_ONLY)file path=opt/libc-tests/tests/wctype_test.amd64 mode=0555
+$(i386_ONLY)file path=opt/libc-tests/tests/wctype_test.i386 mode=0555
+$(sparc_ONLY)file path=opt/libc-tests/tests/wctype_test.sparc mode=0555
+$(sparc_ONLY)file path=opt/libc-tests/tests/wctype_test.sparcv9 mode=0555
license lic_CDDL license=lic_CDDL
depend fmri=locale/de type=require
depend fmri=locale/en type=require
diff --git a/usr/src/test/libc-tests/runfiles/default.run b/usr/src/test/libc-tests/runfiles/default.run
index ae204ecccd..8602bbc543 100644
--- a/usr/src/test/libc-tests/runfiles/default.run
+++ b/usr/src/test/libc-tests/runfiles/default.run
@@ -27,3 +27,5 @@ outputdir = /var/tmp/test_results
[/opt/libc-tests/tests/nl_langinfo_test]
[/opt/libc-tests/tests/wcsrtombs_test]
+
+[/opt/libc-tests/tests/wctype_test]
diff --git a/usr/src/test/libc-tests/tests/Makefile b/usr/src/test/libc-tests/tests/Makefile
index 01207bd6d1..ece9ea77b3 100644
--- a/usr/src/test/libc-tests/tests/Makefile
+++ b/usr/src/test/libc-tests/tests/Makefile
@@ -14,7 +14,7 @@
# Copyright 2014 Garrett D'Amore <garrett@damore.org>
#
-SUBDIRS = newlocale nl_langinfo wcsrtombs
+SUBDIRS = newlocale nl_langinfo wcsrtombs wctype
include $(SRC)/Makefile.master
include $(SRC)/test/Makefile.com
diff --git a/usr/src/test/libc-tests/tests/wctype/Makefile b/usr/src/test/libc-tests/tests/wctype/Makefile
new file mode 100644
index 0000000000..751de6e5dd
--- /dev/null
+++ b/usr/src/test/libc-tests/tests/wctype/Makefile
@@ -0,0 +1,21 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+#
+
+include $(SRC)/Makefile.master
+
+PROG = wctype_test
+ARCHPROG = wctype_test
+
+include ../Makefile.com
diff --git a/usr/src/test/libc-tests/tests/wctype/wctype_test.c b/usr/src/test/libc-tests/tests/wctype/wctype_test.c
new file mode 100644
index 0000000000..1a426ada57
--- /dev/null
+++ b/usr/src/test/libc-tests/tests/wctype/wctype_test.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2014 Lauri Tirkkonen <lotheac@iki.fi>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * This program tests that the characters defined in the POSIX-1.2008 Portable
+ * Character Set are classified correctly by the iswctype and isw* functions.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <wchar.h>
+#include <wctype.h>
+#include <locale.h>
+#include <err.h>
+#include "test_common.h"
+
+wint_t upper_should[] = L"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+wint_t lower_should[] = L"abcdefghijklmnopqrstuvwxyz";
+wint_t digit_should[] = L"0123456789";
+wint_t space_should[] = L"\t\n\v\f\r ";
+wint_t cntrl_should[] = L"\a\b\t\n\v\f\r\0\001\002\003\004\005\006\016\017\020"
+"\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037";
+wint_t punct_should[] = L"!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
+wint_t xdigit_should[] = L"0123456789ABCDEFabcdef";
+wint_t blank_should[] = L" \t";
+wint_t only_space_should[] = L" ";
+
+#define test_ctype_subset(x, y) do {\
+ test_t t = test_start(#x "_should is subset of " #y);\
+ wctype_t class = wctype(#y);\
+ if (!class) test_failed(t, "wctype(\"%s\") returned 0", #y);\
+ size_t nchars = (sizeof (x ## _should) / sizeof (*x ## _should)) - 1;\
+ for (wint_t *wc = x ## _should; wc < x ## _should + nchars; wc++) {\
+ if (!iswctype(*wc, class))\
+ test_failed(t, "iswctype(L'%lc', wctype(\"%s\"))"\
+ "returned 0", *wc, #y);\
+ if (!isw ## y(*wc))\
+ test_failed(t, "isw%s(L'%lc') returned 0", #y, *wc);\
+ }\
+ test_passed(t);\
+} while (*"\0")
+
+#define test_ctype(x) test_ctype_subset(x, x)
+
+int main(void) {
+ if (!setlocale(LC_CTYPE, "POSIX"))
+ err(1, "setlocale POSIX failed");
+ test_ctype(upper);
+ test_ctype(lower);
+ test_ctype(digit);
+ test_ctype(space);
+ test_ctype(cntrl);
+ test_ctype(punct);
+ test_ctype(xdigit);
+ test_ctype(blank);
+
+ test_ctype_subset(upper, alpha);
+ test_ctype_subset(lower, alpha);
+ test_ctype_subset(upper, alnum);
+ test_ctype_subset(lower, alnum);
+ test_ctype_subset(digit, alnum);
+ test_ctype_subset(upper, print);
+ test_ctype_subset(lower, print);
+ test_ctype_subset(digit, print);
+ test_ctype_subset(punct, print);
+ test_ctype_subset(only_space, print);
+ test_ctype_subset(upper, graph);
+ test_ctype_subset(lower, graph);
+ test_ctype_subset(digit, graph);
+ test_ctype_subset(punct, graph);
+ return (0);
+}