mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-108767: Replace ctype.h functions with pyctype.h functions (#108772)
Replace <ctype.h> locale dependent functions with Python "pyctype.h" locale independent functions: * Replace isalpha() with Py_ISALPHA(). * Replace isdigit() with Py_ISDIGIT(). * Replace isxdigit() with Py_ISXDIGIT(). * Replace tolower() with Py_TOLOWER(). Leave Modules/_sre/sre.c unchanged, it uses locale dependent functions on purpose. Include explicitly <ctype.h> in _decimal.c to get isascii().
This commit is contained in:
parent
03c5a68568
commit
578ebc5d5f
6 changed files with 36 additions and 36 deletions
|
@ -11,11 +11,11 @@ PyOS_mystrnicmp(const char *s1, const char *s2, Py_ssize_t size)
|
|||
return 0;
|
||||
p1 = (const unsigned char *)s1;
|
||||
p2 = (const unsigned char *)s2;
|
||||
for (; (--size > 0) && *p1 && *p2 && (tolower(*p1) == tolower(*p2));
|
||||
for (; (--size > 0) && *p1 && *p2 && (Py_TOLOWER(*p1) == Py_TOLOWER(*p2));
|
||||
p1++, p2++) {
|
||||
;
|
||||
}
|
||||
return tolower(*p1) - tolower(*p2);
|
||||
return Py_TOLOWER(*p1) - Py_TOLOWER(*p2);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -23,8 +23,8 @@ PyOS_mystricmp(const char *s1, const char *s2)
|
|||
{
|
||||
const unsigned char *p1 = (const unsigned char *)s1;
|
||||
const unsigned char *p2 = (const unsigned char *)s2;
|
||||
for (; *p1 && *p2 && (tolower(*p1) == tolower(*p2)); p1++, p2++) {
|
||||
for (; *p1 && *p2 && (Py_TOLOWER(*p1) == Py_TOLOWER(*p2)); p1++, p2++) {
|
||||
;
|
||||
}
|
||||
return (tolower(*p1) - tolower(*p2));
|
||||
return (Py_TOLOWER(*p1) - Py_TOLOWER(*p2));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue