[Python-checkins] python/dist/src/Include fileobject.h,2.27,2.28

tim_one@sourceforge.net tim_one@sourceforge.net
Sun, 21 Apr 2002 00:29:16 -0700


Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv23161/Include

Modified Files:
	fileobject.h 
Log Message:
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.


Index: fileobject.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/fileobject.h,v
retrieving revision 2.27
retrieving revision 2.28
diff -C2 -d -r2.27 -r2.28
*** fileobject.h	14 Apr 2002 20:12:39 -0000	2.27
--- fileobject.h	21 Apr 2002 07:29:13 -0000	2.28
***************
*** 42,46 ****
  
  /* The default encoding used by the platform file system APIs
!    If non-NULL, this is different than the default encoding for strings 
  */
  extern DL_IMPORT(const char *) Py_FileSystemDefaultEncoding;
--- 42,46 ----
  
  /* The default encoding used by the platform file system APIs
!    If non-NULL, this is different than the default encoding for strings
  */
  extern DL_IMPORT(const char *) Py_FileSystemDefaultEncoding;
***************
*** 52,61 ****
  #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
--- 52,61 ----
  #define PY_STDIOTEXTMODE "b"
  char *Py_UniversalNewlineFgets(char *, int, 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))
  #endif /* WITH_UNIVERSAL_NEWLINES */
  #ifdef __cplusplus