bug-groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #64155] [troff] specifying -fZD on command line generates warnings


From: G. Branden Robinson
Subject: [bug #64155] [troff] specifying -fZD on command line generates warnings
Date: Tue, 14 May 2024 12:37:20 -0400 (EDT)

Follow-up Comment #42, bug #64155 (group groff):

So here's what got lost last week.

I did in fact implement a string comparison conditional operator in GNU
_troff_ in my working copy.

And it worked.


$ 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()) {


But I immediately thought better of it.

1.  We already have 


.if '\?foo\?'\?bar\?' .tm strings are equal


2.  The `\?` escape sequence is already a GNU _troff_ extension.

3.  I didn't feel good about adding syntactic sugar for this form of
expression.

4.  String comparisons are rare outside of macro files.

5.  Macro files desiring to do string comparisons should decide whether they'd
rather let them be formatted (a popular choice, even in _groff_'s own macro
files) or not.  In most cases there is no harm in performing formatting on the
comparands.  (Where there is, you _must_ use `\?`.)

...

This is growing long.  I will return to it later.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?64155>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]