Merge ssize_t branch.

This commit is contained in:
Martin v. Löwis 2006-02-15 17:27:45 +00:00
parent 4482929734
commit 18e165558b
102 changed files with 2659 additions and 1677 deletions

View file

@ -35,6 +35,7 @@ Copyright (c) Corporation for National Research Initiatives.
------------------------------------------------------------------------ */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
/* --- Registry ----------------------------------------------------------- */
@ -196,7 +197,7 @@ escape_decode(PyObject *self,
{
const char *errors = NULL;
const char *data;
int size;
Py_ssize_t size;
if (!PyArg_ParseTuple(args, "s#|z:escape_decode",
&data, &size, &errors))
@ -241,7 +242,7 @@ unicode_internal_decode(PyObject *self,
PyObject *obj;
const char *errors = NULL;
const char *data;
int size;
Py_ssize_t size;
if (!PyArg_ParseTuple(args, "O|z:unicode_internal_decode",
&obj, &errors))
@ -265,7 +266,7 @@ utf_7_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "t#|z:utf_7_decode",
@ -281,15 +282,19 @@ utf_8_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
int final = 0;
int consumed;
Py_ssize_t consumed;
PyObject *decoded = NULL;
if (!PyArg_ParseTuple(args, "t#|zi:utf_8_decode",
&data, &size, &errors, &final))
return NULL;
if (size < 0) {
PyErr_SetString(PyExc_ValueError, "negative argument");
return 0;
}
consumed = size;
decoded = PyUnicode_DecodeUTF8Stateful(data, size, errors,
@ -304,16 +309,21 @@ utf_16_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
int byteorder = 0;
int final = 0;
int consumed;
Py_ssize_t consumed;
PyObject *decoded;
if (!PyArg_ParseTuple(args, "t#|zi:utf_16_decode",
&data, &size, &errors, &final))
return NULL;
/* XXX Why is consumed initialized to size? mvl */
if (size < 0) {
PyErr_SetString(PyExc_ValueError, "negative argument");
return 0;
}
consumed = size;
decoded = PyUnicode_DecodeUTF16Stateful(data, size, errors, &byteorder,
final ? NULL : &consumed);
@ -327,16 +337,22 @@ utf_16_le_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
int byteorder = -1;
int final = 0;
int consumed;
Py_ssize_t consumed;
PyObject *decoded = NULL;
if (!PyArg_ParseTuple(args, "t#|zi:utf_16_le_decode",
&data, &size, &errors, &final))
return NULL;
/* XXX Why is consumed initialized to size? mvl */
if (size < 0) {
PyErr_SetString(PyExc_ValueError, "negative argument");
return 0;
}
consumed = size;
decoded = PyUnicode_DecodeUTF16Stateful(data, size, errors,
&byteorder, final ? NULL : &consumed);
@ -351,16 +367,21 @@ utf_16_be_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
int byteorder = 1;
int final = 0;
int consumed;
Py_ssize_t consumed;
PyObject *decoded = NULL;
if (!PyArg_ParseTuple(args, "t#|zi:utf_16_be_decode",
&data, &size, &errors, &final))
return NULL;
/* XXX Why is consumed initialized to size? mvl */
if (size < 0) {
PyErr_SetString(PyExc_ValueError, "negative argument");
return 0;
}
consumed = size;
decoded = PyUnicode_DecodeUTF16Stateful(data, size, errors,
&byteorder, final ? NULL : &consumed);
@ -382,17 +403,21 @@ utf_16_ex_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
int byteorder = 0;
PyObject *unicode, *tuple;
int final = 0;
int consumed;
Py_ssize_t consumed;
if (!PyArg_ParseTuple(args, "t#|zii:utf_16_ex_decode",
&data, &size, &errors, &byteorder, &final))
return NULL;
/* XXX Why is consumed initialized to size? mvl */
if (size < 0) {
PyErr_SetString(PyExc_ValueError, "negative argument");
return 0;
}
consumed = size;
unicode = PyUnicode_DecodeUTF16Stateful(data, size, errors, &byteorder,
final ? NULL : &consumed);
@ -408,7 +433,7 @@ unicode_escape_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "t#|z:unicode_escape_decode",
@ -424,7 +449,7 @@ raw_unicode_escape_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "t#|z:raw_unicode_escape_decode",
@ -440,7 +465,7 @@ latin_1_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "t#|z:latin_1_decode",
@ -456,7 +481,7 @@ ascii_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "t#|z:ascii_decode",
@ -472,7 +497,7 @@ charmap_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
PyObject *mapping = NULL;
@ -493,7 +518,7 @@ mbcs_decode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "t#|z:mbcs_decode",
@ -513,7 +538,7 @@ readbuffer_encode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "s#|z:readbuffer_encode",
@ -529,7 +554,7 @@ charbuffer_encode(PyObject *self,
PyObject *args)
{
const char *data;
int size;
Py_ssize_t size;
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "t#|z:charbuffer_encode",
@ -547,7 +572,7 @@ unicode_internal_encode(PyObject *self,
PyObject *obj;
const char *errors = NULL;
const char *data;
int size;
Py_ssize_t size;
if (!PyArg_ParseTuple(args, "O|z:unicode_internal_encode",
&obj, &errors))