[Info-vax] Significance of 2020 / 2021 date
Chris
xxx.syseng.yyy at gfsys.co.uk
Sat Jan 9 07:15:05 EST 2021
On 01/07/21 21:00, issinoho wrote:
> On Thursday, 7 January 2021 at 20:48:52 UTC, abrsvc wrote:
>> On Thursday, 7 January 2021 at 15:38:19 UTC-5, 1tim.... at gmail.com wrote:
>>> On Thursday, January 7, 2021 at 11:52:35 AM UTC-7, Stephen Hoffman wrote:
>>>> On 2021-01-07 18:40:56 +0000, Hein RMS van den Heuvel said:
>>>>
>>>>> On Thursday, January 7, 2021 at 12:33:57 PM UTC-5, Andy Burns wrote:
>>>>>> issinoho wrote:
>>>>>>
>>>>>>> We have some old 90s VAX C code which rejects any dates after the year 2020
>>>>>> Does this use 2 digit years or 4 digit?
>>>>>>
>> Without seeing any of the code, we can speculate till the cows come home and never uncover the real problem. I too have seen all kinds of trickery to get around 2 digit year storage and the change from 19 to 20. Given that the century remained the same here, I suspect a different issue.
>>
>> There are many of us here (myself included) that can provide assistance in tracking this down. Just because the code is old does not mean anything. I am working with code now that was last modified in 1988 and is still running fine. Other code written recently has issues (go figure...)
>>
>> Dan
>
> OK, so the very fact none of you are jumping down my throat with an obvious reason is significant.
>
> For the curious here is the code in question...
>
> if (atoi (date_string + 5)> 2020)
That code is type unsafe for starters. atoi() requires an ascii string,
but you are trying to add 5 decimal to an ascii string ?. The man
page for atoi() quite clearly states that behaviour is undefined if
you give it bad data. Just yet another example of sloppy programming.
Be fussy about types etc !.
Better to use a later library function, such as strtoul (), or similar,
which is more tightly defined...
Chris
> ....
>
> where date_string is a char array
>
> Thanks for the continued support.
More information about the Info-vax
mailing list