diff options
Diffstat (limited to 'newlib/libc/stdio')
-rw-r--r-- | newlib/libc/stdio/fgets.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdio/flags.c | 41 | ||||
-rw-r--r-- | newlib/libc/stdio/vfprintf.c | 4 |
3 files changed, 31 insertions, 16 deletions
diff --git a/newlib/libc/stdio/fgets.c b/newlib/libc/stdio/fgets.c index 1644fba6a..319cfd576 100644 --- a/newlib/libc/stdio/fgets.c +++ b/newlib/libc/stdio/fgets.c @@ -102,7 +102,7 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp), #ifdef __SCLE if (fp->_flags & __SCLE) { - int c; + int c = 0; /* Sorry, have to do it the slow way */ while (--n > 0 && (c = __sgetc_r (ptr, fp)) != EOF) { diff --git a/newlib/libc/stdio/flags.c b/newlib/libc/stdio/flags.c index 26d2f82fd..518cc33f1 100644 --- a/newlib/libc/stdio/flags.c +++ b/newlib/libc/stdio/flags.c @@ -60,27 +60,40 @@ _DEFUN(__sflags, (ptr, mode, optr), ptr->_errno = EINVAL; return (0); } - if (mode[1] && (mode[1] == '+' || mode[2] == '+')) - { - ret = (ret & ~(__SRD | __SWR)) | __SRW; - m = O_RDWR; - } - if (mode[1] && (mode[1] == 'b' || mode[2] == 'b')) + while (*++mode) { + switch (*mode) + { + case '+': + ret = (ret & ~(__SRD | __SWR)) | __SRW; + m = (m & ~O_ACCMODE) | O_RDWR; + break; + case 'b': #ifdef O_BINARY - m |= O_BINARY; + m |= O_BINARY; #endif - } + break; #ifdef __CYGWIN__ - else if (mode[1] && (mode[1] == 't' || mode[2] == 't')) -#else - else + case 't': + m |= O_TEXT; + break; #endif - { -#ifdef O_TEXT - m |= O_TEXT; +#if defined (O_CLOEXEC) && defined (_GLIBC_EXTENSION) + case 'e': + m |= O_CLOEXEC; + break; #endif + case 'x': + m |= O_EXCL; + break; + default: + break; + } } +#if defined (O_TEXT) && !defined (__CYGWIN__) + if (!(m | O_BINARY)) + m |= O_TEXT; +#endif *optr = m | o; return ret; } diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index 4b165e021..76a445b5f 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -333,8 +333,10 @@ int __sprint_r (struct _reent *, FILE *, register struct __suio *); * Helper function for `fprintf to unbuffered unix file': creates a * temporary buffer. We only work on write-only files; this avoids * worries about ungetc buffers and so forth. + * + * Make sure to avoid inlining. */ -static int +_NOINLINE_STATIC int _DEFUN(__sbprintf, (rptr, fp, fmt, ap), struct _reent *rptr _AND register FILE *fp _AND |