File Objects/unicodeobject.c changed (mode: 100644) (index 58899adc46..d5cf9548ae) |
... |
... |
unicode_islower_impl(PyObject *self) |
11748 |
11748 |
|
|
11749 |
11749 |
/* Special case for empty strings */ |
/* Special case for empty strings */ |
11750 |
11750 |
if (length == 0) |
if (length == 0) |
11751 |
|
return PyBool_FromLong(0); |
|
|
11751 |
|
Py_RETURN_FALSE; |
11752 |
11752 |
|
|
11753 |
11753 |
cased = 0; |
cased = 0; |
11754 |
11754 |
for (i = 0; i < length; i++) { |
for (i = 0; i < length; i++) { |
11755 |
11755 |
const Py_UCS4 ch = PyUnicode_READ(kind, data, i); |
const Py_UCS4 ch = PyUnicode_READ(kind, data, i); |
11756 |
11756 |
|
|
11757 |
11757 |
if (Py_UNICODE_ISUPPER(ch) || Py_UNICODE_ISTITLE(ch)) |
if (Py_UNICODE_ISUPPER(ch) || Py_UNICODE_ISTITLE(ch)) |
11758 |
|
return PyBool_FromLong(0); |
|
|
11758 |
|
Py_RETURN_FALSE; |
11759 |
11759 |
else if (!cased && Py_UNICODE_ISLOWER(ch)) |
else if (!cased && Py_UNICODE_ISLOWER(ch)) |
11760 |
11760 |
cased = 1; |
cased = 1; |
11761 |
11761 |
} |
} |
|
... |
... |
unicode_isupper_impl(PyObject *self) |
11793 |
11793 |
|
|
11794 |
11794 |
/* Special case for empty strings */ |
/* Special case for empty strings */ |
11795 |
11795 |
if (length == 0) |
if (length == 0) |
11796 |
|
return PyBool_FromLong(0); |
|
|
11796 |
|
Py_RETURN_FALSE; |
11797 |
11797 |
|
|
11798 |
11798 |
cased = 0; |
cased = 0; |
11799 |
11799 |
for (i = 0; i < length; i++) { |
for (i = 0; i < length; i++) { |
11800 |
11800 |
const Py_UCS4 ch = PyUnicode_READ(kind, data, i); |
const Py_UCS4 ch = PyUnicode_READ(kind, data, i); |
11801 |
11801 |
|
|
11802 |
11802 |
if (Py_UNICODE_ISLOWER(ch) || Py_UNICODE_ISTITLE(ch)) |
if (Py_UNICODE_ISLOWER(ch) || Py_UNICODE_ISTITLE(ch)) |
11803 |
|
return PyBool_FromLong(0); |
|
|
11803 |
|
Py_RETURN_FALSE; |
11804 |
11804 |
else if (!cased && Py_UNICODE_ISUPPER(ch)) |
else if (!cased && Py_UNICODE_ISUPPER(ch)) |
11805 |
11805 |
cased = 1; |
cased = 1; |
11806 |
11806 |
} |
} |
|
... |
... |
unicode_istitle_impl(PyObject *self) |
11840 |
11840 |
|
|
11841 |
11841 |
/* Special case for empty strings */ |
/* Special case for empty strings */ |
11842 |
11842 |
if (length == 0) |
if (length == 0) |
11843 |
|
return PyBool_FromLong(0); |
|
|
11843 |
|
Py_RETURN_FALSE; |
11844 |
11844 |
|
|
11845 |
11845 |
cased = 0; |
cased = 0; |
11846 |
11846 |
previous_is_cased = 0; |
previous_is_cased = 0; |
|
... |
... |
unicode_istitle_impl(PyObject *self) |
11849 |
11849 |
|
|
11850 |
11850 |
if (Py_UNICODE_ISUPPER(ch) || Py_UNICODE_ISTITLE(ch)) { |
if (Py_UNICODE_ISUPPER(ch) || Py_UNICODE_ISTITLE(ch)) { |
11851 |
11851 |
if (previous_is_cased) |
if (previous_is_cased) |
11852 |
|
return PyBool_FromLong(0); |
|
|
11852 |
|
Py_RETURN_FALSE; |
11853 |
11853 |
previous_is_cased = 1; |
previous_is_cased = 1; |
11854 |
11854 |
cased = 1; |
cased = 1; |
11855 |
11855 |
} |
} |
11856 |
11856 |
else if (Py_UNICODE_ISLOWER(ch)) { |
else if (Py_UNICODE_ISLOWER(ch)) { |
11857 |
11857 |
if (!previous_is_cased) |
if (!previous_is_cased) |
11858 |
|
return PyBool_FromLong(0); |
|
|
11858 |
|
Py_RETURN_FALSE; |
11859 |
11859 |
previous_is_cased = 1; |
previous_is_cased = 1; |
11860 |
11860 |
cased = 1; |
cased = 1; |
11861 |
11861 |
} |
} |
|
... |
... |
unicode_isspace_impl(PyObject *self) |
11895 |
11895 |
|
|
11896 |
11896 |
/* Special case for empty strings */ |
/* Special case for empty strings */ |
11897 |
11897 |
if (length == 0) |
if (length == 0) |
11898 |
|
return PyBool_FromLong(0); |
|
|
11898 |
|
Py_RETURN_FALSE; |
11899 |
11899 |
|
|
11900 |
11900 |
for (i = 0; i < length; i++) { |
for (i = 0; i < length; i++) { |
11901 |
11901 |
const Py_UCS4 ch = PyUnicode_READ(kind, data, i); |
const Py_UCS4 ch = PyUnicode_READ(kind, data, i); |
11902 |
11902 |
if (!Py_UNICODE_ISSPACE(ch)) |
if (!Py_UNICODE_ISSPACE(ch)) |
11903 |
|
return PyBool_FromLong(0); |
|
|
11903 |
|
Py_RETURN_FALSE; |
11904 |
11904 |
} |
} |
11905 |
|
return PyBool_FromLong(1); |
|
|
11905 |
|
Py_RETURN_TRUE; |
11906 |
11906 |
} |
} |
11907 |
11907 |
|
|
11908 |
11908 |
/*[clinic input] |
/*[clinic input] |
|
... |
... |
unicode_isalpha_impl(PyObject *self) |
11935 |
11935 |
|
|
11936 |
11936 |
/* Special case for empty strings */ |
/* Special case for empty strings */ |
11937 |
11937 |
if (length == 0) |
if (length == 0) |
11938 |
|
return PyBool_FromLong(0); |
|
|
11938 |
|
Py_RETURN_FALSE; |
11939 |
11939 |
|
|
11940 |
11940 |
for (i = 0; i < length; i++) { |
for (i = 0; i < length; i++) { |
11941 |
11941 |
if (!Py_UNICODE_ISALPHA(PyUnicode_READ(kind, data, i))) |
if (!Py_UNICODE_ISALPHA(PyUnicode_READ(kind, data, i))) |
11942 |
|
return PyBool_FromLong(0); |
|
|
11942 |
|
Py_RETURN_FALSE; |
11943 |
11943 |
} |
} |
11944 |
|
return PyBool_FromLong(1); |
|
|
11944 |
|
Py_RETURN_TRUE; |
11945 |
11945 |
} |
} |
11946 |
11946 |
|
|
11947 |
11947 |
/*[clinic input] |
/*[clinic input] |
|
... |
... |
unicode_isalnum_impl(PyObject *self) |
11976 |
11976 |
|
|
11977 |
11977 |
/* Special case for empty strings */ |
/* Special case for empty strings */ |
11978 |
11978 |
if (len == 0) |
if (len == 0) |
11979 |
|
return PyBool_FromLong(0); |
|
|
11979 |
|
Py_RETURN_FALSE; |
11980 |
11980 |
|
|
11981 |
11981 |
for (i = 0; i < len; i++) { |
for (i = 0; i < len; i++) { |
11982 |
11982 |
const Py_UCS4 ch = PyUnicode_READ(kind, data, i); |
const Py_UCS4 ch = PyUnicode_READ(kind, data, i); |
11983 |
11983 |
if (!Py_UNICODE_ISALNUM(ch)) |
if (!Py_UNICODE_ISALNUM(ch)) |
11984 |
|
return PyBool_FromLong(0); |
|
|
11984 |
|
Py_RETURN_FALSE; |
11985 |
11985 |
} |
} |
11986 |
|
return PyBool_FromLong(1); |
|
|
11986 |
|
Py_RETURN_TRUE; |
11987 |
11987 |
} |
} |
11988 |
11988 |
|
|
11989 |
11989 |
/*[clinic input] |
/*[clinic input] |
|
... |
... |
unicode_isdecimal_impl(PyObject *self) |
12016 |
12016 |
|
|
12017 |
12017 |
/* Special case for empty strings */ |
/* Special case for empty strings */ |
12018 |
12018 |
if (length == 0) |
if (length == 0) |
12019 |
|
return PyBool_FromLong(0); |
|
|
12019 |
|
Py_RETURN_FALSE; |
12020 |
12020 |
|
|
12021 |
12021 |
for (i = 0; i < length; i++) { |
for (i = 0; i < length; i++) { |
12022 |
12022 |
if (!Py_UNICODE_ISDECIMAL(PyUnicode_READ(kind, data, i))) |
if (!Py_UNICODE_ISDECIMAL(PyUnicode_READ(kind, data, i))) |
12023 |
|
return PyBool_FromLong(0); |
|
|
12023 |
|
Py_RETURN_FALSE; |
12024 |
12024 |
} |
} |
12025 |
|
return PyBool_FromLong(1); |
|
|
12025 |
|
Py_RETURN_TRUE; |
12026 |
12026 |
} |
} |
12027 |
12027 |
|
|
12028 |
12028 |
/*[clinic input] |
/*[clinic input] |
|
... |
... |
unicode_isdigit_impl(PyObject *self) |
12056 |
12056 |
|
|
12057 |
12057 |
/* Special case for empty strings */ |
/* Special case for empty strings */ |
12058 |
12058 |
if (length == 0) |
if (length == 0) |
12059 |
|
return PyBool_FromLong(0); |
|
|
12059 |
|
Py_RETURN_FALSE; |
12060 |
12060 |
|
|
12061 |
12061 |
for (i = 0; i < length; i++) { |
for (i = 0; i < length; i++) { |
12062 |
12062 |
if (!Py_UNICODE_ISDIGIT(PyUnicode_READ(kind, data, i))) |
if (!Py_UNICODE_ISDIGIT(PyUnicode_READ(kind, data, i))) |
12063 |
|
return PyBool_FromLong(0); |
|
|
12063 |
|
Py_RETURN_FALSE; |
12064 |
12064 |
} |
} |
12065 |
|
return PyBool_FromLong(1); |
|
|
12065 |
|
Py_RETURN_TRUE; |
12066 |
12066 |
} |
} |
12067 |
12067 |
|
|
12068 |
12068 |
/*[clinic input] |
/*[clinic input] |
|
... |
... |
unicode_isnumeric_impl(PyObject *self) |
12095 |
12095 |
|
|
12096 |
12096 |
/* Special case for empty strings */ |
/* Special case for empty strings */ |
12097 |
12097 |
if (length == 0) |
if (length == 0) |
12098 |
|
return PyBool_FromLong(0); |
|
|
12098 |
|
Py_RETURN_FALSE; |
12099 |
12099 |
|
|
12100 |
12100 |
for (i = 0; i < length; i++) { |
for (i = 0; i < length; i++) { |
12101 |
12101 |
if (!Py_UNICODE_ISNUMERIC(PyUnicode_READ(kind, data, i))) |
if (!Py_UNICODE_ISNUMERIC(PyUnicode_READ(kind, data, i))) |
12102 |
|
return PyBool_FromLong(0); |
|
|
12102 |
|
Py_RETURN_FALSE; |
12103 |
12103 |
} |
} |
12104 |
|
return PyBool_FromLong(1); |
|
|
12104 |
|
Py_RETURN_TRUE; |
12105 |
12105 |
} |
} |
12106 |
12106 |
|
|
12107 |
12107 |
int |
int |