[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6537] convert \\ to \ in macro args
From: |
Gavin D. Smith |
Subject: |
[6537] convert \\ to \ in macro args |
Date: |
Mon, 17 Aug 2015 08:58:02 +0000 |
Revision: 6537
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6537
Author: gavin
Date: 2015-08-17 08:58:01 +0000 (Mon, 17 Aug 2015)
Log Message:
-----------
convert \\ to \ in macro args
Modified Paths:
--------------
trunk/ChangeLog
trunk/doc/texinfo.tex
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2015-08-17 08:18:36 UTC (rev 6536)
+++ trunk/ChangeLog 2015-08-17 08:58:01 UTC (rev 6537)
@@ -1,3 +1,10 @@
+2015-08-17 Gavin Smith <address@hidden>
+
+ * doc/texinfo.tex (\passargtomacro): New macro, to convert
+ doubled backslashes into single backslashes in macro argument.
+ (\braceorline) <braced argument>: Call \passargtomacro.
+ (\macroargctxt): Make catcode of \ active (13) instead of escape (0).
+
2015-08-16 Gavin Smith <address@hidden>
* tp/t/60macro.t: New test 'macro_expands_to_empty'.
Modified: trunk/doc/texinfo.tex
===================================================================
--- trunk/doc/texinfo.tex 2015-08-17 08:18:36 UTC (rev 6536)
+++ trunk/doc/texinfo.tex 2015-08-17 08:58:01 UTC (rev 6537)
@@ -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-03.11}
+\def\texinfoversion{2015-08-17.10}
%
% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
@@ -7458,25 +7458,12 @@
\usembodybackslash
}
-\def\macroargctxt{% used when scanning invocations
+\def\macroargctxt{% used when scanning braced macro arguments
\scanctxt
- \catcode`\\=0
+ \catcode`\\=\active
}
-% why catcode 0 for \ in the above? To recognize \\ \{ \} as "escapes"
-% for the single characters \ { }. Thus, we end up with the "commands"
-% that would be written @\ @{ @} in a Texinfo document.
-%
-% We already have @{ and @}. For @\, we define it here, and only for
-% this purpose, to produce a typewriter backslash (so, the @\ that we
-% define for @math can't be used with @macro calls):
-%
+
\def\\{\normalbackslash}%
-%
-% We would like to do this for \, too, since that is what makeinfo does.
-% But it is not possible, because Texinfo already has a command @, for a
-% cedilla accent. Documents must use @comma{} instead.
-%
-% \anythingelse will almost certainly be an error of some kind.
\def\macrolineargctxt{% used for whole-line arguments without braces
\scanctxt
@@ -7907,16 +7894,86 @@
\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
+
address@hidden \catcode`\\=13
address@hidden@_=11
+
+% Call #1 with a list of tokens #2, with any doubled backslashes in #2
+% compressed to one.
address@hidden@passargtomacro#1#2{%
+ @address@hidden
+ @address@hidden
+ @address@hidden@finish}%
+ @address@hidden
+ @address@hidden@relax
+ @address@hidden
+}
+
+% Input stream is just after a backslash. If the next token is not a
+% backslash, process the rest of the argument; otherwise, remove the next
+% token.
address@hidden@look_ahead{%
+ @address@hidden@look_aheadzzz}
address@hidden@look_aheadzzz{%
+ @address@hidden
+ @address@hidden@gobble_and_check_finish
+ @else
+ @address@hidden@add_segment
+ @address@hidden
+}
+
+% Double backslash found. Add a single backslash here.
address@hidden@gobble_and_check_finish#1{%
+ @add_the_backslash
+ @address@hidden
+ @address@hidden@add_segment
+}
+
+% append a backslash to \arg_result
address@hidden@add_the_backslash{%
+ @address@hidden@address@hidden@address@hidden
+}
+
+% Input stream is either at the start of the argument, or just after a
+% backslash sequence, either a lone backslash, or a doubled backslash.
+% \next_token contains the first token in the input stream: if it is \finish,
+% finish; otherwise, append to \arg_result the segment of the argument up until
+% the next backslash. \pending_backslash contains a backslash to represent
+% a backslash just before the start of the input stream that has not been
+% added to \arg_result.
address@hidden@add_segment#1\{%
address@hidden@address@hidden
+ @address@hidden@call_the_macro%
address@hidden
+ @address@hidden@look_ahead
+ %
+ % append to @arg_result
+ % token list registers might be better
+ @address@hidden@address@hidden
+ @address@hidden@address@hidden
+ @address@hidden@expandafter{%
+ @address@hidden
+ @pending_backslash#1}%
+ @address@hidden
address@hidden@next}
+
address@hidden@address@hidden@address@hidden@arg_result}}
+
+}
+
% \braceorline MAC is used for a one-argument macro MAC. It checks
% whether the next non-whitespace character is a {. It sets the context
% for reading the argument (slightly different in the two cases). Then,
-% to read the argument, in the whole-line case, it then calls the
-% regular \parsearg MAC; in the lbrace case, it just calls MAC itself.
+% to read the argument, in the whole-line case, it then calls the regular
+% \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
%
\def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
\def\braceorlinexxx{%
- \ifx\nchar\bgroup\macroargctxt
- \else\macrolineargctxt\expandafter\parsearg
+ \ifx\nchar\bgroup
+ \macroargctxt
+ \expandafter\passargtomacro
+ \else
+ \macrolineargctxt\expandafter\parsearg
\fi \macnamexxx}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6537] convert \\ to \ in macro args,
Gavin D. Smith <=