gbranden pushed a commit to branch master
in repository groff.
commit 017739fe4c0e9c8fbbbd5a1275f04a59466c45cb
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Jun 23 13:25:27 2024 -0500
[grog]: Trivially refactor (move `@request`).
* src/utils/grog/grog.pl: Relocate declaration of huge list `request`
closer to its point of use.
---
ChangeLog | 5 +++++
src/utils/grog/grog.pl | 50 +++++++++++++++++++++++++-------------------------
2 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 06e44cd7e..3a7faa085 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-06-23 G. Branden Robinson <[email protected]>
+
+ * src/utils/grog/grog.pl: Trivially refactor. Relocate
+ declaration of huge list `request` closer to its point of use.
+
2024-06-23 G. Branden Robinson <[email protected]>
* src/utils/grog/grog.pl: Trivially refactor. Rename scalar
diff --git a/src/utils/grog/grog.pl b/src/utils/grog/grog.pl
index 980b1ab16..5171e7a8d 100644
--- a/src/utils/grog/grog.pl
+++ b/src/utils/grog/grog.pl
@@ -285,6 +285,31 @@ sub interpret_line {
# If the line calls a user-defined macro, skip it.
return if (exists $user_macro{$command});
+ # Add user-defined macro names to %user_macro.
+ #
+ # Macros can also be defined with .dei{,1}, ami{,1}, but supporting
+ # that would be a heavy lift for the benefit of users that probably
+ # don't require grog's help. --GBR
+ if ($command =~ /^(de|am)1?$/) {
+ my $name = $args;
+ # Strip off any end macro.
+ $name =~ s/\s+.*$//;
+ # Handle special cases of macros starting with '[' or ']'.
+ if ($name =~ /^[][]/) {
+ delete $preprocessor_for_macro{'['};
+ }
+ # XXX: If the macro name shadows a standard macro name, maybe we
+ # should delete the latter from our lists and hashes. This might
+ # depend on whether the document is trying to remain compatible
+ # with an existing interface, or simply colliding with names they
+ # don't care about (consider a raw roff document that defines 'PP').
+ # --GBR
+ $user_macro{$name} = 0 unless (exists $user_macro{$name});
+ return;
+ }
+
+ # XXX: Handle .rm as well?
+
# These are all requests supported by groff 1.24.0.
my @request = ('ab', 'ad', 'af', 'aln', 'als', 'am', 'am1', 'ami',
'ami1', 'as', 'as1', 'asciify', 'backtrace', 'bd',
@@ -314,31 +339,6 @@ sub interpret_line {
'ul', 'unformat', 'vpt', 'vs', 'warn', 'warnscale',
'wh', 'while', 'write', 'writec', 'writem');
- # Add user-defined macro names to %user_macro.
- #
- # Macros can also be defined with .dei{,1}, ami{,1}, but supporting
- # that would be a heavy lift for the benefit of users that probably
- # don't require grog's help. --GBR
- if ($command =~ /^(de|am)1?$/) {
- my $name = $args;
- # Strip off any end macro.
- $name =~ s/\s+.*$//;
- # Handle special cases of macros starting with '[' or ']'.
- if ($name =~ /^[][]/) {
- delete $preprocessor_for_macro{'['};
- }
- # XXX: If the macro name shadows a standard macro name, maybe we
- # should delete the latter from our lists and hashes. This might
- # depend on whether the document is trying to remain compatible
- # with an existing interface, or simply colliding with names they
- # don't care about (consider a raw roff document that defines 'PP').
- # --GBR
- $user_macro{$name} = 0 unless (exists $user_macro{$name});
- return;
- }
-
- # XXX: Handle .rm as well?
-
# Ignore all other requests. Again, macro names can contain Perl
# regex metacharacters, so be careful.
return if (grep(/^\Q$command\E$/, @request));
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit