]> Savannah Git Hosting - gnulib.git/commitdiff
mbchar: Optimize is_basic.
authorBruno Haible <bruno@clisp.org>
Thu, 13 Jul 2023 21:23:41 +0000 (23:23 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 13 Jul 2023 21:23:41 +0000 (23:23 +0200)
* lib/mbchar.h (is_basic_table): Remove declaration.
(is_basic) [IS_BASIC_ASCII]: Define through a simple range test.
* lib/mbchar.c (is_basic_table): Remove array.

ChangeLog
lib/mbchar.c
lib/mbchar.h

index b902d6c98babdd525a9c4e865316ce47e1f06753..52b47d42c2e0b80291f13ecff090c114266054f7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2023-07-13  Bruno Haible  <bruno@clisp.org>
 
+       mbchar: Optimize is_basic.
+       * lib/mbchar.h (is_basic_table): Remove declaration.
+       (is_basic) [IS_BASIC_ASCII]: Define through a simple range test.
+       * lib/mbchar.c (is_basic_table): Remove array.
+
        localcharset: Clean up locale encodings used by glibc.
        * lib/localcharset.h: Remove VISCII from the list, since never supported
        in glibc/localedata/SUPPORTED. JOHAB is not supported by glibc any more
index 63ff9c7a72523deee249cbe63b8c497ea7c12df6..af3c7934dc15418f895e19d8af8d82f0d52a0f6a 100644 (file)
 #include <limits.h>
 
 #include "mbchar.h"
-
-#if IS_BASIC_ASCII
-
-/* Bit table of characters in the POSIX "portable character set", which
-   POSIX guarantees to be single-byte and in practice are safe to treat
-   like the ISO C "basic character set".  */
-const unsigned int is_basic_table [UCHAR_MAX / 32 + 1] =
-{
-  0x00003f81,           /* '\0' '\007' '\010' '\t' '\n' '\v' '\f' '\r' */
-  0xffffffff,           /* ' '......'?' */
-  0xffffffff,           /* '@' 'A'...'Z' '[' '\\' ']' '^' '_' */
-  0x7fffffff            /* '`' 'a'...'z' '{' '|' '}' '~' */
-  /* The remaining bits are 0.  */
-};
-
-#endif /* IS_BASIC_ASCII */
index 36bae182763aba749539419e8b3d9907eb4770ea..82c373f47ed1cc62342316867c289d9abcf23fd9 100644 (file)
@@ -309,14 +309,17 @@ mb_copy (mbchar_t *new_mbc, const mbchar_t *old_mbc)
 /* The character set is ISO-646, not EBCDIC. */
 # define IS_BASIC_ASCII 1
 
-extern const unsigned int is_basic_table[];
-
-MBCHAR_INLINE bool
-is_basic (char c)
-{
-  return (is_basic_table [(unsigned char) c >> 5] >> ((unsigned char) c & 31))
-         & 1;
-}
+/* All locale encodings (see localcharset.h) map the characters 0x00..0x7F
+   to U+0000..U+007F, like ASCII, except for
+     CP864      different mapping of '%'
+     SHIFT_JIS  different mappings of 0x5C, 0x7E
+     JOHAB      different mapping of 0x5C
+   However, these characters in the range 0x20..0x7E are in the ISO C
+   "basic character set" and in the POSIX "portable character set", which
+   ISO C and POSIX guarantee to be single-byte.  Thus, locales with these
+   encodings are not POSIX compliant.  And they are most likely not in use
+   any more (as of 2023).  */
+# define is_basic(c) ((unsigned char) (c) < 0x80)
 
 #else