[PATCH, libgfortran] PR 61310 CTIME intrinsic output incorrect on MinGW

Janne Blomqvist blomqvist.janne@gmail.com
Mon May 26 10:01:00 GMT 2014


On Mon, May 26, 2014 at 1:25 AM, Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:
> On Mon, May 26, 2014 at 12:21:21AM +0300, Janne Blomqvist wrote:
>> Hi,
>>
>> 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?


-- 
Janne Blomqvist



More information about the Gcc-patches mailing list