diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | libio/iogetwline.c | 11 | ||||
-rw-r--r-- | localedata/ChangeLog | 7 | ||||
-rw-r--r-- | localedata/Makefile | 11 | ||||
-rw-r--r-- | localedata/tst-wctype.c | 40 | ||||
-rw-r--r-- | localedata/tst-wctype.input | 1 | ||||
-rwxr-xr-x | localedata/tst-wctype.sh | 30 |
7 files changed, 96 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog index 971ec0cb1d..f989092f44 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2000-07-24 Ulrich Drepper <drepper@redhat.com> + + * libio/iogetwline.c (_IO_getwline_info): Use wide character + string functions. + 2000-07-24 Jakub Jelinek <jakub@redhat.com> * libio/wfiledoalloc.c (_IO_wfile_doallocate): Measure size diff --git a/libio/iogetwline.c b/libio/iogetwline.c index 402158a4ef..b7f111586a 100644 --- a/libio/iogetwline.c +++ b/libio/iogetwline.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1997, 1998, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU IO Library. This library is free software; you can redistribute it and/or @@ -91,8 +91,7 @@ _IO_getwline_info (fp, buf, n, delim, extract_delim, eof) wchar_t *t; if ((_IO_size_t) len >= n) len = n; - t = (wchar_t *) memchr ((void *) fp->_wide_data->_IO_read_ptr, - delim, len); + t = wmemchr ((void *) fp->_wide_data->_IO_read_ptr, delim, len); if (t != NULL) { _IO_size_t old_len = ptr - buf; @@ -103,12 +102,12 @@ _IO_getwline_info (fp, buf, n, delim, extract_delim, eof) if (extract_delim > 0) ++len; } - memcpy ((void *) ptr, (void *) fp->_wide_data->_IO_read_ptr, - len); + wmemcpy ((void *) ptr, (void *) fp->_wide_data->_IO_read_ptr, + len); fp->_wide_data->_IO_read_ptr = t; return old_len + len; } - memcpy ((void *) ptr, (void *) fp->_wide_data->_IO_read_ptr, len); + wmemcpy ((void *) ptr, (void *) fp->_wide_data->_IO_read_ptr, len); fp->_wide_data->_IO_read_ptr += len; ptr += len; n -= len; diff --git a/localedata/ChangeLog b/localedata/ChangeLog index 1555ccd217..b347763bd6 100644 --- a/localedata/ChangeLog +++ b/localedata/ChangeLog @@ -1,3 +1,10 @@ +2000-07-24 Ulrich Drepper <drepper@redhat.com> + + * Makefile: Add rules to build, run, and distribute tst-wctype. + * tst-wctype.c: New file. + * tst-wctype.input: New file. + * tst-wctype.sh: New file. + 2000-07-24 Jakub Jelinek <jakub@redhat.com> * locales/de_DE (LC_TIME): Use `Mit', not `Mot' as abbreviation diff --git a/localedata/Makefile b/localedata/Makefile index 87216d296f..1a24df978e 100644 --- a/localedata/Makefile +++ b/localedata/Makefile @@ -43,7 +43,7 @@ vpath %.h tests-mbwc test-srcs := collate-test xfrm-test tst-fmon tst-rpmatch tst-trans \ tst-mbswcs1 tst-mbswcs2 tst-mbswcs3 tst-mbswcs4 tst-mbswcs5 \ - tst-ctype + tst-ctype tst-wctype #test-input := de_DE.ISO-8859-1 da_DK.ISO-8859-1 fr_CA,2.13.ISO-8859-1 \ # hr_HR.ISO-8859-2 # once it is fixed: cs_CZ.ISO-8859-2 test-input := de_DE.ISO-8859-1 en_US.ISO-8859-1 @@ -70,7 +70,8 @@ distribute := CHECKSUMS README SUPPORTED ChangeLog \ th_TH.in cs_CZ.in tst-mbswcs.sh tst-trans.sh tst-ctype.sh \ tst-ctype-de_DE.in $(wildcard tests-mbwc/*.[ch]) \ $(addprefix tst-fmon-locales/tstfmon_,$(fmon-tests)) \ - gen-locale.sh show-ucs-data.c + gen-locale.sh show-ucs-data.c \ + tst-wctype.sh tst-wctype.input # Get $(inst_i18ndir) defined. include ../Makeconfig @@ -136,7 +137,7 @@ $(addsuffix .out,$(addprefix $(objpfx),$(locale_test_suite))): %: \ tests: $(objpfx)sort-test.out $(objpfx)tst-fmon.out $(objpfx)tst-locale.out \ $(objpfx)tst-rpmatch.out $(objpfx)tst-trans.out \ - $(objpfx)tst-mbswcs.out $(objpfx)tst-ctype.out + $(objpfx)tst-mbswcs.out $(objpfx)tst-ctype.out $(objpfx)tst-wctype.out $(objpfx)sort-test.out: sort-test.sh $(objpfx)collate-test $(objpfx)xfrm-test \ $(test-input-data) $(addprefix $(objpfx),$(CTYPE_FILES)) @@ -166,6 +167,10 @@ $(objpfx)tst-ctype.out: tst-ctype.sh $(objpfx)tst-ctype \ $(objpfx)sort-test.out \ $(addprefix $(objpfx),$(CTYPE_FILES)) $(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)' +$(objpfx)tst-wctype.out: tst-wctype.sh $(objpfx)tst-wctype \ + $(objpfx)sort-test.out tst-wctype.input \ + $(addprefix $(objpfx),$(CTYPE_FILES)) + $(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)' endif # Sometimes the whole collection of locale files should be installed. diff --git a/localedata/tst-wctype.c b/localedata/tst-wctype.c new file mode 100644 index 0000000000..6c59a50427 --- /dev/null +++ b/localedata/tst-wctype.c @@ -0,0 +1,40 @@ +#include <error.h> +#include <locale.h> +#include <stdio.h> +#include <stdlib.h> +#include <wchar.h> +#include <wctype.h> + +int +main (void) +{ + wctype_t wct; + wchar_t buf[1000]; + int result = 1; + + setlocale (LC_ALL, ""); + wprintf (L"locale = %s\n", setlocale (LC_CTYPE, NULL)); + + wct = wctype ("jhira"); + if (wct == 0) + error (EXIT_FAILURE, 0, "jhira: no such character class"); + + if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL) + { + int n; + + wprintf (L"buf[] = \"%ls\"\n", buf); + + result = 0; + + for (n = 0; buf[n] != L'\0'; ++n) + { + wprintf (L"jhira(U%04lx = %lc) = %d\n", (long) buf[n], buf[n], + iswctype (buf[n], wct)); + result |= ((buf[n] < 0xff && iswctype (buf[n], wct)) + || (buf[n] > 0xff && !iswctype (buf[n], wct))); + } + } + + return result; +} diff --git a/localedata/tst-wctype.input b/localedata/tst-wctype.input new file mode 100644 index 0000000000..a7b4928c39 --- /dev/null +++ b/localedata/tst-wctype.input @@ -0,0 +1 @@ +ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずabcdefghjklmnoprrstuvwxyz diff --git a/localedata/tst-wctype.sh b/localedata/tst-wctype.sh new file mode 100755 index 0000000000..ae32525e3f --- /dev/null +++ b/localedata/tst-wctype.sh @@ -0,0 +1,30 @@ +#! /bin/sh +# Test locale-define character classes. +# Copyright (C) 1999, 2000 Free Software Foundation, Inc. +# This file is part of the GNU C Library. +# +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with the GNU C Library; see the file COPYING.LIB. If +# not, write to the Free Software Foundation, Inc., +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +common_objpfx=$1 +run_program_prefix=$2 + +# Run the test program. +LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \ +LC_ALL=ja_JP.EUC-JP ${run_program_prefix} \ + ${common_objpfx}localedata/tst-wctype < tst-wctype.input \ + > ${common_objpfx}localedata/tst-wctype.out + +exit $? |