diff options
author | Andreas Tobler <a.tobler@schweiz.ch> | 2002-01-06 22:38:15 +0100 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2002-01-06 21:38:15 +0000 |
commit | ebecd56de9b0040c4e94cd95fd8c2782fdbbcd0e (patch) | |
tree | 09e8454bd50a780cd2dc8bcf9b752dd19c8cbe89 /libjava/java/lang/natSystem.cc | |
parent | 0b34d6fa11e3d4b37af5d5d1b6e78a30e49a2c9f (diff) | |
download | gcc-ebecd56de9b0040c4e94cd95fd8c2782fdbbcd0e.zip gcc-ebecd56de9b0040c4e94cd95fd8c2782fdbbcd0e.tar.gz gcc-ebecd56de9b0040c4e94cd95fd8c2782fdbbcd0e.tar.bz2 |
configure, [...]: Rebuilt.
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.
From-SVN: r48588
Diffstat (limited to 'libjava/java/lang/natSystem.cc')
-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 9d5040c..f970ee6 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; } |