wchar_and_locale.txt 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. User-configurable
  2. UCLIBC_HAS_CTYPE_TABLES
  3. Make toupper etc work thru translation tables
  4. and isalhum etc thru lookup tables. Help says:
  5. "While the non-table versions are often smaller when building
  6. statically linked apps, they work only in stub locale mode."
  7. "stub locale mode" is when !UCLIBC_HAS_LOCALE I presume,
  8. when we are permanently in POSIX/C locale.
  9. UCLIBC_HAS_CTYPE_SIGNED
  10. Handle sign-extended chars. I.e. if you want
  11. toupper((char)0xa0) => toupper(0xffffffa0) => still works correctly,
  12. as if toupper(0xa0) was called.
  13. UCLIBC_HAS_CTYPE_UNSAFE/CHECKED/ENFORCED
  14. Do not check ctype function argument's range/check it and return
  15. error/check it and abort(). Help says:
  16. NOTE: This only affects the 'ctype' _functions_. It does not affect
  17. the macro implementations. [so what happens to macros?]
  18. [examples?]
  19. UCLIBC_HAS_WCHAR
  20. Wide character support. I assume all those wchar_t types and functions
  21. UCLIBC_HAS_LOCALE/XLOCALE
  22. Support locale / extended locale
  23. UCLIBC_PREGENERATED_LOCALE_DATA
  24. Not recommended
  25. uclibc internal machinery
  26. __LOCALE_C_ONLY
  27. #defined if !UCLIBC_HAS_LOCALE
  28. __NO_CTYPE
  29. #defined only by some .c files. Prevents ctype macros to be #defined
  30. (those w/o underscores. __ctype() macros will still be defined).
  31. Looks like user is expected to never mess with defining it.
  32. __UCLIBC_DO_XLOCALE
  33. #defined only by some .c files. Looks like user is expected to never
  34. mess with defining it.
  35. __XL_NPP(N) - "add _l suffix if locale support is on"
  36. #defined to N ## _l if __UCLIBC_HAS_XLOCALE__ && __UCLIBC_DO_XLOCALE,
  37. else #defined to just N.
  38. __CTYPE_HAS_8_BIT_LOCALES
  39. __CTYPE_HAS_UTF_8_LOCALES
  40. Depends on contents of extra/locale/LOCALES data file. Looks like
  41. both will be set if UCLIBC_HAS_LOCALE and extra/locale/LOCALES
  42. is not edited.
  43. __WCHAR_ENABLED
  44. locale_mmap.h defines it unconditionally, extra/locale/gen_ldc.c
  45. defines it too with a warning, and _then_ includes locale_mmap.h.
  46. Makefile seems to prevent the warning in gen_ldc.c:
  47. ifeq ($(UCLIBC_HAS_WCHAR),y)
  48. BUILD_CFLAGS-gen_wc8bit += -DDO_WIDE_CHAR=1
  49. BUILD_CFLAGS-gen_ldc += -D__WCHAR_ENABLED=1
  50. endif
  51. A mess. Why they can't just use __UCLIBC_HAS_WCHAR__?
  52. __WCHAR_REPLACEMENT_CHAR
  53. Never defined (dead code???)
  54. Actual ctype macros are a bloody mess!
  55. ctype.h
  56. ...
  57. ...
  58. #define __isctype(c, type) \
  59. ((__UCLIBC_CTYPE_B)[(int) (c)] & (__ctype_mask_t) type)
  60. #define __isascii(c) (((c) & ~0x7f) == 0) /* If C is a 7 bit value. */
  61. #define __toascii(c) ((c) & 0x7f) /* Mask off high bits. */
  62. #define __isdigit_char(C) (((unsigned char)((C) - '0')) <= 9)
  63. #define __isdigit_int(C) (((unsigned int)((C) - '0')) <= 9)
  64. # define isalnum(c) __isctype((c), _ISalnum)
  65. # define isalpha(c) __isctype((c), _ISalpha)
  66. # if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
  67. # define tolower(c) __tobody (c, tolower, __UCLIBC_CTYPE_TOLOWER, (c))
  68. # define toupper(c) __tobody (c, toupper, __UCLIBC_CTYPE_TOUPPER, (c))
  69. # endif /* Optimizing gcc */
  70. # if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
  71. # define isascii(c) __isascii (c)
  72. # define toascii(c) __toascii (c)
  73. # define _tolower(c) ((int) (__UCLIBC_CTYPE_TOLOWER)[(int) (c)])
  74. # define _toupper(c) ((int) (__UCLIBC_CTYPE_TOUPPER)[(int) (c)])
  75. # endif
  76. ...
  77. ...
  78. bits/uClibc_ctype.h
  79. ...
  80. ...
  81. #define __tolower(c) __body(tolower,c)
  82. #define __toupper(c) __body(toupper,c)
  83. #define _toupper(c) ((c) ^ 0x20)
  84. #define _tolower(c) ((c) | 0x20)
  85. ...
  86. ...
  87. WTF?! We have (at least) TWO DIFFERENT _tolower's?