Show More
@@ -1,8 +1,6 b'' | |||
|
1 | 1 | # Files that just need to be migrated to the formatter. |
|
2 | 2 | # Do not add new files here! |
|
3 | 3 | mercurial/cext/base85.c |
|
4 | mercurial/cext/charencode.c | |
|
5 | mercurial/cext/charencode.h | |
|
6 | 4 | mercurial/cext/dirs.c |
|
7 | 5 | mercurial/cext/manifest.c |
|
8 | 6 | mercurial/cext/mpatch.c |
@@ -151,9 +151,8 b' PyObject *isasciistr(PyObject *self, PyO' | |||
|
151 | 151 | Py_RETURN_TRUE; |
|
152 | 152 | } |
|
153 | 153 | |
|
154 | static inline PyObject *_asciitransform(PyObject *str_obj, | |
|
155 | const char table[128], | |
|
156 | PyObject *fallback_fn) | |
|
154 | static inline PyObject * | |
|
155 | _asciitransform(PyObject *str_obj, const char table[128], PyObject *fallback_fn) | |
|
157 | 156 | { |
|
158 | 157 | char *str, *newstr; |
|
159 | 158 | Py_ssize_t i, len; |
@@ -173,12 +172,12 b' static inline PyObject *_asciitransform(' | |||
|
173 | 172 | char c = str[i]; |
|
174 | 173 | if (c & 0x80) { |
|
175 | 174 | if (fallback_fn != NULL) { |
|
176 |
ret = PyObject_CallFunctionObjArgs( |
|
|
177 |
|
|
|
175 | ret = PyObject_CallFunctionObjArgs( | |
|
176 | fallback_fn, str_obj, NULL); | |
|
178 | 177 | } else { |
|
179 | 178 | PyObject *err = PyUnicodeDecodeError_Create( |
|
180 |
|
|
|
181 |
|
|
|
179 | "ascii", str, len, i, (i + 1), | |
|
180 | "unexpected code byte"); | |
|
182 | 181 | PyErr_SetObject(PyExc_UnicodeDecodeError, err); |
|
183 | 182 | Py_XDECREF(err); |
|
184 | 183 | } |
@@ -220,10 +219,9 b' PyObject *make_file_foldmap(PyObject *se' | |||
|
220 | 219 | Py_ssize_t pos = 0; |
|
221 | 220 | const char *table; |
|
222 | 221 | |
|
223 | if (!PyArg_ParseTuple(args, "O!O!O!:make_file_foldmap", | |
|
224 | &PyDict_Type, &dmap, | |
|
225 | &PyInt_Type, &spec_obj, | |
|
226 | &PyFunction_Type, &normcase_fallback)) | |
|
222 | if (!PyArg_ParseTuple(args, "O!O!O!:make_file_foldmap", &PyDict_Type, | |
|
223 | &dmap, &PyInt_Type, &spec_obj, &PyFunction_Type, | |
|
224 | &normcase_fallback)) | |
|
227 | 225 | goto quit; |
|
228 | 226 | |
|
229 | 227 | spec = (int)PyInt_AS_LONG(spec_obj); |
@@ -251,7 +249,7 b' PyObject *make_file_foldmap(PyObject *se' | |||
|
251 | 249 | while (PyDict_Next(dmap, &pos, &k, &v)) { |
|
252 | 250 | if (!dirstate_tuple_check(v)) { |
|
253 | 251 | PyErr_SetString(PyExc_TypeError, |
|
254 |
|
|
|
252 | "expected a dirstate tuple"); | |
|
255 | 253 | goto quit; |
|
256 | 254 | } |
|
257 | 255 | |
@@ -260,10 +258,10 b' PyObject *make_file_foldmap(PyObject *se' | |||
|
260 | 258 | PyObject *normed; |
|
261 | 259 | if (table != NULL) { |
|
262 | 260 | normed = _asciitransform(k, table, |
|
263 |
|
|
|
261 | normcase_fallback); | |
|
264 | 262 | } else { |
|
265 | 263 | normed = PyObject_CallFunctionObjArgs( |
|
266 |
|
|
|
264 | normcase_fallback, k, NULL); | |
|
267 | 265 | } |
|
268 | 266 | |
|
269 | 267 | if (normed == NULL) |
@@ -292,13 +290,13 b' static Py_ssize_t jsonescapelen(const ch' | |||
|
292 | 290 | char c = buf[i]; |
|
293 | 291 | if (c & 0x80) { |
|
294 | 292 | PyErr_SetString(PyExc_ValueError, |
|
295 |
|
|
|
293 | "cannot process non-ascii str"); | |
|
296 | 294 | return -1; |
|
297 | 295 | } |
|
298 | 296 | esclen += jsonparanoidlentable[(unsigned char)c]; |
|
299 | 297 | if (esclen < 0) { |
|
300 | 298 | PyErr_SetString(PyExc_MemoryError, |
|
301 |
|
|
|
299 | "overflow in jsonescapelen"); | |
|
302 | 300 | return -1; |
|
303 | 301 | } |
|
304 | 302 | } |
@@ -308,7 +306,7 b' static Py_ssize_t jsonescapelen(const ch' | |||
|
308 | 306 | esclen += jsonlentable[(unsigned char)c]; |
|
309 | 307 | if (esclen < 0) { |
|
310 | 308 | PyErr_SetString(PyExc_MemoryError, |
|
311 |
|
|
|
309 | "overflow in jsonescapelen"); | |
|
312 | 310 | return -1; |
|
313 | 311 | } |
|
314 | 312 | } |
@@ -336,17 +334,17 b' static char jsonescapechar2(char c)' | |||
|
336 | 334 | case '\\': |
|
337 | 335 | return '\\'; |
|
338 | 336 | } |
|
339 |
return '\0'; |
|
|
337 | return '\0'; /* should not happen */ | |
|
340 | 338 | } |
|
341 | 339 | |
|
342 | 340 | /* convert 'origbuf' to JSON-escaped form 'escbuf'; 'origbuf' should only |
|
343 | 341 | include characters mappable by json(paranoid)lentable */ |
|
344 | 342 | static void encodejsonescape(char *escbuf, Py_ssize_t esclen, |
|
345 |
|
|
|
346 | bool paranoid) | |
|
343 | const char *origbuf, Py_ssize_t origlen, | |
|
344 | bool paranoid) | |
|
347 | 345 | { |
|
348 | 346 | const uint8_t *lentable = |
|
349 |
|
|
|
347 | (paranoid) ? jsonparanoidlentable : jsonlentable; | |
|
350 | 348 | Py_ssize_t i, j; |
|
351 | 349 | |
|
352 | 350 | for (i = 0, j = 0; i < origlen; i++) { |
@@ -377,15 +375,15 b' PyObject *jsonescapeu8fast(PyObject *sel' | |||
|
377 | 375 | const char *origbuf; |
|
378 | 376 | Py_ssize_t origlen, esclen; |
|
379 | 377 | int paranoid; |
|
380 | if (!PyArg_ParseTuple(args, "O!i:jsonescapeu8fast", | |
|
381 |
|
|
|
378 | if (!PyArg_ParseTuple(args, "O!i:jsonescapeu8fast", &PyBytes_Type, | |
|
379 | &origstr, ¶noid)) | |
|
382 | 380 | return NULL; |
|
383 | 381 | |
|
384 | 382 | origbuf = PyBytes_AS_STRING(origstr); |
|
385 | 383 | origlen = PyBytes_GET_SIZE(origstr); |
|
386 | 384 | esclen = jsonescapelen(origbuf, origlen, paranoid); |
|
387 | 385 | if (esclen < 0) |
|
388 |
return NULL; |
|
|
386 | return NULL; /* unsupported char found or overflow */ | |
|
389 | 387 | if (origlen == esclen) { |
|
390 | 388 | Py_INCREF(origstr); |
|
391 | 389 | return origstr; |
@@ -395,7 +393,7 b' PyObject *jsonescapeu8fast(PyObject *sel' | |||
|
395 | 393 | if (!escstr) |
|
396 | 394 | return NULL; |
|
397 | 395 | encodejsonescape(PyBytes_AS_STRING(escstr), esclen, origbuf, origlen, |
|
398 | paranoid); | |
|
396 | paranoid); | |
|
399 | 397 | |
|
400 | 398 | return escstr; |
|
401 | 399 | } |
General Comments 0
You need to be logged in to leave comments.
Login now