[PATCH, libgfortran] Fix for PR 18982
Andreas Schwab
schwab@suse.de
Fri Jan 14 00:14:00 GMT 2005
Thomas Koenig <Thomas.Koenig@online.de> writes:
> On Thu, Jan 13, 2005 at 12:03:24AM +0100, Steven Bosscher wrote:
>
>> Why is the logical not (the '!') still there if you say "instead"?
>
> Because I messed up the patch in regenerating it, what I meant the
> code to look like this:
>
> if (fd < 0)
> {
> rwflag &= ~(!O_RDWR | O_RDONLY);
This still doesn't make sense, even if you remove the bogus '!'. O_RDWR,
O_RDONLY and O_WRONLY are three distinct values of a 2-bit field defined
by O_ACCMODE (3 by default). Combining any of these three values does not
yield anything useful.
Andreas.
2005-01-14 Andreas Schwab <schwab@suse.de>
PR libfortran/18982
* io/unix.c (O_ACCMODE): Define if not defined.
(regular_file): Properly rewrite access mode for open.
--- libgfortran/io/unix.c.~1.19.~ 2005-01-13 11:45:28.000000000 +0100
+++ libgfortran/io/unix.c 2005-01-14 01:08:04.931881587 +0100
@@ -63,6 +63,10 @@ Boston, MA 02111-1307, USA. */
#define PROT_WRITE 2
#endif
+#ifndef O_ACCMODE
+#define O_ACCMODE 3
+#endif
+
/* These flags aren't defined on all targets (mingw32), so provide them
here. */
#ifndef S_IRGRP
@@ -1069,11 +1073,11 @@ regular_file (unit_flags *flags)
{
if (fd < 0)
{
- rwflag = rwflag & !O_RDWR | O_RDONLY;
+ rwflag = (rwflag & ~O_ACCMODE) | O_RDONLY;
fd = open (path, rwflag, mode);
if (fd < 0)
{
- rwflag = rwflag & !O_RDONLY | O_WRONLY;
+ rwflag = (rwflag & ~O_ACCMODE) | O_WRONLY;
fd = open (path, rwflag, mode);
if (fd < 0)
flags->action = ACTION_READWRITE; /* Could not open at all. */
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
More information about the Fortran
mailing list