Fix bugzilla 24661 - wctype_t and wctrans_t are platform-dependent

The previous definitions are left as the default. They could still
be wrong on some other platforms.
This commit is contained in:
Tim Schendekehl 2024-07-13 16:10:26 +02:00 committed by The Dlang Bot
parent 5f4002ba5e
commit 845adf8e3c
2 changed files with 50 additions and 7 deletions

View file

@ -14,6 +14,7 @@
module core.stdc.wctype;
import core.stdc.config;
public import core.stdc.wchar_; // for wint_t, WEOF
extern (C):
@ -21,10 +22,41 @@ extern (C):
nothrow:
@nogc:
///
alias wchar_t wctrans_t;
///
alias wchar_t wctype_t;
version (CRuntime_Glibc)
{
///
alias wctype_t = c_ulong;
///
alias wctrans_t = const(int)*;
}
else version (CRuntime_Musl)
{
///
alias wctype_t = c_ulong;
///
alias wctrans_t = const(int)*;
}
else version (FreeBSD)
{
///
alias wctype_t = c_ulong;
///
alias wctrans_t = int;
}
else version (CRuntime_Bionic)
{
///
alias wctype_t = c_long;
///
alias wctrans_t = const(void)*;
}
else
{
///
alias wchar_t wctrans_t;
///
alias wchar_t wctype_t;
}
///
pure int iswalnum(wint_t wc);
@ -63,3 +95,17 @@ pure wint_t towupper(wint_t wc);
wint_t towctrans(wint_t wc, wctrans_t desc);
///
@system wctrans_t wctrans(const scope char* property);
unittest
{
assert(iswalpha('A'));
assert(!iswalpha('0'));
wctype_t alpha = wctype("alpha");
assert(alpha);
wctrans_t tolower = wctrans("tolower");
assert(tolower);
assert(iswctype('A', alpha));
assert(!iswctype('0', alpha));
assert(towctrans('A', tolower) == 'a');
assert(towctrans('0', tolower) == '0');
}

View file

@ -51,9 +51,6 @@ immutable ErrorFilter[] knownProblems = [
ErrorFilter("core.stdc.stdio.__sFILE", "", "FreeBSD", 0, ""),
ErrorFilter("core.stdc.wchar_.mbstate_t", "", "Apple", 0, ""),
ErrorFilter("core.stdc.wchar_.mbstate_t", "", "Windows", 0, ""),
ErrorFilter("core.stdc.wctype.wctrans_t", "", "linux", 64, ""),
ErrorFilter("core.stdc.wctype.wctype_t", "", "FreeBSD", 64, ""),
ErrorFilter("core.stdc.wctype.wctype_t", "", "linux", 64, ""),
ErrorFilter("core.sys.linux.perf_event.perf_event_sample_format", "", "linux", 0, ""),
ErrorFilter("core.sys.posix.fcntl.flock", "", "linux", 32, ""),
ErrorFilter("core.sys.posix.sched.sched_param", "", "Apple", 0, ""),