summaryrefslogtreecommitdiff
path: root/Include/fileobject.h
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2002-04-14 20:12:41 +0000
committerJack Jansen <jack.jansen@cwi.nl>2002-04-14 20:12:41 +0000
commit7b8c7546ebc1fc3688ef95768fa8b82f0f205490 (patch)
tree2e14b243347a9c38c82e2e774d4b201f23149916 /Include/fileobject.h
parentdcd2dc2fffce8614c5d2b8d303a303a599b88a23 (diff)
downloadcpython-git-7b8c7546ebc1fc3688ef95768fa8b82f0f205490.tar.gz
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 'Include/fileobject.h')
-rw-r--r--Include/fileobject.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/Include/fileobject.h b/Include/fileobject.h
index 0876cd29a8..d696475f94 100644
--- a/Include/fileobject.h
+++ b/Include/fileobject.h
@@ -14,8 +14,13 @@ typedef struct {
PyObject *f_mode;
int (*f_close)(FILE *);
int f_softspace; /* Flag used by 'print' command */
- int f_binary; /* Flag which indicates whether the file is
+ int f_binary; /* Flag which indicates whether the file is open
open in binary (1) or test (0) mode */
+#ifdef WITH_UNIVERSAL_NEWLINES
+ int f_univ_newline; /* Handle any newline convention */
+ int f_newlinetypes; /* Types of newlines seen */
+ int f_skipnextlf; /* Skip next \n */
+#endif
} PyFileObject;
extern DL_IMPORT(PyTypeObject) PyFile_Type;
@@ -40,6 +45,19 @@ extern DL_IMPORT(int) PyObject_AsFileDescriptor(PyObject *);
*/
extern DL_IMPORT(const char *) Py_FileSystemDefaultEncoding;
+#ifdef WITH_UNIVERSAL_NEWLINES
+/* Routines to replace fread() and fgets() which accept any of \r, \n
+ or \r\n as line terminators.
+*/
+#define PY_STDIOTEXTMODE "b"
+char *Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
+size_t Py_UniversalNewlineFread(void *, size_t, FILE *, PyObject *);
+#else
+#define PY_STDIOTEXTMODE ""
+#define Py_UniversalNewlineFgets(buf, len, fp, obj) (fgets((buf), (len), (fp)))
+#define Py_UniversalNewlineFread(buf, len, fp, obj) \
+ (fread((buf), 1, (len), (fp)))
+#endif /* WITH_UNIVERSAL_NEWLINES */
#ifdef __cplusplus
}
#endif