Merged revisions 81860 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81860 | antoine.pitrou | 2010-06-09 18:24:00 +0200 (mer., 09 juin 2010) | 3 lines Issue #8930: fix some C code indentation ........
This commit is contained in:
parent
46a955b45a
commit
96ec48b414
|
@ -176,27 +176,27 @@ static PyObject *
|
|||
escape_encode(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
PyObject *str;
|
||||
const char *errors = NULL;
|
||||
char *buf;
|
||||
Py_ssize_t len;
|
||||
PyObject *str;
|
||||
const char *errors = NULL;
|
||||
char *buf;
|
||||
Py_ssize_t len;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!|z:escape_encode",
|
||||
&PyString_Type, &str, &errors))
|
||||
return NULL;
|
||||
if (!PyArg_ParseTuple(args, "O!|z:escape_encode",
|
||||
&PyString_Type, &str, &errors))
|
||||
return NULL;
|
||||
|
||||
str = PyString_Repr(str, 0);
|
||||
if (!str)
|
||||
return NULL;
|
||||
str = PyString_Repr(str, 0);
|
||||
if (!str)
|
||||
return NULL;
|
||||
|
||||
/* The string will be quoted. Unquote, similar to unicode-escape. */
|
||||
buf = PyString_AS_STRING (str);
|
||||
len = PyString_GET_SIZE (str);
|
||||
memmove(buf, buf+1, len-2);
|
||||
if (_PyString_Resize(&str, len-2) < 0)
|
||||
return NULL;
|
||||
/* The string will be quoted. Unquote, similar to unicode-escape. */
|
||||
buf = PyString_AS_STRING (str);
|
||||
len = PyString_GET_SIZE (str);
|
||||
memmove(buf, buf+1, len-2);
|
||||
if (_PyString_Resize(&str, len-2) < 0)
|
||||
return NULL;
|
||||
|
||||
return codec_tuple(str, PyString_Size(str));
|
||||
return codec_tuple(str, PyString_Size(str));
|
||||
}
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
|
@ -232,7 +232,7 @@ static PyObject *
|
|||
utf_7_decode(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
Py_buffer pbuf;
|
||||
Py_buffer pbuf;
|
||||
const char *errors = NULL;
|
||||
int final = 0;
|
||||
Py_ssize_t consumed;
|
||||
|
@ -245,7 +245,7 @@ utf_7_decode(PyObject *self,
|
|||
|
||||
decoded = PyUnicode_DecodeUTF7Stateful(pbuf.buf, pbuf.len, errors,
|
||||
final ? NULL : &consumed);
|
||||
PyBuffer_Release(&pbuf);
|
||||
PyBuffer_Release(&pbuf);
|
||||
if (decoded == NULL)
|
||||
return NULL;
|
||||
return codec_tuple(decoded, consumed);
|
||||
|
@ -255,7 +255,7 @@ static PyObject *
|
|||
utf_8_decode(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
Py_buffer pbuf;
|
||||
Py_buffer pbuf;
|
||||
const char *errors = NULL;
|
||||
int final = 0;
|
||||
Py_ssize_t consumed;
|
||||
|
@ -268,7 +268,7 @@ utf_8_decode(PyObject *self,
|
|||
|
||||
decoded = PyUnicode_DecodeUTF8Stateful(pbuf.buf, pbuf.len, errors,
|
||||
final ? NULL : &consumed);
|
||||
PyBuffer_Release(&pbuf);
|
||||
PyBuffer_Release(&pbuf);
|
||||
if (decoded == NULL)
|
||||
return NULL;
|
||||
return codec_tuple(decoded, consumed);
|
||||
|
@ -278,7 +278,7 @@ static PyObject *
|
|||
utf_16_decode(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
Py_buffer pbuf;
|
||||
Py_buffer pbuf;
|
||||
const char *errors = NULL;
|
||||
int byteorder = 0;
|
||||
int final = 0;
|
||||
|
@ -291,7 +291,7 @@ utf_16_decode(PyObject *self,
|
|||
consumed = pbuf.len; /* This is overwritten unless final is true. */
|
||||
decoded = PyUnicode_DecodeUTF16Stateful(pbuf.buf, pbuf.len, errors,
|
||||
&byteorder, final ? NULL : &consumed);
|
||||
PyBuffer_Release(&pbuf);
|
||||
PyBuffer_Release(&pbuf);
|
||||
if (decoded == NULL)
|
||||
return NULL;
|
||||
return codec_tuple(decoded, consumed);
|
||||
|
@ -301,7 +301,7 @@ static PyObject *
|
|||
utf_16_le_decode(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
Py_buffer pbuf;
|
||||
Py_buffer pbuf;
|
||||
const char *errors = NULL;
|
||||
int byteorder = -1;
|
||||
int final = 0;
|
||||
|
@ -315,7 +315,7 @@ utf_16_le_decode(PyObject *self,
|
|||
consumed = pbuf.len; /* This is overwritten unless final is true. */
|
||||
decoded = PyUnicode_DecodeUTF16Stateful(pbuf.buf, pbuf.len, errors,
|
||||
&byteorder, final ? NULL : &consumed);
|
||||
PyBuffer_Release(&pbuf);
|
||||
PyBuffer_Release(&pbuf);
|
||||
if (decoded == NULL)
|
||||
return NULL;
|
||||
return codec_tuple(decoded, consumed);
|
||||
|
@ -325,7 +325,7 @@ static PyObject *
|
|||
utf_16_be_decode(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
Py_buffer pbuf;
|
||||
Py_buffer pbuf;
|
||||
const char *errors = NULL;
|
||||
int byteorder = 1;
|
||||
int final = 0;
|
||||
|
@ -339,7 +339,7 @@ utf_16_be_decode(PyObject *self,
|
|||
consumed = pbuf.len; /* This is overwritten unless final is true. */
|
||||
decoded = PyUnicode_DecodeUTF16Stateful(pbuf.buf, pbuf.len, errors,
|
||||
&byteorder, final ? NULL : &consumed);
|
||||
PyBuffer_Release(&pbuf);
|
||||
PyBuffer_Release(&pbuf);
|
||||
if (decoded == NULL)
|
||||
return NULL;
|
||||
return codec_tuple(decoded, consumed);
|
||||
|
@ -357,7 +357,7 @@ static PyObject *
|
|||
utf_16_ex_decode(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
Py_buffer pbuf;
|
||||
Py_buffer pbuf;
|
||||
const char *errors = NULL;
|
||||
int byteorder = 0;
|
||||
PyObject *unicode, *tuple;
|
||||
|
@ -370,7 +370,7 @@ utf_16_ex_decode(PyObject *self,
|
|||
consumed = pbuf.len; /* This is overwritten unless final is true. */
|
||||
unicode = PyUnicode_DecodeUTF16Stateful(pbuf.buf, pbuf.len, errors,
|
||||
&byteorder, final ? NULL : &consumed);
|
||||
PyBuffer_Release(&pbuf);
|
||||
PyBuffer_Release(&pbuf);
|
||||
if (unicode == NULL)
|
||||
return NULL;
|
||||
tuple = Py_BuildValue("Oni", unicode, consumed, byteorder);
|
||||
|
@ -382,7 +382,7 @@ static PyObject *
|
|||
utf_32_decode(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
Py_buffer pbuf;
|
||||
Py_buffer pbuf;
|
||||
const char *errors = NULL;
|
||||
int byteorder = 0;
|
||||
int final = 0;
|
||||
|
@ -395,7 +395,7 @@ utf_32_decode(PyObject *self,
|
|||
consumed = pbuf.len; /* This is overwritten unless final is true. */
|
||||
decoded = PyUnicode_DecodeUTF32Stateful(pbuf.buf, pbuf.len, errors,
|
||||
&byteorder, final ? NULL : &consumed);
|
||||
PyBuffer_Release(&pbuf);
|
||||
PyBuffer_Release(&pbuf);
|
||||
if (decoded == NULL)
|
||||
return NULL;
|
||||
return codec_tuple(decoded, consumed);
|
||||
|
@ -405,7 +405,7 @@ static PyObject *
|
|||
utf_32_le_decode(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
Py_buffer pbuf;
|
||||
Py_buffer pbuf;
|
||||
const char *errors = NULL;
|
||||
int byteorder = -1;
|
||||
int final = 0;
|
||||
|
@ -418,7 +418,7 @@ utf_32_le_decode(PyObject *self,
|
|||
consumed = pbuf.len; /* This is overwritten unless final is true. */
|
||||
decoded = PyUnicode_DecodeUTF32Stateful(pbuf.buf, pbuf.len, errors,
|
||||
&byteorder, final ? NULL : &consumed);
|
||||
PyBuffer_Release(&pbuf);
|
||||
PyBuffer_Release(&pbuf);
|
||||
if (decoded == NULL)
|
||||
return NULL;
|
||||
return codec_tuple(decoded, consumed);
|
||||
|
@ -428,7 +428,7 @@ static PyObject *
|
|||
utf_32_be_decode(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
Py_buffer pbuf;
|
||||
Py_buffer pbuf;
|
||||
const char *errors = NULL;
|
||||
int byteorder = 1;
|
||||
int final = 0;
|
||||
|
@ -441,7 +441,7 @@ utf_32_be_decode(PyObject *self,
|
|||
consumed = pbuf.len; /* This is overwritten unless final is true. */
|
||||
decoded = PyUnicode_DecodeUTF32Stateful(pbuf.buf, pbuf.len, errors,
|
||||
&byteorder, final ? NULL : &consumed);
|
||||
PyBuffer_Release(&pbuf);
|
||||
PyBuffer_Release(&pbuf);
|
||||
if (decoded == NULL)
|
||||
return NULL;
|
||||
return codec_tuple(decoded, consumed);
|
||||
|
@ -459,7 +459,7 @@ static PyObject *
|
|||
utf_32_ex_decode(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
Py_buffer pbuf;
|
||||
Py_buffer pbuf;
|
||||
const char *errors = NULL;
|
||||
int byteorder = 0;
|
||||
PyObject *unicode, *tuple;
|
||||
|
@ -472,7 +472,7 @@ utf_32_ex_decode(PyObject *self,
|
|||
consumed = pbuf.len; /* This is overwritten unless final is true. */
|
||||
unicode = PyUnicode_DecodeUTF32Stateful(pbuf.buf, pbuf.len, errors,
|
||||
&byteorder, final ? NULL : &consumed);
|
||||
PyBuffer_Release(&pbuf);
|
||||
PyBuffer_Release(&pbuf);
|
||||
if (unicode == NULL)
|
||||
return NULL;
|
||||
tuple = Py_BuildValue("Oni", unicode, consumed, byteorder);
|
||||
|
@ -484,7 +484,7 @@ static PyObject *
|
|||
unicode_escape_decode(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
Py_buffer pbuf;
|
||||
Py_buffer pbuf;
|
||||
const char *errors = NULL;
|
||||
PyObject *unicode;
|
||||
|
||||
|
@ -492,68 +492,68 @@ unicode_escape_decode(PyObject *self,
|
|||
&pbuf, &errors))
|
||||
return NULL;
|
||||
|
||||
unicode = PyUnicode_DecodeUnicodeEscape(pbuf.buf, pbuf.len, errors);
|
||||
PyBuffer_Release(&pbuf);
|
||||
return codec_tuple(unicode, pbuf.len);
|
||||
unicode = PyUnicode_DecodeUnicodeEscape(pbuf.buf, pbuf.len, errors);
|
||||
PyBuffer_Release(&pbuf);
|
||||
return codec_tuple(unicode, pbuf.len);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
raw_unicode_escape_decode(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
Py_buffer pbuf;
|
||||
Py_buffer pbuf;
|
||||
const char *errors = NULL;
|
||||
PyObject *unicode;
|
||||
PyObject *unicode;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s*|z:raw_unicode_escape_decode",
|
||||
&pbuf, &errors))
|
||||
return NULL;
|
||||
|
||||
unicode = PyUnicode_DecodeRawUnicodeEscape(pbuf.buf, pbuf.len, errors);
|
||||
PyBuffer_Release(&pbuf);
|
||||
return codec_tuple(unicode, pbuf.len);
|
||||
unicode = PyUnicode_DecodeRawUnicodeEscape(pbuf.buf, pbuf.len, errors);
|
||||
PyBuffer_Release(&pbuf);
|
||||
return codec_tuple(unicode, pbuf.len);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
latin_1_decode(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
Py_buffer pbuf;
|
||||
PyObject *unicode;
|
||||
Py_buffer pbuf;
|
||||
PyObject *unicode;
|
||||
const char *errors = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s*|z:latin_1_decode",
|
||||
&pbuf, &errors))
|
||||
return NULL;
|
||||
|
||||
unicode = PyUnicode_DecodeLatin1(pbuf.buf, pbuf.len, errors);
|
||||
PyBuffer_Release(&pbuf);
|
||||
return codec_tuple(unicode, pbuf.len);
|
||||
unicode = PyUnicode_DecodeLatin1(pbuf.buf, pbuf.len, errors);
|
||||
PyBuffer_Release(&pbuf);
|
||||
return codec_tuple(unicode, pbuf.len);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
ascii_decode(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
Py_buffer pbuf;
|
||||
PyObject *unicode;
|
||||
Py_buffer pbuf;
|
||||
PyObject *unicode;
|
||||
const char *errors = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s*|z:ascii_decode",
|
||||
&pbuf, &errors))
|
||||
return NULL;
|
||||
|
||||
unicode = PyUnicode_DecodeASCII(pbuf.buf, pbuf.len, errors);
|
||||
PyBuffer_Release(&pbuf);
|
||||
return codec_tuple(unicode, pbuf.len);
|
||||
unicode = PyUnicode_DecodeASCII(pbuf.buf, pbuf.len, errors);
|
||||
PyBuffer_Release(&pbuf);
|
||||
return codec_tuple(unicode, pbuf.len);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
charmap_decode(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
Py_buffer pbuf;
|
||||
PyObject *unicode;
|
||||
Py_buffer pbuf;
|
||||
PyObject *unicode;
|
||||
const char *errors = NULL;
|
||||
PyObject *mapping = NULL;
|
||||
|
||||
|
@ -563,9 +563,9 @@ charmap_decode(PyObject *self,
|
|||
if (mapping == Py_None)
|
||||
mapping = NULL;
|
||||
|
||||
unicode = PyUnicode_DecodeCharmap(pbuf.buf, pbuf.len, mapping, errors);
|
||||
PyBuffer_Release(&pbuf);
|
||||
return codec_tuple(unicode, pbuf.len);
|
||||
unicode = PyUnicode_DecodeCharmap(pbuf.buf, pbuf.len, mapping, errors);
|
||||
PyBuffer_Release(&pbuf);
|
||||
return codec_tuple(unicode, pbuf.len);
|
||||
}
|
||||
|
||||
#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
|
||||
|
@ -574,7 +574,7 @@ static PyObject *
|
|||
mbcs_decode(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
Py_buffer pbuf;
|
||||
Py_buffer pbuf;
|
||||
const char *errors = NULL;
|
||||
int final = 0;
|
||||
Py_ssize_t consumed;
|
||||
|
@ -587,7 +587,7 @@ mbcs_decode(PyObject *self,
|
|||
|
||||
decoded = PyUnicode_DecodeMBCSStateful(pbuf.buf, pbuf.len, errors,
|
||||
final ? NULL : &consumed);
|
||||
PyBuffer_Release(&pbuf);
|
||||
PyBuffer_Release(&pbuf);
|
||||
if (decoded == NULL)
|
||||
return NULL;
|
||||
return codec_tuple(decoded, consumed);
|
||||
|
|
|
@ -114,24 +114,24 @@ bytes_buffer_getcharbuf(PyByteArrayObject *self, Py_ssize_t index, const char **
|
|||
static int
|
||||
bytes_getbuffer(PyByteArrayObject *obj, Py_buffer *view, int flags)
|
||||
{
|
||||
int ret;
|
||||
void *ptr;
|
||||
if (view == NULL) {
|
||||
obj->ob_exports++;
|
||||
return 0;
|
||||
}
|
||||
ptr = (void *) PyByteArray_AS_STRING(obj);
|
||||
ret = PyBuffer_FillInfo(view, (PyObject*)obj, ptr, Py_SIZE(obj), 0, flags);
|
||||
if (ret >= 0) {
|
||||
obj->ob_exports++;
|
||||
}
|
||||
return ret;
|
||||
int ret;
|
||||
void *ptr;
|
||||
if (view == NULL) {
|
||||
obj->ob_exports++;
|
||||
return 0;
|
||||
}
|
||||
ptr = (void *) PyByteArray_AS_STRING(obj);
|
||||
ret = PyBuffer_FillInfo(view, (PyObject*)obj, ptr, Py_SIZE(obj), 0, flags);
|
||||
if (ret >= 0) {
|
||||
obj->ob_exports++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
bytes_releasebuffer(PyByteArrayObject *obj, Py_buffer *view)
|
||||
{
|
||||
obj->ob_exports--;
|
||||
obj->ob_exports--;
|
||||
}
|
||||
|
||||
static Py_ssize_t
|
||||
|
@ -1809,43 +1809,43 @@ replace_single_character_in_place(PyByteArrayObject *self,
|
|||
char from_c, char to_c,
|
||||
Py_ssize_t maxcount)
|
||||
{
|
||||
char *self_s, *result_s, *start, *end, *next;
|
||||
Py_ssize_t self_len;
|
||||
PyByteArrayObject *result;
|
||||
char *self_s, *result_s, *start, *end, *next;
|
||||
Py_ssize_t self_len;
|
||||
PyByteArrayObject *result;
|
||||
|
||||
/* The result string will be the same size */
|
||||
self_s = PyByteArray_AS_STRING(self);
|
||||
self_len = PyByteArray_GET_SIZE(self);
|
||||
/* The result string will be the same size */
|
||||
self_s = PyByteArray_AS_STRING(self);
|
||||
self_len = PyByteArray_GET_SIZE(self);
|
||||
|
||||
next = findchar(self_s, self_len, from_c);
|
||||
next = findchar(self_s, self_len, from_c);
|
||||
|
||||
if (next == NULL) {
|
||||
/* No matches; return the original bytes */
|
||||
return return_self(self);
|
||||
}
|
||||
if (next == NULL) {
|
||||
/* No matches; return the original bytes */
|
||||
return return_self(self);
|
||||
}
|
||||
|
||||
/* Need to make a new bytes */
|
||||
result = (PyByteArrayObject *) PyByteArray_FromStringAndSize(NULL, self_len);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
result_s = PyByteArray_AS_STRING(result);
|
||||
Py_MEMCPY(result_s, self_s, self_len);
|
||||
/* Need to make a new bytes */
|
||||
result = (PyByteArrayObject *) PyByteArray_FromStringAndSize(NULL, self_len);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
result_s = PyByteArray_AS_STRING(result);
|
||||
Py_MEMCPY(result_s, self_s, self_len);
|
||||
|
||||
/* change everything in-place, starting with this one */
|
||||
start = result_s + (next-self_s);
|
||||
*start = to_c;
|
||||
start++;
|
||||
end = result_s + self_len;
|
||||
/* change everything in-place, starting with this one */
|
||||
start = result_s + (next-self_s);
|
||||
*start = to_c;
|
||||
start++;
|
||||
end = result_s + self_len;
|
||||
|
||||
while (--maxcount > 0) {
|
||||
next = findchar(start, end-start, from_c);
|
||||
if (next == NULL)
|
||||
break;
|
||||
*next = to_c;
|
||||
start = next+1;
|
||||
}
|
||||
while (--maxcount > 0) {
|
||||
next = findchar(start, end-start, from_c);
|
||||
if (next == NULL)
|
||||
break;
|
||||
*next = to_c;
|
||||
start = next+1;
|
||||
}
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* len(self)>=1, len(from)==len(to)>=2, maxcount>=1 */
|
||||
|
|
|
@ -369,7 +369,7 @@ PyObject *PyString_Decode(const char *s,
|
|||
|
||||
str = PyString_FromStringAndSize(s, size);
|
||||
if (str == NULL)
|
||||
return NULL;
|
||||
return NULL;
|
||||
v = PyString_AsDecodedString(str, encoding, errors);
|
||||
Py_DECREF(str);
|
||||
return v;
|
||||
|
@ -382,23 +382,23 @@ PyObject *PyString_AsDecodedObject(PyObject *str,
|
|||
PyObject *v;
|
||||
|
||||
if (!PyString_Check(str)) {
|
||||
PyErr_BadArgument();
|
||||
goto onError;
|
||||
PyErr_BadArgument();
|
||||
goto onError;
|
||||
}
|
||||
|
||||
if (encoding == NULL) {
|
||||
#ifdef Py_USING_UNICODE
|
||||
encoding = PyUnicode_GetDefaultEncoding();
|
||||
encoding = PyUnicode_GetDefaultEncoding();
|
||||
#else
|
||||
PyErr_SetString(PyExc_ValueError, "no encoding specified");
|
||||
goto onError;
|
||||
PyErr_SetString(PyExc_ValueError, "no encoding specified");
|
||||
goto onError;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Decode via the codec registry */
|
||||
v = PyCodec_Decode(str, encoding, errors);
|
||||
if (v == NULL)
|
||||
goto onError;
|
||||
goto onError;
|
||||
|
||||
return v;
|
||||
|
||||
|
@ -414,24 +414,24 @@ PyObject *PyString_AsDecodedString(PyObject *str,
|
|||
|
||||
v = PyString_AsDecodedObject(str, encoding, errors);
|
||||
if (v == NULL)
|
||||
goto onError;
|
||||
goto onError;
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
/* Convert Unicode to a string using the default encoding */
|
||||
if (PyUnicode_Check(v)) {
|
||||
PyObject *temp = v;
|
||||
v = PyUnicode_AsEncodedString(v, NULL, NULL);
|
||||
Py_DECREF(temp);
|
||||
if (v == NULL)
|
||||
goto onError;
|
||||
PyObject *temp = v;
|
||||
v = PyUnicode_AsEncodedString(v, NULL, NULL);
|
||||
Py_DECREF(temp);
|
||||
if (v == NULL)
|
||||
goto onError;
|
||||
}
|
||||
#endif
|
||||
if (!PyString_Check(v)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"decoder did not return a string object (type=%.400s)",
|
||||
Py_TYPE(v)->tp_name);
|
||||
Py_DECREF(v);
|
||||
goto onError;
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"decoder did not return a string object (type=%.400s)",
|
||||
Py_TYPE(v)->tp_name);
|
||||
Py_DECREF(v);
|
||||
goto onError;
|
||||
}
|
||||
|
||||
return v;
|
||||
|
@ -449,7 +449,7 @@ PyObject *PyString_Encode(const char *s,
|
|||
|
||||
str = PyString_FromStringAndSize(s, size);
|
||||
if (str == NULL)
|
||||
return NULL;
|
||||
return NULL;
|
||||
v = PyString_AsEncodedString(str, encoding, errors);
|
||||
Py_DECREF(str);
|
||||
return v;
|
||||
|
@ -462,23 +462,23 @@ PyObject *PyString_AsEncodedObject(PyObject *str,
|
|||
PyObject *v;
|
||||
|
||||
if (!PyString_Check(str)) {
|
||||
PyErr_BadArgument();
|
||||
goto onError;
|
||||
PyErr_BadArgument();
|
||||
goto onError;
|
||||
}
|
||||
|
||||
if (encoding == NULL) {
|
||||
#ifdef Py_USING_UNICODE
|
||||
encoding = PyUnicode_GetDefaultEncoding();
|
||||
encoding = PyUnicode_GetDefaultEncoding();
|
||||
#else
|
||||
PyErr_SetString(PyExc_ValueError, "no encoding specified");
|
||||
goto onError;
|
||||
PyErr_SetString(PyExc_ValueError, "no encoding specified");
|
||||
goto onError;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Encode via the codec registry */
|
||||
v = PyCodec_Encode(str, encoding, errors);
|
||||
if (v == NULL)
|
||||
goto onError;
|
||||
goto onError;
|
||||
|
||||
return v;
|
||||
|
||||
|
@ -494,24 +494,24 @@ PyObject *PyString_AsEncodedString(PyObject *str,
|
|||
|
||||
v = PyString_AsEncodedObject(str, encoding, errors);
|
||||
if (v == NULL)
|
||||
goto onError;
|
||||
goto onError;
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
/* Convert Unicode to a string using the default encoding */
|
||||
if (PyUnicode_Check(v)) {
|
||||
PyObject *temp = v;
|
||||
v = PyUnicode_AsEncodedString(v, NULL, NULL);
|
||||
Py_DECREF(temp);
|
||||
if (v == NULL)
|
||||
goto onError;
|
||||
PyObject *temp = v;
|
||||
v = PyUnicode_AsEncodedString(v, NULL, NULL);
|
||||
Py_DECREF(temp);
|
||||
if (v == NULL)
|
||||
goto onError;
|
||||
}
|
||||
#endif
|
||||
if (!PyString_Check(v)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"encoder did not return a string object (type=%.400s)",
|
||||
Py_TYPE(v)->tp_name);
|
||||
Py_DECREF(v);
|
||||
goto onError;
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"encoder did not return a string object (type=%.400s)",
|
||||
Py_TYPE(v)->tp_name);
|
||||
Py_DECREF(v);
|
||||
goto onError;
|
||||
}
|
||||
|
||||
return v;
|
||||
|
@ -3331,17 +3331,17 @@ string_encode(PyStringObject *self, PyObject *args)
|
|||
PyObject *v;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|ss:encode", &encoding, &errors))
|
||||
return NULL;
|
||||
return NULL;
|
||||
v = PyString_AsEncodedObject((PyObject *)self, encoding, errors);
|
||||
if (v == NULL)
|
||||
goto onError;
|
||||
goto onError;
|
||||
if (!PyString_Check(v) && !PyUnicode_Check(v)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"encoder did not return a string/unicode object "
|
||||
"(type=%.400s)",
|
||||
Py_TYPE(v)->tp_name);
|
||||
Py_DECREF(v);
|
||||
return NULL;
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"encoder did not return a string/unicode object "
|
||||
"(type=%.400s)",
|
||||
Py_TYPE(v)->tp_name);
|
||||
Py_DECREF(v);
|
||||
return NULL;
|
||||
}
|
||||
return v;
|
||||
|
||||
|
@ -3368,17 +3368,17 @@ string_decode(PyStringObject *self, PyObject *args)
|
|||
PyObject *v;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|ss:decode", &encoding, &errors))
|
||||
return NULL;
|
||||
return NULL;
|
||||
v = PyString_AsDecodedObject((PyObject *)self, encoding, errors);
|
||||
if (v == NULL)
|
||||
goto onError;
|
||||
goto onError;
|
||||
if (!PyString_Check(v) && !PyUnicode_Check(v)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"decoder did not return a string/unicode object "
|
||||
"(type=%.400s)",
|
||||
Py_TYPE(v)->tp_name);
|
||||
Py_DECREF(v);
|
||||
return NULL;
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"decoder did not return a string/unicode object "
|
||||
"(type=%.400s)",
|
||||
Py_TYPE(v)->tp_name);
|
||||
Py_DECREF(v);
|
||||
return NULL;
|
||||
}
|
||||
return v;
|
||||
|
||||
|
@ -3403,7 +3403,7 @@ string_expandtabs(PyStringObject *self, PyObject *args)
|
|||
int tabsize = 8;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|i:expandtabs", &tabsize))
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
/* First pass: determine size of output string */
|
||||
i = 0; /* chars up to and including most recent \n or \r */
|
||||
|
@ -3412,31 +3412,31 @@ string_expandtabs(PyStringObject *self, PyObject *args)
|
|||
for (p = PyString_AS_STRING(self); p < e; p++)
|
||||
if (*p == '\t') {
|
||||
if (tabsize > 0) {
|
||||
incr = tabsize - (j % tabsize);
|
||||
if (j > PY_SSIZE_T_MAX - incr)
|
||||
goto overflow1;
|
||||
j += incr;
|
||||
incr = tabsize - (j % tabsize);
|
||||
if (j > PY_SSIZE_T_MAX - incr)
|
||||
goto overflow1;
|
||||
j += incr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (j > PY_SSIZE_T_MAX - 1)
|
||||
goto overflow1;
|
||||
goto overflow1;
|
||||
j++;
|
||||
if (*p == '\n' || *p == '\r') {
|
||||
if (i > PY_SSIZE_T_MAX - j)
|
||||
goto overflow1;
|
||||
i += j;
|
||||
j = 0;
|
||||
if (i > PY_SSIZE_T_MAX - j)
|
||||
goto overflow1;
|
||||
i += j;
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (i > PY_SSIZE_T_MAX - j)
|
||||
goto overflow1;
|
||||
goto overflow1;
|
||||
|
||||
/* Second pass: create output string and fill it */
|
||||
u = PyString_FromStringAndSize(NULL, i + j);
|
||||
if (!u)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
j = 0; /* same as in first pass */
|
||||
q = PyString_AS_STRING(u); /* next output char */
|
||||
|
@ -3445,22 +3445,22 @@ string_expandtabs(PyStringObject *self, PyObject *args)
|
|||
for (p = PyString_AS_STRING(self); p < e; p++)
|
||||
if (*p == '\t') {
|
||||
if (tabsize > 0) {
|
||||
i = tabsize - (j % tabsize);
|
||||
j += i;
|
||||
while (i--) {
|
||||
if (q >= qe)
|
||||
goto overflow2;
|
||||
*q++ = ' ';
|
||||
}
|
||||
i = tabsize - (j % tabsize);
|
||||
j += i;
|
||||
while (i--) {
|
||||
if (q >= qe)
|
||||
goto overflow2;
|
||||
*q++ = ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (q >= qe)
|
||||
goto overflow2;
|
||||
goto overflow2;
|
||||
*q++ = *p;
|
||||
j++;
|
||||
if (*p == '\n' || *p == '\r')
|
||||
j = 0;
|
||||
j = 0;
|
||||
}
|
||||
|
||||
return u;
|
||||
|
@ -3478,26 +3478,26 @@ pad(PyStringObject *self, Py_ssize_t left, Py_ssize_t right, char fill)
|
|||
PyObject *u;
|
||||
|
||||
if (left < 0)
|
||||
left = 0;
|
||||
left = 0;
|
||||
if (right < 0)
|
||||
right = 0;
|
||||
right = 0;
|
||||
|
||||
if (left == 0 && right == 0 && PyString_CheckExact(self)) {
|
||||
Py_INCREF(self);
|
||||
return (PyObject *)self;
|
||||
Py_INCREF(self);
|
||||
return (PyObject *)self;
|
||||
}
|
||||
|
||||
u = PyString_FromStringAndSize(NULL,
|
||||
left + PyString_GET_SIZE(self) + right);
|
||||
if (u) {
|
||||
if (left)
|
||||
memset(PyString_AS_STRING(u), fill, left);
|
||||
Py_MEMCPY(PyString_AS_STRING(u) + left,
|
||||
PyString_AS_STRING(self),
|
||||
PyString_GET_SIZE(self));
|
||||
if (right)
|
||||
memset(PyString_AS_STRING(u) + left + PyString_GET_SIZE(self),
|
||||
fill, right);
|
||||
if (left)
|
||||
memset(PyString_AS_STRING(u), fill, left);
|
||||
Py_MEMCPY(PyString_AS_STRING(u) + left,
|
||||
PyString_AS_STRING(self),
|
||||
PyString_GET_SIZE(self));
|
||||
if (right)
|
||||
memset(PyString_AS_STRING(u) + left + PyString_GET_SIZE(self),
|
||||
fill, right);
|
||||
}
|
||||
|
||||
return u;
|
||||
|
@ -3516,11 +3516,11 @@ string_ljust(PyStringObject *self, PyObject *args)
|
|||
char fillchar = ' ';
|
||||
|
||||
if (!PyArg_ParseTuple(args, "n|c:ljust", &width, &fillchar))
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) {
|
||||
Py_INCREF(self);
|
||||
return (PyObject*) self;
|
||||
Py_INCREF(self);
|
||||
return (PyObject*) self;
|
||||
}
|
||||
|
||||
return pad(self, 0, width - PyString_GET_SIZE(self), fillchar);
|
||||
|
@ -3540,11 +3540,11 @@ string_rjust(PyStringObject *self, PyObject *args)
|
|||
char fillchar = ' ';
|
||||
|
||||
if (!PyArg_ParseTuple(args, "n|c:rjust", &width, &fillchar))
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) {
|
||||
Py_INCREF(self);
|
||||
return (PyObject*) self;
|
||||
Py_INCREF(self);
|
||||
return (PyObject*) self;
|
||||
}
|
||||
|
||||
return pad(self, width - PyString_GET_SIZE(self), 0, fillchar);
|
||||
|
@ -3565,11 +3565,11 @@ string_center(PyStringObject *self, PyObject *args)
|
|||
char fillchar = ' ';
|
||||
|
||||
if (!PyArg_ParseTuple(args, "n|c:center", &width, &fillchar))
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) {
|
||||
Py_INCREF(self);
|
||||
return (PyObject*) self;
|
||||
Py_INCREF(self);
|
||||
return (PyObject*) self;
|
||||
}
|
||||
|
||||
marg = width - PyString_GET_SIZE(self);
|
||||
|
@ -3593,18 +3593,18 @@ string_zfill(PyStringObject *self, PyObject *args)
|
|||
Py_ssize_t width;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "n:zfill", &width))
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
if (PyString_GET_SIZE(self) >= width) {
|
||||
if (PyString_CheckExact(self)) {
|
||||
Py_INCREF(self);
|
||||
return (PyObject*) self;
|
||||
}
|
||||
else
|
||||
return PyString_FromStringAndSize(
|
||||
PyString_AS_STRING(self),
|
||||
PyString_GET_SIZE(self)
|
||||
);
|
||||
if (PyString_CheckExact(self)) {
|
||||
Py_INCREF(self);
|
||||
return (PyObject*) self;
|
||||
}
|
||||
else
|
||||
return PyString_FromStringAndSize(
|
||||
PyString_AS_STRING(self),
|
||||
PyString_GET_SIZE(self)
|
||||
);
|
||||
}
|
||||
|
||||
fill = width - PyString_GET_SIZE(self);
|
||||
|
@ -3612,13 +3612,13 @@ string_zfill(PyStringObject *self, PyObject *args)
|
|||
s = pad(self, fill, 0, '0');
|
||||
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
p = PyString_AS_STRING(s);
|
||||
if (p[fill] == '+' || p[fill] == '-') {
|
||||
/* move sign to beginning of string */
|
||||
p[0] = p[fill];
|
||||
p[fill] = '0';
|
||||
/* move sign to beginning of string */
|
||||
p[0] = p[fill];
|
||||
p[fill] = '0';
|
||||
}
|
||||
|
||||
return (PyObject*) s;
|
||||
|
@ -3634,22 +3634,22 @@ static PyObject*
|
|||
string_isspace(PyStringObject *self)
|
||||
{
|
||||
register const unsigned char *p
|
||||
= (unsigned char *) PyString_AS_STRING(self);
|
||||
= (unsigned char *) PyString_AS_STRING(self);
|
||||
register const unsigned char *e;
|
||||
|
||||
/* Shortcut for single character strings */
|
||||
if (PyString_GET_SIZE(self) == 1 &&
|
||||
isspace(*p))
|
||||
return PyBool_FromLong(1);
|
||||
isspace(*p))
|
||||
return PyBool_FromLong(1);
|
||||
|
||||
/* Special case for empty strings */
|
||||
if (PyString_GET_SIZE(self) == 0)
|
||||
return PyBool_FromLong(0);
|
||||
return PyBool_FromLong(0);
|
||||
|
||||
e = p + PyString_GET_SIZE(self);
|
||||
for (; p < e; p++) {
|
||||
if (!isspace(*p))
|
||||
return PyBool_FromLong(0);
|
||||
if (!isspace(*p))
|
||||
return PyBool_FromLong(0);
|
||||
}
|
||||
return PyBool_FromLong(1);
|
||||
}
|
||||
|
@ -3665,22 +3665,22 @@ static PyObject*
|
|||
string_isalpha(PyStringObject *self)
|
||||
{
|
||||
register const unsigned char *p
|
||||
= (unsigned char *) PyString_AS_STRING(self);
|
||||
= (unsigned char *) PyString_AS_STRING(self);
|
||||
register const unsigned char *e;
|
||||
|
||||
/* Shortcut for single character strings */
|
||||
if (PyString_GET_SIZE(self) == 1 &&
|
||||
isalpha(*p))
|
||||
return PyBool_FromLong(1);
|
||||
isalpha(*p))
|
||||
return PyBool_FromLong(1);
|
||||
|
||||
/* Special case for empty strings */
|
||||
if (PyString_GET_SIZE(self) == 0)
|
||||
return PyBool_FromLong(0);
|
||||
return PyBool_FromLong(0);
|
||||
|
||||
e = p + PyString_GET_SIZE(self);
|
||||
for (; p < e; p++) {
|
||||
if (!isalpha(*p))
|
||||
return PyBool_FromLong(0);
|
||||
if (!isalpha(*p))
|
||||
return PyBool_FromLong(0);
|
||||
}
|
||||
return PyBool_FromLong(1);
|
||||
}
|
||||
|
@ -3696,22 +3696,22 @@ static PyObject*
|
|||
string_isalnum(PyStringObject *self)
|
||||
{
|
||||
register const unsigned char *p
|
||||
= (unsigned char *) PyString_AS_STRING(self);
|
||||
= (unsigned char *) PyString_AS_STRING(self);
|
||||
register const unsigned char *e;
|
||||
|
||||
/* Shortcut for single character strings */
|
||||
if (PyString_GET_SIZE(self) == 1 &&
|
||||
isalnum(*p))
|
||||
return PyBool_FromLong(1);
|
||||
isalnum(*p))
|
||||
return PyBool_FromLong(1);
|
||||
|
||||
/* Special case for empty strings */
|
||||
if (PyString_GET_SIZE(self) == 0)
|
||||
return PyBool_FromLong(0);
|
||||
return PyBool_FromLong(0);
|
||||
|
||||
e = p + PyString_GET_SIZE(self);
|
||||
for (; p < e; p++) {
|
||||
if (!isalnum(*p))
|
||||
return PyBool_FromLong(0);
|
||||
if (!isalnum(*p))
|
||||
return PyBool_FromLong(0);
|
||||
}
|
||||
return PyBool_FromLong(1);
|
||||
}
|
||||
|
@ -3727,22 +3727,22 @@ static PyObject*
|
|||
string_isdigit(PyStringObject *self)
|
||||
{
|
||||
register const unsigned char *p
|
||||
= (unsigned char *) PyString_AS_STRING(self);
|
||||
= (unsigned char *) PyString_AS_STRING(self);
|
||||
register const unsigned char *e;
|
||||
|
||||
/* Shortcut for single character strings */
|
||||
if (PyString_GET_SIZE(self) == 1 &&
|
||||
isdigit(*p))
|
||||
return PyBool_FromLong(1);
|
||||
isdigit(*p))
|
||||
return PyBool_FromLong(1);
|
||||
|
||||
/* Special case for empty strings */
|
||||
if (PyString_GET_SIZE(self) == 0)
|
||||
return PyBool_FromLong(0);
|
||||
return PyBool_FromLong(0);
|
||||
|
||||
e = p + PyString_GET_SIZE(self);
|
||||
for (; p < e; p++) {
|
||||
if (!isdigit(*p))
|
||||
return PyBool_FromLong(0);
|
||||
if (!isdigit(*p))
|
||||
return PyBool_FromLong(0);
|
||||
}
|
||||
return PyBool_FromLong(1);
|
||||
}
|
||||
|
@ -3758,25 +3758,25 @@ static PyObject*
|
|||
string_islower(PyStringObject *self)
|
||||
{
|
||||
register const unsigned char *p
|
||||
= (unsigned char *) PyString_AS_STRING(self);
|
||||
= (unsigned char *) PyString_AS_STRING(self);
|
||||
register const unsigned char *e;
|
||||
int cased;
|
||||
|
||||
/* Shortcut for single character strings */
|
||||
if (PyString_GET_SIZE(self) == 1)
|
||||
return PyBool_FromLong(islower(*p) != 0);
|
||||
return PyBool_FromLong(islower(*p) != 0);
|
||||
|
||||
/* Special case for empty strings */
|
||||
if (PyString_GET_SIZE(self) == 0)
|
||||
return PyBool_FromLong(0);
|
||||
return PyBool_FromLong(0);
|
||||
|
||||
e = p + PyString_GET_SIZE(self);
|
||||
cased = 0;
|
||||
for (; p < e; p++) {
|
||||
if (isupper(*p))
|
||||
return PyBool_FromLong(0);
|
||||
else if (!cased && islower(*p))
|
||||
cased = 1;
|
||||
if (isupper(*p))
|
||||
return PyBool_FromLong(0);
|
||||
else if (!cased && islower(*p))
|
||||
cased = 1;
|
||||
}
|
||||
return PyBool_FromLong(cased);
|
||||
}
|
||||
|
@ -3792,25 +3792,25 @@ static PyObject*
|
|||
string_isupper(PyStringObject *self)
|
||||
{
|
||||
register const unsigned char *p
|
||||
= (unsigned char *) PyString_AS_STRING(self);
|
||||
= (unsigned char *) PyString_AS_STRING(self);
|
||||
register const unsigned char *e;
|
||||
int cased;
|
||||
|
||||
/* Shortcut for single character strings */
|
||||
if (PyString_GET_SIZE(self) == 1)
|
||||
return PyBool_FromLong(isupper(*p) != 0);
|
||||
return PyBool_FromLong(isupper(*p) != 0);
|
||||
|
||||
/* Special case for empty strings */
|
||||
if (PyString_GET_SIZE(self) == 0)
|
||||
return PyBool_FromLong(0);
|
||||
return PyBool_FromLong(0);
|
||||
|
||||
e = p + PyString_GET_SIZE(self);
|
||||
cased = 0;
|
||||
for (; p < e; p++) {
|
||||
if (islower(*p))
|
||||
return PyBool_FromLong(0);
|
||||
else if (!cased && isupper(*p))
|
||||
cased = 1;
|
||||
if (islower(*p))
|
||||
return PyBool_FromLong(0);
|
||||
else if (!cased && isupper(*p))
|
||||
cased = 1;
|
||||
}
|
||||
return PyBool_FromLong(cased);
|
||||
}
|
||||
|
@ -3828,38 +3828,38 @@ static PyObject*
|
|||
string_istitle(PyStringObject *self, PyObject *uncased)
|
||||
{
|
||||
register const unsigned char *p
|
||||
= (unsigned char *) PyString_AS_STRING(self);
|
||||
= (unsigned char *) PyString_AS_STRING(self);
|
||||
register const unsigned char *e;
|
||||
int cased, previous_is_cased;
|
||||
|
||||
/* Shortcut for single character strings */
|
||||
if (PyString_GET_SIZE(self) == 1)
|
||||
return PyBool_FromLong(isupper(*p) != 0);
|
||||
return PyBool_FromLong(isupper(*p) != 0);
|
||||
|
||||
/* Special case for empty strings */
|
||||
if (PyString_GET_SIZE(self) == 0)
|
||||
return PyBool_FromLong(0);
|
||||
return PyBool_FromLong(0);
|
||||
|
||||
e = p + PyString_GET_SIZE(self);
|
||||
cased = 0;
|
||||
previous_is_cased = 0;
|
||||
for (; p < e; p++) {
|
||||
register const unsigned char ch = *p;
|
||||
register const unsigned char ch = *p;
|
||||
|
||||
if (isupper(ch)) {
|
||||
if (previous_is_cased)
|
||||
return PyBool_FromLong(0);
|
||||
previous_is_cased = 1;
|
||||
cased = 1;
|
||||
}
|
||||
else if (islower(ch)) {
|
||||
if (!previous_is_cased)
|
||||
return PyBool_FromLong(0);
|
||||
previous_is_cased = 1;
|
||||
cased = 1;
|
||||
}
|
||||
else
|
||||
previous_is_cased = 0;
|
||||
if (isupper(ch)) {
|
||||
if (previous_is_cased)
|
||||
return PyBool_FromLong(0);
|
||||
previous_is_cased = 1;
|
||||
cased = 1;
|
||||
}
|
||||
else if (islower(ch)) {
|
||||
if (!previous_is_cased)
|
||||
return PyBool_FromLong(0);
|
||||
previous_is_cased = 1;
|
||||
cased = 1;
|
||||
}
|
||||
else
|
||||
previous_is_cased = 0;
|
||||
}
|
||||
return PyBool_FromLong(cased);
|
||||
}
|
||||
|
@ -3884,7 +3884,7 @@ string_splitlines(PyStringObject *self, PyObject *args)
|
|||
char *data;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|i:splitlines", &keepends))
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
data = PyString_AS_STRING(self);
|
||||
len = PyString_GET_SIZE(self);
|
||||
|
@ -3899,31 +3899,31 @@ string_splitlines(PyStringObject *self, PyObject *args)
|
|||
|
||||
list = PyList_New(0);
|
||||
if (!list)
|
||||
goto onError;
|
||||
goto onError;
|
||||
|
||||
for (i = j = 0; i < len; ) {
|
||||
Py_ssize_t eol;
|
||||
Py_ssize_t eol;
|
||||
|
||||
/* Find a line and append it */
|
||||
while (i < len && data[i] != '\n' && data[i] != '\r')
|
||||
i++;
|
||||
/* Find a line and append it */
|
||||
while (i < len && data[i] != '\n' && data[i] != '\r')
|
||||
i++;
|
||||
|
||||
/* Skip the line break reading CRLF as one line break */
|
||||
eol = i;
|
||||
if (i < len) {
|
||||
if (data[i] == '\r' && i + 1 < len &&
|
||||
data[i+1] == '\n')
|
||||
i += 2;
|
||||
else
|
||||
i++;
|
||||
if (keepends)
|
||||
/* Skip the line break reading CRLF as one line break */
|
||||
eol = i;
|
||||
}
|
||||
SPLIT_APPEND(data, j, eol);
|
||||
j = i;
|
||||
if (i < len) {
|
||||
if (data[i] == '\r' && i + 1 < len &&
|
||||
data[i+1] == '\n')
|
||||
i += 2;
|
||||
else
|
||||
i++;
|
||||
if (keepends)
|
||||
eol = i;
|
||||
}
|
||||
SPLIT_APPEND(data, j, eol);
|
||||
j = i;
|
||||
}
|
||||
if (j < len) {
|
||||
SPLIT_APPEND(data, j, len);
|
||||
SPLIT_APPEND(data, j, len);
|
||||
}
|
||||
|
||||
return list;
|
||||
|
@ -3973,15 +3973,15 @@ string__format__(PyObject* self, PyObject* args)
|
|||
/* If 2.x, convert format_spec to the same type as value */
|
||||
/* This is to allow things like u''.format('') */
|
||||
if (!PyArg_ParseTuple(args, "O:__format__", &format_spec))
|
||||
goto done;
|
||||
goto done;
|
||||
if (!(PyString_Check(format_spec) || PyUnicode_Check(format_spec))) {
|
||||
PyErr_Format(PyExc_TypeError, "__format__ arg must be str "
|
||||
"or unicode, not %s", Py_TYPE(format_spec)->tp_name);
|
||||
goto done;
|
||||
PyErr_Format(PyExc_TypeError, "__format__ arg must be str "
|
||||
"or unicode, not %s", Py_TYPE(format_spec)->tp_name);
|
||||
goto done;
|
||||
}
|
||||
tmp = PyObject_Str(format_spec);
|
||||
if (tmp == NULL)
|
||||
goto done;
|
||||
goto done;
|
||||
format_spec = tmp;
|
||||
|
||||
result = _PyBytes_FormatAdvanced(self,
|
||||
|
|
Loading…
Reference in New Issue