Update doc to make it agree with code.
Bottom factor out some common code.
This commit is contained in:
parent
a754a229b4
commit
8e6675a7dc
|
@ -3099,7 +3099,7 @@ string_replace(PyStringObject *self, PyObject *args)
|
||||||
|
|
||||||
/** End DALKE **/
|
/** End DALKE **/
|
||||||
|
|
||||||
/* Matches the end (direction > 0) or start (direction < 0) of self
|
/* Matches the end (direction >= 0) or start (direction < 0) of self
|
||||||
* against substr, using the start and end arguments. Returns
|
* against substr, using the start and end arguments. Returns
|
||||||
* -1 on error, 0 if not found and 1 if found.
|
* -1 on error, 0 if not found and 1 if found.
|
||||||
*/
|
*/
|
||||||
|
@ -3131,11 +3131,6 @@ _string_tailmatch(PyStringObject *self, PyObject *substr, Py_ssize_t start,
|
||||||
/* startswith */
|
/* startswith */
|
||||||
if (start+slen > len)
|
if (start+slen > len)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (end-start >= slen)
|
|
||||||
return ! memcmp(str+start, sub, slen);
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
} else {
|
} else {
|
||||||
/* endswith */
|
/* endswith */
|
||||||
if (end-start < slen || start > len)
|
if (end-start < slen || start > len)
|
||||||
|
@ -3143,12 +3138,11 @@ _string_tailmatch(PyStringObject *self, PyObject *substr, Py_ssize_t start,
|
||||||
|
|
||||||
if (end-slen > start)
|
if (end-slen > start)
|
||||||
start = end - slen;
|
start = end - slen;
|
||||||
|
}
|
||||||
if (end-start >= slen)
|
if (end-start >= slen)
|
||||||
return ! memcmp(str+start, sub, slen);
|
return ! memcmp(str+start, sub, slen);
|
||||||
else
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PyDoc_STRVAR(startswith__doc__,
|
PyDoc_STRVAR(startswith__doc__,
|
||||||
|
|
Loading…
Reference in New Issue