[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 10/12: [troff]: Boolify `read_size()`.
From: |
G. Branden Robinson |
Subject: |
[groff] 10/12: [troff]: Boolify `read_size()`. |
Date: |
Sat, 20 Nov 2021 05:19:13 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit 34313f0e91f8085f1cf054cc01bb7999c6b4a8c0
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Nov 20 08:55:29 2021 +1100
[troff]: Boolify `read_size()`.
* src/roff/troff/input.cpp (read_size): Boolify. Update prototype.
Demote return type from `int` to `bool`. Use Boolean literals for
return values. Similarly demote local variable, rename it from
`bad_digit` to `contains_invalid_digit`, and use Boolean literals with
it.
---
ChangeLog | 8 ++++++++
src/roff/troff/input.cpp | 26 +++++++++++++-------------
2 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2f45131..edddf3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2021-11-20 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/roff/troff/input.cpp (read_size): Boolify. Update
+ prototype. Demote return type from `int` to `bool`. Use
+ Boolean literals for return values. Similarly demote local
+ variable, rename it from `bad_digit` to
+ `contains_invalid_digit`, and use Boolean literals with it.
+
2021-11-16 Deri James <deri@chuzzlewit.myzen.co.uk>
* src/devices/gropdf/gropdf.pl: Fixes to importing pdf versions
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 23748c2..e8b726f 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -150,7 +150,7 @@ static int get_delim_number(units *, unsigned char);
static int get_delim_number(units *, unsigned char, units);
static symbol do_get_long_name(bool, char);
static int get_line_arg(units *res, unsigned char si, charinfo **cp);
-static int read_size(int *);
+static bool read_size(int *);
static symbol get_delim_name();
static void init_registers();
static void trapping_blank_line();
@@ -5031,7 +5031,7 @@ static int get_line_arg(units *n, unsigned char si,
charinfo **cp)
return 0;
}
-static int read_size(int *x)
+static bool read_size(int *x)
{
tok.next();
int c = tok.ch();
@@ -5047,7 +5047,7 @@ static int read_size(int *x)
c = tok.ch();
}
int val = 0; // pacify compiler
- int bad_digit = 0;
+ bool contains_invalid_digit = false;
if (c == '(') {
tok.next();
c = tok.ch();
@@ -5065,13 +5065,13 @@ static int read_size(int *x)
}
}
if (!csdigit(c))
- bad_digit = 1;
+ contains_invalid_digit = true;
else {
val = c - '0';
tok.next();
c = tok.ch();
if (!csdigit(c))
- bad_digit = 1;
+ contains_invalid_digit = true;
else {
val = val*10 + (c - '0');
val *= sizescale;
@@ -5085,7 +5085,7 @@ static int read_size(int *x)
tok.next();
c = tok.ch();
if (!csdigit(c))
- bad_digit = 1;
+ contains_invalid_digit = true;
else {
val = val*10 + (c - '0');
error("ambiguous point-size escape; rewrite to use '\\s(%1'"
@@ -5095,7 +5095,7 @@ static int read_size(int *x)
val *= sizescale;
}
else if (!tok.usable_as_delimiter(true /* report error */))
- return 0;
+ return false;
else {
token start(tok);
tok.next();
@@ -5105,22 +5105,22 @@ static int read_size(int *x)
tok.next();
}
if (!get_number(&val, 'z'))
- return 0;
+ return false;
if (!(start.ch() == '[' && tok.ch() == ']') && start != tok) {
if (start.ch() == '[')
error("missing ']' in point-size escape");
else
error("missing closing delimiter in point-size escape");
- return 0;
+ return false;
}
}
- if (bad_digit) {
+ if (contains_invalid_digit) {
if (c)
error("bad digit in point-size escape: %1",
input_char_description(c));
else
error("bad digit in point-size escape");
- return 0;
+ return false;
}
else {
switch (inc) {
@@ -5128,7 +5128,7 @@ static int read_size(int *x)
if (val == 0) {
// special case -- point size 0 means "revert to previous size"
*x = 0;
- return 1;
+ return true;
}
*x = val;
break;
@@ -5147,7 +5147,7 @@ static int read_size(int *x)
" set to 1u", *x);
*x = 1;
}
- return 1;
+ return true;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 10/12: [troff]: Boolify `read_size()`.,
G. Branden Robinson <=