*/\r
#define _PDCLIB_FREAD 8u\r
#define _PDCLIB_FWRITE 16u\r
-#define _PDCLIB_FAPPEND 32u \r
+#define _PDCLIB_FAPPEND 32u\r
#define _PDCLIB_FRW 64u\r
#define _PDCLIB_FBIN 128u\r
\r
#endif\r
void * pointer;\r
_PDCLIB_uintptr_t uval;\r
- _PDCLIB_intptr_t sval; \r
+ _PDCLIB_intptr_t sval;\r
};\r
\r
/******************************************************************************/\r
{\r
while ( stream->bufidx != stream->bufend && i != n)\r
{\r
- c = (unsigned char)\r
- ( out[ i++ ] = stream->buffer[ stream->bufidx++ ] );\r
+ c = (unsigned char) stream->buffer[ stream->bufidx++ ];\r
+#ifdef _PDCLIB_NEED_EOL_TRANSLATION\r
+ if ( !( stream->status & _PDCLIB_FBIN ) && c == '\r' )\r
+ {\r
+ if ( stream->bufidx == stream->bufend )\r
+ break;\r
+\r
+ if ( stream->buffer[ stream->bufidx ] == '\n' )\r
+ {\r
+ c = '\n';\r
+ stream->bufidx++;\r
+ }\r
+ }\r
+#endif\r
+ out[ i++ ] = c;\r
+\r
if( c == stopchar )\r
return i;\r
}\r
\r
- if ( stream->bufidx == stream->bufend )\r
+ if ( i != n )\r
{\r
if( _PDCLIB_fillbuffer( stream ) == -1 )\r
{\r
- return i;\r
+ break;\r
}\r
}\r
}\r
\r
+#ifdef _PDCLIB_NEED_EOL_TRANSLATION\r
+ if ( i != n && stream->bufidx != stream->bufend )\r
+ {\r
+ // we must have EOF'd immediately after a \r\r
+ out[ i++ ] = stream->buffer[ stream->bufidx++ ];\r
+ }\r
+#endif\r
+\r
return i;\r
}\r
\r