Mercurial > hg
changeset 24576:fe173106e7fe
parsers: make _asciilower a generic _asciitransform function
We can now pass in whatever table we like. For example, an upcoming patch will
introduce asciiupper.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Tue, 31 Mar 2015 10:28:17 -0700 |
parents | a62e957413f7 |
children | bf55df007535 |
files | mercurial/parsers.c |
diffstat | 1 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/parsers.c Wed Apr 01 13:58:51 2015 -0700 +++ b/mercurial/parsers.c Tue Mar 31 10:28:17 2015 -0700 @@ -93,7 +93,8 @@ return ret; } -static inline PyObject *_asciilower(PyObject *str_obj) +static inline PyObject *_asciitransform(PyObject *str_obj, + const char table[128]) { char *str, *newstr; Py_ssize_t i, len; @@ -119,7 +120,7 @@ Py_XDECREF(err); goto quit; } - newstr[i] = lowertable[(unsigned char)c]; + newstr[i] = table[(unsigned char)c]; } ret = newobj; @@ -134,7 +135,7 @@ PyObject *str_obj; if (!PyArg_ParseTuple(args, "O!:asciilower", &PyBytes_Type, &str_obj)) return NULL; - return _asciilower(str_obj); + return _asciitransform(str_obj, lowertable); } /*