Show More
@@ -33,19 +33,19 b' b85encode(PyObject *self, PyObject *args' | |||
|
33 | 33 | char *dst; |
|
34 | 34 | int len, olen, i; |
|
35 | 35 | unsigned int acc, val, ch; |
|
36 |
|
|
|
36 | int pad = 0; | |
|
37 | 37 | |
|
38 | 38 | if (!PyArg_ParseTuple(args, "s#|i", &text, &len, &pad)) |
|
39 | 39 | return NULL; |
|
40 | 40 | |
|
41 |
|
|
|
42 |
|
|
|
43 | else { | |
|
44 |
|
|
|
45 | if (olen) | |
|
46 | olen++; | |
|
47 |
|
|
|
48 | } | |
|
41 | if (pad) | |
|
42 | olen = ((len + 3) / 4 * 5) - 3; | |
|
43 | else { | |
|
44 | olen = len % 4; | |
|
45 | if (olen) | |
|
46 | olen++; | |
|
47 | olen += len / 4 * 5; | |
|
48 | } | |
|
49 | 49 | if (!(out = PyString_FromStringAndSize(NULL, olen + 3))) |
|
50 | 50 | return NULL; |
|
51 | 51 | |
@@ -67,8 +67,8 b' b85encode(PyObject *self, PyObject *args' | |||
|
67 | 67 | dst += 5; |
|
68 | 68 | } |
|
69 | 69 | |
|
70 |
|
|
|
71 |
|
|
|
70 | if (!pad) | |
|
71 | _PyString_Resize(&out, olen); | |
|
72 | 72 | |
|
73 | 73 | return out; |
|
74 | 74 | } |
@@ -140,9 +140,9 b' static char base85_doc[] = "Base85 Data ' | |||
|
140 | 140 | |
|
141 | 141 | static PyMethodDef methods[] = { |
|
142 | 142 | {"b85encode", b85encode, METH_VARARGS, |
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
|
143 | "Encode text in base85.\n\n" | |
|
144 | "If the second parameter is true, pad the result to a multiple of " | |
|
145 | "five characters.\n"}, | |
|
146 | 146 | {"b85decode", b85decode, METH_VARARGS, "Decode base85 text.\n"}, |
|
147 | 147 | {NULL, NULL} |
|
148 | 148 | }; |
@@ -46,10 +46,10 b' struct listdir_stat {' | |||
|
46 | 46 | #endif |
|
47 | 47 | |
|
48 | 48 | #define listdir_slot(name) \ |
|
49 |
|
|
|
50 | { \ | |
|
51 |
|
|
|
52 | } | |
|
49 | static PyObject *listdir_stat_##name(PyObject *self, void *x) \ | |
|
50 | { \ | |
|
51 | return PyInt_FromLong(((struct listdir_stat *)self)->st.name); \ | |
|
52 | } | |
|
53 | 53 | |
|
54 | 54 | listdir_slot(st_dev) |
|
55 | 55 | listdir_slot(st_mode) |
@@ -144,9 +144,9 b' typedef unsigned __int64 uint64_t;' | |||
|
144 | 144 | static uint32_t ntohl(uint32_t x) |
|
145 | 145 | { |
|
146 | 146 | return ((x & 0x000000ffUL) << 24) | |
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
|
147 | ((x & 0x0000ff00UL) << 8) | | |
|
148 | ((x & 0x00ff0000UL) >> 8) | | |
|
149 | ((x & 0xff000000UL) >> 24); | |
|
150 | 150 | } |
|
151 | 151 | #else |
|
152 | 152 | /* not windows */ |
@@ -299,7 +299,7 b' static int _parse_index_ng (const char *' | |||
|
299 | 299 | |
|
300 | 300 | while (data < end) { |
|
301 | 301 | unsigned int step; |
|
302 | ||
|
302 | ||
|
303 | 303 | memcpy(decode, data, 64); |
|
304 | 304 | offset_flags = ntohl(*((uint32_t *) (decode + 4))); |
|
305 | 305 | if (n == 0) /* mask out version number for the first entry */ |
@@ -344,9 +344,9 b' static int _parse_index_ng (const char *' | |||
|
344 | 344 | return 0; |
|
345 | 345 | } |
|
346 | 346 | |
|
347 |
/* create the nullid/nullrev entry in the nodemap and the |
|
|
347 | /* create the nullid/nullrev entry in the nodemap and the | |
|
348 | 348 | * magic nullid entry in the index at [-1] */ |
|
349 |
entry = _build_idx_entry(nodemap, |
|
|
349 | entry = _build_idx_entry(nodemap, | |
|
350 | 350 | nullrev, 0, 0, 0, -1, -1, -1, -1, nullid); |
|
351 | 351 | if (!entry) |
|
352 | 352 | return 0; |
@@ -372,16 +372,16 b' static PyObject *parse_index(PyObject *s' | |||
|
372 | 372 | { |
|
373 | 373 | const char *data; |
|
374 | 374 | int size, inlined; |
|
375 |
PyObject *rval = NULL, *index = NULL, *nodemap = NULL, *cache = NULL; |
|
|
375 | PyObject *rval = NULL, *index = NULL, *nodemap = NULL, *cache = NULL; | |
|
376 | 376 | PyObject *data_obj = NULL, *inlined_obj; |
|
377 | 377 | |
|
378 | 378 | if (!PyArg_ParseTuple(args, "s#O", &data, &size, &inlined_obj)) |
|
379 | 379 | return NULL; |
|
380 | 380 | inlined = inlined_obj && PyObject_IsTrue(inlined_obj); |
|
381 | 381 | |
|
382 |
/* If no data is inlined, we know the size of the index list in |
|
|
383 |
* advance: size divided by size of one one revlog record (64 bytes) |
|
|
384 |
* plus one for the nullid */ |
|
|
382 | /* If no data is inlined, we know the size of the index list in | |
|
383 | * advance: size divided by size of one one revlog record (64 bytes) | |
|
384 | * plus one for the nullid */ | |
|
385 | 385 | index = inlined ? PyList_New(0) : PyList_New(size / 64 + 1); |
|
386 | 386 | if (!index) |
|
387 | 387 | goto quit; |
General Comments 0
You need to be logged in to leave comments.
Login now