about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog19
-rw-r--r--assert/Makefile2
-rw-r--r--assert/Versions4
-rw-r--r--assert/__assert.c25
-rw-r--r--assert/assert.h9
-rw-r--r--gnulib/Makefile5
-rw-r--r--gnulib/tst-gcc.c74
-rw-r--r--locale/localeinfo.h8
-rw-r--r--locale/programs/ld-ctype.c29
-rw-r--r--posix/fnmatch_loop.c50
10 files changed, 196 insertions, 29 deletions
diff --git a/ChangeLog b/ChangeLog
index d0eecdaa1a..0108ce5edc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,23 @@
 2000-08-01  Ulrich Drepper  <drepper@redhat.com>
+
+	* gnulib/Makefile (tests): Add tst-gcc.
+	* gnulib/tst-gcc.c: New file.
+
+	* assert/Makefile (routines): Add __assert.
+	* assert/Versions: Export __assert for glibc 2.2.
+	* assert/__assert.c: New file.
+	* assert/assert.h: Declare __assert.
+
+2000-07-27  Bruno Haible  <haible@clisp.cons.org>
+
+	* locale/localeinfo.h (_ISCTYPE): New macro.
+	* posix/fnmatch_loop.c (internal_fnmatch): Use it, support new
+	LC_CTYPE locale format.
+	* locale/programs/ld-ctype.c (locale_ctype_t): New field class_b.
+	(ctype_output): Output class_b[nr] right before class_3level[nr].
+	(allocate_arrays): Fill class_b, similarly to class_3level.
+
+2000-08-01  Ulrich Drepper  <drepper@redhat.com>
 	    Joseph S. Myers  <jsm28@cam.ac.uk>
 
 	* math/tgmath.h: Make standard compliant.  Don't ask how.
diff --git a/assert/Makefile b/assert/Makefile
index c18d673b94..46cae868fd 100644
--- a/assert/Makefile
+++ b/assert/Makefile
@@ -22,7 +22,7 @@
 subdir	:= assert
 headers	:= assert.h
 
-routines := assert assert-perr
+routines := assert assert-perr __assert
 tests := test-assert test-assert-perr
 
 include ../Rules
diff --git a/assert/Versions b/assert/Versions
index 0761373f0e..9e1a5f2d6f 100644
--- a/assert/Versions
+++ b/assert/Versions
@@ -3,4 +3,8 @@ libc {
     # functions used in inline functions or macros
     __assert_fail; __assert_perror_fail;
   }
+  GLIBC_2.2 {
+    # just for standard compliance
+    __assert;
+  }
 }
diff --git a/assert/__assert.c b/assert/__assert.c
new file mode 100644
index 0000000000..50ebac5bf8
--- /dev/null
+++ b/assert/__assert.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 2000 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 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 <assert.h>
+
+void
+__assert (const char *assertion, const char *file, int line)
+{
+  __assert_fail (assertion, file, line, (const char *) 0);
+}
diff --git a/assert/assert.h b/assert/assert.h
index b37583ca15..b24696211f 100644
--- a/assert/assert.h
+++ b/assert/assert.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,92,94,95,96,97,98,99 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,94,95,96,97,98,99,2000 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
@@ -68,6 +68,13 @@ extern void __assert_perror_fail (int __errnum, __const char *__file,
 				  __const char *__function)
      __THROW __attribute__ ((__noreturn__));
 
+
+/* The following is not at all used here but needed for standard
+   compliance.  */
+extern void __assert (const char *__assertion, const char *__file, int __line)
+     __THROW __attribute__ ((__noreturn__));
+
+
 __END_DECLS
 
 # define assert(expr)							      \
diff --git a/gnulib/Makefile b/gnulib/Makefile
index a7255b38b2..3586feb73f 100644
--- a/gnulib/Makefile
+++ b/gnulib/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1991, 1997 Free Software Foundation, Inc.
+# Copyright (C) 1991, 1997, 2000 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
@@ -18,6 +18,9 @@
 
 subdir := gnulib
 
+# Maybe this is the right place for a test of gcc's interface.
+tests = tst-gcc
+
 # Which routines are required is machine-dependent.
 
 include ../Rules
diff --git a/gnulib/tst-gcc.c b/gnulib/tst-gcc.c
new file mode 100644
index 0000000000..2d930aecad
--- /dev/null
+++ b/gnulib/tst-gcc.c
@@ -0,0 +1,74 @@
+/* Test program for the gcc interface.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>.
+
+   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 <stdio.h>
+
+#define __no_type_class		-1
+#define __void_type_class	 0
+#define __integer_type_class	 1
+#define __char_type_class	 2
+#define __enumeral_type_class	 3
+#define __boolean_type_class	 4
+#define __pointer_type_class	 5
+#define __reference_type_class	 6
+#define __offset_type_class	 7
+#define __real_type_class	 8
+#define __complex_type_class	 9
+#define __function_type_class	10
+#define __method_type_class	11
+#define __record_type_class	12
+#define __union_type_class	13
+#define __array_type_class	14
+#define __string_type_class	15
+#define __set_type_class	16
+#define __file_type_class	17
+#define __lang_type_class	18
+
+
+#define TEST(var) \
+  ({ int wrong = (__builtin_classify_type (__##var##_type)		      \
+		  != __##var##_type_class);				      \
+     printf ("%-15s is %d: %s\n",					      \
+	     #var, __builtin_classify_type (__##var##_type),		      \
+	     wrong ? "WRONG" : "OK");					      \
+     wrong;								      \
+  })
+
+
+int
+main (void)
+{
+  int result = 0;
+  int __integer_type;
+  void *__pointer_type;
+  double __real_type;
+  __complex__ double __complex_type;
+  struct { int a; } __record_type;
+  union { int a; int b; } __union_type;
+
+  result |= TEST (integer);
+  result |= TEST (pointer);
+  result |= TEST (real);
+  result |= TEST (complex);
+  result |= TEST (record);
+  result |= TEST (union);
+
+  return result;
+}
diff --git a/locale/localeinfo.h b/locale/localeinfo.h
index 412ac27a06..f986282392 100644
--- a/locale/localeinfo.h
+++ b/locale/localeinfo.h
@@ -130,6 +130,14 @@ enum
 };
 
 
+/* LC_CTYPE specific:
+   Access a wide character class with a single character index.
+   _ISCTYPE (c, desc) = iswctype (btowc (c), desc).
+   c must be an `unsigned char'.  desc must be a nonzero wctype_t.  */
+#define _ISCTYPE(c, desc) \
+  (((((const uint32_t *) (desc)) - 8)[(c) >> 5] >> ((c) & 0x1f)) & 1)
+
+
 /* For each category declare the variable for the current locale data.  */
 #define DEFINE_CATEGORY(category, category_name, items, a) \
 extern struct locale_data *_nl_current_##category;
diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c
index f3edd6cbc0..0460d10084 100644
--- a/locale/programs/ld-ctype.c
+++ b/locale/programs/ld-ctype.c
@@ -170,6 +170,7 @@ struct locale_ctype_t
   uint32_t *names;
   uint32_t **map;
   uint32_t **map32;
+  uint32_t **class_b;
   struct iovec *class_3level;
   struct iovec *map_3level;
   uint32_t *class_name_ptr;
@@ -842,7 +843,7 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap,
 			 + (oldstyle_tables
 			    ? (ctype->map_collection_nr - 2)
 			    : (ctype->nr_charclass + ctype->map_collection_nr)));
-  struct iovec iov[2 + nelems + ctype->nr_charclass
+  struct iovec iov[2 + nelems + 2 * ctype->nr_charclass
 		  + ctype->map_collection_nr + 2];
   struct locale_file data;
   uint32_t idx[nelems + 1];
@@ -1169,6 +1170,12 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap,
 	      size_t nr = elem - _NL_ITEM_INDEX (_NL_CTYPE_EXTRA_MAP_1);
 	      if (nr < ctype->nr_charclass)
 		{
+		  iov[2 + elem + offset].iov_base = ctype->class_b[nr];
+		  iov[2 + elem + offset].iov_len = 256 / 32
+						   * sizeof (uint32_t);
+		  idx[elem] += iov[2 + elem + offset].iov_len;
+		  ++offset;
+
 		  iov[2 + elem + offset] = ctype->class_3level[nr];
 		}
 	      else
@@ -1182,7 +1189,7 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap,
 	}
     }
 
-  assert (2 + elem + offset == (nelems + ctype->nr_charclass
+  assert (2 + elem + offset == (nelems + 2 * ctype->nr_charclass
 				+ ctype->map_collection_nr + 2 + 2));
 
   write_locale_data (output_path, "LC_CTYPE", 2 + elem + offset, iov);
@@ -4083,8 +4090,12 @@ Computing table size for character classes might take a while..."),
     xcalloc ((oldstyle_tables ? ctype->plane_size * ctype->plane_cnt : 256),
 	     sizeof (char_class32_t));
   if (!oldstyle_tables)
-    ctype->class_3level = (struct iovec *)
-      xmalloc (ctype->nr_charclass * sizeof (struct iovec));
+    {
+      ctype->class_b = (uint32_t **)
+	xmalloc (ctype->nr_charclass * sizeof (uint32_t *));
+      ctype->class_3level = (struct iovec *)
+	xmalloc (ctype->nr_charclass * sizeof (struct iovec));
+    }
 
   /* This is the array accessed using the multibyte string elements.  */
   for (idx = 0; idx < 256; ++idx)
@@ -4115,6 +4126,16 @@ Computing table size for character classes might take a while..."),
 
       for (nr = 0; nr < ctype->nr_charclass; nr++)
 	{
+	  ctype->class_b[nr] = (uint32_t *)
+	    xcalloc (256 / 32, sizeof (uint32_t));
+
+	  for (idx = 0; idx < 256; ++idx)
+	    if (ctype->class256_collection[idx] & _ISbit (nr))
+	      ctype->class_b[nr][idx >> 5] |= (uint32_t)1 << (idx & 0x1f);
+	}
+
+      for (nr = 0; nr < ctype->nr_charclass; nr++)
+	{
 	  struct wctype_table t;
 
 	  t.p = 4; /* or: 5 */
diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c
index 38cb8f1d76..86526a15ff 100644
--- a/posix/fnmatch_loop.c
+++ b/posix/fnmatch_loop.c
@@ -256,35 +256,41 @@ FCT (pattern, string, no_leading_period, flags)
 		      /* Invalid character class name.  */
 		      return FNM_NOMATCH;
 
-		    /* The following code is glibc specific but does
-		       there a good job in sppeding up the code since
-		       we can avoid the btowc() call.  The
-		       IS_CHAR_CLASS call will return a bit mask for
-		       the 32-bit table.  We have to convert it to a
-		       bitmask for the __ctype_b table.  This has to
-		       be done based on the byteorder as can be seen
-		       below.  In any case we will fall back on the
-		       code using btowc() if the class is not one of
-		       the standard classes.  */
 # if defined _LIBC && ! WIDE_CHAR_VERSION
-#  if __BYTE_ORDER == __LITTLE_ENDIAN
-		    if ((wt & 0xf0ffff) == 0)
+		    /* The following code is glibc specific but does
+		       there a good job in speeding up the code since
+		       we can avoid the btowc() call.  */
+		    if (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_SIZE) != 0)
 		      {
-			wt >>= 16;
-			if ((__ctype_b[(UCHAR) *n] & wt) != 0)
-			  goto matched;
-		      }
+			/* Old locale format.  */
+#  if __BYTE_ORDER == __LITTLE_ENDIAN
+			if ((wt & 0xf0ffff) == 0)
+			  {
+			    wt >>= 16;
+			    if ((__ctype_b[(UCHAR) *n] & wt) != 0)
+			      goto matched;
+			  }
 #  else
-		    if (wt <= 0x800)
+			if (wt <= 0x800)
+			  {
+			    if ((__ctype_b[(UCHAR) *n] & wt) != 0)
+			      goto matched;
+			  }
+#  endif
+			else
+			  if (ISWCTYPE (BTOWC ((UCHAR) *n), wt))
+			    goto matched;
+		      }
+		    else
 		      {
-			if ((__ctype_b[(UCHAR) *n] & wt) != 0)
+			/* New locale format.  */
+			if (_ISCTYPE ((UCHAR) *n, wt))
 			  goto matched;
 		      }
-#  endif
-		    else
+# else
+		    if (ISWCTYPE (BTOWC ((UCHAR) *n), wt))
+		      goto matched;
 # endif
-		      if (ISWCTYPE (BTOWC ((UCHAR) *n), wt))
-			goto matched;
 #else
 		    if ((STREQ (str, L("alnum")) && ISALNUM ((UCHAR) *n))
 			|| (STREQ (str, L("alpha")) && ISALPHA ((UCHAR) *n))