Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/time Add tzgetgmtoff, delint compat



details:   https://anonhg.NetBSD.org/src/rev/2773befd4710
branches:  trunk
changeset: 811425:2773befd4710
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Oct 29 17:49:24 2015 +0000

description:
Add tzgetgmtoff, delint compat

diffstat:

 lib/libc/time/localtime.c |  27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)

diffs (62 lines):

diff -r 6e0f56b2ec6f -r 2773befd4710 lib/libc/time/localtime.c
--- a/lib/libc/time/localtime.c Thu Oct 29 17:48:55 2015 +0000
+++ b/lib/libc/time/localtime.c Thu Oct 29 17:49:24 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: localtime.c,v 1.98 2015/10/09 17:21:45 christos Exp $  */
+/*     $NetBSD: localtime.c,v 1.99 2015/10/29 17:49:24 christos Exp $  */
 
 /*
 ** This file is in the public domain, so clarified as of
@@ -10,7 +10,7 @@
 #if 0
 static char    elsieid[] = "@(#)localtime.c    8.17";
 #else
-__RCSID("$NetBSD: localtime.c,v 1.98 2015/10/09 17:21:45 christos Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.99 2015/10/29 17:49:24 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -289,6 +289,25 @@
        return NULL;
 }
 
+long
+tzgetgmtoff(const timezone_t sp, int isdst)
+{
+       int i;
+       long l = -1;
+       for (i = 0; i < sp->timecnt; ++i) {
+               const struct ttinfo *const ttisp = &sp->ttis[sp->types[i]];
+
+               if (ttisp->tt_isdst == isdst) {
+                       l = ttisp->tt_gmtoff;
+                       if (sp->types[i] != 0)
+                               return l;
+               }
+       }
+       if (l == -1)
+               errno = ESRCH;
+       return l;
+}
+
 static void
 scrub_abbrs(struct state *sp)
 {
@@ -617,7 +636,7 @@
                                break;
                              }
                            if (! (j < charcnt)) {
-                             int tsabbrlen = strlen(tsabbr);
+                             size_t tsabbrlen = strlen(tsabbr);
                              if (j + tsabbrlen < TZ_MAX_CHARS) {
                                strcpy(sp->chars + j, tsabbr);
                                charcnt = j + tsabbrlen + 1;
@@ -1253,7 +1272,7 @@
                init_ttinfo(&sp->ttis[1], 0, false, 0);
                sp->defaulttype = 0;
        }
-       sp->charcnt = charcnt;
+       sp->charcnt = (int)charcnt;
        cp = sp->chars;
        (void) memcpy(cp, stdname, stdlen);
        cp += stdlen;



Home | Main Index | Thread Index | Old Index