[glibmm/gmmproc-refactor] Add a script print possible macros.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/gmmproc-refactor] Add a script print possible macros.
- Date: Sun, 24 Jun 2012 19:52:27 +0000 (UTC)
commit 1b3193eee55261ec3272362c8ff0be79e5b77299
Author: Krzesimir Nowak <qdlacz gmail com>
Date: Mon Jun 25 01:25:08 2012 +0200
Add a script print possible macros.
Helpful for finding which macros are used.
tools/pm/macrocatcher.pl | 57 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/tools/pm/macrocatcher.pl b/tools/pm/macrocatcher.pl
new file mode 100755
index 0000000..7bd654f
--- /dev/null
+++ b/tools/pm/macrocatcher.pl
@@ -0,0 +1,57 @@
+#!/usr/bin/perl
+# -*- mode: perl; perl-indent-level: 2; indent-tabs-mode: nil -*-
+
+use strict;
+use warnings;
+use IO::File;
+use v5.12;
+
+my %macros = ();
+
+sub grep_for_possible_macros
+{
+ my $m4_block = 0;
+
+ foreach my $line (@_)
+ {
+ my $m4 = 0;
+
+ if ($m4_block or $line =~ /^\s*#m4\b/)
+ {
+ $m4 = 1;
+ }
+ elsif ($line =~ /^\s*#m4end\b/)
+ {
+ $m4 = 1;
+ $m4_block = 0;
+ }
+
+ while (($m4 and $line =~ /\b([A-Z_]+)\b/) or (not $m4 and $line =~ /\b(_[A-Z_]+)\b/))
+ {
+ my $macro = $1;
+
+ $macros{$macro} = undef;
+ $line =~ s/$macro//g;
+ }
+ }
+}
+
+foreach my $file (@ARGV)
+{
+ my $fd = IO::File->new ($file, 'r');
+
+ unless (defined ($fd))
+ {
+ say ('Could not open `' . $file . '.');
+ }
+
+ my @lines = $fd->getlines ();
+
+ $fd->close ();
+ grep_for_possible_macros (@lines);
+}
+
+foreach my $macro (sort (keys (%macros)))
+{
+ say $macro;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]