summaryrefslogtreecommitdiffstats
path: root/Parser/tokenizer.c
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2002-04-14 20:12:41 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2002-04-14 20:12:41 (GMT)
commit7b8c7546ebc1fc3688ef95768fa8b82f0f205490 (patch)
tree2e14b243347a9c38c82e2e774d4b201f23149916 /Parser/tokenizer.c
parentdcd2dc2fffce8614c5d2b8d303a303a599b88a23 (diff)
downloadcpython-7b8c7546ebc1fc3688ef95768fa8b82f0f205490.zip
cpython-7b8c7546ebc1fc3688ef95768fa8b82f0f205490.tar.gz
cpython-7b8c7546ebc1fc3688ef95768fa8b82f0f205490.tar.bz2
Mass checkin of universal newline support.
Highlights: import and friends will understand any of \r, \n and \r\n as end of line. Python file input will do the same if you use mode 'U'. Everything can be disabled by configuring with --without-universal-newlines. See PEP278 for details.
Diffstat (limited to 'Parser/tokenizer.c')
-rw-r--r--Parser/tokenizer.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 324d9b6..b4e0fbf 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -1,6 +1,7 @@
/* Tokenizer implementation */
+#include "Python.h"
#include "pgenheaders.h"
#include <ctype.h>
@@ -245,8 +246,8 @@ tok_nextc(register struct tok_state *tok)
}
tok->end = tok->buf + BUFSIZ;
}
- if (fgets(tok->buf, (int)(tok->end - tok->buf),
- tok->fp) == NULL) {
+ if (Py_UniversalNewlineFgets(tok->buf, (int)(tok->end - tok->buf),
+ tok->fp, NULL) == NULL) {
tok->done = E_EOF;
done = 1;
}
@@ -284,9 +285,9 @@ tok_nextc(register struct tok_state *tok)
tok->end = tok->buf + newsize;
tok->start = curstart < 0 ? NULL :
tok->buf + curstart;
- if (fgets(tok->inp,
+ if (Py_UniversalNewlineFgets(tok->inp,
(int)(tok->end - tok->inp),
- tok->fp) == NULL) {
+ tok->fp, NULL) == NULL) {
/* Last line does not end in \n,
fake one */
strcpy(tok->inp, "\n");