gbranden pushed a commit to branch master
in repository groff.
commit 37e4d238656f5ac47217cd9cef1d94063cd3a3df
Author: G. Branden Robinson <[email protected]>
AuthorDate: Tue Jul 9 07:10:40 2024 -0500
src/roff/troff/input.cpp: Slightly refactor.
* src/roff/troff/input.cpp: Slightly refactor.
(pipe_output): Reduce cleverness of assignment nested inside
conditional--a favorite of C obscurantists and an especially
gratuitous case since it was immediately preceded by a declarator
without an initializer. This aligns the logic with `system_request`.
(pipe_output, system_request): Reorder comparisons to avoid
inadvertent lvalue assignment.
---
ChangeLog | 11 +++++++++++
src/roff/troff/input.cpp | 9 +++++----
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b7daa3341..9300ab8d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-07-09 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp: Slightly refactor.
+ (pipe_output): Reduce cleverness of assignment nested inside
+ conditional--a favorite of C obscurantists and an especially
+ gratuitous case since it was immediately preceded by a
+ declarator without an initializer. This aligns the logic with
+ `system_request`.
+ (pipe_output, system_request): Reorder comparisons to avoid
+ inadvertent lvalue assignment.
+
2024-07-09 G. Branden Robinson <[email protected]>
* doc/groff.texi.in (while):
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 99f19b7c3..d113371a8 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -7846,10 +7846,11 @@ void pipe_output()
skip_line();
}
else {
- char *pc;
- if ((pc = read_string()) == 0)
+ char *pc = read_string();
+ if (0 /* nullptr */ == pc)
error("can't pipe to empty command");
- if (pipe_command) {
+ // Are we adding to an existing pipeline?
+ if (pipe_command != 0 /* nullptr */) {
char *s = new char[strlen(pipe_command) + strlen(pc) + 1 + 1];
strcpy(s, pipe_command);
strcat(s, "|");
@@ -7874,7 +7875,7 @@ void system_request()
}
else {
char *command = read_string();
- if (!command)
+ if (0 /* nullptr */ == command)
error("empty command");
else {
system_status = system(command);
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit