GeezerVison is showing github.com — bpo-20180: complete AC conversion of Objects/stringlib/transmogrify.h… · python/cpython@c929df3
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Objects/bytearrayobject.c +5-6Lines changed: 5 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2138,16 +2138,15 @@ bytearray_methods[] = { | 2138 | 2138 | BYTEARRAY_APPEND_METHODDEF | 2139 | 2139 | {"capitalize", stringlib_capitalize, METH_NOARGS, | 2140 | 2140 | _Py_capitalize__doc__}, | 2141 | | - {"center", (PyCFunction)stringlib_center, METH_VARARGS, _Py_center__doc__}, | | 2141 | + STRINGLIB_CENTER_METHODDEF | 2142 | 2142 | BYTEARRAY_CLEAR_METHODDEF | 2143 | 2143 | BYTEARRAY_COPY_METHODDEF | 2144 | 2144 | {"count", (PyCFunction)bytearray_count, METH_VARARGS, | 2145 | 2145 | _Py_count__doc__}, | 2146 | 2146 | BYTEARRAY_DECODE_METHODDEF | 2147 | 2147 | {"endswith", (PyCFunction)bytearray_endswith, METH_VARARGS, | 2148 | 2148 | _Py_endswith__doc__}, | 2149 | | - {"expandtabs", (PyCFunction)stringlib_expandtabs, METH_VARARGS | METH_KEYWORDS, | 2150 | | - _Py_expandtabs__doc__}, | | 2149 | + STRINGLIB_EXPANDTABS_METHODDEF | 2151 | 2150 | BYTEARRAY_EXTEND_METHODDEF | 2152 | 2151 | {"find", (PyCFunction)bytearray_find, METH_VARARGS, | 2153 | 2152 | _Py_find__doc__}, | @@ -2172,7 +2171,7 @@ bytearray_methods[] = { | 2172 | 2171 | {"isupper", stringlib_isupper, METH_NOARGS, | 2173 | 2172 | _Py_isupper__doc__}, | 2174 | 2173 | BYTEARRAY_JOIN_METHODDEF | 2175 | | - {"ljust", (PyCFunction)stringlib_ljust, METH_VARARGS, _Py_ljust__doc__}, | | 2174 | + STRINGLIB_LJUST_METHODDEF | 2176 | 2175 | {"lower", stringlib_lower, METH_NOARGS, _Py_lower__doc__}, | 2177 | 2176 | BYTEARRAY_LSTRIP_METHODDEF | 2178 | 2177 | BYTEARRAY_MAKETRANS_METHODDEF | @@ -2183,7 +2182,7 @@ bytearray_methods[] = { | 2183 | 2182 | BYTEARRAY_REVERSE_METHODDEF | 2184 | 2183 | {"rfind", (PyCFunction)bytearray_rfind, METH_VARARGS, _Py_rfind__doc__}, | 2185 | 2184 | {"rindex", (PyCFunction)bytearray_rindex, METH_VARARGS, _Py_rindex__doc__}, | 2186 | | - {"rjust", (PyCFunction)stringlib_rjust, METH_VARARGS, _Py_rjust__doc__}, | | 2185 | + STRINGLIB_RJUST_METHODDEF | 2187 | 2186 | BYTEARRAY_RPARTITION_METHODDEF | 2188 | 2187 | BYTEARRAY_RSPLIT_METHODDEF | 2189 | 2188 | BYTEARRAY_RSTRIP_METHODDEF | @@ -2197,7 +2196,7 @@ bytearray_methods[] = { | 2197 | 2196 | {"title", stringlib_title, METH_NOARGS, _Py_title__doc__}, | 2198 | 2197 | BYTEARRAY_TRANSLATE_METHODDEF | 2199 | 2198 | {"upper", stringlib_upper, METH_NOARGS, _Py_upper__doc__}, | 2200 | | - {"zfill", (PyCFunction)stringlib_zfill, METH_VARARGS, _Py_zfill__doc__}, | | 2199 | + STRINGLIB_ZFILL_METHODDEF | 2201 | 2200 | {NULL} | 2202 | 2201 | }; | 2203 | 2202 |
| |
Collapse file Copy file name to clipboardExpand all lines: Objects/bytes_methods.c -30Lines changed: 0 additions & 30 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -845,33 +845,3 @@ _Py_bytes_endswith(const char *str, Py_ssize_t len, PyObject *args) | 845 | 845 | { | 846 | 846 | return _Py_bytes_tailmatch(str, len, "endswith", args, +1); | 847 | 847 | } | 848 | | - | 849 | | -PyDoc_STRVAR_shared(_Py_expandtabs__doc__, | 850 | | -"B.expandtabs(tabsize=8) -> copy of B\n\ | 851 | | -\n\ | 852 | | -Return a copy of B where all tab characters are expanded using spaces.\n\ | 853 | | -If tabsize is not given, a tab size of 8 characters is assumed."); | 854 | | - | 855 | | -PyDoc_STRVAR_shared(_Py_ljust__doc__, | 856 | | -"B.ljust(width[, fillchar]) -> copy of B\n" | 857 | | -"\n" | 858 | | -"Return B left justified in a string of length width. Padding is\n" | 859 | | -"done using the specified fill character (default is a space)."); | 860 | | - | 861 | | -PyDoc_STRVAR_shared(_Py_rjust__doc__, | 862 | | -"B.rjust(width[, fillchar]) -> copy of B\n" | 863 | | -"\n" | 864 | | -"Return B right justified in a string of length width. Padding is\n" | 865 | | -"done using the specified fill character (default is a space)"); | 866 | | - | 867 | | -PyDoc_STRVAR_shared(_Py_center__doc__, | 868 | | -"B.center(width[, fillchar]) -> copy of B\n" | 869 | | -"\n" | 870 | | -"Return B centered in a string of length width. Padding is\n" | 871 | | -"done using the specified fill character (default is a space)."); | 872 | | - | 873 | | -PyDoc_STRVAR_shared(_Py_zfill__doc__, | 874 | | -"B.zfill(width) -> copy of B\n" | 875 | | -"\n" | 876 | | -"Pad a numeric string B with zeros on the left, to fill a field\n" | 877 | | -"of the specified width. B is never truncated."); |
Collapse file Copy file name to clipboardExpand all lines: Objects/bytesobject.c +5-7Lines changed: 5 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2441,15 +2441,13 @@ bytes_methods[] = { | 2441 | 2441 | {"__getnewargs__", (PyCFunction)bytes_getnewargs, METH_NOARGS}, | 2442 | 2442 | {"capitalize", stringlib_capitalize, METH_NOARGS, | 2443 | 2443 | _Py_capitalize__doc__}, | 2444 | | - {"center", (PyCFunction)stringlib_center, METH_VARARGS, | 2445 | | - _Py_center__doc__}, | | 2444 | + STRINGLIB_CENTER_METHODDEF | 2446 | 2445 | {"count", (PyCFunction)bytes_count, METH_VARARGS, | 2447 | 2446 | _Py_count__doc__}, | 2448 | 2447 | BYTES_DECODE_METHODDEF | 2449 | 2448 | {"endswith", (PyCFunction)bytes_endswith, METH_VARARGS, | 2450 | 2449 | _Py_endswith__doc__}, | 2451 | | - {"expandtabs", (PyCFunction)stringlib_expandtabs, METH_VARARGS | METH_KEYWORDS, | 2452 | | - _Py_expandtabs__doc__}, | | 2450 | + STRINGLIB_EXPANDTABS_METHODDEF | 2453 | 2451 | {"find", (PyCFunction)bytes_find, METH_VARARGS, | 2454 | 2452 | _Py_find__doc__}, | 2455 | 2453 | BYTES_FROMHEX_METHODDEF | @@ -2472,15 +2470,15 @@ bytes_methods[] = { | 2472 | 2470 | {"isupper", stringlib_isupper, METH_NOARGS, | 2473 | 2471 | _Py_isupper__doc__}, | 2474 | 2472 | BYTES_JOIN_METHODDEF | 2475 | | - {"ljust", (PyCFunction)stringlib_ljust, METH_VARARGS, _Py_ljust__doc__}, | | 2473 | + STRINGLIB_LJUST_METHODDEF | 2476 | 2474 | {"lower", stringlib_lower, METH_NOARGS, _Py_lower__doc__}, | 2477 | 2475 | BYTES_LSTRIP_METHODDEF | 2478 | 2476 | BYTES_MAKETRANS_METHODDEF | 2479 | 2477 | BYTES_PARTITION_METHODDEF | 2480 | 2478 | BYTES_REPLACE_METHODDEF | 2481 | 2479 | {"rfind", (PyCFunction)bytes_rfind, METH_VARARGS, _Py_rfind__doc__}, | 2482 | 2480 | {"rindex", (PyCFunction)bytes_rindex, METH_VARARGS, _Py_rindex__doc__}, | 2483 | | - {"rjust", (PyCFunction)stringlib_rjust, METH_VARARGS, _Py_rjust__doc__}, | | 2481 | + STRINGLIB_RJUST_METHODDEF | 2484 | 2482 | BYTES_RPARTITION_METHODDEF | 2485 | 2483 | BYTES_RSPLIT_METHODDEF | 2486 | 2484 | BYTES_RSTRIP_METHODDEF | @@ -2494,7 +2492,7 @@ bytes_methods[] = { | 2494 | 2492 | {"title", stringlib_title, METH_NOARGS, _Py_title__doc__}, | 2495 | 2493 | BYTES_TRANSLATE_METHODDEF | 2496 | 2494 | {"upper", stringlib_upper, METH_NOARGS, _Py_upper__doc__}, | 2497 | | - {"zfill", (PyCFunction)stringlib_zfill, METH_VARARGS, _Py_zfill__doc__}, | | 2495 | + STRINGLIB_ZFILL_METHODDEF | 2498 | 2496 | {NULL, NULL} /* sentinel */ | 2499 | 2497 | }; | 2500 | 2498 |
| |
Collapse file Copy file name to clipboard +158Lines changed: 158 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +/*[clinic input] | | 2 | +preserve | | 3 | +[clinic start generated code]*/ | | 4 | + | | 5 | +PyDoc_STRVAR(stringlib_expandtabs__doc__, | | 6 | +"expandtabs($self, /, tabsize=8)\n" | | 7 | +"--\n" | | 8 | +"\n" | | 9 | +"Return a copy where all tab characters are expanded using spaces.\n" | | 10 | +"\n" | | 11 | +"If tabsize is not given, a tab size of 8 characters is assumed."); | | 12 | + | | 13 | +#define STRINGLIB_EXPANDTABS_METHODDEF \ | | 14 | + {"expandtabs", (PyCFunction)stringlib_expandtabs, METH_FASTCALL|METH_KEYWORDS, stringlib_expandtabs__doc__}, | | 15 | + | | 16 | +static PyObject * | | 17 | +stringlib_expandtabs_impl(PyObject *self, int tabsize); | | 18 | + | | 19 | +static PyObject * | | 20 | +stringlib_expandtabs(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) | | 21 | +{ | | 22 | + PyObject *return_value = NULL; | | 23 | + static const char * const _keywords[] = {"tabsize", NULL}; | | 24 | + static _PyArg_Parser _parser = {"|i:expandtabs", _keywords, 0}; | | 25 | + int tabsize = 8; | | 26 | + | | 27 | + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, | | 28 | + &tabsize)) { | | 29 | + goto exit; | | 30 | + } | | 31 | + return_value = stringlib_expandtabs_impl(self, tabsize); | | 32 | + | | 33 | +exit: | | 34 | + return return_value; | | 35 | +} | | 36 | + | | 37 | +PyDoc_STRVAR(stringlib_ljust__doc__, | | 38 | +"ljust($self, width, fillchar=b\' \', /)\n" | | 39 | +"--\n" | | 40 | +"\n" | | 41 | +"Return a left-justified string of length width.\n" | | 42 | +"\n" | | 43 | +"Padding is done using the specified fill character."); | | 44 | + | | 45 | +#define STRINGLIB_LJUST_METHODDEF \ | | 46 | + {"ljust", (PyCFunction)stringlib_ljust, METH_FASTCALL, stringlib_ljust__doc__}, | | 47 | + | | 48 | +static PyObject * | | 49 | +stringlib_ljust_impl(PyObject *self, Py_ssize_t width, char fillchar); | | 50 | + | | 51 | +static PyObject * | | 52 | +stringlib_ljust(PyObject *self, PyObject *const *args, Py_ssize_t nargs) | | 53 | +{ | | 54 | + PyObject *return_value = NULL; | | 55 | + Py_ssize_t width; | | 56 | + char fillchar = ' '; | | 57 | + | | 58 | + if (!_PyArg_ParseStack(args, nargs, "n|c:ljust", | | 59 | + &width, &fillchar)) { | | 60 | + goto exit; | | 61 | + } | | 62 | + return_value = stringlib_ljust_impl(self, width, fillchar); | | 63 | + | | 64 | +exit: | | 65 | + return return_value; | | 66 | +} | | 67 | + | | 68 | +PyDoc_STRVAR(stringlib_rjust__doc__, | | 69 | +"rjust($self, width, fillchar=b\' \', /)\n" | | 70 | +"--\n" | | 71 | +"\n" | | 72 | +"Return a right-justified string of length width.\n" | | 73 | +"\n" | | 74 | +"Padding is done using the specified fill character."); | | 75 | + | | 76 | +#define STRINGLIB_RJUST_METHODDEF \ | | 77 | + {"rjust", (PyCFunction)stringlib_rjust, METH_FASTCALL, stringlib_rjust__doc__}, | | 78 | + | | 79 | +static PyObject * | | 80 | +stringlib_rjust_impl(PyObject *self, Py_ssize_t width, char fillchar); | | 81 | + | | 82 | +static PyObject * | | 83 | +stringlib_rjust(PyObject *self, PyObject *const *args, Py_ssize_t nargs) | | 84 | +{ | | 85 | + PyObject *return_value = NULL; | | 86 | + Py_ssize_t width; | | 87 | + char fillchar = ' '; | | 88 | + | | 89 | + if (!_PyArg_ParseStack(args, nargs, "n|c:rjust", | | 90 | + &width, &fillchar)) { | | 91 | + goto exit; | | 92 | + } | | 93 | + return_value = stringlib_rjust_impl(self, width, fillchar); | | 94 | + | | 95 | +exit: | | 96 | + return return_value; | | 97 | +} | | 98 | + | | 99 | +PyDoc_STRVAR(stringlib_center__doc__, | | 100 | +"center($self, width, fillchar=b\' \', /)\n" | | 101 | +"--\n" | | 102 | +"\n" | | 103 | +"Return a centered string of length width.\n" | | 104 | +"\n" | | 105 | +"Padding is done using the specified fill character."); | | 106 | + | | 107 | +#define STRINGLIB_CENTER_METHODDEF \ | | 108 | + {"center", (PyCFunction)stringlib_center, METH_FASTCALL, stringlib_center__doc__}, | | 109 | + | | 110 | +static PyObject * | | 111 | +stringlib_center_impl(PyObject *self, Py_ssize_t width, char fillchar); | | 112 | + | | 113 | +static PyObject * | | 114 | +stringlib_center(PyObject *self, PyObject *const *args, Py_ssize_t nargs) | | 115 | +{ | | 116 | + PyObject *return_value = NULL; | | 117 | + Py_ssize_t width; | | 118 | + char fillchar = ' '; | | 119 | + | | 120 | + if (!_PyArg_ParseStack(args, nargs, "n|c:center", | | 121 | + &width, &fillchar)) { | | 122 | + goto exit; | | 123 | + } | | 124 | + return_value = stringlib_center_impl(self, width, fillchar); | | 125 | + | | 126 | +exit: | | 127 | + return return_value; | | 128 | +} | | 129 | + | | 130 | +PyDoc_STRVAR(stringlib_zfill__doc__, | | 131 | +"zfill($self, width, /)\n" | | 132 | +"--\n" | | 133 | +"\n" | | 134 | +"Pad a numeric string with zeros on the left, to fill a field of the given width.\n" | | 135 | +"\n" | | 136 | +"The original string is never truncated."); | | 137 | + | | 138 | +#define STRINGLIB_ZFILL_METHODDEF \ | | 139 | + {"zfill", (PyCFunction)stringlib_zfill, METH_O, stringlib_zfill__doc__}, | | 140 | + | | 141 | +static PyObject * | | 142 | +stringlib_zfill_impl(PyObject *self, Py_ssize_t width); | | 143 | + | | 144 | +static PyObject * | | 145 | +stringlib_zfill(PyObject *self, PyObject *arg) | | 146 | +{ | | 147 | + PyObject *return_value = NULL; | | 148 | + Py_ssize_t width; | | 149 | + | | 150 | + if (!PyArg_Parse(arg, "n:zfill", &width)) { | | 151 | + goto exit; | | 152 | + } | | 153 | + return_value = stringlib_zfill_impl(self, width); | | 154 | + | | 155 | +exit: | | 156 | + return return_value; | | 157 | +} | | 158 | +/*[clinic end generated code: output=336620159a1fc70d input=a9049054013a1b77]*/ |
|