Issue #1772673: The type of char* arguments now changed to const char*.

This commit is contained in:
Serhiy Storchaka 2013-10-19 21:03:34 +03:00
parent 80ab13067e
commit c679227e31
39 changed files with 148 additions and 137 deletions

View file

@ -29,7 +29,7 @@ newgrammar(int start)
}
dfa *
adddfa(grammar *g, int type, char *name)
adddfa(grammar *g, int type, const char *name)
{
dfa *d;
@ -85,7 +85,7 @@ addarc(dfa *d, int from, int to, int lbl)
}
int
addlabel(labellist *ll, int type, char *str)
addlabel(labellist *ll, int type, const char *str)
{
int i;
label *lb;
@ -111,7 +111,7 @@ addlabel(labellist *ll, int type, char *str)
/* Same, but rather dies than adds */
int
findlabel(labellist *ll, int type, char *str)
findlabel(labellist *ll, int type, const char *str)
{
int i;

View file

@ -109,7 +109,7 @@ my_fgets(char *buf, int len, FILE *fp)
/* Readline implementation using fgets() */
char *
PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
{
size_t n;
char *p, *pr;
@ -170,13 +170,13 @@ PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
Note: Python expects in return a buffer allocated with PyMem_Malloc. */
char *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *);
char *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *);
/* Interface used by tokenizer.c and bltinmodule.c */
char *
PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
{
char *rv, *res;
size_t len;

View file

@ -134,13 +134,13 @@ push(stack *s, int type, dfa *d, int newstate, int lineno, int col_offset)
/* PARSER PROPER */
static int
classify(parser_state *ps, int type, char *str)
classify(parser_state *ps, int type, const char *str)
{
grammar *g = ps->p_grammar;
int n = g->g_ll.ll_nlabels;
if (type == NAME) {
char *s = str;
const char *s = str;
label *l = g->g_ll.ll_label;
int i;
for (i = n; i > 0; i--, l++) {

View file

@ -94,7 +94,8 @@ PyParser_ParseStringFlagsFilenameEx(const char *s, const char *filename_str,
node *
PyParser_ParseFile(FILE *fp, const char *filename, grammar *g, int start,
char *ps1, char *ps2, perrdetail *err_ret)
const char *ps1, const char *ps2,
perrdetail *err_ret)
{
return PyParser_ParseFileFlags(fp, filename, NULL,
g, start, ps1, ps2, err_ret, 0);
@ -103,7 +104,8 @@ PyParser_ParseFile(FILE *fp, const char *filename, grammar *g, int start,
node *
PyParser_ParseFileFlags(FILE *fp, const char *filename, const char *enc,
grammar *g, int start,
char *ps1, char *ps2, perrdetail *err_ret, int flags)
const char *ps1, const char *ps2,
perrdetail *err_ret, int flags)
{
int iflags = flags;
return PyParser_ParseFileFlagsEx(fp, filename, enc, g, start, ps1,
@ -113,15 +115,15 @@ PyParser_ParseFileFlags(FILE *fp, const char *filename, const char *enc,
node *
PyParser_ParseFileObject(FILE *fp, PyObject *filename,
const char *enc, grammar *g, int start,
char *ps1, char *ps2, perrdetail *err_ret,
int *flags)
const char *ps1, const char *ps2,
perrdetail *err_ret, int *flags)
{
struct tok_state *tok;
if (initerr(err_ret, filename) < 0)
return NULL;
if ((tok = PyTokenizer_FromFile(fp, (char *)enc, ps1, ps2)) == NULL) {
if ((tok = PyTokenizer_FromFile(fp, enc, ps1, ps2)) == NULL) {
err_ret->error = E_NOMEM;
return NULL;
}
@ -135,7 +137,8 @@ PyParser_ParseFileObject(FILE *fp, PyObject *filename,
node *
PyParser_ParseFileFlagsEx(FILE *fp, const char *filename,
const char *enc, grammar *g, int start,
char *ps1, char *ps2, perrdetail *err_ret, int *flags)
const char *ps1, const char *ps2,
perrdetail *err_ret, int *flags)
{
node *n;
PyObject *fileobj = NULL;

View file

@ -138,7 +138,7 @@ Py_FatalError(const char *msg)
/* No-nonsense my_readline() for tokenizer.c */
char *
PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
{
size_t n = 1000;
char *p = (char *)PyMem_MALLOC(n);

View file

@ -31,7 +31,7 @@
|| c == '_'\
|| (c >= 128))
extern char *PyOS_Readline(FILE *, FILE *, char *);
extern char *PyOS_Readline(FILE *, FILE *, const char *);
/* Return malloc'ed string including trailing \n;
empty malloc'ed string for EOF;
NULL if interrupted */
@ -780,7 +780,7 @@ PyTokenizer_FromString(const char *str, int exec_input)
struct tok_state *tok = tok_new();
if (tok == NULL)
return NULL;
str = (char *)decode_str(str, exec_input, tok);
str = decode_str(str, exec_input, tok);
if (str == NULL) {
PyTokenizer_Free(tok);
return NULL;
@ -823,7 +823,8 @@ PyTokenizer_FromUTF8(const char *str, int exec_input)
/* Set up tokenizer for file */
struct tok_state *
PyTokenizer_FromFile(FILE *fp, char* enc, char *ps1, char *ps2)
PyTokenizer_FromFile(FILE *fp, const char* enc,
const char *ps1, const char *ps2)
{
struct tok_state *tok = tok_new();
if (tok == NULL)

View file

@ -35,7 +35,7 @@ struct tok_state {
int indstack[MAXINDENT]; /* Stack of indents */
int atbol; /* Nonzero if at begin of new line */
int pendin; /* Pending indents (if > 0) or dedents (if < 0) */
char *prompt, *nextprompt; /* For interactive prompting */
const char *prompt, *nextprompt; /* For interactive prompting */
int lineno; /* Current line number */
int level; /* () [] {} Parentheses nesting level */
/* Used to allow free continuations inside them */
@ -69,8 +69,8 @@ struct tok_state {
extern struct tok_state *PyTokenizer_FromString(const char *, int);
extern struct tok_state *PyTokenizer_FromUTF8(const char *, int);
extern struct tok_state *PyTokenizer_FromFile(FILE *, char*,
char *, char *);
extern struct tok_state *PyTokenizer_FromFile(FILE *, const char*,
const char *, const char *);
extern void PyTokenizer_Free(struct tok_state *);
extern int PyTokenizer_Get(struct tok_state *, char **, char **);
extern char * PyTokenizer_RestoreEncoding(struct tok_state* tok,