From patchwork Mon Sep 5 07:26:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp58701wrt; Mon, 5 Sep 2022 00:36:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR4mUkzGkzmDdEkRUf5CDJlBHCZFoGRJ7HcUhK7dgkuKVMBspf2ImXDQR1R5jogFoSNV08rG X-Received: by 2002:a17:907:7284:b0:731:82a3:16e3 with SMTP id dt4-20020a170907728400b0073182a316e3mr34880249ejc.30.1662363386416; Mon, 05 Sep 2022 00:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662363386; cv=none; d=google.com; s=arc-20160816; b=t1oGqDeKl5xcle3k87XLqgt5Sj71tFMYenPvaheIW/8yQHNNfunq0Gl+PXSQPFhC3P +ydeslQ+yngbsft5jw8pzc3Jh/wMFf7Eb6nVyfaxL4n7RI2vV8DvP7A0X4EZfWWDfabZ yS0+N3BZzLT6E5Sr6Ej8s3Bf7erkC7is60tB+y+v8/052rPrFYYBuK4Ew+3Ld9GZVFjl d77CdILQSpoyvNHkoBexM+vUbNg0/NpT3GGJm7P9DzKNwGVlogOHyvoHslaM5fEWWvoh lMt4kRITX58pWr92oYn8JvLQtQfYN/uIreWEr67SZCRk26Fl2DJbSCwlIkL68+nigiCk zr/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=2L4ZfzJF/6k8F2uvCjH4poeLPIgOpsx/r7z7Egk8Onc=; b=xZEmBuUVsc0djb8hEPS1yc4HAQMk8v7Bzy1C0CVERdbmVN66dbN/OFFJM4VR464nbS lSpPn+w/qjMgaxGIHS8+bNdw/lwcjdi6zmHZEdc7ucmDJYzgIzjlD2dVn/I9A3WPMBg8 9/MXWn26EGEafg8TvQ2IwTjq+6zOGkSh5f0A6luThAkkluwBIpHT9vcSwLw1CLI3tUsT 14I0/IgpPDxhUPOWLvyWsguxhJR/6hgcNHAStEWzzUf5kkzdbJalUx6vpqwwlM/QtPOT WjMltrrO3FTDD2H/3yrDGZAWP4rp978ZfP3i3vBEhpjCLcXTL4E1cW/Bn4IVYhg3/KF0 86XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gVjWTrWx; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id eb8-20020a0564020d0800b00442edebe687si8512144edb.633.2022.09.05.00.36.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 00:36:26 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gVjWTrWx; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DB09D382E4F1 for ; Mon, 5 Sep 2022 07:30:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB09D382E4F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662363057; bh=2L4ZfzJF/6k8F2uvCjH4poeLPIgOpsx/r7z7Egk8Onc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=gVjWTrWxa2TG1L7BtWvjTasJ/DL6L3s1y0tsOzn044HABce3EPsgv1YiE0mY9uSy4 XlQNmd8WBTP90/tAqrppOhUZ5VF/ck8jFmSPm0VsS90XeqxDq9elj/VBa0pG2wgdRC BxqJpTTINrw+TNt8B72Qh+7WsSvNHdURb5clyJVQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 Received: by mail-wr1-x42b.google.com with SMTP id e20so10045832wri.13 for ; Mon, 05 Sep 2022 00:26:10 -0700 (PDT) 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-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 To: gcc-patches@gcc.gnu.org Subject: [Ada] Small cleanup in body of System.Value_R Message-ID: <20220905072608.GA1174745@poulhies-Precision-5550> MIME-Version: 1.0 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: Marc =?iso-8859-1?q?Poulhi=E8s?= Cc: Eric Botcazou Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743114350706658016?= X-GMAIL-MSGID: =?utf-8?q?1743114350706658016?= 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. 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