diff options
Diffstat (limited to 'man_term.c')
-rw-r--r-- | man_term.c | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.146 2014/04/20 16:46:04 schwarze Exp $ */ +/* $Id: man_term.c,v 1.147 2014/04/20 20:18:12 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -28,6 +28,7 @@ #include <string.h> #include "mandoc.h" +#include "mandoc_aux.h" #include "out.h" #include "man.h" #include "term.h" @@ -1049,9 +1050,9 @@ print_man_nodelist(DECL_ARGS) static void print_man_foot(struct termp *p, const void *arg) { - char title[BUFSIZ]; - size_t datelen; - const struct man_meta *meta; + const struct man_meta *meta; + char *title; + size_t datelen; meta = (const struct man_meta *)arg; assert(meta->title); @@ -1071,11 +1072,12 @@ print_man_foot(struct termp *p, const void *arg) if ( ! p->mdocstyle) { term_vspace(p); term_vspace(p); - snprintf(title, BUFSIZ, "%s(%s)", meta->title, meta->msec); + mandoc_asprintf(&title, "%s(%s)", + meta->title, meta->msec); } else if (meta->source) { - strlcpy(title, meta->source, BUFSIZ); + title = mandoc_strdup(meta->source); } else { - title[0] = '\0'; + title = mandoc_strdup(""); } datelen = term_strlen(p, meta->date); @@ -1111,14 +1113,16 @@ print_man_foot(struct termp *p, const void *arg) term_word(p, title); term_flushln(p); + free(title); } static void print_man_head(struct termp *p, const void *arg) { - char buf[BUFSIZ], title[BUFSIZ]; - size_t buflen, titlen; - const struct man_meta *meta; + char buf[BUFSIZ]; + const struct man_meta *meta; + char *title; + size_t buflen, titlen; meta = (const struct man_meta *)arg; assert(meta->title); @@ -1132,7 +1136,7 @@ print_man_head(struct termp *p, const void *arg) /* Top left corner: manual title and section. */ - snprintf(title, BUFSIZ, "%s(%s)", meta->title, meta->msec); + mandoc_asprintf(&title, "%s(%s)", meta->title, meta->msec); titlen = term_strlen(p, title); p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; @@ -1183,4 +1187,5 @@ print_man_head(struct termp *p, const void *arg) term_vspace(p); term_vspace(p); } + free(title); } |