autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cmp in test scripts


From: John Poltorak
Subject: Re: cmp in test scripts
Date: Fri, 25 Jan 2002 14:08:06 +0000

On Fri, Jan 25, 2002 at 08:47:50AM -0500, Earnie Boyd wrote:
> Tim Van Holder wrote:
> > 
> > On Fri, 2002-01-25 at 02:09, Earnie Boyd wrote:

> > A shell has absolutely NOTHING to do with how a program reads a file.
> > 
> 
> Ok, I'll give you that one, I should have referenced the runtime.  I'm
> guessing from other posts that the runtime is OS/2 but I'm assuming.

It is OS/2, but the situation could apply to any environment where \n is 
interpreted differently to Unix.
 
> > > > "hello, world\n" is longer on a DOS filesystem than on Unix so cmp will
> > > > distinguish between whereas diff won't.
> > > >
> > >
> > > No it isn't.  "hello, world\n" is the same size in both worlds.  "hello,
> > > world\r\n" is the same size in both worlds.  A properly ported cmp would
> > > be a better method.

 
> > It IS properly ported.  cmp is supposed to compare file DATA (on a
> > per-byte basis).  As such it HAS to distinguish between DOS text, Mac
> > text and Unix text (and whatever other forms are there), because the
> > FILES differ.
> > 'diff' on the other hand, is supposed to show differences in a file's
> > CONTENTS, which is a higher-level concept.  For it, text is text, and
> > line endings don't necessarily have to count as different.  As such,
> > diff (or diff -a, if that's a portable option) is better at determining
> > difference between text files than cmp.
> 
> I agree with everything you've said except for suggesting diff as a
> better solution than cmp and that the problem resides with autoconf. 
> The problem as you pointed out isn't cmp.  The problem is the files of
> reference.  It is often customary to need to convert from unix line
> endings to dos line endings and vice versa before operating on files
> from the differing platforms so the burden is still yours.  You may want
> to consider modifying the program that's creating the files you're
> comparing to open files in what is known as `binary mode' so that the \r
> isn't prepended to the \n when writing the file.
> 
> I speak from experience.  I know that the problem can be rectified from
> the user side.  I use autoconf and friends on a DOSISH platform daily. 
> You need to find where the real problem resides.  You need to stop the
> \r\n garbage from being generated.  It can be done.

Wrong answer. 

CRLF is in no way garbage. It is the standard form of line termination on 
DOS filesystems. This issue is about choosing the correct comparison tool 
for test suites.

Makefile.in in SED contains:-

CMP = cmp

This is fine in Unix, and it has the potential of working OK on other 
systems because tests normally consist of '$CMP file1 file2'.

The question I'm posing is whether Autoconf could be used to evaluate the 
appropriate value for $CMP.
 
> Earnie.


-- 
John





reply via email to

[Prev in Thread] Current Thread [Next in Thread]