Mercurial > gnulib
comparison build-aux/texinfo.tex @ 18260:18755f45b6ca
update from texinfo
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Sun, 06 Mar 2016 09:24:46 -0800 |
parents | 21a53f24c390 |
children | 6ecf8487ba63 |
comparison
equal
deleted
inserted
replaced
18259:04cddb00b2c9 | 18260:18755f45b6ca |
---|---|
1 % texinfo.tex -- TeX macros to handle Texinfo files. | 1 % texinfo.tex -- TeX macros to handle Texinfo files. |
2 % | 2 % |
3 % Load plain if necessary, i.e., if running under initex. | 3 % Load plain if necessary, i.e., if running under initex. |
4 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi | 4 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi |
5 % | 5 % |
6 \def\texinfoversion{2016-02-22.15} | 6 \def\texinfoversion{2016-03-05.11} |
7 % | 7 % |
8 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, | 8 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, |
9 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, | 9 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, |
10 % 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 | 10 % 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 |
11 % Free Software Foundation, Inc. | 11 % Free Software Foundation, Inc. |
7797 | 7797 |
7798 % Used at the time of macro expansion. | 7798 % Used at the time of macro expansion. |
7799 % Argument is macro body with arguments substituted | 7799 % Argument is macro body with arguments substituted |
7800 \def\scanmacro#1{% | 7800 \def\scanmacro#1{% |
7801 \newlinechar`\^^M | 7801 \newlinechar`\^^M |
7802 \def\xprocessmacroarg{\eatspaces}% | 7802 \def\xeatspaces{\eatspaces}% |
7803 % | 7803 % |
7804 % Process the macro body under the current catcode regime. | 7804 % Process the macro body under the current catcode regime. |
7805 \scantokens{#1\texinfoc}\aftermacro% | 7805 \scantokens{#1\texinfoc}\aftermacro% |
7806 % | 7806 % |
7807 % The \c is to remove the \newlinechar added by \scantokens, and | 7807 % The \c is to remove the \newlinechar added by \scantokens, and |
8027 % | 8027 % |
8028 \def\parsemargdef#1;{% | 8028 \def\parsemargdef#1;{% |
8029 \paramno=0\def\paramlist{}% | 8029 \paramno=0\def\paramlist{}% |
8030 \let\hash\relax | 8030 \let\hash\relax |
8031 % \hash is redefined to `#' later to get it into definitions | 8031 % \hash is redefined to `#' later to get it into definitions |
8032 \let\processmacroarg\relax | 8032 \let\xeatspaces\relax |
8033 \parsemargdefxxx#1,;,% | 8033 \parsemargdefxxx#1,;,% |
8034 \ifnum\paramno<10\relax\else | 8034 \ifnum\paramno<10\relax\else |
8035 \paramno0\relax | 8035 \paramno0\relax |
8036 \parsemmanyargdef@@#1,;,% 10 or more arguments | 8036 \parsemmanyargdef@@#1,;,% 10 or more arguments |
8037 \fi | 8037 \fi |
8039 \def\parsemargdefxxx#1,{% | 8039 \def\parsemargdefxxx#1,{% |
8040 \if#1;\let\next=\relax | 8040 \if#1;\let\next=\relax |
8041 \else \let\next=\parsemargdefxxx | 8041 \else \let\next=\parsemargdefxxx |
8042 \advance\paramno by 1 | 8042 \advance\paramno by 1 |
8043 \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname | 8043 \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname |
8044 {\processmacroarg{\hash\the\paramno}}% | 8044 {\xeatspaces{\hash\the\paramno}}% |
8045 \edef\paramlist{\paramlist\hash\the\paramno,}% | 8045 \edef\paramlist{\paramlist\hash\the\paramno,}% |
8046 \fi\next} | 8046 \fi\next} |
8047 | 8047 |
8048 % \parsemacbody, \parsermacbody | 8048 % \parsemacbody, \parsermacbody |
8049 % | 8049 % |
8265 | 8265 |
8266 | 8266 |
8267 %%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%% | 8267 %%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%% |
8268 | 8268 |
8269 | 8269 |
8270 | |
8271 % Remove following spaces at the expansion stage. | |
8272 % This works because spaces are discarded before each argument when TeX is | |
8273 % getting the arguments for a macro. | |
8274 % This must not be immediately followed by a }. | |
8275 \long\def\gobblespaces#1{#1} | |
8276 | |
8277 % This defines a Texinfo @macro or @rmacro, called by \parsemacbody. | 8270 % This defines a Texinfo @macro or @rmacro, called by \parsemacbody. |
8278 % \macrobody has the body of the macro in it, with placeholders for | 8271 % \macrobody has the body of the macro in it, with placeholders for |
8279 % its parameters, looking like "\processmacroarg{\hash 1}". | 8272 % its parameters, looking like "\xeatspaces{\hash 1}". |
8280 % \paramno is the number of parameters | 8273 % \paramno is the number of parameters |
8281 % \paramlist is a TeX parameter text, e.g. "#1,#2,#3," | 8274 % \paramlist is a TeX parameter text, e.g. "#1,#2,#3," |
8282 % There are eight cases: recursive and nonrecursive macros of zero, one, | 8275 % There are eight cases: recursive and nonrecursive macros of zero, one, |
8283 % up to nine, and many arguments. | 8276 % up to nine, and many arguments. |
8284 % \xdef is used so that macro definitions will survive the file | 8277 % \xdef is used so that macro definitions will survive the file |
8285 % they're defined in: @include reads the file inside a group. | 8278 % they're defined in: @include reads the file inside a group. |
8286 % | 8279 % |
8287 \def\defmacro{% | 8280 \def\defmacro{% |
8288 \let\hash=##% convert placeholders to macro parameter chars | 8281 \let\hash=##% convert placeholders to macro parameter chars |
8289 \ifnum\paramno=1 | 8282 \ifnum\paramno=1 |
8290 \def\processmacroarg{\gobblespaces}% | 8283 \def\xeatspaces##1{##1}% |
8291 % This removes the pair of braces around the argument. We don't | 8284 % This removes the pair of braces around the argument. We don't |
8292 % use \eatspaces, because this can cause ends of lines to be lost | 8285 % use \eatspaces, because this can cause ends of lines to be lost |
8293 % when the argument to \eatspaces is read, leading to line-based | 8286 % when the argument to \eatspaces is read, leading to line-based |
8294 % commands like "@itemize" not being read correctly. | 8287 % commands like "@itemize" not being read correctly. |
8295 \else | 8288 \else |
8296 \def\processmacroarg{\xprocessmacroarg}% | 8289 \let\xeatspaces\relax % suppress expansion |
8297 \let\xprocessmacroarg\relax | |
8298 \fi | 8290 \fi |
8299 \ifrecursive %%%%%%%%%%%%%% Recursive %%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 8291 \ifrecursive %%%%%%%%%%%%%% Recursive %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
8300 \ifcase\paramno | 8292 \ifcase\paramno |
8301 % 0 | 8293 % 0 |
8302 \expandafter\xdef\csname\the\macname\endcsname{% | 8294 \expandafter\xdef\csname\the\macname\endcsname{% |
8305 \expandafter\xdef\csname\the\macname\endcsname{% | 8297 \expandafter\xdef\csname\the\macname\endcsname{% |
8306 \bgroup | 8298 \bgroup |
8307 \noexpand\braceorline | 8299 \noexpand\braceorline |
8308 \expandafter\noexpand\csname\the\macname @@@\endcsname}% | 8300 \expandafter\noexpand\csname\the\macname @@@\endcsname}% |
8309 \expandafter\xdef\csname\the\macname @@@\endcsname##1{% | 8301 \expandafter\xdef\csname\the\macname @@@\endcsname##1{% |
8310 \expandafter\noexpand\csname\the\macname @@@@\endcsname{% | 8302 \egroup |
8311 \noexpand\gobblespaces##1\empty}% | 8303 \noexpand\scanmacro{\macrobody}% |
8312 % The \empty is for \gobblespaces in case #1 is empty | 8304 }% |
8313 }% | |
8314 \expandafter\xdef\csname\the\macname @@@@\endcsname##1{% | |
8315 \egroup\noexpand\scanmacro{\macrobody}}% | |
8316 \else | 8305 \else |
8317 \ifnum\paramno<10\relax % at most 9 | 8306 \ifnum\paramno<10\relax % at most 9 |
8318 % See non-recursive section below for comments | 8307 % See non-recursive section below for comments |
8319 \expandafter\xdef\csname\the\macname\endcsname{% | 8308 \expandafter\xdef\csname\the\macname\endcsname{% |
8320 \bgroup | 8309 \bgroup |
8349 \expandafter\xdef\csname\the\macname\endcsname{% | 8338 \expandafter\xdef\csname\the\macname\endcsname{% |
8350 \bgroup | 8339 \bgroup |
8351 \noexpand\braceorline | 8340 \noexpand\braceorline |
8352 \expandafter\noexpand\csname\the\macname @@@\endcsname}% | 8341 \expandafter\noexpand\csname\the\macname @@@\endcsname}% |
8353 \expandafter\xdef\csname\the\macname @@@\endcsname##1{% | 8342 \expandafter\xdef\csname\the\macname @@@\endcsname##1{% |
8354 \expandafter\noexpand\csname\the\macname @@@@\endcsname{% | |
8355 \noexpand\gobblespaces##1\empty}% | |
8356 % The \empty is for \gobblespaces in case #1 is empty | |
8357 }% | |
8358 \expandafter\xdef\csname\the\macname @@@@\endcsname##1{% | |
8359 \egroup | 8343 \egroup |
8360 \noexpand\scanmacro{\macrobody}% | 8344 \noexpand\scanmacro{\macrobody}% |
8361 }% | 8345 }% |
8362 \else % at most 9 | 8346 \else % at most 9 |
8363 \ifnum\paramno<10\relax | 8347 \ifnum\paramno<10\relax |