mirror of
https://github.com/python/cpython.git
synced 2025-07-19 17:25:54 +00:00
Issue #1772673: The type of char*
arguments now changed to const char*
.
This commit is contained in:
parent
80ab13067e
commit
c679227e31
39 changed files with 148 additions and 137 deletions
14
Python/ast.c
14
Python/ast.c
|
@ -3651,18 +3651,16 @@ parsenumber(struct compiling *c, const char *s)
|
|||
end = s + strlen(s) - 1;
|
||||
imflag = *end == 'j' || *end == 'J';
|
||||
if (s[0] == '0') {
|
||||
x = (long) PyOS_strtoul((char *)s, (char **)&end, 0);
|
||||
x = (long) PyOS_strtoul(s, (char **)&end, 0);
|
||||
if (x < 0 && errno == 0) {
|
||||
return PyLong_FromString((char *)s,
|
||||
(char **)0,
|
||||
0);
|
||||
return PyLong_FromString(s, (char **)0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
x = PyOS_strtol((char *)s, (char **)&end, 0);
|
||||
x = PyOS_strtol(s, (char **)&end, 0);
|
||||
if (*end == '\0') {
|
||||
if (errno != 0)
|
||||
return PyLong_FromString((char *)s, (char **)0, 0);
|
||||
return PyLong_FromString(s, (char **)0, 0);
|
||||
return PyLong_FromLong(x);
|
||||
}
|
||||
/* XXX Huge floats may silently fail */
|
||||
|
@ -3685,8 +3683,8 @@ parsenumber(struct compiling *c, const char *s)
|
|||
static PyObject *
|
||||
decode_utf8(struct compiling *c, const char **sPtr, const char *end)
|
||||
{
|
||||
char *s, *t;
|
||||
t = s = (char *)*sPtr;
|
||||
const char *s, *t;
|
||||
t = s = *sPtr;
|
||||
/* while (s < end && *s != '\\') s++; */ /* inefficient for u".." */
|
||||
while (s < end && (*s & 0x80)) s++;
|
||||
*sPtr = s;
|
||||
|
|
|
@ -1335,7 +1335,7 @@ min_max(PyObject *args, PyObject *kwds, int op)
|
|||
|
||||
if (positional)
|
||||
v = args;
|
||||
else if (!PyArg_UnpackTuple(args, (char *)name, 1, 1, &v))
|
||||
else if (!PyArg_UnpackTuple(args, name, 1, 1, &v))
|
||||
return NULL;
|
||||
|
||||
emptytuple = PyTuple_New(0);
|
||||
|
|
|
@ -441,7 +441,7 @@ int PyCodec_RegisterError(const char *name, PyObject *error)
|
|||
return -1;
|
||||
}
|
||||
return PyDict_SetItemString(interp->codec_error_registry,
|
||||
(char *)name, error);
|
||||
name, error);
|
||||
}
|
||||
|
||||
/* Lookup the error handling callback function registered under the
|
||||
|
@ -457,7 +457,7 @@ PyObject *PyCodec_LookupError(const char *name)
|
|||
|
||||
if (name==NULL)
|
||||
name = "strict";
|
||||
handler = PyDict_GetItemString(interp->codec_error_registry, (char *)name);
|
||||
handler = PyDict_GetItemString(interp->codec_error_registry, name);
|
||||
if (!handler)
|
||||
PyErr_Format(PyExc_LookupError, "unknown error handler name '%.400s'", name);
|
||||
else
|
||||
|
|
|
@ -517,7 +517,7 @@ _PyImport_FixupExtensionObject(PyObject *mod, PyObject *name,
|
|||
}
|
||||
|
||||
int
|
||||
_PyImport_FixupBuiltin(PyObject *mod, char *name)
|
||||
_PyImport_FixupBuiltin(PyObject *mod, const char *name)
|
||||
{
|
||||
int res;
|
||||
PyObject *nameobj;
|
||||
|
@ -656,22 +656,23 @@ remove_module(PyObject *name)
|
|||
* interface. The other two exist primarily for backward compatibility.
|
||||
*/
|
||||
PyObject *
|
||||
PyImport_ExecCodeModule(char *name, PyObject *co)
|
||||
PyImport_ExecCodeModule(const char *name, PyObject *co)
|
||||
{
|
||||
return PyImport_ExecCodeModuleWithPathnames(
|
||||
name, co, (char *)NULL, (char *)NULL);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
PyImport_ExecCodeModuleEx(char *name, PyObject *co, char *pathname)
|
||||
PyImport_ExecCodeModuleEx(const char *name, PyObject *co, const char *pathname)
|
||||
{
|
||||
return PyImport_ExecCodeModuleWithPathnames(
|
||||
name, co, pathname, (char *)NULL);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
PyImport_ExecCodeModuleWithPathnames(char *name, PyObject *co, char *pathname,
|
||||
char *cpathname)
|
||||
PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co,
|
||||
const char *pathname,
|
||||
const char *cpathname)
|
||||
{
|
||||
PyObject *m = NULL;
|
||||
PyObject *nameobj, *pathobj = NULL, *cpathobj = NULL;
|
||||
|
@ -1019,7 +1020,7 @@ get_frozen_object(PyObject *name)
|
|||
size = p->size;
|
||||
if (size < 0)
|
||||
size = -size;
|
||||
return PyMarshal_ReadObjectFromString((char *)p->code, size);
|
||||
return PyMarshal_ReadObjectFromString((const char *)p->code, size);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -1071,7 +1072,7 @@ PyImport_ImportFrozenModuleObject(PyObject *name)
|
|||
ispackage = (size < 0);
|
||||
if (ispackage)
|
||||
size = -size;
|
||||
co = PyMarshal_ReadObjectFromString((char *)p->code, size);
|
||||
co = PyMarshal_ReadObjectFromString((const char *)p->code, size);
|
||||
if (co == NULL)
|
||||
return -1;
|
||||
if (!PyCode_Check(co)) {
|
||||
|
@ -1113,7 +1114,7 @@ err_return:
|
|||
}
|
||||
|
||||
int
|
||||
PyImport_ImportFrozenModule(char *name)
|
||||
PyImport_ImportFrozenModule(const char *name)
|
||||
{
|
||||
PyObject *nameobj;
|
||||
int ret;
|
||||
|
|
|
@ -1466,15 +1466,15 @@ PyMarshal_ReadObjectFromFile(FILE *fp)
|
|||
}
|
||||
|
||||
PyObject *
|
||||
PyMarshal_ReadObjectFromString(char *str, Py_ssize_t len)
|
||||
PyMarshal_ReadObjectFromString(const char *str, Py_ssize_t len)
|
||||
{
|
||||
RFILE rf;
|
||||
PyObject *result;
|
||||
rf.fp = NULL;
|
||||
rf.readable = NULL;
|
||||
rf.current_filename = NULL;
|
||||
rf.ptr = str;
|
||||
rf.end = str + len;
|
||||
rf.ptr = (char *)str;
|
||||
rf.end = (char *)str + len;
|
||||
rf.buf = NULL;
|
||||
rf.depth = 0;
|
||||
rf.refs = PyList_New(0);
|
||||
|
|
|
@ -92,7 +92,7 @@ static int digitlimit[] = {
|
|||
** exceptions - we don't check for them.
|
||||
*/
|
||||
unsigned long
|
||||
PyOS_strtoul(char *str, char **ptr, int base)
|
||||
PyOS_strtoul(const char *str, char **ptr, int base)
|
||||
{
|
||||
unsigned long result = 0; /* return value of the function */
|
||||
int c; /* current input character */
|
||||
|
@ -111,7 +111,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
|
|||
/* there must be at least one digit after 0x */
|
||||
if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 16) {
|
||||
if (ptr)
|
||||
*ptr = str;
|
||||
*ptr = (char *)str;
|
||||
return 0;
|
||||
}
|
||||
++str;
|
||||
|
@ -120,7 +120,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
|
|||
/* there must be at least one digit after 0o */
|
||||
if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 8) {
|
||||
if (ptr)
|
||||
*ptr = str;
|
||||
*ptr = (char *)str;
|
||||
return 0;
|
||||
}
|
||||
++str;
|
||||
|
@ -129,7 +129,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
|
|||
/* there must be at least one digit after 0b */
|
||||
if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 2) {
|
||||
if (ptr)
|
||||
*ptr = str;
|
||||
*ptr = (char *)str;
|
||||
return 0;
|
||||
}
|
||||
++str;
|
||||
|
@ -141,7 +141,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
|
|||
while (Py_ISSPACE(Py_CHARMASK(*str)))
|
||||
++str;
|
||||
if (ptr)
|
||||
*ptr = str;
|
||||
*ptr = (char *)str;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
|
|||
/* there must be at least one digit after 0x */
|
||||
if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 16) {
|
||||
if (ptr)
|
||||
*ptr = str;
|
||||
*ptr = (char *)str;
|
||||
return 0;
|
||||
}
|
||||
++str;
|
||||
|
@ -171,7 +171,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
|
|||
/* there must be at least one digit after 0o */
|
||||
if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 8) {
|
||||
if (ptr)
|
||||
*ptr = str;
|
||||
*ptr = (char *)str;
|
||||
return 0;
|
||||
}
|
||||
++str;
|
||||
|
@ -185,7 +185,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
|
|||
/* there must be at least one digit after 0b */
|
||||
if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 2) {
|
||||
if (ptr)
|
||||
*ptr = str;
|
||||
*ptr = (char *)str;
|
||||
return 0;
|
||||
}
|
||||
++str;
|
||||
|
@ -197,7 +197,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
|
|||
/* catch silly bases */
|
||||
if (base < 2 || base > 36) {
|
||||
if (ptr)
|
||||
*ptr = str;
|
||||
*ptr = (char *)str;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -239,7 +239,7 @@ PyOS_strtoul(char *str, char **ptr, int base)
|
|||
|
||||
/* set pointer to point to the last character scanned */
|
||||
if (ptr)
|
||||
*ptr = str;
|
||||
*ptr = (char *)str;
|
||||
|
||||
return result;
|
||||
|
||||
|
@ -248,7 +248,7 @@ overflowed:
|
|||
/* spool through remaining digit characters */
|
||||
while (_PyLong_DigitValue[Py_CHARMASK(*str)] < base)
|
||||
++str;
|
||||
*ptr = str;
|
||||
*ptr = (char *)str;
|
||||
}
|
||||
errno = ERANGE;
|
||||
return (unsigned long)-1;
|
||||
|
@ -260,7 +260,7 @@ overflowed:
|
|||
#define PY_ABS_LONG_MIN (0-(unsigned long)LONG_MIN)
|
||||
|
||||
long
|
||||
PyOS_strtol(char *str, char **ptr, int base)
|
||||
PyOS_strtol(const char *str, char **ptr, int base)
|
||||
{
|
||||
long result;
|
||||
unsigned long uresult;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue