This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: patch2 darwin & libgcj
- From: Andreas Tobler <toa at pop dot agri dot ch>
- To: tromey at redhat dot com
- Cc: GCC-Java <java at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 02 Jan 2002 16:13:45 +0100
- Subject: Re: patch2 darwin & libgcj
- Organization: zero
- References: <3C2DF8CB.8E55E6FB@pop.agri.ch> <871yh9bp2r.fsf@creche.redhat.com>
Tom Tromey wrote:
> So you'd end up with something like:
>
> char *tz1, *tz2;
> #ifdef HAVE_TM_ZONE
> tz1 = tim->tm_zone;
> tz2 = NULL;
> #elif defined (HAVE_TZNAME)
> tz1 = tzname[0];
> tz2 = strcmp (tzname[0], tzname[1]) ? tzname[1] : NULL;
> #else
> #error etc
> #endif
Is this one better? Built on darwin5.2 (ppc) and powerpc-unknown-linux-gnu.
On darwin I'm not able to link, but this is due to something else I guess.
2002-01-02 Andreas Tobler <a.tobler@schweiz.ch>
* libjava/configure.in
add a timezone check
* libjava/java/lang/natSystem.cc
handle the above timezone check
--- gccclean/gcc/libjava/configure.in Mon Dec 17 09:01:00 2001
+++ gccsrc/gcc/libjava/configure.in Sat Dec 29 11:30:31 2001
@@ -794,6 +794,8 @@
AC_FUNC_ALLOCA
+AC_STRUCT_TIMEZONE
+
AC_CHECK_PROGS(PERL, perl, false)
SYSDEP_SOURCES=
--- gccclean/gcc/libjava/java/lang/natSystem.cc Sat Dec 1 11:59:02 2001
+++ gccsrc/gcc/libjava/java/lang/natSystem.cc Wed Jan 2 12:42:11 2002
@@ -242,7 +242,8 @@
{
struct tm *tim;
time_t current_time;
- char **tzinfo, *tzid;
+ const char *tz1;
+ char *tzid, *tz2;
long tzoffset;
current_time = time(0);
@@ -263,26 +264,38 @@
// issue exists in java/util/natGregorianCalendar.cc.
tzoffset = 0L;
#endif
- tzinfo = tzname;
+ // check if a system has tzname or not. Not sure how to handle else
+ // darwin does not have the tzname so I tried
+ // a.tobler@schweiz.ch 02012002
+#ifdef HAVE_TM_ZONE
+ tz1 = tim->tm_zone;
+ tz2 = NULL;
+#elif defined (HAVE_TZNAME)
+ tz1 = tzname[0];
+ tz2 = strcmp (tzname[0], tzname[1]) ? tzname[1] : NULL;
+#else
+ //what to do else ?
+#error neither tzname nor tm_zone defined
+#endif
if ((tzoffset % 3600) == 0)
tzoffset = tzoffset / 3600;
- if (!strcmp(tzinfo[0], tzinfo[1]))
+ if (!strcmp(tz1, tz2))
{
- tzid = (char*) _Jv_Malloc (strlen(tzinfo[0]) + 6);
+ tzid = (char*) _Jv_Malloc (strlen(tz1) + 6);
if (!tzid)
return NULL;
- sprintf(tzid, "%s%ld", tzinfo[0], tzoffset);
+ sprintf(tzid, "%s%ld", tz1, tzoffset);
}
else
{
- tzid = (char*) _Jv_Malloc (strlen(tzinfo[0]) + strlen(tzinfo[1])
+ 6);
+ tzid = (char*) _Jv_Malloc (strlen(tz1) + strlen(tz2) + 6);
if (!tzid)
return NULL;
- sprintf(tzid, "%s%ld%s", tzinfo[0], tzoffset, tzinfo[1]);
+ sprintf(tzid, "%s%ld%s", tz1, tzoffset, tz2);
}
jstring retval = JvNewStringUTF (tzid);