[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 03/08: [troff]: Fix code style nit ("nullptr").
From: |
G. Branden Robinson |
Subject: |
[groff] 03/08: [troff]: Fix code style nit ("nullptr"). |
Date: |
Sun, 4 Feb 2024 00:37:51 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit 40a69b3460ac02081c38537106d8e447973007dc
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Feb 3 20:43:31 2024 -0600
[troff]: Fix code style nit ("nullptr").
Annotate null pointers with `nullptr` comment to ease any future
transition to C++11, which defines it as a keyword.
* src/roff/troff/env.cpp:
* src/roff/troff/input.cpp:
* src/roff/troff/node.cpp: Do it.
---
src/roff/troff/env.cpp | 10 +++++-----
src/roff/troff/input.cpp | 50 ++++++++++++++++++++++++------------------------
src/roff/troff/node.cpp | 16 ++++++++--------
3 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index dbaf2d1a9..b916ae37b 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1847,7 +1847,7 @@ void environment::output_line(node *n, hunits width, int
was_centered)
width += tem->width();
}
node *nn = 0;
- while (n != 0) {
+ while (n != 0 /* nullptr */) {
node *tem = n->next;
n->next = nn;
nn = n;
@@ -1947,7 +1947,7 @@ breakpoint *environment::choose_breakpoint()
node *n = line;
breakpoint *best_bp = 0; // the best breakpoint so far
int best_bp_fits = 0;
- while (n != 0) {
+ while (n != 0 /* nullptr */) {
x -= n->width();
s -= n->nspaces();
breakpoint *bp = n->get_breakpoints(x, s);
@@ -2365,7 +2365,7 @@ void environment::construct_format_state(node *n, int
was_centered,
{
if (is_html) {
// find first glyph node which has a state.
- while (n != 0 && n->state == 0)
+ while (n != 0 /* nullptr */ && n->state == 0)
n = n->next;
if (n == 0 || (n->state == 0))
return;
@@ -2381,7 +2381,7 @@ void environment::construct_format_state(node *n, int
was_centered,
n->state->add_tag_if_unknown(MTSM_CE, 0);
n->state->add_tag_if_unknown(MTSM_FI, filling);
n = n->next;
- while (n != 0) {
+ while (n != 0 /* nullptr */) {
if (n->state != 0) {
n->state->sub_tag_ce();
n->state->add_tag_if_unknown(MTSM_FI, filling);
@@ -2395,7 +2395,7 @@ void environment::construct_new_line_state(node *n)
{
if (is_html) {
// find first glyph node which has a state.
- while (n != 0 && n->state == 0)
+ while (n != 0 /* nullptr */ && n->state == 0)
n = n->next;
if (n == 0 || n->state == 0)
return;
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 5b5bec470..d3f3b9dc3 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -399,7 +399,7 @@ file_iterator::file_iterator(FILE *f, const char *fn, int
po)
: fp(f), lineno(1), filename(fn), popened(po),
newline_flag(0), seen_escape(0)
{
- if ((font::use_charnames_in_special) && (fn != 0)) {
+ if ((font::use_charnames_in_special) && (fn != 0 /* nullptr */)) {
if (!the_output)
init_output();
the_output->put_filename(fn, po);
@@ -1879,7 +1879,7 @@ void token::next()
}
units x;
for (;;) {
- node *n = 0;
+ node *n = 0 /* nullptr */;
int cc = input_stack::get(&n);
if (cc != escape_char || escape_char == 0) {
handle_ordinary_char:
@@ -2039,7 +2039,7 @@ void token::next()
return;
case 0:
{
- assert(n != 0);
+ assert(n != 0 /* nullptr */);
token_node *tn = n->get_token_node();
if (tn) {
*this = tn->tk;
@@ -3362,33 +3362,33 @@ public:
void node_list::append(node *n)
{
- if (head == 0) {
- n->next = 0;
+ if (head == 0 /* nullptr */) {
+ n->next = 0 /* nullptr */;
head = tail = n;
}
else {
- n->next = 0;
+ n->next = 0 /* nullptr */;
tail = tail->next = n;
}
}
int node_list::length()
{
- int total = 0;
- for (node *n = head; n != 0; n = n->next)
+ int total = 0 /* nullptr */;
+ for (node *n = head; n != 0 /* nullptr */; n = n->next)
++total;
return total;
}
node_list::node_list()
{
- head = tail = 0;
+ head = tail = 0 /* nullptr */;
}
node *node_list::extract()
{
node *temp = head;
- head = tail = 0;
+ head = tail = 0 /* nullptr */;
return temp;
}
@@ -3408,7 +3408,7 @@ public:
macro::~macro()
{
- if (p != 0 && --(p->count) <= 0)
+ if (p != 0 /* nullptr */ && --(p->count) <= 0)
delete p;
}
@@ -3416,12 +3416,12 @@ macro::macro()
: is_a_diversion(0), is_a_string(1)
{
if (!input_stack::get_location(1, &filename, &lineno)) {
- filename = 0;
- lineno = 0;
+ filename = 0 /* nullptr */;
+ lineno = 0 /* nullptr */;
}
len = 0;
empty_macro = 1;
- p = 0;
+ p = 0; /* nullptr */
}
macro::macro(const macro &m)
@@ -3429,7 +3429,7 @@ macro::macro(const macro &m)
empty_macro(m.empty_macro), is_a_diversion(m.is_a_diversion),
is_a_string(m.is_a_string), p(m.p)
{
- if (p != 0)
+ if (p != 0 /* nullptr */)
p->count++;
}
@@ -3437,13 +3437,13 @@ macro::macro(int is_div)
: is_a_diversion(is_div)
{
if (!input_stack::get_location(1, &filename, &lineno)) {
- filename = 0;
- lineno = 0;
+ filename = 0 /* nullptr */;
+ lineno = 0 /* nullptr */;
}
len = 0;
empty_macro = 1;
is_a_string = 1;
- p = 0;
+ p = 0 /* nullptr */;
}
int macro::is_diversion()
@@ -3464,9 +3464,9 @@ void macro::clear_string_flag()
macro ¯o::operator=(const macro &m)
{
// don't assign object
- if (m.p != 0)
+ if (m.p != 0 /* nullptr */)
m.p->count++;
- if (p != 0 && --(p->count) <= 0)
+ if (p != 0 /* nullptr */ && --(p->count) <= 0)
delete p;
p = m.p;
filename = m.filename;
@@ -3481,7 +3481,7 @@ macro ¯o::operator=(const macro &m)
void macro::append(unsigned char c)
{
assert(c != 0);
- if (p == 0)
+ if (p == 0 /* nullptr */)
p = new macro_header;
if (p->cl.length() != len) {
macro_header *tem = p->copy(len);
@@ -3497,14 +3497,14 @@ void macro::append(unsigned char c)
void macro::set(unsigned char c, int offset)
{
- assert(p != 0);
+ assert(p != 0 /* nullptr */);
assert(c != 0);
p->cl.set(c, offset);
}
unsigned char macro::get(int offset)
{
- assert(p != 0);
+ assert(p != 0 /* nullptr */);
return p->cl.get(offset);
}
@@ -3527,8 +3527,8 @@ void macro::append_str(const char *s)
void macro::append(node *n)
{
- assert(n != 0);
- if (p == 0)
+ assert(n != 0 /* nullptr */);
+ if (p == 0 /* nullptr */)
p = new macro_header;
if (p->cl.length() != len) {
macro_header *tem = p->copy(len);
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 895fb9519..3f621efc5 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -914,7 +914,7 @@ void troff_output_file::really_print_line(hunits x, vunits
y, node *n,
vunits before, vunits after, hunits)
{
moveto(x, y);
- while (n != 0) {
+ while (n != 0 /* nullptr */) {
// Check whether we should push the current troff state and use
// the state at the start of the invocation of this diversion.
if (n->div_nest_level > cur_div_level && n->push_state) {
@@ -1788,7 +1788,7 @@ void ascii_output_file::really_transparent_char(unsigned
char c)
void ascii_output_file::really_print_line(hunits, vunits, node *n,
vunits, vunits, hunits)
{
- while (n != 0) {
+ while (n != 0 /* nullptr */) {
n->ascii_print(this);
n = n->next;
}
@@ -2362,7 +2362,7 @@ node *kern_pair_node::copy()
node *copy_node_list(node *n)
{
node *p = 0;
- while (n != 0) {
+ while (n != 0 /* nullptr */) {
node *nn = n->copy();
nn->next = p;
p = nn;
@@ -2379,7 +2379,7 @@ node *copy_node_list(node *n)
void delete_node_list(node *n)
{
- while (n != 0) {
+ while (n != 0 /* nullptr */) {
node *tem = n;
n = n->next;
delete tem;
@@ -2556,7 +2556,7 @@ void node::debug_node_list()
node *n = next;
debug_node();
- while (n != 0) {
+ while (n != 0 /* nullptr */) {
n->debug_node();
n = n->next;
}
@@ -2578,7 +2578,7 @@ node *kern_pair_node::last_char_node()
hunits dbreak_node::width()
{
hunits x = H0;
- for (node *n = none; n != 0; n = n->next)
+ for (node *n = none; n != 0 /* nullptr */; n = n->next)
x += n->width();
return x;
}
@@ -2649,7 +2649,7 @@ italic_corrected_node::italic_corrected_node(node *nn,
hunits xx, statem *s,
int pop, node *p)
: node(p, s, pop), n(nn), x(xx)
{
- assert(n != 0);
+ assert(n != 0 /* nullptr */);
}
italic_corrected_node::~italic_corrected_node()
@@ -3322,7 +3322,7 @@ int kern_pair_node::ends_sentence()
int node_list_ends_sentence(node *n)
{
- for (; n != 0; n = n->next)
+ for (; n != 0 /* nullptr */; n = n->next)
switch (n->ends_sentence()) {
case 0:
return 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 03/08: [troff]: Fix code style nit ("nullptr").,
G. Branden Robinson <=