[Python-checkins] CVS: python/dist/src/Modules structmodule.c,2.39,2.40

Martin v. Löwis python-dev@python.org
Fri, 15 Sep 2000 01:10:37 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv9534

Modified Files:
	structmodule.c 
Log Message:
Use symbolic constants for allowable short ranges.


Index: structmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/structmodule.c,v
retrieving revision 2.39
retrieving revision 2.40
diff -C2 -r2.39 -r2.40
*** structmodule.c	2000/09/15 07:31:57	2.39
--- structmodule.c	2000/09/15 08:10:33	2.40
***************
*** 67,70 ****
--- 67,72 ----
  #define VOID_P_ALIGN (sizeof(s_void_p) - sizeof(void *))
  
+ #define STRINGIFY(x)    #x
+ 
  #ifdef __powerc
  #pragma options align=reset
***************
*** 520,526 ****
  	if (get_long(v, &x) < 0)
  		return -1;
! 	if (x < -32768 || x > 32767){
  		PyErr_SetString(StructError,
! 				"short format requires -32768<=number<=32767");
  		return -1;
  	}
--- 522,529 ----
  	if (get_long(v, &x) < 0)
  		return -1;
! 	if (x < SHRT_MIN || x > SHRT_MAX){
  		PyErr_SetString(StructError,
! 				"short format requires " STRINGIFY(SHRT_MIN)
!                                 "<=number<=" STRINGIFY(SHRT_MAX));
  		return -1;
  	}
***************
*** 535,541 ****
  	if (get_long(v, &x) < 0)
  		return -1;
! 	if (x < 0 || x > 65535){
  		PyErr_SetString(StructError,
! 				"short format requires 0<=number<=65535");
  		return -1;
  	}
--- 538,544 ----
  	if (get_long(v, &x) < 0)
  		return -1;
! 	if (x < 0 || x > USHRT_MAX){
  		PyErr_SetString(StructError,
! 				"short format requires 0<=number<=" STRINGIFY(USHRT_MAX));
  		return -1;
  	}