Bug #10350
openprintf: * refers to maximum number of bytes not characters
0%
Description
On OpenIndiana (illumos-f482e26cbe
) line of the interactive git
rebase text after a particular name (Gergő Mihály Doma) is broken:
pick 1ea94c756c 10202 loader: use screen-#rows to find bottom left co-ordinates Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Gergő Mihály Doma <domag02@gmail.com> Approved by: Robert Mustacchi <rm@joyent.com> p pick cadd68ea00 10078 smatch fixes for UCB Reviewed by: Andy Fiddaman <omnios@citrus-it.net> Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Peter Tribble <peter.tribble@gmail.com> Approved by: Robert Mustacchi <rm@joyent.com>
While discussing this issue with git upstream (https://public-inbox.org/git/a50734d9-4d30-5847-b5df-67a8458a36cb@startmail.com/) it turned out that this likely illumos libc bug. See the attached test case.
On Linux:
Before setting locale: Expected output: áaaa Actual output: áaaa After setting locale: Expected output: áaaa Actual output: áaaa
On illumos:
Before setting locale: Expected output: áaaa Actual output: áaaa After setting locale: Expected output: áaaa Actual output: áaaaa
According to https://public-inbox.org/git/2cbb5818-643d-bafd-6721-91e0d291a5fd@talktalk.net/:
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. [1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html [2] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf page 309
Files
Updated by Toomas Soome almost 4 years ago
Michal Nowak wrote:
On OpenIndiana (
illumos-f482e26cbe
) line of the interactivegit
rebase text after a particular name (Gergő Mihály Doma) is broken:[...]
While discussing this issue with git upstream (https://public-inbox.org/git/a50734d9-4d30-5847-b5df-67a8458a36cb@startmail.com/) it turned out that this likely illumos libc bug. See the attached test case.
On Linux:
[...]
On illumos:
[...]
According to https://public-inbox.org/git/2cbb5818-643d-bafd-6721-91e0d291a5fd@talktalk.net/:
[...]
The problem is there:
/* * sec_display only needed if width * is specified (ie, "%<width>s") * Solaris behavior counts <width> in * screen column width. (If XPG4 behavior, * <width> is counted in bytes.) */
and indeed:
$ gcc -D_XOPEN_SOURCE -D_XOPEN_VERSION=4 /usr/lib/values-xpg4.o test-case.c $ ./a.out Before setting locale: Expected output: áaaa Actual output: áaaa After setting locale: Expected output: áaaa Actual output: áaaa
So we do have two options - either build git with XPG4 or change illumos default.
Updated by Michal Nowak almost 4 years ago
With -D_XOPEN_SOURCE -D_XOPEN_VERSION=4
following git
test case from t0021-conversion.sh
fails:
test_expect_success 'filter that does not read is fine' ' test-tool genrandom foo $((128 * 1024 + 1)) >big && echo "big filter=epipe" >.gitattributes && test_config filter.epipe.clean "echo xyzzy" && git add big && git cat-file blob :big >actual && echo xyzzy >expect && sleep 300 && test_cmp expect actual '
Files "big" and "actual" are the same, containing 128 KB of random data.
The test case passes without those difines.