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