diff options
author | Ulrich Drepper <drepper@redhat.com> | 2001-08-09 05:21:51 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2001-08-09 05:21:51 +0000 |
commit | 0f78390bd799fc0b0394240a9a704591481ac8c6 (patch) | |
tree | ebcee12924e287ad5811b0a5e2387645dfb44361 | |
parent | 8f739934b026cd0c298e3196d38d483eb1f88bed (diff) | |
download | glibc-0f78390bd799fc0b0394240a9a704591481ac8c6.tar glibc-0f78390bd799fc0b0394240a9a704591481ac8c6.tar.gz glibc-0f78390bd799fc0b0394240a9a704591481ac8c6.tar.bz2 glibc-0f78390bd799fc0b0394240a9a704591481ac8c6.zip |
Update.
* locale/elem-hash.h (elem_hash): Correct stupid mistake and
create real hash values now.
Patch by Isamu Hasegawa <isamu@yamato.ibm.com>.
* libio/iofgetpos.c (_IO_new_fgetpos): Correct a few problems in
the handling of wide streams.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | libio/iofgetpos.c | 34 | ||||
-rw-r--r-- | locale/elem-hash.h | 8 |
3 files changed, 34 insertions, 15 deletions
@@ -1,5 +1,12 @@ 2001-08-08 Ulrich Drepper <drepper@redhat.com> + * locale/elem-hash.h (elem_hash): Correct stupid mistake and + create real hash values now. + Patch by Isamu Hasegawa <isamu@yamato.ibm.com>. + + * libio/iofgetpos.c (_IO_new_fgetpos): Correct a few problems in + the handling of wide streams. + * libio/ioungetwc.c (ungetwc): Orient stream first. * libio/Makefile (tests): Add tst-ungetwc1. * libio/tst-ungetwc1.c: New file. diff --git a/libio/iofgetpos.c b/libio/iofgetpos.c index 7701ce6a4d..b8b2f874a3 100644 --- a/libio/iofgetpos.c +++ b/libio/iofgetpos.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1995-1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1995-1999, 2000, 2001 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 @@ -27,6 +27,7 @@ #include "libioP.h" #include <errno.h> +#include <stdlib.h> #include <shlib-compat.h> int @@ -35,14 +36,19 @@ _IO_new_fgetpos (fp, posp) _IO_fpos_t *posp; { _IO_off_t pos; + int result = 0; CHECK_FILE (fp, EOF); _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); _IO_flockfile (fp); pos = _IO_seekoff (fp, 0, _IO_seek_cur, 0); if (_IO_in_backup (fp)) - pos -= fp->_IO_save_end - fp->_IO_save_base; - _IO_funlockfile (fp); - _IO_cleanup_region_end (0); + { + if (fp->_vtable_offset != 0 || fp->_mode <= 0) + pos -= fp->_IO_save_end - fp->_IO_save_base; + else + /* XXX For now. */ + abort (); + } if (pos == _IO_pos_BAD) { /* ANSI explicitly requires setting errno to a positive value on @@ -51,14 +57,20 @@ _IO_new_fgetpos (fp, posp) if (errno == 0) __set_errno (EIO); #endif - return EOF; + result = EOF; } - posp->__pos = pos; - if (fp->_mode > 0 - && (*fp->_codecvt->__codecvt_do_encoding) (fp->_codecvt) < 0) - /* This is a stateful encoding, safe the state. */ - posp->__state = fp->_wide_data->_IO_state; - return 0; + else + { + posp->__pos = pos; + if (fp->_mode > 0 + && (*fp->_codecvt->__codecvt_do_encoding) (fp->_codecvt) < 0) + /* This is a stateful encoding, safe the state. */ + posp->__state = fp->_wide_data->_IO_state; + } + + _IO_funlockfile (fp); + _IO_cleanup_region_end (0); + return result; } strong_alias (_IO_new_fgetpos, __new_fgetpos) diff --git a/locale/elem-hash.h b/locale/elem-hash.h index f68e764731..9efe8d1385 100644 --- a/locale/elem-hash.h +++ b/locale/elem-hash.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1999 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper, <drepper@cygnus.com>. @@ -24,10 +24,10 @@ elem_hash (const char *str, int_fast32_t n) { int32_t result = n; - while (n > 0) + while (n-- > 0) { - n <<= 3; - n += *str++; + result <<= 3; + result += *str++; } return result; |