diff options
author | Guido van Rossum <guido@python.org> | 1992-03-04 16:40:44 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1992-03-04 16:40:44 (GMT) |
commit | d8b1d37bd89526509f391c69f33a0c547bd1caf9 (patch) | |
tree | fdc490c331e568322650480fc2e2945714c88467 /Parser | |
parent | aa9de679b5f47f2c0576f7923f5b8dc3e97372dd (diff) | |
download | cpython-d8b1d37bd89526509f391c69f33a0c547bd1caf9.zip cpython-d8b1d37bd89526509f391c69f33a0c547bd1caf9.tar.gz cpython-d8b1d37bd89526509f391c69f33a0c547bd1caf9.tar.bz2 |
Append a NEWLINE token at the end of a file.
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/parsetok.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Parser/parsetok.c b/Parser/parsetok.c index 31c2385..ba98418 100644 --- a/Parser/parsetok.c +++ b/Parser/parsetok.c @@ -122,6 +122,7 @@ parsetok(tok, g, start, n_ret) { parser_state *ps; int ret; + int started = 0; if ((ps = newparser(g, start)) == NULL) { fprintf(stderr, "no mem for new parser\n"); @@ -139,6 +140,12 @@ parsetok(tok, g, start, n_ret) ret = tok->done; break; } + if (type == ENDMARKER && started) { + type = NEWLINE; /* Add an extra newline */ + started = 0; + } + else + started = 1; len = b - a; str = NEW(char, len + 1); if (str == NULL) { |