masscomp-request@soma.UUCP (01/12/87)
Someone came to me with a problem with opening a file for reading and
writing with fopen (file, "r+"). Seems you can't write it. This is
true in both the att and ucb universes. It turns out that this is a
System V bug, even though it's in ucb as well.
I found a workaround in the 2.11 news source, file control.c:
#if defined(USG) || defined(MG1)
/*
* U G L Y K L U D G E
* This utter piece of tripe is the only way I know of
* to get around the fact that ATT BROKE standard IO
* in System 5.2. Basically, you can't open a file for
* "r+" and then try and write to it. This hack works
* on all "real" USG Unix systems, It will probably
* break on some obscure look alike that doesnt use the
* real ATT stdio.h
* also broken in WCW MG-1 42nix 2.0
* Don't blame me, blame ATT. stdio should have
* already done the following line for us, but it didn't
*/
actfp->_flag |= _IOWRT;
#endif /* USG */
That is, set the write-enable bit manually.
--
- Joe Buck {hplabs,ihnp4,sun}!oliveb!epimass!jbuck HASA (A,S)
Entropic Processing, Inc., Cupertino, California