diff options
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/time/localtime.c | 46 | ||||
-rw-r--r-- | lib/libc/time/private.h | 11 | ||||
-rw-r--r-- | lib/libc/time/strftime.c | 9 | ||||
-rw-r--r-- | lib/libc/time/wcsftime.c | 13 |
4 files changed, 19 insertions, 60 deletions
diff --git a/lib/libc/time/localtime.c b/lib/libc/time/localtime.c index 9398e8b967c..76324a40908 100644 --- a/lib/libc/time/localtime.c +++ b/lib/libc/time/localtime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: localtime.c,v 1.42 2015/02/09 13:46:22 tedu Exp $ */ +/* $OpenBSD: localtime.c,v 1.43 2015/02/09 14:00:03 tedu Exp $ */ /* ** This file is in the public domain, so clarified as of ** 1996-06-05 by Arthur David Olson. @@ -307,8 +307,7 @@ differ_by_repeat(t1, t0) const time_t t1; const time_t t0; { - if (TYPE_INTEGRAL(time_t) && - TYPE_BIT(time_t) - TYPE_SIGNED(time_t) < SECSPERREPEAT_BITS) + if (TYPE_BIT(time_t) - 1 < SECSPERREPEAT_BITS) return 0; return (int64_t)t1 - t0 == SECSPERREPEAT; } @@ -483,23 +482,10 @@ register const int doextend; for (i = 0; i < sp->timecnt - 2; ++i) if (sp->ats[i] > sp->ats[i + 1]) { ++i; - if (TYPE_SIGNED(time_t)) { - /* - ** Ignore the end (easy). - */ - sp->timecnt = i; - } else { - /* - ** Ignore the beginning (harder). - */ - register int j; - - for (j = 0; j + i < sp->timecnt; ++j) { - sp->ats[j] = sp->ats[j + i]; - sp->types[j] = sp->types[j + i]; - } - sp->timecnt = j; - } + /* + ** Ignore the end (easy). + */ + sp->timecnt = i; break; } /* @@ -513,7 +499,7 @@ register const int doextend; /* ** If this is a narrow integer time_t system, we're done. */ - if (stored >= (int) sizeof(time_t) && TYPE_INTEGRAL(time_t)) + if (stored >= (int) sizeof(time_t)) break; } if (doextend && nread > 2 && @@ -1807,20 +1793,10 @@ const int do_norm_secs; /* ** Do a binary search (this works whatever time_t's type is). */ - if (!TYPE_SIGNED(time_t)) { - lo = 0; - hi = lo - 1; - } else if (!TYPE_INTEGRAL(time_t)) { - if (sizeof(time_t) > sizeof(float)) - hi = (time_t) DBL_MAX; - else hi = (time_t) FLT_MAX; - lo = -hi; - } else { - lo = 1; - for (i = 0; i < (int) TYPE_BIT(time_t) - 1; ++i) - lo *= 2; - hi = -(lo + 1); - } + lo = 1; + for (i = 0; i < (int) TYPE_BIT(time_t) - 1; ++i) + lo *= 2; + hi = -(lo + 1); for ( ; ; ) { t = lo / 2 + hi / 2; if (t < lo) diff --git a/lib/libc/time/private.h b/lib/libc/time/private.h index 647a998ab41..3c7aaec6eee 100644 --- a/lib/libc/time/private.h +++ b/lib/libc/time/private.h @@ -1,4 +1,4 @@ -/* $OpenBSD: private.h,v 1.33 2015/02/09 13:46:22 tedu Exp $ */ +/* $OpenBSD: private.h,v 1.34 2015/02/09 14:00:03 tedu Exp $ */ #ifndef PRIVATE_H #define PRIVATE_H @@ -70,15 +70,6 @@ const char * scheck(const char * string, const char * format); #define TYPE_SIGNED(type) (((type) -1) < 0) #endif /* !defined TYPE_SIGNED */ -/* -** Since the definition of TYPE_INTEGRAL contains floating point numbers, -** it cannot be used in preprocessor directives. -*/ - -#ifndef TYPE_INTEGRAL -#define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5) -#endif /* !defined TYPE_INTEGRAL */ - #ifndef INT_STRLEN_MAXIMUM /* ** 302 / 1000 is log10(2.0) rounded up. diff --git a/lib/libc/time/strftime.c b/lib/libc/time/strftime.c index 98fa6de7000..de1f12cb759 100644 --- a/lib/libc/time/strftime.c +++ b/lib/libc/time/strftime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strftime.c,v 1.23 2015/02/09 13:32:51 tedu Exp $ */ +/* $OpenBSD: strftime.c,v 1.24 2015/02/09 14:00:03 tedu Exp $ */ /* ** Copyright (c) 1989, 1993 ** The Regents of the University of California. All rights reserved. @@ -306,11 +306,8 @@ label: tm = *t; mkt = mktime(&tm); - if (TYPE_SIGNED(time_t)) - (void) snprintf(buf, sizeof buf, - "%ld", (long) mkt); - else (void) snprintf(buf, sizeof buf, - "%lu", (unsigned long) mkt); + (void) snprintf(buf, sizeof buf, + "%ld", (long) mkt); pt = _add(buf, pt, ptlim); } continue; diff --git a/lib/libc/time/wcsftime.c b/lib/libc/time/wcsftime.c index 2affa52a01e..db905a85395 100644 --- a/lib/libc/time/wcsftime.c +++ b/lib/libc/time/wcsftime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wcsftime.c,v 1.4 2015/02/09 13:32:51 tedu Exp $ */ +/* $OpenBSD: wcsftime.c,v 1.5 2015/02/09 14:00:03 tedu Exp $ */ /* ** Based on the UCB version with the ID appearing below. ** This is ANSIish only when "multibyte character == plain character". @@ -292,14 +292,9 @@ label: tm = *t; mkt = mktime(&tm); - if (TYPE_SIGNED(time_t)) - (void) swprintf(buf, - sizeof buf/sizeof buf[0], - L"%ld", (long) mkt); - else - (void) swprintf(buf, - sizeof buf/sizeof buf[0], - L"%lu", (unsigned long) mkt); + (void) swprintf(buf, + sizeof buf/sizeof buf[0], + L"%ld", (long) mkt); pt = _add(buf, pt, ptlim); } continue; |