From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 4C238385AC1B for ; Mon, 5 Sep 2022 07:26:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4C238385AC1B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x42b.google.com with SMTP id e20so10045832wri.13 for ; Mon, 05 Sep 2022 00:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date; bh=2L4ZfzJF/6k8F2uvCjH4poeLPIgOpsx/r7z7Egk8Onc=; b=KQ5pQE33/dkEp0OP+wQ9AygGtW9hLtKwqVSpSKFuEcD1VWFOJjpk9kWlvzXOkIIjx2 YFel+M8Fm/EVoCcrySx6zTTV2sC1LRzFM98Tb/RpL7Kr3E3U3s9kuXSCUBOChFuu5A6G 4SNMOMGL/osKW5LHQrbnzgRLCzRctOBoZO8NASuO7NR9D3RBQ4dCnJiTr9W4553r36d5 WOF2QaO6VYqdTl2icKoFMSVFjx7SC30om0QxDCu9JxgC03O4yoK0+zIWCRQsQ/jIrjZ1 4oBnfLqYZ+AYlwCM34cEunfVtt8AoNm+/xUlXGhMyt33DPo5TkisnF+LQ65dZL3uYqP0 uycw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=2L4ZfzJF/6k8F2uvCjH4poeLPIgOpsx/r7z7Egk8Onc=; b=MbbKvepjbebJy/eNozKwEUMsqo+Hgb5Uglvmn4PTTF4VwgvTLCRsYWegip/AJlbw+G Zu/qDZ42cY1ccon813Xal4vlUOAguk5Hm4bNWpfo+9TQFaanqGY+Sl29YsSFyQb3aM37 6OWvlrbIiolWR5ngtX3v4315yutHy+aC3xrTHQ1OlGxY3HFnxeoQFjq94z6dTO7fWYEW Lc95DNH7PTuPkfGr4RCEls+dtG92+jP1vubdzJ7aRRI9ahkFVVpfF1EOShTdTaoyOfrk UQS3cEAmP9BPwLEZpKfIw90LqLWHWNX9Y8hkP9HdCujFkL1sv2Ar3tfmtqQoFbe2HmUq WNkQ== X-Gm-Message-State: ACgBeo2D1k1hXEtK+CPX59mbb88TheEt35CjqLvL8kD/zZ3Js7/BxFW6 ttPVazplxTX0moPiYTNEIF3Zhky3JaRLGw== X-Google-Smtp-Source: AA6agR4o0zesx0m//LOGQr0Cg8LudooD4sMBVQZ/0dVYTW1Mpr9xQci3C1l7XEWOX41KPEW6x+on7g== X-Received: by 2002:a5d:69c6:0:b0:228:c119:987f with SMTP id s6-20020a5d69c6000000b00228c119987fmr462868wrw.268.1662362769165; Mon, 05 Sep 2022 00:26:09 -0700 (PDT) Received: from poulhies-Precision-5550 (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id l11-20020a05600c10cb00b003a5260b8392sm11843374wmd.23.2022.09.05.00.26.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 00:26:08 -0700 (PDT) Date: Mon, 5 Sep 2022 09:26:08 +0200 From: Marc =?iso-8859-1?Q?Poulhi=E8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Small cleanup in body of System.Value_R Message-ID: <20220905072608.GA1174745@poulhies-Precision-5550> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="fUYQa+Pmc3FrFX/N" Content-Disposition: inline X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --fUYQa+Pmc3FrFX/N Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This is mostly stylistic but also adds a couple of missing comments. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * libgnat/s-valuer.adb (Scan_Decimal_Digits): Consistently avoid initializing local variables. (Scan_Integral_Digits): Likewise. (Scan_Raw_Real): Likewise and add a couple of comments. --fUYQa+Pmc3FrFX/N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/libgnat/s-valuer.adb b/gcc/ada/libgnat/s-valuer.adb --- a/gcc/ada/libgnat/s-valuer.adb +++ b/gcc/ada/libgnat/s-valuer.adb @@ -184,7 +184,7 @@ package body System.Value_R is UmaxB : constant Uns := Precision_Limit / Uns (Base); -- Numbers bigger than UmaxB overflow if multiplied by base - Precision_Limit_Reached : Boolean := False; + Precision_Limit_Reached : Boolean; -- Set to True if addition of a digit will cause Value to be superior -- to Precision_Limit. @@ -198,7 +198,7 @@ package body System.Value_R is Temp : Uns; -- Temporary - Trailing_Zeros : Natural := 0; + Trailing_Zeros : Natural; -- Number of trailing zeros at a given point begin @@ -209,12 +209,17 @@ package body System.Value_R is Precision_Limit_Reached := True; else Extra := 0; + Precision_Limit_Reached := False; end if; if Round then Precision_Limit_Just_Reached := False; end if; + -- Initialize trailing zero counter + + Trailing_Zeros := 0; + -- The function precondition is that the first character is a valid -- digit. @@ -362,7 +367,7 @@ package body System.Value_R is UmaxB : constant Uns := Precision_Limit / Uns (Base); -- Numbers bigger than UmaxB overflow if multiplied by base - Precision_Limit_Reached : Boolean := False; + Precision_Limit_Reached : Boolean; -- Set to True if addition of a digit will cause Value to be superior -- to Precision_Limit. @@ -383,6 +388,8 @@ package body System.Value_R is Scale := 0; Extra := 0; + Precision_Limit_Reached := False; + if Round then Precision_Limit_Just_Reached := False; end if; @@ -494,28 +501,32 @@ package body System.Value_R is After_Point : Boolean; -- True if a decimal should be parsed - Base_Char : Character := ASCII.NUL; - -- Character used to set the base. If Nul this means that default + Base_Char : Character; + -- Character used to set the base. If it is Nul, this means that default -- base is used. - Base_Violation : Boolean := False; + Base_Violation : Boolean; -- If True some digits where not in the base. The real is still scanned -- till the end even if an error will be raised. + Expon : Integer; + -- Exponent as an Integer + Index : Integer; -- Local copy of string pointer Start : Positive; + -- Index of the first non-blank character Value : Uns; -- Mantissa as an Integer - Expon : Integer; - begin -- The default base is 10 - Base := 10; + Base := 10; + Base_Char := ASCII.NUL; + Base_Violation := False; -- We do not tolerate strings with Str'Last = Positive'Last --fUYQa+Pmc3FrFX/N--