[Python-checkins] CVS: python/dist/src/Modules getaddrinfo.c,1.5,1.6 socketmodule.c,1.155,1.156

Martin v. L?wis loewis@users.sourceforge.net
Mon, 23 Jul 2001 23:33:10 -0700


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

Modified Files:
	getaddrinfo.c socketmodule.c 
Log Message:
Autocheck for snprintf, and use sprintf if it is not available.
Remove declaration of h_errno, since it is supposedly declared in netdb.h.
Changes proposed by itojun.


Index: getaddrinfo.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/getaddrinfo.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** getaddrinfo.c	2001/07/23 07:27:16	1.5
--- getaddrinfo.c	2001/07/24 06:33:08	1.6
***************
*** 545,552 ****
  	int i, error = 0, h_error;
  	char *ap;
- #if !defined(INET6) && !defined(h_errno)
- 	/* In winsock.h, h_errno is #defined as a function call. */
- 	extern int h_errno;
- #endif
  
  	top = NULL;
--- 545,548 ----

Index: socketmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v
retrieving revision 1.155
retrieving revision 1.156
diff -C2 -d -r1.155 -r1.156
*** socketmodule.c	2001/07/23 07:27:16	1.155
--- socketmodule.c	2001/07/24 06:33:08	1.156
***************
*** 1790,1796 ****
  	if (h == NULL) {
  		/* Let's get real error message to return */
- #ifndef h_errno
- 		extern int h_errno;
- #endif
  		PyH_Err(h_errno);
  		return NULL;
--- 1790,1793 ----
***************
*** 2349,2353 ****
--- 2346,2354 ----
  	}
  	if (PyInt_Check(pobj)) {
+ #ifndef HAVE_SNPRINTF
+ 		sprintf(pbuf, "%ld", PyInt_AsLong(pobj));
+ #else
  		snprintf(pbuf, sizeof(pbuf), "%ld", PyInt_AsLong(pobj));
+ #endif
  		pptr = pbuf;
  	} else if (PyString_Check(pobj)) {
***************
*** 2420,2424 ****
--- 2421,2429 ----
  	if (n == 0)
  		goto fail;
+ #ifdef HAVE_SPRINTF
  	snprintf(pbuf, sizeof(pbuf), "%d", port);
+ #else
+ 	sprintf(pbuf, "%d", port);
+ #endif
  	memset(&hints, 0, sizeof(hints));
  	hints.ai_family = PF_UNSPEC;