* mdocml: Basic implementation of .Bk/.Ek; from OpenBSD.
@ 2010-06-27 1:26 schwarze
2010-06-27 9:25 ` Kristaps Dzonsons
0 siblings, 1 reply; 2+ messages in thread
From: schwarze @ 2010-06-27 1:26 UTC (permalink / raw)
To: source
Log Message:
-----------
Basic implementation of .Bk/.Ek; from OpenBSD.
OK and one stylistic tweak by kristaps@.
Modified Files:
--------------
mdocml:
mdoc_term.c
term.c
term.h
Revision Data
-------------
Index: term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.c,v
retrieving revision 1.150
retrieving revision 1.151
diff -Lterm.c -Lterm.c -u -p -r1.150 -r1.151
--- term.c
+++ term.c
@@ -480,9 +480,14 @@ term_word(struct termp *p, const char *w
}
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))
Index: term.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.h,v
retrieving revision 1.65
retrieving revision 1.66
diff -Lterm.h -Lterm.h -u -p -r1.65 -r1.66
--- term.h
+++ 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. */
Index: mdoc_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v
retrieving revision 1.158
retrieving revision 1.159
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.158 -r1.159
--- mdoc_term.c
+++ 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[MDO
{ 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 */
@@ -2101,6 +2103,24 @@ termp_lk_pre(DECL_ARGS)
return(0);
}
+
+/* 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
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-06-27 9:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-27 1:26 mdocml: Basic implementation of .Bk/.Ek; from OpenBSD schwarze
2010-06-27 9:25 ` Kristaps Dzonsons
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).