From nobody Sun Feb 8 19:55:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629815172; cv=none; d=zohomail.com; s=zohoarc; b=ivmDV9Lxi3dedlr5V4Z8IdawpdiU0nbjqyj3RhPpF+hn2yViAHEkdguq+ckugvIwacA5CMAPHzDZztFLdY3wlA/2tTEAfADxcmGwGuAkBBJvPIW303xuZl9AdqB+lOOKZiyER2fyM2WeF3ak2/R/B7EQL45KllIrwCyhlYLUTLM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629815172; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xGQr9cFpwb8xY80pKclzG9c9ORXp0ilOQxPnkiTGl/0=; b=RzBRq42KpIFMvAM4UDNX2XdUJigGZGUKrEZbUbKuAlet7m02jpgE+fA08ihyTrwQX5Wj6dEraW896j1p4N5wFa+yB/Qu8bbmIPrEOF4O4cby9cClpO+PKDZX48EkO7w2Aot1Ecki7yP2qIbdifT4sA2nxdkGDCIfGSEheOOL4iE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1629815172108871.6089863193893; Tue, 24 Aug 2021 07:26:12 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-160-y3717PwWMXCJuLnrAVnGAQ-1; Tue, 24 Aug 2021 10:26:08 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 06945CC62B; Tue, 24 Aug 2021 14:26:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D3EF61036D33; Tue, 24 Aug 2021 14:26:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9AB0D4A70B; Tue, 24 Aug 2021 14:26:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17OEQ19Z003533 for ; Tue, 24 Aug 2021 10:26:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6E4026A912; Tue, 24 Aug 2021 14:26:01 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id EABCA6A8FE for ; Tue, 24 Aug 2021 14:25:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629815171; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xGQr9cFpwb8xY80pKclzG9c9ORXp0ilOQxPnkiTGl/0=; b=Hzp8RgwnsfTRygG9z/EMOwVaBBQMI0aq2jFcESCuhCxZtV+oduFjUN3lfB19dfDWt/8b7B manU01dmvJGbqAB1y5+xUXZaasu3mt8GR6UIVPk5oo7gHAFpjCmoPK+Ug+iF+L2kbyhkoi 5toNTMZs5BbWB63KnkknVbij03CrZZ8= X-MC-Unique: y3717PwWMXCJuLnrAVnGAQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 09/11] scripts: group-qemu-caps: only pass relevant lines to regroup_caps Date: Tue, 24 Aug 2021 16:25:12 +0200 Message-Id: <97070ce021a7bae1693102958a87e6f0c8b9f4aa.1629815074.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629815172474100001 This makes reconstructing the fixed version of the file a bit more difficult, but lets us get rid of a cryptic bool. Signed-off-by: J=C3=A1n Tomko --- scripts/group-qemu-caps.py | 63 +++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py index dce25099b8..36a7d7602f 100755 --- a/scripts/group-qemu-caps.py +++ b/scripts/group-qemu-caps.py @@ -61,48 +61,41 @@ def load_caps_flags(lines): return capsflags =20 =20 -def regroup_caps(original, start_regex, end_regex, +def regroup_caps(original, trailing_newline, counter_prefix, capsflags): step =3D 5 fixed =3D [] - game_on =3D False counter =3D 0 for line in original: - if game_on: - if re.search(r'''.*/\* [0-9]+ \*/.*''', line): - continue - if re.search(r'''^\s*$''', line): - continue - if counter % step =3D=3D 0: - if counter !=3D 0: - fixed.append("") - fixed.append("%s/* %d */" % (counter_prefix, counter)) - - if not (line.find("/*") !=3D -1 and line.find("*/") =3D=3D -1): - # count two-line comments as one line - counter =3D counter + 1 - - if re.search(start_regex, line): - game_on =3D True - elif game_on and re.search(end_regex, line): - if (counter - 1) % step =3D=3D 0: - fixed =3D fixed[:-1] # /* $counter */ - if counter !=3D 1: - fixed =3D fixed[:-1] # \n - - if trailing_newline: + if re.search(r'''.*/\* [0-9]+ \*/.*''', line): + continue + if re.search(r'''^\s*$''', line): + continue + if counter % step =3D=3D 0: + if counter !=3D 0: fixed.append("") + fixed.append("%s/* %d */" % (counter_prefix, counter)) =20 - game_on =3D False + if not (line.find("/*") !=3D -1 and line.find("*/") =3D=3D -1): + # count two-line comments as one line + counter =3D counter + 1 =20 # ensure that flag names in the .c file have the correct flag in t= he comment - if game_on and capsflags: + if capsflags: flagname =3D re.search(r'''.*".*",''', line) if flagname: line =3D flagname[0] + " /* %s */" % capsflags[counter - 1] =20 fixed.append(line) =20 + if (counter - 1) % step =3D=3D 0: + fixed =3D fixed[:-1] # /* $counter */ + if counter !=3D 1: + fixed =3D fixed[:-1] # \n + + if trailing_newline: + fixed.append("") + return fixed =20 =20 @@ -147,28 +140,28 @@ source_lines =3D load_file(source_path) 'QEMU_CAPS_LAST /* this must') capsflags =3D load_caps_flags(header_lines[start:end]) =20 -header_fixed =3D regroup_caps(header_lines, - r'virQEMUCapsFlags grouping marker', - r'QEMU_CAPS_LAST \/\* this must', +(source_start, source_end) =3D find_markers(source_lines, + 'virQEMUCaps grouping marker', + ' );') + +header_fixed =3D regroup_caps(header_lines[start + 1:end], 1, " ", None) -source_fixed =3D regroup_caps(source_lines, - r'virQEMUCaps grouping marker', - r'\);', +source_fixed =3D regroup_caps(source_lines[source_start + 1:source_end], 0, " ", capsflags) =20 if not check_wrapping(header_path, header_lines, - header_fixed, + header_lines[:start + 1] + header_fixed + header_lin= es[end:], args.check): ret =3D False =20 if not check_wrapping(source_path, source_lines, - source_fixed, + source_lines[:source_start + 1] + source_fixed + sou= rce_lines[source_end:], args.check): ret =3D False =20 --=20 2.31.1