summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2001-07-24 06:33:08 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2001-07-24 06:33:08 (GMT)
commit791bfda2b364ec91e5affab2fc0a60ac1701f392 (patch)
tree686873e043a38e6326b17d07d7f641d31df4fd99
parentc547b46c067656b39c564a84a2979ec985e7b869 (diff)
downloadcpython-791bfda2b364ec91e5affab2fc0a60ac1701f392.zip
cpython-791bfda2b364ec91e5affab2fc0a60ac1701f392.tar.gz
cpython-791bfda2b364ec91e5affab2fc0a60ac1701f392.tar.bz2
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.
-rw-r--r--Modules/getaddrinfo.c4
-rw-r--r--Modules/socketmodule.c11
-rw-r--r--config.h.in3
-rwxr-xr-xconfigure4
-rw-r--r--configure.in2
5 files changed, 14 insertions, 10 deletions
diff --git a/Modules/getaddrinfo.c b/Modules/getaddrinfo.c
index 7d07e53..67e6ce1 100644
--- a/Modules/getaddrinfo.c
+++ b/Modules/getaddrinfo.c
@@ -544,10 +544,6 @@ get_addr(hostname, af, res, pai, port0)
struct gai_afd *gai_afd;
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;
sentinel.ai_next = NULL;
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 1c19c28..863a407 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1789,9 +1789,6 @@ gethost_common(struct hostent *h, struct sockaddr *addr, int alen, int af)
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;
}
@@ -2348,7 +2345,11 @@ PySocket_getaddrinfo(PyObject *self, PyObject *args)
return NULL;
}
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)) {
pptr = PyString_AsString(pobj);
@@ -2419,7 +2420,11 @@ PySocket_getnameinfo(PyObject *self, PyObject *args)
n = PyArg_ParseTuple(sa, "si|ii", &hostp, &port, &flowinfo, scope_id);
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;
error = getaddrinfo(hostp, pbuf, &hints, &res);
diff --git a/config.h.in b/config.h.in
index b5c495f..f945535 100644
--- a/config.h.in
+++ b/config.h.in
@@ -509,6 +509,9 @@
/* Define if you have the sigrelse function. */
#undef HAVE_SIGRELSE
+/* Define if you have the snprintf function. */
+#undef HAVE_SNPRINTF
+
/* Define if you have the statvfs function. */
#undef HAVE_STATVFS
diff --git a/configure b/configure
index 990faa0..45fc161 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
-# From configure.in Revision: 1.232
+# From configure.in Revision: 1.233
# Guess values for system-dependent variables and create Makefiles.
# Generated automatically using autoconf version 2.13
@@ -4519,7 +4519,7 @@ for ac_func in alarm chown clock confstr ctermid ctermid_r execv \
nice pathconf pause plock poll pthread_init \
putenv readlink \
select setegid seteuid setgid \
- setlocale setregid setreuid setsid setpgid setuid setvbuf \
+ setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
truncate uname waitpid _getpty getpriority
diff --git a/configure.in b/configure.in
index 61aaa97..4ac7377 100644
--- a/configure.in
+++ b/configure.in
@@ -1179,7 +1179,7 @@ AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
nice pathconf pause plock poll pthread_init \
putenv readlink \
select setegid seteuid setgid \
- setlocale setregid setreuid setsid setpgid setuid setvbuf \
+ setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
truncate uname waitpid _getpty getpriority)