From: Richard Henderson <richard.henderson@linaro.org>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>,
Cleber Rosa <crosa@redhat.com>
Subject: Re: [PATCH] decodetree: Allow use of hex/bin format for argument field values
Date: Mon, 30 Nov 2020 12:22:05 -0600 [thread overview]
Message-ID: <080ab4ac-aa73-a5c6-6dec-7c91d0337111@linaro.org> (raw)
In-Reply-To: <20201130122639.2431070-1-f4bug@amsat.org>
On 11/30/20 6:26 AM, Philippe Mathieu-Daudé wrote:
> # 'Foo=number' sets an argument field to a constant value
> - if re.fullmatch(re_C_ident + '=[+-]?[0-9]+', t):
> + if re.fullmatch(re_C_ident + '=[+-]?(0[bx])?[0-9]+', t):
> (fname, value) = t.split('=')
> - value = int(value)
> + if re.fullmatch('[+-]?0b[0-9]+', value):
> + base = 2
> + elif re.fullmatch('[+-]?0x[0-9]+', value):
> + base = 16
> + else:
> + base = 10
> + value = int(value, base)
> flds = add_field(lineno, flds, fname, ConstField(value))
> continue
Well, the regxps are off. No letters for the hex, and 9 accepted for binary.
I think with the right regexps, just trusting int(value, 0) is good enough.
So maybe something like
re_C_ident + "=[+-]?([0-9]+|0x[0-9a-fA-F]+|0b[01]+)"
r~
next prev parent reply other threads:[~2020-11-30 18:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-30 12:26 [PATCH] decodetree: Allow use of hex/bin format for argument field values Philippe Mathieu-Daudé
2020-11-30 12:32 ` Philippe Mathieu-Daudé
2020-11-30 18:22 ` Richard Henderson [this message]
2020-12-01 8:47 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=080ab4ac-aa73-a5c6-6dec-7c91d0337111@linaro.org \
--to=richard.henderson@linaro.org \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=f4bug@amsat.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).