* libc/stdio/flags.c (__sflags): Rewrite recognition of extended mode flags to

just loop over more allowed flags.  Support glibc 'e' flag on systems defining
_GLIBC_EXTENSION.  Support C11 'x' flag.
This commit is contained in:
Christopher Faylor 2012-08-21 14:51:50 +00:00
parent 0b1545eb3a
commit 03f6bb2863
2 changed files with 33 additions and 16 deletions

View File

@ -1,3 +1,9 @@
2012-08-21 Christopher Faylor <me.cygwin2012@cgf.cx>
* libc/stdio/flags.c (__sflags): Rewrite recognition of extended mode
flags to just loop over more allowed flags. Support glibc 'e' flag on
systems defining _GLIBC_EXTENSION. Support C11 'x' flag.
2012-08-10 Corinna Vinschen <vinschen@redhat.com> 2012-08-10 Corinna Vinschen <vinschen@redhat.com>
* libc/stdlib/btowc.c (btowc): Cast to avoid compiler warning. * libc/stdlib/btowc.c (btowc): Cast to avoid compiler warning.

View File

@ -60,27 +60,38 @@ _DEFUN(__sflags, (ptr, mode, optr),
ptr->_errno = EINVAL; ptr->_errno = EINVAL;
return (0); return (0);
} }
if (mode[1] && (mode[1] == '+' || mode[2] == '+')) while (*++mode)
{ {
ret = (ret & ~(__SRD | __SWR)) | __SRW; switch (*mode)
m = O_RDWR; {
} case '+':
if (mode[1] && (mode[1] == 'b' || mode[2] == 'b')) ret = (ret & ~(__SRD | __SWR)) | __SRW;
{ m = (m & ~O_ACCMODE) | O_RDWR;
#ifdef O_BINARY break;
m |= O_BINARY; case 'b':
#endif m |= O_BINARY;
} break;
#ifdef __CYGWIN__ #ifdef __CYGWIN__
else if (mode[1] && (mode[1] == 't' || mode[2] == 't')) case 't':
#else m |= O_TEXT;
else break;
#endif #endif
{ #if defined (O_CLOEXEC) && defined (_GLIBC_EXTENSION)
#ifdef O_TEXT case 'e':
m |= O_TEXT; m |= O_CLOEXEC;
break;
#endif #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; *optr = m | o;
return ret; return ret;
} }