blob: f0546256ed911cdaecbb40568ba18f5d6ee1b25f [file] [log] [blame]
Serhiy Storchakabcde10a2016-05-16 09:42:29 +03001#if STRINGLIB_IS_UNICODE
2# error "ctype.h only compatible with byte-wise strings"
3#endif
Gregory P. Smith60d241f2007-10-16 06:31:30 +00004
5#include "bytes_methods.h"
6
7static PyObject*
8stringlib_isspace(PyObject *self)
9{
10 return _Py_bytes_isspace(STRINGLIB_STR(self), STRINGLIB_LEN(self));
11}
12
13static PyObject*
14stringlib_isalpha(PyObject *self)
15{
16 return _Py_bytes_isalpha(STRINGLIB_STR(self), STRINGLIB_LEN(self));
17}
18
19static PyObject*
20stringlib_isalnum(PyObject *self)
21{
22 return _Py_bytes_isalnum(STRINGLIB_STR(self), STRINGLIB_LEN(self));
23}
24
25static PyObject*
26stringlib_isdigit(PyObject *self)
27{
28 return _Py_bytes_isdigit(STRINGLIB_STR(self), STRINGLIB_LEN(self));
29}
30
31static PyObject*
32stringlib_islower(PyObject *self)
33{
34 return _Py_bytes_islower(STRINGLIB_STR(self), STRINGLIB_LEN(self));
35}
36
37static PyObject*
38stringlib_isupper(PyObject *self)
39{
40 return _Py_bytes_isupper(STRINGLIB_STR(self), STRINGLIB_LEN(self));
41}
42
43static PyObject*
44stringlib_istitle(PyObject *self)
45{
46 return _Py_bytes_istitle(STRINGLIB_STR(self), STRINGLIB_LEN(self));
47}
48
49
50/* functions that return a new object partially translated by ctype funcs: */
51
52static PyObject*
53stringlib_lower(PyObject *self)
54{
55 PyObject* newobj;
56 newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
57 if (!newobj)
58 return NULL;
59 _Py_bytes_lower(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
60 STRINGLIB_LEN(self));
61 return newobj;
62}
63
64static PyObject*
65stringlib_upper(PyObject *self)
66{
67 PyObject* newobj;
68 newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
69 if (!newobj)
70 return NULL;
71 _Py_bytes_upper(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
72 STRINGLIB_LEN(self));
73 return newobj;
74}
75
76static PyObject*
77stringlib_title(PyObject *self)
78{
79 PyObject* newobj;
80 newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
81 if (!newobj)
82 return NULL;
83 _Py_bytes_title(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
84 STRINGLIB_LEN(self));
85 return newobj;
86}
87
88static PyObject*
89stringlib_capitalize(PyObject *self)
90{
91 PyObject* newobj;
92 newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
93 if (!newobj)
94 return NULL;
95 _Py_bytes_capitalize(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
96 STRINGLIB_LEN(self));
97 return newobj;
98}
99
100static PyObject*
101stringlib_swapcase(PyObject *self)
102{
103 PyObject* newobj;
104 newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
105 if (!newobj)
106 return NULL;
107 _Py_bytes_swapcase(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
108 STRINGLIB_LEN(self));
109 return newobj;
110}