[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6566] improve texindex backward compatibility with texinfo.tex
From: |
Gavin D. Smith |
Subject: |
[6566] improve texindex backward compatibility with texinfo.tex |
Date: |
Mon, 24 Aug 2015 15:10:34 +0000 |
Revision: 6566
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6566
Author: gavin
Date: 2015-08-24 15:10:34 +0000 (Mon, 24 Aug 2015)
Log Message:
-----------
improve texindex backward compatibility with texinfo.tex
Modified Paths:
--------------
trunk/ChangeLog
trunk/doc/texinfo.tex
trunk/texindex/texindex.awk
trunk/texindex/ti.twjr
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2015-08-24 11:58:56 UTC (rev 6565)
+++ trunk/ChangeLog 2015-08-24 15:10:34 UTC (rev 6566)
@@ -1,5 +1,20 @@
2015-08-24 Gavin Smith <address@hidden>
+ * ti/ti.twjr (extract_initial): Read initials delimited by
+ balanced curly braces, to be compatible with older versions
+ of texinfo.tex.
+ (Special_chars): Remove backslash.
+ (Problem reported by Norbert Preining, bug-texinfo, on 6 July.)
+
+ * doc/texinfo.tex (\dosubindwrite): Output \ as
+ {\indexbackslash}, not {\tt \indexbackslash}.
+ (\usemathbackslash): Removed.
+ (\indexnofonts): Likewise, output { and } as braced sequences,
+ to be recognized by older versions of texindex.
+ (\printindex): Give these braced sequences meaning.
+
+2015-08-24 Gavin Smith <address@hidden>
+
* doc/texinfo-tex-test.texi: Add more examples of short indices,
and show some index initial glyphs.
Modified: trunk/doc/texinfo.tex
===================================================================
--- trunk/doc/texinfo.tex 2015-08-24 11:58:56 UTC (rev 6565)
+++ trunk/doc/texinfo.tex 2015-08-24 15:10:34 UTC (rev 6566)
@@ -346,10 +346,10 @@
\normalturnoffactive % \ in index entries must not stay \, e.g., if
% the page break happens to be in the middle of an example.
% We don't want .vr (or whatever) entries like this:
- % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}}
+ % \entry{{\indexbackslash }acronym}{32}{\code {\acronym}}
% "\acronym" won't work when it's read back in;
% it needs to be
- % {\code {{\tt \backslashcurfont }acronym}
+ % {\code {{\backslashcurfont }acronym}
\shipout\vbox{%
% Do this early so pdf references go to the beginning of the page.
\ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
@@ -4450,7 +4450,8 @@
\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
-% Take care of Texinfo commands that can appear in an index entry.
+% Used when writing an index entry out to an index file, to prevent
+% expansion of Texinfo commands that can appear in an index entry.
% Since there are some commands we want to expand, and others we don't,
% we have to laboriously prevent expansion for those that we don't.
%
@@ -4679,6 +4680,9 @@
% For testing: output @{ and @} in index sort strings as \{ and \}.
\newif\ifusebracesinindexes
+\let\indexlbrace\relax
+\let\indexrbrace\relax
+
% \indexnofonts is used when outputting the strings to sort the index
% by, and when constructing control sequence names. It eliminates all
% control sequences and just writes whatever the best ASCII sort string
@@ -4704,16 +4708,10 @@
\def\_{\normalunderscore}%
\def\-{}% @- shouldn't affect sorting
%
- % Unfortunately, texindex is not prepared to handle braces in the
- % content at all. So for index sorting, we map @{ and @} to strings
- % starting with |, since that ASCII character is between ASCII { and }.
- \ifusebracesinindexes
- \def\lbracechar{\lbracecmd}%
- \def\rbracechar{\rbracecmd}%
- \else
- \def\lbracechar{|a}%
- \def\rbracechar{|b}%
- \fi
+ % Unfortunately, texindex < 6.0 is not prepared to handle braces in the
+ % content at all, so these won't be sorted in ASCII order.
+ \def\lbracechar{{\indexlbrace}}%
+ \def\rbracechar{{\indexrbrace}}%
\let\{=\lbracechar
\let\}=\rbracechar
%
@@ -4795,7 +4793,6 @@
{\catcode`\`=\active
\gdef\indexlquoteignore{\let`=\empty}}
-\let\indexbackslash=0 %overridden during \printindex.
\let\SETmarginindex=\relax % put index entries in margin (undocumented)?
% Most index entries go through here, but \dosubind is the general case.
@@ -4825,6 +4822,13 @@
\fi
}
+% Output \ as {\indexbackslash}, because \ is an escape character in
+% the index files.
+\let\indexbackslash=\relax
address@hidden \catcode`\\=\active
+ @address@hidden@address@hidden
+}
+
% Write the entry in \toks0 to the index file:
%
\def\dosubindwrite{%
@@ -4835,8 +4839,8 @@
%
% Remember, we are within a group.
\indexdummies % Must do this here, since \bf, etc expand at this stage
- \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now
- % so it will be output as is; and it will print as backslash.
+ \useindexbackslash % \indexbackslash isn't defined now so it will be output
+ % as is; and it will print as backslash.
%
% Process the index entry with all font commands turned off, to
% get the string to sort by.
@@ -5000,7 +5004,9 @@
% Index files are almost Texinfo source, but we use \ as the escape
% character. It would be better to use @, but that's too big a change
% to make right now.
- \def\indexbackslash{\backslashcurfont}%
+ \def\indexbackslash{\ttbackslash}%
+ \let\indexlbrace\{ % Likewise, set these sequences for braces
+ \let\indexrbrace\} % used in the sort key.
\catcode`\\ = 0
\escapechar = `\\
\begindoublecolumns
@@ -5014,9 +5020,6 @@
% These macros are used by the sorted index file itself.
% Change them to control the appearance of the index.
address@hidden \catcode`\\=13
address@hidden@address@hidden@address@hidden@backslash}}}}
-
\let\normalhyphen=-
{\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
\catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
@@ -5025,7 +5028,8 @@
% Some changes for non-alphabetic characters. Using the glyphs from the
% math fonts looks more consistent than the typewriter font used elsewhere
% for these characters.
- \usemathbackslash
+ \def\indexbackslash{\math{\backslash}}%
+ \let\\=\indexbackslash
%
% Can't get bold backslash so don't use bold forward slash
\catcode`\/=13
Modified: trunk/texindex/texindex.awk
===================================================================
--- trunk/texindex/texindex.awk 2015-08-24 11:58:56 UTC (rev 6565)
+++ trunk/texindex/texindex.awk 2015-08-24 15:10:34 UTC (rev 6566)
@@ -161,7 +161,7 @@
EXIT_SUCCESS = 0
EXIT_FAILURE = 1
- Texindex_version = "5.9.93"
+ Texindex_version = "6.0dev"
if (! Invocation_name) {
# provide fallback in case it's not passed in.
Invocation_name = "texindex"
@@ -268,18 +268,30 @@
function extract_initial(key, initial, nextchar, i, l, kchars)
{
l = char_split(key, kchars)
- for (i = 1; i <= l; i++)
- if (kchars[i] != "{")
- break
+ if (l >= 3 && kchars[2] == "{") {
+ bracecount = 1
+ i = 3
+ while (bracecount > 0 && i <= l) {
+ if (kchars[i] == "{")
+ bracecount++
+ else if (kchars[i] == "}")
+ bracecount--
+ i++
+ }
+ if (i > l)
+ fatal(_"%s:%d: Bad key %s in record\n", FILENAME, FNR, key)
+ initial = substr(key, 2, i - 2)
+ } else if (kchars[2] == Command_char) {
+ nextchar = kchars[3]
+ if (initial == Command_char && (nextchar == "{" || nextchar == "}"))
+ initial = substr(key, 2, 3)
+ else {
+ initial = toupper(nextchar)
+ }
+ } else {
+ initial = toupper(kchars[2])
+ }
- if (i > l)
- fatal(_"%s:%d: Bad key %s in record\n", FILENAME, FNR, key)
-
- initial = toupper(kchars[i])
- nextchar = kchars[i+1]
- if (initial == Command_char && (nextchar == "{" || nextchar == "}"))
- initial = nextchar
-
return initial
}
function field_split( \
Modified: trunk/texindex/ti.twjr
===================================================================
--- trunk/texindex/ti.twjr 2015-08-24 11:58:56 UTC (rev 6565)
+++ trunk/texindex/ti.twjr 2015-08-24 15:10:34 UTC (rev 6566)
@@ -411,7 +411,7 @@
@samp{entry}.
@cindex @code{Special_chars} variable
address@hidden are the three characters that must be preceded by
address@hidden are the two characters that must be preceded by
the command character inside the first key.
@cindex @code{beginfile()} function
@@ -443,7 +443,7 @@
|| substr($0, 2, 5) != "entry")
fatal(_"%s is not a Texinfo index file\n", filename)
- Special_chars = "{}" Command_char
+ Special_chars = "{}"
}
@
@@ -512,12 +512,14 @@
initial = extract_initial($0)
@
-Extracting the initial is mildly complicated. Braces can be nested, and
-in particular the very first field of the sort key can be an open brace.
-So it is necessary to skip leading open braces until we encounter the
-first real character. This in turn could be @address@hidden or @address@hidden
-preceded by the command character, or another character.
+The key argument here is the rest of the line after @samp{\entry},
+starting with an open brace.
+The very first field character of the sort key can be an open brace.
+If so, we extract the component of the sort key surrounded by balanced
+braces. We don't account for address@hidden or address@hidden inside this
component, as
address@hidden isn't expected to produce such output.
+
An example can be seen in what older versions of @file{texinfo.tex}
generated if you needed to index a real backslash, namely an input line
something like the following:
@@ -526,8 +528,10 @@
address@hidden@{\tt \indexbackslash @}
(backslash)@address@hidden@address@hidden @address@hidden @dots{}
@end example
-Fortunately, the first non-brace character is a backslash, and that is
-also the correct initial.
+Earlier versions of @command{texindex} took the the first non-brace
+character as the initial, in this example @samp{\}, and output it as
address@hidden; this was not, however, a control sequence recognized by the
+older versions of @file{texinfo.tex}.
@cindex @code{extract_initial()} function
@cindex @code{char_split()} function
@@ -535,18 +539,30 @@
function extract_initial(key, initial, nextchar, i, l, kchars)
{
l = char_split(key, kchars)
- for (i = 1; i <= l; i++)
- if (kchars[i] != "{")
- break
+ if (l >= 3 && kchars[2] == "{") {
+ bracecount = 1
+ i = 3
+ while (bracecount > 0 && i <= l) {
+ if (kchars[i] == "{")
+ bracecount++
+ else if (kchars[i] == "}")
+ bracecount--
+ i++
+ }
+ if (i > l)
+ fatal(_"%s:%d: Bad key %s in record\n", FILENAME, FNR, key)
+ initial = substr(key, 2, i - 2)
+ } else if (kchars[2] == Command_char) {
+ nextchar = kchars[3]
+ if (initial == Command_char && (nextchar == "{" || nextchar == "}"))
+ initial = substr(key, 2, 3)
+ else {
+ initial = toupper(nextchar)
+ }
+ } else {
+ initial = toupper(kchars[2])
+ }
- if (i > l)
- fatal(_"%s:%d: Bad key %s in record\n", FILENAME, FNR, key)
-
- initial = toupper(kchars[i])
- nextchar = kchars[i+1]
- if (initial == Command_char && (nextchar == "{" || nextchar == "}"))
- initial = nextchar
-
return initial
}
@
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6566] improve texindex backward compatibility with texinfo.tex,
Gavin D. Smith <=