aboutsummaryrefslogtreecommitdiff
path: root/readline/doc
diff options
context:
space:
mode:
authorPatrick Palka <patrick@parcs.ath.cx>2015-07-14 20:29:21 -0400
committerPatrick Palka <patrick@parcs.ath.cx>2015-07-25 09:53:01 -0400
commit4a11f2065906976675808364ddbd1c0f77eea41f (patch)
tree8b25495190b4d41b1785910c4cc4fd709d0a628a /readline/doc
parenta496fbc8802f0a5719db6347a43cc869e03d83c9 (diff)
downloadgdb-4a11f2065906976675808364ddbd1c0f77eea41f.zip
gdb-4a11f2065906976675808364ddbd1c0f77eea41f.tar.gz
gdb-4a11f2065906976675808364ddbd1c0f77eea41f.tar.bz2
Sync readline/ to version 7.0 alpha
This patch syncs our upstream copy of readline from version 6.2 to the latest version, 7.0 alpha (released July 10 2015). I essentially copied what was done the last time readline was synced, when Jan updated to readline 6.2 in 2011: http://sourceware.org/ml/gdb-patches/2011-05/msg00003.html Procedure: 1. I extracted the readline-7.0-alpha tarball on top of readline/. 2. I deleted all the new files under doc/ that were deliberately omitted before. 3. I regenerated readline/configure and readline/examples/rlfe/configure using autoconf 2.64. No other configure files need regenerating. 4. I updated the function gdb_printable_part in completer.c with a trivial change made to the readline function it is based off of, printable_part in readline/complete.c. There is more work to be done in completer.c to sync it with readline/complete.c, but it is non-trivial and should probably be done separately anyway. Local patches that had to be reapplied: None. readline 7.0 alpha contains all of our local readline patches. New files in readline/: colors.{c,h} examples/{hist_erasedups,hist_purgecmd,rl-callbacktest,rlbasic}.c parse-colors.{c,h} readline.pc.in configure.ac Deleted files in readline/: configure.in Regressions: After the sync there is one testsuite regression, the test "signal SIGINT" in gdb.gdb/selftest.exp which now FAILs. Previously, the readline 6.2 SIGINT handler would temporarily reinstall the underlying application's SIGINT handler and immediately re-raise SIGINT so that the orginal handler gets invoked. But now (since readline 6.3) its SIGINT handler does not re-raise SIGINT or directly invoke the original handler; it now sets a flag marking that SIGINT was raised, and waits until readline explicitly has control to call the application's SIGINT handler. Anyway, because SIGINT is no longer re-raised from within readline's SIGINT handler, doing "signal SIGINT" with a stopped inferior gdb process will no longer resume and then immediately stop the process (since there is no 2nd SIGINT to immediately catch). Instead, the inferior gdb process will now just print "Quit" and continue to run. So with this commit, this particular test case is adjusted to reflect this change in behavior (we now have to send a 2nd SIGINT manually to stop it). Aside from this one testsuite regression, I personally noticed no regression in user-visible behavior. Though I only tested on x86_64 and on i686 Debian Stretch. Getting this kind of change in at the start of the GDB 7.11 development cycle will allow us to get a lot of passive testing from developers and from bleeding-edge users. readline/ChangeLog.gdb: Import readline 7.0 alpha * configure: Regenerate. * examples/rlfe/configure: Regenerate. gdb/ChangeLog: * completer.c (gdb_printable_part): Sync with readline function it is based off of. gdb/testsuite/ChangeLog: * gdb.gdb/selftest.exp (test_with_self): Update test to now expect the GDB inferior to no longer immediately stop after being resumed with "signal SIGINT".
Diffstat (limited to 'readline/doc')
-rw-r--r--readline/doc/Makefile.in21
-rw-r--r--readline/doc/history.333
-rw-r--r--readline/doc/history.texi26
-rw-r--r--readline/doc/hstech.texi16
-rw-r--r--readline/doc/hsuser.texi40
-rw-r--r--readline/doc/readline.3166
-rw-r--r--readline/doc/rlman.texi27
-rw-r--r--readline/doc/rltech.texi239
-rw-r--r--readline/doc/rluser.texi317
-rw-r--r--readline/doc/rluserman.texi27
-rwxr-xr-xreadline/doc/texi2dvi2316
-rwxr-xr-xreadline/doc/texi2html6
-rw-r--r--readline/doc/version.texi12
13 files changed, 2535 insertions, 711 deletions
diff --git a/readline/doc/Makefile.in b/readline/doc/Makefile.in
index 89d8b47..a38bc9e 100644
--- a/readline/doc/Makefile.in
+++ b/readline/doc/Makefile.in
@@ -16,6 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+
topdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
@@ -24,6 +26,7 @@ prefix = @prefix@
datarootdir = @datarootdir@
+docdir = @docdir@
infodir = @infodir@
mandir = @mandir@
@@ -56,6 +59,8 @@ QUIETPS = #set this to -q to shut up dvips
PAPERSIZE = letter
PSDPI = 600
DVIPS = dvips -D ${PSDPI} $(QUIETPS) -t ${PAPERSIZE} -o $@ # tricky
+# experimental; uses external texi2dvi for now; this needs pdftex to be present
+TEXI2PDF = texi2dvi --pdf
# These tools might not be available; they're not required
DVIPDF = dvipdfm -o $@ -p ${PAPERSIZE}
@@ -98,6 +103,10 @@ DIST_DOCS = $(DVIOBJ) $(PSOBJ) $(HTMLOBJ) $(INFOOBJ) $(TEXTOBJ) $(PDFOBJ)
$(RM) $@
-${DVIPDF} $<
+#.texi.pdf:
+# $(RM) $@
+# -${TEXI2PDF} $<
+
all: info dvi html ps text pdf
nodvi: info html text
@@ -167,9 +176,15 @@ history_3.ps: $(srcdir)/history.3
${RM} $@
${GROFF} -man < $(srcdir)/history.3 > $@
-readline.pdf: readline.dvi
-history.pdf: history.dvi
-rluserman.pdf: rluserman.dvi
+readline.pdf: $(RLSRC)
+ TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2PDF) $(srcdir)/rlman.texi
+ mv rlman.pdf $@
+
+history.pdf: $(HISTSRC)
+ TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2PDF) $(srcdir)/history.texi
+
+rluserman.pdf: $(RLSRC)
+ TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2PDF) $(srcdir)/rluserman.texi
clean:
$(RM) *.aux *.bak *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps \
diff --git a/readline/doc/history.3 b/readline/doc/history.3
index 4eb159c..7ddc26a 100644
--- a/readline/doc/history.3
+++ b/readline/doc/history.3
@@ -4,11 +4,11 @@
.\" Chet Ramey
.\" Information Network Services
.\" Case Western Reserve University
-.\" chet@ins.CWRU.Edu
+.\" chet.ramey@case.edu
.\"
-.\" Last Change: Thu Aug 12 22:24:41 EDT 2010
+.\" Last Change: Sun May 24 18:01:17 EDT 2015
.\"
-.TH HISTORY 3 "2010 August 12" "GNU History 6.2"
+.TH HISTORY 3 "2015 May 24" "GNU History 6.3"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
@@ -40,8 +40,8 @@
.SH NAME
history \- GNU History Library
.SH COPYRIGHT
-.if t The GNU History Library is Copyright \(co 1989-2011 by the Free Software Foundation, Inc.
-.if n The GNU History Library is Copyright (C) 1989-2011 by the Free Software Foundation, Inc.
+.if t The GNU History Library is Copyright \(co 1989-2014 by the Free Software Foundation, Inc.
+.if n The GNU History Library is Copyright (C) 1989-2014 by the Free Software Foundation, Inc.
.SH DESCRIPTION
Many programs read input from the user a line at a time. The GNU
History library is able to keep track of those lines, associate arbitrary
@@ -112,7 +112,7 @@ starting with
.TP
.B !?\fIstring\fR\fB[?]\fR
Refer to the most recent command
-preceding the current postition in the history list
+preceding the current position in the history list
containing
.IR string .
The trailing \fB?\fP may be omitted if
@@ -134,7 +134,7 @@ The entire command line typed so far.
.SS Word Designators
.PP
Word designators are used to select desired words from the event.
-A
+A
.B :
separates the event specification from the word designator.
It may be omitted if the word designator begins with a
@@ -161,7 +161,8 @@ The \fIn\fRth word.
The first argument. That is, word 1.
.TP
.B $
-The last argument.
+The last word. This is usually the last argument, but will expand to the
+zeroth word if there is only one word in the line.
.TP
.B %
The word matched by the most recent `?\fIstring\fR?' search.
@@ -440,9 +441,11 @@ return a pointer to that entry. If there is no previous entry, return
a \fBNULL\fP pointer.
.Fn1 "HIST_ENTRY *" next_history "void"
-Move the current history offset forward to the next history entry, and
-return the a pointer to that entry. If there is no next entry, return
-a \fBNULL\fP pointer.
+If the current history offset refers to a valid history entry,
+increment the current history offset.
+If the possibly-incremented history offset refers to a valid history
+entry, return a pointer to that entry;
+otherwise, return a \fBNULL\fP pointer.
.SS Searching the History List
@@ -612,8 +615,8 @@ string, in addition to space, tab, \fI:\fP and \fI?\fP in the case of
a substring search. The default is empty.
.Vb int history_quotes_inhibit_expansion
-If non-zero, single-quoted words are not scanned for the history expansion
-character. The default value is 0.
+If non-zero, double-quoted words are not scanned for the history expansion
+character or the history comment character. The default value is 0.
.Vb "rl_linebuf_func_t *" history_inhibit_expansion_function
This should be set to the address of a function that takes two arguments:
@@ -649,7 +652,7 @@ bfox@gnu.org
.PP
Chet Ramey, Case Western Reserve University
.br
-chet@ins.CWRU.Edu
+chet.ramey@case.edu
.SH BUG REPORTS
If you find a bug in the
.B history
@@ -669,4 +672,4 @@ newsgroup
.PP
Comments and bug reports concerning
this manual page should be directed to
-.IR chet@ins.CWRU.Edu .
+.IR chet.ramey@case.edu .
diff --git a/readline/doc/history.texi b/readline/doc/history.texi
index 64945d8..a991fe5 100644
--- a/readline/doc/history.texi
+++ b/readline/doc/history.texi
@@ -2,33 +2,25 @@
@c %**start of header (This is for running Texinfo on a region.)
@setfilename history.info
@settitle GNU History Library
-@c %**end of header (This is for running Texinfo on a region.)
-
@include version.texi
+@c %**end of header (This is for running Texinfo on a region.)
+
@copying
This document describes the GNU History library
(version @value{VERSION}, @value{UPDATED}),
a programming tool that provides a consistent user interface for
recalling lines of previously typed input.
-Copyright @copyright{} 1988--2011 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
+Copyright @copyright{} 1988--2014 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
-Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
-and with the Back-Cover Texts as in (a) below. A copy of the license is
-included in the section entitled ``GNU Free Documentation License''.
-
-(a) The FSF's Back-Cover Text is: You are free to copy and modify
-this GNU manual. Buying copies from GNU Press supports the FSF in
-developing GNU and promoting software freedom.''
+Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+A copy of the license is included in the section entitled
+``GNU Free Documentation License''.
@end quotation
@end copying
@@ -50,12 +42,6 @@ developing GNU and promoting software freedom.''
@vskip 0pt plus 1filll
@insertcopying
-@sp 1
-Published by the Free Software Foundation @*
-59 Temple Place, Suite 330, @*
-Boston, MA 02111-1307 @*
-USA @*
-
@end titlepage
@contents
diff --git a/readline/doc/hstech.texi b/readline/doc/hstech.texi
index 4fc9e8e..6deaeee 100644
--- a/readline/doc/hstech.texi
+++ b/readline/doc/hstech.texi
@@ -1,7 +1,7 @@
@ignore
This file documents the user interface to the GNU History library.
-Copyright (C) 1988-2011 Free Software Foundation, Inc.
+Copyright (C) 1988-2014 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
@@ -270,9 +270,11 @@ a @code{NULL} pointer.
@end deftypefun
@deftypefun {HIST_ENTRY *} next_history (void)
-Move the current history offset forward to the next history entry, and
-return the a pointer to that entry. If there is no next entry, return
-a @code{NULL} pointer.
+If the current history offset refers to a valid history entry,
+increment the current history offset.
+If the possibly-incremented history offset refers to a valid history
+entry, return a pointer to that entry;
+otherwise, return a @code{BNULL} pointer.
@end deftypefun
@node Searching the History List
@@ -377,7 +379,7 @@ if the returned line should be displayed, but not executed,
as with the @code{:p} modifier (@pxref{Modifiers}).
@end table
-If an error ocurred in expansion, then @var{output} contains a descriptive
+If an error occurred in expansion, then @var{output} contains a descriptive
error message.
@end deftypefun
@@ -467,8 +469,8 @@ carriage return, and @samp{=}.
@end deftypevar
@deftypevar int history_quotes_inhibit_expansion
-If non-zero, single-quoted words are not scanned for the history expansion
-character. The default value is 0.
+If non-zero, double-quoted words are not scanned for the history expansion
+character or the history comment character. The default value is 0.
@end deftypevar
@deftypevar {rl_linebuf_func_t *} history_inhibit_expansion_function
diff --git a/readline/doc/hsuser.texi b/readline/doc/hsuser.texi
index 9aa6c35..3aa6cfa 100644
--- a/readline/doc/hsuser.texi
+++ b/readline/doc/hsuser.texi
@@ -1,7 +1,7 @@
@ignore
This file documents the user interface to the GNU History library.
-Copyright (C) 1988--2011 Free Software Foundation, Inc.
+Copyright (C) 1988--2014 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
@@ -26,10 +26,9 @@ into another language, under the above conditions for modified versions.
@node Using History Interactively
@chapter Using History Interactively
-@c GDB bundling modification:
-@c @ifclear BashFeatures
-@c @defcodeindex bt
-@c @end ifclear
+@ifclear BashFeatures
+@defcodeindex bt
+@end ifclear
@ifset BashFeatures
This chapter describes how to use the @sc{gnu} History Library
@@ -42,8 +41,7 @@ see the @sc{gnu} Readline Library Manual.
This chapter describes how to use the @sc{gnu} History Library interactively,
from a user's standpoint. It should be considered a user's guide. For
information on using the @sc{gnu} History Library in your own programs,
-@c GDB bundling modification:
-@pxref{Programming with GNU History, , , history, GNU History Library}.
+@pxref{Programming with GNU History}.
@end ifclear
@ifset BashFeatures
@@ -86,17 +84,18 @@ file named by the @env{HISTFILE} variable (default @file{~/.bash_history}).
The file named by the value of @env{HISTFILE} is truncated, if
necessary, to contain no more than the number of lines specified by
the value of the @env{HISTFILESIZE} variable.
-When an interactive shell exits, the last
+When a shell with history enabled exits, the last
@env{$HISTSIZE} lines are copied from the history list to the file
named by @env{$HISTFILE}.
If the @code{histappend} shell option is set (@pxref{Bash Builtins}),
the lines are appended to the history file,
otherwise the history file is overwritten.
If @env{HISTFILE}
-is unset, or if the history file is unwritable, the history is
-not saved. After saving the history, the history file is truncated
-to contain no more than @env{$HISTFILESIZE}
-lines. If @env{HISTFILESIZE} is not set, no truncation is performed.
+is unset, or if the history file is unwritable, the history is not saved.
+After saving the history, the history file is truncated
+to contain no more than @env{$HISTFILESIZE} lines.
+If @env{HISTFILESIZE} is unset, or set to null, a non-numeric value, or
+a numeric value less than zero, the history file is not truncated.
If the @env{HISTTIMEFORMAT} is set, the time stamp information
associated with each history entry is written to the history file,
@@ -143,8 +142,10 @@ history list and history file.
@code{fc -s [@var{pat}=@var{rep}] [@var{command}]}
@end example
-Fix Command. In the first form, a range of commands from @var{first} to
-@var{last} is selected from the history list. Both @var{first} and
+The first form selects a range of commands from @var{first} to
+@var{last} from the history list and displays or edits and re-executes
+them.
+Both @var{first} and
@var{last} may be specified as a string (to locate the most recent
command beginning with that string) or as a number (an index into the
history list, where a negative number is used as an offset from the
@@ -163,6 +164,7 @@ When editing is complete, the edited commands are echoed and executed.
In the second form, @var{command} is re-executed after each instance
of @var{pat} in the selected command is replaced by @var{rep}.
+@var{command} is intepreted the same as @var{first} above.
A useful alias to use with the @code{fc} command is @code{r='fc -s'}, so
that typing @samp{r cc} runs the last command beginning with @code{cc}
@@ -200,9 +202,9 @@ Delete the history entry at position @var{offset}.
displayed.
@item -a
-Append the new
-history lines (history lines entered since the beginning of the
-current Bash session) to the history file.
+Append the new history lines to the history file.
+These are history lines entered since the beginning of the current
+Bash session, but not already appended to the history file.
@item -n
Append the history lines not already read from the history file
@@ -210,11 +212,11 @@ to the current history list. These are lines appended to the history
file since the beginning of the current Bash session.
@item -r
-Read the current history file and append its contents to
+Read the history file and append its contents to
the history list.
@item -w
-Write out the current history to the history file.
+Write out the current history list to the history file.
@item -p
Perform history substitution on the @var{arg}s and display the result
diff --git a/readline/doc/readline.3 b/readline/doc/readline.3
index f79f4bb..765c8fa 100644
--- a/readline/doc/readline.3
+++ b/readline/doc/readline.3
@@ -4,11 +4,11 @@
.\" Chet Ramey
.\" Information Network Services
.\" Case Western Reserve University
-.\" chet@ins.CWRU.Edu
+.\" chet.ramey@case.edu
.\"
-.\" Last Change: Sat Aug 28 18:56:32 EDT 2010
+.\" Last Change: Wed Nov 19 18:32:58 EST 2014
.\"
-.TH READLINE 3 "2010 August 28" "GNU Readline 6.2"
+.TH READLINE 3 "2014 November 19" "GNU Readline 6.3"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
@@ -34,8 +34,8 @@ readline \- get a line from a user with editing
\fBreadline\fP (\fIconst char *prompt\fP);
.fi
.SH COPYRIGHT
-.if n Readline is Copyright (C) 1989\-2011 Free Software Foundation, Inc.
-.if t Readline is Copyright \(co 1989\-2011 Free Software Foundation, Inc.
+.if n Readline is Copyright (C) 1989\-2014 Free Software Foundation, Inc.
+.if t Readline is Copyright \(co 1989\-2014 Free Software Foundation, Inc.
.SH DESCRIPTION
.LP
.B readline
@@ -78,10 +78,10 @@ treated as a newline.
.LP
An Emacs-style notation is used to denote
keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
-means Control\-N. Similarly,
+means Control\-N. Similarly,
.I meta
keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X. (On keyboards
-without a
+without a
.I meta
key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key
then the
@@ -98,14 +98,15 @@ Readline commands may be given numeric
which normally act as a repeat count. Sometimes, however, it is the
sign of the argument that is significant. Passing a negative argument
to a command that acts in the forward direction (e.g., \fBkill\-line\fP)
-causes that command to act in a backward direction. Commands whose
-behavior with arguments deviates from this are noted.
+causes that command to act in a backward direction.
+Commands whose behavior with arguments deviates from this are noted
+below.
.PP
When a command is described as \fIkilling\fP text, the text
deleted is saved for possible future retrieval
(\fIyanking\fP). The killed text is saved in a
\fIkill ring\fP. Consecutive kills cause the text to be
-accumulated into one unit, which can be yanked all at once.
+accumulated into one unit, which can be yanked all at once.
Commands which do not kill text separate the chunks of text
on the kill ring.
.SH INITIALIZATION FILE
@@ -138,7 +139,7 @@ or
C\-Meta\-u: universal\-argument
.RE
.sp
-into the
+into the
.I inputrc
would make M\-C\-u execute the readline command
.IR universal\-argument .
@@ -167,7 +168,7 @@ The syntax for controlling key bindings in the
.I inputrc
file is simple. All that is required is the name of the
command or the text of a macro and a key sequence to which
-it should be bound. The name may be specified in one of two ways:
+it should be bound. The name may be specified in one of two ways:
as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
prefixes, or as a key sequence.
The name and key sequence are separated by a colon. There can be no
@@ -225,7 +226,7 @@ is again bound to the function
.I "C-x C-r"
is bound to the function
.BR re\-read\-init\-file ,
-and
+and
.I "ESC [ 1 1 ~"
is bound to insert the text
.if t \f(CWFunction Key 1\fP.
@@ -347,9 +348,25 @@ If set to \fBnone\fP, readline never rings the bell. If set to
If set to \fBaudible\fP, readline attempts to ring the terminal's bell.
.TP
.B bind\-tty\-special\-chars (On)
-If set to \fBOn\fP, readline attempts to bind the control characters
-treated specially by the kernel's terminal driver to their readline
-equivalents.
+If set to \fBOn\fP (the default), readline attempts to bind the control
+characters treated specially by the kernel's terminal driver to their
+readline equivalents.
+.TP
+.B blink\-matching\-paren (Off)
+If set to \fBOn\fP, readline attempts to briefly move the cursor to an
+opening parenthesis when a closing parenthesis is inserted.
+.TP
+.B colored\-completion\-prefix (Off)
+If set to \fBOn\fP, when listing completions, readline displays the
+common prefix of the set of possible completions using a different color.
+The color definitions are taken from the value of the \fBLS_COLORS\fP
+environment variable.
+.TP
+.B colored\-stats (Off)
+If set to \fBOn\fP, readline displays possible completions using different
+colors to indicate their file type.
+The color definitions are taken from the value of the \fBLS_COLORS\fP
+environment variable.
.TP
.B comment\-begin (``#'')
The string that is inserted in \fBvi\fP mode when the
@@ -419,6 +436,13 @@ When set to \fBOn\fP, on operating systems that indicate they support it,
readline echoes a character corresponding to a signal generated from the
keyboard.
.TP
+.B enable\-bracketed\-paste (Off)
+When set to \fBOn\fP, readline will configure the terminal in a way
+that will enable it to insert each paste into the editing buffer as a
+single string of characters, instead of treating each character as if
+it had been read from the keyboard. This can prevent pasted characters
+from being interpreted as editing commands.
+.TP
.B enable\-keypad (Off)
When set to \fBOn\fP, readline will try to enable the application
keypad when it is called. Some systems need this to enable the
@@ -438,9 +462,13 @@ If set to \fBOn\fP, the history code attempts to place point at the
same location on each history line retrieved with \fBprevious-history\fP
or \fBnext-history\fP.
.TP
-.B history\-size (0)
-Set the maximum number of history entries saved in the history list. If
-set to zero, the number of entries in the history list is not limited.
+.B history\-size (unset)
+Set the maximum number of history entries saved in the history list.
+If set to zero, any existing history entries are deleted and no new entries
+are saved.
+If set to a value less than zero, the number of history entries is not
+limited.
+By default, the number of history entries is not limited.
.TP
.B horizontal\-scroll\-mode (Off)
When set to \fBOn\fP, makes readline use a single line for display,
@@ -472,6 +500,28 @@ The value of
.B editing\-mode
also affects the default keymap.
.TP
+.B emacs\-mode\-string (@)
+This string is displayed immediately before the last line of the primary
+prompt when emacs editing mode is active. The value is expanded like a
+key binding, so the standard set of meta- and control prefixes and
+backslash escape sequences is available.
+Use the \e1 and \e2 escapes to begin and end sequences of
+non-printing characters, which can be used to embed a terminal control
+sequence into the mode string.
+.TP
+.B keyseq\-timeout (500)
+Specifies the duration \fIreadline\fP will wait for a character when reading an
+ambiguous key sequence (one that can form a complete key sequence using
+the input read so far, or can take additional input to complete a longer
+key sequence).
+If no input is received within the timeout, \fIreadline\fP will use the shorter
+but complete key sequence.
+The value is specified in milliseconds, so a value of 1000 means that
+\fIreadline\fP will wait one second for additional input.
+If this variable is set to a value less than or equal to zero, or to a
+non-numeric value, \fIreadline\fP will wait until another key is pressed to
+decide which key sequence to complete.
+.TP
.B mark\-directories (On)
If set to \fBOn\fP, completed directory names have a slash
appended.
@@ -487,7 +537,7 @@ have a slash appended (subject to the value of
.TP
.B match\-hidden\-files (On)
This variable, when set to \fBOn\fP, causes readline to match files whose
-names begin with a `.' (hidden files) when performing filename
+names begin with a `.' (hidden files) when performing filename
completion.
If set to \fBOff\fP, the leading `.' must be
supplied by the user in the filename to be completed.
@@ -533,6 +583,11 @@ possible partial completion (the possible completions don't share
a common prefix) cause the matches to be listed immediately instead
of ringing the bell.
.TP
+.B show\-mode\-in\-prompt (Off)
+If set to \fBOn\fP, add a character to the beginning of the prompt
+indicating the editing mode: emacs, vi command, or vi insertion.
+The mode strings are user-settable.
+.TP
.B skip\-completed\-text (Off)
If set to \fBOn\fP, this alters the default completion behavior when
inserting a single match into the line. It's only active when
@@ -541,6 +596,26 @@ does not insert characters from the completion that match characters
after point in the word being completed, so portions of the word
following the cursor are not duplicated.
.TP
+.B vi\-cmd\-mode\-string ((cmd))
+This string is displayed immediately before the last line of the primary
+prompt when vi editing mode is active and in command mode.
+The value is expanded like a
+key binding, so the standard set of meta- and control prefixes and
+backslash escape sequences is available.
+Use the \e1 and \e2 escapes to begin and end sequences of
+non-printing characters, which can be used to embed a terminal control
+sequence into the mode string.
+.TP
+.B vi\-ins\-mode\-string ((ins))
+This string is displayed immediately before the last line of the primary
+prompt when vi editing mode is active and in insertion mode.
+The value is expanded like a
+key binding, so the standard set of meta- and control prefixes and
+backslash escape sequences is available.
+Use the \e1 and \e2 escapes to begin and end sequences of
+non-printing characters, which can be used to embed a terminal control
+sequence into the mode string.
+.TP
.B visible\-stats (Off)
If set to \fBOn\fP, a character denoting a file's type as reported
by \fIstat\fP(2) is appended to the filename when listing possible
@@ -553,7 +628,7 @@ compilation features of the C preprocessor which allows key
bindings and variable settings to be performed as the result
of tests. There are four parser directives used.
.IP \fB$if\fP
-The
+The
.B $if
construct allows bindings to be made based on the
editing mode, the terminal being used, or the application using
@@ -738,15 +813,30 @@ using a non-incremental search for a string supplied by the user.
Search forward through the history using a non-incremental search
for a string supplied by the user.
.TP
+.B history\-search\-backward
+Search backward through the history for the string of characters
+between the start of the current line and the current cursor
+position (the \fIpoint\fP).
+The search string must match at the beginning of a history line.
+This is a non-incremental search.
+.TP
.B history\-search\-forward
Search forward through the history for the string of characters
+between the start of the current line and the point.
+The search string must match at the beginning of a history line.
+This is a non-incremental search.
+.TP
+.B history\-substring\-search\-backward
+Search backward through the history for the string of characters
between the start of the current line and the current cursor
position (the \fIpoint\fP).
+The search string may match anywhere in a history line.
This is a non-incremental search.
.TP
-.B history\-search\-backward
-Search backward through the history for the string of characters
+.B history\-substring\-search\-forward
+Search forward through the history for the string of characters
between the start of the current line and the point.
+The search string may match anywhere in a history line.
This is a non-incremental search.
.TP
.B yank\-nth\-arg (M\-C\-y)
@@ -778,13 +868,22 @@ as if the "!$" history expansion had been specified.
.PP
.PD 0
.TP
-.B delete\-char (C\-d)
-Delete the character at point. If point is at the
-beginning of the line, there are no characters in the line, and
-the last character typed was not bound to \fBdelete\-char\fP, then return
+.B \fIend\-of\-file\fP (usually C\-d)
+The character indicating end-of-file as set, for example, by
+.if t \f(CWstty\fP.
+.if n ``stty''.
+If this character is read when there are no characters
+on the line, and point is at the beginning of the line, Readline
+interprets it as the end of input and returns
.SM
.BR EOF .
.TP
+.B delete\-char (C\-d)
+Delete the character at point.
+If this function is bound to the
+same character as the tty \fBEOF\fP character, as \fBC\-d\fP
+commonly is, see above for the effects.
+.TP
.B backward\-delete\-char (Rubout)
Delete the character behind the cursor. When given a numeric argument,
save the deleted text on the kill ring.
@@ -835,7 +934,7 @@ switches to overwrite mode. With an explicit non-positive numeric
argument, switches to insert mode. This command affects only
\fBemacs\fP mode; \fBvi\fP mode does overwrite differently.
Each call to \fIreadline()\fP starts in insert mode.
-In overwrite mode, characters bound to \fBself\-insert\fP replace
+In overwrite mode, characters bound to \fBself\-insert\fP replace
the text at point rather than pushing the text to the right.
Characters bound to \fBbackward\-delete\-char\fP replace the character
before point with a space. By default, this command is unbound.
@@ -858,7 +957,7 @@ The killed text is saved on the kill-ring.
.B kill\-whole\-line
Kill all characters on the current line, no matter where point is.
.TP
-.B kill\-word (M\-d)
+.B kill\-word (M\-d)
Kill from point the end of the current word, or if between
words, to the end of the next word. Word boundaries are the same as
those used by \fBforward\-word\fP.
@@ -996,6 +1095,9 @@ and store the definition.
.B call\-last\-kbd\-macro (C\-x e)
Re-execute the last keyboard macro defined, by making the characters
in the macro appear as if typed at the keyboard.
+.B print\-last\-kbd\-macro ()
+Print the last keyboard macro defined in a format suitable for the
+\fIinputrc\fP file.
.PD
.SS Miscellaneous
.PP
@@ -1062,7 +1164,7 @@ but usually bound to ESC\-[.
Without a numeric argument, the value of the readline
.B comment\-begin
variable is inserted at the beginning of the current line.
-If a numeric argument is supplied, this command acts as a toggle: if
+If a numeric argument is supplied, this command acts as a toggle: if
the characters at the beginning of the line do not match the value
of \fBcomment\-begin\fP, the value is inserted, otherwise
the characters in \fBcomment-begin\fP are deleted from the beginning of
@@ -1355,7 +1457,7 @@ bfox@gnu.org
.PP
Chet Ramey, Case Western Reserve University
.br
-chet@ins.CWRU.Edu
+chet.ramey@case.edu
.SH BUG REPORTS
If you find a bug in
.B readline,
@@ -1375,7 +1477,7 @@ newsgroup
.PP
Comments and bug reports concerning
this manual page should be directed to
-.IR chet@ins.CWRU.Edu .
+.IR chet.ramey@case.edu .
.SH BUGS
.PP
It's too big and too slow.
diff --git a/readline/doc/rlman.texi b/readline/doc/rlman.texi
index 1c9ac13..17a8292 100644
--- a/readline/doc/rlman.texi
+++ b/readline/doc/rlman.texi
@@ -2,34 +2,26 @@
@comment %**start of header (This is for running Texinfo on a region.)
@setfilename readline.info
@settitle GNU Readline Library
+@include version.texi
+
@comment %**end of header (This is for running Texinfo on a region.)
@synindex vr fn
-@include version.texi
-
@copying
This manual describes the GNU Readline Library
(version @value{VERSION}, @value{UPDATED}), a library which aids in the
consistency of user interface across discrete programs which provide
a command line interface.
-Copyright @copyright{} 1988--2011 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
+Copyright @copyright{} 1988--2014 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
-Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
-and with the Back-Cover Texts as in (a) below. A copy of the license is
-included in the section entitled ``GNU Free Documentation License''.
-
-(a) The FSF's Back-Cover Text is: You are free to copy and modify
-this GNU manual. Buying copies from GNU Press supports the FSF in
-developing GNU and promoting software freedom.''
+Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+A copy of the license is included in the section entitled
+``GNU Free Documentation License''.
@end quotation
@end copying
@@ -50,12 +42,6 @@ developing GNU and promoting software freedom.''
@vskip 0pt plus 1filll
@insertcopying
-@sp 1
-Published by the Free Software Foundation @*
-59 Temple Place, Suite 330, @*
-Boston, MA 02111-1307 @*
-USA @*
-
@end titlepage
@contents
@@ -67,6 +53,7 @@ USA @*
This document describes the GNU Readline Library, a utility which aids
in the consistency of user interface across discrete programs which
provide a command line interface.
+The Readline home page is @url{http://www.gnu.org/software/readline/}.
@menu
* Command Line Editing:: GNU Readline User's Manual.
diff --git a/readline/doc/rltech.texi b/readline/doc/rltech.texi
index dc272a2..2fd6f44 100644
--- a/readline/doc/rltech.texi
+++ b/readline/doc/rltech.texi
@@ -7,7 +7,7 @@ This document describes the GNU Readline Library, a utility for aiding
in the consistency of user interface across discrete programs that need
to provide a command line interface.
-Copyright (C) 1988--2011 Free Software Foundation, Inc.
+Copyright (C) 1988--2014 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -195,7 +195,7 @@ For Readline 4.2, for example, the value of
@node Readline Typedefs
@subsection Readline Typedefs
-For readabilty, we declare a number of new object types, all pointers
+For readability, we declare a number of new object types, all pointers
to functions.
The reason for declaring these new types is to make it easier to write
@@ -282,7 +282,7 @@ At the very least, it should be aware that it can be passed a
negative argument.
A command function should return 0 if its action completes successfully,
-and a non-zero value if some error occurs.
+and a value greater than zero if some error occurs.
This is the convention obeyed by all of the builtin Readline bindable
command functions.
@@ -440,6 +440,35 @@ If non-zero, Readline will call indirectly through this pointer
to get a character from the input stream. By default, it is set to
@code{rl_getc}, the default Readline character input function
(@pxref{Character Input}).
+In general, an application that sets @var{rl_getc_function} should consider
+setting @var{rl_input_available_hook} as well.
+@end deftypevar
+
+@deftypevar {rl_hook_func_t *} rl_signal_event_hook
+If non-zero, this is the address of a function to call if a read system
+call is interrupted when Readline is reading terminal input.
+@end deftypevar
+
+@deftypevar {rl_hook_func_t *} rl_input_available_hook
+If non-zero, Readline will use this function's return value when it needs
+to determine whether or not there is available input on the current input
+source.
+The default hook checks @code{rl_instream}; if an application is using a
+different input source, it should set the hook appropriately.
+Readline queries for available input when implementing intra-key-sequence
+timeouts during input and incremental searches.
+This may use an application-specific timeout before returning a value;
+Readline uses the value passed to @code{rl_set_keyboard_input_timeout()}
+or the value of the user-settable @var{keyseq-timeout} variable.
+This is designed for use by applications using Readline's callback interface
+(@pxref{Alternate Interface}), which may not use the traditional
+@code{read(2)} and file descriptor interface, or other applications using
+a different input mechanism.
+If an application uses an input mechanism or hook that can potentially exceed
+the value of @var{keyseq-timeout}, it should increase the timeout or set
+this hook appropriately even when not using the callback interface.
+In general, an application that sets @var{rl_getc_function} should consider
+setting @var{rl_input_available_hook} as well.
@end deftypevar
@deftypevar {rl_voidfunc_t *} rl_redisplay_function
@@ -479,6 +508,19 @@ last key binding occurred.
This variable is set to the text of any currently-executing macro.
@end deftypevar
+@deftypevar int rl_executing_key
+The key that caused the dispatch to the currently-executing Readline function.
+@end deftypevar
+
+@deftypevar {char *} rl_executing_keyseq
+The full key sequence that caused the dispatch to the currently-executing
+Readline function.
+@end deftypevar
+
+@deftypevar int rl_key_sequence_length
+The number of characters in @var{rl_executing_keyseq}.
+@end deftypevar
+
@deftypevar {int} rl_readline_state
A variable with bit values that encapsulate the current Readline state.
A bit is set with the @code{RL_SETSTATE} macro, and unset with the
@@ -487,7 +529,7 @@ whether a particular state bit is set. Current state bits include:
@table @code
@item RL_STATE_NONE
-Readline has not yet been called, nor has it begun to intialize.
+Readline has not yet been called, nor has it begun to initialize.
@item RL_STATE_INITIALIZING
Readline is initializing its internal data structures.
@item RL_STATE_INITIALIZED
@@ -580,6 +622,7 @@ means that vi mode is active.
* Miscellaneous Functions:: Functions that don't fall into any category.
* Alternate Interface:: Using Readline in a `callback' fashion.
* A Readline Example:: An example Readline function.
+* Alternate Interface Example:: An example program using the alternate interface.
@end menu
@node Function Naming
@@ -908,7 +951,7 @@ Readline thinks the screen display is correct.
@deftypefun int rl_on_new_line (void)
Tell the update functions that we have moved onto a new (empty) line,
-usually after ouputting a newline.
+usually after outputting a newline.
@end deftypefun
@deftypefun int rl_on_new_line_with_prompt (void)
@@ -977,7 +1020,7 @@ It returns the number of visible characters on the last line of the
Applications may indicate that the prompt contains characters that take
up no physical screen space when displayed by bracketing a sequence of
such characters with the special markers @code{RL_PROMPT_START_IGNORE}
-and @code{RL_PROMPT_END_IGNORE} (declared in @file{readline.h}. This may
+and @code{RL_PROMPT_END_IGNORE} (declared in @file{readline.h}). This may
be used to embed terminal-specific escape sequences in prompts.
@end deftypefun
@@ -1241,21 +1284,31 @@ use all of a terminal's capabilities, and this function will return
values for only those capabilities Readline uses.
@end deftypefun
+@deftypefun {void} rl_clear_history (void)
+Clear the history list by deleting all of the entries, in the same manner
+as the History library's @code{clear_history()} function.
+This differs from @code{clear_history} because it frees private data
+Readline saves in the history list.
+@end deftypefun
+
@node Alternate Interface
@subsection Alternate Interface
An alternate interface is available to plain @code{readline()}. Some
applications need to interleave keyboard I/O with file, device, or
window system I/O, typically by using a main loop to @code{select()}
-on various file descriptors. To accomodate this need, readline can
+on various file descriptors. To accommodate this need, readline can
also be invoked as a `callback' function from an event loop. There
are functions available to make this easy.
@deftypefun void rl_callback_handler_install (const char *prompt, rl_vcpfunc_t *lhandler)
Set up the terminal for readline I/O and display the initial
expanded value of @var{prompt}. Save the value of @var{lhandler} to
-use as a function to call when a complete line of input has been entered.
-The function takes the text of the line as an argument.
+use as a handler function to call when a complete line of input has been
+entered.
+The handler function receives the text of the line as an argument.
+As with @code{readline()}, the handler function should @code{free} the
+line when it it finished with it.
@end deftypefun
@deftypefun void rl_callback_read_char (void)
@@ -1263,20 +1316,29 @@ Whenever an application determines that keyboard input is available, it
should call @code{rl_callback_read_char()}, which will read the next
character from the current input source.
If that character completes the line, @code{rl_callback_read_char} will
-invoke the @var{lhandler} function saved by @code{rl_callback_handler_install}
-to process the line.
+invoke the @var{lhandler} function installed by
+@code{rl_callback_handler_install} to process the line.
Before calling the @var{lhandler} function, the terminal settings are
reset to the values they had before calling
@code{rl_callback_handler_install}.
If the @var{lhandler} function returns,
+and the line handler remains installed,
the terminal settings are modified for Readline's use again.
-@code{EOF} is indicated by calling @var{lhandler} with a
+@code{EOF} is indicated by calling @var{lhandler} with a
@code{NULL} line.
@end deftypefun
+@deftypefun void rl_callback_sigcleanup (void)
+Clean up any internal state the callback interface uses to maintain state
+between calls to rl_callback_read_char (e.g., the state of any active
+incremental searches). This is intended to be used by applications that
+wish to perform their own signal handling; Readline's internal signal handler
+calls this when appropriate.
+@end deftypefun
+
@deftypefun void rl_callback_handler_remove (void)
Restore the terminal to its initial state and remove the line handler.
-This may be called from within a callback as well as independently.
+You may call this function from within a callback as well as independently.
If the @var{lhandler} installed by @code{rl_callback_handler_install}
does not exit the program, either this function or the function referred
to by the value of @code{rl_deprep_term_function} should be called before
@@ -1350,6 +1412,98 @@ invert_case_line (count, key)
@}
@end example
+@node Alternate Interface Example
+@subsection Alternate Interface Example
+
+Here is a complete program that illustrates Readline's alternate interface.
+It reads lines from the terminal and displays them, providing the
+standard history and TAB completion functions.
+It understands the EOF character or "exit" to exit the program.
+
+@example
+/* Standard include files. stdio.h is required. */
+#include <stdlib.h>
+#include <unistd.h>
+
+/* Used for select(2) */
+#include <sys/types.h>
+#include <sys/select.h>
+
+#include <stdio.h>
+
+/* Standard readline include files. */
+#include <readline/readline.h>
+#include <readline/history.h>
+
+static void cb_linehandler (char *);
+
+int running;
+const char *prompt = "rltest$ ";
+
+/* Callback function called for each line when accept-line executed, EOF
+ seen, or EOF character read. This sets a flag and returns; it could
+ also call exit(3). */
+static void
+cb_linehandler (char *line)
+@{
+ /* Can use ^D (stty eof) or `exit' to exit. */
+ if (line == NULL || strcmp (line, "exit") == 0)
+ @{
+ if (line == 0)
+ printf ("\n");
+ printf ("exit\n");
+ /* This function needs to be called to reset the terminal settings,
+ and calling it from the line handler keeps one extra prompt from
+ being displayed. */
+ rl_callback_handler_remove ();
+
+ running = 0;
+ @}
+ else
+ @{
+ if (*line)
+ add_history (line);
+ printf ("input line: %s\n", line);
+ free (line);
+ @}
+@}
+
+int
+main (int c, char **v)
+@{
+ fd_set fds;
+ int r;
+
+ /* Install the line handler. */
+ rl_callback_handler_install (prompt, cb_linehandler);
+
+ /* Enter a simple event loop. This waits until something is available
+ to read on readline's input stream (defaults to standard input) and
+ calls the builtin character read callback to read it. It does not
+ have to modify the user's terminal settings. */
+ running = 1;
+ while (running)
+ @{
+ FD_ZERO (&fds);
+ FD_SET (fileno (rl_instream), &fds);
+
+ r = select (FD_SETSIZE, &fds, NULL, NULL, NULL);
+ if (r < 0)
+ @{
+ perror ("rltest: select");
+ rl_callback_handler_remove ();
+ break;
+ @}
+
+ if (FD_ISSET (fileno (rl_instream), &fds))
+ rl_callback_read_char ();
+ @}
+
+ printf ("rltest: Event loop has exited\n");
+ return 0;
+@}
+@end example
+
@node Readline Signal Handling
@section Readline Signal Handling
@@ -1365,6 +1519,7 @@ functions to do so manually.
Readline contains an internal signal handler that is installed for a
number of signals (@code{SIGINT}, @code{SIGQUIT}, @code{SIGTERM},
+@code{SIGHUP},
@code{SIGALRM}, @code{SIGTSTP}, @code{SIGTTIN}, and @code{SIGTTOU}).
When one of these signals is received, the signal handler
will reset the terminal attributes to those that were in effect before
@@ -1387,7 +1542,14 @@ resetting the terminal to its original state. If the application's signal
handler does more than update its idea of the terminal size and return (for
example, a @code{longjmp} back to a main processing loop), it @emph{must}
call @code{rl_cleanup_after_signal()} (described below), to restore the
-terminal state.
+terminal state.
+
+When an application is using the callback interface
+(@pxref{Alternate Interface}), Readline installs signal handlers only for
+the duration of the call to @code{rl_callback_read_char}. Applications
+using the callback interface should be prepared to clean up Readline's
+state if they wish to handle the signal before the line handler completes
+and restores the terminal state.
Readline provides two variables that allow application writers to
control whether or not it will catch certain signals and act on them
@@ -1397,19 +1559,28 @@ a signal handler, so Readline's internal signal state is not corrupted.
@deftypevar int rl_catch_signals
If this variable is non-zero, Readline will install signal handlers for
-@code{SIGINT}, @code{SIGQUIT}, @code{SIGTERM}, @code{SIGALRM},
+@code{SIGINT}, @code{SIGQUIT}, @code{SIGTERM}, @code{SIGHUP}, @code{SIGALRM},
@code{SIGTSTP}, @code{SIGTTIN}, and @code{SIGTTOU}.
The default value of @code{rl_catch_signals} is 1.
@end deftypevar
@deftypevar int rl_catch_sigwinch
-If this variable is non-zero, Readline will install a signal handler for
-@code{SIGWINCH}.
+If this variable is set to a non-zero value,
+Readline will install a signal handler for @code{SIGWINCH}.
The default value of @code{rl_catch_sigwinch} is 1.
@end deftypevar
+@deftypevar int rl_change_environment
+If this variable is set to a non-zero value,
+and Readline is handling @code{SIGWINCH}, Readline will modify the
+@var{LINES} and @var{COLUMNS} environment variables upon receipt of a
+@code{SIGWINCH}
+
+The default value of @code{rl_change_environment} is 1.
+@end deftypevar
+
If an application does not wish to have Readline catch any signals, or
to handle signals other than those Readline catches (@code{SIGHUP},
for example),
@@ -1477,7 +1648,7 @@ The following functions install and remove Readline's signal handlers.
@deftypefun int rl_set_signals (void)
Install Readline's signal handler for @code{SIGINT}, @code{SIGQUIT},
-@code{SIGTERM}, @code{SIGALRM}, @code{SIGTSTP}, @code{SIGTTIN},
+@code{SIGTERM}, @code{SIGHUP}, @code{SIGALRM}, @code{SIGTSTP}, @code{SIGTTIN},
@code{SIGTTOU}, and @code{SIGWINCH}, depending on the values of
@code{rl_catch_signals} and @code{rl_catch_sigwinch}.
@end deftypefun
@@ -1611,7 +1782,7 @@ This calls @code{rl_complete_internal()} with an argument of @samp{*}.
@end deftypefun
@deftypefun int rl_completion_mode (rl_command_func_t *cfunc)
-Returns the apppriate value to pass to @code{rl_complete_internal()}
+Returns the appropriate value to pass to @code{rl_complete_internal()}
depending on whether @var{cfunc} was called twice in succession and
the values of the @code{show-all-if-ambiguous} and
@code{show-all-if-unmodified} variables.
@@ -1728,29 +1899,45 @@ the directory portion of the pathname the user typed.
At the least, even if no other expansion is performed, this function should
remove any quote characters from the directory name, because its result will
be passed directly to @code{opendir()}.
+
The directory completion hook returns an integer that should be non-zero if
the function modifies its directory argument.
The function should not modify the directory argument if it returns 0.
@end deftypevar
-@ignore
-@deftypevar extern rl_icppfunc_t *rl_directory_rewrite_hook;
+@deftypevar {rl_icppfunc_t *} rl_directory_rewrite_hook;
If non-zero, this is the address of a function to call when completing
a directory name. This function takes the address of the directory name
to be modified as an argument. Unlike @code{rl_directory_completion_hook},
it only modifies the directory name used in @code{opendir}, not what is
displayed when the possible completions are printed or inserted. It is
called before rl_directory_completion_hook.
+At the least, even if no other expansion is performed, this function should
+remove any quote characters from the directory name, because its result will
+be passed directly to @code{opendir()}.
-I'm not happy with how this works yet, so it's undocumented.
+The directory rewrite hook returns an integer that should be non-zero if
+the function modfies its directory argument.
+The function should not modify the directory argument if it returns 0.
+@end deftypevar
+
+@deftypevar {rl_icppfunc_t *} rl_filename_stat_hook
+If non-zero, this is the address of a function for the completer to
+call before deciding which character to append to a completed name.
+This function modifies its filename name argument, and the modified value
+is passed to @code{stat()} to determine the file's type and characteristics.
+This function does not need to remove quote characters from the filename.
+
+The stat hook returns an integer that should be non-zero if
+the function modfies its directory argument.
+The function should not modify the directory argument if it returns 0.
@end deftypevar
-@end ignore
@deftypevar {rl_dequote_func_t *} rl_filename_rewrite_hook
If non-zero, this is the address of a function called when reading
directory entries from the filesystem for completion and comparing
them to the partial word to be completed. The function should
-perform any necesary application or system-specific conversion on
+perform any necessary application or system-specific conversion on
the filename, such as converting between character sets or converting
from a filesystem format to a character input format.
The function takes two arguments: @var{fname}, the filename to be converted,
@@ -1772,8 +1959,8 @@ where @var{matches} is the array of matching strings,
@var{num_matches} is the number of strings in that array, and
@var{max_length} is the length of the longest string in that array.
Readline provides a convenience function, @code{rl_display_match_list},
-that takes care of doing the display to Readline's output stream. That
-function may be called from this hook.
+that takes care of doing the display to Readline's output stream.
+You may call that function from this hook.
@end deftypevar
@deftypevar {const char *} rl_basic_word_break_characters
diff --git a/readline/doc/rluser.texi b/readline/doc/rluser.texi
index 8a69c99..6465895 100644
--- a/readline/doc/rluser.texi
+++ b/readline/doc/rluser.texi
@@ -9,7 +9,7 @@ use these features. There is a document entitled "readline.texinfo"
which contains both end-user and programmer documentation for the
GNU Readline Library.
-Copyright (C) 1988--2011 Free Software Foundation, Inc.
+Copyright (C) 1988--2014 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
@@ -72,6 +72,8 @@ Line editing can be enabled at any time using the @option{-o emacs} or
a specific command.
* Programmable Completion Builtins:: Builtin commands to specify how to
complete arguments for a particular command.
+* A Programmable Completion Example:: An example shell function for
+ generating possible completions.
@end ifset
@end menu
@@ -421,9 +423,31 @@ the terminal's bell.
@item bind-tty-special-chars
@vindex bind-tty-special-chars
-If set to @samp{on}, Readline attempts to bind the control characters
-treated specially by the kernel's terminal driver to their Readline
-equivalents.
+If set to @samp{on} (the default), Readline attempts to bind the control
+characters treated specially by the kernel's terminal driver to their
+Readline equivalents.
+
+@item blink-matching-paren
+@vindex blink-matching-paren
+If set to @samp{on}, Readline attempts to briefly move the cursor to an
+opening parenthesis when a closing parenthesis is inserted. The default
+is @samp{off}.
+
+@item colored-completion-prefix
+@vindex colored-completion-prefix
+If set to @samp{on}, when listing completions, Readline displays the
+common prefix of the set of possible completions using a different color.
+The color definitions are taken from the value of the @env{LS_COLORS}
+environment variable.
+The default is @samp{off}.
+
+@item colored-stats
+@vindex colored-stats
+If set to @samp{on}, Readline displays possible completions using different
+colors to indicate their file type.
+The color definitions are taken from the value of the @env{LS_COLORS}
+environment variable.
+The default is @samp{off}.
@item comment-begin
@vindex comment-begin
@@ -490,11 +514,31 @@ key bindings is used. By default, Readline starts up in Emacs editing
mode, where the keystrokes are most similar to Emacs. This variable can be
set to either @samp{emacs} or @samp{vi}.
+@item emacs-mode-string
+@vindex emacs-mode-string
+This string is displayed immediately before the last line of the primary
+prompt when emacs editing mode is active. The value is expanded like a
+key binding, so the standard set of meta- and control prefixes and
+backslash escape sequences is available.
+Use the @samp{\1} and @samp{\2} escapes to begin and end sequences of
+non-printing characters, which can be used to embed a terminal control
+sequence into the mode string.
+The default is @samp{@@}.
+
@item echo-control-characters
+@vindex echo-control-characters
When set to @samp{on}, on operating systems that indicate they support it,
readline echoes a character corresponding to a signal generated from the
keyboard. The default is @samp{on}.
+@item enable-bracketed-paste
+@vindex enable-bracketed-paste
+When set to @samp{On}, Readline will configure the terminal in a way
+that will enable it to insert each paste into the editing buffer as a
+single string of characters, instead of treating each character as if
+it had been read from the keyboard. This can prevent pasted characters
+from being interpreted as editing commands. The default is @samp{off}.
+
@item enable-keypad
@vindex enable-keypad
When set to @samp{on}, Readline will try to enable the application
@@ -521,8 +565,12 @@ or @code{next-history}. The default is @samp{off}.
@item history-size
@vindex history-size
-Set the maximum number of history entries saved in the history list. If
-set to zero, the number of entries in the history list is not limited.
+Set the maximum number of history entries saved in the history list.
+If set to zero, any existing history entries are deleted and no new entries
+are saved.
+If set to a value less than zero, the number of history entries is not
+limited.
+By default, the number of history entries is not limited.
@item horizontal-scroll-mode
@vindex horizontal-scroll-mode
@@ -565,6 +613,22 @@ equivalent to @code{emacs-standard}. The default value is @code{emacs}.
The value of the @code{editing-mode} variable also affects the
default keymap.
+@item keyseq-timeout
+Specifies the duration Readline will wait for a character when reading an
+ambiguous key sequence (one that can form a complete key sequence using
+the input read so far, or can take additional input to complete a longer
+key sequence).
+If no input is received within the timeout, Readline will use the shorter
+but complete key sequence.
+Readline uses this value to determine whether or not input is
+available on the current input source (@code{rl_instream} by default).
+The value is specified in milliseconds, so a value of 1000 means that
+Readline will wait one second for additional input.
+If this variable is set to a value less than or equal to zero, or to a
+non-numeric value, Readline will wait until another key is pressed to
+decide which key sequence to complete.
+The default value is @code{500}.
+
@item mark-directories
If set to @samp{on}, completed directory names have a slash
appended. The default is @samp{on}.
@@ -640,6 +704,13 @@ a common prefix) cause the matches to be listed immediately instead
of ringing the bell.
The default value is @samp{off}.
+@item show-mode-in-prompt
+@vindex show-mode-in-prompt
+If set to @samp{on}, add a character to the beginning of the prompt
+indicating the editing mode: emacs, vi command, or vi insertion.
+The mode strings are user-settable.
+The default value is @samp{off}.
+
@item skip-completed-text
@vindex skip-completed-text
If set to @samp{on}, this alters the default completion behavior when
@@ -654,6 +725,30 @@ rather than @samp{Makefilefile}, assuming there is a single possible
completion.
The default value is @samp{off}.
+@item vi-cmd-mode-string
+@vindex vi-cmd-mode-string
+This string is displayed immediately before the last line of the primary
+prompt when vi editing mode is active and in command mode.
+The value is expanded like a
+key binding, so the standard set of meta- and control prefixes and
+backslash escape sequences is available.
+Use the @samp{\1} and @samp{\2} escapes to begin and end sequences of
+non-printing characters, which can be used to embed a terminal control
+sequence into the mode string.
+The default is @samp{(cmd)}.
+
+@item vi-ins-mode-string
+@vindex vi-ins-mode-string
+This string is displayed immediately before the last line of the primary
+prompt when vi editing mode is active and in insertion mode.
+The value is expanded like a
+key binding, so the standard set of meta- and control prefixes and
+backslash escape sequences is available.
+Use the @samp{\1} and @samp{\2} escapes to begin and end sequences of
+non-printing characters, which can be used to embed a terminal control
+sequence into the mode string.
+The default is @samp{(ins)}.
+
@item visible-stats
@vindex visible-stats
If set to @samp{on}, a character denoting a file's type
@@ -880,7 +975,7 @@ binding, variable assignment, and conditional syntax.
# You can re-read the inputrc file with C-x C-r.
# Lines beginning with '#' are comments.
#
-# First, include any systemwide bindings and variable
+# First, include any system-wide bindings and variable
# assignments from /etc/Inputrc
$include /etc/Inputrc
@@ -1085,28 +1180,47 @@ the history as necessary. This is an incremental search.
@item forward-search-history (C-s)
Search forward starting at the current line and moving `down' through
-the the history as necessary. This is an incremental search.
+the history as necessary. This is an incremental search.
@item non-incremental-reverse-search-history (M-p)
Search backward starting at the current line and moving `up'
through the history as necessary using a non-incremental search
for a string supplied by the user.
+The search string may match anywhere in a history line.
@item non-incremental-forward-search-history (M-n)
Search forward starting at the current line and moving `down'
-through the the history as necessary using a non-incremental search
+through the history as necessary using a non-incremental search
for a string supplied by the user.
+The search string may match anywhere in a history line.
@item history-search-forward ()
Search forward through the history for the string of characters
between the start of the current line and the point.
+The search string must match at the beginning of a history line.
This is a non-incremental search.
By default, this command is unbound.
@item history-search-backward ()
Search backward through the history for the string of characters
-between the start of the current line and the point. This
-is a non-incremental search. By default, this command is unbound.
+between the start of the current line and the point.
+The search string must match at the beginning of a history line.
+This is a non-incremental search.
+By default, this command is unbound.
+
+@item history-substr-search-forward ()
+Search forward through the history for the string of characters
+between the start of the current line and the point.
+The search string may match anywhere in a history line.
+This is a non-incremental search.
+By default, this command is unbound.
+
+@item history-substr-search-backward ()
+Search backward through the history for the string of characters
+between the start of the current line and the point.
+The search string may match anywhere in a history line.
+This is a non-incremental search.
+By default, this command is unbound.
@item yank-nth-arg (M-C-y)
Insert the first argument to the previous command (usually
@@ -1137,11 +1251,17 @@ as if the @samp{!$} history expansion had been specified.
@subsection Commands For Changing Text
@ftable @code
+
+@item @i{end-of-file} (usually C-d)
+The character indicating end-of-file as set, for example, by
+@code{stty}. If this character is read when there are no characters
+on the line, and point is at the beginning of the line, Readline
+interprets it as the end of input and returns @sc{eof}.
+
@item delete-char (C-d)
-Delete the character at point. If point is at the
-beginning of the line, there are no characters in the line, and
-the last character typed was not bound to @code{delete-char}, then
-return @sc{eof}.
+Delete the character at point. If this function is bound to the
+same character as the tty @sc{eof} character, as @kbd{C-d}
+commonly is, see above for the effects.
@item backward-delete-char (Rubout)
Delete the character behind the cursor. A numeric argument means
@@ -1164,6 +1284,14 @@ Insert a tab character.
@item self-insert (a, b, A, 1, !, @dots{})
Insert yourself.
+@item bracketed-paste-begin ()
+This function is intended to be bound to the "bracketed paste" escape
+sequence sent by some terminals, and such a binding is assigned by default.
+It allows Readline to insert the pasted text as a single unit without treating
+each character as if it had been read from the keyboard. The characters
+are inserted as if each one was bound to @code{self-insert}) instead of
+executing any editing commands.
+
@item transpose-chars (C-t)
Drag the character before the cursor forward over
the character at the cursor, moving the
@@ -1215,7 +1343,7 @@ By default, this command is unbound.
Kill the text from point to the end of the line.
@item backward-kill-line (C-x Rubout)
-Kill backward to the beginning of the line.
+Kill backward from the cursor to the beginning of the current line.
@item unix-line-discard (C-u)
Kill backward from the cursor to the beginning of the current line.
@@ -1297,7 +1425,7 @@ leading minus sign, those digits define the argument.
If the command is followed by digits, executing @code{universal-argument}
again ends the numeric argument, but is otherwise ignored.
As a special case, if this command is immediately followed by a
-character that is neither a digit or minus sign, the argument count
+character that is neither a digit nor minus sign, the argument count
for the next command is multiplied by four.
The argument count is initially one, so executing this function the
first time makes the argument count four, a second time makes the
@@ -1435,6 +1563,10 @@ and save the definition.
Re-execute the last keyboard macro defined, by making the characters
in the macro appear as if typed at the keyboard.
+@item print-last-kbd-macro ()
+Print the last keboard macro defined in a format suitable for the
+@var{inputrc} file.
+
@end ftable
@node Miscellaneous Commands
@@ -1693,10 +1825,11 @@ When the command or function is invoked, the @env{COMP_LINE},
assigned values as described above (@pxref{Bash Variables}).
If a shell function is being invoked, the @env{COMP_WORDS} and
@env{COMP_CWORD} variables are also set.
-When the function or command is invoked, the first argument is the
+When the function or command is invoked, the first argument ($1) is the
name of the command whose arguments are being completed, the
-second argument is the word being completed, and the third argument
-is the word preceding the word being completed on the current command line.
+second argument ($2) is the word being completed, and the third argument
+($3) is the word preceding the word being completed on the current command
+line.
No filtering of the generated completions against the word being completed
is performed; the function or command has complete freedom in generating
the matches.
@@ -1706,7 +1839,7 @@ The function may use any of the shell facilities, including the
@code{compgen} and @code{compopt} builtins described below
(@pxref{Programmable Completion Builtins}), to generate the matches.
It must put the possible completions in the @env{COMPREPLY} array
-variable.
+variable, one per array element.
Next, any command specified with the @option{-C} option is invoked
in an environment equivalent to command substitution.
@@ -1723,6 +1856,10 @@ is removed before attempting a match.
Any completion that matches the pattern will be removed from the list.
A leading @samp{!} negates the pattern; in this case any completion
not matching the pattern will be removed.
+If the @code{nocasematch} shell option
+(see the description of @code{shopt} in @ref{The Shopt Builtin})
+is enabled, the match is performed without regard to the case
+of alphabetic characters.
Finally, any prefix and suffix specified with the @option{-P} and @option{-S}
options are added to each member of the completion list, and the result is
@@ -1774,17 +1911,18 @@ completion function would load completions dynamically:
@example
_completion_loader()
@{
- . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124
+ . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124
@}
-complete -D -F _completion_loader
+complete -D -F _completion_loader -o bashdefault -o default
@end example
@node Programmable Completion Builtins
@section Programmable Completion Builtins
@cindex completion builtins
-Two builtin commands are available to manipulate the programmable completion
-facilities.
+Three builtin commands are available to manipulate the programmable completion
+facilities: one to specify how the arguments to a particular command are to
+be completed, and two to modify the completion as it is happening.
@table @code
@item compgen
@@ -1871,6 +2009,13 @@ quoting special characters, or suppressing trailing spaces).
This option is intended to be used with shell functions specified
with @option{-F}.
+@item noquote
+Tell Readline not to quote the completed words if they are filenames
+(quoting filenames is the default).
+
+@item nosort
+Tell Readline not to sort the list of possible completions alphabetically.
+
@item nospace
Tell Readline not to append a space (the default) to words completed at
the end of the line.
@@ -1970,6 +2115,10 @@ used as the possible completions.
@item -F @var{function}
The shell function @var{function} is executed in the current shell
environment.
+When it is executed, $1 is the name of the command whose arguments are
+being completed, $2 is the word being completed, and $3 is the word
+preceding the word being completed, as described above
+(@pxref{Programmable Completion}).
When it finishes, the possible completions are retrieved from the value
of the @env{COMPREPLY} array variable.
@@ -2034,4 +2183,122 @@ specification exists, or an output error occurs.
@end table
+@node A Programmable Completion Example
+@section A Programmable Completion Example
+
+The most common way to obtain additional completion functionality beyond
+the default actions @code{complete} and @code{compgen} provide is to use
+a shell function and bind it to a particular command using @code{complete -F}.
+
+The following function provides completions for the @code{cd} builtin.
+It is a reasonably good example of what shell functions must do when
+used for completion. This function uses the word passsed as @code{$2}
+to determine the directory name to complete. You can also use the
+@code{COMP_WORDS} array variable; the current word is indexed by the
+@code{COMP_CWORD} variable.
+
+The function relies on the @code{complete} and @code{compgen} builtins
+to do much of the work, adding only the things that the Bash @code{cd}
+does beyond accepting basic directory names:
+tilde expansion (@pxref{Tilde Expansion}),
+searching directories in @var{$CDPATH}, which is described above
+(@pxref{Bourne Shell Builtins}),
+and basic support for the @code{cdable_vars} shell option
+(@pxref{The Shopt Builtin}).
+@code{_comp_cd} modifies the value of @var{IFS} so that it contains only
+a newline to accommodate file names containing spaces and tabs --
+@code{compgen} prints the possible completions it generates one per line.
+
+Possible completions go into the @var{COMPREPLY} array variable, one
+completion per array element. The programmable completion system retrieves
+the completions from there when the function returns.
+
+@example
+# A completion function for the cd builtin
+# based on the cd completion function from the bash_completion package
+_comp_cd()
+@{
+ local IFS=$' \t\n' # normalize IFS
+ local cur _skipdot _cdpath
+ local i j k
+
+ # Tilde expansion, with side effect of expanding tilde to full pathname
+ case "$2" in
+ \~*) eval cur="$2" ;;
+ *) cur=$2 ;;
+ esac
+
+ # no cdpath or absolute pathname -- straight directory completion
+ if [[ -z "$@{CDPATH:-@}" ]] || [[ "$cur" == @@(./*|../*|/*) ]]; then
+ # compgen prints paths one per line; could also use while loop
+ IFS=$'\n'
+ COMPREPLY=( $(compgen -d -- "$cur") )
+ IFS=$' \t\n'
+ # CDPATH+directories in the current directory if not in CDPATH
+ else
+ IFS=$'\n'
+ _skipdot=false
+ # preprocess CDPATH to convert null directory names to .
+ _cdpath=$@{CDPATH/#:/.:@}
+ _cdpath=$@{_cdpath//::/:.:@}
+ _cdpath=$@{_cdpath/%:/:.@}
+ for i in $@{_cdpath//:/$'\n'@}; do
+ if [[ $i -ef . ]]; then _skipdot=true; fi
+ k="$@{#COMPREPLY[@@]@}"
+ for j in $( compgen -d -- "$i/$cur" ); do
+ COMPREPLY[k++]=$@{j#$i/@} # cut off directory
+ done
+ done
+ $_skipdot || COMPREPLY+=( $(compgen -d -- "$cur") )
+ IFS=$' \t\n'
+ fi
+
+ # variable names if appropriate shell option set and no completions
+ if shopt -q cdable_vars && [[ $@{#COMPREPLY[@@]@} -eq 0 ]]; then
+ COMPREPLY=( $(compgen -v -- "$cur") )
+ fi
+
+ return 0
+@}
+@end example
+
+We install the completion function using the @option{-F} option to
+@code{complete}:
+
+@example
+# Tell readline to quote appropriate and append slashes to directories;
+# use the bash default completion for other arguments
+complete -o filenames -o nospace -o bashdefault -F _comp_cd cd
+@end example
+
+@noindent
+Since we'd like Bash and Readline to take care of some
+of the other details for us, we use several other options to tell Bash
+and Readline what to do. The @option{-o filenames} option tells Readline
+that the possible completions should be treated as filenames, and quoted
+appropriately. That option will also cause Readline to append a slash to
+filenames it can determine are directories (which is why we might want to
+extend @code{_comp_cd} to append a slash if we're using directories found
+via @var{CDPATH}: Readline can't tell those completions are directories).
+The @option{-o nospace} option tells Readline to not append a space
+character to the directory name, in case we want to append to it.
+The @option{-o bashdefault} option brings in the rest of the "Bash default"
+completions -- possible completion that Bash adds to the default Readline
+set. These include things like command name completion, variable completion
+for words beginning with @samp{@{}, completions containing pathname
+expansion patterns (@pxref{Filename Expansion}), and so on.
+
+Once installed using @code{complete}, @code{_comp_cd} will be called every
+time we attempt word completion for a @code{cd} command.
+
+Many more examples -- an extensive collection of completions for most of
+the common GNU, Unix, and Linux commands -- are available as part of the
+bash_completion project. This is installed by default on many GNU/Linux
+distributions. Originally written by Ian Macdonald, the project now lives
+at @url{http://bash-completion.alioth.debian.org/}. There are ports for
+other systems such as Solaris and Mac OS X.
+
+An older version of the bash_completion package is distributed with bash
+in the @file{examples/complete} subdirectory.
+
@end ifset
diff --git a/readline/doc/rluserman.texi b/readline/doc/rluserman.texi
index 3d54520..ba6b0ad 100644
--- a/readline/doc/rluserman.texi
+++ b/readline/doc/rluserman.texi
@@ -2,33 +2,25 @@
@comment %**start of header (This is for running Texinfo on a region.)
@setfilename rluserman.info
@settitle GNU Readline Library
-@comment %**end of header (This is for running Texinfo on a region.)
-
@include version.texi
+@comment %**end of header (This is for running Texinfo on a region.)
+
@copying
This manual describes the end user interface of the GNU Readline Library
(version @value{VERSION}, @value{UPDATED}), a library which aids in the
consistency of user interface across discrete programs which provide
a command line interface.
-Copyright @copyright{} 1988--2011 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
+Copyright @copyright{} 1988--2014 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
-Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
-and with the Back-Cover Texts as in (a) below. A copy of the license is
-included in the section entitled ``GNU Free Documentation License''.
-
-(a) The FSF's Back-Cover Text is: You are free to copy and modify
-this GNU manual. Buying copies from GNU Press supports the FSF in
-developing GNU and promoting software freedom.''
+Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+A copy of the license is included in the section entitled
+``GNU Free Documentation License''.
@end quotation
@end copying
@@ -49,12 +41,6 @@ developing GNU and promoting software freedom.''
@vskip 0pt plus 1filll
@insertcopying
-@sp 1
-Published by the Free Software Foundation @*
-59 Temple Place, Suite 330, @*
-Boston, MA 02111-1307 @*
-USA @*
-
@end titlepage
@contents
@@ -66,6 +52,7 @@ USA @*
This document describes the end user interface of the GNU Readline Library,
a utility which aids in the consistency of user interface across discrete
programs which provide a command line interface.
+The Readline home page is @url{http://www.gnu.org/software/readline/}.
@menu
* Command Line Editing:: GNU Readline User's Manual.
diff --git a/readline/doc/texi2dvi b/readline/doc/texi2dvi
index a9165a5..173e8ab 100755
--- a/readline/doc/texi2dvi
+++ b/readline/doc/texi2dvi
@@ -1,103 +1,95 @@
#! /bin/sh
-# texi2dvi --- produce DVI (or PDF) files from Texinfo (or LaTeX) sources.
-# $Id$
+# texi2dvi --- produce DVI (or PDF) files from Texinfo (or (La)TeX) sources.
+# $Id: texi2dvi 5704 2014-07-07 17:45:16Z karl $
#
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001,
-# 2002, 2003 Free Software Foundation, Inc.
+# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014
+# Free Software Foundation, Inc.
#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License,
+# or (at your option) any later version.
#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-# Original author: Noah Friedman <friedman@gnu.org>.
+# Originally written by Noah Friedman.
#
# Please send bug reports, etc. to bug-texinfo@gnu.org.
# If possible, please send a copy of the output of the script called with
# the `--debug' option when making a bug report.
-# This string is expanded by rcs automatically when this file is checked out.
-rcs_revision='$Revision$'
-rcs_version=`set - $rcs_revision; echo $2`
-program=`echo $0 | sed -e 's!.*/!!'`
-version="texi2dvi (GNU Texinfo 4.5) $rcs_version
-
-Copyright (C) 2003 Free Software Foundation, Inc.
-There is NO warranty. You may redistribute this software
-under the terms of the GNU General Public License.
-For more information about these matters, see the files named COPYING."
-
-usage="Usage: $program [OPTION]... FILE...
+test -f /bin/ksh && test -z "$RUNNING_KSH" \
+ && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \
+ && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; }
+unset RUNNING_KSH
-Run each Texinfo or LaTeX FILE through TeX in turn until all
-cross-references are resolved, building all indices. The directory
-containing each FILE is searched for included files. The suffix of FILE
-is used to determine its language (LaTeX or Texinfo).
+# No failure shall remain unpunished.
+set -e
-Makeinfo is used to perform Texinfo macro expansion before running TeX
-when needed.
+# In case the default sed doesn't suffice.
+: ${SED=sed}
-Operation modes:
- -b, --batch no interaction
- -c, --clean remove all auxiliary files
- -D, --debug turn on shell debugging (set -x)
- -h, --help display this help and exit successfully
- -o, --output=OFILE leave output in OFILE (implies --clean);
- Only one input FILE may be specified in this case
- -q, --quiet no output unless errors (implies --batch)
- -s, --silent same as --quiet
- -v, --version display version information and exit successfully
- -V, --verbose report on what is done
+# This string is expanded automatically when this file is checked out.
+rcs_revision='$Revision: 5704 $'
+rcs_version=`set - $rcs_revision; echo $2`
+program=`echo $0 | $SED -e 's!.*/!!'`
-TeX tuning:
- -@ use @input instead of \input; for preloaded Texinfo
- -e, -E, --expand force macro expansion using makeinfo
- -I DIR search DIR for Texinfo files
- -l, --language=LANG specify the LANG of FILE (LaTeX or Texinfo)
- -p, --pdf use pdftex or pdflatex for processing
- -t, --texinfo=CMD insert CMD after @setfilename in copy of input file
- multiple values accumulate
-
-The values of the BIBTEX, LATEX (or PDFLATEX), MAKEINDEX, MAKEINFO,
-TEX (or PDFTEX), and TEXINDEX environment variables are used to run
-those commands, if they are set.
-
-Email bug reports to <bug-texinfo@gnu.org>,
-general questions and discussion to <help-texinfo@gnu.org>.
-Texinfo home page: http://www.gnu.org/software/texinfo/"
+build_mode=${TEXI2DVI_BUILD_MODE:-local}
+build_dir=${TEXI2DVI_BUILD_DIRECTORY:-.}
# Initialize variables for option overriding and otherwise.
# Don't use `unset' since old bourne shells don't have this command.
# Instead, assign them an empty value.
-batch=false # eval for batch mode
-clean=
-debug=
-escape='\'
-expand= # t for expansion via makeinfo
-miincludes= # makeinfo include path
-oformat=dvi
+action=compile
+batch=false # interact normally
+catcode_special=maybe
+debug=false
+escape="\\"
+expand=false # true for expansion via makeinfo
+includes=
+line_error=true # pass --file-line-error to TeX
+max_iters=7 # when to quit
oname= # --output
-quiet= # by default let the tools' message be displayed
+out_lang=dvi
+quiet=false # let the tools' message be displayed
set_language=
-textra=
-tmpdir=${TMPDIR:-/tmp}/t2d$$ # avoid collisions on 8.3 filesystems.
-txincludes= # TEXINPUTS extensions, with trailing colon
-txiprereq=19990129 # minimum texinfo.tex version to have macro expansion
-verbose=false # echo for verbose mode
+src_specials=
+shell_escape=
+latex2html=hevea # or set to tex4ht
+textra= # Extra TeX commands to insert in the input file.
+txiprereq=19990129 # minimum texinfo.tex version with macro expansion
+verb=false # true for verbose mode
+translate_file= # name of charset translation file
orig_pwd=`pwd`
+# We have to initialize IFS to space tab newline since we save and
+# restore IFS and apparently POSIX allows stupid/broken behavior with
+# empty-but-set IFS.
+# http://lists.gnu.org/archive/html/automake-patches/2006-05/msg00008.html
+# We need space, tab and new line, in precisely that order. And don't leave
+# trailing blanks.
+space=' '
+tab=' '
+newline='
+'
+IFS="$space$tab$newline"
+
+# In case someone pedantic insists on using grep -E.
+: ${EGREP=egrep}
+
# Systems which define $COMSPEC or $ComSpec use semicolons to separate
-# directories in TEXINPUTS.
-if test -n "$COMSPEC$ComSpec"; then
+# directories in TEXINPUTS -- except for Cygwin et al., where COMSPEC
+# might be inherited, but : is used.
+if test -n "$COMSPEC$ComSpec" \
+ && uname | $EGREP -iv 'cygwin|mingw|djgpp' >/dev/null; then
path_sep=";"
else
path_sep=":"
@@ -106,14 +98,1537 @@ fi
# Pacify verbose cds.
CDPATH=${ZSH_VERSION+.}$path_sep
-# In case someone crazy insists on using grep -E.
-: ${EGREP=egrep}
+# If $TEX is set to a directory, don't use it.
+test -n "$TEX" && test -d "$TEX" && unset TEX
+
+#
+## --------------------- ##
+## Auxiliary functions. ##
+## --------------------- ##
+
+# In case `local' is not supported by the shell, provide a function
+# that simulates it by simply performing the assignments. This means
+# that we must not expect `local' to work, i.e., we must not (i) rely
+# on it during recursion, and (ii) have two local declarations of the
+# same variable. (ii) is easy to check statically, and our test suite
+# does make sure there is never twice a static local declaration of a
+# variable. (i) cannot be checked easily, so just be careful.
+#
+# Note that since we might use a function simulating `local', we can
+# no longer rely on the fact that no IFS-splitting is performed. So,
+# while
+#
+# foo=$bar
+#
+# is fine (no IFS-splitting), never write
+#
+# local foo=$bar
+#
+# but rather
+#
+# local foo="$bar"
+(
+ foo=bar
+ test_local () {
+ local foo=foo
+ }
+ test_local >/dev/null 2>&1
+ test $foo = bar
+) || eval '
+local () {
+ case $1 in
+ *=*) eval "$1";;
+ esac
+}
+'
+
+
+# cd_orig
+# -------
+# Return to the original directory.
+cd_orig ()
+{
+ # In case $orig_pwd is on a different drive (for DOS).
+ cd /
+
+ # Return to the original directory so that
+ # - the next file is processed in correct conditions
+ # - the temporary file can be removed
+ cd "$orig_pwd" || exit 1
+}
+
+# func_dirname FILE
+# -----------------
+# Return the directory part of FILE.
+func_dirname ()
+{
+ dirname "$1" 2>/dev/null \
+ || { echo "$1" | $SED 's!/[^/]*$!!;s!^$!.!'; }
+}
+
+
+# noexit FILE
+# -----------
+# Return FILE with one extension remove. foo.bar.baz -> foo.bar.
+noext ()
+{
+ echo "$1" | $SED -e 's/\.[^/.][^/.]*$//'
+}
+
+
+# absolute NAME -> ABS-NAME
+# -------------------------
+# Return an absolute path to NAME.
+absolute ()
+{
+ case $1 in
+ [\\/]* | ?:[\\/]*)
+ # Absolute paths don't need to be expanded.
+ echo "$1"
+ ;;
+ *) local slashes
+ slashes=`echo "$1" | $SED -n 's,.*[^/]\(/*\)$,\1,p'`
+ local rel
+ rel=$orig_pwd/`func_dirname "$1"`
+ if test -d "$rel"; then
+ (cd "$rel" 2>/dev/null \
+ && local n
+ n=`pwd`/`basename "$1"`"$slashes"
+ echo "$n")
+ else
+ error 1 "not a directory: $rel"
+ fi
+ ;;
+ esac
+}
+
+
+# ensure_dir DIR1 DIR2...
+# -----------------------
+# Make sure the directories exist.
+ensure_dir ()
+{
+ for dir
+ do
+ # Beware that in parallel builds we may have several concurrent
+ # attempts to create the directory. So fail only if "mkdir"
+ # failed *and* the directory still does not exist.
+ test -d "$dir" \
+ || mkdir "$dir" \
+ || test -d "$dir" \
+ || error 1 "cannot create directory: $dir"
+ done
+}
+
+
+# error EXIT_STATUS LINE1 LINE2...
+# --------------------------------
+# Report an error and exit with failure if EXIT_STATUS is non-null.
+error ()
+{
+ local s="$1"
+ shift
+ report "$@"
+ if test "$s" != 0; then
+ exit $s
+ fi
+}
+
+
+# findprog PROG
+# -------------
+# Return true if PROG is somewhere in PATH, else false.
+findprog ()
+{
+ local saveIFS="$IFS"
+ IFS=$path_sep # break path components at the path separator
+ for dir in $PATH; do
+ IFS=$saveIFS
+ # The basic test for an executable is `test -f $f && test -x $f'.
+ # (`test -x' is not enough, because it can also be true for directories.)
+ # We have to try this both for $1 and $1.exe.
+ #
+ # Note: On Cygwin and DJGPP, `test -x' also looks for .exe. On Cygwin,
+ # also `test -f' has this enhancement, but not on DJGPP. (Both are
+ # design decisions, so there is little chance to make them consistent.)
+ # Thusly, it seems to be difficult to make use of these enhancements.
+ #
+ if { test -f "$dir/$1" && test -x "$dir/$1"; } \
+ || { test -f "$dir/$1.exe" && test -x "$dir/$1.exe"; }; then
+ return 0
+ fi
+ done
+ return 1
+}
+
+# report LINE1 LINE2...
+# ---------------------
+# Report some information on stderr.
+report ()
+{
+ for i in "$@"
+ do
+ echo >&2 "$0: $i"
+ done
+}
+
+
+# run COMMAND-LINE
+# ----------------
+# Run the COMMAND-LINE verbosely, and catching errors as failures.
+run ()
+{
+ verbose "Running $@"
+ "$@" 2>&5 1>&2 \
+ || error 1 "$1 failed"
+}
+
+
+# usage
+# -----
+# Display usage and exit successfully.
+usage ()
+{
+ # We used to simply have `echo "$usage"', but coping with the
+ # changing behavior of `echo' is much harder than simply using a
+ # here-doc.
+ #
+ # echo '\noto' echo '\\noto' echo -e '\\noto'
+ # bash 3.1 \noto \\noto \noto
+ # bash 3.2 %oto \noto -e \noto
+ #
+ # where % denotes the eol character.
+ cat <<EOF
+Usage: $program [OPTION]... FILE...
+ or: texi2pdf [OPTION]... FILE...
+ or: pdftexi2dvi [OPTION]... FILE...
+
+Run each Texinfo or (La)TeX FILE through TeX in turn until all
+cross-references are resolved, building all indices. The directory
+containing each FILE is searched for included files. The suffix of FILE
+is used to determine its language ((La)TeX or Texinfo). To process
+(e)plain TeX files, set the environment variable LATEX=tex.
+
+In order to make texi2dvi a drop-in replacement of TeX/LaTeX in AUC-TeX,
+the FILE may also be composed of the following simple TeX commands.
+ \`\\input{FILE}' the actual file to compile
+ \`\\nonstopmode' same as --batch
+
+When invoked as \`texi2pdf' or \`pdftexi2dvi', or given the option --pdf
+or --dvipdf, generate PDF output. Otherwise, generate DVI.
+
+General options:
+ -b, --batch no interaction
+ -D, --debug turn on shell debugging (set -x)
+ -h, --help display this help and exit successfully
+ -o, --output=OFILE leave output in OFILE; only one input FILE is allowed
+ -q, --quiet no output unless errors (implies --batch)
+ -s, --silent same as --quiet
+ -v, --version display version information and exit successfully
+ -V, --verbose report on what is done
+
+Output format:
+ --dvi output a DVI file [default]
+ --dvipdf output a PDF file via DVI (using a dvi-to-pdf program)
+ --html output an HTML file from LaTeX, using HeVeA
+ --info output an Info file from LaTeX, using HeVeA
+ -p, --pdf use pdftex or pdflatex for processing
+ --ps output a PostScript file via DVI (using dvips)
+ --text output a plain text file from LaTeX, using HeVeA
+
+TeX tuning:
+ -@ use @input instead of \input for preloaded Texinfo
+ -e, -E, --expand force macro expansion using makeinfo
+ -I DIR search DIR for Texinfo files
+ -l, --language=LANG specify LANG for FILE, either latex or texinfo
+ --no-line-error do not pass --file-line-error to TeX
+ --shell-escape pass --shell-escape to TeX
+ --src-specials pass --src-specials to TeX
+ -t, --command=CMD insert CMD in copy of input file
+ or --texinfo=CMD multiple values accumulate
+ --translate-file=FILE use given charset translation file for TeX
+
+Build modes:
+ --build=MODE specify the treatment of auxiliary files [$build_mode]
+ --tidy same as --build=tidy
+ -c, --clean same as --build=clean
+ --build-dir=DIR specify where the tidy compilation is performed;
+ implies --tidy;
+ defaults to TEXI2DVI_BUILD_DIRECTORY [$build_dir]
+ --mostly-clean remove the auxiliary files and directories
+ but not the output
+ --max-iterations=N don't process files more than N times [$max_iters]
+
+The MODE specifies where the TeX compilation takes place, and, as a
+consequence, how auxiliary files are treated. The build mode
+can also be set using the environment variable TEXI2DVI_BUILD_MODE.
+
+Valid MODEs are:
+ \`local' compile in the current directory, leaving all the auxiliary
+ files around. This is the traditional TeX use.
+ \`tidy' compile in a local *.t2d directory, where the auxiliary files
+ are left. Output files are copied back to the original file.
+ \`clean' same as \`tidy', but remove the auxiliary directory afterwards.
+ Every compilation therefore requires the full cycle.
+
+Using the \`tidy' mode brings several advantages:
+ - the current directory is not cluttered with plethora of temporary files.
+ - clutter can be even further reduced using --build-dir=dir: all the *.t2d
+ directories are stored there.
+ - clutter can be reduced to zero using, e.g., --build-dir=/tmp/\$USER.t2d
+ or --build-dir=\$HOME/.t2d.
+ - the output file is updated after every successful TeX run, for
+ sake of concurrent visualization of the output. In a \`local' build
+ the viewer stops during the whole TeX run.
+ - if the compilation fails, the previous state of the output file
+ is preserved.
+ - PDF and DVI compilation are kept in separate subdirectories
+ preventing any possibility of auxiliary file incompatibility.
+
+On the other hand, because \`tidy' compilation takes place in another
+directory, occasionally TeX won't be able to find some files (e.g., when
+using \\graphicspath): in that case, use -I to specify the additional
+directories to consider.
+
+The values of the BIBER, BIBTEX, DVIPDF, DVIPS, HEVEA, LATEX, MAKEINDEX,
+MAKEINFO, PDFLATEX, PDFTEX, SED, T4HT, TEX, TEX4HT, TEXINDEX, and THUMBPDF_CMD
+environment variables are used to run those commands, if they are set.
+
+Regarding --dvipdf, if DVIPDF is not set in the environment, the
+following programs are looked for (in this order): dvipdfmx dvipdfm
+dvipdf dvi2pdf dvitopdf.
+
+Any CMD strings are added after @setfilename for Texinfo input, or in
+the first line for LaTeX input.
+
+Report bugs to bug-texinfo@gnu.org,
+general questions and discussion to help-texinfo@gnu.org.
+GNU Texinfo home page: <http://www.gnu.org/software/texinfo/>
+General help using GNU software: <http://www.gnu.org/gethelp/>
+EOF
+ exit 0
+}
+
+
+# verbose WORD1 WORD2
+# -------------------
+# Report some verbose information.
+verbose ()
+{
+ if $verb; then
+ echo >&2 "$0: $@"
+ fi
+}
+
+
+# version
+# -------
+# Display version info and exit successfully.
+version ()
+{
+ cat <<EOF
+texi2dvi (GNU Texinfo 5.2) $rcs_version
+
+Copyright (C) 2014 Free Software Foundation, Inc.
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
+EOF
+ exit 0
+}
+
+
+## ---------------- ##
+## Handling lists. ##
+## ---------------- ##
+
+
+# list_append LIST-NAME ELEM
+# --------------------------
+# Set LIST-NAME to its former contents, with ELEM appended.
+list_append ()
+{
+ local la_l="$1"
+ shift
+ eval set X \$$la_l "$@"
+ shift
+ eval $la_l=\""$@"\"
+}
+
+
+# list_concat_dirs LIST-NAME DIR-LIST
+# -----------------------------------
+# Append to LIST-NAME all the components (included empty) from
+# the $path_sep separated list DIR-LIST. Make the paths absolute.
+list_concat_dirs ()
+{
+ local lcd_list="$1"
+ # Empty path components are meaningful to tex. We rewrite them as
+ # `EMPTY' so they don't get lost when we split on $path_sep.
+ # Hopefully no one will have an actual directory named EMPTY.
+ local replace_EMPTY="-e 's/^$path_sep/EMPTY$path_sep/g' \
+ -e 's/$path_sep\$/${path_sep}EMPTY/g' \
+ -e 's/$path_sep$path_sep/${path_sep}EMPTY:/g'"
+ save_IFS=$IFS
+ IFS=$path_sep
+ set x `echo "$2" | eval $SED $replace_EMPTY`; shift
+ IFS=$save_IFS
+ local dir
+ for dir
+ do
+ case $dir in
+ EMPTY)
+ list_append $lcd_list ""
+ ;;
+ *)
+ if test -d $dir; then
+ dir=`absolute "$dir"`
+ list_append $lcd_list "$dir"
+ fi
+ ;;
+ esac
+ done
+}
+
+
+# list_prefix LIST-NAME SEP -> STRING
+# -----------------------------------
+# Return a string that is composed of the LIST-NAME with each item
+# preceded by SEP.
+list_prefix ()
+{
+ local lp_p="$2"
+ eval set X \$$1
+ shift
+ local lp_res
+ for i
+ do
+ lp_res="$lp_res \"$lp_p\" \"$i\""
+ done
+ echo "$lp_res"
+}
+
+# list_infix LIST-NAME SEP -> STRING
+# ----------------------------------
+# Same as list_prefix, but a separator.
+list_infix ()
+{
+ eval set X \$$1
+ shift
+ local la_IFS="$IFS"
+ IFS=$path_sep
+ echo "$*"
+ IFS=$la_IFS
+}
+
+# list_dir_to_abs LIST-NAME
+# -------------------------
+# Convert the list to using only absolute dir names.
+# Currently unused, but should replace absolute_filenames some day.
+list_dir_to_abs ()
+{
+ local ld_l="$1"
+ eval set X \$$ld_l
+ shift
+ local ld_res
+ for dir
+ do
+ dir=`absolute "$dir"`
+ test -d "$dir" || continue
+ ld_res="$ld_res \"$dir\""
+ done
+ set X $ld_res; shift
+ eval $ld_l=\"$@\"
+}
-# Save this so we can construct a new TEXINPUTS path for each file.
-TEXINPUTS_orig="$TEXINPUTS"
-# Unfortunately makeindex does not read TEXINPUTS.
-INDEXSTYLE_orig="$INDEXSTYLE"
-export TEXINPUTS INDEXSTYLE
+
+## ------------------------------ ##
+## Language auxiliary functions. ##
+## ------------------------------ ##
+
+
+# out_lang_set LANG
+# -----------------
+out_lang_set ()
+{
+ case $1 in
+ dvi|dvipdf|html|info|pdf|ps|text) out_lang=$1;;
+ *) error 1 "invalid output format: $1";;
+ esac
+}
+
+
+# out_lang_tex
+# ------------
+# Return the tex output language (DVI or PDF) for $OUT_LANG.
+out_lang_tex ()
+{
+ case $out_lang in
+ dvi | ps | dvipdf ) echo dvi;;
+ pdf ) echo $out_lang;;
+ html | info | text ) echo $out_lang;;
+ *) error 1 "invalid out_lang: $1";;
+ esac
+}
+
+
+# out_lang_ext
+# ------------
+# Return the extension for $OUT_LANG.
+out_lang_ext ()
+{
+ case $out_lang in
+ dvipdf ) echo pdf;;
+ dvi | html | info | pdf | ps | text ) echo $out_lang;;
+ *) error 1 "invalid out_lang: $1";;
+ esac
+}
+
+
+## ------------------------- ##
+## TeX auxiliary functions. ##
+## ------------------------- ##
+
+# Save TEXINPUTS so we can construct a new TEXINPUTS path for each file.
+# Likewise for bibtex and makeindex.
+tex_envvars="BIBINPUTS BSTINPUTS DVIPSHEADERS INDEXSTYLE MFINPUTS MPINPUTS \
+TEXINPUTS TFMFONTS"
+for var in $tex_envvars; do
+ eval ${var}_orig=\$$var
+ export $var
+done
+
+
+# absolute_filenames TEX-PATH -> TEX-PATH
+# ---------------------------------------
+# Convert relative paths to absolute paths, so we can run in another
+# directory (e.g., in tidy build mode, or during the macro-support
+# detection). Prepend ".".
+absolute_filenames ()
+{
+ # Empty path components are meaningful to tex. We rewrite them as
+ # `EMPTY' so they don't get lost when we split on $path_sep.
+ # Hopefully no one will have an actual directory named EMPTY.
+ local replace_empty="-e 's/^$path_sep/EMPTY$path_sep/g' \
+ -e 's/$path_sep\$/${path_sep}EMPTY/g' \
+ -e 's/$path_sep$path_sep/${path_sep}EMPTY:/g'"
+ local res
+ res=`echo "$1" | eval $SED $replace_empty`
+ save_IFS=$IFS
+ IFS=$path_sep
+ set x $res; shift
+ res=.
+ for dir
+ do
+ case $dir in
+ EMPTY)
+ res=$res$path_sep
+ ;;
+ *)
+ if test -d "$dir"; then
+ res=$res$path_sep`absolute "$dir"`
+ else
+ # Even if $dir is not a directory, preserve it in the path.
+ # It might contain metacharacters that TeX will expand in
+ # turn, e.g., /some/path/{a,b,c}. This will not get the
+ # implicit absolutification of the path, but we can't help that.
+ res=$res$path_sep$dir
+ fi
+ ;;
+ esac
+ done
+ echo "$res"
+}
+
+
+# output_base_name FILE
+# ---------------------
+# The name of FILE, possibly renamed to satisfy --output.
+# FILE is local, there is no directory part.
+output_base_name ()
+{
+ case $oname in
+ '') echo "$1";;
+ *) local out_noext
+ out_noext=`noext "$oname"`
+ local file_ext
+ file_ext=`echo "$1" | $SED 's/^.*\.//'`
+ echo "$out_noext.$file_ext"
+ ;;
+ esac
+}
+
+
+# destdir
+# -------
+# Return the name of the directory where the output is expected.
+destdir ()
+{
+ case $oname in
+ '') echo "$orig_pwd";;
+ *) dirname "$oname";;
+ esac
+}
+
+
+# move_to_dest FILE...
+# --------------------
+# Move FILE to the place where the user expects it. Truly move it, that
+# is, it must not remain in its build location unless that is also the
+# output location. (Otherwise it might appear as an extra file in make
+# distcheck.)
+#
+# FILE can be the principal output (in which case -o directly applies), or
+# an auxiliary file with the same base name.
+move_to_dest ()
+{
+# echo "move_to_dest $*, tidy=$tidy, oname=$oname"
+
+ # If we built in place and have no output name, there is nothing to
+ # do, so just return.
+ case $tidy:$oname in
+ false:) return;;
+ esac
+
+ local destfile
+ local destdir
+ local destbase
+ local sourcedir
+ local sourcebase
+
+ for file
+ do
+ test -f "$file" \
+ || error 1 "no such file or directory: $file"
+ case $tidy:$oname in
+ true:) destdir=$orig_pwd
+ destfile=$destdir/$file;;
+ true:*) destfile=`output_base_name "$file"`
+ destdir=`dirname "$destfile"`;;
+ false:*) destfile=$oname
+ destdir=`dirname "$destfile"`;;
+ esac
+
+ # We want to compare the source location and the output location,
+ # and if they are different, do the move. But if they are the
+ # same, we must preserve the source. Since we can't assume
+ # stat(1) or test -ef is available, resort to comparing the
+ # directory names, canonicalized with pwd. We can't use cmp -s
+ # since the output file might not actually change from run to run;
+ # e.g., TeX DVI output is timestamped to only the nearest minute.
+ destdir=`cd "$destdir" && pwd`
+ destbase=`basename "$destfile"`
+
+ sourcedir=`dirname "$file"`
+ sourcedir=`cd "$sourcedir" && pwd`
+ sourcebase=`basename "$file"`
+
+ if test "$sourcedir/$sourcebase" != "$destdir/$destbase"; then
+ verbose "Moving $file to $destfile"
+ rm -f "$destfile"
+ mv "$file" "$destfile"
+ fi
+ done
+}
+
+
+## --------------------- ##
+## Managing xref files. ##
+## --------------------- ##
+
+# aux_file_p FILE
+# ---------------
+# Return with success if FILE is an aux file.
+aux_file_p ()
+{
+ test -f "$1" || return 1
+ case $1 in
+ *.aux) return 0;;
+ *) return 1;;
+ esac
+}
+
+# bibaux_file_p FILE
+# ------------------
+# Return with success if FILE is an aux file containing citation
+# requests.
+bibaux_file_p ()
+{
+ test -s "$1" || return 1
+ if (grep '^\\bibstyle[{]' "$1" \
+ && grep '^\\bibdata[{]' "$1" \
+ ## The following line is suspicious: fails when there
+ ## are citations in sub aux files. We need to be
+ ## smarter in this case.
+ ## && grep '^\\citation[{]' "$f"
+ ) >&6 2>&1;
+ then
+ return 0
+ fi
+ return 1
+}
+
+# index_file_p FILE
+# -----------------
+# Return with success if FILE is an index file.
+index_file_p ()
+{
+ test -f "$1" || return 1
+ case $in_lang:$latex2html:`out_lang_tex`:`$SED '1q' "$1"` in
+ # When working with TeX4HT, *.idx are created by LaTeX. They must
+ # be processed to produce *.4ix, *.4dx files. The *.4dx file is
+ # passed to makeindex to produce the *.ind file. This sequence is
+ # handled by run_index, so we are only interested in the *.idx
+ # files, which have each "\indexentry" preceded by a
+ # "\beforeentry".
+ latex:tex4ht:html:"\\beforeentry {"*) return 0;;
+
+ # When index.sty is used, there is a space before the brace.
+ latex:*:*:"\\indexentry{"*|latex:*:*:"\\indexentry {"*) return 0;;
+
+ texinfo:*:*:"\\entry{"*) return 0;;
+
+ *) return 1;;
+ esac
+}
+
+# xref_file_p FILE
+# ----------------
+# Return with success if FILE is an xref file (indexes, tables and lists).
+xref_file_p ()
+{
+ test -f "$1" || return 1
+ # If the file is not suitable to be an index or xref file, don't
+ # process it. It's suitable if the first character is a
+ # backslash or right quote or at, as long as the first line isn't
+ # \input texinfo.
+ case `$SED '1q' "$1"` in
+ "\\input texinfo"*) return 1;;
+ [\\''@]*) return 0;;
+ *) return 1;;
+ esac
+}
+
+
+# generated_files_get FILENAME-NOEXT [PREDICATE-FILTER]
+# -----------------------------------------------------
+# Return the list of files generated by the TeX compilation of FILENAME-NOEXT.
+generated_files_get ()
+{
+ local filter=true
+ if test -n "$2"; then
+ filter=$2
+ fi
+
+ # Gather the files created by TeX.
+ (
+ if test -f "$1.log"; then
+ $SED -n -e "s,^\\\\openout.* = \`\\(.*\\)'\\.,\\1,p" "$1.log"
+ fi
+ echo "$1.log"
+ ) |
+ # Depending on these files, infer outputs from other tools.
+ while read file; do
+ echo $file
+ case $in_lang in
+ texinfo)
+ # texindex: texinfo.cp -> texinfo.cps
+ if index_file_p $file; then
+ echo ${file}s
+ fi
+ ;;
+ latex)
+ if aux_file_p $file; then
+ # bibtex: *.aux -> *.bbl and *.blg.
+ echo $file | $SED 's/^\(.*\)\.aux$/\1.bbl/'
+ echo $file | $SED 's/^\(.*\)\.aux$/\1.blg/'
+ # -recorder: .fls
+ echo $file | $SED 's/^\(.*\)\.aux$/\1.fls/'
+ fi
+ ;;
+ esac
+ done |
+ # Filter existing files matching the criterion.
+ #
+ # With an input file name containing a space, this produces a
+ # "command not found" message (and filtering is ineffective).
+ # The situation with a newline is presumably even worse.
+ while read file; do
+ if $filter "$file"; then
+ echo $file
+ fi
+ done |
+ sort |
+ # Some files are opened several times, e.g., listings.sty's *.vrb.
+ uniq
+}
+
+
+# xref_files_save
+# ---------------
+# Save the xref files.
+xref_files_save ()
+{
+ # Save copies of auxiliary files for later comparison.
+ xref_files_orig=`generated_files_get "$in_noext" xref_file_p`
+ if test -n "$xref_files_orig"; then
+ verbose "Backing up xref files: $xref_files_orig"
+ # The following line improves `cp $xref_files_orig "$work_bak"'
+ # by preserving the directory parts. Think of
+ # cp chap1/main.aux chap2/main.aux $work_bak.
+ #
+ # Users may have, e.g., --keep-old-files. Don't let this interfere.
+ # (Don't use unset for the sake of ancient shells.)
+ TAR_OPTIONS=; export TAR_OPTIONS
+ tar cf - $xref_files_orig | (cd "$work_bak" && tar xf -)
+ fi
+}
+
+
+# xref_files_changed
+# ------------------
+# Whether the xref files were changed since the previous run.
+xref_files_changed ()
+{
+ # LaTeX (and the package changebar) report in the LOG file if it
+ # should be rerun. This is needed for files included from
+ # subdirs, since texi2dvi does not try to compare xref files in
+ # subdirs. Performing xref files test is still good since LaTeX
+ # does not report changes in xref files.
+ if grep "Rerun to get" "$in_noext.log" >&6 2>&1; then
+ return 0
+ fi
+ # biblatex report of whether rerunning is needed.
+ if grep "biblatex.*(re)run" "$in_noext.log" >&6 2>&1; then
+ return 0
+ fi
+
+ # If old and new lists don't have the same file list,
+ # then something has definitely changed.
+ xref_files_new=`generated_files_get "$in_noext" xref_file_p`
+ verbose "Original xref files = $xref_files_orig"
+ verbose "New xref files = $xref_files_new"
+ if test "x$xref_files_orig" != "x$xref_files_new"; then
+ return 0
+ fi
+
+ # Compare each file until we find a difference.
+ for this_file in $xref_files_new; do
+ verbose "Comparing xref file `echo $this_file | $SED 's|\./||g'` ..."
+ # cmp -s returns nonzero exit status if files differ.
+ if cmp -s "$this_file" "$work_bak/$this_file"; then :; else
+ verbose "xref file `echo $this_file | $SED 's|\./||g'` differed ..."
+ if $debug; then
+ diff -u "$work_bak/$this_file" "$this_file"
+ fi
+ return 0
+ fi
+ done
+
+ # No change.
+ return 1
+}
+
+
+
+## ----------------------- ##
+## Running the TeX suite. ##
+## ----------------------- ##
+
+
+
+# run_tex ()
+# ----------
+# Run TeX as "$tex $in_input", taking care of errors and logs.
+run_tex ()
+{
+ case $in_lang:$latex2html:`out_lang_tex` in
+ latex:*:dvi|latex:tex4ht:html)
+ tex=${LATEX:-latex};;
+ latex:*:pdf)
+ tex=${PDFLATEX:-pdflatex};;
+ texinfo:*:dvi)
+ # MetaPost also uses the TEX environment variable. If the user
+ # has set TEX=latex for that reason, don't bomb out.
+ case $TEX in
+ *latex) tex=tex;; # don't bother trying to find etex
+ *) tex=$TEX
+ esac;;
+ texinfo:*:pdf) tex=$PDFTEX;;
+
+ *) error 1 "$out_lang not supported for $in_lang";;
+ esac
+
+ # do the special catcode trick for ~ in filenames only for Texinfo,
+ # not LaTeX.
+ if test x"$in_lang" = xtexinfo && test $catcode_special = maybe; then
+ catcode_special=true
+ else
+ catcode_special=false
+ fi
+
+ # Beware of aux files in subdirectories that require the
+ # subdirectory to exist.
+ case $in_lang:$tidy in
+ latex:true)
+ $SED -n 's|^[ ]*\\include{\(.*\)/.*}.*|\1|p' "$in_input" |
+ sort -u |
+ while read d
+ do
+ ensure_dir "$work_build/$d"
+ done
+ ;;
+ esac
+
+ # Note that this will be used via an eval: quote properly.
+ local cmd="$tex"
+
+ # If possible, make TeX report error locations in GNU format.
+ if $line_error; then
+ if test "${tex_help:+set}" != set; then
+ # Go to a temporary directory to try --help, since old versions that
+ # don't accept --help will generate a texput.log.
+ tex_help_dir=$t2ddir/tex_help
+ ensure_dir "$tex_help_dir"
+ tex_help=`cd "$tex_help_dir" >&6 && $tex --help </dev/null 2>&1 || true`
+ fi
+ # The mk program and perhaps others want to parse TeX's
+ # original error messages.
+ case $tex_help in
+ *file-line-error*) cmd="$cmd --file-line-error";;
+ esac
+ fi
+
+ # Tell TeX about TCX file, if specified.
+ test -n "$translate_file" && cmd="$cmd --translate-file=$translate_file"
+
+ # Tell TeX to make source specials (for backtracking from output to
+ # source, given a sufficiently smart editor), if specified.
+ test -n "$src_specials" && cmd="$cmd $src_specials"
+
+ # Tell TeX to allow running external executables
+ test -n "$shell_escape" && cmd="$cmd $shell_escape"
+
+ # Tell TeX to be batch if requested.
+ if $batch; then
+ # \batchmode does not show terminal output at all, so we don't
+ # want that. And even in batch mode, TeX insists on having input
+ # from the user. Close its stdin to make it impossible.
+ cmd="$cmd </dev/null '${escape}nonstopmode'"
+ fi
+
+ # we'd like to handle arbitrary input file names, especially
+ # foo~bar/a~b.tex, since Debian likes ~ characters.
+ if $catcode_special; then
+ # $normaltilde is just to reduce line length in this source file.
+ # The idea is to define \normaltilde as a catcode other ~ character,
+ # then make the active ~ be equivalent to that, instead of the plain
+ # TeX tie. Then when the active ~ appears in the filename, it will
+ # be expanded to itself, as far as \input will see. (This is the
+ # same thing that texinfo.tex does in general, BTW.)
+ normaltilde="${escape}catcode126=12 ${escape}def${escape}normaltilde{~}"
+ cmd="$cmd '$normaltilde${escape}catcode126=13 ${escape}let~\normaltilde '"
+ fi
+ # Other special (non-active) characters could be supported by
+ # resetting their catcodes to other on the command line and changing
+ # texinfo.tex to initialize everything to plain catcodes. Maybe someday.
+
+ # append the \input command.
+ cmd="$cmd '${escape}input'"
+
+ # TeX's \input does not (easily or reliably) support whitespace
+ # characters or other special characters in file names. Our intensive
+ # use of absolute file names makes this worse: the enclosing directory
+ # names may include white spaces. Improve the situation using a
+ # symbolic link to the filename in the current directory, in tidy mode
+ # only. Do not alter in_input.
+ #
+ # The filename is almost always tokenized using plain TeX conventions
+ # (the exception would be if the user made a texinfo.fmt file). Not
+ # all the plain TeX special characters cause trouble, but there's no
+ # harm in making the link.
+ #
+ case $tidy:`func_dirname "$in_input"` in
+ true:*["$space$tab$newline\"#\$%\\^_{}~"]*)
+ _run_tex_file_name=`basename "$in_input"`
+ if test ! -f "$_run_tex_file_name"; then
+ # It might not be a file, clear it.
+ run rm -f "$_run_tex_file_name"
+ run ln -s "$in_input"
+ fi
+ cmd="$cmd '$_run_tex_file_name'"
+ ;;
+
+ *)
+ cmd="$cmd '$in_input'"
+ ;;
+ esac
+
+ verbose "$0: Running $cmd ..."
+ if eval "$cmd" >&5; then
+ case $out_lang in
+ dvi | pdf ) move_to_dest "$in_noext.$out_lang";;
+ esac
+ else
+ error 1 "$tex exited with bad status, quitting."
+ fi
+}
+
+# run_bibtex ()
+# -------------
+# Run bibtex on (or biber) current file.
+# - If its input (AUX) exists.
+# - If some citations are missing (LOG contains `Citation').
+# or the LOG complains of a missing .bbl
+#
+# Don't try to be too smart:
+# 1. Running bibtex only if the bbl file exists and is older than
+# the LaTeX file is wrong, since the document might include files
+# that have changed.
+#
+# 3. Because there can be several AUX (if there are \include's),
+# but a single LOG, looking for missing citations in LOG is
+# easier, though we take the risk of matching false messages.
+run_bibtex ()
+{
+ case $in_lang in
+ latex) bibtex=${BIBTEX:-bibtex};;
+ texinfo) return;;
+ esac
+
+ # "Citation undefined" is for LaTeX, "Undefined citation" for btxmac.tex.
+ # The no .aux && \bibdata test is also for btxmac, in case it was the
+ # first run of a bibtex-using document. Otherwise, it's possible that
+ # bibtex would never be run.
+ if test -r "$in_noext.aux" \
+ && test -r "$in_noext.log" \
+ && ( (grep 'Warning:.*Citation.*undefined' "$in_noext.log" \
+ || grep '.*Undefined citation' "$in_noext.log" \
+ || grep 'No file .*\.bbl\.' "$in_noext.log") \
+ || (grep 'No \.aux file' "$in_noext.log" \
+ && grep '^\\bibdata' "$in_noext.aux") ) \
+ >&6 2>&1; \
+ then
+ bibtex_aux=`generated_files_get "$in_noext" bibaux_file_p`
+ for f in $bibtex_aux; do
+ run $bibtex "$f"
+ done
+ fi
+
+ # biber(+biblatex) check.
+ if test -r "$in_noext.bcf" \
+ && grep '</bcf:controlfile>' "$in_noext.bcf" >/dev/null; then
+ run ${BIBER:-biber} "$in_noext"
+ fi
+}
+
+# run_index ()
+# ------------
+# Run texindex (or makeindex or texindy) on current index files. If
+# they already exist, and after running TeX a first time the index
+# files don't change, then there's no reason to run TeX again. But we
+# won't know that if the index files are out of date or nonexistent.
+run_index ()
+{
+ local index_files
+ index_files=`generated_files_get $in_noext index_file_p`
+ test -n "$index_files" \
+ || return 0
+
+ : ${MAKEINDEX:=makeindex}
+ : ${TEXINDEX:=texindex}
+ : ${TEXINDY:=texindy}
+
+ local index_file
+ local index_noext
+ case $in_lang:$latex2html:`out_lang_tex` in
+ latex:tex4ht:html)
+ for index_file in $index_files
+ do
+ index_noext=`noext "$index_file"`
+ run tex \
+ '\def\filename{{'"$index_noext"'}{idx}{4dx}{ind}}
+ \input idxmake.4ht'
+ run $MAKEINDEX -o $index_noext.ind $index_noext.4dx
+ done
+ ;;
+
+ latex:*)
+ if $TEXINDY --version >&6 2>&1; then
+ run $TEXINDY $index_files
+ else
+ run $MAKEINDEX $index_files
+ fi
+ ;;
+
+ texinfo:*)
+ run $TEXINDEX $index_files
+ ;;
+ esac
+}
+
+
+# run_tex4ht ()
+# -------------
+# Run the last two phases of TeX4HT: tex4ht extracts the HTML from the
+# instrumented DVI file, and t4ht converts the figures and installs
+# the files when given -d.
+#
+# Because knowing exactly which files are created is complex (in
+# addition the names are not simple to compute), which makes it
+# difficult to install the output files in a second step, it is much
+# simpler to install directly the output files.
+run_tex4ht ()
+{
+ case $in_lang:$latex2html:`out_lang_tex` in
+ latex:tex4ht:html)
+ : ${TEX4HT:=tex4ht} ${T4HT:=t4ht}
+ run "$TEX4HT" "-f/$in_noext"
+ # Do not remove the / after the destdir.
+ run "$T4HT" "-d`destdir`/" "-f/$in_noext"
+ ;;
+ esac
+}
+
+
+# run_thumbpdf ()
+# ---------------
+run_thumbpdf ()
+{
+ if test `out_lang_tex` = pdf \
+ && test -r "$in_noext.log" \
+ && grep 'thumbpdf\.sty' "$in_noext.log" >&6 2>&1; \
+ then
+ thumbpdf=${THUMBPDF_CMD:-thumbpdf}
+ thumbcmd="$thumbpdf $in_dir/$in_noext"
+ verbose "Running $thumbcmd ..."
+ if $thumbcmd >&5; then
+ run_tex
+ else
+ report "$thumbpdf exited with bad status." \
+ "Ignoring its output."
+ fi
+ fi
+}
+
+
+# run_dvipdf FILE.dvi
+# -------------------
+# Convert FILE.dvi to FILE.pdf.
+run_dvipdf ()
+{
+ # Find which dvi->pdf program is available.
+ if test -z "$dvipdf"; then
+ for i in "$DVIPDF" dvipdfmx dvipdfm dvipdf dvi2pdf dvitopdf; do
+ if findprog $i; then
+ dvipdf=$i
+ fi
+ done
+ fi
+ # These tools have varying interfaces, some 'input output', others
+ # 'input -o output'. They all seem to accept 'input' only,
+ # outputting using the expected file name.
+ run $dvipdf "$1"
+ if test ! -f `echo "$1" | $SED -e 's/\.dvi$/.pdf/'`; then
+ error 1 "cannot find output file"
+ fi
+}
+
+# run_tex_suite ()
+# ----------------
+# Run the TeX tools until a fix point is reached.
+run_tex_suite ()
+{
+ # Move to the working directory.
+ if $tidy; then
+ verbose "cd $work_build"
+ cd "$work_build" || exit 1
+ fi
+
+ # Count the number of cycles.
+ local cycle=0
+
+ while :; do
+ # check for probably LaTeX loop (e.g. varioref)
+ if test $cycle -eq "$max_iters"; then
+ error 0 "Maximum of $max_iters cycles exceeded"
+ break
+ fi
+
+ # report progress
+ cycle=`expr $cycle + 1`
+ verbose "Cycle $cycle for $command_line_filename"
+
+ xref_files_save
+
+ # We run bibtex first, because it's more likely for the indexes
+ # to change after bibtex is run than the reverse, though either
+ # would be rare.
+ run_bibtex
+ run_index
+ run_core_conversion
+
+ xref_files_changed || break
+ done
+
+ # If we were using thumbpdf and producing PDF, then run thumbpdf
+ # and TeX one last time.
+ run_thumbpdf
+
+ # If we are using tex4ht, call it.
+ run_tex4ht
+
+ # Install the result if we didn't already (i.e., if the output is
+ # dvipdf or ps).
+ case $latex2html:$out_lang in
+ *:dvipdf)
+ run_dvipdf "$in_noext.`out_lang_tex`"
+ move_to_dest "$in_noext.`out_lang_ext`"
+ ;;
+ *:ps)
+ : ${DVIPS:=dvips}
+ run $DVIPS -o "$in_noext.`out_lang_ext`" "$in_noext.`out_lang_tex`"
+ move_to_dest "$in_noext.`out_lang_ext`"
+ ;;
+ esac
+
+ cd_orig
+}
+
+## -------------------------------- ##
+## TeX processing auxiliary tools. ##
+## -------------------------------- ##
+
+
+# A sed script that preprocesses Texinfo sources in order to keep the
+# iftex sections only. We want to remove non-TeX sections, and comment
+# (with `@c _texi2dvi') TeX sections so that makeinfo does not try to
+# parse them. Nevertheless, while commenting TeX sections, don't
+# comment @macro/@end macro so that makeinfo does propagate them.
+# Unfortunately makeinfo --iftex --no-ifinfo doesn't work well enough
+# (yet), makeinfo can't parse the TeX commands, so work around with sed.
+#
+# We assume that `@c _texi2dvi' starting a line is not present in the
+# document.
+#
+comment_iftex=\
+'/^@tex/,/^@end tex/{
+ s/^/@c _texi2dvi/
+}
+/^@iftex/,/^@end iftex/{
+ s/^/@c _texi2dvi/
+ /^@c _texi2dvi@macro/,/^@c _texi2dvi@end macro/{
+ s/^@c _texi2dvi//
+ }
+}
+/^@ifnottex/,/^@end ifnottex/{
+ s/^/@c (_texi2dvi)/
+}
+/^@ifinfo/,/^@end ifinfo/{
+ /^@node/p
+ /^@menu/,/^@end menu/p
+ t
+ s/^/@c (_texi2dvi)/
+}
+s/^@ifnotinfo/@c _texi2dvi@ifnotinfo/
+s/^@end ifnotinfo/@c _texi2dvi@end ifnotinfo/'
+
+# Uncommenting is simpler: remove any leading `@c texi2dvi'; repeated
+# copies can sneak in via macro invocations.
+uncomment_iftex='s/^@c _texi2dvi\(@c _texi2dvi\)*//'
+
+
+# run_makeinfo ()
+# ---------------
+# Expand macro commands in the original source file using Makeinfo.
+# Always use `end' footnote style, since the `separate' style
+# generates different output (arguably this is a bug in -E). Discard
+# main info output, the user asked to run TeX, not makeinfo.
+run_makeinfo ()
+{
+ test $in_lang = texinfo \
+ || return 0
+
+ # Unless required by the user, makeinfo expansion is wanted only
+ # if texinfo.tex is too old.
+ if $expand; then
+ makeinfo=${MAKEINFO:-makeinfo}
+ else
+ # Check if texinfo.tex performs macro expansion by looking for
+ # its version. The version is a date of the form YEAR-MO-DA.
+ # We don't need to use [0-9] to match the digits since anyway
+ # the comparison with $txiprereq, a number, will fail with non-digits.
+ # Run in a temporary directory to avoid leaving files.
+ version_test_dir=$t2ddir/version_test
+ ensure_dir "$version_test_dir"
+ if (
+ cd "$version_test_dir"
+ echo '\input texinfo.tex @bye' >txiversion.tex
+ # Be sure that if tex wants to fail, it is not interactive:
+ # close stdin.
+ $TEX txiversion.tex </dev/null >txiversion.out 2>txiversion.err
+ ); then :; else
+ report "texinfo.tex appears to be broken.
+This may be due to the environment variable TEX set to something
+other than (plain) tex, a corrupt texinfo.tex file, or
+to tex itself simply not working."
+ cat "$version_test_dir/txiversion.out"
+ cat "$version_test_dir/txiversion.err" >&2
+ error 1 "quitting."
+ fi
+ eval `$SED -n 's/^.*\[\(.*\)version \(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p' "$version_test_dir/txiversion.out"`
+ verbose "texinfo.tex preloaded as \`$txiformat', version is \`$txiversion' ..."
+ if test "$txiprereq" -le "$txiversion" >&6 2>&1; then
+ makeinfo=
+ else
+ makeinfo=${MAKEINFO:-makeinfo}
+ fi
+ # If TeX is preloaded, offer the user this convenience:
+ if test "$txiformat" = Texinfo; then
+ escape=@
+ fi
+ fi
+
+ if test -n "$makeinfo"; then
+ # in_src: the file with macros expanded.
+ # Use the same basename to generate the same aux file names.
+ work_src=$workdir/src
+ ensure_dir "$work_src"
+ in_src=$work_src/$in_base
+ local miincludes
+ miincludes=`list_prefix includes -I`
+ verbose "Macro-expanding $command_line_filename to $in_src ..."
+ # eval $makeinfo because it might be defined as something complex
+ # (running missing) and then we end up with things like '"-I"',
+ # and "-I" (including the quotes) is not an option name. This
+ # happens with gettext 0.14.5, at least.
+ $SED "$comment_iftex" "$command_line_filename" \
+ | eval $makeinfo --footnote-style=end -I "$in_dir" $miincludes \
+ -o /dev/null --macro-expand=- \
+ | $SED "$uncomment_iftex" >"$in_src"
+ # Continue only if everything succeeded.
+ if test $? -ne 0 \
+ || test ! -r "$in_src"; then
+ verbose "Expansion failed, ignored...";
+ else
+ in_input=$in_src
+ fi
+ fi
+}
+
+# insert_commands ()
+# ------------------
+# Used most commonly for @finalout, @smallbook, etc.
+insert_commands ()
+{
+ if test -n "$textra"; then
+ # _xtr. The file with the user's extra commands.
+ work_xtr=$workdir/xtr
+ in_xtr=$work_xtr/$in_base
+ ensure_dir "$work_xtr"
+ verbose "Inserting extra commands: $textra"
+ local textra_cmd
+ case $in_lang in
+ latex) textra_cmd=1i;;
+ texinfo) textra_cmd='/^@setfilename/a';;
+ *) error 1 "internal error, unknown language: $in_lang";;
+ esac
+ $SED "$textra_cmd\\
+$textra" "$in_input" >"$in_xtr"
+ in_input=$in_xtr
+ fi
+
+ case $in_lang:$latex2html:`out_lang_tex` in
+ latex:tex4ht:html)
+ # _tex4ht. The file with the added \usepackage{tex4ht}.
+ work_tex4ht=$workdir/tex4ht
+ in_tex4ht=$work_tex4ht/$in_base
+ ensure_dir "$work_tex4ht"
+ verbose "Inserting \\usepackage{tex4ht}"
+ perl -pe 's<\\documentclass(?:\[.*\])?{.*}>
+ <$&\\usepackage[xhtml]{tex4ht}>' \
+ "$in_input" >"$in_tex4ht"
+ in_input=$in_tex4ht
+ ;;
+ esac
+}
+
+# compute_language FILENAME
+# -------------------------
+# Return the short string describing the language in which FILENAME
+# is written: `texinfo' or `latex'.
+compute_language ()
+{
+ # If the user explicitly specified the language, use that.
+ # Otherwise, if the first line is \input texinfo, assume it's texinfo.
+ # Otherwise, guess from the file extension.
+ if test -n "$set_language"; then
+ echo $set_language
+ elif $SED 1q "$1" | grep 'input texinfo' >&6; then
+ echo texinfo
+ else
+ # Get the type of the file (latex or texinfo) from the given language
+ # we just guessed, or from the file extension if not set yet.
+ case $1 in
+ *.ltx | *.tex | *.drv | *.dtx) echo latex;;
+ *) echo texinfo;;
+ esac
+ fi
+}
+
+
+# run_hevea (MODE)
+# ----------------
+# Convert to HTML/INFO/TEXT.
+#
+# Don't pass `-noiso' to hevea: it's useless in HTML since anyway the
+# charset is set to latin1, and troublesome in other modes since
+# accented characters loose their accents.
+#
+# Don't pass `-o DEST' to hevea because in that case it leaves all its
+# auxiliary files there too... Too bad, because it means we will need
+# to handle images some day.
+run_hevea ()
+{
+ local hevea="${HEVEA:-hevea}"
+ local run_hevea="$hevea"
+
+ case $1 in
+ html) ;;
+ text|info) run_hevea="$run_hevea -$1";;
+ *) error 1 "run_hevea: invalid argument: $1";;
+ esac
+
+ # Compiling to the tmp directory enables to preserve a previous
+ # successful compilation.
+ run_hevea="$run_hevea -fix -O -o '$out_base'"
+ run_hevea="$run_hevea `list_prefix includes -I` -I '$orig_pwd' "
+ run_hevea="$run_hevea '$in_input'"
+
+ if $debug; then
+ run_hevea="$run_hevea -v -v"
+ fi
+
+ verbose "running $run_hevea"
+ if eval "$run_hevea" >&5; then
+ # hevea leaves trailing white spaces, this is annoying.
+ case $1 in text|info)
+ perl -pi -e 's/[ \t]+$//g' "$out_base"*;;
+ esac
+ case $1 in
+ html|text) move_to_dest "$out_base";;
+ info) # There can be foo.info-1, foo.info-2 etc.
+ move_to_dest "$out_base"*;;
+ esac
+ else
+ error 1 "$hevea exited with bad status, quitting."
+ fi
+}
+
+
+# run_core_conversion ()
+# ----------------------
+# Run the TeX (or HeVeA).
+run_core_conversion ()
+{
+ case $in_lang:$latex2html:`out_lang_tex` in
+ *:dvi|*:pdf|latex:tex4ht:html)
+ run_tex;;
+ latex:*:html|latex:*:text|latex:*:info)
+ run_hevea $out_lang;;
+ *)
+ error 1 "invalid input/output combination: $in_lang/$out_lang";;
+ esac
+}
+
+
+# compile ()
+# ----------
+# Run the full compilation chain, from pre-processing to installation
+# of the output at its expected location.
+compile ()
+{
+ # Source file might include additional sources.
+ # We want `.:$orig_pwd' before anything else. (We'll add `.:' later
+ # after all other directories have been turned into absolute paths.)
+ # `.' goes first to ensure that any old .aux, .cps,
+ # etc. files in ${directory} don't get used in preference to fresher
+ # files in `.'. Include orig_pwd in case we are in clean build mode, where
+ # we have cd'd to a temp directory.
+ common="$orig_pwd$path_sep$in_dir$path_sep"
+ #
+ # If we have any includes, put those at the end.
+ # Keep a final path_sep to get the default (system) TeX directories included.
+ txincludes=`list_infix includes $path_sep`
+ test -n "$txincludes" && common="$common$txincludes$path_sep"
+ #
+ for var in $tex_envvars; do
+ eval val="\$common\$${var}_orig"
+ # Convert relative paths to absolute paths, so we can run in another
+ # directory (e.g., in clean build mode, or during the macro-support
+ # detection). ".:" is added here.
+ val=`absolute_filenames "$val"`
+ eval $var="\"$val\""
+ export $var
+ eval verbose \"$var=\'\$${var}\'\"
+ done
+
+ # --expand
+ run_makeinfo
+
+ # --command, --texinfo
+ insert_commands
+
+ # Run until a fix point is reached.
+ run_tex_suite
+}
+
+
+# remove FILES
+# ------------
+remove ()
+{
+ verbose "Removing" "$@"
+ rm -rf "$@"
+}
+
+
+# mostly_clean
+# ------------
+# Remove auxiliary files and directories. Changes the current directory.
+mostly_clean ()
+{
+ cd_orig
+ set X "$t2ddir"
+ shift
+ $tidy || {
+ local log="$work_build/$in_noext.log"
+ set X ${1+"$@"} "$log" `generated_files_get "$work_build/$in_noext"`
+ shift
+ }
+ remove ${1+"$@"}
+}
+
+
+# cleanup ()
+# ----------
+# Remove what should be removed according to options.
+# Called at the end of each compilation cycle, and at the end of
+# the script. Changes the current directory.
+cleanup ()
+{
+ case $build_mode in
+ local) cd_orig; remove "$t2ddir";;
+ clean) mostly_clean;;
+ tidy) ;;
+ esac
+}
+
+
+
+## ---------------------- ##
+## Command line parsing. ##
+## ---------------------- ##
# Push a token among the arguments that will be used to notice when we
# ended options/arguments parsing.
@@ -132,41 +1647,50 @@ while test x"$1" != x"$arg_sep"; do
# Handle --option=value by splitting apart and putting back on argv.
case "$1" in
--*=*)
- opt=`echo "$1" | sed -e 's/=.*//'`
- val=`echo "$1" | sed -e 's/[^=]*=//'`
+ opt=`echo "$1" | $SED -e 's/=.*//'`
+ val=`echo "$1" | $SED -e 's/[^=]*=//'`
shift
set dummy "$opt" "$val" ${1+"$@"}; shift
;;
esac
- # This recognizes --quark as --quiet. So what.
case "$1" in
-@ ) escape=@;;
+ -~ ) catcode_special=false;;
# Silently and without documentation accept -b and --b[atch] as synonyms.
- -b | --b*) batch=eval;;
- -q | -s | --q* | --s*) quiet=t; batch=eval;;
- -c | --c*) clean=t;;
- -D | --d*) debug=t;;
- -e | -E | --e*) expand=t;;
- -h | --h*) echo "$usage"; exit 0;;
- -I | --I*)
+ -b | --batch) batch=true;;
+ --build) shift; build_mode=$1;;
+ --build-dir) shift; build_dir=$1; build_mode=tidy;;
+ -c | --clean) build_mode=clean;;
+ -D | --debug) debug=true;;
+ -e | -E | --expand) expand=true;;
+ -h | --help) usage;;
+ -I) shift; list_concat_dirs includes "$1";;
+ -l | --lang | --language) shift; set_language=$1;;
+ --mostly-clean) action=mostly-clean;;
+ --no-line-error) line_error=false;;
+ --max-iterations) shift; max_iters=$1;;
+ -o | --out | --output)
shift
- miincludes="$miincludes -I $1"
- txincludes="$txincludes$1$path_sep"
- ;;
- -l | --l*) shift; set_language=$1;;
- -o | --o*)
- shift
- clean=t
- case "$1" in
- /* | ?:/*) oname=$1;;
- *) oname="$orig_pwd/$1";;
- esac;;
- -p | --p*) oformat=pdf;;
- -t | --t*) shift; textra="$textra\\
-$1";;
- -v | --vers*) echo "$version"; exit 0;;
- -V | --verb*) verbose=echo;;
+ # Make it absolute, just in case we also have --clean, or whatever.
+ oname=`absolute "$1"`;;
+
+ # Output formats.
+ -O|--output-format) shift; out_lang_set "$1";;
+ --dvi|--dvipdf|--html|--info|--pdf|--ps|--text)
+ out_lang_set `echo "x$1" | $SED 's/^x--//'`;;
+
+ -p) out_lang_set pdf;;
+ -q | -s | --quiet | --silent) quiet=true; batch=true;;
+ --src-specials) src_specials=--src-specials;;
+ --shell-escape) shell_escape=--shell-escape;;
+ --tex4ht) latex2html=tex4ht;;
+ -t | --texinfo | --command ) shift; textra="$textra\\
+"`echo "$1" | $SED 's/\\\\/\\\\\\\\/g'`;;
+ --translate-file ) shift; translate_file="$1";;
+ --tidy) build_mode=tidy;;
+ -v | --vers*) version;;
+ -V | --verb*) verb=true;;
--) # What remains are not options.
shift
while test x"$1" != x"$arg_sep"; do
@@ -175,9 +1699,9 @@ $1";;
done
break;;
-*)
- echo "$0: Unknown or ambiguous option \`$1'." >&2
- echo "$0: Try \`--help' for more information." >&2
- exit 1;;
+ error 1 "Unknown or ambiguous option \`$1'." \
+ "Try \`--help' for more information."
+ ;;
*) set dummy ${1+"$@"} "$1"; shift;;
esac
shift
@@ -185,103 +1709,59 @@ done
# Pop the token
shift
+# $tidy: compile in a t2d directory.
+# $clean: remove all the aux files.
+case $build_mode in
+ local) clean=false; tidy=false;;
+ tidy) clean=false; tidy=true;;
+ clean) clean=true; tidy=true;;
+ *) error 1 "invalid build mode: $build_mode";;
+esac
+
# Interpret remaining command line args as filenames.
case $# in
0)
- echo "$0: Missing file arguments." >&2
- echo "$0: Try \`--help' for more information." >&2
- exit 2
+ error 2 "Missing file arguments." "Try \`--help' for more information."
;;
1) ;;
*)
if test -n "$oname"; then
- echo "$0: Can't use option \`--output' with more than one argument." >&2
- exit 2
+ error 2 "Can't use option \`--output' with more than one argument."
fi
;;
esac
-# Prepare the temporary directory. Remove it at exit, unless debugging.
-if test -z "$debug"; then
- trap "cd / && rm -rf $tmpdir" 0 1 2 15
-fi
-# Create the temporary directory with strict rights
-(umask 077 && mkdir $tmpdir) || exit 1
+# We can't do much without tex.
+#
+if findprog ${TEX:-tex}; then :; else cat <<EOM
+You don't have a working TeX binary (${TEX:-tex}) installed anywhere in
+your PATH, and texi2dvi cannot proceed without one. If you want to use
+this script, you'll need to install TeX (if you don't have it) or change
+your PATH or TEX environment variable (if you do). See the --help
+output for more details.
-# Prepare the tools we might need. This may be extra work in some
-# cases, but improves the readibility of the script.
-utildir=$tmpdir/utils
-mkdir $utildir || exit 1
+For information about obtaining TeX, please see http://tug.org/texlive,
+or do a web search for TeX and your operating system or distro.
+EOM
+ exit 1
+fi
-# A sed script that preprocesses Texinfo sources in order to keep the
-# iftex sections only. We want to remove non TeX sections, and
-# comment (with `@c texi2dvi') TeX sections so that makeinfo does not
-# try to parse them. Nevertheless, while commenting TeX sections,
-# don't comment @macro/@end macro so that makeinfo does propagate
-# them. Unfortunately makeinfo --iftex --no-ifhtml --no-ifinfo
-# doesn't work well enough (yet) to use that, so work around with sed.
-comment_iftex_sed=$utildir/comment.sed
-cat <<EOF >$comment_iftex_sed
-/^@tex/,/^@end tex/{
- s/^/@c texi2dvi/
-}
-/^@iftex/,/^@end iftex/{
- s/^/@c texi2dvi/
- /^@c texi2dvi@macro/,/^@c texi2dvi@end macro/{
- s/^@c texi2dvi//
- }
-}
-/^@html/,/^@end html/{
- s/^/@c (texi2dvi)/
-}
-/^@ifhtml/,/^@end ifhtml/{
- s/^/@c (texi2dvi)/
-}
-/^@ifnottex/,/^@end ifnottex/{
- s/^/@c (texi2dvi)/
-}
-/^@ifinfo/,/^@end ifinfo/{
- /^@node/p
- /^@menu/,/^@end menu/p
- t
- s/^/@c (texi2dvi)/
-}
-s/^@ifnotinfo/@c texi2dvi@ifnotinfo/
-s/^@end ifnotinfo/@c texi2dvi@end ifnotinfo/
-EOF
-# Uncommenting is simple: Remove any leading `@c texi2dvi'.
-uncomment_iftex_sed=$utildir/uncomment.sed
-cat <<EOF >$uncomment_iftex_sed
-s/^@c texi2dvi//
-EOF
-# A shell script that computes the list of xref files.
-# Takes the filename (without extension) of which we look for xref
-# files as argument. The index files must be reported last.
-get_xref_files=$utildir/get_xref.sh
-cat <<\EOF >$get_xref_files
-#! /bin/sh
+# We want to use etex (or pdftex) if they are available, and the user
+# didn't explicitly specify. We don't check for elatex and pdfelatex
+# because (as of 2003), the LaTeX team has asked that new distributions
+# use etex by default anyway.
+#
+# End up with the TEX and PDFTEX variables set to what we are going to use.
+if test -z "$TEX"; then
+ if findprog etex; then TEX=etex; else TEX=tex; fi
+fi
+#
+if test -z "$PDFTEX"; then
+ if findprog pdfetex; then PDFTEX=pdfetex; else PDFTEX=pdftex; fi
+fi
-# Get list of xref files (indexes, tables and lists).
-# Find all files having root filename with a two-letter extension,
-# saves the ones that are really Texinfo-related files. .?o? catches
-# many files: .toc, .log, LaTeX tables and lists, FiXme's .lox, maybe more.
-for this_file in "$1".?o? "$1".aux "$1".?? "$1".idx; do
- # If file is empty, skip it.
- test -s "$this_file" || continue
- # If the file is not suitable to be an index or xref file, don't
- # process it. The file can't be if its first character is not a
- # backslash or single quote.
- first_character=`sed -n '1s/^\(.\).*$/\1/p;q' $this_file`
- if test "x$first_character" = "x\\" \
- || test "x$first_character" = "x'"; then
- xref_files="$xref_files ./$this_file"
- fi
-done
-echo "$xref_files"
-EOF
-chmod 500 $get_xref_files
# File descriptor usage:
# 0 standard input
@@ -290,369 +1770,175 @@ chmod 500 $get_xref_files
# 3 some systems may open it to /dev/tty
# 4 used on the Kubota Titan
# 5 tools output (turned off by --quiet)
+# 6 tracing/debugging (set -x output, etc.)
+
-# Tools' output. If quiet, discard, else redirect to the message flow.
-if test "$quiet" = t; then
+# Main tools' output (TeX, etc.) that TeX users are used to seeing.
+#
+# If quiet, discard, else redirect to the message flow.
+if $quiet; then
exec 5>/dev/null
else
exec 5>&1
fi
-# Enable tracing
-test "$debug" = t && set -x
+
+# Enable tracing, and auxiliary tools output.
+#
+# This fd should be used where you'd typically use /dev/null to throw
+# output away. But sometimes it is convenient to see that output (e.g.,
+# from a grep) to aid debugging. Especially debugging at distance, via
+# the user.
+#
+if $debug; then
+ exec 6>&1
+ set -vx
+else
+ exec 6>/dev/null
+fi
#
-# TeXify files.
-for command_line_filename in ${1+"$@"}; do
- $verbose "Processing $command_line_filename ..."
+# input_file_name_decode
+# ----------------------
+# Decode COMMAND_LINE_FILENAME, and compute:
+# - COMMAND_LINE_FILENAME clean of TeX commands
+# - IN_DIR
+# The directory to the input file, possibly absolute if needed.
+# - IN_DIR_ABS
+# The absolute directory of the input file.
+# - IN_BASE
+# The input file base name (no directory part).
+# - IN_NOEXT
+# The input file name without extensions (nor directory part).
+# - IN_INPUT
+# Defaults to COMMAND_LINE_FILENAME, but might change if the
+# input is preprocessed. With directory, possibly absolute.
+input_file_name_decode ()
+{
+ # See if we are run from within AUC-Tex, in which case we are
+ # passed `\input{FOO.tex}' or even `\nonstopmode\input{FOO.tex}'.
+ case $command_line_filename in
+ *\\nonstopmode*)
+ batch=true;;
+ esac
+ case $command_line_filename in
+ *\\input{*}*)
+ # Let AUC-TeX error parser deal with line numbers.
+ line_error=false
+ command_line_filename=`\
+ expr X"$command_line_filename" : X'.*input{\([^}]*\)}'`
+ ;;
+ esac
# If the COMMAND_LINE_FILENAME is not absolute (e.g., --debug.tex),
# prepend `./' in order to avoid that the tools take it as an option.
- echo "$command_line_filename" | $EGREP '^(/|[A-z]:/)' >/dev/null \
+ echo "$command_line_filename" | LC_ALL=C $EGREP '^(/|[A-Za-z]:/)' >&6 \
|| command_line_filename="./$command_line_filename"
# See if the file exists. If it doesn't we're in trouble since, even
# though the user may be able to reenter a valid filename at the tex
# prompt (assuming they're attending the terminal), this script won't
# be able to find the right xref files and so forth.
- if test ! -r "$command_line_filename"; then
- echo "$0: Could not read $command_line_filename, skipping." >&2
- continue
- fi
+ test -r "$command_line_filename" \
+ || error 1 "cannot read $command_line_filename, skipping."
- # Get the name of the current directory. We want the full path
- # because in clean mode we are in tmp, in which case a relative
- # path has no meaning.
- filename_dir=`echo $command_line_filename | sed 's!/[^/]*$!!;s!^$!.!'`
- filename_dir=`cd "$filename_dir" >/dev/null && pwd`
+ # Get the name of the current directory.
+ in_dir=`func_dirname "$command_line_filename"`
+ in_dir_abs=`absolute "$in_dir"`
+ # In a clean build, we `cd', so get an absolute file name.
+ if $tidy; then
+ in_dir=$in_dir_abs
+ fi
# Strip directory part but leave extension.
- filename_ext=`basename "$command_line_filename"`
+ in_base=`basename "$command_line_filename"`
# Strip extension.
- filename_noext=`echo "$filename_ext" | sed 's/\.[^.]*$//'`
- ext=`echo "$filename_ext" | sed 's/^.*\.//'`
-
- # _src. Use same basename since we want to generate aux files with
- # the same basename as the manual. If --expand, then output the
- # macro-expanded file to here, else copy the original file.
- tmpdir_src=$tmpdir/src
- filename_src=$tmpdir_src/$filename_noext.$ext
+ in_noext=`noext "$in_base"`
- # _xtr. The file with the user's extra commands.
- tmpdir_xtr=$tmpdir/xtr
- filename_xtr=$tmpdir_xtr/$filename_noext.$ext
+ # The normalized file name to compile. Must always point to the
+ # file to actually compile (in case of recoding, macro-expansion etc.).
+ in_input=$in_dir/$in_base
- # _bak. Copies of the previous xref files (another round is run if
- # they differ from the new one).
- tmpdir_bak=$tmpdir/bak
- # Make all those directories and give up if we can't succeed.
- mkdir $tmpdir_src $tmpdir_xtr $tmpdir_bak || exit 1
-
- # Source file might include additional sources.
- # We want `.:$orig_pwd' before anything else. (We'll add `.:' later
- # after all other directories have been turned into absolute paths.)
- # `.' goes first to ensure that any old .aux, .cps,
- # etc. files in ${directory} don't get used in preference to fresher
- # files in `.'. Include orig_pwd in case we are in clean mode, where
- # we've cd'd to a temp directory.
- common="$orig_pwd$path_sep$filename_dir$path_sep$txincludes"
- TEXINPUTS="$common$TEXINPUTS_orig"
- INDEXSTYLE="$common$INDEXSTYLE_orig"
-
- # Convert relative paths to absolute paths, so we can run in another
- # directory (e.g., in --clean mode, or during the macro-support
- # detection.)
- #
- # Empty path components are meaningful to tex. We rewrite them
- # as `EMPTY' so they don't get lost when we split on $path_sep.
- TEXINPUTS=`echo $TEXINPUTS |sed 's/^:/EMPTY:/;s/:$/:EMPTY/;s/::/:EMPTY:/g'`
- INDEXSTYLE=`echo $INDEXSTYLE |sed 's/^:/EMPTY:/;s/:$/:EMPTY/;s/::/:EMPTY:/g'`
- save_IFS=$IFS
- IFS=$path_sep
- set x $TEXINPUTS; shift
- TEXINPUTS=.
- for dir
- do
- case $dir in
- EMPTY)
- TEXINPUTS=$TEXINPUTS$path_sep
- ;;
- [\\/]* | ?:[\\/]*) # Absolute paths don't need to be expansed.
- TEXINPUTS=$TEXINPUTS$path_sep$dir
- ;;
- *)
- abs=`cd "$dir" && pwd` && TEXINPUTS=$TEXINPUTS$path_sep$abs
- ;;
- esac
- done
- set x $INDEXSTYLE; shift
- INDEXSTYLE=.
- for dir
- do
- case $dir in
- EMPTY)
- INDEXSTYLE=$INDEXSTYLE$path_sep
- ;;
- [\\/]* | ?:[\\/]*) # Absolute paths don't need to be expansed.
- INDEXSTYLE=$INDEXSTYLE$path_sep$dir
- ;;
- *)
- abs=`cd "$dir" && pwd` && INDEXSTYLE=$INDEXSTYLE$path_sep$abs
- ;;
- esac
- done
- IFS=$save_IFS
-
- # If the user explicitly specified the language, use that.
- # Otherwise, if the first line is \input texinfo, assume it's texinfo.
- # Otherwise, guess from the file extension.
- if test -n "$set_language"; then
- language=$set_language
- elif sed 1q "$command_line_filename" | grep 'input texinfo' >/dev/null; then
- language=texinfo
+ # Compute the output file name.
+ if test x"$oname" != x; then
+ out_name=$oname
else
- language=
- fi
-
- # Get the type of the file (latex or texinfo) from the given language
- # we just guessed, or from the file extension if not set yet.
- case ${language:-$filename_ext} in
- [lL]a[tT]e[xX] | *.ltx | *.tex)
- # Assume a LaTeX file. LaTeX needs bibtex and uses latex for
- # compilation. No makeinfo.
- bibtex=${BIBTEX:-bibtex}
- makeinfo= # no point in running makeinfo on latex source.
- texindex=${MAKEINDEX:-makeindex}
- if test $oformat = dvi; then
- tex=${LATEX:-latex}
- else
- tex=${PDFLATEX:-pdflatex}
- fi
- ;;
-
- *)
- # Assume a Texinfo file. Texinfo files need makeinfo, texindex and tex.
- bibtex=
- texindex=${TEXINDEX:-texindex}
- if test $oformat = dvi; then
- tex=${TEX:-tex}
- else
- tex=${PDFTEX:-pdftex}
- fi
- # Unless required by the user, makeinfo expansion is wanted only
- # if texinfo.tex is too old.
- if test "$expand" = t; then
- makeinfo=${MAKEINFO:-makeinfo}
- else
- # Check if texinfo.tex performs macro expansion by looking for
- # its version. The version is a date of the form YEAR-MO-DA.
- # We don't need to use [0-9] to match the digits since anyway
- # the comparison with $txiprereq, a number, will fail with non
- # digits.
- txiversion_tex=txiversion.tex
- echo '\input texinfo.tex @bye' >$tmpdir/$txiversion_tex
- # Run in the tmpdir to avoid leaving files.
- eval `cd $tmpdir >/dev/null &&
- $tex $txiversion_tex 2>/dev/null |
- sed -n 's/^.*\[\(.*\)version \(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p'`
- $verbose "texinfo.tex preloaded as \`$txiformat', version is \`$txiversion' ..."
- if test "$txiprereq" -le "$txiversion" >/dev/null 2>&1; then
- makeinfo=
- else
- makeinfo=${MAKEINFO:-makeinfo}
- fi
- # As long as we had to run TeX, offer the user this convenience
- if test "$txiformat" = Texinfo; then
- escape=@
- fi
- fi
- ;;
- esac
-
- # Expand macro commands in the original source file using Makeinfo.
- # Always use `end' footnote style, since the `separate' style
- # generates different output (arguably this is a bug in -E).
- # Discard main info output, the user asked to run TeX, not makeinfo.
- if test -n "$makeinfo"; then
- $verbose "Macro-expanding $command_line_filename to $filename_src ..."
- sed -f $comment_iftex_sed "$command_line_filename" \
- | $makeinfo --footnote-style=end -I "$filename_dir" $miincludes \
- -o /dev/null --macro-expand=- \
- | sed -f $uncomment_iftex_sed >"$filename_src"
- filename_input=$filename_src
- fi
-
- # If makeinfo failed (or was not even run), use the original file as input.
- if test $? -ne 0 \
- || test ! -r "$filename_src"; then
- $verbose "Reverting to $command_line_filename ..."
- filename_input=$filename_dir/$filename_ext
- fi
-
- # Used most commonly for @finalout, @smallbook, etc.
- if test -n "$textra"; then
- $verbose "Inserting extra commands: $textra"
- sed '/^@setfilename/a\
-'"$textra" "$filename_input" >$filename_xtr
- filename_input=$filename_xtr
+ out_name=$in_noext.`out_lang_ext`
fi
+ out_dir=`func_dirname "$out_name"`
+ out_dir_abs=`absolute "$out_dir"`
+ out_base=`basename "$out_name"`
+ out_noext=`noext "$out_base"`
+}
- # If clean mode was specified, then move to the temporary directory.
- if test "$clean" = t; then
- $verbose "cd $tmpdir_src"
- cd "$tmpdir_src" || exit 1
- fi
- while :; do # will break out of loop below
- orig_xref_files=`$get_xref_files "$filename_noext"`
+## -------------- ##
+## TeXify files. ##
+## -------------- ##
- # Save copies of originals for later comparison.
- if test -n "$orig_xref_files"; then
- $verbose "Backing up xref files: `echo $orig_xref_files | sed 's|\./||g'`"
- cp $orig_xref_files $tmpdir_bak
- fi
+for command_line_filename
+do
+ verbose "Processing $command_line_filename ..."
- # Run bibtex on current file.
- # - If its input (AUX) exists.
- # - If AUX contains both `\bibdata' and `\bibstyle'.
- # - If some citations are missing (LOG contains `Citation').
- # or the LOG complains of a missing .bbl
- #
- # We run bibtex first, because I can see reasons for the indexes
- # to change after bibtex is run, but I see no reason for the
- # converse.
- #
- # Don't try to be too smart. Running bibtex only if the bbl file
- # exists and is older than the LaTeX file is wrong, since the
- # document might include files that have changed. Because there
- # can be several AUX (if there are \include's), but a single LOG,
- # looking for missing citations in LOG is easier, though we take
- # the risk to match false messages.
- if test -n "$bibtex" \
- && test -r "$filename_noext.aux" \
- && test -r "$filename_noext.log" \
- && (grep '^\\bibdata[{]' "$filename_noext.aux" \
- && grep '^\\bibstyle[{]' "$filename_noext.aux" \
- && (grep 'Warning:.*Citation.*undefined' "$filename_noext.log" \
- || grep 'No file .*\.bbl\.' "$filename_noext.log")) \
- >/dev/null 2>&1; \
- then
- $verbose "Running $bibtex $filename_noext ..."
- if $bibtex "$filename_noext" >&5; then :; else
- echo "$0: $bibtex exited with bad status, quitting." >&2
- exit 1
- fi
- fi
+ input_file_name_decode
- # What we'll run texindex on -- exclude non-index files.
- # Since we know index files are last, it is correct to remove everything
- # before .aux and .?o?. But don't really do <anything>o<anything>
- # -- don't match whitespace as <anything>.
- # Otherwise, if orig_xref_files contains something like
- # foo.xo foo.whatever
- # the space after the o will get matched.
- index_files=`echo "$orig_xref_files" \
- | sed "s!.*\.aux!!g;
- s!./$filename_noext\.[^ ]o[^ ]!!g;
- s/^[ ]*//;s/[ ]*$//"`
- # Run texindex (or makeindex) on current index files. If they
- # already exist, and after running TeX a first time the index
- # files don't change, then there's no reason to run TeX again.
- # But we won't know that if the index files are out of date or
- # nonexistent.
- if test -n "$texindex" && test -n "$index_files"; then
- $verbose "Running $texindex $index_files ..."
- if $texindex $index_files 2>&5 1>&2; then :; else
- echo "$0: $texindex exited with bad status, quitting." >&2
- exit 1
- fi
- fi
+ # `texinfo' or `latex'?
+ in_lang=`compute_language "$command_line_filename"`
- # Finally, run TeX.
- # Prevent $ESCAPE from being interpreted by the shell if it happens
- # to be `/'.
- $batch tex_args="\\${escape}nonstopmode\ \\${escape}input"
- cmd="$tex $tex_args $filename_input"
- $verbose "Running $cmd ..."
- if $cmd >&5; then :; else
- echo "$0: $tex exited with bad status, quitting." >&2
- echo "$0: see $filename_noext.log for errors." >&2
- test "$clean" = t \
- && cp "$filename_noext.log" "$orig_pwd"
- exit 1
- fi
+ # An auxiliary directory used for all the auxiliary tasks involved
+ # in compiling this document.
+ case $build_dir in
+ '' | . ) t2ddir=$out_noext.t2d ;;
+ *) # Avoid collisions between multiple occurrences of the same
+ # file, so depend on the output path. Remove leading `./',
+ # at least to avoid creating a file starting with `.!', i.e.,
+ # an invisible file. The sed expression is fragile if the cwd
+ # has active characters. Transform / into ! so that we don't
+ # need `mkdir -p'. It might be something to reconsider.
+ t2ddir=$build_dir/`echo "$out_dir_abs/$out_noext.t2d" |
+ $SED "s,^$orig_pwd/,,;s,^\./,,;s,/,!,g"`
+ esac
+ # Remove it at exit if clean mode.
+ trap "cleanup" 0 1 2 15
+ ensure_dir "$build_dir" "$t2ddir"
- # Decide if looping again is needed.
- finished=t
+ # We will change directory, better work with an absolute path...
+ t2ddir=`absolute "$t2ddir"`
+ # Sometimes there are incompatibilities between auxiliary files for
+ # DVI and PDF. The contents can also change whether we work on PDF
+ # and/or DVI. So keep separate spaces for each.
+ workdir=$t2ddir/`out_lang_tex`
+ ensure_dir "$workdir"
- # LaTeX (and the package changebar) report in the LOG file if it
- # should be rerun. This is needed for files included from
- # subdirs, since texi2dvi does not try to compare xref files in
- # subdirs. Performing xref files test is still good since LaTeX
- # does not report changes in xref files.
- if grep "Rerun to get" "$filename_noext.log" >/dev/null 2>&1; then
- finished=
- fi
+ # _build. In a tidy build, where the auxiliary files are output.
+ if $tidy; then
+ work_build=$workdir/build
+ else
+ work_build=.
+ fi
- # Check if xref files changed.
- new_xref_files=`$get_xref_files "$filename_noext"`
- $verbose "Original xref files = `echo $orig_xref_files | sed 's|\./||g'`"
- $verbose "New xref files = `echo $new_xref_files | sed 's|\./||g'`"
-
- # If old and new lists don't at least have the same file list,
- # then one file or another has definitely changed.
- test "x$orig_xref_files" != "x$new_xref_files" && finished=
-
- # File list is the same. We must compare each file until we find
- # a difference.
- if test -n "$finished"; then
- for this_file in $new_xref_files; do
- $verbose "Comparing xref file `echo $this_file | sed 's|\./||g'` ..."
- # cmp -s returns nonzero exit status if files differ.
- if cmp -s "$this_file" "$tmpdir_bak/$this_file"; then :; else
- # We only need to keep comparing until we find one that
- # differs, because we'll have to run texindex & tex again no
- # matter how many more there might be.
- finished=
- $verbose "xref file `echo $this_file | sed 's|\./||g'` differed ..."
- test "$debug" = t && diff -c "$tmpdir_bak/$this_file" "$this_file"
- break
- fi
- done
- fi
+ # _bak. Copies of the previous auxiliary files (another round is
+ # run if they differ from the new ones).
+ work_bak=$workdir/bak
- # If finished, exit the loop, else rerun the loop.
- test -n "$finished" && break
- done
+ # Make those directories.
+ ensure_dir "$work_build" "$work_bak"
- # If we were in clean mode, compilation was in a tmp directory.
- # Copy the DVI (or PDF) file into the directory where the compilation
- # has been done. (The temp dir is about to get removed anyway.)
- # We also return to the original directory so that
- # - the next file is processed in correct conditions
- # - the temporary file can be removed
- if test -n "$clean"; then
- if test -n "$oname"; then
- dest=$oname
- else
- dest=$orig_pwd
- fi
- $verbose "Copying $oformat file from `pwd` to $dest"
- cp -p "./$filename_noext.$oformat" "$dest"
- cd / # in case $orig_pwd is on a different drive (for DOS)
- cd $orig_pwd || exit 1
- fi
+ case $action in
+ compile)
+ # Compile the document.
+ compile
+ cleanup
+ ;;
- # Remove temporary files.
- if test "x$debug" = "x"; then
- $verbose "Removing $tmpdir_src $tmpdir_xtr $tmpdir_bak ..."
- cd /
- rm -rf $tmpdir_src $tmpdir_xtr $tmpdir_bak
- fi
+ mostly-clean)
+ mostly_clean
+ ;;
+ esac
done
-$verbose "$0 done."
+verbose "done."
exit 0 # exit successfully, not however we ended the loop.
diff --git a/readline/doc/texi2html b/readline/doc/texi2html
index 9f9c2eb..13b5588 100755
--- a/readline/doc/texi2html
+++ b/readline/doc/texi2html
@@ -35,7 +35,7 @@ require 5.0;
#--##############################################################################
# CVS version:
-# $Id$
+# $Id: texi2html.pl,v 1.55 2000/07/27 14:39:41 obachman Exp $
# Homepage:
$T2H_HOMEPAGE = <<EOT;
@@ -91,7 +91,7 @@ eval { ($T2H_USER = (getpwuid ($<))[6]) =~ s/,.*//;}; # Who am i
# Copy this file and make changes to it, if you like.
# Afterwards, either, load it with command-line option -init_file <your_init_file>
#
-# $Id$
+# $Id: texi2html.init,v 1.34 2000/07/27 14:09:02 obachman Exp $
######################################################################
# stuff which can also be set by command-line options
@@ -1509,7 +1509,7 @@ package Getopt::MySimple;
# --------------------------------------------------------------------------
# Locally modified by obachman (Display type instead of env, order by cmp)
-# $Id$
+# $Id: MySimple.pm,v 1.1 2000/07/03 08:44:13 obachman Exp $
# use strict;
# no strict 'refs';
diff --git a/readline/doc/version.texi b/readline/doc/version.texi
index 3ee1c10..3f4d36d 100644
--- a/readline/doc/version.texi
+++ b/readline/doc/version.texi
@@ -1,10 +1,10 @@
@ignore
-Copyright (C) 1988-2011 Free Software Foundation, Inc.
+Copyright (C) 1988-2015 Free Software Foundation, Inc.
@end ignore
-@set EDITION 6.2
-@set VERSION 6.2
-@set UPDATED September 6 2010
-@set UPDATED-MONTH September 2010
+@set EDITION 6.4
+@set VERSION 6.4
+@set UPDATED 28 May 2015
+@set UPDATED-MONTH May 2015
-@set LASTCHANGE Mon Sep 6 22:07:10 EDT 2010
+@set LASTCHANGE Thu May 28 16:58:07 EDT 2015