]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Autocheck for snprintf, and use sprintf if it is not available.
authorMartin v. Löwis <martin@v.loewis.de>
Tue, 24 Jul 2001 06:33:08 +0000 (06:33 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Tue, 24 Jul 2001 06:33:08 +0000 (06:33 +0000)
Remove declaration of h_errno, since it is supposedly declared in netdb.h.
Changes proposed by itojun.

Modules/getaddrinfo.c
Modules/socketmodule.c
config.h.in
configure
configure.in

index 7d07e530cf74e44a9dfae57e09f9e10168e7b725..67e6ce13d18d316d9668dacb75402ed72a332130 100644 (file)
@@ -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;
index 1c19c28b3d526943f4ea1279acfcb62c22dc2475..863a4070c44b395eaa85c931a241e2668677c42d 100644 (file)
@@ -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);
index b5c495f9fdc0e5a09816ac00556b970cea4d4d59..f9455350e4233302eb465d5426e591625b305a6a 100644 (file)
 /* 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
 
index 990faa055d1a16cd15db66f1e450a0f78b74cb08..45fc161a4102c492373b265c96fd3cd6aa33d6a5 100755 (executable)
--- 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
index 61aaa97123748a3b6ff30c8754ac8012b321a989..4ac73774dc13ccfab54ee0aaab595265e40cda80 100644 (file)
@@ -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)