diff options
author | Anthony Baxter <anthonybaxter@gmail.com> | 2006-04-11 05:39:14 +0000 |
---|---|---|
committer | Anthony Baxter <anthonybaxter@gmail.com> | 2006-04-11 05:39:14 +0000 |
commit | 114900298ea26e5e25edd5d05f24648dcd5ea95b (patch) | |
tree | 9db37abbea9f0bd5dc1332f6f710de5e521e3c2c /Parser/tokenizer.c | |
parent | 319c47fcdb3b8196cc580c4fab409b0ee58119fe (diff) | |
download | cpython-git-114900298ea26e5e25edd5d05f24648dcd5ea95b.tar.gz |
Fix the code in Parser/ to also compile with C++. This was mostly casts for
malloc/realloc type functions, as well as renaming one variable called 'new'
in tokensizer.c. Still lots more to be done, going to be checking in one
chunk at a time or the patch will be massively huge. Still compiles ok with
gcc.
Diffstat (limited to 'Parser/tokenizer.c')
-rw-r--r-- | Parser/tokenizer.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 469de27b62..5fcf49ea99 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -105,7 +105,8 @@ char *_PyParser_TokenNames[] = { static struct tok_state * tok_new(void) { - struct tok_state *tok = PyMem_MALLOC(sizeof(struct tok_state)); + struct tok_state *tok = (struct tok_state *)PyMem_MALLOC( + sizeof(struct tok_state)); if (tok == NULL) return NULL; tok->buf = tok->cur = tok->end = tok->inp = tok->start = NULL; @@ -775,38 +776,38 @@ tok_nextc(register struct tok_state *tok) return Py_CHARMASK(*tok->cur++); } if (tok->prompt != NULL) { - char *new = PyOS_Readline(stdin, stdout, tok->prompt); + char *newtok = PyOS_Readline(stdin, stdout, tok->prompt); if (tok->nextprompt != NULL) tok->prompt = tok->nextprompt; - if (new == NULL) + if (newtok == NULL) tok->done = E_INTR; - else if (*new == '\0') { - PyObject_FREE(new); + else if (*newtok == '\0') { + PyObject_FREE(newtok); tok->done = E_EOF; } #if !defined(PGEN) && defined(Py_USING_UNICODE) - else if (tok_stdin_decode(tok, &new) != 0) - PyObject_FREE(new); + else if (tok_stdin_decode(tok, &newtok) != 0) + PyObject_FREE(newtok); #endif else if (tok->start != NULL) { size_t start = tok->start - tok->buf; size_t oldlen = tok->cur - tok->buf; - size_t newlen = oldlen + strlen(new); + size_t newlen = oldlen + strlen(newtok); char *buf = tok->buf; buf = (char *)PyObject_REALLOC(buf, newlen+1); tok->lineno++; if (buf == NULL) { PyObject_FREE(tok->buf); tok->buf = NULL; - PyObject_FREE(new); + PyObject_FREE(newtok); tok->done = E_NOMEM; return EOF; } tok->buf = buf; tok->cur = tok->buf + oldlen; tok->line_start = tok->cur; - strcpy(tok->buf + oldlen, new); - PyObject_FREE(new); + strcpy(tok->buf + oldlen, newtok); + PyObject_FREE(newtok); tok->inp = tok->buf + newlen; tok->end = tok->inp + 1; tok->start = tok->buf + start; @@ -815,7 +816,7 @@ tok_nextc(register struct tok_state *tok) tok->lineno++; if (tok->buf != NULL) PyObject_FREE(tok->buf); - tok->buf = new; + tok->buf = newtok; tok->line_start = tok->buf; tok->cur = tok->buf; tok->line_start = tok->buf; |