aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Modules/cjkcodecs
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:30 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:30 +0300
commit2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch)
tree012bb94d777798f1f56ac1cec429509766d05181 /contrib/tools/python3/src/Modules/cjkcodecs
parent6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff)
downloadydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Modules/cjkcodecs')
-rw-r--r--contrib/tools/python3/src/Modules/cjkcodecs/_codecs_cn.c44
-rw-r--r--contrib/tools/python3/src/Modules/cjkcodecs/cjkcodecs.h46
-rw-r--r--contrib/tools/python3/src/Modules/cjkcodecs/clinic/multibytecodec.c.h448
-rw-r--r--contrib/tools/python3/src/Modules/cjkcodecs/mappings_cn.h2
-rw-r--r--contrib/tools/python3/src/Modules/cjkcodecs/mappings_jisx0213_pair.h2
-rw-r--r--contrib/tools/python3/src/Modules/cjkcodecs/mappings_jp.h2
-rw-r--r--contrib/tools/python3/src/Modules/cjkcodecs/mappings_kr.h4
-rw-r--r--contrib/tools/python3/src/Modules/cjkcodecs/multibytecodec.c394
-rw-r--r--contrib/tools/python3/src/Modules/cjkcodecs/multibytecodec.h20
9 files changed, 481 insertions, 481 deletions
diff --git a/contrib/tools/python3/src/Modules/cjkcodecs/_codecs_cn.c b/contrib/tools/python3/src/Modules/cjkcodecs/_codecs_cn.c
index 8a62f7e257..8acabfea3b 100644
--- a/contrib/tools/python3/src/Modules/cjkcodecs/_codecs_cn.c
+++ b/contrib/tools/python3/src/Modules/cjkcodecs/_codecs_cn.c
@@ -52,12 +52,12 @@
}
/*
- * codecs in this file use the first byte of MultibyteCodec_State.c[8]
- * to store a 0 or 1 state value
- */
-#define CN_STATE_OFFSET 0
-
-/*
+ * codecs in this file use the first byte of MultibyteCodec_State.c[8]
+ * to store a 0 or 1 state value
+ */
+#define CN_STATE_OFFSET 0
+
+/*
* GB2312 codec
*/
@@ -335,15 +335,15 @@ DECODER(gb18030)
ENCODER_INIT(hz)
{
- state->c[CN_STATE_OFFSET] = 0;
+ state->c[CN_STATE_OFFSET] = 0;
return 0;
}
ENCODER_RESET(hz)
{
- if (state->c[CN_STATE_OFFSET] != 0) {
+ if (state->c[CN_STATE_OFFSET] != 0) {
WRITEBYTE2('~', '}');
- state->c[CN_STATE_OFFSET] = 0;
+ state->c[CN_STATE_OFFSET] = 0;
NEXT_OUT(2);
}
return 0;
@@ -356,10 +356,10 @@ ENCODER(hz)
DBCHAR code;
if (c < 0x80) {
- if (state->c[CN_STATE_OFFSET]) {
+ if (state->c[CN_STATE_OFFSET]) {
WRITEBYTE2('~', '}');
NEXT_OUT(2);
- state->c[CN_STATE_OFFSET] = 0;
+ state->c[CN_STATE_OFFSET] = 0;
}
WRITEBYTE1((unsigned char)c);
NEXT(1, 1);
@@ -381,10 +381,10 @@ ENCODER(hz)
if (code & 0x8000) /* MSB set: GBK */
return 1;
- if (state->c[CN_STATE_OFFSET] == 0) {
+ if (state->c[CN_STATE_OFFSET] == 0) {
WRITEBYTE4('~', '{', code >> 8, code & 0xff);
NEXT(1, 4);
- state->c[CN_STATE_OFFSET] = 1;
+ state->c[CN_STATE_OFFSET] = 1;
}
else {
WRITEBYTE2(code >> 8, code & 0xff);
@@ -397,13 +397,13 @@ ENCODER(hz)
DECODER_INIT(hz)
{
- state->c[CN_STATE_OFFSET] = 0;
+ state->c[CN_STATE_OFFSET] = 0;
return 0;
}
DECODER_RESET(hz)
{
- state->c[CN_STATE_OFFSET] = 0;
+ state->c[CN_STATE_OFFSET] = 0;
return 0;
}
@@ -417,14 +417,14 @@ DECODER(hz)
unsigned char c2 = INBYTE2;
REQUIRE_INBUF(2);
- if (c2 == '~' && state->c[CN_STATE_OFFSET] == 0)
+ if (c2 == '~' && state->c[CN_STATE_OFFSET] == 0)
OUTCHAR('~');
- else if (c2 == '{' && state->c[CN_STATE_OFFSET] == 0)
- state->c[CN_STATE_OFFSET] = 1; /* set GB */
- else if (c2 == '\n' && state->c[CN_STATE_OFFSET] == 0)
+ else if (c2 == '{' && state->c[CN_STATE_OFFSET] == 0)
+ state->c[CN_STATE_OFFSET] = 1; /* set GB */
+ else if (c2 == '\n' && state->c[CN_STATE_OFFSET] == 0)
; /* line-continuation */
- else if (c2 == '}' && state->c[CN_STATE_OFFSET] == 1)
- state->c[CN_STATE_OFFSET] = 0; /* set ASCII */
+ else if (c2 == '}' && state->c[CN_STATE_OFFSET] == 1)
+ state->c[CN_STATE_OFFSET] = 0; /* set ASCII */
else
return 1;
NEXT_IN(2);
@@ -434,7 +434,7 @@ DECODER(hz)
if (c & 0x80)
return 1;
- if (state->c[CN_STATE_OFFSET] == 0) { /* ASCII mode */
+ if (state->c[CN_STATE_OFFSET] == 0) { /* ASCII mode */
OUTCHAR(c);
NEXT_IN(1);
}
diff --git a/contrib/tools/python3/src/Modules/cjkcodecs/cjkcodecs.h b/contrib/tools/python3/src/Modules/cjkcodecs/cjkcodecs.h
index e41755b197..949856cc9d 100644
--- a/contrib/tools/python3/src/Modules/cjkcodecs/cjkcodecs.h
+++ b/contrib/tools/python3/src/Modules/cjkcodecs/cjkcodecs.h
@@ -72,7 +72,7 @@ static const struct dbcs_map *mapping_list;
#define ENCODER(encoding) \
static Py_ssize_t encoding##_encode( \
MultibyteCodec_State *state, const void *config, \
- int kind, const void *data, \
+ int kind, const void *data, \
Py_ssize_t *inpos, Py_ssize_t inlen, \
unsigned char **outbuf, Py_ssize_t outleft, int flags)
#define ENCODER_RESET(encoding) \
@@ -149,42 +149,42 @@ static const struct dbcs_map *mapping_list;
writer->pos += 2; \
} while (0)
-#define OUTBYTEI(c, i) \
- do { \
- assert((unsigned char)(c) == (c)); \
- ((*outbuf)[i]) = (c); \
- } while (0)
-
-#define OUTBYTE1(c) OUTBYTEI(c, 0)
-#define OUTBYTE2(c) OUTBYTEI(c, 1)
-#define OUTBYTE3(c) OUTBYTEI(c, 2)
-#define OUTBYTE4(c) OUTBYTEI(c, 3)
-
+#define OUTBYTEI(c, i) \
+ do { \
+ assert((unsigned char)(c) == (c)); \
+ ((*outbuf)[i]) = (c); \
+ } while (0)
+
+#define OUTBYTE1(c) OUTBYTEI(c, 0)
+#define OUTBYTE2(c) OUTBYTEI(c, 1)
+#define OUTBYTE3(c) OUTBYTEI(c, 2)
+#define OUTBYTE4(c) OUTBYTEI(c, 3)
+
#define WRITEBYTE1(c1) \
do { \
REQUIRE_OUTBUF(1); \
- OUTBYTE1(c1); \
+ OUTBYTE1(c1); \
} while (0)
#define WRITEBYTE2(c1, c2) \
do { \
REQUIRE_OUTBUF(2); \
- OUTBYTE1(c1); \
- OUTBYTE2(c2); \
+ OUTBYTE1(c1); \
+ OUTBYTE2(c2); \
} while (0)
#define WRITEBYTE3(c1, c2, c3) \
do { \
REQUIRE_OUTBUF(3); \
- OUTBYTE1(c1); \
- OUTBYTE2(c2); \
- OUTBYTE3(c3); \
+ OUTBYTE1(c1); \
+ OUTBYTE2(c2); \
+ OUTBYTE3(c3); \
} while (0)
#define WRITEBYTE4(c1, c2, c3, c4) \
do { \
REQUIRE_OUTBUF(4); \
- OUTBYTE1(c1); \
- OUTBYTE2(c2); \
- OUTBYTE3(c3); \
- OUTBYTE4(c4); \
+ OUTBYTE1(c1); \
+ OUTBYTE2(c2); \
+ OUTBYTE3(c3); \
+ OUTBYTE4(c4); \
} while (0)
#define _TRYMAP_ENC(m, assi, val) \
@@ -291,7 +291,7 @@ getcodec(PyObject *self, PyObject *encoding)
if (codecobj == NULL)
return NULL;
- r = PyObject_CallOneArg(cofunc, codecobj);
+ r = PyObject_CallOneArg(cofunc, codecobj);
Py_DECREF(codecobj);
return r;
diff --git a/contrib/tools/python3/src/Modules/cjkcodecs/clinic/multibytecodec.c.h b/contrib/tools/python3/src/Modules/cjkcodecs/clinic/multibytecodec.c.h
index 5ddbbe221b..93141baf6a 100644
--- a/contrib/tools/python3/src/Modules/cjkcodecs/clinic/multibytecodec.c.h
+++ b/contrib/tools/python3/src/Modules/cjkcodecs/clinic/multibytecodec.c.h
@@ -14,7 +14,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteCodec_encode__doc__,
"registered with codecs.register_error that can handle UnicodeEncodeErrors.");
#define _MULTIBYTECODEC_MULTIBYTECODEC_ENCODE_METHODDEF \
- {"encode", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteCodec_encode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteCodec_encode__doc__},
+ {"encode", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteCodec_encode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteCodec_encode__doc__},
static PyObject *
_multibytecodec_MultibyteCodec_encode_impl(MultibyteCodecObject *self,
@@ -26,39 +26,39 @@ _multibytecodec_MultibyteCodec_encode(MultibyteCodecObject *self, PyObject *cons
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"input", "errors", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "encode", 0};
- PyObject *argsbuf[2];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
+ static _PyArg_Parser _parser = {NULL, _keywords, "encode", 0};
+ PyObject *argsbuf[2];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *input;
const char *errors = NULL;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
- if (!args) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
+ if (!args) {
goto exit;
}
- input = args[0];
- if (!noptargs) {
- goto skip_optional_pos;
- }
- if (args[1] == Py_None) {
- errors = NULL;
- }
- else if (PyUnicode_Check(args[1])) {
- Py_ssize_t errors_length;
- errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
- if (errors == NULL) {
- goto exit;
- }
- if (strlen(errors) != (size_t)errors_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- }
- else {
- _PyArg_BadArgument("encode", "argument 'errors'", "str or None", args[1]);
- goto exit;
- }
-skip_optional_pos:
+ input = args[0];
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("encode", "argument 'errors'", "str or None", args[1]);
+ goto exit;
+ }
+skip_optional_pos:
return_value = _multibytecodec_MultibyteCodec_encode_impl(self, input, errors);
exit:
@@ -77,7 +77,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteCodec_decode__doc__,
"codecs.register_error that is able to handle UnicodeDecodeErrors.\"");
#define _MULTIBYTECODEC_MULTIBYTECODEC_DECODE_METHODDEF \
- {"decode", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteCodec_decode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteCodec_decode__doc__},
+ {"decode", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteCodec_decode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteCodec_decode__doc__},
static PyObject *
_multibytecodec_MultibyteCodec_decode_impl(MultibyteCodecObject *self,
@@ -89,45 +89,45 @@ _multibytecodec_MultibyteCodec_decode(MultibyteCodecObject *self, PyObject *cons
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"input", "errors", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0};
- PyObject *argsbuf[2];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
+ static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0};
+ PyObject *argsbuf[2];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
Py_buffer input = {NULL, NULL};
const char *errors = NULL;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (PyObject_GetBuffer(args[0], &input, PyBUF_SIMPLE) != 0) {
- goto exit;
- }
- if (!PyBuffer_IsContiguous(&input, 'C')) {
- _PyArg_BadArgument("decode", "argument 'input'", "contiguous buffer", args[0]);
- goto exit;
- }
- if (!noptargs) {
- goto skip_optional_pos;
- }
- if (args[1] == Py_None) {
- errors = NULL;
- }
- else if (PyUnicode_Check(args[1])) {
- Py_ssize_t errors_length;
- errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
- if (errors == NULL) {
- goto exit;
- }
- if (strlen(errors) != (size_t)errors_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- }
- else {
- _PyArg_BadArgument("decode", "argument 'errors'", "str or None", args[1]);
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
+ if (!args) {
goto exit;
}
-skip_optional_pos:
+ if (PyObject_GetBuffer(args[0], &input, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&input, 'C')) {
+ _PyArg_BadArgument("decode", "argument 'input'", "contiguous buffer", args[0]);
+ goto exit;
+ }
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (args[1] == Py_None) {
+ errors = NULL;
+ }
+ else if (PyUnicode_Check(args[1])) {
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("decode", "argument 'errors'", "str or None", args[1]);
+ goto exit;
+ }
+skip_optional_pos:
return_value = _multibytecodec_MultibyteCodec_decode_impl(self, &input, errors);
exit:
@@ -145,7 +145,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_encode__doc__,
"\n");
#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_ENCODE_METHODDEF \
- {"encode", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteIncrementalEncoder_encode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteIncrementalEncoder_encode__doc__},
+ {"encode", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteIncrementalEncoder_encode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteIncrementalEncoder_encode__doc__},
static PyObject *
_multibytecodec_MultibyteIncrementalEncoder_encode_impl(MultibyteIncrementalEncoderObject *self,
@@ -157,82 +157,82 @@ _multibytecodec_MultibyteIncrementalEncoder_encode(MultibyteIncrementalEncoderOb
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"input", "final", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "encode", 0};
- PyObject *argsbuf[2];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
+ static _PyArg_Parser _parser = {NULL, _keywords, "encode", 0};
+ PyObject *argsbuf[2];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *input;
int final = 0;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- input = args[0];
- if (!noptargs) {
- goto skip_optional_pos;
- }
- if (PyFloat_Check(args[1])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
+ if (!args) {
goto exit;
}
- final = _PyLong_AsInt(args[1]);
- if (final == -1 && PyErr_Occurred()) {
- goto exit;
- }
-skip_optional_pos:
+ input = args[0];
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ final = _PyLong_AsInt(args[1]);
+ if (final == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional_pos:
return_value = _multibytecodec_MultibyteIncrementalEncoder_encode_impl(self, input, final);
exit:
return return_value;
}
-PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_getstate__doc__,
-"getstate($self, /)\n"
-"--\n"
-"\n");
-
-#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_GETSTATE_METHODDEF \
- {"getstate", (PyCFunction)_multibytecodec_MultibyteIncrementalEncoder_getstate, METH_NOARGS, _multibytecodec_MultibyteIncrementalEncoder_getstate__doc__},
-
-static PyObject *
-_multibytecodec_MultibyteIncrementalEncoder_getstate_impl(MultibyteIncrementalEncoderObject *self);
-
-static PyObject *
-_multibytecodec_MultibyteIncrementalEncoder_getstate(MultibyteIncrementalEncoderObject *self, PyObject *Py_UNUSED(ignored))
-{
- return _multibytecodec_MultibyteIncrementalEncoder_getstate_impl(self);
-}
-
-PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_setstate__doc__,
-"setstate($self, state, /)\n"
-"--\n"
-"\n");
-
-#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_SETSTATE_METHODDEF \
- {"setstate", (PyCFunction)_multibytecodec_MultibyteIncrementalEncoder_setstate, METH_O, _multibytecodec_MultibyteIncrementalEncoder_setstate__doc__},
-
-static PyObject *
-_multibytecodec_MultibyteIncrementalEncoder_setstate_impl(MultibyteIncrementalEncoderObject *self,
- PyLongObject *statelong);
-
-static PyObject *
-_multibytecodec_MultibyteIncrementalEncoder_setstate(MultibyteIncrementalEncoderObject *self, PyObject *arg)
-{
- PyObject *return_value = NULL;
- PyLongObject *statelong;
-
- if (!PyLong_Check(arg)) {
- _PyArg_BadArgument("setstate", "argument", "int", arg);
- goto exit;
- }
- statelong = (PyLongObject *)arg;
- return_value = _multibytecodec_MultibyteIncrementalEncoder_setstate_impl(self, statelong);
-
-exit:
- return return_value;
-}
-
+PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_getstate__doc__,
+"getstate($self, /)\n"
+"--\n"
+"\n");
+
+#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_GETSTATE_METHODDEF \
+ {"getstate", (PyCFunction)_multibytecodec_MultibyteIncrementalEncoder_getstate, METH_NOARGS, _multibytecodec_MultibyteIncrementalEncoder_getstate__doc__},
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalEncoder_getstate_impl(MultibyteIncrementalEncoderObject *self);
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalEncoder_getstate(MultibyteIncrementalEncoderObject *self, PyObject *Py_UNUSED(ignored))
+{
+ return _multibytecodec_MultibyteIncrementalEncoder_getstate_impl(self);
+}
+
+PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_setstate__doc__,
+"setstate($self, state, /)\n"
+"--\n"
+"\n");
+
+#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_SETSTATE_METHODDEF \
+ {"setstate", (PyCFunction)_multibytecodec_MultibyteIncrementalEncoder_setstate, METH_O, _multibytecodec_MultibyteIncrementalEncoder_setstate__doc__},
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalEncoder_setstate_impl(MultibyteIncrementalEncoderObject *self,
+ PyLongObject *statelong);
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalEncoder_setstate(MultibyteIncrementalEncoderObject *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ PyLongObject *statelong;
+
+ if (!PyLong_Check(arg)) {
+ _PyArg_BadArgument("setstate", "argument", "int", arg);
+ goto exit;
+ }
+ statelong = (PyLongObject *)arg;
+ return_value = _multibytecodec_MultibyteIncrementalEncoder_setstate_impl(self, statelong);
+
+exit:
+ return return_value;
+}
+
PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_reset__doc__,
"reset($self, /)\n"
"--\n"
@@ -256,7 +256,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_decode__doc__,
"\n");
#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_DECODE_METHODDEF \
- {"decode", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteIncrementalDecoder_decode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteIncrementalDecoder_decode__doc__},
+ {"decode", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteIncrementalDecoder_decode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteIncrementalDecoder_decode__doc__},
static PyObject *
_multibytecodec_MultibyteIncrementalDecoder_decode_impl(MultibyteIncrementalDecoderObject *self,
@@ -268,36 +268,36 @@ _multibytecodec_MultibyteIncrementalDecoder_decode(MultibyteIncrementalDecoderOb
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"input", "final", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0};
- PyObject *argsbuf[2];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
+ static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0};
+ PyObject *argsbuf[2];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
Py_buffer input = {NULL, NULL};
int final = 0;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
- if (!args) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
+ if (!args) {
goto exit;
}
- if (PyObject_GetBuffer(args[0], &input, PyBUF_SIMPLE) != 0) {
- goto exit;
- }
- if (!PyBuffer_IsContiguous(&input, 'C')) {
- _PyArg_BadArgument("decode", "argument 'input'", "contiguous buffer", args[0]);
- goto exit;
- }
- if (!noptargs) {
- goto skip_optional_pos;
- }
- if (PyFloat_Check(args[1])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
- final = _PyLong_AsInt(args[1]);
- if (final == -1 && PyErr_Occurred()) {
- goto exit;
- }
-skip_optional_pos:
+ if (PyObject_GetBuffer(args[0], &input, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&input, 'C')) {
+ _PyArg_BadArgument("decode", "argument 'input'", "contiguous buffer", args[0]);
+ goto exit;
+ }
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ final = _PyLong_AsInt(args[1]);
+ if (final == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional_pos:
return_value = _multibytecodec_MultibyteIncrementalDecoder_decode_impl(self, &input, final);
exit:
@@ -309,52 +309,52 @@ exit:
return return_value;
}
-PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_getstate__doc__,
-"getstate($self, /)\n"
-"--\n"
-"\n");
-
-#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_GETSTATE_METHODDEF \
- {"getstate", (PyCFunction)_multibytecodec_MultibyteIncrementalDecoder_getstate, METH_NOARGS, _multibytecodec_MultibyteIncrementalDecoder_getstate__doc__},
-
-static PyObject *
-_multibytecodec_MultibyteIncrementalDecoder_getstate_impl(MultibyteIncrementalDecoderObject *self);
-
-static PyObject *
-_multibytecodec_MultibyteIncrementalDecoder_getstate(MultibyteIncrementalDecoderObject *self, PyObject *Py_UNUSED(ignored))
-{
- return _multibytecodec_MultibyteIncrementalDecoder_getstate_impl(self);
-}
-
-PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_setstate__doc__,
-"setstate($self, state, /)\n"
-"--\n"
-"\n");
-
-#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_SETSTATE_METHODDEF \
- {"setstate", (PyCFunction)_multibytecodec_MultibyteIncrementalDecoder_setstate, METH_O, _multibytecodec_MultibyteIncrementalDecoder_setstate__doc__},
-
-static PyObject *
-_multibytecodec_MultibyteIncrementalDecoder_setstate_impl(MultibyteIncrementalDecoderObject *self,
- PyObject *state);
-
-static PyObject *
-_multibytecodec_MultibyteIncrementalDecoder_setstate(MultibyteIncrementalDecoderObject *self, PyObject *arg)
-{
- PyObject *return_value = NULL;
- PyObject *state;
-
- if (!PyTuple_Check(arg)) {
- _PyArg_BadArgument("setstate", "argument", "tuple", arg);
- goto exit;
- }
- state = arg;
- return_value = _multibytecodec_MultibyteIncrementalDecoder_setstate_impl(self, state);
-
-exit:
- return return_value;
-}
-
+PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_getstate__doc__,
+"getstate($self, /)\n"
+"--\n"
+"\n");
+
+#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_GETSTATE_METHODDEF \
+ {"getstate", (PyCFunction)_multibytecodec_MultibyteIncrementalDecoder_getstate, METH_NOARGS, _multibytecodec_MultibyteIncrementalDecoder_getstate__doc__},
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalDecoder_getstate_impl(MultibyteIncrementalDecoderObject *self);
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalDecoder_getstate(MultibyteIncrementalDecoderObject *self, PyObject *Py_UNUSED(ignored))
+{
+ return _multibytecodec_MultibyteIncrementalDecoder_getstate_impl(self);
+}
+
+PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_setstate__doc__,
+"setstate($self, state, /)\n"
+"--\n"
+"\n");
+
+#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_SETSTATE_METHODDEF \
+ {"setstate", (PyCFunction)_multibytecodec_MultibyteIncrementalDecoder_setstate, METH_O, _multibytecodec_MultibyteIncrementalDecoder_setstate__doc__},
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalDecoder_setstate_impl(MultibyteIncrementalDecoderObject *self,
+ PyObject *state);
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalDecoder_setstate(MultibyteIncrementalDecoderObject *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ PyObject *state;
+
+ if (!PyTuple_Check(arg)) {
+ _PyArg_BadArgument("setstate", "argument", "tuple", arg);
+ goto exit;
+ }
+ state = arg;
+ return_value = _multibytecodec_MultibyteIncrementalDecoder_setstate_impl(self, state);
+
+exit:
+ return return_value;
+}
+
PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_reset__doc__,
"reset($self, /)\n"
"--\n"
@@ -378,7 +378,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_read__doc__,
"\n");
#define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READ_METHODDEF \
- {"read", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteStreamReader_read, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_read__doc__},
+ {"read", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteStreamReader_read, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_read__doc__},
static PyObject *
_multibytecodec_MultibyteStreamReader_read_impl(MultibyteStreamReaderObject *self,
@@ -390,14 +390,14 @@ _multibytecodec_MultibyteStreamReader_read(MultibyteStreamReaderObject *self, Py
PyObject *return_value = NULL;
PyObject *sizeobj = Py_None;
- if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
+ if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
goto exit;
}
- if (nargs < 1) {
- goto skip_optional;
- }
- sizeobj = args[0];
-skip_optional:
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ sizeobj = args[0];
+skip_optional:
return_value = _multibytecodec_MultibyteStreamReader_read_impl(self, sizeobj);
exit:
@@ -410,7 +410,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_readline__doc__,
"\n");
#define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READLINE_METHODDEF \
- {"readline", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteStreamReader_readline, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_readline__doc__},
+ {"readline", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteStreamReader_readline, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_readline__doc__},
static PyObject *
_multibytecodec_MultibyteStreamReader_readline_impl(MultibyteStreamReaderObject *self,
@@ -422,14 +422,14 @@ _multibytecodec_MultibyteStreamReader_readline(MultibyteStreamReaderObject *self
PyObject *return_value = NULL;
PyObject *sizeobj = Py_None;
- if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
+ if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
goto exit;
}
- if (nargs < 1) {
- goto skip_optional;
- }
- sizeobj = args[0];
-skip_optional:
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ sizeobj = args[0];
+skip_optional:
return_value = _multibytecodec_MultibyteStreamReader_readline_impl(self, sizeobj);
exit:
@@ -442,7 +442,7 @@ PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_readlines__doc__,
"\n");
#define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READLINES_METHODDEF \
- {"readlines", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteStreamReader_readlines, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_readlines__doc__},
+ {"readlines", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteStreamReader_readlines, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_readlines__doc__},
static PyObject *
_multibytecodec_MultibyteStreamReader_readlines_impl(MultibyteStreamReaderObject *self,
@@ -454,14 +454,14 @@ _multibytecodec_MultibyteStreamReader_readlines(MultibyteStreamReaderObject *sel
PyObject *return_value = NULL;
PyObject *sizehintobj = Py_None;
- if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) {
+ if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) {
goto exit;
}
- if (nargs < 1) {
- goto skip_optional;
- }
- sizehintobj = args[0];
-skip_optional:
+ if (nargs < 1) {
+ goto skip_optional;
+ }
+ sizehintobj = args[0];
+skip_optional:
return_value = _multibytecodec_MultibyteStreamReader_readlines_impl(self, sizehintobj);
exit:
@@ -525,4 +525,4 @@ PyDoc_STRVAR(_multibytecodec___create_codec__doc__,
#define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \
{"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__},
-/*[clinic end generated code: output=5ce6fd4ca1f95620 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=5ce6fd4ca1f95620 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Modules/cjkcodecs/mappings_cn.h b/contrib/tools/python3/src/Modules/cjkcodecs/mappings_cn.h
index 87ca0de784..c4e244d25c 100644
--- a/contrib/tools/python3/src/Modules/cjkcodecs/mappings_cn.h
+++ b/contrib/tools/python3/src/Modules/cjkcodecs/mappings_cn.h
@@ -1,4 +1,4 @@
-// AUTO-GENERATED FILE FROM genmap_schinese.py: DO NOT EDIT
+// AUTO-GENERATED FILE FROM genmap_schinese.py: DO NOT EDIT
static const ucs2_t __gb2312_decmap[7482] = {
12288,12289,12290,12539,713,711,168,12291,12293,8213,65374,8214,8230,8216,
8217,8220,8221,12308,12309,12296,12297,12298,12299,12300,12301,12302,12303,
diff --git a/contrib/tools/python3/src/Modules/cjkcodecs/mappings_jisx0213_pair.h b/contrib/tools/python3/src/Modules/cjkcodecs/mappings_jisx0213_pair.h
index c96f20142b..8172ec2473 100644
--- a/contrib/tools/python3/src/Modules/cjkcodecs/mappings_jisx0213_pair.h
+++ b/contrib/tools/python3/src/Modules/cjkcodecs/mappings_jisx0213_pair.h
@@ -1,4 +1,4 @@
-// AUTO-GENERATED FILE FROM genmap_japanese.py: DO NOT EDIT
+// AUTO-GENERATED FILE FROM genmap_japanese.py: DO NOT EDIT
#define JISX0213_ENCPAIRS 46
#ifdef EXTERN_JISX0213_PAIR
static const struct widedbcs_index *jisx0213_pair_decmap;
diff --git a/contrib/tools/python3/src/Modules/cjkcodecs/mappings_jp.h b/contrib/tools/python3/src/Modules/cjkcodecs/mappings_jp.h
index 409aeae25c..74b8d88e39 100644
--- a/contrib/tools/python3/src/Modules/cjkcodecs/mappings_jp.h
+++ b/contrib/tools/python3/src/Modules/cjkcodecs/mappings_jp.h
@@ -1,4 +1,4 @@
-// AUTO-GENERATED FILE FROM genmap_japanese.py: DO NOT EDIT
+// AUTO-GENERATED FILE FROM genmap_japanese.py: DO NOT EDIT
static const ucs2_t __jisx0208_decmap[6956] = {
12288,12289,12290,65292,65294,12539,65306,65307,65311,65281,12443,12444,180,
65344,168,65342,65507,65343,12541,12542,12445,12446,12291,20189,12293,12294,
diff --git a/contrib/tools/python3/src/Modules/cjkcodecs/mappings_kr.h b/contrib/tools/python3/src/Modules/cjkcodecs/mappings_kr.h
index bb59acccc1..3a710aab20 100644
--- a/contrib/tools/python3/src/Modules/cjkcodecs/mappings_kr.h
+++ b/contrib/tools/python3/src/Modules/cjkcodecs/mappings_kr.h
@@ -1,4 +1,4 @@
-// AUTO-GENERATED FILE FROM genmap_korean.py: DO NOT EDIT
+// AUTO-GENERATED FILE FROM genmap_korean.py: DO NOT EDIT
static const ucs2_t __ksx1001_decmap[8264] = {
12288,12289,12290,183,8229,8230,168,12291,173,8213,8741,65340,8764,8216,8217,
8220,8221,12308,12309,12296,12297,12298,12299,12300,12301,12302,12303,12304,
@@ -3250,4 +3250,4 @@ __cp949_encmap+31959,0,255},{__cp949_encmap+32215,0,255},{__cp949_encmap+32471
__cp949_encmap+32891,0,11},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__cp949_encmap+
32903,1,230},
};
-
+
diff --git a/contrib/tools/python3/src/Modules/cjkcodecs/multibytecodec.c b/contrib/tools/python3/src/Modules/cjkcodecs/multibytecodec.c
index 86402768b6..b586836422 100644
--- a/contrib/tools/python3/src/Modules/cjkcodecs/multibytecodec.c
+++ b/contrib/tools/python3/src/Modules/cjkcodecs/multibytecodec.c
@@ -6,7 +6,7 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
-#include "structmember.h" // PyMemberDef
+#include "structmember.h" // PyMemberDef
#include "multibytecodec.h"
#include "clinic/multibytecodec.c.h"
@@ -81,7 +81,7 @@ internal_error_callback(const char *errors)
static PyObject *
call_error_callback(PyObject *errors, PyObject *exc)
{
- PyObject *cb, *r;
+ PyObject *cb, *r;
const char *str;
assert(PyUnicode_Check(errors));
@@ -92,7 +92,7 @@ call_error_callback(PyObject *errors, PyObject *exc)
if (cb == NULL)
return NULL;
- r = PyObject_CallOneArg(cb, exc);
+ r = PyObject_CallOneArg(cb, exc);
Py_DECREF(cb);
return r;
}
@@ -228,7 +228,7 @@ multibytecodec_encerror(MultibyteCodec *codec,
Py_ssize_t r;
Py_ssize_t inpos;
int kind;
- const void *data;
+ const void *data;
replchar = PyUnicode_FromOrdinal('?');
if (replchar == NULL)
@@ -457,7 +457,7 @@ multibytecodec_encode(MultibyteCodec *codec,
Py_ssize_t finalsize, r = 0;
Py_ssize_t datalen;
int kind;
- const void *data;
+ const void *data;
if (PyUnicode_READY(text) < 0)
return NULL;
@@ -538,7 +538,7 @@ errorexit:
_multibytecodec.MultibyteCodec.encode
input: object
- errors: str(accept={str, NoneType}) = None
+ errors: str(accept={str, NoneType}) = None
Return an encoded string version of `input'.
@@ -552,7 +552,7 @@ static PyObject *
_multibytecodec_MultibyteCodec_encode_impl(MultibyteCodecObject *self,
PyObject *input,
const char *errors)
-/*[clinic end generated code: output=7b26652045ba56a9 input=606d0e128a577bae]*/
+/*[clinic end generated code: output=7b26652045ba56a9 input=606d0e128a577bae]*/
{
MultibyteCodec_State state;
PyObject *errorcb, *r, *ucvt;
@@ -607,7 +607,7 @@ errorexit:
_multibytecodec.MultibyteCodec.decode
input: Py_buffer
- errors: str(accept={str, NoneType}) = None
+ errors: str(accept={str, NoneType}) = None
Decodes 'input'.
@@ -621,7 +621,7 @@ static PyObject *
_multibytecodec_MultibyteCodec_decode_impl(MultibyteCodecObject *self,
Py_buffer *input,
const char *errors)
-/*[clinic end generated code: output=ff419f65bad6cc77 input=e0c78fc7ab190def]*/
+/*[clinic end generated code: output=ff419f65bad6cc77 input=e0c78fc7ab190def]*/
{
MultibyteCodec_State state;
MultibyteDecodeBuffer buf;
@@ -701,10 +701,10 @@ static PyTypeObject MultibyteCodec_Type = {
0, /* tp_itemsize */
/* methods */
(destructor)multibytecodec_dealloc, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
+ 0, /* tp_vectorcall_offset */
0, /* tp_getattr */
0, /* tp_setattr */
- 0, /* tp_as_async */
+ 0, /* tp_as_async */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
@@ -890,93 +890,93 @@ _multibytecodec_MultibyteIncrementalEncoder_encode_impl(MultibyteIncrementalEnco
}
/*[clinic input]
-_multibytecodec.MultibyteIncrementalEncoder.getstate
-[clinic start generated code]*/
-
-static PyObject *
-_multibytecodec_MultibyteIncrementalEncoder_getstate_impl(MultibyteIncrementalEncoderObject *self)
-/*[clinic end generated code: output=9794a5ace70d7048 input=4a2a82874ffa40bb]*/
-{
- /* state made up of 1 byte for buffer size, up to MAXENCPENDING*4 bytes
- for UTF-8 encoded buffer (each character can use up to 4
- bytes), and required bytes for MultibyteCodec_State.c. A byte
- array is used to avoid different compilers generating different
- values for the same state, e.g. as a result of struct padding.
- */
- unsigned char statebytes[1 + MAXENCPENDING*4 + sizeof(self->state.c)];
- Py_ssize_t statesize;
- const char *pendingbuffer = NULL;
- Py_ssize_t pendingsize;
-
- if (self->pending != NULL) {
- pendingbuffer = PyUnicode_AsUTF8AndSize(self->pending, &pendingsize);
- if (pendingbuffer == NULL) {
- return NULL;
- }
- if (pendingsize > MAXENCPENDING*4) {
- PyErr_SetString(PyExc_UnicodeError, "pending buffer too large");
- return NULL;
- }
- statebytes[0] = (unsigned char)pendingsize;
- memcpy(statebytes + 1, pendingbuffer, pendingsize);
- statesize = 1 + pendingsize;
- } else {
- statebytes[0] = 0;
- statesize = 1;
- }
- memcpy(statebytes+statesize, self->state.c,
- sizeof(self->state.c));
- statesize += sizeof(self->state.c);
-
- return (PyObject *)_PyLong_FromByteArray(statebytes, statesize,
- 1 /* little-endian */ ,
- 0 /* unsigned */ );
-}
-
-/*[clinic input]
-_multibytecodec.MultibyteIncrementalEncoder.setstate
- state as statelong: object(type='PyLongObject *', subclass_of='&PyLong_Type')
- /
-[clinic start generated code]*/
-
-static PyObject *
-_multibytecodec_MultibyteIncrementalEncoder_setstate_impl(MultibyteIncrementalEncoderObject *self,
- PyLongObject *statelong)
-/*[clinic end generated code: output=4e5e98ac1f4039ca input=c80fb5830d4d2f76]*/
-{
- PyObject *pending = NULL;
- unsigned char statebytes[1 + MAXENCPENDING*4 + sizeof(self->state.c)];
-
- if (_PyLong_AsByteArray(statelong, statebytes, sizeof(statebytes),
- 1 /* little-endian */ ,
- 0 /* unsigned */ ) < 0) {
- goto errorexit;
- }
-
- if (statebytes[0] > MAXENCPENDING*4) {
- PyErr_SetString(PyExc_UnicodeError, "pending buffer too large");
- return NULL;
- }
-
- pending = PyUnicode_DecodeUTF8((const char *)statebytes+1,
- statebytes[0], "strict");
- if (pending == NULL) {
- goto errorexit;
- }
-
- Py_CLEAR(self->pending);
- self->pending = pending;
- memcpy(self->state.c, statebytes+1+statebytes[0],
- sizeof(self->state.c));
-
- Py_RETURN_NONE;
-
-errorexit:
- Py_XDECREF(pending);
- return NULL;
-}
-
-/*[clinic input]
+_multibytecodec.MultibyteIncrementalEncoder.getstate
+[clinic start generated code]*/
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalEncoder_getstate_impl(MultibyteIncrementalEncoderObject *self)
+/*[clinic end generated code: output=9794a5ace70d7048 input=4a2a82874ffa40bb]*/
+{
+ /* state made up of 1 byte for buffer size, up to MAXENCPENDING*4 bytes
+ for UTF-8 encoded buffer (each character can use up to 4
+ bytes), and required bytes for MultibyteCodec_State.c. A byte
+ array is used to avoid different compilers generating different
+ values for the same state, e.g. as a result of struct padding.
+ */
+ unsigned char statebytes[1 + MAXENCPENDING*4 + sizeof(self->state.c)];
+ Py_ssize_t statesize;
+ const char *pendingbuffer = NULL;
+ Py_ssize_t pendingsize;
+
+ if (self->pending != NULL) {
+ pendingbuffer = PyUnicode_AsUTF8AndSize(self->pending, &pendingsize);
+ if (pendingbuffer == NULL) {
+ return NULL;
+ }
+ if (pendingsize > MAXENCPENDING*4) {
+ PyErr_SetString(PyExc_UnicodeError, "pending buffer too large");
+ return NULL;
+ }
+ statebytes[0] = (unsigned char)pendingsize;
+ memcpy(statebytes + 1, pendingbuffer, pendingsize);
+ statesize = 1 + pendingsize;
+ } else {
+ statebytes[0] = 0;
+ statesize = 1;
+ }
+ memcpy(statebytes+statesize, self->state.c,
+ sizeof(self->state.c));
+ statesize += sizeof(self->state.c);
+
+ return (PyObject *)_PyLong_FromByteArray(statebytes, statesize,
+ 1 /* little-endian */ ,
+ 0 /* unsigned */ );
+}
+
+/*[clinic input]
+_multibytecodec.MultibyteIncrementalEncoder.setstate
+ state as statelong: object(type='PyLongObject *', subclass_of='&PyLong_Type')
+ /
+[clinic start generated code]*/
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalEncoder_setstate_impl(MultibyteIncrementalEncoderObject *self,
+ PyLongObject *statelong)
+/*[clinic end generated code: output=4e5e98ac1f4039ca input=c80fb5830d4d2f76]*/
+{
+ PyObject *pending = NULL;
+ unsigned char statebytes[1 + MAXENCPENDING*4 + sizeof(self->state.c)];
+
+ if (_PyLong_AsByteArray(statelong, statebytes, sizeof(statebytes),
+ 1 /* little-endian */ ,
+ 0 /* unsigned */ ) < 0) {
+ goto errorexit;
+ }
+
+ if (statebytes[0] > MAXENCPENDING*4) {
+ PyErr_SetString(PyExc_UnicodeError, "pending buffer too large");
+ return NULL;
+ }
+
+ pending = PyUnicode_DecodeUTF8((const char *)statebytes+1,
+ statebytes[0], "strict");
+ if (pending == NULL) {
+ goto errorexit;
+ }
+
+ Py_CLEAR(self->pending);
+ self->pending = pending;
+ memcpy(self->state.c, statebytes+1+statebytes[0],
+ sizeof(self->state.c));
+
+ Py_RETURN_NONE;
+
+errorexit:
+ Py_XDECREF(pending);
+ return NULL;
+}
+
+/*[clinic input]
_multibytecodec.MultibyteIncrementalEncoder.reset
[clinic start generated code]*/
@@ -1000,8 +1000,8 @@ _multibytecodec_MultibyteIncrementalEncoder_reset_impl(MultibyteIncrementalEncod
static struct PyMethodDef mbiencoder_methods[] = {
_MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_ENCODE_METHODDEF
- _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_GETSTATE_METHODDEF
- _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_SETSTATE_METHODDEF
+ _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_GETSTATE_METHODDEF
+ _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_SETSTATE_METHODDEF
_MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_RESET_METHODDEF
{NULL, NULL},
};
@@ -1067,7 +1067,7 @@ mbiencoder_dealloc(MultibyteIncrementalEncoderObject *self)
{
PyObject_GC_UnTrack(self);
ERROR_DECREF(self->errors);
- Py_CLEAR(self->pending);
+ Py_CLEAR(self->pending);
Py_TYPE(self)->tp_free(self);
}
@@ -1078,10 +1078,10 @@ static PyTypeObject MultibyteIncrementalEncoder_Type = {
0, /* tp_itemsize */
/* methods */
(destructor)mbiencoder_dealloc, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
+ 0, /* tp_vectorcall_offset */
0, /* tp_getattr */
0, /* tp_setattr */
- 0, /* tp_as_async */
+ 0, /* tp_as_async */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
@@ -1204,85 +1204,85 @@ errorexit:
}
/*[clinic input]
-_multibytecodec.MultibyteIncrementalDecoder.getstate
-[clinic start generated code]*/
-
-static PyObject *
-_multibytecodec_MultibyteIncrementalDecoder_getstate_impl(MultibyteIncrementalDecoderObject *self)
-/*[clinic end generated code: output=255009c4713b7f82 input=4006aa49bddbaa75]*/
-{
- PyObject *buffer;
- PyObject *statelong;
-
- buffer = PyBytes_FromStringAndSize((const char *)self->pending,
- self->pendingsize);
- if (buffer == NULL) {
- return NULL;
- }
-
- statelong = (PyObject *)_PyLong_FromByteArray(self->state.c,
- sizeof(self->state.c),
- 1 /* little-endian */ ,
- 0 /* unsigned */ );
- if (statelong == NULL) {
- Py_DECREF(buffer);
- return NULL;
- }
-
- return Py_BuildValue("NN", buffer, statelong);
-}
-
-/*[clinic input]
-_multibytecodec.MultibyteIncrementalDecoder.setstate
- state: object(subclass_of='&PyTuple_Type')
- /
-[clinic start generated code]*/
-
-static PyObject *
-_multibytecodec_MultibyteIncrementalDecoder_setstate_impl(MultibyteIncrementalDecoderObject *self,
- PyObject *state)
-/*[clinic end generated code: output=106b2fbca3e2dcc2 input=e5d794e8baba1a47]*/
-{
- PyObject *buffer;
- PyLongObject *statelong;
- Py_ssize_t buffersize;
- const char *bufferstr;
- unsigned char statebytes[8];
-
- if (!PyArg_ParseTuple(state, "SO!;setstate(): illegal state argument",
- &buffer, &PyLong_Type, &statelong))
- {
- return NULL;
- }
-
- if (_PyLong_AsByteArray(statelong, statebytes, sizeof(statebytes),
- 1 /* little-endian */ ,
- 0 /* unsigned */ ) < 0) {
- return NULL;
- }
-
- buffersize = PyBytes_Size(buffer);
- if (buffersize == -1) {
- return NULL;
- }
-
- if (buffersize > MAXDECPENDING) {
- PyErr_SetString(PyExc_UnicodeError, "pending buffer too large");
- return NULL;
- }
-
- bufferstr = PyBytes_AsString(buffer);
- if (bufferstr == NULL) {
- return NULL;
- }
- self->pendingsize = buffersize;
- memcpy(self->pending, bufferstr, self->pendingsize);
- memcpy(self->state.c, statebytes, sizeof(statebytes));
-
- Py_RETURN_NONE;
-}
-
-/*[clinic input]
+_multibytecodec.MultibyteIncrementalDecoder.getstate
+[clinic start generated code]*/
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalDecoder_getstate_impl(MultibyteIncrementalDecoderObject *self)
+/*[clinic end generated code: output=255009c4713b7f82 input=4006aa49bddbaa75]*/
+{
+ PyObject *buffer;
+ PyObject *statelong;
+
+ buffer = PyBytes_FromStringAndSize((const char *)self->pending,
+ self->pendingsize);
+ if (buffer == NULL) {
+ return NULL;
+ }
+
+ statelong = (PyObject *)_PyLong_FromByteArray(self->state.c,
+ sizeof(self->state.c),
+ 1 /* little-endian */ ,
+ 0 /* unsigned */ );
+ if (statelong == NULL) {
+ Py_DECREF(buffer);
+ return NULL;
+ }
+
+ return Py_BuildValue("NN", buffer, statelong);
+}
+
+/*[clinic input]
+_multibytecodec.MultibyteIncrementalDecoder.setstate
+ state: object(subclass_of='&PyTuple_Type')
+ /
+[clinic start generated code]*/
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalDecoder_setstate_impl(MultibyteIncrementalDecoderObject *self,
+ PyObject *state)
+/*[clinic end generated code: output=106b2fbca3e2dcc2 input=e5d794e8baba1a47]*/
+{
+ PyObject *buffer;
+ PyLongObject *statelong;
+ Py_ssize_t buffersize;
+ const char *bufferstr;
+ unsigned char statebytes[8];
+
+ if (!PyArg_ParseTuple(state, "SO!;setstate(): illegal state argument",
+ &buffer, &PyLong_Type, &statelong))
+ {
+ return NULL;
+ }
+
+ if (_PyLong_AsByteArray(statelong, statebytes, sizeof(statebytes),
+ 1 /* little-endian */ ,
+ 0 /* unsigned */ ) < 0) {
+ return NULL;
+ }
+
+ buffersize = PyBytes_Size(buffer);
+ if (buffersize == -1) {
+ return NULL;
+ }
+
+ if (buffersize > MAXDECPENDING) {
+ PyErr_SetString(PyExc_UnicodeError, "pending buffer too large");
+ return NULL;
+ }
+
+ bufferstr = PyBytes_AsString(buffer);
+ if (bufferstr == NULL) {
+ return NULL;
+ }
+ self->pendingsize = buffersize;
+ memcpy(self->pending, bufferstr, self->pendingsize);
+ memcpy(self->state.c, statebytes, sizeof(statebytes));
+
+ Py_RETURN_NONE;
+}
+
+/*[clinic input]
_multibytecodec.MultibyteIncrementalDecoder.reset
[clinic start generated code]*/
@@ -1300,8 +1300,8 @@ _multibytecodec_MultibyteIncrementalDecoder_reset_impl(MultibyteIncrementalDecod
static struct PyMethodDef mbidecoder_methods[] = {
_MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_DECODE_METHODDEF
- _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_GETSTATE_METHODDEF
- _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_SETSTATE_METHODDEF
+ _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_GETSTATE_METHODDEF
+ _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_SETSTATE_METHODDEF
_MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_RESET_METHODDEF
{NULL, NULL},
};
@@ -1377,10 +1377,10 @@ static PyTypeObject MultibyteIncrementalDecoder_Type = {
0, /* tp_itemsize */
/* methods */
(destructor)mbidecoder_dealloc, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
+ 0, /* tp_vectorcall_offset */
0, /* tp_getattr */
0, /* tp_setattr */
- 0, /* tp_as_async */
+ 0, /* tp_as_async */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
@@ -1450,7 +1450,7 @@ mbstreamreader_iread(MultibyteStreamReaderObject *self,
PyErr_Format(PyExc_TypeError,
"stream function returned a "
"non-bytes object (%.100s)",
- Py_TYPE(cres)->tp_name);
+ Py_TYPE(cres)->tp_name);
goto errorexit;
}
@@ -1724,10 +1724,10 @@ static PyTypeObject MultibyteStreamReader_Type = {
0, /* tp_itemsize */
/* methods */
(destructor)mbstreamreader_dealloc, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
+ 0, /* tp_vectorcall_offset */
0, /* tp_getattr */
0, /* tp_setattr */
- 0, /* tp_as_async */
+ 0, /* tp_as_async */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
@@ -1776,7 +1776,7 @@ mbstreamwriter_iwrite(MultibyteStreamWriterObject *self,
if (str == NULL)
return -1;
- wr = _PyObject_CallMethodIdOneArg(self->stream, &PyId_write, str);
+ wr = _PyObject_CallMethodIdOneArg(self->stream, &PyId_write, str);
Py_DECREF(str);
if (wr == NULL)
return -1;
@@ -1870,7 +1870,7 @@ _multibytecodec_MultibyteStreamWriter_reset_impl(MultibyteStreamWriterObject *se
if (PyBytes_Size(pwrt) > 0) {
PyObject *wr;
- wr = _PyObject_CallMethodIdOneArg(self->stream, &PyId_write, pwrt);
+ wr = _PyObject_CallMethodIdOneArg(self->stream, &PyId_write, pwrt);
if (wr == NULL) {
Py_DECREF(pwrt);
return NULL;
@@ -1970,10 +1970,10 @@ static PyTypeObject MultibyteStreamWriter_Type = {
0, /* tp_itemsize */
/* methods */
(destructor)mbstreamwriter_dealloc, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
+ 0, /* tp_vectorcall_offset */
0, /* tp_getattr */
0, /* tp_setattr */
- 0, /* tp_as_async */
+ 0, /* tp_as_async */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
@@ -2064,7 +2064,7 @@ PyInit__multibytecodec(void)
&MultibyteIncrementalEncoder_Type,
&MultibyteIncrementalDecoder_Type,
&MultibyteStreamReader_Type,
- &MultibyteStreamWriter_Type
+ &MultibyteStreamWriter_Type
};
if (PyType_Ready(&MultibyteCodec_Type) < 0)
@@ -2074,10 +2074,10 @@ PyInit__multibytecodec(void)
if (m == NULL)
return NULL;
- for (size_t i = 0; i < Py_ARRAY_LENGTH(typelist); i++) {
- if (PyModule_AddType(m, typelist[i]) < 0) {
+ for (size_t i = 0; i < Py_ARRAY_LENGTH(typelist); i++) {
+ if (PyModule_AddType(m, typelist[i]) < 0) {
return NULL;
- }
+ }
}
if (PyErr_Occurred()) {
diff --git a/contrib/tools/python3/src/Modules/cjkcodecs/multibytecodec.h b/contrib/tools/python3/src/Modules/cjkcodecs/multibytecodec.h
index 59468210b9..082cec5a65 100644
--- a/contrib/tools/python3/src/Modules/cjkcodecs/multibytecodec.h
+++ b/contrib/tools/python3/src/Modules/cjkcodecs/multibytecodec.h
@@ -16,21 +16,21 @@ typedef uint16_t ucs2_t, DBCHAR;
typedef unsigned short ucs2_t, DBCHAR;
#endif
-/*
- * A struct that provides 8 bytes of state for multibyte
- * codecs. Codecs are free to use this how they want. Note: if you
- * need to add a new field to this struct, ensure that its byte order
- * is independent of CPU endianness so that the return value of
- * getstate doesn't differ between little and big endian CPUs.
- */
-typedef struct {
+/*
+ * A struct that provides 8 bytes of state for multibyte
+ * codecs. Codecs are free to use this how they want. Note: if you
+ * need to add a new field to this struct, ensure that its byte order
+ * is independent of CPU endianness so that the return value of
+ * getstate doesn't differ between little and big endian CPUs.
+ */
+typedef struct {
unsigned char c[8];
} MultibyteCodec_State;
typedef int (*mbcodec_init)(const void *config);
typedef Py_ssize_t (*mbencode_func)(MultibyteCodec_State *state,
const void *config,
- int kind, const void *data,
+ int kind, const void *data,
Py_ssize_t *inpos, Py_ssize_t inlen,
unsigned char **outbuf, Py_ssize_t outleft,
int flags);
@@ -65,7 +65,7 @@ typedef struct {
MultibyteCodec *codec;
} MultibyteCodecObject;
-#define MultibyteCodec_Check(op) Py_IS_TYPE((op), &MultibyteCodec_Type)
+#define MultibyteCodec_Check(op) Py_IS_TYPE((op), &MultibyteCodec_Type)
#define _MultibyteStatefulCodec_HEAD \
PyObject_HEAD \