From: Michal Nowak <mnowak@startmail.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Junio C Hamano <gitster@pobox.com>,
Phillip Wood <phillip.wood@talktalk.net>,
Alban Gruin <alban.gruin@gmail.com>,
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:24:26 +0100 [thread overview]
Message-ID: <eda7b1c4-5fd6-5440-8998-75eab9f73e47@startmail.com> (raw)
In-Reply-To: <nycvar.QRO.7.76.6.1902011530440.41@tvgsbejvaqbjf.bet>
On 02/01/19 03:33 PM, Johannes Schindelin wrote:
> Hi Michal,
>
> On Fri, 1 Feb 2019, Michal Nowak wrote:
>
>> On Friday, February 1, 2019 at 8:38 AM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>>>
>>> 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.
>
> You already have that example. Just take the UTF-8 text in your original
> bug report, put it into something like
>
> int main(int argc, char **argv)
> {
> char utf8[] = "... your text here...";
>
> printf("%.*s", (int)(sizeof(utf8) - 1), utf8);
>
> return 0;
> }
>
> You should first verify, though, that this replicate the problem, and if
> it does not, use libintl (I think you have to `#include <gettext.h>` and
> `-lintl` or some such) and see whether that reproduces your problem.
Thank you, Johannes for the test case.
However, I don't see any problem with the output on OpenIndiana:
{global} newman@lenovo:~ $ cat printf.c
#include <stdio.h>
//#include <gettext.h>
int main(int argc, char **argv) {
char utf8[] = "Gergő Mihály Doma\n";
printf("%.*s", (int)(sizeof(utf8) - 1), utf8);
return 0;
}
{global} newman@lenovo:~ $ gcc printf.c -o printf && ./printf
Gergő Mihály Doma
Enabled the gettext header in the source file.
{global} newman@lenovo:~ $ gcc printf.c -o printf_intl -lintl
-I/usr/share/gettext/ && ./printf_intl
Gergő Mihály Doma
{global} newman@lenovo:~ $ ldd printf printf_intl
printf:
libc.so.1 => /lib/libc.so.1
libm.so.2 => /lib/libm.so.2
printf_intl:
libintl.so.1 => /lib/libintl.so.1
libc.so.1 => /lib/libc.so.1
libm.so.2 => /lib/libm.so.2
{global} newman@lenovo:~ $ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_ALL=
I even tried more arcane characters from
https://www.w3.org/2001/06/utf-8-test/UTF-8-demo.html but they are
displayed correctly as well.
Michal
>
> Ciao,
> Johannes
>
>>
>> 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
>>
next prev parent reply other threads:[~2019-02-01 16:24 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 [this message]
2019-02-01 17:30 ` Junio C Hamano
2019-02-01 19:00 ` Michal Nowak
2019-02-01 16:15 ` Alban Gruin
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eda7b1c4-5fd6-5440-8998-75eab9f73e47@startmail.com \
--to=mnowak@startmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=alban.gruin@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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).