Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
403d68b4
Commit
403d68b4
authored
Mar 13, 2000
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sq_contains implementation.
parent
ef93b87f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
Objects/unicodeobject.c
Objects/unicodeobject.c
+44
-0
No files found.
Objects/unicodeobject.c
View file @
403d68b4
...
@@ -2737,6 +2737,49 @@ onError:
...
@@ -2737,6 +2737,49 @@ onError:
return
-
1
;
return
-
1
;
}
}
int
PyUnicode_Contains
(
PyObject
*
container
,
PyObject
*
element
)
{
PyUnicodeObject
*
u
=
NULL
,
*
v
=
NULL
;
int
result
;
register
const
Py_UNICODE
*
p
,
*
e
;
register
Py_UNICODE
ch
;
/* Coerce the two arguments */
u
=
(
PyUnicodeObject
*
)
PyUnicode_FromObject
(
container
);
if
(
u
==
NULL
)
goto
onError
;
v
=
(
PyUnicodeObject
*
)
PyUnicode_FromObject
(
element
);
if
(
v
==
NULL
)
goto
onError
;
/* Check v in u */
if
(
PyUnicode_GET_SIZE
(
v
)
!=
1
)
{
PyErr_SetString
(
PyExc_TypeError
,
"string member test needs char left operand"
);
goto
onError
;
}
ch
=
*
PyUnicode_AS_UNICODE
(
v
);
p
=
PyUnicode_AS_UNICODE
(
u
);
e
=
p
+
PyUnicode_GET_SIZE
(
u
);
result
=
0
;
while
(
p
<
e
)
{
if
(
*
p
++
==
ch
)
{
result
=
1
;
break
;
}
}
Py_DECREF
(
u
);
Py_DECREF
(
v
);
return
result
;
onError:
Py_XDECREF
(
u
);
Py_XDECREF
(
v
);
return
-
1
;
}
/* Concat to string or Unicode object giving a new Unicode object. */
/* Concat to string or Unicode object giving a new Unicode object. */
PyObject
*
PyUnicode_Concat
(
PyObject
*
left
,
PyObject
*
PyUnicode_Concat
(
PyObject
*
left
,
...
@@ -3817,6 +3860,7 @@ static PySequenceMethods unicode_as_sequence = {
...
@@ -3817,6 +3860,7 @@ static PySequenceMethods unicode_as_sequence = {
(
intintargfunc
)
unicode_slice
,
/* sq_slice */
(
intintargfunc
)
unicode_slice
,
/* sq_slice */
0
,
/* sq_ass_item */
0
,
/* sq_ass_item */
0
,
/* sq_ass_slice */
0
,
/* sq_ass_slice */
(
objobjproc
)
PyUnicode_Contains
,
/*sq_contains*/
};
};
static
int
static
int
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment