Show More
@@ -1,6 +1,5 b'' | |||||
1 | # Files that just need to be migrated to the formatter. |
|
1 | # Files that just need to be migrated to the formatter. | |
2 | # Do not add new files here! |
|
2 | # Do not add new files here! | |
3 | mercurial/cext/base85.c |
|
|||
4 | mercurial/cext/dirs.c |
|
3 | mercurial/cext/dirs.c | |
5 | mercurial/cext/manifest.c |
|
4 | mercurial/cext/manifest.c | |
6 | mercurial/cext/mpatch.c |
|
5 | mercurial/cext/mpatch.c |
@@ -14,8 +14,9 b'' | |||||
14 |
|
14 | |||
15 | #include "util.h" |
|
15 | #include "util.h" | |
16 |
|
16 | |||
17 |
static const char b85chars[] = |
|
17 | static const char b85chars[] = | |
18 | "abcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"; |
|
18 | "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
|
19 | "abcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"; | |||
19 | static char b85dec[256]; |
|
20 | static char b85dec[256]; | |
20 |
|
21 | |||
21 | static void b85prep(void) |
|
22 | static void b85prep(void) | |
@@ -105,25 +106,25 b' static PyObject *b85decode(PyObject *sel' | |||||
105 | c = b85dec[(int)*text++] - 1; |
|
106 | c = b85dec[(int)*text++] - 1; | |
106 | if (c < 0) |
|
107 | if (c < 0) | |
107 | return PyErr_Format( |
|
108 | return PyErr_Format( | |
108 |
|
|
109 | PyExc_ValueError, | |
109 |
|
|
110 | "bad base85 character at position %d", | |
110 |
|
|
111 | (int)i); | |
111 | acc = acc * 85 + c; |
|
112 | acc = acc * 85 + c; | |
112 | } |
|
113 | } | |
113 | if (i++ < len) { |
|
114 | if (i++ < len) { | |
114 | c = b85dec[(int)*text++] - 1; |
|
115 | c = b85dec[(int)*text++] - 1; | |
115 | if (c < 0) |
|
116 | if (c < 0) | |
116 | return PyErr_Format( |
|
117 | return PyErr_Format( | |
117 |
|
|
118 | PyExc_ValueError, | |
118 |
|
|
119 | "bad base85 character at position %d", | |
119 |
|
|
120 | (int)i); | |
120 | /* overflow detection: 0xffffffff == "|NsC0", |
|
121 | /* overflow detection: 0xffffffff == "|NsC0", | |
121 | * "|NsC" == 0x03030303 */ |
|
122 | * "|NsC" == 0x03030303 */ | |
122 | if (acc > 0x03030303 || (acc *= 85) > 0xffffffff - c) |
|
123 | if (acc > 0x03030303 || (acc *= 85) > 0xffffffff - c) | |
123 | return PyErr_Format( |
|
124 | return PyErr_Format( | |
124 |
|
|
125 | PyExc_ValueError, | |
125 |
|
|
126 | "bad base85 sequence at position %d", | |
126 |
|
|
127 | (int)i); | |
127 | acc += c; |
|
128 | acc += c; | |
128 | } |
|
129 | } | |
129 |
|
130 | |||
@@ -145,23 +146,19 b' static PyObject *b85decode(PyObject *sel' | |||||
145 | static char base85_doc[] = "Base85 Data Encoding"; |
|
146 | static char base85_doc[] = "Base85 Data Encoding"; | |
146 |
|
147 | |||
147 | static PyMethodDef methods[] = { |
|
148 | static PyMethodDef methods[] = { | |
148 |
|
|
149 | {"b85encode", b85encode, METH_VARARGS, | |
149 |
|
|
150 | "Encode text in base85.\n\n" | |
150 |
|
|
151 | "If the second parameter is true, pad the result to a multiple of " | |
151 |
|
|
152 | "five characters.\n"}, | |
152 |
|
|
153 | {"b85decode", b85decode, METH_VARARGS, "Decode base85 text.\n"}, | |
153 |
|
|
154 | {NULL, NULL}, | |
154 | }; |
|
155 | }; | |
155 |
|
156 | |||
156 | static const int version = 1; |
|
157 | static const int version = 1; | |
157 |
|
158 | |||
158 | #ifdef IS_PY3K |
|
159 | #ifdef IS_PY3K | |
159 | static struct PyModuleDef base85_module = { |
|
160 | static struct PyModuleDef base85_module = { | |
160 | PyModuleDef_HEAD_INIT, |
|
161 | PyModuleDef_HEAD_INIT, "base85", base85_doc, -1, methods, | |
161 | "base85", |
|
|||
162 | base85_doc, |
|
|||
163 | -1, |
|
|||
164 | methods |
|
|||
165 | }; |
|
162 | }; | |
166 |
|
163 | |||
167 | PyMODINIT_FUNC PyInit_base85(void) |
|
164 | PyMODINIT_FUNC PyInit_base85(void) |
General Comments 0
You need to be logged in to leave comments.
Login now