summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-06-14 18:26:02 (GMT)
committerGuido van Rossum <guido@python.org>1995-06-14 18:26:02 (GMT)
commit2e96eb9266e4ed47d125998287bbca492335e766 (patch)
tree733e23445f6368772bad41095b653bc228b7b3db
parentb65a48e2b631f9a171e6eab699974bd2074f40d7 (diff)
downloadcpython-2e96eb9266e4ed47d125998287bbca492335e766.zip
cpython-2e96eb9266e4ed47d125998287bbca492335e766.tar.gz
cpython-2e96eb9266e4ed47d125998287bbca492335e766.tar.bz2
replace "\r\n" with "\n" at line end (Jim Ahlstrom)
-rw-r--r--Parser/tokenizer.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 083ef0e..4d759d1 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -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)