libyang BUGFIX set feature macro for strdup() on OSX
Since OS X requires different value (600) of _XOPEN_SOURCE feature test macro for
strdup() than linux (500), better use _POSIX_C_SOURCE 200809L. It is available
since glibc 2.12 (released 2010) so it shouldn't be an issue.
diff --git a/compat/compat.c b/compat/compat.c
index 8165a14..d36f359 100644
--- a/compat/compat.c
+++ b/compat/compat.c
@@ -13,9 +13,8 @@
*/
#include "compat.h"
-#define _POSIX_C_SOURCE 1 /* fdopen, _POSIX_PATH_MAX */
+#define _POSIX_C_SOURCE 200809L /* fdopen, _POSIX_PATH_MAX, strdup */
#define _ISOC99_SOURCE /* vsnprintf */
-#define _XOPEN_SOURCE 500 /* strdup */
#include <errno.h>
#include <limits.h>
diff --git a/src/context.c b/src/context.c
index e345804..59c7093 100644
--- a/src/context.c
+++ b/src/context.c
@@ -12,6 +12,7 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
#define _GNU_SOURCE /* asprintf */
+#define _POSIX_C_SOURCE 200809L /* strdup */
#include "context.h"
diff --git a/src/diff.c b/src/diff.c
index 31090f2..347ebf8 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -11,8 +11,7 @@
*
* https://opensource.org/licenses/BSD-3-Clause
*/
-#define _XOPEN_SOURCE 500
-#define _POSIX_C_SOURCE 200809L
+#define _POSIX_C_SOURCE 200809L /* strdup */
#include "diff.h"
diff --git a/src/in.c b/src/in.c
index f802010..e4320f9 100644
--- a/src/in.c
+++ b/src/in.c
@@ -13,6 +13,11 @@
*/
#define _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L /* strdup, strndup */
+
+#ifdef __APPLE__
+#define _DARWIN_C_SOURCE /* F_GETPATH */
+#endif
#include "in.h"
#include "in_internal.h"
diff --git a/src/log.c b/src/log.c
index 1633b27..45f1750 100644
--- a/src/log.c
+++ b/src/log.c
@@ -13,6 +13,7 @@
*/
#define _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L /* strdup */
#include "log.h"
diff --git a/src/out.c b/src/out.c
index 13f462b..b74ed64 100644
--- a/src/out.c
+++ b/src/out.c
@@ -13,6 +13,7 @@
*/
#define _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L /* strdup, vdprintf */
#include "out.h"
#include "out_internal.h"
diff --git a/src/plugins_types.c b/src/plugins_types.c
index f3786eb..446b2f7 100644
--- a/src/plugins_types.c
+++ b/src/plugins_types.c
@@ -13,6 +13,7 @@
*/
#define _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L /* strdup */
#include "plugins_types.h"
diff --git a/src/schema_compile_node.c b/src/schema_compile_node.c
index a988e02..404150e 100644
--- a/src/schema_compile_node.c
+++ b/src/schema_compile_node.c
@@ -13,6 +13,7 @@
*/
#define _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L /* strdup, strndup */
#include "schema_compile_node.h"
diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index c2134c0..5fed963 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -11,8 +11,7 @@
*
* https://opensource.org/licenses/BSD-3-Clause
*/
-#define _XOPEN_SOURCE 500 /* strdup */
-#define _POSIX_C_SOURCE 200809L /*strndup */
+#define _POSIX_C_SOURCE 200809L /* strdup, strndup */
#include <assert.h>
#include <stdint.h>
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 3d56842..54c5509 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -13,6 +13,7 @@
*/
#define _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L /* strdup */
#include "tree_schema.h"
diff --git a/src/validation.c b/src/validation.c
index 0877b85..f8bc3de 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -11,7 +11,7 @@
*
* https://opensource.org/licenses/BSD-3-Clause
*/
-#define _XOPEN_SOURCE 500 /* strdup */
+#define _POSIX_C_SOURCE 200809L /* strdup */
#include "validation.h"
diff --git a/src/xpath.c b/src/xpath.c
index 88403a0..c8beb28 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -12,6 +12,7 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
#define _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L /* strdup, strndup */
/* needed by libmath functions isfinite(), isinf(), isnan(), signbit(), ... */
#define _ISOC99_SOURCE
diff --git a/tests/utests/test_hash_table.c b/tests/utests/test_hash_table.c
index 57e0de0..2f0265f 100644
--- a/tests/utests/test_hash_table.c
+++ b/tests/utests/test_hash_table.c
@@ -13,6 +13,7 @@
*/
#define _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L /* strdup */
#include <stdarg.h>
#include <stddef.h>
diff --git a/tests/utests/test_set.c b/tests/utests/test_set.c
index fc1b919..4421c3d 100644
--- a/tests/utests/test_set.c
+++ b/tests/utests/test_set.c
@@ -13,6 +13,7 @@
*/
#define _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L /* strdup */
#include <stdarg.h>
#include <stddef.h>
diff --git a/tests/utests/test_xml.c b/tests/utests/test_xml.c
index 89a8ce8..a4dee59 100644
--- a/tests/utests/test_xml.c
+++ b/tests/utests/test_xml.c
@@ -14,6 +14,7 @@
#define _DEFAULT_SOURCE
#define _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L /* strdup */
#include <stdarg.h>
#include <stddef.h>
diff --git a/tools/lint/common.c b/tools/lint/common.c
index bc4d572..16e05d1 100644
--- a/tools/lint/common.c
+++ b/tools/lint/common.c
@@ -13,6 +13,7 @@
*/
#define _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L /* strdup, strndup */
#include "common.h"
diff --git a/tools/lint/completion.c b/tools/lint/completion.c
index 4db17a0..2506019 100644
--- a/tools/lint/completion.c
+++ b/tools/lint/completion.c
@@ -13,6 +13,7 @@
*/
#define _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L /* strdup */
#include <errno.h>
#include <stdint.h>
diff --git a/tools/lint/linenoise/linenoise.c b/tools/lint/linenoise/linenoise.c
index f14d348..dd81e74 100644
--- a/tools/lint/linenoise/linenoise.c
+++ b/tools/lint/linenoise/linenoise.c
@@ -106,6 +106,7 @@
*/
#define _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L /* strdup */
#include "linenoise.h"
diff --git a/tools/lint/main.c b/tools/lint/main.c
index ebbd7f8..44eca9b 100644
--- a/tools/lint/main.c
+++ b/tools/lint/main.c
@@ -13,6 +13,7 @@
*/
#define _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L /* strdup */
#include <stdint.h>
#include <stdio.h>
diff --git a/tools/re/main.c b/tools/re/main.c
index c8d066f..8583e73 100644
--- a/tools/re/main.c
+++ b/tools/re/main.c
@@ -13,6 +13,7 @@
*/
#define _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L /* strdup, getline */
#include <errno.h>
#include <getopt.h>