This is the mail archive of the
mailing list for the GCC project.
Re: How to compare two text files? Using sed, cmp, diff, tr?
- From: Joern Rennecke <amylaar at spamcop dot net>
- To: Georg-Johann Lay <avr at gjlay dot de>
- Cc: gcc at gcc dot gnu dot org, Jörg Wunsch <joerg_wunsch at uriah dot heep dot sax dot de>
- Date: Sat, 26 May 2012 14:07:54 -0400
- Subject: Re: How to compare two text files? Using sed, cmp, diff, tr?
- References: <4FC0AA16.firstname.lastname@example.org>
Quoting Georg-Johann Lay <email@example.com>:
The avr backend auto-generates parts of GCC's texi documentation,
namely the supported -mmcu= options, which are about 200.
I hope that autogenerated documentation is still helpful then.
Sometimes an overabundance of verbose documentation can prevent a user
from finding what (s)he needs.
The sed -e 's:\r::g' from above that tries to fix line endings has the
problem that not all sed implementations are the same, i.e. some just do
sed -e 's:r::g' and remove all r's.
I searched some time how to accomplish this but did not find a neat solution.
Can tr from roff be used? Is it a valid prerequisite for GCC?
tr is already used in a number of places in Makefile.in. Note
that there is a distinction between tools required to rebuild auto-generated
files, and tool required to build GCC assuming all auto-generated files
are up-to-date. You should make it so that tr is not used if the timestamps
indicate that the documentation is up-to-date.
Look for the s-tm-texi rule in Makefile.in, it normalizes the line ending
using tr (while taking care of a Solaris oddity), before comparing it to
the existing version.
Or open a binary file to write the test instead of printf+stdout?
That just shifts the portability issues to how to open a file for binary
writing. Not all platforms support open(2). Some platforms need "b" for
fopen, others reject it. And then you have to make sure that what you
write really makes sense for binary writing on all platforms, when you
naturally describe the data as text.