From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19516 invoked by alias); 3 Dec 2017 15:28:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 19491 invoked by uid 89); 3 Dec 2017 15:28:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=H*MI:7478, referred X-Spam-User: qpsmtpd, 2 recipients X-HELO: mtaout003-public.msg.strl.va.charter.net Received: from mtaout003-public.msg.strl.va.charter.net (HELO mtaout003-public.msg.strl.va.charter.net) (68.114.190.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 03 Dec 2017 15:28:19 +0000 Received: from impout006 ([68.114.189.21]) by mtaout003.msg.strl.va.charter.net (InterMail vM.9.00.023.01 201-2473-194) with ESMTP id <20171203152818.QAYD7355.mtaout003.msg.strl.va.charter.net@impout006>; Sun, 3 Dec 2017 09:28:18 -0600 Received: from [192.168.1.5] ([96.41.213.35]) by impout006 with charter.net id hTUH1w0030mPCJg01TUHAM; Sun, 03 Dec 2017 09:28:18 -0600 X-Authority-Analysis: v=2.2 cv=TffmjVYh c=1 sm=1 tr=0 a=NNeuWy7OTYa7gJ+3pFFB5Q==:117 a=NNeuWy7OTYa7gJ+3pFFB5Q==:17 a=x7bEGLp0ZPQA:10 a=r77TgQKjGQsHNAKrUKIA:9 a=mDV3o1hIAAAA:8 a=Mo04ulbynLiMqo0B9CQA:9 a=QEXdDO2ut3YA:10 a=4adysJlpcVRdIPG1wg4A:9 a=hquHOILUSkIA:10 a=_FVE-zBwftR9WsbkzFJk:22 X-Auth-id: anZkZWxpc2xlQGNoYXJ0ZXIubmV0 To: gfortran Cc: gcc patches From: Jerry DeLisle Subject: [patch, libgfortran] Bug 83191 - [7/8 Regression] Writing a namelist with repeated complex numbers Message-ID: Date: Sun, 03 Dec 2017 15:28:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------348A53C2236291C56470BACA" X-SW-Source: 2017-12/txt/msg00106.txt.bz2 This is a multi-part message in MIME format. --------------348A53C2236291C56470BACA Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 746 Hi all, I plan to commit the attached patch with a test case shortly. It is relatively simple. Thanks to Dominique for pinpointing the location right away. Regression tested on x86_64-pc-linux-gnu. Regards, Jerry 2017-12-03 Jerry DeLisle Dominique d'Humieres PR libgfortran/83191 * io/transfer.c (list_formatted_read_scalar): Do not set namelist_mode bit here. (namelist_read): Likewise. (data_transfer_init): Clear the mode bit here. (finalize_transfer): Do set the mode bit just before any calls to namelist_read or namelist_write. It can now be referred to in complex_write. ^ io/write.c (write_complex): Suppress the leading blanks when namelist_mode bit is not set to 1. --------------348A53C2236291C56470BACA Content-Type: text/x-patch; name="pr83191.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr83191.diff" Content-length: 2482 diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 1d4e62434ac..6e77d53961b 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,7 @@ +2017-12-02 Jerry DeLisle + + PR libgfortran/83191 + 2017-12-02 Jerry DeLisle PR libgfortran/83225 diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c index 3c03a02cad8..379050cecad 100644 --- a/libgfortran/io/list_read.c +++ b/libgfortran/io/list_read.c @@ -2099,8 +2099,6 @@ list_formatted_read_scalar (st_parameter_dt *dtp, bt type, void *p, int c, i, m; int err = 0; - dtp->u.p.namelist_mode = 0; - /* Set the next_char and push_char worker functions. */ set_workers (dtp); @@ -3546,7 +3544,6 @@ namelist_read (st_parameter_dt *dtp) name. */ namelist_info *prev_nl = NULL; - dtp->u.p.namelist_mode = 1; dtp->u.p.input_complete = 0; dtp->u.p.expanded_read = 0; diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 5429a855541..4d7ca7abf7b 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -2671,7 +2671,7 @@ data_transfer_init (st_parameter_dt *dtp, int read_flag) dtp->u.p.ionml = ionml; dtp->u.p.mode = read_flag ? READING : WRITING; - + dtp->u.p.namelist_mode = 0; dtp->u.p.cc.len = 0; if ((dtp->common.flags & IOPARM_LIBRETURN_MASK) != IOPARM_LIBRETURN_OK) @@ -3890,6 +3890,7 @@ finalize_transfer (st_parameter_dt *dtp) if ((dtp->u.p.ionml != NULL) && (cf & IOPARM_DT_HAS_NAMELIST_NAME) != 0) { + dtp->u.p.namelist_mode = 1; if ((cf & IOPARM_DT_NAMELIST_READ_MODE) != 0) namelist_read (dtp); else diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c index 582d196c4e3..926d510f4d7 100644 --- a/libgfortran/io/write.c +++ b/libgfortran/io/write.c @@ -1809,9 +1809,11 @@ write_complex (st_parameter_dt *dtp, const char *source, int kind, size_t size) precision, buf_size, result1, &res_len1); get_float_string (dtp, &f, source + size / 2 , kind, 0, buffer, precision, buf_size, result2, &res_len2); - lblanks = width - res_len1 - res_len2 - 3; - - write_x (dtp, lblanks, lblanks); + if (!dtp->u.p.namelist_mode) + { + lblanks = width - res_len1 - res_len2 - 3; + write_x (dtp, lblanks, lblanks); + } write_char (dtp, '('); write_float_string (dtp, result1, res_len1); write_char (dtp, semi_comma); --------------348A53C2236291C56470BACA--