1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00
cde/src/cmd/ksh93/features/locale
Martijn Dekker c828ea8d0d Fix typeset -u/-l on NetBSD
On NetBSD, for some reason, the wctrans(3) and towctrans(3) C
library functions exist, but have no effect; the "toupper" and
"tolower" maps don't even translate case for ASCII, never mind wide
characters. This kills 'typeset -u' and 'typeset -l' on ksh, which
was the cause of most of the regression test failures on NetBSD.
Fallback versions for these functions are provided in init.c, but
were not being used on NetBSD because the feature test detected the
presence of these functions in the C library.

src/cmd/ksh93/features/locale:
- Replace the simple test for the presence of wctrans(3),
  towctrans(3), and the wctrans_t type by an actual feature test
  that checks that these functions not only compile, but are also
  capable of changing an ASCII 'q' to upper case and back again.

src/cmd/ksh93/sh/init.c: towctrans():
- Add wide character support to the fallback function, for whatever
  good that may do; on NetBSD, the wide-character towupper(3) and
  towlower(3) functions only change case for ASCII.
2021-05-18 18:26:33 +02:00

45 lines
1.2 KiB
Text

hdr locale,wchar,wctype
lib locale,localeconv,wctype,iswctype,iswblank
tst note{ do wctrans/towctrans work }end output{
/*
* On NetBSD, these functions exist, but simply have no effect for some reason.
* So instead of simple lib/typ tests, this custom test checks if they actually work.
*/
#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
int main()
{
wctrans_t toupper = wctrans("toupper"), tolower = wctrans("tolower");
int r = towctrans('q',toupper) == 'Q' && towctrans('Q',tolower) == 'q';
printf("#define _lib_wctrans\t%d\n",r);
printf("#define _lib_towctrans\t%d\n",r);
printf("#define _typ_wctrans_t\t%d\n",r);
return !r;
}
}end
cat{
#if _PACKAGE_ast
# undef _hdr_locale
# define _hdr_locale 1
#else
# ifdef _hdr_locale
# include <locale.h>
# ifndef LC_MESSAGES
# define LC_MESSAGES LC_ALL
# endif /* LC_MESSAGES */
# endif /* _hdr_locale */
#endif /* _PACKAGE_ast */
#ifdef _hdr_locale
# ifdef _lib_localeconv
static struct lconv *lp;
# define GETDECIMAL(x) (((lp=localeconv()) && lp->decimal_point && *lp->decimal_point) ? *lp->decimal_point : '.' )
# else
# define GETDECIMAL(x) ('.')
# endif /* _lib_localeconv */
#else
# define GETDECIMAL(x) ('.')
#endif /* _hdr_locale */
}end