]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Strip leading whitespace from input().
authorGuido van Rossum <guido@python.org>
Thu, 12 Mar 1992 17:33:52 +0000 (17:33 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 12 Mar 1992 17:33:52 +0000 (17:33 +0000)
Python/bltinmodule.c

index 8c8d60c642d84cb0c29b4c50028308a66bafbc40..324ecb071a99df6fa30600b3fbc0b769b8b283e6 100644 (file)
@@ -317,6 +317,7 @@ builtin_input(self, v)
        FILE *out = sysgetfile("stdout", stdout);
        node *n;
        int err;
+       int c;
        object *m, *d;
        flushline();
        if (v != NULL) {
@@ -325,6 +326,9 @@ builtin_input(self, v)
        }
        m = add_module("__main__");
        d = getmoduledict(m);
+       while ((c = getc(in)) != EOF && (c == ' ' || c == '\t'))
+               ;
+       ungetc(c, in);
        return run_file(in, "<stdin>", expr_input, d, d);
 }