[Python-checkins] CVS: python/dist/src/Modules timemodule.c,2.113,2.114

Guido van Rossum gvanrossum@users.sourceforge.net
Tue, 25 Sep 2001 06:59:03 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv7427

Modified Files:
	timemodule.c 
Log Message:
SF patch #459385 (Norman Vine): time.timezone fix for Cygwin.

Also did some whitespace normalization.


Index: timemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v
retrieving revision 2.113
retrieving revision 2.114
diff -C2 -d -r2.113 -r2.114
*** timemodule.c	2001/08/22 12:39:16	2.113
--- timemodule.c	2001/09/25 13:59:01	2.114
***************
*** 89,93 ****
  static long timezone;
  
! static void 
  initmactimezone(void)
  {
--- 89,93 ----
  static long timezone;
  
! static void
  initmactimezone(void)
  {
***************
*** 96,108 ****
  
  	ReadLocation(&loc);
! 	
  	if (loc.latitude == 0 && loc.longitude == 0 && loc.u.gmtDelta == 0)
  		return;
! 	
  	delta = loc.u.gmtDelta & 0x00FFFFFF;
! 	
  	if (delta & 0x00800000)
  		delta |= 0xFF000000;
! 	
  	timezone = -delta;
  }
--- 96,108 ----
  
  	ReadLocation(&loc);
! 
  	if (loc.latitude == 0 && loc.longitude == 0 && loc.u.gmtDelta == 0)
  		return;
! 
  	delta = loc.u.gmtDelta & 0x00FFFFFF;
! 
  	if (delta & 0x00800000)
  		delta |= 0xFF000000;
! 
  	timezone = -delta;
  }
***************
*** 163,170 ****
  	if (LargeIntegerEqualToZero(divisor)) {
  		QueryPerformanceCounter(&ctrStart);
! 		if (!QueryPerformanceFrequency(&divisor) || 
  		    LargeIntegerEqualToZero(divisor)) {
! 				/* Unlikely to happen - 
! 				   this works on all intel machines at least! 
  				   Revert to clock() */
  			return PyFloat_FromDouble(clock());
--- 163,170 ----
  	if (LargeIntegerEqualToZero(divisor)) {
  		QueryPerformanceCounter(&ctrStart);
! 		if (!QueryPerformanceFrequency(&divisor) ||
  		    LargeIntegerEqualToZero(divisor)) {
! 				/* Unlikely to happen -
! 				   this works on all intel machines at least!
  				   Revert to clock() */
  			return PyFloat_FromDouble(clock());
***************
*** 175,182 ****
  	diff = LargeIntegerDivide(diff, divisor, &rem);
  	/* XXX - we assume both divide results fit in 32 bits.  This is
! 	   true on Intels.  First person who can afford a machine that 
  	   doesnt deserves to fix it :-)
  	*/
! 	return PyFloat_FromDouble((double)diff.LowPart + 
  		              ((double)rem.LowPart / (double)divisor.LowPart));
  }
--- 175,182 ----
  	diff = LargeIntegerDivide(diff, divisor, &rem);
  	/* XXX - we assume both divide results fit in 32 bits.  This is
! 	   true on Intels.  First person who can afford a machine that
  	   doesnt deserves to fix it :-)
  	*/
! 	return PyFloat_FromDouble((double)diff.LowPart +
  		              ((double)rem.LowPart / (double)divisor.LowPart));
  }
***************
*** 342,346 ****
  	} else if (!gettmarg(tup, &buf))
  		return NULL;
! 	
  	fmtlen = strlen(fmt);
  
--- 342,346 ----
  	} else if (!gettmarg(tup, &buf))
  		return NULL;
! 
  	fmtlen = strlen(fmt);
  
***************
*** 448,452 ****
  	time_t tt;
  	char *p;
! 	
  	if (PyTuple_Size(args) == 0)
  		tt = time(NULL);
--- 448,452 ----
  	time_t tt;
  	char *p;
! 
  	if (PyTuple_Size(args) == 0)
  		tt = time(NULL);
***************
*** 492,496 ****
  	if (tt == (time_t)(-1)) {
  		PyErr_SetString(PyExc_OverflowError,
!                                 "mktime argument out of range");
  		return NULL;
  	}
--- 492,496 ----
  	if (tt == (time_t)(-1)) {
  		PyErr_SetString(PyExc_OverflowError,
! 				"mktime argument out of range");
  		return NULL;
  	}
***************
*** 585,590 ****
  strptime() -- parse string to time tuple according to format specification\n\
  ";
-   
  
  DL_EXPORT(void)
  inittime(void)
--- 585,590 ----
  strptime() -- parse string to time tuple according to format specification\n\
  ";
  
+ 
  DL_EXPORT(void)
  inittime(void)
***************
*** 600,604 ****
  	Py_INCREF(d);
  	moddict = d;
! #if defined(HAVE_TZNAME) && !defined(__GLIBC__)
  	tzset();
  #ifdef PYOS_OS2
--- 600,604 ----
  	Py_INCREF(d);
  	moddict = d;
! #if defined(HAVE_TZNAME) && !defined(__GLIBC__) && !defined(__CYGWIN__)
  	tzset();
  #ifdef PYOS_OS2
***************
*** 618,622 ****
  	ins(d, "daylight", PyInt_FromLong((long)daylight));
  	ins(d, "tzname", Py_BuildValue("(zz)", tzname[0], tzname[1]));
! #else /* !HAVE_TZNAME || __GLIBC__ */
  #ifdef HAVE_TM_ZONE
  	{
--- 618,622 ----
  	ins(d, "daylight", PyInt_FromLong((long)daylight));
  	ins(d, "tzname", Py_BuildValue("(zz)", tzname[0], tzname[1]));
! #else /* !HAVE_TZNAME || __GLIBC__ || __CYGWIN__*/
  #ifdef HAVE_TM_ZONE
  	{
***************
*** 636,640 ****
  		strncpy(julyname, p->tm_zone ? p->tm_zone : "   ", 9);
  		julyname[9] = '\0';
! 		
  		if( janzone < julyzone ) {
  			/* DST is reversed in the southern hemisphere */
--- 636,640 ----
  		strncpy(julyname, p->tm_zone ? p->tm_zone : "   ", 9);
  		julyname[9] = '\0';
! 
  		if( janzone < julyzone ) {
  			/* DST is reversed in the southern hemisphere */
***************
*** 674,678 ****
  	ins(d, "tzname", Py_BuildValue("(zz)", _tzname[0], _tzname[1]));
  #endif /* __CYGWIN__ */
! #endif /* !HAVE_TZNAME || __GLIBC__ */
  }
  
--- 674,678 ----
  	ins(d, "tzname", Py_BuildValue("(zz)", _tzname[0], _tzname[1]));
  #endif /* __CYGWIN__ */
! #endif /* !HAVE_TZNAME || __GLIBC__ || __CYGWIN__*/
  }
  
***************
*** 821,825 ****
  			return;
  		}
! 		
  		Py_BEGIN_ALLOW_THREADS
  		/* BeOS snooze() is in microseconds... */
--- 821,825 ----
  			return;
  		}
! 
  		Py_BEGIN_ALLOW_THREADS
  		/* BeOS snooze() is in microseconds... */