#if STRINGLIB_IS_UNICODE # error "transmogrify.h only compatible with byte-wise strings" #endif /* the more complicated methods. parts of these should be pulled out into the shared code in bytes_methods.c to cut down on duplicate code bloat. */ /*[clinic input] class B "PyObject *" "&PyType_Type" [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=2935558188d97c76]*/ #include "clinic/transmogrify.h.h" static inline PyObject * return_self(PyObject *self) { … } /*[clinic input] B.expandtabs as stringlib_expandtabs tabsize: int = 8 Return a copy where all tab characters are expanded using spaces. If tabsize is not given, a tab size of 8 characters is assumed. [clinic start generated code]*/ static PyObject * stringlib_expandtabs_impl(PyObject *self, int tabsize) /*[clinic end generated code: output=069cb7fae72e4c2b input=3c6d3b12aa3ccbea]*/ { … } static inline PyObject * pad(PyObject *self, Py_ssize_t left, Py_ssize_t right, char fill) { … } /*[clinic input] B.ljust as stringlib_ljust width: Py_ssize_t fillchar: char = b' ' / Return a left-justified string of length width. Padding is done using the specified fill character. [clinic start generated code]*/ static PyObject * stringlib_ljust_impl(PyObject *self, Py_ssize_t width, char fillchar) /*[clinic end generated code: output=c79ca173c5ff8337 input=eff2d014bc7d80df]*/ { … } /*[clinic input] B.rjust as stringlib_rjust width: Py_ssize_t fillchar: char = b' ' / Return a right-justified string of length width. Padding is done using the specified fill character. [clinic start generated code]*/ static PyObject * stringlib_rjust_impl(PyObject *self, Py_ssize_t width, char fillchar) /*[clinic end generated code: output=7df5d728a5439570 input=218b0bd31308955d]*/ { … } /*[clinic input] B.center as stringlib_center width: Py_ssize_t fillchar: char = b' ' / Return a centered string of length width. Padding is done using the specified fill character. [clinic start generated code]*/ static PyObject * stringlib_center_impl(PyObject *self, Py_ssize_t width, char fillchar) /*[clinic end generated code: output=d8da2e055288b4c2 input=3776fd278765d89b]*/ { … } /*[clinic input] B.zfill as stringlib_zfill width: Py_ssize_t / Pad a numeric string with zeros on the left, to fill a field of the given width. The original string is never truncated. [clinic start generated code]*/ static PyObject * stringlib_zfill_impl(PyObject *self, Py_ssize_t width) /*[clinic end generated code: output=0b3c684a7f1b2319 input=2da6d7b8e9bcb19a]*/ { … } /* find and count characters and substrings */ #define findchar … static Py_ssize_t countchar(const char *target, Py_ssize_t target_len, char c, Py_ssize_t maxcount) { … } /* Algorithms for different cases of string replacement */ /* len(self)>=1, from="", len(to)>=1, maxcount>=1 */ static PyObject * stringlib_replace_interleave(PyObject *self, const char *to_s, Py_ssize_t to_len, Py_ssize_t maxcount) { … } /* Special case for deleting a single character */ /* len(self)>=1, len(from)==1, to="", maxcount>=1 */ static PyObject * stringlib_replace_delete_single_character(PyObject *self, char from_c, Py_ssize_t maxcount) { … } /* len(self)>=1, len(from)>=2, to="", maxcount>=1 */ static PyObject * stringlib_replace_delete_substring(PyObject *self, const char *from_s, Py_ssize_t from_len, Py_ssize_t maxcount) { … } /* len(self)>=1, len(from)==len(to)==1, maxcount>=1 */ static PyObject * stringlib_replace_single_character_in_place(PyObject *self, char from_c, char to_c, Py_ssize_t maxcount) { … } /* len(self)>=1, len(from)==len(to)>=2, maxcount>=1 */ static PyObject * stringlib_replace_substring_in_place(PyObject *self, const char *from_s, Py_ssize_t from_len, const char *to_s, Py_ssize_t to_len, Py_ssize_t maxcount) { … } /* len(self)>=1, len(from)==1, len(to)>=2, maxcount>=1 */ static PyObject * stringlib_replace_single_character(PyObject *self, char from_c, const char *to_s, Py_ssize_t to_len, Py_ssize_t maxcount) { … } /* len(self)>=1, len(from)>=2, len(to)>=2, maxcount>=1 */ static PyObject * stringlib_replace_substring(PyObject *self, const char *from_s, Py_ssize_t from_len, const char *to_s, Py_ssize_t to_len, Py_ssize_t maxcount) { … } static PyObject * stringlib_replace(PyObject *self, const char *from_s, Py_ssize_t from_len, const char *to_s, Py_ssize_t to_len, Py_ssize_t maxcount) { … } #undef findchar