mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-10-31 10:37:00 -04:00 
			
		
		
		
	Update patiencediff to py3
This commit is contained in:
		
							parent
							
								
									7463d23777
								
							
						
					
					
						commit
						5186718fdd
					
				| @ -151,7 +151,7 @@ static inline int | |||||||
| compare_lines(struct line *a, struct line *b) | compare_lines(struct line *a, struct line *b) | ||||||
| { | { | ||||||
|     return ((a->hash != b->hash) |     return ((a->hash != b->hash) | ||||||
|             || PyObject_Compare(a->data, b->data)); |             || PyObject_RichCompareBool(a->data, b->data, Py_NE)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -804,7 +804,7 @@ PatienceSequenceMatcher_dealloc(PatienceSequenceMatcher* self) | |||||||
|     free(self->hashtable.table); |     free(self->hashtable.table); | ||||||
|     delete_lines(self->b, self->bsize); |     delete_lines(self->b, self->bsize); | ||||||
|     delete_lines(self->a, self->asize); |     delete_lines(self->a, self->asize); | ||||||
|     self->ob_type->tp_free((PyObject *)self); |     Py_TYPE(self)->tp_free((PyObject *)self); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -1209,73 +1209,91 @@ static char PatienceSequenceMatcher_doc[] = | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| static PyTypeObject PatienceSequenceMatcherType = { | static PyTypeObject PatienceSequenceMatcherType = { | ||||||
|     PyObject_HEAD_INIT(NULL) |     PyVarObject_HEAD_INIT(NULL, 0) | ||||||
|     0,                                           /* ob_size */ |     /* tp_name           */ "PatienceSequenceMatcher", | ||||||
|     "PatienceSequenceMatcher",                   /* tp_name */ |     /* tp_basicsize      */ sizeof(PatienceSequenceMatcher), | ||||||
|     sizeof(PatienceSequenceMatcher),             /* tp_basicsize */ |     /* tp_itemsize       */ 0, | ||||||
|     0,                                           /* tp_itemsize */ |     /* tp_dealloc        */ (destructor)PatienceSequenceMatcher_dealloc, | ||||||
|     (destructor)PatienceSequenceMatcher_dealloc, /* tp_dealloc */ |     /* tp_print          */ 0, | ||||||
|     0,                                           /* tp_print */ |     /* tp_getattr        */ 0, | ||||||
|     0,                                           /* tp_getattr */ |     /* tp_setattr        */ 0, | ||||||
|     0,                                           /* tp_setattr */ |     /* tp_compare        */ 0, | ||||||
|     0,                                           /* tp_compare */ |     /* tp_repr           */ 0, | ||||||
|     0,                                           /* tp_repr */ |     /* tp_as_number      */ 0, | ||||||
|     0,                                           /* tp_as_number */ |     /* tp_as_sequence    */ 0, | ||||||
|     0,                                           /* tp_as_sequence */ |     /* tp_as_mapping     */ 0, | ||||||
|     0,                                           /* tp_as_mapping */ |     /* tp_hash           */ 0, | ||||||
|     0,                                           /* tp_hash */ |     /* tp_call           */ 0, | ||||||
|     0,                                           /* tp_call */ |     /* tp_str            */ 0, | ||||||
|     0,                                           /* tp_str */ |     /* tp_getattro       */ 0, | ||||||
|     0,                                           /* tp_getattro */ |     /* tp_setattro       */ 0, | ||||||
|     0,                                           /* tp_setattro */ |     /* tp_as_buffer      */ 0, | ||||||
|     0,                                           /* tp_as_buffer */ |     /* tp_flags          */ Py_TPFLAGS_DEFAULT, | ||||||
|     Py_TPFLAGS_DEFAULT,                          /* tp_flags*/ |     /* tp_doc            */ PatienceSequenceMatcher_doc, | ||||||
|     PatienceSequenceMatcher_doc,                 /* tp_doc */ |     /* tp_traverse       */ 0, | ||||||
|     0,                                           /* tp_traverse */ |     /* tp_clear          */ 0, | ||||||
|     0,                                           /* tp_clear */ |     /* tp_richcompare    */ 0, | ||||||
|     0,                                           /* tp_richcompare */ |     /* tp_weaklistoffset */ 0, | ||||||
|     0,                                           /* tp_weaklistoffset */ |     /* tp_iter           */ 0, | ||||||
|     0,                                           /* tp_iter */ |     /* tp_iternext       */ 0, | ||||||
|     0,                                           /* tp_iternext */ |     /* tp_methods        */ PatienceSequenceMatcher_methods, | ||||||
|     PatienceSequenceMatcher_methods,             /* tp_methods */ |     /* tp_members        */ 0, | ||||||
|     0,                                           /* tp_members */ |     /* tp_getset         */ 0, | ||||||
|     0,                                           /* tp_getset */ |     /* tp_base           */ 0, | ||||||
|     0,                                           /* tp_base */ |     /* tp_dict           */ 0, | ||||||
|     0,                                           /* tp_dict */ |     /* tp_descr_get      */ 0, | ||||||
|     0,                                           /* tp_descr_get */ |     /* tp_descr_set      */ 0, | ||||||
|     0,                                           /* tp_descr_set */ |     /* tp_dictoffset     */ 0, | ||||||
|     0,                                           /* tp_dictoffset */ |     /* tp_init           */ 0, | ||||||
|     0,                                           /* tp_init */ |     /* tp_alloc          */ 0, | ||||||
|     0,                                           /* tp_alloc */ |     /* tp_new            */ PatienceSequenceMatcher_new, | ||||||
|     PatienceSequenceMatcher_new,                 /* tp_new */ |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | static PyMethodDef _patiencediff_c_methods[] = { | ||||||
| static PyMethodDef cpatiencediff_methods[] = { |  | ||||||
|     {"unique_lcs_c", py_unique_lcs, METH_VARARGS}, |     {"unique_lcs_c", py_unique_lcs, METH_VARARGS}, | ||||||
|     {"recurse_matches_c", py_recurse_matches, METH_VARARGS}, |     {"recurse_matches_c", py_recurse_matches, METH_VARARGS}, | ||||||
|     {NULL, NULL} |     {NULL, NULL, 0, NULL} | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | #if PY_MAJOR_VERSION >= 3 | ||||||
|  | #define INITERROR return NULL | ||||||
|  | static struct PyModuleDef _patiencediff_c_module = { | ||||||
|  |         /* m_base     */ PyModuleDef_HEAD_INIT, | ||||||
|  |         /* m_name     */ "_patiencediff_c", | ||||||
|  |         /* m_doc      */ "C implementation of PatienceSequenceMatcher.", | ||||||
|  |         /* m_size     */ -1, | ||||||
|  |         /* m_methods  */ _patiencediff_c_methods, | ||||||
|  |         /* m_slots    */ 0, | ||||||
|  |         /* m_traverse */ 0, | ||||||
|  |         /* m_clear    */ 0, | ||||||
|  |         /* m_free     */ 0, | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| CALIBRE_MODINIT_FUNC | CALIBRE_MODINIT_FUNC PyInit__patiencediff_c(void) { | ||||||
| init_patiencediff_c(void) |  | ||||||
| { |  | ||||||
|     PyObject* m; |  | ||||||
| 
 |  | ||||||
|     if (PyType_Ready(&PatienceSequenceMatcherType) < 0) |     if (PyType_Ready(&PatienceSequenceMatcherType) < 0) | ||||||
|         return; |         INITERROR; | ||||||
| 
 | 
 | ||||||
|     m = Py_InitModule3("_patiencediff_c", cpatiencediff_methods, |     PyObject *mod = PyModule_Create(&_patiencediff_c_module); | ||||||
|                        "C implementation of PatienceSequenceMatcher"); | #else | ||||||
|     if (m == NULL) | #define INITERROR return | ||||||
|       return; | CALIBRE_MODINIT_FUNC init_patiencediff_c(void) { | ||||||
|  |     if (PyType_Ready(&PatienceSequenceMatcherType) < 0) | ||||||
|  |         INITERROR; | ||||||
|  | 
 | ||||||
|  |     PyObject *mod = Py_InitModule3("_patiencediff_c", _patiencediff_c_methods, | ||||||
|  |         "C implementation of PatienceSequenceMatcher"); | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  |     if (mod == NULL) INITERROR; | ||||||
| 
 | 
 | ||||||
|     Py_INCREF(&PatienceSequenceMatcherType); |     Py_INCREF(&PatienceSequenceMatcherType); | ||||||
|     PyModule_AddObject(m, "PatienceSequenceMatcher_c", |     PyModule_AddObject(mod, "PatienceSequenceMatcher_c", | ||||||
|                        (PyObject *)&PatienceSequenceMatcherType); |                        (PyObject *)&PatienceSequenceMatcherType); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | #if PY_MAJOR_VERSION >= 3 | ||||||
|  |     return mod; | ||||||
|  | #endif | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | /* vim: sw=4 et */ | ||||||
| /* vim: sw=4 et 
 |  | ||||||
|  */ |  | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user