From: "Alvar Penning" Subject: Re: newsyslog To: "Matthias Kilian" Cc: Date: Thu, 02 Apr 2026 08:20:24 +0200 On Wed Apr 1, 2026 at 11:30 PM CEST, Matthias Kilian wrote: > Hi, > > On Wed, Apr 01, 2026 at 10:41:28PM +0200, Alvar Penning wrote: >> diff --git a/newsyslog.c b/newsyslog.c >> index 0be4ed259b9..d4a62194ab3 100644 >> --- a/newsyslog.c >> +++ b/newsyslog.c >> @@ -1251,12 +1251,12 @@ parseDWM(char *s) >> >> nd = mtab[tm.tm_mon]; >> >> - if (tm.tm_mon == 1) { >> - if (((tm.tm_year + 1900) % 4 == 0) && >> - ((tm.tm_year + 1900) % 100 != 0) && >> - ((tm.tm_year + 1900) % 400 == 0)) { >> - nd++; /* leap year, 29 days in february */ >> - } >> + /* leap year, 29 days in february */ >> + if ((tm.tm_mon == 1) && ((tm.tm_year + 1900) % 4 == 0)) { >> + if ((tm.tm_year + 1900) % 100 != 0) >> + nd++; /* divisible by 4, not divisible by 100 */ >> + else if ((tm.tm_year + 1900) % 400 == 0) >> + nd++; /* divisible by 4, 100 and 400 */ >> } >> tm.tm_hour = tm.tm_min = tm.tm_sec = 0; > > While this looks correct to me, wouldn't something like this be > better? The effect would be the same. However, personally I find it a bit harder to read. That's why I rewrote the logic. But I am fine with both. > > --- newsyslog.c Tue Sep 23 08:09:56 2025 > +++ newsyslog.c.new Wed Apr 1 23:28:07 2026 > @@ -1253,8 +1253,8 @@ > > if (tm.tm_mon == 1) { > if (((tm.tm_year + 1900) % 4 == 0) && > - ((tm.tm_year + 1900) % 100 != 0) && > - ((tm.tm_year + 1900) % 400 == 0)) { > + (((tm.tm_year + 1900) % 100 != 0) || > + ((tm.tm_year + 1900) % 400 == 0))) { > nd++; /* leap year, 29 days in february */ > } > } > > Ciao, > Kili