From 15f3af54fe0f4a8d4964291b7b188494b7ddb70d Mon Sep 17 00:00:00 2001 From: Snaipe Date: Mon, 5 Oct 2015 19:54:49 +0200 Subject: [PATCH] Fixed compilation error on MinGW due to how C++ attributes are handled --- src/compat/posix.h | 14 -------------- src/compat/strtok.h | 43 +++++++++++++++++++++++++++++++++++++++++++ src/log/normal.c | 1 + src/log/tap.c | 1 + src/log/xml.c | 1 + 5 files changed, 46 insertions(+), 14 deletions(-) create mode 100644 src/compat/strtok.h diff --git a/src/compat/posix.h b/src/compat/posix.h index fdd634c..4468f63 100644 --- a/src/compat/posix.h +++ b/src/compat/posix.h @@ -24,8 +24,6 @@ #ifndef POSIX_COMPAT_H_ # define POSIX_COMPAT_H_ -# include "config.h" - # if defined(_WIN32) && !defined(__CYGWIN__) # define VANILLA_WIN32 # endif @@ -66,18 +64,6 @@ # define SIGPROF 27 # define CR_EXCEPTION_TIMEOUT 0xC0001042 -# if HAVE_STRTOK_S -# define strtok_r strtok_s -# else -static CR_INLINE char *strtok_r(char *str, const char *delim, CR_UNUSED char **saveptr) { - return strtok(str, delim); -} -# endif - -# ifdef _MSC_VER -# define strdup _strdup -# endif - # else # include # endif diff --git a/src/compat/strtok.h b/src/compat/strtok.h new file mode 100644 index 0000000..6dbe96c --- /dev/null +++ b/src/compat/strtok.h @@ -0,0 +1,43 @@ +/* + * The MIT License (MIT) + * + * Copyright © 2015 Franklin "Snaipe" Mathieu + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef COMPAT_STRTOK_H_ +# define COMPAT_STRTOK_H_ + +# include "config.h" + +# ifdef VANILLA_WIN32 +# if HAVE_STRTOK_S +# define strtok_r strtok_s +# else +static CR_INLINE char *strtok_r(char *str, const char *delim, CR_UNUSED char **saveptr) { + return strtok(str, delim); +} +# endif + +# ifdef _MSC_VER +# define strdup _strdup +# endif +# endif + +#endif /* !COMPAT_STRTOK_H_ */ diff --git a/src/log/normal.c b/src/log/normal.c index 78b2ece..f7319d3 100644 --- a/src/log/normal.c +++ b/src/log/normal.c @@ -31,6 +31,7 @@ #include "criterion/options.h" #include "criterion/ordered-set.h" #include "compat/posix.h" +#include "compat/strtok.h" #include "compat/time.h" #include "string/i18n.h" #include "config.h" diff --git a/src/log/tap.c b/src/log/tap.c index 5922fb2..c960951 100644 --- a/src/log/tap.c +++ b/src/log/tap.c @@ -30,6 +30,7 @@ #include "criterion/options.h" #include "criterion/ordered-set.h" #include "compat/posix.h" +#include "compat/strtok.h" #include "compat/time.h" #include "config.h" #include "common.h" diff --git a/src/log/xml.c b/src/log/xml.c index eb9be51..fd7c9d6 100644 --- a/src/log/xml.c +++ b/src/log/xml.c @@ -30,6 +30,7 @@ #include "criterion/options.h" #include "criterion/ordered-set.h" #include "compat/posix.h" +#include "compat/strtok.h" #include "compat/time.h" #include "config.h" #include "common.h"