##// END OF EJS Templates
parsers: introduce an asciiupper function
Siddharth Agarwal -
r24577:bf55df00 default
parent child Browse files
Show More
@@ -56,6 +56,27 b' static char lowertable[128] = {'
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]];
@@ -138,6 +159,14 b' static PyObject *asciilower(PyObject *se'
138 return _asciitransform(str_obj, lowertable);
159 return _asciitransform(str_obj, lowertable);
139 }
160 }
140
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);
168 }
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.
@@ -2427,6 +2456,7 b' static PyMethodDef methods[] = {'
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"},
General Comments 0
You need to be logged in to leave comments. Login now