[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #65763] strictly compare strings in macro packages
From: |
G. Branden Robinson |
Subject: |
[bug #65763] strictly compare strings in macro packages |
Date: |
Tue, 4 Jun 2024 23:21:42 -0400 (EDT) |
Update of bug #65763 (group groff):
Summary: Do actual string comparisons in macro packages =>
strictly compare strings in macro packages
_______________________________________________________
Follow-up Comment #1:
I suspect this may be low priority, perhaps so low that it's not worth doing,
because _as deployed_, all of _groff_'s full-service macro packages are
prepared to format documents using the basic Latin character set.
I'm also still a bit undecided whether we should have a syntactically sweeter
way of doing string comparisons.
Here's a proof of concept I did back when discussing this issue with Deri.
It's pretty simple. It grabs the symbol '~' for use as an operator in a
conditional expression and then uses the same infrastructure that's already in
place to handle `\?`.
$ git stash show -p 1
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 8d828a01e..7288f31c5 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -6002,6 +6002,25 @@ static bool do_if_request()
}
result = is_abstract_style(nm);
}
+ else if (c == '~') {
+ tok.next();
+ symbol nm1 = get_name(true /* required */);
+ symbol nm2 = get_name(true /* required */);
+ if ((nm1.is_null() || nm2.is_null())) {
+ skip_branch();
+ return false;
+ }
+ macro *rm1 = static_cast<macro *>(request_dictionary.lookup(nm1));
+ macro *rm2 = static_cast<macro *>(request_dictionary.lookup(nm2));
+ macro *m1 = rm1->to_macro();
+ macro *m2 = rm2->to_macro();
+ if ((0 /* nullptr */ == m1) || (0 /* nullptr */ == m2)) {
+ error("cannot perform equality comparison on a request");
+ skip_branch();
+ return false;
+ }
+ result = (*m1 == *m2);
+ }
else if (tok.is_space())
result = false;
else if (tok.is_usable_as_delimiter()) {
Not sure what the best way forward is. I suggest that nothing about it is a
priority for 1.24.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?65763>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [bug #65763] strictly compare strings in macro packages,
G. Branden Robinson <=
- Message not available
- Message not available