summaryrefslogtreecommitdiff
path: root/string/strcoll.c
diff options
context:
space:
mode:
Diffstat (limited to 'string/strcoll.c')
-rw-r--r--string/strcoll.c69
1 files changed, 49 insertions, 20 deletions
diff --git a/string/strcoll.c b/string/strcoll.c
index fa1025e0d7..e58b74cf51 100644
--- a/string/strcoll.c
+++ b/string/strcoll.c
@@ -1,22 +1,23 @@
-/* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
+/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <endian.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@@ -24,7 +25,11 @@ Boston, MA 02111-1307, USA. */
#ifndef STRING_TYPE
# define STRING_TYPE char
# define USTRING_TYPE unsigned char
-# define STRCOLL strcoll
+# ifdef USE_IN_EXTENDED_LOCALE_MODEL
+# define STRCOLL __strcoll_l
+# else
+# define STRCOLL strcoll
+# endif
# define STRCMP strcmp
#endif
@@ -36,11 +41,35 @@ Boston, MA 02111-1307, USA. */
/* Compare S1 and S2, returning less than, equal to or
greater than zero if the collated form of S1 is lexicographically
less than, equal to or greater than the collated form of S2. */
+#ifndef USE_IN_EXTENDED_LOCALE_MODEL
int
STRCOLL (s1, s2)
const STRING_TYPE *s1;
const STRING_TYPE *s2;
+#else
+int
+STRCOLL (s1, s2, l)
+ const STRING_TYPE *s1;
+ const STRING_TYPE *s2;
+ __locale_t l;
+#endif
{
+#ifdef USE_IN_EXTENDED_LOCALE_MODEL
+ struct locale_data *current = l->__locales[LC_COLLATE];
+# if BYTE_ORDER == BIG_ENDIAN
+ const u_int32_t *collate_table = (const u_int32_t *)
+ current->values[_NL_ITEM_INDEX (_NL_COLLATE_TABLE_EB)].string;
+ const u_int32_t *collate_extra = (const u_int32_t *)
+ current->values[_NL_ITEM_INDEX (_NL_COLLATE_EXTRA_EB)].string;
+# elif BYTE_ORDER == LITTLE_ENDIAN
+ const u_int32_t *collate_table = (const u_int32_t *)
+ current->values[_NL_ITEM_INDEX (_NL_COLLATE_TABLE_EL)].string;
+ const u_int32_t *collate_extra = (const u_int32_t *)
+ current->values[_NL_ITEM_INDEX (_NL_COLLATE_EXTRA_EL)].string;
+# else
+# error bizarre byte order
+# endif
+#endif
weight_t *s1forw = NULL;
weight_t *s1backw = NULL;
weight_t *s2forw = NULL;