2000-07-24  Ulrich Drepper  <drepper@redhat.com>

	* libio/iogetwline.c (_IO_getwline_info): Use wide character
	string functions.
This commit is contained in:
Ulrich Drepper 2000-07-25 00:38:27 +00:00
parent 33101abcb8
commit a64e8af150
7 changed files with 96 additions and 9 deletions

View File

@ -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> 2000-07-24 Jakub Jelinek <jakub@redhat.com>
* libio/wfiledoalloc.c (_IO_wfile_doallocate): Measure size * libio/wfiledoalloc.c (_IO_wfile_doallocate): Measure size

View File

@ -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 file is part of the GNU IO Library.
This library is free software; you can redistribute it and/or 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; wchar_t *t;
if ((_IO_size_t) len >= n) if ((_IO_size_t) len >= n)
len = n; len = n;
t = (wchar_t *) memchr ((void *) fp->_wide_data->_IO_read_ptr, t = wmemchr ((void *) fp->_wide_data->_IO_read_ptr, delim, len);
delim, len);
if (t != NULL) if (t != NULL)
{ {
_IO_size_t old_len = ptr - buf; _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) if (extract_delim > 0)
++len; ++len;
} }
memcpy ((void *) ptr, (void *) fp->_wide_data->_IO_read_ptr, wmemcpy ((void *) ptr, (void *) fp->_wide_data->_IO_read_ptr,
len); len);
fp->_wide_data->_IO_read_ptr = t; fp->_wide_data->_IO_read_ptr = t;
return old_len + len; 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; fp->_wide_data->_IO_read_ptr += len;
ptr += len; ptr += len;
n -= len; n -= len;

View File

@ -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> 2000-07-24 Jakub Jelinek <jakub@redhat.com>
* locales/de_DE (LC_TIME): Use `Mit', not `Mot' as abbreviation * locales/de_DE (LC_TIME): Use `Mit', not `Mot' as abbreviation

View File

@ -43,7 +43,7 @@ vpath %.h tests-mbwc
test-srcs := collate-test xfrm-test tst-fmon tst-rpmatch tst-trans \ test-srcs := collate-test xfrm-test tst-fmon tst-rpmatch tst-trans \
tst-mbswcs1 tst-mbswcs2 tst-mbswcs3 tst-mbswcs4 tst-mbswcs5 \ 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 \ #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 # 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 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 \ th_TH.in cs_CZ.in tst-mbswcs.sh tst-trans.sh tst-ctype.sh \
tst-ctype-de_DE.in $(wildcard tests-mbwc/*.[ch]) \ tst-ctype-de_DE.in $(wildcard tests-mbwc/*.[ch]) \
$(addprefix tst-fmon-locales/tstfmon_,$(fmon-tests)) \ $(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. # Get $(inst_i18ndir) defined.
include ../Makeconfig 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 \ tests: $(objpfx)sort-test.out $(objpfx)tst-fmon.out $(objpfx)tst-locale.out \
$(objpfx)tst-rpmatch.out $(objpfx)tst-trans.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 \ $(objpfx)sort-test.out: sort-test.sh $(objpfx)collate-test $(objpfx)xfrm-test \
$(test-input-data) $(addprefix $(objpfx),$(CTYPE_FILES)) $(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 \ $(objpfx)sort-test.out \
$(addprefix $(objpfx),$(CTYPE_FILES)) $(addprefix $(objpfx),$(CTYPE_FILES))
$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)' $(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 endif
# Sometimes the whole collection of locale files should be installed. # Sometimes the whole collection of locale files should be installed.

40
localedata/tst-wctype.c Normal file
View File

@ -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;
}

View File

@ -0,0 +1 @@
ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずabcdefghjklmnoprrstuvwxyz

30
localedata/tst-wctype.sh Executable file
View File

@ -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 $?