From c55c7c742e50a932784d8cd8689f4ad216fcc91f Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Thu, 12 Nov 2009 08:21:05 +0000 Subject: Fixed \c support for all input and output modes (documented in mandoc_char.7). --- html.c | 5 ++++- man.7 | 10 +--------- man_term.c | 15 +++------------ mandoc_char.7 | 5 +++-- out.c | 7 ++++++- out.h | 3 ++- term.c | 5 ++++- 7 files changed, 23 insertions(+), 27 deletions(-) diff --git a/html.c b/html.c index 042f1641..f1a256f1 100644 --- a/html.c +++ b/html.c @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.83 2009/11/10 16:32:00 kristaps Exp $ */ +/* $Id: html.c,v 1.84 2009/11/12 08:21:05 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -262,6 +262,9 @@ print_encode(struct html *h, const char *p) } p += len - 1; + + if (DECO_NOSPACE == deco && '\0' == *(p + 1)) + h->flags |= HTML_NOSPACE; } } diff --git a/man.7 b/man.7 index 5a2bc440..92a1dc3b 100644 --- a/man.7 +++ b/man.7 @@ -1,4 +1,4 @@ -.\" $Id: man.7,v 1.51 2009/11/12 08:00:21 kristaps Exp $ +.\" $Id: man.7,v 1.52 2009/11/12 08:21:05 kristaps Exp $ .\" .\" Copyright (c) 2009 Kristaps Dzonsons .\" @@ -67,14 +67,6 @@ line termination. Blank lines are acceptable; where found, the output will assert a vertical space. . -.Pp -The -.Sq \ec -escape is common in historical -.Nm -documents; if encountered at the end of a word, it ensures that the -subsequent word isn't off-set by whitespace. -. . .Ss Comments Text following a diff --git a/man_term.c b/man_term.c index 704511b4..fefbc1cb 100644 --- a/man_term.c +++ b/man_term.c @@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.53 2009/11/12 08:00:21 kristaps Exp $ */ +/* $Id: man_term.c,v 1.54 2009/11/12 08:21:05 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -783,7 +783,7 @@ post_RS(DECL_ARGS) static void print_man_node(DECL_ARGS) { - int c, sz; + int c; c = 1; @@ -793,17 +793,8 @@ print_man_node(DECL_ARGS) term_vspace(p); break; } - /* - * Note! This is hacky. Here, we recognise the `\c' - * escape embedded in so many -man pages. It's supposed - * to remove the subsequent space, so we mark NOSPACE if - * it's encountered in the string. - */ - sz = (int)strlen(n->string); + term_word(p, n->string); - if (sz >= 2 && n->string[sz - 1] == 'c' && - n->string[sz - 2] == '\\') - p->flags |= TERMP_NOSPACE; /* FIXME: this means that macro lines are munged! */ diff --git a/mandoc_char.7 b/mandoc_char.7 index 3c9392df..631bba6c 100644 --- a/mandoc_char.7 +++ b/mandoc_char.7 @@ -1,4 +1,4 @@ -.\" $Id: mandoc_char.7,v 1.27 2009/10/17 04:37:52 kristaps Exp $ +.\" $Id: mandoc_char.7,v 1.28 2009/11/12 08:21:05 kristaps Exp $ .\" .\" Copyright (c) 2009 Kristaps Dzonsons .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: October 17 2009 $ +.Dd $Mdocdate: November 12 2009 $ .Dt MANDOC_CHAR 7 .Os . @@ -110,6 +110,7 @@ Spacing: .It \e& Ta zero-width space .It \e| Ta zero-width space .It \e0 Ta breaking, non-collapsing digit-width space +.It \ec Ta removes any trailing space (if applicable) .El . .Pp diff --git a/out.c b/out.c index 713e5fa2..67860d9b 100644 --- a/out.c +++ b/out.c @@ -1,4 +1,4 @@ -/* $Id: out.c,v 1.10 2009/11/08 09:23:35 kristaps Exp $ */ +/* $Id: out.c,v 1.11 2009/11/12 08:21:05 kristaps Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons * @@ -331,6 +331,11 @@ a2roffdeco(enum roffdeco *d, case ('['): break; + case ('c'): + *d = DECO_NOSPACE; + *sz = 1; + return(1); + default: *d = DECO_SPECIAL; *word = wp; diff --git a/out.h b/out.h index e94ed541..9ace7117 100644 --- a/out.h +++ b/out.h @@ -1,4 +1,4 @@ -/* $Id: out.h,v 1.8 2009/11/08 09:23:35 kristaps Exp $ */ +/* $Id: out.h,v 1.9 2009/11/12 08:21:05 kristaps Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons * @@ -44,6 +44,7 @@ enum roffdeco { DECO_ROMAN, DECO_PREVIOUS, DECO_SIZE, + DECO_NOSPACE, DECO_MAX }; diff --git a/term.c b/term.c index 4d44ad0f..0d2c1ef6 100644 --- a/term.c +++ b/term.c @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.126 2009/11/12 05:58:30 kristaps Exp $ */ +/* $Id: term.c,v 1.127 2009/11/12 08:21:06 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -487,7 +487,10 @@ term_word(struct termp *p, const char *word) default: break; } + word += sz; + if (DECO_NOSPACE == deco && '\0' == *word) + p->flags |= TERMP_NOSPACE; } if (sv[0] && 0 == sv[1]) -- cgit v1.2.3-56-ge451