NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

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
 


Home | Main Index | Thread Index | Old Index