| www.delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-SWARE-Spam-Status: | No, hits=-3.2 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_63,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY |
| X-Spam-Check-By: | sourceware.org |
| To: | cygwin AT cygwin DOT com |
| From: | Eric Blake <ebb9 AT byu DOT net> |
| Subject: | [1.7] wctomb bug |
| Date: | Thu, 26 Feb 2009 21:11:08 +0000 (UTC) |
| Lines: | 26 |
| Message-ID: | <loom.20090226T210806-72@post.gmane.org> |
| Mime-Version: | 1.0 |
| User-Agent: | Loom/3.14 (http://gmane.org/) |
| X-IsSubscribed: | yes |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
Simple test case. This application uses the C locale (by virtue of the fact
that we did not use setlocale(), and evidenced by mb_cur_max of 1). On Linux,
this correctly shows wctomb rejecting the conversion (0x100 is too big to fit
in a 1-byte sequence) with EILSEQ, but newlib currently truncates the invalid
wchar_t value to int and returns 1.
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <wchar.h>
#include <string.h>
#include <limits.h>
int main (int argc, char **argv)
{
wchar_t w = 0x100;
char str[MB_LEN_MAX];
int i = wctomb(str, w);
printf("mb_cur_max %zd, len %d, str[0] 0x%02hhx, errno %d\n",
MB_CUR_MAX, i, str[0], errno);
return 0;
}
--
Eric Blake
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |