From de153e7f50baa4ea7fac013f3b77b3a4fe314664 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 31 Oct 2000 05:20:53 +0000 Subject: [PATCH] Update. * stdio-common/Makefile (tests): Add tst-fmemopen. * stdio-common/tst-fmemopen.c: New file. Test case by Ben Collins . * libio/iofopncook.c (_IO_cookie_seek): Correct test for error. * libio/fmemopen.c (fmemopen_read): Return 0 at end of buffer. (fmemopen_write): Set errno at end of buffer. --- ChangeLog | 9 ++++ libio/fmemopen.c | 10 ++-- libio/iofopncook.c | 3 +- localedata/ChangeLog | 65 ++++++++++++++++++++++++++ stdio-common/tst-fmemopen.c | 111 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 194 insertions(+), 4 deletions(-) create mode 100644 stdio-common/tst-fmemopen.c diff --git a/ChangeLog b/ChangeLog index a9c9b69..78e5d31 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2000-10-30 Ulrich Drepper + * stdio-common/Makefile (tests): Add tst-fmemopen. + * stdio-common/tst-fmemopen.c: New file. + Test case by Ben Collins . + + * libio/iofopncook.c (_IO_cookie_seek): Correct test for error. + + * libio/fmemopen.c (fmemopen_read): Return 0 at end of buffer. + (fmemopen_write): Set errno at end of buffer. + * posix/runtests.c (main): Don't use exit() to avoid warning with broken compilers. diff --git a/libio/fmemopen.c b/libio/fmemopen.c index 92df2e4..99670b5 100644 --- a/libio/fmemopen.c +++ b/libio/fmemopen.c @@ -69,6 +69,7 @@ * so I don't need the stream to add null characters on its own.) */ +#include #include #include #include @@ -96,7 +97,7 @@ fmemopen_read (void *cookie, char *b, size_t s) if (c->pos + s > c->size) { if (c->pos == c->size) - return -1; + return 0; s = c->size - c->pos; } @@ -123,7 +124,10 @@ fmemopen_write (void *cookie, const char *b, size_t s) if (c->pos + s + addnullc > c->size) { if (c->pos + addnullc == c->size) - return -1; + { + __set_errno (ENOSPC); + return -1; + } s = c->size - c->pos - addnullc; } @@ -142,7 +146,7 @@ fmemopen_write (void *cookie, const char *b, size_t s) int -fmemopen_seek (void *cookie, _IO_off64_t * p, int w) +fmemopen_seek (void *cookie, _IO_off64_t *p, int w) { _IO_off64_t np; fmemopen_cookie_t *c; diff --git a/libio/iofopncook.c b/libio/iofopncook.c index c016cfb..52e025b 100644 --- a/libio/iofopncook.c +++ b/libio/iofopncook.c @@ -76,7 +76,8 @@ _IO_cookie_seek (fp, offset, dir) return ((cfile->__io_functions.seek == NULL || (cfile->__io_functions.seek (cfile->__cookie, &offset, dir) - == (_IO_off64_t) -1)) + == -1) + || offset == (_IO_off64_t) -1) ? _IO_pos_BAD : offset); } diff --git a/localedata/ChangeLog b/localedata/ChangeLog index ed2fe80..e420ad0 100644 --- a/localedata/ChangeLog +++ b/localedata/ChangeLog @@ -1,3 +1,68 @@ +2000-10-29 Bruno Haible + + * locales/translit_hangul: New file. + * locales/ko_KR (LC_CTYPE): Include it. + +2000-10-29 Bruno Haible + + * locales/translit_cjk_variants: New file. + * locales/ja_JP (LC_CTYPE): Include it. + +2000-10-29 Bruno Haible + + * locales/da_DK (LC_CTYPE): Include translit_combining, add A-ring + transliteration rules. + +2000-10-29 Bruno Haible + + * locales/de_DE (LC_CTYPE): Include translit_combining, add umlaut + transliteration rules. + * locales/de_AT (LC_CTYPE): Include de_DE instead of i18n. + * locales/de_BE (LC_CTYPE): Likewise. + * locales/de_CH (LC_CTYPE): Likewise. + * locales/de_LU (LC_CTYPE): Likewise. + * locales/de_DE@euro (LC_CTYPE): Include de_DE instead of i18n. + * locales/de_AT@euro (LC_CTYPE): Include de_AT instead of i18n. + * locales/de_BE@euro (LC_CTYPE): Include de_BE instead of i18n. + * locales/de_LU@euro (LC_CTYPE): Include de_LU instead of i18n. + +2000-10-29 Bruno Haible + + * locales/translit_combining: New file. + * locales/fr_FR (LC_CTYPE): Include it. + * locales/fr_BE (LC_CTYPE): Include fr_FR instead of i18n. + * locales/fr_CA (LC_CTYPE): Likewise. + * locales/fr_CH (LC_CTYPE): Likewise. + * locales/fr_LU (LC_CTYPE): Likewise. + * locales/fr_FR@euro (LC_CTYPE): Include fr_FR instead of i18n. + * locales/fr_BE@euro (LC_CTYPE): Include fr_BE instead of i18n. + * locales/fr_LU@euro (LC_CTYPE): Include fr_LU instead of i18n. + +2000-10-29 Bruno Haible + + * locales/translit_wide: New file. + * locales/translit_narrow: New file. + * locales/translit_font: New file. + * locales/translit_circle: New file. + * locales/translit_small: New file. + * locales/translit_fraction: New file. + * locales/translit_compat: New file. + * locales/translit_cjk_compat: New file. + * locales/translit_neutral: New file. Include all of the above. + * locales/i18n (LC_CTYPE): Include translit_neutral. Remove a few + German and Danish specific rules. + +2000-10-29 Bruno Haible + + * locales/ja_JP (LC_CTYPE): Refer to "i18n" instead of duplicating it. + * locales/zh_CN (LC_CTYPE): Likewise. + * locales/ko_KR (LC_CTYPE): Likewise. + +2000-10-29 Bruno Haible + + * charmaps/UTF-8: Set width of U200B to 0. + * charmaps/GB18030: Likewise. + 2000-10-29 Ulrich Drepper * charmaps/BIG5: Update. diff --git a/stdio-common/tst-fmemopen.c b/stdio-common/tst-fmemopen.c new file mode 100644 index 0000000..f22ebd5 --- /dev/null +++ b/stdio-common/tst-fmemopen.c @@ -0,0 +1,111 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define TEST_FILE "test-1" + +int +main (void) +{ + const char blah[] = "BLAH"; + FILE *fp; + char *mmap_data; + int ch, fd; + struct stat fs; + const char *cp; + + /* setup the physical file, and use it */ + if ((fp = fopen (TEST_FILE, "w+")) == NULL) + exit (1); + if (fwrite (blah, 1, strlen (blah), fp) != strlen (blah)) + exit (2); + + rewind (fp); + printf ("file: "); + cp = blah; + while ((ch = getc (fp)) != EOF) + { + fputc (ch, stdout); + if (ch != *cp) + { + printf ("\ncharacter %d: '%c' instead of '%c'\n", + cp - blah, ch, *cp); + exit (1); + } + ++cp; + } + fputc ('\n', stdout); + if (ferror (fp)) + { + puts ("fp: error"); + exit (1); + } + if (feof (fp)) + printf ("fp: EOF\n"); + else + { + puts ("not EOF"); + exit (1); + } + fclose (fp); + + /* Now, mmap the file into a buffer, and do that too */ + if ((fd = open (TEST_FILE, O_RDONLY)) == -1) + exit (3); + if (fstat (fd, &fs) == -1) + exit (4); + + if ((mmap_data = (char *) mmap (NULL, fs.st_size, PROT_READ, + MAP_SHARED, fd, 0)) == NULL) + { + if (errno == ENOSYS) + exit (0); + exit (5); + } + + if ((fp = fmemopen (mmap_data, fs.st_size, "r")) == NULL) + exit (1); + + printf ("mem: "); + cp = blah; + while ((ch = getc (fp)) != EOF) + { + fputc (ch, stdout); + if (ch != *cp) + { + printf ("%d character: '%c' instead of '%c'\n", + cp - blah, ch, *cp); + exit (1); + } + ++cp; + } + + fputc ('\n', stdout); + + if (ferror (fp)) + { + puts ("fp: error"); + exit (1); + } + if (feof (fp)) + printf ("fp: EOF\n"); + else + { + puts ("not EOF"); + exit (1); + } + + fclose (fp); + + munmap (mmap_data, fs.st_size); + + unlink (TEST_FILE); + + return 0; +} -- 2.7.4