delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:date:from:to:subject:message-id:mime-version | |
:content-type; q=dns; s=default; b=slRsFrzVblEiIGGOo7UhrioITzk+d | |
9UQqUHWl31D+A9c1FK3HBcvRMETL1S/Uxpy1U9jpgqncw7s/1CedxDKuybpZhMon | |
AKmYk8LM0kTyJxHIB8nWJGkgwDySlthVyTPRtQI39fzpKBSUmgjZDrevu3ipaxIp | |
1LPlvPAqU7HHVM= | |
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:date:from:to:subject:message-id:mime-version | |
:content-type; s=default; bh=ufsQMo0sfz02qFenNrI1uRf+r7Q=; b=p+H | |
y8r21ohDh7gNmwNAeMK5J1ut/4BJoRP11gx8m5jomOqmM5XtJk7tUYFXtzE9h2be | |
PRZZd/FeKnCMcMF0p1TkDocb5LGElPfTOiFERfIZUsy0Q6M2U+8Ypzgm7GRbQV94 | |
B6CTITR87gfduDTkSJKwhsEy7StMgwt0GUHXWuMs= | |
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 |
Authentication-Results: | sourceware.org; auth=none |
X-Virus-Found: | No |
X-Spam-SWARE-Status: | No, score=-0.5 required=5.0 tests=BAYES_20,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=mars, H*F:U*tony, 9699919799, pubs.opengroup.org |
X-HELO: | mars.tony.develop-help.com |
Date: | Tue, 2 Feb 2016 15:32:47 +1100 |
From: | Tony Cook <tony AT develop-help DOT com> |
To: | cygwin AT cygwin DOT com |
Subject: | cygwin 2.4.1: broken ps_AF and ps_AF.utf8 locales |
Message-ID: | <20160202043247.GP31193@mars.tony.develop-help.com> |
MIME-Version: | 1.0 |
User-Agent: | Mutt/1.5.23 (2014-03-12) |
Hi list, Simplified to a C program below, calls to sprintf() under the ps_AF and ps_AF.utf8 locales are returning a value that doesn't match the length of the formatted string: tony AT phobos ~ $ cat ps_AF.c #include <stdio.h> #include <locale.h> #include <string.h> int main(int argc, char **argv) { char buf[100]; char *loc = argc > 1 ? argv[1] : "ps_AF"; const char *real_loc; if (!(real_loc = setlocale(LC_NUMERIC, loc))) { perror("setlocale"); return 1; } printf("locale %s\n", real_loc); size_t len = sprintf(buf, "%g", 2.34); printf("len %zu\n", len); printf("strlen %zu\n", strlen(buf)); return 0; } tony AT phobos ~ $ gcc -ops_AF.exe ps_AF.c tony AT phobos ~ $ ./ps_AF locale ps_AF len 4 strlen 5 tony AT phobos ~ $ ./ps_AF ps_AF.utf8 locale ps_AF.utf8 len 4 strlen 5 tony AT phobos ~ $ ./ps_AF en_US.utf8 locale en_US.utf8 len 4 strlen 4 tony AT phobos ~ $ uname -a CYGWIN_NT-6.1-WOW phobos 2.4.1(0.293/5/3) 2016-01-24 11:24 i686 Cygwin The man pages and C standard could be read as sprintf() returning the number of multi-byte characters, but if cygwin is intended to follow Linux behaviour: tony AT mars:~/play$ gcc -ops_AF ps_AF.c tony AT mars:~/play$ ./ps_AF locale ps_AF len 5 strlen 5 tony AT mars:~/play$ ./ps_AF ps_AF.utf8 locale ps_AF.utf8 len 5 strlen 5 tony AT mars:~/play$ ./ps_AF en_AU.utf8 locale en_AU.utf8 len 4 strlen 4 tony AT mars:~/play$ uname -a Linux mars 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u3 (2016-01-17) x86_64 GNU/Linux (and the decimal point under ps_AF on Linux is multi-byte, character 0x66b or ARABIC DECIMAL SEPARATOR.) POSIX is less confusing and specifies: Upon successful completion, the sprintf() function shall return the number of bytes written to s, excluding the terminating null byte. (http://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html) Tony -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |