Skip to content

Commit 7669cb8

Browse files
gnpricebenjaminp
authored andcommitted
bpo-38043: Use bool for boolean flags on is_normalized_quickcheck. (GH-15711)
1 parent 71ea688 commit 7669cb8

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Modules/unicodedata.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ typedef enum {YES = 0, MAYBE = 1, NO = 2} QuickcheckResult;
795795
*/
796796
static QuickcheckResult
797797
is_normalized_quickcheck(PyObject *self, PyObject *input,
798-
int nfc, int k, bool yes_only)
798+
bool nfc, bool k, bool yes_only)
799799
{
800800
/* An older version of the database is requested, quickchecks must be
801801
disabled. */
@@ -869,25 +869,25 @@ unicodedata_UCD_is_normalized_impl(PyObject *self, PyObject *form,
869869
}
870870

871871
PyObject *result;
872-
int nfc = 0;
873-
int k = 0;
872+
bool nfc = false;
873+
bool k = false;
874874
QuickcheckResult m;
875875

876876
PyObject *cmp;
877877
int match = 0;
878878

879879
if (_PyUnicode_EqualToASCIIId(form, &PyId_NFC)) {
880-
nfc = 1;
880+
nfc = true;
881881
}
882882
else if (_PyUnicode_EqualToASCIIId(form, &PyId_NFKC)) {
883-
nfc = 1;
884-
k = 1;
883+
nfc = true;
884+
k = true;
885885
}
886886
else if (_PyUnicode_EqualToASCIIId(form, &PyId_NFD)) {
887887
/* matches default values for `nfc` and `k` */
888888
}
889889
else if (_PyUnicode_EqualToASCIIId(form, &PyId_NFKD)) {
890-
k = 1;
890+
k = true;
891891
}
892892
else {
893893
PyErr_SetString(PyExc_ValueError, "invalid normalization form");
@@ -940,28 +940,28 @@ unicodedata_UCD_normalize_impl(PyObject *self, PyObject *form,
940940
}
941941

942942
if (_PyUnicode_EqualToASCIIId(form, &PyId_NFC)) {
943-
if (is_normalized_quickcheck(self, input, 1, 0, true) == YES) {
943+
if (is_normalized_quickcheck(self, input, true, false, true) == YES) {
944944
Py_INCREF(input);
945945
return input;
946946
}
947947
return nfc_nfkc(self, input, 0);
948948
}
949949
if (_PyUnicode_EqualToASCIIId(form, &PyId_NFKC)) {
950-
if (is_normalized_quickcheck(self, input, 1, 1, true) == YES) {
950+
if (is_normalized_quickcheck(self, input, true, true, true) == YES) {
951951
Py_INCREF(input);
952952
return input;
953953
}
954954
return nfc_nfkc(self, input, 1);
955955
}
956956
if (_PyUnicode_EqualToASCIIId(form, &PyId_NFD)) {
957-
if (is_normalized_quickcheck(self, input, 0, 0, true) == YES) {
957+
if (is_normalized_quickcheck(self, input, false, false, true) == YES) {
958958
Py_INCREF(input);
959959
return input;
960960
}
961961
return nfd_nfkd(self, input, 0);
962962
}
963963
if (_PyUnicode_EqualToASCIIId(form, &PyId_NFKD)) {
964-
if (is_normalized_quickcheck(self, input, 0, 1, true) == YES) {
964+
if (is_normalized_quickcheck(self, input, false, true, true) == YES) {
965965
Py_INCREF(input);
966966
return input;
967967
}

0 commit comments

Comments
 (0)