From 298deb0a047da064ee335a194b9533d1c457f1a7 Mon Sep 17 00:00:00 2001 From: Jim Derry Date: Sun, 1 Oct 2017 10:39:30 -0400 Subject: [PATCH 1/2] Update CMakeLists and tidyplatform to include automatic support for using runtime configuration files on Unix-like platforms. This addresses #584 in the strictest sense, but some message work needs to happen as a result of this change. Additionally, the tidyplatform.h has been reformatted for legibility as part of the continuing (slow) effort to improve our internal documentation. --- CMakeLists.txt | 42 ++- include/tidyplatform.h | 735 +++++++++++++++++++++-------------------- 2 files changed, 408 insertions(+), 369 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f0b99b..1c7e957 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,17 +157,43 @@ if (TIDY_RC_NUMBER) add_definitions ( -DRC_NUMBER="${TIDY_RC_NUMBER}" ) endif () -# Issue #188 - Support user items in platform.h -if (TIDY_CONFIG_FILE) - add_definitions( -DTIDY_CONFIG_FILE="${TIDY_CONFIG_FILE}" ) -endif () -if (TIDY_USER_CONFIG_FILE) - add_definitions( -DTIDY_USER_CONFIG_FILE="${TIDY_USER_CONFIG_FILE}" ) -endif () -if (SUPPORT_GETPWNAM) + +#============================================================================= +# Unix console application features +# By default on Unix-like systems when building for the console program, +# support runtime configuration files in /etc/ and in ~/. To prevent this, +# set ENABLE_CONFIG_FILES to NO. Specify -DTIDY_CONFIG_FILE and/or +# -DTIDY_USER_CONFIG_FILE to override the default paths in tidyplatform.h. +# @note: this section refactored to support #584. +#============================================================================= +if (UNIX AND SUPPORT_CONSOLE_APP) + + option ( ENABLE_CONFIG_FILES "Set to OFF to disable Tidy runtime configuration file support" ON ) + + if ( ENABLE_CONFIG_FILES ) + + message(STATUS "*** Building support for runtime configuration files.") + + add_definitions( -DTIDY_ENABLE_CONFIG_FILES ) + + # For example, /etc/tidy.conf + if (TIDY_CONFIG_FILE) + add_definitions( -DTIDY_CONFIG_FILE="${TIDY_CONFIG_FILE}" ) + endif () + + # For example, ~/.tidy.rc + if (TIDY_USER_CONFIG_FILE) + add_definitions( -DTIDY_USER_CONFIG_FILE="${TIDY_USER_CONFIG_FILE}" ) + endif () + + # All Unixes support getpwnam(); undef'd in tidyplatform.h if necessary. add_definitions( -DSUPPORT_GETPWNAM=1 ) + + endif () endif () + + if(BUILD_SHARED_LIB) set(LIB_TYPE SHARED) message(STATUS "*** Also building DLL library ${LIB_TYPE}, version ${LIBTIDY_VERSION}, date ${LIBTIDY_DATE}") diff --git a/include/tidyplatform.h b/include/tidyplatform.h index 597bb04..3006de4 100644 --- a/include/tidyplatform.h +++ b/include/tidyplatform.h @@ -32,342 +32,343 @@ extern "C" { #endif -/* - Uncomment and edit one of the following #defines if you - want to specify the config file at compile-time. -*/ +/*============================================================================= + * Unix console application features + * By default on Unix-like systems when building for the console program, + * support runtime configuration files in /etc/ and in ~/. To prevent this, + * set ENABLE_CONFIG_FILES to NO. Specify -DTIDY_CONFIG_FILE and/or + * -DTIDY_USER_CONFIG_FILE to override the default paths in tidyplatform.h. + * @note: this section refactored to support #584. + *===========================================================================*/ -/* #define TIDY_CONFIG_FILE "/etc/tidy_config.txt" */ /* original */ -/* #define TIDY_CONFIG_FILE "/etc/tidyrc" */ -/* #define TIDY_CONFIG_FILE "/etc/tidy.conf" */ +/* #define ENABLE_CONFIG_FILES */ -/* - Uncomment the following #define if you are on a system - supporting the HOME environment variable. - It enables tidy to find config files named ~/.tidyrc if - the HTML_TIDY environment variable is not set. -*/ -/* #define TIDY_USER_CONFIG_FILE "~/.tidyrc" */ +#if defined(TIDY_ENABLE_CONFIG_FILES) +# if !defined(TIDY_CONFIG_FILE) +# define TIDY_CONFIG_FILE "/etc/tidy.conf" +# endif +# if !defined(TIDY_USER_CONFIG_FILE) +# define TIDY_USER_CONFIG_FILE "~/.tidyrc" +# endif +#else +# if defined(TIDY_CONFIG_FILE) +# undef TIDY_CONFIG_FILE +# endif +# if defined(TIDY_USER_CONFIG_FILE) +# undef TIDY_USER_CONFIG_FILE +# endif +#endif -/* - Uncomment the following #define if your - system supports the call getpwnam(). - E.g. Unix and Linux. - It enables tidy to find files named - ~your/foo for use in the HTML_TIDY environment - variable or CONFIG_FILE or USER_CONFIGFILE or - on the command line: -config ~joebob/tidy.cfg - - Contributed by Todd Lewis. -*/ +/*============================================================================= + * Unix tilde expansion support + * By default on Unix-like systems when building for the console program, + * this flag is set so that Tidy knows getpwname() is available. It allows + * tidy to find files named ~your/foo for use in the HTML_TIDY environment + * variable or TIDY_CONFIG_FILE or TIDY_USER_CONFIG_FILE or on the command + * command line: -config ~joebob/tidy.cfg + * Contributed by Todd Lewis. + *===========================================================================*/ /* #define SUPPORT_GETPWNAM */ +/*============================================================================= + * Optional Tidy features support + *===========================================================================*/ + /* Enable/disable support for Big5 and Shift_JIS character encodings */ #ifndef SUPPORT_ASIAN_ENCODINGS -#define SUPPORT_ASIAN_ENCODINGS 1 +# define SUPPORT_ASIAN_ENCODINGS 1 #endif /* Enable/disable support for UTF-16 character encodings */ #ifndef SUPPORT_UTF16_ENCODINGS -#define SUPPORT_UTF16_ENCODINGS 1 +# define SUPPORT_UTF16_ENCODINGS 1 #endif /* Enable/disable support for additional accessibility checks */ #ifndef SUPPORT_ACCESSIBILITY_CHECKS -#define SUPPORT_ACCESSIBILITY_CHECKS 1 +# define SUPPORT_ACCESSIBILITY_CHECKS 1 #endif /* Enable/disable support for additional languages */ #ifndef SUPPORT_LOCALIZATIONS -#define SUPPORT_LOCALIZATIONS 1 +# define SUPPORT_LOCALIZATIONS 1 #endif /* Enable/disable support for console */ #ifndef SUPPORT_CONSOLE_APP -#define SUPPORT_CONSOLE_APP 1 +# define SUPPORT_CONSOLE_APP 1 #endif -/* Convenience defines for Mac platforms */ +/*============================================================================= + * Platform specific convenience definitions + *===========================================================================*/ + +/* === Convenience defines for Mac platforms === */ #if defined(macintosh) /* Mac OS 6.x/7.x/8.x/9.x, with or without CarbonLib - MPW or Metrowerks 68K/PPC compilers */ -#define MAC_OS_CLASSIC -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "Mac OS" -#endif +# define MAC_OS_CLASSIC +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "Mac OS" +# endif /* needed for access() */ -#if !defined(_POSIX) && !defined(NO_ACCESS_SUPPORT) -#define NO_ACCESS_SUPPORT -#endif +# if !defined(_POSIX) && !defined(NO_ACCESS_SUPPORT) +# define NO_ACCESS_SUPPORT +# endif -#ifdef SUPPORT_GETPWNAM -#undef SUPPORT_GETPWNAM -#endif +# ifdef SUPPORT_GETPWNAM +# undef SUPPORT_GETPWNAM +# endif #elif defined(__APPLE__) && defined(__MACH__) /* Mac OS X (client) 10.x (or server 1.x/10.x) - gcc or Metrowerks MachO compilers */ -#define MAC_OS_X -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "Mac OS X" -#endif +# define MAC_OS_X +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "Mac OS X" +# endif #endif #if defined(MAC_OS_CLASSIC) || defined(MAC_OS_X) /* Any OS on Mac platform */ -#define MAC_OS -#define FILENAMES_CASE_SENSITIVE 0 -#define strcasecmp strcmp +# define MAC_OS +# define FILENAMES_CASE_SENSITIVE 0 +# define strcasecmp strcmp #endif -/* Convenience defines for BSD like platforms */ - +/* === Convenience defines for BSD-like platforms === */ + #if defined(__FreeBSD__) -#define BSD_BASED_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "FreeBSD" -#endif +# define BSD_BASED_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "FreeBSD" +# endif #elif defined(__NetBSD__) -#define BSD_BASED_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "NetBSD" -#endif +# define BSD_BASED_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "NetBSD" +# endif #elif defined(__OpenBSD__) -#define BSD_BASED_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "OpenBSD" -#endif +# define BSD_BASED_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "OpenBSD" +# endif #elif defined(__DragonFly__) -#define BSD_BASED_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "DragonFly" -#endif +# define BSD_BASED_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "DragonFly" +# endif #elif defined(__MINT__) -#define BSD_BASED_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "FreeMiNT" -#endif +# define BSD_BASED_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "FreeMiNT" +# endif #elif defined(__bsdi__) -#define BSD_BASED_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "BSD/OS" +# define BSD_BASED_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "BSD/OS" +# endif #endif -#endif +/* === Convenience defines for Windows platforms === */ -/* Convenience defines for Windows platforms */ - #if defined(WINDOWS) || defined(_WIN32) -#define WINDOWS_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "Windows" -#endif +# define WINDOWS_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "Windows" +# endif -#if defined(__MWERKS__) || defined(__MSL__) -/* not available with Metrowerks Standard Library */ +# if defined(__MWERKS__) || defined(__MSL__) + /* not available with Metrowerks Standard Library */ +# ifdef SUPPORT_GETPWNAM +# undef SUPPORT_GETPWNAM +# endif + /* needed for setmode() */ +# if !defined(NO_SETMODE_SUPPORT) +# define NO_SETMODE_SUPPORT +# endif +# define strcasecmp _stricmp +# endif -#ifdef SUPPORT_GETPWNAM -#undef SUPPORT_GETPWNAM -#endif +# if defined(__BORLANDC__) +# define strcasecmp stricmp +# endif -/* needed for setmode() */ -#if !defined(NO_SETMODE_SUPPORT) -#define NO_SETMODE_SUPPORT -#endif +# define FILENAMES_CASE_SENSITIVE 0 +# define SUPPORT_POSIX_MAPPED_FILES 0 -#define strcasecmp _stricmp +#endif /* WINDOWS */ -#endif +/* === Convenience defines for Linux platforms === */ -#if defined(__BORLANDC__) -#define strcasecmp stricmp -#endif - -#define FILENAMES_CASE_SENSITIVE 0 -#define SUPPORT_POSIX_MAPPED_FILES 0 - -#endif - -/* Convenience defines for Linux platforms */ - #if defined(linux) && defined(__alpha__) -/* Linux on Alpha - gcc compiler */ -#define LINUX_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "Linux/Alpha" -#endif + /* Linux on Alpha - gcc compiler */ +# define LINUX_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "Linux/Alpha" +# endif #elif defined(linux) && defined(__sparc__) -/* Linux on Sparc - gcc compiler */ -#define LINUX_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "Linux/Sparc" -#endif + /* Linux on Sparc - gcc compiler */ +# define LINUX_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "Linux/Sparc" +# endif #elif defined(linux) && (defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__)) -/* Linux on x86 - gcc compiler */ -#define LINUX_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "Linux/x86" -#endif + /* Linux on x86 - gcc compiler */ +# define LINUX_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "Linux/x86" +# endif #elif defined(linux) && defined(__powerpc__) -/* Linux on PPC - gcc compiler */ -#define LINUX_OS - -#if defined(__linux__) && defined(__powerpc__) - -/* #if #system(linux) */ -/* MkLinux on PPC - gcc (egcs) compiler */ -/* #define MAC_OS_MKLINUX */ -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "MkLinux" -#endif - -#else - -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "Linux/PPC" -#endif - -#endif + /* Linux on PPC - gcc compiler */ +# define LINUX_OS +# if defined(__linux__) && defined(__powerpc__) +# ifndef PLATFORM_NAME + /* MkLinux on PPC - gcc (egcs) compiler */ +# define PLATFORM_NAME "MkLinux" +# endif +# else +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "Linux/PPC" +# endif +# endif #elif defined(linux) || defined(__linux__) -/* generic Linux */ -#define LINUX_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "Linux" + /* generic Linux */ +# define LINUX_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "Linux" +# endif #endif -#endif - -/* Convenience defines for Solaris platforms */ +/* === Convenience defines for Solaris platforms === */ #if defined(sun) -#define SOLARIS_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "Solaris" -#endif +# define SOLARIS_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "Solaris" +# endif #endif -/* Convenience defines for HPUX + gcc platforms */ +/* === Convenience defines for HPUX + gcc platforms === */ #if defined(__hpux) -#define HPUX_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "HPUX" -#endif +# define HPUX_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "HPUX" +# endif #endif -/* Convenience defines for RISCOS + gcc platforms */ +/* === Convenience defines for RISCOS + gcc platforms === */ #if defined(__riscos__) -#define RISC_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "RISC OS" -#endif +# define RISC_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "RISC OS" +# endif #endif -/* Convenience defines for OS/2 + icc/gcc platforms */ +/* === Convenience defines for OS/2 + icc/gcc platforms === */ #if defined(__OS2__) || defined(__EMX__) -#define OS2_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "OS/2" -#endif -#define FILENAMES_CASE_SENSITIVE 0 -#define strcasecmp stricmp +# define OS2_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "OS/2" +# endif +# define FILENAMES_CASE_SENSITIVE 0 +# define strcasecmp stricmp #endif -/* Convenience defines for IRIX */ +/* === Convenience defines for IRIX === */ #if defined(__sgi) -#define IRIX_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "SGI IRIX" -#endif +# define IRIX_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "SGI IRIX" +# endif #endif -/* Convenience defines for AIX */ +/* === Convenience defines for AIX === */ #if defined(_AIX) -#define AIX_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "IBM AIX" -#endif +# define AIX_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "IBM AIX" +# endif #endif - -/* Convenience defines for BeOS platforms */ +/* === Convenience defines for BeOS platforms === */ #if defined(__BEOS__) -#define BE_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "BeOS" -#endif +# define BE_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "BeOS" +# endif #endif -/* Convenience defines for Cygwin platforms */ +/* === Convenience defines for Cygwin platforms === */ #if defined(__CYGWIN__) -#define CYGWIN_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "Cygwin" -#endif -#define FILENAMES_CASE_SENSITIVE 0 +# define CYGWIN_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "Cygwin" +# endif +# define FILENAMES_CASE_SENSITIVE 0 #endif -/* Convenience defines for OpenVMS */ +/* === Convenience defines for OpenVMS === */ #if defined(__VMS) -#define OPENVMS_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "OpenVMS" -#endif -#define FILENAMES_CASE_SENSITIVE 0 +# define OPENVMS_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "OpenVMS" +# endif +# define FILENAMES_CASE_SENSITIVE 0 #endif -/* Convenience defines for DEC Alpha OSF + gcc platforms */ +/* === Convenience defines for DEC Alpha OSF + gcc platforms === */ #if defined(__osf__) -#define OSF_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "DEC Alpha OSF" -#endif +# define OSF_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "DEC Alpha OSF" +# endif #endif -/* Convenience defines for ARM platforms */ +/* === Convenience defines for ARM platforms === */ #if defined(__arm) -#define ARM_OS - -#if defined(forARM) && defined(__NEWTON_H) - -/* Using Newton C++ Tools ARMCpp compiler */ -#define NEWTON_OS -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "Newton" +# define ARM_OS +# if defined(forARM) && defined(__NEWTON_H) + /* Using Newton C++ Tools ARMCpp compiler */ +# define NEWTON_OS +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "Newton" +# endif +# else +# ifndef PLATFORM_NAME +# define PLATFORM_NAME "ARM" +# endif +# endif #endif -#else -#ifndef PLATFORM_NAME -#define PLATFORM_NAME "ARM" -#endif - -#endif - -#endif +/*============================================================================= + * Standard Library Includes + *===========================================================================*/ #include #include @@ -378,193 +379,207 @@ extern "C" { #include #ifdef NEEDS_MALLOC_H -#include +# include #endif #ifdef SUPPORT_GETPWNAM -#include +# include #endif #ifdef NEEDS_UNISTD_H -#include /* needed for unlink on some Unix systems */ +# include /* needed for unlink on some Unix systems */ #endif -/* By default, use case-sensitive filename comparison. -*/ + +/*============================================================================= + * Case sensitive file systems + *===========================================================================*/ + +/* By default, use case-sensitive filename comparison. */ #ifndef FILENAMES_CASE_SENSITIVE -#define FILENAMES_CASE_SENSITIVE 1 +# define FILENAMES_CASE_SENSITIVE 1 #endif -/* - Tidy preserves the last modified time for the files it - cleans up. -*/ - -/* - If your platform doesn't support and the - utime() function, or and the futime() - function then set PRESERVE_FILE_TIMES to 0. - - If your platform doesn't support and the - futime() function, then set HAS_FUTIME to 0. - - If your platform supports and the - utime() function requires the file to be - closed first, then set UTIME_NEEDS_CLOSED_FILE to 1. -*/ +/*============================================================================= + * Last modified time preservation + * Tidy preserves the last modified time for the files it cleans up. + * + * If your platform doesn't support and the utime() function, or + * and the futime() function then set PRESERVE_FILE_TIMES to 0. + * + * If your platform doesn't support and the futime() function, + * then set HAS_FUTIME to 0. + * + * If your platform supports and the utime() function requires the + * file to be closed first, then set UTIME_NEEDS_CLOSED_FILE to 1. + *===========================================================================*/ /* Keep old PRESERVEFILETIMES define for compatibility */ #ifdef PRESERVEFILETIMES -#undef PRESERVE_FILE_TIMES -#define PRESERVE_FILE_TIMES PRESERVEFILETIMES +# undef PRESERVE_FILE_TIMES +# define PRESERVE_FILE_TIMES PRESERVEFILETIMES #endif #ifndef PRESERVE_FILE_TIMES -#if defined(RISC_OS) || defined(OPENVMS_OS) || defined(OSF_OS) -#define PRESERVE_FILE_TIMES 0 -#else -#define PRESERVE_FILE_TIMES 1 -#endif +# if defined(RISC_OS) || defined(OPENVMS_OS) || defined(OSF_OS) +# define PRESERVE_FILE_TIMES 0 +# else +# define PRESERVE_FILE_TIMES 1 +# endif #endif #if PRESERVE_FILE_TIMES -#ifndef HAS_FUTIME -#if defined(CYGWIN_OS) || defined(BE_OS) || defined(OS2_OS) || defined(HPUX_OS) || defined(SOLARIS_OS) || defined(LINUX_OS) || defined(BSD_BASED_OS) || defined(MAC_OS) || defined(__MSL__) || defined(IRIX_OS) || defined(AIX_OS) || defined(__BORLANDC__) || defined(__GLIBC__) -#define HAS_FUTIME 0 -#else -#define HAS_FUTIME 1 -#endif -#endif +# ifndef HAS_FUTIME +# if defined(CYGWIN_OS) || defined(BE_OS) || defined(OS2_OS) || defined(HPUX_OS) || defined(SOLARIS_OS) || defined(LINUX_OS) || defined(BSD_BASED_OS) || defined(MAC_OS) || defined(__MSL__) || defined(IRIX_OS) || defined(AIX_OS) || defined(__BORLANDC__) || defined(__GLIBC__) +# define HAS_FUTIME 0 +# else +# define HAS_FUTIME 1 +# endif +# endif -#ifndef UTIME_NEEDS_CLOSED_FILE -#if defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(MAC_OS) || defined(__MSL__) || defined(LINUX_OS) -#define UTIME_NEEDS_CLOSED_FILE 1 -#else -#define UTIME_NEEDS_CLOSED_FILE 0 -#endif -#endif +# ifndef UTIME_NEEDS_CLOSED_FILE +# if defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(MAC_OS) || defined(__MSL__) || defined(LINUX_OS) +# define UTIME_NEEDS_CLOSED_FILE 1 +# else +# define UTIME_NEEDS_CLOSED_FILE 0 +# endif +# endif -#if defined(MAC_OS_X) || (!defined(MAC_OS_CLASSIC) && !defined(__MSL__)) -#include -#include -#else -#include -#endif +# if defined(MAC_OS_X) || (!defined(MAC_OS_CLASSIC) && !defined(__MSL__)) +# include +# include +# else +# include +# endif -#if HAS_FUTIME -#include -#else -#include -#endif /* HASFUTIME */ +# if HAS_FUTIME +# include +# else +# include +# endif -/* - MS Windows needs _ prefix for Unix file functions. - Not required by Metrowerks Standard Library (MSL). +/* MS Windows needs _ prefix for Unix file functions. + Not required by Metrowerks Standard Library (MSL). - Tidy uses following for preserving the last modified time. + Tidy uses following for preserving the last modified time. - WINDOWS automatically set by Win16 compilers. - _WIN32 automatically set by Win32 compilers. + WINDOWS automatically set by Win16 compilers. + _WIN32 automatically set by Win32 compilers. */ +# if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__) +# define futime _futime +# define fstat _fstat +# define utimbuf _utimbuf /* Windows seems to want utimbuf */ +# define stat _stat +# define utime _utime +# define vsnprintf _vsnprintf +# endif + +#endif + + +/*============================================================================= + * Windows file functions + * Windows needs _ prefix for Unix file functions. + * Not required by Metrowerks Standard Library (MSL). + * + * WINDOWS automatically set by Win16 compilers. + * _WIN32 automatically set by Win32 compilers. + *===========================================================================*/ + #if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__) -#define futime _futime -#define fstat _fstat -#define utimbuf _utimbuf /* Windows seems to want utimbuf */ -#define stat _stat -#define utime _utime -#define vsnprintf _vsnprintf -#endif /* _WIN32 */ +# if !(defined(__WATCOMC__) || defined(__MINGW32__)) +# define fileno _fileno +# define setmode _setmode +# endif -#endif /* PRESERVE_FILE_TIMES */ +# define access _access +# define strcasecmp _stricmp -/* - MS Windows needs _ prefix for Unix file functions. - Not required by Metrowerks Standard Library (MSL). - - WINDOWS automatically set by Win16 compilers. - _WIN32 automatically set by Win32 compilers. -*/ -#if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__) +# ifndef va_copy +# define va_copy(dest, src) (dest = src) +# endif -#if !(defined(__WATCOMC__) || defined(__MINGW32__)) -#define fileno _fileno -#define setmode _setmode -#endif +# if _MSC_VER > 1000 +# pragma warning( disable : 4189 ) /* local variable is initialized but not referenced */ +# pragma warning( disable : 4100 ) /* unreferenced formal parameter */ +# pragma warning( disable : 4706 ) /* assignment within conditional expression */ +# endif -#define access _access -#define strcasecmp _stricmp - -#ifndef va_copy -#define va_copy(dest, src) (dest = src) -#endif - -#if _MSC_VER > 1000 -#pragma warning( disable : 4189 ) /* local variable is initialized but not referenced */ -#pragma warning( disable : 4100 ) /* unreferenced formal parameter */ -#pragma warning( disable : 4706 ) /* assignment within conditional expression */ -#endif - -#if _MSC_VER > 1300 -#pragma warning( disable : 4996 ) /* disable depreciation warning */ -#endif +# if _MSC_VER > 1300 +# pragma warning( disable : 4996 ) /* disable depreciation warning */ +# endif #endif /* _WIN32 */ #if defined(_WIN32) -#if (defined(_USRDLL) || defined(_WINDLL) || defined(BUILD_SHARED_LIB)) && !defined(TIDY_EXPORT) && !defined(TIDY_STATIC) -#ifdef BUILDING_SHARED_LIB -#define TIDY_EXPORT __declspec( dllexport ) -#else -#define TIDY_EXPORT __declspec( dllimport ) -#endif -#else -#define TIDY_EXPORT extern -#endif +# if (defined(_USRDLL) || defined(_WINDLL) || defined(BUILD_SHARED_LIB)) && !defined(TIDY_EXPORT) && !defined(TIDY_STATIC) +# ifdef BUILDING_SHARED_LIB +# define TIDY_EXPORT __declspec( dllexport ) +# else +# define TIDY_EXPORT __declspec( dllimport ) +# endif +# else +# define TIDY_EXPORT extern +# endif -#ifndef TIDY_CALL -#ifdef _WIN64 -# define TIDY_CALL __fastcall -#else -# define TIDY_CALL __stdcall -#endif -#endif +# ifndef TIDY_CALL +# ifdef _WIN64 +# define TIDY_CALL __fastcall +# else +# define TIDY_CALL __stdcall +# endif +# endif #endif /* _WIN32 */ -/* hack for gnu sys/types.h file which defines uint and ulong */ + +/*============================================================================= + * Hack for gnu sys/types.h file which defines uint and ulong + *===========================================================================*/ #if defined(BE_OS) || defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(OSF_OS) || defined(IRIX_OS) || defined(AIX_OS) -#include -#endif -#if !defined(HPUX_OS) && !defined(CYGWIN_OS) && !defined(MAC_OS_X) && !defined(BE_OS) && !defined(SOLARIS_OS) && !defined(BSD_BASED_OS) && !defined(OSF_OS) && !defined(IRIX_OS) && !defined(AIX_OS) && !defined(LINUX_OS) -# undef uint -typedef unsigned int uint; -#endif -#if defined(HPUX_OS) || defined(CYGWIN_OS) || defined(MAC_OS) || defined(BSD_BASED_OS) || defined(_WIN32) -# undef ulong -typedef unsigned long ulong; +# include #endif -/* -With GCC 4, __attribute__ ((visibility("default"))) can be used along compiling with tidylib -with "-fvisibility=hidden". See http://gcc.gnu.org/wiki/Visibility and build/gmake/Makefile. -*/ +#if !defined(HPUX_OS) && !defined(CYGWIN_OS) && !defined(MAC_OS_X) && !defined(BE_OS) && !defined(SOLARIS_OS) && !defined(BSD_BASED_OS) && !defined(OSF_OS) && !defined(IRIX_OS) && !defined(AIX_OS) && !defined(LINUX_OS) +# undef uint + typedef unsigned int uint; +#endif + +#if defined(HPUX_OS) || defined(CYGWIN_OS) || defined(MAC_OS) || defined(BSD_BASED_OS) || defined(_WIN32) +# undef ulong + typedef unsigned long ulong; +#endif + + +/*============================================================================= + * Visibility support + * With GCC 4, __attribute__ ((visibility("default"))) can be used + * along compiling with tidylib with "-fvisibility=hidden". See + * http://gcc.gnu.org/wiki/Visibility and build/gmake/Makefile. + *===========================================================================*/ /* #if defined(__GNUC__) && __GNUC__ >= 4 -#define TIDY_EXPORT __attribute__ ((visibility("default"))) +# define TIDY_EXPORT __attribute__ ((visibility("default"))) #endif */ + +/*============================================================================= + * Other definitions + *===========================================================================*/ + #ifndef TIDY_EXPORT /* Define it away for most builds */ -#define TIDY_EXPORT +# define TIDY_EXPORT #endif #ifndef TIDY_STRUCT -#define TIDY_STRUCT +# define TIDY_STRUCT #endif typedef unsigned char byte; @@ -572,41 +587,39 @@ typedef unsigned char byte; typedef uint tchar; /* single, full character */ typedef char tmbchar; /* single, possibly partial character */ #ifndef TMBSTR_DEFINED -typedef tmbchar* tmbstr; /* pointer to buffer of possibly partial chars */ -typedef const tmbchar* ctmbstr; /* Ditto, but const */ -#define NULLSTR (tmbstr)"" -#define TMBSTR_DEFINED + typedef tmbchar* tmbstr; /* pointer to buffer of possibly partial chars */ + typedef const tmbchar* ctmbstr; /* Ditto, but const */ +# define NULLSTR (tmbstr)"" +# define TMBSTR_DEFINED #endif #ifndef TIDY_CALL -#define TIDY_CALL +# define TIDY_CALL #endif #if defined(__GNUC__) || defined(__INTEL_COMPILER) -# define ARG_UNUSED(x) x __attribute__((unused)) -# define FUNC_UNUSED __attribute__((unused)) +# define ARG_UNUSED(x) x __attribute__((unused)) +# define FUNC_UNUSED __attribute__((unused)) #else -# define ARG_UNUSED(x) x -# define FUNC_UNUSED +# define ARG_UNUSED(x) x +# define FUNC_UNUSED #endif /* HAS_VSNPRINTF triggers the use of "vsnprintf", which is safe related to buffer overflow. Therefore, we make it the default unless HAS_VSNPRINTF has been defined. */ #ifndef HAS_VSNPRINTF -# define HAS_VSNPRINTF 1 +# define HAS_VSNPRINTF 1 #endif #ifndef SUPPORT_POSIX_MAPPED_FILES -# define SUPPORT_POSIX_MAPPED_FILES 1 +# define SUPPORT_POSIX_MAPPED_FILES 1 #endif -/* - bool is a reserved word in some but - not all C++ compilers depending on age - work around is to avoid bool altogether - by introducing a new enum called Bool +/* `bool` is a reserved word in some but not all C++ compilers depending on age. + age. Work around is to avoid bool by introducing a new enum called `Bool`. */ + /* We could use the C99 definition where supported typedef _Bool Bool; #define no (_Bool)0 @@ -624,7 +637,7 @@ extern void* null; */ #if defined(DMALLOC) -#include "dmalloc.h" +# include "dmalloc.h" #endif /* Opaque data structure. From 2860160b5455e96db2ee53d9e6ca9f6841121073 Mon Sep 17 00:00:00 2001 From: Jim Derry Date: Sun, 1 Oct 2017 10:42:18 -0400 Subject: [PATCH 2/2] Version bump due to new behavior on Unix. --- version.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.txt b/version.txt index 8fcb5bb..f92297a 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ -5.5.46 -2017.09.29 +5.5.47 +2017.10.01