groff-commit
[Top][All Lists]
Advanced

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

[groff] 07/26: src/preproc/tbl/table.cpp: Fix code style nits.


From: G. Branden Robinson
Subject: [groff] 07/26: src/preproc/tbl/table.cpp: Fix code style nits.
Date: Sun, 14 Nov 2021 22:04:25 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit e53f81bc87bf2868fa837281bca6c06181cc8f38
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Nov 13 06:09:52 2021 +1100

    src/preproc/tbl/table.cpp: Fix code style nits.
    
    * src/preproc/tbl/table.cpp (table::do_vspan): Fix code style nits.
      Swap order of null pointer and zero equality comparisons when a typo
      or thinko could lead to lvalue assignment.  Break a series of 6 and-ed
      assertion predicates into separate `assert()` calls--sure to be less
      maddening for anyone who has to debug such a contingency.  Clarify
      comment since C++98 didn't yet have `nullptr`.
---
 ChangeLog                 | 10 ++++++++++
 src/preproc/tbl/table.cpp | 16 +++++++++-------
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b0e5025..48a0429 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2021-11-13  G. Branden Robinson <g.branden.robinson@gmail.com>
 
+       * src/preproc/tbl/table.cpp (table::do_vspan): Fix code style
+       nits.  Swap order of null pointer and zero equality comparisons
+       when a typo or thinko could lead to lvalue assignment.  Break a
+       series of 6 and-ed assertion predicates into separate `assert()`
+       calls--sure to be less maddening for anyone who has to debug
+       such a contingency.  Clarify comment since C++98 didn't yet have
+       `nullptr`.
+
+2021-11-13  G. Branden Robinson <g.branden.robinson@gmail.com>
+
        [m4]: Clean up shell variable quoting and bracing.
 
        * m4/groff.m4 (GROFF_PROG_YACC, GROFF_MAKEINFO,
diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp
index 6b16625..444333c 100644
--- a/src/preproc/tbl/table.cpp
+++ b/src/preproc/tbl/table.cpp
@@ -1424,21 +1424,23 @@ void table::do_hspan(int r, int c)
 void table::do_vspan(int r, int c)
 {
   assert(r >= 0 && c >= 0 && r < nrows && c < ncolumns);
-  if (r == 0) {
+  if (0 == r) {
     error("first row cannot be vertically spanned");
     return;
   }
   table_entry *e = entry[r][c];
   if (e) {
-    assert(e->start_row <= r && r <= e->end_row
-          && e->start_col <= c && c <= e->end_col
-          && e->end_row - e->start_row > 0
-          && e->end_col - e->start_col > 0);
+    assert(e->start_row <= r);
+    assert(r <= e->end_row);
+    assert(e->start_col <= c);
+    assert(c <= e->end_col);
+    assert((e->end_row - e->start_row) > 0);
+    assert((e->end_col - e->start_col) > 0);
     return;
   }
   e = entry[r-1][c];
-  // e can be 0 if we had an empty entry or an error
-  if (e == 0)
+  // e can be a null pointer if we had an empty entry or an error
+  if (0 == e)
     return;
   if (e->start_col != c) {
     /* l s



reply via email to

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