scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit c6e47d620ccb3d0882fcdb938ec8e8d3c5c817b4
parent 5f241cec09bb5c207955933e41ac692f2de2c44b
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Fri, 24 Apr 2026 23:59:39 +0200

libc/time: Remove dst variable in mktime()

This avoids an additional call to _isdst() when it it is not
required and it also avoids problems in case of _isdst() has
to call mktime(), because the current code would produce an
infinite call loop.

Diffstat:
Msrc/libc/time/mktime.c | 6++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/libc/time/mktime.c b/src/libc/time/mktime.c @@ -104,7 +104,7 @@ mktime(struct tm *ptm) time_t t; long off; char *name; - int i, year, dst; + int i, year; struct tm tm; tm = *ptm; @@ -131,9 +131,7 @@ mktime(struct tm *ptm) t += (tm.tm_mday-1) * SECDAY; _tzset(); - dst = _isdst(&tm); - - if (tm.tm_isdst == 0 || tm.tm_isdst < 0 && !dst) + if (tm.tm_isdst == 0 || tm.tm_isdst < 0 && !_isdst(&tm)) off = _timezone; else off = _dstzone;