[PATCH 1/1] strings patch for bug 33360
Alan Modra
amodra@gmail.com
Wed Sep 3 22:57:50 GMT 2025
On Wed, Sep 03, 2025 at 11:02:12PM +0100, Alice Carlotti wrote:
> On Wed, Sep 03, 2025 at 03:08:33PM +0100, Andrew C Aitchison wrote:
> > ---
> > binutils/strings.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/binutils/strings.c b/binutils/strings.c
> > index f5c022b50a1..38da6381edf 100644
> > --- a/binutils/strings.c
> > +++ b/binutils/strings.c
> > @@ -757,8 +757,8 @@ display_utf8_char (const unsigned char * buffer)
> >
> > case 4:
> > printf ("\\u%02x%02x%02x",
>
> Should 5 digit outputs be allowed?
>
> > - ((buffer[0] & 0x07) << 6) | ((buffer[1] & 0x3c) >> 2),
> > - ((buffer[1] & 0x03) << 6) | ((buffer[2] & 0x3c) >> 2),
> > + ((buffer[0] & 0x07) << 2) | ((buffer[1] & 0x30) >> 4),
> > + ((buffer[1] & 0x0f) << 4) | ((buffer[2] & 0x3c) >> 2),
>
> Your updated bit arithmetic looks correct to me, but I do wonder whether we
> should simplify things by building the whole value into a 32 bit integer and
> printing that. Is there any reason we can't do that?
Thanks for reviewing. I'm going to accept the patch as-is.
Improvements, if necessary, can come later.
> Alice
>
> > ((buffer[2] & 0x03) << 6) | ((buffer[3] & 0x3f)));
> > break;
> > default:
> > --
> > 2.48.1
> >
--
Alan Modra
More information about the Binutils
mailing list