Przeglądaj źródła

More unification.

tags/v0.3
Ben Kurtovic 11 lat temu
rodzic
commit
8923d96a57
2 zmienionych plików z 8 dodań i 10 usunięć
  1. +6
    -10
      mwparserfromhell/parser/tokenizer.c
  2. +2
    -0
      mwparserfromhell/parser/tokenizer.h

+ 6
- 10
mwparserfromhell/parser/tokenizer.c Wyświetl plik

@@ -835,11 +835,7 @@ static int Tokenizer_parse_heading(Tokenizer* self)
self->global ^= GL_HEADING;
return 0;
}
#ifdef IS_PY3K
level = PyLong_FromSsize_t(heading->level);
#else
level = PyInt_FromSsize_t(heading->level);
#endif
level = NEW_INT_FUNC(heading->level);
if (!level) {
Py_DECREF(heading->title);
free(heading);
@@ -2279,7 +2275,11 @@ static PyObject* Tokenizer_tokenize(Tokenizer* self, PyObject* args)
{
PyObject *text, *temp;

if (!PyArg_ParseTuple(args, "U", &text)) {
if (PyArg_ParseTuple(args, "U", &text)) {
Py_XDECREF(self->text);
self->text = PySequence_Fast(text, "expected a sequence");
}
else {
const char* encoded;
Py_ssize_t size;
/* Failed to parse a Unicode object; try a string instead. */
@@ -2294,10 +2294,6 @@ static PyObject* Tokenizer_tokenize(Tokenizer* self, PyObject* args)
Py_XDECREF(temp);
self->text = text;
}
else {
Py_XDECREF(self->text);
self->text = PySequence_Fast(text, "expected a sequence");
}
self->head = self->global = self->depth = self->cycles = 0;
self->length = PyList_GET_SIZE(self->text);
return Tokenizer_parse(self, 0, 1);


+ 2
- 0
mwparserfromhell/parser/tokenizer.h Wyświetl plik

@@ -255,12 +255,14 @@ static PyObject* Tokenizer_tokenize(Tokenizer*, PyObject*);
/* Macros for Python 2/3 compatibility: */

#ifdef IS_PY3K
#define NEW_INT_FUNC PyLong_FromSsize_t
#define IMPORT_NAME_FUNC PyUnicode_FromString
#define CREATE_MODULE PyModule_Create(&module_def);
#define ENTITYDEFS_MODULE "html.entities"
#define INIT_FUNC_NAME PyInit__tokenizer
#define INIT_ERROR return NULL
#else
#define NEW_INT_FUNC PyInt_FromSsize_t
#define IMPORT_NAME_FUNC PyBytes_FromString
#define CREATE_MODULE Py_InitModule("_tokenizer", NULL);
#define ENTITYDEFS_MODULE "htmlentitydefs"


Ładowanie…
Anuluj
Zapisz