comparison mercurial/base85.c @ 7190:aecea6934fdd

Some additional space/tab cleanups
author Thomas Arendsen Hein <thomas@intevation.de>
date Mon, 20 Oct 2008 15:19:05 +0200
parents 4bad632913d8
children 08a0f04b56bd
comparison
equal deleted inserted replaced
7189:8bbbba2a1a9c 7190:aecea6934fdd
31 const unsigned char *text; 31 const unsigned char *text;
32 PyObject *out; 32 PyObject *out;
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 int pad = 0; 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 if (pad) 41 if (pad)
42 olen = ((len + 3) / 4 * 5) - 3; 42 olen = ((len + 3) / 4 * 5) - 3;
43 else { 43 else {
44 olen = len % 4; 44 olen = len % 4;
45 if (olen) 45 if (olen)
46 olen++; 46 olen++;
47 olen += len / 4 * 5; 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
52 dst = PyString_AS_STRING(out); 52 dst = PyString_AS_STRING(out);
53 53
65 dst[i] = b85chars[val]; 65 dst[i] = b85chars[val];
66 } 66 }
67 dst += 5; 67 dst += 5;
68 } 68 }
69 69
70 if (!pad) 70 if (!pad)
71 _PyString_Resize(&out, olen); 71 _PyString_Resize(&out, olen);
72 72
73 return out; 73 return out;
74 } 74 }
75 75
76 static PyObject * 76 static PyObject *
138 138
139 static char base85_doc[] = "Base85 Data Encoding"; 139 static char base85_doc[] = "Base85 Data Encoding";
140 140
141 static PyMethodDef methods[] = { 141 static PyMethodDef methods[] = {
142 {"b85encode", b85encode, METH_VARARGS, 142 {"b85encode", b85encode, METH_VARARGS,
143 "Encode text in base85.\n\n" 143 "Encode text in base85.\n\n"
144 "If the second parameter is true, pad the result to a multiple of " 144 "If the second parameter is true, pad the result to a multiple of "
145 "five characters.\n"}, 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 };
149 149
150 PyMODINIT_FUNC initbase85(void) 150 PyMODINIT_FUNC initbase85(void)