gbranden pushed a commit to branch master
in repository groff.
commit db4fb9b75254b450a2af7da9e0ea7649e2e77fe7
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Oct 9 01:12:09 2026 -0500
[soelim]: Implement undocumented new `-x` option.
* src/preproc/soelim/soelim.cpp: Add new global of type `bool`,
`want_exit_on_inclusion_failure`, defaulting false.
(main): Instruct getopt_long(3) to accept `x` as an unparameterized
option. If specified, make the new `bool` `true`.
* src/preproc/soelim/tests/x-option-works.sh: New unit test exercises
functionality.
* src/preproc/soelim/soelim.am (soelim_TESTS): Run test.
See <https://savannah.gnu.org/bugs/?68761>.
---
ChangeLog | 16 ++++++++++++++++
src/preproc/soelim/soelim.am | 3 ++-
src/preproc/soelim/soelim.cpp | 17 +++++++++++++----
src/preproc/soelim/tests/x-option-works.sh | 30 ++++++++++++++++++++++++++++++
4 files changed, 61 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5b6fd16fc..4d5c7fcba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2026-10-09 G. Branden Robinson <[email protected]>
+
+ [soelim]: Implement undocumented new `-x` option.
+
+ * src/preproc/soelim/soelim.cpp: Add new global of type `bool`,
+ `want_exit_on_inclusion_failure`, defaulting false.
+ (main): Instruct getopt_long(3) to accept `x` as an
+ unparameterized option. If specified, make the new `bool`
+ `true`.
+
+ * src/preproc/soelim/tests/x-option-works.sh: New unit test
+ exercises functionality.
+ * src/preproc/soelim/soelim.am (soelim_TESTS): Run test.
+
+ See <https://savannah.gnu.org/bugs/?68761>.
+
2026-10-08 G. Branden Robinson <[email protected]>
* src/preproc/eqn/neqn.sh: Use the documented run-time
diff --git a/src/preproc/soelim/soelim.am b/src/preproc/soelim/soelim.am
index 0bea7646a..ab23eb0f6 100644
--- a/src/preproc/soelim/soelim.am
+++ b/src/preproc/soelim/soelim.am
@@ -23,7 +23,8 @@ EXTRA_DIST += \
soelim_TESTS = \
src/preproc/soelim/tests/passes-through-input-with-eighth-bit-set.sh \
- src/preproc/soelim/tests/space-in-argument-works.sh
+ src/preproc/soelim/tests/space-in-argument-works.sh \
+ src/preproc/soelim/tests/x-option-works.sh
TESTS += $(soelim_TESTS)
EXTRA_DIST += $(soelim_TESTS)
diff --git a/src/preproc/soelim/soelim.cpp b/src/preproc/soelim/soelim.cpp
index c607ccee0..edd2109ab 100644
--- a/src/preproc/soelim/soelim.cpp
+++ b/src/preproc/soelim/soelim.cpp
@@ -45,6 +45,7 @@ static search_path include_search_path(0 /* nullptr */, 0 /*
nullptr */,
bool want_att_compat = false;
bool want_raw_output = false;
bool want_tex_output = false;
+bool want_exit_on_inclusion_failure = false;
extern "C" const char *Version_string;
@@ -79,7 +80,7 @@ int main(int argc, char **argv)
{ "version", no_argument, 0 /* nullptr */, 'v' },
{ 0 /* nullptr */, 0, 0 /* nullptr */, 0 }
};
- while ((opt = getopt_long(argc, argv, ":CI:rtv", long_options,
+ while ((opt = getopt_long(argc, argv, ":CI:rtvx", long_options,
0 /* nullptr */))
!= EOF)
switch (opt) {
@@ -99,6 +100,9 @@ int main(int argc, char **argv)
case 't':
want_tex_output = true;
break;
+ case 'x':
+ want_exit_on_inclusion_failure = true;
+ break;
case CHAR_MAX + 1: // --help
usage(stdout);
exit(EXIT_SUCCESS);
@@ -206,9 +210,14 @@ static bool do_file(const char *filename)
whole_filename += '\0';
free(file_name_in_path);
if (0 /* nullptr */ == fp) {
- error("cannot open '%1': %2", whole_filename.contents(),
- strerror(err));
- return false;
+ if (want_exit_on_inclusion_failure)
+ fatal("cannot open '%1': %2", whole_filename.contents(),
+ strerror(err));
+ else {
+ error("cannot open '%1': %2", whole_filename.contents(),
+ strerror(err));
+ return false;
+ }
}
normalize_file_name_for_lf_request(whole_filename);
current_filename = whole_filename.contents();
diff --git a/src/preproc/soelim/tests/x-option-works.sh
b/src/preproc/soelim/tests/x-option-works.sh
new file mode 100755
index 000000000..5f86644de
--- /dev/null
+++ b/src/preproc/soelim/tests/x-option-works.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+# This file is part of groff, the GNU roff typesetting system.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+soelim="${abs_top_builddir:-.}/soelim"
+
+# Test that soelim's `-x` option causes inclusion failures to produce an
+# error exit status.
+
+if ! printf '.so nonexistent-file.roff\n' | "$soelim" -x
+then
+ exit 0
+fi
+
+exit 1
+
+# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit