This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Simplify and generalize rust-demangle's unescaping logic.
- From: "Ian Lance Taylor via gcc-patches" <gcc-patches at gcc dot gnu dot org>
- To: Eduard-Mihai Burtescu <eddyb at lyken dot rs>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, Ian Lance Taylor <ian at airs dot com>
- Date: Mon, 26 Aug 2019 13:03:53 -0700
- Subject: Re: [PATCH] Simplify and generalize rust-demangle's unescaping logic.
- References: <firstname.lastname@example.org>
- Reply-to: Ian Lance Taylor <iant at google dot com>
On Wed, Aug 14, 2019 at 10:24 AM Eduard-Mihai Burtescu <email@example.com> wrote:
> Previously, rust-demangle.c was special-casing a fixed number
> of '$uXY$' escapes, but 'XY' can technically be any hex value,
> representing some Unicode codepoint.
> This patch adds more general support for '$u...$' escapes,
> similar to https://github.com/alexcrichton/rustc-demangle/pull/29,
> but only for the the ASCII subset. More complete Unicode support
> may come at a later time, but right now I want to keep it simple.
> Escapes that decode to ASCII control codes are considered invalid,
> as the Rust compiler should never emit them, and to avoid any
> undesirable effects from accidentally outputting a control code.
> Additionally, the switch statements, which had one case for each
> alphanumeric character, were replaced with if-else chains.
> Bootstrapped and tested on x86_64-unknown-linux-gnu.
> 2019-08-14 Eduard-Mihai Burtescu <firstname.lastname@example.org>
> * rust-demangle.c (unescape): Remove.
> (parse_lower_hex_nibble): New function.
> (parse_legacy_escape): New function.
> (is_prefixed_hash): Use parse_lower_hex_nibble.
> (looks_like_rust): Use parse_legacy_escape.
> (rust_demangle_sym): Use parse_legacy_escape.
> * testsuite/rust-demangle-expected: Add 'llv$u6d$' test.
This is OK.