From patchwork Tue Aug 17 17:21:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 61943 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 84A56B7163 for ; Wed, 18 Aug 2010 03:21:03 +1000 (EST) Received: (qmail 19890 invoked by alias); 17 Aug 2010 17:21:00 -0000 Received: (qmail 19871 invoked by uid 22791); 17 Aug 2010 17:20:59 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_CP, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 17 Aug 2010 17:20:55 +0000 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7HHKsCW015219 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 17 Aug 2010 13:20:54 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7HHKrni015075 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 17 Aug 2010 13:20:53 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o7HHLBun020399; Tue, 17 Aug 2010 19:21:11 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o7HHLBVg020329; Tue, 17 Aug 2010 19:21:11 +0200 Date: Tue, 17 Aug 2010 19:21:11 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: [PATCH] Change date_and_time for F03+ (PR fortran/45308) Message-ID: <20100817172111.GH702@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes 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 Hi! As reported in the PR, F03 changed date_and_time incompatibly, instead of setting first 8/10/5 characters of the strings the routine is now supposed to set the strings. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2010-08-17 Jakub Jelinek PR fortran/45308 * intrinsics/date_and_time.c (date_and_time): Pass __{zone,time,date}_len instead of {ZONE,TIME,DATE}_LEN as second argument to fstrcpy. Drop asserts. Adjust comment to the F2003 wording from the F95 wording. Jakub --- libgfortran/intrinsics/date_and_time.c.jj 2010-06-07 11:25:15.000000000 +0200 +++ libgfortran/intrinsics/date_and_time.c 2010-08-17 15:44:53.000000000 +0200 @@ -93,29 +93,25 @@ gmtime_r (const time_t * timep, struct t Arguments: - DATE (optional) shall be scalar and of type default character, and - shall be of length at least 8 in order to contain the complete - value. It is an INTENT(OUT) argument. Its leftmost 8 characters - are assigned a value of the form CCYYMMDD, where CC is the century, - YY the year within the century, MM the month within the year, and - DD the day within the month. If there is no date available, they - are assigned blanks. - - TIME (optional) shall be scalar and of type default character, and - shall be of length at least 10 in order to contain the complete - value. It is an INTENT(OUT) argument. Its leftmost 10 characters - are assigned a value of the form hhmmss.sss, where hh is the hour - of the day, mm is the minutes of the hour, and ss.sss is the - seconds and milliseconds of the minute. If there is no clock - available, they are assigned blanks. - - ZONE (optional) shall be scalar and of type default character, and - shall be of length at least 5 in order to contain the complete - value. It is an INTENT(OUT) argument. Its leftmost 5 characters - are assigned a value of the form [+-]hhmm, where hh and mm are the - time difference with respect to Coordinated Universal Time (UTC) in - hours and parts of an hour expressed in minutes, respectively. If - there is no clock available, they are assigned blanks. + DATE (optional) shall be scalar and of type default character. + It is an INTENT(OUT) argument. It is assigned a value of the + form CCYYMMDD, where CC is the century, YY the year within the + century, MM the month within the year, and DD the day within the + month. If there is no date available, they are assigned blanks. + + TIME (optional) shall be scalar and of type default character. + It is an INTENT(OUT) argument. It is assigned a value of the + form hhmmss.sss, where hh is the hour of the day, mm is the + minutes of the hour, and ss.sss is the seconds and milliseconds + of the minute. If there is no clock available, they are assigned + blanks. + + ZONE (optional) shall be scalar and of type default character. + It is an INTENT(OUT) argument. It is assigned a value of the + form [+-]hhmm, where hh and mm are the time difference with + respect to Coordinated Universal Time (UTC) in hours and parts + of an hour expressed in minutes, respectively. If there is no + clock available, they are assigned blanks. VALUES (optional) shall be of type default integer and of rank one. It is an INTENT(OUT) argument. Its size shall be at least @@ -311,22 +307,13 @@ date_and_time (char *__date, char *__tim } if (__zone) - { - assert (__zone_len >= ZONE_LEN); - fstrcpy (__zone, ZONE_LEN, zone, ZONE_LEN); - } + fstrcpy (__zone, __zone_len, zone, ZONE_LEN); if (__time) - { - assert (__time_len >= TIME_LEN); - fstrcpy (__time, TIME_LEN, timec, TIME_LEN); - } + fstrcpy (__time, __time_len, timec, TIME_LEN); if (__date) - { - assert (__date_len >= DATE_LEN); - fstrcpy (__date, DATE_LEN, date, DATE_LEN); - } + fstrcpy (__date, __date_len, date, DATE_LEN); } --- gcc/testsuite/gfortran.dg/pr45308.f03.jj 2010-08-17 15:37:27.000000000 +0200 +++ gcc/testsuite/gfortran.dg/pr45308.f03 2010-08-17 15:21:01.000000000 +0200 @@ -0,0 +1,9 @@ +! PR fortran/45308 +! { dg-do run } + character(len=36) :: date, time + date = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + time = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + call date_and_time (date, time) + if (index (date, 'a') /= 0 .or. index (time, 'a') /= 0) & + call abort +end