summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwlemb <wlemb>2002-06-23 08:26:23 +0000
committerwlemb <wlemb>2002-06-23 08:26:23 +0000
commit1132b5340421bdafcf9068eef5bfd72c613c7a11 (patch)
treed7aefba512699416e669f09bf2409ba241d826b6
parente7b5a67c456d819aafaf5cdc2a5beee2df03027b (diff)
downloadgroff-1132b5340421bdafcf9068eef5bfd72c613c7a11.tar.gz
Make \X accept both `\ ' and `\~', converting them to single space
characters. * src/roff/troff/token.h (token): Add TOKEN_UNSTRETCHABLE_SPACE. (token::unstretchable_space): New inline function. * src/roff/troff/input.cc (token::next, token::delimiter, token::description, token::add_to_node_list, token::process): Handle TOKEN_UNSTRETCHABLE_NODE. (encode_char): Handle tok.stretchable_space and tok.unstretchable_space. * NEWS, doc/groff.texinfo: Document it..
-rw-r--r--ChangeLog15
-rw-r--r--NEWS3
-rw-r--r--doc/groff.texinfo5
-rw-r--r--src/roff/troff/input.cc15
-rw-r--r--src/roff/troff/token.h9
5 files changed, 41 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index ad09ae9c..331c9606 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2002-06-20 Werner LEMBERG <wl@gnu.org>
+
+ Make \X accept both `\ ' and `\~', converting them to single space
+ characters.
+
+ * src/roff/troff/token.h (token): Add TOKEN_UNSTRETCHABLE_SPACE.
+ (token::unstretchable_space): New inline function.
+ * src/roff/troff/input.cc (token::next, token::delimiter,
+ token::description, token::add_to_node_list, token::process): Handle
+ TOKEN_UNSTRETCHABLE_NODE.
+ (encode_char): Handle tok.stretchable_space and
+ tok.unstretchable_space.
+
+ * NEWS, doc/groff.texinfo: Document it..
+
2002-06-19 Werner LEMBERG <wl@gnu.org>
* src/devices/grops/ps.cc (ps_printer::special): Fix error message.
diff --git a/NEWS b/NEWS
index cc1bac1c..0b09a895 100644
--- a/NEWS
+++ b/NEWS
@@ -150,7 +150,8 @@ o A new escape sequence `\O' is available to disable and enable glyph
output. Please see groff_diff.7 and groff.texinfo for more details.
o The escapes `\%', `\&', `\)', and `\:' no longer cause an error in \X;
- they are ignored now.
+ they are ignored now. Additionally `\ ' and `\~' are converted to
+ single space characters.
o The default tab distance in nroff mode is now 0.8i to be compatible
with UNIX troff.
diff --git a/doc/groff.texinfo b/doc/groff.texinfo
index 05a44874..392fc4d4 100644
--- a/doc/groff.texinfo
+++ b/doc/groff.texinfo
@@ -6752,7 +6752,7 @@ Internals}, for more on this process).
@DefreqListEnd {trin, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
Translate character @var{a} to glyph@w{ }@var{b}, character @var{c} to
glyph@w{ }@var{d}, etc. If there is an odd number of arguments, the
-last one is translated to an unstretchable space (@samp{\ }).
+last one is translated to an unstretchable space (@w{@samp{\ }}).
The @code{trin} request is identical to @code{tr},
but when you unformat a diversion with @code{asciify}
@@ -11611,7 +11611,8 @@ output preceded with @w{@samp{x X}}.
@cindex @code{\@r{<colon>}}, in @code{\X}
@end ifinfo
The escapes @code{\&}, @code{\)}, @code{\%}, and @code{\:} are ignored
-within @code{\X}; all other escapes (except @code{\\} which produces a
+within @code{\X}, @w{@samp{\ }} and @code{\~} are converted to single
+space characters. All other escapes (except @code{\\} which produces a
backslash) cause an error.
@kindex use_charnames_in_special
diff --git a/src/roff/troff/input.cc b/src/roff/troff/input.cc
index f1b96d71..4df1fc55 100644
--- a/src/roff/troff/input.cc
+++ b/src/roff/troff/input.cc
@@ -1569,8 +1569,7 @@ void token::next()
return;
case ESCAPE_SPACE:
ESCAPE_SPACE:
- type = TOKEN_NODE;
- nd = new space_char_hmotion_node(curenv->get_space_width());
+ type = TOKEN_UNSTRETCHABLE_SPACE;
return;
case ESCAPE_TILDE:
ESCAPE_TILDE:
@@ -2097,6 +2096,7 @@ int token::delimiter(int err)
case TOKEN_NODE:
case TOKEN_SPACE:
case TOKEN_STRETCHABLE_SPACE:
+ case TOKEN_UNSTRETCHABLE_SPACE:
case TOKEN_TAB:
case TOKEN_NEWLINE:
if (err)
@@ -2151,6 +2151,8 @@ const char *token::description()
return "`\\p'";
case TOKEN_STRETCHABLE_SPACE:
return "`\\~'";
+ case TOKEN_UNSTRETCHABLE_SPACE:
+ return "`\\ '";
case TOKEN_TAB:
return "a tab character";
case TOKEN_TRANSPARENT:
@@ -4610,6 +4612,9 @@ static void encode_char(macro *mac, char c)
mac->append(')');
}
}
+ else if (tok.stretchable_space()
+ || tok.unstretchable_space())
+ mac->append(' ');
else if (!(tok.hyphen_indicator()
|| tok.dummy()
|| tok.transparent_dummy()
@@ -5949,6 +5954,9 @@ int token::add_to_node_list(node **pp)
case TOKEN_STRETCHABLE_SPACE:
n = new unbreakable_space_node(curenv->get_space_width());
break;
+ case TOKEN_UNSTRETCHABLE_SPACE:
+ n = new space_char_hmotion_node(curenv->get_space_width());
+ break;
case TOKEN_TRANSPARENT_DUMMY:
n = new transparent_dummy_node;
break;
@@ -6040,6 +6048,9 @@ void token::process()
case TOKEN_STRETCHABLE_SPACE:
curenv->add_node(new unbreakable_space_node(curenv->get_space_width()));
break;
+ case TOKEN_UNSTRETCHABLE_SPACE:
+ curenv->add_node(new space_char_hmotion_node(curenv->get_space_width()));
+ break;
case TOKEN_TAB:
curenv->handle_tab(0);
break;
diff --git a/src/roff/troff/token.h b/src/roff/troff/token.h
index 2f0c3ccc..59f2aa2d 100644
--- a/src/roff/troff/token.h
+++ b/src/roff/troff/token.h
@@ -51,9 +51,10 @@ class token {
TOKEN_REQUEST,
TOKEN_RIGHT_BRACE,
TOKEN_SPACE, // ` ' -- ordinary space
- TOKEN_SPECIAL, // a special character -- \' \` \- \(xx
+ TOKEN_SPECIAL, // a special character -- \' \` \- \(xx \[xxx]
TOKEN_SPREAD, // \p -- break and spread output line
TOKEN_STRETCHABLE_SPACE, // \~
+ TOKEN_UNSTRETCHABLE_SPACE, // `\ '
TOKEN_TAB, // tab
TOKEN_TRANSPARENT, // \!
TOKEN_TRANSPARENT_DUMMY, // \)
@@ -72,6 +73,7 @@ public:
int nspaces(); // 1 if space, 2 if double space, 0 otherwise
int space(); // is the current token a space?
int stretchable_space(); // is the current token a stretchable space?
+ int unstretchable_space(); // is the current token an unstretchable space?
int white_space(); // is the current token space or tab?
int special(); // is the current token a special character?
int newline(); // is the current token a newline?
@@ -140,6 +142,11 @@ inline int token::stretchable_space()
return type == TOKEN_STRETCHABLE_SPACE;
}
+inline int token::unstretchable_space()
+{
+ return type == TOKEN_UNSTRETCHABLE_SPACE;
+}
+
inline int token::special()
{
return type == TOKEN_SPECIAL;