diff options
author | Jakub Jelinek <jakub@redhat.com> | 2005-09-12 07:10:59 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2005-09-12 07:10:59 +0000 |
commit | 5e6e144e096c83beefb5bd50ea22da7266e72aee (patch) | |
tree | 80b4ba2f5794225b6f0dbee4171394423dc82cf2 | |
parent | 753ea4414a6a5994cf156d9a11582d18a1fb2a6f (diff) | |
download | glibc-5e6e144e096c83beefb5bd50ea22da7266e72aee.tar.gz glibc-5e6e144e096c83beefb5bd50ea22da7266e72aee.tar.xz glibc-5e6e144e096c83beefb5bd50ea22da7266e72aee.zip |
Updated to fedora-glibc-20050912T0656
49 files changed, 1470 insertions, 1703 deletions
diff --git a/ChangeLog b/ChangeLog index cb977d6c3f..9d0d99ab99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,349 @@ +2005-09-09 Jakub Jelinek <jakub@redhat.com> + + * inet/getnetgrent_r.c: Include assert. + (setup): Remove FUNC_NAME and ALL arguments, assume they are always + "setnetgrent" and 1. + (endnetgrent_hook): New function. + (internal_endnetgrent): Use it. + (__internal_setnetgrent_reuse): Use it. Adjust setup caller. + If status is NSS_STATUS_SUCCESS, yet action is continue, call + endnetgrent hook. + (internal_getnetgrent_r): Use __nss_lookup_function rather than + setup. Recompute getfct pointer after successful + __internal_setnetgrent_reuse. Don't use __nss_next. + (innetgr): Use __nss_lookup_function instead of __nss_lookup. + Adjust setup caller. + * nss/nss_files/files-netgrp.c (_nss_files_endnetgrent): Always clear + data_size and cursor. Add libnss_files_hidden_proto and + libnss_files_hidden_def. + (_nss_files_setnetgrent): Call _nss_files_endnetgrent on failure. + * nis/nss_nis/nis-netgrp.c (internal_endnetgrent): Always clear + data_size and cursor. + (_nss_nis_setnetgrent): Don't call internal_endnetgrent. + (_nss_nis_getnetgrent_r): Remove result->cursor == NULL handling. + * nis/nss_nisplus/nisplus-netgrp.c (internal_endnetgrent): Always clear + data_size and position. + (_nss_nisplus_setnetgrent): Don't call internal_endnetgrent. + +2005-09-09 Ulrich Drepper <drepper@redhat.com> + + * nss/getent.c (netgroup_keys): Call endnetgrent. + (main): Call mtrace. + + * nss/nss_files/files-netgrp.c (_nss_files_setnetgrent): We don't + need locking for the stream. Use feof_unlocked. + +2005-09-09 Jakub Jelinek <jakub@redhat.com> + + [BZ #1318] + * locale/loadarchive.c (_nl_load_locale_from_archive): Free + normalized_codeset even if p was already normalized. + Reported by Jaroslav Snajdr <jsnajdr@kerio.com>. + +2005-09-08 Roland McGrath <roland@redhat.com> + + * sysdeps/generic/dl-sysdep.c (_dl_important_hwcaps): Decode DSOCAPS + properly, first byte is bit number in mask. Skip disabled caps. + +2005-07-11 Derek R. Price <derek@ximbiot.com> + + [BZ #1061] + * sysdeps/generic/glob.c (glob): Only a 0 return from + getlogin_r means success, according to POSIX 1003.2. + +2005-06-23 Paul Eggert <eggert@cs.ucla.edu> + + [BZ #1033] + * time/mktime.c: Import from gnulib. + The following macros are now consistent with other gnulib code. + This does not change mktime's behavior. + (TYPE_IS_INTEGER): New macro. + (time_t_is_integer): Use it. + (TYPE_TWOS_COMPLEMENT): New macro. + (twos_complement_arithmetic): Use it. + (TYPE_ONES_COMPLEMENT): New macro. + (TYPE_MINIMUM, TYPE_MAXIMUM): Now supports signed-magnitude. + mktime doesn't use this, but the code now matches other gnulib code. + (ranged_convert): Pacify GCC 4.0 in a different way, which + generates a few bytes less code. + (ranged_convert, __mktime_internal): When calling a function via a + pointer P, use P () rather than (*P) (), as we now assume C89 or + better. + +2005-09-07 Alexandre Oliva <aoliva@redhat.com> + + * timezone/test-tz.c: Update to match tzdata2005m. + * timezone/tst-timezone.c: Likewise. + +2005-09-07 Ulrich Drepper <drepper@redhat.com> + + * posix/regexec.c (find_recover_state): Remove unnecessary + initialization. + (transit_state_bkref): Make DFA a const pointer. + (get_subexp): Likewise. + (check_arrival): Likewise. + (update_cur_sifted_state): Likewise. + (re_search_internal): Likewise. + (prune_impossible_nodes): Likewise. + (acquire_init_state_context): Likewise. + (proceed_next_node): Likewise. + (set_regs): Likewise. + (free_fail_stack_return): Likewise. + (check_arrival_expand_ecl): Mark DFA parameter as const. + (check_arrival_expand_ecl_sub): Likewise. + (check_subexp_limits): Likewise. + (sub_epsilon_src_nodes): Likewise. + (add_epsilon_src_nodes): Likewise. + (merge_state_array): Likewise. + (update_regs): Likewise. + (build_trtable): Likewise. + (sift_states_backward): Mark MCTX parameter as const. + (build_sifted_states): Likewise. + (update_cur_sifted_state): Likewise. + (sift_states_mkref): Likewise. + (check_arrival_expand_ecl): Mark eclosure as const. + (check_dst_limits_calc_pos_1): Likewise. + * posix/regex_internal.h (re_match_context_t): Make dfa a const + pointer. + +2005-09-06 Ulrich Drepper <drepper@redhat.com> + + * timezone/africa: Update from tzdata2005m. + * timezone/asia: Likewise. + * timezone/australasia: Likewise. + * timezone/backward: Likewise. + * timezone/europe: Likewise. + * timezone/northamerica: Likewise. + * timezone/southamerica: Likewise. + * timezone/zone.tab: Likewise. + * timezone/zdump.c: Update from tzcode2005m. + + * posix/regexec.c (merge_state_with_log): Define dfa as const pointer. + (transit_state_sb): Likewise. + (transit_state_mb): Likewise. + (sift_states_iter_mb): Likewise. + (check_arrival_add_next_nodes): Likewise. + (check_node_accept_bytes): Change first parameter to pointer-to-const. + [_LIBC] (re_search_2_stub): Use mempcpy. + + * posix/regex_internal.c (re_string_reconstruct): Avoid calling + mbrtowc for very simple UTF-8 case. + +2005-09-01 Paul Eggert <eggert@cs.ucla.edu> + + * posix/regex_internal.c (build_wcs_upper_buffer): Fix portability + bugs in int versus size_t comparisons. + +2005-09-06 Ulrich Drepper <drepper@redhat.com> + + * posix/regex_internal.c (re_acquire_state): Make DFA pointer arg + a pointer-to-const. + (re_acquire_state_context): Likewise. + * posix/regex_internal.h: Adjust prototypes. + +2005-08-31 Jim Meyering <jim@meyering.net> + + * posix/regcomp.c (search_duplicated_node): Make first pointer arg + a pointer-to-const. + * posix/regex_internal.c (create_ci_newstate, create_cd_newstate, + register_state): Likewise. + * posix/regexec.c (search_cur_bkref_entry, check_dst_limits): + (check_dst_limits_calc_pos_1, check_dst_limits_calc_pos): + (group_nodes_into_DFAstates): Likewise. + +2005-08-31 Paul Eggert <eggert@cs.ucla.edu> + + * posix/regexec.c (re_search_internal): Simplify update of + rm_so and rm_eo by replacing "if (A == B) A += C - B;" + with the equivalent of "if (A == B) A = C;". + +2005-09-06 Ulrich Drepper <drepper@redhat.com> + + * posix/regcomp.c (re_compile_internal): Change third parameter type + to size_t. + (init_dfa): Likewise. Make sure that arithmetic on pat_len doesn't + overflow. + * posix/regex_internal.h (struct re_dfa_t): Change type of nodes_alloc + and nodes_len to size_t. + * posix/regex_internal.c (re_dfa_add_node): Use size_t as type for + new_nodes_alloc. Check for overflow. + +2005-08-31 Paul Eggert <eggert@cs.ucla.edu> + + * posix/regcomp.c (re_compile_fastmap_iter, init_dfa, init_word_char): + (optimize_subexps, lower_subexp): + Don't assume 1<<31 has defined behavior on hosts with 32-bit int, + since the signed shift might overflow. Use 1u<<31 instead. + * posix/regex_internal.h (bitset_set, bitset_clear, bitset_contain): + Likewise. + * posix/regexec.c (check_dst_limits_calc_pos_1): Likewise. + (check_subexp_matching_top): Likewise. + * posix/regcomp.c (optimize_subexps, lower_subexp): + Use CHAR_BIT rather than 8, for clarity. + * posix/regexec.c (check_dst_limits_calc_pos_1): + (check_subexp_matching_top): Likewise. + * posix/regcomp.c (init_dfa): Make table_size unsigned, so that we + don't have to worry about portability issues when shifting it left. + Remove no-longer-needed test for table_size > 0. + * posix/regcomp.c (parse_sub_exp): Do not shift more bits than there + are in a word, as the resulting behavior is undefined. + * posix/regexec.c (check_dst_limits_calc_pos_1): Likewise; + in one case, a <= should have been an <, and in another case the + whole test was missing. + * posix/regex_internal.h (BYTE_BITS): Remove. All uses changed to + the standard name CHAR_BIT. + + * posix/regex_internal.h (re_sub_match_top_t): Remove unused member + next_last_offset. + (struct re_dfa_t): Remove unused member states_alloc. + * posix/regcomp.c (init_dfa): Don't initialize unused members. + +2005-08-25 Paul Eggert <eggert@cs.ucla.edu> + + * posix/regexec.c (set_regs): Don't alloca with an unbounded size. + + alloca modernization/simplification for regex. + * posix/regex.c: Remove portability cruft for alloca. This no longer + needs to be at the start of the file, and can be moved into + regex_internal.h and simplified. + * posix/regex_internal.h: Include <alloca.h>. + (__libc_use_alloca) [!defined _LIBC]: New macro. + * posix/regexec.c (build_trtable): Remove "#ifdef _LIBC", + since the code now works outside glibc. + +2005-09-06 Ulrich Drepper <drepper@redhat.com> + + * include/regex.h: Remove use of _RE_ARGS. + +2005-08-25 Paul Eggert <eggert@cs.ucla.edu> + + * posix/regexec.c (find_recover_state): Change "err" to "*err". + +2005-08-24 Paul Eggert <eggert@cs.ucla.edu> + + * posix/regcomp.c (regerror): Pointer args are 'restrict', + as per POSIX. + * posix/regex.h (regerror): Likewise. + * manual/pattern.texi (POSIX Regexp Compilation): Likewise. + Similarly for regcomp and regexec. Also, first 2 args of regexec + and 2nd arg of regerror are const. + + * posix/regex.c: Do not include <sys/types.h>, as POSIX no longer + requires this. (The code never needed it.) + +2005-08-20 Paul Eggert <eggert@cs.ucla.edu> + + * posix/regexec.c (sift_states_bkref): re_node_set_insert returns + int, not reg_errcode_t. + + * posix/regex_internal.c (calc_state_hash): Put 'inline' before type, + since some broken compilers warn about it otherwise. + + * posix/regcomp.c (create_initial_state): Remove duplicate decl. + +2005-08-20 Paul Eggert <eggert@cs.ucla.edu> + + * posix/regex.h (_RE_ARGS): Remove. No longer needed, since we assume + C89 or better. All uses removed. + +2005-09-06 Ulrich Drepper <drepper@redhat.com> + + * posix/regex.c: Prevent using C++ compilers. + +2005-08-19 Paul Eggert <eggert@cs.ucla.edu> + + * posix/regcomp.c (duplicate_node): Return new index, not an error + code, and let the caller return REG_ESPACE if out of space. This + removes an uninitialied-variable warning with GCC 4.0.1, and also + avoids taking the address of a local variable. All callers + changed. + +2005-09-06 Ulrich Drepper <drepper@redhat.com> + + * include/time.h (__strptime_internal): Rename parameter to avoid + bogus compiler warning. + +2005-08-19 Jim Meyering <jim@meyering.net> + + * posix/regexec.c (proceed_next_node): Redo local variables to + avoid GCC shadowing warnings. + +2005-09-06 Ulrich Drepper <drepper@redhat.com> + + * posix/regex_internal.c (re_acquire_state): Minor code rearrangement. + (re_acquire_state_context): Likewise. + +2005-08-19 Paul Eggert <eggert@cs.ucla.edu> + + * posix/regex_internal.c (re_string_realloc_buffers): + (re_node_set_insert, re_node_set_insert_last, re_dfa_add_node): + Rename local variables to avoid GCC shadowing warnings. + +2005-07-08 Eric Blake <ebb9@byu.net> + Paul Eggert <eggert@cs.ucla.edu> + + * posix/regcomp.c (init_dfa): Store __btowc value in wint_t, not + wchar_t. Remove now-unnecessary cast. + (build_range_exp): Likewise. + +2005-08-31 Bob Wilson <bob.wilson@acm.org> + + * sysdeps/ieee754/flt-32/e_hypotf.c (__ieee754_hypotf): Remove the + exponent bias from the increment value for scaling by 2^60. + +2005-09-05 Alexandre Oliva <aoliva@redhat.com> + + * configure.in: Compile source test file with -fPIC for -shared. + +2005-09-04 Ulrich Drepper <drepper@redhat.com> + + * iconv/skeleton.c: Eliminate DEFINE_DIRECTION_OBJECTS macro use, + it wasn't used. Remove use of from_object and to_object variable, + replace with some constants. Adjust users. + + * sysdeps/i386/bits/string.h: Removed. + + * stdio-common/Makefile (tests): Add tst-put-error. + * stdio-common/tst-put-error.c: New file. + * libio/fileops.c (_IO_new_file_xsputn): If overflow fails and no more + data would have to be written signal error. + * libio/oldfileops.c (_IO_old_file_xsputn): Likewise. + + * libio/fileops.c (_IO_new_file_overflow): Use NULL not 0. + +2005-09-02 Ulrich Drepper <drepper@redhat.com> + + * elf/dl-load.c (_dl_map_object_from_fd): No need to change + protection of memory used for the last segment. + +2005-08-22 Robert Millan <robertmh@gnu.org> + + * sysdeps/mach/hurd/nfs/nfs.h: Move to ... + * sysdeps/generic/nfs/nfs.h: ... here. + +2005-09-01 Ulrich Drepper <drepper@redhat.com> + + * libio/stdio.h: Remove __wur from ungetc, sscanf, and vsscanf. + Add __wur to feof{,_unlocked}, ferror{,_unlocked}, + fileno{,_unlocked}, and popen. + +2005-08-30 Ulrich Drepper <drepper@redhat.com> + + * sysdeps/ieee754/flt-32/e_hypotf.c [!__STDC__]: Fix function name. + +2005-08-01 Bob Wilson <bob.wilson@acm.org> + Richard Sandiford <richard@codesourcery.com> + + * sysdeps/ieee754/flt-32/e_hypotf.c (__ieee754_hypotf): Add missing + exponent bias to the value for 2^126. + +2005-08-30 Jakub Jelinek <jakub@redhat.com> + Alan Modra <amodra@bigpond.net.au> + + * elf/dl-addr.c (_dl_addr): Use DL_ADDR_SYM_MATCH macro. + * sysdeps/generic/ldsodefs.h (DL_ADDR_SYM_MATCH): Define. + * sysdeps/unix/sysv/linux/powerpc/powerpc64/ldsodefs.h: New file. + 2005-08-23 Ulrich Drepper <drepper@redhat.com> * nscd/nscd.c (main): Use error while process isn't running in the diff --git a/configure b/configure index a449415c01..00733b2486 100755 --- a/configure +++ b/configure @@ -5361,7 +5361,7 @@ if test "${libc_cv_have_sdata_section+set}" = set; then else echo "int i;" > conftest.c libc_cv_have_sdata_section=no - if ${CC-cc} $LDFLAGS -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \ + if ${CC-cc} $LDFLAGS -fPIC -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \ | grep '\.sdata' >/dev/null; then libc_cv_have_sdata_section=yes fi @@ -5453,7 +5453,7 @@ else int _start (void) { return 42; } EOF if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -nostartfiles -nostdlib -Wl,--enable-new-dtags,-z,nodelete 1>&5' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 @@ -5481,7 +5481,7 @@ else int _start (void) { return 42; } EOF if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -nostartfiles -nostdlib -Wl,--enable-new-dtags,-z,nodlopen 1>&5' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 @@ -5509,7 +5509,7 @@ else int _start (void) { return 42; } EOF if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -nostartfiles -nostdlib -Wl,--enable-new-dtags,-z,initfirst 1>&5' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 @@ -5571,7 +5571,7 @@ else int _start (void) { return 42; } EOF if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -Wl,-Bgroup -nostdlib 1>&5' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -5598,7 +5598,7 @@ else int main (void) { return 0; } EOF libc_cv_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \ - -shared -shared-libgcc -o conftest.so \ + -fPIC -shared -shared-libgcc -o conftest.so \ conftest.c -v 2>&1 >/dev/null \ | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'` rm -f conftest* @@ -5616,7 +5616,7 @@ else int main (void) { return 0; } EOF if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -lgcc_s$libc_cv_libgcc_s_suffix -Wl,--as-needed -nostdlib 1>&5' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 @@ -5684,7 +5684,7 @@ extern int mumble; int foo (void) { return bar (mumble); } EOF if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -nostdlib -nostartfiles -Wl,-z,combreloc 1>&5' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 @@ -5722,7 +5722,7 @@ else int _start (void) { return 42; } EOF if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -Wl,-z,execstack -nostdlib 1>&5' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 diff --git a/configure.in b/configure.in index 21756e00a8..f4556a1f1d 100644 --- a/configure.in +++ b/configure.in @@ -1238,7 +1238,7 @@ EOF libc_cv_have_sdata_section, [echo "int i;" > conftest.c libc_cv_have_sdata_section=no - if ${CC-cc} $LDFLAGS -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \ + if ${CC-cc} $LDFLAGS -fPIC -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \ | grep '\.sdata' >/dev/null; then libc_cv_have_sdata_section=yes fi @@ -1297,7 +1297,7 @@ EOF int _start (void) { return 42; } EOF if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -nostartfiles -nostdlib -Wl,--enable-new-dtags,-z,nodelete 1>&AS_MESSAGE_LOG_FD]) then @@ -1314,7 +1314,7 @@ EOF int _start (void) { return 42; } EOF if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -nostartfiles -nostdlib -Wl,--enable-new-dtags,-z,nodlopen 1>&AS_MESSAGE_LOG_FD]) then @@ -1331,7 +1331,7 @@ EOF int _start (void) { return 42; } EOF if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -nostartfiles -nostdlib -Wl,--enable-new-dtags,-z,initfirst 1>&AS_MESSAGE_LOG_FD]) then @@ -1363,7 +1363,7 @@ EOF int _start (void) { return 42; } EOF if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -Wl,-Bgroup -nostdlib 1>&AS_MESSAGE_LOG_FD]) then libc_cv_Bgroup=yes @@ -1380,7 +1380,7 @@ int main (void) { return 0; } EOF changequote(,)dnl libc_cv_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \ - -shared -shared-libgcc -o conftest.so \ + -fPIC -shared -shared-libgcc -o conftest.so \ conftest.c -v 2>&1 >/dev/null \ | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'` changequote([,])dnl @@ -1393,7 +1393,7 @@ changequote([,])dnl int main (void) { return 0; } EOF if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -lgcc_s$libc_cv_libgcc_s_suffix -Wl,--as-needed -nostdlib 1>&AS_MESSAGE_LOG_FD]) then @@ -1434,7 +1434,7 @@ extern int mumble; int foo (void) { return bar (mumble); } EOF if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -nostdlib -nostartfiles -Wl,-z,combreloc 1>&AS_MESSAGE_LOG_FD]) then @@ -1463,7 +1463,7 @@ dnl look for a section named .rel.dyn. int _start (void) { return 42; } EOF if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -Wl,-z,execstack -nostdlib 1>&AS_MESSAGE_LOG_FD]) then diff --git a/elf/dl-addr.c b/elf/dl-addr.c index 6bd7f7b69c..fa62e40840 100644 --- a/elf/dl-addr.c +++ b/elf/dl-addr.c @@ -85,22 +85,15 @@ _dl_addr (const void *address, Dl_info *info, the string table which generally follows the symbol table. */ symtabend = (const ElfW(Sym) *) strtab; - /* We assume that the string table follows the symbol table, - because there is no way in ELF to know the size of the - dynamic symbol table!! */ const ElfW(Sym) *matchsym; for (matchsym = NULL; (void *) symtab < (void *) symtabend; ++symtab) - if (addr >= match->l_addr + symtab->st_value + if ((ELFW(ST_BIND) (symtab->st_info) == STB_GLOBAL + || ELFW(ST_BIND) (symtab->st_info) == STB_WEAK) #if defined USE_TLS && ELFW(ST_TYPE) (symtab->st_info) != STT_TLS #endif - && ((symtab->st_size == 0 - && addr == match->l_addr + symtab->st_value) - || addr < match->l_addr + symtab->st_value + symtab->st_size) - && symtab->st_name < strtabsize - && (matchsym == NULL || matchsym->st_value < symtab->st_value) - && (ELFW(ST_BIND) (symtab->st_info) == STB_GLOBAL - || ELFW(ST_BIND) (symtab->st_info) == STB_WEAK)) + && DL_ADDR_SYM_MATCH (match, symtab, matchsym, addr) + && symtab->st_name < strtabsize) matchsym = (ElfW(Sym) *) symtab; if (mapp) diff --git a/elf/dl-load.c b/elf/dl-load.c index 677174d036..58b0f91731 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -1200,7 +1200,7 @@ cannot allocate TLS data structures for initial thread"); handle the portion of the segment past the end of the file mapping. */ __mprotect ((caddr_t) (l->l_addr + c->mapend), - loadcmds[nloadcmds - 1].allocend - c->mapend, + loadcmds[nloadcmds - 1].mapstart - c->mapend, PROT_NONE); goto postmap; diff --git a/fedora/branch.mk b/fedora/branch.mk index d170858f12..dd93d8d799 100644 --- a/fedora/branch.mk +++ b/fedora/branch.mk @@ -3,5 +3,5 @@ glibc-branch := fedora glibc-base := HEAD DIST_BRANCH := devel COLLECTION := dist-fc4 -fedora-sync-date := 2005-08-29 18:54 UTC -fedora-sync-tag := fedora-glibc-20050829T1854 +fedora-sync-date := 2005-09-12 06:56 UTC +fedora-sync-tag := fedora-glibc-20050912T0656 diff --git a/iconv/skeleton.c b/iconv/skeleton.c index 579426c7e5..c74935693f 100644 --- a/iconv/skeleton.c +++ b/iconv/skeleton.c @@ -1,5 +1,5 @@ /* Skeleton for a conversion module. - Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1998-2002, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -58,13 +58,6 @@ of one round through the TO_LOOP. Defaults to MIN_NEEDED_FROM and MAX_NEEDED_FROM, respectively. - DEFINE_DIRECTION_OBJECTS - two objects will be defined to be used when the - `gconv' function must only distinguish two - directions. This is implied by DEFINE_INIT. - If this macro is not defined the following - macro must be available. - FROM_DIRECTION this macro is supposed to return a value != 0 if we convert from the current character set, otherwise it return 0. @@ -156,16 +149,15 @@ #endif /* The direction objects. */ -#if DEFINE_DIRECTION_OBJECTS || DEFINE_INIT -static int from_object; -static int to_object; - +#if DEFINE_INIT # ifndef FROM_DIRECTION -# define FROM_DIRECTION (step->__data == &from_object) +# define FROM_DIRECTION_VAL NULL +# define TO_DIRECTION_VAL ((void *) ~((uintptr_t) 0)) +# define FROM_DIRECTION (step->__data == FROM_DIRECTION_VAL) # endif #else # ifndef FROM_DIRECTION -# error "FROM_DIRECTION must be provided if direction objects are not used" +# error "FROM_DIRECTION must be provided if non-default init is used" # endif #endif @@ -329,7 +321,7 @@ gconv_init (struct __gconv_step *step) /* Determine which direction. */ if (strcmp (step->__from_name, CHARSET_NAME) == 0) { - step->__data = &from_object; + step->__data = FROM_DIRECTION_VAL; step->__min_needed_from = FROM_LOOP_MIN_NEEDED_FROM; step->__max_needed_from = FROM_LOOP_MAX_NEEDED_FROM; @@ -342,7 +334,7 @@ gconv_init (struct __gconv_step *step) } else if (__builtin_expect (strcmp (step->__to_name, CHARSET_NAME), 0) == 0) { - step->__data = &to_object; + step->__data = TO_DIRECTION_VAL; step->__min_needed_from = TO_LOOP_MIN_NEEDED_FROM; step->__max_needed_from = TO_LOOP_MAX_NEEDED_FROM; @@ -681,8 +673,8 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data, #ifdef RESET_INPUT_BUFFER RESET_INPUT_BUFFER; #else - /* We have a problem with the in on of the functions - below. Undo the conversion upto the error point. */ + /* We have a problem in one of the functions below. + Undo the conversion upto the error point. */ size_t nstatus; /* Reload the pointers. */ @@ -780,12 +772,11 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data, STORE_REST # else - size_t cnt; - /* Make sure the remaining bytes fit into the state objects buffer. */ assert (inend - *inptrp < 4); + size_t cnt; for (cnt = 0; *inptrp < inend; ++cnt) data->__statep->__value.__wchb[cnt] = *(*inptrp)++; data->__statep->__count &= ~7; @@ -815,7 +806,6 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data, #undef TO_LOOP_MAX_NEEDED_FROM #undef TO_LOOP_MIN_NEEDED_TO #undef TO_LOOP_MAX_NEEDED_TO -#undef DEFINE_DIRECTION_OBJECTS #undef FROM_DIRECTION #undef EMIT_SHIFT_TO_INIT #undef FROM_LOOP diff --git a/include/regex.h b/include/regex.h index 81789be897..a7606c5e0d 100644 --- a/include/regex.h +++ b/include/regex.h @@ -2,45 +2,42 @@ #include <posix/regex.h> /* Document internal interfaces. */ -extern reg_syntax_t __re_set_syntax _RE_ARGS ((reg_syntax_t syntax)); +extern reg_syntax_t __re_set_syntax (reg_syntax_t syntax); -extern const char *__re_compile_pattern - _RE_ARGS ((const char *pattern, size_t length, - struct re_pattern_buffer *buffer)); +extern const char *__re_compile_pattern (const char *pattern, size_t length, + struct re_pattern_buffer *buffer); -extern int __re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); +extern int __re_compile_fastmap (struct re_pattern_buffer *buffer); -extern int __re_search - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, int range, struct re_registers *regs)); +extern int __re_search (struct re_pattern_buffer *buffer, const char *string, + int length, int start, int range, + struct re_registers *regs); extern int __re_search_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, int range, struct re_registers *regs, int stop)); + (struct re_pattern_buffer *buffer, const char *string1, + int length1, const char *string2, int length2, + int start, int range, struct re_registers *regs, int stop); extern int __re_match - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, struct re_registers *regs)); + (struct re_pattern_buffer *buffer, const char *string, + int length, int start, struct re_registers *regs); extern int __re_match_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, struct re_registers *regs, int stop)); + (struct re_pattern_buffer *buffer, const char *string1, + int length1, const char *string2, int length2, + int start, struct re_registers *regs, int stop); extern void __re_set_registers - _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, - unsigned num_regs, regoff_t *starts, regoff_t *ends)); + (struct re_pattern_buffer *buffer, struct re_registers *regs, + unsigned num_regs, regoff_t *starts, regoff_t *ends); -extern int __regcomp _RE_ARGS ((regex_t *__preg, const char *__pattern, - int __cflags)); +extern int __regcomp (regex_t *__preg, const char *__pattern, int __cflags); -extern int __regexec _RE_ARGS ((const regex_t *__preg, - const char *__string, size_t __nmatch, - regmatch_t __pmatch[], int __eflags)); +extern int __regexec (const regex_t *__preg, const char *__string, + size_t __nmatch, regmatch_t __pmatch[], int __eflags); -extern size_t __regerror _RE_ARGS ((int __errcode, const regex_t *__preg, - char *__errbuf, size_t __errbuf_size)); +extern size_t __regerror (int __errcode, const regex_t *__preg, + char *__errbuf, size_t __errbuf_size); -extern void __regfree _RE_ARGS ((regex_t *__preg)); +extern void __regfree (regex_t *__preg); #endif diff --git a/include/time.h b/include/time.h index 3d8fef8bf9..c2171ef449 100644 --- a/include/time.h +++ b/include/time.h @@ -94,7 +94,7 @@ enum ptime_locale_status { not, loc, raw }; extern char * __strptime_internal (const char *rp, const char *fmt, struct tm *tm, enum ptime_locale_status *decided, - int era_cnt, __locale_t loc) + int era_cnt, __locale_t locparam) internal_function; extern double __difftime (time_t time1, time_t time0); diff --git a/inet/getnetgrent_r.c b/inet/getnetgrent_r.c index 640210ab2e..4dbccd94ea 100644 --- a/inet/getnetgrent_r.c +++ b/inet/getnetgrent_r.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1996,1997,1998,1999,2002,2004 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998, 1999, 2002, 2004, 2005 + 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 @@ -16,6 +17,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include <assert.h> #include <bits/libc-lock.h> #include <errno.h> #include <netdb.h> @@ -33,15 +35,13 @@ __libc_lock_define_initialized (static, lock) static struct __netgrent dataset; /* The lookup function for the first entry of this service. */ -extern int __nss_netgroup_lookup (service_user **nip, const char *name, +extern int __nss_netgroup_lookup (service_user **nipp, const char *name, void **fctp) internal_function; - -/* Set up NIP to run through the services. If ALL is zero, use NIP's - current location if it's not nil. Return nonzero if there are no +/* Set up NIP to run through the services. Return nonzero if there are no services (left). */ -static enum nss_status -setup (void **fctp, const char *func_name, int all, service_user **nipp) +static int +setup (void **fctp, service_user **nipp) { /* Remember the first service_entry, it's always the same. */ static service_user *startp; @@ -51,7 +51,7 @@ setup (void **fctp, const char *func_name, int all, service_user **nipp) { /* Executing this more than once at the same time must yield the same result every time. So we need no locking. */ - no_more = __nss_netgroup_lookup (nipp, func_name, fctp); + no_more = __nss_netgroup_lookup (nipp, "setnetgrent", fctp); startp = no_more ? (service_user *) -1 : *nipp; } else if (startp == (service_user *) -1) @@ -59,11 +59,10 @@ setup (void **fctp, const char *func_name, int all, service_user **nipp) return 1; else { - if (all || *nipp == NULL) - /* Reset to the beginning of the service list. */ - *nipp = startp; + /* Reset to the beginning of the service list. */ + *nipp = startp; /* Look up the first function. */ - no_more = __nss_lookup (nipp, func_name, fctp); + no_more = __nss_lookup (nipp, "setnetgrent", fctp); } return no_more; } @@ -87,6 +86,20 @@ free_memory (struct __netgrent *data) } } +static void +endnetgrent_hook (struct __netgrent *datap) +{ + enum nss_status (*endfct) (struct __netgrent *); + + if (datap->nip == NULL) + return; + + endfct = __nss_lookup_function (datap->nip, "endnetgrent"); + if (endfct != NULL) + (void) (*endfct) (datap); + datap->nip = NULL; +} + static int internal_function __internal_setnetgrent_reuse (const char *group, struct __netgrent *datap, @@ -100,14 +113,29 @@ __internal_setnetgrent_reuse (const char *group, struct __netgrent *datap, enum nss_status status = NSS_STATUS_UNAVAIL; struct name_list *new_elem; + /* Free data from previous service. */ + endnetgrent_hook (datap); + /* Cycle through all the services and run their setnetgrent functions. */ - int no_more = setup (&fct.ptr, "setnetgrent", 1, &datap->nip); + int no_more = setup (&fct.ptr, &datap->nip); while (! no_more) { + assert (datap->data == NULL); + /* Ignore status, we force check in `__nss_next'. */ status = (*fct.f) (group, datap); + service_user *old_nip = datap->nip; no_more = __nss_next (&datap->nip, "setnetgrent", &fct.ptr, status, 0); + + if (status == NSS_STATUS_SUCCESS && ! no_more) + { + enum nss_status (*endfct) (struct __netgrent *); + + endfct = __nss_lookup_function (old_nip, "endnetgrent"); + if (endfct != NULL) + (void) (*endfct) (datap); + } } /* Add the current group to the list of known groups. */ @@ -157,34 +185,13 @@ setnetgrent (const char *group) return result; } - void internal_endnetgrent (struct __netgrent *datap); libc_hidden_proto (internal_endnetgrent) void internal_endnetgrent (struct __netgrent *datap) { - service_user *old_nip; - union - { - enum nss_status (*f) (struct __netgrent *); - void *ptr; - } fct; - - /* Remember which was the last used service. */ - old_nip = datap->nip; - - /* Cycle through all the services and run their endnetgrent functions. */ - int no_more = setup (&fct.ptr, "endnetgrent", 1, &datap->nip); - while (! no_more) - { - /* Ignore status, we force check in `__nss_next'. */ - (void) (*fct.f) (datap); - - no_more = (datap->nip == old_nip - || __nss_next (&datap->nip, "endnetgrent", &fct.ptr, 0, 1)); - } - + endnetgrent_hook (datap); /* Now free list of all netgroup names from last run. */ free_memory (datap); } @@ -213,11 +220,7 @@ internal_getnetgrent_r (char **hostp, char **userp, char **domainp, struct __netgrent *datap, char *buffer, size_t buflen, int *errnop) { - union - { - enum nss_status (*f) (struct __netgrent *, char *, size_t, int *); - void *ptr; - } fct; + enum nss_status (*fct) (struct __netgrent *, char *, size_t, int *); /* Initialize status to return if no more functions are found. */ enum nss_status status = NSS_STATUS_NOTFOUND; @@ -225,10 +228,12 @@ internal_getnetgrent_r (char **hostp, char **userp, char **domainp, /* Run through available functions, starting with the same function last run. We will repeat each function as long as it succeeds, and then go on to the next service action. */ - int no_more = setup (&fct.ptr, "getnetgrent_r", 0, &datap->nip); + int no_more = (datap->nip == NULL + || (fct = __nss_lookup_function (datap->nip, "getnetgrent_r")) + == NULL); while (! no_more) { - status = (*fct.f) (datap, buffer, buflen, &errno); + status = (*fct) (datap, buffer, buflen, &errno); if (status == NSS_STATUS_RETURN) { @@ -246,8 +251,12 @@ internal_getnetgrent_r (char **hostp, char **userp, char **domainp, datap, errnop); } - if (found) - continue; + if (found && datap->nip != NULL) + { + fct = __nss_lookup_function (datap->nip, "getnetgrent_r"); + if (fct != NULL) + continue; + } } else if (status == NSS_STATUS_SUCCESS && datap->type == group_val) { @@ -279,7 +288,7 @@ internal_getnetgrent_r (char **hostp, char **userp, char **domainp, } } - no_more = __nss_next (&datap->nip, "getnetgrent_r", &fct.ptr, status, 0); + break; } if (status == NSS_STATUS_SUCCESS) @@ -322,16 +331,8 @@ innetgr (const char *netgroup, const char *host, const char *user, int (*f) (const char *, struct __netgrent *); void *ptr; } setfct; - union - { - void (*f) (struct __netgrent *); - void *ptr; - } endfct; - union - { - int (*f) (struct __netgrent *, char *, size_t, int *); - void *ptr; - } getfct; + void (*endfct) (struct __netgrent *); + int (*getfct) (struct __netgrent *, char *, size_t, int *); struct __netgrent entry; int result = 0; const char *current_group = netgroup; @@ -345,18 +346,21 @@ innetgr (const char *netgroup, const char *host, const char *user, the work during one walk through the service list. */ while (1) { - int no_more = setup (&setfct.ptr, "setnetgrent", 1, &entry.nip); + int no_more = setup (&setfct.ptr, &entry.nip); while (! no_more) { + assert (entry.data == NULL); + /* Open netgroup. */ enum nss_status status = (*setfct.f) (current_group, &entry); if (status == NSS_STATUS_SUCCESS - && __nss_lookup (&entry.nip, "getnetgrent_r", &getfct.ptr) == 0) + && (getfct = __nss_lookup_function (entry.nip, "getnetgrent_r")) + != NULL) { char buffer[1024]; - while ((*getfct.f) (&entry, buffer, sizeof buffer, &errno) + while ((*getfct) (&entry, buffer, sizeof buffer, &errno) == NSS_STATUS_SUCCESS) { if (entry.type == group_val) @@ -414,8 +418,9 @@ innetgr (const char *netgroup, const char *host, const char *user, } /* Free all resources of the service. */ - if (__nss_lookup (&entry.nip, "endnetgrent", &endfct.ptr) == 0) - (*endfct.f) (&entry); + endfct = __nss_lookup_function (entry.nip, "endnetgrent"); + if (endfct != NULL) + (*endfct) (&entry); /* Look for the next service. */ no_more = __nss_next (&entry.nip, "setnetgrent", diff --git a/libio/fileops.c b/libio/fileops.c index 19151cf188..3ad9b74011 100644 --- a/libio/fileops.c +++ b/libio/fileops.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1995, 1997-2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1995, 1997-2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Per Bothner <bothner@cygnus.com>. @@ -826,10 +826,10 @@ _IO_new_file_overflow (f, ch) return EOF; } /* If currently reading or no buffer allocated. */ - if ((f->_flags & _IO_CURRENTLY_PUTTING) == 0 || f->_IO_write_base == 0) + if ((f->_flags & _IO_CURRENTLY_PUTTING) == 0 || f->_IO_write_base == NULL) { /* Allocate a buffer if needed. */ - if (f->_IO_write_base == 0) + if (f->_IO_write_base == NULL) { INTUSE(_IO_doallocbuf) (f); _IO_setg (f, f->_IO_buf_base, f->_IO_buf_base, f->_IO_buf_base); @@ -1338,7 +1338,9 @@ _IO_new_file_xsputn (f, data, n) _IO_size_t block_size, do_write; /* Next flush the (full) buffer. */ if (_IO_OVERFLOW (f, EOF) == EOF) - return n - to_do; + /* If nothing else has to be written we must not signal the + caller that everything has been written. */ + return to_do == 0 ? EOF : n - to_do; /* Try to maintain alignment: write a whole number of blocks. dont_write is what gets left over. */ diff --git a/libio/oldfileops.c b/libio/oldfileops.c index b9efca7aa8..2dd618215b 100644 --- a/libio/oldfileops.c +++ b/libio/oldfileops.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1995, 1997-2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1995, 1997-2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Per Bothner <bothner@cygnus.com>. @@ -752,7 +752,7 @@ _IO_old_file_xsputn (f, data, n) _IO_size_t block_size, do_write; /* Next flush the (full) buffer. */ if (__overflow (f, EOF) == EOF) - return n - to_do; + return to_do == 0 ? 0 : n - to_do; /* Try to maintain alignment: write a whole number of blocks. dont_write is what gets left over. */ diff --git a/libio/stdio.h b/libio/stdio.h index ac42b3e2ac..4c1fe287e3 100644 --- a/libio/stdio.h +++ b/libio/stdio.h @@ -401,7 +401,7 @@ extern int fscanf (FILE *__restrict __stream, extern int scanf (__const char *__restrict __format, ...) __wur; /* Read formatted input from S. */ extern int sscanf (__const char *__restrict __s, - __const char *__restrict __format, ...) __THROW __wur; + __const char *__restrict __format, ...) __THROW; __END_NAMESPACE_STD #ifdef __USE_ISOC99 @@ -424,7 +424,7 @@ extern int vscanf (__const char *__restrict __format, _G_va_list __arg) /* Read formatted input from S into argument list ARG. */ extern int vsscanf (__const char *__restrict __s, __const char *__restrict __format, _G_va_list __arg) - __THROW __attribute__ ((__format__ (__scanf__, 2, 0))) __wur; + __THROW __attribute__ ((__format__ (__scanf__, 2, 0))); __END_NAMESPACE_C99 #endif /* Use ISO C9x. */ @@ -596,7 +596,7 @@ extern int puts (__const char *__s); This function is a possible cancellation points and therefore not marked with __THROW. */ -extern int ungetc (int __c, FILE *__stream) __wur; +extern int ungetc (int __c, FILE *__stream); /* Read chunks of generic data from STREAM. @@ -722,16 +722,16 @@ __BEGIN_NAMESPACE_STD /* Clear the error and EOF indicators for STREAM. */ extern void clearerr (FILE *__stream) __THROW; /* Return the EOF indicator for STREAM. */ -extern int feof (FILE *__stream) __THROW; +extern int feof (FILE *__stream) __THROW __wur; /* Return the error indicator for STREAM. */ -extern int ferror (FILE *__stream) __THROW; +extern int ferror (FILE *__stream) __THROW __wur; __END_NAMESPACE_STD #ifdef __USE_MISC /* Faster versions when locking is not required. */ extern void clearerr_unlocked (FILE *__stream) __THROW; -extern int feof_unlocked (FILE *__stream) __THROW; -extern int ferror_unlocked (FILE *__stream) __THROW; +extern int feof_unlocked (FILE *__stream) __THROW __wur; +extern int ferror_unlocked (FILE *__stream) __THROW __wur; #endif @@ -752,12 +752,12 @@ __END_NAMESPACE_STD #ifdef __USE_POSIX /* Return the system file descriptor for STREAM. */ -extern int fileno (FILE *__stream) __THROW; +extern int fileno (FILE *__stream) __THROW __wur; #endif /* Use POSIX. */ #ifdef __USE_MISC /* Faster version when locking is not required. */ -extern int fileno_unlocked (FILE *__stream) __THROW; +extern int fileno_unlocked (FILE *__stream) __THROW __wur; #endif @@ -767,7 +767,7 @@ extern int fileno_unlocked (FILE *__stream) __THROW; This function is a possible cancellation point and therefore not marked with __THROW. */ -extern FILE *popen (__const char *__command, __const char *__modes); +extern FILE *popen (__const char *__command, __const char *__modes) __wur; /* Close a stream opened by popen and return the status of its child. diff --git a/locale/loadarchive.c b/locale/loadarchive.c index 80bab9e7c9..d545f17fb5 100644 --- a/locale/loadarchive.c +++ b/locale/loadarchive.c @@ -1,5 +1,5 @@ /* Code to load locale data from the locale archive file. - Copyright (C) 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2005 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 @@ -185,9 +185,9 @@ _nl_load_locale_from_archive (int category, const char **namep) memcpy (__mempcpy (__mempcpy (newname, name, p - name), normalized_codeset, normlen), rest, restlen); - free ((char *) normalized_codeset); name = newname; } + free ((char *) normalized_codeset); } } diff --git a/manual/pattern.texi b/manual/pattern.texi index 872fde05fb..c2a42cd843 100644 --- a/manual/pattern.texi +++ b/manual/pattern.texi @@ -721,7 +721,7 @@ expression into it by calling @code{regcomp}. @comment regex.h @comment POSIX.2 -@deftypefun int regcomp (regex_t *@var{compiled}, const char *@var{pattern}, int @var{cflags}) +@deftypefun int regcomp (regex_t *restrict @var{compiled}, const char *restrict @var{pattern}, int @var{cflags}) The function @code{regcomp} ``compiles'' a regular expression into a data structure that you can use with @code{regexec} to match against a string. The compiled regular expression format is designed for @@ -870,7 +870,7 @@ unless the regular expression contains anchor characters (@samp{^} or @comment regex.h @comment POSIX.2 -@deftypefun int regexec (regex_t *@var{compiled}, char *@var{string}, size_t @var{nmatch}, regmatch_t @var{matchptr} @t{[]}, int @var{eflags}) +@deftypefun int regexec (const regex_t *restrict @var{compiled}, const char *restrict @var{string}, size_t @var{nmatch}, regmatch_t @var{matchptr}[restrict], int @var{eflags}) This function tries to match the compiled regular expression @code{*@var{compiled}} against @var{string}. @@ -1049,7 +1049,7 @@ the function @code{regerror} to turn it into an error message string. @comment regex.h @comment POSIX.2 -@deftypefun size_t regerror (int @var{errcode}, regex_t *@var{compiled}, char *@var{buffer}, size_t @var{length}) +@deftypefun size_t regerror (int @var{errcode}, const regex_t *restrict @var{compiled}, char *restrict @var{buffer}, size_t @var{length}) This function produces an error message string for the error code @var{errcode}, and stores the string in @var{length} bytes of memory starting at @var{buffer}. For the @var{compiled} argument, supply the diff --git a/manual/signal.texi b/manual/signal.texi index 1d28f74027..cbf746639a 100644 --- a/manual/signal.texi +++ b/manual/signal.texi @@ -2029,8 +2029,8 @@ This is an integer data type. Objects of this type are always accessed atomically. @end deftp -In practice, you can assume that @code{int} and other integer types no -longer than @code{int} are atomic. You can also assume that pointer +In practice, you can assume that @code{int} is atomic. +You can also assume that pointer types are atomic; that is very convenient. Both of these assumptions are true on all of the machines that the GNU C library supports and on all POSIX systems we know of. diff --git a/nis/nss_nis/nis-netgrp.c b/nis/nss_nis/nis-netgrp.c index 7bd6527f2d..049bd8cdb4 100644 --- a/nis/nss_nis/nis-netgrp.c +++ b/nis/nss_nis/nis-netgrp.c @@ -41,13 +41,10 @@ _nss_netgroup_parseline (char **cursor, struct __netgrent *netgrp, static void internal_nis_endnetgrent (struct __netgrent *netgrp) { - if (netgrp->data != NULL) - { - free (netgrp->data); - netgrp->data = NULL; - netgrp->data_size = 0; - netgrp->cursor = NULL; - } + free (netgrp->data); + netgrp->data = NULL; + netgrp->data_size = 0; + netgrp->cursor = NULL; } enum nss_status @@ -65,8 +62,6 @@ _nss_nis_setnetgrent (const char *group, struct __netgrent *netgrp) if (yp_get_default_domain (&domain)) return NSS_STATUS_UNAVAIL; - internal_nis_endnetgrent (netgrp); - status = yperr2nss (yp_match (domain, "netgroup", group, strlen (group), &netgrp->data, &len)); if (status == NSS_STATUS_SUCCESS) @@ -99,9 +94,6 @@ enum nss_status _nss_nis_getnetgrent_r (struct __netgrent *result, char *buffer, size_t buflen, int *errnop) { - if (result->cursor == NULL) - return NSS_STATUS_NOTFOUND; - return _nss_netgroup_parseline (&result->cursor, result, buffer, buflen, errnop); } diff --git a/nis/nss_nisplus/nisplus-netgrp.c b/nis/nss_nisplus/nisplus-netgrp.c index 607bc2c1ca..344d65f4c4 100644 --- a/nis/nss_nisplus/nisplus-netgrp.c +++ b/nis/nss_nisplus/nisplus-netgrp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1997, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997. @@ -141,13 +141,10 @@ _nss_nisplus_getnetgrent_r (struct __netgrent *result, char *buffer, static void internal_endnetgrent (struct __netgrent *netgrp) { - if (netgrp->data != NULL) - { - nis_freeresult ((nis_result *) netgrp->data); - netgrp->data = NULL; - netgrp->data_size = 0; - netgrp->position = 0; - } + nis_freeresult ((nis_result *) netgrp->data); + netgrp->data = NULL; + netgrp->data_size = 0; + netgrp->position = 0; } enum nss_status @@ -161,8 +158,6 @@ _nss_nisplus_setnetgrent (const char *group, struct __netgrent *netgrp) status = NSS_STATUS_SUCCESS; - internal_endnetgrent (netgrp); - sprintf (buf, "[name=%s],netgroup.org_dir", group); netgrp->data = (char *) nis_list (buf, EXPAND_NAME, NULL, NULL); diff --git a/nptl/ChangeLog b/nptl/ChangeLog index d728d92316..8da47cb54c 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -24,6 +24,11 @@ (FUTEX_WAKE_OP, FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define. (__pthread_cond_signal): Use FUTEX_WAKE_OP. +2005-09-05 Kaz Kojima <kkojima@rr.iij4u.or.jp> + + * sysdeps/unix/sysv/linux/sh/lowlevellock.S (__lll_mutex_lock_wait): + Fix typo in register name. + 2005-08-23 Ulrich Drepper <drepper@redhat.com> * sysdeps/unix/sysv/linux/timer_routines.c (timer_helper_thread): diff --git a/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S index bcb15615e5..b4826ef7aa 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S +++ b/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2005 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 @@ -51,8 +51,8 @@ __lll_mutex_lock_wait: SYSCALL_INST_PAD 2: - mov #2, r4 - XCHG (r4, @r8, r2) + mov #2, r6 + XCHG (r6, @r8, r2) tst r2, r2 bf 1b diff --git a/nss/getent.c b/nss/getent.c index 7124e6303f..02bba39752 100644 --- a/nss/getent.c +++ b/nss/getent.c @@ -21,22 +21,23 @@ #include <aliases.h> #include <argp.h> -#include <grp.h> -#include <pwd.h> -#include <shadow.h> #include <ctype.h> #include <error.h> +#include <grp.h> #include <libintl.h> #include <locale.h> +#include <mcheck.h> #include <netdb.h> +#include <pwd.h> +#include <shadow.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <netinet/ether.h> #include <arpa/inet.h> #include <arpa/nameser.h> +#include <netinet/ether.h> +#include <netinet/in.h> +#include <sys/socket.h> /* Get libc version number. */ #include <version.h> @@ -410,6 +411,8 @@ netgroup_keys (int number, char *key[]) } } + endnetgrent (); + return result; } @@ -838,7 +841,8 @@ more_help (int key, const char *text, void *input) int main (int argc, char *argv[]) { - int remaining, i; + /* Debugging support. */ + mtrace (); /* Set locale via LC_ALL. */ setlocale (LC_ALL, ""); @@ -846,6 +850,7 @@ main (int argc, char *argv[]) textdomain (PACKAGE); /* Parse and process arguments. */ + int remaining; argp_parse (&argp, argc, argv, 0, &remaining, NULL); if ((argc - remaining) < 1) @@ -855,7 +860,7 @@ main (int argc, char *argv[]) return 1; } - for (i = 0; databases[i].name; ++i) + for (int i = 0; databases[i].name; ++i) if (argv[remaining][0] == databases[i].name[0] && !strcmp (argv[remaining], databases[i].name)) return databases[i].func (argc - remaining - 1, &argv[remaining + 1]); diff --git a/nss/nss_files/files-netgrp.c b/nss/nss_files/files-netgrp.c index 8bdc68bd14..45f3b8ac42 100644 --- a/nss/nss_files/files-netgrp.c +++ b/nss/nss_files/files-netgrp.c @@ -1,5 +1,5 @@ /* Netgroup file parser in nss_files modules. - Copyright (C) 1996, 1997, 2000, 2004 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 2000, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -22,6 +22,7 @@ #include <errno.h> #include <netdb.h> #include <stdio.h> +#include <stdio_ext.h> #include <stdlib.h> #include <string.h> #include "nsswitch.h" @@ -29,6 +30,7 @@ #define DATAFILE "/etc/netgroup" +libnss_files_hidden_proto (_nss_files_endnetgrent) #define EXPAND(needed) \ do \ @@ -75,7 +77,9 @@ _nss_files_setnetgrent (const char *group, struct __netgrent *result) status = NSS_STATUS_NOTFOUND; result->cursor = result->data; - while (!feof (fp)) + __fsetlocking (fp, FSETLOCKING_BYCALLER); + + while (!feof_unlocked (fp)) { ssize_t curlen = getline (&line, &line_len, fp); int found; @@ -140,6 +144,9 @@ _nss_files_setnetgrent (const char *group, struct __netgrent *result) /* We don't need the file and the line buffer anymore. */ free (line); fclose (fp); + + if (status != NSS_STATUS_SUCCESS) + _nss_files_endnetgrent (result); } return status; @@ -150,16 +157,13 @@ int _nss_files_endnetgrent (struct __netgrent *result) { /* Free allocated memory for data if some is present. */ - if (result->data != NULL) - { - free (result->data); - result->data = NULL; - result->data_size = 0; - result->cursor = NULL; - } - + free (result->data); + result->data = NULL; + result->data_size = 0; + result->cursor = NULL; return NSS_STATUS_SUCCESS; } +libnss_files_hidden_def (_nss_files_endnetgrent) static char * strip_whitespace (char *str) diff --git a/posix/regcomp.c b/posix/regcomp.c index 37e06797ac..c93f79ea24 100644 --- a/posix/regcomp.c +++ b/posix/regcomp.c @@ -19,11 +19,11 @@ 02111-1307 USA. */ static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern, - int length, reg_syntax_t syntax); + size_t length, reg_syntax_t syntax); static void re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state, char *fastmap); -static reg_errcode_t init_dfa (re_dfa_t *dfa, int pat_len); +static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len); static void init_word_char (re_dfa_t *dfa); #ifdef RE_ENABLE_I18N static void free_charset (re_charset_t *cset); @@ -34,7 +34,6 @@ static reg_errcode_t create_initial_state (re_dfa_t *dfa); static void optimize_utf8 (re_dfa_t *dfa); #endif static reg_errcode_t analyze (regex_t *preg); -static reg_errcode_t create_initial_state (re_dfa_t *dfa); static reg_errcode_t preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)), void *extra); @@ -51,9 +50,8 @@ static reg_errcode_t link_nfa_nodes (void *extra, bin_tree_t *node); static reg_errcode_t duplicate_node_closure (re_dfa_t *dfa, int top_org_node, int top_clone_node, int root_node, unsigned int constraint); -static reg_errcode_t duplicate_node (int *new_idx, re_dfa_t *dfa, int org_idx, - unsigned int constraint); -static int search_duplicated_node (re_dfa_t *dfa, int org_node, +static int duplicate_node (re_dfa_t *dfa, int org_idx, unsigned int constraint); +static int search_duplicated_node (const re_dfa_t *dfa, int org_node, unsigned int constraint); static reg_errcode_t calc_eclosure (re_dfa_t *dfa); static reg_errcode_t calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, @@ -370,7 +368,7 @@ re_compile_fastmap_iter (bufp, init_state, fastmap) int i, j, ch; for (i = 0, ch = 0; i < BITSET_UINTS; ++i) for (j = 0; j < UINT_BITS; ++j, ++ch) - if (dfa->nodes[node].opr.sbcset[i] & (1 << j)) + if (dfa->nodes[node].opr.sbcset[i] & (1u << j)) re_set_fastmap (fastmap, icase, ch); } #ifdef RE_ENABLE_I18N @@ -536,8 +534,8 @@ weak_alias (__regcomp, regcomp) size_t regerror (errcode, preg, errbuf, errbuf_size) int errcode; - const regex_t *preg; - char *errbuf; + const regex_t *__restrict preg; + char *__restrict errbuf; size_t errbuf_size; { const char *msg; @@ -742,7 +740,7 @@ static reg_errcode_t re_compile_internal (preg, pattern, length, syntax) regex_t *preg; const char * pattern; - int length; + size_t length; reg_syntax_t syntax; { reg_errcode_t err = REG_NOERROR; @@ -783,6 +781,7 @@ re_compile_internal (preg, pattern, length, syntax) return err; } #ifdef DEBUG + /* Note: length+1 will not overflow since it is checked in init_dfa. */ dfa->re_str = re_malloc (char, length + 1); strncpy (dfa->re_str, pattern, length + 1); #endif @@ -842,9 +841,9 @@ re_compile_internal (preg, pattern, length, syntax) static reg_errcode_t init_dfa (dfa, pat_len) re_dfa_t *dfa; - int pat_len; + size_t pat_len; { - int table_size; + unsigned int table_size; #ifndef _LIBC char *codeset_name; #endif @@ -854,13 +853,15 @@ init_dfa (dfa, pat_len) /* Force allocation of str_tree_storage the first time. */ dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE; + /* Avoid overflows. */ + if (pat_len == SIZE_MAX) + return REG_ESPACE; + dfa->nodes_alloc = pat_len + 1; dfa->nodes = re_malloc (re_token_t, dfa->nodes_alloc); - dfa->states_alloc = pat_len + 1; - /* table_size = 2 ^ ceil(log pat_len) */ - for (table_size = 1; table_size > 0; table_size <<= 1) + for (table_size = 1; ; table_size <<= 1) if (table_size > pat_len) break; @@ -918,11 +919,11 @@ init_dfa (dfa, pat_len) for (i = 0, ch = 0; i < BITSET_UINTS; ++i) for (j = 0; j < UINT_BITS; ++j, ++ch) { - wchar_t wch = __btowc (ch); + wint_t wch = __btowc (ch); if (wch != WEOF) - dfa->sb_char[i] |= 1 << j; + dfa->sb_char[i] |= 1u << j; # ifndef _LIBC - if (isascii (ch) && wch != (wchar_t) ch) + if (isascii (ch) && wch != ch) dfa->map_notascii = 1; # endif } @@ -948,7 +949,7 @@ init_word_char (dfa) for (i = 0, ch = 0; i < BITSET_UINTS; ++i) for (j = 0; j < UINT_BITS; ++j, ++ch) if (isalnum (ch) || ch == '_') - dfa->word_char[i] |= 1 << j; + dfa->word_char[i] |= 1u << j; } /* Free the work area which are only used while compiling. */ @@ -1281,8 +1282,8 @@ optimize_subexps (extra, node) node->left->parent = node; dfa->subexp_map[other_idx] = dfa->subexp_map[node->token.opr.idx]; - if (other_idx < 8 * sizeof (dfa->used_bkref_map)) - dfa->used_bkref_map &= ~(1 << other_idx); + if (other_idx < CHAR_BIT * sizeof dfa->used_bkref_map) + dfa->used_bkref_map &= ~(1u << other_idx); } return REG_NOERROR; @@ -1330,8 +1331,8 @@ lower_subexp (err, preg, node) very common, so we do not lose much. An example that triggers this case is the sed "script" /\(\)/x. */ && node->left != NULL - && (node->token.opr.idx >= 8 * sizeof (dfa->used_bkref_map) - || !(dfa->used_bkref_map & (1 << node->token.opr.idx)))) + && (node->token.opr.idx >= CHAR_BIT * sizeof dfa->used_bkref_map + || !(dfa->used_bkref_map & (1u << node->token.opr.idx)))) return node->left; /* Convert the SUBEXP node to the concatenation of an @@ -1469,7 +1470,6 @@ duplicate_node_closure (dfa, top_org_node, top_clone_node, root_node, int top_org_node, top_clone_node, root_node; unsigned int init_constraint; { - reg_errcode_t err; int org_node, clone_node, ret; unsigned int constraint = init_constraint; for (org_node = top_org_node, clone_node = top_clone_node;;) @@ -1483,9 +1483,9 @@ duplicate_node_closure (dfa, top_org_node, top_clone_node, root_node, edests of the back reference. */ org_dest = dfa->nexts[org_node]; re_node_set_empty (dfa->edests + clone_node); - err = duplicate_node (&clone_dest, dfa, org_dest, constraint); - if (BE (err != REG_NOERROR, 0)) - return err; + clone_dest = duplicate_node (dfa, org_dest, constraint); + if (BE (clone_dest == -1, 0)) + return REG_ESPACE; dfa->nexts[clone_node] = dfa->nexts[org_node]; ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); if (BE (ret < 0, 0)) @@ -1521,9 +1521,9 @@ duplicate_node_closure (dfa, top_org_node, top_clone_node, root_node, } constraint |= dfa->nodes[org_node].opr.ctx_type; } - err = duplicate_node (&clone_dest, dfa, org_dest, constraint); - if (BE (err != REG_NOERROR, 0)) - return err; + clone_dest = duplicate_node (dfa, org_dest, constraint); + if (BE (clone_dest == -1, 0)) + return REG_ESPACE; ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); if (BE (ret < 0, 0)) return REG_ESPACE; @@ -1539,9 +1539,10 @@ duplicate_node_closure (dfa, top_org_node, top_clone_node, root_node, if (clone_dest == -1) { /* There are no such a duplicated node, create a new one. */ - err = duplicate_node (&clone_dest, dfa, org_dest, constraint); - if (BE (err != REG_NOERROR, 0)) - return err; + reg_errcode_t err; + clone_dest = duplicate_node (dfa, org_dest, constraint); + if (BE (clone_dest == -1, 0)) + return REG_ESPACE; ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); if (BE (ret < 0, 0)) return REG_ESPACE; @@ -1560,9 +1561,9 @@ duplicate_node_closure (dfa, top_org_node, top_clone_node, root_node, } org_dest = dfa->edests[org_node].elems[1]; - err = duplicate_node (&clone_dest, dfa, org_dest, constraint); - if (BE (err != REG_NOERROR, 0)) - return err; + clone_dest = duplicate_node (dfa, org_dest, constraint); + if (BE (clone_dest == -1, 0)) + return REG_ESPACE; ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); if (BE (ret < 0, 0)) return REG_ESPACE; @@ -1578,7 +1579,7 @@ duplicate_node_closure (dfa, top_org_node, top_clone_node, root_node, static int search_duplicated_node (dfa, org_node, constraint) - re_dfa_t *dfa; + const re_dfa_t *dfa; int org_node; unsigned int constraint; { @@ -1593,27 +1594,27 @@ search_duplicated_node (dfa, org_node, constraint) } /* Duplicate the node whose index is ORG_IDX and set the constraint CONSTRAINT. - The new index will be stored in NEW_IDX and return REG_NOERROR if succeeded, - otherwise return the error code. */ + Return the index of the new node, or -1 if insufficient storage is + available. */ -static reg_errcode_t -duplicate_node (new_idx, dfa, org_idx, constraint) +static int +duplicate_node (dfa, org_idx, constraint) re_dfa_t *dfa; - int *new_idx, org_idx; + int org_idx; unsigned int constraint; { int dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]); - if (BE (dup_idx == -1, 0)) - return REG_ESPACE; - dfa->nodes[dup_idx].constraint = constraint; - if (dfa->nodes[org_idx].type == ANCHOR) - dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].opr.ctx_type; - dfa->nodes[dup_idx].duplicated = 1; - - /* Store the index of the original node. */ - dfa->org_indices[dup_idx] = org_idx; - *new_idx = dup_idx; - return REG_NOERROR; + if (BE (dup_idx != -1, 1)) + { + dfa->nodes[dup_idx].constraint = constraint; + if (dfa->nodes[org_idx].type == ANCHOR) + dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].opr.ctx_type; + dfa->nodes[dup_idx].duplicated = 1; + + /* Store the index of the original node. */ + dfa->org_indices[dup_idx] = org_idx; + } + return dup_idx; } static reg_errcode_t @@ -2496,7 +2497,9 @@ parse_sub_exp (regexp, preg, token, syntax, nest, err) if (BE (*err != REG_NOERROR, 0)) return NULL; } - dfa->completed_bkref_map |= 1 << cur_nsub; + + if (cur_nsub <= '9' - '1') + dfa->completed_bkref_map |= 1 << cur_nsub; tree = create_tree (dfa, tree, NULL, SUBEXP); if (BE (tree == NULL, 0)) @@ -2683,7 +2686,9 @@ build_range_exp (sbcset, start_elem, end_elem) # ifdef RE_ENABLE_I18N { - wchar_t wc, start_wc, end_wc; + wchar_t wc; + wint_t start_wc; + wint_t end_wc; wchar_t cmp_buf[6] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'}; start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch diff --git a/posix/regex.c b/posix/regex.c index 7a4f304cdd..d2d4f28e01 100644 --- a/posix/regex.c +++ b/posix/regex.c @@ -1,5 +1,5 @@ /* Extended regular expression matching and search library. - Copyright (C) 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. @@ -22,28 +22,9 @@ #include "config.h" #endif -#ifdef _AIX -#pragma alloca -#else -# ifndef allocax /* predefined by HP cc +Olibcalls */ -# ifdef __GNUC__ -# define alloca(size) __builtin_alloca (size) -# else -# if HAVE_ALLOCA_H -# include <alloca.h> -# else -# ifdef __hpux - void *alloca (); -# else -# if !defined __OS2__ && !defined WIN32 - char *alloca (); -# else -# include <malloc.h> /* OS/2 defines alloca in here */ -# endif -# endif -# endif -# endif -# endif +/* Make sure noone compiles this code with a C++ compiler. */ +#ifdef __cplusplus +# error "This is C code, use a C compiler" #endif #ifdef _LIBC @@ -71,10 +52,6 @@ # include "../locale/localeinfo.h" #endif -/* POSIX says that <sys/types.h> must be included (by the caller) before - <regex.h>. */ -#include <sys/types.h> - /* On some systems, limits.h sets RE_DUP_MAX to a lower value than GNU regex allows. Include it before <regex.h>, which correctly #undefs RE_DUP_MAX and sets it to the right value. */ diff --git a/posix/regex.h b/posix/regex.h index 1f73d23866..e5ec398106 100644 --- a/posix/regex.h +++ b/posix/regex.h @@ -1,6 +1,6 @@ /* Definitions for data structures and routines for the regular expression library. - Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003 + Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -452,38 +452,21 @@ typedef struct /* Declarations for routines. */ -/* To avoid duplicating every routine declaration -- once with a - prototype (if we are ANSI), and once without (if we aren't) -- we - use the following macro to declare argument types. This - unfortunately clutters up the declarations a bit, but I think it's - worth it. */ - -#if __STDC__ - -# define _RE_ARGS(args) args - -#else /* not __STDC__ */ - -# define _RE_ARGS(args) () - -#endif /* not __STDC__ */ - /* Sets the current default syntax to SYNTAX, and return the old syntax. You can also simply assign to the `re_syntax_options' variable. */ -extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax)); +extern reg_syntax_t re_set_syntax (reg_syntax_t syntax); /* Compile the regular expression PATTERN, with length LENGTH and syntax given by the global `re_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not. */ -extern const char *re_compile_pattern - _RE_ARGS ((const char *pattern, size_t length, - struct re_pattern_buffer *buffer)); +extern const char *re_compile_pattern (const char *pattern, size_t length, + struct re_pattern_buffer *buffer); /* Compile a fastmap for the compiled pattern in BUFFER; used to accelerate searches. Return 0 if successful and -2 if was an internal error. */ -extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); +extern int re_compile_fastmap (struct re_pattern_buffer *buffer); /* Search in the string STRING (with length LENGTH) for the pattern @@ -491,31 +474,29 @@ extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); characters. Return the starting position of the match, -1 for no match, or -2 for an internal error. Also return register information in REGS (if REGS and BUFFER->no_sub are nonzero). */ -extern int re_search - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, int range, struct re_registers *regs)); +extern int re_search (struct re_pattern_buffer *buffer, const char *string, + int length, int start, int range, + struct re_registers *regs); /* Like `re_search', but search in the concatenation of STRING1 and STRING2. Also, stop searching at index START + STOP. */ -extern int re_search_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, int range, struct re_registers *regs, int stop)); +extern int re_search_2 (struct re_pattern_buffer *buffer, const char *string1, + int length1, const char *string2, int length2, + int start, int range, struct re_registers *regs, + int stop); /* Like `re_search', but return how many characters in STRING the regexp in BUFFER matched, starting at position START. */ -extern int re_match - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, struct re_registers *regs)); +extern int re_match (struct re_pattern_buffer *buffer, const char *string, + int length, int start, struct re_registers *regs); /* Relates to `re_match' as `re_search_2' relates to `re_search'. */ -extern int re_match_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, struct re_registers *regs, int stop)); +extern int re_match_2 (struct re_pattern_buffer *buffer, const char *string1, + int length1, const char *string2, int length2, + int start, struct re_registers *regs, int stop); /* Set REGS to hold NUM_REGS registers, storing them in STARTS and @@ -530,15 +511,15 @@ extern int re_match_2 Unless this function is called, the first search or match using PATTERN_BUFFER will allocate its own register data, without freeing the old data. */ -extern void re_set_registers - _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, - unsigned num_regs, regoff_t *starts, regoff_t *ends)); +extern void re_set_registers (struct re_pattern_buffer *buffer, + struct re_registers *regs, unsigned num_regs, + regoff_t *starts, regoff_t *ends); #if defined _REGEX_RE_COMP || defined _LIBC # ifndef _CRAY /* 4.2 bsd compatibility. */ -extern char *re_comp _RE_ARGS ((const char *)); -extern int re_exec _RE_ARGS ((const char *)); +extern char *re_comp (const char *); +extern int re_exec (const char *); # endif #endif @@ -563,19 +544,19 @@ extern int re_exec _RE_ARGS ((const char *)); #endif /* POSIX compatibility. */ -extern int regcomp _RE_ARGS ((regex_t *__restrict __preg, - const char *__restrict __pattern, - int __cflags)); +extern int regcomp (regex_t *__restrict __preg, + const char *__restrict __pattern, + int __cflags); -extern int regexec _RE_ARGS ((const regex_t *__restrict __preg, - const char *__restrict __string, size_t __nmatch, - regmatch_t __pmatch[__restrict_arr], - int __eflags)); +extern int regexec (const regex_t *__restrict __preg, + const char *__restrict __string, size_t __nmatch, + regmatch_t __pmatch[__restrict_arr], + int __eflags); -extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg, - char *__errbuf, size_t __errbuf_size)); +extern size_t regerror (int __errcode, const regex_t *__restrict __preg, + char *__restrict __errbuf, size_t __errbuf_size); -extern void regfree _RE_ARGS ((regex_t *__preg)); +extern void regfree (regex_t *__preg); #ifdef __cplusplus diff --git a/posix/regex_internal.c b/posix/regex_internal.c index baa58443ac..240e8872b3 100644 --- a/posix/regex_internal.c +++ b/posix/regex_internal.c @@ -26,16 +26,17 @@ static void re_string_construct_common (const char *str, int len, static int re_string_skip_chars (re_string_t *pstr, int new_raw_idx, wint_t *last_wc) internal_function; #endif /* RE_ENABLE_I18N */ -static reg_errcode_t register_state (re_dfa_t *dfa, re_dfastate_t *newstate, +static reg_errcode_t register_state (const re_dfa_t *dfa, + re_dfastate_t *newstate, unsigned int hash) internal_function; -static re_dfastate_t *create_ci_newstate (re_dfa_t *dfa, +static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes, unsigned int hash) internal_function; -static re_dfastate_t *create_cd_newstate (re_dfa_t *dfa, +static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes, unsigned int context, unsigned int hash) internal_function; -static unsigned int inline calc_state_hash (const re_node_set *nodes, +static inline unsigned int calc_state_hash (const re_node_set *nodes, unsigned int context) internal_function; /* Functions for string operation. */ @@ -148,26 +149,26 @@ re_string_realloc_buffers (pstr, new_buf_len) #ifdef RE_ENABLE_I18N if (pstr->mb_cur_max > 1) { - wint_t *new_array = re_realloc (pstr->wcs, wint_t, new_buf_len); - if (BE (new_array == NULL, 0)) + wint_t *new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len); + if (BE (new_wcs == NULL, 0)) return REG_ESPACE; - pstr->wcs = new_array; + pstr->wcs = new_wcs; if (pstr->offsets != NULL) { - int *new_array = re_realloc (pstr->offsets, int, new_buf_len); - if (BE (new_array == NULL, 0)) + int *new_offsets = re_realloc (pstr->offsets, int, new_buf_len); + if (BE (new_offsets == NULL, 0)) return REG_ESPACE; - pstr->offsets = new_array; + pstr->offsets = new_offsets; } } #endif /* RE_ENABLE_I18N */ if (pstr->mbs_allocated) { - unsigned char *new_array = re_realloc (pstr->mbs, unsigned char, - new_buf_len); - if (BE (new_array == NULL, 0)) + unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char, + new_buf_len); + if (BE (new_mbs == NULL, 0)) return REG_ESPACE; - pstr->mbs = new_array; + pstr->mbs = new_mbs; } pstr->bufs_len = new_buf_len; return REG_NOERROR; @@ -654,37 +655,50 @@ re_string_reconstruct (pstr, idx, eflags) byte other than 0x80 - 0xbf. */ raw = pstr->raw_mbs + pstr->raw_mbs_idx; end = raw + (offset - pstr->mb_cur_max); - for (p = raw + offset - 1; p >= end; --p) - if ((*p & 0xc0) != 0x80) - { - mbstate_t cur_state; - wchar_t wc2; - int mlen = raw + pstr->len - p; - unsigned char buf[6]; - - q = p; - if (BE (pstr->trans != NULL, 0)) - { - int i = mlen < 6 ? mlen : 6; - while (--i >= 0) - buf[i] = pstr->trans[p[i]]; - q = buf; - } - /* XXX Don't use mbrtowc, we know which conversion - to use (UTF-8 -> UCS4). */ - memset (&cur_state, 0, sizeof (cur_state)); - mlen = (mbrtowc (&wc2, (const char *) p, mlen, - &cur_state) - - (raw + offset - p)); - if (mlen >= 0) - { - memset (&pstr->cur_state, '\0', - sizeof (mbstate_t)); - pstr->valid_len = mlen; - wc = wc2; - } - break; - } + p = raw + offset - 1; +#ifdef _LIBC + /* We know the wchar_t encoding is UCS4, so for the simple + case, ASCII characters, skip the conversion step. */ + if (isascii (*p) && BE (pstr->trans == NULL, 1)) + { + memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); + pstr->valid_len = 0; + wc = (wchar_t) *p; + } + else +#endif + for (; p >= end; --p) + if ((*p & 0xc0) != 0x80) + { + mbstate_t cur_state; + wchar_t wc2; + int mlen = raw + pstr->len - p; + unsigned char buf[6]; + size_t mbclen; + + q = p; + if (BE (pstr->trans != NULL, 0)) + { + int i = mlen < 6 ? mlen : 6; + while (--i >= 0) + buf[i] = pstr->trans[p[i]]; + q = buf; + } + /* XXX Don't use mbrtowc, we know which conversion + to use (UTF-8 -> UCS4). */ + memset (&cur_state, 0, sizeof (cur_state)); + mbclen = mbrtowc (&wc2, (const char *) p, mlen, + &cur_state); + if (raw + offset - p <= mbclen + && mbclen < (size_t) -2) + { + memset (&pstr->cur_state, '\0', + sizeof (mbstate_t)); + pstr->valid_len = mbclen - (raw + offset - p); + wc = wc2; + } + break; + } } if (wc == WEOF) @@ -738,15 +752,15 @@ re_string_reconstruct (pstr, idx, eflags) } else #endif /* RE_ENABLE_I18N */ - if (BE (pstr->mbs_allocated, 0)) - { - if (pstr->icase) - build_upper_buffer (pstr); - else if (pstr->trans != NULL) - re_string_translate_buffer (pstr); - } - else - pstr->valid_len = pstr->len; + if (BE (pstr->mbs_allocated, 0)) + { + if (pstr->icase) + build_upper_buffer (pstr); + else if (pstr->trans != NULL) + re_string_translate_buffer (pstr); + } + else + pstr->valid_len = pstr->len; pstr->cur_idx = 0; return REG_NOERROR; @@ -1227,12 +1241,12 @@ re_node_set_insert (set, elem) /* Realloc if we need. */ if (set->alloc == set->nelem) { - int *new_array; + int *new_elems; set->alloc = set->alloc * 2; - new_array = re_realloc (set->elems, int, set->alloc); - if (BE (new_array == NULL, 0)) + new_elems = re_realloc (set->elems, int, set->alloc); + if (BE (new_elems == NULL, 0)) return -1; - set->elems = new_array; + set->elems = new_elems; } /* Move the elements which follows the new element. Test the @@ -1267,12 +1281,12 @@ re_node_set_insert_last (set, elem) /* Realloc if we need. */ if (set->alloc == set->nelem) { - int *new_array; + int *new_elems; set->alloc = (set->alloc + 1) * 2; - new_array = re_realloc (set->elems, int, set->alloc); - if (BE (new_array == NULL, 0)) + new_elems = re_realloc (set->elems, int, set->alloc); + if (BE (new_elems == NULL, 0)) return -1; - set->elems = new_array; + set->elems = new_elems; } /* Insert the new element. */ @@ -1345,15 +1359,19 @@ re_dfa_add_node (dfa, token) int type = token.type; if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0)) { - int new_nodes_alloc = dfa->nodes_alloc * 2; + size_t new_nodes_alloc = dfa->nodes_alloc * 2; int *new_nexts, *new_indices; re_node_set *new_edests, *new_eclosures; + re_token_t *new_nodes; - re_token_t *new_array = re_realloc (dfa->nodes, re_token_t, - new_nodes_alloc); - if (BE (new_array == NULL, 0)) + /* Avoid overflows. */ + if (BE (new_nodes_alloc < dfa->nodes_alloc, 0)) return -1; - dfa->nodes = new_array; + + new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc); + if (BE (new_nodes == NULL, 0)) + return -1; + dfa->nodes = new_nodes; new_nexts = re_realloc (dfa->nexts, int, new_nodes_alloc); new_indices = re_realloc (dfa->org_indices, int, new_nodes_alloc); new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc); @@ -1379,7 +1397,7 @@ re_dfa_add_node (dfa, token) return dfa->nodes_len++; } -static unsigned int inline +static inline unsigned int calc_state_hash (nodes, context) const re_node_set *nodes; unsigned int context; @@ -1403,7 +1421,7 @@ calc_state_hash (nodes, context) static re_dfastate_t* re_acquire_state (err, dfa, nodes) reg_errcode_t *err; - re_dfa_t *dfa; + const re_dfa_t *dfa; const re_node_set *nodes; { unsigned int hash; @@ -1429,13 +1447,10 @@ re_acquire_state (err, dfa, nodes) /* There are no appropriate state in the dfa, create the new one. */ new_state = create_ci_newstate (dfa, nodes, hash); - if (BE (new_state != NULL, 1)) - return new_state; - else - { - *err = REG_ESPACE; - return NULL; - } + if (BE (new_state == NULL, 0)) + *err = REG_ESPACE; + + return new_state; } /* Search for the state whose node_set is equivalent to NODES and @@ -1451,7 +1466,7 @@ re_acquire_state (err, dfa, nodes) static re_dfastate_t* re_acquire_state_context (err, dfa, nodes, context) reg_errcode_t *err; - re_dfa_t *dfa; + const re_dfa_t *dfa; const re_node_set *nodes; unsigned int context; { @@ -1477,13 +1492,10 @@ re_acquire_state_context (err, dfa, nodes, context) } /* There are no appropriate state in `dfa', create the new one. */ new_state = create_cd_newstate (dfa, nodes, context, hash); - if (BE (new_state != NULL, 1)) - return new_state; - else - { - *err = REG_ESPACE; - return NULL; - } + if (BE (new_state == NULL, 0)) + *err = REG_ESPACE; + + return new_state; } /* Finish initialization of the new state NEWSTATE, and using its hash value @@ -1492,7 +1504,7 @@ re_acquire_state_context (err, dfa, nodes, context) static reg_errcode_t register_state (dfa, newstate, hash) - re_dfa_t *dfa; + const re_dfa_t *dfa; re_dfastate_t *newstate; unsigned int hash; { @@ -1531,7 +1543,7 @@ register_state (dfa, newstate, hash) static re_dfastate_t * create_ci_newstate (dfa, nodes, hash) - re_dfa_t *dfa; + const re_dfa_t *dfa; const re_node_set *nodes; unsigned int hash; { @@ -1582,7 +1594,7 @@ create_ci_newstate (dfa, nodes, hash) static re_dfastate_t * create_cd_newstate (dfa, nodes, context, hash) - re_dfa_t *dfa; + const re_dfa_t *dfa; const re_node_set *nodes; unsigned int context, hash; { diff --git a/posix/regex_internal.h b/posix/regex_internal.h index 6db384416a..debbe0db3b 100644 --- a/posix/regex_internal.h +++ b/posix/regex_internal.h @@ -91,8 +91,6 @@ # define inline #endif -/* Number of bits in a byte. */ -#define BYTE_BITS 8 /* Number of single byte character. */ #define SBC_MAX 256 @@ -123,16 +121,16 @@ extern const char __re_error_msgid[] attribute_hidden; extern const size_t __re_error_msgid_idx[] attribute_hidden; /* Number of bits in an unsinged int. */ -#define UINT_BITS (sizeof (unsigned int) * BYTE_BITS) +#define UINT_BITS (sizeof (unsigned int) * CHAR_BIT) /* Number of unsigned int in an bit_set. */ #define BITSET_UINTS ((SBC_MAX + UINT_BITS - 1) / UINT_BITS) typedef unsigned int bitset[BITSET_UINTS]; typedef unsigned int *re_bitset_ptr_t; typedef const unsigned int *re_const_bitset_ptr_t; -#define bitset_set(set,i) (set[i / UINT_BITS] |= 1 << i % UINT_BITS) -#define bitset_clear(set,i) (set[i / UINT_BITS] &= ~(1 << i % UINT_BITS)) -#define bitset_contain(set,i) (set[i / UINT_BITS] & (1 << i % UINT_BITS)) +#define bitset_set(set,i) (set[i / UINT_BITS] |= 1u << i % UINT_BITS) +#define bitset_clear(set,i) (set[i / UINT_BITS] &= ~(1u << i % UINT_BITS)) +#define bitset_contain(set,i) (set[i / UINT_BITS] & (1u << i % UINT_BITS)) #define bitset_empty(set) memset (set, 0, sizeof (unsigned int) * BITSET_UINTS) #define bitset_set_all(set) \ memset (set, 255, sizeof (unsigned int) * BITSET_UINTS) @@ -430,6 +428,21 @@ static unsigned char re_string_fetch_byte_case (re_string_t *pstr) #define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx)) #define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx)) +#include <alloca.h> + +#ifndef _LIBC +# if HAVE_ALLOCA +/* The OS usually guarantees only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + allocate anything larger than 4096 bytes. Also care for the possibility + of a few compiler-allocated temporary stack slots. */ +# define __libc_use_alloca(n) ((n) < 4032) +# else +/* alloca is implemented with malloc, so just use malloc. */ +# define __libc_use_alloca(n) 0 +# endif +#endif + #define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t))) #define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t))) #define re_free(p) free (p) @@ -541,7 +554,6 @@ typedef struct { int str_idx; int node; - int next_last_offset; state_array_t *path; int alasts; /* Allocation size of LASTS. */ int nlasts; /* The number of LASTS. */ @@ -564,9 +576,9 @@ typedef struct /* The string object corresponding to the input string. */ re_string_t input; #if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) - re_dfa_t *const dfa; + const re_dfa_t *const dfa; #else - re_dfa_t *dfa; + const re_dfa_t *dfa; #endif /* EFLAGS of the argument of regexec. */ int eflags; @@ -613,8 +625,8 @@ struct re_fail_stack_t struct re_dfa_t { re_token_t *nodes; - int nodes_alloc; - int nodes_len; + size_t nodes_alloc; + size_t nodes_len; int *nexts; int *org_indices; re_node_set *edests; @@ -632,7 +644,6 @@ struct re_dfa_t /* number of subexpressions `re_nsub' is in regex_t. */ unsigned int state_hash_mask; - int states_alloc; int init_node; int nbackref; /* The number of backreference in this dfa. */ @@ -688,10 +699,12 @@ static void re_node_set_remove_at (re_node_set *set, int idx) internal_function; #define re_node_set_empty(p) ((p)->nelem = 0) #define re_node_set_free(set) re_free ((set)->elems) static int re_dfa_add_node (re_dfa_t *dfa, re_token_t token) internal_function; -static re_dfastate_t *re_acquire_state (reg_errcode_t *err, re_dfa_t *dfa, - const re_node_set *nodes) internal_function; +static re_dfastate_t *re_acquire_state (reg_errcode_t *err, const + re_dfa_t *dfa, + const re_node_set *nodes) + internal_function; static re_dfastate_t *re_acquire_state_context (reg_errcode_t *err, - re_dfa_t *dfa, + const re_dfa_t *dfa, const re_node_set *nodes, unsigned int context) internal_function; static void free_state (re_dfastate_t *state) internal_function; diff --git a/posix/regexec.c b/posix/regexec.c index e635261d05..78042727f9 100644 --- a/posix/regexec.c +++ b/posix/regexec.c @@ -25,7 +25,7 @@ static void match_ctx_free (re_match_context_t *cache) internal_function; static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache, int node, int str_idx, int from, int to) internal_function; -static int search_cur_bkref_entry (re_match_context_t *mctx, int str_idx) +static int search_cur_bkref_entry (const re_match_context_t *mctx, int str_idx) internal_function; static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, int node, int str_idx) internal_function; @@ -58,14 +58,13 @@ static inline re_dfastate_t *acquire_init_state_context static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx) internal_function; static int check_matching (re_match_context_t *mctx, int fl_longest_match, - int *p_match_first) - internal_function; + int *p_match_first) internal_function; static int check_halt_node_context (const re_dfa_t *dfa, int node, unsigned int context) internal_function; static int check_halt_state_context (const re_match_context_t *mctx, const re_dfastate_t *state, int idx) internal_function; -static void update_regs (re_dfa_t *dfa, regmatch_t *pmatch, +static void update_regs (const re_dfa_t *dfa, regmatch_t *pmatch, regmatch_t *prev_idx_match, int cur_node, int cur_idx, int nmatch) internal_function; static int proceed_next_node (const re_match_context_t *mctx, @@ -75,58 +74,73 @@ static int proceed_next_node (const re_match_context_t *mctx, static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs, int str_idx, int dest_node, int nregs, regmatch_t *regs, - re_node_set *eps_via_nodes) internal_function; + re_node_set *eps_via_nodes) + internal_function; static int pop_fail_stack (struct re_fail_stack_t *fs, int *pidx, int nregs, - regmatch_t *regs, re_node_set *eps_via_nodes) internal_function; + regmatch_t *regs, re_node_set *eps_via_nodes) + internal_function; static reg_errcode_t set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch, regmatch_t *pmatch, int fl_backtrack) internal_function; -static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs) internal_function; +static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs) + internal_function; #ifdef RE_ENABLE_I18N static int sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx, - int node_idx, int str_idx, int max_str_idx) internal_function; + int node_idx, int str_idx, int max_str_idx) + internal_function; #endif /* RE_ENABLE_I18N */ -static reg_errcode_t sift_states_backward (re_match_context_t *mctx, - re_sift_context_t *sctx) internal_function; -static reg_errcode_t build_sifted_states (re_match_context_t *mctx, +static reg_errcode_t sift_states_backward (const re_match_context_t *mctx, + re_sift_context_t *sctx) + internal_function; +static reg_errcode_t build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx, int str_idx, - re_node_set *cur_dest) internal_function; -static reg_errcode_t update_cur_sifted_state (re_match_context_t *mctx, + re_node_set *cur_dest) + internal_function; +static reg_errcode_t update_cur_sifted_state (const re_match_context_t *mctx, re_sift_context_t *sctx, int str_idx, - re_node_set *dest_nodes) internal_function; -static reg_errcode_t add_epsilon_src_nodes (re_dfa_t *dfa, + re_node_set *dest_nodes) + internal_function; +static reg_errcode_t add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes, - const re_node_set *candidates) internal_function; -static reg_errcode_t sub_epsilon_src_nodes (re_dfa_t *dfa, int node, + const re_node_set *candidates) + internal_function; +static reg_errcode_t sub_epsilon_src_nodes (const re_dfa_t *dfa, int node, re_node_set *dest_nodes, - const re_node_set *and_nodes) internal_function; -static int check_dst_limits (re_match_context_t *mctx, re_node_set *limits, + const re_node_set *and_nodes) + internal_function; +static int check_dst_limits (const re_match_context_t *mctx, + re_node_set *limits, int dst_node, int dst_idx, int src_node, int src_idx) internal_function; -static int check_dst_limits_calc_pos_1 (re_match_context_t *mctx, +static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries, int subexp_idx, - int from_node, int bkref_idx) internal_function; -static int check_dst_limits_calc_pos (re_match_context_t *mctx, + int from_node, int bkref_idx) + internal_function; +static int check_dst_limits_calc_pos (const re_match_context_t *mctx, int limit, int subexp_idx, int node, int str_idx, int bkref_idx) internal_function; -static reg_errcode_t check_subexp_limits (re_dfa_t *dfa, +static reg_errcode_t check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes, const re_node_set *candidates, re_node_set *limits, struct re_backref_cache_entry *bkref_ents, int str_idx) internal_function; -static reg_errcode_t sift_states_bkref (re_match_context_t *mctx, +static reg_errcode_t sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx, - int str_idx, const re_node_set *candidates) internal_function; + int str_idx, const re_node_set *candidates) + internal_function; static reg_errcode_t clean_state_log_if_needed (re_match_context_t *mctx, - int next_state_log_idx) internal_function; -static reg_errcode_t merge_state_array (re_dfa_t *dfa, re_dfastate_t **dst, - re_dfastate_t **src, int num) internal_function; + int next_state_log_idx) + internal_function; +static reg_errcode_t merge_state_array (const re_dfa_t *dfa, + re_dfastate_t **dst, + re_dfastate_t **src, int num) + internal_function; static re_dfastate_t *find_recover_state (reg_errcode_t *err, re_match_context_t *mctx) internal_function; static re_dfastate_t *transit_state (reg_errcode_t *err, @@ -134,27 +148,33 @@ static re_dfastate_t *transit_state (reg_errcode_t *err, re_dfastate_t *state) internal_function; static re_dfastate_t *merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx, - re_dfastate_t *next_state) internal_function; + re_dfastate_t *next_state) + internal_function; static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes, int str_idx) internal_function; #if 0 static re_dfastate_t *transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx, - re_dfastate_t *pstate) internal_function; + re_dfastate_t *pstate) + internal_function; #endif #ifdef RE_ENABLE_I18N static reg_errcode_t transit_state_mb (re_match_context_t *mctx, - re_dfastate_t *pstate) internal_function; + re_dfastate_t *pstate) + internal_function; #endif /* RE_ENABLE_I18N */ static reg_errcode_t transit_state_bkref (re_match_context_t *mctx, - const re_node_set *nodes) internal_function; + const re_node_set *nodes) + internal_function; static reg_errcode_t get_subexp (re_match_context_t *mctx, - int bkref_node, int bkref_str_idx) internal_function; + int bkref_node, int bkref_str_idx) + internal_function; static reg_errcode_t get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top, re_sub_match_last_t *sub_last, - int bkref_node, int bkref_str) internal_function; + int bkref_node, int bkref_str) + internal_function; static int find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes, int subexp_idx, int type) internal_function; static reg_errcode_t check_arrival (re_match_context_t *mctx, @@ -164,34 +184,41 @@ static reg_errcode_t check_arrival (re_match_context_t *mctx, static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t *mctx, int str_idx, re_node_set *cur_nodes, - re_node_set *next_nodes) internal_function; -static reg_errcode_t check_arrival_expand_ecl (re_dfa_t *dfa, + re_node_set *next_nodes) + internal_function; +static reg_errcode_t check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes, - int ex_subexp, int type) internal_function; -static reg_errcode_t check_arrival_expand_ecl_sub (re_dfa_t *dfa, + int ex_subexp, int type) + internal_function; +static reg_errcode_t check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes, int target, int ex_subexp, int type) internal_function; static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes, int cur_str, - int subexp_num, int type) internal_function; -static int build_trtable (re_dfa_t *dfa, + int subexp_num, int type) + internal_function; +static int build_trtable (const re_dfa_t *dfa, re_dfastate_t *state) internal_function; #ifdef RE_ENABLE_I18N -static int check_node_accept_bytes (re_dfa_t *dfa, int node_idx, - const re_string_t *input, int idx) internal_function; +static int check_node_accept_bytes (const re_dfa_t *dfa, int node_idx, + const re_string_t *input, int idx) + internal_function; # ifdef _LIBC static unsigned int find_collation_sequence_value (const unsigned char *mbs, - size_t name_len) internal_function; + size_t name_len) + internal_function; # endif /* _LIBC */ #endif /* RE_ENABLE_I18N */ -static int group_nodes_into_DFAstates (re_dfa_t *dfa, +static int group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state, re_node_set *states_node, bitset *states_ch) internal_function; static int check_node_accept (const re_match_context_t *mctx, - const re_token_t *node, int idx) internal_function; -static reg_errcode_t extend_buffers (re_match_context_t *mctx) internal_function; + const re_token_t *node, int idx) + internal_function; +static reg_errcode_t extend_buffers (re_match_context_t *mctx) + internal_function; /* Entry point for POSIX code. */ @@ -219,7 +246,7 @@ regexec (preg, string, nmatch, pmatch, eflags) { reg_errcode_t err; int start, length; - re_dfa_t *dfa = (re_dfa_t *)preg->buffer; + re_dfa_t *dfa = (re_dfa_t *) preg->buffer; if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND)) return REG_BADPAT; @@ -373,8 +400,12 @@ re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs, if (BE (s == NULL, 0)) return -2; +#ifdef _LIBC + memcpy (__mempcpy (s, string1, length1), string2, length2); +#else memcpy (s, string1, length1); memcpy (s + length1, string2, length2); +#endif str = s; free_str = 1; } @@ -406,7 +437,7 @@ re_search_stub (bufp, string, length, start, range, stop, regs, ret_len) regmatch_t *pmatch; int nregs, rval; int eflags = 0; - re_dfa_t *dfa = (re_dfa_t *)bufp->buffer; + re_dfa_t *dfa = (re_dfa_t *) bufp->buffer; /* Check for out-of-range. */ if (BE (start < 0 || start > length, 0)) @@ -614,7 +645,7 @@ re_search_internal (preg, string, length, start, range, stop, nmatch, pmatch, regmatch_t pmatch[]; { reg_errcode_t err; - re_dfa_t *dfa = (re_dfa_t *)preg->buffer; + const re_dfa_t *dfa = (const re_dfa_t *) preg->buffer; int left_lim, right_lim, incr; int fl_longest_match, match_first, match_kind, match_last = -1; int extra_nmatch; @@ -883,14 +914,14 @@ re_search_internal (preg, string, length, start, range, stop, nmatch, pmatch, #ifdef RE_ENABLE_I18N if (BE (mctx.input.offsets_needed != 0, 0)) { - if (pmatch[reg_idx].rm_so == mctx.input.valid_len) - pmatch[reg_idx].rm_so += mctx.input.valid_raw_len - mctx.input.valid_len; - else - pmatch[reg_idx].rm_so = mctx.input.offsets[pmatch[reg_idx].rm_so]; - if (pmatch[reg_idx].rm_eo == mctx.input.valid_len) - pmatch[reg_idx].rm_eo += mctx.input.valid_raw_len - mctx.input.valid_len; - else - pmatch[reg_idx].rm_eo = mctx.input.offsets[pmatch[reg_idx].rm_eo]; + pmatch[reg_idx].rm_so = + (pmatch[reg_idx].rm_so == mctx.input.valid_len + ? mctx.input.valid_raw_len + : mctx.input.offsets[pmatch[reg_idx].rm_so]); + pmatch[reg_idx].rm_eo = + (pmatch[reg_idx].rm_eo == mctx.input.valid_len + ? mctx.input.valid_raw_len + : mctx.input.offsets[pmatch[reg_idx].rm_eo]); } #else assert (mctx.input.offsets_needed == 0); @@ -927,7 +958,7 @@ static reg_errcode_t prune_impossible_nodes (mctx) re_match_context_t *mctx; { - re_dfa_t *const dfa = mctx->dfa; + const re_dfa_t *const dfa = mctx->dfa; int halt_node, match_last; reg_errcode_t ret; re_dfastate_t **sifted_states; @@ -1015,7 +1046,7 @@ acquire_init_state_context (err, mctx, idx) const re_match_context_t *mctx; int idx; { - re_dfa_t *const dfa = mctx->dfa; + const re_dfa_t *const dfa = mctx->dfa; if (dfa->init_state->has_constraint) { unsigned int context; @@ -1054,11 +1085,11 @@ acquire_init_state_context (err, mctx, idx) static int check_matching (mctx, fl_longest_match, p_match_first) - re_match_context_t *mctx; - int fl_longest_match; - int *p_match_first; + re_match_context_t *mctx; + int fl_longest_match; + int *p_match_first; { - re_dfa_t *const dfa = mctx->dfa; + const re_dfa_t *const dfa = mctx->dfa; reg_errcode_t err; int match = 0; int match_last = -1; @@ -1236,9 +1267,8 @@ proceed_next_node (mctx, nregs, regs, pidx, node, eps_via_nodes, fs) re_node_set *eps_via_nodes; struct re_fail_stack_t *fs; { - re_dfa_t *const dfa = mctx->dfa; - int i, err, dest_node; - dest_node = -1; + const re_dfa_t *const dfa = mctx->dfa; + int i, err; if (IS_EPSILON_NODE (dfa->nodes[node].type)) { re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes; @@ -1304,6 +1334,7 @@ proceed_next_node (mctx, nregs, regs, pidx, node, eps_via_nodes, fs) if (naccepted == 0) { + int dest_node; err = re_node_set_insert (eps_via_nodes, node); if (BE (err < 0, 0)) return -2; @@ -1317,7 +1348,7 @@ proceed_next_node (mctx, nregs, regs, pidx, node, eps_via_nodes, fs) if (naccepted != 0 || check_node_accept (mctx, dfa->nodes + node, *pidx)) { - dest_node = dfa->nexts[node]; + int dest_node = dfa->nexts[node]; *pidx = (naccepted == 0) ? *pidx + 1 : *pidx + naccepted; if (fs && (*pidx > mctx->match_last || mctx->state_log[*pidx] == NULL || !re_node_set_contains (&mctx->state_log[*pidx]->nodes, @@ -1389,12 +1420,13 @@ set_regs (preg, mctx, nmatch, pmatch, fl_backtrack) regmatch_t *pmatch; int fl_backtrack; { - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; + const re_dfa_t *dfa = (const re_dfa_t *) preg->buffer; int idx, cur_node; re_node_set eps_via_nodes; struct re_fail_stack_t *fs; struct re_fail_stack_t fs_body = { 0, 2, NULL }; regmatch_t *prev_idx_match; + int prev_idx_match_malloced = 0; #ifdef DEBUG assert (nmatch > 1); @@ -1413,7 +1445,18 @@ set_regs (preg, mctx, nmatch, pmatch, fl_backtrack) cur_node = dfa->init_node; re_node_set_init_empty (&eps_via_nodes); - prev_idx_match = (regmatch_t *) alloca (sizeof (regmatch_t) * nmatch); + if (__libc_use_alloca (nmatch * sizeof (regmatch_t))) + prev_idx_match = (regmatch_t *) alloca (nmatch * sizeof (regmatch_t)); + else + { + prev_idx_match = re_malloc (regmatch_t, nmatch); + if (prev_idx_match == NULL) + { + free_fail_stack_return (fs); + return REG_ESPACE; + } + prev_idx_match_malloced = 1; + } memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch); for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;) @@ -1431,6 +1474,8 @@ set_regs (preg, mctx, nmatch, pmatch, fl_backtrack) if (reg_idx == nmatch) { re_node_set_free (&eps_via_nodes); + if (prev_idx_match_malloced) + re_free (prev_idx_match); return free_fail_stack_return (fs); } cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch, @@ -1439,6 +1484,8 @@ set_regs (preg, mctx, nmatch, pmatch, fl_backtrack) else { re_node_set_free (&eps_via_nodes); + if (prev_idx_match_malloced) + re_free (prev_idx_match); return REG_NOERROR; } } @@ -1452,6 +1499,8 @@ set_regs (preg, mctx, nmatch, pmatch, fl_backtrack) if (BE (cur_node == -2, 0)) { re_node_set_free (&eps_via_nodes); + if (prev_idx_match_malloced) + re_free (prev_idx_match); free_fail_stack_return (fs); return REG_ESPACE; } @@ -1461,11 +1510,15 @@ set_regs (preg, mctx, nmatch, pmatch, fl_backtrack) else { re_node_set_free (&eps_via_nodes); + if (prev_idx_match_malloced) + re_free (prev_idx_match); return REG_NOMATCH; } } } re_node_set_free (&eps_via_nodes); + if (prev_idx_match_malloced) + re_free (prev_idx_match); return free_fail_stack_return (fs); } @@ -1488,7 +1541,7 @@ free_fail_stack_return (fs) static void update_regs (dfa, pmatch, prev_idx_match, cur_node, cur_idx, nmatch) - re_dfa_t *dfa; + const re_dfa_t *dfa; regmatch_t *pmatch, *prev_idx_match; int cur_node, cur_idx, nmatch; { @@ -1561,7 +1614,7 @@ update_regs (dfa, pmatch, prev_idx_match, cur_node, cur_idx, nmatch) static reg_errcode_t sift_states_backward (mctx, sctx) - re_match_context_t *mctx; + const re_match_context_t *mctx; re_sift_context_t *sctx; { reg_errcode_t err; @@ -1620,13 +1673,13 @@ sift_states_backward (mctx, sctx) static reg_errcode_t build_sifted_states (mctx, sctx, str_idx, cur_dest) - re_match_context_t *mctx; + const re_match_context_t *mctx; re_sift_context_t *sctx; int str_idx; re_node_set *cur_dest; { - re_dfa_t *const dfa = mctx->dfa; - re_node_set *cur_src = &mctx->state_log[str_idx]->non_eps_nodes; + const re_dfa_t *const dfa = mctx->dfa; + const re_node_set *cur_src = &mctx->state_log[str_idx]->non_eps_nodes; int i; /* Then build the next sifted state. @@ -1710,7 +1763,7 @@ clean_state_log_if_needed (mctx, next_state_log_idx) static reg_errcode_t merge_state_array (dfa, dst, src, num) - re_dfa_t *dfa; + const re_dfa_t *dfa; re_dfastate_t **dst; re_dfastate_t **src; int num; @@ -1739,12 +1792,12 @@ merge_state_array (dfa, dst, src, num) static reg_errcode_t update_cur_sifted_state (mctx, sctx, str_idx, dest_nodes) - re_match_context_t *mctx; + const re_match_context_t *mctx; re_sift_context_t *sctx; int str_idx; re_node_set *dest_nodes; { - re_dfa_t *const dfa = mctx->dfa; + const re_dfa_t *const dfa = mctx->dfa; reg_errcode_t err; const re_node_set *candidates; candidates = ((mctx->state_log[str_idx] == NULL) ? NULL @@ -1788,7 +1841,7 @@ update_cur_sifted_state (mctx, sctx, str_idx, dest_nodes) static reg_errcode_t add_epsilon_src_nodes (dfa, dest_nodes, candidates) - re_dfa_t *dfa; + const re_dfa_t *dfa; re_node_set *dest_nodes; const re_node_set *candidates; { @@ -1814,7 +1867,7 @@ add_epsilon_src_nodes (dfa, dest_nodes, candidates) static reg_errcode_t sub_epsilon_src_nodes (dfa, node, dest_nodes, candidates) - re_dfa_t *dfa; + const re_dfa_t *dfa; int node; re_node_set *dest_nodes; const re_node_set *candidates; @@ -1865,11 +1918,11 @@ sub_epsilon_src_nodes (dfa, node, dest_nodes, candidates) static int check_dst_limits (mctx, limits, dst_node, dst_idx, src_node, src_idx) - re_match_context_t *mctx; + const re_match_context_t *mctx; re_node_set *limits; int dst_node, dst_idx, src_node, src_idx; { - re_dfa_t *const dfa = mctx->dfa; + const re_dfa_t *const dfa = mctx->dfa; int lim_idx, src_pos, dst_pos; int dst_bkref_idx = search_cur_bkref_entry (mctx, dst_idx); @@ -1902,11 +1955,11 @@ check_dst_limits (mctx, limits, dst_node, dst_idx, src_node, src_idx) static int check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx, from_node, bkref_idx) - re_match_context_t *mctx; + const re_match_context_t *mctx; int boundaries, subexp_idx, from_node, bkref_idx; { - re_dfa_t *const dfa = mctx->dfa; - re_node_set *eclosures = dfa->eclosures + from_node; + const re_dfa_t *const dfa = mctx->dfa; + const re_node_set *eclosures = dfa->eclosures + from_node; int node_idx; /* Else, we are on the boundary: examine the nodes on the epsilon @@ -1927,8 +1980,9 @@ check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx, from_node, bkref_idx) if (ent->node != node) continue; - if (subexp_idx <= 8 * sizeof (ent->eps_reachable_subexps_map) - && !(ent->eps_reachable_subexps_map & (1 << subexp_idx))) + if (subexp_idx + < CHAR_BIT * sizeof ent->eps_reachable_subexps_map + && !(ent->eps_reachable_subexps_map & (1u << subexp_idx))) continue; /* Recurse trying to reach the OP_OPEN_SUBEXP and @@ -1954,7 +2008,9 @@ check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx, from_node, bkref_idx) if (cpos == 0 && (boundaries & 2)) return 0; - ent->eps_reachable_subexps_map &= ~(1 << subexp_idx); + if (subexp_idx + < CHAR_BIT * sizeof ent->eps_reachable_subexps_map) + ent->eps_reachable_subexps_map &= ~(1u << subexp_idx); } while (ent++->more); } @@ -1980,7 +2036,7 @@ check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx, from_node, bkref_idx) static int check_dst_limits_calc_pos (mctx, limit, subexp_idx, from_node, str_idx, bkref_idx) - re_match_context_t *mctx; + const re_match_context_t *mctx; int limit, subexp_idx, from_node, str_idx, bkref_idx; { struct re_backref_cache_entry *lim = mctx->bkref_ents + limit; @@ -2009,7 +2065,7 @@ check_dst_limits_calc_pos (mctx, limit, subexp_idx, from_node, str_idx, bkref_id static reg_errcode_t check_subexp_limits (dfa, dest_nodes, candidates, limits, bkref_ents, str_idx) - re_dfa_t *dfa; + const re_dfa_t *dfa; re_node_set *dest_nodes; const re_node_set *candidates; re_node_set *limits; @@ -2100,12 +2156,12 @@ check_subexp_limits (dfa, dest_nodes, candidates, limits, bkref_ents, str_idx) static reg_errcode_t sift_states_bkref (mctx, sctx, str_idx, candidates) - re_match_context_t *mctx; + const re_match_context_t *mctx; re_sift_context_t *sctx; int str_idx; const re_node_set *candidates; { - re_dfa_t *const dfa = mctx->dfa; + const re_dfa_t *const dfa = mctx->dfa; reg_errcode_t err; int node_idx, node; re_sift_context_t local_sctx; @@ -2133,7 +2189,10 @@ sift_states_bkref (mctx, sctx, str_idx, candidates) enabled_idx = first_idx; do { - int subexp_len, to_idx, dst_node; + int subexp_len; + int to_idx; + int dst_node; + int ret; re_dfastate_t *cur_state; if (entry->node != node) @@ -2159,8 +2218,8 @@ sift_states_bkref (mctx, sctx, str_idx, candidates) } local_sctx.last_node = node; local_sctx.last_str_idx = str_idx; - err = re_node_set_insert (&local_sctx.limits, enabled_idx); - if (BE (err < 0, 0)) + ret = re_node_set_insert (&local_sctx.limits, enabled_idx); + if (BE (ret < 0, 0)) { err = REG_ESPACE; goto free_return; @@ -2203,7 +2262,7 @@ sift_states_iter_mb (mctx, sctx, node_idx, str_idx, max_str_idx) re_sift_context_t *sctx; int node_idx, str_idx, max_str_idx; { - re_dfa_t *const dfa = mctx->dfa; + const re_dfa_t *const dfa = mctx->dfa; int naccepted; /* Check the node can accept `multi byte'. */ naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx); @@ -2293,7 +2352,7 @@ merge_state_with_log (err, mctx, next_state) re_match_context_t *mctx; re_dfastate_t *next_state; { - re_dfa_t *const dfa = mctx->dfa; + const re_dfa_t *const dfa = mctx->dfa; int cur_idx = re_string_cur_idx (&mctx->input); if (cur_idx > mctx->state_log_top) @@ -2372,7 +2431,7 @@ find_recover_state (err, mctx) reg_errcode_t *err; re_match_context_t *mctx; { - re_dfastate_t *cur_state = NULL; + re_dfastate_t *cur_state; do { int max = mctx->state_log_top; @@ -2388,7 +2447,7 @@ find_recover_state (err, mctx) cur_state = merge_state_with_log (err, mctx, NULL); } - while (err == REG_NOERROR && cur_state == NULL); + while (*err == REG_NOERROR && cur_state == NULL); return cur_state; } @@ -2405,7 +2464,7 @@ check_subexp_matching_top (mctx, cur_nodes, str_idx) re_node_set *cur_nodes; int str_idx; { - re_dfa_t *const dfa = mctx->dfa; + const re_dfa_t *const dfa = mctx->dfa; int node_idx; reg_errcode_t err; @@ -2418,8 +2477,8 @@ check_subexp_matching_top (mctx, cur_nodes, str_idx) { int node = cur_nodes->elems[node_idx]; if (dfa->nodes[node].type == OP_OPEN_SUBEXP - && dfa->nodes[node].opr.idx < (8 * sizeof (dfa->used_bkref_map)) - && dfa->used_bkref_map & (1 << dfa->nodes[node].opr.idx)) + && dfa->nodes[node].opr.idx < CHAR_BIT * sizeof dfa->used_bkref_map + && dfa->used_bkref_map & (1u << dfa->nodes[node].opr.idx)) { err = match_ctx_add_subtop (mctx, node, str_idx); if (BE (err != REG_NOERROR, 0)) @@ -2439,7 +2498,7 @@ transit_state_sb (err, mctx, state) re_match_context_t *mctx; re_dfastate_t *state; { - re_dfa_t *const dfa = mctx->dfa; + const re_dfa_t *const dfa = mctx->dfa; re_node_set next_nodes; re_dfastate_t *next_state; int node_cnt, cur_str_idx = re_string_cur_idx (&mctx->input); @@ -2479,7 +2538,7 @@ transit_state_mb (mctx, pstate) re_match_context_t *mctx; re_dfastate_t *pstate; { - re_dfa_t *const dfa = mctx->dfa; + const re_dfa_t *const dfa = mctx->dfa; reg_errcode_t err; int i; @@ -2532,7 +2591,8 @@ transit_state_mb (mctx, pstate) if (BE (err != REG_NOERROR, 0)) return err; } - context = re_string_context_at (&mctx->input, dest_idx - 1, mctx->eflags); + context = re_string_context_at (&mctx->input, dest_idx - 1, + mctx->eflags); mctx->state_log[dest_idx] = re_acquire_state_context (&err, dfa, &dest_nodes, context); if (dest_state != NULL) @@ -2549,7 +2609,7 @@ transit_state_bkref (mctx, nodes) re_match_context_t *mctx; const re_node_set *nodes; { - re_dfa_t *const dfa = mctx->dfa; + const re_dfa_t *const dfa = mctx->dfa; reg_errcode_t err; int i; int cur_str_idx = re_string_cur_idx (&mctx->input); @@ -2664,14 +2724,15 @@ get_subexp (mctx, bkref_node, bkref_str_idx) re_match_context_t *mctx; int bkref_node, bkref_str_idx; { - re_dfa_t *const dfa = mctx->dfa; + const re_dfa_t *const dfa = mctx->dfa; int subexp_num, sub_top_idx; const char *buf = (const char *) re_string_get_buffer (&mctx->input); /* Return if we have already checked BKREF_NODE at BKREF_STR_IDX. */ int cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx); if (cache_idx != -1) { - const struct re_backref_cache_entry *entry = mctx->bkref_ents + cache_idx; + const struct re_backref_cache_entry *entry + = mctx->bkref_ents + cache_idx; do if (entry->node == bkref_node) return REG_NOERROR; /* We already checked it. */ @@ -2718,7 +2779,8 @@ get_subexp (mctx, bkref_node, bkref_str_idx) buf = (const char *) re_string_get_buffer (&mctx->input); } if (memcmp (buf + bkref_str_off, buf + sl_str, sl_str_diff) != 0) - break; /* We don't need to search this sub expression any more. */ + /* We don't need to search this sub expression any more. */ + break; } bkref_str_off += sl_str_diff; sl_str += sl_str_diff; @@ -2769,7 +2831,8 @@ get_subexp (mctx, bkref_node, bkref_str_idx) continue; /* Does this state have a ')' of the sub expression? */ nodes = &mctx->state_log[sl_str]->nodes; - cls_node = find_subexp_node (dfa, nodes, subexp_num, OP_CLOSE_SUBEXP); + cls_node = find_subexp_node (dfa, nodes, subexp_num, + OP_CLOSE_SUBEXP); if (cls_node == -1) continue; /* No. */ if (sub_top->path == NULL) @@ -2782,7 +2845,8 @@ get_subexp (mctx, bkref_node, bkref_str_idx) /* Can the OP_OPEN_SUBEXP node arrive the OP_CLOSE_SUBEXP node in the current context? */ err = check_arrival (mctx, sub_top->path, sub_top->node, - sub_top->str_idx, cls_node, sl_str, OP_CLOSE_SUBEXP); + sub_top->str_idx, cls_node, sl_str, + OP_CLOSE_SUBEXP); if (err == REG_NOMATCH) continue; if (BE (err != REG_NOERROR, 0)) @@ -2816,7 +2880,8 @@ get_subexp_sub (mctx, sub_top, sub_last, bkref_node, bkref_str) int to_idx; /* Can the subexpression arrive the back reference? */ err = check_arrival (mctx, &sub_last->path, sub_last->node, - sub_last->str_idx, bkref_node, bkref_str, OP_OPEN_SUBEXP); + sub_last->str_idx, bkref_node, bkref_str, + OP_OPEN_SUBEXP); if (err != REG_NOERROR) return err; err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx, @@ -2865,7 +2930,7 @@ check_arrival (mctx, path, top_node, top_str, last_node, last_str, state_array_t *path; int top_node, top_str, last_node, last_str, type; { - re_dfa_t *const dfa = mctx->dfa; + const re_dfa_t *const dfa = mctx->dfa; reg_errcode_t err; int subexp_num, backup_cur_idx, str_idx, null_cnt; re_dfastate_t *cur_state = NULL; @@ -2881,7 +2946,7 @@ check_arrival (mctx, path, top_node, top_str, last_node, last_str, int old_alloc = path->alloc; path->alloc += last_str + mctx->max_mb_elem_len + 1; new_array = re_realloc (path->array, re_dfastate_t *, path->alloc); - if (new_array == NULL) + if (BE (new_array == NULL, 0)) { path->alloc = old_alloc; return REG_ESPACE; @@ -2919,7 +2984,7 @@ check_arrival (mctx, path, top_node, top_str, last_node, last_str, if (cur_state && cur_state->has_backref) { err = re_node_set_init_copy (&next_nodes, &cur_state->nodes); - if (BE ( err != REG_NOERROR, 0)) + if (BE (err != REG_NOERROR, 0)) return err; } else @@ -2931,7 +2996,7 @@ check_arrival (mctx, path, top_node, top_str, last_node, last_str, { err = expand_bkref_cache (mctx, &next_nodes, str_idx, subexp_num, type); - if (BE ( err != REG_NOERROR, 0)) + if (BE (err != REG_NOERROR, 0)) { re_node_set_free (&next_nodes); return err; @@ -2962,7 +3027,8 @@ check_arrival (mctx, path, top_node, top_str, last_node, last_str, if (cur_state) { err = check_arrival_add_next_nodes (mctx, str_idx, - &cur_state->non_eps_nodes, &next_nodes); + &cur_state->non_eps_nodes, + &next_nodes); if (BE (err != REG_NOERROR, 0)) { re_node_set_free (&next_nodes); @@ -2980,7 +3046,7 @@ check_arrival (mctx, path, top_node, top_str, last_node, last_str, } err = expand_bkref_cache (mctx, &next_nodes, str_idx, subexp_num, type); - if (BE ( err != REG_NOERROR, 0)) + if (BE (err != REG_NOERROR, 0)) { re_node_set_free (&next_nodes); return err; @@ -3026,7 +3092,7 @@ check_arrival_add_next_nodes (mctx, str_idx, cur_nodes, next_nodes) int str_idx; re_node_set *cur_nodes, *next_nodes; { - re_dfa_t *const dfa = mctx->dfa; + const re_dfa_t *const dfa = mctx->dfa; int result; int cur_idx; reg_errcode_t err; @@ -3102,7 +3168,7 @@ check_arrival_add_next_nodes (mctx, str_idx, cur_nodes, next_nodes) static reg_errcode_t check_arrival_expand_ecl (dfa, cur_nodes, ex_subexp, type) - re_dfa_t *dfa; + const re_dfa_t *dfa; re_node_set *cur_nodes; int ex_subexp, type; { @@ -3121,7 +3187,7 @@ check_arrival_expand_ecl (dfa, cur_nodes, ex_subexp, type) for (idx = 0; idx < cur_nodes->nelem; ++idx) { int cur_node = cur_nodes->elems[idx]; - re_node_set *eclosure = dfa->eclosures + cur_node; + const re_node_set *eclosure = dfa->eclosures + cur_node; outside_node = find_subexp_node (dfa, eclosure, ex_subexp, type); if (outside_node == -1) { @@ -3156,7 +3222,7 @@ check_arrival_expand_ecl (dfa, cur_nodes, ex_subexp, type) static reg_errcode_t check_arrival_expand_ecl_sub (dfa, dst_nodes, target, ex_subexp, type) - re_dfa_t *dfa; + const re_dfa_t *dfa; int target, ex_subexp, type; re_node_set *dst_nodes; { @@ -3206,7 +3272,7 @@ expand_bkref_cache (mctx, cur_nodes, cur_str, subexp_num, int cur_str, subexp_num, type; re_node_set *cur_nodes; { - re_dfa_t *const dfa = mctx->dfa; + const re_dfa_t *const dfa = mctx->dfa; reg_errcode_t err; int cache_idx_start = search_cur_bkref_entry (mctx, cur_str); struct re_backref_cache_entry *ent; @@ -3292,8 +3358,8 @@ expand_bkref_cache (mctx, cur_nodes, cur_str, subexp_num, static int build_trtable (dfa, state) - re_dfa_t *dfa; - re_dfastate_t *state; + const re_dfa_t *dfa; + re_dfastate_t *state; { reg_errcode_t err; int i, j, ch, need_word_trtable = 0; @@ -3310,12 +3376,10 @@ build_trtable (dfa, state) from `state'. `dests_node[i]' represents the nodes which i-th destination state contains, and `dests_ch[i]' represents the characters which i-th destination state accepts. */ -#ifdef _LIBC if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset)) * SBC_MAX)) dests_node = (re_node_set *) alloca ((sizeof (re_node_set) + sizeof (bitset)) * SBC_MAX); else -#endif { dests_node = (re_node_set *) malloc ((sizeof (re_node_set) + sizeof (bitset)) * SBC_MAX); @@ -3349,13 +3413,11 @@ build_trtable (dfa, state) if (BE (err != REG_NOERROR, 0)) goto out_free; -#ifdef _LIBC if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset)) * SBC_MAX + ndests * 3 * sizeof (re_dfastate_t *))) dest_states = (re_dfastate_t **) alloca (ndests * 3 * sizeof (re_dfastate_t *)); else -#endif { dest_states = (re_dfastate_t **) malloc (ndests * 3 * sizeof (re_dfastate_t *)); @@ -3518,10 +3580,10 @@ out_free: static int group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch) - re_dfa_t *dfa; - const re_dfastate_t *state; - re_node_set *dests_node; - bitset *dests_ch; + const re_dfa_t *dfa; + const re_dfastate_t *state; + re_node_set *dests_node; + bitset *dests_ch; { reg_errcode_t err; int result; @@ -3710,9 +3772,9 @@ group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch) static int check_node_accept_bytes (dfa, node_idx, input, str_idx) - re_dfa_t *dfa; - int node_idx, str_idx; - const re_string_t *input; + const re_dfa_t *dfa; + int node_idx, str_idx; + const re_string_t *input; { const re_token_t *node = dfa->nodes + node_idx; int char_len, elem_len; @@ -4244,7 +4306,7 @@ match_ctx_add_entry (mctx, node, str_idx, from, to) static int search_cur_bkref_entry (mctx, str_idx) - re_match_context_t *mctx; + const re_match_context_t *mctx; int str_idx; { int left, right, mid, last; diff --git a/stdio-common/Makefile b/stdio-common/Makefile index d860d75dee..39c7d9db52 100644 --- a/stdio-common/Makefile +++ b/stdio-common/Makefile @@ -53,7 +53,7 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \ scanf11 scanf12 tst-tmpnam tst-cookie tst-obprintf tst-sscanf \ tst-swprintf tst-fseek tst-fmemopen test-vfprintf tst-gets \ tst-perror tst-sprintf tst-rndseek tst-fdopen tst-fphex bug14 bug15 \ - tst-popen tst-unlockedio tst-fmemopen2 + tst-popen tst-unlockedio tst-fmemopen2 tst-put-error test-srcs = tst-unbputc tst-printf diff --git a/stdio-common/tst-put-error.c b/stdio-common/tst-put-error.c new file mode 100644 index 0000000000..115dbd509a --- /dev/null +++ b/stdio-common/tst-put-error.c @@ -0,0 +1,33 @@ +#include <errno.h> +#include <error.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + + +static int +do_test (void) +{ + char tmpl[] = "/tmp/tst-put-error.XXXXXX"; + int fd = mkstemp (tmpl); + if (fd == -1) + error (EXIT_FAILURE, errno, "cannot create temporary file"); + FILE *fp = fdopen (fd, "w"); + if (fp == NULL) + error (EXIT_FAILURE, errno, "fdopen"); + setlinebuf (fp); + close (fd); + unlink (tmpl); + int n = fprintf (fp, "hello world\n"); + printf ("fprintf = %d\n", n); + if (n >= 0) + error (EXIT_FAILURE, 0, "first fprintf succeeded"); + n = fprintf (fp, "hello world\n"); + printf ("fprintf = %d\n", n); + if (n >= 0) + error (EXIT_FAILURE, 0, "second fprintf succeeded"); + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/sysdeps/generic/dl-sysdep.c b/sysdeps/generic/dl-sysdep.c index 6ac0d95ea6..985e2b8f77 100644 --- a/sysdeps/generic/dl-sysdep.c +++ b/sysdeps/generic/dl-sysdep.c @@ -393,7 +393,7 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz, cnt += *p++; ++p; /* Skip mask word. */ dsocaps = (const char *) p; - dsocapslen = note->datalen - sizeof *p; + dsocapslen = note->datalen - sizeof *p * 2; break; } note = ((const void *) (note + 1) @@ -431,14 +431,23 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz, #if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO if (dsocaps != NULL) { - GLRO(dl_hwcap) |= ((uint64_t) ((const ElfW(Word) *) dsocaps)[-1] - << _DL_FIRST_EXTRA); - for (const char *p = dsocaps; - p < dsocaps + dsocapslen; - p += temp[m++].len + 1) + const ElfW(Word) mask = ((const ElfW(Word) *) dsocaps)[-1]; + GLRO(dl_hwcap) |= (uint64_t) mask << _DL_FIRST_EXTRA; + size_t len; + for (const char *p = dsocaps; p < dsocaps + dsocapslen; p += len + 1) { - temp[m].str = p; - temp[m].len = strlen (p); + uint_fast8_t bit = *p++; + len = strlen (p); + + /* Skip entries that are not enabled in the mask word. */ + if (__builtin_expect (mask & ((ElfW(Word)) 1 << bit), 1)) + { + temp[m].str = p; + temp[m].len = len; + ++m; + } + else + --cnt; } } #endif diff --git a/sysdeps/generic/glob.c b/sysdeps/generic/glob.c index c0e76b377e..2e767304a7 100644 --- a/sysdeps/generic/glob.c +++ b/sysdeps/generic/glob.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1991-2002,2003,2004,2005 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 @@ -715,7 +715,7 @@ glob (pattern, flags, errfunc, pglob) buflen = 20; name = (char *) __alloca (buflen); - success = getlogin_r (name, buflen) >= 0; + success = getlogin_r (name, buflen) == 0; # else success = (name = getlogin ()) != NULL; # endif diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index a24c2ff58e..191ae4d4fb 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -62,7 +62,7 @@ typedef struct link_map *lookup_t; # define LOOKUP_VALUE(map) map # define LOOKUP_VALUE_ADDRESS(map) ((map) ? (map)->l_addr : 0) -/* on some architectures a pointer to a function is not just a pointer +/* On some architectures a pointer to a function is not just a pointer to the actual code of the function but rather an architecture specific descriptor. */ #ifndef ELF_FUNCTION_PTR_IS_SPECIAL @@ -73,6 +73,14 @@ typedef struct link_map *lookup_t; # define DL_DT_FINI_ADDRESS(map, start) (start) #endif +/* On some architectures dladdr can't use st_size of all symbols this way. */ +#define DL_ADDR_SYM_MATCH(L, SYM, MATCHSYM, ADDR) \ + ((ADDR) >= (L)->l_addr + (SYM)->st_value \ + && (((SYM)->st_size == 0 \ + && (ADDR) == (L)->l_addr + (SYM)->st_value) \ + || (ADDR) < (L)->l_addr + (SYM)->st_value + (SYM)->st_size) \ + && ((MATCHSYM) == NULL || (MATCHSYM)->st_value < (SYM)->st_value)) + /* Unmap a loaded object, called by _dl_close (). */ #ifndef DL_UNMAP_IS_SPECIAL # define DL_UNMAP(map) \ diff --git a/sysdeps/mach/hurd/nfs/nfs.h b/sysdeps/generic/nfs/nfs.h index e83a874fe6..e83a874fe6 100644 --- a/sysdeps/mach/hurd/nfs/nfs.h +++ b/sysdeps/generic/nfs/nfs.h diff --git a/sysdeps/i386/bits/string.h b/sysdeps/i386/bits/string.h deleted file mode 100644 index d181afd48b..0000000000 --- a/sysdeps/i386/bits/string.h +++ /dev/null @@ -1,922 +0,0 @@ -/* Optimized, inlined string functions. i386 version. - Copyright (C) 1997,1998,1999,2000,2003 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _STRING_H -# error "Never use <bits/string.h> directly; include <string.h> instead." -#endif - -/* The ix86 processors can access unaligned multi-byte variables. */ -#define _STRING_ARCH_unaligned 1 - - -/* We only provide optimizations if the user selects them and if - GNU CC is used. */ -#if !defined __NO_STRING_INLINES && defined __USE_STRING_INLINES \ - && defined __GNUC__ && __GNUC__ >= 2 && !__BOUNDED_POINTERS__ - -#ifndef __STRING_INLINE -# ifdef __cplusplus -# define __STRING_INLINE inline -# else -# define __STRING_INLINE extern __inline -# endif -#endif - - -/* Copy N bytes of SRC to DEST. */ -#define _HAVE_STRING_ARCH_memcpy 1 -#define memcpy(dest, src, n) \ - (__extension__ (__builtin_constant_p (n) \ - ? __memcpy_c ((dest), (src), (n)) \ - : memcpy ((dest), (src), (n)))) -/* This looks horribly ugly, but the compiler can optimize it totally, - as the count is constant. */ -__STRING_INLINE void *__memcpy_c (void *__dest, __const void *__src, - size_t __n); - -__STRING_INLINE void * -__memcpy_c (void *__dest, __const void *__src, size_t __n) -{ - register unsigned long int __d0, __d1, __d2; - union { - unsigned int __ui; - unsigned short int __usi; - unsigned char __uc; - } *__u = __dest; - switch (__n) - { - case 0: - return __dest; - case 1: - __u->__uc = *(const unsigned char *) __src; - return __dest; - case 2: - __u->__usi = *(const unsigned short int *) __src; - return __dest; - case 3: - __u->__usi = *(const unsigned short int *) __src; - __u = (void *) __u + 2; - __u->__uc = *(2 + (const unsigned char *) __src); - return __dest; - case 4: - __u->__ui = *(const unsigned int *) __src; - return __dest; - case 6: - __u->__ui = *(const unsigned int *) __src; - __u = (void *) __u + 4; - __u->__usi = *(2 + (const unsigned short int *) __src); - return __dest; - case 8: - __u->__ui = *(const unsigned int *) __src; - __u = (void *) __u + 4; - __u->__ui = *(1 + (const unsigned int *) __src); - return __dest; - case 12: - __u->__ui = *(const unsigned int *) __src; - __u = (void *) __u + 4; - __u->__ui = *(1 + (const unsigned int *) __src); - __u = (void *) __u + 4; - __u->__ui = *(2 + (const unsigned int *) __src); - return __dest; - case 16: - __u->__ui = *(const unsigned int *) __src; - __u = (void *) __u + 4; - __u->__ui = *(1 + (const unsigned int *) __src); - __u = (void *) __u + 4; - __u->__ui = *(2 + (const unsigned int *) __src); - __u = (void *) __u + 4; - __u->__ui = *(3 + (const unsigned int *) __src); - return __dest; - case 20: - __u->__ui = *(const unsigned int *) __src; - __u = (void *) __u + 4; - __u->__ui = *(1 + (const unsigned int *) __src); - __u = (void *) __u + 4; - __u->__ui = *(2 + (const unsigned int *) __src); - __u = (void *) __u + 4; - __u->__ui = *(3 + (const unsigned int *) __src); - __u = (void *) __u + 4; - __u->__ui = *(4 + (const unsigned int *) __src); - return __dest; - } -#define __COMMON_CODE(x) \ - __asm__ __volatile__ \ - ("cld\n\t" \ - "rep; movsl" \ - x \ - : "=&c" (__d0), "=&D" (__d1), "=&S" (__d2) \ - : "0" (__n / 4), "1" (&__u->__uc), "2" (__src) \ - : "memory"); - - switch (__n % 4) - { - case 0: - __COMMON_CODE (""); - break; - case 1: - __COMMON_CODE ("\n\tmovsb"); - break; - case 2: - __COMMON_CODE ("\n\tmovsw"); - break; - case 3: - __COMMON_CODE ("\n\tmovsw\n\tmovsb"); - break; - } - return __dest; -#undef __COMMON_CODE -} - - -/* Copy N bytes of SRC to DEST, guaranteeing - correct behavior for overlapping strings. */ -#define _HAVE_STRING_ARCH_memmove 1 -#ifndef _FORCE_INLINES -__STRING_INLINE void * -memmove (void *__dest, __const void *__src, size_t __n) -{ - register unsigned long int __d0, __d1, __d2; - if (__dest < __src) - __asm__ __volatile__ - ("cld\n\t" - "rep\n\t" - "movsb" - : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) - : "0" (__n), "1" (__src), "2" (__dest) - : "memory"); - else - __asm__ __volatile__ - ("std\n\t" - "rep\n\t" - "movsb\n\t" - "cld" - : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) - : "0" (__n), "1" (__n - 1 + (const char *) __src), - "2" (__n - 1 + (char *) __dest) - : "memory"); - return __dest; -} -#endif - -/* Set N bytes of S to C. */ -#define _HAVE_STRING_ARCH_memset 1 -#define _USE_STRING_ARCH_memset 1 -#define memset(s, c, n) \ - (__extension__ (__builtin_constant_p (c) \ - ? (__builtin_constant_p (n) \ - ? __memset_cc (s, 0x01010101UL * (unsigned char) (c), n) \ - : __memset_cg (s, 0x01010101UL * (unsigned char) (c), n))\ - : __memset_gg (s, c, n))) - -__STRING_INLINE void *__memset_cc (void *__s, unsigned long int __pattern, - size_t __n); - -__STRING_INLINE void * -__memset_cc (void *__s, unsigned long int __pattern, size_t __n) -{ - register unsigned long int __d0, __d1; - union { - unsigned int __ui; - unsigned short int __usi; - unsigned char __uc; - } *__u = __s; - switch (__n) - { - case 0: - return __s; - case 1: - __u->__uc = __pattern; - return __s; - case 2: - __u->__usi = __pattern; - return __s; - case 3: - __u->__usi = __pattern; - __u = __extension__ ((void *) __u + 2); - __u->__uc = __pattern; - return __s; - case 4: - __u->__ui = __pattern; - return __s; - } -#define __COMMON_CODE(x) \ - __asm__ __volatile__ \ - ("cld\n\t" \ - "rep; stosl" \ - x \ - : "=&c" (__d0), "=&D" (__d1) \ - : "a" (__pattern), "0" (__n / 4), "1" (&__u->__uc) \ - : "memory") - - switch (__n % 4) - { - case 0: - __COMMON_CODE (""); - break; - case 1: - __COMMON_CODE ("\n\tstosb"); - break; - case 2: - __COMMON_CODE ("\n\tstosw"); - break; - case 3: - __COMMON_CODE ("\n\tstosw\n\tstosb"); - break; - } - return __s; -#undef __COMMON_CODE -} - -__STRING_INLINE void *__memset_cg (void *__s, unsigned long __c, size_t __n); - -__STRING_INLINE void * -__memset_cg (void *__s, unsigned long __c, size_t __n) -{ - register unsigned long int __d0, __d1; - __asm__ __volatile__ - ("cld\n\t" - "rep; stosl\n\t" - "testb $2,%b3\n\t" - "je 1f\n\t" - "stosw\n" - "1:\n\t" - "testb $1,%b3\n\t" - "je 2f\n\t" - "stosb\n" - "2:" - : "=&c" (__d0), "=&D" (__d1) - : "a" (__c), "q" (__n), "0" (__n / 4), "1" (__s) - : "memory"); - return __s; -} - -__STRING_INLINE void *__memset_gg (void *__s, char __c, size_t __n); - -__STRING_INLINE void * -__memset_gg (void *__s, char __c, size_t __n) -{ - register unsigned long int __d0, __d1; - __asm__ __volatile__ - ("cld\n\t" - "rep; stosb" - : "=&D" (__d0), "=&c" (__d1) - : "a" (__c), "0" (__s), "1" (__n) - : "memory"); - return __s; -} - - - - -/* Search N bytes of S for C. */ -#define _HAVE_STRING_ARCH_memchr 1 -#ifndef _FORCE_INLINES -__STRING_INLINE void * -memchr (__const void *__s, int __c, size_t __n) -{ - register unsigned long int __d0; - register void *__res; - if (__n == 0) - return NULL; - __asm__ __volatile__ - ("cld\n\t" - "repne; scasb\n\t" - "je 1f\n\t" - "movl $1,%0\n" - "1:" - : "=D" (__res), "=&c" (__d0) - : "a" (__c), "0" (__s), "1" (__n), - "m" ( *(struct { __extension__ char __x[__n]; } *)__s) - : "cc"); - return __res - 1; -} -#endif - -#define _HAVE_STRING_ARCH_memrchr 1 -#ifndef _FORCE_INLINES -__STRING_INLINE void * -__memrchr (__const void *__s, int __c, size_t __n) -{ - register unsigned long int __d0; - register void *__res; - if (__n == 0) - return NULL; - __asm__ __volatile__ - ("std\n\t" - "repne; scasb\n\t" - "je 1f\n\t" - "orl $-1,%0\n" - "1:\tcld\n\t" - "incl %0" - : "=D" (__res), "=&c" (__d0) - : "a" (__c), "0" (__s + __n - 1), "1" (__n), - "m" ( *(struct { __extension__ char __x[__n]; } *)__s) - : "cc"); - return __res; -} -# ifdef __USE_GNU -# define memrchr(s, c, n) __memrchr (s, c, n) -# endif -#endif - -/* Return the length of S. */ -#define _HAVE_STRING_ARCH_strlen 1 -#ifndef _FORCE_INLINES -__STRING_INLINE size_t -strlen (__const char *__str) -{ - register unsigned long int __d0; - register size_t __res; - __asm__ __volatile__ - ("cld\n\t" - "repne; scasb\n\t" - "notl %0" - : "=c" (__res), "=&D" (__d0) - : "1" (__str), "a" (0), "0" (0xffffffff), - "m" ( *(struct { char __x[0xfffffff]; } *)__str) - : "cc"); - return __res - 1; -} -#endif - -/* Copy SRC to DEST. */ -#define _HAVE_STRING_ARCH_strcpy 1 -#ifndef _FORCE_INLINES -__STRING_INLINE char * -strcpy (char *__dest, __const char *__src) -{ - register unsigned long int __d0, __d1; - __asm__ __volatile__ - ("cld\n" - "1:\n\t" - "lodsb\n\t" - "stosb\n\t" - "testb %%al,%%al\n\t" - "jne 1b" - : "=&S" (__d0), "=&D" (__d1) - : "0" (__src), "1" (__dest) - : "ax", "memory", "cc"); - return __dest; -} -#endif - -/* Copy no more than N characters of SRC to DEST. */ -#define _HAVE_STRING_ARCH_strncpy 1 -#ifndef _FORCE_INLINES -__STRING_INLINE char * -strncpy (char *__dest, __const char *__src, size_t __n) -{ - register unsigned long int __d0, __d1, __d2; - __asm__ __volatile__ - ("cld\n" - "1:\n\t" - "decl %2\n\t" - "js 2f\n\t" - "lodsb\n\t" - "stosb\n\t" - "testb %%al,%%al\n\t" - "jne 1b\n\t" - "rep; stosb\n" - "2:" - : "=&S" (__d0), "=&D" (__d1), "=&c" (__d2) - : "0" (__src), "1" (__dest), "2" (__n) - : "ax", "memory", "cc"); - return __dest; -} -#endif - -/* Append SRC onto DEST. */ -#define _HAVE_STRING_ARCH_strcat 1 -#ifndef _FORCE_INLINES -__STRING_INLINE char * -strcat (char *__dest, __const char *__src) -{ - register unsigned long int __d0, __d1, __d2, __d3; - __asm__ __volatile__ - ("cld\n\t" - "repne; scasb\n\t" - "decl %1\n" - "1:\n\t" - "lodsb\n\t" - "stosb\n\t" - "testb %%al,%%al\n\t" - "jne 1b" - : "=&S" (__d0), "=&D" (__d1), "=&c" (__d2), "=&a" (__d3) - : "0" (__src), "1" (__dest), "2" (0xffffffff), "3" (0) - : "memory", "cc"); - return __dest; -} -#endif - -/* Append no more than N characters from SRC onto DEST. */ -#define _HAVE_STRING_ARCH_strncat 1 -#ifndef _FORCE_INLINES -__STRING_INLINE char * -strncat (char *__dest, __const char *__src, size_t __n) -{ - register unsigned long int __d0, __d1, __d2, __d3; - __asm__ __volatile__ - ("cld\n\t" - "repne; scasb\n\t" - "decl %1\n\t" - "movl %4,%2\n" - "1:\n\t" - "decl %2\n\t" - "js 2f\n\t" - "lodsb\n\t" - "stosb\n\t" - "testb %%al,%%al\n\t" - "jne 1b\n\t" - "jmp 3f\n" - "2:\n\t" - "xorl %3,%3\n\t" - "stosb\n" - "3:" - : "=&S" (__d0), "=&D" (__d1), "=&c" (__d2), "=&a" (__d3) - : "g" (__n), "0" (__src), "1" (__dest), "2" (0xffffffff), "3" (0) - : "memory", "cc"); - return __dest; -} -#endif - -/* Compare S1 and S2. */ -#define _HAVE_STRING_ARCH_strcmp 1 -#ifndef _FORCE_INLINES -__STRING_INLINE int -strcmp (__const char *__s1, __const char *__s2) -{ - register unsigned long int __d0, __d1; - register int __res; - __asm__ __volatile__ - ("cld\n" - "1:\n\t" - "lodsb\n\t" - "scasb\n\t" - "jne 2f\n\t" - "testb %%al,%%al\n\t" - "jne 1b\n\t" - "xorl %%eax,%%eax\n\t" - "jmp 3f\n" - "2:\n\t" - "sbbl %%eax,%%eax\n\t" - "orb $1,%%al\n" - "3:" - : "=a" (__res), "=&S" (__d0), "=&D" (__d1) - : "1" (__s1), "2" (__s2), - "m" ( *(struct { char __x[0xfffffff]; } *)__s1), - "m" ( *(struct { char __x[0xfffffff]; } *)__s2) - : "cc"); - return __res; -} -#endif - -/* Compare N characters of S1 and S2. */ -#define _HAVE_STRING_ARCH_strncmp 1 -#ifndef _FORCE_INLINES -__STRING_INLINE int -strncmp (__const char *__s1, __const char *__s2, size_t __n) -{ - register unsigned long int __d0, __d1, __d2; - register int __res; - __asm__ __volatile__ - ("cld\n" - "1:\n\t" - "decl %3\n\t" - "js 2f\n\t" - "lodsb\n\t" - "scasb\n\t" - "jne 3f\n\t" - "testb %%al,%%al\n\t" - "jne 1b\n" - "2:\n\t" - "xorl %%eax,%%eax\n\t" - "jmp 4f\n" - "3:\n\t" - "sbbl %%eax,%%eax\n\t" - "orb $1,%%al\n" - "4:" - : "=a" (__res), "=&S" (__d0), "=&D" (__d1), "=&c" (__d2) - : "1" (__s1), "2" (__s2), "3" (__n), - "m" ( *(struct { __extension__ char __x[__n]; } *)__s1), - "m" ( *(struct { __extension__ char __x[__n]; } *)__s2) - : "cc"); - return __res; -} -#endif - -/* Find the first occurrence of C in S. */ -#define _HAVE_STRING_ARCH_strchr 1 -#define _USE_STRING_ARCH_strchr 1 -#define strchr(s, c) \ - (__extension__ (__builtin_constant_p (c) \ - ? __strchr_c (s, ((c) & 0xff) << 8) \ - : __strchr_g (s, c))) - -__STRING_INLINE char *__strchr_g (__const char *__s, int __c); - -__STRING_INLINE char * -__strchr_g (__const char *__s, int __c) -{ - register unsigned long int __d0; - register char *__res; - __asm__ __volatile__ - ("cld\n\t" - "movb %%al,%%ah\n" - "1:\n\t" - "lodsb\n\t" - "cmpb %%ah,%%al\n\t" - "je 2f\n\t" - "testb %%al,%%al\n\t" - "jne 1b\n\t" - "movl $1,%1\n" - "2:\n\t" - "movl %1,%0" - : "=a" (__res), "=&S" (__d0) - : "0" (__c), "1" (__s), - "m" ( *(struct { char __x[0xfffffff]; } *)__s) - : "cc"); - return __res - 1; -} - -__STRING_INLINE char *__strchr_c (__const char *__s, int __c); - -__STRING_INLINE char * -__strchr_c (__const char *__s, int __c) -{ - register unsigned long int __d0; - register char *__res; - __asm__ __volatile__ - ("cld\n\t" - "1:\n\t" - "lodsb\n\t" - "cmpb %%ah,%%al\n\t" - "je 2f\n\t" - "testb %%al,%%al\n\t" - "jne 1b\n\t" - "movl $1,%1\n" - "2:\n\t" - "movl %1,%0" - : "=a" (__res), "=&S" (__d0) - : "0" (__c), "1" (__s), - "m" ( *(struct { char __x[0xfffffff]; } *)__s) - : "cc"); - return __res - 1; -} - - -/* Find the first occurrence of C in S or the final NUL byte. */ -#define _HAVE_STRING_ARCH_strchrnul 1 -#define __strchrnul(s, c) \ - (__extension__ (__builtin_constant_p (c) \ - ? ((c) == '\0' \ - ? (char *) __rawmemchr (s, c) \ - : __strchrnul_c (s, ((c) & 0xff) << 8)) \ - : __strchrnul_g (s, c))) - -__STRING_INLINE char *__strchrnul_g (__const char *__s, int __c); - -__STRING_INLINE char * -__strchrnul_g (__const char *__s, int __c) -{ - register unsigned long int __d0; - register char *__res; - __asm__ __volatile__ - ("cld\n\t" - "movb %%al,%%ah\n" - "1:\n\t" - "lodsb\n\t" - "cmpb %%ah,%%al\n\t" - "je 2f\n\t" - "testb %%al,%%al\n\t" - "jne 1b\n\t" - "2:\n\t" - "movl %1,%0" - : "=a" (__res), "=&S" (__d0) - : "0" (__c), "1" (__s), - "m" ( *(struct { char __x[0xfffffff]; } *)__s) - : "cc"); - return __res - 1; -} - -__STRING_INLINE char *__strchrnul_c (__const char *__s, int __c); - -__STRING_INLINE char * -__strchrnul_c (__const char *__s, int __c) -{ - register unsigned long int __d0; - register char *__res; - __asm__ __volatile__ - ("cld\n\t" - "1:\n\t" - "lodsb\n\t" - "cmpb %%ah,%%al\n\t" - "je 2f\n\t" - "testb %%al,%%al\n\t" - "jne 1b\n\t" - "2:\n\t" - "movl %1,%0" - : "=a" (__res), "=&S" (__d0) - : "0" (__c), "1" (__s), - "m" ( *(struct { char __x[0xfffffff]; } *)__s) - : "cc"); - return __res - 1; -} -#ifdef __USE_GNU -# define strchrnul(s, c) __strchrnul (s, c) -#endif - - -/* Return the length of the initial segment of S which - consists entirely of characters not in REJECT. */ -#define _HAVE_STRING_ARCH_strcspn 1 -#ifndef _FORCE_INLINES -# ifdef __PIC__ -__STRING_INLINE size_t -strcspn (__const char *__s, __const char *__reject) -{ - register unsigned long int __d0, __d1, __d2; - register char *__res; - __asm__ __volatile__ - ("pushl %%ebx\n\t" - "cld\n\t" - "movl %4,%%edi\n\t" - "repne; scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%ebx\n" - "1:\n\t" - "lodsb\n\t" - "testb %%al,%%al\n\t" - "je 2f\n\t" - "movl %4,%%edi\n\t" - "movl %%ebx,%%ecx\n\t" - "repne; scasb\n\t" - "jne 1b\n" - "2:\n\t" - "popl %%ebx" - : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) - : "d" (__reject), "0" (__s), "1" (0), "2" (0xffffffff), - "m" ( *(struct { char __x[0xfffffff]; } *)__s) - : "cc"); - return (__res - 1) - __s; -} -# else -__STRING_INLINE size_t -strcspn (__const char *__s, __const char *__reject) -{ - register unsigned long int __d0, __d1, __d2, __d3; - register char *__res; - __asm__ __volatile__ - ("cld\n\t" - "movl %5,%%edi\n\t" - "repne; scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%edx\n" - "1:\n\t" - "lodsb\n\t" - "testb %%al,%%al\n\t" - "je 2f\n\t" - "movl %5,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne; scasb\n\t" - "jne 1b\n" - "2:" - : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3) - : "g" (__reject), "0" (__s), "1" (0), "2" (0xffffffff), - "m" ( *(struct { char __x[0xfffffff]; } *)__s) - : "cc"); - return (__res - 1) - __s; -} -# endif -#endif - - -/* Return the length of the initial segment of S which - consists entirely of characters in ACCEPT. */ -#define _HAVE_STRING_ARCH_strspn 1 -#ifndef _FORCE_INLINES -# ifdef __PIC__ -__STRING_INLINE size_t -strspn (__const char *__s, __const char *__accept) -{ - register unsigned long int __d0, __d1, __d2; - register char *__res; - __asm__ __volatile__ - ("pushl %%ebx\n\t" - "cld\n\t" - "movl %4,%%edi\n\t" - "repne; scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%ebx\n" - "1:\n\t" - "lodsb\n\t" - "testb %%al,%%al\n\t" - "je 2f\n\t" - "movl %4,%%edi\n\t" - "movl %%ebx,%%ecx\n\t" - "repne; scasb\n\t" - "je 1b\n" - "2:\n\t" - "popl %%ebx" - : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) - : "r" (__accept), "0" (__s), "1" (0), "2" (0xffffffff), - "m" ( *(struct { char __x[0xfffffff]; } *)__s) - : "cc"); - return (__res - 1) - __s; -} -# else -__STRING_INLINE size_t -strspn (__const char *__s, __const char *__accept) -{ - register unsigned long int __d0, __d1, __d2, __d3; - register char *__res; - __asm__ __volatile__ - ("cld\n\t" - "movl %5,%%edi\n\t" - "repne; scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%edx\n" - "1:\n\t" - "lodsb\n\t" - "testb %%al,%%al\n\t" - "je 2f\n\t" - "movl %5,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne; scasb\n\t" - "je 1b\n" - "2:" - : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3) - : "g" (__accept), "0" (__s), "1" (0), "2" (0xffffffff), - "m" ( *(struct { char __x[0xfffffff]; } *)__s) - : "cc"); - return (__res - 1) - __s; -} -# endif -#endif - - -/* Find the first occurrence in S of any character in ACCEPT. */ -#define _HAVE_STRING_ARCH_strpbrk 1 -#ifndef _FORCE_INLINES -# ifdef __PIC__ -__STRING_INLINE char * -strpbrk (__const char *__s, __const char *__accept) -{ - unsigned long int __d0, __d1, __d2; - register char *__res; - __asm__ __volatile__ - ("pushl %%ebx\n\t" - "cld\n\t" - "movl %4,%%edi\n\t" - "repne; scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%ebx\n" - "1:\n\t" - "lodsb\n\t" - "testb %%al,%%al\n\t" - "je 2f\n\t" - "movl %4,%%edi\n\t" - "movl %%ebx,%%ecx\n\t" - "repne; scasb\n\t" - "jne 1b\n\t" - "decl %0\n\t" - "jmp 3f\n" - "2:\n\t" - "xorl %0,%0\n" - "3:\n\t" - "popl %%ebx" - : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) - : "r" (__accept), "0" (__s), "1" (0), "2" (0xffffffff), - "m" ( *(struct { char __x[0xfffffff]; } *)__s) - : "cc"); - return __res; -} -# else -__STRING_INLINE char * -strpbrk (__const char *__s, __const char *__accept) -{ - register unsigned long int __d0, __d1, __d2, __d3; - register char *__res; - __asm__ __volatile__ - ("cld\n\t" - "movl %5,%%edi\n\t" - "repne; scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" - "movl %%ecx,%%edx\n" - "1:\n\t" - "lodsb\n\t" - "testb %%al,%%al\n\t" - "je 2f\n\t" - "movl %5,%%edi\n\t" - "movl %%edx,%%ecx\n\t" - "repne; scasb\n\t" - "jne 1b\n\t" - "decl %0\n\t" - "jmp 3f\n" - "2:\n\t" - "xorl %0,%0\n" - "3:" - : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3) - : "g" (__accept), "0" (__s), "1" (0), "2" (0xffffffff), - "m" ( *(struct { char __x[0xfffffff]; } *)__s) - : "cc"); - return __res; -} -# endif -#endif - - -/* Find the first occurrence of NEEDLE in HAYSTACK. */ -#define _HAVE_STRING_ARCH_strstr 1 -#ifndef _FORCE_INLINES -# ifdef __PIC__ -__STRING_INLINE char * -strstr (__const char *__haystack, __const char *__needle) -{ - register unsigned long int __d0, __d1, __d2; - register char *__res; - __asm__ __volatile__ - ("pushl %%ebx\n\t" - "cld\n\t" \ - "movl %4,%%edi\n\t" - "repne; scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */ - "movl %%ecx,%%ebx\n" - "1:\n\t" - "movl %4,%%edi\n\t" - "movl %%esi,%%eax\n\t" - "movl %%ebx,%%ecx\n\t" - "repe; cmpsb\n\t" - "je 2f\n\t" /* also works for empty string, see above */ - "xchgl %%eax,%%esi\n\t" - "incl %%esi\n\t" - "cmpb $0,-1(%%eax)\n\t" - "jne 1b\n\t" - "xorl %%eax,%%eax\n\t" - "2:\n\t" - "popl %%ebx" - : "=&a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) - : "r" (__needle), "0" (0), "1" (0xffffffff), "2" (__haystack) - : "memory", "cc"); - return __res; -} -# else -__STRING_INLINE char * -strstr (__const char *__haystack, __const char *__needle) -{ - register unsigned long int __d0, __d1, __d2, __d3; - register char *__res; - __asm__ __volatile__ - ("cld\n\t" \ - "movl %5,%%edi\n\t" - "repne; scasb\n\t" - "notl %%ecx\n\t" - "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */ - "movl %%ecx,%%edx\n" - "1:\n\t" - "movl %5,%%edi\n\t" - "movl %%esi,%%eax\n\t" - "movl %%edx,%%ecx\n\t" - "repe; cmpsb\n\t" - "je 2f\n\t" /* also works for empty string, see above */ - "xchgl %%eax,%%esi\n\t" - "incl %%esi\n\t" - "cmpb $0,-1(%%eax)\n\t" - "jne 1b\n\t" - "xorl %%eax,%%eax\n\t" - "2:" - : "=&a" (__res), "=&c" (__d0), "=&S" (__d1), "=&d" (__d2), "=&D" (__d3) - : "g" (__needle), "0" (0), "1" (0xffffffff), "2" (__haystack) - : "memory", "cc"); - return __res; -} -# endif -#endif - -#ifndef _FORCE_INLINES -# undef __STRING_INLINE -#endif - -#endif /* use string inlines && GNU CC */ diff --git a/sysdeps/ieee754/flt-32/e_hypotf.c b/sysdeps/ieee754/flt-32/e_hypotf.c index d6b1520cb8..a8e1a52d2b 100644 --- a/sysdeps/ieee754/flt-32/e_hypotf.c +++ b/sysdeps/ieee754/flt-32/e_hypotf.c @@ -23,7 +23,7 @@ static char rcsid[] = "$NetBSD: e_hypotf.c,v 1.5 1995/05/12 04:57:30 jtc Exp $"; #ifdef __STDC__ float __ieee754_hypotf(float x, float y) #else - float __ieee754_hypot(x,y) + float __ieee754_hypotf(x,y) float x, y; #endif { @@ -47,20 +47,20 @@ static char rcsid[] = "$NetBSD: e_hypotf.c,v 1.5 1995/05/12 04:57:30 jtc Exp $"; return w; } /* scale a and b by 2**-60 */ - ha -= 0x5d800000; hb -= 0x5d800000; k += 60; + ha -= 0x1e000000; hb -= 0x1e000000; k += 60; SET_FLOAT_WORD(a,ha); SET_FLOAT_WORD(b,hb); } if(hb < 0x26800000) { /* b < 2**-50 */ if(hb <= 0x007fffff) { /* subnormal b or 0 */ if(hb==0) return a; - SET_FLOAT_WORD(t1,0x3f000000); /* t1=2^126 */ + SET_FLOAT_WORD(t1,0x7e800000); /* t1=2^126 */ b *= t1; a *= t1; k -= 126; } else { /* scale a and b by 2^60 */ - ha += 0x5d800000; /* a *= 2^60 */ - hb += 0x5d800000; /* b *= 2^60 */ + ha += 0x1e000000; /* a *= 2^60 */ + hb += 0x1e000000; /* b *= 2^60 */ k -= 60; SET_FLOAT_WORD(a,ha); SET_FLOAT_WORD(b,hb); diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/ldsodefs.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/ldsodefs.h new file mode 100644 index 0000000000..1ead3dd63d --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/ldsodefs.h @@ -0,0 +1,77 @@ +/* Run-time dynamic linker data structures for loaded ELF shared objects. + Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _LDSODEFS_H + +/* Get the real definitions. */ +#include_next <ldsodefs.h> + +/* Now define our stuff. */ + +static __always_inline bool +_dl_ppc64_is_opd_sym (const struct link_map *l, const ElfW(Sym) *sym) +{ + return (ELFW(ST_TYPE) (sym->st_info) == STT_FUNC + && l->l_addr + sym->st_value >= (ElfW(Addr)) l->l_ld + && l->l_addr + sym->st_value < l->l_map_end + && sym->st_size != 0); +} + +static __always_inline bool +_dl_ppc64_addr_sym_match (const struct link_map *l, const ElfW(Sym) *sym, + const ElfW(Sym) *matchsym, ElfW(Addr) addr) +{ + ElfW(Addr) value = l->l_addr + sym->st_value; + if (_dl_ppc64_is_opd_sym (l, sym)) + { + if (addr < value || addr >= value + 24) + { + value = *(ElfW(Addr) *) value; + if (addr < value || addr >= value + sym->st_size) + return false; + } + } + else if (sym->st_size == 0) + { + if (addr != value) + return false; + } + else if (addr < value || addr >= value + sym->st_size) + return false; + + if (matchsym == NULL) + return true; + + ElfW(Addr) matchvalue = l->l_addr + matchsym->st_value; + if (_dl_ppc64_is_opd_sym (l, matchsym) + && (addr < matchvalue || addr > matchvalue + 24)) + matchvalue = *(ElfW(Addr) *) matchvalue; + + return matchvalue < value; +} + +/* If this is a function symbol defined past the end of our dynamic + section, then it must be a function descriptor. Allow these symbols + to match their associated function code range as well as the + descriptor addresses. */ +#undef DL_ADDR_SYM_MATCH +#define DL_ADDR_SYM_MATCH(L, SYM, MATCHSYM, ADDR) \ + _dl_ppc64_addr_sym_match (L, SYM, MATCHSYM, ADDR) + +#endif /* ldsodefs.h */ diff --git a/time/mktime.c b/time/mktime.c index 258eec637b..5a326d1e79 100644 --- a/time/mktime.c +++ b/time/mktime.c @@ -62,13 +62,38 @@ ? (a) >> (b) \ : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) -/* The extra casts work around common compiler bugs. */ +/* The extra casts in the following macros work around compiler bugs, + e.g., in Cray C 5.0.3.0. */ + +/* True if the arithmetic type T is an integer type. bool counts as + an integer. */ +#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) + +/* True if negative values of the signed integer type T use two's + complement, ones' complement, or signed magnitude representation, + respectively. Much GNU code assumes two's complement, but some + people like to be portable to all possible C hosts. */ +#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1) +#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0) +#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1) + +/* True if the arithmetic type T is signed. */ #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) -/* The outer cast is needed to work around a bug in Cray C 5.0.3.0. - It is necessary at least when t == time_t. */ -#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \ - ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0)) -#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t))) + +/* The maximum and minimum values for the integer type T. These + macros have undefined behavior if T is signed and has padding bits. + If this is a problem for you, please let us know how to fix it for + your host. */ +#define TYPE_MINIMUM(t) \ + ((t) (! TYPE_SIGNED (t) \ + ? (t) 0 \ + : TYPE_SIGNED_MAGNITUDE (t) \ + ? ~ (t) 0 \ + : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))) +#define TYPE_MAXIMUM(t) \ + ((t) (! TYPE_SIGNED (t) \ + ? (t) -1 \ + : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) #ifndef TIME_T_MIN # define TIME_T_MIN TYPE_MINIMUM (time_t) @@ -81,8 +106,8 @@ /* Verify a requirement at compile-time (unlike assert, which is runtime). */ #define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; } -verify (time_t_is_integer, (time_t) 0.5 == 0); -verify (twos_complement_arithmetic, -1 == ~1 + 1); +verify (time_t_is_integer, TYPE_IS_INTEGER (time_t)); +verify (twos_complement_arithmetic, TYPE_TWOS_COMPLEMENT (int)); /* The code also assumes that signed integer overflow silently wraps around, but this assumption can't be stated without causing a diagnostic on some hosts. */ @@ -204,14 +229,12 @@ static struct tm * ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), time_t *t, struct tm *tp) { - struct tm *r; + struct tm *r = convert (t, tp); - if (! (r = (*convert) (t, tp)) && *t) + if (!r && *t) { time_t bad = *t; time_t ok = 0; - /* Initialize to make the compiler happy. */ - struct tm tm = { 0, }; /* BAD is a known unconvertible time_t, and OK is a known good one. Use binary search to narrow the range between BAD and OK until @@ -221,11 +244,9 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), time_t mid = *t = (bad < 0 ? bad + ((ok - bad) >> 1) : ok + ((bad - ok) >> 1)); - if ((r = (*convert) (t, tp))) - { - tm = *r; - ok = mid; - } + r = convert (t, tp); + if (r) + ok = mid; else bad = mid; } @@ -235,8 +256,7 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), /* The last conversion attempt failed; revert to the most recent successful attempt. */ *t = ok; - *tp = tm; - r = tp; + r = convert (t, tp); } } @@ -465,7 +485,7 @@ __mktime_internal (struct tm *tp, t2 = t1 + sec_adjustment; if (((t1 < t) != (sec_requested < 0)) | ((t2 < t1) != (sec_adjustment < 0)) - | ! (*convert) (&t2, &tm)) + | ! convert (&t2, &tm)) return -1; t = t2; } diff --git a/timezone/africa b/timezone/africa index 7d75ae3a05..87ae9e36e5 100644 --- a/timezone/africa +++ b/timezone/africa @@ -1,4 +1,4 @@ -# @(#)africa 7.38 +# @(#)africa 7.39 # This data is by no means authoritative; if you think you know better, # go ahead and edit the file (and please send any changes to @@ -348,9 +348,6 @@ Zone Africa/Bamako -0:32:00 - LMT 1912 0:00 - GMT 1934 Feb 26 -1:00 - WAT 1960 Jun 20 0:00 - GMT -# no longer different from Bamako, but too famous to omit -Zone Africa/Timbuktu -0:12:04 - LMT 1912 - 0:00 - GMT # Mauritania # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -557,6 +554,23 @@ Zone Africa/Lome 0:04:52 - LMT 1893 0:00 - GMT # Tunisia + +# From Gwillim Law (2005-04-30): +# +# My correspondent, Risto Nykanen, has alerted me to another adoption of DST, +# this time in Tunisia. According to Yahoo France News +# <http://fr.news.yahoo.com/050426/5/4dumk.html>, in a story attributed to AP +# and dated 2005-04-26, "Tunisia has decided to advance its official time by +# one hour, starting on Sunday, May 1. Henceforth, Tunisian time will be +# UTC+2 instead of UTC+1. The change will take place at 23:00 UTC next +# Saturday." (My translation) +# +# From Oscar van Vlijmen (2005-05-02): +# LaPresse, the first national daily newspaper ... +# <http://www.lapresse.tn/archives/archives280405/actualites/lheure.html> +# ... DST for 2005: on: Sun May 1 0h standard time, off: Fri Sept. 30, +# 1h standard time. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Tunisia 1939 only - Apr 15 23:00s 1:00 S Rule Tunisia 1939 only - Nov 18 23:00s 0 - @@ -579,6 +593,8 @@ Rule Tunisia 1988 only - Jun 1 0:00s 1:00 S Rule Tunisia 1988 1990 - Sep lastSun 0:00s 0 - Rule Tunisia 1989 only - Mar 26 0:00s 1:00 S Rule Tunisia 1990 only - May 1 0:00s 1:00 S +Rule Tunisia 2005 only - May 1 0:00s 1:00 S +Rule Tunisia 2005 only - Sep 30 1:00s 0 - # Shanks gives 0:09 for Paris Mean Time; go with Howse's more precise 0:09:21. # Shanks says the 1911 switch occurred on Mar 9; go with Howse's Mar 11. # Zone NAME GMTOFF RULES FORMAT [UNTIL] diff --git a/timezone/asia b/timezone/asia index 1a40fb4c5f..52ba32338e 100644 --- a/timezone/asia +++ b/timezone/asia @@ -1,4 +1,4 @@ -# @(#)asia 7.83 +# @(#)asia 7.85 # This data is by no means authoritative; if you think you know better, # go ahead and edit the file (and please send any changes to @@ -43,8 +43,8 @@ # 8:00 CST China # 9:00 CJT Central Japanese Time (1896/1937)* # 9:00 EIT east Indonesia -# 9:00 JST Japan -# 9:00 KST Korea +# 9:00 JST JDT Japan +# 9:00 KST KDT Korea # 9:30 CST (Australian) Central Standard Time # # See the `europe' file for Russia and Turkey in Asia. @@ -201,7 +201,6 @@ Zone Asia/Phnom_Penh 6:59:40 - LMT 1906 Jun 9 Rule Shang 1940 only - Jun 3 0:00 1:00 D Rule Shang 1940 1941 - Oct 1 0:00 0 S Rule Shang 1941 only - Mar 16 0:00 1:00 D -Rule PRC 1949 only - Jan 1 0:00 0 S Rule PRC 1986 only - May 4 0:00 1:00 D Rule PRC 1986 1991 - Sep Sun>=11 0:00 0 S Rule PRC 1987 1991 - Apr Sun>=10 0:00 1:00 D @@ -387,11 +386,11 @@ Zone Asia/Tbilisi 2:59:16 - LMT 1880 # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Dili 8:22:20 - LMT 1912 - 8:00 - TPT 1942 Feb 21 23:00 # E Timor Time + 8:00 - TLT 1942 Feb 21 23:00 # E Timor Time 9:00 - JST 1945 Aug - 9:00 - TPT 1976 May 3 + 9:00 - TLT 1976 May 3 8:00 - CIT 2000 Sep 17 00:00 - 9:00 - TPT + 9:00 - TLT # India # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -847,14 +846,28 @@ Zone Asia/Jerusalem 2:20:56 - LMT 1880 # Today's _Asahi Evening News_ (page 4) reports that Japan had # daylight saving between 1948 and 1951, but ``the system was discontinued # because the public believed it would lead to longer working hours.'' + +# From Mayumi Negishi in the 2005-08-10 Japan Times +# <http://www.japantimes.co.jp/cgi-bin/getarticle.pl5?nn20050810f2.htm>: +# Occupation authorities imposed daylight-saving time on Japan on +# [1948-05-01].... But lack of prior debate and the execution of +# daylight-saving time just three days after the bill was passed generated +# deep hatred of the concept.... The Diet unceremoniously passed a bill to +# dump the unpopular system in October 1951, less than a month after the San +# Francisco Peace Treaty was signed. (A government poll in 1951 showed 53% +# of the Japanese wanted to scrap daylight-saving time, as opposed to 30% who +# wanted to keep it.) + # Shanks writes that daylight saving in Japan during those years was as follows: # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -#Rule Japan 1948 only - May Sun>=1 2:00 1:00 D -#Rule Japan 1948 1951 - Sep Sat>=8 2:00 0 S -#Rule Japan 1949 only - Apr Sun>=1 2:00 1:00 D -#Rule Japan 1950 1951 - May Sun>=1 2:00 1:00 D -# but the only locations using it were US military bases. -# We go with Shanks and omit daylight saving in those years for Asia/Tokyo. +Rule Japan 1948 only - May Sun>=1 2:00 1:00 D +Rule Japan 1948 1951 - Sep Sat>=8 2:00 0 S +Rule Japan 1949 only - Apr Sun>=1 2:00 1:00 D +Rule Japan 1950 1951 - May Sun>=1 2:00 1:00 D +# but the only locations using it (for birth certificates, presumably, since +# Shanks's audience is astrologers) were US military bases. For now, assume +# that for most purposes daylight-saving time was observed; otherwise, what +# would have been the point of the 1951 poll? # From Hideyuki Suzuki (1998-11-09): # 'Tokyo' usually stands for the former location of Tokyo Astronomical @@ -884,7 +897,7 @@ Zone Asia/Jerusalem 2:20:56 - LMT 1880 Zone Asia/Tokyo 9:18:59 - LMT 1887 Dec 31 15:00u 9:00 - JST 1896 9:00 - CJT 1938 - 9:00 - JST + 9:00 Japan J%sT # Since 1938, all Japanese possessions have been like Asia/Tokyo. # Jordan @@ -930,14 +943,16 @@ Rule Jordan 2000 max - Mar lastThu 0:00s 1:00 S Zone Asia/Amman 2:23:44 - LMT 1931 2:00 Jordan EE%sT + # Kazakhstan + # From Paul Eggert (1996-11-22): # Andrew Evtichov (1996-04-13) writes that Kazakhstan # stayed in sync with Moscow after 1990, and that Aqtobe (formerly Aktyubinsk) # and Aqtau (formerly Shevchenko) are the largest cities in their zones. # Guess that Aqtau and Aqtobe diverged in 1995, since that's the first time # IATA SSIM mentions a third time zone in Kazakhstan. -# + # From Paul Eggert (2001-10-18): # German Iofis, ELSI, Almaty (2001-10-09) reports that Kazakhstan uses # RussiaAsia rules, instead of switching at 00:00 as the IATA has it. @@ -947,7 +962,7 @@ Zone Asia/Amman 2:23:44 - LMT 1931 # - Kazakhstan did not observe DST in 1991. # - Qyzylorda switched from +5:00 to +6:00 on 1992-01-19 02:00. # - Oral switched from +5:00 to +4:00 in spring 1989. -# + # <a href="http://www.kazsociety.org.uk/news/2005/03/30.htm"> # From Kazakhstan Embassy's News Bulletin #11 (2005-03-21): # </a> @@ -955,6 +970,16 @@ Zone Asia/Amman 2:23:44 - LMT 1931 # daylight saving time citing lack of economic benefits and health # complications coupled with a decrease in productivity. # +# From Branislav Kojic (in Astana) via Gwillim Law (2005-06-28): +# ... what happened was that the former Kazakhstan Eastern time zone +# was "blended" with the Central zone. Therefore, Kazakhstan now has +# two time zones, and difference between them is one hour. The zone +# closer to UTC is the former Western zone (probably still called the +# same), encompassing four provinces in the west: Aqtobe, Atyrau, +# Mangghystau, and West Kazakhstan. The other zone encompasses +# everything else.... I guess that would make Kazakhstan time zones +# de jure UTC+5 and UTC+6 respectively. + # # Zone NAME GMTOFF RULES FORMAT [UNTIL] # @@ -998,7 +1023,7 @@ Zone Asia/Aqtau 3:21:04 - LMT 1924 May 2 5:00 - SHET 1991 Dec 16 # independence 5:00 RussiaAsia AQT%sT 1995 Mar lastSun 2:00 # Aqtau Time 4:00 RussiaAsia AQT%sT 2005 Mar 15 - 4:00 - AQTT + 5:00 - AQTT # West Kazakhstan Zone Asia/Oral 3:25:24 - LMT 1924 May 2 # or Ural'sk 4:00 - URAT 1930 Jun 21 # Ural'sk time @@ -1009,10 +1034,17 @@ Zone Asia/Oral 3:25:24 - LMT 1924 May 2 # or Ural'sk 4:00 RussiaAsia URA%sT 1991 4:00 - URAT 1991 Dec 16 # independence 4:00 RussiaAsia ORA%sT 2005 Mar 15 # Oral Time - 4:00 - ORAT + 5:00 - ORAT # Kyrgyzstan (Kirgizstan) # Transitions through 1991 are from Shanks. + +# From Paul Eggert (2005-08-15): +# According to an article dated today in the Kyrgyzstan Development Gateway +# <http://eng.gateway.kg/cgi-bin/page.pl?id=1&story_name=doc9979.shtml> +# Kyrgyzstan is canceling the daylight saving time system. I take the article +# to mean that they will leave their clocks at 6 hours ahead of UTC. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Kirgiz 1992 1996 - Apr Sun>=7 0:00s 1:00 S Rule Kirgiz 1992 1996 - Sep lastSun 0:00 0 - @@ -1191,6 +1223,24 @@ Zone Indian/Maldives 4:54:00 - LMT 1880 # Male # For now, assume Rives McDow's informant got confused about Friday vs # Saturday, and that his 2001 dates should have 1 added to them. +# From Paul Eggert (2005-07-26): +# We have wildly conflicting information about Mongolia's time zones. +# Bill Bonnet (2005-05-19) reports that the US Embassy in Ulaanbaatar says +# there is only one time zone and that DST is observed, citing Microsoft +# Windows XP as the source. Risto Nykanen (2005-05-16) reports that +# travelmongolia.org says there are two time zones (UTC+7, UTC+8) with no DST. +# Oscar van Vlijmen (2005-05-20) reports that the Mongolian Embassy in +# Washington, DC says there are two time zones, with DST observed. +# He also found +# <http://ubpost.mongolnews.mn/index.php?subaction=showcomments&id=1111634894&archive=&start_from=&ucat=1&> +# which also says that there is DST, and which has a comment by "Toddius" +# (2005-03-31 06:05 +0700) saying "Mongolia actually has 3.5 time zones. +# The West (OLGII) is +7 GMT, most of the country is ULAT is +8 GMT +# and some Eastern provinces are +9 GMT but Sukhbaatar Aimag is SUHK +8.5 GMT. +# The SUKH timezone is new this year, it is one of the few things the +# parliament passed during the tumultuous winter session." +# For now, let's ignore this information, until we have more confirmation. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Mongol 1983 1984 - Apr 1 0:00 1:00 S Rule Mongol 1983 only - Oct 1 0:00 0 - diff --git a/timezone/australasia b/timezone/australasia index b39ada2cd4..57bd60adb4 100644 --- a/timezone/australasia +++ b/timezone/australasia @@ -1,4 +1,4 @@ -# @(#)australasia 7.72 +# @(#)australasia 7.73 # This file also includes Pacific islands. # Notes are at the end of this file @@ -77,7 +77,9 @@ Rule AS 1991 only - Mar Sun>=1 2:00s 0 - Rule AS 1992 only - Mar Sun>=18 2:00s 0 - Rule AS 1993 only - Mar Sun>=1 2:00s 0 - Rule AS 1994 only - Mar Sun>=18 2:00s 0 - -Rule AS 1995 max - Mar lastSun 2:00s 0 - +Rule AS 1995 2005 - Mar lastSun 2:00s 0 - +Rule AS 2006 only - Apr Sun>=1 2:00s 0 - +Rule AS 2007 max - Mar lastSun 2:00s 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Australia/Adelaide 9:14:20 - LMT 1895 Feb 9:00 - CST 1899 May @@ -85,6 +87,11 @@ Zone Australia/Adelaide 9:14:20 - LMT 1895 Feb 9:30 AS CST # Tasmania +# +# From Paul Eggert (2005-08-16): +# <http://www.bom.gov.au/climate/averages/tables/dst_times.shtml> +# says King Island didn't observe DST from WWII until late 1971. +# # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule AT 1967 only - Oct Sun>=1 2:00s 1:00 - Rule AT 1968 only - Mar lastSun 2:00s 0 - @@ -99,15 +106,22 @@ Rule AT 1987 1990 - Mar Sun>=15 2:00s 0 - Rule AT 1987 only - Oct Sun>=22 2:00s 1:00 - Rule AT 1988 1990 - Oct lastSun 2:00s 1:00 - Rule AT 1991 1999 - Oct Sun>=1 2:00s 1:00 - -Rule AT 1991 max - Mar lastSun 2:00s 0 - +Rule AT 1991 2005 - Mar lastSun 2:00s 0 - Rule AT 2000 only - Aug lastSun 2:00s 1:00 - Rule AT 2001 max - Oct Sun>=1 2:00s 1:00 - +Rule AT 2006 only - Apr Sun>=1 2:00s 0 - +Rule AT 2007 max - Mar lastSun 2:00s 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Australia/Hobart 9:49:16 - LMT 1895 Sep 10:00 - EST 1916 Oct 1 2:00 10:00 1:00 EST 1917 Feb 10:00 Aus EST 1967 10:00 AT EST +Zone Australia/Currie 9:35:28 - LMT 1895 Sep + 10:00 - EST 1916 Oct 1 2:00 + 10:00 1:00 EST 1917 Feb + 10:00 Aus EST 1971 Jul + 10:00 AT EST # Victoria # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -118,9 +132,11 @@ Rule AV 1986 1990 - Mar Sun>=15 2:00s 0 - Rule AV 1986 1987 - Oct Sun>=15 2:00s 1:00 - Rule AV 1988 1999 - Oct lastSun 2:00s 1:00 - Rule AV 1991 1994 - Mar Sun>=1 2:00s 0 - -Rule AV 1995 max - Mar lastSun 2:00s 0 - +Rule AV 1995 2005 - Mar lastSun 2:00s 0 - Rule AV 2000 only - Aug lastSun 2:00s 1:00 - Rule AV 2001 max - Oct lastSun 2:00s 1:00 - +Rule AV 2006 only - Apr Sun>=1 2:00s 0 - +Rule AV 2007 max - Mar lastSun 2:00s 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Australia/Melbourne 9:39:52 - LMT 1895 Feb 10:00 Aus EST 1971 @@ -137,9 +153,11 @@ Rule AN 1986 1989 - Mar Sun>=15 2:00s 0 - Rule AN 1986 only - Oct 19 2:00s 1:00 - Rule AN 1987 1999 - Oct lastSun 2:00s 1:00 - Rule AN 1990 1995 - Mar Sun>=1 2:00s 0 - -Rule AN 1996 max - Mar lastSun 2:00s 0 - +Rule AN 1996 2005 - Mar lastSun 2:00s 0 - Rule AN 2000 only - Aug lastSun 2:00s 1:00 - Rule AN 2001 max - Oct lastSun 2:00s 1:00 - +Rule AN 2006 only - Apr Sun>=1 2:00s 0 - +Rule AN 2007 max - Mar lastSun 2:00s 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Australia/Sydney 10:04:52 - LMT 1895 Feb 10:00 Aus EST 1971 @@ -160,9 +178,11 @@ Rule LH 1986 1989 - Mar Sun>=15 2:00 0 - Rule LH 1986 only - Oct 19 2:00 0:30 - Rule LH 1987 1999 - Oct lastSun 2:00 0:30 - Rule LH 1990 1995 - Mar Sun>=1 2:00 0 - -Rule LH 1996 max - Mar lastSun 2:00 0 - +Rule LH 1996 2005 - Mar lastSun 2:00 0 - Rule LH 2000 only - Aug lastSun 2:00 0:30 - Rule LH 2001 max - Oct lastSun 2:00 0:30 - +Rule LH 2006 only - Apr Sun>=1 2:00 0 - +Rule LH 2007 max - Mar lastSun 2:00 0 - Zone Australia/Lord_Howe 10:36:20 - LMT 1895 Feb 10:00 - EST 1981 Mar 10:30 LH LHST @@ -264,9 +284,6 @@ Zone Pacific/Kwajalein 11:09:20 - LMT 1901 # Micronesia # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Yap 9:12:32 - LMT 1901 # Colonia - 9:00 - YAPT 1969 Oct # Yap Time - 10:00 - YAPT Zone Pacific/Truk 10:07:08 - LMT 1901 10:00 - TRUT # Truk Time Zone Pacific/Ponape 10:32:52 - LMT 1901 # Kolonia @@ -670,6 +687,24 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # Standard Time Act, 1898 # </a> +# From David Grosz (2005-06-13): +# It was announced last week that Daylight Saving would be extended by +# one week next year to allow for the 2006 Commonwealth Games. +# Daylight Saving is now to end for next year only on the first Sunday +# in April instead of the last Sunday in March. +# +# From Gwillim Law (2005-06-14): +# I did some Googling and found that all of those states (and territory) plan +# to extend DST together in 2006. +# ACT: http://www.cmd.act.gov.au/mediareleases/fileread.cfm?file=86.txt +# New South Wales: http://www.thecouriermail.news.com.au/common/story_page/0,5936,15538869%255E1702,00.html +# South Australia: http://www.news.com.au/story/0,10117,15555031-1246,00.html +# Tasmania: http://www.media.tas.gov.au/release.php?id=14772 +# Victoria: I wasn't able to find anything separate, but the other articles +# allude to it. +# But not Queensland +# http://www.news.com.au/story/0,10117,15564030-1248,00.html. + # Northern Territory # From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06): @@ -856,7 +891,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # 1994 was at +0930 as John Connolly's customer seems to assert, then I can # only conclude that the actual rule is more complicated.... -# From John Warburton <jwarb@SACBH.com.au> (1994-10-07): +# From John Warburton (1994-10-07): # The new Daylight Savings dates for South Australia ... # was gazetted in the Government Hansard on Sep 26 1994.... # start on last Sunday in October and end in last sunday in March. diff --git a/timezone/backward b/timezone/backward index 9fbab94d79..ca22dfeaee 100644 --- a/timezone/backward +++ b/timezone/backward @@ -1,16 +1,20 @@ -# @(#)backward 7.27 +# @(#)backward 7.29 # This file provides links between current names for time zones # and their old names. Many names changed in late 1993. +Link Africa/Bamako Africa/Timbuktu +Link America/Argentina/Catamarca America/Argentina/ComodRivadavia Link America/Adak America/Atka Link America/Argentina/Buenos_Aires America/Buenos_Aires Link America/Argentina/Catamarca America/Catamarca Link America/Argentina/Cordoba America/Cordoba Link America/Tijuana America/Ensenada -Link America/Indianapolis America/Fort_Wayne +Link America/Indiana/Indianapolis America/Fort_Wayne +Link America/Indiana/Indianapolis America/Indianapolis Link America/Argentina/Jujuy America/Jujuy Link America/Indiana/Knox America/Knox_IN +Link America/Kentucky/Louisville America/Louisville Link America/Argentina/Mendoza America/Mendoza Link America/Rio_Branco America/Porto_Acre Link America/Argentina/Cordoba America/Rosario @@ -19,9 +23,9 @@ Link Asia/Ashgabat Asia/Ashkhabad Link Asia/Chongqing Asia/Chungking Link Asia/Dhaka Asia/Dacca Link Asia/Macau Asia/Macao -Link Asia/Makassar Asia/Ujung_Pandang Link Asia/Jerusalem Asia/Tel_Aviv Link Asia/Thimphu Asia/Thimbu +Link Asia/Makassar Asia/Ujung_Pandang Link Asia/Ulaanbaatar Asia/Ulan_Bator Link Australia/Sydney Australia/ACT Link Australia/Sydney Australia/Canberra @@ -38,6 +42,7 @@ Link America/Rio_Branco Brazil/Acre Link America/Noronha Brazil/DeNoronha Link America/Sao_Paulo Brazil/East Link America/Manaus Brazil/West +Link America/Chicago CST6CDT Link America/Halifax Canada/Atlantic Link America/Winnipeg Canada/Central Link America/Regina Canada/East-Saskatchewan @@ -50,8 +55,11 @@ Link America/Whitehorse Canada/Yukon Link America/Santiago Chile/Continental Link Pacific/Easter Chile/EasterIsland Link America/Havana Cuba +Link America/Panama EST +Link America/New_York EST5EDT Link Africa/Cairo Egypt Link Europe/Dublin Eire +Link Europe/London Europe/Belfast Link Europe/Chisinau Europe/Tiraspol Link Europe/London GB Link Europe/London GB-Eire @@ -59,6 +67,7 @@ Link Etc/GMT GMT+0 Link Etc/GMT GMT-0 Link Etc/GMT GMT0 Link Etc/GMT Greenwich +Link Pacific/Honolulu HST Link Asia/Hong_Kong Hongkong Link Atlantic/Reykjavik Iceland Link Asia/Tehran Iran @@ -67,16 +76,20 @@ Link America/Jamaica Jamaica Link Asia/Tokyo Japan Link Pacific/Kwajalein Kwajalein Link Africa/Tripoli Libya +Link America/Phoenix MST +Link America/Denver MST7MDT Link America/Tijuana Mexico/BajaNorte Link America/Mazatlan Mexico/BajaSur Link America/Mexico_City Mexico/General -Link America/Denver Navajo Link Pacific/Auckland NZ Link Pacific/Chatham NZ-CHAT +Link America/Denver Navajo +Link Asia/Shanghai PRC +Link America/Los_Angeles PST8PDT Link Pacific/Pago_Pago Pacific/Samoa +Link Pacific/Truk Pacific/Yap Link Europe/Warsaw Poland Link Europe/Lisbon Portugal -Link Asia/Shanghai PRC Link Asia/Taipei ROC Link Asia/Seoul ROK Link Asia/Singapore Singapore @@ -86,7 +99,7 @@ Link America/Anchorage US/Alaska Link America/Adak US/Aleutian Link America/Phoenix US/Arizona Link America/Chicago US/Central -Link America/Indianapolis US/East-Indiana +Link America/Indiana/Indianapolis US/East-Indiana Link America/New_York US/Eastern Link Pacific/Honolulu US/Hawaii Link America/Indiana/Knox US/Indiana-Starke diff --git a/timezone/europe b/timezone/europe index 9535a667b5..ec6720a804 100644 --- a/timezone/europe +++ b/timezone/europe @@ -1,4 +1,4 @@ -# @(#)europe 7.94 +# @(#)europe 7.95 # This data is by no means authoritative; if you think you know better, # go ahead and edit the file (and please send any changes to @@ -422,13 +422,6 @@ Zone Europe/London -0:01:15 - LMT 1847 Dec 1 1:00 - BST 1971 Oct 31 2:00u 0:00 GB-Eire %s 1996 0:00 EU GMT/BST -Zone Europe/Belfast -0:23:40 - LMT 1880 Aug 2 - -0:25:21 - DMT 1916 May 21 2:00 # Dublin/Dunsink MT - -0:25:21 1:00 IST 1916 Oct 1 2:00s # Irish Summer Time - 0:00 GB-Eire %s 1968 Oct 27 - 1:00 - BST 1971 Oct 31 2:00u - 0:00 GB-Eire %s 1996 - 0:00 EU GMT/BST Zone Europe/Dublin -0:25:00 - LMT 1880 Aug 2 -0:25:21 - DMT 1916 May 21 2:00 -0:25:21 1:00 IST 1916 Oct 1 2:00s @@ -756,6 +749,40 @@ Zone Europe/Prague 0:57:44 - LMT 1850 1:00 EU CE%sT # Denmark, Faeroe Islands, and Greenland + +# From Jesper Norgaard Welen (2005-04-26): +# http://www.hum.aau.dk/~poe/tid/tine/DanskTid.htm says that the law +# [introducing standard time] was in effect from 1894-01-01.... +# The page http://www.retsinfo.dk/_GETDOCI_/ACCN/A18930008330-REGL +# confirms this, and states that the law was put forth 1893-03-29. +# +# The EU treaty with effect from 1973: +# http://www.retsinfo.dk/_GETDOCI_/ACCN/A19722110030-REGL +# +# This provoked a new law from 1974 to make possible summer time changes +# in subsequenet decrees with the law +# http://www.retsinfo.dk/_GETDOCI_/ACCN/A19740022330-REGL +# +# It seems however that no decree was set forward until 1980. I have +# not found any decree, but in another related law, the effecting DST +# changes are stated explicitly to be from 1980-04-06 at 02:00 to +# 1980-09-28 at 02:00. If this is true, this differs slightly from +# the EU rule in that DST runs to 02:00, not 03:00. We don't know +# when Denmark began using the EU rule correctly, but we have only +# confirmation of the 1980-time, so I presume it was correct in 1981: +# The law is about the management of the extra hour, concerning +# working hours reported and effect on obligatory-rest rules (which +# was suspended on that night): +# http://www.retsinfo.dk/_GETDOCI_/ACCN/C19801120554-REGL + +# From Jesper Norgaard Welen (2005-06-11): +# The Herning Folkeblad (1980-09-26) reported that the night between +# Saturday and Sunday the clock is set back from three to two. + +# From Paul Eggert (2005-06-11): +# Hence the "02:00" of the 1980 law refers to standard time, not +# wall-clock time, and so the EU rules were in effect in 1980. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Denmark 1916 only - May 14 23:00 1:00 S Rule Denmark 1916 only - Sep 30 23:00 0 - @@ -768,13 +795,10 @@ Rule Denmark 1947 only - May 4 2:00s 1:00 S Rule Denmark 1947 only - Aug 10 2:00s 0 - Rule Denmark 1948 only - May 9 2:00s 1:00 S Rule Denmark 1948 only - Aug 8 2:00s 0 - -# Whitman also gives 1949 Apr 9 to 1949 Oct 1, and disagrees in minor ways -# about many of the above dates; go with Shanks. # -# For 1894, Shanks says Jan, Whitman Apr; go with Whitman. # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Europe/Copenhagen 0:50:20 - LMT 1890 - 0:50:20 - CMT 1894 Apr # Copenhagen Mean Time + 0:50:20 - CMT 1894 Jan 1 # Copenhagen MT 1:00 Denmark CE%sT 1942 Nov 2 2:00s 1:00 C-Eur CE%sT 1945 Apr 2 2:00 1:00 Denmark CE%sT 1980 @@ -1608,12 +1632,10 @@ Zone Europe/Amsterdam 0:19:32 - LMT 1835 1:00 EU CE%sT # Norway +# http://met.no/met/met_lex/q_u/sommertid.html (2004-01) agrees with Shanks. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -# Whitman gives 1916 May 21 - 1916 Oct 21; go with Shanks. Rule Norway 1916 only - May 22 1:00 1:00 S Rule Norway 1916 only - Sep 30 0:00 0 - -# Whitman says DST observed 1935-08-11/1942-11-01, then 1943-03-29/10-04, -# 1944-04-03/10-02, and 1945-04-01/10-01; go with Shanks. Rule Norway 1945 only - Apr 2 2:00s 1:00 S Rule Norway 1945 only - Oct 1 2:00s 0 - Rule Norway 1959 1964 - Mar Sun>=15 2:00s 1:00 S @@ -1686,19 +1708,26 @@ Rule Poland 1944 only - Oct 4 2:00 0 - # For 1944-1948 Whitman gives the previous day; go with Shanks. Rule Poland 1945 only - Apr 29 0:00 1:00 S Rule Poland 1945 only - Nov 1 0:00 0 - -Rule Poland 1946 only - Apr 14 0:00 1:00 S -Rule Poland 1946 only - Sep 7 0:00 0 - -Rule Poland 1947 only - May 4 0:00 1:00 S -Rule Poland 1947 1948 - Oct Sun>=1 0:00 0 - -Rule Poland 1948 only - Apr 18 0:00 1:00 S -# Whitman also gives 1949 Apr 9 - 1949 Oct 1; go with Shanks. +# For 1946 on the source is Kazimierz Borkowski, +# Torun Center for Astronomy, Dept. of Radio Astronomy, Nicolaus Copernicus U., +# <http://www.astro.uni.torun.pl/~kb/Artykuly/U-PA/Czas2.htm#tth_tAb1> +# Thanks to Przemyslaw Augustyniak (2005-05-28) for this reference. +# He also gives these further references: +# Mon Pol nr 13, poz 162 (1995) <http://www.abc.com.pl/serwis/mp/1995/0162.htm> +# Druk nr 2180 (2003) <http://www.senat.gov.pl/k5/dok/sejm/053/2180.pdf> +Rule Poland 1946 only - Apr 14 0:00s 1:00 S +Rule Poland 1946 only - Oct 7 2:00s 0 - +Rule Poland 1947 only - May 4 2:00s 1:00 S +Rule Poland 1947 1949 - Oct Sun>=1 2:00s 0 - +Rule Poland 1948 only - Apr 18 2:00s 1:00 S +Rule Poland 1949 only - Apr 10 2:00s 1:00 S Rule Poland 1957 only - Jun 2 1:00s 1:00 S Rule Poland 1957 1958 - Sep lastSun 1:00s 0 - Rule Poland 1958 only - Mar 30 1:00s 1:00 S Rule Poland 1959 only - May 31 1:00s 1:00 S Rule Poland 1959 1961 - Oct Sun>=1 1:00s 0 - Rule Poland 1960 only - Apr 3 1:00s 1:00 S -Rule Poland 1961 1964 - May Sun>=25 1:00s 1:00 S +Rule Poland 1961 1964 - May lastSun 1:00s 1:00 S Rule Poland 1962 1964 - Sep lastSun 1:00s 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Europe/Warsaw 1:24:00 - LMT 1880 @@ -1707,24 +1736,8 @@ Zone Europe/Warsaw 1:24:00 - LMT 1880 2:00 Poland EE%sT 1922 Jun 1:00 Poland CE%sT 1940 Jun 23 2:00 1:00 C-Eur CE%sT 1944 Oct - 1:00 Poland CE%sT 1977 Apr 3 1:00 - 1:00 W-Eur CE%sT 1999 -# IATA SSIM (1991/1996) gives EU rules, but the _The Warsaw Voice_ -# <a href="http://www.warsawvoice.com.pl/v361/NewsInBrief.shtml"> -# http://www.warsawvoice.com/pl/v361/NewsInBrief.shtml (1995-09-24) -# </a> -# says the autumn 1995 switch was at 02:00. -# Stick with W-Eur for now. -# -# From Marcin Kasperski (1999-06-10): -# According to my colleagues someone recently decided, that Poland would -# follow European Union regulations, so - I think - the matter is not -# worth further discussion. -# -# From Paul Eggert (1999-06-10): -# Kasperski also writes that the government futzed with the rules in 1997 -# or 1998 but he doesn't remember the details. Assume they switched to -# EU rules in 1999. + 1:00 Poland CE%sT 1977 + 1:00 W-Eur CE%sT 1988 1:00 EU CE%sT # Portugal diff --git a/timezone/northamerica b/timezone/northamerica index c290caf67b..40a2ce269d 100644 --- a/timezone/northamerica +++ b/timezone/northamerica @@ -1,4 +1,4 @@ -# @(#)northamerica 7.75 +# @(#)northamerica 7.79 # also includes Central America and the Caribbean # This data is by no means authoritative; if you think you know better, @@ -110,21 +110,26 @@ # # He had scored a 20-second scoop on other broadcasters. +# From Arthur David Olson (2005-08-22): +# Paul has been careful to use the "US" rules only in those locations +# that are part of the United States; this reflects the real scope of +# U.S. government action. So even though the "US" rules have changed +# in the latest release, other countries won't be affected. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule US 1918 1919 - Mar lastSun 2:00 1:00 D Rule US 1918 1919 - Oct lastSun 2:00 0 S Rule US 1942 only - Feb 9 2:00 1:00 W # War Rule US 1945 only - Aug 14 23:00u 1:00 P # Peace Rule US 1945 only - Sep 30 2:00 0 S -Rule US 1967 max - Oct lastSun 2:00 0 S +Rule US 1967 2006 - Oct lastSun 2:00 0 S Rule US 1967 1973 - Apr lastSun 2:00 1:00 D Rule US 1974 only - Jan 6 2:00 1:00 D Rule US 1975 only - Feb 23 2:00 1:00 D Rule US 1976 1986 - Apr lastSun 2:00 1:00 D -Rule US 1987 max - Apr Sun>=1 2:00 1:00 D -# <a href="http://thomas.loc.gov/cgi-bin/bdquery/z?d106:h.r.00177:"> -# H.R.177 -# </a> (introduced 1999-01-06) would change April to March in the above rule. +Rule US 1987 2006 - Apr Sun>=1 2:00 1:00 D +Rule US 2007 max - Mar Sun>=8 2:00 1:00 D +Rule US 2007 max - Nov Sun>=1 2:00 0 S # From Bob Devine (1988-01-28): # ...Alaska (and Hawaii) had the timezone names changed in 1967. @@ -202,13 +207,32 @@ Rule US 1987 max - Apr Sun>=1 2:00 1:00 D # Public law 106-564 (2000-12-23) introduced the abbreviation # "Chamorro Standard Time" for time in Guam and the Northern Marianas. # See the file "australasia". - + +# From Arthur David Olson, 2005-08-09 +# The following was signed into law on 2005-08-08. +# +# H.R. 6, Energy Policy Act of 2005, SEC. 110. DAYLIGHT SAVINGS. +# (a) Amendment- Section 3(a) of the Uniform Time Act of 1966 (15 +# U.S.C. 260a(a)) is amended-- +# (1) by striking `first Sunday of April' and inserting `second +# Sunday of March'; and +# (2) by striking `last Sunday of October' and inserting `first +# Sunday of November'. +# (b) Effective Date- Subsection (a) shall take effect 1 year after the +# date of enactment of this Act or March 1, 2007, whichever is later. +# (c) Report to Congress- Not later than 9 months after the effective +# date stated in subsection (b), the Secretary shall report to Congress +# on the impact of this section on energy consumption in the United +# States. +# (d) Right to Revert- Congress retains the right to revert the +# Daylight Saving Time back to the 2005 time schedules once the +# Department study is complete. # US eastern time, represented by New York # Connecticut, Delaware, District of Columbia, most of Florida, -# Georgia, southeast Indiana (Clark, Dearborn, Floyd, Harrison, and -# Ohio counties), eastern Kentucky, Maine, Maryland, Massachusetts, +# Georgia, southeast Indiana (Dearborn and Ohio counties), eastern Kentucky +# (except America/Kentucky/Louisville below), Maine, Maryland, Massachusetts, # New Hampshire, New Jersey, New York, North Carolina, Ohio, # Pennsylvania, Rhode Island, South Carolina, eastern Tennessee, # Vermont, Virginia, West Virginia @@ -463,40 +487,44 @@ Zone America/Boise -7:44:49 - LMT 1883 Nov 18 12:15:11 # For a map of Indiana's time zone regions, see: # <a href="http://www.mccsc.edu/time.html"> # What time is it in Indiana? -# </a> (1999-04-06) +# </a> (2005-05-03) +# +# From Paul Eggert (2005-08-22): +# Since 1970, most of Indiana has been like America/Indiana/Indianapolis, +# with the following exceptions: +# +# - Gibson, Jasper, Lake, LaPorte, Newton, Porter, Posey, Spencer, +# Vandenburgh, and Warrick counties have been like America/Chicago. +# +# - Dearborn and Ohio counties have been like America/New_York. +# +# - Clark, Floyd, and Harrison counties have been like +# America/Kentucky/Louisville. +# +# - Crawford, Starke, and Switzerland counties have their own time zone +# histories as noted below. # -# From Paul Eggert (1995-12-19): -# Indiana generally observes either EST all year, or CST/CDT, -# but areas near Cincinnati and Louisville use those cities' timekeeping -# and in 1969 and 1970 the whole state observed daylight time; -# and there are other exceptions as noted below. # Shanks partitions Indiana into 345 regions, each with its own time history, # and writes ``Even newspaper reports present contradictory information.'' # Fortunately, most of the complexity occurred before our cutoff date of 1970. # -# Since 1970, EST-only Indiana has been like America/Indianapolis, -# with exceptions noted below for Crawford, Starke, and Switzerland counties. -# The parts of Indiana not listed below have been like America/Chicago, -# America/Louisville, or America/New_York. -# # Other than Indianapolis, the Indiana place names are so nondescript # that they would be ambiguous if we left them at the `America' level. # So we reluctantly put them all in a subdirectory `America/Indiana'. -# -# Most of EST-only Indiana last observed DST in 1970. -# From Paul Eggert (2001-03-06), following a tip by Markus Kuhn: -# Pam Belluck reported in the New York Times (2001-01-31) that the -# Indiana Legislature is considering a bill to adopt DST statewide. -# Her article mentioned Vevay, whose post office observes a different -# time zone from Danner's Hardware across the street. +# From Paul Eggert (2005-08-16): +# http://www.mccsc.edu/time.html says that Indiana will use DST starting 2006, +# and that many counties may switch either to Central or to Eastern time. +# The county-by-county decisions have not been made yet, so for now assume +# that no counties will switch: this assumption is most likely wrong, +# but it's the best we can do for now. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER Rule Indianapolis 1941 only - Jun 22 2:00 1:00 D Rule Indianapolis 1941 1954 - Sep lastSun 2:00 0 S Rule Indianapolis 1946 1954 - Apr lastSun 2:00 1:00 D # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Indianapolis -5:44:38 - LMT 1883 Nov 18 12:15:22 +Zone America/Indiana/Indianapolis -5:44:38 - LMT 1883 Nov 18 12:15:22 -6:00 US C%sT 1920 -6:00 Indianapolis C%sT 1942 -6:00 US C%sT 1946 @@ -505,8 +533,8 @@ Zone America/Indianapolis -5:44:38 - LMT 1883 Nov 18 12:15:22 -6:00 - CST 1958 Apr 27 2:00 -5:00 - EST 1969 -5:00 US E%sT 1971 - -5:00 - EST -Link America/Indianapolis America/Indiana/Indianapolis + -5:00 - EST 2006 + -5:00 US E%sT # # Part of Crawford County, Indiana, last observed DST in 1975, # and left its clocks alone in 1974. @@ -523,7 +551,8 @@ Zone America/Indiana/Marengo -5:45:23 - LMT 1883 Nov 18 12:14:37 -5:00 US E%sT 1974 Jan 6 2:00 -6:00 1:00 CDT 1974 Oct 27 2:00 -5:00 US E%sT 1976 - -5:00 - EST + -5:00 - EST 2006 + -5:00 US E%sT # # Starke County, Indiana # From Arthur David Olson (1991-10-28): @@ -542,7 +571,8 @@ Zone America/Indiana/Knox -5:46:30 - LMT 1883 Nov 18 12:13:30 -6:00 Starke C%sT 1962 Apr 29 2:00 -5:00 - EST 1963 Oct 27 2:00 -6:00 US C%sT 1991 Oct 27 2:00 - -5:00 - EST + -5:00 - EST 2006 + -5:00 US E%sT # # Switzerland County, Indiana, last observed DST in 1972. # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -550,10 +580,11 @@ Zone America/Indiana/Vevay -5:40:16 - LMT 1883 Nov 18 12:19:44 -6:00 US C%sT 1954 Apr 25 2:00 -5:00 - EST 1969 -5:00 US E%sT 1973 - -5:00 - EST + -5:00 - EST 2006 + -5:00 US E%sT # Part of Kentucky left its clocks alone in 1974. -# This also includes a part of Indiana immediately adjacent to Louisville. +# This also includes Clark, Floyd, and Harrison counties in Indiana. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER Rule Louisville 1921 only - May 1 2:00 1:00 D Rule Louisville 1921 only - Sep 1 2:00 0 S @@ -563,7 +594,7 @@ Rule Louisville 1946 only - Jun 2 2:00 0 S Rule Louisville 1950 1955 - Sep lastSun 2:00 0 S Rule Louisville 1956 1960 - Oct lastSun 2:00 0 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Louisville -5:43:02 - LMT 1883 Nov 18 12:16:58 +Zone America/Kentucky/Louisville -5:43:02 - LMT 1883 Nov 18 12:16:58 -6:00 US C%sT 1921 -6:00 Louisville C%sT 1942 -6:00 US C%sT 1946 @@ -572,7 +603,6 @@ Zone America/Louisville -5:43:02 - LMT 1883 Nov 18 12:16:58 -5:00 US E%sT 1974 Jan 6 2:00 -6:00 1:00 CDT 1974 Oct 27 2:00 -5:00 US E%sT -Link America/Louisville America/Kentucky/Louisville # # Wayne, Clinton, and Russell Counties, Kentucky # @@ -695,17 +725,6 @@ Zone America/Menominee -5:50:27 - LMT 1885 Sep 18 12:00 # _Los Angeles Times_ (1998-11-10), A1, A10; it cites # Jimmy Skaggs, _The Great Guano Rush_ (1994). -# Old names, for S5 users - -# Link LINK-FROM LINK-TO -Link America/New_York EST5EDT -Link America/Chicago CST6CDT -Link America/Denver MST7MDT -Link America/Los_Angeles PST8PDT -Link America/Indianapolis EST -Link America/Phoenix MST -Link Pacific/Honolulu HST - ################################################################################ @@ -1294,8 +1313,6 @@ Zone America/Dawson_Creek -8:00:56 - LMT 1884 # </a> (1999) reports that Pangnirtung operates on eastern time, # and that Coral Harbour does not observe DST. We don't know when # Pangnirtung switched to eastern time; we'll guess 1995. -# We'll ignore the claim about Coral Harbour for now, -# since we have no further info. # From Rives McDow (1999-11-08): # On October 31, when the rest of Nunavut went to Central time, @@ -1370,6 +1387,23 @@ Zone America/Dawson_Creek -8:00:56 - LMT 1884 # more. # [Also see <http://www.nunatsiaq.com/nunavut/nvt10309_06.html> (2001-03-09).] +# From Gwillim Law (2005-05-21): +# According to maps at +# http://inms-ienm.nrc-cnrc.gc.ca/images/time_services/TZ01SWE.jpg +# http://inms-ienm.nrc-cnrc.gc.ca/images/time_services/TZ01SSE.jpg +# (both dated 2003), and +# http://www.canadiangeographic.ca/Magazine/SO98/geomap.asp +# (from a 1998 Canadian Geographic article), the de facto and de jure time +# for Southampton Island (at the north end of Hudson Bay) is UTC-5 all year +# round. Using Google, it's easy to find other websites that confirm this. +# I wasn't able to find how far back this time regimen goes, but since it +# predates the creation of Nunavut, it probably goes back many years.... +# The Inuktitut name of Coral Harbour is Sallit, but it's rarely used. +# +# From Paul Eggert (2005-07-26): +# For lack of better information, assume that Southampton Island observed +# daylight saving only during wartime. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule NT_YK 1918 only - Apr 14 2:00 1:00 D Rule NT_YK 1918 only - Oct 27 2:00 0 S @@ -1393,6 +1427,9 @@ Zone America/Iqaluit -4:33:52 - LMT 1884 # Frobisher Bay before 1987 -5:00 NT_YK E%sT 1999 Oct 31 2:00 -6:00 Canada C%sT 2000 Oct 29 2:00 -5:00 Canada E%sT +Zone America/Coral_Harbour -5:32:40 - LMT 1884 + -5:00 NT_YK E%sT 1946 + -5:00 - EST Zone America/Rankin_Inlet -6:08:40 - LMT 1884 -6:00 NT_YK C%sT 2000 Oct 29 2:00 -5:00 - EST 2001 Apr 1 3:00 @@ -1968,10 +2005,21 @@ Zone America/Montserrat -4:08:52 - LMT 1911 Jul 1 0:01 # Olveston # The Decree, no 23-2005 is available here: # http://www.presidencia.gob.ni/buscador_gaceta/BD/DECRETOS/2005/Decreto%2023-2005%20Se%20adelanta%20en%20una%20hora%20en%20todo%20el%20territorio%20nacional%20apartir%20de%20las%2024horas%20del%2009%20de%20Abril.pdf # -# From Paul Eggert (2005-04-12): +# From Paul Eggert (2005-05-01): # The decree doesn't say anything about daylight saving, but for now let's # assume that it is daylight saving and that they'll switch back on the -# 2nd Sunday in September. +# 3rd Sunday in September. +# +# From Gwillim Law (2005-04-21): +# The Associated Press story on the time change, which can be found at +# http://www.lapalmainteractivo.com/guias/content/gen/ap/America_Latina/AMC_GEN_NICARAGUA_HORA.html +# and elsewhere, says (fifth paragraph, translated from Spanish): "The last +# time that a change of clocks was applied to save energy was in the year 2000 +# during the Arnoldo Aleman administration."... +# The northamerica file says that Nicaragua has been on UTC-6 continuously +# since December 1998. I wasn't able to find any details of Nicaraguan time +# changes in 2000. Perhaps a note could be added to the northamerica file, to +# the effect that we have indirect evidence that DST was observed in 2000. # # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Nic 1979 1980 - Mar Sun>=16 0:00 1:00 D @@ -1979,7 +2027,7 @@ Rule Nic 1979 1980 - Jun Mon>=23 0:00 0 S Rule Nic 1992 only - Jan 1 4:00 1:00 D Rule Nic 1992 only - Sep 24 0:00 0 S Rule Nic 2005 only - Apr 10 0:00 1:00 D -Rule Nic 2005 only - Sep 11 0:00 0 S +Rule Nic 2005 only - Sep 18 0:00 0 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Managua -5:45:08 - LMT 1890 -5:45:12 - MMT 1934 Jun 23 # Managua Mean Time? diff --git a/timezone/southamerica b/timezone/southamerica index d348d7a475..9bf068ba9e 100644 --- a/timezone/southamerica +++ b/timezone/southamerica @@ -1,4 +1,4 @@ -# @(#)southamerica 7.60 +# @(#)southamerica 7.61 # This data is by no means authoritative; if you think you know better, # go ahead and edit the file (and please send any changes to @@ -293,7 +293,7 @@ Zone America/Argentina/Jujuy -4:21:12 - LMT 1894 Oct 31 -4:00 Arg AR%sT 2000 Mar 3 -3:00 - ART # -# Catamarca (CT) +# Catamarca (CT), Chubut (CH) Zone America/Argentina/Catamarca -4:23:08 - LMT 1894 Oct 31 -4:16:48 - CMT 1920 May -4:00 - ART 1930 Dec @@ -323,20 +323,6 @@ Zone America/Argentina/Mendoza -4:35:16 - LMT 1894 Oct 31 -4:00 - WART 2004 Sep 26 -3:00 - ART # -# Chubut (CH) -# The name "Comodoro Rivadavia" exceeds the 14-byte POSIX limit. -Zone America/Argentina/ComodRivadavia -4:30:00 - LMT 1894 Oct 31 - -4:16:48 - CMT 1920 May - -4:00 - ART 1930 Dec - -4:00 Arg AR%sT 1969 Oct 5 - -3:00 Arg AR%sT 1991 Mar 3 - -4:00 - WART 1991 Oct 20 - -3:00 Arg AR%sT 1999 Oct 3 - -4:00 Arg AR%sT 2000 Mar 3 - -3:00 - ART 2004 Jun 1 - -4:00 - WART 2004 Jun 20 - -3:00 - ART -# # Santa Cruz (SC) Zone America/Argentina/Rio_Gallegos -4:36:52 - LMT 1894 Oct 31 -4:16:48 - CMT 1920 May # Cordoba Mean Time diff --git a/timezone/test-tz.c b/timezone/test-tz.c index 642b45a0ed..55613654c7 100644 --- a/timezone/test-tz.c +++ b/timezone/test-tz.c @@ -7,7 +7,7 @@ struct { const char * env; time_t expected; } tests[] = { - {"MST", 832935315}, + {"MST", 832910115}, {"", 832910115}, {":UTC", 832910115}, {"UTC", 832910115}, diff --git a/timezone/tst-timezone.c b/timezone/tst-timezone.c index 127956de29..4c879163cf 100644 --- a/timezone/tst-timezone.c +++ b/timezone/tst-timezone.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999, 2000, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger <aj@suse.de>, 1998. @@ -42,9 +42,9 @@ static const struct test_times tests[] = { "Australia/Melbourne", 1, -36000, { "EST", "EST" }}, { "America/Sao_Paulo", 1, 10800, {"BRT", "BRST" }}, { "America/Chicago", 1, 21600, {"CST", "CDT" }}, - { "America/Indianapolis", 1, 18000, {"EST", "EDT" }}, + { "America/Indiana/Indianapolis", 1, 18000, {"EST", "EDT" }}, { "America/Los_Angeles", 1, 28800, {"PST", "PDT" }}, - { "Asia/Tokyo", 0, -32400, {"JST", "JST" }}, + { "Asia/Tokyo", 1, -32400, {"JST", "JDT" }}, { "Pacific/Auckland", 1, -43200, { "NZST", "NZDT" }}, { NULL, 0, 0 } }; diff --git a/timezone/zdump.c b/timezone/zdump.c index 78cc28ef65..659f572b98 100644 --- a/timezone/zdump.c +++ b/timezone/zdump.c @@ -1,4 +1,4 @@ -static char elsieid[] = "@(#)zdump.c 7.65"; +static char elsieid[] = "@(#)zdump.c 7.66"; /* ** This code has been made independent of the rest of the time @@ -198,7 +198,6 @@ abbrok(abbr, zone) const char * const abbr; const char * const zone; { - register int i; register const char * cp; register char * wp; diff --git a/timezone/zone.tab b/timezone/zone.tab index 794c342a2d..d9b278b0ec 100644 --- a/timezone/zone.tab +++ b/timezone/zone.tab @@ -1,4 +1,4 @@ -# @(#)zone.tab 1.31 +# @(#)zone.tab 1.32 # # TZ zone descriptions # @@ -45,17 +45,17 @@ AR -3436-05827 America/Argentina/Buenos_Aires Buenos Aires (BA, CF) AR -3124-06411 America/Argentina/Cordoba most locations (CB, CC, CN, ER, FM, LP, MN, NQ, RN, SA, SE, SF, SL) AR -2411-06518 America/Argentina/Jujuy Jujuy (JY) AR -3124-06411 America/Argentina/Tucuman Tucuman (TM) -AR -2828-06547 America/Argentina/Catamarca Catamarca (CT) +AR -2828-06547 America/Argentina/Catamarca Catamarca (CT), Chubut (CH) AR -2926-06651 America/Argentina/La_Rioja La Rioja (LR) AR -3132-06831 America/Argentina/San_Juan San Juan (SJ) AR -3253-06849 America/Argentina/Mendoza Mendoza (MZ) -AR -4552-06730 America/Argentina/ComodRivadavia Chubut (CH) AR -5138-06913 America/Argentina/Rio_Gallegos Santa Cruz (SC) AR -5448-06818 America/Argentina/Ushuaia Tierra del Fuego (TF) AS -1416-17042 Pacific/Pago_Pago AT +4813+01620 Europe/Vienna AU -3133+15905 Australia/Lord_Howe Lord Howe Island -AU -4253+14719 Australia/Hobart Tasmania +AU -4253+14719 Australia/Hobart Tasmania - most locations +AU -3956+14352 Australia/Currie Tasmania - King Island AU -3749+14458 Australia/Melbourne Victoria AU -3352+15113 Australia/Sydney New South Wales - most locations AU -3157+14127 Australia/Broken_Hill New South Wales - Yancowinna @@ -107,9 +107,10 @@ CA +4531-07334 America/Montreal Eastern Time - Quebec - most locations CA +4339-07923 America/Toronto Eastern Time - Ontario - most locations CA +4901-08816 America/Nipigon Eastern Time - Ontario & Quebec - places that did not observe DST 1967-1973 CA +4823-08915 America/Thunder_Bay Eastern Time - Thunder Bay, Ontario -CA +6608-06544 America/Pangnirtung Eastern Standard Time - Pangnirtung, Nunavut -CA +6344-06828 America/Iqaluit Eastern Standard Time - east Nunavut -CA +6245-09210 America/Rankin_Inlet Eastern Standard Time - central Nunavut +CA +6608-06544 America/Pangnirtung Eastern Time - Pangnirtung, Nunavut +CA +6344-06828 America/Iqaluit Eastern Time - east Nunavut +CA +6408-08310 America/Coral_Harbour Eastern Standard Time - Southampton Island +CA +6245-09210 America/Rankin_Inlet Central Time - central Nunavut CA +4953-09709 America/Winnipeg Central Time - Manitoba & west Ontario CA +4843-09429 America/Rainy_River Central Time - Rainy River & Fort Frances, Ontario CA +6903-10505 America/Cambridge_Bay Central Time - west Nunavut @@ -165,15 +166,13 @@ ET +0902+03842 Africa/Addis_Ababa FI +6010+02458 Europe/Helsinki FJ -1808+17825 Pacific/Fiji FK -5142-05751 Atlantic/Stanley -FM +0931+13808 Pacific/Yap Yap -FM +0725+15147 Pacific/Truk Truk (Chuuk) +FM +0725+15147 Pacific/Truk Truk (Chuuk) and Yap FM +0658+15813 Pacific/Ponape Ponape (Pohnpei) FM +0519+16259 Pacific/Kosrae Kosrae FO +6201-00646 Atlantic/Faeroe FR +4852+00220 Europe/Paris GA +0023+00927 Africa/Libreville -GB +512830-0001845 Europe/London Great Britain -GB +5435-00555 Europe/Belfast Northern Ireland +GB +512830-0001845 Europe/London GD +1203-06145 America/Grenada GE +4143+04449 Asia/Tbilisi GF +0456-05220 America/Cayenne @@ -248,8 +247,7 @@ MG -1855+04731 Indian/Antananarivo MH +0709+17112 Pacific/Majuro most locations MH +0905+16720 Pacific/Kwajalein Kwajalein MK +4159+02126 Europe/Skopje -ML +1239-00800 Africa/Bamako southwest Mali -ML +1446-00301 Africa/Timbuktu northeast Mali +ML +1239-00800 Africa/Bamako MM +1647+09610 Asia/Rangoon MN +4755+10653 Asia/Ulaanbaatar most locations MN +4801+09139 Asia/Hovd Bayan-Olgiy, Govi-Altai, Hovd, Uvs, Zavkhan @@ -370,9 +368,9 @@ UM +2813-17722 Pacific/Midway Midway Islands UM +1917+16637 Pacific/Wake Wake Island US +404251-0740023 America/New_York Eastern Time US +421953-0830245 America/Detroit Eastern Time - Michigan - most locations -US +381515-0854534 America/Louisville Eastern Time - Kentucky - Louisville area +US +381515-0854534 America/Kentucky/Louisville Eastern Time - Kentucky - Louisville area US +364947-0845057 America/Kentucky/Monticello Eastern Time - Kentucky - Wayne County -US +394606-0860929 America/Indianapolis Eastern Standard Time - Indiana - most locations +US +394606-0860929 America/Indiana/Indianapolis Eastern Standard Time - Indiana - most locations US +382232-0862041 America/Indiana/Marengo Eastern Standard Time - Indiana - Crawford County US +411745-0863730 America/Indiana/Knox Eastern Standard Time - Indiana - Starke County US +384452-0850402 America/Indiana/Vevay Eastern Standard Time - Indiana - Switzerland County |