Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Sun, 4 Apr 2004 15:16:57 -0400 (EDT)
From: Igor Pechtchanski <pechtcha@cs.nyu.edu>
Reply-To: cygwin@cygwin.com
To: David Fritz <zeroxdf@att.net>
cc: cygwin@cygwin.com
Subject: Re: Bogus assumption prevents d2u/u2d/conv/etal working on mixed files.
In-Reply-To: <406F92EC.707@att.net>
Message-ID: <Pine.GSO.4.56.0404041515270.14458@slinky.cs.nyu.edu>
References: <NUTMEGuwtvWNkywIUEh00000336@NUTMEG.CAM.ARTIMI.COM> <406E4184.30904@cwilson.fastmail.fm> <406F92EC.707@att.net>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Scanned-By: MIMEDefang 2.39

On Sat, 3 Apr 2004, David Fritz wrote:

> Charles Wilson wrote:
> [...]
> >   (2) it's an attempt to prevent users from permanently scrogging binary
> > files.  See: d2u, on a binary file, is an irreversible operation.  So,
> > if you do "d2u *" you'll probably kill something deep inside some binary
> > file, and you can't fix it -- unless some minimal safeguards are in place.
> >
> >   u2d MAY be reversible -- IF there were no pre-exising \r\n
> > combinations in the file to begin with -- so when (OMG-fixit-)d2u is
> > run, obviously the first '\n' is preceeded by a (newly-added) '\r\n', so
> > the prog merrily replaces ALL '\r\n' with '\n'...which MAY fix your
> > oops, but maybe not.
> >
> >
> > So, with the current code, if you snarf the first "line" -- all chars
> > until the first '\n' -- if it's a binary file the odds are pretty low
> > that the immediately-preceeding character is a '\r' -- so d2u as
> > currently coded will bail out, and no harm is done.
> >
> > It doesn't work so well in the other direction -- by the same logic
> > above, you'll almost never bail out early if you run 'u2d' on a binary
> > file -- but if you immediately do a 'd2u' you MIGHT be able to recover.)
> >
> [...]
>
> If detection of binary files is desirable, why not use an explicit test
> with a more robust methodology?  GNU grep detects binary files by
> looking for a '\0' byte.  Such a test could be used by both d2u and u2d;
> they could bail out with a message like "skipping binary file".
>
> Cheers

Why not just call "file"?  ...Before using d2u/u2d?  And then call
"d2u/u2d --force".
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

