brian 97/01/20 01:36:27
Modified: src util.c
Log:
Reviewed by: Randy Terbush, Brian Behlendorf
Submitted by: Dean Gaudet
Subject: warning from irix 6.2 cc
cfe: Warning 851: util.c, line 109: constant initializer expression is
invalid (refers to automatic variables).
struct tm gmt = *gmtime(&tt);
----^
Interesting. I'd have to dig out my copy of the ansi c standard to see
if this is valid -- but I'm tempted to believe the compiler because this
is a structure initialization, not a scalar.
Revision Changes Path
1.41 +15 -8 apache/src/util.c
Index: util.c
===================================================================
RCS file: /export/home/cvs/apache/src/util.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -C3 -r1.40 -r1.41
*** util.c 1997/01/20 04:28:17 1.40
--- util.c 1997/01/20 09:36:26 1.41
***************
*** 104,128 ****
}
/* What a pain in the ass. */
struct tm *get_gmtoff(int *tz) {
time_t tt = time(NULL);
- #if !defined(HAS_GMTOFF)
- struct tm gmt = *gmtime(&tt);
- #endif
struct tm *t = localtime(&tt);
- #if defined(HAS_GMTOFF)
*tz = (int) (t->tm_gmtoff / 60);
#else
/* Assume we are never more than 24 hours away. */
! int days = t->tm_yday - gmt.tm_yday;
! int hours = ((days < -1 ? 24 : 1 < days ? -24 : days * 24)
+ t->tm_hour - gmt.tm_hour);
! int minutes = hours * 60 + t->tm_min - gmt.tm_min;
*tz = minutes;
- #endif
return t;
}
/* Match = 0, NoMatch = 1, Abort = -1 */
--- 104,135 ----
}
/* What a pain in the ass. */
+ #if defined(HAS_GMTOFF)
struct tm *get_gmtoff(int *tz) {
time_t tt = time(NULL);
struct tm *t = localtime(&tt);
*tz = (int) (t->tm_gmtoff / 60);
+ return t
+ }
#else
+ struct tm *get_gmtoff(int *tz) {
+ time_t tt = time(NULL);
+ struct tm gmt;
+ struct tm *t;
+ int days, hours, minutes;
+
/* Assume we are never more than 24 hours away. */
! gmt = *gmtime(&tt); /* remember gmtime/localtime return ptr to static */
! t = localtime(&tt); /* buffer... so be careful */
! days = t->tm_yday - gmt.tm_yday;
! hours = ((days < -1 ? 24 : 1 < days ? -24 : days * 24)
+ t->tm_hour - gmt.tm_hour);
! minutes = hours * 60 + t->tm_min - gmt.tm_min;
*tz = minutes;
return t;
}
+ #endif
/* Match = 0, NoMatch = 1, Abort = -1 */