From ea31b613feba1c5f34ff2cf9f2c0bab3be4f8d2a Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 16 Jan 2003 02:27:47 +0000 Subject: Update. * iconv/gconv_simple.c (STORE_REST): Explicitly store the total expected size into state. (UNPACK_BYTES): Do the reverse. * wcsmbs/tst-mbrtowc.c (utf8_test_1): Add test for the bug. Reported by Al Viro . --- wcsmbs/tst-mbrtowc.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'wcsmbs') diff --git a/wcsmbs/tst-mbrtowc.c b/wcsmbs/tst-mbrtowc.c index 4f1d1e586d..2400d8369f 100644 --- a/wcsmbs/tst-mbrtowc.c +++ b/wcsmbs/tst-mbrtowc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2000. @@ -17,6 +17,8 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +/* We always want assert to be fully defined. */ +#undef NDEBUG #include #include #include @@ -45,6 +47,20 @@ utf8_test_1 (void) assert (mbrtowc (&wc, "", 1, &s) == 0); /* test final byte processing */ assert (wc == 0); /* test final byte decoding */ + /* The following test is by Al Viro . */ + const char str[] = "\xe0\xa0\x80"; + + wc = 42; /* arbitrary number */ + memset (&s, 0, sizeof (s)); /* get s into initial state */ + assert (mbrtowc (&wc, str, 1, &s) == -2); + assert (mbrtowc (&wc, str + 1, 2, &s) == 2); + assert (wc == 0x800); + + wc = 42; /* arbitrary number */ + memset (&s, 0, sizeof (s)); /* get s into initial state */ + assert (mbrtowc (&wc, str, 3, &s) == 3); + assert (wc == 0x800); + return 0; } -- cgit v1.2.3