Append a NEWLINE token at the end of a file.

This commit is contained in:
Guido van Rossum 1992-03-04 16:40:44 +00:00
parent aa9de679b5
commit d8b1d37bd8
1 changed files with 7 additions and 0 deletions

View File

@ -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) {