From: drupp AT cs DOT washington DOT edu (Douglas Rupp) Message-Id: <199605070233.TAA11024@june.cs.washington.edu> Subject: Re: Patch bug To: eliz AT is DOT elta DOT co DOT il (Eli Zaretskii) Date: Mon, 6 May 1996 19:33:44 -0700 (PDT) Cc: drupp AT cs DOT washington DOT edu, djgpp-workers AT delorie DOT com In-Reply-To: from "Eli Zaretskii" at May 5, 96 02:57:06 pm MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit > > > I've noticed that patch doesn't open files in O_BINARY mode. I > > think it should. When trying to patch Unix style files with Unix style > > patches, the first patch works fine but the file gets written out in > > DOS text style. Then if a second Unix style patch is applied, it messes up > > because of the mis-match. > > But AFAIK patch only knows about line numbers, not byte offsets, so how > can extra CR characters mess it up? Are you sure you use the latest > version of `patch'? A bug in `fseek' and `ftell' in the initial release > of v2.0 made `patch' buggy; please get the latest version of pat21b.zip, > dated 22-Feb-96 or later and try it. I build patch from pat21s.zip and it messed up. > > If that also doesn't work, please post an example of file and a > patch-file that demonstrates the problem. > > > A simple "_fmode=O_BINARY" in main() will fix this (appropriately ifdef'ed). > > Even if reading in binary is necessary, this may not be enough. `_fmode' > doesn't affect stdin and stdout, so if you say "patch < patchfile", > `patchfile' will be still read in text mode. If you need to read stdin in > binary, use `setmode' (but first test for stdin being a file with > `isatty'). > patch