mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
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 commitb5047fd019
in 2004 for MacOSX and FreeBSD. * Test removed by commit52ddaefb6b
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 commitfb1f68ed7c
(in 2001).
This commit is contained in:
parent
1796c191b4
commit
03c4080c71
22 changed files with 86 additions and 114 deletions
|
@ -392,44 +392,6 @@ extern "C" {
|
|||
# define Py_NO_INLINE
|
||||
#endif
|
||||
|
||||
/* On 4.4BSD-descendants, ctype functions serves the whole range of
|
||||
* wchar_t character set rather than single byte code points only.
|
||||
* This characteristic can break some operations of string object
|
||||
* including str.upper() and str.split() on UTF-8 locales. This
|
||||
* workaround was provided by Tim Robbins of FreeBSD project.
|
||||
*/
|
||||
|
||||
#if defined(__APPLE__)
|
||||
# define _PY_PORT_CTYPE_UTF8_ISSUE
|
||||
#endif
|
||||
|
||||
#ifdef _PY_PORT_CTYPE_UTF8_ISSUE
|
||||
#ifndef __cplusplus
|
||||
/* The workaround below is unsafe in C++ because
|
||||
* the <locale> defines these symbols as real functions,
|
||||
* with a slightly different signature.
|
||||
* See issue #10910
|
||||
*/
|
||||
#include <ctype.h>
|
||||
#include <wctype.h>
|
||||
#undef isalnum
|
||||
#define isalnum(c) iswalnum(btowc(c))
|
||||
#undef isalpha
|
||||
#define isalpha(c) iswalpha(btowc(c))
|
||||
#undef islower
|
||||
#define islower(c) iswlower(btowc(c))
|
||||
#undef isspace
|
||||
#define isspace(c) iswspace(btowc(c))
|
||||
#undef isupper
|
||||
#define isupper(c) iswupper(btowc(c))
|
||||
#undef tolower
|
||||
#define tolower(c) towlower(btowc(c))
|
||||
#undef toupper
|
||||
#define toupper(c) towupper(btowc(c))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Declarations for symbol visibility.
|
||||
|
||||
PyAPI_FUNC(type): Declares a public Python API function and return type
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue