git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alban Gruin <alban.gruin@gmail.com>
To: Michal Nowak <mnowak@startmail.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Junio C Hamano <gitster@pobox.com>,
	Phillip Wood <phillip.wood@talktalk.net>,
	phillip.wood@dunelm.org.uk, git@vger.kernel.org
Subject: Re: Broken interactive rebase text after some UTF-8 characters
Date: Fri, 1 Feb 2019 17:15:48 +0100	[thread overview]
Message-ID: <c71f63cb-d956-96f5-4770-581a3b6b5543@gmail.com> (raw)
In-Reply-To: <747726ae27ff52509f831c9615f2b102.startmail@startmail.com>

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

Hi Michal,

Le 01/02/2019 à 10:06, Michal Nowak a écrit :
> Johannes,
> 
> On Friday, February 1, 2019 at 8:38 AM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>> Hi,
>>
>> On Thu, 31 Jan 2019, Junio C Hamano wrote:
>>
>>> Phillip Wood <phillip.wood@talktalk.net> writes:
>>>
>>>>> Are we misusing C formats?
>>>>
>>>> The C standard and POSIX both say that the * refers to the maximum
>>>> number of bytes to print but it looks like it is being treated as the
>>>> maximum number of characters on OpenIndiana.
>>>>
>>>> Johannes - Perhaps we should change it to use fwrite() unless
>>> printf()
>>>> gets fixed and we're sure no other operating systems are affected?
>>>
>>> Avoid such a rewrite, as "%*.s" that takes (int, char *) are used in
>>> many other places in our codebase, if you can.
>>
>> Yes, this would be painful in particular in cases like
>>
>> 	master:advice.c:101:           fprintf(stderr, _("%shint: %.*s%s\n"),
>>
>> where we want to write more than just a variable-length buffer.
>>
>> I am curious: is libintl (gettext) used on OpenIndiana? I ask because
>> AFAIR fprintf() is overridden in that case, and the bug might be a lot
>> easier to fix if it is in libintl rather than in libc.
> 
> here you can see the full output of the OpenIndiana git build: https://hipster.openindiana.org/logs/oi-userland/latest/git.publish.log.
> 
> From what I see there, libintl was found.
> 
> If you believe this is illumos libc bug, it would be cool if someone created an simple testcase, which I can forward to the illumos developers.
> 

I attached a test case to this email.  You can build it with `gcc
test-case.c', and run it with `./a.out'.

Output on my Linux system:

    Before setting locale:
    Expected output:
    áaaa
    Actual output:
    áaaa

    After setting locale:
    Expected output:
    áaaa
    Actual output:
    áaaa

Output on an OpenIndiana system:

    Before setting locale:
    Expected output:
    áaaa
    Actual output:
    áaaa

    After setting locale:
    Expected output:
    áaaa
    Actual output:
    áaaaa

> Thanks,
> Michal
> 
>>
>> Of course, it might *still* be a bug in libc by virtue of handing '%.*s'
>> through to libc's implementation.
>>
>> Alban, can you test this with NO_GETTEXT?
>>
>> Thanks,
>> Johannes

Cheers,
Alban


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: test-case.c --]
[-- Type: text/x-csrc; name="test-case.c", Size: 650 bytes --]

/*
 * Test case for OpenIndiana '%.*s' bug
 * Build with `gcc test-case.c'
 * Run with `./a.out'
 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include <locale.h>
#include <libintl.h>

static void compare_output(const char *str, int len) {
	puts("Expected output:");
	fwrite(str, len, sizeof(char), stdout);

	puts("\nActual output:");
	printf("%.*s\n", len, str);
}

int main(int argc, char **argv) {
	char buf[] = "áaaaaaa";

	puts("Before setting locale:");
	compare_output(buf, 5);

	setlocale(LC_ALL, "");

	puts("\nAfter setting locale:");
	compare_output(buf, 5);

	return EXIT_SUCCESS;
}

  parent reply	other threads:[~2019-02-01 16:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-15 19:29 Broken interactive rebase text after some UTF-8 characters Michal Nowak
2019-01-16 10:33 ` Phillip Wood
2019-01-16 21:36   ` Michal Nowak
2019-01-17 11:04     ` Phillip Wood
2019-01-31 17:43       ` Alban Gruin
2019-01-31 20:40         ` Phillip Wood
2019-01-31 21:00           ` Alban Gruin
2019-01-31 21:35           ` Junio C Hamano
2019-02-01  7:38             ` Johannes Schindelin
2019-02-01  9:06               ` Michal Nowak
2019-02-01 14:33                 ` Johannes Schindelin
2019-02-01 16:24                   ` Michal Nowak
2019-02-01 17:30                     ` Junio C Hamano
2019-02-01 19:00                       ` Michal Nowak
2019-02-01 16:15                 ` Alban Gruin [this message]
2019-02-01 16:13               ` Alban Gruin

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=c71f63cb-d956-96f5-4770-581a3b6b5543@gmail.com \
    --to=alban.gruin@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=mnowak@startmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=phillip.wood@talktalk.net \
    /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 NNTP newsgroup(s).