cygwin 2.4.1: broken ps_AF and ps_AF.utf8 locales

Corinna Vinschen corinna-cygwin@cygwin.com
Mon Feb 8 12:37:00 GMT 2016


On Feb  2 15:32, Tony Cook wrote:
> 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@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;
> }

Thanks for the testcase.

> (and the decimal point under ps_AF on Linux is multi-byte, character
> 0x66b or ARABIC DECIMAL SEPARATOR.)

As on Cygwin.  The problem was that Newlib's printf function didn't take
multibyte decimal points into account when computing the field size for
the output.  I fixed that in the git repo.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20160208/1452d4b0/attachment.sig>


More information about the Cygwin mailing list