lmi
[Top][All Lists]
Advanced

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

Re: [lmi] [PATCH] Fix headers display (was: Group premium quotes)


From: Vadim Zeitlin
Subject: Re: [lmi] [PATCH] Fix headers display (was: Group premium quotes)
Date: Thu, 27 Aug 2015 19:22:12 +0200

On Sun, 16 Aug 2015 17:07:38 +0000 Greg Chicares <address@hidden> wrote:

GC> And the headers seem to need more vertical room. I see:
GC> 
GC>         |               |              |    Annual
GC>         |    Annual    |    Annual    | Premium with
GC>  Annual | Premium with | Premium with |   Waiver &
GC> 
GC> where I'd expect another line like
GC> 
GC> Premium |    Waiver    |      ADB     |     ADB

 Sorry, this turned out to be another breakage introduced while fixing the
code to work with MinGW 3.4 and which went unnoticed during my rash testing
(I swear I do not do it on purpose to convince you that examining PDF files
visually is not the best way to check that they're correct -- but you could
definitely choose to interpret it as a proof for the need of automatic
tests...).

 Here is the trivial patch fixing this (also attached):
---------------------------------- >8 --------------------------------------
diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index baec6f9..73161d0 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -57,11 +57,15 @@ std::vector<std::string> split_in_lines(std::string const& 
s)
     // here.
     std::vector<std::string> lines;
     std::string line;
-    for(std::string::const_iterator i = s.begin(); i != s.end(); ++i)
+    for(std::string::const_iterator i = s.begin(); ; ++i)
         {
-        if('\n' == *i)
+        if(i == s.end() || '\n' == *i)
             {
             lines.push_back(line);
+            if(i == s.end())
+                {
+                break;
+                }
             line.clear();
             }
         else
---------------------------------- >8 --------------------------------------

 Sorry again for introducing this bug,
VZ

P.S. The condition in the "if" looks weird now but I really hope it could
     be fixed by writing it as "i == s.end() || *i == '\n'" instead of
     writing it as an even more unreadable "s.end() == i || ...". The use
     such Yoda conditions really doesn't have any justification since about
     20 years ago when all compilers implemented warnings for possibly
     accidental assignments.

Attachment: 0001-Fix-bug-in-split_in_lines-which-lost-the-last-line-e.patch
Description: Text document


reply via email to

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