#if IS_BASIC_ASCII
-/* Bit table of characters in the ISO C "basic character set",
- plus the characters '@', '$', and '`' which
- ISO C guarantees to be single-byte and in practice are safe
- to treat as basic in the execution character set. */
+/* 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] =
{
- 0x00001a00, /* '\t' '\v' '\f' */
+ 0x00003f81, /* '\0' '\007' '\010' '\t' '\n' '\v' '\f' '\r' */
0xffffffff, /* ' '......'?' */
0xffffffff, /* '@' 'A'...'Z' '[' '\\' ']' '^' '_' */
0x7fffffff /* '`' 'a'...'z' '{' '|' '}' '~' */
}
-/* is_basic(c) tests whether the single-byte character c is in the
- ISO C "basic character set" or is one of '@', '$', and '`' which
- ISO C 23 § 5.2.1.1.(1) guarantees to be single-byte and in practice
- are safe to treat as basic in the execution character set.
+/* is_basic(c) tests whether the single-byte character c is
+ - in the ISO C "basic character set" or is one of '@', '$', and '`'
+ which ISO C 23 § 5.2.1.1.(1) guarantees to be single-byte and in
+ practice are safe to treat as basic in the execution character set,
+ or
+ - in the POSIX "portable character set", which
+ <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap06.html>
+ equally guarantees to be single-byte.
This is a convenience function, and is in this file only to share code
- between mbiter_multi.h and mbfile_multi.h. */
-#if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) && ('$' == 36) \
- && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
- && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
- && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
- && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
- && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
- && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
- && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('@' == 64) && ('A' == 65) \
- && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
- && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
- && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
- && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
- && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
- && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
- && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
- && ('^' == 94) && ('_' == 95) && ('`' == 96) && ('a' == 97) && ('b' == 98) \
- && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
- && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
- && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
- && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
- && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
- && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
- && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)
+ between mbiter.h, mbuiter.h, and mbfile.h. */
+#if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
+ && ('$' == 36) && ('%' == 37) && ('&' == 38) && ('\'' == 39) \
+ && ('(' == 40) && (')' == 41) && ('*' == 42) && ('+' == 43) \
+ && (',' == 44) && ('-' == 45) && ('.' == 46) && ('/' == 47) \
+ && ('0' == 48) && ('1' == 49) && ('2' == 50) && ('3' == 51) \
+ && ('4' == 52) && ('5' == 53) && ('6' == 54) && ('7' == 55) \
+ && ('8' == 56) && ('9' == 57) && (':' == 58) && (';' == 59) \
+ && ('<' == 60) && ('=' == 61) && ('>' == 62) && ('?' == 63) \
+ && ('@' == 64) && ('A' == 65) && ('B' == 66) && ('C' == 67) \
+ && ('D' == 68) && ('E' == 69) && ('F' == 70) && ('G' == 71) \
+ && ('H' == 72) && ('I' == 73) && ('J' == 74) && ('K' == 75) \
+ && ('L' == 76) && ('M' == 77) && ('N' == 78) && ('O' == 79) \
+ && ('P' == 80) && ('Q' == 81) && ('R' == 82) && ('S' == 83) \
+ && ('T' == 84) && ('U' == 85) && ('V' == 86) && ('W' == 87) \
+ && ('X' == 88) && ('Y' == 89) && ('Z' == 90) && ('[' == 91) \
+ && ('\\' == 92) && (']' == 93) && ('^' == 94) && ('_' == 95) \
+ && ('`' == 96) && ('a' == 97) && ('b' == 98) && ('c' == 99) \
+ && ('d' == 100) && ('e' == 101) && ('f' == 102) && ('g' == 103) \
+ && ('h' == 104) && ('i' == 105) && ('j' == 106) && ('k' == 107) \
+ && ('l' == 108) && ('m' == 109) && ('n' == 110) && ('o' == 111) \
+ && ('p' == 112) && ('q' == 113) && ('r' == 114) && ('s' == 115) \
+ && ('t' == 116) && ('u' == 117) && ('v' == 118) && ('w' == 119) \
+ && ('x' == 120) && ('y' == 121) && ('z' == 122) && ('{' == 123) \
+ && ('|' == 124) && ('}' == 125) && ('~' == 126)
/* The character set is ISO-646, not EBCDIC. */
# define IS_BASIC_ASCII 1
{
switch (c)
{
- case '\t': case '\v': case '\f':
+ case '\0':
+ case '\007': case '\010':
+ case '\t': case '\n': case '\v': case '\f': case '\r':
case ' ': case '!': case '"': case '#': case '$': case '%':
case '&': case '\'': case '(': case ')': case '*':
case '+': case ',': case '-': case '.': case '/':
/* Handle most ASCII characters quickly, without calling mbrtowc(). */
if (mbf->bufcount == 1 && mbsinit (&mbf->state) && is_basic (mbf->buf[0]))
{
- /* These characters are part of the basic character set. ISO C 99
- guarantees that their wide character code is identical to their
- char code. The 32-bit wide character code is the same as well. */
+ /* These characters are part of the POSIX portable character set.
+ For most of them, namely those in the ISO C basic character set,
+ ISO C 99 guarantees that their wide character code is identical to
+ their char code. For the few other ones, this is the case as well,
+ in all locale encodings that are in use. The 32-bit wide character
+ code is the same as well. */
mbc->wc = mbc->buf[0] = mbf->buf[0];
mbc->wc_valid = true;
mbc->ptr = &mbc->buf[0];