summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-11-22 02:38:40 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-11-22 02:38:40 (GMT)
commitca4f20782e57ca4c754f477b19d36ac23e456b39 (patch)
tree4e35b0d791acc2e11706b50f95057c71d364c065 /Objects
parent63ab875cfefc0f1f4e123f4d9c885b3079446f35 (diff)
downloadcpython-ca4f20782e57ca4c754f477b19d36ac23e456b39.zip
cpython-ca4f20782e57ca4c754f477b19d36ac23e456b39.tar.gz
cpython-ca4f20782e57ca4c754f477b19d36ac23e456b39.tar.bz2
find_maxchar_surrogates() reuses surrogate macros
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 77bc1a9..ff22f85 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -1308,12 +1308,12 @@ find_maxchar_surrogates(const wchar_t *begin, const wchar_t *end,
#endif
}
#if SIZEOF_WCHAR_T == 2
- if (*iter >= 0xD800 && *iter <= 0xDBFF
- && (iter+1) < end && iter[1] >= 0xDC00 && iter[1] <= 0xDFFF)
+ if (Py_UNICODE_IS_HIGH_SURROGATE(iter[0])
+ && (iter+1) < end
+ && Py_UNICODE_IS_LOW_SURROGATE(iter[1]))
{
Py_UCS4 surrogate_val;
- surrogate_val = (((iter[0] & 0x3FF)<<10)
- | (iter[1] & 0x3FF)) + 0x10000;
+ surrogate_val = Py_UNICODE_JOIN_SURROGATES(iter[0], iter[1]);
++(*num_surrogates);
if (surrogate_val > *maxchar)
*maxchar = surrogate_val;