mirror of
https://github.com/python/cpython.git
synced 2025-11-25 12:44:13 +00:00
Issue #25923: Added more const qualifiers to signatures of static and private functions.
This commit is contained in:
parent
2d06e84455
commit
ef1585eb9a
60 changed files with 210 additions and 191 deletions
|
|
@ -1648,8 +1648,8 @@ _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n)
|
|||
/* NOTE: `end` must point to the real end of the Py_UCS4 storage,
|
||||
that is to the NUL character. Otherwise the function will produce
|
||||
incorrect results. */
|
||||
static char *
|
||||
find_control_char(int kind, char *s, char *end, Py_UCS4 ch)
|
||||
static const char *
|
||||
find_control_char(int kind, const char *s, const char *end, Py_UCS4 ch)
|
||||
{
|
||||
if (kind == PyUnicode_1BYTE_KIND) {
|
||||
assert(ch < 256);
|
||||
|
|
@ -1669,13 +1669,13 @@ find_control_char(int kind, char *s, char *end, Py_UCS4 ch)
|
|||
Py_ssize_t
|
||||
_PyIO_find_line_ending(
|
||||
int translated, int universal, PyObject *readnl,
|
||||
int kind, char *start, char *end, Py_ssize_t *consumed)
|
||||
int kind, const char *start, const char *end, Py_ssize_t *consumed)
|
||||
{
|
||||
Py_ssize_t len = ((char*)end - (char*)start)/kind;
|
||||
|
||||
if (translated) {
|
||||
/* Newlines are already translated, only search for \n */
|
||||
char *pos = find_control_char(kind, start, end, '\n');
|
||||
const char *pos = find_control_char(kind, start, end, '\n');
|
||||
if (pos != NULL)
|
||||
return (pos - start)/kind + 1;
|
||||
else {
|
||||
|
|
@ -1687,7 +1687,7 @@ _PyIO_find_line_ending(
|
|||
/* Universal newline search. Find any of \r, \r\n, \n
|
||||
* The decoder ensures that \r\n are not split in two pieces
|
||||
*/
|
||||
char *s = start;
|
||||
const char *s = start;
|
||||
for (;;) {
|
||||
Py_UCS4 ch;
|
||||
/* Fast path for non-control chars. The loop always ends
|
||||
|
|
@ -1717,21 +1717,21 @@ _PyIO_find_line_ending(
|
|||
/* Assume that readnl is an ASCII character. */
|
||||
assert(PyUnicode_KIND(readnl) == PyUnicode_1BYTE_KIND);
|
||||
if (readnl_len == 1) {
|
||||
char *pos = find_control_char(kind, start, end, nl[0]);
|
||||
const char *pos = find_control_char(kind, start, end, nl[0]);
|
||||
if (pos != NULL)
|
||||
return (pos - start)/kind + 1;
|
||||
*consumed = len;
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
char *s = start;
|
||||
char *e = end - (readnl_len - 1)*kind;
|
||||
char *pos;
|
||||
const char *s = start;
|
||||
const char *e = end - (readnl_len - 1)*kind;
|
||||
const char *pos;
|
||||
if (e < s)
|
||||
e = s;
|
||||
while (s < e) {
|
||||
Py_ssize_t i;
|
||||
char *pos = find_control_char(kind, s, end, nl[0]);
|
||||
const char *pos = find_control_char(kind, s, end, nl[0]);
|
||||
if (pos == NULL || pos >= e)
|
||||
break;
|
||||
for (i = 1; i < readnl_len; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue