summaryrefslogtreecommitdiffstats
path: root/Modules/_codecsmodule.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-06-14 05:21:04 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2006-06-14 05:21:04 (GMT)
commitd825143be1118ba7e320661b3a71d8822ae5d600 (patch)
treea74764df14558614917b7f4d9abd56c44ffd5623 /Modules/_codecsmodule.c
parent6ce9fe880be7416d88e6d800528db4079db6d6b1 (diff)
downloadcpython-d825143be1118ba7e320661b3a71d8822ae5d600.zip
cpython-d825143be1118ba7e320661b3a71d8822ae5d600.tar.gz
cpython-d825143be1118ba7e320661b3a71d8822ae5d600.tar.bz2
Patch #1455898: Incremental mode for "mbcs" codec.
Diffstat (limited to 'Modules/_codecsmodule.c')
-rw-r--r--Modules/_codecsmodule.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index 32fa82f..6d384b7 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -479,15 +479,20 @@ mbcs_decode(PyObject *self,
PyObject *args)
{
const char *data;
- Py_ssize_t size;
+ Py_ssize_t size, consumed;
const char *errors = NULL;
+ int final = 1;
+ PyObject *decoded;
- if (!PyArg_ParseTuple(args, "t#|z:mbcs_decode",
- &data, &size, &errors))
+ if (!PyArg_ParseTuple(args, "t#|zi:mbcs_decode",
+ &data, &size, &errors, &final))
return NULL;
- return codec_tuple(PyUnicode_DecodeMBCS(data, size, errors),
- size);
+ decoded = PyUnicode_DecodeMBCSStateful(
+ data, size, errors, final ? NULL : &consumed);
+ if (!decoded)
+ return NULL;
+ return codec_tuple(decoded, final ? size : consumed);
}
#endif /* MS_WINDOWS */