diff options
author | G. Branden Robinson <g.branden.robinson@gmail.com> | 2024-01-03 18:39:46 -0600 |
---|---|---|
committer | G. Branden Robinson <g.branden.robinson@gmail.com> | 2024-01-04 12:26:00 -0600 |
commit | c22df76cfd3b3e760aaab1d43590309b13fb6a2f (patch) | |
tree | 666eca93428f5d3cea71f02a0f40a39f9bbb3f6a | |
parent | 57462a90a9e0a63470ead09186679fa714811b45 (diff) |
src/libs/libgroff/glyphuni.cpp: Slightly refactor.
* src/libs/libgroff/glyphuni.cpp: Slightly refactor.
(glyph_to_unicode_init::glyph_to_unicode_init): Use `array_length()`
(our std::size for C++98) and `size_t` as type for loop index.
Also annotate null pointer with `nullptr` comment to ease any future
transition to C++11, which defines it as a keyword.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/libs/libgroff/glyphuni.cpp | 6 |
2 files changed, 9 insertions, 4 deletions
@@ -4,6 +4,13 @@ 2024-01-03 G. Branden Robinson <g.branden.robinson@gmail.com> + * src/libs/libgroff/glyphuni.cpp: Slightly refactor. + (glyph_to_unicode_init::glyph_to_unicode_init): Use + `array_length()` (our std::size for C++98) and `size_t` as type + for loop index. + +2024-01-03 G. Branden Robinson <g.branden.robinson@gmail.com> + * src/libs/libgroff/glyphuni.cpp: Trivially refactor. (struct glyph_to_unicode): Rename this... (struct glyph_to_unicode_map): ...to this. We already have a diff --git a/src/libs/libgroff/glyphuni.cpp b/src/libs/libgroff/glyphuni.cpp index a4ff3a746..cad59b858 100644 --- a/src/libs/libgroff/glyphuni.cpp +++ b/src/libs/libgroff/glyphuni.cpp @@ -506,9 +506,7 @@ static struct glyph_to_unicode_init { glyph_to_unicode_init::glyph_to_unicode_init() { - for (unsigned int i = 0; - i < sizeof(glyph_to_unicode_list)/sizeof(glyph_to_unicode_list[0]); - i++) { + for (size_t i = 0; i < array_length(glyph_to_unicode_list); i++) { glyph_to_unicode_map *gtu = new glyph_to_unicode_map[1]; gtu->value = (char *)glyph_to_unicode_list[i].value; glyph_to_unicode_table.define(glyph_to_unicode_list[i].key, gtu); @@ -518,7 +516,7 @@ glyph_to_unicode_init::glyph_to_unicode_init() const char *glyph_name_to_unicode(const char *s) { glyph_to_unicode_map *result = glyph_to_unicode_table.lookup(s); - return result ? result->value : 0; + return result ? result->value : 0 /* nullptr */; } // Local Variables: |