From 5e3f7933267db1e73f020e40a36d98b6fe06a88a Mon Sep 17 00:00:00 2001 From: mainzelm Date: Fri, 19 Oct 2001 13:26:56 +0000 Subject: [PATCH] Prevent FreeBSD's strftime from segfaulting by setting tm_zone. --- scsh/time1.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scsh/time1.c b/scsh/time1.c index 0621207..2c335ba 100644 --- a/scsh/time1.c +++ b/scsh/time1.c @@ -322,7 +322,7 @@ s48_value date2time(s48_value sec, s48_value min, s48_value hour, s48_value format_date(s48_value sch_fmt, s48_value sch_sec, s48_value sch_min, s48_value sch_hour, s48_value sch_mday, s48_value sch_month, s48_value sch_year, - s48_value tz, s48_value sch_summer, + s48_value sch_tz, s48_value sch_summer, s48_value sch_week_day, s48_value sch_year_day) { struct tm d; @@ -349,6 +349,10 @@ s48_value format_date(s48_value sch_fmt, s48_value sch_sec, s48_value sch_min, d.tm_yday = s48_extract_fixnum(sch_year_day); d.tm_isdst = (S48_EQ_P (sch_summer, S48_FALSE)) ? 0 : 1; +#ifdef HAVE_TM_ZONE + d.tm_zone = s48_extract_string(sch_tz); /* FreeBSD's strftime reads this */ +#endif + /* Copy fmt -> fmt2, converting ~ escape codes to % escape codes. ** Set zone=1 if fmt has a ~Z. ** Build up an estimate of how large the target buffer needs to be. @@ -404,8 +408,8 @@ s48_value format_date(s48_value sch_fmt, s48_value sch_sec, s48_value sch_min, *q++ = 'x'; *q = '\0'; /* Append the guard "x" suffix and nul-terminate. */ /* Fix up the time-zone if it is being used and the user passed one in. */ - if( zone && S48_STRING_P(tz) ) { - oldenv = make_newenv(tz, newenv); + if( zone && S48_STRING_P(sch_tz) ) { + oldenv = make_newenv(sch_tz, newenv); if( !oldenv ) { int err = errno; Free(fmt);