Show More
@@ -46,6 +46,8 b' static uint32_t htonl(uint32_t x)' | |||||
46 | #include <inttypes.h> |
|
46 | #include <inttypes.h> | |
47 | #endif |
|
47 | #endif | |
48 |
|
48 | |||
|
49 | #include "util.h" | |||
|
50 | ||||
49 | struct line { |
|
51 | struct line { | |
50 | int h, len, n, e; |
|
52 | int h, len, n, e; | |
51 | const char *l; |
|
53 | const char *l; | |
@@ -309,8 +311,9 b' static PyObject *blocks(PyObject *self, ' | |||||
309 | if (!PyArg_ParseTuple(args, "SS:bdiff", &sa, &sb)) |
|
311 | if (!PyArg_ParseTuple(args, "SS:bdiff", &sa, &sb)) | |
310 | return NULL; |
|
312 | return NULL; | |
311 |
|
313 | |||
312 |
an = splitlines(Py |
|
314 | an = splitlines(PyBytes_AsString(sa), PyBytes_Size(sa), &a); | |
313 |
bn = splitlines(Py |
|
315 | bn = splitlines(PyBytes_AsString(sb), PyBytes_Size(sb), &b); | |
|
316 | ||||
314 | if (!a || !b) |
|
317 | if (!a || !b) | |
315 | goto nomem; |
|
318 | goto nomem; | |
316 |
|
319 | |||
@@ -363,12 +366,13 b' static PyObject *bdiff(PyObject *self, P' | |||||
363 | lb = h->b2; |
|
366 | lb = h->b2; | |
364 | } |
|
367 | } | |
365 |
|
368 | |||
366 |
result = Py |
|
369 | result = PyBytes_FromStringAndSize(NULL, len); | |
|
370 | ||||
367 | if (!result) |
|
371 | if (!result) | |
368 | goto nomem; |
|
372 | goto nomem; | |
369 |
|
373 | |||
370 | /* build binary patch */ |
|
374 | /* build binary patch */ | |
371 |
rb = Py |
|
375 | rb = PyBytes_AsString(result); | |
372 | la = lb = 0; |
|
376 | la = lb = 0; | |
373 |
|
377 | |||
374 | for (h = l.base; h != l.head; h++) { |
|
378 | for (h = l.base; h != l.head; h++) { | |
@@ -400,8 +404,23 b' static PyMethodDef methods[] = {' | |||||
400 | {NULL, NULL} |
|
404 | {NULL, NULL} | |
401 | }; |
|
405 | }; | |
402 |
|
406 | |||
|
407 | #ifdef IS_PY3K | |||
|
408 | static struct PyModuleDef bdiff_module = { | |||
|
409 | PyModuleDef_HEAD_INIT, | |||
|
410 | "bdiff", | |||
|
411 | mdiff_doc, | |||
|
412 | -1, | |||
|
413 | methods | |||
|
414 | }; | |||
|
415 | ||||
|
416 | PyMODINIT_FUNC PyInit_bdiff(void) | |||
|
417 | { | |||
|
418 | return PyModule_Create(&bdiff_module); | |||
|
419 | } | |||
|
420 | #else | |||
403 | PyMODINIT_FUNC initbdiff(void) |
|
421 | PyMODINIT_FUNC initbdiff(void) | |
404 | { |
|
422 | { | |
405 | Py_InitModule3("bdiff", methods, mdiff_doc); |
|
423 | Py_InitModule3("bdiff", methods, mdiff_doc); | |
406 | } |
|
424 | } | |
|
425 | #endif | |||
407 |
|
426 |
General Comments 0
You need to be logged in to leave comments.
Login now