Bug#815369: texi2pdf output filename bug?

2016-05-01 Thread Gavin Smith
On 1 May 2016 at 12:14, Gavin Smith  wrote:
> I haven't researched why --tidy makes a difference. I plan to stop
> this error by making @value non-expandable when writing to auxiliary
> files. This would have the effect that the value used would be the
> value at the time when the auxiliary file was read in, instead of when
> it was written to, that's when @value worked at all. I think this
> change would be okay, because this is already the case for @macro and
> I doubt that many documents would rely on changing a @value in the
> middle of the document.

I have found another problem: the --tidy and --command options appear
to be incompatible. In the "insert_commands" function, the "in_input"
variable is changed to be the file that is the result of inserting the
extra commands, but in the "run_tex" function, this is discarded if
--tidy was given.



Bug#815369: texi2pdf output filename bug?

2016-05-01 Thread Gavin Smith
On 30 April 2016 at 22:57, Guo Yixuan  wrote:

> The mwe.texi file by Norbert:
>
> $ cat mwe.texi
> \input texinfo   @c -*-texinfo-*-
> @setfilename min2.info
>
> What ever
> @anchor{@value{cmd1} doc}@anchor{0}
> Here we go
> @bye
>


> ./mwe.aux:1: TeX capacity exceeded, sorry [input stack size=18000].
> @value ->@begingroup @makevalueexpandable
>   @valuexxx
> @makevalueexpandable ->@let @value
>= @expandablevalue @catcode `@-=@other 
> @c...
>
> @value ->@begingroup @makevalueexpandable
>   @valuexxx
> @makevalueexpandable ->@let @value
>= @expandablevalue @catcode `@-=@other 
> @c...
>
> @value ->@begingroup @makevalueexpandable
>   @valuexxx
> @makevalueexpandable ->@let @value
>= @expandablevalue @catcode `@-=@other 
> @c...
> ...
> l.1 ..., used in @value, is not set.} doc-title}{}

Appears to be a bug with --tidy. The filename appears to be irrelevant.

I haven't researched why --tidy makes a difference. I plan to stop
this error by making @value non-expandable when writing to auxiliary
files. This would have the effect that the value used would be the
value at the time when the auxiliary file was read in, instead of when
it was written to, that's when @value worked at all. I think this
change would be okay, because this is already the case for @macro and
I doubt that many documents would rely on changing a @value in the
middle of the document.

$ texi2pdf --command="@set cmd1 HELLO" --tidy  mwe.texi
This is pdfeTeXk, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)
 file:line:error style messages enabled.
entering extended mode
(/home/g/src/texinfo/PROJ_SVN/util/mwe.texi
(/home/g/src/texinfo/PROJ_SVN/util/texinfo.tex
Loading texinfo [version 2016-02-20.23]: pdf, fonts, markup, glyphs,
page headings, tables, conditionals, indexing, sectioning, toc, environments,
defuns, macros, cross references, insertions,
(/usr/share/texmf/tex/generic/epsf/epsf.tex
This is `epsf.tex' v2.7.4 <14 February 2011>
) localization, formatting, and turning on texinfo input format.) [1{/usr/share
/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] )
Output written on mwe.pdf (1 page, 8835 bytes).
Transcript written on mwe.log.
This is pdfeTeXk, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)
 file:line:error style messages enabled.
entering extended mode
(/home/g/src/texinfo/PROJ_SVN/util/mwe.texi
(/home/g/src/texinfo/PROJ_SVN/util/texinfo.tex
Loading texinfo [version 2016-02-20.23]: pdf, fonts, markup, glyphs,
page headings, tables, conditionals, indexing, sectioning, toc, environments,
defuns, macros, cross references, insertions,
(/usr/share/texmf/tex/generic/epsf/epsf.tex
This is `epsf.tex' v2.7.4 <14 February 2011>
) localization, formatting, and turning on texinfo input format.) (./mwe.aux
./mwe.aux:1: TeX capacity exceeded, sorry [input stack size=1500].
@value ->@begingroup @makevalueexpandable
  @valuexxx
@makevalueexpandable ->@let @value
   = @expandablevalue @catcode `@-=@other @c...

@value ->@begingroup @makevalueexpandable
  @valuexxx
@makevalueexpandable ->@let @value
   = @expandablevalue @catcode `@-=@other @c...

@value ->@begingroup @makevalueexpandable
  @valuexxx
@makevalueexpandable ->@let @value
   = @expandablevalue @catcode `@-=@other @c...
...
l.1 ..., used in @value, is not set.} doc-title}{}

No pages of output.
Transcript written on mwe.log.
/usr/local/bin/texi2dvi: pdfetex exited with bad status, quitting.
$ rm mwe.t2d/ mwe.aux -r
rm: cannot remove 'mwe.aux': No such file or directory
$ texi2pdf --command="@set cmd1 HELLO" mwe.texi
tar: mwe.aux: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
This is pdfeTeXk, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)
 file:line:error style messages enabled.
entering extended mode
(/home/g/src/texinfo/PROJ_SVN/util/mwe.t2d/pdf/xtr/mwe.texi
(/home/g/src/texinfo/PROJ_SVN/util/texinfo.tex
Loading texinfo [version 2016-02-20.23]: pdf, fonts, markup, glyphs,
page headings, tables, conditionals, indexing, sectioning, toc, environments,
defuns, macros, cross references, insertions,
(/usr/share/texmf/tex/generic/epsf/epsf.tex
This is `epsf.tex' v2.7.4 <14 February 2011>
) localization, formatting, and turning on texinfo input format.) [1{/usr/share
/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] )
Output written on mwe.pdf (1 page, 8685 bytes).
Transcript written on mwe.log.
This is pdfeTeXk, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)
 file:line:error style messages enabled.
entering extended mode
(/home/g/src/texinfo/PROJ_SVN/util/mwe.t2d/pdf/xtr/mwe.texi
(/home/g/src/texinfo/PROJ_SVN/util/texinfo.tex
Loa

Bug#815205: another texinfo.tex bug in \scanmacro

2016-04-12 Thread Gavin Smith
On 12 April 2016 at 09:05, Norbert Preining  wrote:
> Here is a minimal example extracted from the sbcl sources that shows
> the effect:
> \input texinfo   @c -*-texinfo-*-
>
> @iftex
> @macro cl{name}
> {@smallertt@phantom{concurrency:}@llap{cl:}}\name\
> @end macro
> @end iftex
>
> Some text
>
> @tindex @cl{built-in-class}
> foo bar baz
>
> @printindex tp
>
>
> @bye
>

Thanks for sending, I believe the diff below fixes it. Please let me
know whether it works. These catcode changes were there before but I
must have removed them when the expansion of Texinfo macros no longer
took place within a TeX group. They're needed for macro expansion in
index entries, as you found.

Index: texinfo.tex
===
--- texinfo.tex (revision 7054)
+++ texinfo.tex (working copy)
@@ -5305,7 +5305,6 @@
 \putwordIndexNonexistent
   \else
 \catcode`\\ = 0
-\escapechar = `\\
 %
 % If the index file exists but is empty, then \openin leaves \ifeof
 % false.  We have to make TeX try to read something from the file, so
@@ -6866,7 +6865,6 @@
   \catcode `\>=\other
   \catcode `\`=\other
   \catcode `\'=\other
-  \escapechar=`\\
   %
   % ' is active in math mode (mathcode"8000).  So reset it, and all our
   % other math active characters (just in case), to plain's definitions.
@@ -7844,15 +7842,27 @@
 % alias because \c means cedilla in @tex or @math
 \let\texinfoc=\c

+\newcount\savedcatcodeone
+\newcount\savedcatcodetwo
+
 % Used at the time of macro expansion.
 % Argument is macro body with arguments substituted
 \def\scanmacro#1{%
   \newlinechar`\^^M
   \def\xeatspaces{\eatspaces}%
   %
+  % Temporarily undo catcode changes of \printindex
+  \savedcatcodeone=\catcode`\@
+  \savedcatcodetwo=\catcode`\\
+  \catcode`\@=0
+  \catcode`\\=\active
+  %
   % Process the macro body under the current catcode regime.
-  \scantokens{#1\texinfoc}\aftermacro%
+  \scantokens{#1@texinfoc}\aftermacro%
   %
+  \catcode`\@=\savedcatcodeone
+  \catcode`\\=\savedcatcodetwo
+  %
   % The \texinfoc is to remove the \newlinechar added by \scantokens, and
   % can be noticed by \parsearg.
   %   The \aftermacro allows a \comment at the end of the macro definition



Bug#815205: another texinfo.tex bug in \scanmacro

2016-04-11 Thread Gavin Smith
On 17 March 2016 at 07:25, Gavin Smith  wrote:
> I've checked and using \gdef instead of \def works, because the
> definition took place within a TeX group:

I've come across the following message:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815205#95:

==
The patch mentioned in #815205, and distributed along with 2:1.3.3-1,
does allow the TeXinfo manual to build.  Unfortunately, it ruins the
typesetting of the index in the PDF version of the manual, which now
typesets literal @llap...@phantomconcurrency (rather than interpreting
the TeX commands).

I'm not sure what's going on; I will try to find out, but if someone
more versed in TeXinfo is able to look as well, that would be helpful.
You can see what the index should look like in the document at
<http://www.sbcl.org/manual/sbcl.pdf>.
==

If there are still problems could someone email me the Texinfo sources
so I can have a look?



Bug#815205: another texinfo.tex bug in \scanmacro

2016-03-19 Thread Gavin Smith
On 16 March 2016 at 10:01, Norbert Preining  wrote:
>
> I reduced the problem to the following minimal not-working
> example:
>
>
> \input texinfo   @c -*-texinfo-*-
>
> @iftex
> @tex
> \newif\ifdash
> \long\def\dashp#1{\expandafter\setnext#1-\dashphelper}
> \long\def\setnext#1-{\futurelet\next\dashphelper}
> \long\def\dashphelper#1\dashphelper{
>   \ifx\dashphelper\next\dashfalse\else\dashtrue\fi
> }
> \def\lw#1{\leavevmode\dashp{#1}\ifdash#1\else\hbox{#1}\fi}
> @end tex
> @end iftex
>
> @macro lw{word}
> @tex
> \\lw{\word\}%
> @end tex
> @end macro
>
> @code{@lw{aaa}}
>
> @bye

>
> and the error message is
> /mnwe.texinfo:21: TeX capacity exceeded, sorry [text input levels=15].

Why not use a different name for the \lw macro defined in the @tex
block, so it isn't used in its own definition?  That's the cause of
the problem. If I remember correctly, the TeX implementation had a way
that the previous definition of a macro could be used in the
definition of a macro, but I must have broken or removed it.  I expect
that's why this code used to work. As far as I know, this was never
implemented in makeinfo. (This didn't apply for @rmacro, either.) In
this context @lw and \lw are the same thing and it would be a
significant complication to make them different, and it doesn't seem
necessary to make this work.



Bug#815205: another texinfo.tex bug in \scanmacro

2016-03-19 Thread Gavin Smith
On 17 March 2016 at 01:31, Norbert Preining  wrote:
>
> Ok, I tried your  suggestion, but that again breaks:

I've checked and using \gdef instead of \def works, because the
definition took place within a TeX group:

\input texinfo   @c -*-texinfo-*-

@iftex
@tex
\gdef\aaa#1{Hello #1}
@end tex
@end iftex

@macro bbb{word}
@tex
\\aaa{\word\}
@end tex
@end macro

@bbb{World}

@bye

I don't know why the original code used to work, because \gdef wasn't
used there either.

> Is this just an incorrect usage of macro definitions and @tex
> in the original sources, that "just happened" to work till 6.0,
> or is there something else behind?

There's nothing else to it as far as I can tell. As far as I know,
this usage has never been documented or encouraged. It appears to be a
recursive definition of a macro which actually uses a definition from
elsewhere.



Bug#815734: regression: ESS cannot be compiled

2016-03-05 Thread Gavin Smith
On 4 March 2016 at 21:28, Gavin Smith  wrote:
> On 4 March 2016 at 04:01, Norbert Preining  wrote:
>> The output is:
>> ./bla.texi:9: Argument of @gobblespaces has an extra }.
>
> I got the same. I think it's easy enough to fix. The only possible
> problem is that this error comes about due to an attempt to remove
> whitespace from the start of a macro argument when the macro only
> takes one argument. To fix, this would be removed, so any whitespace
> after the opening brace of the macro invocation wouldn't be ignored. I
> think this is okay, because people will only expect spaces following
> commas separating macro arguments to be discarded.

Done in SVN revision 7041. Please email if there are further problems.



Bug#815734: regression: ESS cannot be compiled

2016-03-04 Thread Gavin Smith
> > I have reduced the problematic case to the following minimal example:

Thank you for taking the time to do this, Norbert.

> From these two facts I'd declare that the new texinfo.tex that
> you have in Debian is broken.
> (Yes, that is a strong statement; but still breaking something
>  that worked dozens of year w/o problems needs VERY good arguments
>  before you can call it "progress" !!)

No-one's said that breaking this usage is progress. It wasn't intended
and we will fix it.

The problem comes from trying to support the Texinfo macro facility,
the different ways that it's been used in different documents and
managing multiple incompatible implementations of it. It's caused
problems ever since it was introduced, maybe about 20 years ago.
Evidently these problems aren't at an end yet, despite hope. When the
fix is finalized I'll add this breaking usage to our test file to
prevent it breaking again.



Bug#815734: regression: ESS cannot be compiled

2016-03-04 Thread Gavin Smith
On 4 March 2016 at 04:01, Norbert Preining  wrote:
> The output is:
> ./bla.texi:9: Argument of @gobblespaces has an extra }.

I got the same. I think it's easy enough to fix. The only possible
problem is that this error comes about due to an attempt to remove
whitespace from the start of a macro argument when the macro only
takes one argument. To fix, this would be removed, so any whitespace
after the opening brace of the macro invocation wouldn't be ignored. I
think this is okay, because people will only expect spaces following
commas separating macro arguments to be discarded. In the past, spaces
were trimmed at the beginning and end of macro arguments regardless of
the number of arguments they took, but this broke when the macro
argument had newlines which had to be significant (as far as I
remember).



Bug#815369: [BUG] command line definitions not expanded

2016-02-21 Thread Gavin Smith
On 21 February 2016 at 09:50, Norbert Preining  wrote:
> HI Gavin,
>
>> The problem is that @setfilename is missing from the file, and
>> texi2dvi looks for that line to add the extra line. @setfilename was
>> required before, so this isn't a regression (I hope).
>
> Ahh, I see. The original did have a line like this:
> @setfilename @value{cmd1}.info
> so it might be necessary to add it *before* this line.
>

Did this ever work, and if so, which version of texinfo.tex and texi2dvi?



Bug#815369: [BUG] command line definitions not expanded

2016-02-21 Thread Gavin Smith
On 21 February 2016 at 06:19, Norbert Preining  wrote:
> Hi Gavin, hi all
>
> (please keep Cc)
>
> I am sorry for all the bug reports, but here is the next one that
> surfaced when building the documentation for gcc.
>
> In short, it seems that definitions given on the command line
> --command='@set foobar value'
> are not properly expanded in the aux files.
>
> Here a minimal not working example:
>
> The following code works without problems:
> \input texinfo   @c -*-texinfo-*-
> @set cmd1 HELLO
>
> What ever
> @anchor{@value{cmd1} doc}@anchor{0}
> Here we go
> @bye
>
> But when I remove the @set line and instead call
> texi2pdf --command='@set cmd1 HELLO' mwe.texi
> I get the following error:
>
> /home/norbert/Debian/gcc-doc/mwe/mwe.aux:1: TeX capacity exceeded, sorry 
> [input
>  stack size=5000].
> @value ->@begingroup @makevalueexpandable
>   @valuexxx
> .
> l.1 ..., used in @value, is not set.} doc-title}{}
>
>
> The reason is that the mwe.aux file contains:
>
> @xrdef{{[No value for ``cmd1'']}@message {Variable `cmd1', used in @value, is 
> not set.} doc-title}{}

The problem is that @setfilename is missing from the file, and
texi2dvi looks for that line to add the extra line. @setfilename was
required before, so this isn't a regression (I hope).

Here's a patch. Please try it, and if it works fine, I'll commit it
and upload the new texi2dvi.

It might work fine just to always add the extra lines after the first,
depending on how people use this command: for example, --command
"\ngngnngng" would break for older versions of texinfo.tex (similarly
index commands could break, and possibly others as well). I can't
think of a likely use-case which would break, but it's more reliable
to do it this way.

Index: texi2dvi
===
--- texi2dvi(revision 7006)
+++ texi2dvi(working copy)
@@ -1312,7 +1312,14 @@ insert_commands ()
 verbose "Inserting extra commands: $textra"
 case $in_lang in
   latex)   textra_cmd=1i;;
-  texinfo) textra_cmd='/^@setfilename/a';;
+  texinfo)
+# If @setfilename is used in the first few lines of the file,
+# add the extra lines after it, otherwise add after the first line.
+if sed 10q "$in_input" | grep "^@setfilename"; then
+  textra_cmd='/^@setfilename/a'
+else
+  textra_cmd=1a
+fi ;;
   *)   error 1 "internal error, unknown language: $in_lang";;
 esac
 $SED "$textra_cmd\\