[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r6172 - in /fsf/trunk/libc: ./ bits/ iconv/ iconvdata/ inet/netinet/ localedata/ localedata/locales/ nss/ posix/ string/ sys...



Author: eglibc
Date: Thu May 15 00:06:29 2008
New Revision: 6172

Log:
Import glibc-mainline for 2008-05-15

Added:
    fsf/trunk/libc/string/str-two-way.h
    fsf/trunk/libc/string/tst-endian.c
Modified:
    fsf/trunk/libc/ChangeLog
    fsf/trunk/libc/NEWS
    fsf/trunk/libc/bits/byteswap.h
    fsf/trunk/libc/configure
    fsf/trunk/libc/configure.in
    fsf/trunk/libc/iconv/gconv_simple.c
    fsf/trunk/libc/iconvdata/Makefile
    fsf/trunk/libc/iconvdata/bug-iconv6.c
    fsf/trunk/libc/iconvdata/run-iconv-test.sh
    fsf/trunk/libc/inet/netinet/in.h
    fsf/trunk/libc/localedata/ChangeLog
    fsf/trunk/libc/localedata/locales/be_BY
    fsf/trunk/libc/localedata/locales/iso14651_t1_common
    fsf/trunk/libc/nss/getent.c
    fsf/trunk/libc/posix/regcomp.c
    fsf/trunk/libc/posix/regex_internal.c
    fsf/trunk/libc/posix/tst-rfc3484-2.c
    fsf/trunk/libc/posix/tst-rfc3484-3.c
    fsf/trunk/libc/posix/tst-rfc3484.c
    fsf/trunk/libc/string/Makefile
    fsf/trunk/libc/string/endian.h
    fsf/trunk/libc/string/memmem.c
    fsf/trunk/libc/string/strcasestr.c
    fsf/trunk/libc/string/strstr.c
    fsf/trunk/libc/sysdeps/i386/bits/byteswap.h
    fsf/trunk/libc/sysdeps/ia64/bits/byteswap.h
    fsf/trunk/libc/sysdeps/posix/getaddrinfo.c
    fsf/trunk/libc/sysdeps/s390/bits/byteswap.h
    fsf/trunk/libc/sysdeps/unix/sysv/linux/bits/socket.h
    fsf/trunk/libc/sysdeps/x86_64/bits/byteswap.h

Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Thu May 15 00:06:29 2008
@@ -1,3 +1,80 @@
+2008-05-14  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* string/Makefile (distribute): Add str-two-way.h.
+
+2008-03-29  Eric Blake	<ebb9@xxxxxxx>
+
+	Rewrite string searches to O(n) rather than O(n^2).
+	* string/str-two-way.h: New file.  For linear fixed-allocation
+	string searching.
+	* string/memmem.c: New implementation.
+	* string/strstr.c: New implementation.
+	* string/strcasestr.c: New implementation.
+
+2008-04-11  Paolo Bonzini  <bonzini@xxxxxxx>
+
+	* posix/regcomp.c (optimize_utf8): Add a note on why we test
+	opr.ctx_type.
+	(calc_first): Initialize constraint field.
+	(duplicate_node_closure): Use it instead of special casing ANCHORS.
+	Use search_duplicated_node to avoid loops.  Fix grammar.
+	(duplicate_node): Merge constraint field for all node types.
+	(calc_eclosure_iter): Look at constraint field for all node types.
+	* posix/regex_internal.c (create_cd_newstate): Don't look at
+	create_cd_newstate.
+
+2008-05-14  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	[BZ #6428]
+	* configure.in: Don't use $CFLAGS when assembling, use $ASFLAGS.
+
+	[BZ #6442]
+	* string/endian.h: Add macros for fixed-size endian conversion.
+	* bits/byteswap.h: Allow inclusion from <endian.h>.
+	* sysdeps/i386/bits/byteswap.h: Likewise.
+	* sysdeps/ia64/bits/byteswap.h: Likewise.
+	* sysdeps/s390/bits/byteswap.h: Likewise.
+	* sysdeps/x86_64/bits/byteswap.h: Likewise.
+	* string/Makefile (tests): Add tst-endian.
+	* string/tst-endian.c: New file.
+
+	* iconvdata/run-iconv-test.sh: Use = instead of == in test.
+	Patch by Reuben Thomas.
+
+2008-05-14  Joseph Myers  <joseph@xxxxxxxxxxxxxxxx>
+
+	* iconvdata/Makefile (bug-iconv6-ENV, tst-iconv7-ENV): Define.
+
+2008-05-14  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* iconvdata/bug-iconv6.c (do_test): Use de_DE.UTF-8 locale.
+
+	[BZ #6461]
+	* iconv/gconv_simple.c (BODY for __gconv_transform_ascii_internal):
+	Add missing braces.
+	(BODY for __gconv_transform_internal_ascii): Likewise.
+
+	[BZ #6472]
+	* sysdeps/posix/getaddrinfo.c (get_scope): Loopback addresses have
+	to be treated like link-local addresses.
+	(match_prefix): Don't treat IPv4 loopback address special when
+	converting to v4 mapped addressed.
+
+	* sysdeps/posix/getaddrinfo.c (getaddrinfo): Call _res_hconf_init
+	if necessary.
+	* posix/tst-rfc3484.c: Add dummy definition of _res_hconf_init.
+	* posix/tst-rfc3484-2.c: Likewise.
+	* posix/tst-rfc3484-3.c: Likewise.
+
+	* sysdeps/posix/getaddrinfo.c: Implement handling of DCCP, UDPlite,
+	and SCTP.
+
+	* nss/getent.c (ahosts_keys_int): Handle all known socket types.
+
+	* inet/netinet/in.h (IPPIPPROTO_DCCP, IPPROTO_UDPLITE): Define.
+
+	* sysdeps/unix/sysv/linux/bits/socket.h (SOCK_DCCP): Define.
+
 2008-05-13  Ulrich Drepper  <drepper@xxxxxxxxxx>
 
 	* po/lt.po: New file.  From Lituanian translation team.

Modified: fsf/trunk/libc/NEWS
==============================================================================
--- fsf/trunk/libc/NEWS (original)
+++ fsf/trunk/libc/NEWS Thu May 15 00:06:29 2008
@@ -1,4 +1,4 @@
-GNU C Library NEWS -- history of user-visible changes.  2008-5-12
+GNU C Library NEWS -- history of user-visible changes.  2008-5-14
 Copyright (C) 1992-2007, 2008 Free Software Foundation, Inc.
 See the end for copying conditions.
 
@@ -12,6 +12,16 @@
 
 * TLS descriptors for LD and GD on x86 and x86-64.
   Implemented by Alexandre Oliva.
+
+* getaddrinfo now handles DCCP and UDPlite.
+  Implemented by Ulrich Drepper.
+
+* New fixed-size conversion macros: htobe16, htole16, be16toh, le16toh,
+  htobe32, htole32, be32toh, le32toh, htobe64, htole64, be64toh, le64toh.
+  Implemented by Ulrich Drepper.
+
+* New implementation of memmem, strstr, and strcasestr which is O(n).
+  Implemented by Eric Blake.
 
 Version 2.8
 

Modified: fsf/trunk/libc/bits/byteswap.h
==============================================================================
--- fsf/trunk/libc/bits/byteswap.h (original)
+++ fsf/trunk/libc/bits/byteswap.h Thu May 15 00:06:29 2008
@@ -1,5 +1,5 @@
 /* Macros to swap the order of bytes in integer values.
-   Copyright (C) 1997,1998,2000,2001,2002,2005 Free Software Foundation, Inc.
+   Copyright (C) 1997,1998,2000-2002,2005,2008 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
@@ -17,7 +17,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
+#if !defined _BYTESWAP_H && !defined _NETINET_IN_H && !defined _ENDIAN_H
 # error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
 #endif
 

Modified: fsf/trunk/libc/configure
==============================================================================
--- fsf/trunk/libc/configure (original)
+++ fsf/trunk/libc/configure Thu May 15 00:06:29 2008
@@ -6266,7 +6266,7 @@
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; } \
      && grep -q .note.GNU-stack conftest.s \
-     && { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Wa,--noexecstack
+     && { ac_try='${CC-cc} $ASFLAGS -Wa,--noexecstack
 		       -c -o conftest.o conftest.s 1>&5'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5

Modified: fsf/trunk/libc/configure.in
==============================================================================
--- fsf/trunk/libc/configure.in (original)
+++ fsf/trunk/libc/configure.in Thu May 15 00:06:29 2008
@@ -1520,7 +1520,7 @@
   if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS
 		     -S -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD]) \
      && grep -q .note.GNU-stack conftest.s \
-     && AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wa,--noexecstack
+     && AC_TRY_COMMAND([${CC-cc} $ASFLAGS -Wa,--noexecstack
 		       -c -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD])
   then
     libc_cv_as_noexecstack=yes

Modified: fsf/trunk/libc/iconv/gconv_simple.c
==============================================================================
--- fsf/trunk/libc/iconv/gconv_simple.c (original)
+++ fsf/trunk/libc/iconv/gconv_simple.c Thu May 15 00:06:29 2008
@@ -1,5 +1,5 @@
 /* Simple transformations functions.
-   Copyright (C) 1997-2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1997-2005, 2007, 2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1997.
 
@@ -820,9 +820,11 @@
 	STANDARD_FROM_LOOP_ERR_HANDLER (1);				      \
       }									      \
     else								      \
-      /* It's an one byte sequence.  */					      \
-      *((uint32_t *) outptr) = *inptr++;				      \
-      outptr += sizeof (uint32_t);					      \
+      {									      \
+	/* It's an one byte sequence.  */				      \
+	*((uint32_t *) outptr) = *inptr++;				      \
+	outptr += sizeof (uint32_t);					      \
+      }									      \
   }
 #define LOOP_NEED_FLAGS
 #include <iconv/loop.c>
@@ -851,9 +853,11 @@
 	STANDARD_TO_LOOP_ERR_HANDLER (4);				      \
       }									      \
     else								      \
-      /* It's an one byte sequence.  */					      \
-      *outptr++ = *((const uint32_t *) inptr);				      \
-      inptr += sizeof (uint32_t);					      \
+      {									      \
+	/* It's an one byte sequence.  */				      \
+	*outptr++ = *((const uint32_t *) inptr);			      \
+	inptr += sizeof (uint32_t);					      \
+      }									      \
   }
 #define LOOP_NEED_FLAGS
 #include <iconv/loop.c>

Modified: fsf/trunk/libc/iconvdata/Makefile
==============================================================================
--- fsf/trunk/libc/iconvdata/Makefile (original)
+++ fsf/trunk/libc/iconvdata/Makefile Thu May 15 00:06:29 2008
@@ -73,6 +73,9 @@
 endif
 
 test-srcs := tst-table-from tst-table-to
+
+bug-iconv6-ENV = LOCPATH=$(common-objpfx)localedata
+tst-iconv7-ENV = LOCPATH=$(common-objpfx)localedata
 endif
 
 # No code here is in libc.so.

Modified: fsf/trunk/libc/iconvdata/bug-iconv6.c
==============================================================================
--- fsf/trunk/libc/iconvdata/bug-iconv6.c (original)
+++ fsf/trunk/libc/iconvdata/bug-iconv6.c Thu May 15 00:06:29 2008
@@ -13,7 +13,7 @@
 static int
 do_test (void)
 {
-  setlocale (LC_ALL, "en_US.UTF-8");
+  setlocale (LC_ALL, "de_DE.UTF-8");
   iconv_t ic = iconv_open ("ISO-2022-JP//TRANSLIT", "UTF-8");
   if (ic == (iconv_t) -1)
     {

Modified: fsf/trunk/libc/iconvdata/run-iconv-test.sh
==============================================================================
--- fsf/trunk/libc/iconvdata/run-iconv-test.sh (original)
+++ fsf/trunk/libc/iconvdata/run-iconv-test.sh Thu May 15 00:06:29 2008
@@ -1,6 +1,6 @@
 #! /bin/sh -f
 # Run available iconv(1) tests.
-# Copyright (C) 1998-2002, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1998-2002, 2005, 2006, 2008 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 # Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1998.
 #
@@ -130,7 +130,7 @@
     done
   fi
 
-  if test "$subset" == N; then
+  if test "$subset" = N; then
     echo $ac_n "      suntzu: ASCII -> $to -> ASCII $ac_c"
     $PROG -f ASCII -t $to testdata/suntzus |
     $PROG -f $to -t ASCII > $temp1 ||

Modified: fsf/trunk/libc/inet/netinet/in.h
==============================================================================
--- fsf/trunk/libc/inet/netinet/in.h (original)
+++ fsf/trunk/libc/inet/netinet/in.h Thu May 15 00:06:29 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2001, 2003, 2004, 2006, 2007
+/* Copyright (C) 1991-2001, 2003, 2004, 2006, 2007, 2008
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -53,6 +53,8 @@
 #define IPPROTO_IDP		IPPROTO_IDP
     IPPROTO_TP = 29,	   /* SO Transport Protocol Class 4.  */
 #define IPPROTO_TP		IPPROTO_TP
+    IPPROTO_DCCP = 33,	   /* Datagram Congestion Control Protocol.  */
+#define IPPROTO_DCCP		IPPROTO_DCCP
     IPPROTO_IPV6 = 41,     /* IPv6 header.  */
 #define IPPROTO_IPV6		IPPROTO_IPV6
     IPPROTO_ROUTING = 43,  /* IPv6 routing header.  */
@@ -83,6 +85,8 @@
 #define IPPROTO_COMP		IPPROTO_COMP
     IPPROTO_SCTP = 132,	   /* Stream Control Transmission Protocol.  */
 #define IPPROTO_SCTP		IPPROTO_SCTP
+    IPPROTO_UDPLITE = 136, /* UDP-Lite protocol.  */
+#define IPPROTO_UDPLITE		IPPROTO_UDPLITE
     IPPROTO_RAW = 255,	   /* Raw IP packets.  */
 #define IPPROTO_RAW		IPPROTO_RAW
     IPPROTO_MAX

Modified: fsf/trunk/libc/localedata/ChangeLog
==============================================================================
--- fsf/trunk/libc/localedata/ChangeLog (original)
+++ fsf/trunk/libc/localedata/ChangeLog Thu May 15 00:06:29 2008
@@ -1,3 +1,12 @@
+2008-05-14  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	[BZ #6438]
+	* locales/iso14651_t1_common: Add sorting data for Telugu.
+
+	[BZ #6447]
+	* locales/be_BY: Fix yesexpr.
+	Patch by Alexander Mikhailian <mikhailian@xxxxxxxxxx>.
+
 2008-04-15  Ulrich Drepper  <drepper@xxxxxxxxxx>
 
 	* charmaps/UTF-8: Update for Unicode v5.1.

Modified: fsf/trunk/libc/localedata/locales/be_BY
==============================================================================
--- fsf/trunk/libc/localedata/locales/be_BY (original)
+++ fsf/trunk/libc/localedata/locales/be_BY Thu May 15 00:06:29 2008
@@ -69,7 +69,7 @@
 END LC_CTYPE
 
 LC_MESSAGES
-yesexpr "<U005E><U005B><U0414><U0434><U0059><U0079><U005D><U002E><U002A>"
+yesexpr "<U005E><U005B><U0422><U0442><U0059><U0079><U005D><U002E><U002A>"
 noexpr  "<U005E><U005B><U041D><U043D><U004E><U006E><U005D><U002E><U002A>"
 END LC_MESSAGES
 

Modified: fsf/trunk/libc/localedata/locales/iso14651_t1_common
==============================================================================
--- fsf/trunk/libc/localedata/locales/iso14651_t1_common (original)
+++ fsf/trunk/libc/localedata/locales/iso14651_t1_common Thu May 15 00:06:29 2008
@@ -62,6 +62,7 @@
 script <GEORGIAN>
 script <DEVANAGARI>
 script <GUJARATI>
+script <TELUGU>
 
 # Déclaration des symboles internes / Declaration of internal symbols
 #
@@ -652,6 +653,95 @@
 collating-symbol <gvd-visarg>
 collating-symbol <g-halant>
 
+# <TELUGU>
+#
+# tvd - denotes Telugu vowel modifier
+# tm  -  denotes Telugu matras
+# tvw - denotes Telugu vowels
+
+# defining symbols
+collating-symbol <tummu>
+collating-symbol <tvw-a>
+collating-symbol <tvw-aa>
+collating-symbol <tvw-i>
+collating-symbol <tvw-ii>
+collating-symbol <tvw-u>
+collating-symbol <tvw-uu>
+collating-symbol <tvw-vocalicr>
+collating-symbol <tvw-vocalicrr>
+collating-symbol <tvw-vocalicl>
+collating-symbol <tvw-vocalicll>
+collating-symbol <tvw-candrae>
+collating-symbol <tvw-shorte>
+collating-symbol <tvw-e>
+collating-symbol <tvw-ai>
+collating-symbol <tvw-shorto>
+collating-symbol <tvw-o>
+collating-symbol <tvw-au>
+collating-symbol <t-ka>
+collating-symbol <t-kha>
+collating-symbol <t-ga>
+collating-symbol <t-gga>
+collating-symbol <t-gha>
+collating-symbol <t-nga>
+collating-symbol <t-ca>
+collating-symbol <t-tsa>
+collating-symbol <t-cha>
+collating-symbol <t-ja>
+collating-symbol <t-dza>
+collating-symbol <t-jja>
+collating-symbol <t-jha>
+collating-symbol <t-nya>
+collating-symbol <t-tta>
+collating-symbol <t-ttha>
+collating-symbol <t-dda>
+collating-symbol <t-ddda>
+collating-symbol <t-ddha>
+collating-symbol <t-nna>
+collating-symbol <t-ta>
+collating-symbol <t-tha>
+collating-symbol <t-da>
+collating-symbol <t-dha>
+collating-symbol <t-na>
+collating-symbol <t-pa>
+collating-symbol <t-pha>
+collating-symbol <t-ba>
+collating-symbol <t-bba>
+collating-symbol <t-bha>
+collating-symbol <t-ma>
+collating-symbol <t-ya>
+collating-symbol <t-ra>
+collating-symbol <t-rra>
+collating-symbol <t-la>
+collating-symbol <t-lla>
+collating-symbol <t-va>
+collating-symbol <t-sha>
+collating-symbol <t-ssa>
+collating-symbol <t-sa>
+collating-symbol <t-ha>
+collating-symbol <t-avagrah>
+collating-symbol <tm-aa>
+collating-symbol <tm-i>
+collating-symbol <tm-ii>
+collating-symbol <tm-u>
+collating-symbol <tm-uu>
+collating-symbol <tm-vocalicr>
+collating-symbol <tm-vocalicrr>
+collating-symbol <tm-vocalicl>
+collating-symbol <tm-vocalicll>
+collating-symbol <tm-shorte>
+collating-symbol <tm-e>
+collating-symbol <tm-ai>
+collating-symbol <tm-shorto>
+collating-symbol <tm-o>
+collating-symbol <tm-au>
+collating-symbol <tvd-chandrabindu>
+collating-symbol <tvd-anuswara>
+collating-symbol <tvd-visarg>
+collating-symbol <t-halant>
+collating-symbol <t-lenghtmark>
+collating-symbol <t-ailenghtmark>
+
 # Ordre des symboles internes / Order of internal symbols
 #
 # SYMB. N°
@@ -1236,6 +1326,92 @@
 <gvd-chandrabindu>
 <gvd-visarg>
 <g-halant>
+#
+#<TELUGU>
+#
+# collation weights in order
+
+<tummu>
+<tvw-a>
+<tvw-aa>
+<tvw-i>
+<tvw-ii>
+<tvw-u>
+<tvw-uu>
+<tvw-vocalicr>
+<tvw-vocalicrr>
+<tvw-vocalicl>
+<tvw-vocalicll>
+<tvw-candrae>
+<tvw-shorte>
+<tvw-e>
+<tvw-ai>
+<tvw-shorto>
+<tvw-o>
+<tvw-au>
+<t-ka>
+<t-kha>
+<t-ga>
+<t-gga>
+<t-gha>
+<t-nga>
+<t-ca>
+<t-tsa>
+<t-cha>
+<t-ja>
+<t-dza>
+<t-jja>
+<t-jha>
+<t-nya>
+<t-tta>
+<t-ttha>
+<t-dda>
+<t-ddda>
+<t-ddha>
+<t-nna>
+<t-ta>
+<t-tha>
+<t-da>
+<t-dha>
+<t-na>
+<t-pa>
+<t-pha>
+<t-ba>
+<t-bba>
+<t-bha>
+<t-ma>
+<t-ya>
+<t-ra>
+<t-rra>
+<t-la>
+<t-lla>
+<t-va>
+<t-sha>
+<t-ssa>
+<t-sa>
+<t-ha>
+<t-avagrah>
+<tm-aa>
+<tm-i>
+<tm-ii>
+<tm-u>
+<tm-uu>
+<tm-vocalicr>
+<tm-vocalicrr>
+<tm-vocalicl>
+<tm-vocalicll>
+<tm-shorte>
+<tm-e>
+<tm-ai>
+<tm-shorto>
+<tm-o>
+<tm-au>
+<tvd-chandrabindu>
+<tvd-anuswara>
+<tvd-visarg>
+<t-halant>
+<t-lenghtmark>
+<t-ailenghtmark>
 
 order_start <SPECIAL>;forward;backward;forward;forward,position
 #
@@ -3201,6 +3377,103 @@
 <U0ACD> <g-halant>;<BAS>;<MIN>;IGNORE
 <U0ABC> IGNORE;<GNKT>;<MIN>;IGNORE
 
+order_start <TELUGU>;forward;forward;forward;forward,position
+<U0C66> <0>;"<BAS><NUM>";"<MIN><MIN>";IGNORE
+<U0C78> <0>;"<BAS><NUM>";"<MIN><MIN>";IGNORE
+<U0C67> <1>;"<BAS><NUM>";"<MIN><MIN>";IGNORE
+<U0C79> <1>;"<BAS><NUM>";"<MIN><MIN>";IGNORE
+<U0C7C> <1>;"<BAS><NUM>";"<MIN><MIN>";IGNORE
+<U0C68> <2>;"<BAS><NUM>";"<MIN><MIN>";IGNORE
+<U0C7A> <2>;"<BAS><NUM>";"<MIN><MIN>";IGNORE
+<U0C7D> <2>;"<BAS><NUM>";"<MIN><MIN>";IGNORE
+<U0C69> <3>;"<BAS><NUM>";"<MIN><MIN>";IGNORE
+<U0C7B> <3>;"<BAS><NUM>";"<MIN><MIN>";IGNORE
+<U0C7E> <3>;"<BAS><NUM>";"<MIN><MIN>";IGNORE
+<U0C6A> <4>;"<BAS><NUM>";"<MIN><MIN>";IGNORE
+<U0C6B> <5>;"<BAS><NUM>";"<MIN><MIN>";IGNORE
+<U0C6C> <6>;"<BAS><NUM>";"<MIN><MIN>";IGNORE
+<U0C6D> <7>;"<BAS><NUM>";"<MIN><MIN>";IGNORE
+<U0C6E> <8>;"<BAS><NUM>";"<MIN><MIN>";IGNORE
+<U0C6F> <9>;"<BAS><NUM>";"<MIN><MIN>";IGNORE
+<U0C7F> <tummu> ;<BAS>;<MIN>;IGNORE
+<U0C05> <tvw-a> ;<BAS>;<MIN>;IGNORE
+<U0C06> <tvw-aa> ;<BAS>;<MIN>;IGNORE
+<U0C07> <tvw-i> ;<BAS>;<MIN>;IGNORE
+<U0C08> <tvw-ii> ;<BAS>;<MIN>;IGNORE
+<U0C09> <tvw-u> ;<BAS>;<MIN>;IGNORE
+<U0C0A> <tvw-uu>;<BAS>;<MIN>;IGNORE
+<U0C0B> <tvw-vocalicr>;<BAS>;<MIN>;IGNORE
+<U0C60> <tvw-vocalicrr>;<BAS>;<MIN>;IGNORE
+<U0C0C> <tvw-vocalicl>;<BAS>;<MIN>;IGNORE
+<U0C61> <tvw-vocalicll>;<BAS>;<MIN>;IGNORE
+<U0C0D> <tvw-candrae>;<BAS>;<MIN>;IGNORE
+<U0C0E> <tvw-shorte>;<BAS>;<MIN>;IGNORE
+<U0C0F> <tvw-e>;<BAS>;<MIN>;IGNORE
+<U0C10> <tvw-ai>;<BAS>;<MIN>;IGNORE
+<U0C12> <tvw-shorto>;<BAS>;<MIN>;IGNORE
+<U0C13> <tvw-o>;<BAS>;<MIN>;IGNORE
+<U0C14> <tvw-au>;<BAS>;<MIN>;IGNORE
+<U0C15> <t-ka>;<BAS>;<MIN>;IGNORE
+<U0C16> <t-kha>;<BAS>;<MIN>;IGNORE
+<U0C17> <t-ga>;<BAS>;<MIN>;IGNORE
+<U0C7B> <t-gga>;<BAS>;<MIN>;IGNORE
+<U0C18> <t-gha>;<BAS>;<MIN>;IGNORE
+<U0C19> <t-nga>;<BAS>;<MIN>;IGNORE
+<U0C1A> <t-ca>;<BAS>;<MIN>;IGNORE
+<U0C58> <t-tsa>;<BAS>;<MIN>;IGNORE
+<U0C1B> <t-cha>;<BAS>;<MIN>;IGNORE
+<U0C1C> <t-ja>;<BAS>;<MIN>;IGNORE
+<U0C59> <t-dza>;<BAS>;<MIN>;IGNORE
+<U0C1D> <t-jha>;<BAS>;<MIN>;IGNORE
+<U0C1E> <t-nya>;<BAS>;<MIN>;IGNORE
+<U0C1F> <t-tta>;<BAS>;<MIN>;IGNORE
+<U0C20> <t-ttha>;<BAS>;<MIN>;IGNORE
+<U0C21> <t-dda>;<BAS>;<MIN>;IGNORE
+<U0C22> <t-ddha>;<BAS>;<MIN>;IGNORE
+<U0C23> <t-nna>;<BAS>;<MIN>;IGNORE
+<U0C24> <t-ta>;<BAS>;<MIN>;IGNORE
+<U0C25> <t-tha>;<BAS>;<MIN>;IGNORE
+<U0C26> <t-da>;<BAS>;<MIN>;IGNORE
+<U0C27> <t-dha>;<BAS>;<MIN>;IGNORE
+<U0C28> <t-na>;<BAS>;<MIN>;IGNORE
+<U0C2A> <t-pa>;<BAS>;<MIN>;IGNORE
+<U0C2B> <t-pha>;<BAS>;<MIN>;IGNORE
+<U0C2C> <t-ba>;<BAS>;<MIN>;IGNORE
+<U0C2D> <t-bha>;<BAS>;<MIN>;IGNORE
+<U0C2E> <t-ma>;<BAS>;<MIN>;IGNORE
+<U0C2F> <t-ya>;<BAS>;<MIN>;IGNORE
+<U0C30> <t-ra>;<BAS>;<MIN>;IGNORE
+<U0C31> <t-rra>;<BAS>;<MIN>;IGNORE
+<U0C32> <t-la>;<BAS>;<MIN>;IGNORE
+<U0C33> <t-lla>;<BAS>;<MIN>;IGNORE
+<U0C35> <t-va>;<BAS>;<MIN>;IGNORE
+<U0C36> <t-sha>;<BAS>;<MIN>;IGNORE
+<U0C37> <t-ssa>;<BAS>;<MIN>;IGNORE
+<U0C38> <t-sa>;<BAS>;<MIN>;IGNORE
+<U0C39> <t-ha>;<BAS>;<MIN>;IGNORE
+<U0C3D> <t-avagrah>;<BAS>;<MIN>;IGNORE
+<U0C3E> <tm-aa>;<BAS>;<MIN>;IGNORE
+<U0C3F> <tm-i>;<BAS>;<MIN>;IGNORE
+<U0C40> <tm-ii>;<BAS>;<MIN>;IGNORE
+<U0C41> <tm-u>;<BAS>;<MIN>;IGNORE
+<U0C42> <tm-uu>;<BAS>;<MIN>;IGNORE
+<U0C43> <tm-vocalicr>;<BAS>;<MIN>;IGNORE
+<U0C44> <tm-vocalicrr>;<BAS>;<MIN>;IGNORE
+<U0C62> <tm-vocalicl>;<BAS>;<MIN>;IGNORE
+<U0C63> <tm-vocalicll>;<BAS>;<MIN>;IGNORE
+<U0C46>  <tm-shorte>;<BAS>;<MIN>;IGNORE
+<U0C47> <tm-e>;<BAS>;<MIN>;IGNORE
+<U0C48> <tm-ai>;<BAS>;<MIN>;IGNORE
+<U0C4A> <tm-shorto>;<BAS>;<MIN>;IGNORE
+<U0C4B> <tm-o>;<BAS>;<MIN>;IGNORE
+<U0C4C> <tm-au>;<BAS>;<MIN>;IGNORE
+<U0C01> <tvd-chandrabindu>;<BAS>;<MIN>;IGNORE
+<U0C02> <tvd-anuswara>;<BAS>;<MIN>;IGNORE
+<U0C03> <tvd-visarg>;<BAS>;<MIN>;IGNORE
+<U0C4D> <t-halant>;<BAS>;<MIN>;IGNORE
+<U0C55> <t-lenghtmark>;<BAS>;<MIN>;IGNORE
+<U0C56> <t-ailenghtmark>;<BAS>;<MIN>;IGNORE
+
 order_end
 
 END LC_COLLATE

Modified: fsf/trunk/libc/nss/getent.c
==============================================================================
--- fsf/trunk/libc/nss/getent.c (original)
+++ fsf/trunk/libc/nss/getent.c Thu May 15 00:06:29 2008
@@ -337,6 +337,22 @@
 		sockstr = "DGRAM";
 	      else if (runp->ai_socktype == SOCK_RAW)
 		sockstr = "RAW";
+#ifdef SOCK_SEQPACKET
+	      else if (runp->ai_socktype == SOCK_SEQPACKET)
+		sockstr = "SEQPACKET";
+#endif
+#ifdef SOCK_RDM
+	      else if (runp->ai_socktype == SOCK_RDM)
+		sockstr = "RDM";
+#endif
+#ifdef SOCK_DCCP
+	      else if (runp->ai_socktype == SOCK_DCCP)
+		sockstr = "DCCP";
+#endif
+#ifdef SOCK_PACKET
+	      else if (runp->ai_socktype == SOCK_PACKET)
+		sockstr = "PACKET";
+#endif
 	      else
 		{
 		  snprintf (sockbuf, sizeof (sockbuf), "%d",

Modified: fsf/trunk/libc/posix/regcomp.c
==============================================================================
--- fsf/trunk/libc/posix/regcomp.c (original)
+++ fsf/trunk/libc/posix/regcomp.c Thu May 15 00:06:29 2008
@@ -1038,7 +1038,9 @@
 	  case BUF_LAST:
 	    break;
 	  default:
-	    /* Word anchors etc. cannot be handled.  */
+	    /* Word anchors etc. cannot be handled.  It's okay to test
+	       opr.ctx_type since constraints (for all DFA nodes) are
+	       created by ORing one or more opr.ctx_type values.  */
 	    return;
 	  }
 	break;
@@ -1318,6 +1320,8 @@
       node->node_idx = re_dfa_add_node (dfa, node->token);
       if (BE (node->node_idx == -1, 0))
         return REG_ESPACE;
+      if (node->token.type == ANCHOR)
+        dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type;
     }
   return REG_NOERROR;
 }
@@ -1446,22 +1450,17 @@
 	     destination.  */
 	  org_dest = dfa->edests[org_node].elems[0];
 	  re_node_set_empty (dfa->edests + clone_node);
-	  if (dfa->nodes[org_node].type == ANCHOR)
+	  /* If the node is root_node itself, it means the epsilon clsoure
+	     has a loop.   Then tie it to the destination of the root_node.  */
+	  if (org_node == root_node && clone_node != org_node)
 	    {
-	      /* In case of the node has another constraint, append it.  */
-	      if (org_node == root_node && clone_node != org_node)
-		{
-		  /* ...but if the node is root_node itself, it means the
-		     epsilon closure have a loop, then tie it to the
-		     destination of the root_node.  */
-		  ret = re_node_set_insert (dfa->edests + clone_node,
-					    org_dest);
-		  if (BE (ret < 0, 0))
-		    return REG_ESPACE;
-		  break;
-		}
-	      constraint |= dfa->nodes[org_node].opr.ctx_type;
+	      ret = re_node_set_insert (dfa->edests + clone_node, org_dest);
+	      if (BE (ret < 0, 0))
+		return REG_ESPACE;
+	      break;
 	    }
+	  /* In case of the node has another constraint, add it.  */
+	  constraint |= dfa->nodes[org_node].constraint;
 	  clone_dest = duplicate_node (dfa, org_dest, constraint);
 	  if (BE (clone_dest == -1, 0))
 	    return REG_ESPACE;
@@ -1479,7 +1478,7 @@
 	  clone_dest = search_duplicated_node (dfa, org_dest, constraint);
 	  if (clone_dest == -1)
 	    {
-	      /* There are no such a duplicated node, create a new one.  */
+	      /* There is no such duplicated node, create a new one.  */
 	      reg_errcode_t err;
 	      clone_dest = duplicate_node (dfa, org_dest, constraint);
 	      if (BE (clone_dest == -1, 0))
@@ -1494,7 +1493,7 @@
 	    }
 	  else
 	    {
-	      /* There are a duplicated node which satisfy the constraint,
+	      /* There is a duplicated node which satisfies the constraint,
 		 use it to avoid infinite loop.  */
 	      ret = re_node_set_insert (dfa->edests + clone_node, clone_dest);
 	      if (BE (ret < 0, 0))
@@ -1543,8 +1542,7 @@
   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].constraint |= dfa->nodes[org_idx].constraint;
       dfa->nodes[dup_idx].duplicated = 1;
 
       /* Store the index of the original node.  */
@@ -1624,7 +1622,6 @@
 calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, int node, int root)
 {
   reg_errcode_t err;
-  unsigned int constraint;
   int i, incomplete;
   re_node_set eclosure;
   incomplete = 0;
@@ -1636,15 +1633,14 @@
      We reference this value to avoid infinite loop.  */
   dfa->eclosures[node].nelem = -1;
 
-  constraint = ((dfa->nodes[node].type == ANCHOR)
-		? dfa->nodes[node].opr.ctx_type : 0);
-  /* If the current node has constraints, duplicate all nodes.
-     Since they must inherit the constraints.  */
-  if (constraint
+  /* If the current node has constraints, duplicate all nodes
+     since they must inherit the constraints.  */
+  if (dfa->nodes[node].constraint
       && dfa->edests[node].nelem
       && !dfa->nodes[dfa->edests[node].elems[0]].duplicated)
     {
-      err = duplicate_node_closure (dfa, node, node, node, constraint);
+      err = duplicate_node_closure (dfa, node, node, node,
+				    dfa->nodes[node].constraint);
       if (BE (err != REG_NOERROR, 0))
 	return err;
     }

Modified: fsf/trunk/libc/posix/regex_internal.c
==============================================================================
--- fsf/trunk/libc/posix/regex_internal.c (original)
+++ fsf/trunk/libc/posix/regex_internal.c Thu May 15 00:06:29 2008
@@ -1665,11 +1665,9 @@
 
   for (i = 0 ; i < nodes->nelem ; i++)
     {
-      unsigned int constraint = 0;
       re_token_t *node = dfa->nodes + nodes->elems[i];
       re_token_type_t type = node->type;
-      if (node->constraint)
-	constraint = node->constraint;
+      unsigned int constraint = node->constraint;
 
       if (type == CHARACTER && !constraint)
 	continue;
@@ -1682,8 +1680,6 @@
 	newstate->halt = 1;
       else if (type == OP_BACK_REF)
 	newstate->has_backref = 1;
-      else if (type == ANCHOR)
-	constraint = node->opr.ctx_type;
 
       if (constraint)
 	{

Modified: fsf/trunk/libc/posix/tst-rfc3484-2.c
==============================================================================
--- fsf/trunk/libc/posix/tst-rfc3484-2.c (original)
+++ fsf/trunk/libc/posix/tst-rfc3484-2.c Thu May 15 00:06:29 2008
@@ -18,22 +18,33 @@
   *in6ai = NULL;
   *in6ailen = 0;
 }
+
 void
 attribute_hidden
 __check_native (uint32_t a1_index, int *a1_native,
 		uint32_t a2_index, int *a2_native)
 {
 }
+
 int
+attribute_hidden
 __idna_to_ascii_lz (const char *input, char **output, int flags)
 {
   return 0;
 }
+
 int
+attribute_hidden
 __idna_to_unicode_lzlz (const char *input, char **output, int flags)
 {
   *output = NULL;
   return 0;
+}
+
+void
+attribute_hidden
+_res_hconf_init (void)
+{
 }
 
 #include "../sysdeps/posix/getaddrinfo.c"

Modified: fsf/trunk/libc/posix/tst-rfc3484-3.c
==============================================================================
--- fsf/trunk/libc/posix/tst-rfc3484-3.c (original)
+++ fsf/trunk/libc/posix/tst-rfc3484-3.c Thu May 15 00:06:29 2008
@@ -18,22 +18,33 @@
   *in6ai = NULL;
   *in6ailen = 0;
 }
+
 void
 attribute_hidden
 __check_native (uint32_t a1_index, int *a1_native,
 		uint32_t a2_index, int *a2_native)
 {
 }
+
 int
+attribute_hidden
 __idna_to_ascii_lz (const char *input, char **output, int flags)
 {
   return 0;
 }
+
 int
+attribute_hidden
 __idna_to_unicode_lzlz (const char *input, char **output, int flags)
 {
   *output = NULL;
   return 0;
+}
+
+void
+attribute_hidden
+_res_hconf_init (void)
+{
 }
 
 #include "../sysdeps/posix/getaddrinfo.c"

Modified: fsf/trunk/libc/posix/tst-rfc3484.c
==============================================================================
--- fsf/trunk/libc/posix/tst-rfc3484.c (original)
+++ fsf/trunk/libc/posix/tst-rfc3484.c Thu May 15 00:06:29 2008
@@ -18,22 +18,33 @@
   *in6ai = NULL;
   *in6ailen = 0;
 }
+
 void
 attribute_hidden
 __check_native (uint32_t a1_index, int *a1_native,
 		uint32_t a2_index, int *a2_native)
 {
 }
+
 int
+attribute_hidden
 __idna_to_ascii_lz (const char *input, char **output, int flags)
 {
   return 0;
 }
+
 int
+attribute_hidden
 __idna_to_unicode_lzlz (const char *input, char **output, int flags)
 {
   *output = NULL;
   return 0;
+}
+
+void
+attribute_hidden
+_res_hconf_init (void)
+{
 }
 
 #include "../sysdeps/posix/getaddrinfo.c"

Modified: fsf/trunk/libc/string/Makefile
==============================================================================
--- fsf/trunk/libc/string/Makefile (original)
+++ fsf/trunk/libc/string/Makefile Thu May 15 00:06:29 2008
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-2002, 2005, 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1991-2002, 2005-2007, 2008 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
@@ -54,8 +54,9 @@
 		   bug-strncat1 bug-strspn1 bug-strpbrk1 tst-bswap	\
 		   tst-strtok tst-strxfrm bug-strcoll1 tst-strfry	\
 		   bug-strtok1 $(addprefix test-,$(strop-tests))	\
-		   bug-envz1 tst-strxfrm2
-distribute	:= memcopy.h pagecopy.h tst-svc.expect test-string.h
+		   bug-envz1 tst-strxfrm2 tst-endian
+distribute	:= memcopy.h pagecopy.h tst-svc.expect test-string.h	\
+		   str-two-way.h
 
 
 include ../Rules

Modified: fsf/trunk/libc/string/endian.h
==============================================================================
--- fsf/trunk/libc/string/endian.h (original)
+++ fsf/trunk/libc/string/endian.h Thu May 15 00:06:29 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1996, 1997, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1996, 1997, 2000, 2008 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
@@ -55,4 +55,40 @@
 # define __LONG_LONG_PAIR(HI, LO) HI, LO
 #endif
 
+
+/* Conversion interfaces.  */
+#include <bits/byteswap.h>
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# define htobe16(x) __bswap_16 (x)
+# define htole16(x) (x)
+# define be16toh(x) __bswap_16 (x)
+# define le16toh(x) (x)
+
+# define htobe32(x) __bswap_32 (x)
+# define htole32(x) (x)
+# define be32toh(x) __bswap_32 (x)
+# define le32toh(x) (x)
+
+# define htobe64(x) __bswap_64 (x)
+# define htole64(x) (x)
+# define be64toh(x) __bswap_64 (x)
+# define le64toh(x) (x)
+#else
+# define htobe16(x) (x)
+# define htole16(x) __bswap_16 (x)
+# define be16toh(x) (x)
+# define le16toh(x) __bswap_16 (x)
+
+# define htobe32(x) (x)
+# define htole32(x) __bswap_32 (x)
+# define be32toh(x) (x)
+# define le32toh(x) __bswap_32 (x)
+
+# define htobe64(x) (x)
+# define htole64(x) __bswap_64 (x)
+# define be64toh(x) (x)
+# define le64toh(x) __bswap_64 (x)
+#endif
+
 #endif	/* endian.h */

Modified: fsf/trunk/libc/string/memmem.c
==============================================================================
--- fsf/trunk/libc/string/memmem.c (original)
+++ fsf/trunk/libc/string/memmem.c Thu May 15 00:06:29 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,92,93,94,96,97,98,2000,2004 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,94,96,97,98,2000,2004,2008 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,26 +16,36 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#include <stddef.h>
+/* This particular implementation was written by Eric Blake, 2008.  */
+
+#ifndef _LIBC
+# include <config.h>
+#endif
+
+/* Specification of memmem.  */
 #include <string.h>
 
 #ifndef _LIBC
 # define __builtin_expect(expr, val)   (expr)
 #endif
 
+#define RETURN_TYPE void *
+#define AVAILABLE(h, h_l, j, n_l) ((j) <= (h_l) - (n_l))
+#include "str-two-way.h"
+
 #undef memmem
 
-/* Return the first occurrence of NEEDLE in HAYSTACK.  */
+/* Return the first occurrence of NEEDLE in HAYSTACK.  Return HAYSTACK
+   if NEEDLE_LEN is 0, otherwise NULL if NEEDLE is not found in
+   HAYSTACK.  */
 void *
-memmem (haystack, haystack_len, needle, needle_len)
-     const void *haystack;
-     size_t haystack_len;
-     const void *needle;
-     size_t needle_len;
+memmem (const void *haystack_start, size_t haystack_len,
+	const void *needle_start, size_t needle_len)
 {
-  const char *begin;
-  const char *const last_possible
-    = (const char *) haystack + haystack_len - needle_len;
+  /* Abstract memory is considered to be an array of 'unsigned char' values,
+     not an array of 'char' values.  See ISO C 99 section 6.2.6.1.  */
+  const unsigned char *haystack = (const unsigned char *) haystack_start;
+  const unsigned char *needle = (const unsigned char *) needle_start;
 
   if (needle_len == 0)
     /* The first occurrence of the empty string is deemed to occur at
@@ -47,12 +57,22 @@
   if (__builtin_expect (haystack_len < needle_len, 0))
     return NULL;
 
-  for (begin = (const char *) haystack; begin <= last_possible; ++begin)
-    if (begin[0] == ((const char *) needle)[0] &&
-	!memcmp ((const void *) &begin[1],
-		 (const void *) ((const char *) needle + 1),
-		 needle_len - 1))
-      return (void *) begin;
+  /* Use optimizations in memchr when possible, to reduce the search
+     size of haystack using a linear algorithm with a smaller
+     coefficient.  However, avoid memchr for long needles, since we
+     can often achieve sublinear performance.  */
+  if (needle_len < LONG_NEEDLE_THRESHOLD)
+    {
+      haystack = memchr (haystack, *needle, haystack_len);
+      if (!haystack || __builtin_expect (needle_len == 1, 0))
+	return (void *) haystack;
+      haystack_len -= haystack - (const unsigned char *) haystack_start;
+      if (haystack_len < needle_len)
+	return NULL;
+      return two_way_short_needle (haystack, haystack_len, needle, needle_len);
+    }
+  else
+    return two_way_long_needle (haystack, haystack_len, needle, needle_len);
+}
 
-  return NULL;
-}
+#undef LONG_NEEDLE_THRESHOLD

Added: fsf/trunk/libc/string/str-two-way.h
==============================================================================
--- fsf/trunk/libc/string/str-two-way.h (added)
+++ fsf/trunk/libc/string/str-two-way.h Thu May 15 00:06:29 2008
@@ -1,0 +1,430 @@
+/* Byte-wise substring search, using the Two-Way algorithm.
+   Copyright (C) 2008 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Eric Blake <ebb9@xxxxxxx>, 2008.
+
+   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.  */
+
+/* Before including this file, you need to include <string.h> (and
+   <config.h> before that, if not part of libc), and define:
+     RESULT_TYPE             A macro that expands to the return type.
+     AVAILABLE(h, h_l, j, n_l)
+			     A macro that returns nonzero if there are
+			     at least N_L bytes left starting at H[J].
+			     H is 'unsigned char *', H_L, J, and N_L
+			     are 'size_t'; H_L is an lvalue.  For
+			     NUL-terminated searches, H_L can be
+			     modified each iteration to avoid having
+			     to compute the end of H up front.
+
+  For case-insensitivity, you may optionally define:
+     CMP_FUNC(p1, p2, l)     A macro that returns 0 iff the first L
+			     characters of P1 and P2 are equal.
+     CANON_ELEMENT(c)        A macro that canonicalizes an element right after
+			     it has been fetched from one of the two strings.
+			     The argument is an 'unsigned char'; the result
+			     must be an 'unsigned char' as well.
+
+  This file undefines the macros documented above, and defines
+  LONG_NEEDLE_THRESHOLD.
+*/
+
+#include <limits.h>
+#include <stdint.h>
+
+/* We use the Two-Way string matching algorithm, which guarantees
+   linear complexity with constant space.  Additionally, for long
+   needles, we also use a bad character shift table similar to the
+   Boyer-Moore algorithm to achieve improved (potentially sub-linear)
+   performance.
+
+   See http://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260
+   and http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm
+*/
+
+/* Point at which computing a bad-byte shift table is likely to be
+   worthwhile.  Small needles should not compute a table, since it
+   adds (1 << CHAR_BIT) + NEEDLE_LEN computations of preparation for a
+   speedup no greater than a factor of NEEDLE_LEN.  The larger the
+   needle, the better the potential performance gain.  On the other
+   hand, on non-POSIX systems with CHAR_BIT larger than eight, the
+   memory required for the table is prohibitive.  */
+#if CHAR_BIT < 10
+# define LONG_NEEDLE_THRESHOLD 32U
+#else
+# define LONG_NEEDLE_THRESHOLD SIZE_MAX
+#endif
+
+#ifndef MAX
+# define MAX(a, b) ((a < b) ? (b) : (a))
+#endif
+
+#ifndef CANON_ELEMENT
+# define CANON_ELEMENT(c) c
+#endif
+#ifndef CMP_FUNC
+# define CMP_FUNC memcmp
+#endif
+
+/* Perform a critical factorization of NEEDLE, of length NEEDLE_LEN.
+   Return the index of the first byte in the right half, and set
+   *PERIOD to the global period of the right half.
+
+   The global period of a string is the smallest index (possibly its
+   length) at which all remaining bytes in the string are repetitions
+   of the prefix (the last repetition may be a subset of the prefix).
+
+   When NEEDLE is factored into two halves, a local period is the
+   length of the smallest word that shares a suffix with the left half
+   and shares a prefix with the right half.  All factorizations of a
+   non-empty NEEDLE have a local period of at least 1 and no greater
+   than NEEDLE_LEN.
+
+   A critical factorization has the property that the local period
+   equals the global period.  All strings have at least one critical
+   factorization with the left half smaller than the global period.
+
+   Given an ordered alphabet, a critical factorization can be computed
+   in linear time, with 2 * NEEDLE_LEN comparisons, by computing the
+   larger of two ordered maximal suffixes.  The ordered maximal
+   suffixes are determined by lexicographic comparison of
+   periodicity.  */
+static size_t
+critical_factorization (const unsigned char *needle, size_t needle_len,
+			size_t *period)
+{
+  /* Index of last byte of left half, or SIZE_MAX.  */
+  size_t max_suffix, max_suffix_rev;
+  size_t j; /* Index into NEEDLE for current candidate suffix.  */
+  size_t k; /* Offset into current period.  */
+  size_t p; /* Intermediate period.  */
+  unsigned char a, b; /* Current comparison bytes.  */
+
+  /* Invariants:
+     0 <= j < NEEDLE_LEN - 1
+     -1 <= max_suffix{,_rev} < j (treating SIZE_MAX as if it were signed)
+     min(max_suffix, max_suffix_rev) < global period of NEEDLE
+     1 <= p <= global period of NEEDLE
+     p == global period of the substring NEEDLE[max_suffix{,_rev}+1...j]
+     1 <= k <= p
+  */
+
+  /* Perform lexicographic search.  */
+  max_suffix = SIZE_MAX;
+  j = 0;
+  k = p = 1;
+  while (j + k < needle_len)
+    {
+      a = CANON_ELEMENT (needle[j + k]);
+      b = CANON_ELEMENT (needle[max_suffix + k]);
+      if (a < b)
+	{
+	  /* Suffix is smaller, period is entire prefix so far.  */
+	  j += k;
+	  k = 1;
+	  p = j - max_suffix;
+	}
+      else if (a == b)
+	{
+	  /* Advance through repetition of the current period.  */
+	  if (k != p)
+	    ++k;
+	  else
+	    {
+	      j += p;
+	      k = 1;
+	    }
+	}
+      else /* b < a */
+	{
+	  /* Suffix is larger, start over from current location.  */
+	  max_suffix = j++;
+	  k = p = 1;
+	}
+    }
+  *period = p;
+
+  /* Perform reverse lexicographic search.  */
+  max_suffix_rev = SIZE_MAX;
+  j = 0;
+  k = p = 1;
+  while (j + k < needle_len)
+    {
+      a = CANON_ELEMENT (needle[j + k]);
+      b = CANON_ELEMENT (needle[max_suffix_rev + k]);
+      if (b < a)
+	{
+	  /* Suffix is smaller, period is entire prefix so far.  */
+	  j += k;
+	  k = 1;
+	  p = j - max_suffix_rev;
+	}
+      else if (a == b)
+	{
+	  /* Advance through repetition of the current period.  */
+	  if (k != p)
+	    ++k;
+	  else
+	    {
+	      j += p;
+	      k = 1;
+	    }
+	}
+      else /* a < b */
+	{
+	  /* Suffix is larger, start over from current location.  */
+	  max_suffix_rev = j++;
+	  k = p = 1;
+	}
+    }
+
+  /* Choose the longer suffix.  Return the first byte of the right
+     half, rather than the last byte of the left half.  */
+  if (max_suffix_rev + 1 < max_suffix + 1)
+    return max_suffix + 1;
+  *period = p;
+  return max_suffix_rev + 1;
+}
+
+/* Return the first location of non-empty NEEDLE within HAYSTACK, or
+   NULL.  HAYSTACK_LEN is the minimum known length of HAYSTACK.  This
+   method is optimized for NEEDLE_LEN < LONG_NEEDLE_THRESHOLD.
+   Performance is guaranteed to be linear, with an initialization cost
+   of 2 * NEEDLE_LEN comparisons.
+
+   If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at
+   most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching.
+   If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 *
+   HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching.  */
+static RETURN_TYPE
+two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
+		      const unsigned char *needle, size_t needle_len)
+{
+  size_t i; /* Index into current byte of NEEDLE.  */
+  size_t j; /* Index into current window of HAYSTACK.  */
+  size_t period; /* The period of the right half of needle.  */
+  size_t suffix; /* The index of the right half of needle.  */
+
+  /* Factor the needle into two halves, such that the left half is
+     smaller than the global period, and the right half is
+     periodic (with a period as large as NEEDLE_LEN - suffix).  */
+  suffix = critical_factorization (needle, needle_len, &period);
+
+  /* Perform the search.  Each iteration compares the right half
+     first.  */
+  if (CMP_FUNC (needle, needle + period, suffix) == 0)
+    {
+      /* Entire needle is periodic; a mismatch can only advance by the
+	 period, so use memory to avoid rescanning known occurrences
+	 of the period.  */
+      size_t memory = 0;
+      j = 0;
+      while (AVAILABLE (haystack, haystack_len, j, needle_len))
+	{
+	  /* Scan for matches in right half.  */
+	  i = MAX (suffix, memory);
+	  while (i < needle_len && (CANON_ELEMENT (needle[i])
+				    == CANON_ELEMENT (haystack[i + j])))
+	    ++i;
+	  if (needle_len <= i)
+	    {
+	      /* Scan for matches in left half.  */
+	      i = suffix - 1;
+	      while (memory < i + 1 && (CANON_ELEMENT (needle[i])
+					== CANON_ELEMENT (haystack[i + j])))
+		--i;
+	      if (i + 1 < memory + 1)
+		return (RETURN_TYPE) (haystack + j);
+	      /* No match, so remember how many repetitions of period
+		 on the right half were scanned.  */
+	      j += period;
+	      memory = needle_len - period;
+	    }
+	  else
+	    {
+	      j += i - suffix + 1;
+	      memory = 0;
+	    }
+	}
+    }
+  else
+    {
+      /* The two halves of needle are distinct; no extra memory is
+	 required, and any mismatch results in a maximal shift.  */
+      period = MAX (suffix, needle_len - suffix) + 1;
+      j = 0;
+      while (AVAILABLE (haystack, haystack_len, j, needle_len))
+	{
+	  /* Scan for matches in right half.  */
+	  i = suffix;
+	  while (i < needle_len && (CANON_ELEMENT (needle[i])
+				    == CANON_ELEMENT (haystack[i + j])))
+	    ++i;
+	  if (needle_len <= i)
+	    {
+	      /* Scan for matches in left half.  */
+	      i = suffix - 1;
+	      while (i != SIZE_MAX && (CANON_ELEMENT (needle[i])
+				       == CANON_ELEMENT (haystack[i + j])))
+		--i;
+	      if (i == SIZE_MAX)
+		return (RETURN_TYPE) (haystack + j);
+	      j += period;
+	    }
+	  else
+	    j += i - suffix + 1;
+	}
+    }
+  return NULL;
+}
+
+/* Return the first location of non-empty NEEDLE within HAYSTACK, or
+   NULL.  HAYSTACK_LEN is the minimum known length of HAYSTACK.  This
+   method is optimized for LONG_NEEDLE_THRESHOLD <= NEEDLE_LEN.
+   Performance is guaranteed to be linear, with an initialization cost
+   of 3 * NEEDLE_LEN + (1 << CHAR_BIT) operations.
+
+   If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at
+   most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching,
+   and sublinear performance O(HAYSTACK_LEN / NEEDLE_LEN) is possible.
+   If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 *
+   HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and
+   sublinear performance is not possible.  */
+static RETURN_TYPE
+two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
+		     const unsigned char *needle, size_t needle_len)
+{
+  size_t i; /* Index into current byte of NEEDLE.  */
+  size_t j; /* Index into current window of HAYSTACK.  */
+  size_t period; /* The period of the right half of needle.  */
+  size_t suffix; /* The index of the right half of needle.  */
+  size_t shift_table[1U << CHAR_BIT]; /* See below.  */
+
+  /* Factor the needle into two halves, such that the left half is
+     smaller than the global period, and the right half is
+     periodic (with a period as large as NEEDLE_LEN - suffix).  */
+  suffix = critical_factorization (needle, needle_len, &period);
+
+  /* Populate shift_table.  For each possible byte value c,
+     shift_table[c] is the distance from the last occurrence of c to
+     the end of NEEDLE, or NEEDLE_LEN if c is absent from the NEEDLE.
+     shift_table[NEEDLE[NEEDLE_LEN - 1]] contains the only 0.  */
+  for (i = 0; i < 1U << CHAR_BIT; i++)
+    shift_table[i] = needle_len;
+  for (i = 0; i < needle_len; i++)
+    shift_table[CANON_ELEMENT (needle[i])] = needle_len - i - 1;
+
+  /* Perform the search.  Each iteration compares the right half
+     first.  */
+  if (CMP_FUNC (needle, needle + period, suffix) == 0)
+    {
+      /* Entire needle is periodic; a mismatch can only advance by the
+	 period, so use memory to avoid rescanning known occurrences
+	 of the period.  */
+      size_t memory = 0;
+      size_t shift;
+      j = 0;
+      while (AVAILABLE (haystack, haystack_len, j, needle_len))
+	{
+	  /* Check the last byte first; if it does not match, then
+	     shift to the next possible match location.  */
+	  shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])];
+	  if (0 < shift)
+	    {
+	      if (memory && shift < period)
+		{
+		  /* Since needle is periodic, but the last period has
+		     a byte out of place, there can be no match until
+		     after the mismatch.  */
+		  shift = needle_len - period;
+		  memory = 0;
+		}
+	      j += shift;
+	      continue;
+	    }
+	  /* Scan for matches in right half.  The last byte has
+	     already been matched, by virtue of the shift table.  */
+	  i = MAX (suffix, memory);
+	  while (i < needle_len - 1 && (CANON_ELEMENT (needle[i])
+					== CANON_ELEMENT (haystack[i + j])))
+	    ++i;
+	  if (needle_len - 1 <= i)
+	    {
+	      /* Scan for matches in left half.  */
+	      i = suffix - 1;
+	      while (memory < i + 1 && (CANON_ELEMENT (needle[i])
+					== CANON_ELEMENT (haystack[i + j])))
+		--i;
+	      if (i + 1 < memory + 1)
+		return (RETURN_TYPE) (haystack + j);
+	      /* No match, so remember how many repetitions of period
+		 on the right half were scanned.  */
+	      j += period;
+	      memory = needle_len - period;
+	    }
+	  else
+	    {
+	      j += i - suffix + 1;
+	      memory = 0;
+	    }
+	}
+    }
+  else
+    {
+      /* The two halves of needle are distinct; no extra memory is
+	 required, and any mismatch results in a maximal shift.  */
+      size_t shift;
+      period = MAX (suffix, needle_len - suffix) + 1;
+      j = 0;
+      while (AVAILABLE (haystack, haystack_len, j, needle_len))
+	{
+	  /* Check the last byte first; if it does not match, then
+	     shift to the next possible match location.  */
+	  shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])];
+	  if (0 < shift)
+	    {
+	      j += shift;
+	      continue;
+	    }
+	  /* Scan for matches in right half.  The last byte has
+	     already been matched, by virtue of the shift table.  */
+	  i = suffix;
+	  while (i < needle_len - 1 && (CANON_ELEMENT (needle[i])
+					== CANON_ELEMENT (haystack[i + j])))
+	    ++i;
+	  if (needle_len - 1 <= i)
+	    {
+	      /* Scan for matches in left half.  */
+	      i = suffix - 1;
+	      while (i != SIZE_MAX && (CANON_ELEMENT (needle[i])
+				       == CANON_ELEMENT (haystack[i + j])))
+		--i;
+	      if (i == SIZE_MAX)
+		return (RETURN_TYPE) (haystack + j);
+	      j += period;
+	    }
+	  else
+	    j += i - suffix + 1;
+	}
+    }
+  return NULL;
+}
+
+#undef AVAILABLE
+#undef CANON_ELEMENT
+#undef CMP_FUNC
+#undef MAX
+#undef RETURN_TYPE

Modified: fsf/trunk/libc/string/strcasestr.c
==============================================================================
--- fsf/trunk/libc/string/strcasestr.c (original)
+++ fsf/trunk/libc/string/strcasestr.c Thu May 15 00:06:29 2008
@@ -1,5 +1,5 @@
 /* Return the offset of one string within another.
-   Copyright (C) 1994, 1996-2000, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1994, 1996-2000, 2004, 2008 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
@@ -30,113 +30,71 @@
 # include <config.h>
 #endif
 
+/* Specification.  */
+#include <string.h>
+
 #include <ctype.h>
+#include <stdbool.h>
+#include <strings.h>
 
-#if defined _LIBC || defined HAVE_STRING_H
-# include <string.h>
-#endif
+#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
 
-#ifdef _LIBC
-# include <locale/localeinfo.h>
-# define TOLOWER(c) __tolower_l ((unsigned char) c, loc)
-#else
-# define TOLOWER(c) _tolower (c)
-#endif
-
-typedef unsigned chartype;
+/* Two-Way algorithm.  */
+#define RETURN_TYPE char *
+#define AVAILABLE(h, h_l, j, n_l)			\
+  (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l))	\
+   && ((h_l) = (j) + (n_l)))
+#define CANON_ELEMENT(c) TOLOWER (c)
+#define CMP_FUNC(p1, p2, l)				\
+  strncasecmp ((const char *) (p1), (const char *) (p2), l)
+#include "str-two-way.h"
 
 #undef strcasestr
 #undef __strcasestr
 
+/* Find the first occurrence of NEEDLE in HAYSTACK, using
+   case-insensitive comparison.  This function gives unspecified
+   results in multibyte locales.  */
 char *
-__strcasestr (phaystack, pneedle)
-     const char *phaystack;
-     const char *pneedle;
+__strcasestr (const char *haystack_start, const char *needle_start)
 {
-  register const unsigned char *haystack, *needle;
-  register chartype b, c;
-#ifdef _LIBC
-  __locale_t loc = _NL_CURRENT_LOCALE;
-#endif
+  const char *haystack = haystack_start;
+  const char *needle = needle_start;
+  size_t needle_len; /* Length of NEEDLE.  */
+  size_t haystack_len; /* Known minimum length of HAYSTACK.  */
+  bool ok = true; /* True if NEEDLE is prefix of HAYSTACK.  */
 
-  haystack = (const unsigned char *) phaystack;
-  needle = (const unsigned char *) pneedle;
+  /* Determine length of NEEDLE, and in the process, make sure
+     HAYSTACK is at least as long (no point processing all of a long
+     NEEDLE if HAYSTACK is too short).  */
+  while (*haystack && *needle)
+    {
+      ok &= (TOLOWER ((unsigned char) *haystack)
+	     == TOLOWER ((unsigned char) *needle));
+      haystack++;
+      needle++;
+    }
+  if (*needle)
+    return NULL;
+  if (ok)
+    return (char *) haystack_start;
+  needle_len = needle - needle_start;
+  haystack = haystack_start + 1;
+  haystack_len = needle_len - 1;
 
-  b = TOLOWER (*needle);
-  if (b != '\0')
-    {
-      haystack--;				/* possible ANSI violation */
-      do
-	{
-	  c = *++haystack;
-	  if (c == '\0')
-	    goto ret0;
-	}
-      while (TOLOWER (c) != (int) b);
-
-      c = TOLOWER (*++needle);
-      if (c == '\0')
-	goto foundneedle;
-      ++needle;
-      goto jin;
-
-      for (;;)
-        {
-          register chartype a;
-	  register const unsigned char *rhaystack, *rneedle;
-
-	  do
-	    {
-	      a = *++haystack;
-	      if (a == '\0')
-		goto ret0;
-	      if (TOLOWER (a) == (int) b)
-		break;
-	      a = *++haystack;
-	      if (a == '\0')
-		goto ret0;
-shloop:
-	      ;
-	    }
-          while (TOLOWER (a) != (int) b);
-
-jin:	  a = *++haystack;
-	  if (a == '\0')
-	    goto ret0;
-
-	  if (TOLOWER (a) != (int) c)
-	    goto shloop;
-
-	  rhaystack = haystack-- + 1;
-	  rneedle = needle;
-	  a = TOLOWER (*rneedle);
-
-	  if (TOLOWER (*rhaystack) == (int) a)
-	    do
-	      {
-		if (a == '\0')
-		  goto foundneedle;
-		++rhaystack;
-		a = TOLOWER (*++needle);
-		if (TOLOWER (*rhaystack) != (int) a)
-		  break;
-		if (a == '\0')
-		  goto foundneedle;
-		++rhaystack;
-		a = TOLOWER (*++needle);
-	      }
-	    while (TOLOWER (*rhaystack) == (int) a);
-
-	  needle = rneedle;		/* took the register-poor approach */
-
-	  if (a == '\0')
-	    break;
-        }
-    }
-foundneedle:
-  return (char*) haystack;
-ret0:
-  return 0;
+  /* Perform the search.  Abstract memory is considered to be an array
+     of 'unsigned char' values, not an array of 'char' values.  See
+     ISO C 99 section 6.2.6.1.  */
+  if (needle_len < LONG_NEEDLE_THRESHOLD)
+    return two_way_short_needle ((const unsigned char *) haystack,
+				 haystack_len,
+				 (const unsigned char *) needle_start,
+				 needle_len);
+  return two_way_long_needle ((const unsigned char *) haystack, haystack_len,
+			      (const unsigned char *) needle_start,
+			      needle_len);
 }
 
+#undef LONG_NEEDLE_THRESHOLD
+
 weak_alias (__strcasestr, strcasestr)

Modified: fsf/trunk/libc/string/strstr.c
==============================================================================
--- fsf/trunk/libc/string/strstr.c (original)
+++ fsf/trunk/libc/string/strstr.c Thu May 15 00:06:29 2008
@@ -1,5 +1,5 @@
 /* Return the offset of one string within another.
-   Copyright (C) 1994,1996,1997,2000,2001,2003 Free Software Foundation, Inc.
+   Copyright (C) 1994,1996,1997,2000,2001,2003,2008 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
@@ -17,107 +17,71 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-/*
- * My personal strstr() implementation that beats most other algorithms.
- * Until someone tells me otherwise, I assume that this is the
- * fastest implementation of strstr() in C.
- * I deliberately chose not to comment it.  You should have at least
- * as much fun trying to understand it, as I had to write it :-).
- *
- * Stephen R. van den Berg, berg@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx	*/
+/* This particular implementation was written by Eric Blake, 2008.  */
 
-#if HAVE_CONFIG_H
+#ifndef _LIBC
 # include <config.h>
 #endif
 
-#if defined _LIBC || defined HAVE_STRING_H
-# include <string.h>
+/* Specification of strstr.  */
+#include <string.h>
+
+#include <stdbool.h>
+
+#ifndef _LIBC
+# define __builtin_expect(expr, val)   (expr)
 #endif
 
-typedef unsigned chartype;
+#define RETURN_TYPE char *
+#define AVAILABLE(h, h_l, j, n_l)			\
+  (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l))	\
+   && ((h_l) = (j) + (n_l)))
+#include "str-two-way.h"
 
 #undef strstr
 
+/* Return the first occurrence of NEEDLE in HAYSTACK.  Return HAYSTACK
+   if NEEDLE is empty, otherwise NULL if NEEDLE is not found in
+   HAYSTACK.  */
 char *
-strstr (phaystack, pneedle)
-     const char *phaystack;
-     const char *pneedle;
+strstr (const char *haystack_start, const char *needle_start)
 {
-  const unsigned char *haystack, *needle;
-  chartype b;
-  const unsigned char *rneedle;
+  const char *haystack = haystack_start;
+  const char *needle = needle_start;
+  size_t needle_len; /* Length of NEEDLE.  */
+  size_t haystack_len; /* Known minimum length of HAYSTACK.  */
+  bool ok = true; /* True if NEEDLE is prefix of HAYSTACK.  */
 
-  haystack = (const unsigned char *) phaystack;
+  /* Determine length of NEEDLE, and in the process, make sure
+     HAYSTACK is at least as long (no point processing all of a long
+     NEEDLE if HAYSTACK is too short).  */
+  while (*haystack && *needle)
+    ok &= *haystack++ == *needle++;
+  if (*needle)
+    return NULL;
+  if (ok)
+    return (char *) haystack_start;
 
-  if ((b = *(needle = (const unsigned char *) pneedle)))
-    {
-      chartype c;
-      haystack--;		/* possible ANSI violation */
+  /* Reduce the size of haystack using strchr, since it has a smaller
+     linear coefficient than the Two-Way algorithm.  */
+  needle_len = needle - needle_start;
+  haystack = strchr (haystack_start + 1, *needle_start);
+  if (!haystack || __builtin_expect (needle_len == 1, 0))
+    return (char *) haystack;
+  needle -= needle_len;
+  haystack_len = (haystack > haystack_start + needle_len ? 1
+		  : needle_len + haystack_start - haystack);
 
-      {
-	chartype a;
-	do
-	  if (!(a = *++haystack))
-	    goto ret0;
-	while (a != b);
-      }
-
-      if (!(c = *++needle))
-	goto foundneedle;
-      ++needle;
-      goto jin;
-
-      for (;;)
-	{
-	  {
-	    chartype a;
-	    if (0)
-	    jin:{
-		if ((a = *++haystack) == c)
-		  goto crest;
-	      }
-	    else
-	      a = *++haystack;
-	    do
-	      {
-		for (; a != b; a = *++haystack)
-		  {
-		    if (!a)
-		      goto ret0;
-		    if ((a = *++haystack) == b)
-		      break;
-		    if (!a)
-		      goto ret0;
-		  }
-	      }
-	    while ((a = *++haystack) != c);
-	  }
-	crest:
-	  {
-	    chartype a;
-	    {
-	      const unsigned char *rhaystack;
-	      if (*(rhaystack = haystack-- + 1) == (a = *(rneedle = needle)))
-		do
-		  {
-		    if (!a)
-		      goto foundneedle;
-		    if (*++rhaystack != (a = *++needle))
-		      break;
-		    if (!a)
-		      goto foundneedle;
-		  }
-		while (*++rhaystack == (a = *++needle));
-	      needle = rneedle;	/* took the register-poor aproach */
-	    }
-	    if (!a)
-	      break;
-	  }
-	}
-    }
-foundneedle:
-  return (char *) haystack;
-ret0:
-  return 0;
+  /* Perform the search.  Abstract memory is considered to be an array
+     of 'unsigned char' values, not an array of 'char' values.  See
+     ISO C 99 section 6.2.6.1.  */
+  if (needle_len < LONG_NEEDLE_THRESHOLD)
+    return two_way_short_needle ((const unsigned char *) haystack,
+				 haystack_len,
+				 (const unsigned char *) needle, needle_len);
+  return two_way_long_needle ((const unsigned char *) haystack, haystack_len,
+			      (const unsigned char *) needle, needle_len);
 }
 libc_hidden_builtin_def (strstr)
+
+#undef LONG_NEEDLE_THRESHOLD

Added: fsf/trunk/libc/string/tst-endian.c
==============================================================================
--- fsf/trunk/libc/string/tst-endian.c (added)
+++ fsf/trunk/libc/string/tst-endian.c Thu May 15 00:06:29 2008
@@ -1,0 +1,112 @@
+#include <byteswap.h>
+#include <endian.h>
+#include <inttypes.h>
+#include <stdio.h>
+
+
+static int
+do_test (void)
+{
+  int result = 0;
+
+  for (uint64_t i = 0; i < (~UINT64_C (0)) >> 2; i = (i << 1) + 3)
+    {
+      if (i < UINT64_C (65536))
+	{
+	  if (htobe16 (be16toh (i)) != i)
+	    {
+	      printf ("htobe16 (be16toh (%" PRIx64 ")) == %" PRIx16 "\n",
+		      i, (uint16_t) htobe16 (be16toh (i)));
+	      result = 1;
+	    }
+	  if (htole16 (le16toh (i)) != i)
+	    {
+	      printf ("htole16 (le16toh (%" PRIx64 ")) == %" PRIx16 "\n",
+		      i, (uint16_t) htole16 (le16toh (i)));
+	      result = 1;
+	    }
+
+	  uint16_t n[2];
+	  n[__BYTE_ORDER == __LITTLE_ENDIAN] = bswap_16 (i);
+	  n[__BYTE_ORDER == __BIG_ENDIAN] = i;
+	  if (htole16 (i) != n[0])
+	    {
+	      printf ("htole16 (%" PRIx64 ") == %" PRIx16 " != %" PRIx16 "\n",
+		      i, (uint16_t) htole16 (i), n[0]);
+	      result = 1;
+	    }
+	  if (htobe16 (i) != n[1])
+	    {
+	      printf ("htobe16 (%" PRIx64 ") == %" PRIx16 " != %" PRIx16 "\n",
+		      i, (uint16_t) htobe16 (i), n[1]);
+	      result = 1;
+	    }
+	}
+
+      if (i < UINT64_C (4294967296))
+	{
+	  if (htobe32 (be32toh (i)) != i)
+	    {
+	      printf ("htobe32 (be32toh (%" PRIx64 ")) == %" PRIx32 "\n",
+		      i, (uint32_t) htobe32 (be32toh (i)));
+	      result = 1;
+	    }
+	  if (htole32 (le32toh (i)) != i)
+	    {
+	      printf ("htole32 (le32toh (%" PRIx64 ")) == %" PRIx32 "\n",
+		      i, (uint32_t) htole32 (le32toh (i)));
+	      result = 1;
+	    }
+
+	  uint32_t n[2];
+	  n[__BYTE_ORDER == __LITTLE_ENDIAN] = bswap_32 (i);
+	  n[__BYTE_ORDER == __BIG_ENDIAN] = i;
+	  if (htole32 (i) != n[0])
+	    {
+	      printf ("htole32 (%" PRIx64 ") == %" PRIx32 " != %" PRIx32 "\n",
+		      i, (uint32_t) htole32 (i), n[0]);
+	      result = 1;
+	    }
+	  if (htobe32 (i) != n[1])
+	    {
+	      printf ("htobe32 (%" PRIx64 ") == %" PRIx32 " != %" PRIx32 "\n",
+		      i, (uint32_t) htobe32 (i), n[1]);
+	      result = 1;
+	    }
+	}
+
+      if (htobe64 (be64toh (i)) != i)
+	{
+	  printf ("htobe64 (be64toh (%" PRIx64 ")) == %" PRIx64 "\n",
+		  i, htobe64 (be64toh (i)));
+	  result = 1;
+	}
+      if (htole64 (le64toh (i)) != i)
+	{
+	  printf ("htole64 (le64toh (%" PRIx64 ")) == %" PRIx64 "\n",
+		  i, htole64 (le64toh (i)));
+	  result = 1;
+	}
+
+      uint64_t n[2];
+      n[__BYTE_ORDER == __LITTLE_ENDIAN] = bswap_64 (i);
+      n[__BYTE_ORDER == __BIG_ENDIAN] = i;
+      if (htole64 (i) != n[0])
+	{
+	  printf ("htole64 (%" PRIx64 ") == %" PRIx64 " != %" PRIx64 "\n",
+		  i, htole64 (i), n[0]);
+	  result = 1;
+	}
+      if (htobe64 (i) != n[1])
+	{
+	  printf ("htobe64 (%" PRIx64 ") == %" PRIx64 " != %" PRIx64 "\n",
+		  i, htobe64 (i), n[1]);
+	  result = 1;
+	}
+    }
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"

Modified: fsf/trunk/libc/sysdeps/i386/bits/byteswap.h
==============================================================================
--- fsf/trunk/libc/sysdeps/i386/bits/byteswap.h (original)
+++ fsf/trunk/libc/sysdeps/i386/bits/byteswap.h Thu May 15 00:06:29 2008
@@ -1,5 +1,5 @@
 /* Macros to swap the order of bytes in integer values.
-   Copyright (C) 1997, 1998, 2000, 2002, 2003, 2006, 2007
+   Copyright (C) 1997, 1998, 2000, 2002, 2003, 2006, 2007, 2008
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -18,7 +18,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
+#if !defined _BYTESWAP_H && !defined _NETINET_IN_H && !defined _ENDIAN_H
 # error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
 #endif
 

Modified: fsf/trunk/libc/sysdeps/ia64/bits/byteswap.h
==============================================================================
--- fsf/trunk/libc/sysdeps/ia64/bits/byteswap.h (original)
+++ fsf/trunk/libc/sysdeps/ia64/bits/byteswap.h Thu May 15 00:06:29 2008
@@ -1,5 +1,5 @@
 /* Macros to swap the order of bytes in integer values.
-   Copyright (C) 1997, 1998, 2000, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1997,1998,2000,2002,2003,2008 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
@@ -17,7 +17,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
+#if !defined _BYTESWAP_H && !defined _NETINET_IN_H && !defined _ENDIAN_H
 # error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
 #endif
 

Modified: fsf/trunk/libc/sysdeps/posix/getaddrinfo.c
==============================================================================
--- fsf/trunk/libc/sysdeps/posix/getaddrinfo.c (original)
+++ fsf/trunk/libc/sysdeps/posix/getaddrinfo.c Thu May 15 00:06:29 2008
@@ -61,6 +61,7 @@
 #include <not-cancel.h>
 #include <nscd/nscd-client.h>
 #include <nscd/nscd_proto.h>
+#include <resolv/res_hconf.h>
 
 #ifdef HAVE_LIBIDN
 extern int __idna_to_ascii_lz (const char *input, char **output, int flags);
@@ -97,8 +98,9 @@
   {
     int socktype;
     int protocol;
-    char name[4];
-    int protoflag;
+    uint8_t protoflag;
+    bool defaultflag;
+    char name[8];
   };
 
 /* Values for `protoflag'.  */
@@ -107,11 +109,21 @@
 
 static const struct gaih_typeproto gaih_inet_typeproto[] =
 {
-  { 0, 0, "", 0 },
-  { SOCK_STREAM, IPPROTO_TCP, "tcp", 0 },
-  { SOCK_DGRAM, IPPROTO_UDP, "udp", 0 },
-  { SOCK_RAW, 0, "raw", GAI_PROTO_PROTOANY|GAI_PROTO_NOSERVICE },
-  { 0, 0, "", 0 }
+  { 0, 0, 0, false, "" },
+  { SOCK_STREAM, IPPROTO_TCP, 0, true, "tcp" },
+  { SOCK_DGRAM, IPPROTO_UDP, 0, true, "udp" },
+#if defined SOCK_DCCP && defined IPPROTO_DCCP
+  { SOCK_DCCP, IPPROTO_DCCP, 0, false, "dccp" },
+#endif
+#ifdef IPPROTO_UDPLITE
+  { SOCK_DGRAM, IPPROTO_UDPLITE, 0, false, "udplite" },
+#endif
+#ifdef IPPROTO_SCTP
+  { SOCK_STREAM, IPPROTO_SCTP, 0, false, "sctp" },
+  { SOCK_SEQPACKET, IPPROTO_SCTP, 0, false, "sctp" },
+#endif
+  { SOCK_RAW, 0, GAI_PROTO_PROTOANY|GAI_PROTO_NOSERVICE, true, "raw" },
+  { 0, 0, 0, false, "" }
 };
 
 struct gaih
@@ -363,18 +375,19 @@
 	     we know about.  */
 	  struct gaih_servtuple **lastp = &st;
 	  for (++tp; tp->name[0]; ++tp)
-	    {
-	      struct gaih_servtuple *newp;
-
-	      newp = __alloca (sizeof (struct gaih_servtuple));
-	      newp->next = NULL;
-	      newp->socktype = tp->socktype;
-	      newp->protocol = tp->protocol;
-	      newp->port = port;
-
-	      *lastp = newp;
-	      lastp = &newp->next;
-	    }
+	    if (tp->defaultflag)
+	      {
+		struct gaih_servtuple *newp;
+
+		newp = __alloca (sizeof (struct gaih_servtuple));
+		newp->next = NULL;
+		newp->socktype = tp->socktype;
+		newp->protocol = tp->protocol;
+		newp->port = port;
+
+		*lastp = newp;
+		lastp = &newp->next;
+	      }
 	}
     }
 
@@ -1099,7 +1112,10 @@
     {
       if (! IN6_IS_ADDR_MULTICAST (&in6->sin6_addr))
 	{
-	  if (IN6_IS_ADDR_LINKLOCAL (&in6->sin6_addr))
+	  if (IN6_IS_ADDR_LINKLOCAL (&in6->sin6_addr)
+	      /* RFC 4291 2.5.3 says that the loopback address is to be
+		 treated like a link-local address.  */
+	      || IN6_IS_ADDR_LOOPBACK (&in6->sin6_addr))
 	    scope = 2;
 	  else if (IN6_IS_ADDR_SITELOCAL (&in6->sin6_addr))
 	    scope = 5;
@@ -1232,20 +1248,14 @@
     {
       const struct sockaddr_in *in = (const struct sockaddr_in *) in6;
 
-      /* Convert to IPv6 address.  */
+      /* Construct a V4-to-6 mapped address.  */
       in6_mem.sin6_family = PF_INET6;
       in6_mem.sin6_port = in->sin_port;
       in6_mem.sin6_flowinfo = 0;
-      if (in->sin_addr.s_addr == htonl (0x7f000001))
-	in6_mem.sin6_addr = (struct in6_addr) IN6ADDR_LOOPBACK_INIT;
-      else
-	{
-	  /* Construct a V4-to-6 mapped address.  */
-	  memset (&in6_mem.sin6_addr, '\0', sizeof (in6_mem.sin6_addr));
-	  in6_mem.sin6_addr.s6_addr16[5] = 0xffff;
-	  in6_mem.sin6_addr.s6_addr32[3] = in->sin_addr.s_addr;
-	  in6_mem.sin6_scope_id = 0;
-	}
+      memset (&in6_mem.sin6_addr, '\0', sizeof (in6_mem.sin6_addr));
+      in6_mem.sin6_addr.s6_addr16[5] = 0xffff;
+      in6_mem.sin6_addr.s6_addr32[3] = in->sin_addr.s_addr;
+      in6_mem.sin6_scope_id = 0;
 
       in6 = &in6_mem;
     }
@@ -2076,6 +2086,10 @@
 
   if ((hints->ai_flags & AI_CANONNAME) && name == NULL)
     return EAI_BADFLAGS;
+
+  /* Initialize configurations.  */
+  if (__builtin_expect (!_res_hconf.initialized, 0))
+    _res_hconf_init ();
 
   struct in6addrinfo *in6ai = NULL;
   size_t in6ailen = 0;

Modified: fsf/trunk/libc/sysdeps/s390/bits/byteswap.h
==============================================================================
--- fsf/trunk/libc/sysdeps/s390/bits/byteswap.h (original)
+++ fsf/trunk/libc/sysdeps/s390/bits/byteswap.h Thu May 15 00:06:29 2008
@@ -1,5 +1,5 @@
 /* Macros to swap the order of bytes in integer values.  s390 version.
-   Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002, 2003, 2008 Free Software Foundation, Inc.
    Contributed by Martin Schwidefsky (schwidefsky@xxxxxxxxxx).
    This file is part of the GNU C Library.
 
@@ -18,7 +18,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
+#if !defined _BYTESWAP_H && !defined _NETINET_IN_H && !defined _ENDIAN_H
 # error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
 #endif
 

Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/bits/socket.h
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/bits/socket.h (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/bits/socket.h Thu May 15 00:06:29 2008
@@ -1,5 +1,5 @@
 /* System-specific socket constants and types.  Linux version.
-   Copyright (C) 1991, 1992, 1994-2001, 2004, 2006, 2007
+   Copyright (C) 1991, 1992, 1994-2001, 2004, 2006, 2007, 2008
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -52,6 +52,8 @@
   SOCK_SEQPACKET = 5,		/* Sequenced, reliable, connection-based,
 				   datagrams of fixed maximum length.  */
 #define SOCK_SEQPACKET SOCK_SEQPACKET
+  SOCK_DCCP = 6,
+#define SOCK_DCCP SOCK_DCCP	/* Datagram Congestion Control Protocol.  */
   SOCK_PACKET = 10		/* Linux specific way of getting packets
 				   at the dev level.  For writing rarp and
 				   other similar things on the user level. */

Modified: fsf/trunk/libc/sysdeps/x86_64/bits/byteswap.h
==============================================================================
--- fsf/trunk/libc/sysdeps/x86_64/bits/byteswap.h (original)
+++ fsf/trunk/libc/sysdeps/x86_64/bits/byteswap.h Thu May 15 00:06:29 2008
@@ -1,5 +1,5 @@
 /* Macros to swap the order of bytes in integer values.
-   Copyright (C) 1997, 1998, 2000, 2002, 2003, 2007
+   Copyright (C) 1997, 1998, 2000, 2002, 2003, 2007, 2008
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -18,7 +18,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
+#if !defined _BYTESWAP_H && !defined _NETINET_IN_H && !defined _ENDIAN_H
 # error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
 #endif