GNU logs - #33144, boring messages


Message sent to bug-diffutils@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#33144: Replace some loops with str functions
Resent-From: "Kapus, Timotej" <timotej.kapus13@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-diffutils@HIDDEN
Resent-Date: Wed, 24 Oct 2018 23:43:02 +0000
Resent-Message-ID: <handler.33144.B.15404245705766 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 33144
X-GNU-PR-Package: diffutils
X-GNU-PR-Keywords: 
To: 33144 <at> debbugs.gnu.org
Cc: "Cadar, Cristian" <c.cadar@HIDDEN>
X-Debbugs-Original-To: "bug-diffutils@HIDDEN" <bug-diffutils@HIDDEN>
Received: via spool by submit <at> debbugs.gnu.org id=B.15404245705766
          (code B ref -1); Wed, 24 Oct 2018 23:43:02 +0000
Received: (at submit) by debbugs.gnu.org; 24 Oct 2018 23:42:50 +0000
Received: from localhost ([127.0.0.1]:41017 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gFSnZ-0001Uv-OF
	for submit <at> debbugs.gnu.org; Wed, 24 Oct 2018 19:42:50 -0400
Received: from eggs.gnu.org ([208.118.235.92]:55599)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <timotej.kapus13@HIDDEN>) id 1gFSEz-0000cg-T7
 for submit <at> debbugs.gnu.org; Wed, 24 Oct 2018 19:07:06 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <timotej.kapus13@HIDDEN>) id 1gFSEs-0001Ci-66
 for submit <at> debbugs.gnu.org; Wed, 24 Oct 2018 19:07:00 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,HTML_MESSAGE
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:35587)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <timotej.kapus13@HIDDEN>)
 id 1gFSEq-00011q-UI
 for submit <at> debbugs.gnu.org; Wed, 24 Oct 2018 19:06:58 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:36966)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <timotej.kapus13@HIDDEN>) id 1gFSEp-00089X-QM
 for bug-diffutils@HIDDEN; Wed, 24 Oct 2018 19:06:56 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <timotej.kapus13@HIDDEN>) id 1gFSEn-0000lN-Jy
 for bug-diffutils@HIDDEN; Wed, 24 Oct 2018 19:06:55 -0400
Received: from smtphub2.cc.ic.ac.uk ([2001:630:12:681::47]:59247)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <timotej.kapus13@HIDDEN>)
 id 1gFSEm-0000Xd-9t
 for bug-diffutils@HIDDEN; Wed, 24 Oct 2018 19:06:53 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=imperial.ac.uk; s=main01; h=MIME-Version:Content-Type:Message-ID:Date:
 Subject:CC:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID:
 Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
 :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=An9D9WNxk88CK/PA3n9FIbwtdDuSQmT18Igu7sUxjhY=; b=nRndg11MK6KCJJKdQvtaVI3n2U
 dKAhY6MLfTbLk11zfMPGykfZjSeb952vp/qChE1/D+gDH7mdkIBqlz+FHj/vgI/QKk7SbjMiQ+XRg
 LEJqdyR3+txXK5LF+VXzmOHsAHEbcmJYfSjHQUTp7kRjvUsM6XnRxg4fZT8MN76GrrBk=;
Received: from mail-db5eur01lp0209.outbound.protection.outlook.com
 ([2a01:111:f400:7e02::209]
 helo=EUR01-DB5-obe.outbound.protection.outlook.com)
 by smtphub2.cc.ic.ac.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256)
 (Exim 4.90_1) (envelope-from <timotej.kapus13@HIDDEN>)
 id 1gFSEg-00021H-3r
 for bug-diffutils@HIDDEN; Thu, 25 Oct 2018 00:06:46 +0100
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=ImperialLondon.onmicrosoft.com; s=selector1-imperial-ac-uk;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=An9D9WNxk88CK/PA3n9FIbwtdDuSQmT18Igu7sUxjhY=;
 b=KznYph+ZOS+tKVLstSVk7sxex+XKrsh0zut+kG0/bHkCjLLzOWoGzUAoY2y21m91RfxUX0Qfa3/1f2lW0dqKjUi0BJYVDl5S2sUnm2B5Jc/bOe22Y+A0T0cf1ztGdELuQtrw0g0WcX1gjj9tYSgcL5eDrX+Dh9hCnTP6Mc5o010=
Received: from AMSPR06MB262.eurprd06.prod.outlook.com (10.242.19.19) by
 AMSPR06MB501.eurprd06.prod.outlook.com (10.242.107.11) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.1250.29; Wed, 24 Oct 2018 23:06:41 +0000
Received: from AMSPR06MB262.eurprd06.prod.outlook.com
 ([fe80::d938:fa98:7652:219b]) by AMSPR06MB262.eurprd06.prod.outlook.com
 ([fe80::d938:fa98:7652:219b%3]) with mapi id 15.20.1250.032; Wed, 24 Oct 2018
 23:06:41 +0000
From: "Kapus, Timotej" <timotej.kapus13@HIDDEN>
Thread-Topic: Replace some loops with str functions
Thread-Index: AQHUa+0GHYe4o+/aj0eDja5+tUHXbA==
Date: Wed, 24 Oct 2018 23:06:41 +0000
Message-ID: <AMSPR06MB2629589702E6F37524A2779D5F60@HIDDEN>
Accept-Language: sl-SI, en-US
Content-Language: sl-SI
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
authentication-results: spf=none (sender IP is )
 smtp.mailfrom=timotej.kapus13@HIDDEN; 
x-originating-ip: [2a02:c7f:c01c:0:14f6:e749:fcfe:79ff]
x-ms-publictraffictype: Email
x-microsoft-exchange-diagnostics: 1; AMSPR06MB501;
 20:x+GMAErXK5FxRCIquFTIuxCWSan44MarenYZ9cVBm8Wu8R+OFURS6sQK+IDZRa7/kbQffbPdUEfVhgedYWhVD9GyzNrXODNvJpsoCZi8AaMTQ1F9f251I64vw8F+WOznfik6mGja46ommnj/b6FWaTo6UEV0y1PeZe44yPqVNpc=
x-ms-exchange-antispam-srfa-diagnostics: SOS;
x-ms-office365-filtering-correlation-id: 93d990d5-4264-43c6-c7dc-08d63a055c23
x-microsoft-antispam: BCL:0; PCL:0;
 RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);
 SRVR:AMSPR06MB501; 
x-ms-traffictypediagnostic: AMSPR06MB501:
x-microsoft-antispam-prvs: <AMSPR06MB5012761168DE354917404B2D5F60@HIDDEN>
x-exchange-antispam-report-test: UriScan:(788757137089);
x-ms-exchange-senderadcheck: 1
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0;
 RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231355)(944501410)(52105095)(93006095)(93001095)(148016)(149066)(150057)(6041310)(201703131423095)(201702281529075)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095);
 SRVR:AMSPR06MB501; BCL:0; PCL:0; RULEID:; SRVR:AMSPR06MB501; 
x-forefront-prvs: 083526BF8A
x-forefront-antispam-report: SFV:NSPM;
 SFS:(10019020)(396003)(136003)(39860400002)(376002)(366004)(346002)(199004)(189003)(478600001)(4326008)(316002)(25786009)(102836004)(2900100001)(6916009)(107886003)(786003)(7736002)(6116002)(33656002)(6506007)(6606003)(53546011)(74482002)(81166006)(106356001)(7696005)(476003)(71200400001)(486006)(19627405001)(2351001)(68736007)(97736004)(81156014)(8676002)(5660300001)(256004)(53936002)(55016002)(105586002)(5640700003)(6436002)(14454004)(99286004)(86362001)(2906002)(2501003)(74316002)(53336002)(8936002)(186003)(54896002)(46003)(5250100002)(71190400001)(9686003)(554374003);
 DIR:OUT; SFP:1102; SCL:1; SRVR:AMSPR06MB501;
 H:AMSPR06MB262.eurprd06.prod.outlook.com; FPR:; SPF:None; LANG:en;
 PTR:InfoNoRecords; A:1; MX:1; 
received-spf: None (protection.outlook.com: imperial.ac.uk does not designate
 permitted sender hosts)
x-microsoft-antispam-message-info: /WynzCF9OW5c8Wr7uf6h158w082HO58abXoiglWbyovtbC6XpytpYxIhj/XcByeNfZaszJX/uIHRRZRXolgkq07/DgYkTA7FwYffxhMvgBP367cWtcSQLrV8WardQt23/eoRiVzIajdSRXOfXOtFeWTj4Zt/DBzA11fdv306Ord2f0G9ky/PniqBQM3LeKmzVYC6mrhEyRNKOJyqp63FzWkBh8Juhg9tJ9POquSFWrN2hlQXdYWO9/DyKSWwQUjps7UL2WMmOY8FQGFz62gsJG/Wanpvhf0w/jVyo+agXf+iAhxYVhJf/tmY1QvXSwr8eiPeynT4Jhr+m0+DL9JXRIKGv3yJEXG7g73Qfue12Hw=
spamdiagnosticoutput: 1:99
spamdiagnosticmetadata: NSPM
Content-Type: multipart/alternative;
 boundary="_000_AMSPR06MB2629589702E6F37524A2779D5F60AMSPR06MB262eurprd_"
MIME-Version: 1.0
X-OriginatorOrg: imperial.ac.uk
X-MS-Exchange-CrossTenant-Network-Message-Id: 93d990d5-4264-43c6-c7dc-08d63a055c23
X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Oct 2018 23:06:41.2100 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 2b897507-ee8c-4575-830b-4f8267c3d307
X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMSPR06MB501
X-IC-MsgID: 1gFSEg-00021H-3r
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Mailman-Approved-At: Wed, 24 Oct 2018 19:42:49 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

--_000_AMSPR06MB2629589702E6F37524A2779D5F60AMSPR06MB262eurprd_
Content-Type: text/plain; charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable

Hi,

I'm writing a program analysis that tries to find and replace some loops wi=
th str* functions. I'm trying to see if these replacements are a useful ref=
actoring or the loops are intentional. I noticed that diff has a couple of =
these loops and wrote a patch (pasted below) that changes this.

I find strspn easier to read, communicate intention and has less LOC, but w=
ould be interested to hear why you would like to keep the loops to.

Cheers,
Timotej

From 38e7030f127f567fd2d02f27663168dde4472d57 Mon Sep 17 00:00:00 2001
From: Timotej Kapus <tk1713@HIDDEN>
Date: Wed, 24 Oct 2018 23:47:22 +0100
Subject: [PATCH] maint: change 3 loops to strspn calls

  * src/ifdef.c: Change 3 loops to equivalent calls to strspn
---
 src/ifdef.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/ifdef.c b/src/ifdef.c
index 0ecc2c0..8046ac5 100644
--- a/src/ifdef.c
+++ b/src/ifdef.c
@@ -313,13 +313,10 @@ do_printf_spec (FILE *out, char const *spec,
   /* Scan printf-style SPEC of the form %[-'0]*[0-9]*(.[0-9]*)?[cdoxX].  *=
/
   /* assert (*f =3D=3D '%'); */
   f++;
-  while ((c =3D *f++) =3D=3D '-' || c =3D=3D '\'' || c =3D=3D '0')
-    continue;
-  while (ISDIGIT (c))
-    c =3D *f++;
-  if (c =3D=3D '.')
-    while (ISDIGIT (c =3D *f++))
-      continue;
+  f +=3D strspn(f, "-\'0") + 1;
+  f +=3D strspn(f, "0123456789") + 1;
+  if ((c =3D *f++) =3D=3D '.')
+    f +=3D strspn(f, "0123456789") + 1;
   c1 =3D *f++;

   switch (c)
--
2.7.4





--_000_AMSPR06MB2629589702E6F37524A2779D5F60AMSPR06MB262eurprd_
Content-Type: text/html; charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
2">
<style type=3D"text/css" style=3D"display:none;"><!-- P {margin-top:0;margi=
n-bottom:0;} --></style>
</head>
<body dir=3D"ltr">
<div id=3D"divtagdefaultwrapper" style=3D"font-size:12pt;color:#000000;font=
-family:Calibri,Helvetica,sans-serif;" dir=3D"ltr">
<p style=3D"margin-top:0;margin-bottom:0"></p>
<div>Hi,&nbsp;<br>
<br>
I'm writing a program analysis that tries to find and replace some loops wi=
th str* functions. I'm trying to see if these replacements are a useful ref=
actoring or the loops are intentional. I noticed that diff has a couple of =
these loops and wrote a patch (pasted
 below) that changes this.</div>
<div><br>
</div>
<div>I find strspn easier to read, communicate intention and has less LOC, =
but would be interested to hear why you would like to keep the loops to.</d=
iv>
<div><br>
</div>
<div>Cheers,</div>
<div>Timotej</div>
<div><br>
</div>
<div>
<div>
<div>From 38e7030f127f567fd2d02f27663168dde4472d57 Mon Sep 17 00:00:00 2001=
</div>
<div>From: Timotej Kapus &lt;tk1713@HIDDEN&gt;</div>
<div>Date: Wed, 24 Oct 2018 23:47:22 &#43;0100</div>
<div>Subject: [PATCH] maint: change 3 loops to strspn calls</div>
<div><br>
</div>
<div>&nbsp; * src/ifdef.c: Change 3 loops to equivalent calls to strspn</di=
v>
<div>---</div>
<div>&nbsp;src/ifdef.c | 11 &#43;&#43;&#43;&#43;-------</div>
<div>&nbsp;1 file changed, 4 insertions(&#43;), 7 deletions(-)</div>
<div><br>
</div>
<div>diff --git a/src/ifdef.c b/src/ifdef.c</div>
<div>index 0ecc2c0..8046ac5 100644</div>
<div>--- a/src/ifdef.c</div>
<div>&#43;&#43;&#43; b/src/ifdef.c</div>
<div>@@ -313,13 &#43;313,10 @@ do_printf_spec (FILE *out, char const *spec,=
</div>
<div>&nbsp; &nbsp;/* Scan printf-style SPEC of the form %[-'0]*[0-9]*(.[0-9=
]*)?[cdoxX].&nbsp; */</div>
<div>&nbsp; &nbsp;/* assert (*f =3D=3D '%'); */</div>
<div>&nbsp; &nbsp;f&#43;&#43;;</div>
<div>-&nbsp; while ((c =3D *f&#43;&#43;) =3D=3D '-' || c =3D=3D '\'' || c =
=3D=3D '0')</div>
<div>-&nbsp; &nbsp; continue;</div>
<div>-&nbsp; while (ISDIGIT (c))</div>
<div>-&nbsp; &nbsp; c =3D *f&#43;&#43;;</div>
<div>-&nbsp; if (c =3D=3D '.')</div>
<div>-&nbsp; &nbsp; while (ISDIGIT (c =3D *f&#43;&#43;))</div>
<div>-&nbsp; &nbsp; &nbsp; continue;</div>
<div>&#43;&nbsp; f &#43;=3D strspn(f, &quot;-\'0&quot;) &#43; 1;</div>
<div>&#43;&nbsp; f &#43;=3D strspn(f, &quot;0123456789&quot;) &#43; 1;</div=
>
<div>&#43;&nbsp; if ((c =3D *f&#43;&#43;) =3D=3D '.')</div>
<div>&#43;&nbsp; &nbsp; f &#43;=3D strspn(f, &quot;0123456789&quot;) &#43; =
1;</div>
<div>&nbsp; &nbsp;c1 =3D *f&#43;&#43;;</div>
<div><br>
</div>
<div>&nbsp; &nbsp;switch (c)</div>
<div>--</div>
<div>2.7.4</div>
<br>
</div>
<div></div>
<div><br>
</div>
<br>
</div>
<br>
<p></p>
</div>
</body>
</html>

--_000_AMSPR06MB2629589702E6F37524A2779D5F60AMSPR06MB262eurprd_--




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: "Kapus, Timotej" <timotej.kapus13@HIDDEN>
Subject: bug#33144: Acknowledgement (Replace some loops with str functions)
Message-ID: <handler.33144.B.15404245705766.ack <at> debbugs.gnu.org>
References: <AMSPR06MB2629589702E6F37524A2779D5F60@HIDDEN>
X-Gnu-PR-Message: ack 33144
X-Gnu-PR-Package: diffutils
Reply-To: 33144 <at> debbugs.gnu.org
Date: Wed, 24 Oct 2018 23:43:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-diffutils@HIDDEN

If you wish to submit further information on this problem, please
send it to 33144 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
33144: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D33144
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-diffutils@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#33144: [bug-diffutils] bug#33144: Replace some loops with str functions
Resent-From: Paul Eggert <eggert@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-diffutils@HIDDEN
Resent-Date: Thu, 25 Oct 2018 19:58:01 +0000
Resent-Message-ID: <handler.33144.B33144.154049743923491 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 33144
X-GNU-PR-Package: diffutils
X-GNU-PR-Keywords: 
To: "Kapus, Timotej" <timotej.kapus13@HIDDEN>, 33144 <at> debbugs.gnu.org
Cc: "Cadar, Cristian" <c.cadar@HIDDEN>
Received: via spool by 33144-submit <at> debbugs.gnu.org id=B33144.154049743923491
          (code B ref 33144); Thu, 25 Oct 2018 19:58:01 +0000
Received: (at 33144) by debbugs.gnu.org; 25 Oct 2018 19:57:19 +0000
Received: from localhost ([127.0.0.1]:42871 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gFlks-00066p-Uj
	for submit <at> debbugs.gnu.org; Thu, 25 Oct 2018 15:57:19 -0400
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:51442)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1gFlkr-00066c-3o
 for 33144 <at> debbugs.gnu.org; Thu, 25 Oct 2018 15:57:17 -0400
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 25A14160075;
 Thu, 25 Oct 2018 12:57:11 -0700 (PDT)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id BdqjiQCA_Psf; Thu, 25 Oct 2018 12:57:10 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 75992160079;
 Thu, 25 Oct 2018 12:57:10 -0700 (PDT)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id XLjABe1CrAmO; Thu, 25 Oct 2018 12:57:10 -0700 (PDT)
Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 4F336160075;
 Thu, 25 Oct 2018 12:57:10 -0700 (PDT)
References: <AMSPR06MB2629589702E6F37524A2779D5F60@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Openpgp: preference=signencrypt
Autocrypt: addr=eggert@HIDDEN; prefer-encrypt=mutual; keydata=
 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
 uNcby4U=
Organization: UCLA Computer Science Department
Message-ID: <75663f40-ea53-e4d0-0ffc-2887d9444d43@HIDDEN>
Date: Thu, 25 Oct 2018 12:57:10 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
 Thunderbird/60.2.1
MIME-Version: 1.0
In-Reply-To: <AMSPR06MB2629589702E6F37524A2779D5F60@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

On 10/24/18 4:06 PM, Kapus, Timotej wrote:
> I find strspn easier to read, communicate intention and has less LOC

On the other hand, it's probably slower for this particular use case, 
and the replacement code you wrote is not equivalent to the code it 
replaced because 'c' ends up having a different value.





Message sent to bug-diffutils@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#33144: [bug-diffutils] bug#33144: Replace some loops with str functions
Resent-From: "Kapus, Timotej" <timotej.kapus13@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-diffutils@HIDDEN
Resent-Date: Fri, 26 Oct 2018 09:52:01 +0000
Resent-Message-ID: <handler.33144.B33144.154054752113169 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 33144
X-GNU-PR-Package: diffutils
X-GNU-PR-Keywords: 
To: Paul Eggert <eggert@HIDDEN>, "33144 <at> debbugs.gnu.org" <33144 <at> debbugs.gnu.org>
Cc: "Cadar, Cristian" <c.cadar@HIDDEN>
Received: via spool by 33144-submit <at> debbugs.gnu.org id=B33144.154054752113169
          (code B ref 33144); Fri, 26 Oct 2018 09:52:01 +0000
Received: (at 33144) by debbugs.gnu.org; 26 Oct 2018 09:52:01 +0000
Received: from localhost ([127.0.0.1]:43224 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gFyma-0003QH-HX
	for submit <at> debbugs.gnu.org; Fri, 26 Oct 2018 05:52:01 -0400
Received: from smtphub1.cc.ic.ac.uk ([155.198.31.79]:37467)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <timotej.kapus13@HIDDEN>) id 1gFymY-0003Q3-Ol
 for 33144 <at> debbugs.gnu.org; Fri, 26 Oct 2018 05:51:55 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=imperial.ac.uk; s=main01; h=MIME-Version:Content-Type:In-Reply-To:
 References:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To:
 Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:
 Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:
 List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=q9FDbSMF1qKPlOrt80xUPZdCNU6uSXx5ly7nQZMalcM=; b=m1IbuQv6A9S8rdChbW7G06MVx
 5z5DFiL06aUHjDZoACWXj1QqVrX8KjG1ceLtWkP4Q+qdcXCU0t2FbJxxRQueBn5RVqGFbBCS/gHIE
 rqIEcb2LyLzPH/5e8YLum/BBj8Cwd3MseUIDu+tq4Q+nBbJXcJLfawJamXL0j47of/VqA=;
Received: from mail-db3eur04lp0149.outbound.protection.outlook.com
 ([23.103.133.149] helo=EUR04-DB3-obe.outbound.protection.outlook.com)
 by smtphub1.cc.ic.ac.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256)
 (Exim 4.90_1) (envelope-from <timotej.kapus13@HIDDEN>)
 id 1gFymS-0002hN-N4; Fri, 26 Oct 2018 10:51:49 +0100
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=ImperialLondon.onmicrosoft.com; s=selector1-imperial-ac-uk;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=q9FDbSMF1qKPlOrt80xUPZdCNU6uSXx5ly7nQZMalcM=;
 b=GoizE7ydYvF9QX+JuWYo0c1KKQsqNy72mkHevkbz38Vps5m5LsQTbiSfwsXiruuhZoOtDZ/9aNgPGNgm5y+f9Tj8a+OqDxsT+9iLgrDDGTvcA+Tqp5zyIy8LkunjSkeY+rW1dA9rkNgIKuJND2XiT1K+4mD1gLFJRCXu1eqDRhI=
Received: from AMSPR06MB262.eurprd06.prod.outlook.com (10.242.19.19) by
 AMSPR06MB502.eurprd06.prod.outlook.com (10.242.107.14) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.1250.30; Fri, 26 Oct 2018 09:51:46 +0000
Received: from AMSPR06MB262.eurprd06.prod.outlook.com
 ([fe80::d938:fa98:7652:219b]) by AMSPR06MB262.eurprd06.prod.outlook.com
 ([fe80::d938:fa98:7652:219b%3]) with mapi id 15.20.1250.032; Fri, 26 Oct 2018
 09:51:45 +0000
From: "Kapus, Timotej" <timotej.kapus13@HIDDEN>
Thread-Topic: [bug-diffutils] bug#33144: Replace some loops with str functions
Thread-Index: AQHUa+0GHYe4o+/aj0eDja5+tUHXbKUwYfoAgADniqM=
Date: Fri, 26 Oct 2018 09:51:45 +0000
Message-ID: <AMSPR06MB2623188ECD44B00E2D7773AD5F00@HIDDEN>
References: <AMSPR06MB2629589702E6F37524A2779D5F60@HIDDEN>,
 <75663f40-ea53-e4d0-0ffc-2887d9444d43@HIDDEN>
In-Reply-To: <75663f40-ea53-e4d0-0ffc-2887d9444d43@HIDDEN>
Accept-Language: sl-SI, en-US
Content-Language: sl-SI
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
authentication-results: spf=none (sender IP is )
 smtp.mailfrom=timotej.kapus13@HIDDEN; 
x-originating-ip: [2a0c:5bc0:40:11a8:f98b:3dce:dd92:1c67]
x-ms-publictraffictype: Email
x-microsoft-exchange-diagnostics: 1; AMSPR06MB502;
 20:GYEMsuwISuKJ+yqWhyw1kUBBc0Z9k2lLoCIVj0efj1VM4pk8SY8N/d06qtGynDKUBEe/a9vQCEtpZzOeENWnZLvbIdnxUAoWMAFqfW5p94T+d9kYQ7+mDPc45cpZvp0JHUsuZQxiK8GOIfIW8BPV9v/C0j3dgmhDPacL+aFKnaU=
x-ms-exchange-antispam-srfa-diagnostics: SOS;
x-ms-office365-filtering-correlation-id: 917c3714-73ab-48d2-93d8-08d63b28a40b
x-microsoft-antispam: BCL:0; PCL:0;
 RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020);
 SRVR:AMSPR06MB502; 
x-ms-traffictypediagnostic: AMSPR06MB502:
x-microsoft-antispam-prvs: <AMSPR06MB5027E25FBEC7328D9CB6C87D5F00@HIDDEN>
x-exchange-antispam-report-test: UriScan:(788757137089)(270544422350281)(22074186197030); 
x-ms-exchange-senderadcheck: 1
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0;
 RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(148016)(149066)(150057)(6041310)(201703131423095)(201702281529075)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201708071742011)(7699051)(76991095);
 SRVR:AMSPR06MB502; BCL:0; PCL:0; RULEID:; SRVR:AMSPR06MB502; 
x-forefront-prvs: 083751FCA6
x-forefront-antispam-report: SFV:NSPM;
 SFS:(10019020)(376002)(366004)(39860400002)(346002)(396003)(136003)(189003)(199004)(53546011)(9686003)(575784001)(55016002)(68736007)(76176011)(7736002)(7696005)(19627405001)(53936002)(8676002)(478600001)(6246003)(54896002)(2171002)(86362001)(486006)(2906002)(81166006)(2900100001)(446003)(256004)(4326008)(5024004)(33656002)(5660300001)(71190400001)(476003)(99286004)(25786009)(316002)(46003)(6606003)(97736004)(2501003)(106356001)(71200400001)(186003)(81156014)(74482002)(14454004)(5250100002)(74316002)(786003)(6506007)(8936002)(11346002)(102836004)(229853002)(110136005)(6436002)(105586002)(107886003)(6116002);
 DIR:OUT; SFP:1102; SCL:1; SRVR:AMSPR06MB502;
 H:AMSPR06MB262.eurprd06.prod.outlook.com; FPR:; SPF:None; LANG:en;
 PTR:InfoNoRecords; MX:1; A:1; 
received-spf: None (protection.outlook.com: imperial.ac.uk does not designate
 permitted sender hosts)
x-microsoft-antispam-message-info: 4S39nevbAIUaEmp0GQlAHRMUZXmLePaJw4isteNGBU1UhhygpOmF//lPKgpKcMiBkIL8KYUIrlY+BHyjN0t9gfLZXORdgPsXARkJkSmEJaUUAoawa9nskBseg5J20DJEKapMdED6M4ecJUWwOEMgATLNkXhmbGzR4fJF8bzfBhmNTDgtUUj2ES0l0Rzqvw0VTSeCm29RR9gBVzDeXZGB3Z93YC4Jl9cW1u+BOTL0s2q9tUTcNjRksi6SHz3phI17S1UigmjjSdwMYIWE+BIW989SBDa0WRxTSGkG1YzH+b+CkicDx/xl526ZXtPx0vUY5Dyb9WxzPx9bmApblwVYJOKtdUjpvmLTQa9Eu3J6M4M=
spamdiagnosticoutput: 1:99
spamdiagnosticmetadata: NSPM
Content-Type: multipart/alternative;
 boundary="_000_AMSPR06MB2623188ECD44B00E2D7773AD5F00AMSPR06MB262eurprd_"
MIME-Version: 1.0
X-OriginatorOrg: imperial.ac.uk
X-MS-Exchange-CrossTenant-Network-Message-Id: 917c3714-73ab-48d2-93d8-08d63b28a40b
X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Oct 2018 09:51:45.5519 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 2b897507-ee8c-4575-830b-4f8267c3d307
X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMSPR06MB502
X-IC-MsgID: 1gFymS-0002hN-N4
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

--_000_AMSPR06MB2623188ECD44B00E2D7773AD5F00AMSPR06MB262eurprd_
Content-Type: text/plain; charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable

Thanks for your reply and apologies for sending a buggy patch. Yes I agree =
it's probably slower, but I doubt it has significant impact on the whole ru=
ntime. The insignifcant slowdown might be worth it, if you would find the c=
ode much clearer. In any case, I'm attaching an updated version of the patc=
h, where I  proved c and c1 are eqvivalent at the end, up to the bound of 5=
 bytes, so should be fine this time.


From 4911d9676f1914fb4691061887396f2b21a0d036 Mon Sep 17 00:00:00 2001
From: Timotej Kapus <tk1713@HIDDEN>
Date: Wed, 24 Oct 2018 23:47:22 +0100
Subject: [PATCH] maint: change 3 loops to strspn calls

  * src/ifdef.c: Change 3 loops to equivalent calls to strspn
---
 src/ifdef.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/ifdef.c b/src/ifdef.c
index 0ecc2c0..4533e3a 100644
--- a/src/ifdef.c
+++ b/src/ifdef.c
@@ -313,13 +313,13 @@ do_printf_spec (FILE *out, char const *spec,
   /* Scan printf-style SPEC of the form %[-'0]*[0-9]*(.[0-9]*)?[cdoxX].  *=
/
   /* assert (*f =3D=3D '%'); */
   f++;
-  while ((c =3D *f++) =3D=3D '-' || c =3D=3D '\'' || c =3D=3D '0')
-    continue;
-  while (ISDIGIT (c))
-    c =3D *f++;
-  if (c =3D=3D '.')
-    while (ISDIGIT (c =3D *f++))
-      continue;
+  f +=3D strspn(f, "-\'0") + 1;
+  if(ISDIGIT(c =3D *(f - 1)))
+    f +=3D strspn(f, "0123456789") + 1;
+  if ((c =3D *(f - 1)) =3D=3D '.') {
+    f +=3D strspn(f, "0123456789") + 1;
+    c =3D *(f - 1);
+  }
   c1 =3D *f++;

   switch (c)
--
2.7.4



________________________________
Od: Paul Eggert <eggert@HIDDEN>
Poslano: =E8etrtek, 25. oktober 2018 20:57:10
Za: Kapus, Timotej; 33144 <at> debbugs.gnu.org
Kp: Cadar, Cristian
Zadeva: Re: [bug-diffutils] bug#33144: Replace some loops with str function=
s

On 10/24/18 4:06 PM, Kapus, Timotej wrote:
> I find strspn easier to read, communicate intention and has less LOC

On the other hand, it's probably slower for this particular use case,
and the replacement code you wrote is not equivalent to the code it
replaced because 'c' ends up having a different value.


--_000_AMSPR06MB2623188ECD44B00E2D7773AD5F00AMSPR06MB262eurprd_
Content-Type: text/html; charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
2">
<style type=3D"text/css" style=3D"display:none;"><!-- P {margin-top:0;margi=
n-bottom:0;} --></style>
</head>
<body dir=3D"ltr">
<div id=3D"divtagdefaultwrapper" style=3D"font-size:12pt;color:#000000;font=
-family:Calibri,Helvetica,sans-serif;" dir=3D"ltr">
<p style=3D"margin-top:0;margin-bottom:0">Thanks for your reply and apologi=
es for sending a buggy patch. Yes I agree it's probably slower, but I doubt=
 it has significant impact on the whole runtime. The insignifcant slowdown =
might be worth it, if you would find
 the code much clearer. In any case, I'm attaching an updated version of th=
e patch, where I &nbsp;proved c and c1 are eqvivalent at the end, up to the=
 bound of 5 bytes, so should be fine this time.</p>
<p style=3D"margin-top:0;margin-bottom:0"><br>
</p>
<p style=3D"margin-top:0;margin-bottom:0"></p>
<div>From 4911d9676f1914fb4691061887396f2b21a0d036 Mon Sep 17 00:00:00 2001=
</div>
<div>From: Timotej Kapus &lt;tk1713@HIDDEN&gt;</div>
<div>Date: Wed, 24 Oct 2018 23:47:22 &#43;0100</div>
<div>Subject: [PATCH] maint: change 3 loops to strspn calls</div>
<div><br>
</div>
<div>&nbsp; * src/ifdef.c: Change 3 loops to equivalent calls to strspn</di=
v>
<div>---</div>
<div>&nbsp;src/ifdef.c | 14 &#43;&#43;&#43;&#43;&#43;&#43;&#43;-------</div=
>
<div>&nbsp;1 file changed, 7 insertions(&#43;), 7 deletions(-)</div>
<div><br>
</div>
<div>diff --git a/src/ifdef.c b/src/ifdef.c</div>
<div>index 0ecc2c0..4533e3a 100644</div>
<div>--- a/src/ifdef.c</div>
<div>&#43;&#43;&#43; b/src/ifdef.c</div>
<div>@@ -313,13 &#43;313,13 @@ do_printf_spec (FILE *out, char const *spec,=
</div>
<div>&nbsp; &nbsp;/* Scan printf-style SPEC of the form %[-'0]*[0-9]*(.[0-9=
]*)?[cdoxX].&nbsp; */</div>
<div>&nbsp; &nbsp;/* assert (*f =3D=3D '%'); */</div>
<div>&nbsp; &nbsp;f&#43;&#43;;</div>
<div>-&nbsp; while ((c =3D *f&#43;&#43;) =3D=3D '-' || c =3D=3D '\'' || c =
=3D=3D '0')</div>
<div>-&nbsp; &nbsp; continue;</div>
<div>-&nbsp; while (ISDIGIT (c))</div>
<div>-&nbsp; &nbsp; c =3D *f&#43;&#43;;</div>
<div>-&nbsp; if (c =3D=3D '.')</div>
<div>-&nbsp; &nbsp; while (ISDIGIT (c =3D *f&#43;&#43;))</div>
<div>-&nbsp; &nbsp; &nbsp; continue;</div>
<div>&#43;&nbsp; f &#43;=3D strspn(f, &quot;-\'0&quot;) &#43; 1;</div>
<div>&#43;&nbsp; if(ISDIGIT(c =3D *(f - 1)))</div>
<div>&#43;&nbsp; &nbsp; f &#43;=3D strspn(f, &quot;0123456789&quot;) &#43; =
1;</div>
<div>&#43;&nbsp; if ((c =3D *(f - 1)) =3D=3D '.') {</div>
<div>&#43;&nbsp; &nbsp; f &#43;=3D strspn(f, &quot;0123456789&quot;) &#43; =
1;</div>
<div>&#43;&nbsp; &nbsp; c =3D *(f - 1);</div>
<div>&#43;&nbsp; }</div>
<div>&nbsp; &nbsp;c1 =3D *f&#43;&#43;;</div>
<div>&nbsp;</div>
<div>&nbsp; &nbsp;switch (c)</div>
<div>--&nbsp;</div>
<div>2.7.4</div>
<div><br>
</div>
<br>
<p></p>
</div>
<hr style=3D"display:inline-block;width:98%" tabindex=3D"-1">
<div id=3D"divRplyFwdMsg" dir=3D"ltr"><font face=3D"Calibri, sans-serif" st=
yle=3D"font-size:11pt" color=3D"#000000"><b>Od:</b> Paul Eggert &lt;eggert@=
cs.ucla.edu&gt;<br>
<b>Poslano:</b> =E8etrtek, 25. oktober 2018 20:57:10<br>
<b>Za:</b> Kapus, Timotej; 33144 <at> debbugs.gnu.org<br>
<b>Kp:</b> Cadar, Cristian<br>
<b>Zadeva:</b> Re: [bug-diffutils] bug#33144: Replace some loops with str f=
unctions</font>
<div>&nbsp;</div>
</div>
<div class=3D"BodyFragment"><font size=3D"2"><span style=3D"font-size:11pt;=
">
<div class=3D"PlainText">On 10/24/18 4:06 PM, Kapus, Timotej wrote:<br>
&gt; I find strspn easier to read, communicate intention and has less LOC<b=
r>
<br>
On the other hand, it's probably slower for this particular use case, <br>
and the replacement code you wrote is not equivalent to the code it <br>
replaced because 'c' ends up having a different value.<br>
<br>
</div>
</span></font></div>
</body>
</html>

--_000_AMSPR06MB2623188ECD44B00E2D7773AD5F00AMSPR06MB262eurprd_--





Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.