summaryrefslogtreecommitdiff
path: root/ACE/bin/indent_macros.pl
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/bin/indent_macros.pl')
-rwxr-xr-xACE/bin/indent_macros.pl59
1 files changed, 59 insertions, 0 deletions
diff --git a/ACE/bin/indent_macros.pl b/ACE/bin/indent_macros.pl
new file mode 100755
index 00000000000..3429d746dba
--- /dev/null
+++ b/ACE/bin/indent_macros.pl
@@ -0,0 +1,59 @@
+eval '(exit $?0)' && eval 'exec perl -i -S $0 ${1+"$@"}'
+ & eval 'exec perl -i -S $0 $argv:q'
+ if 0;
+
+# $Id$
+
+# This perl script re-arrange the macro indentation so it's easier to
+# see the layering relationship.
+
+$lineno = 0;
+$indent = 0;
+
+sub inc_indent
+{
+ $indent += 2;
+}
+
+sub dec_indent
+{
+ $indent -= 2;
+}
+
+sub get_indent
+{
+ $retv = 0;
+ print STDERR "$0 (", $lineno, "): Unbalanced macro pairs\n" if ($indent < 0);
+ $retv = $indent - 1 if ($indent > 0);
+ $retv;
+}
+
+while (<>) {
+ $lineno++;
+ if (/^[ \t]*\#[ \t]*((if|el|en|).*)/)
+ {
+ $cont = $1;
+ $temp = $2;
+ if ($temp =~ /if/) {
+ print "#", " " x &get_indent (), $cont,"\n";
+ inc_indent ();
+ }
+ elsif ($temp =~ /el/) {
+ dec_indent ();
+ print "#", " " x &get_indent (), $cont,"\n";
+ inc_indent ();
+ }
+ elsif ($temp =~ /en/) {
+ dec_indent ();
+ print "#", " " x &get_indent (), $cont,"\n";
+ }
+ else {
+ print "#", " " x &get_indent (), $cont,"\n";
+ }
+ }
+ else {
+ print $_;
+ }
+}
+
+die ("$0 (EOF): Unbalanced macro pairs\n") if ($indent != 0);