summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-06-28 22:00:02 (GMT)
committerGuido van Rossum <guido@python.org>2000-06-28 22:00:02 (GMT)
commit6da3434e037a281c771ad0fe37896920bfedd140 (patch)
tree62e6693804a2140d177126ba0754485ad44862cf /Parser
parent0ed1148b75de3ab7b969cc22c35bdb6273992954 (diff)
downloadcpython-6da3434e037a281c771ad0fe37896920bfedd140.zip
cpython-6da3434e037a281c771ad0fe37896920bfedd140.tar.gz
cpython-6da3434e037a281c771ad0fe37896920bfedd140.tar.bz2
Trent Mick: familiar simple Win64 patches
Diffstat (limited to 'Parser')
-rw-r--r--Parser/myreadline.c11
-rw-r--r--Parser/parsetok.c4
-rw-r--r--Parser/pgenmain.c4
-rw-r--r--Parser/tokenizer.c6
4 files changed, 14 insertions, 11 deletions
diff --git a/Parser/myreadline.c b/Parser/myreadline.c
index 9bf770e..7ce0cdf 100644
--- a/Parser/myreadline.c
+++ b/Parser/myreadline.c
@@ -86,7 +86,7 @@ char *
PyOS_StdioReadline(prompt)
char *prompt;
{
- int n;
+ size_t n;
char *p;
n = 100;
if ((p = PyMem_MALLOC(n)) == NULL)
@@ -95,7 +95,7 @@ PyOS_StdioReadline(prompt)
if (prompt)
fprintf(stderr, "%s", prompt);
fflush(stderr);
- switch (my_fgets(p, n, stdin)) {
+ switch (my_fgets(p, (int)n, stdin)) {
case 0: /* Normal case */
break;
case 1: /* Interrupt */
@@ -116,11 +116,14 @@ PyOS_StdioReadline(prompt)
#endif
n = strlen(p);
while (n > 0 && p[n-1] != '\n') {
- int incr = n+2;
+ size_t incr = n+2;
p = PyMem_REALLOC(p, n + incr);
if (p == NULL)
return NULL;
- if (my_fgets(p+n, incr, stdin) != 0)
+ if (incr > INT_MAX) {
+ PyErr_SetString(PyExc_OverflowError, "input line too long");
+ }
+ if (my_fgets(p+n, (int)incr, stdin) != 0)
break;
n += strlen(p+n);
}
diff --git a/Parser/parsetok.c b/Parser/parsetok.c
index 7e87859..6e8523b 100644
--- a/Parser/parsetok.c
+++ b/Parser/parsetok.c
@@ -136,7 +136,7 @@ parsetok(tok, g, start, err_ret)
for (;;) {
char *a, *b;
int type;
- int len;
+ size_t len;
char *str;
type = PyTokenizer_Get(tok, &a, &b);
@@ -184,7 +184,7 @@ parsetok(tok, g, start, err_ret)
err_ret->lineno = tok->lineno;
err_ret->offset = tok->cur - tok->buf;
if (tok->buf != NULL) {
- int len = tok->inp - tok->buf;
+ size_t len = tok->inp - tok->buf;
err_ret->text = PyMem_NEW(char, len + 1);
if (err_ret->text != NULL) {
if (len > 0)
diff --git a/Parser/pgenmain.c b/Parser/pgenmain.c
index 34c3b01..569a588 100644
--- a/Parser/pgenmain.c
+++ b/Parser/pgenmain.c
@@ -127,7 +127,7 @@ getgrammar(filename)
fprintf(stderr, "Parsing error %d, line %d.\n",
err.error, err.lineno);
if (err.text != NULL) {
- int i;
+ size_t i;
fprintf(stderr, "%s", err.text);
i = strlen(err.text);
if (i == 0 || err.text[i-1] != '\n')
@@ -195,7 +195,7 @@ char *
PyOS_Readline(prompt)
char *prompt;
{
- int n = 1000;
+ size_t n = 1000;
char *p = PyMem_MALLOC(n);
char *q;
if (p == NULL)
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 7d9a273..3337c75 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -223,9 +223,9 @@ tok_nextc(tok)
tok->done = E_EOF;
}
else if (tok->start != NULL) {
- int start = tok->start - tok->buf;
- int oldlen = tok->cur - tok->buf;
- int newlen = oldlen + strlen(new);
+ size_t start = tok->start - tok->buf;
+ size_t oldlen = tok->cur - tok->buf;
+ size_t newlen = oldlen + strlen(new);
char *buf = tok->buf;
PyMem_RESIZE(buf, char, newlen+1);
tok->lineno++;