summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2010-06-27 01:26:20 +0000
committerIngo Schwarze <schwarze@openbsd.org>2010-06-27 01:26:20 +0000
commit186075c603215a3baa6ee2dd6ff0060ae58deb63 (patch)
tree6a031f6e6b2fe6e9aef2093cce03b01c787d5d89
parentc5cf90497acc3621015972b85b9c079b43601342 (diff)
downloadmandoc-186075c603215a3baa6ee2dd6ff0060ae58deb63.tar.gz
Basic implementation of .Bk/.Ek; from OpenBSD.
OK and one stylistic tweak by kristaps@.
-rw-r--r--mdoc_term.c22
-rw-r--r--term.c9
-rw-r--r--term.h2
3 files changed, 30 insertions, 3 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index 8943e8d2..7cc7388c 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -73,6 +73,7 @@ static void termp____post(DECL_ARGS);
static void termp_an_post(DECL_ARGS);
static void termp_aq_post(DECL_ARGS);
static void termp_bd_post(DECL_ARGS);
+static void termp_bk_post(DECL_ARGS);
static void termp_bl_post(DECL_ARGS);
static void termp_bq_post(DECL_ARGS);
static void termp_brq_post(DECL_ARGS);
@@ -97,6 +98,7 @@ static int termp_ap_pre(DECL_ARGS);
static int termp_aq_pre(DECL_ARGS);
static int termp_bd_pre(DECL_ARGS);
static int termp_bf_pre(DECL_ARGS);
+static int termp_bk_pre(DECL_ARGS);
static int termp_bl_pre(DECL_ARGS);
static int termp_bold_pre(DECL_ARGS);
static int termp_bq_pre(DECL_ARGS);
@@ -236,7 +238,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ NULL, NULL }, /* Fc */
{ termp_op_pre, termp_op_post }, /* Oo */
{ NULL, NULL }, /* Oc */
- { NULL, NULL }, /* Bk */
+ { termp_bk_pre, termp_bk_post }, /* Bk */
{ NULL, NULL }, /* Ek */
{ termp_bt_pre, NULL }, /* Bt */
{ NULL, NULL }, /* Hf */
@@ -2104,6 +2106,24 @@ termp_lk_pre(DECL_ARGS)
/* ARGSUSED */
static int
+termp_bk_pre(DECL_ARGS)
+{
+
+ p->flags |= TERMP_PREKEEP;
+ return(1);
+}
+
+
+/* ARGSUSED */
+static void
+termp_bk_post(DECL_ARGS)
+{
+
+ p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
+}
+
+/* ARGSUSED */
+static int
termp_under_pre(DECL_ARGS)
{
diff --git a/term.c b/term.c
index fef878d7..1d51ed4b 100644
--- a/term.c
+++ b/term.c
@@ -480,9 +480,14 @@ term_word(struct termp *p, const char *word)
}
if ( ! (TERMP_NOSPACE & p->flags)) {
- bufferc(p, ' ');
- if (TERMP_SENTENCE & p->flags)
+ if ( ! (TERMP_KEEP & p->flags)) {
+ if (TERMP_PREKEEP & p->flags)
+ p->flags |= TERMP_KEEP;
bufferc(p, ' ');
+ if (TERMP_SENTENCE & p->flags)
+ bufferc(p, ' ');
+ } else
+ bufferc(p, ASCII_NBRSP);
}
if ( ! (p->flags & TERMP_NONOSPACE))
diff --git a/term.h b/term.h
index 41acd5df..28efc9e7 100644
--- a/term.h
+++ b/term.h
@@ -78,6 +78,8 @@ struct termp {
#define TERMP_NOSPLIT (1 << 11) /* See termp_an_pre/post(). */
#define TERMP_SPLIT (1 << 12) /* See termp_an_pre/post(). */
#define TERMP_ANPREC (1 << 13) /* See termp_an_pre(). */
+#define TERMP_KEEP (1 << 14) /* Keep words together. */
+#define TERMP_PREKEEP (1 << 15) /* ...starting with the next one. */
char *buf; /* Output buffer. */
enum termenc enc; /* Type of encoding. */
void *symtab; /* Encoded-symbol table. */