groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 08/18: src/libs/libgroff/glyphuni.cpp: Slightly refactor.


From: G. Branden Robinson
Subject: [groff] 08/18: src/libs/libgroff/glyphuni.cpp: Slightly refactor.
Date: Fri, 5 Jan 2024 22:25:18 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit c22df76cfd3b3e760aaab1d43590309b13fb6a2f
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Jan 3 18:39:46 2024 -0600

    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.
---
 ChangeLog                      | 7 +++++++
 src/libs/libgroff/glyphuni.cpp | 6 ++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4b0f30bae..18dae35c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,13 @@
 
        * src/utils/grog/grog.pl: Trivially refactor; simplify code.
 
+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.
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:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]