diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2009-04-15 20:10:21 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2009-04-15 20:10:21 +0000 |
commit | 3df9170d3de4c2e6db515283aeb375d34e819233 (patch) | |
tree | 4858baf4f1d0d7f7d56e0bc80fdc585ae4514118 /usr.bin/mandoc | |
parent | a377a06ec4216b7415ec3f4a9de96bc37b8904f2 (diff) |
Replace variadic macros with real functions, so that this compiles on
platforms still using gcc 2.
ok deraadt@
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r-- | usr.bin/mandoc/Makefile | 9 | ||||
-rw-r--r-- | usr.bin/mandoc/libmdoc.h | 45 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc.c | 137 |
3 files changed, 153 insertions, 38 deletions
diff --git a/usr.bin/mandoc/Makefile b/usr.bin/mandoc/Makefile index 26886be5de0..e1071157e07 100644 --- a/usr.bin/mandoc/Makefile +++ b/usr.bin/mandoc/Makefile @@ -1,6 +1,11 @@ -# $OpenBSD: Makefile,v 1.1 2009/04/06 20:30:40 kristaps Exp $ +# $OpenBSD: Makefile,v 1.2 2009/04/15 20:10:20 miod Exp $ -CFLAGS+=-W -Wall -Wstrict-prototypes -Wno-unused-parameter +.include <bsd.own.mk> + +CFLAGS+=-W -Wall -Wstrict-prototypes +.if ${USE_GCC3:L} != "no" +CFLAGS+=-Wno-unused-parameter +.endif SRCS= mdoc_macro.c mdoc.c mdoc_hash.c mdoc_strings.c \ mdoc_argv.c mdoc_validate.c mdoc_action.c lib.c att.c \ diff --git a/usr.bin/mandoc/libmdoc.h b/usr.bin/mandoc/libmdoc.h index fa0c996a066..ea83e542118 100644 --- a/usr.bin/mandoc/libmdoc.h +++ b/usr.bin/mandoc/libmdoc.h @@ -1,4 +1,4 @@ -/* $Id: libmdoc.h,v 1.1 2009/04/06 20:30:40 kristaps Exp $ */ +/* $Id: libmdoc.h,v 1.2 2009/04/15 20:10:20 miod Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org> * @@ -57,38 +57,6 @@ struct mdoc_macro { /* Reserved words in arguments treated as text. */ }; -#define mdoc_nwarn(mdoc, node, type, fmt, ...) \ - mdoc_vwarn((mdoc), (node)->line, \ - (node)->pos, (type), (fmt), ##__VA_ARGS__) - -#define mdoc_nerr(mdoc, node, fmt, ...) \ - mdoc_verr((mdoc), (node)->line, \ - (node)->pos, (fmt), ##__VA_ARGS__) - -#define mdoc_warn(mdoc, type, fmt, ...) \ - mdoc_vwarn((mdoc), (mdoc)->last->line, \ - (mdoc)->last->pos, (type), (fmt), ##__VA_ARGS__) - -#define mdoc_err(mdoc, fmt, ...) \ - mdoc_verr((mdoc), (mdoc)->last->line, \ - (mdoc)->last->pos, (fmt), ##__VA_ARGS__) - -#define mdoc_msg(mdoc, fmt, ...) \ - mdoc_vmsg((mdoc), (mdoc)->last->line, \ - (mdoc)->last->pos, (fmt), ##__VA_ARGS__) - -#define mdoc_pmsg(mdoc, line, pos, fmt, ...) \ - mdoc_vmsg((mdoc), (line), \ - (pos), (fmt), ##__VA_ARGS__) - -#define mdoc_pwarn(mdoc, line, pos, type, fmt, ...) \ - mdoc_vwarn((mdoc), (line), \ - (pos), (type), (fmt), ##__VA_ARGS__) - -#define mdoc_perr(mdoc, line, pos, fmt, ...) \ - mdoc_verr((mdoc), (line), \ - (pos), (fmt), ##__VA_ARGS__) - extern const struct mdoc_macro *const mdoc_macros; __BEGIN_DECLS @@ -99,6 +67,17 @@ void mdoc_vmsg(struct mdoc *, int, int, const char *, ...); int mdoc_verr(struct mdoc *, int, int, const char *, ...); +int mdoc_nwarn(struct mdoc *, const struct mdoc_node *, + enum mdoc_warn, const char *, ...); +int mdoc_nerr(struct mdoc *, const struct mdoc_node *, + const char *, ...); +int mdoc_warn(struct mdoc *, enum mdoc_warn, const char *, ...); +int mdoc_err(struct mdoc *, const char *, ...); +void mdoc_msg(struct mdoc *, const char *, ...); +void mdoc_pmsg(struct mdoc *, int, int, const char *, ...); +int mdoc_pwarn(struct mdoc *, int, int, + enum mdoc_warn,const char *, ...); +int mdoc_perr(struct mdoc *, int, int, const char *, ...); int mdoc_macro(MACRO_PROT_ARGS); int mdoc_word_alloc(struct mdoc *, int, int, const char *); diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c index ca4a42f74dc..d1c84c6c870 100644 --- a/usr.bin/mandoc/mdoc.c +++ b/usr.bin/mandoc/mdoc.c @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.1 2009/04/06 20:30:40 kristaps Exp $ */ +/* $Id: mdoc.c,v 1.2 2009/04/15 20:10:20 miod Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org> * @@ -261,8 +261,7 @@ mdoc_vmsg(struct mdoc *mdoc, int ln, int pos, const char *fmt, ...) int -mdoc_verr(struct mdoc *mdoc, int ln, int pos, - const char *fmt, ...) +mdoc_verr(struct mdoc *mdoc, int ln, int pos, const char *fmt, ...) { char buf[256]; va_list ap; @@ -295,6 +294,138 @@ mdoc_vwarn(struct mdoc *mdoc, int ln, int pos, int +mdoc_nwarn(struct mdoc *mdoc, const struct mdoc_node *node, enum mdoc_warn type, + const char *fmt, ...) +{ + char buf[256]; + va_list ap; + + if (NULL == mdoc->cb.mdoc_warn) + return(0); + + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + return((*mdoc->cb.mdoc_warn)(mdoc->data, node->line, node->pos, type, + buf)); +} + +int +mdoc_nerr(struct mdoc *mdoc, const struct mdoc_node *node, const char *fmt, ...) +{ + char buf[256]; + va_list ap; + + if (NULL == mdoc->cb.mdoc_err) + return(0); + + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + return((*mdoc->cb.mdoc_err)(mdoc->data, node->line, node->pos, buf)); +} + + +int +mdoc_warn(struct mdoc *mdoc, enum mdoc_warn type, const char *fmt, ...) +{ + char buf[256]; + va_list ap; + + if (NULL == mdoc->cb.mdoc_warn) + return(0); + + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + return((*mdoc->cb.mdoc_warn)(mdoc->data, mdoc->last->line, + mdoc->last->pos, type, buf)); +} + + +int +mdoc_err(struct mdoc *mdoc, const char *fmt, ...) +{ + char buf[256]; + va_list ap; + + if (NULL == mdoc->cb.mdoc_err) + return(0); + + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + return((*mdoc->cb.mdoc_err)(mdoc->data, mdoc->last->line, + mdoc->last->pos, buf)); +} + + +void +mdoc_msg(struct mdoc *mdoc, const char *fmt, ...) +{ + char buf[256]; + va_list ap; + + if (NULL == mdoc->cb.mdoc_msg) + return; + + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + (*mdoc->cb.mdoc_msg)(mdoc->data, mdoc->last->line, mdoc->last->pos, + buf); +} + + +void +mdoc_pmsg(struct mdoc *mdoc, int line, int pos, const char *fmt, ...) +{ + char buf[256]; + va_list ap; + + if (NULL == mdoc->cb.mdoc_msg) + return; + + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + (*mdoc->cb.mdoc_msg)(mdoc->data, line, pos, buf); +} + + +int +mdoc_pwarn(struct mdoc *mdoc, int line, int pos, enum mdoc_warn type, + const char *fmt, ...) +{ + char buf[256]; + va_list ap; + + if (NULL == mdoc->cb.mdoc_warn) + return(0); + + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + return((*mdoc->cb.mdoc_warn)(mdoc->data, line, pos, type, buf)); +} + +int +mdoc_perr(struct mdoc *mdoc, int line, int pos, const char *fmt, ...) +{ + char buf[256]; + va_list ap; + + if (NULL == mdoc->cb.mdoc_err) + return(0); + + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); + va_end(ap); + return((*mdoc->cb.mdoc_err)(mdoc->data, line, pos, buf)); +} + + +int mdoc_macro(struct mdoc *m, int tok, int ln, int pp, int *pos, char *buf) { |