Patch: FYI: timezone
Tom Tromey
tromey@redhat.com
Sun Jan 6 13:37:00 GMT 2002
Here's the modified timezone patch discussed on the main list.
I'm checking this in.
Tom
Index: ChangeLog
from Andreas Tobler <a.tobler@schweiz.ch>
* configure, include/config.h.in: Rebuilt.
* java/lang/natSystem.cc (getSystemTimeZone): Check HAVE_TM_ZONE.
* configure.in: Call AC_STRUCT_TIMEZONE.
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/libjava/configure.in,v
retrieving revision 1.103
diff -u -r1.103 configure.in
--- configure.in 2001/12/16 22:33:01 1.103
+++ configure.in 2002/01/06 19:51:37
@@ -450,6 +450,7 @@
AC_DEFINE(HAVE_PROC_SELF_EXE)])
AM_ICONV
+ AC_STRUCT_TIMEZONE
AC_CHECK_FUNCS(gethostbyname_r, [
AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Index: java/lang/natSystem.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natSystem.cc,v
retrieving revision 1.41
diff -u -r1.41 natSystem.cc
--- java/lang/natSystem.cc 2001/09/05 17:11:57 1.41
+++ java/lang/natSystem.cc 2002/01/06 19:51:37
@@ -1,6 +1,6 @@
// natSystem.cc - Native code implementing System class.
-/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001 , 2002 Free Software Foundation
This file is part of libgcj.
@@ -242,8 +242,9 @@
{
struct tm *tim;
time_t current_time;
- char **tzinfo, *tzid;
long tzoffset;
+ const char *tz1, *tz2;
+ char *tzid;
current_time = time(0);
@@ -259,34 +260,28 @@
// is available, esp. if tzname is valid.
// Richard Earnshaw <rearnsha@arm.com> has suggested using difftime to
// calculate between gmtime and localtime (and accounting for possible
- // daylight savings time) as an alternative. Also note that this same
- // issue exists in java/util/natGregorianCalendar.cc.
+ // daylight savings time) as an alternative.
tzoffset = 0L;
#endif
- tzinfo = tzname;
+#ifdef HAVE_TM_ZONE
+ tz1 = tim->tm_zone;
+ tz2 = "";
+#elif defined (HAVE_TZNAME)
+ tz1 = tzname[0];
+ tz2 = strcmp (tzname[0], tzname[1]) ? tzname[1] : "";
+#else
+#error Neither tm_zone nor tzname defined
+#endif
+
if ((tzoffset % 3600) == 0)
tzoffset = tzoffset / 3600;
-
- if (!strcmp(tzinfo[0], tzinfo[1]))
- {
- tzid = (char*) _Jv_Malloc (strlen(tzinfo[0]) + 6);
- if (!tzid)
- return NULL;
-
- sprintf(tzid, "%s%ld", tzinfo[0], tzoffset);
- }
- else
- {
- tzid = (char*) _Jv_Malloc (strlen(tzinfo[0]) + strlen(tzinfo[1]) + 6);
- if (!tzid)
- return NULL;
- sprintf(tzid, "%s%ld%s", tzinfo[0], tzoffset, tzinfo[1]);
- }
-
+ tzid = (char*) _Jv_Malloc (strlen(tz1) + strlen(tz2) + 6);
+ sprintf(tzid, "%s%ld%s", tz1, tzoffset, tz2);
jstring retval = JvNewStringUTF (tzid);
_Jv_Free (tzid);
+
return retval;
}
More information about the Java-patches
mailing list