summaryrefslogtreecommitdiffstats
path: root/Objects/bytes_methods.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/bytes_methods.c')
-rw-r--r--Objects/bytes_methods.c63
1 files changed, 21 insertions, 42 deletions
diff --git a/Objects/bytes_methods.c b/Objects/bytes_methods.c
index ef3c2f7..9ff7ace 100644
--- a/Objects/bytes_methods.c
+++ b/Objects/bytes_methods.c
@@ -10,9 +10,9 @@ and there is at least one character in B, False otherwise.");
PyObject*
_Py_bytes_isspace(const char *cptr, Py_ssize_t len)
{
- register const unsigned char *p
+ const unsigned char *p
= (unsigned char *) cptr;
- register const unsigned char *e;
+ const unsigned char *e;
/* Shortcut for single character strings */
if (len == 1 && Py_ISSPACE(*p))
@@ -40,9 +40,9 @@ and there is at least one character in B, False otherwise.");
PyObject*
_Py_bytes_isalpha(const char *cptr, Py_ssize_t len)
{
- register const unsigned char *p
+ const unsigned char *p
= (unsigned char *) cptr;
- register const unsigned char *e;
+ const unsigned char *e;
/* Shortcut for single character strings */
if (len == 1 && Py_ISALPHA(*p))
@@ -70,9 +70,9 @@ and there is at least one character in B, False otherwise.");
PyObject*
_Py_bytes_isalnum(const char *cptr, Py_ssize_t len)
{
- register const unsigned char *p
+ const unsigned char *p
= (unsigned char *) cptr;
- register const unsigned char *e;
+ const unsigned char *e;
/* Shortcut for single character strings */
if (len == 1 && Py_ISALNUM(*p))
@@ -100,9 +100,9 @@ and there is at least one character in B, False otherwise.");
PyObject*
_Py_bytes_isdigit(const char *cptr, Py_ssize_t len)
{
- register const unsigned char *p
+ const unsigned char *p
= (unsigned char *) cptr;
- register const unsigned char *e;
+ const unsigned char *e;
/* Shortcut for single character strings */
if (len == 1 && Py_ISDIGIT(*p))
@@ -130,9 +130,9 @@ at least one cased character in B, False otherwise.");
PyObject*
_Py_bytes_islower(const char *cptr, Py_ssize_t len)
{
- register const unsigned char *p
+ const unsigned char *p
= (unsigned char *) cptr;
- register const unsigned char *e;
+ const unsigned char *e;
int cased;
/* Shortcut for single character strings */
@@ -164,9 +164,9 @@ at least one cased character in B, False otherwise.");
PyObject*
_Py_bytes_isupper(const char *cptr, Py_ssize_t len)
{
- register const unsigned char *p
+ const unsigned char *p
= (unsigned char *) cptr;
- register const unsigned char *e;
+ const unsigned char *e;
int cased;
/* Shortcut for single character strings */
@@ -200,9 +200,9 @@ otherwise.");
PyObject*
_Py_bytes_istitle(const char *cptr, Py_ssize_t len)
{
- register const unsigned char *p
+ const unsigned char *p
= (unsigned char *) cptr;
- register const unsigned char *e;
+ const unsigned char *e;
int cased, previous_is_cased;
/* Shortcut for single character strings */
@@ -217,7 +217,7 @@ _Py_bytes_istitle(const char *cptr, Py_ssize_t len)
cased = 0;
previous_is_cased = 0;
for (; p < e; p++) {
- register const unsigned char ch = *p;
+ const unsigned char ch = *p;
if (Py_ISUPPER(ch)) {
if (previous_is_cased)
@@ -363,41 +363,20 @@ for use in the bytes or bytearray translate method where each byte\n\
in frm is mapped to the byte at the same position in to.\n\
The bytes objects frm and to must be of the same length.");
-static Py_ssize_t
-_getbuffer(PyObject *obj, Py_buffer *view)
-{
- PyBufferProcs *buffer = Py_TYPE(obj)->tp_as_buffer;
-
- if (buffer == NULL || buffer->bf_getbuffer == NULL)
- {
- PyErr_Format(PyExc_TypeError,
- "Type %.100s doesn't support the buffer API",
- Py_TYPE(obj)->tp_name);
- return -1;
- }
-
- if (buffer->bf_getbuffer(obj, view, PyBUF_SIMPLE) < 0)
- return -1;
- return view->len;
-}
-
PyObject *
_Py_bytes_maketrans(PyObject *args)
{
- PyObject *frm, *to, *res = NULL;
- Py_buffer bfrm, bto;
+ PyObject *res = NULL;
+ Py_buffer bfrm = {NULL, NULL};
+ Py_buffer bto = {NULL, NULL};
Py_ssize_t i;
char *p;
bfrm.len = -1;
bto.len = -1;
- if (!PyArg_ParseTuple(args, "OO:maketrans", &frm, &to))
- return NULL;
- if (_getbuffer(frm, &bfrm) < 0)
+ if (!PyArg_ParseTuple(args, "y*y*:maketrans", &bfrm, &bto))
return NULL;
- if (_getbuffer(to, &bto) < 0)
- goto done;
if (bfrm.len != bto.len) {
PyErr_Format(PyExc_ValueError,
"maketrans arguments must have same length");
@@ -415,9 +394,9 @@ _Py_bytes_maketrans(PyObject *args)
}
done:
- if (bfrm.len != -1)
+ if (bfrm.obj != NULL)
PyBuffer_Release(&bfrm);
- if (bto.len != -1)
+ if (bfrm.obj != NULL)
PyBuffer_Release(&bto);
return res;
}