From MAILER-DAEMON Thu Jul 16 06:06:50 2015
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1ZFg42-0004Bf-DT
	for mharc-groff-commit@gnu.org; Thu, 16 Jul 2015 06:06:50 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:33342)
	by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <wl@gnu.org>)
	id 1ZFg3z-0004An-R0
	for groff-commit@gnu.org; Thu, 16 Jul 2015 06:06:48 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wl@gnu.org>) id 1ZFg3l-0001PC-U6
	for groff-commit@gnu.org; Thu, 16 Jul 2015 06:06:47 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:41239)
	by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <wl@gnu.org>)
	id 1ZFg3l-0001P3-Qo
	for groff-commit@gnu.org; Thu, 16 Jul 2015 06:06:33 -0400
Received: from wl by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <wl@gnu.org>) id 1ZFg3l-00085Q-3P
	for groff-commit@gnu.org; Thu, 16 Jul 2015 10:06:33 +0000
Date: Thu, 16 Jul 2015 10:06:33 +0000
Message-Id: <E1ZFg3l-00085Q-3P@vcs.savannah.gnu.org>
To: groff-commit@gnu.org
Subject: [groff] 01/01: [mm] Fix line length of `.DS' with indentation
	(#45452).
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
In-Reply-To: groff@gnu.org
References: <20150716100633.31053.81060@vcs.savannah.gnu.org>
X-Git-Repo: groff
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Rev: 06dbfabd78c4b7b7a6c85aa3e187d6dc6bb7f6f5
Auto-Submitted: auto-generated
From: Werner LEMBERG <wl@gnu.org>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: groff-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: groff@gnu.org
List-Id: <groff-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/groff-commit>,
	<mailto:groff-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/groff-commit>
List-Post: <mailto:groff-commit@gnu.org>
List-Help: <mailto:groff-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/groff-commit>,
	<mailto:groff-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 16 Jul 2015 10:06:48 -0000

wl pushed a commit to branch master
in repository groff.

commit 06dbfabd78c4b7b7a6c85aa3e187d6dc6bb7f6f5
Author: Carsten Kunze <carsten.kunze@arcor.de>
Date:   Thu Jul 16 12:05:55 2015 +0200

    [mm] Fix line length of `.DS' with indentation (#45452).
    
    If `.DS' with first argument `1' or `I' is used the output should
    use an indentation of `\n[Si]n'.  To make this work, the line length
    within the `.DS' diversion must be set to zero, otherwise the
    effective line length is too large.
    
    * m.tmac (DS): Call `ds@set-new-ev' with correct indentation value.
---
 contrib/mm/ChangeLog |   11 +++++++++++
 contrib/mm/m.tmac    |    4 +++-
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/contrib/mm/ChangeLog b/contrib/mm/ChangeLog
index a351c10..83deaf9 100644
--- a/contrib/mm/ChangeLog
+++ b/contrib/mm/ChangeLog
@@ -1,3 +1,14 @@
+Thu Jul 16 11:52:03 2015  Carsten Kunze  <carsten.kunze@arcor.de>
+
+	Fix line length of `.DS' with indentation (#45452).
+
+	If `.DS' with first argument `1' or `I' is used the output should
+	use an indentation of `\n[Si]n'.  To make this work, the line length
+	within the `.DS' diversion must be set to zero, otherwise the
+	effective line length is too large.
+
+	* m.tmac (DS): Call `ds@set-new-ev' with correct indentation value.
+
 Fri Apr  3 16:33:22 2015  Werner LEMBERG  <wl@gnu.org>
 
 	Make man pages work in compatibility mode.
diff --git a/contrib/mm/m.tmac b/contrib/mm/m.tmac
index 4b76039..09cc03b 100644
--- a/contrib/mm/m.tmac
+++ b/contrib/mm/m.tmac
@@ -2083,7 +2083,9 @@ in=\\n[.i] fi=\\n[.u] .d=\\n[.d] nl=\\n[nl] pg=\\n[%]
 'in 0
 .di ds*div!\\n[ds*snr]
 .\"
-.ds@set-new-ev \\n[ds*old-ll]
+.nr ds*div-ll \\n[ds*old-ll]
+.if \\n[ds*format]=1 .nr ds*div-ll -\\n(Sin
+.ds@set-new-ev \\n[ds*div-ll]
 .nr df*float 0
 ..
 .\"--------------------------------------------


From MAILER-DAEMON Sun Jul 19 04:15:44 2015
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1ZGjl9-0006ct-Uf
	for mharc-groff-commit@gnu.org; Sun, 19 Jul 2015 04:15:43 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:44189)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bernd.warken@web.de>) id 1ZGjl0-0006c8-Lm
	for groff-commit@gnu.org; Sun, 19 Jul 2015 04:15:42 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bernd.warken@web.de>) id 1ZGjkt-000461-DI
	for groff-commit@gnu.org; Sun, 19 Jul 2015 04:15:34 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:53292)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bernd.warken@web.de>) id 1ZGjkt-00045v-6V
	for groff-commit@gnu.org; Sun, 19 Jul 2015 04:15:27 -0400
Received: from bwarken by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <bernd.warken@web.de>) id 1ZGjkr-0001XD-7Y
	for groff-commit@gnu.org; Sun, 19 Jul 2015 08:15:25 +0000
Date: Sun, 19 Jul 2015 08:15:25 +0000
Message-Id: <E1ZGjkr-0001XD-7Y@vcs.savannah.gnu.org>
To: groff-commit@gnu.org
Subject: [groff] 01/01: grog: enhance detection of .TH to .TH_first (for
	man) and .TH_later (for ms).
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
In-Reply-To: groff@gnu.org
References: <20150719081525.5868.74501@vcs.savannah.gnu.org>
X-Git-Repo: groff
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Rev: 56971f6e54841e6cbf1e1a504cb1abd21fe3393b
Auto-Submitted: auto-generated
From: Bernd Warken <bernd.warken@web.de>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: groff-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: groff@gnu.org
List-Id: <groff-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/groff-commit>,
	<mailto:groff-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/groff-commit>
List-Post: <mailto:groff-commit@gnu.org>
List-Help: <mailto:groff-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/groff-commit>,
	<mailto:groff-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 19 Jul 2015 08:15:42 -0000

bwarken pushed a commit to branch master
in repository groff.

commit 56971f6e54841e6cbf1e1a504cb1abd21fe3393b
Author: Bernd Warken <groff-bernd.warken-72@web.de>
Date:   Sun Jul 19 10:13:11 2015 +0200

    grog: enhance detection of .TH to .TH_first (for man) and .TH_later (for ms).
---
 ChangeLog             |    9 +
 src/roff/grog/grog.pl |  202 ++--
 src/roff/grog/subs.pl | 2511 +++++++++++++++++++++++++------------------------
 3 files changed, 1384 insertions(+), 1338 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6951dcf..75520c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2015-07-19  Bernd Warken  <groff-bernd.warken-72@web.de>
+
+        * src/roff/grog/*.pl: Add last update.
+
+        * src/roff/grog/subs.pl: Remove call to Perl INC::System::Simple,
+	use backticks instead.  Define &err().  Reorder some extensions.
+	Distinguish between .TH at first command for man and later on for
+	ms.
+
 2015-07-01 Peter Bray <pdb_ml@yahoo.com.au>
 
 	Fix Savannah bug #44784
diff --git a/src/roff/grog/grog.pl b/src/roff/grog/grog.pl
index fb7b54c..b78963e 100644
--- a/src/roff/grog/grog.pl
+++ b/src/roff/grog/grog.pl
@@ -1,100 +1,102 @@
-#! /usr/bin/env perl
-# grog - guess options for groff command
-# Inspired by doctype script in Kernighan & Pike, Unix Programming
-# Environment, pp 306-8.
-
-# Source file position: <groff-source>/src/roff/grog/grog.pl
-# Installed position: <prefix>/bin/grog
-
-# Copyright (C) 1993-2014  Free Software Foundation, Inc.
-# Written by James Clark, maintained by Werner Lemberg.
-# Rewritten with Perl by Bernd Warken <groff-bernd.warken-72@web.de>.
-# The macros for identifying the devices were taken from Ralph
-# Corderoy's `grog.sh' from 2006.
-
-# This file is part of `grog', which is part of `groff'.
-
-# `groff' is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-
-# `groff' is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see
-# <http://www.gnu.org/licenses/gpl-2.0.html>.
-
-########################################################################
-
-require v5.6;
-
-use warnings;
-use strict;
-
-# $Bin is the directory where this script is located
-use FindBin;
-
-my $before_make;	# script before run of `make'
-{
-  my $at = '@';
-  $before_make = 1 if '@VERSION@' eq "${at}VERSION${at}";
-}
-
-
-our %at_at;
-my $grog_dir;
-
-if ($before_make) { # before installation
-  my $grog_source_dir = $FindBin::Bin;
-  $at_at{'BINDIR'} = $grog_source_dir;
-# $grog_dir = $grog_source_dir;
-  $grog_dir = '.';
-  my $top = $grog_source_dir . '/../../../';
-  open FILE, '<', $top . 'VERSION' ||
-    die 'Could not open top file VERSION.';
-  my $version = <FILE>;
-  chomp $version;
-  close FILE;
-  open FILE, '<', $top . 'REVISION' ||
-    die 'Could not open top file REVISION.';
-  my $revision = <FILE>;
-  chomp $revision;
-  $at_at{'GROFF_VERSION'} = $version . '.' . $revision;
-} else { # after installation}
-  $at_at{'GROFF_VERSION'} = '@VERSION@';
-  $at_at{'BINDIR'} = '@BINDIR@';
-  $grog_dir = '@grog_dir@';
-} # before make
-
-die "$grog_dir is not an existing directory;" unless -d $grog_dir;
-
-
-#############
-# import subs
-
-unshift(@INC, $grog_dir);
-require 'subs.pl';
-
-
-##########
-# run subs
-
-&handle_args();
-&handle_file_ext(); # see $tmac_ext for gotten value
-&handle_whole_files();
-&make_groff_device();
-&make_groff_preproc();
-&make_groff_tmac_man_ms() || &make_groff_tmac_others();
-&make_groff_line_rest();
-
-
-1;
-########################################################################
-### Emacs settings
-# Local Variables:
-# mode: CPerl
-# End:
+#! /usr/bin/env perl
+# grog - guess options for groff command
+# Inspired by doctype script in Kernighan & Pike, Unix Programming
+# Environment, pp 306-8.
+
+# Source file position: <groff-source>/src/roff/grog/grog.pl
+# Installed position: <prefix>/bin/grog
+
+# Copyright (C) 1993-2015  Free Software Foundation, Inc.
+# Written by James Clark, maintained by Werner Lemberg.
+# Rewritten with Perl by Bernd Warken <groff-bernd.warken-72@web.de>.
+# The macros for identifying the devices were taken from Ralph
+# Corderoy's `grog.sh' of 2006.
+
+# Last update: 19 Jul 2015
+
+# This file is part of `grog', which is part of `groff'.
+
+# `groff' is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+
+# `groff' is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see
+# <http://www.gnu.org/licenses/gpl-2.0.html>.
+
+########################################################################
+
+require v5.6;
+
+use warnings;
+use strict;
+
+# $Bin is the directory where this script is located
+use FindBin;
+
+my $before_make;	# script before run of `make'
+{
+  my $at = '@';
+  $before_make = 1 if '@VERSION@' eq "${at}VERSION${at}";
+}
+
+
+our %at_at;
+my $grog_dir;
+
+if ($before_make) { # before installation
+  my $grog_source_dir = $FindBin::Bin;
+  $at_at{'BINDIR'} = $grog_source_dir;
+# $grog_dir = $grog_source_dir;
+  $grog_dir = '.';
+  my $top = $grog_source_dir . '/../../../';
+  open FILE, '<', $top . 'VERSION' ||
+    die 'Could not open top file VERSION.';
+  my $version = <FILE>;
+  chomp $version;
+  close FILE;
+  open FILE, '<', $top . 'REVISION' ||
+    die 'Could not open top file REVISION.';
+  my $revision = <FILE>;
+  chomp $revision;
+  $at_at{'GROFF_VERSION'} = $version . '.' . $revision;
+} else { # after installation}
+  $at_at{'GROFF_VERSION'} = '@VERSION@';
+  $at_at{'BINDIR'} = '@BINDIR@';
+  $grog_dir = '@grog_dir@';
+} # before make
+
+die "$grog_dir is not an existing directory;" unless -d $grog_dir;
+
+
+#############
+# import subs
+
+unshift(@INC, $grog_dir);
+require 'subs.pl';
+
+
+##########
+# run subs
+
+&handle_args();
+&handle_file_ext(); # see $tmac_ext for gotten value
+&handle_whole_files();
+&make_groff_device();
+&make_groff_preproc();
+&make_groff_tmac_man_ms() || &make_groff_tmac_others();
+&make_groff_line_rest();
+
+
+1;
+########################################################################
+### Emacs settings
+# Local Variables:
+# mode: CPerl
+# End:
diff --git a/src/roff/grog/subs.pl b/src/roff/grog/subs.pl
index 2220db7..ec5e1a9 100644
--- a/src/roff/grog/subs.pl
+++ b/src/roff/grog/subs.pl
@@ -1,1238 +1,1273 @@
-#! /usr/bin/env perl
-# grog - guess options for groff command
-# Inspired by doctype script in Kernighan & Pike, Unix Programming
-# Environment, pp 306-8.
-
-# Source file position: <groff-source>/src/roff/grog/subs.pl
-# Installed position: <prefix>/lib/grog/subs.pl
-
-# Copyright (C) 1993-2014  Free Software Foundation, Inc.
-# This file was split from grog.pl and put under GPL2 by
-#               Bernd Warken <groff-bernd.warken-72@web.de>.
-# The macros for identifying the devices were taken from Ralph
-# Corderoy's `grog.sh' of 2006.
-
-# This file is part of `grog', which is part of `groff'.
-
-# `groff' is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-
-# `groff' is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-
-# You can get the license text for the GNU General Public License
-# version 2 in the internet at
-# <http://www.gnu.org/licenses/gpl-2.0.html>.
-
-########################################################################
-
-require v5.6;
-
-use warnings;
-use strict;
-
-use File::Spec;
-
-# printing of hashes: my %hash = ...; print Dumper(\%hash);
-use Data::Dumper;
-
-$\ = "\n";
-
-# my $Sp = "[\\s\\n]";
-# my $Sp = qr([\s\n]);
-# my $Sp = '' if $arg eq '-C';
-my $Sp = '';
-
-# from `src/roff/groff/groff.cpp' near `getopt_long'
-my $groff_opts =
-  'abcCd:D:eEf:F:gGhiI:jJkK:lL:m:M:n:No:pP:r:RsStT:UvVw:W:XzZ';
-
-my @Command = ();		# stores the final output
-my @Mparams = ();		# stores the options `-m*'
-my @devices = ();
-my $do_run = 0;			# run generated `groff' command
-my $pdf_with_ligatures = 0;	# `-P-y -PU' for `pdf' device
-my $with_warnings = 0;
-
-my $Prog = $0;
-{
-  my ($v, $d, $f) = File::Spec->splitpath($Prog);
-  $Prog = $f;
-}
-
-
-my %macros;
-my %Groff =
-  (
-   # preprocessors
-   'chem' => 0,
-   'eqn' => 0,
-   'gperl' => 0,
-   'grap' => 0,
-   'grn' => 0,
-   'gideal' => 0,
-   'gpinyin' => 0,
-   'lilypond' => 0,
-
-   'pic' => 0,
-   'PS' => 0,		# opening for pic
-   'PF' => 0,		# alternative opening for pic
-   'PE' => 0,		# closing for pic
-
-   'refer' => 0,
-   'refer_open' => 0,
-   'refer_close' => 0,
-   'soelim' => 0,
-   'tbl' => 0,
-
-   # tmacs
-#   'man' => 0,
-#   'mandoc' => 0,
-#   'mdoc' => 0,
-#   'mdoc_old' => 0,
-#   'me' => 0,
-#   'mm' => 0,
-#   'mom' => 0,
-#   'ms' => 0,
-
-   # requests
-   'AB' => 0,		# ms
-   'AE' => 0,		# ms
-   'AI' => 0,		# ms
-   'AU' => 0,		# ms
-   'NH' => 0,		# ms
-   'TL' => 0,		# ms
-   'UL' => 0,		# ms
-   'XP' => 0,		# ms
-
-   'IP' => 0,		# man and ms
-   'LP' => 0,		# man and ms
-   'P' => 0,		# man and ms
-   'PP' => 0,		# man and ms
-   'SH' => 0,		# man and ms
-
-   'OP' => 0,		# man
-   'SS' => 0,		# man
-   'SY' => 0,		# man
-   'TH' => 0,		# man
-   'TP' => 0,		# man
-   'UR' => 0,		# man
-   'YS' => 0,		# man
-
-   # for mdoc and mdoc-old
-   # .Oo and .Oc for modern mdoc, only .Oo for mdoc-old
-   'Oo' => 0,		# mdoc and mdoc-old
-   'Oc' => 0,		# mdoc
-   'Dd' => 0,		# mdoc
-  ); # end of %Groff
-
-
-# for first line check
-my %preprocs_tmacs =
-  (
-   'chem' => 0,
-   'eqn' => 0,
-   'gideal' => 0,
-   'gpinyin' => 0,
-   'grap' => 0,
-   'grn' => 0,
-   'pic' => 0,
-   'refer' => 0,
-   'soelim' => 0,
-   'tbl' => 0,
-
-   'geqn' => 0,
-   'gpic' => 0,
-   'neqn' => 0,
-
-   'man' => 0,
-   'mandoc' => 0,
-   'mdoc' => 0,
-   'mdoc-old' => 0,
-   'me' => 0,
-   'mm' => 0,
-   'mom' => 0,
-   'ms' => 0,
-  );
-
-my @filespec;
-
-my $tmac_ext = '';
-
-
-########################################################################
-# handle_args()
-########################################################################
-
-sub handle_args {
-  my $double_minus = 0;
-  my $was_minus = 0;
-  my $was_T = 0;
-  my $optarg = 0;
-  # globals: @filespec, @Command, @devices, @Mparams
-
-  foreach my $arg (@ARGV) {
-
-    if ( $optarg ) {
-      push @Command, $arg;
-      $optarg = 0;
-      next;
-    }
-
-    if ( $double_minus ) {
-      if (-f $arg && -r $arg) {
-	push @filespec, $arg;
-      } else {
-	print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	  "grog: $arg is not a readable file.";
-      }
-      next;
-    }
-
-    if ( $was_T ) {
-      push @devices, $arg;
-      $was_T = 0;
-      next;
-    }
-####### handle_args()
-
-    unless ( $arg =~ /^-/ ) { # file name, no opt, no optarg
-      unless (-f $arg && -r $arg) {
-	print 'unknown file name: ' . $arg;
-      }
-      push @filespec, $arg;
-      next;
-    }
-
-    # now $arg starts with `-'
-
-    if ($arg eq '-') {
-      unless ($was_minus) {
-	push @filespec, $arg;
-	$was_minus = 1;
-      }
-      next;
-    }
-
-    if ($arg eq '--') {
-      $double_minus = 1;
-      push(@filespec, $arg);
-      next;
-    }
-
-    &version() if $arg =~ /^--?v/;	# --version, with exit
-    &help() if $arg  =~ /--?h/;		# --help, with exit
-
-    if ( $arg =~ /^--r/ ) {		#  --run, no exit
-      $do_run = 1;
-      next;
-    }
-
-    if ( $arg =~ /^--wa/ ) {		#  --warnings, no exit
-      $with_warnings = 1;
-      next;
-    }
-####### handle_args()
-
-    if ( $arg =~ /^--(wi|l)/ ) { # --ligatures, no exit
-      # the old --with_ligatures is only kept for compatibility
-      $pdf_with_ligatures = 1;
-      next;
-    }
-
-    if ($arg =~ /^-m/) {
-      push @Mparams, $arg;
-      next;
-    }
-
-    if ($arg =~ /^-T$/) {
-      $was_T = 1;
-      next;
-    }
-
-    if ($arg =~ s/^-T(\w+)$/$1/) {
-      push @devices, $1;
-      next;
-    }
-
-    if ($arg =~ /^-(\w)(\w*)$/) {	# maybe a groff option
-      my $opt_char = $1;
-      my $opt_char_with_arg = $opt_char . ':';
-      my $others = $2;
-      if ( $groff_opts =~ /$opt_char_with_arg/ ) {	# groff optarg
-	if ( $others ) {	# optarg is here
-	  push @Command, '-' . $opt_char;
-	  push @Command, '-' . $others;
-	  next;
-	}
-	# next arg is optarg
-	$optarg = 1;
-	next;
-####### handle_args()
-      } elsif ( $groff_opts =~ /$opt_char/ ) {	# groff no optarg
-	push @Command, '-' . $opt_char;
-	if ( $others ) {	# $others is now an opt collection
-	  $arg = '-' . $others;
-	  redo;
-	}
-	# arg finished
-	next;
-      } else {		# not a groff opt
-	print STDERR __FILE__ . ' '  . __LINE__ . ': ' .
-	  'unknown argument ' . $arg;
-	push(@Command, $arg);
-	next;
-      }
-    }
-  }
-  @filespec = ('-') unless (@filespec);
-} # handle_args()
-
-
-
-########################################################################
-# handle_file_ext()
-########################################################################
-
-sub handle_file_ext {
-  # get tmac from file name extension
-  # output number of found single tmac
-
-  # globals: @filespec, $tmac_ext;
-
-  foreach my $file ( @filespec ) {
-    # test for each file name in the arguments
-    unless ( open(FILE, $file eq "-" ? $file : "< $file") ) {
-      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	"$Prog: can't open \`$file\': $!";
-      next;
-    }
-
-    next unless ( $file =~ /\./ ); # file name has no dot `.'
-
-##### handle_file_ext()
-    # get extension
-    my $ext = $file;
-    $ext =~ s/^
-	      .*
-	      \.
-	      ([^.]*)
-	      $
-	     /$1/x;
-    next unless ( $ext );
-
-##### handle_file_ext()
-    # these extensions are correct, but not based on a tmac
-    next if ( $ext =~ /^(
-			 chem|
-			 eqn|
-			 pic|
-			 tbl|
-			 ref|
-			 t|
-			 tr|
-			 g|
-			 groff|
-			 roff|
-			 www|
-			 hdtbl|
-			 grap|
-			 grn|
-			 pdfroff|
-			 pinyin
-		       )$/x );
-
-##### handle_file_ext()
-    # extensions for man tmac
-    if ( $ext =~ /^(
-		      [1-9lno]|
-		      man|
-		      n|
-		      1b
-		    )$/x ) {
-      # `man|n' from `groff' source
-      # `1b' from `heirloom'
-      # `[1-9lno]' from man-pages
-      if ( $tmac_ext && $tmac_ext ne 'man' ) {
-	# found tmac is not 'man'
-	print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	  '2 different file name extensions found ' .
-	    $tmac_ext . ' and ' . $ext;
-	$tmac_ext = '';
-	next;
-      }
-
-##### handle_file_ext()
-      $tmac_ext = 'man';
-      next;
-    }
-
-    if ( $ext =~ /^(
-		    mandoc|
-		    mdoc|
-		    me|
-		    mm|
-		    mmse|
-		    mom|
-		    ms|
-		    $)/x ) {
-      if ( $tmac_ext && $tmac_ext ne $ext ) {
-	# found tmac is not identical to former found tmac
-##### handle_file_ext()
-	print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	  '2 different file name extensions found ' .
-	    $tmac_ext . ' and ' . $ext;
-	$tmac_ext = '';
-	next;
-      }
-
-      $tmac_ext = $ext;
-      next;
-    }
-
-    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-      'Unknown file name extension '. $file . '.';
-    next;
-  } # end foreach file
-
-  1;
-} # handle_file_ext()
-
-
-########################################################################
-# handle_whole_files()
-########################################################################
-
-sub handle_whole_files {
-  # globals: @filespec
-
-  foreach my $file ( @filespec ) {
-    unless ( open(FILE, $file eq "-" ? $file : "< $file") ) {
-      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	"$Prog: can't open \`$file\': $!";
-      next;
-    }
-    my $line = <FILE>; # get single line
-
-    unless ( defined($line) ) {
-      # empty file, go to next filearg
-      close (FILE);
-      next;
-    }
-
-    if ( $line ) {
-      chomp $line;
-      unless ( &do_first_line( $line, $file ) ) {
-	# not an option line
-	&do_line( $line, $file );
-      }
-    } else { # emptry line
-      next;
-    }
-
-    while (<FILE>) { # get lines by and by
-      chomp;
-      &do_line( $_, $file );
-    }
-    close(FILE);
-  } # end foreach
-} # handle_whole_files()
-
-
-########################################################################
-# do_first_line()
-########################################################################
-
-# As documented for the `man' program, the first line can be
-# used as a groff option line.  This is done by:
-# - start the line with '\" (apostrophe, backslash, double quote)
-# - add a space character
-# - a word using the following characters can be appended: `egGjJpRst'.
-#     Each of these characters means an option for the generated
-#     `groff' command line, e.g. `-t'.
-
-sub do_first_line {
-  my ( $line, $file ) = @_;
-
-  # globals: %preprocs_tmacs
-
-  # For a leading groff options line use only [egGjJpRst]
-  if  ( $line =~ /^[.']\\"[\segGjJpRst]+&/ ) {
-    # this is a groff options leading line
-    if ( $line =~ /^\./ ) {
-      # line is a groff options line with . instead of '
-      print "First line in $file must start with an apostrophe \ " .
-	"instead of a period . for groff options line!";
-    }
-
-    if ( $line =~ /j/ ) {
-      $Groff{'chem'}++;
-    }
-    if ( $line =~ /e/ ) {
-      $Groff{'eqn'}++;
-    }
-    if ( $line =~ /g/ ) {
-      $Groff{'grn'}++;
-    }
-    if ( $line =~ /G/ ) {
-      $Groff{'grap'}++;
-    }
-    if ( $line =~ /i/ ) {
-      $Groff{'gideal'}++;
-    }
-    if ( $line =~ /p/ ) {
-      $Groff{'pic'}++;
-    }
-    if ( $line =~ /R/ ) {
-      $Groff{'refer'}++;
-    }
-    if ( $line =~ /s/ ) {
-      $Groff{'soelim'}++;
-    }
-####### do_first_line()
-    if ( $line =~ /t/ ) {
-      $Groff{'tbl'}++;
-    }
-    return 1;	# a leading groff options line, 1 means yes, 0 means no
-  }
-
-  # not a leading short groff options line
-
-  return 0 if ( $line !~ /^[.']\\"\s*(.*)$/ );	# ignore non-comments
-
-  return 0 unless ( $1 );	# for empty comment
-
-  # all following array members are either preprocs or 1 tmac
-  my @words = split '\s+', $1;
-
-  my @in = ();
-  my $word;
-  for $word ( @words ) {
-    if ( $word eq 'ideal' ) {
-      $word = 'gideal';
-    } elsif ( $word eq 'gpic' ) {
-      $word = 'pic';
-    } elsif ( $word =~ /^(gn|)eqn$/ ) {
-      $word = 'eqn';
-    }
-    if ( exists $preprocs_tmacs{$word} ) {
-      push @in, $word;
-    } else {
-      # not word for preproc or tmac
-      return 0;
-    }
-  }
-
-  for $word ( @in ) {
-    $Groff{$word}++;
-  }
-} # do_first_line()
-
-
-########################################################################
-# do_line()
-########################################################################
-
-sub do_line {
-  my ( $line, $file ) = @_;
-
-  return if ( $line =~ /^[.']\s*\\"/ );	# comment
-
-  return unless ( $line =~ /^[.']/ );	# ignore text lines
-
-  $line =~ s/^['.]\s*/./;	# let only a dot as leading character,
-				# remove spaces after the leading dot
-  $line =~ s/\s+$//;		# remove final spaces
-
-  return if ( $line =~ /^\.$/ );	# ignore .
-  return if ( $line =~ /^\.\.$/ );	# ignore ..
-
-  # split command
-  $line =~ /^(\.\w+)\s*(.*)$/;
-  my $command = $1;
-  $command = '' unless ( defined $command );
-  my $args = $2;
-  $args = '' unless ( defined $args );
-
-
-  ######################################################################
-  # soelim
-  if ( $line =~ /^\.(do)?\s*(so|mso|PS\s*<|SO_START).*$/ ) {
-    # `.so', `.mso', `.PS<...', `.SO_START'
-    $Groff{'soelim'}++;
-    return;
-  }
-  if ( $line =~ /^\.(do)?\s*(so|mso|PS\s*<|SO_START).*$/ ) {
-    # `.do so', `.do mso', `.do PS<...', `.do SO_START'
-    $Groff{'soelim'}++;
-    return;
-  }
-####### do_line()
-
-  ######################################################################
-  # macros
-
-  if ( $line =~ /^\.de1?\W?/ ) {
-    # this line is a macro definition, add it to %macros
-    my $macro = $line;
-    $macro =~ s/^\.de1?\s+(\w+)\W*/.$1/;
-    return if ( exists $macros{$macro} );
-    $macros{$macro} = 1;
-    return;
-  }
-
-
-  # if line command is a defined macro, just ignore this line
-  return if ( exists $macros{$command} );
-
-
-  ######################################################################
-  # preprocessors
-
-  if ( $command =~ /^(\.cstart)|(begin\s+chem)$/ ) {
-    $Groff{'chem'}++;		# for chem
-    return;
-  }
-  if ( $command =~ /^\.EQ$/ ) {
-    $Groff{'eqn'}++;		# for eqn
-    return;
-  }
-  if ( $command =~ /^\.G1$/ ) {
-    $Groff{'grap'}++;		# for grap
-    return;
-  }
-  if ( $command =~ /^\.Perl/ ) {
-    $Groff{'gperl'}++;		# for gperl
-    return;
-  }
-  if ( $command =~ /^\.pinyin/ ) {
-    $Groff{'gpinyin'}++;		# for gperl
-    return;
-  }
-  if ( $command =~ /^\.GS$/ ) {
-    $Groff{'grn'}++;		# for grn
-    return;
-  }
-  if ( $command =~ /^\.IS$/ ) {
-    $Groff{'gideal'}++;		# preproc gideal for ideal
-    return;
-  }
-  if ( $command =~ /^\.lilypond$/ ) {
-    $Groff{'lilypond'}++;	# for glilypond
-    return;
-  }
-
-####### do_line()
-
-  # pic can be opened by .PS or .PF and closed by .PE
-  if ( $command =~ /^\.PS$/ ) {
-    $Groff{'pic'}++;		# normal opening for pic
-    return;
-  }
-  if ( $command =~ /^\.PF$/ ) {
-    $Groff{'PF'}++;		# alternate opening for pic
-    return;
-  }
-  if ( $command =~ /^\.PE$/ ) {
-    $Groff{'PE'}++;		# closing for pic
-    return;
-  }
-
-  if ( $command =~ /^\.R1$/ ) {
-    $Groff{'refer'}++;		# for refer
-    return;
-  }
-  if ( $command =~ /^\.\[$/ ) {
-    $Groff{'refer_open'}++;	# for refer open
-    return;
-  }
-  if ( $command =~ /^\.\]$/ ) {
-    $Groff{'refer_close'}++;	# for refer close
-    return;
-  }
-  if ( $command =~ /^\.TS$/ ) {
-    $Groff{'tbl'}++;		# for tbl
-    return;
-  }
-
-
-  ######################################################################
-  # macro package (tmac)
-  ######################################################################
-
-  ##########
-  # modern mdoc
-
-  if ( $command =~ /^\.(Dd)$/ ) {
-    $Groff{'Dd'}++;		# for modern mdoc
-    return;
-  }
-
-####### do_line()
-  # In the old version of -mdoc `Oo' is a toggle, in the new it's
-  # closed by `Oc'.
-  if ( $command =~ /^\.Oc$/ ) {
-    $Groff{'Oc'}++;		# only for modern mdoc
-    return;
-  }
-
-
-  ##########
-  # old and modern mdoc
-
-  if ( $command =~ /^\.Oo$/ ) {
-    $Groff{'Oo'}++;		# for mdoc and mdoc-old
-    return;
-  }
-
-
-  ##########
-  # old mdoc
-  if ( $command =~ /^\.(Tp|Dp|De|Cx|Cl)$/ ) {
-    $Groff{'mdoc_old'}++;	# true for old mdoc
-    return;
-  }
-
-
-  ##########
-  # for ms
-
-####### do_line()
-  if ( $command =~ /^\.AB$/ ) {
-    $Groff{'AB'}++;		# for ms
-    return;
-  }
-  if ( $command =~ /^\.AE$/ ) {
-    $Groff{'AE'}++;		# for ms
-    return;
-  }
-  if ( $command =~ /^\.AI$/ ) {
-    $Groff{'AI'}++;		# for ms
-    return;
-  }
-  if ( $command =~ /^\.AU$/ ) {
-    $Groff{'AU'}++;		# for ms
-    return;
-  }
-  if ( $command =~ /^\.NH$/ ) {
-    $Groff{'NH'}++;		# for ms
-    return;
-  }
-  if ( $command =~ /^\.TL$/ ) {
-    $Groff{'TL'}++;		# for ms
-    return;
-  }
-  if ( $command =~ /^\.XP$/ ) {
-    $Groff{'XP'}++;		# for ms
-    return;
-  }
-
-
-  ##########
-  # for man and ms
-
-  if ( $command =~ /^\.IP$/ ) {
-    $Groff{'IP'}++;		# for man and ms
-    return;
-  }
-  if ( $command =~ /^\.LP$/ ) {
-    $Groff{'LP'}++;		# for man and ms
-    return;
-  }
-####### do_line()
-  if ( $command =~ /^\.P$/ ) {
-    $Groff{'P'}++;		# for man and ms
-    return;
-  }
-  if ( $command =~ /^\.PP$/ ) {
-    $Groff{'PP'}++;		# for man and ms
-    return;
-  }
-  if ( $command =~ /^\.SH$/ ) {
-    $Groff{'SH'}++;		# for man and ms
-    return;
-  }
-  if ( $command =~ /^\.UL$/ ) {
-    $Groff{'UL'}++;		# for man and ms
-    return;
-  }
-
-
-  ##########
-  # for man only
-
-  if ( $command =~ /^\.OP$/ ) {	# for man
-    $Groff{'OP'}++;
-    return;
-  }
-  if ( $command =~ /^\.SS$/ ) {	# for man
-    $Groff{'SS'}++;
-    return;
-  }
-  if ( $command =~ /^\.SY$/ ) {	# for man
-    $Groff{'SY'}++;
-    return;
-  }
-  if ( $command =~ /^\.TH$/ ) {
-    $Groff{'TH'}++;		# for man
-    return;
-  }
-  if ( $command =~ /^\.TP$/ ) {	# for man
-    $Groff{'TP'}++;
-    return;
-  }
-  if ( $command =~ /^\.UR$/ ) {
-    $Groff{'UR'}++;		# for man
-    return;
-  }
-  if ( $command =~ /^\.YS$/ ) {	# for man
-   $Groff{'YS'}++;
-    return;
-  }
-####### do_line()
-
-
-  ##########
-  # me
-
-  if ( $command =~ /^\.(
-		      [ilnp]p|
-		      sh
-		    )$/x ) {
-    $Groff{'me'}++;		# for me
-    return;
-  }
-
-
-  #############
-  # mm and mmse
-
-  if ( $command =~ /^\.(
-		      H|
-		      MULB|
-		      LO|
-		      LT|
-		      NCOL|
-		      P\$|
-		      PH|
-		      SA
-		    )$/x ) {
-    $Groff{'mm'}++;		# for mm and mmse
-    if ( $command =~ /^\.LO$/ ) {
-      if ( $args =~ /^(DNAMN|MDAT|BIL|KOMP|DBET|BET|SIDOR)/ ) {
-	$Groff{'mmse'}++;	# for mmse
-      }
-    } elsif ( $command =~ /^\.LT$/ ) {
-      if ( $args =~ /^(SVV|SVH)/ ) {
-	$Groff{'mmse'}++;	# for mmse
-      }
-    }
-    return;
-  }
-####### do_line()
-
-  ##########
-  # mom
-
-  if ( $line =~ /^\.(
-		   ALD|
-		   DOCTYPE|
-		   FAMILY|
-		   FT|
-		   FAM|
-		   LL|
-		   LS|
-		   NEWPAGE|
-		   PAGE|
-		   PAPER|
-		   PRINTSTYLE|
-		   PT_SIZE|
-		   T_MARGIN
-		 )$/x ) {
-    $Groff{'mom'}++;		# for mom
-    return;
-  }
-
-} # do_line()
-
-
-########################################################################
-# sub make_groff_device
-########################################################################
-
-my @m = ();
-my @preprograms = ();
-my $correct_tmac = '';
-
-sub make_groff_device {
-  # globals: @devices
-
-  # default device is empty, i.e. it is `ps' when without `-T'
-  return '' unless ( @devices );
-
-  for ( @devices ) {
-    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-      $_ . ': not a suitable device'
-      unless (
-	      /^(
-		 dvi|
-		 html|
-		 xhtml|
-		 lbp|
-		 lj4|
-		 ps|
-		 pdf|
-		 ascii|
-		 cp1047|
-		 latin1|
-		 utf8
-	       )$/x );
-  }
-
-###### make_groff_device()
-  my $device = pop( @devices );
-  if ( @devices ) {
-    for ( @devices ) {
-      next if ( $_ eq $device );
-      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	'additional device: ' . $_;
-    }
-    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-      'device ' . $device . ' taken instead';
-  }
-
-  return '' unless ( $device );
-  push @Command, '-T';
-  push @Command, $device;
-
-###### make_groff_device()
-  if ( $device eq 'pdf' ) {
-    if ( $pdf_with_ligatures ) {	# with --ligature argument
-      push( @Command, '-P-y' );
-      push( @Command, '-PU' );
-    } else {	# no --ligature argument
-      if ( $with_warnings ) {
-	print STDERR <<EOF;
-If you have trouble with ligatures like `fi' in the `groff' output, you
-can proceed as one of
-- add `grog' option `--with_ligatures' or
-- use the `grog' option combination `-P-y -PU' or
-- try to remove the font named similar to `fonts-texgyre' from your system.
-EOF
-      }	# end of warning
-    }	# end of ligature
-  }	# end of pdf device
-} # make_groff_device()
-
-
-########################################################################
-# make_groff_preproc()
-########################################################################
-
-sub make_groff_preproc {
-  # globals: %Groff, @preprograms, @Command
-
-  # preprocessors without `groff' option
-  if ( $Groff{'lilypond'} ) {
-    push @preprograms, 'glilypond';
-  }
-  if ( $Groff{'gperl'} ) {
-    push @preprograms, 'gperl';
-  }
-  if ( $Groff{'gpinyin'} ) {
-    push @preprograms, 'gpinyin';
-  }
-
-  # preprocessors with `groff' option
-  if ( ( $Groff{'PS'} ||  $Groff{'PF'} ) &&  $Groff{'PE'} ) {
-    $Groff{'pic'} = 1;
-  }
-  if ( $Groff{'gideal'} ) {
-    $Groff{'pic'} = 1;
-  }
-
-###### make_groff_preproc()
-  $Groff{'refer'} ||= $Groff{'refer_open'} && $Groff{'refer_close'};
-
-  if ( $Groff{'chem'} || $Groff{'eqn'} ||  $Groff{'gideal'} ||
-       $Groff{'grap'} || $Groff{'grn'} || $Groff{'pic'} ||
-       $Groff{'refer'} || $Groff{'tbl'} ) {
-    push(@Command, '-s') if $Groff{'soelim'};
-
-    push(@Command, '-R') if $Groff{'refer'};
-
-    push(@Command, '-t') if $Groff{'tbl'};	# tbl before eqn
-    push(@Command, '-e') if $Groff{'eqn'};
-
-    push(@Command, '-j') if $Groff{'chem'};	# chem produces pic code
-    push(@Command, '-J') if $Groff{'gideal'};	# gideal produces pic
-    push(@Command, '-G') if $Groff{'grap'};
-    push(@Command, '-g') if $Groff{'grn'};	# gremlin files for -me
-    push(@Command, '-p') if $Groff{'pic'};
-
-  }
-} # make_groff_preproc()
-
-
-########################################################################
-# make_groff_tmac_man_ms()
-########################################################################
-
-sub make_groff_tmac_man_ms {
-  # globals: @filespec, $tmac_ext, %Groff
-
-  # `man' requests, not from `ms'
-  if ( $Groff{'SS'} || $Groff{'SY'} || $Groff{'OP'} ||
-       $Groff{'TH'} || $Groff{'TP'} || $Groff{'UR'} ) {
-    $Groff{'man'} = 1;
-    push(@m, '-man');
-
-    $tmac_ext = 'man' unless ( $tmac_ext );
-    &err('man requests found, but file name extension ' .
-	 'was: ' . $tmac_ext) unless ( $tmac_ext eq 'man' );
-    $tmac_ext = 'man';
-    return 1;	# true
-  }
-
-###### make_groff_tmac_man_ms()
-  # `ms' requests, not from `man'
-  if (
-      $Groff{'1C'} || $Groff{'2C'} ||
-      $Groff{'AB'} || $Groff{'AE'} || $Groff{'AI'} || $Groff{'AU'} ||
-      $Groff{'BX'} || $Groff{'CD'} || $Groff{'DA'} || $Groff{'DE'} ||
-      $Groff{'DS'} || $Groff{'LD'} || $Groff{'ID'} || $Groff{'NH'} ||
-      $Groff{'TL'} || $Groff{'UL'} || $Groff{'XP'}
-     ) {
-    $Groff{'ms'} = 1;
-    push(@m, '-ms');
-
-    $tmac_ext = 'ms' unless ( $tmac_ext );
-    &err('ms requests found, but file name extension ' .
-	 'was: ' . $tmac_ext) unless ( $tmac_ext eq 'ms' );
-    $tmac_ext = 'ms';
-    return 1;	# true
-  }
-
-###### make_groff_tmac_man_ms()
-
-  # both `man' and `ms' requests
-  if ( $Groff{'P'} || $Groff{'IP'}  ||
-       $Groff{'LP'} || $Groff{'PP'} || $Groff{'SH'} ) {
-    if ( $tmac_ext eq 'man' ) {
-      $Groff{'man'} = 1;
-      push(@m, '-man');
-      return 1;	# true
-    } elsif ( $tmac_ext eq 'ms' ) {
-      $Groff{'ms'} = 1;
-      push(@m, '-ms');
-      return 1;	# true
-    }
-    return 0;
-  }
-} # make_groff_tmac_man_ms()
-
-
-
-########################################################################
-# make_groff_tmac_others()
-########################################################################
-
-sub make_groff_tmac_others {
-  # globals: @filespec, $tmac_ext, %Groff
-
-  # mdoc
-  if ( ( $Groff{'Oo'} && $Groff{'Oc'} ) || $Groff{'Dd'} ) {
-    $Groff{'Oc'} = 0;
-    $Groff{'Oo'} = 0;
-    push(@m, '-mdoc');
-    return 1;	# true
-  }
-  if ( $Groff{'mdoc_old'} || $Groff{'Oo'} ) {
-    push(@m, '-mdoc_old');
-    return 1;	# true
-  }
-
-  # me
-  if ( $Groff{'me'} ) {
-    push(@m, '-me');
-    return 1;	# true
-  }
-
-##### make_groff_tmac_others()
-  # mm and mmse
-  if ( $Groff{'mm'} ) {
-    push(@m, '-mm');
-    return 1;	# true
-  }
-  if ( $Groff{'mmse'} ) {	# Swedish mm
-    push(@m, '-mmse');
-    return 1;	# true
-  }
-
-  # mom
-  if ( $Groff{'mom'} ) {
-    push(@m, '-mom');
-    return 1;	# true
-  }
-} # make_groff_tmac_others()
-
-
-########################################################################
-# make_groff_line_rest()
-########################################################################
-
-sub make_groff_line_rest {
-  my $file_args_included;	# file args now only at 1st preproc
-  unshift @Command, 'groff';
-  if ( @preprograms ) {
-    my @progs;
-    $progs[0] = shift @preprograms;
-    push(@progs, @filespec);
-    for ( @preprograms ) {
-      push @progs, '|';
-      push @progs, $_;
-    }
-    push @progs, '|';
-    unshift @Command, @progs;
-    $file_args_included = 1;
-  } else {
-    $file_args_included = 0;
-  }
-
-  foreach (@Command) {
-    next unless /\s/;
-    # when one argument has several words, use accents
-    $_ = "'" . $_ . "'";
-  }
-
-
-  ##########
-  # -m arguments
-  my $nr_m_guessed = scalar @m;
-  if ( $nr_m_guessed > 1 ) {
-    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-      'argument for -m found: ' . @m;
-  }
-
-###### make_groff_line()
-
-  my $nr_m_args = scalar @Mparams;	# m-arguments for grog
-  my $last_m_arg = '';	# last provided -m option
-  if ( $nr_m_args > 1 ) {
-    # take the last given -m argument of grog call,
-    # ignore other -m arguments and the found ones
-    $last_m_arg = $Mparams[-1];	# take the last -m argument
-    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-      $Prog . ": more than 1 `-m' argument: @Mparams";
-    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-      'We take the last one: ' . $last_m_arg;
-  } elsif ( $nr_m_args == 1 ) {
-    $last_m_arg = $Mparams[0];
-  }
-
-  my $final_m = '';
-  if ( $last_m_arg ) {
-    my $is_equal = 0;
-    for ( @m ) {
-      if ( $_ eq $last_m_arg ) {
-	$is_equal = 1;
-	last;
-      }
-      next;
-    }	# end for @m
-    if ( $is_equal ) {
-      $final_m = $last_m_arg;
-    } else {
-      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	'Provided -m argument ' . $last_m_arg .
-	  ' differs from guessed -m args: ' . @m;
-      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	'The argument is taken.';
-      $final_m = $last_m_arg;
-    }
-###### make_groff_line()
-  } else {	# no -m arg provided
-    if ( $nr_m_guessed > 1 ) {
-      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	'More than 1 -m arguments were guessed: ' . @m;
-      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' . 'Guessing stopped.';
-      exit 1;
-    } elsif ( $nr_m_guessed == 1 ) {
-      $final_m = $m[0];
-    } else {
-      # no -m provided or guessed
-    }
-  }
-  push @Command, $final_m if ( $final_m );
-
-  push(@Command, @filespec) unless ( $file_args_included );
-
-  #########
-  # execute the `groff' command here with option `--run'
-  if ( $do_run ) { # with --run
-    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' . "@Command";
-    my $cmd = join ' ', @Command;
-    system($cmd);
-  } else {
-    print "@Command";
-  }
-
-  exit 0;
-} # make_groff_line()
-
-
-########################################################################
-# sub help
-########################################################################
-
-sub help {
-  print <<EOF;
-usage: grog [option]... [--] [filespec]...
-
-"filespec" is either the name of an existing, readable file or "-" for
-standard input.  If no `filespec' is specified, standard input is
-assumed automatically.  All arguments after a `--' are regarded as file
-names, even if they start with a `-' character.
-
-`option' is either a `groff' option or one of these:
-
--h|--help	print this uasge message and exit
--v|--version	print version information and exit
-
--C		compatibility mode
---ligatures	include options `-P-y -PU' for internal font, which
-		preserverses the ligatures like `fi'
---run		run the checked-out groff command
---warnings	display more warnings to standard error
-
-All other options should be `groff' 1-character options.  These are then
-appended to the generated `groff' command line.  The `-m' options will
-be checked by `grog'.
-
-EOF
-  exit 0;
-} # help()
-
-
-########################################################################
-# sub version
-########################################################################
-
-sub version {
-  our %at_at;
-  print "Perl version of GNU $Prog " .
-    "in groff version " . $at_at{'GROFF_VERSION'};
-  exit 0;
-} # version()
-
-
-1;
-########################################################################
-### Emacs settings
-# Local Variables:
-# mode: CPerl
-# End:
+#! /usr/bin/env perl
+# grog - guess options for groff command
+# Inspired by doctype script in Kernighan & Pike, Unix Programming
+# Environment, pp 306-8.
+
+# Source file position: <groff-source>/src/roff/grog/subs.pl
+# Installed position: <prefix>/lib/grog/subs.pl
+
+# Copyright (C) 1993-2015  Free Software Foundation, Inc.
+# This file was split from grog.pl and put under GPL2 by
+#               Bernd Warken <groff-bernd.warken-72@web.de>.
+# The macros for identifying the devices were taken from Ralph
+# Corderoy's `grog.sh' of 2006.
+
+# Last update: 19 Jul 2015
+
+# This file is part of `grog', which is part of `groff'.
+
+# `groff' is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+
+# `groff' is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+
+# You can get the license text for the GNU General Public License
+# version 2 in the internet at
+# <http://www.gnu.org/licenses/gpl-2.0.html>.
+
+########################################################################
+
+require v5.6;
+
+use warnings;
+use strict;
+
+use File::Spec;
+
+# printing of hashes: my %hash = ...; print Dumper(\%hash);
+use Data::Dumper;
+
+# for running shell based programs within Perl; use `` instead of
+# use IPC::System::Simple qw(capture capturex run runx system systemx);
+
+$\ = "\n";
+
+# my $Sp = "[\\s\\n]";
+# my $Sp = qr([\s\n]);
+# my $Sp = '' if $arg eq '-C';
+my $Sp = '';
+
+# from `src/roff/groff/groff.cpp' near `getopt_long'
+my $groff_opts =
+  'abcCd:D:eEf:F:gGhiI:jJkK:lL:m:M:n:No:pP:r:RsStT:UvVw:W:XzZ';
+
+my @Command = ();		# stores the final output
+my @Mparams = ();		# stores the options `-m*'
+my @devices = ();
+my $do_run = 0;			# run generated `groff' command
+my $pdf_with_ligatures = 0;	# `-P-y -PU' for `pdf' device
+my $with_warnings = 0;
+
+my $Prog = $0;
+{
+  my ($v, $d, $f) = File::Spec->splitpath($Prog);
+  $Prog = $f;
+}
+
+
+my %macros;
+my %Groff =
+  (
+   # preprocessors
+   'chem' => 0,
+   'eqn' => 0,
+   'gperl' => 0,
+   'grap' => 0,
+   'grn' => 0,
+   'gideal' => 0,
+   'gpinyin' => 0,
+   'lilypond' => 0,
+
+   'pic' => 0,
+   'PS' => 0,		# opening for pic
+   'PF' => 0,		# alternative opening for pic
+   'PE' => 0,		# closing for pic
+
+   'refer' => 0,
+   'refer_open' => 0,
+   'refer_close' => 0,
+   'soelim' => 0,
+   'tbl' => 0,
+
+   # tmacs
+#   'man' => 0,
+#   'mandoc' => 0,
+#   'mdoc' => 0,
+#   'mdoc_old' => 0,
+#   'me' => 0,
+#   'mm' => 0,
+#   'mom' => 0,
+#   'ms' => 0,
+
+   # requests
+   'AB' => 0,		# ms
+   'AE' => 0,		# ms
+   'AI' => 0,		# ms
+   'AU' => 0,		# ms
+   'NH' => 0,		# ms
+   'TH_later' => 0,	# TH not 1st command is ms
+   'TL' => 0,		# ms
+   'UL' => 0,		# ms
+   'XP' => 0,		# ms
+
+   'IP' => 0,		# man and ms
+   'LP' => 0,		# man and ms
+   'P' => 0,		# man and ms
+   'PP' => 0,		# man and ms
+   'SH' => 0,		# man and ms
+
+   'OP' => 0,		# man
+   'SS' => 0,		# man
+   'SY' => 0,		# man
+   'TH_first' => 0,	# TH as 1st command is man
+   'TP' => 0,		# man
+   'UR' => 0,		# man
+   'YS' => 0,		# man
+
+   # for mdoc and mdoc-old
+   # .Oo and .Oc for modern mdoc, only .Oo for mdoc-old
+   'Oo' => 0,		# mdoc and mdoc-old
+   'Oc' => 0,		# mdoc
+   'Dd' => 0,		# mdoc
+  ); # end of %Groff
+
+
+# for first line check
+my %preprocs_tmacs =
+  (
+   'chem' => 0,
+   'eqn' => 0,
+   'gideal' => 0,
+   'gpinyin' => 0,
+   'grap' => 0,
+   'grn' => 0,
+   'pic' => 0,
+   'refer' => 0,
+   'soelim' => 0,
+   'tbl' => 0,
+
+   'geqn' => 0,
+   'gpic' => 0,
+   'neqn' => 0,
+
+   'man' => 0,
+   'mandoc' => 0,
+   'mdoc' => 0,
+   'mdoc-old' => 0,
+   'me' => 0,
+   'mm' => 0,
+   'mom' => 0,
+   'ms' => 0,
+  );
+
+my @filespec;
+
+my $tmac_ext = '';
+
+
+########################################################################
+# err()
+########################################################################
+
+sub err {
+  my $text = shift;
+  print STDERR $text;
+}
+
+
+########################################################################
+# handle_args()
+########################################################################
+
+sub handle_args {
+  my $double_minus = 0;
+  my $was_minus = 0;
+  my $was_T = 0;
+  my $optarg = 0;
+  # globals: @filespec, @Command, @devices, @Mparams
+
+  foreach my $arg (@ARGV) {
+
+    if ( $optarg ) {
+      push @Command, $arg;
+      $optarg = 0;
+      next;
+    }
+
+    if ( $double_minus ) {
+      if (-f $arg && -r $arg) {
+	push @filespec, $arg;
+      } else {
+	print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	  "grog: $arg is not a readable file.";
+      }
+      next;
+    }
+
+    if ( $was_T ) {
+      push @devices, $arg;
+      $was_T = 0;
+      next;
+    }
+####### handle_args()
+
+    unless ( $arg =~ /^-/ ) { # file name, no opt, no optarg
+      unless (-f $arg && -r $arg) {
+	print 'unknown file name: ' . $arg;
+      }
+      push @filespec, $arg;
+      next;
+    }
+
+    # now $arg starts with `-'
+
+    if ($arg eq '-') {
+      unless ($was_minus) {
+	push @filespec, $arg;
+	$was_minus = 1;
+      }
+      next;
+    }
+
+    if ($arg eq '--') {
+      $double_minus = 1;
+      push(@filespec, $arg);
+      next;
+    }
+
+    &version() if $arg =~ /^--?v/;	# --version, with exit
+    &help() if $arg  =~ /--?h/;		# --help, with exit
+
+    if ( $arg =~ /^--r/ ) {		#  --run, no exit
+      $do_run = 1;
+      next;
+    }
+
+    if ( $arg =~ /^--wa/ ) {		#  --warnings, no exit
+      $with_warnings = 1;
+      next;
+    }
+####### handle_args()
+
+    if ( $arg =~ /^--(wi|l)/ ) { # --ligatures, no exit
+      # the old --with_ligatures is only kept for compatibility
+      $pdf_with_ligatures = 1;
+      next;
+    }
+
+    if ($arg =~ /^-m/) {
+      push @Mparams, $arg;
+      next;
+    }
+
+    if ($arg =~ /^-T$/) {
+      $was_T = 1;
+      next;
+    }
+
+    if ($arg =~ s/^-T(\w+)$/$1/) {
+      push @devices, $1;
+      next;
+    }
+
+    if ($arg =~ /^-(\w)(\w*)$/) {	# maybe a groff option
+      my $opt_char = $1;
+      my $opt_char_with_arg = $opt_char . ':';
+      my $others = $2;
+      if ( $groff_opts =~ /$opt_char_with_arg/ ) {	# groff optarg
+	if ( $others ) {	# optarg is here
+	  push @Command, '-' . $opt_char;
+	  push @Command, '-' . $others;
+	  next;
+	}
+	# next arg is optarg
+	$optarg = 1;
+	next;
+####### handle_args()
+      } elsif ( $groff_opts =~ /$opt_char/ ) {	# groff no optarg
+	push @Command, '-' . $opt_char;
+	if ( $others ) {	# $others is now an opt collection
+	  $arg = '-' . $others;
+	  redo;
+	}
+	# arg finished
+	next;
+      } else {		# not a groff opt
+	print STDERR __FILE__ . ' '  . __LINE__ . ': ' .
+	  'unknown argument ' . $arg;
+	push(@Command, $arg);
+	next;
+      }
+    }
+  }
+  @filespec = ('-') unless (@filespec);
+} # handle_args()
+
+
+
+########################################################################
+# handle_file_ext()
+########################################################################
+
+sub handle_file_ext {
+  # get tmac from file name extension
+  # output number of found single tmac
+
+  # globals: @filespec, $tmac_ext;
+
+  foreach my $file ( @filespec ) {
+    # test for each file name in the arguments
+    unless ( open(FILE, $file eq "-" ? $file : "< $file") ) {
+      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	"$Prog: can't open \`$file\': $!";
+      next;
+    }
+
+    next unless ( $file =~ /\./ ); # file name has no dot `.'
+
+##### handle_file_ext()
+    # get extension
+    my $ext = $file;
+    $ext =~ s/^
+	      .*
+	      \.
+	      ([^.]*)
+	      $
+	     /$1/x;
+    next unless ( $ext );
+
+##### handle_file_ext()
+    # these extensions are correct, but not based on a tmac
+    next if ( $ext =~ /^(
+			 chem|
+			 eqn|
+			 g|
+			 grap|
+			 grn|
+			 groff|
+			 hdtbl|
+			 pdfroff|
+			 pic|
+			 pinyin|
+			 ref|
+			 roff|
+			 t|
+			 tbl|
+			 tr|
+			 www
+		       )$/x );
+
+##### handle_file_ext()
+    # extensions for man tmac
+    if ( $ext =~ /^(
+		      [1-9lno]|
+		      man|
+		      n|
+		      1b
+		    )$/x ) {
+      # `man|n' from `groff' source
+      # `1b' from `heirloom'
+      # `[1-9lno]' from man-pages
+      if ( $tmac_ext && $tmac_ext ne 'man' ) {
+	# found tmac is not 'man'
+	print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	  '2 different file name extensions found ' .
+	    $tmac_ext . ' and ' . $ext;
+	$tmac_ext = '';
+	next;
+      }
+
+##### handle_file_ext()
+      $tmac_ext = 'man';
+      next;
+    }
+
+    if ( $ext =~ /^(
+		    mandoc|
+		    mdoc|
+		    me|
+		    mm|
+		    mmse|
+		    mom|
+		    ms|
+		    $)/x ) {
+      if ( $tmac_ext && $tmac_ext ne $ext ) {
+	# found tmac is not identical to former found tmac
+##### handle_file_ext()
+	print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	  '2 different file name extensions found ' .
+	    $tmac_ext . ' and ' . $ext;
+	$tmac_ext = '';
+	next;
+      }
+
+      $tmac_ext = $ext;
+      next;
+    }
+
+    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+      'Unknown file name extension '. $file . '.';
+    next;
+  } # end foreach file
+
+  1;
+} # handle_file_ext()
+
+
+########################################################################
+# handle_whole_files()
+########################################################################
+
+sub handle_whole_files {
+  # globals: @filespec
+
+  foreach my $file ( @filespec ) {
+    unless ( open(FILE, $file eq "-" ? $file : "< $file") ) {
+      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	"$Prog: can't open \`$file\': $!";
+      next;
+    }
+    my $line = <FILE>; # get single line
+
+    unless ( defined($line) ) {
+      # empty file, go to next filearg
+      close (FILE);
+      next;
+    }
+
+    if ( $line ) {
+      chomp $line;
+      unless ( &do_first_line( $line, $file ) ) {
+	# not an option line
+	&do_line( $line, $file );
+      }
+    } else { # empty line
+      next;
+    }
+
+    while (<FILE>) { # get lines by and by
+      chomp;
+      &do_line( $_, $file );
+    }
+    close(FILE);
+  } # end foreach
+} # handle_whole_files()
+
+
+########################################################################
+# do_first_line()
+########################################################################
+
+# As documented for the `man' program, the first line can be
+# used as a groff option line.  This is done by:
+# - start the line with '\" (apostrophe, backslash, double quote)
+# - add a space character
+# - a word using the following characters can be appended: `egGjJpRst'.
+#     Each of these characters means an option for the generated
+#     `groff' command line, e.g. `-t'.
+
+sub do_first_line {
+  my ( $line, $file ) = @_;
+
+  # globals: %preprocs_tmacs
+
+  # For a leading groff options line use only [egGjJpRst]
+  if  ( $line =~ /^[.']\\"[\segGjJpRst]+&/ ) {
+    # this is a groff options leading line
+    if ( $line =~ /^\./ ) {
+      # line is a groff options line with . instead of '
+      print "First line in $file must start with an apostrophe \ " .
+	"instead of a period . for groff options line!";
+    }
+
+    if ( $line =~ /j/ ) {
+      $Groff{'chem'}++;
+    }
+    if ( $line =~ /e/ ) {
+      $Groff{'eqn'}++;
+    }
+    if ( $line =~ /g/ ) {
+      $Groff{'grn'}++;
+    }
+    if ( $line =~ /G/ ) {
+      $Groff{'grap'}++;
+    }
+    if ( $line =~ /i/ ) {
+      $Groff{'gideal'}++;
+    }
+    if ( $line =~ /p/ ) {
+      $Groff{'pic'}++;
+    }
+    if ( $line =~ /R/ ) {
+      $Groff{'refer'}++;
+    }
+    if ( $line =~ /s/ ) {
+      $Groff{'soelim'}++;
+    }
+####### do_first_line()
+    if ( $line =~ /t/ ) {
+      $Groff{'tbl'}++;
+    }
+    return 1;	# a leading groff options line, 1 means yes, 0 means no
+  }
+
+  # not a leading short groff options line
+
+  return 0 if ( $line !~ /^[.']\\"\s*(.*)$/ );	# ignore non-comments
+
+  return 0 unless ( $1 );	# for empty comment
+
+  # all following array members are either preprocs or 1 tmac
+  my @words = split '\s+', $1;
+
+  my @in = ();
+  my $word;
+  for $word ( @words ) {
+    if ( $word eq 'ideal' ) {
+      $word = 'gideal';
+    } elsif ( $word eq 'gpic' ) {
+      $word = 'pic';
+    } elsif ( $word =~ /^(gn|)eqn$/ ) {
+      $word = 'eqn';
+    }
+    if ( exists $preprocs_tmacs{$word} ) {
+      push @in, $word;
+    } else {
+      # not word for preproc or tmac
+      return 0;
+    }
+  }
+
+  for $word ( @in ) {
+    $Groff{$word}++;
+  }
+} # do_first_line()
+
+
+########################################################################
+# do_line()
+########################################################################
+
+my $before_first_command = 1; # for check of .TH
+
+sub do_line {
+  my ( $line, $file ) = @_;
+
+  return if ( $line =~ /^[.']\s*\\"/ );	# comment
+
+  return unless ( $line =~ /^[.']/ );	# ignore text lines
+
+  $line =~ s/^['.]\s*/./;	# let only a dot as leading character,
+				# remove spaces after the leading dot
+  $line =~ s/\s+$//;		# remove final spaces
+
+  return if ( $line =~ /^\.$/ );	# ignore .
+  return if ( $line =~ /^\.\.$/ );	# ignore ..
+
+  if ( $before_first_command ) { # so far without 1st command
+    if ( $line =~ /^\.TH/ ) {
+      # check if .TH is 1st command for man
+      $Groff{'TH_first'} = 1 if ( $line =~ /^\.\s*TH/ );
+    }
+    if ( $line =~ /^\./ ) {
+      $before_first_command = 0;
+    }
+  }
+
+  # split command
+  $line =~ /^(\.\w+)\s*(.*)$/;
+  my $command = $1;
+  $command = '' unless ( defined $command );
+  my $args = $2;
+  $args = '' unless ( defined $args );
+
+
+  ######################################################################
+  # soelim
+  if ( $line =~ /^\.(do)?\s*(so|mso|PS\s*<|SO_START).*$/ ) {
+    # `.so', `.mso', `.PS<...', `.SO_START'
+    $Groff{'soelim'}++;
+    return;
+  }
+  if ( $line =~ /^\.(do)?\s*(so|mso|PS\s*<|SO_START).*$/ ) {
+    # `.do so', `.do mso', `.do PS<...', `.do SO_START'
+    $Groff{'soelim'}++;
+    return;
+  }
+####### do_line()
+
+  ######################################################################
+  # macros
+
+  if ( $line =~ /^\.de1?\W?/ ) {
+    # this line is a macro definition, add it to %macros
+    my $macro = $line;
+    $macro =~ s/^\.de1?\s+(\w+)\W*/.$1/;
+    return if ( exists $macros{$macro} );
+    $macros{$macro} = 1;
+    return;
+  }
+
+
+  # if line command is a defined macro, just ignore this line
+  return if ( exists $macros{$command} );
+
+
+  ######################################################################
+  # preprocessors
+
+  if ( $command =~ /^(\.cstart)|(begin\s+chem)$/ ) {
+    $Groff{'chem'}++;		# for chem
+    return;
+  }
+  if ( $command =~ /^\.EQ$/ ) {
+    $Groff{'eqn'}++;		# for eqn
+    return;
+  }
+  if ( $command =~ /^\.G1$/ ) {
+    $Groff{'grap'}++;		# for grap
+    return;
+  }
+  if ( $command =~ /^\.Perl/ ) {
+    $Groff{'gperl'}++;		# for gperl
+    return;
+  }
+  if ( $command =~ /^\.pinyin/ ) {
+    $Groff{'gpinyin'}++;		# for gperl
+    return;
+  }
+  if ( $command =~ /^\.GS$/ ) {
+    $Groff{'grn'}++;		# for grn
+    return;
+  }
+  if ( $command =~ /^\.IS$/ ) {
+    $Groff{'gideal'}++;		# preproc gideal for ideal
+    return;
+  }
+  if ( $command =~ /^\.lilypond$/ ) {
+    $Groff{'lilypond'}++;	# for glilypond
+    return;
+  }
+
+####### do_line()
+
+  # pic can be opened by .PS or .PF and closed by .PE
+  if ( $command =~ /^\.PS$/ ) {
+    $Groff{'pic'}++;		# normal opening for pic
+    return;
+  }
+  if ( $command =~ /^\.PF$/ ) {
+    $Groff{'PF'}++;		# alternate opening for pic
+    return;
+  }
+  if ( $command =~ /^\.PE$/ ) {
+    $Groff{'PE'}++;		# closing for pic
+    return;
+  }
+
+  if ( $command =~ /^\.R1$/ ) {
+    $Groff{'refer'}++;		# for refer
+    return;
+  }
+  if ( $command =~ /^\.\[$/ ) {
+    $Groff{'refer_open'}++;	# for refer open
+    return;
+  }
+  if ( $command =~ /^\.\]$/ ) {
+    $Groff{'refer_close'}++;	# for refer close
+    return;
+  }
+  if ( $command =~ /^\.TS$/ ) {
+    $Groff{'tbl'}++;		# for tbl
+    return;
+  }
+  if ( $command =~ /^\.TH$/ ) {
+    unless ( $Groff{'TH_first'} ) {
+      $Groff{'TH_later'}++;		# for tbl
+    }
+    return;
+  }
+
+
+  ######################################################################
+  # macro package (tmac)
+  ######################################################################
+
+  ##########
+  # modern mdoc
+
+  if ( $command =~ /^\.(Dd)$/ ) {
+    $Groff{'Dd'}++;		# for modern mdoc
+    return;
+  }
+
+####### do_line()
+  # In the old version of -mdoc `Oo' is a toggle, in the new it's
+  # closed by `Oc'.
+  if ( $command =~ /^\.Oc$/ ) {
+    $Groff{'Oc'}++;		# only for modern mdoc
+    return;
+  }
+
+
+  ##########
+  # old and modern mdoc
+
+  if ( $command =~ /^\.Oo$/ ) {
+    $Groff{'Oo'}++;		# for mdoc and mdoc-old
+    return;
+  }
+
+
+  ##########
+  # old mdoc
+  if ( $command =~ /^\.(Tp|Dp|De|Cx|Cl)$/ ) {
+    $Groff{'mdoc_old'}++;	# true for old mdoc
+    return;
+  }
+
+
+  ##########
+  # for ms
+
+####### do_line()
+  if ( $command =~ /^\.AB$/ ) {
+    $Groff{'AB'}++;		# for ms
+    return;
+  }
+  if ( $command =~ /^\.AE$/ ) {
+    $Groff{'AE'}++;		# for ms
+    return;
+  }
+  if ( $command =~ /^\.AI$/ ) {
+    $Groff{'AI'}++;		# for ms
+    return;
+  }
+  if ( $command =~ /^\.AU$/ ) {
+    $Groff{'AU'}++;		# for ms
+    return;
+  }
+  if ( $command =~ /^\.NH$/ ) {
+    $Groff{'NH'}++;		# for ms
+    return;
+  }
+  if ( $command =~ /^\.TL$/ ) {
+    $Groff{'TL'}++;		# for ms
+    return;
+  }
+  if ( $command =~ /^\.XP$/ ) {
+    $Groff{'XP'}++;		# for ms
+    return;
+  }
+
+
+  ##########
+  # for man and ms
+
+  if ( $command =~ /^\.IP$/ ) {
+    $Groff{'IP'}++;		# for man and ms
+    return;
+  }
+  if ( $command =~ /^\.LP$/ ) {
+    $Groff{'LP'}++;		# for man and ms
+    return;
+  }
+####### do_line()
+  if ( $command =~ /^\.P$/ ) {
+    $Groff{'P'}++;		# for man and ms
+    return;
+  }
+  if ( $command =~ /^\.PP$/ ) {
+    $Groff{'PP'}++;		# for man and ms
+    return;
+  }
+  if ( $command =~ /^\.SH$/ ) {
+    $Groff{'SH'}++;		# for man and ms
+    return;
+  }
+  if ( $command =~ /^\.UL$/ ) {
+    $Groff{'UL'}++;		# for man and ms
+    return;
+  }
+
+
+  ##########
+  # for man only
+
+  if ( $command =~ /^\.OP$/ ) {	# for man
+    $Groff{'OP'}++;
+    return;
+  }
+  if ( $command =~ /^\.SS$/ ) {	# for man
+    $Groff{'SS'}++;
+    return;
+  }
+  if ( $command =~ /^\.SY$/ ) {	# for man
+    $Groff{'SY'}++;
+    return;
+  }
+  if ( $command =~ /^\.TP$/ ) {	# for man
+    $Groff{'TP'}++;
+    return;
+  }
+  if ( $command =~ /^\.UR$/ ) {
+    $Groff{'UR'}++;		# for man
+    return;
+  }
+  if ( $command =~ /^\.YS$/ ) {	# for man
+   $Groff{'YS'}++;
+    return;
+  }
+####### do_line()
+
+
+  ##########
+  # me
+
+  if ( $command =~ /^\.(
+		      [ilnp]p|
+		      sh
+		    )$/x ) {
+    $Groff{'me'}++;		# for me
+    return;
+  }
+
+
+  #############
+  # mm and mmse
+
+  if ( $command =~ /^\.(
+		      H|
+		      MULB|
+		      LO|
+		      LT|
+		      NCOL|
+		      P\$|
+		      PH|
+		      SA
+		    )$/x ) {
+    $Groff{'mm'}++;		# for mm and mmse
+    if ( $command =~ /^\.LO$/ ) {
+      if ( $args =~ /^(DNAMN|MDAT|BIL|KOMP|DBET|BET|SIDOR)/ ) {
+	$Groff{'mmse'}++;	# for mmse
+      }
+    } elsif ( $command =~ /^\.LT$/ ) {
+      if ( $args =~ /^(SVV|SVH)/ ) {
+	$Groff{'mmse'}++;	# for mmse
+      }
+    }
+    return;
+  }
+####### do_line()
+
+  ##########
+  # mom
+
+  if ( $line =~ /^\.(
+		   ALD|
+		   DOCTYPE|
+		   FAMILY|
+		   FT|
+		   FAM|
+		   LL|
+		   LS|
+		   NEWPAGE|
+		   PAGE|
+		   PAPER|
+		   PRINTSTYLE|
+		   PT_SIZE|
+		   T_MARGIN
+		 )$/x ) {
+    $Groff{'mom'}++;		# for mom
+    return;
+  }
+
+} # do_line()
+
+
+########################################################################
+# sub make_groff_device
+########################################################################
+
+my @m = ();
+my @preprograms = ();
+my $correct_tmac = '';
+
+sub make_groff_device {
+  # globals: @devices
+
+  # default device is empty, i.e. it is `ps' when without `-T'
+  my $device = '';
+
+  for my $d ( @devices ) {
+    if ( $d =~			# suitable devices
+	 /^(
+	    dvi|
+	    html|
+	    xhtml|
+	    lbp|
+	    lj4|
+	    ps|
+	    pdf|
+	    ascii|
+	    cp1047|
+	    latin1|
+	    utf8
+	  )$/x ) {
+###### make_groff_device()
+      if ( $device ) {
+	next if ( $device eq $d );
+	print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	  'several different devices given: ' .
+	    $device . ' and ' .$d;
+	$device = $d;	# the last provided device is taken
+	next;
+      } else { # empty $device
+	$device = $d;
+	next;
+      }
+    } else {		# not suitable device
+      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	'not a suitable device for groff: ' . $d;
+      next;
+    }
+
+    if ( $device ) {
+      push @Command, '-T';
+      push @Command, $device;
+    }
+  }
+
+###### make_groff_device()
+  if ( $device eq 'pdf' ) {
+    if ( $pdf_with_ligatures ) {	# with --ligature argument
+      push( @Command, '-P-y' );
+      push( @Command, '-PU' );
+    } else {	# no --ligature argument
+      if ( $with_warnings ) {
+	print STDERR <<EOF;
+If you have trouble with ligatures like `fi' in the `groff' output, you
+can proceed as one of
+- add `grog' option `--with_ligatures' or
+- use the `grog' option combination `-P-y -PU' or
+- try to remove the font named similar to `fonts-texgyre' from your system.
+EOF
+      }	# end of warning
+    }	# end of ligature
+  }	# end of pdf device
+} # make_groff_device()
+
+
+########################################################################
+# make_groff_preproc()
+########################################################################
+
+sub make_groff_preproc {
+  # globals: %Groff, @preprograms, @Command
+
+  # preprocessors without `groff' option
+  if ( $Groff{'lilypond'} ) {
+    push @preprograms, 'glilypond';
+  }
+  if ( $Groff{'gperl'} ) {
+    push @preprograms, 'gperl';
+  }
+  if ( $Groff{'gpinyin'} ) {
+    push @preprograms, 'gpinyin';
+  }
+
+  # preprocessors with `groff' option
+  if ( ( $Groff{'PS'} ||  $Groff{'PF'} ) &&  $Groff{'PE'} ) {
+    $Groff{'pic'} = 1;
+  }
+  if ( $Groff{'gideal'} ) {
+    $Groff{'pic'} = 1;
+  }
+
+###### make_groff_preproc()
+  $Groff{'refer'} ||= $Groff{'refer_open'} && $Groff{'refer_close'};
+
+  if ( $Groff{'chem'} || $Groff{'eqn'} ||  $Groff{'gideal'} ||
+       $Groff{'grap'} || $Groff{'grn'} || $Groff{'pic'} ||
+       $Groff{'refer'} || $Groff{'tbl'} ) {
+    push(@Command, '-s') if $Groff{'soelim'};
+
+    push(@Command, '-R') if $Groff{'refer'};
+
+    push(@Command, '-t') if $Groff{'tbl'};	# tbl before eqn
+    push(@Command, '-e') if $Groff{'eqn'};
+
+    push(@Command, '-j') if $Groff{'chem'};	# chem produces pic code
+    push(@Command, '-J') if $Groff{'gideal'};	# gideal produces pic
+    push(@Command, '-G') if $Groff{'grap'};
+    push(@Command, '-g') if $Groff{'grn'};	# gremlin files for -me
+    push(@Command, '-p') if $Groff{'pic'};
+
+  }
+} # make_groff_preproc()
+
+
+########################################################################
+# make_groff_tmac_man_ms()
+########################################################################
+
+sub make_groff_tmac_man_ms {
+  # globals: @filespec, $tmac_ext, %Groff
+
+  # `man' requests, not from `ms'
+  if ( $Groff{'SS'} || $Groff{'SY'} || $Groff{'OP'} ||
+       $Groff{'TH_first'} || $Groff{'TP'} || $Groff{'UR'} ) {
+    $Groff{'man'} = 1;
+    push(@m, '-man');
+
+    $tmac_ext = 'man' unless ( $tmac_ext );
+    &err('man requests found, but file name extension ' .
+	 'was: ' . $tmac_ext) unless ( $tmac_ext eq 'man' );
+    $tmac_ext = 'man';
+    return 1;	# true
+  }
+
+###### make_groff_tmac_man_ms()
+  # `ms' requests, not from `man'
+  if (
+      $Groff{'1C'} || $Groff{'2C'} ||
+      $Groff{'AB'} || $Groff{'AE'} || $Groff{'AI'} || $Groff{'AU'} ||
+      $Groff{'BX'} || $Groff{'CD'} || $Groff{'DA'} || $Groff{'DE'} ||
+      $Groff{'DS'} || $Groff{'ID'} || $Groff{'LD'} || $Groff{'NH'} ||
+      $Groff{'TH_later'} ||
+      $Groff{'TL'} || $Groff{'UL'} || $Groff{'XP'}
+     ) {
+    $Groff{'ms'} = 1;
+    push(@m, '-ms');
+
+    $tmac_ext = 'ms' unless ( $tmac_ext );
+    &err('ms requests found, but file name extension ' .
+	 'was: ' . $tmac_ext) unless ( $tmac_ext eq 'ms' );
+    $tmac_ext = 'ms';
+    return 1;	# true
+  }
+
+###### make_groff_tmac_man_ms()
+
+  # both `man' and `ms' requests
+  if ( $Groff{'P'} || $Groff{'IP'}  ||
+       $Groff{'LP'} || $Groff{'PP'} || $Groff{'SH'} ) {
+    if ( $tmac_ext eq 'man' ) {
+      $Groff{'man'} = 1;
+      push(@m, '-man');
+      return 1;	# true
+    } elsif ( $tmac_ext eq 'ms' ) {
+      $Groff{'ms'} = 1;
+      push(@m, '-ms');
+      return 1;	# true
+    }
+    return 0;
+  }
+} # make_groff_tmac_man_ms()
+
+
+
+########################################################################
+# make_groff_tmac_others()
+########################################################################
+
+sub make_groff_tmac_others {
+  # globals: @filespec, $tmac_ext, %Groff
+
+  # mdoc
+  if ( ( $Groff{'Oo'} && $Groff{'Oc'} ) || $Groff{'Dd'} ) {
+    $Groff{'Oc'} = 0;
+    $Groff{'Oo'} = 0;
+    push(@m, '-mdoc');
+    return 1;	# true
+  }
+  if ( $Groff{'mdoc_old'} || $Groff{'Oo'} ) {
+    push(@m, '-mdoc_old');
+    return 1;	# true
+  }
+
+  # me
+  if ( $Groff{'me'} ) {
+    push(@m, '-me');
+    return 1;	# true
+  }
+
+##### make_groff_tmac_others()
+  # mm and mmse
+  if ( $Groff{'mm'} ) {
+    push(@m, '-mm');
+    return 1;	# true
+  }
+  if ( $Groff{'mmse'} ) {	# Swedish mm
+    push(@m, '-mmse');
+    return 1;	# true
+  }
+
+  # mom
+  if ( $Groff{'mom'} ) {
+    push(@m, '-mom');
+    return 1;	# true
+  }
+} # make_groff_tmac_others()
+
+
+########################################################################
+# make_groff_line_rest()
+########################################################################
+
+sub make_groff_line_rest {
+  my $file_args_included;	# file args now only at 1st preproc
+  unshift @Command, 'groff';
+  if ( @preprograms ) {
+    my @progs;
+    $progs[0] = shift @preprograms;
+    push(@progs, @filespec);
+    for ( @preprograms ) {
+      push @progs, '|';
+      push @progs, $_;
+    }
+    push @progs, '|';
+    unshift @Command, @progs;
+    $file_args_included = 1;
+  } else {
+    $file_args_included = 0;
+  }
+
+  foreach (@Command) {
+    next unless /\s/;
+    # when one argument has several words, use accents
+    $_ = "'" . $_ . "'";
+  }
+
+
+  ##########
+  # -m arguments
+  my $nr_m_guessed = scalar @m;
+  if ( $nr_m_guessed > 1 ) {
+    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+      'argument for -m found: ' . @m;
+  }
+
+###### make_groff_line()
+
+  my $nr_m_args = scalar @Mparams;	# m-arguments for grog
+  my $last_m_arg = '';	# last provided -m option
+  if ( $nr_m_args > 1 ) {
+    # take the last given -m argument of grog call,
+    # ignore other -m arguments and the found ones
+    $last_m_arg = $Mparams[-1];	# take the last -m argument
+    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+      $Prog . ": more than 1 `-m' argument: @Mparams";
+    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+      'We take the last one: ' . $last_m_arg;
+  } elsif ( $nr_m_args == 1 ) {
+    $last_m_arg = $Mparams[0];
+  }
+
+  my $final_m = '';
+  if ( $last_m_arg ) {
+    my $is_equal = 0;
+    for ( @m ) {
+      if ( $_ eq $last_m_arg ) {
+	$is_equal = 1;
+	last;
+      }
+      next;
+    }	# end for @m
+    if ( $is_equal ) {
+      $final_m = $last_m_arg;
+    } else {
+      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	'Provided -m argument ' . $last_m_arg .
+	  ' differs from guessed -m args: ' . @m;
+      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	'The argument is taken.';
+      $final_m = $last_m_arg;
+    }
+###### make_groff_line()
+  } else {	# no -m arg provided
+    if ( $nr_m_guessed > 1 ) {
+      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	'More than 1 -m arguments were guessed: ' . @m;
+      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' . 'Guessing stopped.';
+      exit 1;
+    } elsif ( $nr_m_guessed == 1 ) {
+      $final_m = $m[0];
+    } else {
+      # no -m provided or guessed
+    }
+  }
+  push @Command, $final_m if ( $final_m );
+
+  push(@Command, @filespec) unless ( $file_args_included );
+
+  #########
+  # execute the `groff' command here with option `--run'
+  if ( $do_run ) { # with --run
+    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' . "@Command";
+    my $cmd = join ' ', @Command;
+    system($cmd);
+  } else {
+    print "@Command";
+  }
+
+  exit 0;
+} # make_groff_line()
+
+
+########################################################################
+# sub help
+########################################################################
+
+sub help {
+  print <<EOF;
+usage: grog [option]... [--] [filespec]...
+
+"filespec" is either the name of an existing, readable file or "-" for
+standard input.  If no `filespec' is specified, standard input is
+assumed automatically.  All arguments after a `--' are regarded as file
+names, even if they start with a `-' character.
+
+`option' is either a `groff' option or one of these:
+
+-h|--help	print this uasge message and exit
+-v|--version	print version information and exit
+
+-C		compatibility mode
+--ligatures	include options `-P-y -PU' for internal font, which
+		preserverses the ligatures like `fi'
+--run		run the checked-out groff command
+--warnings	display more warnings to standard error
+
+All other options should be `groff' 1-character options.  These are then
+appended to the generated `groff' command line.  The `-m' options will
+be checked by `grog'.
+
+EOF
+  exit 0;
+} # help()
+
+
+########################################################################
+# sub version
+########################################################################
+
+sub version {
+  our %at_at;
+  print "Perl version of GNU $Prog " .
+    "in groff version " . $at_at{'GROFF_VERSION'};
+  exit 0;
+} # version()
+
+
+1;
+########################################################################
+### Emacs settings
+# Local Variables:
+# mode: CPerl
+# End:


From MAILER-DAEMON Thu Jul 23 02:26:35 2015
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1ZI9xj-0002Rv-CV
	for mharc-groff-commit@gnu.org; Thu, 23 Jul 2015 02:26:35 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:47654)
	by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <wl@gnu.org>)
	id 1ZI9xa-0002Qj-Bj
	for groff-commit@gnu.org; Thu, 23 Jul 2015 02:26:34 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <wl@gnu.org>) id 1ZI9xS-0002Yy-W3
	for groff-commit@gnu.org; Thu, 23 Jul 2015 02:26:26 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:54514)
	by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <wl@gnu.org>)
	id 1ZI9xS-0002Yu-Pt
	for groff-commit@gnu.org; Thu, 23 Jul 2015 02:26:18 -0400
Received: from wl by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <wl@gnu.org>) id 1ZI9xR-0004CO-KZ
	for groff-commit@gnu.org; Thu, 23 Jul 2015 06:26:18 +0000
Date: Thu, 23 Jul 2015 06:26:17 +0000
Message-Id: <E1ZI9xR-0004CO-KZ@vcs.savannah.gnu.org>
To: groff-commit@gnu.org
Subject: [groff] 01/01: [grog] Don't use CR/LF line endings.
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
In-Reply-To: groff@gnu.org
References: <20150723062617.16097.65860@vcs.savannah.gnu.org>
X-Git-Repo: groff
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Rev: bb001e7fdf11408276d8c18a5357403baa7e6fc3
Auto-Submitted: auto-generated
From: Werner LEMBERG <wl@gnu.org>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: groff-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: groff@gnu.org
List-Id: <groff-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/groff-commit>,
	<mailto:groff-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/groff-commit>
List-Post: <mailto:groff-commit@gnu.org>
List-Help: <mailto:groff-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/groff-commit>,
	<mailto:groff-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 23 Jul 2015 06:26:34 -0000

wl pushed a commit to branch master
in repository groff.

commit bb001e7fdf11408276d8c18a5357403baa7e6fc3
Author: Werner Lemberg <wl@gnu.org>
Date:   Thu Jul 23 08:25:39 2015 +0200

    [grog] Don't use CR/LF line endings.
---
 ChangeLog             |   10 +-
 src/roff/grog/grog.pl |  204 ++--
 src/roff/grog/subs.pl | 2546 ++++++++++++++++++++++++------------------------
 3 files changed, 1381 insertions(+), 1379 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 75520c3..0a51b5d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,15 +1,17 @@
 2015-07-19  Bernd Warken  <groff-bernd.warken-72@web.de>
 
-        * src/roff/grog/*.pl: Add last update.
+	* src/roff/grog/*.pl: Add last update.
 
-        * src/roff/grog/subs.pl: Remove call to Perl INC::System::Simple,
-	use backticks instead.  Define &err().  Reorder some extensions.
+	* src/roff/grog/subs.pl: Remove call to Perl INC::System::Simple,
+	use backticks instead.
+	Define &err().
+	Reorder some extensions.
 	Distinguish between .TH at first command for man and later on for
 	ms.
 
 2015-07-01 Peter Bray <pdb_ml@yahoo.com.au>
 
-	Fix Savannah bug #44784
+	Fix Savannah bug #44784.
 
 	Compatibility Mode rendering of groff manual pages
 
diff --git a/src/roff/grog/grog.pl b/src/roff/grog/grog.pl
index b78963e..4bfd2db 100644
--- a/src/roff/grog/grog.pl
+++ b/src/roff/grog/grog.pl
@@ -1,102 +1,102 @@
-#! /usr/bin/env perl
-# grog - guess options for groff command
-# Inspired by doctype script in Kernighan & Pike, Unix Programming
-# Environment, pp 306-8.
-
-# Source file position: <groff-source>/src/roff/grog/grog.pl
-# Installed position: <prefix>/bin/grog
-
-# Copyright (C) 1993-2015  Free Software Foundation, Inc.
-# Written by James Clark, maintained by Werner Lemberg.
-# Rewritten with Perl by Bernd Warken <groff-bernd.warken-72@web.de>.
-# The macros for identifying the devices were taken from Ralph
-# Corderoy's `grog.sh' of 2006.
-
-# Last update: 19 Jul 2015
-
-# This file is part of `grog', which is part of `groff'.
-
-# `groff' is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-
-# `groff' is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see
-# <http://www.gnu.org/licenses/gpl-2.0.html>.
-
-########################################################################
-
-require v5.6;
-
-use warnings;
-use strict;
-
-# $Bin is the directory where this script is located
-use FindBin;
-
-my $before_make;	# script before run of `make'
-{
-  my $at = '@';
-  $before_make = 1 if '@VERSION@' eq "${at}VERSION${at}";
-}
-
-
-our %at_at;
-my $grog_dir;
-
-if ($before_make) { # before installation
-  my $grog_source_dir = $FindBin::Bin;
-  $at_at{'BINDIR'} = $grog_source_dir;
-# $grog_dir = $grog_source_dir;
-  $grog_dir = '.';
-  my $top = $grog_source_dir . '/../../../';
-  open FILE, '<', $top . 'VERSION' ||
-    die 'Could not open top file VERSION.';
-  my $version = <FILE>;
-  chomp $version;
-  close FILE;
-  open FILE, '<', $top . 'REVISION' ||
-    die 'Could not open top file REVISION.';
-  my $revision = <FILE>;
-  chomp $revision;
-  $at_at{'GROFF_VERSION'} = $version . '.' . $revision;
-} else { # after installation}
-  $at_at{'GROFF_VERSION'} = '@VERSION@';
-  $at_at{'BINDIR'} = '@BINDIR@';
-  $grog_dir = '@grog_dir@';
-} # before make
-
-die "$grog_dir is not an existing directory;" unless -d $grog_dir;
-
-
-#############
-# import subs
-
-unshift(@INC, $grog_dir);
-require 'subs.pl';
-
-
-##########
-# run subs
-
-&handle_args();
-&handle_file_ext(); # see $tmac_ext for gotten value
-&handle_whole_files();
-&make_groff_device();
-&make_groff_preproc();
-&make_groff_tmac_man_ms() || &make_groff_tmac_others();
-&make_groff_line_rest();
-
-
-1;
-########################################################################
-### Emacs settings
-# Local Variables:
-# mode: CPerl
-# End:
+#! /usr/bin/env perl
+# grog - guess options for groff command
+# Inspired by doctype script in Kernighan & Pike, Unix Programming
+# Environment, pp 306-8.
+
+# Source file position: <groff-source>/src/roff/grog/grog.pl
+# Installed position: <prefix>/bin/grog
+
+# Copyright (C) 1993-2015  Free Software Foundation, Inc.
+# Written by James Clark, maintained by Werner Lemberg.
+# Rewritten with Perl by Bernd Warken <groff-bernd.warken-72@web.de>.
+# The macros for identifying the devices were taken from Ralph
+# Corderoy's `grog.sh' of 2006.
+
+# Last update: 19 Jul 2015
+
+# This file is part of `grog', which is part of `groff'.
+
+# `groff' is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+
+# `groff' is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see
+# <http://www.gnu.org/licenses/gpl-2.0.html>.
+
+########################################################################
+
+require v5.6;
+
+use warnings;
+use strict;
+
+# $Bin is the directory where this script is located
+use FindBin;
+
+my $before_make;	# script before run of `make'
+{
+  my $at = '@';
+  $before_make = 1 if '@VERSION@' eq "${at}VERSION${at}";
+}
+
+
+our %at_at;
+my $grog_dir;
+
+if ($before_make) { # before installation
+  my $grog_source_dir = $FindBin::Bin;
+  $at_at{'BINDIR'} = $grog_source_dir;
+# $grog_dir = $grog_source_dir;
+  $grog_dir = '.';
+  my $top = $grog_source_dir . '/../../../';
+  open FILE, '<', $top . 'VERSION' ||
+    die 'Could not open top file VERSION.';
+  my $version = <FILE>;
+  chomp $version;
+  close FILE;
+  open FILE, '<', $top . 'REVISION' ||
+    die 'Could not open top file REVISION.';
+  my $revision = <FILE>;
+  chomp $revision;
+  $at_at{'GROFF_VERSION'} = $version . '.' . $revision;
+} else { # after installation}
+  $at_at{'GROFF_VERSION'} = '@VERSION@';
+  $at_at{'BINDIR'} = '@BINDIR@';
+  $grog_dir = '@grog_dir@';
+} # before make
+
+die "$grog_dir is not an existing directory;" unless -d $grog_dir;
+
+
+#############
+# import subs
+
+unshift(@INC, $grog_dir);
+require 'subs.pl';
+
+
+##########
+# run subs
+
+&handle_args();
+&handle_file_ext(); # see $tmac_ext for gotten value
+&handle_whole_files();
+&make_groff_device();
+&make_groff_preproc();
+&make_groff_tmac_man_ms() || &make_groff_tmac_others();
+&make_groff_line_rest();
+
+
+1;
+########################################################################
+### Emacs settings
+# Local Variables:
+# mode: CPerl
+# End:
diff --git a/src/roff/grog/subs.pl b/src/roff/grog/subs.pl
index ec5e1a9..06121b8 100644
--- a/src/roff/grog/subs.pl
+++ b/src/roff/grog/subs.pl
@@ -1,1273 +1,1273 @@
-#! /usr/bin/env perl
-# grog - guess options for groff command
-# Inspired by doctype script in Kernighan & Pike, Unix Programming
-# Environment, pp 306-8.
-
-# Source file position: <groff-source>/src/roff/grog/subs.pl
-# Installed position: <prefix>/lib/grog/subs.pl
-
-# Copyright (C) 1993-2015  Free Software Foundation, Inc.
-# This file was split from grog.pl and put under GPL2 by
-#               Bernd Warken <groff-bernd.warken-72@web.de>.
-# The macros for identifying the devices were taken from Ralph
-# Corderoy's `grog.sh' of 2006.
-
-# Last update: 19 Jul 2015
-
-# This file is part of `grog', which is part of `groff'.
-
-# `groff' is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-
-# `groff' is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-
-# You can get the license text for the GNU General Public License
-# version 2 in the internet at
-# <http://www.gnu.org/licenses/gpl-2.0.html>.
-
-########################################################################
-
-require v5.6;
-
-use warnings;
-use strict;
-
-use File::Spec;
-
-# printing of hashes: my %hash = ...; print Dumper(\%hash);
-use Data::Dumper;
-
-# for running shell based programs within Perl; use `` instead of
-# use IPC::System::Simple qw(capture capturex run runx system systemx);
-
-$\ = "\n";
-
-# my $Sp = "[\\s\\n]";
-# my $Sp = qr([\s\n]);
-# my $Sp = '' if $arg eq '-C';
-my $Sp = '';
-
-# from `src/roff/groff/groff.cpp' near `getopt_long'
-my $groff_opts =
-  'abcCd:D:eEf:F:gGhiI:jJkK:lL:m:M:n:No:pP:r:RsStT:UvVw:W:XzZ';
-
-my @Command = ();		# stores the final output
-my @Mparams = ();		# stores the options `-m*'
-my @devices = ();
-my $do_run = 0;			# run generated `groff' command
-my $pdf_with_ligatures = 0;	# `-P-y -PU' for `pdf' device
-my $with_warnings = 0;
-
-my $Prog = $0;
-{
-  my ($v, $d, $f) = File::Spec->splitpath($Prog);
-  $Prog = $f;
-}
-
-
-my %macros;
-my %Groff =
-  (
-   # preprocessors
-   'chem' => 0,
-   'eqn' => 0,
-   'gperl' => 0,
-   'grap' => 0,
-   'grn' => 0,
-   'gideal' => 0,
-   'gpinyin' => 0,
-   'lilypond' => 0,
-
-   'pic' => 0,
-   'PS' => 0,		# opening for pic
-   'PF' => 0,		# alternative opening for pic
-   'PE' => 0,		# closing for pic
-
-   'refer' => 0,
-   'refer_open' => 0,
-   'refer_close' => 0,
-   'soelim' => 0,
-   'tbl' => 0,
-
-   # tmacs
-#   'man' => 0,
-#   'mandoc' => 0,
-#   'mdoc' => 0,
-#   'mdoc_old' => 0,
-#   'me' => 0,
-#   'mm' => 0,
-#   'mom' => 0,
-#   'ms' => 0,
-
-   # requests
-   'AB' => 0,		# ms
-   'AE' => 0,		# ms
-   'AI' => 0,		# ms
-   'AU' => 0,		# ms
-   'NH' => 0,		# ms
-   'TH_later' => 0,	# TH not 1st command is ms
-   'TL' => 0,		# ms
-   'UL' => 0,		# ms
-   'XP' => 0,		# ms
-
-   'IP' => 0,		# man and ms
-   'LP' => 0,		# man and ms
-   'P' => 0,		# man and ms
-   'PP' => 0,		# man and ms
-   'SH' => 0,		# man and ms
-
-   'OP' => 0,		# man
-   'SS' => 0,		# man
-   'SY' => 0,		# man
-   'TH_first' => 0,	# TH as 1st command is man
-   'TP' => 0,		# man
-   'UR' => 0,		# man
-   'YS' => 0,		# man
-
-   # for mdoc and mdoc-old
-   # .Oo and .Oc for modern mdoc, only .Oo for mdoc-old
-   'Oo' => 0,		# mdoc and mdoc-old
-   'Oc' => 0,		# mdoc
-   'Dd' => 0,		# mdoc
-  ); # end of %Groff
-
-
-# for first line check
-my %preprocs_tmacs =
-  (
-   'chem' => 0,
-   'eqn' => 0,
-   'gideal' => 0,
-   'gpinyin' => 0,
-   'grap' => 0,
-   'grn' => 0,
-   'pic' => 0,
-   'refer' => 0,
-   'soelim' => 0,
-   'tbl' => 0,
-
-   'geqn' => 0,
-   'gpic' => 0,
-   'neqn' => 0,
-
-   'man' => 0,
-   'mandoc' => 0,
-   'mdoc' => 0,
-   'mdoc-old' => 0,
-   'me' => 0,
-   'mm' => 0,
-   'mom' => 0,
-   'ms' => 0,
-  );
-
-my @filespec;
-
-my $tmac_ext = '';
-
-
-########################################################################
-# err()
-########################################################################
-
-sub err {
-  my $text = shift;
-  print STDERR $text;
-}
-
-
-########################################################################
-# handle_args()
-########################################################################
-
-sub handle_args {
-  my $double_minus = 0;
-  my $was_minus = 0;
-  my $was_T = 0;
-  my $optarg = 0;
-  # globals: @filespec, @Command, @devices, @Mparams
-
-  foreach my $arg (@ARGV) {
-
-    if ( $optarg ) {
-      push @Command, $arg;
-      $optarg = 0;
-      next;
-    }
-
-    if ( $double_minus ) {
-      if (-f $arg && -r $arg) {
-	push @filespec, $arg;
-      } else {
-	print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	  "grog: $arg is not a readable file.";
-      }
-      next;
-    }
-
-    if ( $was_T ) {
-      push @devices, $arg;
-      $was_T = 0;
-      next;
-    }
-####### handle_args()
-
-    unless ( $arg =~ /^-/ ) { # file name, no opt, no optarg
-      unless (-f $arg && -r $arg) {
-	print 'unknown file name: ' . $arg;
-      }
-      push @filespec, $arg;
-      next;
-    }
-
-    # now $arg starts with `-'
-
-    if ($arg eq '-') {
-      unless ($was_minus) {
-	push @filespec, $arg;
-	$was_minus = 1;
-      }
-      next;
-    }
-
-    if ($arg eq '--') {
-      $double_minus = 1;
-      push(@filespec, $arg);
-      next;
-    }
-
-    &version() if $arg =~ /^--?v/;	# --version, with exit
-    &help() if $arg  =~ /--?h/;		# --help, with exit
-
-    if ( $arg =~ /^--r/ ) {		#  --run, no exit
-      $do_run = 1;
-      next;
-    }
-
-    if ( $arg =~ /^--wa/ ) {		#  --warnings, no exit
-      $with_warnings = 1;
-      next;
-    }
-####### handle_args()
-
-    if ( $arg =~ /^--(wi|l)/ ) { # --ligatures, no exit
-      # the old --with_ligatures is only kept for compatibility
-      $pdf_with_ligatures = 1;
-      next;
-    }
-
-    if ($arg =~ /^-m/) {
-      push @Mparams, $arg;
-      next;
-    }
-
-    if ($arg =~ /^-T$/) {
-      $was_T = 1;
-      next;
-    }
-
-    if ($arg =~ s/^-T(\w+)$/$1/) {
-      push @devices, $1;
-      next;
-    }
-
-    if ($arg =~ /^-(\w)(\w*)$/) {	# maybe a groff option
-      my $opt_char = $1;
-      my $opt_char_with_arg = $opt_char . ':';
-      my $others = $2;
-      if ( $groff_opts =~ /$opt_char_with_arg/ ) {	# groff optarg
-	if ( $others ) {	# optarg is here
-	  push @Command, '-' . $opt_char;
-	  push @Command, '-' . $others;
-	  next;
-	}
-	# next arg is optarg
-	$optarg = 1;
-	next;
-####### handle_args()
-      } elsif ( $groff_opts =~ /$opt_char/ ) {	# groff no optarg
-	push @Command, '-' . $opt_char;
-	if ( $others ) {	# $others is now an opt collection
-	  $arg = '-' . $others;
-	  redo;
-	}
-	# arg finished
-	next;
-      } else {		# not a groff opt
-	print STDERR __FILE__ . ' '  . __LINE__ . ': ' .
-	  'unknown argument ' . $arg;
-	push(@Command, $arg);
-	next;
-      }
-    }
-  }
-  @filespec = ('-') unless (@filespec);
-} # handle_args()
-
-
-
-########################################################################
-# handle_file_ext()
-########################################################################
-
-sub handle_file_ext {
-  # get tmac from file name extension
-  # output number of found single tmac
-
-  # globals: @filespec, $tmac_ext;
-
-  foreach my $file ( @filespec ) {
-    # test for each file name in the arguments
-    unless ( open(FILE, $file eq "-" ? $file : "< $file") ) {
-      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	"$Prog: can't open \`$file\': $!";
-      next;
-    }
-
-    next unless ( $file =~ /\./ ); # file name has no dot `.'
-
-##### handle_file_ext()
-    # get extension
-    my $ext = $file;
-    $ext =~ s/^
-	      .*
-	      \.
-	      ([^.]*)
-	      $
-	     /$1/x;
-    next unless ( $ext );
-
-##### handle_file_ext()
-    # these extensions are correct, but not based on a tmac
-    next if ( $ext =~ /^(
-			 chem|
-			 eqn|
-			 g|
-			 grap|
-			 grn|
-			 groff|
-			 hdtbl|
-			 pdfroff|
-			 pic|
-			 pinyin|
-			 ref|
-			 roff|
-			 t|
-			 tbl|
-			 tr|
-			 www
-		       )$/x );
-
-##### handle_file_ext()
-    # extensions for man tmac
-    if ( $ext =~ /^(
-		      [1-9lno]|
-		      man|
-		      n|
-		      1b
-		    )$/x ) {
-      # `man|n' from `groff' source
-      # `1b' from `heirloom'
-      # `[1-9lno]' from man-pages
-      if ( $tmac_ext && $tmac_ext ne 'man' ) {
-	# found tmac is not 'man'
-	print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	  '2 different file name extensions found ' .
-	    $tmac_ext . ' and ' . $ext;
-	$tmac_ext = '';
-	next;
-      }
-
-##### handle_file_ext()
-      $tmac_ext = 'man';
-      next;
-    }
-
-    if ( $ext =~ /^(
-		    mandoc|
-		    mdoc|
-		    me|
-		    mm|
-		    mmse|
-		    mom|
-		    ms|
-		    $)/x ) {
-      if ( $tmac_ext && $tmac_ext ne $ext ) {
-	# found tmac is not identical to former found tmac
-##### handle_file_ext()
-	print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	  '2 different file name extensions found ' .
-	    $tmac_ext . ' and ' . $ext;
-	$tmac_ext = '';
-	next;
-      }
-
-      $tmac_ext = $ext;
-      next;
-    }
-
-    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-      'Unknown file name extension '. $file . '.';
-    next;
-  } # end foreach file
-
-  1;
-} # handle_file_ext()
-
-
-########################################################################
-# handle_whole_files()
-########################################################################
-
-sub handle_whole_files {
-  # globals: @filespec
-
-  foreach my $file ( @filespec ) {
-    unless ( open(FILE, $file eq "-" ? $file : "< $file") ) {
-      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	"$Prog: can't open \`$file\': $!";
-      next;
-    }
-    my $line = <FILE>; # get single line
-
-    unless ( defined($line) ) {
-      # empty file, go to next filearg
-      close (FILE);
-      next;
-    }
-
-    if ( $line ) {
-      chomp $line;
-      unless ( &do_first_line( $line, $file ) ) {
-	# not an option line
-	&do_line( $line, $file );
-      }
-    } else { # empty line
-      next;
-    }
-
-    while (<FILE>) { # get lines by and by
-      chomp;
-      &do_line( $_, $file );
-    }
-    close(FILE);
-  } # end foreach
-} # handle_whole_files()
-
-
-########################################################################
-# do_first_line()
-########################################################################
-
-# As documented for the `man' program, the first line can be
-# used as a groff option line.  This is done by:
-# - start the line with '\" (apostrophe, backslash, double quote)
-# - add a space character
-# - a word using the following characters can be appended: `egGjJpRst'.
-#     Each of these characters means an option for the generated
-#     `groff' command line, e.g. `-t'.
-
-sub do_first_line {
-  my ( $line, $file ) = @_;
-
-  # globals: %preprocs_tmacs
-
-  # For a leading groff options line use only [egGjJpRst]
-  if  ( $line =~ /^[.']\\"[\segGjJpRst]+&/ ) {
-    # this is a groff options leading line
-    if ( $line =~ /^\./ ) {
-      # line is a groff options line with . instead of '
-      print "First line in $file must start with an apostrophe \ " .
-	"instead of a period . for groff options line!";
-    }
-
-    if ( $line =~ /j/ ) {
-      $Groff{'chem'}++;
-    }
-    if ( $line =~ /e/ ) {
-      $Groff{'eqn'}++;
-    }
-    if ( $line =~ /g/ ) {
-      $Groff{'grn'}++;
-    }
-    if ( $line =~ /G/ ) {
-      $Groff{'grap'}++;
-    }
-    if ( $line =~ /i/ ) {
-      $Groff{'gideal'}++;
-    }
-    if ( $line =~ /p/ ) {
-      $Groff{'pic'}++;
-    }
-    if ( $line =~ /R/ ) {
-      $Groff{'refer'}++;
-    }
-    if ( $line =~ /s/ ) {
-      $Groff{'soelim'}++;
-    }
-####### do_first_line()
-    if ( $line =~ /t/ ) {
-      $Groff{'tbl'}++;
-    }
-    return 1;	# a leading groff options line, 1 means yes, 0 means no
-  }
-
-  # not a leading short groff options line
-
-  return 0 if ( $line !~ /^[.']\\"\s*(.*)$/ );	# ignore non-comments
-
-  return 0 unless ( $1 );	# for empty comment
-
-  # all following array members are either preprocs or 1 tmac
-  my @words = split '\s+', $1;
-
-  my @in = ();
-  my $word;
-  for $word ( @words ) {
-    if ( $word eq 'ideal' ) {
-      $word = 'gideal';
-    } elsif ( $word eq 'gpic' ) {
-      $word = 'pic';
-    } elsif ( $word =~ /^(gn|)eqn$/ ) {
-      $word = 'eqn';
-    }
-    if ( exists $preprocs_tmacs{$word} ) {
-      push @in, $word;
-    } else {
-      # not word for preproc or tmac
-      return 0;
-    }
-  }
-
-  for $word ( @in ) {
-    $Groff{$word}++;
-  }
-} # do_first_line()
-
-
-########################################################################
-# do_line()
-########################################################################
-
-my $before_first_command = 1; # for check of .TH
-
-sub do_line {
-  my ( $line, $file ) = @_;
-
-  return if ( $line =~ /^[.']\s*\\"/ );	# comment
-
-  return unless ( $line =~ /^[.']/ );	# ignore text lines
-
-  $line =~ s/^['.]\s*/./;	# let only a dot as leading character,
-				# remove spaces after the leading dot
-  $line =~ s/\s+$//;		# remove final spaces
-
-  return if ( $line =~ /^\.$/ );	# ignore .
-  return if ( $line =~ /^\.\.$/ );	# ignore ..
-
-  if ( $before_first_command ) { # so far without 1st command
-    if ( $line =~ /^\.TH/ ) {
-      # check if .TH is 1st command for man
-      $Groff{'TH_first'} = 1 if ( $line =~ /^\.\s*TH/ );
-    }
-    if ( $line =~ /^\./ ) {
-      $before_first_command = 0;
-    }
-  }
-
-  # split command
-  $line =~ /^(\.\w+)\s*(.*)$/;
-  my $command = $1;
-  $command = '' unless ( defined $command );
-  my $args = $2;
-  $args = '' unless ( defined $args );
-
-
-  ######################################################################
-  # soelim
-  if ( $line =~ /^\.(do)?\s*(so|mso|PS\s*<|SO_START).*$/ ) {
-    # `.so', `.mso', `.PS<...', `.SO_START'
-    $Groff{'soelim'}++;
-    return;
-  }
-  if ( $line =~ /^\.(do)?\s*(so|mso|PS\s*<|SO_START).*$/ ) {
-    # `.do so', `.do mso', `.do PS<...', `.do SO_START'
-    $Groff{'soelim'}++;
-    return;
-  }
-####### do_line()
-
-  ######################################################################
-  # macros
-
-  if ( $line =~ /^\.de1?\W?/ ) {
-    # this line is a macro definition, add it to %macros
-    my $macro = $line;
-    $macro =~ s/^\.de1?\s+(\w+)\W*/.$1/;
-    return if ( exists $macros{$macro} );
-    $macros{$macro} = 1;
-    return;
-  }
-
-
-  # if line command is a defined macro, just ignore this line
-  return if ( exists $macros{$command} );
-
-
-  ######################################################################
-  # preprocessors
-
-  if ( $command =~ /^(\.cstart)|(begin\s+chem)$/ ) {
-    $Groff{'chem'}++;		# for chem
-    return;
-  }
-  if ( $command =~ /^\.EQ$/ ) {
-    $Groff{'eqn'}++;		# for eqn
-    return;
-  }
-  if ( $command =~ /^\.G1$/ ) {
-    $Groff{'grap'}++;		# for grap
-    return;
-  }
-  if ( $command =~ /^\.Perl/ ) {
-    $Groff{'gperl'}++;		# for gperl
-    return;
-  }
-  if ( $command =~ /^\.pinyin/ ) {
-    $Groff{'gpinyin'}++;		# for gperl
-    return;
-  }
-  if ( $command =~ /^\.GS$/ ) {
-    $Groff{'grn'}++;		# for grn
-    return;
-  }
-  if ( $command =~ /^\.IS$/ ) {
-    $Groff{'gideal'}++;		# preproc gideal for ideal
-    return;
-  }
-  if ( $command =~ /^\.lilypond$/ ) {
-    $Groff{'lilypond'}++;	# for glilypond
-    return;
-  }
-
-####### do_line()
-
-  # pic can be opened by .PS or .PF and closed by .PE
-  if ( $command =~ /^\.PS$/ ) {
-    $Groff{'pic'}++;		# normal opening for pic
-    return;
-  }
-  if ( $command =~ /^\.PF$/ ) {
-    $Groff{'PF'}++;		# alternate opening for pic
-    return;
-  }
-  if ( $command =~ /^\.PE$/ ) {
-    $Groff{'PE'}++;		# closing for pic
-    return;
-  }
-
-  if ( $command =~ /^\.R1$/ ) {
-    $Groff{'refer'}++;		# for refer
-    return;
-  }
-  if ( $command =~ /^\.\[$/ ) {
-    $Groff{'refer_open'}++;	# for refer open
-    return;
-  }
-  if ( $command =~ /^\.\]$/ ) {
-    $Groff{'refer_close'}++;	# for refer close
-    return;
-  }
-  if ( $command =~ /^\.TS$/ ) {
-    $Groff{'tbl'}++;		# for tbl
-    return;
-  }
-  if ( $command =~ /^\.TH$/ ) {
-    unless ( $Groff{'TH_first'} ) {
-      $Groff{'TH_later'}++;		# for tbl
-    }
-    return;
-  }
-
-
-  ######################################################################
-  # macro package (tmac)
-  ######################################################################
-
-  ##########
-  # modern mdoc
-
-  if ( $command =~ /^\.(Dd)$/ ) {
-    $Groff{'Dd'}++;		# for modern mdoc
-    return;
-  }
-
-####### do_line()
-  # In the old version of -mdoc `Oo' is a toggle, in the new it's
-  # closed by `Oc'.
-  if ( $command =~ /^\.Oc$/ ) {
-    $Groff{'Oc'}++;		# only for modern mdoc
-    return;
-  }
-
-
-  ##########
-  # old and modern mdoc
-
-  if ( $command =~ /^\.Oo$/ ) {
-    $Groff{'Oo'}++;		# for mdoc and mdoc-old
-    return;
-  }
-
-
-  ##########
-  # old mdoc
-  if ( $command =~ /^\.(Tp|Dp|De|Cx|Cl)$/ ) {
-    $Groff{'mdoc_old'}++;	# true for old mdoc
-    return;
-  }
-
-
-  ##########
-  # for ms
-
-####### do_line()
-  if ( $command =~ /^\.AB$/ ) {
-    $Groff{'AB'}++;		# for ms
-    return;
-  }
-  if ( $command =~ /^\.AE$/ ) {
-    $Groff{'AE'}++;		# for ms
-    return;
-  }
-  if ( $command =~ /^\.AI$/ ) {
-    $Groff{'AI'}++;		# for ms
-    return;
-  }
-  if ( $command =~ /^\.AU$/ ) {
-    $Groff{'AU'}++;		# for ms
-    return;
-  }
-  if ( $command =~ /^\.NH$/ ) {
-    $Groff{'NH'}++;		# for ms
-    return;
-  }
-  if ( $command =~ /^\.TL$/ ) {
-    $Groff{'TL'}++;		# for ms
-    return;
-  }
-  if ( $command =~ /^\.XP$/ ) {
-    $Groff{'XP'}++;		# for ms
-    return;
-  }
-
-
-  ##########
-  # for man and ms
-
-  if ( $command =~ /^\.IP$/ ) {
-    $Groff{'IP'}++;		# for man and ms
-    return;
-  }
-  if ( $command =~ /^\.LP$/ ) {
-    $Groff{'LP'}++;		# for man and ms
-    return;
-  }
-####### do_line()
-  if ( $command =~ /^\.P$/ ) {
-    $Groff{'P'}++;		# for man and ms
-    return;
-  }
-  if ( $command =~ /^\.PP$/ ) {
-    $Groff{'PP'}++;		# for man and ms
-    return;
-  }
-  if ( $command =~ /^\.SH$/ ) {
-    $Groff{'SH'}++;		# for man and ms
-    return;
-  }
-  if ( $command =~ /^\.UL$/ ) {
-    $Groff{'UL'}++;		# for man and ms
-    return;
-  }
-
-
-  ##########
-  # for man only
-
-  if ( $command =~ /^\.OP$/ ) {	# for man
-    $Groff{'OP'}++;
-    return;
-  }
-  if ( $command =~ /^\.SS$/ ) {	# for man
-    $Groff{'SS'}++;
-    return;
-  }
-  if ( $command =~ /^\.SY$/ ) {	# for man
-    $Groff{'SY'}++;
-    return;
-  }
-  if ( $command =~ /^\.TP$/ ) {	# for man
-    $Groff{'TP'}++;
-    return;
-  }
-  if ( $command =~ /^\.UR$/ ) {
-    $Groff{'UR'}++;		# for man
-    return;
-  }
-  if ( $command =~ /^\.YS$/ ) {	# for man
-   $Groff{'YS'}++;
-    return;
-  }
-####### do_line()
-
-
-  ##########
-  # me
-
-  if ( $command =~ /^\.(
-		      [ilnp]p|
-		      sh
-		    )$/x ) {
-    $Groff{'me'}++;		# for me
-    return;
-  }
-
-
-  #############
-  # mm and mmse
-
-  if ( $command =~ /^\.(
-		      H|
-		      MULB|
-		      LO|
-		      LT|
-		      NCOL|
-		      P\$|
-		      PH|
-		      SA
-		    )$/x ) {
-    $Groff{'mm'}++;		# for mm and mmse
-    if ( $command =~ /^\.LO$/ ) {
-      if ( $args =~ /^(DNAMN|MDAT|BIL|KOMP|DBET|BET|SIDOR)/ ) {
-	$Groff{'mmse'}++;	# for mmse
-      }
-    } elsif ( $command =~ /^\.LT$/ ) {
-      if ( $args =~ /^(SVV|SVH)/ ) {
-	$Groff{'mmse'}++;	# for mmse
-      }
-    }
-    return;
-  }
-####### do_line()
-
-  ##########
-  # mom
-
-  if ( $line =~ /^\.(
-		   ALD|
-		   DOCTYPE|
-		   FAMILY|
-		   FT|
-		   FAM|
-		   LL|
-		   LS|
-		   NEWPAGE|
-		   PAGE|
-		   PAPER|
-		   PRINTSTYLE|
-		   PT_SIZE|
-		   T_MARGIN
-		 )$/x ) {
-    $Groff{'mom'}++;		# for mom
-    return;
-  }
-
-} # do_line()
-
-
-########################################################################
-# sub make_groff_device
-########################################################################
-
-my @m = ();
-my @preprograms = ();
-my $correct_tmac = '';
-
-sub make_groff_device {
-  # globals: @devices
-
-  # default device is empty, i.e. it is `ps' when without `-T'
-  my $device = '';
-
-  for my $d ( @devices ) {
-    if ( $d =~			# suitable devices
-	 /^(
-	    dvi|
-	    html|
-	    xhtml|
-	    lbp|
-	    lj4|
-	    ps|
-	    pdf|
-	    ascii|
-	    cp1047|
-	    latin1|
-	    utf8
-	  )$/x ) {
-###### make_groff_device()
-      if ( $device ) {
-	next if ( $device eq $d );
-	print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	  'several different devices given: ' .
-	    $device . ' and ' .$d;
-	$device = $d;	# the last provided device is taken
-	next;
-      } else { # empty $device
-	$device = $d;
-	next;
-      }
-    } else {		# not suitable device
-      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	'not a suitable device for groff: ' . $d;
-      next;
-    }
-
-    if ( $device ) {
-      push @Command, '-T';
-      push @Command, $device;
-    }
-  }
-
-###### make_groff_device()
-  if ( $device eq 'pdf' ) {
-    if ( $pdf_with_ligatures ) {	# with --ligature argument
-      push( @Command, '-P-y' );
-      push( @Command, '-PU' );
-    } else {	# no --ligature argument
-      if ( $with_warnings ) {
-	print STDERR <<EOF;
-If you have trouble with ligatures like `fi' in the `groff' output, you
-can proceed as one of
-- add `grog' option `--with_ligatures' or
-- use the `grog' option combination `-P-y -PU' or
-- try to remove the font named similar to `fonts-texgyre' from your system.
-EOF
-      }	# end of warning
-    }	# end of ligature
-  }	# end of pdf device
-} # make_groff_device()
-
-
-########################################################################
-# make_groff_preproc()
-########################################################################
-
-sub make_groff_preproc {
-  # globals: %Groff, @preprograms, @Command
-
-  # preprocessors without `groff' option
-  if ( $Groff{'lilypond'} ) {
-    push @preprograms, 'glilypond';
-  }
-  if ( $Groff{'gperl'} ) {
-    push @preprograms, 'gperl';
-  }
-  if ( $Groff{'gpinyin'} ) {
-    push @preprograms, 'gpinyin';
-  }
-
-  # preprocessors with `groff' option
-  if ( ( $Groff{'PS'} ||  $Groff{'PF'} ) &&  $Groff{'PE'} ) {
-    $Groff{'pic'} = 1;
-  }
-  if ( $Groff{'gideal'} ) {
-    $Groff{'pic'} = 1;
-  }
-
-###### make_groff_preproc()
-  $Groff{'refer'} ||= $Groff{'refer_open'} && $Groff{'refer_close'};
-
-  if ( $Groff{'chem'} || $Groff{'eqn'} ||  $Groff{'gideal'} ||
-       $Groff{'grap'} || $Groff{'grn'} || $Groff{'pic'} ||
-       $Groff{'refer'} || $Groff{'tbl'} ) {
-    push(@Command, '-s') if $Groff{'soelim'};
-
-    push(@Command, '-R') if $Groff{'refer'};
-
-    push(@Command, '-t') if $Groff{'tbl'};	# tbl before eqn
-    push(@Command, '-e') if $Groff{'eqn'};
-
-    push(@Command, '-j') if $Groff{'chem'};	# chem produces pic code
-    push(@Command, '-J') if $Groff{'gideal'};	# gideal produces pic
-    push(@Command, '-G') if $Groff{'grap'};
-    push(@Command, '-g') if $Groff{'grn'};	# gremlin files for -me
-    push(@Command, '-p') if $Groff{'pic'};
-
-  }
-} # make_groff_preproc()
-
-
-########################################################################
-# make_groff_tmac_man_ms()
-########################################################################
-
-sub make_groff_tmac_man_ms {
-  # globals: @filespec, $tmac_ext, %Groff
-
-  # `man' requests, not from `ms'
-  if ( $Groff{'SS'} || $Groff{'SY'} || $Groff{'OP'} ||
-       $Groff{'TH_first'} || $Groff{'TP'} || $Groff{'UR'} ) {
-    $Groff{'man'} = 1;
-    push(@m, '-man');
-
-    $tmac_ext = 'man' unless ( $tmac_ext );
-    &err('man requests found, but file name extension ' .
-	 'was: ' . $tmac_ext) unless ( $tmac_ext eq 'man' );
-    $tmac_ext = 'man';
-    return 1;	# true
-  }
-
-###### make_groff_tmac_man_ms()
-  # `ms' requests, not from `man'
-  if (
-      $Groff{'1C'} || $Groff{'2C'} ||
-      $Groff{'AB'} || $Groff{'AE'} || $Groff{'AI'} || $Groff{'AU'} ||
-      $Groff{'BX'} || $Groff{'CD'} || $Groff{'DA'} || $Groff{'DE'} ||
-      $Groff{'DS'} || $Groff{'ID'} || $Groff{'LD'} || $Groff{'NH'} ||
-      $Groff{'TH_later'} ||
-      $Groff{'TL'} || $Groff{'UL'} || $Groff{'XP'}
-     ) {
-    $Groff{'ms'} = 1;
-    push(@m, '-ms');
-
-    $tmac_ext = 'ms' unless ( $tmac_ext );
-    &err('ms requests found, but file name extension ' .
-	 'was: ' . $tmac_ext) unless ( $tmac_ext eq 'ms' );
-    $tmac_ext = 'ms';
-    return 1;	# true
-  }
-
-###### make_groff_tmac_man_ms()
-
-  # both `man' and `ms' requests
-  if ( $Groff{'P'} || $Groff{'IP'}  ||
-       $Groff{'LP'} || $Groff{'PP'} || $Groff{'SH'} ) {
-    if ( $tmac_ext eq 'man' ) {
-      $Groff{'man'} = 1;
-      push(@m, '-man');
-      return 1;	# true
-    } elsif ( $tmac_ext eq 'ms' ) {
-      $Groff{'ms'} = 1;
-      push(@m, '-ms');
-      return 1;	# true
-    }
-    return 0;
-  }
-} # make_groff_tmac_man_ms()
-
-
-
-########################################################################
-# make_groff_tmac_others()
-########################################################################
-
-sub make_groff_tmac_others {
-  # globals: @filespec, $tmac_ext, %Groff
-
-  # mdoc
-  if ( ( $Groff{'Oo'} && $Groff{'Oc'} ) || $Groff{'Dd'} ) {
-    $Groff{'Oc'} = 0;
-    $Groff{'Oo'} = 0;
-    push(@m, '-mdoc');
-    return 1;	# true
-  }
-  if ( $Groff{'mdoc_old'} || $Groff{'Oo'} ) {
-    push(@m, '-mdoc_old');
-    return 1;	# true
-  }
-
-  # me
-  if ( $Groff{'me'} ) {
-    push(@m, '-me');
-    return 1;	# true
-  }
-
-##### make_groff_tmac_others()
-  # mm and mmse
-  if ( $Groff{'mm'} ) {
-    push(@m, '-mm');
-    return 1;	# true
-  }
-  if ( $Groff{'mmse'} ) {	# Swedish mm
-    push(@m, '-mmse');
-    return 1;	# true
-  }
-
-  # mom
-  if ( $Groff{'mom'} ) {
-    push(@m, '-mom');
-    return 1;	# true
-  }
-} # make_groff_tmac_others()
-
-
-########################################################################
-# make_groff_line_rest()
-########################################################################
-
-sub make_groff_line_rest {
-  my $file_args_included;	# file args now only at 1st preproc
-  unshift @Command, 'groff';
-  if ( @preprograms ) {
-    my @progs;
-    $progs[0] = shift @preprograms;
-    push(@progs, @filespec);
-    for ( @preprograms ) {
-      push @progs, '|';
-      push @progs, $_;
-    }
-    push @progs, '|';
-    unshift @Command, @progs;
-    $file_args_included = 1;
-  } else {
-    $file_args_included = 0;
-  }
-
-  foreach (@Command) {
-    next unless /\s/;
-    # when one argument has several words, use accents
-    $_ = "'" . $_ . "'";
-  }
-
-
-  ##########
-  # -m arguments
-  my $nr_m_guessed = scalar @m;
-  if ( $nr_m_guessed > 1 ) {
-    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-      'argument for -m found: ' . @m;
-  }
-
-###### make_groff_line()
-
-  my $nr_m_args = scalar @Mparams;	# m-arguments for grog
-  my $last_m_arg = '';	# last provided -m option
-  if ( $nr_m_args > 1 ) {
-    # take the last given -m argument of grog call,
-    # ignore other -m arguments and the found ones
-    $last_m_arg = $Mparams[-1];	# take the last -m argument
-    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-      $Prog . ": more than 1 `-m' argument: @Mparams";
-    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-      'We take the last one: ' . $last_m_arg;
-  } elsif ( $nr_m_args == 1 ) {
-    $last_m_arg = $Mparams[0];
-  }
-
-  my $final_m = '';
-  if ( $last_m_arg ) {
-    my $is_equal = 0;
-    for ( @m ) {
-      if ( $_ eq $last_m_arg ) {
-	$is_equal = 1;
-	last;
-      }
-      next;
-    }	# end for @m
-    if ( $is_equal ) {
-      $final_m = $last_m_arg;
-    } else {
-      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	'Provided -m argument ' . $last_m_arg .
-	  ' differs from guessed -m args: ' . @m;
-      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	'The argument is taken.';
-      $final_m = $last_m_arg;
-    }
-###### make_groff_line()
-  } else {	# no -m arg provided
-    if ( $nr_m_guessed > 1 ) {
-      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	'More than 1 -m arguments were guessed: ' . @m;
-      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' . 'Guessing stopped.';
-      exit 1;
-    } elsif ( $nr_m_guessed == 1 ) {
-      $final_m = $m[0];
-    } else {
-      # no -m provided or guessed
-    }
-  }
-  push @Command, $final_m if ( $final_m );
-
-  push(@Command, @filespec) unless ( $file_args_included );
-
-  #########
-  # execute the `groff' command here with option `--run'
-  if ( $do_run ) { # with --run
-    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' . "@Command";
-    my $cmd = join ' ', @Command;
-    system($cmd);
-  } else {
-    print "@Command";
-  }
-
-  exit 0;
-} # make_groff_line()
-
-
-########################################################################
-# sub help
-########################################################################
-
-sub help {
-  print <<EOF;
-usage: grog [option]... [--] [filespec]...
-
-"filespec" is either the name of an existing, readable file or "-" for
-standard input.  If no `filespec' is specified, standard input is
-assumed automatically.  All arguments after a `--' are regarded as file
-names, even if they start with a `-' character.
-
-`option' is either a `groff' option or one of these:
-
--h|--help	print this uasge message and exit
--v|--version	print version information and exit
-
--C		compatibility mode
---ligatures	include options `-P-y -PU' for internal font, which
-		preserverses the ligatures like `fi'
---run		run the checked-out groff command
---warnings	display more warnings to standard error
-
-All other options should be `groff' 1-character options.  These are then
-appended to the generated `groff' command line.  The `-m' options will
-be checked by `grog'.
-
-EOF
-  exit 0;
-} # help()
-
-
-########################################################################
-# sub version
-########################################################################
-
-sub version {
-  our %at_at;
-  print "Perl version of GNU $Prog " .
-    "in groff version " . $at_at{'GROFF_VERSION'};
-  exit 0;
-} # version()
-
-
-1;
-########################################################################
-### Emacs settings
-# Local Variables:
-# mode: CPerl
-# End:
+#! /usr/bin/env perl
+# grog - guess options for groff command
+# Inspired by doctype script in Kernighan & Pike, Unix Programming
+# Environment, pp 306-8.
+
+# Source file position: <groff-source>/src/roff/grog/subs.pl
+# Installed position: <prefix>/lib/grog/subs.pl
+
+# Copyright (C) 1993-2015  Free Software Foundation, Inc.
+# This file was split from grog.pl and put under GPL2 by
+#               Bernd Warken <groff-bernd.warken-72@web.de>.
+# The macros for identifying the devices were taken from Ralph
+# Corderoy's `grog.sh' of 2006.
+
+# Last update: 19 Jul 2015
+
+# This file is part of `grog', which is part of `groff'.
+
+# `groff' is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+
+# `groff' is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+
+# You can get the license text for the GNU General Public License
+# version 2 in the internet at
+# <http://www.gnu.org/licenses/gpl-2.0.html>.
+
+########################################################################
+
+require v5.6;
+
+use warnings;
+use strict;
+
+use File::Spec;
+
+# printing of hashes: my %hash = ...; print Dumper(\%hash);
+use Data::Dumper;
+
+# for running shell based programs within Perl; use `` instead of
+# use IPC::System::Simple qw(capture capturex run runx system systemx);
+
+$\ = "\n";
+
+# my $Sp = "[\\s\\n]";
+# my $Sp = qr([\s\n]);
+# my $Sp = '' if $arg eq '-C';
+my $Sp = '';
+
+# from `src/roff/groff/groff.cpp' near `getopt_long'
+my $groff_opts =
+  'abcCd:D:eEf:F:gGhiI:jJkK:lL:m:M:n:No:pP:r:RsStT:UvVw:W:XzZ';
+
+my @Command = ();		# stores the final output
+my @Mparams = ();		# stores the options `-m*'
+my @devices = ();
+my $do_run = 0;			# run generated `groff' command
+my $pdf_with_ligatures = 0;	# `-P-y -PU' for `pdf' device
+my $with_warnings = 0;
+
+my $Prog = $0;
+{
+  my ($v, $d, $f) = File::Spec->splitpath($Prog);
+  $Prog = $f;
+}
+
+
+my %macros;
+my %Groff =
+  (
+   # preprocessors
+   'chem' => 0,
+   'eqn' => 0,
+   'gperl' => 0,
+   'grap' => 0,
+   'grn' => 0,
+   'gideal' => 0,
+   'gpinyin' => 0,
+   'lilypond' => 0,
+
+   'pic' => 0,
+   'PS' => 0,		# opening for pic
+   'PF' => 0,		# alternative opening for pic
+   'PE' => 0,		# closing for pic
+
+   'refer' => 0,
+   'refer_open' => 0,
+   'refer_close' => 0,
+   'soelim' => 0,
+   'tbl' => 0,
+
+   # tmacs
+#   'man' => 0,
+#   'mandoc' => 0,
+#   'mdoc' => 0,
+#   'mdoc_old' => 0,
+#   'me' => 0,
+#   'mm' => 0,
+#   'mom' => 0,
+#   'ms' => 0,
+
+   # requests
+   'AB' => 0,		# ms
+   'AE' => 0,		# ms
+   'AI' => 0,		# ms
+   'AU' => 0,		# ms
+   'NH' => 0,		# ms
+   'TH_later' => 0,	# TH not 1st command is ms
+   'TL' => 0,		# ms
+   'UL' => 0,		# ms
+   'XP' => 0,		# ms
+
+   'IP' => 0,		# man and ms
+   'LP' => 0,		# man and ms
+   'P' => 0,		# man and ms
+   'PP' => 0,		# man and ms
+   'SH' => 0,		# man and ms
+
+   'OP' => 0,		# man
+   'SS' => 0,		# man
+   'SY' => 0,		# man
+   'TH_first' => 0,	# TH as 1st command is man
+   'TP' => 0,		# man
+   'UR' => 0,		# man
+   'YS' => 0,		# man
+
+   # for mdoc and mdoc-old
+   # .Oo and .Oc for modern mdoc, only .Oo for mdoc-old
+   'Oo' => 0,		# mdoc and mdoc-old
+   'Oc' => 0,		# mdoc
+   'Dd' => 0,		# mdoc
+  ); # end of %Groff
+
+
+# for first line check
+my %preprocs_tmacs =
+  (
+   'chem' => 0,
+   'eqn' => 0,
+   'gideal' => 0,
+   'gpinyin' => 0,
+   'grap' => 0,
+   'grn' => 0,
+   'pic' => 0,
+   'refer' => 0,
+   'soelim' => 0,
+   'tbl' => 0,
+
+   'geqn' => 0,
+   'gpic' => 0,
+   'neqn' => 0,
+
+   'man' => 0,
+   'mandoc' => 0,
+   'mdoc' => 0,
+   'mdoc-old' => 0,
+   'me' => 0,
+   'mm' => 0,
+   'mom' => 0,
+   'ms' => 0,
+  );
+
+my @filespec;
+
+my $tmac_ext = '';
+
+
+########################################################################
+# err()
+########################################################################
+
+sub err {
+  my $text = shift;
+  print STDERR $text;
+}
+
+
+########################################################################
+# handle_args()
+########################################################################
+
+sub handle_args {
+  my $double_minus = 0;
+  my $was_minus = 0;
+  my $was_T = 0;
+  my $optarg = 0;
+  # globals: @filespec, @Command, @devices, @Mparams
+
+  foreach my $arg (@ARGV) {
+
+    if ( $optarg ) {
+      push @Command, $arg;
+      $optarg = 0;
+      next;
+    }
+
+    if ( $double_minus ) {
+      if (-f $arg && -r $arg) {
+	push @filespec, $arg;
+      } else {
+	print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	  "grog: $arg is not a readable file.";
+      }
+      next;
+    }
+
+    if ( $was_T ) {
+      push @devices, $arg;
+      $was_T = 0;
+      next;
+    }
+####### handle_args()
+
+    unless ( $arg =~ /^-/ ) { # file name, no opt, no optarg
+      unless (-f $arg && -r $arg) {
+	print 'unknown file name: ' . $arg;
+      }
+      push @filespec, $arg;
+      next;
+    }
+
+    # now $arg starts with `-'
+
+    if ($arg eq '-') {
+      unless ($was_minus) {
+	push @filespec, $arg;
+	$was_minus = 1;
+      }
+      next;
+    }
+
+    if ($arg eq '--') {
+      $double_minus = 1;
+      push(@filespec, $arg);
+      next;
+    }
+
+    &version() if $arg =~ /^--?v/;	# --version, with exit
+    &help() if $arg  =~ /--?h/;		# --help, with exit
+
+    if ( $arg =~ /^--r/ ) {		#  --run, no exit
+      $do_run = 1;
+      next;
+    }
+
+    if ( $arg =~ /^--wa/ ) {		#  --warnings, no exit
+      $with_warnings = 1;
+      next;
+    }
+####### handle_args()
+
+    if ( $arg =~ /^--(wi|l)/ ) { # --ligatures, no exit
+      # the old --with_ligatures is only kept for compatibility
+      $pdf_with_ligatures = 1;
+      next;
+    }
+
+    if ($arg =~ /^-m/) {
+      push @Mparams, $arg;
+      next;
+    }
+
+    if ($arg =~ /^-T$/) {
+      $was_T = 1;
+      next;
+    }
+
+    if ($arg =~ s/^-T(\w+)$/$1/) {
+      push @devices, $1;
+      next;
+    }
+
+    if ($arg =~ /^-(\w)(\w*)$/) {	# maybe a groff option
+      my $opt_char = $1;
+      my $opt_char_with_arg = $opt_char . ':';
+      my $others = $2;
+      if ( $groff_opts =~ /$opt_char_with_arg/ ) {	# groff optarg
+	if ( $others ) {	# optarg is here
+	  push @Command, '-' . $opt_char;
+	  push @Command, '-' . $others;
+	  next;
+	}
+	# next arg is optarg
+	$optarg = 1;
+	next;
+####### handle_args()
+      } elsif ( $groff_opts =~ /$opt_char/ ) {	# groff no optarg
+	push @Command, '-' . $opt_char;
+	if ( $others ) {	# $others is now an opt collection
+	  $arg = '-' . $others;
+	  redo;
+	}
+	# arg finished
+	next;
+      } else {		# not a groff opt
+	print STDERR __FILE__ . ' '  . __LINE__ . ': ' .
+	  'unknown argument ' . $arg;
+	push(@Command, $arg);
+	next;
+      }
+    }
+  }
+  @filespec = ('-') unless (@filespec);
+} # handle_args()
+
+
+
+########################################################################
+# handle_file_ext()
+########################################################################
+
+sub handle_file_ext {
+  # get tmac from file name extension
+  # output number of found single tmac
+
+  # globals: @filespec, $tmac_ext;
+
+  foreach my $file ( @filespec ) {
+    # test for each file name in the arguments
+    unless ( open(FILE, $file eq "-" ? $file : "< $file") ) {
+      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	"$Prog: can't open \`$file\': $!";
+      next;
+    }
+
+    next unless ( $file =~ /\./ ); # file name has no dot `.'
+
+##### handle_file_ext()
+    # get extension
+    my $ext = $file;
+    $ext =~ s/^
+	      .*
+	      \.
+	      ([^.]*)
+	      $
+	     /$1/x;
+    next unless ( $ext );
+
+##### handle_file_ext()
+    # these extensions are correct, but not based on a tmac
+    next if ( $ext =~ /^(
+			 chem|
+			 eqn|
+			 g|
+			 grap|
+			 grn|
+			 groff|
+			 hdtbl|
+			 pdfroff|
+			 pic|
+			 pinyin|
+			 ref|
+			 roff|
+			 t|
+			 tbl|
+			 tr|
+			 www
+		       )$/x );
+
+##### handle_file_ext()
+    # extensions for man tmac
+    if ( $ext =~ /^(
+		      [1-9lno]|
+		      man|
+		      n|
+		      1b
+		    )$/x ) {
+      # `man|n' from `groff' source
+      # `1b' from `heirloom'
+      # `[1-9lno]' from man-pages
+      if ( $tmac_ext && $tmac_ext ne 'man' ) {
+	# found tmac is not 'man'
+	print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	  '2 different file name extensions found ' .
+	    $tmac_ext . ' and ' . $ext;
+	$tmac_ext = '';
+	next;
+      }
+
+##### handle_file_ext()
+      $tmac_ext = 'man';
+      next;
+    }
+
+    if ( $ext =~ /^(
+		    mandoc|
+		    mdoc|
+		    me|
+		    mm|
+		    mmse|
+		    mom|
+		    ms|
+		    $)/x ) {
+      if ( $tmac_ext && $tmac_ext ne $ext ) {
+	# found tmac is not identical to former found tmac
+##### handle_file_ext()
+	print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	  '2 different file name extensions found ' .
+	    $tmac_ext . ' and ' . $ext;
+	$tmac_ext = '';
+	next;
+      }
+
+      $tmac_ext = $ext;
+      next;
+    }
+
+    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+      'Unknown file name extension '. $file . '.';
+    next;
+  } # end foreach file
+
+  1;
+} # handle_file_ext()
+
+
+########################################################################
+# handle_whole_files()
+########################################################################
+
+sub handle_whole_files {
+  # globals: @filespec
+
+  foreach my $file ( @filespec ) {
+    unless ( open(FILE, $file eq "-" ? $file : "< $file") ) {
+      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	"$Prog: can't open \`$file\': $!";
+      next;
+    }
+    my $line = <FILE>; # get single line
+
+    unless ( defined($line) ) {
+      # empty file, go to next filearg
+      close (FILE);
+      next;
+    }
+
+    if ( $line ) {
+      chomp $line;
+      unless ( &do_first_line( $line, $file ) ) {
+	# not an option line
+	&do_line( $line, $file );
+      }
+    } else { # empty line
+      next;
+    }
+
+    while (<FILE>) { # get lines by and by
+      chomp;
+      &do_line( $_, $file );
+    }
+    close(FILE);
+  } # end foreach
+} # handle_whole_files()
+
+
+########################################################################
+# do_first_line()
+########################################################################
+
+# As documented for the `man' program, the first line can be
+# used as a groff option line.  This is done by:
+# - start the line with '\" (apostrophe, backslash, double quote)
+# - add a space character
+# - a word using the following characters can be appended: `egGjJpRst'.
+#     Each of these characters means an option for the generated
+#     `groff' command line, e.g. `-t'.
+
+sub do_first_line {
+  my ( $line, $file ) = @_;
+
+  # globals: %preprocs_tmacs
+
+  # For a leading groff options line use only [egGjJpRst]
+  if  ( $line =~ /^[.']\\"[\segGjJpRst]+&/ ) {
+    # this is a groff options leading line
+    if ( $line =~ /^\./ ) {
+      # line is a groff options line with . instead of '
+      print "First line in $file must start with an apostrophe \ " .
+	"instead of a period . for groff options line!";
+    }
+
+    if ( $line =~ /j/ ) {
+      $Groff{'chem'}++;
+    }
+    if ( $line =~ /e/ ) {
+      $Groff{'eqn'}++;
+    }
+    if ( $line =~ /g/ ) {
+      $Groff{'grn'}++;
+    }
+    if ( $line =~ /G/ ) {
+      $Groff{'grap'}++;
+    }
+    if ( $line =~ /i/ ) {
+      $Groff{'gideal'}++;
+    }
+    if ( $line =~ /p/ ) {
+      $Groff{'pic'}++;
+    }
+    if ( $line =~ /R/ ) {
+      $Groff{'refer'}++;
+    }
+    if ( $line =~ /s/ ) {
+      $Groff{'soelim'}++;
+    }
+####### do_first_line()
+    if ( $line =~ /t/ ) {
+      $Groff{'tbl'}++;
+    }
+    return 1;	# a leading groff options line, 1 means yes, 0 means no
+  }
+
+  # not a leading short groff options line
+
+  return 0 if ( $line !~ /^[.']\\"\s*(.*)$/ );	# ignore non-comments
+
+  return 0 unless ( $1 );	# for empty comment
+
+  # all following array members are either preprocs or 1 tmac
+  my @words = split '\s+', $1;
+
+  my @in = ();
+  my $word;
+  for $word ( @words ) {
+    if ( $word eq 'ideal' ) {
+      $word = 'gideal';
+    } elsif ( $word eq 'gpic' ) {
+      $word = 'pic';
+    } elsif ( $word =~ /^(gn|)eqn$/ ) {
+      $word = 'eqn';
+    }
+    if ( exists $preprocs_tmacs{$word} ) {
+      push @in, $word;
+    } else {
+      # not word for preproc or tmac
+      return 0;
+    }
+  }
+
+  for $word ( @in ) {
+    $Groff{$word}++;
+  }
+} # do_first_line()
+
+
+########################################################################
+# do_line()
+########################################################################
+
+my $before_first_command = 1; # for check of .TH
+
+sub do_line {
+  my ( $line, $file ) = @_;
+
+  return if ( $line =~ /^[.']\s*\\"/ );	# comment
+
+  return unless ( $line =~ /^[.']/ );	# ignore text lines
+
+  $line =~ s/^['.]\s*/./;	# let only a dot as leading character,
+				# remove spaces after the leading dot
+  $line =~ s/\s+$//;		# remove final spaces
+
+  return if ( $line =~ /^\.$/ );	# ignore .
+  return if ( $line =~ /^\.\.$/ );	# ignore ..
+
+  if ( $before_first_command ) { # so far without 1st command
+    if ( $line =~ /^\.TH/ ) {
+      # check if .TH is 1st command for man
+      $Groff{'TH_first'} = 1 if ( $line =~ /^\.\s*TH/ );
+    }
+    if ( $line =~ /^\./ ) {
+      $before_first_command = 0;
+    }
+  }
+
+  # split command
+  $line =~ /^(\.\w+)\s*(.*)$/;
+  my $command = $1;
+  $command = '' unless ( defined $command );
+  my $args = $2;
+  $args = '' unless ( defined $args );
+
+
+  ######################################################################
+  # soelim
+  if ( $line =~ /^\.(do)?\s*(so|mso|PS\s*<|SO_START).*$/ ) {
+    # `.so', `.mso', `.PS<...', `.SO_START'
+    $Groff{'soelim'}++;
+    return;
+  }
+  if ( $line =~ /^\.(do)?\s*(so|mso|PS\s*<|SO_START).*$/ ) {
+    # `.do so', `.do mso', `.do PS<...', `.do SO_START'
+    $Groff{'soelim'}++;
+    return;
+  }
+####### do_line()
+
+  ######################################################################
+  # macros
+
+  if ( $line =~ /^\.de1?\W?/ ) {
+    # this line is a macro definition, add it to %macros
+    my $macro = $line;
+    $macro =~ s/^\.de1?\s+(\w+)\W*/.$1/;
+    return if ( exists $macros{$macro} );
+    $macros{$macro} = 1;
+    return;
+  }
+
+
+  # if line command is a defined macro, just ignore this line
+  return if ( exists $macros{$command} );
+
+
+  ######################################################################
+  # preprocessors
+
+  if ( $command =~ /^(\.cstart)|(begin\s+chem)$/ ) {
+    $Groff{'chem'}++;		# for chem
+    return;
+  }
+  if ( $command =~ /^\.EQ$/ ) {
+    $Groff{'eqn'}++;		# for eqn
+    return;
+  }
+  if ( $command =~ /^\.G1$/ ) {
+    $Groff{'grap'}++;		# for grap
+    return;
+  }
+  if ( $command =~ /^\.Perl/ ) {
+    $Groff{'gperl'}++;		# for gperl
+    return;
+  }
+  if ( $command =~ /^\.pinyin/ ) {
+    $Groff{'gpinyin'}++;		# for gperl
+    return;
+  }
+  if ( $command =~ /^\.GS$/ ) {
+    $Groff{'grn'}++;		# for grn
+    return;
+  }
+  if ( $command =~ /^\.IS$/ ) {
+    $Groff{'gideal'}++;		# preproc gideal for ideal
+    return;
+  }
+  if ( $command =~ /^\.lilypond$/ ) {
+    $Groff{'lilypond'}++;	# for glilypond
+    return;
+  }
+
+####### do_line()
+
+  # pic can be opened by .PS or .PF and closed by .PE
+  if ( $command =~ /^\.PS$/ ) {
+    $Groff{'pic'}++;		# normal opening for pic
+    return;
+  }
+  if ( $command =~ /^\.PF$/ ) {
+    $Groff{'PF'}++;		# alternate opening for pic
+    return;
+  }
+  if ( $command =~ /^\.PE$/ ) {
+    $Groff{'PE'}++;		# closing for pic
+    return;
+  }
+
+  if ( $command =~ /^\.R1$/ ) {
+    $Groff{'refer'}++;		# for refer
+    return;
+  }
+  if ( $command =~ /^\.\[$/ ) {
+    $Groff{'refer_open'}++;	# for refer open
+    return;
+  }
+  if ( $command =~ /^\.\]$/ ) {
+    $Groff{'refer_close'}++;	# for refer close
+    return;
+  }
+  if ( $command =~ /^\.TS$/ ) {
+    $Groff{'tbl'}++;		# for tbl
+    return;
+  }
+  if ( $command =~ /^\.TH$/ ) {
+    unless ( $Groff{'TH_first'} ) {
+      $Groff{'TH_later'}++;		# for tbl
+    }
+    return;
+  }
+
+
+  ######################################################################
+  # macro package (tmac)
+  ######################################################################
+
+  ##########
+  # modern mdoc
+
+  if ( $command =~ /^\.(Dd)$/ ) {
+    $Groff{'Dd'}++;		# for modern mdoc
+    return;
+  }
+
+####### do_line()
+  # In the old version of -mdoc `Oo' is a toggle, in the new it's
+  # closed by `Oc'.
+  if ( $command =~ /^\.Oc$/ ) {
+    $Groff{'Oc'}++;		# only for modern mdoc
+    return;
+  }
+
+
+  ##########
+  # old and modern mdoc
+
+  if ( $command =~ /^\.Oo$/ ) {
+    $Groff{'Oo'}++;		# for mdoc and mdoc-old
+    return;
+  }
+
+
+  ##########
+  # old mdoc
+  if ( $command =~ /^\.(Tp|Dp|De|Cx|Cl)$/ ) {
+    $Groff{'mdoc_old'}++;	# true for old mdoc
+    return;
+  }
+
+
+  ##########
+  # for ms
+
+####### do_line()
+  if ( $command =~ /^\.AB$/ ) {
+    $Groff{'AB'}++;		# for ms
+    return;
+  }
+  if ( $command =~ /^\.AE$/ ) {
+    $Groff{'AE'}++;		# for ms
+    return;
+  }
+  if ( $command =~ /^\.AI$/ ) {
+    $Groff{'AI'}++;		# for ms
+    return;
+  }
+  if ( $command =~ /^\.AU$/ ) {
+    $Groff{'AU'}++;		# for ms
+    return;
+  }
+  if ( $command =~ /^\.NH$/ ) {
+    $Groff{'NH'}++;		# for ms
+    return;
+  }
+  if ( $command =~ /^\.TL$/ ) {
+    $Groff{'TL'}++;		# for ms
+    return;
+  }
+  if ( $command =~ /^\.XP$/ ) {
+    $Groff{'XP'}++;		# for ms
+    return;
+  }
+
+
+  ##########
+  # for man and ms
+
+  if ( $command =~ /^\.IP$/ ) {
+    $Groff{'IP'}++;		# for man and ms
+    return;
+  }
+  if ( $command =~ /^\.LP$/ ) {
+    $Groff{'LP'}++;		# for man and ms
+    return;
+  }
+####### do_line()
+  if ( $command =~ /^\.P$/ ) {
+    $Groff{'P'}++;		# for man and ms
+    return;
+  }
+  if ( $command =~ /^\.PP$/ ) {
+    $Groff{'PP'}++;		# for man and ms
+    return;
+  }
+  if ( $command =~ /^\.SH$/ ) {
+    $Groff{'SH'}++;		# for man and ms
+    return;
+  }
+  if ( $command =~ /^\.UL$/ ) {
+    $Groff{'UL'}++;		# for man and ms
+    return;
+  }
+
+
+  ##########
+  # for man only
+
+  if ( $command =~ /^\.OP$/ ) {	# for man
+    $Groff{'OP'}++;
+    return;
+  }
+  if ( $command =~ /^\.SS$/ ) {	# for man
+    $Groff{'SS'}++;
+    return;
+  }
+  if ( $command =~ /^\.SY$/ ) {	# for man
+    $Groff{'SY'}++;
+    return;
+  }
+  if ( $command =~ /^\.TP$/ ) {	# for man
+    $Groff{'TP'}++;
+    return;
+  }
+  if ( $command =~ /^\.UR$/ ) {
+    $Groff{'UR'}++;		# for man
+    return;
+  }
+  if ( $command =~ /^\.YS$/ ) {	# for man
+   $Groff{'YS'}++;
+    return;
+  }
+####### do_line()
+
+
+  ##########
+  # me
+
+  if ( $command =~ /^\.(
+		      [ilnp]p|
+		      sh
+		    )$/x ) {
+    $Groff{'me'}++;		# for me
+    return;
+  }
+
+
+  #############
+  # mm and mmse
+
+  if ( $command =~ /^\.(
+		      H|
+		      MULB|
+		      LO|
+		      LT|
+		      NCOL|
+		      P\$|
+		      PH|
+		      SA
+		    )$/x ) {
+    $Groff{'mm'}++;		# for mm and mmse
+    if ( $command =~ /^\.LO$/ ) {
+      if ( $args =~ /^(DNAMN|MDAT|BIL|KOMP|DBET|BET|SIDOR)/ ) {
+	$Groff{'mmse'}++;	# for mmse
+      }
+    } elsif ( $command =~ /^\.LT$/ ) {
+      if ( $args =~ /^(SVV|SVH)/ ) {
+	$Groff{'mmse'}++;	# for mmse
+      }
+    }
+    return;
+  }
+####### do_line()
+
+  ##########
+  # mom
+
+  if ( $line =~ /^\.(
+		   ALD|
+		   DOCTYPE|
+		   FAMILY|
+		   FT|
+		   FAM|
+		   LL|
+		   LS|
+		   NEWPAGE|
+		   PAGE|
+		   PAPER|
+		   PRINTSTYLE|
+		   PT_SIZE|
+		   T_MARGIN
+		 )$/x ) {
+    $Groff{'mom'}++;		# for mom
+    return;
+  }
+
+} # do_line()
+
+
+########################################################################
+# sub make_groff_device
+########################################################################
+
+my @m = ();
+my @preprograms = ();
+my $correct_tmac = '';
+
+sub make_groff_device {
+  # globals: @devices
+
+  # default device is empty, i.e. it is `ps' when without `-T'
+  my $device = '';
+
+  for my $d ( @devices ) {
+    if ( $d =~			# suitable devices
+	 /^(
+	    dvi|
+	    html|
+	    xhtml|
+	    lbp|
+	    lj4|
+	    ps|
+	    pdf|
+	    ascii|
+	    cp1047|
+	    latin1|
+	    utf8
+	  )$/x ) {
+###### make_groff_device()
+      if ( $device ) {
+	next if ( $device eq $d );
+	print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	  'several different devices given: ' .
+	    $device . ' and ' .$d;
+	$device = $d;	# the last provided device is taken
+	next;
+      } else { # empty $device
+	$device = $d;
+	next;
+      }
+    } else {		# not suitable device
+      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	'not a suitable device for groff: ' . $d;
+      next;
+    }
+
+    if ( $device ) {
+      push @Command, '-T';
+      push @Command, $device;
+    }
+  }
+
+###### make_groff_device()
+  if ( $device eq 'pdf' ) {
+    if ( $pdf_with_ligatures ) {	# with --ligature argument
+      push( @Command, '-P-y' );
+      push( @Command, '-PU' );
+    } else {	# no --ligature argument
+      if ( $with_warnings ) {
+	print STDERR <<EOF;
+If you have trouble with ligatures like `fi' in the `groff' output, you
+can proceed as one of
+- add `grog' option `--with_ligatures' or
+- use the `grog' option combination `-P-y -PU' or
+- try to remove the font named similar to `fonts-texgyre' from your system.
+EOF
+      }	# end of warning
+    }	# end of ligature
+  }	# end of pdf device
+} # make_groff_device()
+
+
+########################################################################
+# make_groff_preproc()
+########################################################################
+
+sub make_groff_preproc {
+  # globals: %Groff, @preprograms, @Command
+
+  # preprocessors without `groff' option
+  if ( $Groff{'lilypond'} ) {
+    push @preprograms, 'glilypond';
+  }
+  if ( $Groff{'gperl'} ) {
+    push @preprograms, 'gperl';
+  }
+  if ( $Groff{'gpinyin'} ) {
+    push @preprograms, 'gpinyin';
+  }
+
+  # preprocessors with `groff' option
+  if ( ( $Groff{'PS'} ||  $Groff{'PF'} ) &&  $Groff{'PE'} ) {
+    $Groff{'pic'} = 1;
+  }
+  if ( $Groff{'gideal'} ) {
+    $Groff{'pic'} = 1;
+  }
+
+###### make_groff_preproc()
+  $Groff{'refer'} ||= $Groff{'refer_open'} && $Groff{'refer_close'};
+
+  if ( $Groff{'chem'} || $Groff{'eqn'} ||  $Groff{'gideal'} ||
+       $Groff{'grap'} || $Groff{'grn'} || $Groff{'pic'} ||
+       $Groff{'refer'} || $Groff{'tbl'} ) {
+    push(@Command, '-s') if $Groff{'soelim'};
+
+    push(@Command, '-R') if $Groff{'refer'};
+
+    push(@Command, '-t') if $Groff{'tbl'};	# tbl before eqn
+    push(@Command, '-e') if $Groff{'eqn'};
+
+    push(@Command, '-j') if $Groff{'chem'};	# chem produces pic code
+    push(@Command, '-J') if $Groff{'gideal'};	# gideal produces pic
+    push(@Command, '-G') if $Groff{'grap'};
+    push(@Command, '-g') if $Groff{'grn'};	# gremlin files for -me
+    push(@Command, '-p') if $Groff{'pic'};
+
+  }
+} # make_groff_preproc()
+
+
+########################################################################
+# make_groff_tmac_man_ms()
+########################################################################
+
+sub make_groff_tmac_man_ms {
+  # globals: @filespec, $tmac_ext, %Groff
+
+  # `man' requests, not from `ms'
+  if ( $Groff{'SS'} || $Groff{'SY'} || $Groff{'OP'} ||
+       $Groff{'TH_first'} || $Groff{'TP'} || $Groff{'UR'} ) {
+    $Groff{'man'} = 1;
+    push(@m, '-man');
+
+    $tmac_ext = 'man' unless ( $tmac_ext );
+    &err('man requests found, but file name extension ' .
+	 'was: ' . $tmac_ext) unless ( $tmac_ext eq 'man' );
+    $tmac_ext = 'man';
+    return 1;	# true
+  }
+
+###### make_groff_tmac_man_ms()
+  # `ms' requests, not from `man'
+  if (
+      $Groff{'1C'} || $Groff{'2C'} ||
+      $Groff{'AB'} || $Groff{'AE'} || $Groff{'AI'} || $Groff{'AU'} ||
+      $Groff{'BX'} || $Groff{'CD'} || $Groff{'DA'} || $Groff{'DE'} ||
+      $Groff{'DS'} || $Groff{'ID'} || $Groff{'LD'} || $Groff{'NH'} ||
+      $Groff{'TH_later'} ||
+      $Groff{'TL'} || $Groff{'UL'} || $Groff{'XP'}
+     ) {
+    $Groff{'ms'} = 1;
+    push(@m, '-ms');
+
+    $tmac_ext = 'ms' unless ( $tmac_ext );
+    &err('ms requests found, but file name extension ' .
+	 'was: ' . $tmac_ext) unless ( $tmac_ext eq 'ms' );
+    $tmac_ext = 'ms';
+    return 1;	# true
+  }
+
+###### make_groff_tmac_man_ms()
+
+  # both `man' and `ms' requests
+  if ( $Groff{'P'} || $Groff{'IP'}  ||
+       $Groff{'LP'} || $Groff{'PP'} || $Groff{'SH'} ) {
+    if ( $tmac_ext eq 'man' ) {
+      $Groff{'man'} = 1;
+      push(@m, '-man');
+      return 1;	# true
+    } elsif ( $tmac_ext eq 'ms' ) {
+      $Groff{'ms'} = 1;
+      push(@m, '-ms');
+      return 1;	# true
+    }
+    return 0;
+  }
+} # make_groff_tmac_man_ms()
+
+
+
+########################################################################
+# make_groff_tmac_others()
+########################################################################
+
+sub make_groff_tmac_others {
+  # globals: @filespec, $tmac_ext, %Groff
+
+  # mdoc
+  if ( ( $Groff{'Oo'} && $Groff{'Oc'} ) || $Groff{'Dd'} ) {
+    $Groff{'Oc'} = 0;
+    $Groff{'Oo'} = 0;
+    push(@m, '-mdoc');
+    return 1;	# true
+  }
+  if ( $Groff{'mdoc_old'} || $Groff{'Oo'} ) {
+    push(@m, '-mdoc_old');
+    return 1;	# true
+  }
+
+  # me
+  if ( $Groff{'me'} ) {
+    push(@m, '-me');
+    return 1;	# true
+  }
+
+##### make_groff_tmac_others()
+  # mm and mmse
+  if ( $Groff{'mm'} ) {
+    push(@m, '-mm');
+    return 1;	# true
+  }
+  if ( $Groff{'mmse'} ) {	# Swedish mm
+    push(@m, '-mmse');
+    return 1;	# true
+  }
+
+  # mom
+  if ( $Groff{'mom'} ) {
+    push(@m, '-mom');
+    return 1;	# true
+  }
+} # make_groff_tmac_others()
+
+
+########################################################################
+# make_groff_line_rest()
+########################################################################
+
+sub make_groff_line_rest {
+  my $file_args_included;	# file args now only at 1st preproc
+  unshift @Command, 'groff';
+  if ( @preprograms ) {
+    my @progs;
+    $progs[0] = shift @preprograms;
+    push(@progs, @filespec);
+    for ( @preprograms ) {
+      push @progs, '|';
+      push @progs, $_;
+    }
+    push @progs, '|';
+    unshift @Command, @progs;
+    $file_args_included = 1;
+  } else {
+    $file_args_included = 0;
+  }
+
+  foreach (@Command) {
+    next unless /\s/;
+    # when one argument has several words, use accents
+    $_ = "'" . $_ . "'";
+  }
+
+
+  ##########
+  # -m arguments
+  my $nr_m_guessed = scalar @m;
+  if ( $nr_m_guessed > 1 ) {
+    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+      'argument for -m found: ' . @m;
+  }
+
+###### make_groff_line()
+
+  my $nr_m_args = scalar @Mparams;	# m-arguments for grog
+  my $last_m_arg = '';	# last provided -m option
+  if ( $nr_m_args > 1 ) {
+    # take the last given -m argument of grog call,
+    # ignore other -m arguments and the found ones
+    $last_m_arg = $Mparams[-1];	# take the last -m argument
+    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+      $Prog . ": more than 1 `-m' argument: @Mparams";
+    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+      'We take the last one: ' . $last_m_arg;
+  } elsif ( $nr_m_args == 1 ) {
+    $last_m_arg = $Mparams[0];
+  }
+
+  my $final_m = '';
+  if ( $last_m_arg ) {
+    my $is_equal = 0;
+    for ( @m ) {
+      if ( $_ eq $last_m_arg ) {
+	$is_equal = 1;
+	last;
+      }
+      next;
+    }	# end for @m
+    if ( $is_equal ) {
+      $final_m = $last_m_arg;
+    } else {
+      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	'Provided -m argument ' . $last_m_arg .
+	  ' differs from guessed -m args: ' . @m;
+      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	'The argument is taken.';
+      $final_m = $last_m_arg;
+    }
+###### make_groff_line()
+  } else {	# no -m arg provided
+    if ( $nr_m_guessed > 1 ) {
+      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
+	'More than 1 -m arguments were guessed: ' . @m;
+      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' . 'Guessing stopped.';
+      exit 1;
+    } elsif ( $nr_m_guessed == 1 ) {
+      $final_m = $m[0];
+    } else {
+      # no -m provided or guessed
+    }
+  }
+  push @Command, $final_m if ( $final_m );
+
+  push(@Command, @filespec) unless ( $file_args_included );
+
+  #########
+  # execute the `groff' command here with option `--run'
+  if ( $do_run ) { # with --run
+    print STDERR __FILE__ . ' ' .  __LINE__ . ': ' . "@Command";
+    my $cmd = join ' ', @Command;
+    system($cmd);
+  } else {
+    print "@Command";
+  }
+
+  exit 0;
+} # make_groff_line()
+
+
+########################################################################
+# sub help
+########################################################################
+
+sub help {
+  print <<EOF;
+usage: grog [option]... [--] [filespec]...
+
+"filespec" is either the name of an existing, readable file or "-" for
+standard input.  If no `filespec' is specified, standard input is
+assumed automatically.  All arguments after a `--' are regarded as file
+names, even if they start with a `-' character.
+
+`option' is either a `groff' option or one of these:
+
+-h|--help	print this uasge message and exit
+-v|--version	print version information and exit
+
+-C		compatibility mode
+--ligatures	include options `-P-y -PU' for internal font, which
+		preserverses the ligatures like `fi'
+--run		run the checked-out groff command
+--warnings	display more warnings to standard error
+
+All other options should be `groff' 1-character options.  These are then
+appended to the generated `groff' command line.  The `-m' options will
+be checked by `grog'.
+
+EOF
+  exit 0;
+} # help()
+
+
+########################################################################
+# sub version
+########################################################################
+
+sub version {
+  our %at_at;
+  print "Perl version of GNU $Prog " .
+    "in groff version " . $at_at{'GROFF_VERSION'};
+  exit 0;
+} # version()
+
+
+1;
+########################################################################
+### Emacs settings
+# Local Variables:
+# mode: CPerl
+# End:


From MAILER-DAEMON Thu Jul 23 09:31:26 2015
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1ZIGas-00068j-NO
	for mharc-groff-commit@gnu.org; Thu, 23 Jul 2015 09:31:26 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:53300)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bernd.warken@web.de>) id 1ZIGaq-00067p-6q
	for groff-commit@gnu.org; Thu, 23 Jul 2015 09:31:25 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bernd.warken@web.de>) id 1ZIGak-00062d-Ax
	for groff-commit@gnu.org; Thu, 23 Jul 2015 09:31:24 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:59180)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bernd.warken@web.de>) id 1ZIGak-00062Z-8c
	for groff-commit@gnu.org; Thu, 23 Jul 2015 09:31:18 -0400
Received: from bwarken by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <bernd.warken@web.de>) id 1ZIGaf-0002tj-Hu
	for groff-commit@gnu.org; Thu, 23 Jul 2015 13:31:16 +0000
Date: Thu, 23 Jul 2015 13:31:13 +0000
Message-Id: <E1ZIGaf-0002tj-Hu@vcs.savannah.gnu.org>
To: groff-commit@gnu.org
Subject: [groff] 01/01: man/groff.man: add info in "See Also"
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
In-Reply-To: groff@gnu.org
References: <20150723133113.11104.16582@vcs.savannah.gnu.org>
X-Git-Repo: groff
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Rev: 9837b71d6270e1777242e964272ba7635d48863d
Auto-Submitted: auto-generated
From: Bernd Warken <bernd.warken@web.de>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: groff-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: groff@gnu.org
List-Id: <groff-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/groff-commit>,
	<mailto:groff-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/groff-commit>
List-Post: <mailto:groff-commit@gnu.org>
List-Help: <mailto:groff-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/groff-commit>,
	<mailto:groff-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 23 Jul 2015 13:31:25 -0000

bwarken pushed a commit to branch master
in repository groff.

commit 9837b71d6270e1777242e964272ba7635d48863d
Author: Bernd Warken <groff-bernd.warken-72@web.de>
Date:   Thu Jul 23 15:30:59 2015 +0200

    man/groff.man: add info in "See Also"
---
 ChangeLog     |    5 +++++
 man/groff.man |   25 +++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0a51b5d..108c942 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-07-23  Bernd Warken  <groff-bernd.warken-72@web.de>
+
+	* man/groff.man: Add last update.  Add link on Wikipedia on groff.
+	Add link of groff tutorial by Laha.
+
 2015-07-19  Bernd Warken  <groff-bernd.warken-72@web.de>
 
 	* src/roff/grog/*.pl: Add last update.
diff --git a/man/groff.man b/man/groff.man
index df9e495..ed53ca1 100644
--- a/man/groff.man
+++ b/man/groff.man
@@ -13,7 +13,9 @@ groff \- a short reference for the GNU roff language
 .de co
 This file is part of groff, the GNU roff type-setting system.
 
-Copyright \(co 2000-2014 Free Software Foundation, Inc.
+Copyright \(co 2000-2015 Free Software Foundation, Inc.
+
+Last update: 23 Jul 2015
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -4541,7 +4543,7 @@ be reproduced, and say which version of groff you are using.
 .\" --------------------------------------------------------------------
 .
 The main source of information for the groff language is the
-.B groff
+.I groff
 .BR info (1)
 file.
 .
@@ -4579,6 +4581,25 @@ Nroff/\:Troff User\[aq]s Manual by Ossanna & Kernighan
 .UE
 \[em] the bible for classical troff.
 .
+.TP
+.I Wikipedia
+article about
+.I groff
+.UR https://en.wikipedia.org/wiki/Groff_%28software%29
+.UE .
+.
+.TP
+.I Tutorial about groff
+.UR dl.dropbox.com/u/4299293/grofftut.pdf
+Manas Laha - An Introduction to the GNU Groff Text Processing System
+.UE
+.
+.TP
+.I troff.org
+This is a collection of internet sites with classical
+.I roff
+documentations and other information.
+.
 .
 .\" --------------------------------------------------------------------
 .SH COPYING


From MAILER-DAEMON Sun Jul 26 20:56:35 2015
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1ZJWiZ-0004EZ-Je
	for mharc-groff-commit@gnu.org; Sun, 26 Jul 2015 20:56:35 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:38072)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <peter@schaffter.ca>) id 1ZJWiW-0004EI-Qy
	for groff-commit@gnu.org; Sun, 26 Jul 2015 20:56:33 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <peter@schaffter.ca>) id 1ZJWiV-0008Dj-Ld
	for groff-commit@gnu.org; Sun, 26 Jul 2015 20:56:32 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:53131)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <peter@schaffter.ca>) id 1ZJWiV-0008DV-Hv
	for groff-commit@gnu.org; Sun, 26 Jul 2015 20:56:31 -0400
Received: from PTPi by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <peter@schaffter.ca>) id 1ZJWiU-0005gN-LH
	for groff-commit@gnu.org; Mon, 27 Jul 2015 00:56:30 +0000
Date: Mon, 27 Jul 2015 00:56:30 +0000
Message-Id: <E1ZJWiU-0005gN-LH@vcs.savannah.gnu.org>
To: groff-commit@gnu.org
Subject: [groff] 01/01: Fix for issue of some part-by-part formatting
	changes to headers not being recognized when global header options have
	been invoked.
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
In-Reply-To: groff@gnu.org
References: <20150727005630.21812.11473@vcs.savannah.gnu.org>
X-Git-Repo: groff
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Rev: aa24e0e974244a027922dee54ad56752250399fd
Auto-Submitted: auto-generated
From: Peter Schaffter <peter@schaffter.ca>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: groff-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: groff@gnu.org
List-Id: <groff-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/groff-commit>,
	<mailto:groff-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/groff-commit>
List-Post: <mailto:groff-commit@gnu.org>
List-Help: <mailto:groff-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/groff-commit>,
	<mailto:groff-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 27 Jul 2015 00:56:34 -0000

PTPi pushed a commit to branch master
in repository groff.

commit aa24e0e974244a027922dee54ad56752250399fd
Author: Peter Schaffter <peter@schaffter.ca>
Date:   Sun Jul 26 20:52:38 2015 -0400

    Fix for issue of some part-by-part formatting changes to headers not
    being recognized when global header options have been invoked.
---
 contrib/mom/BUGS      |    8 ++++++++
 contrib/mom/ChangeLog |    4 ++++
 contrib/mom/om.tmac-u |   43 +++++++++++++++++++++++++++++++++++--------
 3 files changed, 47 insertions(+), 8 deletions(-)

diff --git a/contrib/mom/BUGS b/contrib/mom/BUGS
index 197d728..7bb753a 100644
--- a/contrib/mom/BUGS
+++ b/contrib/mom/BUGS
@@ -22,8 +22,16 @@ Also, please--no html email.  That, too, gets nuked.
 
 ====================================================================
 
+Version 2.1-a
+=============
+
+Some part-by-part formatting changes to headers not being recognized
+when global header options have been invoked.
+---Fixed---
+
 Version 2.1
 ===========
+
 UNDERSCORE adding an extra space after underlined text.
 ---Fixed---
 
diff --git a/contrib/mom/ChangeLog b/contrib/mom/ChangeLog
index 56085a3..8b87800 100644
--- a/contrib/mom/ChangeLog
+++ b/contrib/mom/ChangeLog
@@ -1,3 +1,7 @@
+* Sun Jul 26 2015
+
+	o Fix to header part-by-part changes.
+
 * Mon Apr 27 2015
 
 	o version 2.1-a release (see NEWS)
diff --git a/contrib/mom/om.tmac-u b/contrib/mom/om.tmac-u
index 70172e9..d0c1089 100644
--- a/contrib/mom/om.tmac-u
+++ b/contrib/mom/om.tmac-u
@@ -5170,15 +5170,16 @@ y\R'#DESCENDER \\n[.cdp]'
 .\" See if ELEMENT is of the form HDRFTR_<pos>_<param>
 .       substring hdrftr-pos-element 0 7
 .       substring hdrftr-pos-element -1
-.       if '\\*[hdrftr-pos-element]'L' .nr hdrftr-pos-element 1
-.       if '\\*[hdrftr-pos-element]'C' .nr hdrftr-pos-element 1
-.       if '\\*[hdrftr-pos-element]'R' .nr hdrftr-pos-element 1
+.       if !'\\*[ELEMENT]'HDRFTR_COLOR' \{\
+.          if '\\*[hdrftr-pos-element]'L' .nr hdrftr-pos-element 1
+.          if '\\*[hdrftr-pos-element]'C' .nr hdrftr-pos-element 1
+.          if '\\*[hdrftr-pos-element]'R' .nr hdrftr-pos-element 1
+.       \}
 .    \}
 .    if !\\n[hdrftr-pos-element] \{\
 .       ds c1-c5 \\*[ELEMENT]
 .       substring c1-c5 0 4  \" Grab first five letters of the alias
 .    \}
-.    rr hdrftr-pos-element
 .\"  If none of the following, convert the substring of the
 .\"  calling alias, ie \*[ELEMENT], into the parameter string, eg
 .\"  $TITLE_FAM, assign arg, and set register.
@@ -5208,6 +5209,15 @@ y\R'#DESCENDER \\n[.cdp]'
 .       if '\\*[c1-c5]'LINEN' .ASSIGN_PARAM LN_       \\$1
 .       if '\\*[c1-c5]'PAGEN' .ASSIGN_PARAM PAGE_NUM_ \\$1
 .    \}
+.    if \\n[hdrftr-pos-element] \{\
+.       if '\\*[hdrftr-pos-element]'L' .ds hdrftr-pos-element LEFT
+.       if '\\*[hdrftr-pos-element]'C' .ds hdrftr-pos-element CENTER
+.       if '\\*[hdrftr-pos-element]'R' .ds hdrftr-pos-element RIGHT
+.       if '\\*[ELEMENT]'HDRFTR_\\*[hdrftr-pos-element]_FAM' \
+.          ds $HDRFTR_\\*[hdrftr-pos-element]_FAM \\$1
+.    \}
+.    rr hdrftr-pos-element
+.    rm hdrftr-pos-element
 .END
 \#
 .MAC ASSIGN_PARAM END
@@ -5234,17 +5244,34 @@ y\R'#DESCENDER \\n[.cdp]'
 .    if '\\$1'EPI_' .rm ELEMENT
 .    if '\\$1'FN_'  .rm ELEMENT
 .    if '\\$1'HDRFTR_' \{\
-.       ie '\\*[ELEMENT]'HDRFTR_FAM' \{\
+.       if '\\*[ELEMENT]'HDRFTR_FAM' \{\
 .          nr #HDRFTR 1
 .          ds $HDRFTR_FAM        \\$2
 .          ds $HDRFTR_LEFT_FAM   \\$2
 .          ds $HDRFTR_CENTER_FAM \\$2
 .          ds $HDRFTR_RIGHT_FAM  \\$2
 .       \}
-.       el \{\
+.       if '\\*[ELEMENT]'HDRFTR_COLOR' \{\
+.          nr #HDRFTR 1
+.          nr #HDRFTR_COLOR 1
+.          ds $HDRFTR_COLOR \\$2
+.       \}
+.       if '\\*[ELEMENT]'HDRFTR_SIZE_CHANGE' \{\
+.          nr #HDRFTR 1
+.          ds $HDRFTR_SIZE_CHANGE \\$2
+.       \}
+.       if '\\*[PARAM]'SIZE_CHANGE' \{\
+.          nr #HDRFTR 1
+.          if '\\*[hdrftr-pos-element]'L' \
+.             ds $HDRFTR_LEFT_SIZE_CHANGE \\$2
+.          if '\\*[hdrftr-pos-element]'C' \
+.             ds $HDRFTR_CENTER_SIZE_CHANGE \\$2
+.          if '\\*[hdrftr-pos-element]'R' \
+.             ds $HDRFTR_RIGHT_SIZE_CHANGE \\$2
+.       \}
+.       if !r #HDRFTR \{\
 .          substring ELEMENT 7 \\n[substr-index]
-.          if '\\*[ELEMENT]'_LEFT' \
-.             ds ELEMENT _STRING_
+.          if '\\*[ELEMENT]'_LEFT' .ds ELEMENT _STRING_
 .       \}
 .    \}
 .    if '\\$1'LN_'       .rm ELEMENT


From MAILER-DAEMON Thu Jul 30 04:01:42 2015
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1ZKimb-0003j1-VG
	for mharc-groff-commit@gnu.org; Thu, 30 Jul 2015 04:01:41 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:40024)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bernd.warken@web.de>) id 1ZKimZ-0003hk-88
	for groff-commit@gnu.org; Thu, 30 Jul 2015 04:01:40 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bernd.warken@web.de>) id 1ZKimX-0006zB-Rd
	for groff-commit@gnu.org; Thu, 30 Jul 2015 04:01:39 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:46336)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bernd.warken@web.de>) id 1ZKimX-0006yZ-OZ
	for groff-commit@gnu.org; Thu, 30 Jul 2015 04:01:37 -0400
Received: from bwarken by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <bernd.warken@web.de>) id 1ZKim0-00022t-Va
	for groff-commit@gnu.org; Thu, 30 Jul 2015 08:01:30 +0000
Date: Thu, 30 Jul 2015 08:01:05 +0000
Message-Id: <E1ZKim0-00022t-Va@vcs.savannah.gnu.org>
To: groff-commit@gnu.org
Subject: [groff] 01/01: grog: add -T in all output, including -Tps for default.
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
In-Reply-To: groff@gnu.org
References: <20150730080102.7550.41295@vcs.savannah.gnu.org>
X-Git-Repo: groff
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Rev: 01896f04028f1962e69314257dd542c6539a0e73
Auto-Submitted: auto-generated
From: Bernd Warken <bernd.warken@web.de>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: groff-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: groff@gnu.org
List-Id: <groff-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/groff-commit>,
	<mailto:groff-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/groff-commit>
List-Post: <mailto:groff-commit@gnu.org>
List-Help: <mailto:groff-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/groff-commit>,
	<mailto:groff-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 30 Jul 2015 08:01:40 -0000

bwarken pushed a commit to branch master
in repository groff.

commit 01896f04028f1962e69314257dd542c6539a0e73
Author: Bernd Warken <groff-bernd.warken-72@web.de>
Date:   Thu Jul 30 10:00:07 2015 +0200

    grog: add -T in all output, including -Tps for default.
---
 ChangeLog              |    7 ++++++
 src/roff/grog/grog.man |   19 +++++++++++++---
 src/roff/grog/subs.pl  |   55 ++++++++++++++++++++---------------------------
 3 files changed, 45 insertions(+), 36 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 108c942..810106f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-07-29  Bernd Warken  <groff-bernd.warken-72@web.de>
+
+	* src/roff/grog/subs.pl: Add -T for all `grog' output, also using
+	-Tps when no option -T is given in the arguments.
+
+	* src/roff/grog/grog.man: Add information about -T output.
+
 2015-07-23  Bernd Warken  <groff-bernd.warken-72@web.de>
 
 	* man/groff.man: Add last update.  Add link on Wikipedia on groff.
diff --git a/src/roff/grog/grog.man b/src/roff/grog/grog.man
index 4609155..386d28b 100644
--- a/src/roff/grog/grog.man
+++ b/src/roff/grog/grog.man
@@ -12,7 +12,9 @@ grog \(em guess options for a following groff command
 .\" --------------------------------------------------------------------
 .
 .de co
-Copyright \(co 1989-2014 Free Software Foundation, Inc.
+Copyright \(co 1989-2015 Free Software Foundation, Inc.
+
+Last update: 29 Jul 2015
 
 This file is part of grog, which is part of groff, a free software
 project.  You can redistribute it and/or modify it under the terms of
@@ -64,10 +66,12 @@ Bernd Warken
 .
 .SY grog
 .OP \-C
+.OP \-T device
 .OP \-\-run
 .OP \-\-warnings
 .OP \-\-ligatures
-.OP \& "\%groff\-option \*(EL"
+.OP \& "\%groff\-option no arg"
+.OP \& "\%groff\-option with arg \*(EL"
 .OP \-\-
 .OP \& "\%filespec \*(EL"
 .YS
@@ -89,8 +93,12 @@ options are needed to perform the input with the
 .B groff
 program.
 .
+A suitable device is now always written as
+.BI -T device
+including the groff default as
+.BR "-T ps" .
+.
 .
-.RS
 .P
 The corresponding
 .B groff
@@ -102,7 +110,10 @@ the generated line is output into standard error and the generated
 .B groff
 command is run on the
 .IR "standard output" .
-.RE
+.
+.BR groffer (@MAN1EXT@)
+relies on a perfectly running
+.BR groff (@MAN1EXT@).
 .
 .
 .\" --------------------------------------------------------------------
diff --git a/src/roff/grog/subs.pl b/src/roff/grog/subs.pl
index 06121b8..c2a5aee 100644
--- a/src/roff/grog/subs.pl
+++ b/src/roff/grog/subs.pl
@@ -12,7 +12,7 @@
 # The macros for identifying the devices were taken from Ralph
 # Corderoy's `grog.sh' of 2006.
 
-# Last update: 19 Jul 2015
+# Last update: 29 Jul 2015
 
 # This file is part of `grog', which is part of `groff'.
 
@@ -58,7 +58,8 @@ my $groff_opts =
 
 my @Command = ();		# stores the final output
 my @Mparams = ();		# stores the options `-m*'
-my @devices = ();
+my @devices = ();		# stores -T
+
 my $do_run = 0;			# run generated `groff' command
 my $pdf_with_ligatures = 0;	# `-P-y -PU' for `pdf' device
 my $with_warnings = 0;
@@ -901,42 +902,32 @@ my $correct_tmac = '';
 sub make_groff_device {
   # globals: @devices
 
-  # default device is empty, i.e. it is `ps' when without `-T'
-  my $device = '';
+  # default device is `ps' when without `-T'
+  my $device;
+  push @devices, 'ps' unless ( @devices );
 
+###### make_groff_device()
   for my $d ( @devices ) {
-    if ( $d =~			# suitable devices
-	 /^(
-	    dvi|
-	    html|
-	    xhtml|
-	    lbp|
-	    lj4|
-	    ps|
-	    pdf|
-	    ascii|
-	    cp1047|
-	    latin1|
-	    utf8
-	  )$/x ) {
+    if ( $d =~ /^(		# suitable devices
+		  dvi|
+		  html|
+		  xhtml|
+		  lbp|
+		  lj4|
+		  ps|
+		  pdf|
+		  ascii|
+		  cp1047|
+		  latin1|
+		  utf8
+		)$/x ) {
 ###### make_groff_device()
-      if ( $device ) {
-	next if ( $device eq $d );
-	print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	  'several different devices given: ' .
-	    $device . ' and ' .$d;
-	$device = $d;	# the last provided device is taken
-	next;
-      } else { # empty $device
-	$device = $d;
-	next;
-      }
-    } else {		# not suitable device
-      print STDERR __FILE__ . ' ' .  __LINE__ . ': ' .
-	'not a suitable device for groff: ' . $d;
+      $device = $d;
+    } else {
       next;
     }
 
+
     if ( $device ) {
       push @Command, '-T';
       push @Command, $device;


