From 70d2140adda533680aec3c0cb0e828a868fafa68 Mon Sep 17 00:00:00 2001 From: jfoug Date: Fri, 28 Nov 2014 06:43:27 -0600 Subject: [PATCH] crypt: problems with #defines and strdup --- src/c3_fmt.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/c3_fmt.c b/src/c3_fmt.c index d1c694e..0fe867f 100644 --- a/src/c3_fmt.c +++ b/src/c3_fmt.c @@ -17,6 +17,28 @@ #if HAVE_CRYPT +/* if this comes after the #define crap below, there are often + * problems with strdup or other things not being defined. We + * move this block of includes to above the _XOPEN_* defines + */ +#if STRING_WITH_STRINGS +#include +#include +#elif HAVE_STRING_H +#include +#elif HAVE_STRINGS_H +#include +#endif +#if !AC_BUILT +#include +#ifndef _MSC_VER +#include +#endif +#undef _XOPEN_VERSION +#undef _XOPEN_SOURCE +#undef _XOPEN_SOURCE_EXTENDED +#undef _GNU_SOURCE + #define _XOPEN_SOURCE 4 /* for crypt(3) */ #define _XOPEN_SOURCE_EXTENDED 1 /* for OpenBSD */ #define _XOPEN_VERSION 4 @@ -24,11 +46,6 @@ #define _GNU_SOURCE 1 /* for crypt_r(3) */ #include -#if !AC_BUILT -#include -#ifndef _MSC_VER -#include -#endif #ifdef __CYGWIN__ #include #endif @@ -41,14 +58,6 @@ #endif #endif -#if STRING_WITH_STRINGS -#include -#include -#elif HAVE_STRING_H -#include -#elif HAVE_STRINGS_H -#include -#endif #if HAVE_CRYPT_H #include #endif