This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH, libgfortran] PR 61310 CTIME intrinsic output incorrect on MinGW
- From: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- To: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- Cc: Fortran List <fortran at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 26 May 2014 13:00:56 +0300
- Subject: Re: [PATCH, libgfortran] PR 61310 CTIME intrinsic output incorrect on MinGW
- Authentication-results: sourceware.org; auth=none
- References: <CAO9iq9HQvTKd_eLrh=uR0sQx9=1Y1JTkapYuaFWR2xsncbSAtg at mail dot gmail dot com> <20140525222511 dot GA32519 at troutmask dot apl dot washington dot edu>
On Mon, May 26, 2014 at 1:25 AM, Steve Kargl
> On Mon, May 26, 2014 at 12:21:21AM +0300, Janne Blomqvist wrote:
>> GFortran currently uses strftime(...,"%c",...) to produce the result
>> for the CTIME and FDATE intrinsics. Unfortunately, it seems that on
>> MinGW this does not produce identical output to the C stdlib ctime(),
>> even in the default locale.
>> The attached patch implements an alternative approach, originally
>> suggested by Jakub in PR 47802, to produce a thread-safe ctime-like
>> function by using snprintf manually.
>> Regtested on x86_64-unknown-linux-gnu, Ok for trunk/4.9/4.8/4.7?
> Patch looks ok to me.
>> +/* Maximum space a ctime-like string might need. A "normal" ctime
>> + string is 26 bytes, but the maximum possible year number is
>> + 2,147,485,547 (2,147,483,647 + 1900, since tm_year is a 32-bit
>> + signed integer) so an extra 6 bytes are needed. */
>> +#define CSZ 32
> Is there a better name than CSZ, which is not exactly too descriptive?
Hmm, what about CTIME_BUFSZ? Ok with that change?