[Patch, libfortran] PR 47802 Implementation of CTIME intrinsic
Janne Blomqvist
blomqvist.janne@gmail.com
Thu Feb 24 21:24:00 GMT 2011
On Wed, Feb 23, 2011 at 20:23, Tobias Burnus
<tobias.burnus@physik.fu-berlin.de> wrote:
> Janne Blomqvist wrote:
>> The attached patch changes the implementation of CTIME and FDATE to
>> use strftime instead.
> fdate_sub (char * date, gfc_charlen_type date_len)
> [...]
> + fctime (date, date_len, &now);
>
> As convenient as I find that one directly passes the buffer:
> Doesn't this reduce the number of characters effectively
> by one? Assume 'Sat Aug 19 18:13:14 1995'. That's 24 characters.
> If one now does:
> character(len=24) :: str
> call fdate(str)
> will this work? I fear that this will produce
> 'Sat Aug 19 18:13:14 199\0'. It seems to work is the string is
> at least one character longer than needed as then memset should
> get rid of the tailing '\0'.
>
>
> + not available, gmtime use thread-local storage so it's
>
> s/use/uses/
>
>
>
> libgfortran/intrinsics/time_1.h
> +static struct tm *
> +localtime_r (const time_t * timep, struct tm * result)
> +{
> + *result = *localtime (timep);
> + return result;
> +}
>
> Any reason that you do not mark it as inline?
Patch with the above improvements attached. Ok for trunk?
2011-02-24 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/47802
* config.h.in: Regenerated.
* configure: Regenerated.
* configure.ac: Remove checks for ctime and ctime_r, add check for
strftime.
* intrinsics/date_and_time.c (localtime_r): Move fallback
implementation to time_1.h.
* intrinsics/time_1.h (localtime_r): Fallback implementation.
* intrinsics/ctime.c: Include time_1.h.
(ctime_r): Remove fallback implementation.
(strctime): New function.
(fdate): Use strctime instead of ctime_r.
(fdate_sub): Likewise.
(ctime): Likewise.
(ctime_sub): Likewise.
--
Janne Blomqvist
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ctime2.diff
Type: text/x-patch
Size: 7360 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20110224/37706972/attachment.bin>
More information about the Fortran
mailing list