From: schwarze Date: Fri, 8 Jul 2016 22:27:58 +0000 (+0000) Subject: ISO C99 7.19.2.5 doesn't like mixing putchar(3) and putwchar(3) on X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2db2cb23316801370eb6bebdc8d2fa99d46a233f;p=openbsd ISO C99 7.19.2.5 doesn't like mixing putchar(3) and putwchar(3) on the same stream, and actually, it fails spectacularly on glibc. Portability issue pointed out by Svyatoslav Mishyn after testing on Void Linux. --- diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c index 8cadeef4eac..1a4092fe80e 100644 --- a/usr.bin/mandoc/main.c +++ b/usr.bin/mandoc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.172 2016/04/14 20:54:15 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.173 2016/07/08 22:27:58 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2012, 2014-2016 Ingo Schwarze @@ -438,7 +438,7 @@ main(int argc, char *argv[]) conf.output.synopsisonly); if (argc > 1 && curp.outtype <= OUTT_UTF8) - ascii_sepline(curp.outdata); + terminal_sepline(curp.outdata); } else if (rc < MANDOCLEVEL_ERROR) rc = MANDOCLEVEL_ERROR; diff --git a/usr.bin/mandoc/main.h b/usr.bin/mandoc/main.h index a295d41e135..ee2cbf1d34a 100644 --- a/usr.bin/mandoc/main.h +++ b/usr.bin/mandoc/main.h @@ -1,4 +1,4 @@ -/* $OpenBSD: main.h,v 1.19 2015/11/07 13:57:55 schwarze Exp $ */ +/* $OpenBSD: main.h,v 1.20 2016/07/08 22:27:58 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2014, 2015 Ingo Schwarze @@ -43,7 +43,6 @@ void *locale_alloc(const struct manoutput *); void *utf8_alloc(const struct manoutput *); void *ascii_alloc(const struct manoutput *); void ascii_free(void *); -void ascii_sepline(void *); void *pdf_alloc(const struct manoutput *); void *ps_alloc(const struct manoutput *); @@ -51,3 +50,4 @@ void pspdf_free(void *); void terminal_mdoc(void *, const struct roff_man *); void terminal_man(void *, const struct roff_man *); +void terminal_sepline(void *); diff --git a/usr.bin/mandoc/term_ascii.c b/usr.bin/mandoc/term_ascii.c index bf8a0a555ea..e2e3c251416 100644 --- a/usr.bin/mandoc/term_ascii.c +++ b/usr.bin/mandoc/term_ascii.c @@ -1,4 +1,4 @@ -/* $OpenBSD: term_ascii.c,v 1.38 2015/11/12 21:49:29 schwarze Exp $ */ +/* $OpenBSD: term_ascii.c,v 1.39 2016/07/08 22:27:58 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * Copyright (c) 2014, 2015 Ingo Schwarze @@ -151,18 +151,17 @@ ascii_setwidth(struct termp *p, int iop, int width) } void -ascii_sepline(void *arg) +terminal_sepline(void *arg) { struct termp *p; size_t i; p = (struct termp *)arg; - p->line += 3; - putchar('\n'); + (*p->endline)(p); for (i = 0; i < p->defrmargin; i++) - putchar('-'); - putchar('\n'); - putchar('\n'); + (*p->letter)(p, '-'); + (*p->endline)(p); + (*p->endline)(p); } static size_t