[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 27c0391 1/2: Revisit yesterday's segfault, ph
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 27c0391 1/2: Revisit yesterday's segfault, phase I of II |
Date: |
Thu, 9 Mar 2017 13:33:03 -0500 (EST) |
branch: master
commit 27c0391c5ae3ea3d3c3cceaf17469e03db6049cd
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Revisit yesterday's segfault, phase I of II
Added simpler new code in parallel with the old. For the moment, both
are run, and an assertion fires if they do not behave identically.
---
group_quote_pdf_gen_wx.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 46 insertions(+), 2 deletions(-)
diff --git a/group_quote_pdf_gen_wx.cpp b/group_quote_pdf_gen_wx.cpp
index 99ab3b3..95ea992 100644
--- a/group_quote_pdf_gen_wx.cpp
+++ b/group_quote_pdf_gen_wx.cpp
@@ -176,6 +176,25 @@ wxString brbrb(std::string const& html)
);
}
+/// Generate HTML representation of a field name and value in an HTML table.
+///
+/// The HTML fragment generated by this function contains two <td> tags with
+/// the given contents.
+
+wxString name_value_as_html_table_data
+ (std::string const& name
+ ,std::string const& value
+ )
+{
+ return wxString::Format
+ ("<td nowrap align=\"right\"><b>%s%s </b></td>"
+ "<td>%s </td>"
+ ,escape_for_html_elem(name)
+ ,(value.empty() ? "" : ":")
+ ,escape_for_html_elem(value)
+ );
+}
+
/// Generate HTML representation of a field name and value in an HTML table and
/// append it to the specified string, defining the HTML.
///
@@ -1232,15 +1251,16 @@ void
group_quote_pdf_generator_wx::output_document_header
// TRICKY !! This for-statement deliberately does not increment
// 'i' at the top. Instead, 'i' is incremented in the body of the
// subordinate for-statement that iterates across 'col'.
+ wxString extra_fields;
for(auto i = fields.begin(); i != fields.end();)
{
// Start a new table row and ensure it will be closed.
- open_and_ensure_closing_tag tag_tr(summary_html, "tr");
+ open_and_ensure_closing_tag tag_tr(extra_fields, "tr");
// Add one (if there is only one) or two fields to this new row.
for(int col = 0; col < 2; ++col)
{
- append_name_value_to_html_table(summary_html, i->name, i->value);
+ append_name_value_to_html_table(extra_fields, i->name, i->value);
if(++i == fields.end())
{
@@ -1249,6 +1269,30 @@ void group_quote_pdf_generator_wx::output_document_header
}
}
+ wxString Y;
+ bool parity = true;
+ for(auto const& i : fields)
+ {
+ Y += parity ? "<tr>" : "";
+ Y += name_value_as_html_table_data(i.name, i.value);
+ Y += parity ? "" : "</tr>";
+ parity = !parity;
+ }
+ Y += parity ? "" : "</tr>";
+
+ if(Y != extra_fields)
+ {
+ warning()
+ << fields.size() << " fields.size()\n"
+ << extra_fields << " extra_fields\n"
+ << Y << " Y\n"
+ << LMI_FLUSH
+ ;
+ }
+ LMI_ASSERT(Y == extra_fields);
+
+ summary_html += extra_fields;
+
// Finally close the summary table.
summary_html += "</table>";