[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] xen-analysis.py: Substitute only the comment instead of the line
commit d064b429b670998e1e4a5ab73ac34d67cf44b083 Author: Luca Fancellu <luca.fancellu@xxxxxxx> AuthorDate: Wed Jan 31 11:02:40 2024 +0000 Commit: Julien Grall <jgrall@xxxxxxxxxx> CommitDate: Thu Feb 22 16:08:22 2024 +0000 xen-analysis.py: Substitute only the comment instead of the line Change the code in tag_database.py to substitute only the SAF-* comment instead of replacing the line. Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx> Acked-by: Stefano Stabellini <sstabellini@xxxxxxxxxx> --- xen/scripts/xen_analysis/tag_database.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/xen/scripts/xen_analysis/tag_database.py b/xen/scripts/xen_analysis/tag_database.py index abba163aec..dc0558a46e 100644 --- a/xen/scripts/xen_analysis/tag_database.py +++ b/xen/scripts/xen_analysis/tag_database.py @@ -16,14 +16,18 @@ tool_syntax = { "eclair":"-E> hide VID 1 \"\"" } +def get_xen_tag_regex(tool): + return rf'(?P<tag>SAF-(?P<id>\d+)-(?P<type>safe|false-positive-{tool}))' + def get_xen_tag_index_type_regex(tool): - return rf'^SAF-(?P<id>\d+)-(?P<type>safe|false-positive-{tool})$' + return rf'^{get_xen_tag_regex(tool)}$' def get_xen_tag_comment_regex(tool): - tag=rf'(?P<tag>SAF-\d+-(?:safe|false-positive-{tool}))' - return rf'^[ \t]*/\* +{tag}.*\*/$' + before_comment = r'(?P<before>[ \t]*)' + comment = rf'(?P<comment>/\* +{get_xen_tag_regex(tool)}.*\*/)' + return rf'^(?P<full_line>{before_comment}{comment})$' # Returns a data structure containing dictionaries for safe and false-positive-* @@ -66,7 +70,7 @@ def load_tag_database(tool, input_files, data_struct = None, schema = "safe"): # Save in safe or false-positive-* the key {#id: "comment"} id_number = int(xen_tag.group('id')) key = xen_tag.group('type') - ret[key][id_number] = "/* {} */\n".format(comment) + ret[key][id_number] = "/* {} */".format(comment) else: raise TagDatabaseError( "Error in database file, entry {} has unexpected " @@ -101,7 +105,11 @@ def substitute_tags(tool, input_file, grep_struct, subs_rules): id_number = int(xen_tag_regex_obj.group('id')) key = xen_tag_regex_obj.group('type') if id_number in subs_rules[key]: - parsed_content[line_number-1] = subs_rules[key][id_number] + comment_in = grep_struct["matches"][line_number]['comment'] + comment_out = subs_rules[key][id_number] + parsed_content[line_number-1] = re.sub( + re.escape(comment_in), comment_out, + parsed_content[line_number-1]) outfile.writelines(parsed_content) except Exception as e: -- generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |