summaryrefslogtreecommitdiffstatshomepage
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
commitadf4f1cf3dd98e5676c333b40212a2f4b0d1347d (patch)
tree7e2ab3273e586a7c28665998fe016c9063953d43
parent397916af9099ebb9b23d491efef58d48d4e88133 (diff)
downloadmandoc-adf4f1cf3dd98e5676c333b40212a2f4b0d1347d.tar.gz
mandoc-adf4f1cf3dd98e5676c333b40212a2f4b0d1347d.tar.zst
mandoc-adf4f1cf3dd98e5676c333b40212a2f4b0d1347d.zip
Basic implementation of .Bk/.Ek; from OpenBSD.
OK and one stylistic tweak by kristaps@.
-rw-r--r--mdoc_term.c24
-rw-r--r--term.c11
-rw-r--r--term.h4
3 files changed, 33 insertions, 6 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index a3585e76..e4d50a70 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.158 2010/06/26 15:36:37 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.159 2010/06/27 01:26:20 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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 1585c1af..c41482ca 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.150 2010/06/26 15:36:37 kristaps Exp $ */
+/* $Id: term.c,v 1.151 2010/06/27 01:26:20 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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 a9493a1b..4293e9d6 100644
--- a/term.h
+++ b/term.h
@@ -1,4 +1,4 @@
-/* $Id: term.h,v 1.65 2010/06/25 18:53:14 kristaps Exp $ */
+/* $Id: term.h,v 1.66 2010/06/27 01:26:20 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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. */