[x265] [PATCH] strtok_r: fix detection on Windows

Steve Borho steve at borho.org
Sat Apr 5 22:27:42 CEST 2014


On Sat, Apr 5, 2014 at 4:26 AM, Rafaël Carré <funman at videolan.org> wrote:
> Make sure HAVE_STRTOK_R is always defined, to 0 if absent
> Fix typo in #if
> mingw-w64's pthread.h #defines strtok_r, make sure to undef it
> before we use our own definition.
> ---
>  source/common/CMakeLists.txt | 3 +++
>  source/common/param.cpp      | 3 ++-
>  2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/source/common/CMakeLists.txt b/source/common/CMakeLists.txt
> index 09029ba..63cdf09 100644
> --- a/source/common/CMakeLists.txt
> +++ b/source/common/CMakeLists.txt
> @@ -130,6 +130,9 @@ if(ENABLE_ASSEMBLY)
>  endif(ENABLE_ASSEMBLY)
>
>  check_symbol_exists(strtok_r "string.h" HAVE_STRTOK_R)
> +if(HAVE_STRTOK_R STREQUAL "")
> +    set(HAVE_STRTOK_R "0")
> +endif()

hmm, I think I would prefer to use:

if(HAVE_STRTOK_R)
  set_source_files_properties(param.cpp PROPERTIES COMPILE_FLAGS
-DHAVE_STRTOK_R=1)
endif()

then use #ifndef in the source

>  set_source_files_properties(param.cpp PROPERTIES COMPILE_FLAGS -DHAVE_STRTOK_R=${HAVE_STRTOK_R})
>
>  if(GCC AND GCC_HAS_NO_NARROWING)
> diff --git a/source/common/param.cpp b/source/common/param.cpp
> index 57e3388..ac19c7e 100644
> --- a/source/common/param.cpp
> +++ b/source/common/param.cpp
> @@ -37,7 +37,7 @@
>  #define strcasecmp _stricmp
>  #endif
>
> -#if !HAVE_STROTOK_R
> +#if !HAVE_STRTOK_R

this is an obvious fix, thanks

>  /*
>   * adapted from public domain strtok_r() by Charlie Gordon
>   *
> @@ -49,6 +49,7 @@
>   *      http://groups.google.com/group/comp.lang.c/msg/7c7b39328fefab9c
>   */
> +#undef strtok_r

and I understand the need for this

>  char* strtok_r(
>      char *str,
>      const char *delim,

Cheers

-- 
Steve Borho


More information about the x265-devel mailing list