Update of bug #68497 (group groff):
Status: Need Info => Duplicate
Open/Closed: Open => Closed
_______________________________________________________
Follow-up Comment #23:
Thanks for the correction, Dave.
After considerable more time in a Vagrant OpenIndiana container, I have
re-confirmed that this report is a duplicate of bug #68256.
Commenting out the `bd` in Solaris's "an" macro file is not sufficient to
resolve the issue because the `cs` request handler in _groff_ 1.24 has the
same problem. And your bug reproducer employs the `cs` request.
Here is the fix for bug #68256, backported to _groff_ 1.24.1.
$ git diff
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 90880c3..6f33163 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1282,6 +1282,10 @@ static void select_stroke_color_request()
static symbol P_symbol("P");
// Select font with name or mounting position `s`.
+//
+// TODO: This duplicates logic from node.cpp:read_font_identifier().
+// Refactor. Need read_font_mounting_position_or_identifier(), storing
+// the resolved mounting position in an argument.
void select_font(symbol s)
{
bool is_number = true;
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index f3d9642..8173c32 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -6970,28 +6970,60 @@ bool is_valid_font_mounting_position(int n)
// Read the next token and look it up as a font name or position number.
// Return lookup success. Store, in the supplied struct argument, the
// requested name or position, and the position actually resolved.
+//
+// TODO: This duplicates logic from env.cpp:select_font(). Refactor.
+// Need read_font_mounting_position_or_identifier(), storing the
+// resolved mounting position in an argument.
static bool read_font_identifier(font_lookup_info *finfo)
{
- int n;
tok.skip_spaces();
- if (tok.is_usable_as_delimiter()) {
- symbol s = read_identifier(true /* required */);
+ // Painful. We read the whole argument as a symbol, then see if it's
+ // interpretable as an (unsigned) decimal integer. If is, we treat it
+ // as a mounting position. If not, we treat it as a font "name".
+ symbol s = read_identifier();
+ bool is_number = true;
+ assert(!s.is_null() && !s.is_empty());
+ if (!s.is_null() && !s.is_empty()) {
+ const char *p = s.contents();
+ assert(*p != 0 /* nullptr */);
+ // Silently ignore a leading minus sign so we can issue a range
+ // warning later.
+ if ((csdigit(*p)) || ('-' == *p))
+ p++;
+ for (; (p != 0 /* nullptr */) && (*p != '\0'); p++) {
+ if (!csdigit(*p)) {
+ is_number = false;
+ break;
+ }
+ }
+ }
+ if (is_number) {
+ errno = 0;
+ long val = strtol(s.contents(), NULL, 10);
+ if ((ERANGE == errno) || (val > INT_MAX) || (val < 0)) {
+ warning(WARN_RANGE, "font mounting position must be in range"
+ " 0..%1, got %2", INT_MAX, s.contents());
+ return false;
+ }
+ int mp = int(val);
+ if (!is_valid_font_mounting_position(mp)) {
+ warning(WARN_FONT, "no font mounted at position %1", mp);
+ return false;
+ }
+ finfo->position = curenv->get_family()->resolve(mp);
+ }
+ else {
finfo->requested_name = const_cast<char *>(s.contents());
if (!s.is_null()) {
- n = symbol_fontno(s);
- if (n < 0) {
- n = next_available_font_position();
- if (mount_font(n, s))
- finfo->position = n;
+ int mp = symbol_fontno(s);
+ if (mp < 0) {
+ mp = next_available_font_position();
+ if (mount_font(mp, s))
+ finfo->position = mp;
}
- finfo->position = curenv->get_family()->resolve(n);
+ finfo->position = curenv->get_family()->resolve(mp);
}
}
- else if (read_integer(&n)) {
- finfo->requested_position = n;
- if (is_valid_font_mounting_position(n))
- finfo->position = curenv->get_family()->resolve(n);
- }
return (finfo->position != FONT_NOT_MOUNTED);
}
Here's evidence of successful operation, using your reproducer and the
foregoing patch.
$ ./build/amd64/test-groff -Ca -man ~/9.l
<beginning of page>
BES(LOCAL) CADP MANUAL PAGES BES(LOCAL)
NAME
bes, BES <-> text file format for Boolean Equation Systems
BOOLEAN EQUATION SYSTEMS
A BES is a non-empty set of equation blocks. Each block is a (possibly empty)
set of equations. Each equa<hy>
tion contains, on its left-hand side, a boolean variable, and, on its
right-hand side, a boolean formula built us<hy>
ing boolean variables (noted X, X', etc.), constants (true, false), and
binary operators of disjunction (or)
and conjunction (and).
SYNTAX DEFINITION
The textual syntax of BES files is described by the following context-free
grammar, where <empty> denotes
the empty sequence of symbols and <nat> denotes a non-negative integer:
<axiom> ::= <block-list>
<block-list> ::= <block>
| <block> <block-list>
<block> ::= block <sign> <block-idf> <unique> <mode> is
<equation-list>
end block
<sign> ::= mu
| nu
<block-idf> ::= B<nat>
<unique> ::= <empty>
| unique
<mode> ::= <empty>
| mode <nat>
<equation-list> ::= <equation>
| <equation> <equation-list>
<equation> ::= <local-variable-idf> = <formula>
<local-variable-idf> ::= X<nat>
<global-variable-idf> ::= X<nat>_<nat>
<formula> ::= <atomic-form>
| <disjunctive-form>
| <conjunctive-form>
<atomic-form> ::= false
| true
| <local-variable-idf>
| <global-variable-idf>
<disjunctive-form> ::= <atomic-form> or <atomic-form>
(C) INRIA 2021/02/12 1
<beginning of page>
BES(LOCAL) CADP MANUAL PAGES BES(LOCAL)
| <atomic-form> or <disjunctive-form>
<conjunctive-form> ::= <atomic-form> and <atomic-form>
| <atomic-form> and <conjunctive-form>
(C) INRIA 2021/02/12 2
With the foregoing patch applied, commenting out the `bd` request in
_/usr/share/lib/tmac/an_ is unnecessary.
I apologize for the difficulty--this problem will definitely be fixed in
_groff_ 1.25 if the OpenIndiana folks don't want to apply this backported
patch.
Re-closing.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?68497>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
