From: "John A. Kroll" <krollj@worldnet.att.net>
Subject: Re: What do you look for in C/C++ source? tm_year?
Date: 1997/09/03 [thread overview]
Message-ID: <340D4287.2F3E9DA1@worldnet.att.net> (raw)
In-Reply-To: 340C34A2.FD0EE69F@bellsouth.net.no_spam
David Means wrote:
> If you're greping through 1000's of lines of ( C/C++ ) code for date related
> bugs, what do you look for? My first assumption is to find tm_year.
>
> What other stuff do you look for?
>
> Thanks
>
> David Means
>
Then of course there is always leap year calculations. The simple function that
is always seen is
something along the following:
int
check_leap_year( int test_year )
{
return ( ( ( (test_year % 4) == 0 ) && ( (test_year % 100) != 0 ) ) ||
( (test_year % 400) == 0 ) );
}
Note that this function fails to work when called as:
check_leap_year( my_tm_struct.tm_year )
Also you probably want to write a simple test program
to check your OS's C library functions. Several OS's
until very recently still shipped with non-compliant
date related library functions.
So in answer to your question, while grep is a good place
to start, you will still need to take a hard look at the code.
John Kroll
next prev parent reply other threads:[~1997-09-03 4:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-09-02 4:00 What do you look for in C/C++ source? tm_year? David Means
1997-09-02 4:00 ` Eric Buckley
1997-09-03 4:00 ` John A. Kroll [this message]
1997-09-04 4:00 ` Arne Vajh�j
[not found] ` <34101ba1.2323741@news.gate.net>
1997-09-05 4:00 ` Chris Waters
[not found] <340C34B7.1BE36F49@bellsouth.net.no_spam>
[not found] ` <340CAC2A.167E@stl.dec.com>
1997-09-03 4:00 ` Kaz Kylheku
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox