gbranden pushed a commit to branch master
in repository groff.
commit b2000b64c8bad140add6c66fbe354531a39cf0d8
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Aug 19 10:33:57 2024 -0500
[troff]: Boolify and rename `class_flag`.
Boolify and rename `class_flag`, demoting it from `int` to `bool` and
calling it `using_character_classes`. Initialize and assign to it using
Boolean, not integer, literals.
* src/roff/troff/charinfo.h
(charinfo::overlaps_horizontally, charinfo::overlaps_vertically)
(charinfo::can_break_before, charinfo::can_break_after)
(charinfo::ends_sentence, charinfo::transparent)
(charinfo::ignore_hcodes)
(charinfo::prohibit_break_before, charinfo::prohibit_break_after)
(charinfo::inter_char_space, charinfo::add_to_class):
* src/roff/troff/input.cpp (get_flags): Do it.
---
ChangeLog | 16 ++++++++++++++++
src/roff/troff/charinfo.h | 30 +++++++++++++++---------------
src/roff/troff/input.cpp | 4 ++--
3 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index afa048f4f..a846b59dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2024-08-19 G. Branden Robinson <[email protected]>
+
+ [troff]: Boolify and rename `class_flag`, demoting it from `int`
+ to `bool` and calling it `using_character_classes`. Initialize
+ and assign to it using Boolean, not integer, literals.
+
+ * src/roff/troff/charinfo.h
+ (charinfo::overlaps_horizontally, charinfo::overlaps_vertically)
+ (charinfo::can_break_before, charinfo::can_break_after)
+ (charinfo::ends_sentence, charinfo::transparent)
+ (charinfo::ignore_hcodes)
+ (charinfo::prohibit_break_before)
+ (charinfo::prohibit_break_after)
+ (charinfo::inter_char_space, charinfo::add_to_class):
+ * src/roff/troff/input.cpp (get_flags): Do it.
+
2024-08-18 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp: Trivially refactor.
diff --git a/src/roff/troff/charinfo.h b/src/roff/troff/charinfo.h
index 02be5aa95..fc441088a 100644
--- a/src/roff/troff/charinfo.h
+++ b/src/roff/troff/charinfo.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
Written by James Clark ([email protected])
This file is part of groff.
@@ -19,7 +19,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <vector>
#include <utility>
-extern int class_flag; // set if there was a call to '.class'
+extern bool using_character_classes; // if `.class` is invoked
extern void get_flags();
class macro;
@@ -117,70 +117,70 @@ charinfo *get_charinfo_by_number(int);
inline int charinfo::overlaps_horizontally()
{
- if (class_flag)
+ if (using_character_classes)
::get_flags();
return flags & OVERLAPS_HORIZONTALLY;
}
inline int charinfo::overlaps_vertically()
{
- if (class_flag)
+ if (using_character_classes)
::get_flags();
return flags & OVERLAPS_VERTICALLY;
}
inline int charinfo::can_break_before()
{
- if (class_flag)
+ if (using_character_classes)
::get_flags();
return flags & BREAK_BEFORE;
}
inline int charinfo::can_break_after()
{
- if (class_flag)
+ if (using_character_classes)
::get_flags();
return flags & BREAK_AFTER;
}
inline int charinfo::ends_sentence()
{
- if (class_flag)
+ if (using_character_classes)
::get_flags();
return flags & ENDS_SENTENCE;
}
inline int charinfo::transparent()
{
- if (class_flag)
+ if (using_character_classes)
::get_flags();
return flags & TRANSPARENT;
}
inline int charinfo::ignore_hcodes()
{
- if (class_flag)
+ if (using_character_classes)
::get_flags();
return flags & IGNORE_HCODES;
}
inline int charinfo::prohibit_break_before()
{
- if (class_flag)
+ if (using_character_classes)
::get_flags();
return flags & DONT_BREAK_BEFORE;
}
inline int charinfo::prohibit_break_after()
{
- if (class_flag)
+ if (using_character_classes)
::get_flags();
return flags & DONT_BREAK_AFTER;
}
inline int charinfo::inter_char_space()
{
- if (class_flag)
+ if (using_character_classes)
::get_flags();
return flags & INTER_CHAR_SPACE;
}
@@ -276,7 +276,7 @@ inline symbol *charinfo::get_symbol()
inline void charinfo::add_to_class(int c)
{
- class_flag = 1;
+ using_character_classes = true;
// TODO ranges cumbersome for single characters?
ranges.push_back(std::pair<int, int>(c, c));
}
@@ -284,13 +284,13 @@ inline void charinfo::add_to_class(int c)
inline void charinfo::add_to_class(int lo,
int hi)
{
- class_flag = 1;
+ using_character_classes = true;
ranges.push_back(std::pair<int, int>(lo, hi));
}
inline void charinfo::add_to_class(charinfo *ci)
{
- class_flag = 1;
+ using_character_classes = true;
nested_classes.push_back(ci);
}
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 580a8932a..b9159d2be 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -87,7 +87,7 @@ void transparent_file();
token tok;
bool want_break = false;
-int class_flag = 0;
+bool using_character_classes = false;
bool want_color_output = true;
static int backtrace_flag = 0;
char *pipe_command = 0 /* nullptr */;
@@ -9392,7 +9392,7 @@ void get_flags()
assert(!s.is_null());
ci->get_flags();
}
- class_flag = 0;
+ using_character_classes = false;
}
// Get the union of all flags affecting this charinfo.
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit