Hi Thomas:
Thanks for your reply.
Here is some more informations.
I tried print out the result of lower:
When I set it to "towlower":
And here is the result of setting to "tolower":
You can try again and change LC_ALL to C maybe the crash will be come out.
printf("set locale: %s\n", setlocale(LC_ALL, "C"));
The source code will be found here:
And sorry for this, I'm a newbee for NetBSD, I couldn't find a way to set up the network for netbsd, so I couldn't export the core file.
------------------------------------------------------------------
发件人:Thomas Klausner via gnats <gnats-admin%NetBSD.org@localhost>
发送时间:2025年2月11日(星期二) 14:45
收件人:"lib-bug-people"<lib-bug-people%netbsd.org@localhost>; "gnats-admin"<gnats-admin%netbsd.org@localhost>; "netbsd-bugs"<netbsd-bugs%netbsd.org@localhost>; ru_j217<ru_j217%aliyun.com@localhost>
主 题:Re: lib/59067: wctrans got error member.
The following reply was made to PR lib/59067; it has been noted by GNATS.
From: Thomas Klausner <wiz%NetBSD.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: lib/59067: wctrans got error member.
Date: Tue, 11 Feb 2025 07:44:40 +0100
On Tue, Feb 11, 2025 at 02:40:00AM +0000, ru_j217%aliyun.com@localhost wrote:
> wctrans got error member make a crash on running.
I didn't see an error when I tried your test program on NetBSD
10.99.12/x86_64. Where did you get a crash? What was the backtrace?
However, you should really check the return value of wctrans, the man
page says:
RETURN VALUES
wctrans() returns:
0 If the string charmap does not corresponding to a valid
character mapping name.
(There's a typo, it should be "tolower", not "towlower".)
#include <stdio.h>
#include <wchar.h>
#include <locale.h>
#include <wctype.h>
int main()
{
printf("set locale: %s\n", setlocale(LC_ALL, ""));
wchar_t wc = L'A';
wctrans_t lower = wctrans("towlower");
if (lower == 0) {
printf("wctrans failed\n");
return 1;
}
// crash on this line
wchar_t res = towctrans(wc, lower);
if (res != WEOF) {
printf("wc: %lc, res: %lc\n", wc, res);
} else {
printf("test failed!\n");
}
return 0;
}
Thomas