[Python-checkins] cpython: Mark _PyUnicode_FindMaxCharAndNumSurrogatePairs() as private

victor.stinner python-checkins at python.org
Wed Sep 28 22:17:16 CEST 2011


http://hg.python.org/cpython/rev/e395f1436fe6
changeset:   72498:e395f1436fe6
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Wed Sep 28 22:15:37 2011 +0200
summary:
  Mark _PyUnicode_FindMaxCharAndNumSurrogatePairs() as private

files:
  Include/unicodeobject.h |  12 ------------
  Objects/unicodeobject.c |  17 ++++++++++-------
  2 files changed, 10 insertions(+), 19 deletions(-)


diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -543,18 +543,6 @@
     );
 #endif
 
-/* Find the maximum code point and count the number of surrogate pairs so a
-   correct string length can be computed before converting a string to UCS4.
-   This function counts single surrogates as a character and not as a pair. */
-#ifndef Py_LIMITED_API
-PyAPI_FUNC(int) _PyUnicode_FindMaxCharAndNumSurrogatePairs(
-    const wchar_t *begin,
-    const wchar_t *end,
-    Py_UCS4 *maxchar,
-    Py_ssize_t *num_surrogates
-    );
-#endif
-
 /* Create a Unicode Object from the Py_UNICODE buffer u of the given
    size.
 
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -708,11 +708,14 @@
     return -1;
 }
 
-int
-_PyUnicode_FindMaxCharAndNumSurrogatePairs(const wchar_t *begin,
-                                           const wchar_t *end,
-                                           Py_UCS4 *maxchar,
-                                           Py_ssize_t *num_surrogates)
+/* Find the maximum code point and count the number of surrogate pairs so a
+   correct string length can be computed before converting a string to UCS4.
+   This function counts single surrogates as a character and not as a pair.
+
+   Return 0 on success, or -1 on error. */
+static int
+find_maxchar_surrogates(const wchar_t *begin, const wchar_t *end,
+                        Py_UCS4 *maxchar, Py_ssize_t *num_surrogates)
 {
     const wchar_t *iter;
 
@@ -789,7 +792,7 @@
 #endif
 
     end = _PyUnicode_WSTR(unicode) + _PyUnicode_WSTR_LENGTH(unicode);
-    if (_PyUnicode_FindMaxCharAndNumSurrogatePairs(_PyUnicode_WSTR(unicode), end,
+    if (find_maxchar_surrogates(_PyUnicode_WSTR(unicode), end,
                                                   &maxchar,
                                                   &num_surrogates) == -1) {
         assert(0 && "PyUnicode_FindMaxCharAndNumSurrogatePairs failed");
@@ -1022,7 +1025,7 @@
 
     /* If not empty and not single character, copy the Unicode data
        into the new object */
-    if (_PyUnicode_FindMaxCharAndNumSurrogatePairs(u, u + size, &maxchar,
+    if (find_maxchar_surrogates(u, u + size, &maxchar,
                                                   &num_surrogates) == -1)
         return NULL;
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list