Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdio/stdio.c')
-rw-r--r--newlib/libc/stdio/stdio.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/newlib/libc/stdio/stdio.c b/newlib/libc/stdio/stdio.c
index c06f51aa0..abb7c2335 100644
--- a/newlib/libc/stdio/stdio.c
+++ b/newlib/libc/stdio/stdio.c
@@ -37,8 +37,19 @@ __sread (cookie, buf, n)
register FILE *fp = (FILE *) cookie;
register int ret;
+#ifdef __SCLE
+ int oldmode = 0;
+ if (fp->_flags & __SCLE)
+ oldmode = setmode(fp->_file, O_BINARY);
+#endif
+
ret = _read_r (fp->_data, fp->_file, buf, n);
+#ifdef __SCLE
+ if (oldmode)
+ setmode(fp->_file, oldmode);
+#endif
+
/* If the read succeeded, update the current offset. */
if (ret >= 0)
@@ -55,11 +66,25 @@ __swrite (cookie, buf, n)
int n;
{
register FILE *fp = (FILE *) cookie;
+ int w, oldmode=0;
if (fp->_flags & __SAPP)
(void) _lseek_r (fp->_data, fp->_file, (off_t) 0, SEEK_END);
fp->_flags &= ~__SOFF; /* in case O_APPEND mode is set */
- return _write_r (fp->_data, fp->_file, buf, n);
+
+#ifdef __SCLE
+ if (fp->_flags & __SCLE)
+ oldmode = setmode(fp->_file, O_BINARY);
+#endif
+
+ w = _write_r (fp->_data, fp->_file, buf, n);
+
+#ifdef __SCLE
+ if (oldmode)
+ setmode(fp->_file, oldmode);
+#endif
+
+ return w;
}
fpos_t
@@ -90,3 +115,15 @@ __sclose (cookie)
return _close_r (fp->_data, fp->_file);
}
+
+#ifdef __SCLE
+int
+__stextmode (int fd)
+{
+#ifdef __CYGWIN__
+ return _cygwin_istext_for_stdio (fd);
+#else
+ return 0;
+#endif
+}
+#endif