wchar_and_locale.txt 3.9 KB

  1. User-configurable
  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.
  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.
  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?]
  20. Wide character support. I assume all those wchar_t types and functions
  22. Support locale / extended locale
  24. Not recommended
  25. uclibc internal machinery
  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.
  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.
  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.
  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__?
  53. Never defined (dead code???)
  54. Actual ctype macros are a bloody mess!
  55. __C_isspace(c), __C_tolower(c) et al
  56. Defined in bits/uClibc_ctype.h. Non-locale-aware, unsafe
  57. wrt multiple-evaluation, macros. Return unsigned int.
  58. __isspace(c), __tolower(c) et al
  59. Defined in bits/uClibc_ctype.h. Non-locale-aware,
  60. but safe wrt multiple-evaluation, macros. Return int.
  61. __isdigit_char, __isdigit_int
  62. Visible only to uclibc code. ((unsigned char/int)((c) - '0') <= 9).
  63. _tolower(c), _toupper(c)
  64. Even more unsafe versions (they just do | 0x20 or ^ 0x20). Sheesh.
  65. They are mandated by POSIX so we must have them defined,
  66. but I removed all uses in uclibc code. Half of them were buggy.
  67. isspace(c), tolower(c) et al
  68. Declared as int isXXXX(int c) in bits/uClibc_ctype.h. Then,
  69. if not C++ compile, defined as macros to __usXXXX(c)
  70. bits/uClibc_ctype.h is included by ctype.h only if !__UCLIBC_HAS_CTYPE_TABLES__.
  71. Otherwise, ctype.h declares int isXXXX(int c) functions,
  72. then defines macros for isXXXX(c), __isXXX(c), toXXXX(c).
  73. Surprisingly, there are no __toXXXX(c), but if __USE_EXTERN_INLINES,
  74. there are inlines (yes, not macros!) for toXXXX(c) functions,
  75. so those may have both inlines and macros!).
  76. It also defines "unsafe" _toXXXX macros.
  77. All in all, __isXXXX(c) and __toXXXXX(c) seem to be useless,
  78. they are full equivalents to non-underscored versions.
  79. Remove?
  80. Macro-ization of isXXX(c) for __UCLIBC_HAS_XLOCALE__ case is problematic:
  81. it is done by indexing: __UCLIBC_CTYPE_B[c], and in __UCLIBC_HAS_XLOCALE__
  82. case __UCLIBC_CTYPE_B is doing a __ctype_b_loc() call! We do not save
  83. function call! Thus, why not have dedicated optimized functions
  84. for each isXXXX() instead? Looking deeper, __ctype_b_loc() may have
  85. another lever of function calls inside! What a mess...