Following an idea from Franco Fichtner, but implemented more cleanly.
This reduces groff-mandoc-differences in base by a fantastic 7.5%.
-# $OpenBSD: Makefile,v 1.6 2012/11/18 00:05:28 schwarze Exp $
+# $OpenBSD: Makefile,v 1.7 2013/12/25 00:39:14 schwarze Exp $
-REGRESS_TARGETS = basic section noarg font eos
+REGRESS_TARGETS = basic section break noarg font eos
-# groff 1.21 does not handle .nr nS
+# groff does not handle .nr nS
SKIP_GROFF ?= section
--- /dev/null
+.Dd December 25, 2013
+.Dt FO-BREAK 1
+.Os OpenBSD
+.Sh NAME
+.Nm Fo-break
+.Nd line breaks in function blocks
+.Sh SYNOPSIS
+.Ft my_long_return_type *
+.Fn my_long_function "my_long_type first_argument" "my_long_type second_argument"
+.Sh DESCRIPTION
+.Fn my_long_function "my_long_type first_argument" "my_long_type second_argument"
--- /dev/null
+FO-BREAK(1) OpenBSD Reference Manual FO-BREAK(1)
+
+N\bNA\bAM\bME\bE
+ F\bFo\bo-\b-b\bbr\bre\bea\bak\bk - line breaks in function blocks
+
+S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
+ _\bm_\by_\b__\bl_\bo_\bn_\bg_\b__\br_\be_\bt_\bu_\br_\bn_\b__\bt_\by_\bp_\be _\b*
+ m\bmy\by_\b_l\blo\bon\bng\bg_\b_f\bfu\bun\bnc\bct\bti\bio\bon\bn(_\bm_\by_\b__\bl_\bo_\bn_\bg_\b__\bt_\by_\bp_\be _\bf_\bi_\br_\bs_\bt_\b__\ba_\br_\bg_\bu_\bm_\be_\bn_\bt,
+ _\bm_\by_\b__\bl_\bo_\bn_\bg_\b__\bt_\by_\bp_\be _\bs_\be_\bc_\bo_\bn_\bd_\b__\ba_\br_\bg_\bu_\bm_\be_\bn_\bt);
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ m\bmy\by_\b_l\blo\bon\bng\bg_\b_f\bfu\bun\bnc\bct\bti\bio\bon\bn(_\bm_\by_\b__\bl_\bo_\bn_\bg_\b__\bt_\by_\bp_\be _\bf_\bi_\br_\bs_\bt_\b__\ba_\br_\bg_\bu_\bm_\be_\bn_\bt, _\bm_\by_\b__\bl_\bo_\bn_\bg_\b__\bt_\by_\bp_\be
+ _\bs_\be_\bc_\bo_\bn_\bd_\b__\ba_\br_\bg_\bu_\bm_\be_\bn_\bt)
+
+OpenBSD December 25, 2013 OpenBSD
-/* $Id: mdoc_man.c,v 1.54 2013/12/24 22:08:23 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.55 2013/12/25 00:39:13 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
*
#define MMAN_An_split (1 << 9) /* author mode is "split" */
#define MMAN_An_nosplit (1 << 10) /* author mode is "nosplit" */
#define MMAN_PD (1 << 11) /* inter-paragraph spacing disabled */
+#define MMAN_nbrword (1 << 12) /* do not break the next word */
#define BL_STACK_MAX 32
case (ASCII_HYPH):
putchar('-');
break;
+ case (' '):
+ if (MMAN_nbrword & outflags) {
+ printf("\\ ");
+ break;
+ }
+ /* FALLTHROUGH */
default:
putchar((unsigned char)*s);
break;
if (TPremain)
TPremain--;
}
+ outflags &= ~MMAN_nbrword;
}
static void
while (NULL != n) {
font_push('I');
+ if (MDOC_SYNPRETTY & n->flags)
+ outflags |= MMAN_nbrword;
print_node(meta, n);
font_pop();
if (NULL != (n = n->next))
-/* $Id: mdoc_term.c,v 1.156 2013/12/24 23:04:29 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.157 2013/12/25 00:39:13 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
for (n = n->next; n; n = n->next) {
assert(MDOC_TEXT == n->type);
term_fontpush(p, TERMFONT_UNDER);
+ if (pretty)
+ p->flags |= TERMP_NBRWORD;
term_word(p, n->string);
term_fontpop(p);
-/* $Id: term.c,v 1.74 2013/12/24 23:04:29 schwarze Exp $ */
+/* $Id: term.c,v 1.75 2013/12/25 00:39:13 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
void
term_word(struct termp *p, const char *word)
{
+ const char nbrsp[2] = { ASCII_NBRSP, 0 };
const char *seq, *cp;
char c;
int sz, uc;
word++;
continue;
}
- ssz = strcspn(word, "\\");
+ if (TERMP_NBRWORD & p->flags) {
+ if (' ' == *word) {
+ encode(p, nbrsp, 1);
+ word++;
+ continue;
+ }
+ ssz = strcspn(word, "\\ ");
+ } else
+ ssz = strcspn(word, "\\");
encode(p, word, ssz);
word += (int)ssz;
continue;
break;
}
}
+ p->flags &= ~TERMP_NBRWORD;
}
static void
-/* $Id: term.h,v 1.40 2013/12/24 23:04:29 schwarze Exp $ */
+/* $Id: term.h,v 1.41 2013/12/25 00:39:13 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
#define TERMP_SENTENCE (1 << 1) /* Space before a sentence. */
#define TERMP_NOSPACE (1 << 2) /* No space before words. */
#define TERMP_NONOSPACE (1 << 3) /* No space (no autounset). */
+#define TERMP_NBRWORD (1 << 4) /* Make next word nonbreaking. */
#define TERMP_KEEP (1 << 5) /* Keep words together. */
#define TERMP_PREKEEP (1 << 6) /* ...starting with the next one. */
#define TERMP_SKIPCHAR (1 << 7) /* Skip the next character. */