diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-01-06 21:38:15 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-01-06 21:38:15 +0000 |
commit | 33a40528d32b7325928af88e2f243d761bbea93c (patch) | |
tree | 09e8454bd50a780cd2dc8bcf9b752dd19c8cbe89 /libjava/java/lang | |
parent | 60ed36a27941ad3adbfa192642ea2a4ca0d79b20 (diff) | |
download | gcc-33a40528d32b7325928af88e2f243d761bbea93c.tar.gz |
2002-01-06 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48588 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/lang')
-rw-r--r-- | libjava/java/lang/natSystem.cc | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/libjava/java/lang/natSystem.cc b/libjava/java/lang/natSystem.cc index 9d5040cb2e9..f970ee64de5 100644 --- a/libjava/java/lang/natSystem.cc +++ b/libjava/java/lang/natSystem.cc @@ -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 @@ java::lang::System::getSystemTimeZone (void) { 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 @@ java::lang::System::getSystemTimeZone (void) // 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; } |