[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6541] strip final active newline from macro body
From: |
Gavin D. Smith |
Subject: |
[6541] strip final active newline from macro body |
Date: |
Mon, 17 Aug 2015 13:22:57 +0000 |
Revision: 6541
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6541
Author: gavin
Date: 2015-08-17 13:22:56 +0000 (Mon, 17 Aug 2015)
Log Message:
-----------
strip final active newline from macro body
Modified Paths:
--------------
trunk/ChangeLog
trunk/doc/texinfo-tex-test.texi
trunk/doc/texinfo.tex
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2015-08-17 13:01:26 UTC (rev 6540)
+++ trunk/ChangeLog 2015-08-17 13:22:56 UTC (rev 6541)
@@ -1,5 +1,11 @@
2015-08-17 Gavin Smith <address@hidden>
+ * doc/texinfo.tex (\scanmacro): Strip a trailing active newline
+ from the macro body if newlines are active.
+ * doc/texinfo-tex-test.texi: Add example.
+
+2015-08-17 Gavin Smith <address@hidden>
+
* doc/texinfo.tex (\macrobodyctxt): Make catcode of space
\other, so they are preserved when expanded in a context like
@example.
Modified: trunk/doc/texinfo-tex-test.texi
===================================================================
--- trunk/doc/texinfo-tex-test.texi 2015-08-17 13:01:26 UTC (rev 6540)
+++ trunk/doc/texinfo-tex-test.texi 2015-08-17 13:22:56 UTC (rev 6541)
@@ -110,5 +110,38 @@
@end example
@Mac
address@hidden Trailing newlines in macro bodies
+Output should be doubled:
+
+1y
+
+z
+x2
+
address@hidden nbsp
+y
+
+z
+x
address@hidden macro
+
address@hidden
+
+Output should be doubled:
+
+
address@hidden
+1y
+
+z
+x2
address@hidden example
+
address@hidden
address@hidden
address@hidden example
+
+
+
@bye
Modified: trunk/doc/texinfo.tex
===================================================================
--- trunk/doc/texinfo.tex 2015-08-17 13:01:26 UTC (rev 6540)
+++ trunk/doc/texinfo.tex 2015-08-17 13:22:56 UTC (rev 6541)
@@ -3,7 +3,7 @@
% Load plain if necessary, i.e., if running under initex.
\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
%
-\def\texinfoversion{2015-08-17.15}
+\def\texinfoversion{2015-08-17.16}
%
% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
@@ -7343,6 +7343,11 @@
}
\fi
+% Used to remove a category 13 newline, added to the end of the last
+% line read in by \scantokens.
+{\catcode`\^^M=13 \gdef\gobblecr^^M{}}
+
+% Argument is macro body with arguments substituted
\def\scanmacro#1{\begingroup
\newlinechar`\^^M
\let\xeatspaces\eatspaces
@@ -7357,15 +7362,14 @@
% ... and for \example:
\spaceisspace
%
- % The \empty here causes a following catcode 5 newline to be eaten as
- % part of reading whitespace after a control sequence. It does not
- % eat a catcode 13 newline. There's no good way to handle the two
- % cases (untried: maybe e-TeX's \everyeof could help, though plain TeX
- % would then have different behavior). See the Macro Details node in
- % the manual for the workaround we recommend for macros and
- % line-oriented commands.
- %
- \scantokens{#1\empty}%
+ \ifnum\catcode`\^^M=5
+ % The \empty here causes a following catcode 5 newline to be eaten as
+ % part of reading whitespace after a control sequence.
+ \scantokens{#1\empty}%
+ \else
+ \catcode`\^^M=13
+ \scantokens{#1\gobblecr}%
+ \fi
\endgroup}
\def\scanexp#1{%
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6541] strip final active newline from macro body,
Gavin D. Smith <=