From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from impout007.msg.chrl.nc.charter.net (impout007aa.msg.chrl.nc.charter.net [47.43.20.31]) by sourceware.org (Postfix) with ESMTPS id 777463857808; Sun, 7 Feb 2021 13:34:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 777463857808 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=charter.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=jvdelisle@charter.net Received: from [192.168.1.9] ([96.41.221.129]) by cmsmtp with ESMTPA id 8kCblQN2Ld7s78kCcljI04; Sun, 07 Feb 2021 13:34:14 +0000 Authentication-Results: charter.net; none X-Authority-Analysis: v=2.3 cv=Db+jVclW c=1 sm=1 tr=0 a=07pILqX15KmGv9ZXTMmBNA==:117 a=07pILqX15KmGv9ZXTMmBNA==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=mDV3o1hIAAAA:8 a=O7A_1_-CcfinQ2XAh0cA:9 a=QEXdDO2ut3YA:10 a=v_XbUBYvp8fFCOv3RrYA:9 a=De_Ol2h6w80A:10 a=_FVE-zBwftR9WsbkzFJk:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=jd6J4Gguk5HxikPWLKER:22 To: gfortran Cc: gcc-patches From: Jerry DeLisle Subject: [patch, libgfortran] PR98825 Unexpected behavior of FORTRAN FORMAT expressions when suppressing new line with '$' Message-ID: Date: Sun, 7 Feb 2021 05:34:13 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------8DFE47E5B302A34105330D40" Content-Language: en-US X-CMAE-Envelope: MS4wfH7QZhIElFtA72yYKcPLwesmDEWHhbXUOnOYKe4nLVB9NIZdxpRUrjke4k5FvfIfIRut2K4BEuJW0TqwJkfNqWxOjmdLnnczKLKYiIdzk++1ZBtXKqOv +CYBmHmaUK/1GpXUwFDsQ7U/n6y+o5Cj1bFHj+NWLuWprL6FIxicGXlT6l+zKndVMWaNVh9WgtH19FRJ03mQXtSfzU/yPZQw9u4= X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Feb 2021 13:34:16 -0000 This is a multi-part message in MIME format. --------------8DFE47E5B302A34105330D40 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hello all, Attached patch fixes this and adds a test case. The "$" edit descriptor was being completely ignored when next_record_w is processed. Fixed by adding a simple check. OK for trunk and backport to 10 since it is simple enough? Regards, Jerry libgfortran: Do not emit end-of-record if seen_dollar. 2021-02-07  Jerry DeLisle  libgfortran/ChangeLog:     PR libgfortran/98825     * io/transfer.c (next_record_w): Insert check for seen_dollar and if     so, skip issueing next record. gcc/testsuite/ChangeLog:     * gfortran.dg/dollar_edit_descriptor_4.f: New test. --------------8DFE47E5B302A34105330D40 Content-Type: text/x-patch; charset=UTF-8; name="pr98825.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr98825.diff" diff --git a/gcc/testsuite/gfortran.dg/dollar_edit_descriptor_4.f b/gcc/testsuite/gfortran.dg/dollar_edit_descriptor_4.f new file mode 100644 index 00000000000..c8453ce6bc8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dollar_edit_descriptor_4.f @@ -0,0 +1,16 @@ +! { dg-do run } +! { dg-options "-std=gnu" } +! PR98825 Test for fix of '$' edit descriptor. + character(30) :: line + 10 format (i3,$) + + open(10, status='scratch') + write (10,10) 1 + write (10,10) 2,3,4,5 +! Check the result. + line = 'abcdefg' + rewind(10) + read(10, '(a)') line + close(10) + if (line .ne. ' 1 2 3 4 5') call abort + end diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 8ab0583dd55..27bee9d4e01 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -4020,6 +4020,8 @@ next_record_w (st_parameter_dt *dtp, int done) } } } + else if (dtp->u.p.seen_dollar == 1) + break; /* Handle legacy CARRIAGECONTROL line endings. */ else if (dtp->u.p.current_unit->flags.cc == CC_FORTRAN) next_record_cc (dtp); --------------8DFE47E5B302A34105330D40--