From nobody Sat Jul 5 16:15:55 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15215286203661011.9562871947128; Mon, 19 Mar 2018 23:50:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 73CB93DE42; Tue, 20 Mar 2018 06:50:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 45FE25C888; Tue, 20 Mar 2018 06:50:18 +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 05D40180BAEC; Tue, 20 Mar 2018 06:50:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2K6nw85019589 for ; Tue, 20 Mar 2018 02:49:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id C6CD8C5DA7; Tue, 20 Mar 2018 06:49:58 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BE1FB5C545 for ; Tue, 20 Mar 2018 06:49:58 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F401C356C2 for ; Tue, 20 Mar 2018 06:49:57 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id f14so457123wre.8 for ; Mon, 19 Mar 2018 23:49:57 -0700 (PDT) Received: from rst.Home ([2a02:c7d:692a:c500:1ebc:73f3:5f60:b131]) by smtp.gmail.com with ESMTPSA id g38sm1923269wra.77.2018.03.19.23.49.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Mar 2018 23:49:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+NrtiXcMnDlhAhkAVbpzi/uRoYKK1hY98PbOp5aO7Qw=; b=q0aDjui4dg6cNHhfPVASk8WXwhUB+c6WiCq518gd5H2oA9Y+ENCOkk7fKorJRIdKsZ IRQjQNnU2bia10h1TqiaFNnhQM15+k9llSg0k1akxBBwEXeNNTXoAgSvtmRwGOctIVA/ bXxsVJWQBLcDST8w6z9kYU7XDuTh6A2UhLv/MyBZaT7tWBVkkdFnpnMQp96sC0Pj8i4m O6IYWSvCt4jDWQ7wF76opFwEQHcNjRAN6WcfyJm5ONsl3YUZznDe4TiLjKYrB/i4syEO sQNxzufAyCkGEEuntrIxVG1CIG8DFj+pxFhZj/Kzka/wTq+OZPS7ABoQnM69ioPfZFLc S3Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+NrtiXcMnDlhAhkAVbpzi/uRoYKK1hY98PbOp5aO7Qw=; b=BN1KX7OMDF7UT2sFTU2di4/UC30yMeyROkvGJHa8XcXj7L6HPas1NwMX2BlK6FtABG nN4JHMmhmWECDY5UoOozZFfMmGdgzNhX3R+QpOiiiqMHnkhpPQwiD5xhWlOpv5126kXy j7IB1qvqsR9t/tUfiXWOIicC05aueUr/b3x9GpDJdbDKKfGsjOkiiPLXvi4CGSShxqlV IAcX/c8WwYTDL78hxGuaNh1AloCzEpZvqzui/olIyuwjXrKSvtRHDw+erQgbOGBTJD51 wbxkzw4j5BlZz5mjpvyy1pL2DIDqusN4bX5r11uINrwD83Qj79eODSUh1RpkIn+lTA2Y la2g== X-Gm-Message-State: AElRT7EfvEzAu/CqDAHshhVFPBdZRlpALcsrLrZ8fvEzkHpinHJwB4JN viR2gWC8FeAK/m6AN52k0nnCqcd8 X-Google-Smtp-Source: AG47ELsz3HADe+rZ54jgzZlWzesPM47IP7bmQgkPbGbwes1Yc7B4aER/Nnt48p/DBff4ADRWdlEzFg== X-Received: by 10.223.193.10 with SMTP id r10mr775224wre.255.1521528596452; Mon, 19 Mar 2018 23:49:56 -0700 (PDT) From: Radostin Stoyanov To: libvir-list@redhat.com Date: Tue, 20 Mar 2018 06:49:06 +0000 Message-Id: <20180320064908.17723-24-rstoyanov1@gmail.com> In-Reply-To: <20180320064908.17723-1-rstoyanov1@gmail.com> References: <20180320064908.17723-1-rstoyanov1@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 20 Mar 2018 06:49:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 20 Mar 2018 06:49:58 +0000 (UTC) for IP:'209.85.128.196' DOMAIN:'mail-wr0-f196.google.com' HELO:'mail-wr0-f196.google.com' FROM:'rstoyanov1@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.139 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.128.196 mail-wr0-f196.google.com 209.85.128.196 mail-wr0-f196.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Radostin Stoyanov Subject: [libvirt] [PATCHv2 23/25] apibuild: Simplify parsing string tokens 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 20 Mar 2018 06:50:18 +0000 (UTC) X-ZohoMail-DKIM: fail (Computed bodyhash is different from the expected one) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Improve readability and reduce the complexity of the code that is searching for string tokens (i.e. characters surrounded by a single or double quote). Signed-off-by: Radostin Stoyanov --- docs/apibuild.py | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/docs/apibuild.py b/docs/apibuild.py index 4c8fa5740..94de13b56 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -483,28 +483,16 @@ class CLexer: break l =3D len(line) if line[0] =3D=3D '"' or line[0] =3D=3D "'": - end =3D line[0] - line =3D line[1:] - found =3D 0 - tok =3D "" - while found =3D=3D 0: - i =3D 0 - l =3D len(line) - while i < l: - if line[i] =3D=3D end: - self.line =3D line[i+1:] - line =3D line[:i] - l =3D i - found =3D 1 - break - if line[i] =3D=3D '\\': - i =3D i + 1 - i =3D i + 1 - tok =3D tok + line - if found =3D=3D 0: - line =3D self.getline() - if line is None: - return None + quote =3D line[0] + i =3D 1 + while quote not in line[i:]: + i =3D len(line) + nextline =3D self.getline() + if nextline is None: + return None + line +=3D nextline + + tok, self.line =3D line[1:].split(quote, 1) self.last =3D ('string', tok) return self.last =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list