delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1996/05/05/07:58:31

Date: Sun, 5 May 1996 14:57:06 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Douglas Rupp <drupp AT cs DOT washington DOT edu>
Cc: djgpp-workers AT delorie DOT com
Subject: Re: Patch bug
In-Reply-To: <199605050803.BAA16060@june.cs.washington.edu>
Message-Id: <Pine.SUN.3.91.960505144946.11941U-100000@is>
Mime-Version: 1.0

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'). 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019