public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix Rust lex selftest when using libiconv
@ 2021-09-30 18:55 Tom Tromey
  2021-10-19 19:26 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2021-09-30 18:55 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The Rust lex selftest fails on our Windows build.  I tracked this down
to a use of UTF-32 as a parameter to convert_between_encodings.  Here,
iconv_open succeeds, but the actual conversion of a tab character
fails with EILSEQ.  I suspect that "UTF-32" is being interpreted as
big-endian, as changing the call to use "UTF-32LE" makes it work.
This patch implements this fix.
---
 gdb/rust-parse.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c
index 539e1c8256d..e12bf29a71d 100644
--- a/gdb/rust-parse.c
+++ b/gdb/rust-parse.c
@@ -695,9 +695,16 @@ rust_parser::lex_string ()
 	  if (is_byte)
 	    obstack_1grow (&obstack, value);
 	  else
-	    convert_between_encodings ("UTF-32", "UTF-8", (gdb_byte *) &value,
-				       sizeof (value), sizeof (value),
-				       &obstack, translit_none);
+	    {
+#if WORDS_BIGENDIAN
+#define UTF32 "UTF-32BE"
+#else
+#define UTF32 "UTF-32LE"
+#endif
+	      convert_between_encodings (UTF32, "UTF-8", (gdb_byte *) &value,
+					 sizeof (value), sizeof (value),
+					 &obstack, translit_none);
+	    }
 	}
       else if (pstate->lexptr[0] == '\0')
 	error (_("Unexpected EOF in string"));
-- 
2.31.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix Rust lex selftest when using libiconv
  2021-09-30 18:55 [PATCH] Fix Rust lex selftest when using libiconv Tom Tromey
@ 2021-10-19 19:26 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2021-10-19 19:26 UTC (permalink / raw)
  To: Tom Tromey via Gdb-patches; +Cc: Tom Tromey

>>>>> "Tom" == Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> The Rust lex selftest fails on our Windows build.  I tracked this down
Tom> to a use of UTF-32 as a parameter to convert_between_encodings.  Here,
Tom> iconv_open succeeds, but the actual conversion of a tab character
Tom> fails with EILSEQ.  I suspect that "UTF-32" is being interpreted as
Tom> big-endian, as changing the call to use "UTF-32LE" makes it work.
Tom> This patch implements this fix.

I'm checking this in.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-19 19:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 18:55 [PATCH] Fix Rust lex selftest when using libiconv Tom Tromey
2021-10-19 19:26 ` Tom Tromey

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).