Issue #604 - Try to fix. Initial cut. WIP

This commit is contained in:
Geoff McLane 2017-10-13 20:50:53 +02:00
parent 0f86647741
commit 3b154dc407
10 changed files with 43 additions and 41 deletions

View file

@ -22,15 +22,12 @@
#include "tidy.h" #include "tidy.h"
#include "tidybuffio.h" #include "tidybuffio.h"
#include "locale.h" #include "locale.h"
#include "sprtf.h"
#if defined(_WIN32) #if defined(_WIN32)
# include <windows.h> /* Force console to UTF8. */ # include <windows.h> /* Force console to UTF8. */
#endif #endif
#ifdef ENABLE_DEBUG_LOG
# include "sprtf.h"
#endif
#if defined(ENABLE_DEBUG_LOG) && defined(_MSC_VER) && defined(_CRTDBG_MAP_ALLOC) #if defined(ENABLE_DEBUG_LOG) && defined(_MSC_VER) && defined(_CRTDBG_MAP_ALLOC)
# include <stdlib.h> # include <stdlib.h>
# include <crtdbg.h> # include <crtdbg.h>
@ -2016,7 +2013,6 @@ int main( int argc, char** argv )
# if defined(_CRTDBG_MAP_ALLOC) # if defined(_CRTDBG_MAP_ALLOC)
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
# endif # endif
set_log_file((char *)"temptidy.txt", 0);
#endif #endif
tdoc = tidyCreate(); tdoc = tidyCreate();

View file

@ -483,6 +483,9 @@ extern "C" {
# if defined(_MSC_VER) # if defined(_MSC_VER)
# define fileno _fileno # define fileno _fileno
#if !defined(NDEBUG) && !defined(ENABLE_DEBUG_LOG) && !defined(DISABLE_DEBUG_LOG)
#define ENABLE_DEBUG_LOG
#endif
#endif #endif
# define access _access # define access _access
@ -651,38 +654,8 @@ opaque_type( TidyIterator );
} /* extern "C" */ } /* extern "C" */
#endif #endif
/*=============================================================================
* Debugging
* When building and defining the ENABLE_DEBUG_LOG macro, Tidy will output
* extensive debug information. In addition to this macro, you can supply
* build flags for additional diagnostic information:
* - _CRTDBG_MAP_ALLOC (_MSC_VER only)
* - DEBUG_ALLOCATION
* - DEBUG_MEMORY
*
* You can use DEBUG_LOG( SPRTF() ) to avoid #ifdef ENABLE_DEBUG_LOG for
* one-liners.
*===========================================================================*/
#ifdef ENABLE_DEBUG_LOG
# include "sprtf.h"
#endif
#ifndef SPRTF
# define SPRTF printf
#endif
#ifdef ENABLE_DEBUG_LOG
# define DEBUG_LOG(ARG) do { ARG; } while(0)
#else
# define DEBUG_LOG(ARG)
#endif
#endif /* __TIDY_PLATFORM_H__ */ #endif /* __TIDY_PLATFORM_H__ */
/* /*
* local variables: * local variables:
* mode: c * mode: c

View file

@ -9,6 +9,7 @@
#include "tidy.h" #include "tidy.h"
#include "forward.h" #include "forward.h"
#include "sprtf.h"
static TidyMalloc g_malloc = NULL; static TidyMalloc g_malloc = NULL;
static TidyRealloc g_realloc = NULL; static TidyRealloc g_realloc = NULL;

View file

@ -13,6 +13,7 @@
#include "forward.h" #include "forward.h"
#include "fileio.h" #include "fileio.h"
#include "tidy.h" #include "tidy.h"
#include "sprtf.h"
typedef struct _fp_input_source typedef struct _fp_input_source
{ {

View file

@ -39,6 +39,7 @@
#include "clean.h" #include "clean.h"
#include "utf8.h" #include "utf8.h"
#include "streamio.h" #include "streamio.h"
#include "sprtf.h"
#if defined(ENABLE_DEBUG_LOG) #if defined(ENABLE_DEBUG_LOG)
/* #define DEBUG_ALLOCATION special EXTRA allocation debug information - VERY NOISY */ /* #define DEBUG_ALLOCATION special EXTRA allocation debug information - VERY NOISY */

View file

@ -12,6 +12,7 @@
#include "clean.h" #include "clean.h"
#include "tags.h" #include "tags.h"
#include "tmbstr.h" #include "tmbstr.h"
#include "sprtf.h"
/* /*
Issue #72 - Need to know to avoid error-reporting - no warning only if --show-body-only yes Issue #72 - Need to know to avoid error-reporting - no warning only if --show-body-only yes

View file

@ -56,11 +56,8 @@ char *GetNxtBuf()
} }
#define MXIO 512 #define MXIO 512
#ifdef _MSC_VER /* use local log */
static char def_log[] = "tempex.txt"; static char def_log[] = "temptidy.txt"; /* use local log */
#else
static char def_log[] = "ex.log";
#endif
static char logfile[264] = "\0"; static char logfile[264] = "\0";
static FILE * outfile = NULL; static FILE * outfile = NULL;
static int addsystime = 0; static int addsystime = 0;

View file

@ -25,6 +25,36 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif
/*=============================================================================
* EXTRA Debugging, and information aid.
*
* When building and defining the ENABLE_DEBUG_LOG macro, Tidy will output
* extensive debug information. In addition to this macro, you can supply
* cmake build flags for additional diagnostic information:
* - -DENABLE_ALLOC_DEBUG:BOOL=ON - DEBUG_ALLOCATION
* - -DENABLE_MEMORY_DEBUG:BOOL=ON - DEBUG_MEMORY
* - -DENABLE_CRTDBG_MEMORY:BOOL=ON - _CRTDBG_MAP_ALLOC (WIN32 only)
*
* _MSC_VER Only - ENABLE_DEBUG_LOG is automatically enabled in the Debug
* build, unless DISABLE_DEBUG_LOG is defined. See 'tidyplatform.h'
*
* You can use DEBUG_LOG( SPRTF() ) to avoid #ifdef ENABLE_DEBUG_LOG for
* one-liners.
*
* This EXTRA Debug information is also written to a 'temptidy.txt' log
* file, for review, and analysis.
*
*===========================================================================*/
#ifndef SPRTF
# define SPRTF sprtf
#endif
#ifdef ENABLE_DEBUG_LOG
# define DEBUG_LOG(ARG) do { ARG; } while(0)
#else
# define DEBUG_LOG(ARG)
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER

View file

@ -10,6 +10,8 @@
#include "tidy-int.h" #include "tidy-int.h"
#include "message.h" #include "message.h"
#include "tmbstr.h" #include "tmbstr.h"
#include "sprtf.h"
/* Attribute checking methods */ /* Attribute checking methods */
static CheckAttribs CheckIMG; static CheckAttribs CheckIMG;
static CheckAttribs CheckLINK; static CheckAttribs CheckLINK;

View file

@ -33,7 +33,7 @@
#include "utf8.h" #include "utf8.h"
#include "mappedio.h" #include "mappedio.h"
#include "language.h" #include "language.h"
#include "sprtf.h"
/* Create/Destroy a Tidy "document" object */ /* Create/Destroy a Tidy "document" object */
static TidyDocImpl* tidyDocCreate( TidyAllocator *allocator ); static TidyDocImpl* tidyDocCreate( TidyAllocator *allocator );