2016-05-16 03:42:29 -03:00
|
|
|
#if STRINGLIB_IS_UNICODE
|
|
|
|
# error "ctype.h only compatible with byte-wise strings"
|
|
|
|
#endif
|
2007-10-16 03:31:30 -03:00
|
|
|
|
2020-02-12 17:32:34 -04:00
|
|
|
#include "pycore_bytes_methods.h"
|
2007-10-16 03:31:30 -03:00
|
|
|
|
|
|
|
static PyObject*
|
2018-04-29 15:59:33 -03:00
|
|
|
stringlib_isspace(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2007-10-16 03:31:30 -03:00
|
|
|
{
|
|
|
|
return _Py_bytes_isspace(STRINGLIB_STR(self), STRINGLIB_LEN(self));
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject*
|
2018-04-29 15:59:33 -03:00
|
|
|
stringlib_isalpha(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2007-10-16 03:31:30 -03:00
|
|
|
{
|
|
|
|
return _Py_bytes_isalpha(STRINGLIB_STR(self), STRINGLIB_LEN(self));
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject*
|
2018-04-29 15:59:33 -03:00
|
|
|
stringlib_isalnum(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2007-10-16 03:31:30 -03:00
|
|
|
{
|
|
|
|
return _Py_bytes_isalnum(STRINGLIB_STR(self), STRINGLIB_LEN(self));
|
|
|
|
}
|
|
|
|
|
2018-01-27 01:06:21 -04:00
|
|
|
static PyObject*
|
2018-04-29 15:59:33 -03:00
|
|
|
stringlib_isascii(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2018-01-27 01:06:21 -04:00
|
|
|
{
|
|
|
|
return _Py_bytes_isascii(STRINGLIB_STR(self), STRINGLIB_LEN(self));
|
|
|
|
}
|
|
|
|
|
2007-10-16 03:31:30 -03:00
|
|
|
static PyObject*
|
2018-04-29 15:59:33 -03:00
|
|
|
stringlib_isdigit(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2007-10-16 03:31:30 -03:00
|
|
|
{
|
|
|
|
return _Py_bytes_isdigit(STRINGLIB_STR(self), STRINGLIB_LEN(self));
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject*
|
2018-04-29 15:59:33 -03:00
|
|
|
stringlib_islower(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2007-10-16 03:31:30 -03:00
|
|
|
{
|
|
|
|
return _Py_bytes_islower(STRINGLIB_STR(self), STRINGLIB_LEN(self));
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject*
|
2018-04-29 15:59:33 -03:00
|
|
|
stringlib_isupper(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2007-10-16 03:31:30 -03:00
|
|
|
{
|
|
|
|
return _Py_bytes_isupper(STRINGLIB_STR(self), STRINGLIB_LEN(self));
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject*
|
2018-04-29 15:59:33 -03:00
|
|
|
stringlib_istitle(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2007-10-16 03:31:30 -03:00
|
|
|
{
|
|
|
|
return _Py_bytes_istitle(STRINGLIB_STR(self), STRINGLIB_LEN(self));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* functions that return a new object partially translated by ctype funcs: */
|
|
|
|
|
|
|
|
static PyObject*
|
2018-04-29 15:59:33 -03:00
|
|
|
stringlib_lower(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2007-10-16 03:31:30 -03:00
|
|
|
{
|
|
|
|
PyObject* newobj;
|
|
|
|
newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
|
|
|
|
if (!newobj)
|
|
|
|
return NULL;
|
|
|
|
_Py_bytes_lower(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
|
|
|
|
STRINGLIB_LEN(self));
|
|
|
|
return newobj;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject*
|
2018-04-29 15:59:33 -03:00
|
|
|
stringlib_upper(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2007-10-16 03:31:30 -03:00
|
|
|
{
|
|
|
|
PyObject* newobj;
|
|
|
|
newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
|
|
|
|
if (!newobj)
|
|
|
|
return NULL;
|
|
|
|
_Py_bytes_upper(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
|
|
|
|
STRINGLIB_LEN(self));
|
|
|
|
return newobj;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject*
|
2018-04-29 15:59:33 -03:00
|
|
|
stringlib_title(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2007-10-16 03:31:30 -03:00
|
|
|
{
|
|
|
|
PyObject* newobj;
|
|
|
|
newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
|
|
|
|
if (!newobj)
|
|
|
|
return NULL;
|
|
|
|
_Py_bytes_title(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
|
|
|
|
STRINGLIB_LEN(self));
|
|
|
|
return newobj;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject*
|
2018-04-29 15:59:33 -03:00
|
|
|
stringlib_capitalize(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2007-10-16 03:31:30 -03:00
|
|
|
{
|
|
|
|
PyObject* newobj;
|
|
|
|
newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
|
|
|
|
if (!newobj)
|
|
|
|
return NULL;
|
|
|
|
_Py_bytes_capitalize(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
|
|
|
|
STRINGLIB_LEN(self));
|
|
|
|
return newobj;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject*
|
2018-04-29 15:59:33 -03:00
|
|
|
stringlib_swapcase(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2007-10-16 03:31:30 -03:00
|
|
|
{
|
|
|
|
PyObject* newobj;
|
|
|
|
newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
|
|
|
|
if (!newobj)
|
|
|
|
return NULL;
|
|
|
|
_Py_bytes_swapcase(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
|
|
|
|
STRINGLIB_LEN(self));
|
|
|
|
return newobj;
|
|
|
|
}
|