On Nov 13 2020, Nikhil Benesch via Gcc-patches wrote: > +static void > +demangle_const_char (struct rust_demangler *rdm) > +{ > + size_t hex_len; > + uint64_t value; > + > + hex_len = parse_hex_nibbles (rdm, &value); > + > + if (hex_len == 0 || hex_len > 8) > + { > + rdm->errored = 1; > + return; > + } > + > + /* Match Rust's character "debug" output as best as we can. */ > + PRINT ("'"); > + if (value == '\t') > + PRINT ("\\t"); > + else if (value == '\r') > + PRINT ("\\r"); > + else if (value == '\n') > + PRINT ("\\n"); > + else if (value > ' ' && value < '~') > + /* Rust also considers many non-ASCII codepoints to be printable, but > + that logic is not easily ported to C. */ > + print_str (rdm, (char *) &value, 1);
* rust-demangle.c (demangle_const_char): Properly print the character value. diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c index 6fd8f6a4db0..449941b56dc 100644 --- a/libiberty/rust-demangle.c +++ b/libiberty/rust-demangle.c @@ -1253,9 +1253,12 @@ demangle_const_char (struct rust_demangler *rdm) else if (value == '\n') PRINT ("\\n"); else if (value > ' ' && value < '~') - /* Rust also considers many non-ASCII codepoints to be printable, but - that logic is not easily ported to C. */ - print_str (rdm, (char *) &value, 1); + { + /* Rust also considers many non-ASCII codepoints to be printable, but + that logic is not easily ported to C. */ + char c = value; + print_str (rdm, &c, 1); + } else { PRINT ("\\u{"); -- 2.31.1 -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."