On non-Cygwin, use O_TEXT when O_BINARY is not set.

Message ID 20190221080821.9039-1-michael.haubenwallner@ssi-schaefer.com
State New
Headers show
Series
  • On non-Cygwin, use O_TEXT when O_BINARY is not set.
Related show

Commit Message

Michael Haubenwallner Feb. 21, 2019, 8:08 a.m.
* libc/stdio/flags.c (__sflags): Fix typo when testing if O_BINARY is
set, to really set O_TEXT if not O_BINARY, applies to non-Cygwin only.
---
 newlib/libc/stdio/flags.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.19.2

Comments

Corinna Vinschen Feb. 21, 2019, 9:56 a.m. | #1
On Feb 21 09:08, Michael Haubenwallner wrote:
> * libc/stdio/flags.c (__sflags): Fix typo when testing if O_BINARY is

> set, to really set O_TEXT if not O_BINARY, applies to non-Cygwin only.

> ---

>  newlib/libc/stdio/flags.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/newlib/libc/stdio/flags.c b/newlib/libc/stdio/flags.c

> index 71fc1f60a..cd73385ce 100644

> --- a/newlib/libc/stdio/flags.c

> +++ b/newlib/libc/stdio/flags.c

> @@ -90,7 +90,7 @@ __sflags (struct _reent *ptr,

>  	}

>      }

>  #if defined (O_TEXT) && !defined (__CYGWIN__)

> -  if (!(m | O_BINARY))

> +  if (!(m & O_BINARY))

>      m |= O_TEXT;

>  #endif

>    *optr = m | o;

> -- 

> 2.19.2


Given that O_TEXT is under #if defined (__CYGWIN__) guard, do
we need this code at all?  Does anybody actually *want* O_TEXT
outside of the Windows world?


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
Michael Haubenwallner Feb. 21, 2019, 12:12 p.m. | #2
On 2/21/19 10:56 AM, Corinna Vinschen wrote:
> On Feb 21 09:08, Michael Haubenwallner wrote:

>> * libc/stdio/flags.c (__sflags): Fix typo when testing if O_BINARY is

>> set, to really set O_TEXT if not O_BINARY, applies to non-Cygwin only.

>> ---

>>  newlib/libc/stdio/flags.c | 2 +-

>>  1 file changed, 1 insertion(+), 1 deletion(-)

>>

>> diff --git a/newlib/libc/stdio/flags.c b/newlib/libc/stdio/flags.c

>> index 71fc1f60a..cd73385ce 100644

>> --- a/newlib/libc/stdio/flags.c

>> +++ b/newlib/libc/stdio/flags.c

>> @@ -90,7 +90,7 @@ __sflags (struct _reent *ptr,

>>  	}

>>      }

>>  #if defined (O_TEXT) && !defined (__CYGWIN__)

>> -  if (!(m | O_BINARY))

>> +  if (!(m & O_BINARY))

>>      m |= O_TEXT;

>>  #endif

>>    *optr = m | o;

>> -- 

>> 2.19.2

> 

> Given that O_TEXT is under #if defined (__CYGWIN__) guard, do

> we need this code at all?  Does anybody actually *want* O_TEXT

> outside of the Windows world?


Actually I've no idea whereever newlib can go beyond Cygwin and Linux.
To me, this line is a typo, and I won't care if these lines are dropped.

Thanks!
/haubi/

Patch

diff --git a/newlib/libc/stdio/flags.c b/newlib/libc/stdio/flags.c
index 71fc1f60a..cd73385ce 100644
--- a/newlib/libc/stdio/flags.c
+++ b/newlib/libc/stdio/flags.c
@@ -90,7 +90,7 @@  __sflags (struct _reent *ptr,
 	}
     }
 #if defined (O_TEXT) && !defined (__CYGWIN__)
-  if (!(m | O_BINARY))
+  if (!(m & O_BINARY))
     m |= O_TEXT;
 #endif
   *optr = m | o;