Mercurial > cpython-lru_cache-weakref
diff Modules/socketmodule.c @ 18818:cebb4e187449 legacy-trunk
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.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Tue, 24 Jul 2001 06:33:08 +0000 |
| parents | 6d9874bb978f |
| children | 4677d2ff3150 |
line wrap: on
line diff
--- a/Modules/socketmodule.c Mon Jul 23 21:14:59 2001 +0000 +++ b/Modules/socketmodule.c Tue Jul 24 06:33:08 2001 +0000 @@ -1789,9 +1789,6 @@ 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 @@ 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 @@ 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);
