[Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.102,1.103

Guido van Rossum python-dev@python.org
Fri, 21 Apr 2000 16:33:03 -0400 (EDT)


Update of /projects/cvsroot/python/dist/src/Modules
In directory eric:/projects/python/develop/guido/src/Modules

Modified Files:
	socketmodule.c 
Log Message:
Use an explicit macro SOCKETCLOSE which expands to closesocket (on
Windows), soclose (on OS2), or to close (everywhere else).

Hopefully this fixes a new compilation error that I suddenly get on
Windows because the macro definition for close -> closesocket
apparently was done before including io.h, which contains a prototype
for close.  (No idea why this wasn't an error before.)


Index: socketmodule.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Modules/socketmodule.c,v
retrieving revision 1.102
retrieving revision 1.103
diff -C2 -r1.102 -r1.103
*** socketmodule.c	2000/04/10 12:45:45	1.102
--- socketmodule.c	2000/04/21 20:33:00	1.103
***************
*** 215,219 ****
  /* BeOS suffers from the same socket dichotomy as Win32... - [cjh] */
  /* seem to be a few differences in the API */
! #define close closesocket
  #define NO_DUP /* Actually it exists on NT 3.5, but what the heck... */
  #define FORCE_ANSI_FUNC_DEFS
--- 215,219 ----
  /* BeOS suffers from the same socket dichotomy as Win32... - [cjh] */
  /* seem to be a few differences in the API */
! #define SOCKETCLOSE closesocket
  #define NO_DUP /* Actually it exists on NT 3.5, but what the heck... */
  #define FORCE_ANSI_FUNC_DEFS
***************
*** 221,229 ****
  
  #if defined(PYOS_OS2)
! #define close soclose
  #define NO_DUP /* Sockets are Not Actual File Handles under OS/2 */
  #define FORCE_ANSI_FUNC_DEFS
  #endif
  
  #ifdef FORCE_ANSI_FUNC_DEFS
  #define BUILD_FUNC_DEF_1( fnname, arg1type, arg1name )	\
--- 221,233 ----
  
  #if defined(PYOS_OS2)
! #define SOCKETCLOSE soclose
  #define NO_DUP /* Sockets are Not Actual File Handles under OS/2 */
  #define FORCE_ANSI_FUNC_DEFS
  #endif
  
+ #ifndef SOCKETCLOSE
+ #define SOCKETCLOSE close
+ #endif
+ 
  #ifdef FORCE_ANSI_FUNC_DEFS
  #define BUILD_FUNC_DEF_1( fnname, arg1type, arg1name )	\
***************
*** 683,687 ****
  					s->sock_proto);
  	if (sock == NULL) {
! 		close(newfd);
  		goto finally;
  	}
--- 687,691 ----
  					s->sock_proto);
  	if (sock == NULL) {
! 		SOCKETCLOSE(newfd);
  		goto finally;
  	}
***************
*** 890,894 ****
  	if (s->sock_fd != -1) {
  		Py_BEGIN_ALLOW_THREADS
! 		(void) close(s->sock_fd);
  		Py_END_ALLOW_THREADS
  	}
--- 894,898 ----
  	if (s->sock_fd != -1) {
  		Py_BEGIN_ALLOW_THREADS
! 		(void) SOCKETCLOSE(s->sock_fd);
  		Py_END_ALLOW_THREADS
  	}
***************
*** 989,993 ****
  					     s->sock_proto);
  	if (sock == NULL)
! 		close(newfd);
  	return sock;
  }
--- 993,997 ----
  					     s->sock_proto);
  	if (sock == NULL)
! 		SOCKETCLOSE(newfd);
  	return sock;
  }
***************
*** 1113,1117 ****
  	{
  		if (fd >= 0)
! 			close(fd);
  		return PySocket_Err();
  	}
--- 1117,1121 ----
  	{
  		if (fd >= 0)
! 			SOCKETCLOSE(fd);
  		return PySocket_Err();
  	}
***************
*** 1358,1362 ****
  {
  	if (s->sock_fd != -1)
! 		(void) close(s->sock_fd);
  	PyMem_DEL(s);
  }
--- 1362,1366 ----
  {
  	if (s->sock_fd != -1)
! 		(void) SOCKETCLOSE(s->sock_fd);
  	PyMem_DEL(s);
  }
***************
*** 1726,1730 ****
  	   file descriptor again! */
  	if (s == NULL)
! 		(void) close(fd);
  	/* From now on, ignore SIGPIPE and let the error checking
  	   do the work. */
--- 1730,1734 ----
  	   file descriptor again! */
  	if (s == NULL)
! 		(void) SOCKETCLOSE(fd);
  	/* From now on, ignore SIGPIPE and let the error checking
  	   do the work. */
***************
*** 1945,1950 ****
  		return NULL;
  	}
! 	memset(self->server, NULL, sizeof(char) * 256);
! 	memset(self->issuer, NULL, sizeof(char) * 256);  
    
  	self->x_attr = PyDict_New();
--- 1949,1954 ----
  		return NULL;
  	}
! 	memset(self->server, '\0', sizeof(char) * 256);
! 	memset(self->issuer, '\0', sizeof(char) * 256);  
    
  	self->x_attr = PyDict_New();