aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/cython/Cython/Utility/StringTools.c
diff options
context:
space:
mode:
authorAleksandr <ivansduck@gmail.com>2022-02-10 16:47:52 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:52 +0300
commitb05913d1c3c02a773578bceb7285084d2933ae86 (patch)
treec0748b5dcbade83af788c0abfa89c0383d6b779c /contrib/tools/cython/Cython/Utility/StringTools.c
parentea6c5b7f172becca389cacaff7d5f45f6adccbe6 (diff)
downloadydb-b05913d1c3c02a773578bceb7285084d2933ae86.tar.gz
Restoring authorship annotation for Aleksandr <ivansduck@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/cython/Cython/Utility/StringTools.c')
-rw-r--r--contrib/tools/cython/Cython/Utility/StringTools.c284
1 files changed, 142 insertions, 142 deletions
diff --git a/contrib/tools/cython/Cython/Utility/StringTools.c b/contrib/tools/cython/Cython/Utility/StringTools.c
index c3247ece8a..2fdae812a0 100644
--- a/contrib/tools/cython/Cython/Utility/StringTools.c
+++ b/contrib/tools/cython/Cython/Utility/StringTools.c
@@ -38,9 +38,9 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
#endif
if (!*t->p)
return -1;
- // initialise cached hash value
- if (PyObject_Hash(*t->p) == -1)
- return -1;
+ // initialise cached hash value
+ if (PyObject_Hash(*t->p) == -1)
+ return -1;
++t;
}
return 0;
@@ -79,30 +79,30 @@ static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(PyObject* unicode, Py_UCS4 ch
#endif
#if !defined(Py_UNICODE_SIZE) || Py_UNICODE_SIZE == 2
-static int __Pyx_PyUnicodeBufferContainsUCS4_SP(Py_UNICODE* buffer, Py_ssize_t length, Py_UCS4 character) {
- /* handle surrogate pairs for Py_UNICODE buffers in 16bit Unicode builds */
- Py_UNICODE high_val, low_val;
- Py_UNICODE* pos;
- high_val = (Py_UNICODE) (0xD800 | (((character - 0x10000) >> 10) & ((1<<10)-1)));
- low_val = (Py_UNICODE) (0xDC00 | ( (character - 0x10000) & ((1<<10)-1)));
- for (pos=buffer; pos < buffer+length-1; pos++) {
- if (unlikely((high_val == pos[0]) & (low_val == pos[1]))) return 1;
- }
- return 0;
-}
+static int __Pyx_PyUnicodeBufferContainsUCS4_SP(Py_UNICODE* buffer, Py_ssize_t length, Py_UCS4 character) {
+ /* handle surrogate pairs for Py_UNICODE buffers in 16bit Unicode builds */
+ Py_UNICODE high_val, low_val;
+ Py_UNICODE* pos;
+ high_val = (Py_UNICODE) (0xD800 | (((character - 0x10000) >> 10) & ((1<<10)-1)));
+ low_val = (Py_UNICODE) (0xDC00 | ( (character - 0x10000) & ((1<<10)-1)));
+ for (pos=buffer; pos < buffer+length-1; pos++) {
+ if (unlikely((high_val == pos[0]) & (low_val == pos[1]))) return 1;
+ }
+ return 0;
+}
#endif
-
-static int __Pyx_PyUnicodeBufferContainsUCS4_BMP(Py_UNICODE* buffer, Py_ssize_t length, Py_UCS4 character) {
- Py_UNICODE uchar;
- Py_UNICODE* pos;
- uchar = (Py_UNICODE) character;
- for (pos=buffer; pos < buffer+length; pos++) {
- if (unlikely(uchar == pos[0])) return 1;
- }
- return 0;
-}
+
+static int __Pyx_PyUnicodeBufferContainsUCS4_BMP(Py_UNICODE* buffer, Py_ssize_t length, Py_UCS4 character) {
+ Py_UNICODE uchar;
+ Py_UNICODE* pos;
+ uchar = (Py_UNICODE) character;
+ for (pos=buffer; pos < buffer+length; pos++) {
+ if (unlikely(uchar == pos[0])) return 1;
+ }
+ return 0;
+}
#endif
-
+
static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(PyObject* unicode, Py_UCS4 character) {
#if CYTHON_PEP393_ENABLED
const int kind = PyUnicode_KIND(unicode);
@@ -127,17 +127,17 @@ static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(PyObject* unicode, Py_UCS4 ch
#if PY_VERSION_HEX < 0x03090000 || (defined(PyUnicode_WCHAR_KIND) && defined(PyUnicode_AS_UNICODE))
#if !defined(Py_UNICODE_SIZE) || Py_UNICODE_SIZE == 2
if ((sizeof(Py_UNICODE) == 2) && unlikely(character > 65535)) {
- return __Pyx_PyUnicodeBufferContainsUCS4_SP(
+ return __Pyx_PyUnicodeBufferContainsUCS4_SP(
__Pyx_PyUnicode_AS_UNICODE(unicode),
__Pyx_PyUnicode_GET_SIZE(unicode),
- character);
+ character);
} else
#endif
{
- return __Pyx_PyUnicodeBufferContainsUCS4_BMP(
+ return __Pyx_PyUnicodeBufferContainsUCS4_BMP(
__Pyx_PyUnicode_AS_UNICODE(unicode),
__Pyx_PyUnicode_GET_SIZE(unicode),
- character);
+ character);
}
#endif
@@ -223,21 +223,21 @@ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int
if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
goto return_ne;
}
-#if CYTHON_USE_UNICODE_INTERNALS
- {
- Py_hash_t hash1, hash2;
- #if CYTHON_PEP393_ENABLED
- hash1 = ((PyASCIIObject*)s1)->hash;
- hash2 = ((PyASCIIObject*)s2)->hash;
- #else
- hash1 = ((PyUnicodeObject*)s1)->hash;
- hash2 = ((PyUnicodeObject*)s2)->hash;
- #endif
- if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
- goto return_ne;
- }
- }
-#endif
+#if CYTHON_USE_UNICODE_INTERNALS
+ {
+ Py_hash_t hash1, hash2;
+ #if CYTHON_PEP393_ENABLED
+ hash1 = ((PyASCIIObject*)s1)->hash;
+ hash2 = ((PyASCIIObject*)s2)->hash;
+ #else
+ hash1 = ((PyUnicodeObject*)s1)->hash;
+ hash2 = ((PyUnicodeObject*)s2)->hash;
+ #endif
+ if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
+ goto return_ne;
+ }
+ }
+#endif
// len(s1) == len(s2) >= 1 (empty string is interned, and "s1 is not s2")
kind = __Pyx_PyUnicode_KIND(s1);
if (kind != __Pyx_PyUnicode_KIND(s2)) {
@@ -313,16 +313,16 @@ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int eq
} else if (length == 1) {
return (equals == Py_EQ);
} else {
- int result;
-#if CYTHON_USE_UNICODE_INTERNALS
- Py_hash_t hash1, hash2;
- hash1 = ((PyBytesObject*)s1)->ob_shash;
- hash2 = ((PyBytesObject*)s2)->ob_shash;
- if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
- return (equals == Py_NE);
- }
-#endif
- result = memcmp(ps1, ps2, (size_t)length);
+ int result;
+#if CYTHON_USE_UNICODE_INTERNALS
+ Py_hash_t hash1, hash2;
+ hash1 = ((PyBytesObject*)s1)->ob_shash;
+ hash2 = ((PyBytesObject*)s2)->ob_shash;
+ if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
+ return (equals == Py_NE);
+ }
+#endif
+ result = memcmp(ps1, ps2, (size_t)length);
return (equals == Py_EQ) ? (result == 0) : (result != 0);
}
} else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
@@ -434,21 +434,21 @@ static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py
}
-/////////////// decode_c_string_utf16.proto ///////////////
-
-static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
- int byteorder = 0;
- return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
-}
-static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
- int byteorder = -1;
- return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
-}
-static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
- int byteorder = 1;
- return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
-}
-
+/////////////// decode_c_string_utf16.proto ///////////////
+
+static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
+ int byteorder = 0;
+ return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
+}
+static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
+ int byteorder = -1;
+ return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
+}
+static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
+ int byteorder = 1;
+ return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
+}
+
/////////////// decode_cpp_string.proto ///////////////
//@requires: IncludeCppStringH
//@requires: decode_c_bytes
@@ -470,7 +470,7 @@ static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
/////////////// decode_c_string ///////////////
//@requires: IncludeStringH
-//@requires: decode_c_string_utf16
+//@requires: decode_c_string_utf16
//@substitute: naming
/* duplicate code to avoid calling strlen() if start >= 0 and stop >= 0 */
@@ -514,7 +514,7 @@ static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
/////////////// decode_c_bytes ///////////////
-//@requires: decode_c_string_utf16
+//@requires: decode_c_string_utf16
//@substitute: naming
static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
@@ -617,8 +617,8 @@ static CYTHON_INLINE int __Pyx_Py_UNICODE_ISTITLE(Py_UCS4 uchar)
/////////////// unicode_tailmatch.proto ///////////////
-static int __Pyx_PyUnicode_Tailmatch(
- PyObject* s, PyObject* substr, Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/
+static int __Pyx_PyUnicode_Tailmatch(
+ PyObject* s, PyObject* substr, Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/
/////////////// unicode_tailmatch ///////////////
@@ -626,32 +626,32 @@ static int __Pyx_PyUnicode_Tailmatch(
// tuple of prefixes/suffixes, whereas it's much more common to
// test for a single unicode string.
-static int __Pyx_PyUnicode_TailmatchTuple(PyObject* s, PyObject* substrings,
- Py_ssize_t start, Py_ssize_t end, int direction) {
- Py_ssize_t i, count = PyTuple_GET_SIZE(substrings);
- for (i = 0; i < count; i++) {
- Py_ssize_t result;
+static int __Pyx_PyUnicode_TailmatchTuple(PyObject* s, PyObject* substrings,
+ Py_ssize_t start, Py_ssize_t end, int direction) {
+ 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
- result = PyUnicode_Tailmatch(s, PyTuple_GET_ITEM(substrings, i),
- start, end, direction);
+ result = PyUnicode_Tailmatch(s, PyTuple_GET_ITEM(substrings, i),
+ start, end, direction);
#else
- PyObject* sub = PySequence_ITEM(substrings, i);
- if (unlikely(!sub)) return -1;
- result = PyUnicode_Tailmatch(s, sub, start, end, direction);
- Py_DECREF(sub);
+ PyObject* sub = PySequence_ITEM(substrings, i);
+ if (unlikely(!sub)) return -1;
+ result = PyUnicode_Tailmatch(s, sub, start, end, direction);
+ Py_DECREF(sub);
#endif
- if (result) {
- return (int) result;
+ if (result) {
+ return (int) result;
}
}
- return 0;
-}
-
-static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr,
- Py_ssize_t start, Py_ssize_t end, int direction) {
- if (unlikely(PyTuple_Check(substr))) {
- return __Pyx_PyUnicode_TailmatchTuple(s, substr, start, end, direction);
- }
+ return 0;
+}
+
+static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr,
+ Py_ssize_t start, Py_ssize_t end, int direction) {
+ if (unlikely(PyTuple_Check(substr))) {
+ return __Pyx_PyUnicode_TailmatchTuple(s, substr, start, end, direction);
+ }
return (int) PyUnicode_Tailmatch(s, substr, start, end, direction);
}
@@ -721,33 +721,33 @@ static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg,
return retval;
}
-static int __Pyx_PyBytes_TailmatchTuple(PyObject* self, PyObject* substrings,
- Py_ssize_t start, Py_ssize_t end, int direction) {
- Py_ssize_t i, count = PyTuple_GET_SIZE(substrings);
- for (i = 0; i < count; i++) {
- int result;
+static int __Pyx_PyBytes_TailmatchTuple(PyObject* self, PyObject* substrings,
+ Py_ssize_t start, Py_ssize_t end, int direction) {
+ 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
- result = __Pyx_PyBytes_SingleTailmatch(self, PyTuple_GET_ITEM(substrings, i),
- start, end, direction);
+ result = __Pyx_PyBytes_SingleTailmatch(self, PyTuple_GET_ITEM(substrings, i),
+ start, end, direction);
#else
- PyObject* sub = PySequence_ITEM(substrings, i);
- if (unlikely(!sub)) return -1;
- result = __Pyx_PyBytes_SingleTailmatch(self, sub, start, end, direction);
- Py_DECREF(sub);
+ PyObject* sub = PySequence_ITEM(substrings, i);
+ if (unlikely(!sub)) return -1;
+ result = __Pyx_PyBytes_SingleTailmatch(self, sub, start, end, direction);
+ Py_DECREF(sub);
#endif
- if (result) {
- return result;
+ if (result) {
+ return result;
}
}
- return 0;
-}
-
-static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr,
- Py_ssize_t start, Py_ssize_t end, int direction) {
- if (unlikely(PyTuple_Check(substr))) {
- return __Pyx_PyBytes_TailmatchTuple(self, substr, start, end, direction);
- }
-
+ return 0;
+}
+
+static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr,
+ Py_ssize_t start, Py_ssize_t end, int direction) {
+ if (unlikely(PyTuple_Check(substr))) {
+ return __Pyx_PyBytes_TailmatchTuple(self, substr, start, end, direction);
+ }
+
return __Pyx_PyBytes_SingleTailmatch(self, substr, start, end, direction);
}
@@ -788,7 +788,7 @@ static CYTHON_INLINE char __Pyx_PyBytes_GetItemInt(PyObject* bytes, Py_ssize_t i
Py_ssize_t size = PyBytes_GET_SIZE(bytes);
if (unlikely(!__Pyx_is_valid_index(index, size))) {
PyErr_SetString(PyExc_IndexError, "string index out of range");
- return (char) -1;
+ return (char) -1;
}
}
return PyBytes_AS_STRING(bytes)[index];
@@ -873,7 +873,7 @@ static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_co
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)
+ #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;
@@ -1169,27 +1169,27 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObj
Py_DECREF(s);
return result;
}
-
-
-//////////////////// PyUnicode_Unicode.proto ////////////////////
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj);/*proto*/
-
-//////////////////// PyUnicode_Unicode ////////////////////
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj) {
- if (unlikely(obj == Py_None))
- obj = PYUNICODE("None");
- return __Pyx_NewRef(obj);
-}
-
-
-//////////////////// PyObject_Unicode.proto ////////////////////
-
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyObject_Unicode(obj) \
- (likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Str(obj))
-#else
-#define __Pyx_PyObject_Unicode(obj) \
- (likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Unicode(obj))
-#endif
+
+
+//////////////////// PyUnicode_Unicode.proto ////////////////////
+
+static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj);/*proto*/
+
+//////////////////// PyUnicode_Unicode ////////////////////
+
+static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj) {
+ if (unlikely(obj == Py_None))
+ obj = PYUNICODE("None");
+ return __Pyx_NewRef(obj);
+}
+
+
+//////////////////// PyObject_Unicode.proto ////////////////////
+
+#if PY_MAJOR_VERSION >= 3
+#define __Pyx_PyObject_Unicode(obj) \
+ (likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Str(obj))
+#else
+#define __Pyx_PyObject_Unicode(obj) \
+ (likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Unicode(obj))
+#endif