groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff-commit] [groff] 01/01: src/roff/grog/grog.pl: Add handling of mac


From: Bernd Warken
Subject: [Groff-commit] [groff] 01/01: src/roff/grog/grog.pl: Add handling of macro definition and fix @VERSION@
Date: Thu, 13 Feb 2014 21:43:52 +0000

bwarken pushed a commit to branch master
in repository groff.

commit b7e96ea4b33abb879b65e6c8be0d88808eb5f6a7
Author: Bernd Warken <address@hidden>
Date:   Thu Feb 13 22:43:37 2014 +0100

    src/roff/grog/grog.pl: Add handling of macro definition and fix @VERSION@
---
 ChangeLog             |    5 +++++
 src/roff/grog/grog.pl |   26 +++++++++++++++++++++++---
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 178c998..1959588 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-02-12  Bernd Warken  <address@hidden>
+
+       * src/roff/grog/grog.pl: Add handling of macro definition and fix
+       problems with @address@hidden
+
 2014-02-12  Rich Burridge  <address@hidden>
 
        [grn] Prevent crash if more than 50 command line arguments.
diff --git a/src/roff/grog/grog.pl b/src/roff/grog/grog.pl
index 3f33d86..12aaace 100644
--- a/src/roff/grog/grog.pl
+++ b/src/roff/grog/grog.pl
@@ -6,7 +6,7 @@
 # Source file position: <groff-source>/src/roff/grog/grog.pl
 # Installed position: <prefix>/bin/grog
 
-# Copyright (C) 1993, 2006, 2009, 2011-2012 Free Software Foundation, Inc.
+# Copyright (C) 1993, 2006, 2009, 2011-2012, 2014 Free Software Foundation, 
Inc.
 # Written by James Clark, maintained by Werner Lemberg.
 # Rewritten and put under GPL by Bernd Warken <address@hidden>.
 
@@ -26,7 +26,7 @@
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 
 ########################################################################
-my $Last_Update = '24 May 2012';
+my $Last_Update = '12 Feb 2014';
 ########################################################################
 
 require v5.6;
@@ -114,6 +114,7 @@ foreach my $arg (@ARGV) {
 sub process {
   my ($filename, $level) = @_;
   local(*FILE);
+  my %macros;
 
   if (!open(FILE, $filename eq "-" ? $filename : "< $filename")) {
     print STDERR "$Prog: can't open \`$filename': $!\n";
@@ -126,6 +127,25 @@ sub process {
     s/^\s+|\s+$//g;
     s/$/\n/;
 
+
+    if ( /^\.de1?\s+\w+/ ) {
+      # this line is a macro definition, add it to %macros
+      my $macro = s/^\.de1?\s+(\w+)\W*$/.$1/;
+      if (exists $macros{$macro}) {
+       next;
+      }
+      $macros{$macro} = 1;
+      next;
+    }
+    if ( /^\.\w+\W*/ ) {
+      # if line command is a defined macro, just ignore this line
+      my $macro = s/^(\.\w+)\W*.*$/$1/;
+      if ( exists $macros{$macro} ) {
+       next;
+      }
+    }
+
+
     if (/^(.cstart)|(begin\s+chem)$/) {
       $Groff{'chem'}++;
       $Groff{'soelim'}++ if $level;
@@ -288,7 +308,7 @@ EOF
 sub version {
   my ($exit_status) = @_;
   print "Perl version of GNU $Prog of $Last_Update " .
-    "in groff version @address@hidden";
+    "in groff version " . '@VERSION@' . "\n";
   exit $exit_status;
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]