Py_UniversalNewlineFread(): Many changes.
+ Continued looping until n bytes in the buffer have been filled, not
just when n bytes have been read from the file. This repairs the
bug that f.readlines() only sucked up the first 8192 bytes of the file
on Windows when universal newlines was enabled and f was opened in
U mode (see Python-Dev -- this was the ultimate cause of the
test_inspect.py failure).
+ Changed prototye to take a char* buffer (void* doesn't make much sense).
+ Squashed size_t vs int mismatches (in particular, besides the unsigned
vs signed distinction, size_t may be larger than int).
+ Gets out under all error conditions now (it's possible for fread() to
suffer an error even if it returns a number larger than 0 -- any
"short read" is an error or EOF condition).
+ Rearranged and simplified declarations.
diff --git a/Include/fileobject.h b/Include/fileobject.h
index d696475..6c34223 100644
--- a/Include/fileobject.h
+++ b/Include/fileobject.h
@@ -41,7 +41,7 @@
extern DL_IMPORT(int) PyObject_AsFileDescriptor(PyObject *);
/* The default encoding used by the platform file system APIs
- If non-NULL, this is different than the default encoding for strings
+ If non-NULL, this is different than the default encoding for strings
*/
extern DL_IMPORT(const char *) Py_FileSystemDefaultEncoding;
@@ -51,12 +51,12 @@
*/
#define PY_STDIOTEXTMODE "b"
char *Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
-size_t Py_UniversalNewlineFread(void *, size_t, FILE *, PyObject *);
+size_t Py_UniversalNewlineFread(char *, 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)))
+#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
}