On 3/23/21 5:40 AM, Markus Armbruster wrote:
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 <arm...@redhat.com>
Reviewed-by: John Snow <js...@redhat.com>
---
scripts/qapi/expr.py | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py
index 30285fe334..a815060ee2 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