gbranden pushed a commit to branch master
in repository groff.
commit 1b31ec574f45a2c9c030eb40fdf4e9aa06653284
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Apr 2 08:42:46 2025 -0500
[troff]: Make Boolean function capable of failure.
* src/roff/troff/input.cpp (file_iterator::get_location): This
`bool`-returning function always returned true. Return `false` if no
file name information is available; one should always be available,
and the line number is meaningless without a file name (we handle the
standard input stream specially, and it _has_ a file name for our
purposes).
---
ChangeLog | 9 +++++++++
src/roff/troff/input.cpp | 6 ++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f728adb86..e2aa3b6e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-04-02 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (file_iterator::get_location): This
+ `bool`-returning function always returned true. Return `false`
+ if no file name information is available; one should always be
+ available, and the line number is meaningless without a file
+ name (we handle the standard input stream specially, and it
+ _has_ a file name for our purposes).
+
2025-04-02 G. Branden Robinson <[email protected]>
* src/libs/libgroff/string.cpp (string::json_extract):
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index da3311fac..ee847cf1f 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -509,11 +509,13 @@ bool file_iterator::get_location(bool /*allow_macro*/,
const char **filenamep, int *linenop)
{
*linenop = lineno;
- if (filename != 0 && strcmp(filename, "-") == 0)
+ if (0 /* nullptr */ == filename)
+ return false;
+ if (strcmp(filename, "-") == 0)
*filenamep = "<standard input>";
else
*filenamep = filename;
- return 1;
+ return true;
}
void file_iterator::backtrace()
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit