]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
replace "\r\n" with "\n" at line end (Jim Ahlstrom)
authorGuido van Rossum <guido@python.org>
Wed, 14 Jun 1995 18:26:02 +0000 (18:26 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 14 Jun 1995 18:26:02 +0000 (18:26 +0000)
Parser/tokenizer.c

index 083ef0e9a2e738fe59f666dfd761185c9d961126..4d759d1cd97805eac4765dc88f3c70f91752b55b 100644 (file)
@@ -235,6 +235,7 @@ tok_nextc(tok)
                else {
                        int done = 0;
                        int cur = 0;
+                       char *pt;
                        if (tok->start == NULL) {
                                if (tok->buf == NULL) {
                                        tok->buf = NEW(char, BUFSIZ);
@@ -295,6 +296,13 @@ tok_nextc(tok)
                                done = tok->inp[-1] == '\n';
                        }
                        tok->cur = tok->buf + cur;
+                       /* replace "\r\n" with "\n" */
+                       pt = tok->inp - 2;
+                       if (pt >= tok->buf && *pt == '\r') {
+                               *pt++ = '\n';
+                               *pt = '\0';
+                               tok->inp = pt;
+                       }
                }
                if (tok->done != E_OK) {
                        if (tok->prompt != NULL)