summaryrefslogtreecommitdiffstats
path: root/src/message.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/message.cpp')
-rw-r--r--src/message.cpp42
1 files changed, 33 insertions, 9 deletions
diff --git a/src/message.cpp b/src/message.cpp
index a787357..bbf578b 100644
--- a/src/message.cpp
+++ b/src/message.cpp
@@ -18,6 +18,9 @@
#include "debug.h"
#include "portable.h"
#include "message.h"
+#include "doxygen.h"
+
+#include <mutex>
static QCString outputFormat;
static const char *warning_str = "warning: ";
@@ -31,6 +34,11 @@ static const char *error_str = "error: ";
static FILE *warnFile = stderr;
+
+#if MULTITHREADED_INPUT
+static std::mutex g_mutex;
+#endif
+
void initWarningFormat()
{
// int filePos = Config_getString(WARN_FORMAT).find("$file");
@@ -104,6 +112,9 @@ void msg(const char *fmt, ...)
{
if (!Config_getBool(QUIET))
{
+#if MULTITHREADED_INPUT
+ std::unique_lock<std::mutex> lock(g_mutex);
+#endif
if (Debug::isFlagSet(Debug::Time))
{
printf("%.3f sec: ",((double)Debug::elapsedTime())/1000.0);
@@ -143,8 +154,13 @@ static void format_warn(const char *file,int line,const char *text)
}
msgText += '\n';
- // print resulting message
- fwrite(msgText.data(),1,msgText.length(),warnFile);
+ {
+#if MULTITHREADED_INPUT
+ std::unique_lock<std::mutex> lock(g_mutex);
+#endif
+ // print resulting message
+ fwrite(msgText.data(),1,msgText.length(),warnFile);
+ }
if (warnAsError)
{
exit(1);
@@ -240,14 +256,19 @@ extern void err_full(const char *file,int line,const char *fmt, ...)
void term(const char *fmt, ...)
{
- va_list args;
- va_start(args, fmt);
- vfprintf(warnFile, (QCString(error_str) + fmt).data(), args);
- va_end(args);
- if (warnFile != stderr)
{
- for (int i = 0; i < (int)strlen(error_str); i++) fprintf(warnFile, " ");
- fprintf(warnFile, "%s\n", "Exiting...");
+#if MULTITHREADED_INPUT
+ std::unique_lock<std::mutex> lock(g_mutex);
+#endif
+ va_list args;
+ va_start(args, fmt);
+ vfprintf(warnFile, (QCString(error_str) + fmt).data(), args);
+ va_end(args);
+ if (warnFile != stderr)
+ {
+ for (int i = 0; i < (int)strlen(error_str); i++) fprintf(warnFile, " ");
+ fprintf(warnFile, "%s\n", "Exiting...");
+ }
}
exit(1);
}
@@ -263,6 +284,9 @@ void printlex(int dbg, bool enter, const char *lexName, const char *fileName)
enter_txt_uc = "Finished";
}
+#if MULTITHREADED_INPUT
+ std::unique_lock<std::mutex> lock(g_mutex);
+#endif
if (dbg)
{
if (fileName)