From 24bf8c334c3c9aa9ddbd76bb5c1b0e8ab88762a7 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 7 Jul 2018 21:18:07 +0200 Subject: [PATCH 1/2] Add include statements (needed for following commit) Signed-off-by: Stefan Weil --- src/ccmain/thresholder.cpp | 1 + src/ccstruct/rect.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ccmain/thresholder.cpp b/src/ccmain/thresholder.cpp index 1bed1741..5b83dea5 100644 --- a/src/ccmain/thresholder.cpp +++ b/src/ccmain/thresholder.cpp @@ -21,6 +21,7 @@ #include "thresholder.h" +#include // for uint32_t #include #include "otsuthr.h" diff --git a/src/ccstruct/rect.cpp b/src/ccstruct/rect.cpp index 72773c22..f0049e07 100644 --- a/src/ccstruct/rect.cpp +++ b/src/ccstruct/rect.cpp @@ -1,8 +1,7 @@ /********************************************************************** * File: rect.cpp (Formerly box.c) * Description: Bounding box class definition. - * Author: Phil Cheatle - * Created: Wed Oct 16 15:18:45 BST 1991 + * Author: Phil Cheatle * * (C) Copyright 1991, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,7 +16,8 @@ * **********************************************************************/ -#include "rect.h" +#include "rect.h" +#include "strngs.h" // for STRING // Include automatically generated configuration file if running autoconf. #ifdef HAVE_CONFIG_H From 0d4975933e177f24fd7768b546fd1415f516e2a2 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 7 Jul 2018 12:02:02 +0200 Subject: [PATCH 2/2] Replace tprintf_internal by tprintf and clean tprintf code Commit 4d514d5a606f43b5fbbb163a7244f5e19d0f6e88 introduced tprintf_internal with an additional argument "level" which was removed again in commit 7dc5296fe992c4a0bbfb9a0672363e7c12d32460. So we can now restore the original state without tprintf_internal. Remove also the declaration of debug_window_on (it does not exist since commit 030aae98969d41cabb500560b3bac2262b91a344) and make the configuration parameter debug_file local as it is only used by tprintf. Signed-off-by: Stefan Weil --- src/ccutil/tprintf.cpp | 23 ++++++++++------------- src/ccutil/tprintf.h | 17 +++++------------ src/training/tlog.h | 2 +- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/src/ccutil/tprintf.cpp b/src/ccutil/tprintf.cpp index da196581..a51d040d 100644 --- a/src/ccutil/tprintf.cpp +++ b/src/ccutil/tprintf.cpp @@ -22,23 +22,20 @@ #include "config_auto.h" #endif -#include -#include -#include "ccutil.h" -#include "params.h" -#include "strngs.h" -#include "tprintf.h" +#include +#include +#include "ccutil.h" +#include "params.h" +#include "strngs.h" +#include "tprintf.h" #define MAX_MSG_LEN 65536 -#define EXTERN -// Since tprintf is protected by a mutex, these parameters can remain global. -DLLSYM STRING_VAR(debug_file, "", "File to send tprintf output to"); +static STRING_VAR(debug_file, "", "File to send tprintf output to"); -DLLSYM void -tprintf_internal( // Trace printf - const char *format, ... // Message -) { +// Trace printf +DLLSYM void tprintf(const char *format, ...) +{ tesseract::tprintfMutex.Lock(); va_list args; // variable args static FILE *debugfp = nullptr; // debug file diff --git a/src/ccutil/tprintf.h b/src/ccutil/tprintf.h index 27a33823..6622a3a2 100644 --- a/src/ccutil/tprintf.h +++ b/src/ccutil/tprintf.h @@ -17,20 +17,13 @@ * **********************************************************************/ -#ifndef TESSERACT_CCUTIL_TPRINTF_H -#define TESSERACT_CCUTIL_TPRINTF_H +#ifndef TESSERACT_CCUTIL_TPRINTF_H +#define TESSERACT_CCUTIL_TPRINTF_H -#include "params.h" - -extern DLLSYM STRING_VAR_H(debug_file, "", - "File to send tprintf output to"); -extern DLLSYM BOOL_VAR_H(debug_window_on, TRUE, - "Send tprintf to window unless file set"); +#include "platform.h" // for TESS_API // Main logging function. -#define tprintf(...) tprintf_internal(__VA_ARGS__) - -extern TESS_API void tprintf_internal( // Trace printf - const char *format, ...); // Message +extern TESS_API void tprintf( // Trace printf + const char *format, ...); // Message #endif // define TESSERACT_CCUTIL_TPRINTF_H diff --git a/src/training/tlog.h b/src/training/tlog.h index 6dcf6e6c..29db457c 100644 --- a/src/training/tlog.h +++ b/src/training/tlog.h @@ -32,7 +32,7 @@ DECLARE_INT_PARAM_FLAG(tlog_level); // config file like other params. #define tlog(level, ...) { \ if (FLAGS_tlog_level >= level) { \ - tprintf_internal(__VA_ARGS__); \ + tprintf(__VA_ARGS__); \ } \ }