[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: diff of souce C
From: |
Stepan Kasal |
Subject: |
Re: diff of souce C |
Date: |
Fri, 24 Jan 2003 14:08:28 +0100 |
User-agent: |
Mutt/1.2.5.1i |
Hello,
On Fri, Jan 24, 2003 at 01:14:46PM +0100, address@hidden wrote:
> I would like ignore differences of this type:
> file1.c_
> if (a==1) { printf("Hello World"); }
> ---
> file2.c:
> if (a==1)
> {
> printf("Hello World");
> }
as this is not a bug-report, address@hidden or news:comp.unix.shell
would be more appropriate.
You have to preprocess the files.
For example, take file
======= f.sed
s/\([{}]\) *$/\1/
s/^ *\([{}]\)/\1/
s/\([{}]\) *\([^ ]\)/\1\
\2/g
s/\([^ ]\) *\([{}]\)/\1\
\2/g
t loop
:loop
s/\(\n\) *\n/\1/g
t loop
s/^ *\n//
s/\n *$//
======= end of file f.sed
and run
sed -f f.sed file1.c >file1.c.a
sed -f f.sed file2.c >file2.c.a
Then compare the pre-processed versions.
(For mass preprocessing, you need to write a small shell script;
if you won't succeed, ask at comp.unix.shell for help with any particular
problem you encounter.)
GNU indent might be used instead of sed, to preprocess the source before
the comparison is done.
The final comparison may need -b or -w options to diff (see the info
documatation for explanation of these).
HTH,
Stepan
- diff of souce C, address@hidden, 2003/01/24
- Re: diff of souce C,
Stepan Kasal <=