bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: info: INFOPATH interpretation severely flawed


From: Bruno Haible
Subject: Re: info: INFOPATH interpretation severely flawed
Date: Sun, 06 May 2012 22:56:02 +0200
User-agent: KMail/4.7.4 (Linux/3.1.10-1.9-desktop; KDE/4.7.4; x86_64; ; )

Eli Zaretskii wrote:
> it's a flaw in the basic design of the Info system: it doesn't
> cope well, to say the least, with several versions of the same manual
> that are accessible from the same Info session.

OK, now where to put the improvement/fix?

Inside 'install-info', it's too early to detect "conflicts", because
$INFOPATH is not known at that time.

> > The one who maintains the 'dir' files is the 'install-info' program -
> > from texinfo 4.13.
> 
> I meant the human who maintains the Info installations.

But installation of packages is supposed to be performed through
"make install" without human intervention.

So, an approach that relies on the user to clean up 'dir' files is
IMO not practical.

Therefore, let's concentrate on the 'info' program:

> >   a) In this synthetic 'dir' file (which only exists in memory of 'info'
> >      before it is presented to the user), remember which portion came
> >      from which directory.
> > 
> >   b) When creating this synthetic 'dir' file, use absolute file names
> >      of 'info' files everywhere, e.g.
> > 
> >        * Automake: 
> > (/arch/x86-linux/gnu-inst-automake/1.11.2/share/info/automake).
> >                            Making GNU standards-compliant Makefiles.
> > 
> >      and make 'info' understand these absolute file names.
> 
> This is doable, but is not free of disadvantages.  First, there's no
> requirement that each directory on INFOPATH should have its own 'dir'
> file.

True, you need to keep the "hand-maintained dir file" approach supported.
But for the vast majority of users, it's distros of packages with
post_install actions and packages installed via "make install" which will
maintain the 'dir' file. Thus, it is *normal* that every directory listed
in $INFOPATH will have a 'dir' file.

> Second, I think this will slow down Info startup, because it
> will need to look for every Info file in every 'dir', to resolve its
> full absolute file name.

This can be avoided: You need to cache only the directory of the
'dir' file. You combine this directory name and "automake.info" only just
before you access it.

> By contrast, currently the Info reader just parses the 'dir' files at
> startup.

So it does something like

  dir_buffer = ""
  for directory in $INFOPATH
    dir_buffer += contents of $directory/dir
  done

and when the command-line asks to look up a menu-item, this search is
performed like this:

  filename = none
  node = none
  for line in dir_buffer
    if $line matches $menuitem, take filename and node from $line; break
  done
  if $filename != none
    buffer = none
    for directory in $INFOPATH
      if $directory/$filename.info exists
        buffer = open($directory/$filename.info), break
    done
    if $buffer == none
      buffer = contents of "man menuitem"
    if $node != none
      go to node $node in buffer.

The solution I'm seeing is to apply this variation:

  dir_buffer = ""
  dir_buffer_regions = {}
  for directory in $INFOPATH
    dir_buffer += contents of $directory/dir
    dir_buffer_regions += (start offset of this contents in $dir_buffer,
                           end offset of this contents in $dir_buffer,
                           $directory)
  done

and for the search:

  filename = none
  associated_directory = none
  node = none
  for line in dir_buffer
    if $line matches $menuitem
      take filename and node from $line
      for (start_offset, end_offset, directory) in $dir_buffer_regions
        if line lies between start_offset and end_offset
          associated_directory = $directory
      break
  done
  if $filename != none
    buffer = none
    if $associated_directory != none
             && $associated_directory/$filename.info exists
      buffer = open($associated_directory/$filename.info
    else
      for directory in $INFOPATH
        if $directory != $associated_directory
          if $directory/$filename.info exists
            buffer = open($directory/$filename.info), break
    done
    if $buffer == none
      buffer = contents of "man menuitem"
    if $node != none
      go to node $node in buffer.

In this way,
  - while creating the dir_buffer, you don't need to make more file
    accesses; just store the associated directory in the dir_buffer_regions
    (list of triples),
  - while looking up the info file for the given menu item, you don't
    need to make more file accesses either; just look in the directory
    where the specific region of the dir_buffer came from first, and in
    the remaining elements of $INFOPATH afterwards.

It is maybe not exactly like this, but you get the idea.

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]