diff options
author | Markus Armbruster <armbru@redhat.com> | 2021-03-23 10:40:08 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2021-03-23 22:31:05 +0100 |
commit | d224e0c092653f0b9cff77ba6852147687b1bedb (patch) | |
tree | 5ec1308dd4ccca37e5cc932509bc8b9c3c09ae9e | |
parent | eaab06faa5540e02e4f4782c1a650c9805a36671 (diff) | |
download | qemu-d224e0c092653f0b9cff77ba6852147687b1bedb.zip qemu-d224e0c092653f0b9cff77ba6852147687b1bedb.tar.gz qemu-d224e0c092653f0b9cff77ba6852147687b1bedb.tar.bz2 |
qapi: Move uppercase rejection to check_name_lower()
check_name_lower() is the only user of check_name_str() using
permit_upper=False. Move the associated code from check_name_str() to
check_name_lower(), and drop the parameter.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210323094025.3569441-12-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
-rw-r--r-- | scripts/qapi/expr.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 30285fe..a815060 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -34,32 +34,31 @@ def check_name_is_str(name, info, source): raise QAPISemError(info, "%s requires a string name" % source) -def check_name_str(name, info, source, - permit_upper=False): +def check_name_str(name, info, source): # Reserve the entire 'q_' namespace for c_name(), and for 'q_empty' # and 'q_obj_*' implicit type names. match = valid_name.match(name) if not match or c_name(name, False).startswith('q_'): raise QAPISemError(info, "%s has an invalid name" % source) - if not permit_upper and name.lower() != name: - raise QAPISemError( - info, "%s uses uppercase in name" % source) return match.group(3) def check_name_upper(name, info, source): - stem = check_name_str(name, info, source, permit_upper=True) + stem = check_name_str(name, info, source) # TODO reject '[a-z-]' in @stem def check_name_lower(name, info, source, permit_upper=False): - stem = check_name_str(name, info, source, permit_upper) + stem = check_name_str(name, info, source) + if not permit_upper and name.lower() != name: + raise QAPISemError( + info, "%s uses uppercase in name" % source) # TODO reject '_' in stem def check_name_camel(name, info, source): - stem = check_name_str(name, info, source, permit_upper=True) + stem = check_name_str(name, info, source) # TODO reject '[_-]' in stem, require CamelCase |