aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--man.715
-rw-r--r--man.c22
-rw-r--r--mdoc.722
-rw-r--r--mdoc.c22
4 files changed, 51 insertions, 30 deletions
diff --git a/man.7 b/man.7
index 76c63a38..b03a0f8b 100644
--- a/man.7
+++ b/man.7
@@ -1,4 +1,4 @@
-.\" $Id: man.7,v 1.63 2010/05/07 15:49:36 kristaps Exp $
+.\" $Id: man.7,v 1.64 2010/05/08 08:36:44 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -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: May 7 2010 $
+.Dd $Mdocdate: May 8 2010 $
.Dt MAN 7
.Os
.Sh NAME
@@ -126,10 +126,13 @@ and
.Sq \ef
attributes are forgotten when entering or exiting a macro block.
.Ss Whitespace
-Unless specifically escaped, consecutive blocks of whitespace are pruned
-from input. These are later re-added, if applicable, by a front-end
-utility such as
-.Xr mandoc 1 .
+In free-form lines, whitespace is preserved within a line; un-escaped
+trailing spaces are stripped from input (unless in a literal context).
+Blank free-form lines, which may include spaces, are permitted and
+rendered as an empty line.
+.Pp
+In macro lines, whitespace delimits arguments and is discarded. If
+arguments are quoted, whitespace within the quotes is retained.
.Ss Dates
The
.Sx \&TH
diff --git a/man.c b/man.c
index a92fac8d..385ccaf5 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.62 2010/05/08 07:30:19 kristaps Exp $ */
+/* $Id: man.c,v 1.63 2010/05/08 08:36:44 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -395,16 +395,30 @@ man_ptext(struct man *m, int line, char *buf)
goto descope;
}
- /* Warn if the last un-escaped character is whitespace. */
+ /*
+ * Warn if the last un-escaped character is whitespace. Then
+ * strip away the remaining spaces (tabs stay!).
+ */
i = (int)strlen(buf);
assert(i);
- if (' ' == buf[i - 1] || '\t' == buf[i - 1])
- if (1 == i || ('\\' != buf[i - 2]))
+ if (' ' == buf[i - 1] || '\t' == buf[i - 1]) {
+ assert(i > 1);
+ if ('\\' != buf[i - 2])
if ( ! man_pwarn(m, line, i - 1, WTSPACE))
return(0);
+ for (--i; i && ' ' == buf[i]; i--)
+ /* Spin back to non-space. */ ;
+
+ /* Jump ahead of escaped whitespace. */
+ assert(i);
+ i += '\\' == buf[i] ? 2 : 1;
+
+ buf[i] = '\0';
+ }
+
if ( ! man_word_alloc(m, line, 0, buf))
return(0);
diff --git a/mdoc.7 b/mdoc.7
index e2eaa5e2..dc60ad83 100644
--- a/mdoc.7
+++ b/mdoc.7
@@ -1,4 +1,4 @@
-.\" $Id: mdoc.7,v 1.95 2010/05/07 15:49:36 kristaps Exp $
+.\" $Id: mdoc.7,v 1.96 2010/05/08 08:36:44 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -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: May 7 2010 $
+.Dd $Mdocdate: May 8 2010 $
.Dt MDOC 7
.Os
.Sh NAME
@@ -181,23 +181,13 @@ and
.Sq \e*(Ba
.Pq vertical bar .
.Ss Whitespace
-In non-literal free-form lines, consecutive blocks of whitespace are
-pruned from input and added later in the output filter, if applicable:
-.Bd -literal -offset indent
-These spaces are pruned from input.
-\&.Bd \-literal
-These are not.
-\&.Ed
-.Ed
+In free-form lines, whitespace is preserved within a line; un-escaped
+trailing spaces are stripped from input (unless in a literal context).
+Blank free-form lines, which may include spaces, are only permitted
+within literal contexts.
.Pp
In macro lines, whitespace delimits arguments and is discarded. If
arguments are quoted, whitespace within the quotes is retained.
-.Pp
-Blank lines are only permitted within literal contexts, as are lines
-containing only whitespace. Tab characters are only acceptable when
-delimiting
-.Sq \&Bl \-column
-or when in a literal context.
.Ss Quotation
Macro arguments may be quoted with a double-quote to group
space-delimited terms or to retain blocks of whitespace. A quoted
diff --git a/mdoc.c b/mdoc.c
index 5974c19b..f2636ef5 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.125 2010/05/08 07:30:19 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.126 2010/05/08 08:36:44 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -665,16 +665,30 @@ mdoc_ptext(struct mdoc *m, int line, char *buf)
return(1);
}
- /* Warn if the last un-escaped character is whitespace. */
+ /*
+ * Warn if the last un-escaped character is whitespace. Then
+ * strip away the remaining spaces (tabs stay!).
+ */
i = (int)strlen(buf);
assert(i);
- if (' ' == buf[i - 1] || '\t' == buf[i - 1])
- if (1 == i || ('\\' != buf[i - 2]))
+ if (' ' == buf[i - 1] || '\t' == buf[i - 1]) {
+ assert(i > 1);
+ if ('\\' != buf[i - 2])
if ( ! mdoc_pwarn(m, line, i - 1, ETAILWS))
return(0);
+ for (--i; i && ' ' == buf[i]; i--)
+ /* Spin back to non-space. */ ;
+
+ /* Jump ahead of escaped whitespace. */
+ assert(i);
+ i += '\\' == buf[i] ? 2 : 1;
+
+ buf[i] = '\0';
+ }
+
/* Allocate the whole word. */
return(mdoc_word_alloc(m, line, 0, buf));