summaryrefslogtreecommitdiffstats
path: root/term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-01-22 20:58:39 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-01-22 20:58:39 +0000
commit654e28baaa103a868af40d8ce155ddd09fe76f98 (patch)
tree061e60883aded25bdcf06071df7bf3b4e00c8548 /term.c
parent3d40007c4e92346d3e69337fa770e26de69c6ffe (diff)
downloadmandoc-654e28baaa103a868af40d8ce155ddd09fe76f98.tar.gz
Implement the \: (optional line break) escape sequence,
documented in the Ossanna-Kernighan-Ritter troff manual and also supported by groff. Missing feature reported by Steffen Nurpmeso <sdaoden at gmail dot com>.
Diffstat (limited to 'term.c')
-rw-r--r--term.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/term.c b/term.c
index 9f59d113..01d6ed60 100644
--- a/term.c
+++ b/term.c
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010, 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -179,7 +179,8 @@ term_flushln(struct termp *p)
/* Regular word. */
/* Break at the hyphen point if we overrun. */
if (vend > vis && vend < bp &&
- ASCII_HYPH == p->buf[j])
+ (ASCII_HYPH == p->buf[j] ||
+ ASCII_BREAK == p->buf[j]))
jhy = j;
vend += (*p->width)(p, p->buf[j]);
@@ -233,6 +234,8 @@ term_flushln(struct termp *p)
vbl += (*p->width)(p, ' ');
continue;
}
+ if (ASCII_BREAK == p->buf[i])
+ continue;
/*
* Now we definitely know there will be
@@ -644,7 +647,8 @@ term_strlen(const struct termp *p, const char *cp)
int ssz, skip, c;
const char *seq, *rhs;
enum mandoc_esc esc;
- static const char rej[] = { '\\', ASCII_HYPH, ASCII_NBRSP, '\0' };
+ static const char rej[] = { '\\', ASCII_NBRSP, ASCII_HYPH,
+ ASCII_BREAK, '\0' };
/*
* Account for escaped sequences within string length
@@ -732,6 +736,8 @@ term_strlen(const struct termp *p, const char *cp)
case (ASCII_HYPH):
sz += cond_width(p, '-', &skip);
cp++;
+ /* FALLTHROUGH */
+ case (ASCII_BREAK):
break;
default:
break;