Skip to content

Sprtf #626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Oct 4, 2017
Merged

Sprtf #626

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2758939
Removed SUPPORT_UTF16_ENCODINGS, and regen'd strings.
balthisar Oct 3, 2017
dfa2501
Removed option for SUPPORT_ASIAN_ENCODINGS, and regen'd strings.
balthisar Oct 3, 2017
a1e4dcc
Removed option for SUPPORT_ACCESSIBILITY_CHECKS, regen'd strings.
balthisar Oct 3, 2017
67f7b77
Added a flag to CMakeLists.txt simply to point out that one can build…
balthisar Oct 3, 2017
238b8f0
Wipe out dead code. We use git for a reason, so it's never really del…
balthisar Oct 3, 2017
558082c
Cleanup structure.
balthisar Oct 3, 2017
ff030aa
ELEMENT_HASH_LOOKUP is no longer conditional, and is a permanent part…
balthisar Oct 3, 2017
ab67229
AUTO_INPUT_ENCODING has been dead since first git commit.
balthisar Oct 3, 2017
9679d88
Format macros nicely.
balthisar Oct 3, 2017
9706b9e
Purged TIDY_STORE_ORIGINAL_TEXT.
balthisar Oct 3, 2017
e412297
TIDY_WIN32_MLANG_SUPPORT has been dead code for ages. Not tested, not…
balthisar Oct 3, 2017
4d2e750
Removed unused iconvtc from source
balthisar Oct 3, 2017
5ff6aa8
Not sure how this got missed...
balthisar Oct 3, 2017
8d7e5f7
Documentation formatting.
balthisar Oct 3, 2017
1cd0438
Standard Library file header; termporary notes for me.
balthisar Oct 3, 2017
4e3c1a1
Move all of the sprtf includes into tidyplatform.h
balthisar Oct 4, 2017
a137c06
Added debug to several files. WIP
balthisar Oct 4, 2017
ee54057
Added debug to several files. WIP
balthisar Oct 4, 2017
dedcb7b
SPRTF is now compatible with macOS and Linux, and most likely all sup…
balthisar Oct 4, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,21 @@ endif ()
# NOTE: Currently only available in the Debug configuration build in
# Windows, but could be maybe extended to Unix, others...
#------------------------------------------------------------------------
if (WIN32)
option( ENABLE_MEMORY_DEBUG "Set ON to output some memory diagnostics." OFF )
option( ENABLE_ALLOC_DEBUG "Set ON to output node allocation diagnostics." OFF )
option( ENABLE_CRTDBG_MEMORY "Set ON to enable the Windows CRT debug library." OFF )
option( ENABLE_ALLOC_DEBUG "Set ON to output node allocation diagnostics." OFF )
option( ENABLE_MEMORY_DEBUG "Set ON to output some memory diagnostics." OFF )

if (ENABLE_ALLOC_DEBUG)
add_definitions ( -DDEBUG_ALLOCATION ) # see lexer.c for details
message(STATUS "*** Note, lexer.c node allocation diagnostics are ON")
endif ()

if (ENABLE_MEMORY_DEBUG)
add_definitions ( -DDEBUG_MEMORY ) # see alloc.c for details
message(STATUS "*** Note, alloc.c memory diagnostics are ON")
endif ()
if (ENABLE_MEMORY_DEBUG)
add_definitions ( -DDEBUG_MEMORY ) # see alloc.c for details
message(STATUS "*** Note, alloc.c memory diagnostics are ON")
endif ()

if (ENABLE_ALLOC_DEBUG)
add_definitions ( -DDEBUG_ALLOCATION ) # see lexer.c for details
message(STATUS "*** Note, lexer.c node allocation diagnostics are ON")
endif ()
if (WIN32)
option( ENABLE_CRTDBG_MEMORY "Set ON to enable the Windows CRT debug library." OFF )

if (ENABLE_CRTDBG_MEMORY)
add_definitions ( -D_CRTDBG_MAP_ALLOC ) # see tidy.c for details
Expand Down Expand Up @@ -226,11 +227,10 @@ endif ()

#------------------------------------------------------------------------
# Macro Values
# These additional macros are set in Tidy's source code.
# These additional macros are set in Tidy's source code. It is *very*
# seldom that you would ever have to change any of these in order to
# achieve a functioning build.
#------------------------------------------------------------------------
add_definitions ( -DSUPPORT_UTF16_ENCODINGS=1 )
add_definitions ( -DSUPPORT_ASIAN_ENCODINGS=1 )
add_definitions ( -DSUPPORT_ACCESSIBILITY_CHECKS=1 )
add_definitions ( -DLIBTIDY_VERSION="${LIBTIDY_VERSION}" )
add_definitions ( -DRELEASE_DATE="${tidy_YEAR}/${tidy_MONTH}/${tidy_DAY}" )

Expand All @@ -239,6 +239,16 @@ if (TIDY_RC_NUMBER)
add_definitions ( -DRC_NUMBER="${TIDY_RC_NUMBER}" )
endif ()

# If your OS doesn't have native ISO2022 support, then build with this flag.
if (NO_NATIVE_ISO2022_SUPPORT)
add_definitions ( -DNO_NATIVE_ISO2022_SUPPORT=1 )
endif ()

# If your OS doesn't have library function access(), build with this flag.
if (NO_ACCESS_SUPPORT)
add_definitions ( -DNO_ACCESS_SUPPORT=1 )
endif ()

# Delete me? Not used in Tidy source!
add_definitions ( -DHAVE_CONFIG_H )

Expand Down Expand Up @@ -325,7 +335,7 @@ set ( CFILES
${SRCDIR}/buffio.c ${SRCDIR}/fileio.c ${SRCDIR}/streamio.c
${SRCDIR}/tagask.c ${SRCDIR}/tmbstr.c ${SRCDIR}/utf8.c
${SRCDIR}/tidylib.c ${SRCDIR}/mappedio.c ${SRCDIR}/gdoc.c
${SRCDIR}/language.c ${SRCDIR}/messageobj.c )
${SRCDIR}/language.c ${SRCDIR}/messageobj.c ${SRCDIR}/sprtf.c )

set ( HFILES
${INCDIR}/tidyplatform.h ${INCDIR}/tidy.h ${INCDIR}/tidyenum.h
Expand All @@ -343,13 +353,8 @@ set ( LIBHFILES
${SRCDIR}/pprint.h ${SRCDIR}/streamio.h ${SRCDIR}/tags.h
${SRCDIR}/tmbstr.h ${SRCDIR}/utf8.h ${SRCDIR}/tidy-int.h
${SRCDIR}/version.h ${SRCDIR}/gdoc.h ${SRCDIR}/language.h
${SRCDIR}/language_en.h ${SRCDIR}/win32tc.h )

if (MSVC)
list(APPEND CFILES ${SRCDIR}/sprtf.c)
list(APPEND LIBHFILES ${SRCDIR}/sprtf.h)
endif ()

${SRCDIR}/language_en.h ${SRCDIR}/sprtf.h )


#------------------------------------------------------------------------
# Target Locations
Expand Down
64 changes: 13 additions & 51 deletions console/tidy.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,23 @@
#include "tidybuffio.h"
#include "locale.h" /* for determing and setting locale */
#if defined(_WIN32)
#include <windows.h> /* Force console to UTF8. */
#endif
#if !defined(NDEBUG) && defined(_MSC_VER)
#include "sprtf.h"
#ifdef _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
# include <windows.h> /* Force console to UTF8. */
#endif
#if !defined(NDEBUG) && defined(_MSC_VER) && defined(_CRTDBG_MAP_ALLOC)
# include <stdlib.h>
# include <crtdbg.h>
#endif

#ifndef SPRTF
#define SPRTF printf
#endif
#include "sprtf.h"

/** Tidy will send errors to this file, which will be stderr later. */
static FILE* errout = NULL;

#if defined(_WIN32)
/** On Windows, we will store the original code page here. */
static uint win_cp; /* original Windows code page */
#if (defined(_MSC_VER) && (_MSC_VER < 1900))
#define snprintf _snprintf
#endif
static uint win_cp; /* original Windows code page */
# if (defined(_MSC_VER) && (_MSC_VER < 1900))
# define snprintf _snprintf
# endif
#endif


Expand Down Expand Up @@ -362,9 +356,7 @@ static const CmdOptDesc cmdopt_defs[] = {
{ CmdOptProcDir, "-xml", TC_OPT_XML, 0, "input-xml: yes" },
{ CmdOptProcDir, "-asxml", TC_OPT_ASXML, 0, "output-xhtml: yes", "-asxhtml" },
{ CmdOptProcDir, "-ashtml", TC_OPT_ASHTML, 0, "output-html: yes" },
#if SUPPORT_ACCESSIBILITY_CHECKS
{ CmdOptProcDir, "-access <%s>", TC_OPT_ACCESS, TC_LABEL_LEVL, "accessibility-check: <%s>" },
#endif
{ CmdOptCharEnc, "-raw", TC_OPT_RAW, 0, NULL },
{ CmdOptCharEnc, "-ascii", TC_OPT_ASCII, 0, NULL },
{ CmdOptCharEnc, "-latin0", TC_OPT_LATIN0, 0, NULL },
Expand All @@ -376,15 +368,11 @@ static const CmdOptDesc cmdopt_defs[] = {
{ CmdOptCharEnc, "-mac", TC_OPT_MAC, 0, NULL },
{ CmdOptCharEnc, "-win1252", TC_OPT_WIN1252, 0, NULL },
{ CmdOptCharEnc, "-ibm858", TC_OPT_IBM858, 0, NULL },
#if SUPPORT_UTF16_ENCODINGS
{ CmdOptCharEnc, "-utf16le", TC_OPT_UTF16LE, 0, NULL },
{ CmdOptCharEnc, "-utf16be", TC_OPT_UTF16BE, 0, NULL },
{ CmdOptCharEnc, "-utf16", TC_OPT_UTF16, 0, NULL },
#endif
#if SUPPORT_ASIAN_ENCODINGS /* #431953 - RJ */
{ CmdOptCharEnc, "-big5", TC_OPT_BIG5, 0, NULL },
{ CmdOptCharEnc, "-shiftjis", TC_OPT_SHIFTJIS, 0, NULL },
#endif
{ CmdOptMisc, "-version", TC_OPT_VERSION, 0, NULL, "-v" },
{ CmdOptMisc, "-help", TC_OPT_HELP, 0, NULL, "-h", "-?" },
{ CmdOptMisc, "-help-config", TC_OPT_HELPCFG, 0, NULL },
Expand Down Expand Up @@ -2021,11 +2009,10 @@ int main( int argc, char** argv )
uint accessWarnings = 0;

#if !defined(NDEBUG) && defined(_MSC_VER)
#if defined(_CRTDBG_MAP_ALLOC)
# if defined(_CRTDBG_MAP_ALLOC)
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
# endif
set_log_file((char *)"temptidy.txt", 0);
/* add_append_log(1); */
#endif

tdoc = tidyCreate();
Expand Down Expand Up @@ -2144,15 +2131,11 @@ int main( int argc, char** argv )
#ifndef NO_NATIVE_ISO2022_SUPPORT
strcasecmp(arg, "iso2022") == 0 ||
#endif
#if SUPPORT_UTF16_ENCODINGS
strcasecmp(arg, "utf16le") == 0 ||
strcasecmp(arg, "utf16be") == 0 ||
strcasecmp(arg, "utf16") == 0 ||
#endif
#if SUPPORT_ASIAN_ENCODINGS
strcasecmp(arg, "shiftjis") == 0 ||
strcasecmp(arg, "big5") == 0 ||
#endif
strcasecmp(arg, "mac") == 0 ||
strcasecmp(arg, "win1252") == 0 ||
strcasecmp(arg, "ibm858") == 0 )
Expand Down Expand Up @@ -2365,8 +2348,6 @@ int main( int argc, char** argv )
--argc;
}
}

#if SUPPORT_ACCESSIBILITY_CHECKS
else if ( strcasecmp(arg, "access") == 0 )
{
if ( argc >= 3 )
Expand All @@ -2381,7 +2362,6 @@ int main( int argc, char** argv )
}
}
}
#endif

else
{
Expand Down Expand Up @@ -2446,7 +2426,7 @@ int main( int argc, char** argv )
if ( argc > 1 )
{
htmlfil = argv[1];
#if (!defined(NDEBUG) && defined(_MSC_VER))
#if (!defined(NDEBUG))
SPRTF("Tidying '%s'\n", htmlfil);
#endif /* DEBUG outout */
if ( tidyOptGetBool(tdoc, TidyEmacs) )
Expand All @@ -2464,24 +2444,6 @@ int main( int argc, char** argv )

if ( status >= 0 ) {
status = tidyRunDiagnostics( tdoc );
/*\ Issue #119 - but not really related to 'custom_tags' support.
* Issue ?: To remove some 2014 extra debug output - I wanted to
* remove the Info: messages, but chose to except one, namely
* tidyReportDoctype(), but never intended keeping it here
* for so long!
* That doctype Info:, and all others, are still reported by
* default. geoff
\*/
#if 0 /* 000000000 this code can be removed some time in future 00000000000 */
if ( !tidyOptGetBool(tdoc, TidyQuiet) ) {
/* NOT quiet, show DOCTYPE, if not already shown */
if (!tidyOptGetBool(tdoc, TidyShowInfo)) {
tidyOptSetBool( tdoc, TidyShowInfo, yes );
tidyReportDoctype( tdoc ); /* FIX20140913: like warnings, errors, ALWAYS report DOCTYPE */
tidyOptSetBool( tdoc, TidyShowInfo, no );
}
}
#endif /* 000000000 this code can be removed some time in future 00000000000 */
}
if ( status > 1 ) /* If errors, do we want to force output? */
status = ( tidyOptGetBool(tdoc, TidyForceOutput) ? status : -1 );
Expand All @@ -2496,7 +2458,7 @@ int main( int argc, char** argv )
if ( outfil ) {
status = tidySaveFile( tdoc, outfil );
} else {
#if !defined(NDEBUG) && defined(_MSC_VER)
#if !defined(NDEBUG)
static char tmp_buf[264];
sprintf(tmp_buf,"%s.html",get_log_file());
status = tidySaveFile( tdoc, tmp_buf );
Expand Down
14 changes: 6 additions & 8 deletions include/tidy.h
Original file line number Diff line number Diff line change
Expand Up @@ -1418,10 +1418,8 @@ TIDY_EXPORT double TIDY_CALL tidyGetArgValueDouble(TidyMessage tmessage, /**<
** Your callback function will be provided with the following parameters.
** @param tdoc Indicates the source tidy document.
** @param line Indicates the line in the source document at this point in the process.
** @param column Indicates the column in the source document at this point in the process.
** @param col Indicates the column in the source document at this point in the process.
** @param destLine Indicates the line number in the output document at this point in the process.
** @return Your callback function will return `yes` if Tidy should include the
** report in its own output sink, or `no` if Tidy should suppress it.
*/
typedef void (TIDY_CALL *TidyPPProgress)( TidyDoc tdoc, uint line, uint col, uint destLine );

Expand Down Expand Up @@ -1898,7 +1896,7 @@ TIDY_EXPORT uint TIDY_CALL tidyErrorCodeFromKey(ctmbstr code);
** @result Returns a TidyIterator, which is a token used to represent the
** current position in a list within LibTidy.
*/
TIDY_EXPORT TidyIterator TIDY_CALL getErrorCodeList();
TIDY_EXPORT TidyIterator TIDY_CALL getErrorCodeList(void);

/** Given a valid TidyIterator initiated with getErrorCodeList(), returns
** an instance of the opaque type TidyMessageArgument, which serves as a token
Expand Down Expand Up @@ -1946,7 +1944,7 @@ TIDY_EXPORT Bool TIDY_CALL tidySetLanguage( ctmbstr languageCode );
/** Gets the current language used by Tidy.
** @result Returns a string indicating the currently set language.
*/
TIDY_EXPORT ctmbstr TIDY_CALL tidyGetLanguage();
TIDY_EXPORT ctmbstr TIDY_CALL tidyGetLanguage(void);

/** @}
** @name Locale Mappings
Expand Down Expand Up @@ -1978,7 +1976,7 @@ opaque_type(tidyLocaleMapItem);
** @result Returns a TidyIterator, which is a token used to represent the
** current position in a list within LibTidy.
*/
TIDY_EXPORT TidyIterator TIDY_CALL getWindowsLanguageList();
TIDY_EXPORT TidyIterator TIDY_CALL getWindowsLanguageList(void);

/** Given a valid TidyIterator initiated with getWindowsLanguageList(), returns
** a pointer to a tidyLocaleMapItem, which can be further interrogated with
Expand Down Expand Up @@ -2046,7 +2044,7 @@ TIDY_EXPORT ctmbstr TIDY_CALL tidyDefaultString( uint messageType );
** @result Returns a TidyIterator, which is a token used to represent the
** current position in a list within LibTidy.
*/
TIDY_EXPORT TidyIterator TIDY_CALL getStringKeyList();
TIDY_EXPORT TidyIterator TIDY_CALL getStringKeyList(void);

/** Given a valid TidyIterator initiated with getStringKeyList(), returns
** an unsigned integer representing the next key value.
Expand Down Expand Up @@ -2076,7 +2074,7 @@ TIDY_EXPORT uint TIDY_CALL getNextStringKey( TidyIterator* iter );
** @result Returns a TidyIterator, which is a token used to represent the
** current position in a list within LibTidy.
*/
TIDY_EXPORT TidyIterator TIDY_CALL getInstalledLanguageList();
TIDY_EXPORT TidyIterator TIDY_CALL getInstalledLanguageList(void);

/** Given a valid TidyIterator initiated with getInstalledLanguageList(),
** returns a string representing a language name that is installed in Tidy.
Expand Down
22 changes: 0 additions & 22 deletions include/tidyenum.h
Original file line number Diff line number Diff line change
Expand Up @@ -603,30 +603,18 @@ typedef enum
TidyMergeEmphasis, /**< Merge nested B and I elements */
TidyMergeSpans, /**< Merge multiple SPANs */
TidyMetaCharset, /**< Adds/checks/fixes meta charset in the head, based on document type */
#if SUPPORT_ASIAN_ENCODINGS
TidyNCR, /**< Allow numeric character references */
#else
TidyNCRNotUsed, /**< This option is not compiled in */
#endif
TidyNewline, /**< Output line ending (default to platform) */
TidyNumEntities, /**< Use numeric entities */
TidyOmitOptionalTags, /**< Suppress optional start tags and end tags */
TidyOutCharEncoding, /**< Output character encoding (if different) */
TidyOutFile, /**< File name to write markup to */
#if SUPPORT_UTF16_ENCODINGS
TidyOutputBOM, /**< Output a Byte Order Mark (BOM) for UTF-16 encodings */
#else
TidyOutputBOMNotUsed, /**< This option is not compiled in */
#endif
TidyPPrintTabs, /**< Indent using tabs istead of spaces */
TidyPreserveEntities, /**< Preserve entities */
TidyPreTags, /**< Declared pre tags */
TidyPriorityAttributes, /**< Attributes to place first in an element */
#if SUPPORT_ASIAN_ENCODINGS
TidyPunctWrap, /**< consider punctuation and breaking spaces for wrapping */
#else
TidyPunctWrapNotUsed, /**< This option is not compiled in */
#endif
TidyQuiet, /**< No 'Parsing X', guessed DTD or summary */
TidyQuoteAmpersand, /**< Output naked ampersand as &amp; */
TidyQuoteMarks, /**< Output " marks as &quot; */
Expand Down Expand Up @@ -756,17 +744,11 @@ typedef enum
TidyEncMac,
TidyEncWin1252,
TidyEncIbm858,

#if SUPPORT_UTF16_ENCODINGS
TidyEncUtf16le,
TidyEncUtf16be,
TidyEncUtf16,
#endif

#if SUPPORT_ASIAN_ENCODINGS
TidyEncBig5,
TidyEncShiftjis
#endif
} TidyEncodingOptions;


Expand Down Expand Up @@ -1424,11 +1406,7 @@ typedef enum
FOREACH_FOOTNOTE_MSG(MAKE_ENUM)
FOREACH_DIALOG_MSG(MAKE_ENUM)
FOREACH_REPORT_MSG(MAKE_ENUM)

#if SUPPORT_ACCESSIBILITY_CHECKS
/* Defined in `access.h` */
FOREACH_ACCESS_MSG(MAKE_ENUM)
#endif

#if SUPPORT_CONSOLE_APP
FOREACH_MSG_CONSOLE(MAKE_ENUM)
Expand Down
Loading