]> git.ipfire.org Git - people/ms/gcc.git/commit
**/*.texi: Reorder index entries
authorArsen Arsenović <arsen@aarsen.me>
Thu, 23 Feb 2023 10:27:11 +0000 (11:27 +0100)
committerGerald Pfeifer <gerald@pfeifer.com>
Thu, 23 Feb 2023 22:42:01 +0000 (23:42 +0100)
commitf33d7a88d069d169bbe76da8e5c52de17f68ca05
tree6d399142c972278067733d030a73fb2e807af488
parentf83e76c3f998c8708fe2ddca16ae3f317c39c37a
**/*.texi: Reorder index entries

This change is a generalization of r13-6292-gddf6fe375d9110.

Historically, makeinfo exhibited a bug, due to which a structure like:

  @item foo
  @cindex foo
  @cindex bar

... would be transformed into an item heading, with the first index
entry on it, followed by an item body, with the second index entry in
it.  This has often lead to index entries not linking to relevant items,
but rather, just below them.

This bug was exhibited in both Info and HTML documentation, and was most
glaringly obvious in the latter.

After a discussion with the Texinfo developers, it was decided that the
appropriate construct for this case is:

  @cindex foo
  @cindex bar
  @item foo

... which behaves correctly in newer versions, linking all the index
entries to the item itself.  This pattern also produces copiable
anchors in HTML output.

This commit fixes most indices to follow the pattern above, however,
omits relevant changes in the Ada manuals, as the algorithm described
below lead to many false positives and unwanted changes in that manual.

Much like the previous commit, this change is mostly mechanical, with a
simple script.  I have, however, gone over the patch myself also, to see
if there's anything that ought to be kept as-is.  Formatter:

  # GPL3+
  use v5.35;
  use strict;
  use warnings;

  my @lineq = ();
  my @itemq = ();
  my @indxq = ();
  my $lstin = 0;

  while (<>)
    {
      push (@lineq, $_);
      if (/^\@[a-zA-Z0-9]{1,2}index\W/)
        {
          $lstin = @lineq;
          push (@indxq, $_);
          next;
        }
      if (/^\@itemx?\W/)
        {
          $lstin = @lineq;
          push (@itemq, $_);
          next;
        }
      next if $lstin && /^\s*(\@c(omment)?\W.*)?$/;

      if (@indxq and @itemq)
        {
          print @indxq;
          print @itemq;
          print @lineq[$lstin..@lineq-1];
        }
      else
        {
          print @lineq;
        }
      @lineq = ();
      @itemq = ();
      @indxq = ();
      $lstin = 0;
    }

  if (@indxq and @itemq)
    {
      print @indxq;
      print @itemq;
      print @lineq[$lstin..@lineq-1];
    }
  else
    {
      print @lineq;
    }

  # Local Variables:
  # indent-tabs-mode: nil
  # End:

gcc/d/ChangeLog:

* implement-d.texi: Reorder index entries around @items.

gcc/ChangeLog:

* doc/cfg.texi: Reorder index entries around @items.
* doc/cpp.texi: Ditto.
* doc/cppenv.texi: Ditto.
* doc/cppopts.texi: Ditto.
* doc/generic.texi: Ditto.
* doc/install.texi: Ditto.
* doc/extend.texi: Ditto.
* doc/invoke.texi: Ditto.
* doc/md.texi: Ditto.
* doc/rtl.texi: Ditto.
* doc/tm.texi.in: Ditto.
* doc/trouble.texi: Ditto.
* doc/tm.texi: Regenerate.

gcc/fortran/ChangeLog:

* invoke.texi: Reorder index entries around @items.

gcc/go/ChangeLog:

* gccgo.texi: Reorder index entries around @items.
16 files changed:
gcc/d/implement-d.texi
gcc/doc/cfg.texi
gcc/doc/cpp.texi
gcc/doc/cppenv.texi
gcc/doc/cppopts.texi
gcc/doc/extend.texi
gcc/doc/generic.texi
gcc/doc/install.texi
gcc/doc/invoke.texi
gcc/doc/md.texi
gcc/doc/rtl.texi
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/doc/trouble.texi
gcc/fortran/invoke.texi
gcc/go/gccgo.texi