1717#include < cstdlib>
1818#include < mutex>
1919#include < atomic>
20+ #include < unordered_set>
2021
2122#include " config.h"
2223#include " debug.h"
2526#include " doxygen.h"
2627#include " fileinfo.h"
2728#include " dir.h"
29+ #include " md5.h"
2830
2931// globals
3032static QCString g_warnFormat;
@@ -37,9 +39,20 @@ static QCString g_warnlogFile;
3739static bool g_warnlogTemp = false ;
3840static std::atomic_bool g_warnStat = false ;
3941static std::mutex g_mutex;
42+ static std::unordered_set<std::string> g_warnHash;
4043
4144// -----------------------------------------------------------------------------------------
4245
46+ static bool checkWarnMessage (QCString result)
47+ {
48+ uint8_t md5_sig[16 ];
49+ char sigStr[33 ];
50+ MD5Buffer (result.data (),result.length (),md5_sig);
51+ MD5SigToString (md5_sig,sigStr);
52+
53+ return g_warnHash.insert (sigStr).second ;
54+ }
55+
4356static void format_warn (const QCString &file,int line,const QCString &text)
4457{
4558 QCString fileSubst = file.isEmpty () ? " <unknown>" : file;
@@ -70,7 +83,7 @@ static void format_warn(const QCString &file,int line,const QCString &text)
7083 {
7184 std::unique_lock<std::mutex> lock (g_mutex);
7285 // print resulting message
73- fwrite (msgText.data (),1 ,msgText.length (),g_warnFile);
86+ if ( checkWarnMessage (msgText)) fwrite (msgText.data (),1 ,msgText.length (),g_warnFile);
7487 }
7588 if (g_warnBehavior == WARN_AS_ERROR_t::YES)
7689 {
@@ -150,15 +163,15 @@ void warn_(WarningType type, const QCString &file, int line, fmt::string_view fm
150163
151164void warn_uncond_ (fmt::string_view fmt, fmt::format_args args)
152165{
153- fmt::print (g_warnFile," {}{}" ,g_warningStr,vformat (fmt,args));
166+ if ( checkWarnMessage (g_errorStr+ fmt::vformat (fmt,args))) fmt::print (g_warnFile," {}{}" ,g_warningStr,vformat (fmt,args));
154167 handle_warn_as_error ();
155168}
156169
157170// -----------------------------------------------------------------------------------------
158171
159172void err_ (fmt::string_view fmt, fmt::format_args args)
160173{
161- fmt::print (g_warnFile," {}{}" ,g_errorStr,fmt::vformat (fmt,args));
174+ if ( checkWarnMessage (g_errorStr+ fmt::vformat (fmt,args))) fmt::print (g_warnFile," {}{}" ,g_errorStr,fmt::vformat (fmt,args));
162175 handle_warn_as_error ();
163176}
164177
@@ -175,7 +188,7 @@ void term_(fmt::string_view fmt, fmt::format_args args)
175188{
176189 {
177190 std::unique_lock<std::mutex> lock (g_mutex);
178- fmt::print (g_warnFile, " {}{}" , g_errorStr, fmt::vformat (fmt,args));
191+ if ( checkWarnMessage (g_errorStr+ fmt::vformat (fmt,args))) fmt::print (g_warnFile, " {}{}" , g_errorStr, fmt::vformat (fmt,args));
179192 if (g_warnFile != stderr)
180193 {
181194 size_t l = strlen (g_errorStr);
0 commit comments