aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2021-09-30 12:53:55 -0600
committerTom Tromey <tromey@adacore.com>2021-10-19 13:22:31 -0600
commit775d36a916c1be042ceb67fc6ea22f53a9f5e331 (patch)
tree37dca5468d9c3a3333bf068da8bf7eb232407a5a
parent5dfe4bfcb96945dc5cc1f8717be454f1f7f6bbec (diff)
downloadgdb-775d36a916c1be042ceb67fc6ea22f53a9f5e331.zip
gdb-775d36a916c1be042ceb67fc6ea22f53a9f5e331.tar.gz
gdb-775d36a916c1be042ceb67fc6ea22f53a9f5e331.tar.bz2
Fix Rust lex selftest when using libiconv
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.
-rw-r--r--gdb/rust-parse.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c
index 539e1c8..e12bf29 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"));