This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [ping] [PATCH] Different outputs affected by locale
- From: Yao Qi <yao at codesourcery dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: Tom Tromey <tromey at redhat dot com>, Joel Brobecker <brobecker at adacore dot com>, <gdb-patches at sourceware dot org>
- Date: Tue, 17 Jun 2014 11:44:28 +0800
- Subject: Re: [ping] [PATCH] Different outputs affected by locale
- Authentication-results: sourceware.org; auth=none
- References: <1401192650-29688-1-git-send-email-yao at codesourcery dot com> <538EAEE5 dot 2080708 at codesourcery dot com> <20140604124708 dot GR4289 at adacore dot com> <538F1CC3 dot 9090605 at codesourcery dot com> <87oay8a0t6 dot fsf at fleche dot redhat dot com> <538F803A dot 9020007 at redhat dot com> <538FE412 dot 1050806 at codesourcery dot com> <53903119 dot 6000204 at redhat dot com> <53903EE5 dot 8090107 at codesourcery dot com> <539042A2 dot 4050409 at redhat dot com> <539571C6 dot 40605 at codesourcery dot com> <53958862 dot 5020106 at redhat dot com> <5397BCEC dot 8080300 at codesourcery dot com> <539990BD dot 9020504 at redhat dot com> <5399BB32 dot 5050409 at codesourcery dot com> <5399E216 dot 1090601 at redhat dot com>
On 06/13/2014 01:23 AM, Pedro Alves wrote:
> So what I'm thinking is indeed going with making the test
> accept the cent, but conditioned, like:
OK, that is more restrict.
>
> # Fallback to assuming 7-bit ASCII. Test are ran under LC_CTYPE=C.
>
> set cent "\\\\242"
>
> set test "show host-charset"
> gdb_test_multiple $test $test {
> -re "CP1252\r\n$gdb_prompt $" {
I tweak the pattern to match the output...
> # With Windows code page 1252 (Latin 1), the cent
> # is printable.
> set cent "\u00A2"
> pass $test
> }
> -re "$gdb_prompt $" {
> pass $test
> }
> }
... and how about the patch below?
--
Yao (éå)
Subject: [PATCH] Different outputs affected by hosts
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We find the following fails in gdb test on mingw host.
FAIL: gdb.base/wchar.exp: print repeat
FAIL: gdb.base/wchar.exp: print repeat_p
FAIL: gdb.base/wchar.exp: print repeat (print null on)
FAIL: gdb.base/wchar.exp: print repeat (print elements 3)
FAIL: gdb.base/wchar.exp: print repeat_p (print elements 3)
print repeat^M
$7 = L"A", 'Â' <repeats 21 times>, "B", '\000' <repeats 104 times>^M
(gdb) FAIL: gdb.base/wchar.exp: print repeat
the \242 is expected in the test but cent sign is displayed.
In valprint.c:print_wchar, wchar_printable is called to determine
whether a wchar is printable. wchar_printable calls iswprint but
the iswprint's return value depends on LC_CTYPE setting of locale [1, 2].
The output may vary with different locale settings and OS. IMO, 'Â'
(cent sign) is a correct output on Windows.
[1] http://pubs.opengroup.org/onlinepubs/009604499/functions/iswprint.html
[2] http://msdn.microsoft.com/en-us/library/ewx8s4kw.aspx
This patch is set $cent to cent sign if the GDB is running on a
Windows host.
gdb/testsuite:
2014-06-17 Yao Qi <yao@codesourcery.com>
* gdb.base/wchar.exp: Set $cent to \u00A2 if "host-charset" is
CP1252.
---
gdb/testsuite/gdb.base/wchar.exp | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/gdb/testsuite/gdb.base/wchar.exp b/gdb/testsuite/gdb.base/wchar.exp
index 4290478..651bd88 100644
--- a/gdb/testsuite/gdb.base/wchar.exp
+++ b/gdb/testsuite/gdb.base/wchar.exp
@@ -37,6 +37,20 @@ gdb_test "print simple\[2\]" "= 99 L'c'"
gdb_test "print difficile\[2\]" "= 65261 L'\\\\xfeed'"
set cent "\\\\242"
+
+set test "show host-charset"
+gdb_test_multiple $test $test {
+ -re "CP1252\".*\r\n$gdb_prompt $" {
+ # With Windows code page 1252 (Latin 1), the cent
+ # is printable.
+ set cent "\u00A2"
+ pass $test
+ }
+ -re "$gdb_prompt $" {
+ pass $test
+ }
+}
+
gdb_test "print repeat" "= L\"A\", '$cent' <repeats 21 times>, \"B.*"
global hex
--
1.9.0