bwarken pushed a commit to branch master
in repository groff.
commit b7e96ea4b33abb879b65e6c8be0d88808eb5f6a7
Author: Bernd Warken <[email protected]>
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 <[email protected]>
+
+ * src/roff/grog/grog.pl: Add handling of macro definition and fix
+ problems with @VERSION@.
+
2014-02-12 Rich Burridge <[email protected]>
[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 <[email protected]>.
@@ -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 @VERSION@\n";
+ "in groff version " . '@VERSION@' . "\n";
exit $exit_status;
}
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit