bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Bug-gnulib] getdate.y question


From: Jim.Hyslop
Subject: RE: [Bug-gnulib] getdate.y question
Date: Thu, 13 May 2004 09:35:27 -0400

Derek Robert Price wrote:
> I'm not sure whether the correct fix would be some sort of overflow
> checking in getdate.y (though I worry that this solution would end up
> duplicating much of the same code from mktime() that we wish to avoid
> duplicating), or the implementation of some sort of "overflow
> converted" return value from mktime(), or perhaps even a new argument
> to mktime() to force strict overflow checks (more likely a new
> mktime_strict() function which could wrap and share an internal
> function with mktime(), to prevent changing the mktime() interface),

The last option seems to be the best, IMO. Refactor the functionality out of
mktime into a separate function, say mktime_checked, which accepts an
additional boolean parameter, say allow_overflow.

If allow_overflow is TRUE, the function behaves exactly as mktime does
currently. If allow_overflow is FALSE, then the function will return an
error if any of the date values are invalid.

mktime passes FALSE, and getdate() passes TRUE.

-- 
Jim Hyslop
Senior Software Designer
Leitch Technology International Inc. (http://www.leitch.com)
Columnist, C/C++ Users Journal (http://www.cuj.com/experts)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]