Subject: Re: standards/11807
To: None <tech-userlevel@netbsd.org>
From: Nick Hudson <skrll@netbsd.org>
List: tech-userlevel
Date: 02/24/2001 11:59:30
This is a multi-part message in MIME format.
--------------B92E33749E8FF12B570EFF54
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

So I've been playing with a solution to the PR I raised about timezone
and I've come up with these patches. Hopefully I've addressed backwards
compatibility correctly.

Things that I'd like some guidance on the following and if I'm going in
the right direction.

o  the use of SUSV2 in lib/libc/time
o  the use of _COMPAT_TIMEZONE
o  the name of the new variable - is __susv2_timezone acceptable

Nick
[who is outside his normal pkgsrc work area]
-- 
aka skrll@netbsd.org, skrll@excite.co.uk
--------------B92E33749E8FF12B570EFF54
Content-Type: text/plain; charset=us-ascii;
 name="timezone-diffs"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="timezone-diffs"

Index: basesrc/include/time.h
===================================================================
RCS file: /cvsroot/basesrc/include/time.h,v
retrieving revision 1.25
diff -c -r1.25 time.h
*** basesrc/include/time.h	2000/07/06 12:46:48	1.25
--- basesrc/include/time.h	2001/02/24 11:50:33
***************
*** 147,155 ****
  time_t timegm __P((struct tm *const));
  time_t timeoff __P((struct tm *const, const long));
  time_t timelocal __P((struct tm *const));
- char *timezone __P((int, int));
  void tzsetwall __P((void));
  struct tm *offtime __P((const time_t *const, const long));
  #endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */
  
  #endif /* !_ANSI_SOURCE */
--- 147,161 ----
  time_t timegm __P((struct tm *const));
  time_t timeoff __P((struct tm *const, const long));
  time_t timelocal __P((struct tm *const));
  void tzsetwall __P((void));
  struct tm *offtime __P((const time_t *const, const long));
+ 
+ /* This might need to be outside this if */
+ #ifndef _COMPAT_TIMEZONE
+ extern long int timezone __RENAME(_susv2_timezone);
+ #else
+ char *timezone __P((int, int));
+ #endif
  #endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */
  
  #endif /* !_ANSI_SOURCE */
Index: basesrc/lib/libc/shlib_version
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/shlib_version,v
retrieving revision 1.101
diff -c -r1.101 shlib_version
*** basesrc/lib/libc/shlib_version	2001/02/19 22:15:35	1.101
--- basesrc/lib/libc/shlib_version	2001/02/24 11:50:33
***************
*** 6,11 ****
  # - libc/net: resolver update to BIND8/9?
  # - md4, md5, rmd160 & sha1 functions should take the same arguments AFAP
  # - libc/gen/assert.c: __{diag,}assert13() -> __{diag,}assert()
  #
  major=12
! minor=71
--- 6,12 ----
  # - libc/net: resolver update to BIND8/9?
  # - md4, md5, rmd160 & sha1 functions should take the same arguments AFAP
  # - libc/gen/assert.c: __{diag,}assert13() -> __{diag,}assert()
+ # - move char *timezone() to libcompat
  #
  major=12
! minor=72
Index: basesrc/lib/libc/gen/timezone.c
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/gen/timezone.c,v
retrieving revision 1.14
diff -c -r1.14 timezone.c
*** basesrc/lib/libc/gen/timezone.c	2000/01/23 07:37:47	1.14
--- basesrc/lib/libc/gen/timezone.c	2001/02/24 11:50:35
***************
*** 33,38 ****
--- 33,42 ----
   * SUCH DAMAGE.
   */
  
+ #ifndef _COMPAT_TIMEZONE
+ #define _COMPAT_TIMEZONE
+ #endif
+ 
  #include <sys/cdefs.h>
  #if defined(LIBC_SCCS) && !defined(lint)
  #if 0
***************
*** 49,54 ****
--- 53,61 ----
  #include <stdlib.h>
  #include <string.h>
  #include <tzfile.h>
+ 
+ __warn_references(timezone,
+     "warning: reference to compatibility timezone; include <time.h> to generate correct reference")
  
  #if 0
  #ifdef __weak_alias
Index: basesrc/lib/libc/time/Makefile.inc
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/time/Makefile.inc,v
retrieving revision 1.7
diff -c -r1.7 Makefile.inc
*** basesrc/lib/libc/time/Makefile.inc	1999/05/04 15:34:50	1.7
--- basesrc/lib/libc/time/Makefile.inc	2001/02/24 11:50:44
***************
*** 4,10 ****
  
  SRCS+=	asctime.c difftime.c localtime.c strftime.c strptime.c
  MAN+=	ctime.3 time2posix.3 tzfile.5 tzset.3 strftime.3 strptime.3
! CFLAGS+=-DALL_STATE
  
  MLINKS+=ctime.3 ctime_r.3	\
  	ctime.3 asctime.3	\
--- 4,10 ----
  
  SRCS+=	asctime.c difftime.c localtime.c strftime.c strptime.c
  MAN+=	ctime.3 time2posix.3 tzfile.5 tzset.3 strftime.3 strptime.3
! CFLAGS+=-DALL_STATE -DSUSV2
  
  MLINKS+=ctime.3 ctime_r.3	\
  	ctime.3 asctime.3	\
Index: basesrc/lib/libc/time/localtime.c
===================================================================
RCS file: /cvsroot/basesrc/lib/libc/time/localtime.c,v
retrieving revision 1.24
diff -c -r1.24 localtime.c
*** basesrc/lib/libc/time/localtime.c	2000/09/13 22:32:28	1.24
--- basesrc/lib/libc/time/localtime.c	2001/02/24 11:51:18
***************
*** 236,241 ****
--- 236,249 ----
  time_t			altzone = 0;
  #endif /* defined ALTZONE */
  
+ /*
+  * XXX
+  * SUSv2 specifies a timezone as follows. What should the SUSV2 name be?
+  */
+ #ifdef SUSV2
+ long int timezone = 0;
+ #endif
+ 
  static long
  detzcode(codep)
  const char * const	codep;
***************
*** 279,284 ****
--- 287,295 ----
  #ifdef ALTZONE
  	altzone = 0;
  #endif /* defined ALTZONE */
+ #ifdef SUSV2
+ 	timezone = 0;
+ #endif
  #ifdef ALL_STATE
  	if (sp == NULL) {
  		tzname[0] = tzname[1] = (__aconst char *)gmt;
***************
*** 300,305 ****
--- 311,320 ----
  		if (i == 0 || ttisp->tt_isdst)
  			altzone = -(ttisp->tt_gmtoff);
  #endif /* defined ALTZONE */
+ #ifdef SUSV2
+ 		if (i == 0 || !ttisp->tt_isdst)
+ 			timezone = -(ttisp->tt_gmtoff);
+ #endif
  	}
  	/*
  	** And to get the latest zone names into tzname. . .




--------------B92E33749E8FF12B570EFF54--