gh-108765: Python.h no longer includes <ctype.h> (#108831)

Remove <ctype.h> in C files which don't use it; only sre.c and
_decimal.c still use it.

Remove _PY_PORT_CTYPE_UTF8_ISSUE code from pyport.h:

* Code added by commit b5047fd019
  in 2004 for MacOSX and FreeBSD.
* Test removed by commit 52ddaefb6b
  in 2007, since Python str type now uses locale independent
  functions like Py_ISALPHA() and Py_TOLOWER() and the Unicode
  database.

Modules/_sre/sre.c replaces _PY_PORT_CTYPE_UTF8_ISSUE with new
functions: sre_isalnum(), sre_tolower(), sre_toupper().

Remove unused includes:

* _localemodule.c: remove <stdio.h>.
* getargs.c: remove <float.h>.
* dynload_win.c: remove <direct.h>, it no longer calls _getcwd()
  since commit fb1f68ed7c (in 2001).
This commit is contained in:
Victor Stinner 2023-09-03 18:54:27 +02:00 committed by GitHub
parent 1796c191b4
commit 03c4080c71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 86 additions and 114 deletions

View file

@ -1,16 +1,22 @@
// strtol() and strtoul(), renamed to avoid conflicts.
//
// API:
//
// - PyOS_strtol(): convert string to C long integer.
// - PyOS_strtoul(): convert string to C unsigned long integer.
#include "Python.h"
#include "pycore_long.h" // _PyLong_DigitValue
#if defined(__sgi) && !defined(_SGI_MP_SOURCE)
#define _SGI_MP_SOURCE
# define _SGI_MP_SOURCE
#endif
/* strtol and strtoul, renamed to avoid conflicts */
#include <ctype.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
# include <errno.h> // errno
#endif
/* Static overflow check values for bases 2 through 36.
@ -75,7 +81,7 @@ static const int digitlimit[] = {
14, 14, 14, 14, 13, 13, 13, 13, 13, 13, /* 20 - 29 */
13, 12, 12, 12, 12, 12, 12}; /* 30 - 36 */
#else
#error "Need table for SIZEOF_LONG"
# error "Need table for SIZEOF_LONG"
#endif
/*