Commits

Naoki INADA  committed 0e4ad38 Draft

Prepare python3

  • Participants
  • Parent commits ac0c23b

Comments (0)

Files changed (1)

File porterstemmer.c

    regarded as release 1.)
 */
 
+#include <Python.h>
 #include <string.h>  /* for memcmp, memmove */
 
 /* The main part of the stemming algorithm starts here.
 
 
 /* Python Wrapper */
-#include <Python.h>
 
 
 typedef struct {
     struct stemmer stem;
 } Stemmer;
 
-static void Stemmer_dealloc(Stemmer *self)
-{
-    self->ob_type->tp_free((PyObject*)self);
-}
-
 static PyObject* Stemmer_call(Stemmer *self, PyObject *args, PyObject *kw)
 {
     PyObject *from_stem;
         return NULL;
     }
 
-    //unicode = PyUnicode_CheckExact(from_stem);
     unicode = PyUnicode_Check(from_stem);
     if (unicode) {
         if (PyUnicode_GET_SIZE(from_stem) < 2) {
 
 static PyTypeObject StemmerType = {
     PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
+    0,                         /*tp_size*/
     "porterstemmer.Stemmer",   /*tp_name*/
     sizeof(Stemmer),           /*tp_basicsize*/
     0,                         /*tp_itemsize*/
-    (destructor)Stemmer_dealloc,       /*tp_dealloc*/
+    0,                         /*tp_dealloc*/
     0,                         /*tp_print*/
     0,                         /*tp_getattr*/
     0,                         /*tp_setattr*/
     0,                         /*tp_getattro*/
     0,                         /*tp_setattro*/
     0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+    Py_TPFLAGS_DEFAULT,        /*tp_flags*/
     0,                         /* tp_doc */
-    0,                         /* tp_traverse */
-    0,                         /* tp_clear */
-    0,                         /* tp_richcompare */
-    0,                         /* tp_weaklistoffset */
-    0,                         /* tp_iter */
-    0,                         /* tp_iternext */
-    0,                         /* tp_methods */
-    0,                         /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    0,                         /* tp_init */
-    0,                         /* tp_alloc */
-    0,                         /* tp_new */
 };
 
 
     {NULL}
 };
 
+#if PY_MAJOR_VERSION < 3
 PyMODINIT_FUNC
 initporterstemmer(void)
+#else
+PyMODINIT_FUNC
+PyInit_porterstemmer(void)
+#endif
 {
     PyObject *m;