From a7e3705d051bafd1cae90f6605287cc1d9f2a18d Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Fri, 22 Jun 2012 16:03:04 +1000 Subject: [PATCH] Move code inside #ifdef _MSC_VER to compat.h. --- include/share/compat.h | 30 ++++++++++++++++++++++++++++++ src/libFLAC/metadata_iterators.c | 13 ------------- src/libFLAC/metadata_object.c | 7 +------ src/libFLAC/stream_decoder.c | 16 +--------------- src/libFLAC/stream_encoder.c | 8 -------- 5 files changed, 32 insertions(+), 42 deletions(-) diff --git a/include/share/compat.h b/include/share/compat.h index 220f5a2a..19f5dd65 100644 --- a/include/share/compat.h +++ b/include/share/compat.h @@ -74,3 +74,33 @@ #else #define FLAC__U64L(x) x##LLU #endif + +#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ +#define FLAC__STRNCASECMP strnicmp +#else +#define FLAC__STRNCASECMP strncasecmp +#endif + +#if defined _MSC_VER || defined __MINGW32__ +#include /* for _setmode() */ +#include /* for _O_BINARY */ +#endif +#if defined __CYGWIN__ || defined __EMX__ +#include /* for setmode(), O_BINARY */ +#include /* for _O_BINARY */ +#endif + + +#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ +#if defined __BORLANDC__ +#include /* for utime() */ +#else +#include /* for utime() */ +#endif +#include /* for chmod() */ +#include /* for off_t */ +#else +#include /* some flavors of BSD (like OS X) require this to get time_t */ +#include /* for utime() */ +#include /* for chown(), unlink() */ +#endif diff --git a/src/libFLAC/metadata_iterators.c b/src/libFLAC/metadata_iterators.c index d35b9ef0..b321e452 100644 --- a/src/libFLAC/metadata_iterators.c +++ b/src/libFLAC/metadata_iterators.c @@ -38,19 +38,6 @@ #include #include -#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ -#if defined __BORLANDC__ -#include /* for utime() */ -#else -#include /* for utime() */ -#endif -#include /* for chmod() */ -#include /* for off_t */ -#else -#include /* some flavors of BSD (like OS X) require this to get time_t */ -#include /* for utime() */ -#include /* for chown(), unlink() */ -#endif #include /* for stat(), maybe chmod() */ #include "private/metadata.h" diff --git a/src/libFLAC/metadata_object.c b/src/libFLAC/metadata_object.c index 149f78de..22d39d46 100644 --- a/src/libFLAC/metadata_object.c +++ b/src/libFLAC/metadata_object.c @@ -41,6 +41,7 @@ #include "FLAC/assert.h" #include "share/alloc.h" +#include "share/compat.h" /* Alias the first (in share/alloc.h) to the second (in src/libFLAC/memory.c). */ #define safe_malloc_mul_2op_ safe_malloc_mul_2op_p @@ -1379,13 +1380,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_matches(const FLAC FLAC__ASSERT(0 != entry.entry && entry.length > 0); { const FLAC__byte *eq = (FLAC__byte*)memchr(entry.entry, '=', entry.length); -#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ -#define FLAC__STRNCASECMP strnicmp -#else -#define FLAC__STRNCASECMP strncasecmp -#endif return (0 != eq && (unsigned)(eq-entry.entry) == field_name_length && 0 == FLAC__STRNCASECMP(field_name, (const char *)entry.entry, field_name_length)); -#undef FLAC__STRNCASECMP } } diff --git a/src/libFLAC/stream_decoder.c b/src/libFLAC/stream_decoder.c index ec728abe..789db1b6 100644 --- a/src/libFLAC/stream_decoder.c +++ b/src/libFLAC/stream_decoder.c @@ -33,14 +33,6 @@ # include #endif -#if defined _MSC_VER || defined __MINGW32__ -#include /* for _setmode() */ -#include /* for _O_BINARY */ -#endif -#if defined __CYGWIN__ || defined __EMX__ -#include /* for setmode(), O_BINARY */ -#include /* for _O_BINARY */ -#endif #include #include /* for malloc() */ #include /* for memset/memcpy() */ @@ -63,13 +55,7 @@ /* technically this should be in an "export.c" but this is convenient enough */ -FLAC_API int FLAC_API_SUPPORTS_OGG_FLAC = -#if FLAC__HAS_OGG - 1 -#else - 0 -#endif -; +FLAC_API int FLAC_API_SUPPORTS_OGG_FLAC = FLAC__HAS_OGG ; /*********************************************************************** diff --git a/src/libFLAC/stream_encoder.c b/src/libFLAC/stream_encoder.c index 48c0d935..0c1bbdf6 100644 --- a/src/libFLAC/stream_encoder.c +++ b/src/libFLAC/stream_encoder.c @@ -33,14 +33,6 @@ # include #endif -#if defined _MSC_VER || defined __MINGW32__ -#include /* for _setmode() */ -#include /* for _O_BINARY */ -#endif -#if defined __CYGWIN__ || defined __EMX__ -#include /* for setmode(), O_BINARY */ -#include /* for _O_BINARY */ -#endif #include #include #include /* for malloc() */