[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 10/11: [grog]: Use more careful matching patterns.
From: |
G. Branden Robinson |
Subject: |
[groff] 10/11: [grog]: Use more careful matching patterns. |
Date: |
Sat, 31 Jul 2021 10:36:30 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 6a9ebdea349db669c71440394dd2ed04b4c62c15
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Jul 31 19:56:34 2021 +1000
[grog]: Use more careful matching patterns.
* src/utils/grog/grog.pl (do_line): When matching macro/request names,
accept any non-whitespace character (Perl: \S) instead of just a
word-constituent character (Perl: \w), since roff identifiers can
contain unusual characters (refer(1) and groff_me(7) illustrate some
real-world cases).
---
ChangeLog | 8 ++++++++
src/utils/grog/grog.pl | 8 ++++----
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index de6c4d2..78bc8bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2021-07-31 G. Branden Robinson <g.branden.robinson@gmail.com>
+ * src/utils/grog/grog.pl (do_line): When matching macro/request
+ names, accept any non-whitespace character (Perl: \S) instead of
+ just a word-constituent character (Perl: \w), since roff
+ identifiers can contain unusual characters (refer(1) and
+ groff_me(7) illustrate some real-world cases).
+
+2021-07-31 G. Branden Robinson <g.branden.robinson@gmail.com>
+
* src/utils/grog/grog.pl: Refactor macro package inference.
- Stop manually populating `Groff` hash. (It's itching for a
rename.)
diff --git a/src/utils/grog/grog.pl b/src/utils/grog/grog.pl
index c083982..b2c9b5b 100644
--- a/src/utils/grog/grog.pl
+++ b/src/utils/grog/grog.pl
@@ -309,7 +309,7 @@ sub do_line {
my $boundary = '\\b';
$boundary = '' if ($use_compatibility_mode);
- if ($line =~ /^\.(\w\w)$boundary/ || $line =~ /^\.(\[)/) {
+ if ($line =~ /^\.(\S\S)$boundary/ || $line =~ /^\.(\[)/) {
my $macro = $1;
# groff identifiers can have extremely weird characters in them.
# The ones we care about are conventionally named, but me(7)
@@ -333,17 +333,17 @@ sub do_line {
# Split control line into a request or macro call and its arguments.
# Handle single-letter macro names.
- if ($line =~ /^\.(\w)(\s+(.*))?$/) {
+ if ($line =~ /^\.(\S)(\s+(.*))?$/) {
$command = $1;
$args = $2;
# Handle two-letter macro/request names in compatibility mode.
} elsif ($use_compatibility_mode) {
- $line =~ /^\.(\w\w)\s*(.*)$/;
+ $line =~ /^\.(\S\S)\s*(.*)$/;
$command = $1;
$args = $2;
# Handle multi-letter macro/request names in groff mode.
} else {
- $line =~ /^\.(\w+)(\s+(.*))?$/;
+ $line =~ /^\.(\S+)(\s+(.*))?$/;
$command = $1;
$args = $3;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 10/11: [grog]: Use more careful matching patterns.,
G. Branden Robinson <=