comp.lang.ada
 help / color / mirror / Atom feed
From: mazzanti@iei.pi.cnr.it (Franco Mazzanti)
Subject: Ada Code Formatting (Ada source diff)
Date: 1996/09/05
Date: 1996-09-05T00:00:00+00:00	[thread overview]
Message-ID: <mazzanti-0509961241430001@mac-mazz.iei.pi.cnr.it> (raw)


Some time ago on this thread it has been said (by Robert Dewar?):

> A useful utility would be an Ada specific diff, with an option to ignore
> white space, ignore line changes, ignore reformatting of comments, or
> igore comments completely.
>

Supposing GNAT is installed, the following simple CSH script, compares
the sources of two files containing a set of compilation units, and
report any difference which is not due to indenting, casing or comments.
It has been tested on Sun/Solaris1 but should be easily portable to any
Unix system since if just calls gnatchop, gnatf and diff.

Franco Mazzanti

----------------------- cut and make executable ---------------------------
#!/bin/csh
############################################################################
# src-diff
#    :compares the Ada sources inside two files omitting the
#    differences caused by indentations, case of identifiers or comments
#
# assumes gnatf and gnatchop are properly installed and visible through PATH
# assumes "diff" is available
############################################################################

if ($#argv == '0' || $#argv == '1') then
   echo 'usage: src-diff <file1> <file2>'
   exit
endif

set dir1=/tmp/$$src1
set dir2=/tmp/$$src2
mkdir $dir1
mkdir $dir2

gnatchop $1 $dir1  >/dev/null
gnatchop $2 $dir2  >/dev/null

cd $dir1
foreach unit (`/bin/ls *.ad?`)
  gnatf -s -do ${dir1}//$unit > ${dir1}/$unit.do
  gnatf -s -do ${dir2}/$unit > ${dir2}/$unit.do
  diff ${dir1}/$unit.tree  ${dir2}/$unit.do
end

/bin/rm -r $dir1 $dir2

############################################################################




             reply	other threads:[~1996-09-05  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-05  0:00 Franco Mazzanti [this message]
1996-09-06  0:00 ` Ada Code Formatting (Ada source diff) Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1996-09-06  0:00 Franco Mazzanti
1996-09-06  0:00 ` Robert Dewar
1996-09-06  0:00 ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox