|
4 | 4 |
|
5 | 5 | #include <Python.h> |
6 | 6 | #include "CPy.h" |
7 | | -#include <string.h> |
8 | 7 |
|
9 | 8 | // Returns -1 on error, 0 on inequality, 1 on equality. |
10 | 9 | // |
@@ -163,51 +162,3 @@ CPyTagged CPyBytes_Ord(PyObject *obj) { |
163 | 162 | PyErr_SetString(PyExc_TypeError, "ord() expects a character"); |
164 | 163 | return CPY_INT_TAG; |
165 | 164 | } |
166 | | - |
167 | | -PyObject *CPyBytes_Rjust(PyObject *self, Py_ssize_t width, PyObject *fillbyte) { |
168 | | - if (!PyBytes_Check(self)) { |
169 | | - PyErr_SetString(PyExc_TypeError, "self must be bytes"); |
170 | | - return NULL; |
171 | | - } |
172 | | - if (!PyBytes_Check(fillbyte) || PyBytes_Size(fillbyte) != 1) { |
173 | | - PyErr_SetString(PyExc_TypeError, "fillbyte must be a single byte"); |
174 | | - return NULL; |
175 | | - } |
176 | | - Py_ssize_t len = PyBytes_Size(self); |
177 | | - if (width <= len) { |
178 | | - return PyBytes_FromStringAndSize(PyBytes_AsString(self), len); |
179 | | - } |
180 | | - char fill = PyBytes_AsString(fillbyte)[0]; |
181 | | - Py_ssize_t pad = width - len; |
182 | | - PyObject *result = PyBytes_FromStringAndSize(NULL, width); |
183 | | - if (!result) return NULL; |
184 | | - char *res_buf = PyBytes_AsString(result); |
185 | | - memset(res_buf, fill, pad); |
186 | | - memcpy(res_buf + pad, PyBytes_AsString(self), len); |
187 | | - return result; |
188 | | -} |
189 | | - |
190 | | -PyObject *CPyBytes_Ljust(PyObject *self, Py_ssize_t width, PyObject *fillbyte) { |
191 | | - if (!PyBytes_Check(self)) { |
192 | | - PyErr_SetString(PyExc_TypeError, "self must be bytes"); |
193 | | - return NULL; |
194 | | - } |
195 | | - if (!PyBytes_Check(fillbyte) || PyBytes_Size(fillbyte) != 1) { |
196 | | - PyErr_SetString(PyExc_TypeError, "fillbyte must be a single byte"); |
197 | | - return NULL; |
198 | | - } |
199 | | - Py_ssize_t len = PyBytes_Size(self); |
200 | | - if (width <= len) { |
201 | | - return PyBytes_FromStringAndSize(PyBytes_AsString(self), len); |
202 | | - } |
203 | | - char fill = PyBytes_AsString(fillbyte)[0]; |
204 | | - Py_ssize_t pad = width - len; |
205 | | - PyObject *result = PyBytes_FromStringAndSize(NULL, width); |
206 | | - if (!result) return NULL; |
207 | | - char *res_buf = PyBytes_AsString(result); |
208 | | - memcpy(res_buf, PyBytes_AsString(self), len); |
209 | | - memset(res_buf + len, fill, pad); |
210 | | - return result; |
211 | | -} |
212 | | - |
213 | | -// ... existing code ... |
0 commit comments