summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Price <gnprice@gmail.com>2019-09-09 09:16:31 (GMT)
committerBenjamin Peterson <benjamin@python.org>2019-09-09 09:16:31 (GMT)
commit7669cb8b21c7c9cef758609c44017c09d1ce4658 (patch)
tree7ad10f9bde5df67b20140b78bb4f109e9d1092fb
parent71ea688d662a74ddf39a3874e06c73e58df55c02 (diff)
downloadcpython-7669cb8b21c7c9cef758609c44017c09d1ce4658.zip
cpython-7669cb8b21c7c9cef758609c44017c09d1ce4658.tar.gz
cpython-7669cb8b21c7c9cef758609c44017c09d1ce4658.tar.bz2
bpo-38043: Use `bool` for boolean flags on is_normalized_quickcheck. (GH-15711)
-rw-r--r--Modules/unicodedata.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c
index 5e8ba60..bb09b7d 100644
--- a/Modules/unicodedata.c
+++ b/Modules/unicodedata.c
@@ -795,7 +795,7 @@ typedef enum {YES = 0, MAYBE = 1, NO = 2} QuickcheckResult;
*/
static QuickcheckResult
is_normalized_quickcheck(PyObject *self, PyObject *input,
- int nfc, int k, bool yes_only)
+ bool nfc, bool k, bool yes_only)
{
/* An older version of the database is requested, quickchecks must be
disabled. */
@@ -869,25 +869,25 @@ unicodedata_UCD_is_normalized_impl(PyObject *self, PyObject *form,
}
PyObject *result;
- int nfc = 0;
- int k = 0;
+ bool nfc = false;
+ bool k = false;
QuickcheckResult m;
PyObject *cmp;
int match = 0;
if (_PyUnicode_EqualToASCIIId(form, &PyId_NFC)) {
- nfc = 1;
+ nfc = true;
}
else if (_PyUnicode_EqualToASCIIId(form, &PyId_NFKC)) {
- nfc = 1;
- k = 1;
+ nfc = true;
+ k = true;
}
else if (_PyUnicode_EqualToASCIIId(form, &PyId_NFD)) {
/* matches default values for `nfc` and `k` */
}
else if (_PyUnicode_EqualToASCIIId(form, &PyId_NFKD)) {
- k = 1;
+ k = true;
}
else {
PyErr_SetString(PyExc_ValueError, "invalid normalization form");
@@ -940,28 +940,28 @@ unicodedata_UCD_normalize_impl(PyObject *self, PyObject *form,
}
if (_PyUnicode_EqualToASCIIId(form, &PyId_NFC)) {
- if (is_normalized_quickcheck(self, input, 1, 0, true) == YES) {
+ if (is_normalized_quickcheck(self, input, true, false, true) == YES) {
Py_INCREF(input);
return input;
}
return nfc_nfkc(self, input, 0);
}
if (_PyUnicode_EqualToASCIIId(form, &PyId_NFKC)) {
- if (is_normalized_quickcheck(self, input, 1, 1, true) == YES) {
+ if (is_normalized_quickcheck(self, input, true, true, true) == YES) {
Py_INCREF(input);
return input;
}
return nfc_nfkc(self, input, 1);
}
if (_PyUnicode_EqualToASCIIId(form, &PyId_NFD)) {
- if (is_normalized_quickcheck(self, input, 0, 0, true) == YES) {
+ if (is_normalized_quickcheck(self, input, false, false, true) == YES) {
Py_INCREF(input);
return input;
}
return nfd_nfkd(self, input, 0);
}
if (_PyUnicode_EqualToASCIIId(form, &PyId_NFKD)) {
- if (is_normalized_quickcheck(self, input, 0, 1, true) == YES) {
+ if (is_normalized_quickcheck(self, input, false, true, true) == YES) {
Py_INCREF(input);
return input;
}