unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* Patch for scm_strftime() in stime.c
@ 2004-05-02 14:45 Andreas Vögele
  2004-05-02 19:46 ` Andreas Vögele
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Vögele @ 2004-05-02 14:45 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 315 bytes --]

Hi,

on HP-UX, test-suite/time.test fails. The problem is that there may be 
a mismatch between the time zone name and the daylight savings time 
setting. The patch changes scm_strftime() so that mktime() is called to 
fix tm_isdst. I don't know if this problem is HP-specific but I decided 
to use #ifdef __hpux.


[-- Attachment #2: stime.c.diff --]
[-- Type: application/octet-stream, Size: 583 bytes --]

Index: stime.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/stime.c,v
retrieving revision 1.88
diff -u -r1.88 stime.c
--- stime.c	27 Apr 2004 22:43:28 -0000	1.88
+++ stime.c	2 May 2004 14:36:59 -0000
@@ -633,6 +633,12 @@
 	have_zone = 1;
 	SCM_DEFER_INTS;
 	oldenv = setzone (zone, SCM_ARG2, FUNC_NAME);
+
+	/* On HP-UX, the conversion specifier %Z may produce an empty time
+	   zone abbreviation unless mktime() is called to fix tm_isdst. */
+# if defined(__hpux)
+	mktime (&t);
+# endif
       }
 #endif
 

[-- Attachment #3: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Patch for scm_strftime() in stime.c
  2004-05-02 14:45 Patch for scm_strftime() in stime.c Andreas Vögele
@ 2004-05-02 19:46 ` Andreas Vögele
  2004-05-02 23:02   ` Kevin Ryde
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Vögele @ 2004-05-02 19:46 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1338 bytes --]

Andreas Vögele wrote:

> Hi,
>
> on HP-UX, test-suite/time.test fails. The problem is that there may be 
> a mismatch between the time zone name and the daylight savings time 
> setting.

I thought about this problem. It's probably better to fix the test 
instead of scm_strftime(). The test gets the local time and then sets 
the time zone to "ZOW". The daylights savings time indicator, which is 
currently set in Central Europe, is not unset. Since "ZOW" is not known 
to be a time zone where dst is in effect the function strftime() 
outputs an empty  time zone name on HP-UX. BTW, that explains why the 
time test didn't fail a couple of weeks ago. At that time dst wasn't in 
effect in Central Europe.

The patch that I sent this afternoon uses mktime() in scm_strftime() to 
fix the tm_isdst field. But IMHO it's better to fix the test even if 
that means that HP-UX and glibc-based systems behave differently in 
some cases. Or do you think that scm_strftime() should silently fix 
mismatches between the time zone name and dst?

If yes, then I'd remove #idef __hpux since other systems might behave 
similarly to HP-UX. On HP-UX, mktime() doesn't fail if the time zone 
and dst mismatch. Instead, tm_isdst is modified. I don't know about 
other systems, though.

A patch for time.test is attached.


[-- Attachment #2: time.test.diff --]
[-- Type: application/octet-stream, Size: 557 bytes --]

Index: time.test
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/test-suite/tests/time.test,v
retrieving revision 1.1
diff -u -r1.1 time.test
--- time.test	15 Jun 1999 14:09:53 -0000	1.1
+++ time.test	2 May 2004 19:20:39 -0000
@@ -24,5 +24,7 @@
 (pass-if "strftime %Z doesn't return garbage"
 	 (let ((t (localtime (current-time))))
 	   (vector-set! t 10 "ZOW")
+	   ; Make sure that daylight savings time is disabled.
+	   (vector-set! t 8 0)
 	   (string=? (strftime "%Z" t)
 		     "ZOW")))

[-- Attachment #3: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Patch for scm_strftime() in stime.c
  2004-05-02 19:46 ` Andreas Vögele
@ 2004-05-02 23:02   ` Kevin Ryde
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Ryde @ 2004-05-02 23:02 UTC (permalink / raw)


Andreas Vögele <voegelas@gmx.net> writes:
>
> I thought about this problem. It's probably better to fix the test
> instead of scm_strftime().

Yep, it looks pretty dodgy.  I wonder what it was trying to exercise.

> Or do you think that scm_strftime() should silently fix
> mismatches between the time zone name and dst?

I think it should print what's in the tm record it's given.  If the
user has butchered the info then that's their problem.

> A patch for time.test is attached.

Thanks, I made that change, but using set-tm:isdst.


_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-05-02 23:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-02 14:45 Patch for scm_strftime() in stime.c Andreas Vögele
2004-05-02 19:46 ` Andreas Vögele
2004-05-02 23:02   ` Kevin Ryde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).