From 75c1407b9556f1c1d36c1a83929522e72d1a00bd Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Tue, 13 Jan 1998 20:54:17 +0000 Subject: [PATCH] more merges from 1.0 branch git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@423 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/date.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/date.c b/src/date.c index 906793ece5..4f484b4f64 100644 --- a/src/date.c +++ b/src/date.c @@ -43,6 +43,8 @@ static int validateDate( Date *date ); static char days[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 }; +static int been_here = 0; + /********************************************************************\ * adjustDay * * adds adj to the current day of the month... the resulting day * @@ -91,6 +93,10 @@ validateDate( Date *date ) { int valid = True; + /* the "been here" flag prevents infinite recursion */ + if (1 == been_here) return valid; + been_here = 1; + /* adjust days in february for leap year */ if ( ( ( date->year % 4 == 0 ) && ( date->year % 100 != 0 ) ) || ( date->year % 400 == 0 ) ) @@ -125,6 +131,10 @@ validateDate( Date *date ) date->year--; } + /* try again, in case a year change messed up leap year calcs. */ + validateDate (date); + been_here = 0; + return valid; }