gbranden pushed a commit to branch master
in repository groff.
commit b17d0699e5b79f77fb1c20dc8792a9389ebe70fe
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Aug 2 04:49:35 2025 -0500
[afmtodit]: Add `-q` command-line option.
* src/utils/afmtodit/afmtodit.pl: Add `-q` command-line option to
suppress diagnostics reporting duplicate mappings in favor of a count
thereof. Add new `opt_q` and `duplicate_mappings_count` scalars.
Update `GetOptions()` call. Implement the logic. _Don't_ report the
flag in the header of the generated file. If the option was given and
any duplicate mappings were encountered, report the count to the
standard error stream before exiting.
* src/utils/afmtodit/afmtodit.1.man (Options, Diagnostics): Document it.
---
ChangeLog | 13 +++++++++++++
src/utils/afmtodit/afmtodit.1.man | 18 ++++++++++++++++--
src/utils/afmtodit/afmtodit.pl | 25 ++++++++++++++++++-------
3 files changed, 47 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 820754f0d..f935786c8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2025-08-02 G. Branden Robinson <[email protected]>
+
+ * src/utils/afmtodit/afmtodit.pl: Add `-q` command-line option
+ to suppress diagnostics reporting duplicate mappings in favor of
+ a count thereof. Add new `opt_q` and `duplicate_mappings_count`
+ scalars. Update `GetOptions()` call. Implement the logic.
+ _Don't_ report the flag in the header of the generated file.
+ If the option was given and any duplicate mappings were
+ encountered, report the count to the standard error stream
+ before exiting.
+ * src/utils/afmtodit/afmtodit.1.man (Options, Diagnostics):
+ Document it.
+
2025-08-02 G. Branden Robinson <[email protected]>
* src/utils/afmtodit/afmtodit.pl: Trivially refactor, renaming
diff --git a/src/utils/afmtodit/afmtodit.1.man
b/src/utils/afmtodit/afmtodit.1.man
index f7111e5b1..aa4766526 100644
--- a/src/utils/afmtodit/afmtodit.1.man
+++ b/src/utils/afmtodit/afmtodit.1.man
@@ -9,7 +9,7 @@ PostScript and PDF output
.\" Legal Terms
.\" ====================================================================
.\"
-.\" Copyright (C) 1989-2024 Free Software Foundation, Inc.
+.\" Copyright (C) 1989-2025 Free Software Foundation, Inc.
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
@@ -52,7 +52,7 @@ PostScript and PDF output
.\" ====================================================================
.
.SY afmtodit
-.RB [ \-ckmnsx ]
+.RB [ \-ckmnqsx ]
.RB [ \-a\~\c
.IR slant ]
.RB [ \-d\~\c
@@ -469,6 +469,12 @@ use with monospaced (constant-width) fonts.
.
.
.TP
+.B \-q
+Quieten duplicate mapping warnings;
+see section \[lq]Diagnostics\[rq] below.
+.
+.
+.TP
.B \-s
Add the
.B special
@@ -607,6 +613,14 @@ and re-run
using it.
.
.
+.IP
+When the
+.B \-q
+option is used,
+these messages are suppressed in favor of a count of how many
+would have been emitted were the option not present.
+.
+.
.\" ====================================================================
.SH "See also"
.\" ====================================================================
diff --git a/src/utils/afmtodit/afmtodit.pl b/src/utils/afmtodit/afmtodit.pl
index ec746538c..602329fbf 100644
--- a/src/utils/afmtodit/afmtodit.pl
+++ b/src/utils/afmtodit/afmtodit.pl
@@ -33,11 +33,11 @@ my $want_help;
my $space_width = 0;
our ($opt_a, $opt_c, $opt_d, $opt_e, $opt_f, $opt_i, $opt_k,
- $opt_m, $opt_n, $opt_o, $opt_s, $opt_v, $opt_w, $opt_x);
+ $opt_m, $opt_n, $opt_o, $opt_q, $opt_s, $opt_v, $opt_w, $opt_x);
use Getopt::Long qw(:config gnu_getopt);
GetOptions( "a=s", "c", "d=s", "e=s", "f=s", "i=s", "k", "m", "n",
- "o=s", "s", "v", "w=i", "x", "version" => \$opt_v,
+ "o=s", "q", "s", "v", "w=i", "x", "version" => \$opt_v,
"help" => \$want_help
);
@@ -361,7 +361,7 @@ $filename = "";
$lineno = 0;
$italic_angle = $opt_a if $opt_a;
-
+my $duplicate_mappings_count = 0; # used only if $opt_q
if (!$opt_x) {
my %mapped;
@@ -375,10 +375,15 @@ if (!$opt_x) {
if ($nmap{$ch}) {
for (my $j = 0; $j < $nmap{$ch}; $j++) {
if (defined $mapped{$map{$ch, $j}}) {
- print STDERR "$program_name: AGL name"
- . " '$mapped{$map{$ch, $j}}' already mapped to"
- . " groff name '$map{$ch, $j}'; ignoring AGL"
- . " name '$ch'\n";
+ if ($opt_q) {
+ $duplicate_mappings_count++;
+ }
+ else {
+ print STDERR "$program_name: AGL name"
+ . " '$mapped{$map{$ch, $j}}' already mapped"
+ . " to groff name '$map{$ch, $j}'; ignoring"
+ . " AGL name '$ch'\n";
+ }
}
else {
$mapped{$map{$ch, $j}} = $ch;
@@ -532,6 +537,7 @@ push @options, "-k" if defined $opt_k;
push @options, "-m" if defined $opt_m;
push @options, "-n" if defined $opt_n;
push @options, "-o $opt_o" if defined $opt_o;
+# Don't add $opt_q here; it is irrelevant to the generated file.
push @options, "-s" if defined $opt_s;
push @options, "-v" if defined $opt_v;
push @options, "-w $opt_w" if defined $opt_w;
@@ -720,6 +726,11 @@ for (my $i = 0; $i <= $#encoding; $i++) {
}
}
+if ($opt_q && $duplicate_mappings_count) {
+ print STDERR "$program_name: $duplicate_mappings_count duplicate"
+ . "mappings encountered";
+}
+
sub conv {
$_[0]*$unitwidth*$resolution/(72*1000*$sizescale)
+ ($_[0] < 0 ? -.5 : .5);
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit