[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 10/19: [groff]: Fix code style nit: boolify.
From: |
G. Branden Robinson |
Subject: |
[groff] 10/19: [groff]: Fix code style nit: boolify. |
Date: |
Sun, 22 Sep 2024 00:33:06 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 065dbab3e129910121f8ff33129b75e34eb7dfbe
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Sep 21 18:50:49 2024 -0500
[groff]: Fix code style nit: boolify.
* src/roff/groff/groff.cpp: Boolify variables controlling whether a
command pipeline is constructed.
(run_commands): Demote `no_pipe` argument from `int` to `bool`.
(main): Rename `vflag` to `want_version_info` and demote it from `int`
to `bool`. Assign to it using Boolean, not integer, literals.
* src/roff/groff/pipeline.c:
* src/roff/groff/pipeline.h:
(run_pipeline): Demote `no_pipe` argument from `int` to `bool`.
* src/roff/groff/pipeline.c: Include "stdbool.h" header file.
---
ChangeLog | 13 +++++++++++++
src/roff/groff/groff.cpp | 14 +++++++-------
src/roff/groff/pipeline.c | 13 +++++++------
src/roff/groff/pipeline.h | 4 ++--
4 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a98da9f64..8bbd0ade8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-09-21 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/roff/groff/groff.cpp: Boolify variables controlling
+ whether a command pipeline is constructed.
+ (run_commands): Demote `no_pipe` argument from `int` to `bool`.
+ (main): Rename `vflag` to `want_version_info` and demote it from
+ `int` to `bool`. Assign to it using Boolean, not integer,
+ literals.
+ * src/roff/groff/pipeline.c:
+ * src/roff/groff/pipeline.h:
+ (run_pipeline): Demote `no_pipe` argument from `int` to `bool`.
+ * src/roff/groff/pipeline.c: Include "stdbool.h" header file.
+
2024-09-20 G. Branden Robinson <g.branden.robinson@gmail.com>
[gxditview]: Accept the `-v` option groff(1) may supply.
diff --git a/src/roff/groff/groff.cpp b/src/roff/groff/groff.cpp
index a9e79c342..bdabc51e2 100644
--- a/src/roff/groff/groff.cpp
+++ b/src/roff/groff/groff.cpp
@@ -107,7 +107,7 @@ char *groff_font_path = 0 /* nullptr */;
possible_command commands[NCOMMANDS];
-int run_commands(int no_pipe);
+int run_commands(bool no_pipe);
void print_commands(FILE *);
void append_arg_to_string(const char *arg, string &str);
void handle_unknown_desc_command(const char *command, const char *arg,
@@ -149,7 +149,7 @@ int main(int argc, char **argv)
assert(NCOMMANDS <= MAX_COMMANDS);
string Pargs, Largs, Fargs;
int Kflag = 0;
- int vflag = 0;
+ bool want_version_info = false;
int Vflag = 0;
int zflag = 0;
int iflag = 0;
@@ -253,7 +253,7 @@ int main(int argc, char **argv)
Vflag++;
break;
case 'v':
- vflag = 1;
+ want_version_info = true;
printf("GNU groff version %s\n", Version_string);
puts(
"Copyright (C) 1989-2023 Free Software Foundation, Inc.\n"
@@ -396,7 +396,7 @@ int main(int argc, char **argv)
commands[TROFF_INDEX].insert_args(Pargs);
if (eflag && is_xhtml)
commands[TROFF_INDEX].insert_arg("-e");
- if (vflag)
+ if (want_version_info)
commands[TROFF_INDEX].insert_arg("-v");
}
const char *real_driver = 0 /* nullptr */;
@@ -442,7 +442,7 @@ int main(int argc, char **argv)
}
if (gxditview_flag)
commands[POST_INDEX].append_arg("-");
- if (lflag && !vflag && !Xflag && spooler) {
+ if (lflag && !want_version_info && !Xflag && spooler) {
commands[SPOOL_INDEX].set_name(BSHELL);
commands[SPOOL_INDEX].append_arg(BSHELL_DASH_C);
Largs += '\0';
@@ -532,7 +532,7 @@ int main(int argc, char **argv)
print_commands(Vflag == 1 ? stdout : stderr);
if (Vflag == 1)
xexit(EXIT_SUCCESS);
- xexit(run_commands(vflag));
+ xexit(run_commands(want_version_info));
}
const char *xbasename(const char *s)
@@ -611,7 +611,7 @@ void print_commands(FILE *fp)
// Run the commands. Return the code with which to exit.
-int run_commands(int no_pipe)
+int run_commands(bool no_pipe)
{
char **v[NCOMMANDS]; // vector of argv arrays to pipe together
int ncommands = 0;
diff --git a/src/roff/groff/pipeline.c b/src/roff/groff/pipeline.c
index defafc24e..281905b9b 100644
--- a/src/roff/groff/pipeline.c
+++ b/src/roff/groff/pipeline.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -20,6 +20,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <config.h>
#endif
+#include <stdbool.h>
#include <stdio.h>
#include <signal.h>
#include <errno.h>
@@ -76,7 +77,7 @@ extern char *strerror();
#include "pipeline.h"
/* Prototype */
-int run_pipeline(int, char ***, int);
+int run_pipeline(int, char ***, bool);
#ifdef __cplusplus
extern "C" {
@@ -210,7 +211,7 @@ int is_system_shell(const char *prog)
and before waiting for any of the children.
*/
-int run_pipeline(int ncommands, char ***commands, int no_pipe)
+int run_pipeline(int ncommands, char ***commands, bool no_pipe)
{
int i;
int last_input = 0; /* pacify some compilers */
@@ -356,7 +357,7 @@ static RETSIGTYPE signal_catcher(int signo)
child_interrupted++;
}
-int run_pipeline(int ncommands, char ***commands, int no_pipe)
+int run_pipeline(int ncommands, char ***commands, bool no_pipe)
{
int save_stdin = dup(0);
int save_stdout = dup(1);
@@ -391,7 +392,7 @@ int run_pipeline(int ncommands, char ***commands, int
no_pipe)
if (f < 0)
sys_fatal("open stdin");
if (dup2(f, 0) < 0)
- sys_fatal("dup2 stdin");
+ sys_fatal("dup2 stdin");
if (close(f) < 0)
sys_fatal("close stdin");
}
@@ -443,7 +444,7 @@ int run_pipeline(int ncommands, char ***commands, int
no_pipe)
#else /* not __MSDOS__, not _WIN32 */
-int run_pipeline(int ncommands, char ***commands, int no_pipe)
+int run_pipeline(int ncommands, char ***commands, bool no_pipe)
{
int i;
int last_input = 0;
diff --git a/src/roff/groff/pipeline.h b/src/roff/groff/pipeline.h
index 17c02a6df..3cfd9ff62 100644
--- a/src/roff/groff/pipeline.h
+++ b/src/roff/groff/pipeline.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -18,7 +18,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#ifdef __cplusplus
extern "C" {
- int run_pipeline(int, char ***, int);
+ int run_pipeline(int, char ***, bool);
}
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 10/19: [groff]: Fix code style nit: boolify.,
G. Branden Robinson <=