public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: cygwin 2.4.1: broken ps_AF and ps_AF.utf8 locales
Date: Mon, 08 Feb 2016 12:37:00 -0000	[thread overview]
Message-ID: <20160208123739.GA12975@calimero.vinschen.de> (raw)
In-Reply-To: <20160202043247.GP31193@mars.tony.develop-help.com>

[-- Attachment #1: Type: text/plain, Size: 1259 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2016-02-08 12:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-02  4:33 Tony Cook
2016-02-02  8:42 ` Achim Gratz
2016-02-08 12:37 ` Corinna Vinschen [this message]
2016-02-02 22:22 Tony Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160208123739.GA12975@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).