summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2016-07-19 13:36:13 +0000
committerIngo Schwarze <schwarze@openbsd.org>2016-07-19 13:36:13 +0000
commitaf5633117326edd60450c53218694c3e0a895639 (patch)
treeb6879fc1b21fcf25e8f558cc4d83f3c02404bbec
parent0d64a6e6bb89ff458faef3450acd365244bcf4a8 (diff)
downloadmandoc-af5633117326edd60450c53218694c3e0a895639.tar.gz
Use __attribute__((__format__ throughout.
Triggered by a smaller patch from Christos Zoulas. While here, unify style, move several config tests to config.h, and delete the useless MANDOC_CONFIG_H.
-rwxr-xr-xconfigure8
-rw-r--r--html.h6
-rw-r--r--libmandoc.h6
-rw-r--r--main.c6
-rw-r--r--mandoc_aux.h3
-rw-r--r--mandocdb.c7
-rw-r--r--term_ps.c6
7 files changed, 15 insertions, 27 deletions
diff --git a/configure b/configure
index 9d670b43..9e7128e6 100755
--- a/configure
+++ b/configure
@@ -285,8 +285,9 @@ cat << __HEREDOC__
#error "Do not use C++. See the INSTALL file."
#endif
-#ifndef MANDOC_CONFIG_H
-#define MANDOC_CONFIG_H
+#if !defined(__GNUC__) || (__GNUC__ < 4)
+#define __attribute__(x)
+#endif
#if defined(__linux__) || defined(__MINT__)
#define _GNU_SOURCE /* See test-*.c what needs this. */
@@ -391,9 +392,6 @@ fi
[ ${HAVE_VASPRINTF} -eq 0 ] && \
echo "extern int vasprintf(char **, const char *, va_list);"
-echo
-echo "#endif /* MANDOC_CONFIG_H */"
-
echo "config.h: written" 1>&2
echo "config.h: written" 1>&3
diff --git a/html.h b/html.h
index 500c2c0a..9f650630 100644
--- a/html.h
+++ b/html.h
@@ -158,10 +158,8 @@ void print_tbl(struct html *, const struct tbl_span *);
void print_eqn(struct html *, const struct eqn *);
void print_paragraph(struct html *);
-#if __GNUC__ - 0 >= 4
-__attribute__((__format__ (__printf__, 2, 3)))
-#endif
-void bufcat_fmt(struct html *, const char *, ...);
+void bufcat_fmt(struct html *, const char *, ...)
+ __attribute__((__format__ (printf, 2, 3)));
void bufcat(struct html *, const char *);
void bufcat_id(struct html *, const char *);
void bufcat_style(struct html *,
diff --git a/libmandoc.h b/libmandoc.h
index c00679fd..2003ec63 100644
--- a/libmandoc.h
+++ b/libmandoc.h
@@ -41,11 +41,9 @@ struct roff_man;
void mandoc_msg(enum mandocerr, struct mparse *,
int, int, const char *);
-#if __GNUC__ - 0 >= 4
-__attribute__((__format__ (__printf__, 5, 6)))
-#endif
void mandoc_vmsg(enum mandocerr, struct mparse *,
- int, int, const char *, ...);
+ int, int, const char *, ...)
+ __attribute__((__format__ (printf, 5, 6)));
char *mandoc_getarg(struct mparse *, char **, int, int *);
char *mandoc_normdate(struct mparse *, char *, int, int);
int mandoc_eos(const char *, size_t);
diff --git a/main.c b/main.c
index a637ef4f..40c06b8f 100644
--- a/main.c
+++ b/main.c
@@ -51,12 +51,6 @@
#include "manconf.h"
#include "mansearch.h"
-#if !defined(__GNUC__) || (__GNUC__ < 2)
-# if !defined(lint)
-# define __attribute__(x)
-# endif
-#endif /* !defined(__GNUC__) || (__GNUC__ < 2) */
-
enum outmode {
OUTMODE_DEF = 0,
OUTMODE_FLN,
diff --git a/mandoc_aux.h b/mandoc_aux.h
index feb84994..b6a70ae9 100644
--- a/mandoc_aux.h
+++ b/mandoc_aux.h
@@ -16,7 +16,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-int mandoc_asprintf(char **, const char *, ...);
+int mandoc_asprintf(char **, const char *, ...)
+ __attribute__((__format__ (printf, 2, 3)));
void *mandoc_calloc(size_t, size_t);
void *mandoc_malloc(size_t);
void *mandoc_realloc(void *, size_t);
diff --git a/mandocdb.c b/mandocdb.c
index 40de09f1..e08d855a 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -185,7 +185,8 @@ static void putkeys(const struct mpage *, char *, size_t, uint64_t);
static void putmdockey(const struct mpage *,
const struct roff_node *, uint64_t);
static int render_string(char **, size_t *);
-static void say(const char *, const char *, ...);
+static void say(const char *, const char *, ...)
+ __attribute__((__format__ (printf, 2, 3)));
static int set_basedir(const char *, int);
static int treescan(void);
static size_t utf8(unsigned int, char [7]);
@@ -1818,7 +1819,7 @@ putkeys(const struct mpage *mpage, char *cp, size_t sz, uint64_t v)
name_mask &= ~NAME_FIRST;
if (debug > 1)
say(mpage->mlinks->file,
- "Adding name %*s, bits=%d", sz, cp, v);
+ "Adding name %*s, bits=0x%llu", (int)sz, cp, v);
} else {
htab = &strings;
if (debug > 1)
@@ -1826,7 +1827,7 @@ putkeys(const struct mpage *mpage, char *cp, size_t sz, uint64_t v)
if ((uint64_t)1 << i & v)
say(mpage->mlinks->file,
"Adding key %s=%*s",
- mansearch_keynames[i], sz, cp);
+ mansearch_keynames[i], (int)sz, cp);
}
end = cp + sz;
diff --git a/term_ps.c b/term_ps.c
index f297d35a..017a575b 100644
--- a/term_ps.c
+++ b/term_ps.c
@@ -103,10 +103,8 @@ static void ps_growbuf(struct termp *, size_t);
static void ps_letter(struct termp *, int);
static void ps_pclose(struct termp *);
static void ps_pletter(struct termp *, int);
-#if __GNUC__ - 0 >= 4
-__attribute__((__format__ (__printf__, 2, 3)))
-#endif
-static void ps_printf(struct termp *, const char *, ...);
+static void ps_printf(struct termp *, const char *, ...)
+ __attribute__((__format__ (printf, 2, 3)));
static void ps_putchar(struct termp *, char);
static void ps_setfont(struct termp *, enum termfont);
static void ps_setwidth(struct termp *, int, int);