@@ -28,9 +28,11 @@ joins them together under one interface. | |||||
try: | try: | ||||
from ._builder import CBuilder as Builder | from ._builder import CBuilder as Builder | ||||
from ._tokenizer import CTokenizer as Tokenizer | |||||
except ImportError: | except ImportError: | ||||
from .builder import Builder | from .builder import Builder | ||||
try: | |||||
from ._tokenizer import CTokenizer as Tokenizer | |||||
except ImportError: | |||||
from .tokenizer import Tokenizer | from .tokenizer import Tokenizer | ||||
__all__ = ["Parser"] | __all__ = ["Parser"] | ||||
@@ -1,24 +0,0 @@ | |||||
/* | |||||
Builder for MWParserFromHell | |||||
Copyright (C) 2012 Ben Kurtovic <ben.kurtovic@verizon.net> | |||||
Permission is hereby granted, free of charge, to any person obtaining a copy of | |||||
this software and associated documentation files (the "Software"), to deal in | |||||
the Software without restriction, including without limitation the rights to | |||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | |||||
of the Software, and to permit persons to whom the Software is furnished to do | |||||
so, subject to the following conditions: | |||||
The above copyright notice and this permission notice shall be included in all | |||||
copies or substantial portions of the Software. | |||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |||||
SOFTWARE. | |||||
*/ | |||||
#include <Python.h> |
@@ -1394,7 +1394,7 @@ init_tokenizer(void) | |||||
numdefs = (unsigned) PyList_GET_SIZE(defmap); | numdefs = (unsigned) PyList_GET_SIZE(defmap); | ||||
entitydefs = calloc(numdefs + 1, sizeof(char*)); | entitydefs = calloc(numdefs + 1, sizeof(char*)); | ||||
for (i = 0; i < numdefs; i++) | for (i = 0; i < numdefs; i++) | ||||
entitydefs[i] = PyString_AsString(PyList_GET_ITEM(deflist, i)); | |||||
entitydefs[i] = PyBytes_AsString(PyList_GET_ITEM(deflist, i)); | |||||
Py_DECREF(deflist); | Py_DECREF(deflist); | ||||
EMPTY = PyUnicode_FromString(""); | EMPTY = PyUnicode_FromString(""); | ||||
@@ -29,6 +29,10 @@ SOFTWARE. | |||||
#include <math.h> | #include <math.h> | ||||
#include <structmember.h> | #include <structmember.h> | ||||
#if PY_MAJOR_VERSION >= 3 | |||||
#define IS_PY3K | |||||
#endif | |||||
#define malloc PyObject_Malloc | #define malloc PyObject_Malloc | ||||
#define free PyObject_Free | #define free PyObject_Free | ||||
@@ -28,8 +28,8 @@ from mwparserfromhell import __version__ | |||||
with open("README.rst") as fp: | with open("README.rst") as fp: | ||||
long_docs = fp.read() | long_docs = fp.read() | ||||
builder = Extension("mwparserfromhell.parser._builder", | |||||
sources = ["mwparserfromhell/parser/builder.c"]) | |||||
# builder = Extension("mwparserfromhell.parser._builder", | |||||
# sources = ["mwparserfromhell/parser/builder.c"]) | |||||
tokenizer = Extension("mwparserfromhell.parser._tokenizer", | tokenizer = Extension("mwparserfromhell.parser._tokenizer", | ||||
sources = ["mwparserfromhell/parser/tokenizer.c"]) | sources = ["mwparserfromhell/parser/tokenizer.c"]) | ||||
@@ -37,7 +37,7 @@ tokenizer = Extension("mwparserfromhell.parser._tokenizer", | |||||
setup( | setup( | ||||
name = "mwparserfromhell", | name = "mwparserfromhell", | ||||
packages = find_packages(exclude=("tests",)), | packages = find_packages(exclude=("tests",)), | ||||
ext_modules = [builder, tokenizer], | |||||
ext_modules = [tokenizer], | |||||
test_suite = "tests", | test_suite = "tests", | ||||
version = __version__, | version = __version__, | ||||
author = "Ben Kurtovic", | author = "Ben Kurtovic", | ||||