Date: Sun, 5 May 1996 14:57:06 +0200 (IST) From: Eli Zaretskii To: Douglas Rupp Cc: djgpp-workers AT delorie DOT com Subject: Re: Patch bug In-Reply-To: <199605050803.BAA16060@june.cs.washington.edu> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Sun, 5 May 1996, Douglas Rupp wrote: > 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. 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').