aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/cython/Cython/Utility/StringTools.c
diff options
context:
space:
mode:
authororivej <orivej@yandex-team.ru>2022-02-10 16:45:01 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:01 +0300
commit2d37894b1b037cf24231090eda8589bbb44fb6fc (patch)
treebe835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/tools/cython/Cython/Utility/StringTools.c
parent718c552901d703c502ccbefdfc3c9028d608b947 (diff)
downloadydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/cython/Cython/Utility/StringTools.c')
-rw-r--r--contrib/tools/cython/Cython/Utility/StringTools.c646
1 files changed, 323 insertions, 323 deletions
diff --git a/contrib/tools/cython/Cython/Utility/StringTools.c b/contrib/tools/cython/Cython/Utility/StringTools.c
index 25255f2630..2fdae812a0 100644
--- a/contrib/tools/cython/Cython/Utility/StringTools.c
+++ b/contrib/tools/cython/Cython/Utility/StringTools.c
@@ -51,12 +51,12 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
static CYTHON_INLINE int __Pyx_BytesContains(PyObject* bytes, char character); /*proto*/
//////////////////// BytesContains ////////////////////
-//@requires: IncludeStringH
+//@requires: IncludeStringH
static CYTHON_INLINE int __Pyx_BytesContains(PyObject* bytes, char character) {
const Py_ssize_t length = PyBytes_GET_SIZE(bytes);
char* char_start = PyBytes_AS_STRING(bytes);
- return memchr(char_start, (unsigned char)character, (size_t)length) != NULL;
+ return memchr(char_start, (unsigned char)character, (size_t)length) != NULL;
}
@@ -146,24 +146,24 @@ static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(PyObject* unicode, Py_UCS4 ch
//////////////////// PyUnicodeContains.proto ////////////////////
-static CYTHON_INLINE int __Pyx_PyUnicode_ContainsTF(PyObject* substring, PyObject* text, int eq) {
+static CYTHON_INLINE int __Pyx_PyUnicode_ContainsTF(PyObject* substring, PyObject* text, int eq) {
int result = PyUnicode_Contains(text, substring);
return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}
-//////////////////// CStringEquals.proto ////////////////////
-
-static CYTHON_INLINE int __Pyx_StrEq(const char *, const char *); /*proto*/
-
-//////////////////// CStringEquals ////////////////////
-
-static CYTHON_INLINE int __Pyx_StrEq(const char *s1, const char *s2) {
- while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
- return *s1 == *s2;
-}
-
-
+//////////////////// CStringEquals.proto ////////////////////
+
+static CYTHON_INLINE int __Pyx_StrEq(const char *, const char *); /*proto*/
+
+//////////////////// CStringEquals ////////////////////
+
+static CYTHON_INLINE int __Pyx_StrEq(const char *s1, const char *s2) {
+ while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
+ return *s1 == *s2;
+}
+
+
//////////////////// StrEquals.proto ////////////////////
//@requires: BytesEquals
//@requires: UnicodeEquals
@@ -263,9 +263,9 @@ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int
} else {
int result;
PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
+ #if PY_MAJOR_VERSION < 3
+ Py_XDECREF(owned_ref);
+ #endif
if (!py_result)
return -1;
result = __Pyx_PyObject_IsTrue(py_result);
@@ -359,7 +359,7 @@ static CYTHON_INLINE int __Pyx_GetItemInt_ByteArray_Fast(PyObject* string, Py_ss
if (wraparound | boundscheck) {
length = PyByteArray_GET_SIZE(string);
if (wraparound & unlikely(i < 0)) i += length;
- if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) {
+ if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) {
return (unsigned char) (PyByteArray_AS_STRING(string)[i]);
} else {
PyErr_SetString(PyExc_IndexError, "bytearray index out of range");
@@ -389,7 +389,7 @@ static CYTHON_INLINE int __Pyx_SetItemInt_ByteArray_Fast(PyObject* string, Py_ss
if (wraparound | boundscheck) {
length = PyByteArray_GET_SIZE(string);
if (wraparound & unlikely(i < 0)) i += length;
- if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) {
+ if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) {
PyByteArray_AS_STRING(string)[i] = (char) v;
return 0;
} else {
@@ -422,7 +422,7 @@ static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py
if (wraparound | boundscheck) {
length = __Pyx_PyUnicode_GET_LENGTH(ustring);
if (wraparound & unlikely(i < 0)) i += length;
- if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) {
+ if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) {
return __Pyx_PyUnicode_READ_CHAR(ustring, i);
} else {
PyErr_SetString(PyExc_IndexError, "string index out of range");
@@ -480,13 +480,13 @@ static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
Py_ssize_t length;
if (unlikely((start < 0) | (stop < 0))) {
- size_t slen = strlen(cstring);
- if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
- PyErr_SetString(PyExc_OverflowError,
- "c-string too long to convert to Python");
- return NULL;
- }
- length = (Py_ssize_t) slen;
+ size_t slen = strlen(cstring);
+ if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
+ PyErr_SetString(PyExc_OverflowError,
+ "c-string too long to convert to Python");
+ return NULL;
+ }
+ length = (Py_ssize_t) slen;
if (start < 0) {
start += length;
if (start < 0)
@@ -586,7 +586,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring(
start = 0;
}
if (stop < 0)
- stop += length;
+ stop += length;
else if (stop > length)
stop = length;
if (stop <= start)
@@ -619,9 +619,9 @@ static CYTHON_INLINE int __Pyx_Py_UNICODE_ISTITLE(Py_UCS4 uchar)
static int __Pyx_PyUnicode_Tailmatch(
PyObject* s, PyObject* substr, Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/
-
-/////////////// unicode_tailmatch ///////////////
-
+
+/////////////// unicode_tailmatch ///////////////
+
// Python's unicode.startswith() and unicode.endswith() support a
// tuple of prefixes/suffixes, whereas it's much more common to
// test for a single unicode string.
@@ -631,7 +631,7 @@ static int __Pyx_PyUnicode_TailmatchTuple(PyObject* s, PyObject* substrings,
Py_ssize_t i, count = PyTuple_GET_SIZE(substrings);
for (i = 0; i < count; i++) {
Py_ssize_t result;
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
result = PyUnicode_Tailmatch(s, PyTuple_GET_ITEM(substrings, i),
start, end, direction);
#else
@@ -652,21 +652,21 @@ static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr,
if (unlikely(PyTuple_Check(substr))) {
return __Pyx_PyUnicode_TailmatchTuple(s, substr, start, end, direction);
}
- return (int) PyUnicode_Tailmatch(s, substr, start, end, direction);
+ return (int) PyUnicode_Tailmatch(s, substr, start, end, direction);
}
/////////////// bytes_tailmatch.proto ///////////////
-static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg,
- Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/
-static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr,
- Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/
-
-/////////////// bytes_tailmatch ///////////////
-
-static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg,
- Py_ssize_t start, Py_ssize_t end, int direction) {
+static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg,
+ Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/
+static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr,
+ Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/
+
+/////////////// bytes_tailmatch ///////////////
+
+static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg,
+ Py_ssize_t start, Py_ssize_t end, int direction) {
const char* self_ptr = PyBytes_AS_STRING(self);
Py_ssize_t self_len = PyBytes_GET_SIZE(self);
const char* sub_ptr;
@@ -683,7 +683,7 @@ static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg,
#if PY_MAJOR_VERSION < 3
// Python 2.x allows mixing unicode and str
else if ( PyUnicode_Check(arg) ) {
- return (int) PyUnicode_Tailmatch(self, arg, start, end, direction);
+ return (int) PyUnicode_Tailmatch(self, arg, start, end, direction);
}
#endif
else {
@@ -726,7 +726,7 @@ static int __Pyx_PyBytes_TailmatchTuple(PyObject* self, PyObject* substrings,
Py_ssize_t i, count = PyTuple_GET_SIZE(substrings);
for (i = 0; i < count; i++) {
int result;
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
result = __Pyx_PyBytes_SingleTailmatch(self, PyTuple_GET_ITEM(substrings, i),
start, end, direction);
#else
@@ -755,7 +755,7 @@ static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr,
/////////////// str_tailmatch.proto ///////////////
static CYTHON_INLINE int __Pyx_PyStr_Tailmatch(PyObject* self, PyObject* arg, Py_ssize_t start,
- Py_ssize_t end, int direction); /*proto*/
+ Py_ssize_t end, int direction); /*proto*/
/////////////// str_tailmatch ///////////////
//@requires: bytes_tailmatch
@@ -777,16 +777,16 @@ static CYTHON_INLINE int __Pyx_PyStr_Tailmatch(PyObject* self, PyObject* arg, Py
/////////////// bytes_index.proto ///////////////
-static CYTHON_INLINE char __Pyx_PyBytes_GetItemInt(PyObject* bytes, Py_ssize_t index, int check_bounds); /*proto*/
-
-/////////////// bytes_index ///////////////
-
+static CYTHON_INLINE char __Pyx_PyBytes_GetItemInt(PyObject* bytes, Py_ssize_t index, int check_bounds); /*proto*/
+
+/////////////// bytes_index ///////////////
+
static CYTHON_INLINE char __Pyx_PyBytes_GetItemInt(PyObject* bytes, Py_ssize_t index, int check_bounds) {
- if (index < 0)
- index += PyBytes_GET_SIZE(bytes);
+ if (index < 0)
+ index += PyBytes_GET_SIZE(bytes);
if (check_bounds) {
Py_ssize_t size = PyBytes_GET_SIZE(bytes);
- if (unlikely(!__Pyx_is_valid_index(index, size))) {
+ if (unlikely(!__Pyx_is_valid_index(index, size))) {
PyErr_SetString(PyExc_IndexError, "string index out of range");
return (char) -1;
}
@@ -825,170 +825,170 @@ static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* value
#endif
-/////////////// JoinPyUnicode.proto ///////////////
-
-static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
- Py_UCS4 max_char);
-
-/////////////// JoinPyUnicode ///////////////
-//@requires: IncludeStringH
-//@substitute: naming
-
-static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
- CYTHON_UNUSED Py_UCS4 max_char) {
-#if CYTHON_USE_UNICODE_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- PyObject *result_uval;
- int result_ukind;
- Py_ssize_t i, char_pos;
- void *result_udata;
-#if CYTHON_PEP393_ENABLED
- // Py 3.3+ (post PEP-393)
- result_uval = PyUnicode_New(result_ulength, max_char);
- if (unlikely(!result_uval)) return NULL;
- result_ukind = (max_char <= 255) ? PyUnicode_1BYTE_KIND : (max_char <= 65535) ? PyUnicode_2BYTE_KIND : PyUnicode_4BYTE_KIND;
- result_udata = PyUnicode_DATA(result_uval);
-#else
- // Py 2.x/3.2 (pre PEP-393)
- result_uval = PyUnicode_FromUnicode(NULL, result_ulength);
- if (unlikely(!result_uval)) return NULL;
- result_ukind = sizeof(Py_UNICODE);
- result_udata = PyUnicode_AS_UNICODE(result_uval);
-#endif
-
- char_pos = 0;
- for (i=0; i < value_count; i++) {
- int ukind;
- Py_ssize_t ulength;
- void *udata;
- PyObject *uval = PyTuple_GET_ITEM(value_tuple, i);
- if (unlikely(__Pyx_PyUnicode_READY(uval)))
- goto bad;
- ulength = __Pyx_PyUnicode_GET_LENGTH(uval);
- if (unlikely(!ulength))
- continue;
- if (unlikely(char_pos + ulength < 0))
- goto overflow;
- ukind = __Pyx_PyUnicode_KIND(uval);
- udata = __Pyx_PyUnicode_DATA(uval);
- if (!CYTHON_PEP393_ENABLED || ukind == result_ukind) {
- memcpy((char *)result_udata + char_pos * result_ukind, udata, (size_t) (ulength * result_ukind));
- } else {
+/////////////// JoinPyUnicode.proto ///////////////
+
+static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
+ Py_UCS4 max_char);
+
+/////////////// JoinPyUnicode ///////////////
+//@requires: IncludeStringH
+//@substitute: naming
+
+static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
+ CYTHON_UNUSED Py_UCS4 max_char) {
+#if CYTHON_USE_UNICODE_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
+ PyObject *result_uval;
+ int result_ukind;
+ Py_ssize_t i, char_pos;
+ void *result_udata;
+#if CYTHON_PEP393_ENABLED
+ // Py 3.3+ (post PEP-393)
+ result_uval = PyUnicode_New(result_ulength, max_char);
+ if (unlikely(!result_uval)) return NULL;
+ result_ukind = (max_char <= 255) ? PyUnicode_1BYTE_KIND : (max_char <= 65535) ? PyUnicode_2BYTE_KIND : PyUnicode_4BYTE_KIND;
+ result_udata = PyUnicode_DATA(result_uval);
+#else
+ // Py 2.x/3.2 (pre PEP-393)
+ result_uval = PyUnicode_FromUnicode(NULL, result_ulength);
+ if (unlikely(!result_uval)) return NULL;
+ result_ukind = sizeof(Py_UNICODE);
+ result_udata = PyUnicode_AS_UNICODE(result_uval);
+#endif
+
+ char_pos = 0;
+ for (i=0; i < value_count; i++) {
+ int ukind;
+ Py_ssize_t ulength;
+ void *udata;
+ PyObject *uval = PyTuple_GET_ITEM(value_tuple, i);
+ if (unlikely(__Pyx_PyUnicode_READY(uval)))
+ goto bad;
+ ulength = __Pyx_PyUnicode_GET_LENGTH(uval);
+ if (unlikely(!ulength))
+ continue;
+ if (unlikely(char_pos + ulength < 0))
+ goto overflow;
+ ukind = __Pyx_PyUnicode_KIND(uval);
+ udata = __Pyx_PyUnicode_DATA(uval);
+ if (!CYTHON_PEP393_ENABLED || ukind == result_ukind) {
+ memcpy((char *)result_udata + char_pos * result_ukind, udata, (size_t) (ulength * result_ukind));
+ } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030300F0 || defined(_PyUnicode_FastCopyCharacters)
- _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
- #else
- Py_ssize_t j;
- for (j=0; j < ulength; j++) {
- Py_UCS4 uchar = __Pyx_PyUnicode_READ(ukind, udata, j);
- __Pyx_PyUnicode_WRITE(result_ukind, result_udata, char_pos+j, uchar);
- }
- #endif
- }
- char_pos += ulength;
- }
- return result_uval;
-overflow:
- PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string");
-bad:
- Py_DECREF(result_uval);
- return NULL;
-#else
- // non-CPython fallback
- result_ulength++;
- value_count++;
- return PyUnicode_Join($empty_unicode, value_tuple);
-#endif
-}
-
-
-/////////////// BuildPyUnicode.proto ///////////////
-
-static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, char* chars, int clength,
- int prepend_sign, char padding_char);
-
-/////////////// BuildPyUnicode ///////////////
-
-// Create a PyUnicode object from an ASCII char*, e.g. a formatted number.
-
-static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, char* chars, int clength,
- int prepend_sign, char padding_char) {
- PyObject *uval;
- Py_ssize_t uoffset = ulength - clength;
-#if CYTHON_USE_UNICODE_INTERNALS
- Py_ssize_t i;
-#if CYTHON_PEP393_ENABLED
- // Py 3.3+ (post PEP-393)
- void *udata;
- uval = PyUnicode_New(ulength, 127);
- if (unlikely(!uval)) return NULL;
- udata = PyUnicode_DATA(uval);
-#else
- // Py 2.x/3.2 (pre PEP-393)
- Py_UNICODE *udata;
- uval = PyUnicode_FromUnicode(NULL, ulength);
- if (unlikely(!uval)) return NULL;
- udata = PyUnicode_AS_UNICODE(uval);
-#endif
- if (uoffset > 0) {
- i = 0;
- if (prepend_sign) {
- __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, 0, '-');
- i++;
- }
- for (; i < uoffset; i++) {
- __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, i, padding_char);
- }
- }
- for (i=0; i < clength; i++) {
- __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, uoffset+i, chars[i]);
- }
-
-#else
- // non-CPython
- {
- PyObject *sign = NULL, *padding = NULL;
- uval = NULL;
- if (uoffset > 0) {
- prepend_sign = !!prepend_sign;
- if (uoffset > prepend_sign) {
- padding = PyUnicode_FromOrdinal(padding_char);
- if (likely(padding) && uoffset > prepend_sign + 1) {
- PyObject *tmp;
- PyObject *repeat = PyInt_FromSize_t(uoffset - prepend_sign);
- if (unlikely(!repeat)) goto done_or_error;
- tmp = PyNumber_Multiply(padding, repeat);
- Py_DECREF(repeat);
- Py_DECREF(padding);
- padding = tmp;
- }
- if (unlikely(!padding)) goto done_or_error;
- }
- if (prepend_sign) {
- sign = PyUnicode_FromOrdinal('-');
- if (unlikely(!sign)) goto done_or_error;
- }
- }
-
- uval = PyUnicode_DecodeASCII(chars, clength, NULL);
- if (likely(uval) && padding) {
- PyObject *tmp = PyNumber_Add(padding, uval);
- Py_DECREF(uval);
- uval = tmp;
- }
- if (likely(uval) && sign) {
- PyObject *tmp = PyNumber_Add(sign, uval);
- Py_DECREF(uval);
- uval = tmp;
- }
-done_or_error:
- Py_XDECREF(padding);
- Py_XDECREF(sign);
- }
-#endif
-
- return uval;
-}
-
-
+ _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
+ #else
+ Py_ssize_t j;
+ for (j=0; j < ulength; j++) {
+ Py_UCS4 uchar = __Pyx_PyUnicode_READ(ukind, udata, j);
+ __Pyx_PyUnicode_WRITE(result_ukind, result_udata, char_pos+j, uchar);
+ }
+ #endif
+ }
+ char_pos += ulength;
+ }
+ return result_uval;
+overflow:
+ PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string");
+bad:
+ Py_DECREF(result_uval);
+ return NULL;
+#else
+ // non-CPython fallback
+ result_ulength++;
+ value_count++;
+ return PyUnicode_Join($empty_unicode, value_tuple);
+#endif
+}
+
+
+/////////////// BuildPyUnicode.proto ///////////////
+
+static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, char* chars, int clength,
+ int prepend_sign, char padding_char);
+
+/////////////// BuildPyUnicode ///////////////
+
+// Create a PyUnicode object from an ASCII char*, e.g. a formatted number.
+
+static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, char* chars, int clength,
+ int prepend_sign, char padding_char) {
+ PyObject *uval;
+ Py_ssize_t uoffset = ulength - clength;
+#if CYTHON_USE_UNICODE_INTERNALS
+ Py_ssize_t i;
+#if CYTHON_PEP393_ENABLED
+ // Py 3.3+ (post PEP-393)
+ void *udata;
+ uval = PyUnicode_New(ulength, 127);
+ if (unlikely(!uval)) return NULL;
+ udata = PyUnicode_DATA(uval);
+#else
+ // Py 2.x/3.2 (pre PEP-393)
+ Py_UNICODE *udata;
+ uval = PyUnicode_FromUnicode(NULL, ulength);
+ if (unlikely(!uval)) return NULL;
+ udata = PyUnicode_AS_UNICODE(uval);
+#endif
+ if (uoffset > 0) {
+ i = 0;
+ if (prepend_sign) {
+ __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, 0, '-');
+ i++;
+ }
+ for (; i < uoffset; i++) {
+ __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, i, padding_char);
+ }
+ }
+ for (i=0; i < clength; i++) {
+ __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, uoffset+i, chars[i]);
+ }
+
+#else
+ // non-CPython
+ {
+ PyObject *sign = NULL, *padding = NULL;
+ uval = NULL;
+ if (uoffset > 0) {
+ prepend_sign = !!prepend_sign;
+ if (uoffset > prepend_sign) {
+ padding = PyUnicode_FromOrdinal(padding_char);
+ if (likely(padding) && uoffset > prepend_sign + 1) {
+ PyObject *tmp;
+ PyObject *repeat = PyInt_FromSize_t(uoffset - prepend_sign);
+ if (unlikely(!repeat)) goto done_or_error;
+ tmp = PyNumber_Multiply(padding, repeat);
+ Py_DECREF(repeat);
+ Py_DECREF(padding);
+ padding = tmp;
+ }
+ if (unlikely(!padding)) goto done_or_error;
+ }
+ if (prepend_sign) {
+ sign = PyUnicode_FromOrdinal('-');
+ if (unlikely(!sign)) goto done_or_error;
+ }
+ }
+
+ uval = PyUnicode_DecodeASCII(chars, clength, NULL);
+ if (likely(uval) && padding) {
+ PyObject *tmp = PyNumber_Add(padding, uval);
+ Py_DECREF(uval);
+ uval = tmp;
+ }
+ if (likely(uval) && sign) {
+ PyObject *tmp = PyNumber_Add(sign, uval);
+ Py_DECREF(uval);
+ uval = tmp;
+ }
+done_or_error:
+ Py_XDECREF(padding);
+ Py_XDECREF(sign);
+ }
+#endif
+
+ return uval;
+}
+
+
//////////////////// ByteArrayAppendObject.proto ////////////////////
static CYTHON_INLINE int __Pyx_PyByteArray_AppendObject(PyObject* bytearray, PyObject* value);
@@ -1006,7 +1006,7 @@ static CYTHON_INLINE int __Pyx_PyByteArray_AppendObject(PyObject* bytearray, PyO
}
ival = (unsigned char) (PyString_AS_STRING(value)[0]);
} else
-#endif
+#endif
#if CYTHON_USE_PYLONG_INTERNALS
if (likely(PyLong_CheckExact(value)) && likely(Py_SIZE(value) == 1 || Py_SIZE(value) == 0)) {
if (Py_SIZE(value) == 0) {
@@ -1020,7 +1020,7 @@ static CYTHON_INLINE int __Pyx_PyByteArray_AppendObject(PyObject* bytearray, PyO
{
// CPython calls PyNumber_Index() internally
ival = __Pyx_PyIndex_AsSsize_t(value);
- if (unlikely(!__Pyx_is_valid_index(ival, 256))) {
+ if (unlikely(!__Pyx_is_valid_index(ival, 256))) {
if (ival == -1 && PyErr_Occurred())
return -1;
goto bad_range;
@@ -1042,7 +1042,7 @@ static CYTHON_INLINE int __Pyx_PyByteArray_Append(PyObject* bytearray, int value
static CYTHON_INLINE int __Pyx_PyByteArray_Append(PyObject* bytearray, int value) {
PyObject *pyval, *retval;
#if CYTHON_COMPILING_IN_CPYTHON
- if (likely(__Pyx_is_valid_index(value, 256))) {
+ if (likely(__Pyx_is_valid_index(value, 256))) {
Py_ssize_t n = Py_SIZE(bytearray);
if (likely(n != PY_SSIZE_T_MAX)) {
if (unlikely(PyByteArray_Resize(bytearray, n + 1) < 0))
@@ -1065,110 +1065,110 @@ static CYTHON_INLINE int __Pyx_PyByteArray_Append(PyObject* bytearray, int value
Py_DECREF(retval);
return 0;
}
-
-
-//////////////////// PyObjectFormat.proto ////////////////////
-
-#if CYTHON_USE_UNICODE_WRITER
-static PyObject* __Pyx_PyObject_Format(PyObject* s, PyObject* f);
-#else
-#define __Pyx_PyObject_Format(s, f) PyObject_Format(s, f)
-#endif
-
-//////////////////// PyObjectFormat ////////////////////
-
-#if CYTHON_USE_UNICODE_WRITER
-static PyObject* __Pyx_PyObject_Format(PyObject* obj, PyObject* format_spec) {
- int ret;
- _PyUnicodeWriter writer;
-
- if (likely(PyFloat_CheckExact(obj))) {
- // copied from CPython 3.5 "float__format__()" in floatobject.c
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x03040000
- _PyUnicodeWriter_Init(&writer, 0);
-#else
- _PyUnicodeWriter_Init(&writer);
-#endif
- ret = _PyFloat_FormatAdvancedWriter(
- &writer,
- obj,
- format_spec, 0, PyUnicode_GET_LENGTH(format_spec));
- } else if (likely(PyLong_CheckExact(obj))) {
- // copied from CPython 3.5 "long__format__()" in longobject.c
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x03040000
- _PyUnicodeWriter_Init(&writer, 0);
-#else
- _PyUnicodeWriter_Init(&writer);
-#endif
- ret = _PyLong_FormatAdvancedWriter(
- &writer,
- obj,
- format_spec, 0, PyUnicode_GET_LENGTH(format_spec));
- } else {
- return PyObject_Format(obj, format_spec);
- }
-
- if (unlikely(ret == -1)) {
- _PyUnicodeWriter_Dealloc(&writer);
- return NULL;
- }
- return _PyUnicodeWriter_Finish(&writer);
-}
-#endif
-
-
-//////////////////// PyObjectFormatSimple.proto ////////////////////
-
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyObject_FormatSimple(s, f) ( \
- likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \
- PyObject_Format(s, f))
-#elif PY_MAJOR_VERSION < 3
- // str is common in Py2, but formatting must return a Unicode string
- #define __Pyx_PyObject_FormatSimple(s, f) ( \
- likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \
- likely(PyString_CheckExact(s)) ? PyUnicode_FromEncodedObject(s, NULL, "strict") : \
- PyObject_Format(s, f))
-#elif CYTHON_USE_TYPE_SLOTS
- // Py3 nicely returns unicode strings from str() which makes this quite efficient for builtin types
- #define __Pyx_PyObject_FormatSimple(s, f) ( \
- likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \
- likely(PyLong_CheckExact(s)) ? PyLong_Type.tp_str(s) : \
- likely(PyFloat_CheckExact(s)) ? PyFloat_Type.tp_str(s) : \
- PyObject_Format(s, f))
-#else
- #define __Pyx_PyObject_FormatSimple(s, f) ( \
- likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \
- PyObject_Format(s, f))
-#endif
-
-
-//////////////////// PyObjectFormatAndDecref.proto ////////////////////
-
-static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f);
-static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f);
-
-//////////////////// PyObjectFormatAndDecref ////////////////////
-
-static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f) {
- if (unlikely(!s)) return NULL;
- if (likely(PyUnicode_CheckExact(s))) return s;
- #if PY_MAJOR_VERSION < 3
- // str is common in Py2, but formatting must return a Unicode string
- if (likely(PyString_CheckExact(s))) {
- PyObject *result = PyUnicode_FromEncodedObject(s, NULL, "strict");
- Py_DECREF(s);
- return result;
- }
- #endif
- return __Pyx_PyObject_FormatAndDecref(s, f);
-}
-
-static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f) {
- PyObject *result = PyObject_Format(s, f);
- Py_DECREF(s);
- return result;
-}
+
+
+//////////////////// PyObjectFormat.proto ////////////////////
+
+#if CYTHON_USE_UNICODE_WRITER
+static PyObject* __Pyx_PyObject_Format(PyObject* s, PyObject* f);
+#else
+#define __Pyx_PyObject_Format(s, f) PyObject_Format(s, f)
+#endif
+
+//////////////////// PyObjectFormat ////////////////////
+
+#if CYTHON_USE_UNICODE_WRITER
+static PyObject* __Pyx_PyObject_Format(PyObject* obj, PyObject* format_spec) {
+ int ret;
+ _PyUnicodeWriter writer;
+
+ if (likely(PyFloat_CheckExact(obj))) {
+ // copied from CPython 3.5 "float__format__()" in floatobject.c
+#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x03040000
+ _PyUnicodeWriter_Init(&writer, 0);
+#else
+ _PyUnicodeWriter_Init(&writer);
+#endif
+ ret = _PyFloat_FormatAdvancedWriter(
+ &writer,
+ obj,
+ format_spec, 0, PyUnicode_GET_LENGTH(format_spec));
+ } else if (likely(PyLong_CheckExact(obj))) {
+ // copied from CPython 3.5 "long__format__()" in longobject.c
+#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x03040000
+ _PyUnicodeWriter_Init(&writer, 0);
+#else
+ _PyUnicodeWriter_Init(&writer);
+#endif
+ ret = _PyLong_FormatAdvancedWriter(
+ &writer,
+ obj,
+ format_spec, 0, PyUnicode_GET_LENGTH(format_spec));
+ } else {
+ return PyObject_Format(obj, format_spec);
+ }
+
+ if (unlikely(ret == -1)) {
+ _PyUnicodeWriter_Dealloc(&writer);
+ return NULL;
+ }
+ return _PyUnicodeWriter_Finish(&writer);
+}
+#endif
+
+
+//////////////////// PyObjectFormatSimple.proto ////////////////////
+
+#if CYTHON_COMPILING_IN_PYPY
+ #define __Pyx_PyObject_FormatSimple(s, f) ( \
+ likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \
+ PyObject_Format(s, f))
+#elif PY_MAJOR_VERSION < 3
+ // str is common in Py2, but formatting must return a Unicode string
+ #define __Pyx_PyObject_FormatSimple(s, f) ( \
+ likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \
+ likely(PyString_CheckExact(s)) ? PyUnicode_FromEncodedObject(s, NULL, "strict") : \
+ PyObject_Format(s, f))
+#elif CYTHON_USE_TYPE_SLOTS
+ // Py3 nicely returns unicode strings from str() which makes this quite efficient for builtin types
+ #define __Pyx_PyObject_FormatSimple(s, f) ( \
+ likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \
+ likely(PyLong_CheckExact(s)) ? PyLong_Type.tp_str(s) : \
+ likely(PyFloat_CheckExact(s)) ? PyFloat_Type.tp_str(s) : \
+ PyObject_Format(s, f))
+#else
+ #define __Pyx_PyObject_FormatSimple(s, f) ( \
+ likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \
+ PyObject_Format(s, f))
+#endif
+
+
+//////////////////// PyObjectFormatAndDecref.proto ////////////////////
+
+static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f);
+static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f);
+
+//////////////////// PyObjectFormatAndDecref ////////////////////
+
+static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f) {
+ if (unlikely(!s)) return NULL;
+ if (likely(PyUnicode_CheckExact(s))) return s;
+ #if PY_MAJOR_VERSION < 3
+ // str is common in Py2, but formatting must return a Unicode string
+ if (likely(PyString_CheckExact(s))) {
+ PyObject *result = PyUnicode_FromEncodedObject(s, NULL, "strict");
+ Py_DECREF(s);
+ return result;
+ }
+ #endif
+ return __Pyx_PyObject_FormatAndDecref(s, f);
+}
+
+static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f) {
+ PyObject *result = PyObject_Format(s, f);
+ Py_DECREF(s);
+ return result;
+}
//////////////////// PyUnicode_Unicode.proto ////////////////////