On Thu, Dec 04, 2025 at 04:21:11PM +0100, Marc Espie wrote:
>      This program is commonly installed as both `makeinfo' and `texi2any'; the
>      behavior is identical, and does not depend on the installed name.
> 
> This is not true, the generated info file will start with a line
> that reads like this:
> 
> This is texinfo.info, produced by texi2any version 7.1 from
> texinfo.texi.
> 
> where "texi2any" is set by
>     'PROGRAM' => $real_command_name,
> 
> around line 346 of texi2any.pl
> 
> This can occasionally be a problem for writing file format recognizers
> that depend on parsing the first few lines of a given file

The first line produced is quite bad for format recognition, as there is
nothing constant in the string.  The program should not be considered
constant, since if the Info file was generated by another program (not
texi2any nor makeinfo), the name of the program should be different (the
Info file could also have been generated manually).

Using the first line for the detection of an Info file is not such a
good idea anyway.  In the Info format specification at
https://www.gnu.org/software/texinfo/manual/texinfo/html_node/Info-Format-Preamble.html
the line is described as:
      An arbitrary string beginning the output file, followed by a blank line.

Better targets are the following, but they are not in the beginning of
the file, after the @copying block for the two first and after the @copying and
the @direntry/@dircategory block for the next two:
INFO-DIR-SECTION
START-INFO-DIR-ENTRY
\037\012Indirect:
\037\012Tag Table:

For indirect files, the following could be used:
INFO-DIR-SECTION
START-INFO-DIR-ENTRY
\037\012File:

I had a look at file and the magic file that tries to find the Info file
type, and it is in
https://github.com/file/file/blob/master/magic/Magdir/tex:

0       search/1        This\ is\ Info\ file    GNU Info text
!:mime  text/x-info

It does not actually work since a long time (I had a look at the oldest
texinfo version I have in my computer, 4.1 from 2002, and it is already
more like the current string).

-- 
Pat

Reply via email to