From patchwork Sun Jan 12 15:54:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerry D X-Patchwork-Id: 1221780 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-517231-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=e7GiSFqu; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=b28qP541; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47wh9t1BLYz9s4Y for ; Mon, 13 Jan 2020 02:54:39 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=UHGHlEksF+0PVbqJ7AJprgYa3Eo7BHpsDBiD0OSWKJOAxiheWG Jr7zjrz/aCETH1SyiDEjCt71WrVWWZEUuNisTGZu0NBVNb3O/TlwTaUbdf09GjvH N19BtZzh+lAaDOTU/fzYXqH+lU2txr+m2WPQHC4M4dIMFidI+xqso974I= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=NVAhMfIxlWpfVNoYOTi7xIqA6mI=; b=e7GiSFquuiyez87QTK6S ojGq8V0gqMQodZ7yYrQWlcsuofvDD3X6WlxPxLJTDo6SLD7WzzTRdT0bp1TaOqnp mkt1P3daGO7DfTPO6pw3CNHAd3Kp0D8JR9WtGcIAn4X/i7H63JQ6NqAR/vmSo8nC llgmHlYwumc/G9VcA1ewC0E= Received: (qmail 46389 invoked by alias); 12 Jan 2020 15:54:31 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 46376 invoked by uid 89); 12 Jan 2020 15:54:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=editing, Jerry, jerry, U*jvdelisle X-HELO: mail-pf1-f177.google.com Received: from mail-pf1-f177.google.com (HELO mail-pf1-f177.google.com) (209.85.210.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 12 Jan 2020 15:54:29 +0000 Received: by mail-pf1-f177.google.com with SMTP id 2so3633140pfg.12; Sun, 12 Jan 2020 07:54:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-language; bh=AGJ9AcvYbtVdVr6J9lZqUCigtewEEhs9feYFSvjQJ30=; b=b28qP541Nr/sAozubjSoPGk/I77donpCnOoHQ2sQYJ5vtMkCGxgJ7LL3NQfkcuiw+H Qw6IDgKw0T+fmQj0rZvOpCWfZytobQQgitEUBY5Tq20dInw+rgj/j/imapitd3WPvqwB 8U9kFaqHMYZrVeG3hDhb9PSjiUp7AvpIE72jBfyaU7aklbRKDHxzBUDeo8Y/6EzIpRkZ eA1vxLPrIKIX24SW6qr0Pux8NL4K2i+1rWo5OtClVe16HV0/lUEZmNmYIUa61IfsFm9F tUvueS/IO2LmTPOmtPg6WD4CSRoGipJDzHlFB/o4GB1Go2dQHpTsZqEv7ovdaVxeLOWL o82Q== Received: from [192.168.1.25] (66-191-41-128.static.snfr.nc.charter.com. [66.191.41.128]) by smtp.gmail.com with ESMTPSA id x197sm10972553pfc.1.2020.01.12.07.54.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Jan 2020 07:54:25 -0800 (PST) To: gfortran Cc: gcc-patches From: Jerry Gmail Subject: [patch, libgfortran] PR90374 Zero width format specifiers. Message-ID: Date: Sun, 12 Jan 2020 07:54:24 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 Hi all, The attached patch is simple enough. Zero width exponent format specifier is not allowed with "D" editing. Also, needed to adjust the width calculated for exponents greater than 999 for the larger kind cases (real 10 and real 16). Regression tested on x86_64.  I will commit as soon as I include in the test case. Regards, Jerry 2020-01-12  Jerry DeLisle      PR libfortran/90374     * io/format.c (parse_format_list): Zero width not allowed with     FMT_D.     * io/write_float.def (build_float_string): Include range of     higher exponent values that require wider width. diff --git a/libgfortran/io/format.c b/libgfortran/io/format.c index b42a5593e38..3be861fb19c 100644 --- a/libgfortran/io/format.c +++ b/libgfortran/io/format.c @@ -954,7 +954,9 @@ parse_format_list (st_parameter_dt *dtp, bool *seen_dd) } tail->u.real.d = fmt->value; - /* Look for optional exponent */ + /* Look for optional exponent, not allowed for FMT_D */ + if (t == FMT_D) + break; u = format_lex (fmt); if (u != FMT_E) fmt->saved_token = u; diff --git a/libgfortran/io/write_float.def b/libgfortran/io/write_float.def index 75c7942c4c5..8a1be054371 100644 --- a/libgfortran/io/write_float.def +++ b/libgfortran/io/write_float.def @@ -497,7 +497,9 @@ build_float_string (st_parameter_dt *dtp, const fnode *f, char *buffer, else if (f->u.real.e == 0) { /* Zero width specified, no leading zeros in exponent */ - if (e > 99 || e < -99) + if (e > 999 || e < -999) + edigits = 6; + else if (e > 99 || e < -99) edigits = 5; else if (e > 9 || e < -9) edigits = 4;