Mercurial > hg
comparison mercurial/parsers.c @ 24577:bf55df007535
parsers: introduce an asciiupper function
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Tue, 31 Mar 2015 13:46:21 -0700 |
parents | fe173106e7fe |
children | e4a733c34bc6 |
comparison
equal
deleted
inserted
replaced
24576:fe173106e7fe | 24577:bf55df007535 |
---|---|
54 '\x68', '\x69', '\x6a', '\x6b', '\x6c', '\x6d', '\x6e', '\x6f', | 54 '\x68', '\x69', '\x6a', '\x6b', '\x6c', '\x6d', '\x6e', '\x6f', |
55 '\x70', '\x71', '\x72', '\x73', '\x74', '\x75', '\x76', '\x77', | 55 '\x70', '\x71', '\x72', '\x73', '\x74', '\x75', '\x76', '\x77', |
56 '\x78', '\x79', '\x7a', '\x7b', '\x7c', '\x7d', '\x7e', '\x7f' | 56 '\x78', '\x79', '\x7a', '\x7b', '\x7c', '\x7d', '\x7e', '\x7f' |
57 }; | 57 }; |
58 | 58 |
59 static char uppertable[128] = { | |
60 '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', | |
61 '\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f', | |
62 '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', | |
63 '\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f', | |
64 '\x20', '\x21', '\x22', '\x23', '\x24', '\x25', '\x26', '\x27', | |
65 '\x28', '\x29', '\x2a', '\x2b', '\x2c', '\x2d', '\x2e', '\x2f', | |
66 '\x30', '\x31', '\x32', '\x33', '\x34', '\x35', '\x36', '\x37', | |
67 '\x38', '\x39', '\x3a', '\x3b', '\x3c', '\x3d', '\x3e', '\x3f', | |
68 '\x40', '\x41', '\x42', '\x43', '\x44', '\x45', '\x46', '\x47', | |
69 '\x48', '\x49', '\x4a', '\x4b', '\x4c', '\x4d', '\x4e', '\x4f', | |
70 '\x50', '\x51', '\x52', '\x53', '\x54', '\x55', '\x56', '\x57', | |
71 '\x58', '\x59', '\x5a', '\x5b', '\x5c', '\x5d', '\x5e', '\x5f', | |
72 '\x60', | |
73 '\x41', '\x42', '\x43', '\x44', '\x45', '\x46', '\x47', /* a-g */ | |
74 '\x48', '\x49', '\x4a', '\x4b', '\x4c', '\x4d', '\x4e', '\x4f', /* h-o */ | |
75 '\x50', '\x51', '\x52', '\x53', '\x54', '\x55', '\x56', '\x57', /* p-w */ | |
76 '\x58', '\x59', '\x5a', /* x-z */ | |
77 '\x7b', '\x7c', '\x7d', '\x7e', '\x7f' | |
78 }; | |
79 | |
59 static inline int hexdigit(const char *p, Py_ssize_t off) | 80 static inline int hexdigit(const char *p, Py_ssize_t off) |
60 { | 81 { |
61 int8_t val = hextable[(unsigned char)p[off]]; | 82 int8_t val = hextable[(unsigned char)p[off]]; |
62 | 83 |
63 if (val >= 0) { | 84 if (val >= 0) { |
134 { | 155 { |
135 PyObject *str_obj; | 156 PyObject *str_obj; |
136 if (!PyArg_ParseTuple(args, "O!:asciilower", &PyBytes_Type, &str_obj)) | 157 if (!PyArg_ParseTuple(args, "O!:asciilower", &PyBytes_Type, &str_obj)) |
137 return NULL; | 158 return NULL; |
138 return _asciitransform(str_obj, lowertable); | 159 return _asciitransform(str_obj, lowertable); |
160 } | |
161 | |
162 static PyObject *asciiupper(PyObject *self, PyObject *args) | |
163 { | |
164 PyObject *str_obj; | |
165 if (!PyArg_ParseTuple(args, "O!:asciiupper", &PyBytes_Type, &str_obj)) | |
166 return NULL; | |
167 return _asciitransform(str_obj, uppertable); | |
139 } | 168 } |
140 | 169 |
141 /* | 170 /* |
142 * This code assumes that a manifest is stitched together with newline | 171 * This code assumes that a manifest is stitched together with newline |
143 * ('\n') characters. | 172 * ('\n') characters. |
2425 {"pack_dirstate", pack_dirstate, METH_VARARGS, "pack a dirstate\n"}, | 2454 {"pack_dirstate", pack_dirstate, METH_VARARGS, "pack a dirstate\n"}, |
2426 {"parse_manifest", parse_manifest, METH_VARARGS, "parse a manifest\n"}, | 2455 {"parse_manifest", parse_manifest, METH_VARARGS, "parse a manifest\n"}, |
2427 {"parse_dirstate", parse_dirstate, METH_VARARGS, "parse a dirstate\n"}, | 2456 {"parse_dirstate", parse_dirstate, METH_VARARGS, "parse a dirstate\n"}, |
2428 {"parse_index2", parse_index2, METH_VARARGS, "parse a revlog index\n"}, | 2457 {"parse_index2", parse_index2, METH_VARARGS, "parse a revlog index\n"}, |
2429 {"asciilower", asciilower, METH_VARARGS, "lowercase an ASCII string\n"}, | 2458 {"asciilower", asciilower, METH_VARARGS, "lowercase an ASCII string\n"}, |
2459 {"asciiupper", asciiupper, METH_VARARGS, "uppercase an ASCII string\n"}, | |
2430 {"encodedir", encodedir, METH_VARARGS, "encodedir a path\n"}, | 2460 {"encodedir", encodedir, METH_VARARGS, "encodedir a path\n"}, |
2431 {"pathencode", pathencode, METH_VARARGS, "fncache-encode a path\n"}, | 2461 {"pathencode", pathencode, METH_VARARGS, "fncache-encode a path\n"}, |
2432 {"lowerencode", lowerencode, METH_VARARGS, "lower-encode a path\n"}, | 2462 {"lowerencode", lowerencode, METH_VARARGS, "lower-encode a path\n"}, |
2433 {"fm1readmarkers", fm1readmarkers, METH_VARARGS, | 2463 {"fm1readmarkers", fm1readmarkers, METH_VARARGS, |
2434 "parse v1 obsolete markers\n"}, | 2464 "parse v1 obsolete markers\n"}, |