[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 15/45: [libdriver]: Trivially refactor.
From: |
G. Branden Robinson |
Subject: |
[groff] 15/45: [libdriver]: Trivially refactor. |
Date: |
Thu, 20 Jan 2022 10:17:49 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit a69ea57ff0f0c4c1dda70fe7158463991cd48822
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Jan 16 17:26:37 2022 +1100
[libdriver]: Trivially refactor.
* src/libs/libdriver/printer.cpp: Fix code style nits.
- Fix null pointer representation and comparison styles; see commits
11b43053, 639db849. Also annotate null pointers with `nullptr`
comment to ease any future transition to C++11, which defines it as
a keyword. (I have no plans at all to undertake such a migration,
but I want to smooth the way for future groff developers who might.)
- Wrap lines at 72 columns.
- Use of white space and parentheses more consistently with the rest
of the codebase.
Also drop unnecessary header comments. Add editor aid comments at end.
---
src/libs/libdriver/printer.cpp | 64 ++++++++++++++++++++++--------------------
1 file changed, 33 insertions(+), 31 deletions(-)
diff --git a/src/libs/libdriver/printer.cpp b/src/libs/libdriver/printer.cpp
index 24c43bf1..c7b48026 100644
--- a/src/libs/libdriver/printer.cpp
+++ b/src/libs/libdriver/printer.cpp
@@ -1,7 +1,3 @@
-// -*- C++ -*-
-
-// <groff_src_dir>/src/libs/libdriver/printer.cpp
-
/* Copyright (C) 1989-2020 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -27,8 +23,8 @@
when reading man pages), then we may get an error state on the output
stream, if the user does not read all the way to the end.
- We normally expect to catch this, and clean up the error context, when
- the pager exits, because we should get, and handle, a SIGPIPE.
+ We normally expect to catch this, and clean up the error context,
+ when the pager exits, because we should get, and handle, a SIGPIPE.
However ...
*/
@@ -36,10 +32,11 @@
#if (defined(_MSC_VER) || defined(_WIN32)) \
&& !defined(__CYGWIN__) && !defined(_UWIN)
- /* Native MS-Windows doesn't know about SIGPIPE, so we cannot detect the
- early exit from the pager, and therefore, cannot clean up the error
- context; thus we use the following static function to identify this
- particular error context, and so suppress unwanted diagnostics.
+ /* Native MS-Windows doesn't know about SIGPIPE, so we cannot detect
+ the early exit from the pager, and therefore, cannot clean up the
+ error context; thus we use the following static function to
+ identify this particular error context, and so suppress unwanted
+ diagnostics.
*/
static int
@@ -50,14 +47,14 @@
clearerr (stream);
/* Clear errno, in case clearerr() and fflush() don't */
errno = 0;
- /* Flush the output stream, so we can capture any error context, other
- than the specific case we wish to suppress.
-
- Microsoft doesn't document it, but the error code for the specific
- context we are trying to suppress seems to be EINVAL -- a strange
- choice, since it is not normally associated with fflush(); of course,
- it *should* be EPIPE, but this *definitely* is not used, and *is* so
- documented.
+ /* Flush the output stream, so we can capture any error context,
+ other than the specific case we wish to suppress.
+
+ Microsoft doesn't document it, but the error code for the
+ specific context we are trying to suppress seems to be EINVAL --
+ a strange choice, since it is not normally associated with
+ fflush(); of course, it *should* be EPIPE, but this *definitely*
+ is not used, and *is* so documented.
*/
return ((fflush(stream) < 0) && (errno != EINVAL));
}
@@ -132,7 +129,7 @@ font *printer::find_font(const char *nm)
if (strcmp(p->p->get_name(), nm) == 0)
return p->p;
font *f = make_font(nm);
- if (!f)
+ if (0 /* nullptr */ == f)
fatal("sorry, I can't continue");
font_list = new font_pointer_list(f, font_list);
return f;
@@ -179,7 +176,7 @@ void printer::set_ascii_char(unsigned char c, const
environment *env,
glyph *g = set_char_and_width(buf, env, &w, &f);
- if (g != UNDEFINED_GLYPH ) {
+ if (g != UNDEFINED_GLYPH) {
set_char(g, f, env, w, 0);
if (widthp)
*widthp = w;
@@ -199,8 +196,9 @@ void printer::set_special_char(const char *nm, const
environment *env,
}
}
-glyph *printer::set_char_and_width(const char *nm, const environment *env,
- int *widthp, font **f)
+glyph *printer::set_char_and_width(const char *nm,
+ const environment *env, int *widthp,
+ font **f)
{
glyph *g = name_to_glyph(nm);
int fn = env->fontno;
@@ -216,12 +214,10 @@ glyph *printer::set_char_and_width(const char *nm, const
environment *env,
if (!(*f)->contains(g)) {
if (nm[0] != '\0' && nm[1] == '\0')
error("font '%1' does not contain ascii character '%2'",
- (*f)->get_name(),
- nm[0]);
+ (*f)->get_name(), nm[0]);
else
error("font '%1' does not contain special character '%2'",
- (*f)->get_name(),
- nm);
+ (*f)->get_name(), nm);
return UNDEFINED_GLYPH;
}
int w = (*f)->get_width(g, env->size);
@@ -230,7 +226,8 @@ glyph *printer::set_char_and_width(const char *nm, const
environment *env,
return g;
}
-void printer::set_numbered_char(int num, const environment *env, int *widthp)
+void printer::set_numbered_char(int num, const environment *env, int
+ *widthp)
{
glyph *g = number_to_glyph(num);
int fn = env->fontno;
@@ -245,8 +242,7 @@ void printer::set_numbered_char(int num, const environment
*env, int *widthp)
}
if (!f->contains(g)) {
error("font '%1' does not contain numbered character %2",
- f->get_name(),
- num);
+ f->get_name(), num);
return;
}
int w = f->get_width(g, env->size);
@@ -258,7 +254,13 @@ void printer::set_numbered_char(int num, const environment
*env, int *widthp)
font *printer::get_font_from_index(int fontno)
{
if ((fontno >= 0) && (fontno < nfonts))
- return(font_table[fontno]);
+ return font_table[fontno];
else
- return(0);
+ return 0;
}
+
+// Local Variables:
+// fill-column: 72
+// mode: C++
+// End:
+// vim: set cindent noexpandtab shiftwidth=2 textwidth=72:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 15/45: [libdriver]: Trivially refactor.,
G. Branden Robinson <=