aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_man.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2012-11-19 02:08:33 +0000
committerIngo Schwarze <schwarze@openbsd.org>2012-11-19 02:08:33 +0000
commit96e68bb947ec46849925ed6850e64391bc2d85e3 (patch)
treec9356cdc378c08a01b98e812158a1264f1e19acf /mdoc_man.c
parentdd41ba9876ecdb30f9dbb35bcdeff569f90b2c0a (diff)
downloadmandoc-96e68bb947ec46849925ed6850e64391bc2d85e3.tar.gz
mandoc-96e68bb947ec46849925ed6850e64391bc2d85e3.tar.zst
mandoc-96e68bb947ec46849925ed6850e64391bc2d85e3.zip
Three portability improvements by millert@:
* Use "\\ " not "\\~" as the non-breaking space as historic nroff doesn't support the latter. * The '-' before the flags needs to be quoted to prevent nroff from putting a line break between the '-' and the flag character. * Disable hyphenation and, for nroff, disable justification which is consistent with how mdoc behaves (and produces more readable manuals). (OpenBSD rev. 1.39, 1.40 and 1.41)
Diffstat (limited to 'mdoc_man.c')
-rw-r--r--mdoc_man.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/mdoc_man.c b/mdoc_man.c
index 960e9ea8..f7463498 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_man.c,v 1.44 2012/11/18 19:34:19 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.45 2012/11/19 02:08:33 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -334,11 +334,9 @@ print_word(const char *s)
*/
if (MMAN_spc_force & outflags || '\0' == s[0] ||
NULL == strchr(".,:;)]?!", s[0]) || '\0' != s[1]) {
- if (MMAN_Bk & outflags) {
+ if (MMAN_Bk & outflags)
putchar('\\');
- putchar('~');
- } else
- putchar(' ');
+ putchar(' ');
if (TPremain)
TPremain--;
}
@@ -358,7 +356,7 @@ print_word(const char *s)
for ( ; *s; s++) {
switch (*s) {
case (ASCII_NBRSP):
- printf("\\~");
+ printf("\\ ");
break;
case (ASCII_HYPH):
putchar('-');
@@ -535,10 +533,13 @@ man_mdoc(void *arg, const struct mdoc *mdoc)
meta = mdoc_meta(mdoc);
n = mdoc_node(mdoc);
- printf(".TH \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"",
+ printf(".TH \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n",
meta->title, meta->msec, meta->date,
meta->os, meta->vol);
+ /* Disable hyphenation and if nroff, disable justification. */
+ printf(".nh\n.if n .ad l");
+
outflags = MMAN_nl | MMAN_Sm;
if (0 == fontqueue.size) {
fontqueue.size = 8;
@@ -1053,7 +1054,7 @@ pre_fl(DECL_ARGS)
{
font_push('B');
- print_word("-");
+ print_word("\\-");
outflags &= ~MMAN_spc;
return(1);
}
@@ -1531,7 +1532,7 @@ pre_ux(DECL_ARGS)
if (NULL == n->child)
return(0);
outflags &= ~MMAN_spc;
- print_word("\\~");
+ print_word("\\ ");
outflags &= ~MMAN_spc;
return(1);
}