Kaydet (Commit) 22ebe2f4 authored tarafından Guido van Rossum's avatar Guido van Rossum

Strip leading whitespace from input().

üst 27aaa6da
...@@ -317,6 +317,7 @@ builtin_input(self, v) ...@@ -317,6 +317,7 @@ builtin_input(self, v)
FILE *out = sysgetfile("stdout", stdout); FILE *out = sysgetfile("stdout", stdout);
node *n; node *n;
int err; int err;
int c;
object *m, *d; object *m, *d;
flushline(); flushline();
if (v != NULL) { if (v != NULL) {
...@@ -325,6 +326,9 @@ builtin_input(self, v) ...@@ -325,6 +326,9 @@ builtin_input(self, v)
} }
m = add_module("__main__"); m = add_module("__main__");
d = getmoduledict(m); d = getmoduledict(m);
while ((c = getc(in)) != EOF && (c == ' ' || c == '\t'))
;
ungetc(c, in);
return run_file(in, "<stdin>", expr_input, d, d); return run_file(in, "<stdin>", expr_input, d, d);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment