From c18c9c5a0493bca0c978911460da67ef5e59b442 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 19 Nov 2009 10:23:12 +0100 Subject: move Catcut's description generation to lib/Utils/make_descr.cpp Signed-off-by: Denys Vlasenko --- lib/Utils/make_descr.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'lib/Utils/make_descr.cpp') diff --git a/lib/Utils/make_descr.cpp b/lib/Utils/make_descr.cpp index 0c09614..46dd48c 100644 --- a/lib/Utils/make_descr.cpp +++ b/lib/Utils/make_descr.cpp @@ -2,6 +2,15 @@ //#include "abrt_types.h" #include "CrashTypes.h" #include "DebugDump.h" /* FILENAME_ARCHITECTURE etc */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#if ENABLE_NLS +# include +# define _(S) gettext(S) +#else +# define _(S) (S) +#endif using namespace std; @@ -131,3 +140,65 @@ string make_description_logger(const map_crash_report_t& pCrashReport) return description; } + +/* This needs more work to make the result less ugly */ +string make_description_catcut(const map_crash_report_t& pCrashReport) +{ + map_crash_report_t::const_iterator end = pCrashReport.end(); + map_crash_report_t::const_iterator it; + + string howToReproduce; + it = pCrashReport.find(CD_REPRODUCE); + if (it != end) + { + howToReproduce = "\n\nHow to reproduce\n" + "-----\n"; + howToReproduce += it->second[CD_CONTENT]; + } + string comment; + it = pCrashReport.find(CD_COMMENT); + if (it != end) + { + comment = "\n\nComment\n" + "-----\n"; + comment += it->second[CD_CONTENT]; + } + + string pDescription = "\nabrt "VERSION" detected a crash.\n"; + pDescription += howToReproduce; + pDescription += comment; + pDescription += "\n\nAdditional information\n" + "======\n"; + + for (it = pCrashReport.begin(); it != end; it++) + { + if (it->second[CD_TYPE] == CD_TXT) + { + if (it->first != CD_UUID + && it->first != FILENAME_ARCHITECTURE + && it->first != FILENAME_RELEASE + && it->first != CD_REPRODUCE + && it->first != CD_COMMENT + ) { + pDescription += '\n'; + pDescription += it->first; + pDescription += "\n-----\n"; + pDescription += it->second[CD_CONTENT]; + pDescription += "\n\n"; + } + } + else if (it->second[CD_TYPE] == CD_ATT) + { + pDescription += "\n\nAttached files\n" + "----\n"; + pDescription += it->first; + pDescription += '\n'; + } + else if (it->second[CD_TYPE] == CD_BIN) + { + error_msg(_("Binary file %s will not be reported"), it->first.c_str()); + } + } + + return pDescription; +} -- cgit From c3afe7c8ea7ccb147e30ccbafbfcdad279d479aa Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 19 Nov 2009 13:26:08 +0100 Subject: make BZ insert small text attachments inline; move text file detection code Run-tested Signed-off-by: Denys Vlasenko --- lib/Utils/make_descr.cpp | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'lib/Utils/make_descr.cpp') diff --git a/lib/Utils/make_descr.cpp b/lib/Utils/make_descr.cpp index 46dd48c..c4cc3f3 100644 --- a/lib/Utils/make_descr.cpp +++ b/lib/Utils/make_descr.cpp @@ -51,6 +51,9 @@ static void add_content(bool &was_multiline, string& description, const char *he } } +/* Text attachments smaller than this will be also included in descrition */ +#define INLINE_TEXT_ATT_SIZE 1024 + string make_description_bz(const map_crash_report_t& pCrashReport) { string description; @@ -77,8 +80,9 @@ string make_description_bz(const map_crash_report_t& pCrashReport) const string &filename = it->first; const string &type = it->second[CD_TYPE]; const string &content = it->second[CD_CONTENT]; - if (type == CD_TXT) - { + if (type == CD_TXT + || (type == CD_ATT && content.size() < INLINE_TEXT_ATT_SIZE) + ) { if (filename != CD_UUID && filename != FILENAME_ARCHITECTURE && filename != FILENAME_RELEASE @@ -87,8 +91,9 @@ string make_description_bz(const map_crash_report_t& pCrashReport) ) { add_content(was_multiline, description, filename.c_str(), content.c_str()); } + continue; } - else if (type == CD_ATT) + if (type == CD_ATT) { add_content(was_multiline, description, "Attached file", filename.c_str()); } @@ -172,31 +177,34 @@ string make_description_catcut(const map_crash_report_t& pCrashReport) for (it = pCrashReport.begin(); it != end; it++) { - if (it->second[CD_TYPE] == CD_TXT) + const string &filename = it->first; + const string &type = it->second[CD_TYPE]; + const string &content = it->second[CD_CONTENT]; + if (type == CD_TXT) { - if (it->first != CD_UUID - && it->first != FILENAME_ARCHITECTURE - && it->first != FILENAME_RELEASE - && it->first != CD_REPRODUCE - && it->first != CD_COMMENT + if (filename != CD_UUID + && filename != FILENAME_ARCHITECTURE + && filename != FILENAME_RELEASE + && filename != CD_REPRODUCE + && filename != CD_COMMENT ) { pDescription += '\n'; - pDescription += it->first; + pDescription += filename; pDescription += "\n-----\n"; - pDescription += it->second[CD_CONTENT]; + pDescription += content; pDescription += "\n\n"; } } - else if (it->second[CD_TYPE] == CD_ATT) + else if (type == CD_ATT) { pDescription += "\n\nAttached files\n" "----\n"; - pDescription += it->first; + pDescription += filename; pDescription += '\n'; } - else if (it->second[CD_TYPE] == CD_BIN) + else if (type == CD_BIN) { - error_msg(_("Binary file %s will not be reported"), it->first.c_str()); + error_msg(_("Binary file %s will not be reported"), filename.c_str()); } } -- cgit