nickle: Fix build on SunOS and systems without timelocal().

This commit is contained in:
jperkin 2018-01-03 12:12:07 +00:00
parent 7b33b78f23
commit 9de2cbfbc5
2 changed files with 40 additions and 1 deletions

View file

@ -1,8 +1,9 @@
$NetBSD: distinfo,v 1.12 2017/11/23 16:15:23 wiz Exp $
$NetBSD: distinfo,v 1.13 2018/01/03 12:12:07 jperkin Exp $
SHA1 (nickle-2.81.tar.gz) = ef9c6de7ad2a544a3245657fbfd46dbfa9675476
RMD160 (nickle-2.81.tar.gz) = 03c8ffbebfd0104b3cd54f748f702de7e6f999f5
SHA512 (nickle-2.81.tar.gz) = b11755f824b3abf74f104db7bfaf58f52fef0b76e194ffd8c562693d5497f9de69121f9ce98777fb0366a7e02be7b32e7d800a31be03f5a5921b9d8bc3502aca
Size (nickle-2.81.tar.gz) = 579140 bytes
SHA1 (patch-aa) = 4cbb563244883f6c9f7a3594875052f8d9a9e9b3
SHA1 (patch-builtin-date.c) = ca55181a501cfbe3437d38728398852e96b0111a
SHA1 (patch-lex.c) = f9d5f3f282f97a94195730062525e9f6310bb316

View file

@ -0,0 +1,38 @@
$NetBSD: patch-builtin-date.c,v 1.1 2018/01/03 12:12:07 jperkin Exp $
Fix missing tm_zone on SunOS.
Pull in upstream fix for missing timelocal().
--- builtin-date.c.orig 2017-11-14 10:30:06.000000000 +0000
+++ builtin-date.c
@@ -76,7 +76,11 @@ to_date(struct tm *tm)
BoxValueSet (box, 6, int_value(tm->tm_wday));
BoxValueSet (box, 7, int_value(tm->tm_yday));
BoxValueSet (box, 8, tm->tm_isdst ? TrueVal : FalseVal);
+#ifdef __sun
+ BoxValueSet (box, 9, NewStrString("GMT"));
+#else
BoxValueSet (box, 9, NewStrString(tm->tm_zone));
+#endif
return ret;
}
@@ -92,7 +96,9 @@ from_date(Value date, struct tm *tm)
tm->tm_wday = value_int(date, "wday", "invalid wday", 0);
tm->tm_yday = value_int(date, "yday", "invalid yday", 0);
tm->tm_isdst = value_bool(date, "isdst", "invalid isdst", 0);
+#ifndef __sun
tm->tm_zone = NULL;
+#endif
}
static Value
@@ -143,7 +149,7 @@ do_Date_timelocal(Value v)
time_t seconds;
from_date(v, &tm);
- seconds = timelocal(&tm);
+ seconds = mktime(&tm);
RETURN(Reduce(NewSignedDigitInteger((signed_digit) seconds)));
}