summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-01-01 17:14:26 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-01-01 17:14:26 +0000
commit92f665747e9d9aecac7c203e53d4eb175e662fc8 (patch)
tree343b938cade639d1cbcc09a9a00911f2789ee947
parent21ddc0a002b54301ac9de5f6dd73928ed0d73a94 (diff)
downloadmandoc-92f665747e9d9aecac7c203e53d4eb175e662fc8.tar.gz
Big check-in of compatibility layer. This should work on most major architectures. Thanks to Joerg Sonnenberger.
-rw-r--r--Makefile30
-rw-r--r--arch.c4
-rw-r--r--att.c4
-rw-r--r--chars.c4
-rw-r--r--compat.c9
-rw-r--r--config.h.post25
-rw-r--r--config.h.pre6
-rw-r--r--html.c9
-rw-r--r--lib.c4
-rw-r--r--main.c9
-rw-r--r--man.c8
-rw-r--r--man_action.c4
-rw-r--r--man_argv.c4
-rw-r--r--man_hash.c4
-rw-r--r--man_html.c9
-rw-r--r--man_macro.c4
-rw-r--r--man_term.c9
-rw-r--r--man_validate.c4
-rw-r--r--mandoc.c4
-rw-r--r--mdoc.c21
-rw-r--r--mdoc_action.c8
-rw-r--r--mdoc_argv.c4
-rw-r--r--mdoc_hash.c4
-rw-r--r--mdoc_html.c14
-rw-r--r--mdoc_macro.c4
-rw-r--r--mdoc_strings.c4
-rw-r--r--mdoc_term.c9
-rw-r--r--mdoc_validate.c8
-rw-r--r--msec.c4
-rw-r--r--out.c8
-rw-r--r--st.c4
-rw-r--r--term.c4
-rw-r--r--test-strlcat.c8
-rw-r--r--test-strlcpy.c8
-rw-r--r--tree.c4
-rw-r--r--vol.c4
36 files changed, 207 insertions, 67 deletions
diff --git a/Makefile b/Makefile
index 1ee8b325..09602188 100644
--- a/Makefile
+++ b/Makefile
@@ -13,9 +13,9 @@ INSTALL_MAN = $(INSTALL_DATA)
VERSION = 1.9.14
VDATE = 16 November 2009
-VFLAGS = -DVERSION="\"$(VERSION)\""
-CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings -g
-CFLAGS += $(VFLAGS)
+VFLAGS = -DVERSION="\"$(VERSION)\"" -DHAVE_CONFIG_H
+WFLAGS = -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
+CFLAGS += -g $(VFLAGS) $(WFLAGS)
#CFLAGS += -DOSNAME="\"OpenBSD 4.5\""
LINTFLAGS += $(VFLAGS)
@@ -74,11 +74,13 @@ TARGZS = mdocml-$(VERSION).tar.gz
MANS = mandoc.1 mdoc.3 mdoc.7 manuals.7 mandoc_char.7 \
man.7 man.3
BINS = mandoc
+TESTS = test-strlcat.c test-strlcpy.c
+CONFIGS = config.h.pre config.h.post
CLEAN = $(BINS) $(LNS) $(LLNS) $(LIBS) $(OBJS) $(HTMLS) \
$(TARGZS) tags $(MD5S) $(XMLS) $(TEXTS) $(GSGMLS) \
- $(GHTMLS)
+ $(GHTMLS) config.h config.log
INSTALL = $(SRCS) $(HEADS) Makefile $(MANS) $(SGMLS) $(STATICS) \
- $(DATAS) $(XSLS) $(EXAMPLES)
+ $(DATAS) $(XSLS) $(EXAMPLES) $(TESTS) $(CONFIGS)
all: $(BINS)
@@ -123,6 +125,8 @@ uninstall:
rm -f $(MANDIR)/man7/man.7
rm -f $(EXAMPLEDIR)/example.style.css
+$(OBJS): config.h
+
man_macro.ln: man_macro.c libman.h
man_macro.o: man_macro.c libman.h
@@ -254,3 +258,19 @@ mandoc: $(MAINOBJS) libmdoc.a libman.a
.tar.gz.md5:
md5 $< > $@
+
+config.h: config.h.pre config.h.post
+ rm -f config.log
+ ( cat config.h.pre; \
+ echo; \
+ if $(CC) $(CFLAGS) -c test-strlcat.c >> config.log 2>&1; then \
+ echo '#define HAVE_STRLCAT'; \
+ rm test-strlcat.o; \
+ fi; \
+ if $(CC) $(CFLAGS) -c test-strlcpy.c >> config.log 2>&1; then \
+ echo '#define HAVE_STRLCPY'; \
+ rm test-strlcpy.o; \
+ fi; \
+ echo; \
+ cat config.h.post \
+ ) > $@
diff --git a/arch.c b/arch.c
index 61eafd84..2455c474 100644
--- a/arch.c
+++ b/arch.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <time.h>
diff --git a/att.c b/att.c
index 46618ba2..40254d99 100644
--- a/att.c
+++ b/att.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <time.h>
diff --git a/chars.c b/chars.c
index c297e610..e1822e2e 100644
--- a/chars.c
+++ b/chars.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/compat.c b/compat.c
index 8665ffa8..f00cc5c6 100644
--- a/compat.c
+++ b/compat.c
@@ -15,12 +15,16 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <sys/types.h>
#include <string.h>
-#ifdef __linux__
+int dummy; /* To prevent an empty object file */
+#ifndef HAVE_STRLCAT
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
@@ -55,7 +59,9 @@ strlcat(char *dst, const char *src, size_t siz)
return(dlen + (s - src)); /* count does not include NUL */
}
+#endif
+#ifndef HAVE_STRLCPY
/*
* Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
@@ -86,5 +92,4 @@ strlcpy(char *dst, const char *src, size_t siz)
return(s - src - 1); /* count does not include NUL */
}
-
#endif
diff --git a/config.h.post b/config.h.post
new file mode 100644
index 00000000..81c01b93
--- /dev/null
+++ b/config.h.post
@@ -0,0 +1,25 @@
+#include <sys/types.h>
+
+#if !defined(__BEGIN_DECLS)
+# ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# else
+# define __BEGIN_DECLS
+# endif
+#endif
+#if !defined(__END_DECLS)
+# ifdef __cplusplus
+# define __END_DECLS }
+# else
+# define __END_DECLS
+# endif
+#endif
+
+#ifndef HAVE_STRLCAT
+extern size_t strlcat(char *, const char *, size_t);
+#endif
+#ifndef HAVE_STRLCPY
+extern size_t strlcpy(char *, const char *, size_t);
+#endif
+
+#endif /* MANDOC_CONFIG_H */
diff --git a/config.h.pre b/config.h.pre
new file mode 100644
index 00000000..a309ed95
--- /dev/null
+++ b/config.h.pre
@@ -0,0 +1,6 @@
+#ifndef MANDOC_CONFIG_H
+#define MANDOC_CONFIG_H
+
+#if defined(__linux__) || defined(__MINT__)
+# define _GNU_SOURCE /* strptime(), getsubopt() */
+#endif
diff --git a/html.c b/html.c
index be87919e..c1ae9eea 100644
--- a/html.c
+++ b/html.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/types.h>
#include <assert.h>
@@ -89,11 +93,6 @@ static const char *const htmlattrs[ATTR_MAX] = {
"summary",
};
-#ifdef __linux__
-extern int getsubopt(char **, char * const *, char **);
-#endif
-
-
static void print_spec(struct html *, const char *, size_t);
static void print_res(struct html *, const char *, size_t);
static void print_ctag(struct html *, enum htmltag);
diff --git a/lib.c b/lib.c
index fa0b4ad2..e9f4a80d 100644
--- a/lib.c
+++ b/lib.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <time.h>
diff --git a/main.c b/main.c
index ddc74756..20fe0cce 100644
--- a/main.c
+++ b/main.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/stat.h>
#include <assert.h>
@@ -38,11 +42,6 @@
# endif
#endif /* !defined(__GNUC__) || (__GNUC__ < 2) */
-#ifdef __linux__
-extern int getsubopt(char **, char * const *, char **);
-extern size_t strlcat(char *, const char *, size_t);
-#endif
-
typedef void (*out_mdoc)(void *, const struct mdoc *);
typedef void (*out_man)(void *, const struct man *);
typedef void (*out_free)(void *);
diff --git a/man.c b/man.c
index 345e0789..1bcf7d5b 100644
--- a/man.c
+++ b/man.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/types.h>
#include <assert.h>
@@ -72,10 +76,6 @@ static int pstring(struct man *, int, int,
const char *, size_t);
static int macrowarn(struct man *, int, const char *);
-#ifdef __linux__
-extern size_t strlcpy(char *, const char *, size_t);
-#endif
-
const struct man_node *
man_node(const struct man *m)
diff --git a/man_action.c b/man_action.c
index aa56dda6..2d3000f5 100644
--- a/man_action.c
+++ b/man_action.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/utsname.h>
#include <assert.h>
diff --git a/man_argv.c b/man_argv.c
index 65d088f7..92c46d0e 100644
--- a/man_argv.c
+++ b/man_argv.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/types.h>
#include <assert.h>
diff --git a/man_hash.c b/man_hash.c
index 572be63d..7ca0da44 100644
--- a/man_hash.c
+++ b/man_hash.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/types.h>
#include <assert.h>
diff --git a/man_html.c b/man_html.c
index d510ac09..32406eff 100644
--- a/man_html.c
+++ b/man_html.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/types.h>
#include <assert.h>
@@ -66,11 +70,6 @@ static int man_SH_pre(MAN_ARGS);
static int man_SM_pre(MAN_ARGS);
static int man_SS_pre(MAN_ARGS);
-#ifdef __linux__
-extern size_t strlcpy(char *, const char *, size_t);
-extern size_t strlcat(char *, const char *, size_t);
-#endif
-
static const struct htmlman mans[MAN_MAX] = {
{ man_br_pre, NULL }, /* br */
{ NULL, NULL }, /* TH */
diff --git a/man_macro.c b/man_macro.c
index 9c290e45..6f2e8348 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
diff --git a/man_term.c b/man_term.c
index 03f5cfdf..139ec436 100644
--- a/man_term.c
+++ b/man_term.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/types.h>
#include <assert.h>
@@ -63,11 +67,6 @@ struct termact {
void (*post)(DECL_ARGS);
};
-#ifdef __linux__
-extern size_t strlcpy(char *, const char *, size_t);
-extern size_t strlcat(char *, const char *, size_t);
-#endif
-
static int a2width(const struct man_node *);
static int a2height(const struct man_node *);
diff --git a/man_validate.c b/man_validate.c
index 3c5944fa..85cc763f 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/types.h>
#include <assert.h>
diff --git a/mandoc.c b/mandoc.c
index 58c2d273..cf545382 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -14,8 +14,8 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if defined(__linux__) || defined(__MINT__)
-# define _GNU_SOURCE /* strptime() */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
#endif
#include <sys/types.h>
diff --git a/mdoc.c b/mdoc.c
index fd5b291c..f8024332 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/types.h>
#include <assert.h>
@@ -93,11 +97,11 @@ const char *const __mdoc_macronames[MDOC_MAX] = {
"Nm", "Op", "Ot", "Pa",
"Rv", "St", "Va", "Vt",
/* LINTED */
- "Xr", "\%A", "\%B", "\%D",
+ "Xr", "%A", "%B", "%D",
/* LINTED */
- "\%I", "\%J", "\%N", "\%O",
+ "%I", "%J", "%N", "%O",
/* LINTED */
- "\%P", "\%R", "\%T", "\%V",
+ "%P", "%R", "%T", "%V",
"Ac", "Ao", "Aq", "At",
"Bc", "Bf", "Bo", "Bq",
"Bsx", "Bx", "Db", "Dc",
@@ -114,11 +118,11 @@ const char *const __mdoc_macronames[MDOC_MAX] = {
"Fr", "Ud", "Lb", "Lp",
"Lk", "Mt", "Brq", "Bro",
/* LINTED */
- "Brc", "\%C", "Es", "En",
+ "Brc", "%C", "Es", "En",
/* LINTED */
- "Dx", "\%Q", "br", "sp",
+ "Dx", "%Q", "br", "sp",
/* LINTED */
- "\%U"
+ "%U"
};
const char *const __mdoc_argnames[MDOC_ARG_MAX] = {
@@ -148,11 +152,6 @@ static int macrowarn(struct mdoc *, int, const char *);
static int pstring(struct mdoc *, int, int,
const char *, size_t);
-#ifdef __linux__
-extern size_t strlcpy(char *, const char *, size_t);
-#endif
-
-
const struct mdoc_node *
mdoc_node(const struct mdoc *m)
{
diff --git a/mdoc_action.c b/mdoc_action.c
index 3cd0332c..dfe2aafc 100644
--- a/mdoc_action.c
+++ b/mdoc_action.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#ifndef OSNAME
#include <sys/utsname.h>
#endif
@@ -42,10 +46,6 @@ static int concat(struct mdoc *, char *,
const struct mdoc_node *, size_t);
static inline int order_rs(int);
-#ifdef __linux__
-extern size_t strlcat(char *, const char *, size_t);
-#endif
-
static int post_ar(POST_ARGS);
static int post_at(POST_ARGS);
static int post_bl(POST_ARGS);
diff --git a/mdoc_argv.c b/mdoc_argv.c
index 726a3f3f..4a96436c 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/types.h>
#include <assert.h>
diff --git a/mdoc_hash.c b/mdoc_hash.c
index be2d457a..871000fc 100644
--- a/mdoc_hash.c
+++ b/mdoc_hash.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/types.h>
#include <assert.h>
diff --git a/mdoc_html.c b/mdoc_html.c
index e43d9809..c9766217 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -14,8 +14,11 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/types.h>
-#include <sys/param.h>
#include <assert.h>
#include <ctype.h>
@@ -36,6 +39,10 @@
const struct mdoc_node *n, \
struct html *h
+#ifndef MIN
+#define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b))
+#endif
+
struct htmlmdoc {
int (*pre)(MDOC_ARGS);
void (*post)(MDOC_ARGS);
@@ -126,11 +133,6 @@ static int mdoc_vt_pre(MDOC_ARGS);
static int mdoc_xr_pre(MDOC_ARGS);
static int mdoc_xx_pre(MDOC_ARGS);
-#ifdef __linux__
-extern size_t strlcpy(char *, const char *, size_t);
-extern size_t strlcat(char *, const char *, size_t);
-#endif
-
static const struct htmlmdoc mdocs[MDOC_MAX] = {
{mdoc_ap_pre, NULL}, /* Ap */
{NULL, NULL}, /* Dd */
diff --git a/mdoc_macro.c b/mdoc_macro.c
index ca4e554f..106a05db 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
diff --git a/mdoc_strings.c b/mdoc_strings.c
index 44413cbc..be96ca87 100644
--- a/mdoc_strings.c
+++ b/mdoc_strings.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/types.h>
#include <assert.h>
diff --git a/mdoc_term.c b/mdoc_term.c
index 6c6c4775..405fde3f 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/types.h>
#include <assert.h>
@@ -64,11 +68,6 @@ static void print_mdoc_head(DECL_ARGS);
static void print_mdoc_nodelist(DECL_ARGS);
static void print_foot(DECL_ARGS);
-#ifdef __linux__
-extern size_t strlcpy(char *, const char *, size_t);
-extern size_t strlcat(char *, const char *, size_t);
-#endif
-
static void termp____post(DECL_ARGS);
static void termp_an_post(DECL_ARGS);
static void termp_aq_post(DECL_ARGS);
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 5a4a92b3..22376c13 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/types.h>
#include <assert.h>
@@ -62,10 +66,6 @@ static int warn_count(struct mdoc *, const char *,
static int err_count(struct mdoc *, const char *,
int, const char *, int);
-#ifdef __linux__
-extern size_t strlcat(char *, const char *, size_t);
-#endif
-
static int berr_ge1(POST_ARGS);
static int bwarn_ge1(POST_ARGS);
static int ebool(POST_ARGS);
diff --git a/msec.c b/msec.c
index 9ab85ca6..058cb992 100644
--- a/msec.c
+++ b/msec.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <time.h>
diff --git a/out.c b/out.c
index dd584d7a..3ec0f319 100644
--- a/out.c
+++ b/out.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/types.h>
#include <assert.h>
@@ -45,10 +49,6 @@
(t) = 3; } \
while (/* CONSTCOND */ 0)
-#ifdef __linux__
-extern size_t strlcat(char *, const char *, size_t);
-#endif
-
/*
* Convert a `scaling unit' to a consistent form, or fail. Scaling
* units are documented in groff.7, mdoc.7, man.7.
diff --git a/st.c b/st.c
index 1c9a45a0..05593eb2 100644
--- a/st.c
+++ b/st.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <time.h>
diff --git a/term.c b/term.c
index 4ab35a2d..ede55851 100644
--- a/term.c
+++ b/term.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <sys/types.h>
#include <assert.h>
diff --git a/test-strlcat.c b/test-strlcat.c
new file mode 100644
index 00000000..5d450dd0
--- /dev/null
+++ b/test-strlcat.c
@@ -0,0 +1,8 @@
+#include <string.h>
+
+int
+main(int argc, char **argv)
+{
+ strlcat(argv[0], argv[1], 10);
+ return 0;
+}
diff --git a/test-strlcpy.c b/test-strlcpy.c
new file mode 100644
index 00000000..c7d182aa
--- /dev/null
+++ b/test-strlcpy.c
@@ -0,0 +1,8 @@
+#include <string.h>
+
+int
+main(int argc, char **argv)
+{
+ strlcpy(argv[0], argv[1], 10);
+ return 0;
+}
diff --git a/tree.c b/tree.c
index 21137e1f..bf498a87 100644
--- a/tree.c
+++ b/tree.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/vol.c b/vol.c
index c90be044..798129f0 100644
--- a/vol.c
+++ b/vol.c
@@ -14,6 +14,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <time.h>