[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 690194e 2/2: Revisit yesterday's segfault, ph
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 690194e 2/2: Revisit yesterday's segfault, phase II of II |
Date: |
Thu, 9 Mar 2017 13:33:04 -0500 (EST) |
branch: master
commit 690194ecba42c34fe75171c8c55a5cc66c074eb0
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Revisit yesterday's segfault, phase II of II
Removed the old code and the testing framework from phase I.
---
group_quote_pdf_gen_wx.cpp | 95 ++--------------------------------------------
1 file changed, 4 insertions(+), 91 deletions(-)
diff --git a/group_quote_pdf_gen_wx.cpp b/group_quote_pdf_gen_wx.cpp
index 95ea992..a5ff966 100644
--- a/group_quote_pdf_gen_wx.cpp
+++ b/group_quote_pdf_gen_wx.cpp
@@ -195,58 +195,6 @@ wxString name_value_as_html_table_data
);
}
-/// Generate HTML representation of a field name and value in an HTML table and
-/// append it to the specified string, defining the HTML.
-///
-/// The HTML fragment generated by this function contains two <td> tags with
-/// the given contents.
-
-void append_name_value_to_html_table
- (wxString& html_table
- ,std::string const& name
- ,std::string const& value
- )
-{
- html_table += 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)
- );
-}
-
-/// Append the given tag to the string and ensure that the matching closing tag
-/// will be appended to it later.
-///
-/// This helper class helps with not forgetting the closing tags in the
-/// generated HTML. It doesn't actually make it impossible to forget them (this
-/// would require much heavier API and seems not to be worth it), but makes it
-/// less likely.
-
-class open_and_ensure_closing_tag
-{
- public:
- open_and_ensure_closing_tag(wxString& html, char const* tag)
- :html_(html)
- ,tag_(tag)
- {
- html_ << "<" << tag_ << ">";
- }
-
- ~open_and_ensure_closing_tag()
- {
- html_ << "</" << tag_ << ">";
- }
-
- private:
- open_and_ensure_closing_tag(open_and_ensure_closing_tag const&) = delete;
- open_and_ensure_closing_tag& operator=(open_and_ensure_closing_tag const&)
= delete;
-
- wxString& html_;
- wxString const tag_;
-};
-
/// Simple description of a custom field, consisting of a non-empty name and a
/// possibly empty string value.
///
@@ -1248,50 +1196,15 @@ void
group_quote_pdf_generator_wx::output_document_header
std::vector<extra_summary_field> const& f = report_data_.extra_fields_;
fields.insert(fields.end(), f.begin(), f.end());
- // 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(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(extra_fields, i->name, i->value);
-
- if(++i == fields.end())
- {
- break;
- }
- }
- }
-
- 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>";
+ summary_html += parity ? "<tr>" : "";
+ summary_html += name_value_as_html_table_data(i.name, i.value);
+ summary_html += 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;
+ summary_html += parity ? "" : "</tr>";
// Finally close the summary table.
summary_html += "</table>";