diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2002-12-11 14:04:59 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2002-12-11 14:04:59 (GMT) |
commit | 95292d6caa3af3196c5b9f5f95dae209815c09e5 (patch) | |
tree | 193e6e6a45f1e1319e4bb4ba07a3fee838a2ca5d /Parser | |
parent | 0e88c9f65d163c0c8551d0f079a19b71a8a9e3ca (diff) | |
download | cpython-95292d6caa3af3196c5b9f5f95dae209815c09e5.zip cpython-95292d6caa3af3196c5b9f5f95dae209815c09e5.tar.gz cpython-95292d6caa3af3196c5b9f5f95dae209815c09e5.tar.bz2 |
Constify filenames and scripts. Fixes #651362.
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/parsetok.c | 14 | ||||
-rw-r--r-- | Parser/tokenizer.c | 8 | ||||
-rw-r--r-- | Parser/tokenizer.h | 4 |
3 files changed, 14 insertions, 12 deletions
diff --git a/Parser/parsetok.c b/Parser/parsetok.c index d70e2d6..82a5450 100644 --- a/Parser/parsetok.c +++ b/Parser/parsetok.c @@ -15,17 +15,17 @@ int Py_TabcheckFlag; /* Forward */ static node *parsetok(struct tok_state *, grammar *, int, perrdetail *, int); -static void initerr(perrdetail *err_ret, char* filename); +static void initerr(perrdetail *err_ret, const char* filename); /* Parse input coming from a string. Return error code, print some errors. */ node * -PyParser_ParseString(char *s, grammar *g, int start, perrdetail *err_ret) +PyParser_ParseString(const char *s, grammar *g, int start, perrdetail *err_ret) { return PyParser_ParseStringFlags(s, g, start, err_ret, 0); } node * -PyParser_ParseStringFlags(char *s, grammar *g, int start, +PyParser_ParseStringFlags(const char *s, grammar *g, int start, perrdetail *err_ret, int flags) { return PyParser_ParseStringFlagsFilename(s, NULL, @@ -33,7 +33,7 @@ PyParser_ParseStringFlags(char *s, grammar *g, int start, } node * -PyParser_ParseStringFlagsFilename(char *s, char *filename, +PyParser_ParseStringFlagsFilename(const char *s, const char *filename, grammar *g, int start, perrdetail *err_ret, int flags) { @@ -60,7 +60,7 @@ PyParser_ParseStringFlagsFilename(char *s, char *filename, /* Parse input coming from a file. Return error code, print some errors. */ node * -PyParser_ParseFile(FILE *fp, char *filename, grammar *g, int start, +PyParser_ParseFile(FILE *fp, const char *filename, grammar *g, int start, char *ps1, char *ps2, perrdetail *err_ret) { return PyParser_ParseFileFlags(fp, filename, g, start, ps1, ps2, @@ -68,7 +68,7 @@ PyParser_ParseFile(FILE *fp, char *filename, grammar *g, int start, } node * -PyParser_ParseFileFlags(FILE *fp, char *filename, grammar *g, int start, +PyParser_ParseFileFlags(FILE *fp, const char *filename, grammar *g, int start, char *ps1, char *ps2, perrdetail *err_ret, int flags) { struct tok_state *tok; @@ -201,7 +201,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, } static void -initerr(perrdetail *err_ret, char* filename) +initerr(perrdetail *err_ret, const char* filename) { err_ret->error = E_OK; err_ret->filename = filename; diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 800a166..d7a223a 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -386,7 +386,8 @@ fp_setreadl(struct tok_state *tok, const char* enc) { PyObject *reader, *stream, *readline; - stream = PyFile_FromFile(tok->fp, tok->filename, "rb", NULL); + /* XXX: constify filename argument. */ + stream = PyFile_FromFile(tok->fp, (char*)tok->filename, "rb", NULL); if (stream == NULL) return 0; @@ -591,7 +592,7 @@ decode_str(const char *str, struct tok_state *tok) /* Set up tokenizer for string */ struct tok_state * -PyTokenizer_FromString(char *str) +PyTokenizer_FromString(const char *str) { struct tok_state *tok = tok_new(); if (tok == NULL) @@ -599,7 +600,8 @@ PyTokenizer_FromString(char *str) str = (char *)decode_str(str, tok); if (str == NULL) return NULL; - tok->buf = tok->cur = tok->end = tok->inp = str; + /* XXX: constify members. */ + tok->buf = tok->cur = tok->end = tok->inp = (char*)str; return tok; } diff --git a/Parser/tokenizer.h b/Parser/tokenizer.h index b3d456a..e942333 100644 --- a/Parser/tokenizer.h +++ b/Parser/tokenizer.h @@ -34,7 +34,7 @@ struct tok_state { int level; /* () [] {} Parentheses nesting level */ /* Used to allow free continuations inside them */ /* Stuff for checking on different tab sizes */ - char *filename; /* For error messages */ + const char *filename; /* For error messages */ int altwarning; /* Issue warning if alternate tabs don't match */ int alterror; /* Issue error if alternate tabs don't match */ int alttabsize; /* Alternate tab spacing */ @@ -54,7 +54,7 @@ struct tok_state { const char* str; }; -extern struct tok_state *PyTokenizer_FromString(char *); +extern struct tok_state *PyTokenizer_FromString(const char *); extern struct tok_state *PyTokenizer_FromFile(FILE *, char *, char *); extern void PyTokenizer_Free(struct tok_state *); extern int PyTokenizer_Get(struct tok_state *, char **, char **); |