[groff] 09/14: [troff]: Slightly refactor.

2025-02-21 Thread G. Branden Robinson
gbranden pushed a commit to branch master
in repository groff.

commit 58ebe1d0514fd1a5c0602d4bc190d3e1e78d97ac
Author: G. Branden Robinson 
AuthorDate: Fri Feb 21 15:23:41 2025 -0600

[troff]: Slightly refactor.

Unpublish function that doesn't need to be visible outside its
translation unit.

* src/roff/troff/charinfo.h (get_charinfo_by_number): Move declaration
  from here...
* src/roff/troff/input.cpp (get_charinfo_by_number): ...to here.
  Declare and define it as `static`.
---
 ChangeLog | 10 ++
 src/roff/troff/charinfo.h |  1 -
 src/roff/troff/input.cpp  |  4 +++-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 66920b408..0a0f85faf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2025-02-21  G. Branden Robinson 
+
+   [troff]: Unpublish function that doesn't need to be visible
+   outside its translation unit.
+
+   * src/roff/troff/charinfo.h (get_charinfo_by_number): Move
+   declaration from here...
+   * src/roff/troff/input.cpp (get_charinfo_by_number): ...to here.
+   Declare and define it as `static`.
+
 2025-02-21  G. Branden Robinson 
 
[troff]: Trivially refactor; rename enumerator in `token` `enum`
diff --git a/src/roff/troff/charinfo.h b/src/roff/troff/charinfo.h
index fecd10347..05d785e91 100644
--- a/src/roff/troff/charinfo.h
+++ b/src/roff/troff/charinfo.h
@@ -116,7 +116,6 @@ public:
 
 charinfo *get_charinfo(symbol);
 extern charinfo *charset_table[];
-charinfo *get_charinfo_by_number(int);
 
 inline bool charinfo::overlaps_horizontally()
 {
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 2c401bb3b..d30862a36 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8148,6 +8148,8 @@ void define_class()
   skip_line();
 }
 
+static charinfo *get_charinfo_by_number(int n); // forward declaration
+
 charinfo *token::get_char(bool required)
 {
   if (type == TOKEN_CHAR)
@@ -10209,7 +10211,7 @@ symbol UNNAMED_SYMBOL("---");
 
 dictionary numbered_charinfo_dictionary(11);
 
-charinfo *get_charinfo_by_number(int n)
+static charinfo *get_charinfo_by_number(int n)
 {
   static charinfo *number_table[256];
 

___
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit


[groff] 06/14: [troff]: Recast warning diagnostic.

2025-02-21 Thread G. Branden Robinson
gbranden pushed a commit to branch master
in repository groff.

commit e9c931b9e11a7584a487d1b6884d7a01fc007b7d
Author: G. Branden Robinson 
AuthorDate: Fri Feb 21 02:17:37 2025 -0600

[troff]: Recast warning diagnostic.

* src/roff/troff/input.cpp (token::next): Recast warning diagnostic
  issued when encountering an invalid character index (in an `\N'xxx'`
  escape sequence).
---
 ChangeLog| 6 ++
 src/roff/troff/input.cpp | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index b56a2981b..69476fc22 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-02-21  G. Branden Robinson 
+
+   * src/roff/troff/input.cpp (token::next): Recast warning
+   diagnostic issued when encountering an invalid character index
+   {in an `\N'xxx'` escape sequence}.
+
 2025-02-20  G. Branden Robinson 
 
* src/roff/troff/input.cpp (get_charinfo): Use C++ `static_cast`
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index f06e8a348..1eaf907f2 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2418,7 +2418,8 @@ void token::next()
if (!read_delimited_number(&val, 0))
  break;
if (val < 0) {
- warning(WARN_CHAR, "invalid numbered character %1", val);
+ warning(WARN_CHAR, "ignoring negative character index %1",
+ val);
  break;
}
type = TOKEN_NUMBERED_CHAR;

___
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit


[groff] 13/14: [troff]: Create characters less aggressively.

2025-02-21 Thread G. Branden Robinson
gbranden pushed a commit to branch master
in repository groff.

commit 9a9d7b55b6cc565ed2c065b8e993bdac9fb576d1
Author: G. Branden Robinson 
AuthorDate: Fri Feb 21 04:05:40 2025 -0600

[troff]: Create characters less aggressively.

Make it possible to retrieve information about a *roff character without
creating it as a side effect.

* src/roff/troff/charinfo.h (get_charinfo, get_charinfo_by_index):
* src/roff/troff/token.h (get_char):
* src/roff/troff/input.cpp (get_charinfo_by_index): Add new `bool`
  argument `lookup_only`, defaulting `false`.

* src/roff/troff/input.cpp: Use these new facilities.

  (report_character_request): Prevent creation of each character we look
  up.  Improve diagnostics.  Report information about indexed characters
  (`\N'123'`) more intelligibly.

  (remove_character): Prevent creation of each character we remove.
  Intelligibly report nonexistence of characters for which removal is
  attempted.  Throw error when attempt is made to remove a
  non-character, like `\~`.
---
 ChangeLog | 18 
 src/roff/troff/charinfo.h |  2 +-
 src/roff/troff/input.cpp  | 74 ++-
 src/roff/troff/token.h|  3 +-
 4 files changed, 75 insertions(+), 22 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index afad02463..c03dd90ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2025-02-21  G. Branden Robinson 
+
+   [troff]: Make it possible to retrieve information about a *roff
+   character without creating it as a side effect.
+
+   * src/roff/troff/charinfo.h (get_charinfo):
+   * src/roff/troff/token.h (get_char):
+   * src/roff/troff/input.cpp (get_charinfo_by_index): Add new
+   `bool` argument `lookup_only`, defaulting `false`.
+   * src/roff/troff/input.cpp: Use these new facilities.
+   (report_character_request): Prevent creation of each character
+   we look up.  Improve diagnostics.  Report information about
+   indexed characters (`\N'123'`) more intelligibly.
+   (remove_character): Prevent creation of each character we
+   remove.  Intelligibly report nonexistence of characters for
+   which removal is attempted.  Throw error when attempt is made to
+   remove a non-character, like `\~`.
+
 2025-02-21  G. Branden Robinson 
 
[troff]: Add member functions to `token` class to assist with
diff --git a/src/roff/troff/charinfo.h b/src/roff/troff/charinfo.h
index 05d785e91..93c1ca8a1 100644
--- a/src/roff/troff/charinfo.h
+++ b/src/roff/troff/charinfo.h
@@ -114,7 +114,7 @@ public:
   void dump();
 };
 
-charinfo *get_charinfo(symbol);
+charinfo *get_charinfo(symbol, bool /* lookup_only */ = false);
 extern charinfo *charset_table[];
 
 inline bool charinfo::overlaps_horizontally()
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 54072a520..f67090bef 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -4690,12 +4690,26 @@ static void report_character_request()
   }
   charinfo *ci;
   do {
-ci = tok.get_char();
-if (0 /* nullptr */ == ci)
-  warning(WARN_CHAR, "%1 is not a character", tok.description());
+ci = tok.get_char(false, true /* lookup only */);
+if (!tok.is_character()) {
+  error("character report request expects characters as arguments;"
+   " got %1", tok.description());
+  break;
+}
+if (0 /* nullptr */ == ci) {
+  if (!tok.is_indexed_character())
+   warning(WARN_CHAR, "%1 is not defined", tok.description());
+  else
+   warning(WARN_CHAR, "character with index %1 in the current font"
+   " is not defined", tok.character_index());
+}
 else {
   // A charinfo doesn't know the name by which it is accessed.
-  errprint("%1\n", tok.description());
+  if (tok.is_indexed_character())
+   errprint("character indexed %1 in current font\n",
+tok.character_index());
+  else
+   errprint("%1\n", tok.description());
   fflush(stderr);
   ci->dump();
 }
@@ -4714,12 +4728,27 @@ static void remove_character()
   }
   while (!tok.is_newline() && !tok.is_eof()) {
 if (!tok.is_space() && !tok.is_tab()) {
-  charinfo *ci = tok.get_char(true /* required */);
-  if (0 /* nullptr */ == ci)
+  if (tok.is_character()) {
+   charinfo *ci = tok.get_char(true /* required */,
+   true /* lookup only */);
+   if (0 /* nullptr */ == ci) {
+ if (!tok.is_indexed_character())
+   warning(WARN_CHAR, "%1 is not defined", tok.description());
+ else
+   warning(WARN_CHAR, "character with index %1 in the current"
+   " font is not defined", tok.character_index());
+   }
+   else {
+ macro *m = ci->set_macro(0 /* nullptr */);
+ if (m)
+   delete m;
+   }
+  }
+  else {
+   er

[groff] 05/14: [troff]: Refactor ("static_cast").

2025-02-21 Thread G. Branden Robinson
gbranden pushed a commit to branch master
in repository groff.

commit ae093b98326af1c3cf440dce97cf8b855033ce14
Author: G. Branden Robinson 
AuthorDate: Thu Feb 20 23:00:44 2025 -0600

[troff]: Refactor ("static_cast").

* src/roff/troff/input.cpp (get_charinfo): Use C++ `static_cast`
  operator instead of C-style type cast.

Also annotate null pointer with `nullptr` comment to ease any future
transition to C++11, which defines it as a keyword.
---
 ChangeLog| 5 +
 src/roff/troff/input.cpp | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8690bfbeb..b56a2981b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2025-02-20  G. Branden Robinson 
+
+   * src/roff/troff/input.cpp (get_charinfo): Use C++ `static_cast`
+   operator instead of C-style type cast.
+
 2025-02-08  G. Branden Robinson 
 
* src/roff/troff/input.cpp (interpolate_environment_variable):
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 1a66d242d..f06e8a348 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -9986,8 +9986,8 @@ dictionary charinfo_dictionary(501);
 charinfo *get_charinfo(symbol nm)
 {
   void *p = charinfo_dictionary.lookup(nm);
-  if (p != 0)
-return (charinfo *)p;
+  if (p != 0 /* nullptr */)
+return static_cast(p);
   charinfo *cp = new charinfo(nm);
   (void) charinfo_dictionary.lookup(nm, cp);
   return cp;

___
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit


[groff] 03/14: NEWS: Add caveat regarding quotes in file names.

2025-02-21 Thread G. Branden Robinson
gbranden pushed a commit to branch master
in repository groff.

commit 790dc6688559810b67cd454e0764026703acc537
Author: G. Branden Robinson 
AuthorDate: Thu Feb 20 20:42:52 2025 -0600

NEWS: Add caveat regarding quotes in file names.
---
 NEWS | 20 
 1 file changed, 20 insertions(+)

diff --git a/NEWS b/NEWS
index d9efeb4d5..dee304b13 100644
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,26 @@ Noteworthy incompatible changes
   to tell the formatter to load the "e.tmac" file rather than "e.tmac ".
   See the items below for further details.
 
+* If your roff(7) documents specify a file name that starts with a
+  neutral double quote (") to any of the requests `cf`, `hpf`,
+  `hpfa`, `mso`, `msoquiet`, `nx`, `open`, `opena`, `so`, `soquiet`, or
+  `trf`, you are likely to get a diagnostic message, or the formatter
+  will open a file of the same name except for the leading neutral
+  double quote.  That is because these requests are now able to process
+  file names containing leading space characters.  (This change also
+  makes the request syntax consistent with that of `ds`, `as`, and
+  others.)  The solution is to add an additional neutral double quote to
+  the start of the file name argument.  For example, we would change:
+
+.so "5150".lrc
+
+  to:
+
+.so ""5150".lrc
+
+  to tell the formatter to read a file named '"5150".lrc', where the
+  neutral single quotes bracket the file name.
+
 troff
 -
 

___
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit


[groff] 04/14: eqn(1): Fix content nits.

2025-02-21 Thread G. Branden Robinson
gbranden pushed a commit to branch master
in repository groff.

commit 75ea5f42fbbc06e67f83b6c3f8e2034159d6eed7
Author: G. Branden Robinson 
AuthorDate: Thu Feb 20 20:50:32 2025 -0600

eqn(1): Fix content nits.

* Present Newton's second law with more care.  (Force is the derivative
  of momentum; this is more general than its more widely seen expression
  as the product of mass and acceleration.)
* Drop needless qualification of file name resolution; it is only ever
  relative file specifications that get resolved with respect to a
  Unix process's current working directory.
---
 src/preproc/eqn/eqn.1.man | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/preproc/eqn/eqn.1.man b/src/preproc/eqn/eqn.1.man
index 38c1408fd..baa4c424f 100644
--- a/src/preproc/eqn/eqn.1.man
+++ b/src/preproc/eqn/eqn.1.man
@@ -242,7 +242,7 @@ argument as a pair of equation delimiters.
 .I eqn
 input consists of tokens.
 .
-Consider a form of Newton's second law of motion.
+Consider a form of Newton's second law of motion for constant mass.
 .
 The input
 .
@@ -703,7 +703,6 @@ beginning with
 or
 .BR .EN .
 .
-If a relative path name,
 .I file
 is sought relative to the current working directory.
 .

___
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit


[groff] 12/14: [troff]: Add member functions to `token` class.

2025-02-21 Thread G. Branden Robinson
gbranden pushed a commit to branch master
in repository groff.

commit 025d6604839dafe2d80cde94429d20edde0100a2
Author: G. Branden Robinson 
AuthorDate: Fri Feb 21 03:56:49 2025 -0600

[troff]: Add member functions to `token` class.

...to assist with runtime character analysis.

* src/roff/troff/token.h (class charinfo): Declare new public member
  functions `is_character()`, `is_indexed_character()`, and
  `character_index()`.

  (token::is_character): New function returns whether the object has
  `type` of `TOKEN_CHAR`, `TOKEN_SPECIAL_CHAR`, or `TOKEN_INDEXED_CHAR`.

  (token::is_indexed_character): New function returns whether the object
  has `type` of `TOKEN_INDEXED_CHAR`.

  (token::character_index): New function returns value of `val` private
  member variable.  Throws assertion if token's `type` is not
  `TOKEN_INDEXED_CHAR`.
---
 ChangeLog  | 17 +
 src/roff/troff/token.h | 25 +
 2 files changed, 42 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 87278eaeb..afad02463 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2025-02-21  G. Branden Robinson 
+
+   [troff]: Add member functions to `token` class to assist with
+   runtime character analysis.
+
+   * src/roff/troff/token.h (class charinfo): Declare new public
+   member functions `is_character()`, `is_indexed_character()`, and
+   `character_index()`.
+   (token::is_character): New function returns whether the object
+   has `type` of `TOKEN_CHAR`, `TOKEN_SPECIAL_CHAR`, or
+   `TOKEN_INDEXED_CHAR`.
+   (token::is_indexed_character): New function returns whether the
+   object has `type` of `TOKEN_INDEXED_CHAR`.
+   (token::character_index): New function returns value of `val`
+   private member variable.  Throws assertion if token's `type` is
+   not `TOKEN_INDEXED_CHAR`.
+
 2025-02-21  G. Branden Robinson 
 
[libgroff]: Validate character indices in font description files
diff --git a/src/roff/troff/token.h b/src/roff/troff/token.h
index f6709e7e4..796d2b1bf 100644
--- a/src/roff/troff/token.h
+++ b/src/roff/troff/token.h
@@ -16,6 +16,11 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see . */
 
+#ifdef HAVE_CONFIG_H
+#include 
+#endif
+
+#include 
 
 class charinfo;
 struct node;
@@ -74,7 +79,9 @@ public:
   bool is_unstretchable_space();
   bool is_horizontal_space();
   bool is_white_space();
+  bool is_character();
   bool is_special_character();
+  bool is_indexed_character();
   bool is_newline();
   bool is_tab();
   bool is_leader();
@@ -91,6 +98,7 @@ public:
   bool operator==(const token &); // for delimiters & conditional exprs
   bool operator!=(const token &); // ditto
   unsigned char ch();
+  int character_index();
   charinfo *get_char(bool /* required */ = false);
   bool add_to_zero_width_node_list(node **);
   void make_space();
@@ -192,6 +200,23 @@ inline unsigned char token::ch()
   return type == TOKEN_CHAR ? c : '\0';
 }
 
+inline bool token::is_character()
+{
+  return (TOKEN_CHAR == type) || (TOKEN_SPECIAL_CHAR == type)
+ || (TOKEN_INDEXED_CHAR == type);
+}
+
+inline bool token::is_indexed_character()
+{
+  return TOKEN_INDEXED_CHAR == type;
+}
+
+inline int token::character_index()
+{
+  assert(TOKEN_INDEXED_CHAR == type);
+  return val;
+}
+
 inline bool token::is_eof()
 {
   return type == TOKEN_EOF;

___
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit


[groff] 14/14: [doc,man]: Avoid documentary faceplant.

2025-02-21 Thread G. Branden Robinson
gbranden pushed a commit to branch master
in repository groff.

commit 0d88675983d73a011cd64c986d094cdee5aa2b64
Author: G. Branden Robinson 
AuthorDate: Fri Feb 21 04:19:03 2025 -0600

[doc,man]: Avoid documentary faceplant.

Correct misstatements that crept into descriptions of character
definition and removal requests post-1.23.0 (my fault).  Make further
clarifications and parallelize language between man pages and our
Texinfo manual.
---
 doc/groff.texi.in| 15 +++
 man/groff.7.man  | 32 
 man/groff_diff.7.man | 16 ++--
 3 files changed, 45 insertions(+), 18 deletions(-)

diff --git a/doc/groff.texi.in b/doc/groff.texi.in
index bd470649e..785d9dbed 100644
--- a/doc/groff.texi.in
+++ b/doc/groff.texi.in
@@ -11463,8 +11463,10 @@ on the right doesn't get examined.
 @cindex @code{\e}, and glyph definitions
 @cindex @code{hcode} request, and glyph definitions
 Define an ordinary or special character@tie{}@var{c} as @var{contents}.
-If @var{contents} is absent, an existing character definition made with
-the same request is deleted.
+If
+@var{contents}
+is absent,
+the character is defined with empty contents.
 
 A leading neutral double quote in the second argument is stripped from
 it, allowing embedded leading spaces in @var{contents}, which is read to
@@ -11546,8 +11548,13 @@ request in @ref{Strings}.
 @cindex fallback glyph, removing definition (@code{rchar}, @code{rfschar})
 Remove definition of each ordinary or special character @var{c},
 undoing the effect of a @code{char}, @code{fchar}, or @code{schar}
-request.  Those supplied by font description files cannot be removed.
-Spaces need not separate @var{c}@tie{}arguments.
+request.
+The character definition removed
+(if any)
+is the first encountered in the glyph resolution process documented
+above.
+Those supplied by font description files cannot be removed.
+Spaces need not separate the arguments.
 
 The request @code{rfschar} removes glyph definitions defined with
 @code{fschar} for font@tie{}@var{f}.
diff --git a/man/groff.7.man b/man/groff.7.man
index 2ac7e67ca..9e25a44ac 100644
--- a/man/groff.7.man
+++ b/man/groff.7.man
@@ -2855,8 +2855,9 @@ by moving its location to
 .
 .TPx
 .REQ .char c
-Remove definition of ordinary or special
-.RI character\~ c.
+Define ordinary or special character
+.I c
+as empty.
 .
 .TPx
 .REQ .char "c contents"
@@ -3275,8 +3276,9 @@ and pad glyph to\~\c
 .
 .TPx
 .REQ .fchar c
-Remove definition of fallback
-.RI character\~ c.
+Define fallback
+.RI character\~ c
+as empty.
 .
 .TPx
 .REQ .fchar "c contents"
@@ -3335,10 +3337,11 @@ at non-negative position
 .
 .TPx
 .REQ .fschar "f c"
-Remove definition of fallback
+Define fallback
 .RI character\~ c
 specific to
-.RI font\~ f.
+.RI font\~ f
+as empty.
 .
 .TPx
 .REQ .fschar "f c contents"
@@ -4256,6 +4259,18 @@ or
 .request .schar
 request.
 .
+The character definition removed
+(if any)
+is the first encountered in the glyph resolution process;
+see section \[lq]Using Symbols\[rq] of
+.IR "Groff: The GNU Implementation of troff" .
+.
+Glyphs,
+which are defined by font description files,
+cannot be removed.
+.
+Spaces need not separate the arguments.
+.
 .TPx
 .REQ .rd
 Read insertion from standard input stream,
@@ -4367,8 +4382,9 @@ unit\~\c
 .
 .TPx
 .REQ .schar c
-Remove definition of global fallback
-.RI character\~ c.
+Define global fallback character
+.I c
+as empty.
 .
 .TPx
 .REQ .schar "c contents"
diff --git a/man/groff_diff.7.man b/man/groff_diff.7.man
index fa9130565..5001cf4b3 100644
--- a/man/groff_diff.7.man
+++ b/man/groff_diff.7.man
@@ -2060,7 +2060,7 @@ as
 If
 .I contents
 is absent,
-an existing character definition made with the same request is deleted.
+the character is defined with empty contents.
 .
 .
 .IP
@@ -2144,9 +2144,9 @@ requests take precedence if
 also applies
 .RI to\~ c .
 .
-A character definition can be removed with the
+The
 .B rchar
-request.
+request removes character definitions.
 .
 .
 .TP
@@ -3512,13 +3512,17 @@ or
 .B schar
 request.
 .
+The character definition removed
+(if any)
+is the first encountered in the glyph resolution process;
+see section \[lq]Using Symbols\[rq] of
+.IR "Groff: The GNU Implementation of troff" .
+.
 Glyphs,
 which are defined by font description files,
 cannot be removed.
 .
-Spaces and tabs may separate
-.I c
-arguments.
+Spaces need not separate the arguments.
 .
 .
 .TP

___
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit


[groff] 10/14: [troff]: Trivially refactor (2/2).

2025-02-21 Thread G. Branden Robinson
gbranden pushed a commit to branch master
in repository groff.

commit be95332b1ec2f204ec0b8b12c625b4df91dcb33d
Author: G. Branden Robinson 
AuthorDate: Fri Feb 21 02:47:26 2025 -0600

[troff]: Trivially refactor (2/2).

Rename symbols for clarity.

* src/roff/troff/input.cpp (get_charinfo_by_number): Rename function in
  declaration and definition from this...
  (get_charinfo_by_index): ...to this.

  (token::get_char)
  (token::add_to_zero_width_node_list, token::process)
  (name_to_glyph): Update call sites.

* src/roff/troff/input.cpp: Rename global object of `dictionary` type
  from `numbered_charinfo_dictionary` to `indexed_charinfo_dictionary`.

* src/roff/troff/input.cpp (get_charinfo_by_index): Rename static local
  array of `charinfo` type from `number_table` to `index_table`.
---
 ChangeLog| 17 +
 src/roff/troff/input.cpp | 26 +-
 2 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0a0f85faf..0a66b1632 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2025-02-21  G. Branden Robinson 
+
+   * src/roff/troff/input.cpp (get_charinfo_by_number): Rename
+   function in declaration and definition from this...
+   (get_charinfo_by_index): ...to this.
+   (token::get_char)
+   (token::add_to_zero_width_node_list, token::process)
+   (name_to_glyph): Update call sites.
+
+   * src/roff/troff/input.cpp: Rename global object of `dictionary`
+   type from `numbered_charinfo_dictionary` to
+   `indexed_charinfo_dictionary`.
+
+   * src/roff/troff/input.cpp (get_charinfo_by_index): Rename
+   static local array of `charinfo` type from `number_table` to
+   `index_table`.
+
 2025-02-21  G. Branden Robinson 
 
[troff]: Unpublish function that doesn't need to be visible
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index d30862a36..54072a520 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8148,7 +8148,7 @@ void define_class()
   skip_line();
 }
 
-static charinfo *get_charinfo_by_number(int n); // forward declaration
+static charinfo *get_charinfo_by_index(int n); // forward declaration
 
 charinfo *token::get_char(bool required)
 {
@@ -8157,7 +8157,7 @@ charinfo *token::get_char(bool required)
   if (type == TOKEN_SPECIAL_CHAR)
 return get_charinfo(nm);
   if (type == TOKEN_INDEXED_CHAR)
-return get_charinfo_by_number(val);
+return get_charinfo_by_index(val);
   if (type == TOKEN_ESCAPE) {
 if (escape_char != 0)
   return charset_table[escape_char];
@@ -8235,7 +8235,7 @@ bool token::add_to_zero_width_node_list(node **pp)
 nd = 0 /* nullptr */;
 break;
   case TOKEN_INDEXED_CHAR:
-*pp = (*pp)->add_char(get_charinfo_by_number(val), curenv, &w, &s);
+*pp = (*pp)->add_char(get_charinfo_by_index(val), curenv, &w, &s);
 break;
   case TOKEN_RIGHT_BRACE:
 break;
@@ -8328,7 +8328,7 @@ void token::process()
 nd = 0;
 break;
   case TOKEN_INDEXED_CHAR:
-curenv->add_char(get_charinfo_by_number(val));
+curenv->add_char(get_charinfo_by_index(val));
 break;
   case TOKEN_REQUEST:
 // handled in process_input_stack()
@@ -10206,31 +10206,31 @@ void charinfo::dump()
 
 symbol UNNAMED_SYMBOL("---");
 
-// For numbered characters not between 0 and 255, we make a symbol out
+// For indexed characters not between 0 and 255, we make a symbol out
 // of the number and store them in this dictionary.
 
-dictionary numbered_charinfo_dictionary(11);
+dictionary indexed_charinfo_dictionary(11);
 
-static charinfo *get_charinfo_by_number(int n)
+static charinfo *get_charinfo_by_index(int n)
 {
-  static charinfo *number_table[256];
+  static charinfo *index_table[256];
 
   if (n >= 0 && n < 256) {
-charinfo *ci = number_table[n];
+charinfo *ci = index_table[n];
 if (0 /*nullptr */ == ci) {
   ci = new charinfo(UNNAMED_SYMBOL);
   ci->set_number(n);
-  number_table[n] = ci;
+  index_table[n] = ci;
 }
 return ci;
   }
   else {
 symbol ns(i_to_a(n));
-charinfo *ci = (charinfo *)numbered_charinfo_dictionary.lookup(ns);
+charinfo *ci = (charinfo *)indexed_charinfo_dictionary.lookup(ns);
 if (0 /*nullptr */ == ci) {
   ci = new charinfo(UNNAMED_SYMBOL);
   ci->set_number(n);
-  (void) numbered_charinfo_dictionary.lookup(ns, ci);
+  (void) indexed_charinfo_dictionary.lookup(ns, ci);
 }
 return ci;
   }
@@ -10256,7 +10256,7 @@ glyph *name_to_glyph(const char *nm)
 
 glyph *number_to_glyph(int n)
 {
-  return get_charinfo_by_number(n)->as_glyph();
+  return get_charinfo_by_index(n)->as_glyph();
 }
 
 const char *glyph_to_name(glyph *g)

___
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit


[groff] 08/14: [troff]: Trivially refactor (1/2).

2025-02-21 Thread G. Branden Robinson
gbranden pushed a commit to branch master
in repository groff.

commit 1b69deeeb17c0c82016a85c9c957c63a225a454d
Author: G. Branden Robinson 
AuthorDate: Fri Feb 21 02:22:32 2025 -0600

[troff]: Trivially refactor (1/2).

Rename enumerator in `token` `enum` type from `TOKEN_NUMBERED_CHAR` to
`TOKEN_INDEXED_CHAR`.

* src/roff/troff/token.h (class token): Revise definition.

* src/roff/troff/input.cpp (token::next, token::operator==)
  (token::description, token::get_char)
  (token::add_to_zero_width_node_list, token::process): Update sites of
  use.
---
 ChangeLog| 11 +++
 src/roff/troff/input.cpp | 12 ++--
 src/roff/troff/token.h   |  2 +-
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c3fbcd897..66920b408 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2025-02-21  G. Branden Robinson 
+
+   [troff]: Trivially refactor; rename enumerator in `token` `enum`
+   type from `TOKEN_NUMBERED_CHAR` to `TOKEN_INDEXED_CHAR`.
+
+   * src/roff/troff/token.h (class token): Revise definition.
+   * src/roff/troff/input.cpp (token::next, token::operator==)
+   (token::description, token::get_char)
+   (token::add_to_zero_width_node_list, token::process): Update
+   sites of use.
+
 2025-02-21  G. Branden Robinson 
 
* src/roff/troff/input.cpp (remove_character, get_optional_char)
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index bdfe8c922..2c401bb3b 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2422,7 +2422,7 @@ void token::next()
  val);
  break;
}
-   type = TOKEN_NUMBERED_CHAR;
+   type = TOKEN_INDEXED_CHAR;
return;
   case 'o':
nd = do_overstrike();
@@ -2608,7 +2608,7 @@ bool token::operator==(const token &t)
 return c == t.c;
   case TOKEN_SPECIAL_CHAR:
 return nm == t.nm;
-  case TOKEN_NUMBERED_CHAR:
+  case TOKEN_INDEXED_CHAR:
 return val == t.val;
   default:
 return true;
@@ -2732,7 +2732,7 @@ const char *token::description()
 return "a newline";
   case TOKEN_NODE:
 return "a node";
-  case TOKEN_NUMBERED_CHAR:
+  case TOKEN_INDEXED_CHAR:
 return "an escaped 'N'";
   case TOKEN_RIGHT_BRACE:
 return "an escaped '}'";
@@ -8154,7 +8154,7 @@ charinfo *token::get_char(bool required)
 return charset_table[c];
   if (type == TOKEN_SPECIAL_CHAR)
 return get_charinfo(nm);
-  if (type == TOKEN_NUMBERED_CHAR)
+  if (type == TOKEN_INDEXED_CHAR)
 return get_charinfo_by_number(val);
   if (type == TOKEN_ESCAPE) {
 if (escape_char != 0)
@@ -8232,7 +8232,7 @@ bool token::add_to_zero_width_node_list(node **pp)
 n = nd;
 nd = 0 /* nullptr */;
 break;
-  case TOKEN_NUMBERED_CHAR:
+  case TOKEN_INDEXED_CHAR:
 *pp = (*pp)->add_char(get_charinfo_by_number(val), curenv, &w, &s);
 break;
   case TOKEN_RIGHT_BRACE:
@@ -8325,7 +8325,7 @@ void token::process()
 curenv->add_node(nd);
 nd = 0;
 break;
-  case TOKEN_NUMBERED_CHAR:
+  case TOKEN_INDEXED_CHAR:
 curenv->add_char(get_charinfo_by_number(val));
 break;
   case TOKEN_REQUEST:
diff --git a/src/roff/troff/token.h b/src/roff/troff/token.h
index cb71ea981..f6709e7e4 100644
--- a/src/roff/troff/token.h
+++ b/src/roff/troff/token.h
@@ -43,7 +43,7 @@ class token {
 TOKEN_MARK_INPUT,  // \k
 TOKEN_NEWLINE, // ^J
 TOKEN_NODE,
-TOKEN_NUMBERED_CHAR,   // \N
+TOKEN_INDEXED_CHAR,// \N
 TOKEN_PAGE_EJECTOR,
 TOKEN_REQUEST,
 TOKEN_RIGHT_BRACE, // \}

___
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit


[groff] 01/14: pic(1): Fix incorrect quotation mark characters.

2025-02-21 Thread G. Branden Robinson
gbranden pushed a commit to branch master
in repository groff.

commit 4228245ed8347f0141a09d5124c538465bdef8da
Author: Sebastien Peterson-Boudreau 
AuthorDate: Wed Jan 29 00:57:19 2025 -0400

pic(1): Fix incorrect quotation mark characters.

[I fleshed out the example so that it is a "capsule" example that
renders all by itself (within `PS`/`PE` macros) in a document. --GBR]
---
 src/preproc/pic/pic.1.man | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/preproc/pic/pic.1.man b/src/preproc/pic/pic.1.man
index a15bec176..b98518b50 100644
--- a/src/preproc/pic/pic.1.man
+++ b/src/preproc/pic/pic.1.man
@@ -9,7 +9,7 @@ or TeX
 .\" Legal Terms
 .\" 
 .\"
-.\" Copyright (C) 1989-2024 Free Software Foundation, Inc.
+.\" Copyright (C) 1989-2025 Free Software Foundation, Inc.
 .\"
 .\" Permission is granted to make and distribute verbatim copies of this
 .\" manual provided the copyright notice and this permission notice are
@@ -1286,10 +1286,10 @@ has no effect on objects whose start and end points are 
coincident.
 In places where
 .IB n th
 is allowed,
-.BI \[aq] expr \[aq]th
+.BI \[ga] expr \[aq]th
 is also allowed.
 .
-.RB \[lq] \[aq]th \[lq]
+.RB \[lq] \[aq]th \[rq]
 is a single token:
 no space is allowed between the apostrophe and the
 .RB \[lq] th \[rq].
@@ -1300,7 +1300,11 @@ Consider the following example.
 .IP
 .EX
 for i = 1 to 4 do {
-   line from \[aq]i\[aq]th box.nw to \[aq]i+1\[aq]th box.se
+   box
+   move right 0.5
+}
+for i = 1 to 3 do {
+   arrow from \[ga]i\[aq]th box.ne to \[ga]i+1\[aq]th box.sw
 }
 .EE
 .

___
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit


[groff] 07/14: [troff]: Fix code style nits.

2025-02-21 Thread G. Branden Robinson
gbranden pushed a commit to branch master
in repository groff.

commit 183b3128068a92c5c17a48055879d0035fc1b3b3
Author: G. Branden Robinson 
AuthorDate: Fri Feb 21 02:32:52 2025 -0600

[troff]: Fix code style nits.

* src/roff/troff/input.cpp (remove_character, get_optional_char)
  (get_charinfo_by_number): Reorder equality comparison to avoid
  inadvertent lvalue assignment.  Explicitly compare variable of pointer
  type to null pointer literal instead of letting it pun down to a
  Boolean.
---
 ChangeLog| 8 
 src/roff/troff/input.cpp | 8 
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 69476fc22..c3fbcd897 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-02-21  G. Branden Robinson 
+
+   * src/roff/troff/input.cpp (remove_character, get_optional_char)
+   (get_charinfo_by_number): Fix code style nits.  Reorder equality
+   comparison to avoid inadvertent lvalue assignment.  Explicitly
+   compare variable of pointer type to null pointer literal instead
+   of letting it pun down to a Boolean.
+
 2025-02-21  G. Branden Robinson 
 
* src/roff/troff/input.cpp (token::next): Recast warning
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 1eaf907f2..bdfe8c922 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -4715,7 +4715,7 @@ static void remove_character()
   while (!tok.is_newline() && !tok.is_eof()) {
 if (!tok.is_space() && !tok.is_tab()) {
   charinfo *ci = tok.get_char(true /* required */);
-  if (!ci)
+  if (0 /* nullptr */ == ci)
break;
   macro *m = ci->set_macro(0 /* nullptr */);
   if (m)
@@ -8183,7 +8183,7 @@ charinfo *get_optional_char()
   while (tok.is_space())
 tok.next();
   charinfo *ci = tok.get_char();
-  if (!ci)
+  if (0 /* nullptr */ == ci)
 check_missing_character();
   else
 tok.next();
@@ -10215,7 +10215,7 @@ charinfo *get_charinfo_by_number(int n)
 
   if (n >= 0 && n < 256) {
 charinfo *ci = number_table[n];
-if (!ci) {
+if (0 /*nullptr */ == ci) {
   ci = new charinfo(UNNAMED_SYMBOL);
   ci->set_number(n);
   number_table[n] = ci;
@@ -10225,7 +10225,7 @@ charinfo *get_charinfo_by_number(int n)
   else {
 symbol ns(i_to_a(n));
 charinfo *ci = (charinfo *)numbered_charinfo_dictionary.lookup(ns);
-if (!ci) {
+if (0 /*nullptr */ == ci) {
   ci = new charinfo(UNNAMED_SYMBOL);
   ci->set_number(n);
   (void) numbered_charinfo_dictionary.lookup(ns, ci);

___
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit


[groff] 11/14: [libgroff]: Validate font desc character indices.

2025-02-21 Thread G. Branden Robinson
gbranden pushed a commit to branch master
in repository groff.

commit c29c5d0dfea49f853ceb4f335166137d4efba585
Author: G. Branden Robinson 
AuthorDate: Fri Feb 21 03:44:58 2025 -0600

[libgroff]: Validate font desc character indices.

...more rigorously.

* src/libs/libgroff/font.cpp (font::load): Do it.  Refer to an index as
  an "index", not a "code", in diagnostic messages.  Check for failure
  of strtol(3).  Reject indices that are out of `int` range.  Thus
  convinced that a narrowing conversion will be value-preserving, use
  C++ `static_cast` operator instead of C-style type cast.

* doc/groff.texi.in (Font Description File Format):
* man/groff_font.5.man (Font description file format): Rename "code"
  field to "index" and revise its description.
---
 ChangeLog  | 16 
 doc/groff.texi.in  | 17 +++--
 man/groff_font.5.man   | 19 ---
 src/libs/libgroff/font.cpp | 29 +
 4 files changed, 64 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0a66b1632..87278eaeb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2025-02-21  G. Branden Robinson 
+
+   [libgroff]: Validate character indices in font description files
+   more rigorously.
+
+   * src/libs/libgroff/font.cpp (font::load): Do it.  Refer to an
+   index as an "index", not a "code", in diagnostic messages.
+   Check for failure of strtol(3).  Reject indices that are out of
+   `int` range.  Thus convinced that a narrowing conversion will be
+   value-preserving, use C++ `static_cast` operator instead of
+   C-style type cast.
+
+   * doc/groff.texi.in (Font Description File Format):
+   * man/groff_font.5.man (Font description file format): Rename
+   "code" field to "index" and revise its description.
+
 2025-02-21  G. Branden Robinson 
 
* src/roff/troff/input.cpp (get_charinfo_by_number): Rename
diff --git a/doc/groff.texi.in b/doc/groff.texi.in
index f09bcc6a0..bd470649e 100644
--- a/doc/groff.texi.in
+++ b/doc/groff.texi.in
@@ -464,7 +464,7 @@ Documentation License''.
 @title groff
 @subtitle The GNU implementation of @code{troff}
 @subtitle version @VERSION@
-@subtitle January 2025
+@subtitle February 2025
 @author Trent@tie{}A.@: Fisher
 @author Werner Lemberg
 @author G.@tie{}Branden Robinson
@@ -19660,7 +19660,7 @@ descriptions, one per line.  Each such glyph 
description comprises a set
 of fields separated by spaces or tabs and organized as follows.
 
 @quotation
-@var{name} @var{metrics} @var{type} @var{code} [@var{entity-name}]
+@var{name} @var{metrics} @var{type} @var{index} [@var{entity-name}]
 [@code{--} @var{comment}]
 @end quotation
 
@@ -19774,10 +19774,15 @@ means the glyph is both an ascender and a 
descender---this is true of
 parentheses in some fonts.
 @end table
 
-The @var{code} field gives a numeric identifier that the postprocessor
-uses to render the glyph.  The glyph can be specified to @code{troff}
-using this code by means of the @code{\N} escape sequence.  @var{code}
-can be any integer.@footnote{that is, any integer parsable by the C
+The
+@var{index}
+field is an integer that uniquely identifies a glyph within the font.
+The glyph can be specified to
+@code{troff} @c generic
+using this index by means of the
+@code{\N}
+escape sequence.
+The index can be any integer.@footnote{that is, any integer parsable by the C
 standard library's @cite{strtol@r{(3)}} function}
 
 The @var{entity-name} field defines an identifier for the glyph that the
diff --git a/man/groff_font.5.man b/man/groff_font.5.man
index 2c9f69986..de1f1a33e 100644
--- a/man/groff_font.5.man
+++ b/man/groff_font.5.man
@@ -9,7 +9,7 @@ device and font description files
 .\" Legal Terms
 .\" 
 .\"
-.\" Copyright (C) 1989-2021 Free Software Foundation, Inc.
+.\" Copyright (C) 1989-2025 Free Software Foundation, Inc.
 .\"
 .\" This file is part of groff (GNU roff), which is a free software
 .\" project.
@@ -725,7 +725,7 @@ spaces or tabs and organized as follows.
 .
 .
 .IP
-.I name metrics type code
+.I name metrics type index
 .RI [ entity-name ]
 .RB [ \-\-
 .IR comment ]
@@ -928,22 +928,27 @@ parentheses in some fonts.
 .
 .P
 The
-.I code
-field gives a numeric identifier that the postprocessor uses to render
-the glyph.
+.I index
+field is an integer that uniquely identifies a glyph within the font.
 .
 The glyph can be specified to
 .I troff \" generic
-using this code by means of the
+using this index by means of the
 .B \[rs]N
 escape sequence.
 .
-The code can be any integer
+The index can be any integer
 (that is,
 any integer parsable by the C standard library's
 .MR strtol 3
 function).
 .
+An
+.I index
+is limited to the range of the C language
+.I int
+type on the system.
+.
 .
 .P
 The
diff --git a/src/libs/libgroff/font.cpp b/src/libs/libgroff

[groff] 02/14: ANNOUNCE: Acknowledge Sebastien Peterson-Boudreau.

2025-02-21 Thread G. Branden Robinson
gbranden pushed a commit to branch master
in repository groff.

commit 3b6727361491668ecc6d021f6a11996eff05a515
Author: G. Branden Robinson 
AuthorDate: Sun Feb 16 17:29:47 2025 -0600

ANNOUNCE: Acknowledge Sebastien Peterson-Boudreau.
---
 ANNOUNCE | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ANNOUNCE b/ANNOUNCE
index 9e0ea8b20..439138e89 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -199,6 +199,7 @@ Ralph Corderoy
 Rob Kolstad
 Robert Yang
 Ross Burton
+Sebastien Peterson-Boudreau
 Sven Schober
 TANAKA Takuji
 Tadziu Hoffman

___
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit