[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 13/28: [troff]: Fix code style nits.
From: |
G. Branden Robinson |
Subject: |
[groff] 13/28: [troff]: Fix code style nits. |
Date: |
Sat, 7 Sep 2024 21:36:47 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 3bb13e47528b8dbe64ad0a1b504f9565086b236a
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Sep 4 17:22:27 2024 -0500
[troff]: Fix code style nits.
* src/roff/troff/input.cpp (do_open): Fix code style nits. Use C++
`static_cast` operator instead of C-style type casts. Emit error
diagnostic if `fclose()` fails.
Also annotate null pointer with `nullptr` comment to ease any future
transition to C++11, which defines it as a keyword.
---
ChangeLog | 6 ++++++
src/roff/troff/input.cpp | 9 +++++----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 12d618e6a..26f60f633 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-09-04 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/roff/troff/input.cpp (do_open): Fix code style nits.
+ Use C++ `static_cast` operator instead of C-style type casts.
+ Emit error diagnostic if `fclose()` fails.
+
2024-09-04 G. Branden Robinson <g.branden.robinson@gmail.com>
* Makefile.am: Revise and update internal documentation.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index cd1d97ad4..0f930282e 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -7214,12 +7214,13 @@ static void do_open(bool append)
filename.contents(),
append ? "appending" : "writing",
strerror(errno));
- fp = (FILE *)stream_dictionary.remove(stream);
+ fp = static_cast<FILE *>(stream_dictionary.remove(stream));
}
else
- fp = (FILE *)stream_dictionary.lookup(stream, fp);
- if (fp)
- fclose(fp);
+ fp = static_cast<FILE *>(stream_dictionary.lookup(stream, fp));
+ if (fp != 0 /* nullptr */ && (fclose(fp) != 0))
+ error("cannot close file '%1': %2", filename.contents(),
+ strerror(errno));
}
}
skip_line();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 13/28: [troff]: Fix code style nits.,
G. Branden Robinson <=