Mercurial > hg-stable
changeset 36263:6c87d4113a90
charencode: allow clang-format oversight
Nice and easy.
Differential Revision: https://phab.mercurial-scm.org/D2181
author | Augie Fackler <augie@google.com> |
---|---|
date | Mon, 12 Feb 2018 10:38:11 -0500 |
parents | d0a3fa849cb8 |
children | e1138fc2c4e2 |
files | contrib/clang-format-blacklist mercurial/cext/charencode.c |
diffstat | 2 files changed, 23 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/clang-format-blacklist Wed Feb 14 21:12:48 2018 -0500 +++ b/contrib/clang-format-blacklist Mon Feb 12 10:38:11 2018 -0500 @@ -1,8 +1,6 @@ # Files that just need to be migrated to the formatter. # Do not add new files here! mercurial/cext/base85.c -mercurial/cext/charencode.c -mercurial/cext/charencode.h mercurial/cext/dirs.c mercurial/cext/manifest.c mercurial/cext/mpatch.c
--- a/mercurial/cext/charencode.c Wed Feb 14 21:12:48 2018 -0500 +++ b/mercurial/cext/charencode.c Mon Feb 12 10:38:11 2018 -0500 @@ -151,9 +151,8 @@ Py_RETURN_TRUE; } -static inline PyObject *_asciitransform(PyObject *str_obj, - const char table[128], - PyObject *fallback_fn) +static inline PyObject * +_asciitransform(PyObject *str_obj, const char table[128], PyObject *fallback_fn) { char *str, *newstr; Py_ssize_t i, len; @@ -173,12 +172,12 @@ char c = str[i]; if (c & 0x80) { if (fallback_fn != NULL) { - ret = PyObject_CallFunctionObjArgs(fallback_fn, - str_obj, NULL); + ret = PyObject_CallFunctionObjArgs( + fallback_fn, str_obj, NULL); } else { PyObject *err = PyUnicodeDecodeError_Create( - "ascii", str, len, i, (i + 1), - "unexpected code byte"); + "ascii", str, len, i, (i + 1), + "unexpected code byte"); PyErr_SetObject(PyExc_UnicodeDecodeError, err); Py_XDECREF(err); } @@ -220,10 +219,9 @@ Py_ssize_t pos = 0; const char *table; - if (!PyArg_ParseTuple(args, "O!O!O!:make_file_foldmap", - &PyDict_Type, &dmap, - &PyInt_Type, &spec_obj, - &PyFunction_Type, &normcase_fallback)) + if (!PyArg_ParseTuple(args, "O!O!O!:make_file_foldmap", &PyDict_Type, + &dmap, &PyInt_Type, &spec_obj, &PyFunction_Type, + &normcase_fallback)) goto quit; spec = (int)PyInt_AS_LONG(spec_obj); @@ -251,7 +249,7 @@ while (PyDict_Next(dmap, &pos, &k, &v)) { if (!dirstate_tuple_check(v)) { PyErr_SetString(PyExc_TypeError, - "expected a dirstate tuple"); + "expected a dirstate tuple"); goto quit; } @@ -260,10 +258,10 @@ PyObject *normed; if (table != NULL) { normed = _asciitransform(k, table, - normcase_fallback); + normcase_fallback); } else { normed = PyObject_CallFunctionObjArgs( - normcase_fallback, k, NULL); + normcase_fallback, k, NULL); } if (normed == NULL) @@ -292,13 +290,13 @@ char c = buf[i]; if (c & 0x80) { PyErr_SetString(PyExc_ValueError, - "cannot process non-ascii str"); + "cannot process non-ascii str"); return -1; } esclen += jsonparanoidlentable[(unsigned char)c]; if (esclen < 0) { PyErr_SetString(PyExc_MemoryError, - "overflow in jsonescapelen"); + "overflow in jsonescapelen"); return -1; } } @@ -308,7 +306,7 @@ esclen += jsonlentable[(unsigned char)c]; if (esclen < 0) { PyErr_SetString(PyExc_MemoryError, - "overflow in jsonescapelen"); + "overflow in jsonescapelen"); return -1; } } @@ -336,17 +334,17 @@ case '\\': return '\\'; } - return '\0'; /* should not happen */ + return '\0'; /* should not happen */ } /* convert 'origbuf' to JSON-escaped form 'escbuf'; 'origbuf' should only include characters mappable by json(paranoid)lentable */ static void encodejsonescape(char *escbuf, Py_ssize_t esclen, - const char *origbuf, Py_ssize_t origlen, - bool paranoid) + const char *origbuf, Py_ssize_t origlen, + bool paranoid) { const uint8_t *lentable = - (paranoid) ? jsonparanoidlentable : jsonlentable; + (paranoid) ? jsonparanoidlentable : jsonlentable; Py_ssize_t i, j; for (i = 0, j = 0; i < origlen; i++) { @@ -377,15 +375,15 @@ const char *origbuf; Py_ssize_t origlen, esclen; int paranoid; - if (!PyArg_ParseTuple(args, "O!i:jsonescapeu8fast", - &PyBytes_Type, &origstr, ¶noid)) + if (!PyArg_ParseTuple(args, "O!i:jsonescapeu8fast", &PyBytes_Type, + &origstr, ¶noid)) return NULL; origbuf = PyBytes_AS_STRING(origstr); origlen = PyBytes_GET_SIZE(origstr); esclen = jsonescapelen(origbuf, origlen, paranoid); if (esclen < 0) - return NULL; /* unsupported char found or overflow */ + return NULL; /* unsupported char found or overflow */ if (origlen == esclen) { Py_INCREF(origstr); return origstr; @@ -395,7 +393,7 @@ if (!escstr) return NULL; encodejsonescape(PyBytes_AS_STRING(escstr), esclen, origbuf, origlen, - paranoid); + paranoid); return escstr; }