[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 01/15: [libgroff]: Boolify more interfaces.
From: |
G. Branden Robinson |
Subject: |
[groff] 01/15: [libgroff]: Boolify more interfaces. |
Date: |
Fri, 17 Sep 2021 05:34:35 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 273ca559086ff95c9b5f21b01289cf2f5983f962
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Sep 17 07:04:41 2021 +1000
[libgroff]: Boolify more interfaces.
* src/libs/libgroff/font.cpp (struct text_file): Rename `next` member
function to `next_line`. Demote its return type from `int` to `bool`.
Use Boolean literals instead of integers.
Also fix nearby trailing whitespace.
---
ChangeLog | 8 ++++++++
src/libs/libgroff/font.cpp | 28 ++++++++++++++--------------
2 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 12b07e0..789e0e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2021-09-17 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [libgroff]: Boolify more interfaces.
+
+ * src/libs/libgroff/font.cpp (struct text_file): Rename `next`
+ member function to `next_line`. Demote its return type from
+ `int` to `bool`. Use Boolean literals instead of integers.
+
2021-09-16 G. Branden Robinson <g.branden.robinson@gmail.com>
[libgroff]: Boolify local variables.
diff --git a/src/libs/libgroff/font.cpp b/src/libs/libgroff/font.cpp
index b31e8e3..6d79686 100644
--- a/src/libs/libgroff/font.cpp
+++ b/src/libs/libgroff/font.cpp
@@ -74,14 +74,14 @@ struct text_file {
char *buf;
text_file(FILE *fp, char *p);
~text_file();
- int next();
- void error(const char *format,
+ bool next_line();
+ void error(const char *format,
const errarg &arg1 = empty_errarg,
const errarg &arg2 = empty_errarg,
const errarg &arg3 = empty_errarg);
};
-text_file::text_file(FILE *p, char *s)
+text_file::text_file(FILE *p, char *s)
: fp(p), path(s), lineno(0), size(0), skip_comments(1), silent(0), buf(0)
{
}
@@ -94,10 +94,10 @@ text_file::~text_file()
fclose(fp);
}
-int text_file::next()
+bool text_file::next_line()
{
if (fp == 0)
- return 0;
+ return false;
if (buf == 0) {
buf = new char[128];
size = 128;
@@ -131,12 +131,12 @@ int text_file::next()
while (csspace(*ptr))
ptr++;
if (*ptr != 0 && (!skip_comments || *ptr != '#'))
- return 1;
+ return true;
}
- return 0;
+ return false;
}
-void text_file::error(const char *format,
+void text_file::error(const char *format,
const errarg &arg1,
const errarg &arg2,
const errarg &arg3)
@@ -782,7 +782,7 @@ bool font::load(int *not_found, bool head_only)
t.silent = head_only;
char *p;
for (;;) {
- if (!t.next()) {
+ if (!t.next_line()) {
p = 0;
break;
}
@@ -862,7 +862,7 @@ bool font::load(int *not_found, bool head_only)
if (head_only)
return true;
for (;;) {
- if (!t.next()) {
+ if (!t.next_line()) {
command = 0;
break;
}
@@ -895,7 +895,7 @@ bool font::load(int *not_found, bool head_only)
had_charset = true;
glyph *last_glyph = NULL;
for (;;) {
- if (!t.next()) {
+ if (!t.next_line()) {
command = 0;
break;
}
@@ -1039,7 +1039,7 @@ bool font::load_desc()
text_file t(fp, path);
t.skip_comments = 1;
res = 0;
- while (t.next()) {
+ while (t.next_line()) {
char *p = strtok(t.buf, WS);
bool directive_found = false;
unsigned int idx;
@@ -1080,7 +1080,7 @@ bool font::load_desc()
for (int i = 0; i < nfonts; i++) {
p = strtok(0, WS);
while (p == 0) {
- if (!t.next()) {
+ if (!t.next_line()) {
t.error("end of file while reading list of fonts");
return false;
}
@@ -1131,7 +1131,7 @@ bool font::load_desc()
for (;;) {
p = strtok(0, WS);
while (p == 0) {
- if (!t.next()) {
+ if (!t.next_line()) {
t.error("list of sizes must be terminated by '0'");
return false;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 01/15: [libgroff]: Boolify more interfaces.,
G. Branden Robinson <=