gbranden pushed a commit to branch master
in repository groff.
commit 6297957a8679fb9657c544cd13c35650a8731ff7
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Mar 17 19:28:20 2025 -0500
[troff]: Add grout comment facility.
Add internal facility for writing trout/grout comments to GNU troff
output. This is a developers' aid.
* src/roff/troff/node.cpp (class troff_output_file): Declare new
`comment()` member function, taking a groff string and returning void.
(troff_output_file::comment): Define it.
---
ChangeLog | 10 ++++++++++
src/roff/troff/node.cpp | 11 +++++++++++
2 files changed, 21 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 92c800b97..a4cce559c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2025-03-17 G. Branden Robinson <[email protected]>
+
+ [troff]: Add internal facility for writing trout/grout comments
+ to GNU troff output. This is a developers' aid.
+
+ * src/roff/troff/node.cpp (class troff_output_file): Declare new
+ `comment()` member function, taking a groff string and returning
+ void.
+ (troff_output_file::comment): Define it.
+
2025-03-17 G. Branden Robinson <[email protected]>
* src/roff/troff/node.cpp: Trivially refactor.
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index fa7048e80..566c40279 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -850,6 +850,7 @@ public:
int get_hpos() { return hpos; }
int get_vpos() { return vpos; }
void add_to_tag_list(string s);
+ void comment(string s);
friend void space_char_hmotion_node::tprint(troff_output_file *);
friend void unbreakable_space_node::tprint(troff_output_file *);
};
@@ -1382,6 +1383,16 @@ void troff_output_file::add_to_tag_list(string s)
}
}
+void troff_output_file::comment(string s)
+{
+ flush_tbuf();
+ assert(s.search('\n') == -1); // Don't write a multi-line comment.
+ put("# ");
+ string t = s + '\0';
+ put(t.contents());
+ put('\n');
+}
+
// determine_line_limits - works out the smallest box which will contain
// the entity, code, built from the point array.
void troff_output_file::determine_line_limits(char code, hvpair *point,
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit