diff options
author | Tim Peters <tim.peters@gmail.com> | 2000-07-09 08:02:21 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2000-07-09 08:02:21 (GMT) |
commit | c2e7da9859c54b91b0cb8e20e91be60437a765f6 (patch) | |
tree | ea42e94469124a553ac4a52ab340e989d1dd08db /Objects | |
parent | ba09633e1e644720087d49e68555f630e905ba49 (diff) | |
download | cpython-c2e7da9859c54b91b0cb8e20e91be60437a765f6.zip cpython-c2e7da9859c54b91b0cb8e20e91be60437a765f6.tar.gz cpython-c2e7da9859c54b91b0cb8e20e91be60437a765f6.tar.bz2 |
Somebody started playing with const, so of course the outcome
was cascades of warnings about mismatching const decls. Overall,
I think const creates lots of headaches and solves almost
nothing. Added enough consts to shut up the warnings, but
this did require casting away const in one spot too (another
usual outcome of starting down this path): the function
mymemreplace can't return const char*, but sometimes wants to
return its first argument as-is, which latter must be declared
const char* in order to avoid const warnings at mymemreplace's
call sites. So, in the case the function wants to return the
first arg, that arg's declared constness must be subverted.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/stringobject.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 7da58da..9677d4b 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -609,7 +609,7 @@ static PyBufferProcs string_as_buffer = { static PyObject * -split_whitespace(char *s, int len, int maxsplit) +split_whitespace(const char *s, int len, int maxsplit) { int i, j, err; PyObject* item; @@ -1412,7 +1412,7 @@ string_translate(PyStringObject *self, PyObject *args) MEM, the function returns -1. */ static int -mymemfind(char *mem, int len, char *pat, int pat_len) +mymemfind(const char *mem, int len, const char *pat, int pat_len) { register int ii; @@ -1435,7 +1435,7 @@ mymemfind(char *mem, int len, char *pat, int pat_len) mem=11111 and pat==11 also return 2. */ static int -mymemcnt(char *mem, int len, char *pat, int pat_len) +mymemcnt(const char *mem, int len, const char *pat, int pat_len) { register int offset = 0; int nfound = 0; @@ -1471,10 +1471,10 @@ mymemcnt(char *mem, int len, char *pat, int pat_len) NULL if an error occurred. */ static char * -mymemreplace(char *str, int len, /* input string */ - char *pat, int pat_len, /* pattern string to find */ - char *sub, int sub_len, /* substitution string */ - int count, /* number of replacements */ +mymemreplace(const char *str, int len, /* input string */ + const char *pat, int pat_len, /* pattern string to find */ + const char *sub, int sub_len, /* substitution string */ + int count, /* number of replacements */ int *out_len) { char *out_s; @@ -1526,7 +1526,7 @@ mymemreplace(char *str, int len, /* input string */ return_same: *out_len = -1; - return str; + return (char*)str; /* have to cast away constness here */ } |