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