Conditionalize temporary compatibility inclusions These inclusions were in place for backward compatibility purposes, when the headers were split so that code using them would not break. Make it possible for applications to disable them by defining LIBBSD_CLEAN_INCLUDES so that buildability can be tested and fixed before they get removed in a subsequent release.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
diff --git a/Makefile b/Makefile
index 05771b7..94cf55c 100644
--- a/Makefile
+++ b/Makefile
@@ -125,7 +125,9 @@ CFLAGS ?= -g -Wall -Wextra -Wno-unused-variable
LDFLAGS ?=
# Internal makefile variables
-MK_CPPFLAGS := -Iinclude/bsd/ -Iinclude/ -DLIBBSD_TRANSPARENT -D_GNU_SOURCE -D__REENTRANT
+MK_CPPFLAGS := -Iinclude/bsd/ -Iinclude/ \
+ -DLIBBSD_TRANSPARENT -DLIBBSD_CLEAN_INCLUDES \
+ -D_GNU_SOURCE -D__REENTRANT
MK_CFLAGS :=
MK_LDFLAGS :=
diff --git a/include/bsd/stdlib.h b/include/bsd/stdlib.h
index 6736ed1..4a185fc 100644
--- a/include/bsd/stdlib.h
+++ b/include/bsd/stdlib.h
@@ -47,8 +47,10 @@
#endif
/* FIXME: Temporary inclusions to avoid API breakage, will be removed soon. */
+#ifndef LIBBSD_CLEAN_INCLUDES
#include <bsd/stdio.h>
#include <bsd/unistd.h>
+#endif
__BEGIN_DECLS
u_int32_t arc4random();
diff --git a/include/bsd/string.h b/include/bsd/string.h
index edc16fc..f9e733f 100644
--- a/include/bsd/string.h
+++ b/include/bsd/string.h
@@ -36,8 +36,10 @@
#include <string.h>
#endif
+#ifndef LIBBSD_CLEAN_INCLUDES
/* FIXME: Temporary inclusion to avoid API breakage, will be removed soon. */
#include <bsd/stdio.h>
+#endif
__BEGIN_DECLS
size_t strlcpy(char *dst, const char *src, size_t siz);
diff --git a/src/vis.c b/src/vis.c
index 6153a7f..f869ed8 100644
--- a/src/vis.c
+++ b/src/vis.c
@@ -32,6 +32,7 @@
#include <limits.h>
#include <ctype.h>
#include <string.h>
+#include <stdio.h>
#include <vis.h>
#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')