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:
authorDJ Delorie <dj@redhat.com>2000-05-24 03:51:54 +0400
committerDJ Delorie <dj@redhat.com>2000-05-24 03:51:54 +0400
commitc4e1aa01152f5b0b9637b965604273a52f040323 (patch)
treec96b9c34d59d4aee60caf3a9e671130bf2fa7b39 /newlib/libc/stdio/stdio.c
parent98c6450eaa8cec6ea0243f3305143d77dfcb3d07 (diff)
* libc/stdio/stdio.c (__stextmode): new, see if file is text mode
(__sread): always read in binary mode (__swrite): always write in binary mode * libc/include/stdio.h: no getc/putc macros for cygwin; causes compatibility issues with different dll versions * libc/stdio/fopen.c: use __stextmode * libc/stdio/fdopen.c: ditto * libc/stdio/freopen.c: ditto * libc/stdio/findfp.c: set up __SCLE for std{in,out,err} * libc/stdio/local.h: declare __stextmode
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