prepare for Py_ssize_t conversion

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3530 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2006-12-08 22:07:23 +00:00
parent 7397929e9e
commit b274787c5b
3 changed files with 12 additions and 4 deletions

View file

@ -57,7 +57,8 @@
CHECK_NULL(pencoding = PyObject_GetAttrString(yyextra->parser, "encoding")); \
encoding = PyString_AsString(pencoding); \
if (encoding==NULL) { Py_DECREF(pencoding); return T_ERROR; } \
(a) = PyUnicode_Decode(yyextra->tmp_buf, strlen(yyextra->tmp_buf), \
(a) = PyUnicode_Decode(yyextra->tmp_buf, \
(Py_ssize_t)strlen(yyextra->tmp_buf), \
encoding, "ignore"); \
Py_DECREF(pencoding); \
CHECK_NULL(a); \
@ -65,7 +66,7 @@
#define PYSTRING_TMP_ASCII(a) \
CHECK_NULL((a) = PyUnicode_Decode(yyextra->tmp_buf, \
strlen(yyextra->tmp_buf), "ascii", "ignore"))
(Py_ssize_t)strlen(yyextra->tmp_buf), "ascii", "ignore"))
/* set return value from tmp_buf */
#define SETLVAL_UNICODE { \

View file

@ -630,8 +630,8 @@ static PyObject* parser_flush (parser_object* self, PyObject* args) {
int error = 0;
const char* enc = PyString_AsString(self->encoding);
PyObject* s = PyUnicode_Decode(self->userData->buf,
strlen(self->userData->buf),
enc, "ignore");
(Py_ssize_t)strlen(self->userData->buf),
enc, "ignore");
PyObject* callback = NULL;
PyObject* result = NULL;
/* reset buffer */

View file

@ -31,6 +31,13 @@
#error please install Python >= 2.4
#endif
/* See http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
typedef int Py_ssize_t;
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
#endif
/* user_data type for SAX calls */
typedef struct {
/* the Python SAX object to issue callbacks */