gbranden pushed a commit to branch master
in repository groff.
commit 56059ac906971c174373de7af97475cc70b77ac4
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Jul 13 11:59:26 2024 -0500
[libgroff]: Trivially refactor (2/5).
* src/libs/libgroff/font.cpp (text_file::next_line, scale_round)
(font::get_width, font::alloc_ch_index, font::load_desc): Do the same
for comparisons to integral zeroes.
---
ChangeLog | 4 ++++
src/libs/libgroff/font.cpp | 14 +++++++-------
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3f1cb0f3b..7c32f92cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,10 @@
Reorder comparisons with null pointers to avoid inadvertent
lvalue assignment.
+ * src/libs/libgroff/font.cpp (text_file::next_line, scale_round)
+ (font::get_width, font::alloc_ch_index, font::load_desc): Do the
+ same for comparisons to integral zeroes.
+
2024-07-13 G. Branden Robinson <[email protected]>
* src/libs/libgroff/font.cpp (font::load, font::load_desc):
diff --git a/src/libs/libgroff/font.cpp b/src/libs/libgroff/font.cpp
index c58efce49..7d54bff39 100644
--- a/src/libs/libgroff/font.cpp
+++ b/src/libs/libgroff/font.cpp
@@ -131,7 +131,7 @@ bool text_file::next_line()
break;
}
}
- if (length == 0)
+ if (0 == length)
break;
buf[length] = '\0';
char *ptr = buf;
@@ -245,7 +245,7 @@ static int scale_round(int n, int x, int y)
{
assert(x >= 0 && y > 0);
int y2 = y/2;
- if (x == 0)
+ if (0 == x)
return 0;
if (n >= 0) {
if (n <= (INT_MAX - y2) / x)
@@ -262,7 +262,7 @@ static int scale_round(int n, int x, int y)
static int scale_round(int n, int x, int y, int z)
{
assert(x >= 0 && y > 0 && z > 0);
- if (x == 0)
+ if (0 == x)
return 0;
if (n >= 0)
return int((n * double(x) / double(y)) * (double(z) / 1000.0) + .5);
@@ -357,7 +357,7 @@ int font::get_width(glyph *g, int point_size)
int idx = glyph_to_index(g);
assert(idx >= 0);
int real_size;
- if (zoom == 0) // 0 means "don't zoom"
+ if (0 == zoom) // 0 means "don't zoom"
real_size = point_size;
else
{
@@ -620,7 +620,7 @@ const char *font::get_image_generator()
void font::alloc_ch_index(int idx)
{
- if (nindices == 0) {
+ if (0 == nindices) {
nindices = 128;
if (idx >= nindices)
nindices = idx + 10;
@@ -1226,7 +1226,7 @@ const char *font::load_desc()
delete[] old_sizes;
}
sizes[i++] = lower;
- if (lower == 0)
+ if (0 == lower)
break;
sizes[i++] = upper;
}
@@ -1290,7 +1290,7 @@ const char *font::load_desc()
t.error("device description file missing 'res' directive");
return 0 /* nullptr */;
}
- if (unitwidth == 0) {
+ if (0 == unitwidth) {
t.error("device description file missing 'unitwidth' directive");
return 0 /* nullptr */;
}
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit