texinfo-commits
[Top][All Lists]
Advanced

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

texinfo ChangeLog NEWS info/filesys.c info/file...


From: Karl Berry
Subject: texinfo ChangeLog NEWS info/filesys.c info/file...
Date: Sat, 14 Mar 2009 17:31:30 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Karl Berry <karl>       09/03/14 17:31:30

Modified files:
        .              : ChangeLog NEWS 
        info           : filesys.c filesys.h 
        doc            : info-stnd.texi 

Log message:
        support dynamically getting INFOPATH from PATH, by default

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/ChangeLog?cvsroot=texinfo&r1=1.979&r2=1.980
http://cvs.savannah.gnu.org/viewcvs/texinfo/NEWS?cvsroot=texinfo&r1=1.186&r2=1.187
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/filesys.c?cvsroot=texinfo&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/filesys.h?cvsroot=texinfo&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/texinfo/doc/info-stnd.texi?cvsroot=texinfo&r1=1.24&r2=1.25

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/texinfo/texinfo/ChangeLog,v
retrieving revision 1.979
retrieving revision 1.980
diff -u -b -r1.979 -r1.980
--- ChangeLog   7 Feb 2009 19:45:36 -0000       1.979
+++ ChangeLog   14 Mar 2009 17:31:29 -0000      1.980
@@ -1,3 +1,10 @@
+2009-03-14  Peter Breitenlohner  <address@hidden>
+
+       * info/filesys.c (build_infopath_from_path): new fn.
+       (info_add_path): if INFOPATH includes the word "PATH",
+       call the new fn.
+       * doc/info-stnd.texi (Invoking Info) <directory-path>: document it.
+
 2009-02-07  Karl Berry  <address@hidden>
 
        * doc/texinfo.txi (Not Ending a Sentence): also mention ).

Index: NEWS
===================================================================
RCS file: /sources/texinfo/texinfo/NEWS,v
retrieving revision 1.186
retrieving revision 1.187
diff -u -b -r1.186 -r1.187
--- NEWS        19 Jan 2009 01:56:13 -0000      1.186
+++ NEWS        14 Mar 2009 17:31:30 -0000      1.187
@@ -1,9 +1,10 @@
-$Id: NEWS,v 1.186 2009/01/19 01:56:13 karl Exp $
+$Id: NEWS,v 1.187 2009/03/14 17:31:30 karl Exp $
 This NEWS file records noteworthy changes, very tersely.
 See the manual for detailed information.
 
-  Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-  2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+  Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+  2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
+  Foundation, Inc.
 
   Copying and distribution of this file, with or without modification,
   are permitted in any medium without royalty provided the copyright
@@ -28,6 +29,10 @@
   . new diacritic command @ogonek.
   . DEL (0x7f = 0177 = 127) is a true comment character (catcode 14 in TeX).
 
+* info:
+  . INFOPATH is determined by PATH by default, or if an element "PATH"
+    is specified.
+
 * texinfo.tex:
   . support some per-language hyphenation, when the underlying TeX
     engine does (for instance, etex/pdfetex from TeX Live 2008).  Words

Index: info/filesys.c
===================================================================
RCS file: /sources/texinfo/texinfo/info/filesys.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- info/filesys.c      11 Jun 2008 09:55:42 -0000      1.12
+++ info/filesys.c      14 Mar 2009 17:31:30 -0000      1.13
@@ -1,7 +1,7 @@
 /* filesys.c -- filesystem specific functions.
-   $Id: filesys.c,v 1.12 2008/06/11 09:55:42 gray Exp $
+   $Id: filesys.c,v 1.13 2009/03/14 17:31:30 karl Exp $
 
-   Copyright (C) 1993, 1997, 1998, 2000, 2002, 2003, 2004, 2007, 2008
+   Copyright 1993, 1997, 1998, 2000, 2002, 2003, 2004, 2007, 2008, 2009
    Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -17,7 +17,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-   Written by Brian Fox (address@hidden). */
+   Originally written by Brian Fox. */
 
 #include "info.h"
 
@@ -28,6 +28,7 @@
 static char *info_file_in_path (char *filename, char *path);
 static char *lookup_info_filename (char *filename);
 static char *info_absolute_file (char *fname);
+static char *build_infopath_from_path (void);
 
 static void remember_info_filename (char *filename, char *expansion);
 static void maybe_initialize_infopath (void);
@@ -55,8 +56,8 @@
 static COMPRESSION_ALIST compress_suffixes[] = {
   { ".gz", "gunzip" },
   { ".bz2", "bunzip2" },
-  { ".lzma", "unlzma" },
   { ".z", "gunzip" },
+  { ".lzma", "unlzma" },
   { ".Z", "uncompress" },
   { ".Y", "unyabba" },
 #ifdef __MSDOS__
@@ -364,12 +365,149 @@
     }
 }
 
+/* For each path element PREFIX/DIR in PATH substitute either
+   PREFIX/share/info or PREFIX/info if that directory exists.
+   Avoid duplicates from, e.g., PREFIX/bin and PREFIX/sbin. */
+static char *
+build_infopath_from_path (void)
+{
+  typedef struct path_el
+    {
+      struct path_el *next;
+      char *path;
+      unsigned int len;
+    } PATH_EL, *PATH_PTR;
+
+  PATH_EL path_head = { NULL, NULL, 1 };
+  PATH_PTR path_prev, path_next;
+  char *res, *path_from_env, *temp_dirname;
+  int dirname_index = 0;
+  struct stat finfo;
+
+  path_from_env = getenv ("PATH");
+
+  while ((temp_dirname = extract_colon_unit (path_from_env, &dirname_index)))
+    {
+      unsigned int i, dir = 0;
+
+      /* Find end of DIRNAME/ (but ignore "/") */
+      for (i = 0; temp_dirname[i]; i++)
+        if (i && IS_SLASH (temp_dirname[i]))
+          dir = i + 1;
+
+      /* Discard path elements ending with "/", "/.", or "/.." */
+      if (!temp_dirname[dir] || STREQ (temp_dirname + dir, ".") || STREQ 
(temp_dirname + dir, "."))
+        dir = 0;
+      
+      path_prev = &path_head;
+      while (dir && (path_next = path_prev->next))
+        {
+          /* Ignore duplicate DIRNAME */
+          if (dir == path_next->len && strncmp (temp_dirname, path_next->path, 
dir) == 0)
+            dir = 0;
+
+          path_prev = path_next;
+        }
+
+      if (dir)
+        {
+          temp_dirname = xrealloc (temp_dirname, dir + strlen ("share/info") 
+1);
+
+          /* first try DIRNAME/share/info */
+          strcpy (temp_dirname + dir, "share/info");
+          if (stat (temp_dirname, &finfo) != 0 || !S_ISDIR (finfo.st_mode))
+            {
+              /* then try DIRNAME/info */
+              strcpy (temp_dirname + dir, "info");
+              if (stat (temp_dirname, &finfo) != 0 || !S_ISDIR (finfo.st_mode))
+                dir = 0;
+            }
+        }
+
+      if (dir)
+        {
+          path_next = xmalloc (sizeof (PATH_EL));
+          path_next->next = NULL;
+          path_next->path = temp_dirname;
+          path_next->len = dir;
+          path_prev->next = path_next;
+          path_head.len += strlen (temp_dirname) + 1;
+        }
+      else
+        free (temp_dirname);
+    }
+
+  /* Build the resulting sequence of paths */
+  res = xmalloc (path_head.len);
+  res[0] = '\0';
+
+  for (path_prev = path_head.next; path_prev; path_prev = path_next)
+    {
+      strcat (res, path_prev->path);
+      if ((path_next = path_prev->next))
+        strcat (res, PATH_SEP);
+
+      free (path_prev->path);
+      free (path_prev);
+    }
+
+  return res;
+}
+
 /* Add PATH to the list of paths found in INFOPATH.  2nd argument says
-   whether to put PATH at the front or end of INFOPATH. */
+   whether to put PATH at the front or end of INFOPATH.
+   Replace one path element "PATH" in PATH by a sequence of
+   path elements derived from the environment variable PATH. */
 void
 info_add_path (char *path, int where)
 {
   int len;
+  int found = 0;
+  unsigned int i, j;
+
+  /* Search for "PATH" in PATH */
+  for (i = 0; path[i]; i++)
+    {
+      j = i + strlen ("PATH");
+      if (strncmp (path + i, "PATH", strlen ("PATH")) == 0 &&
+          (!path[j] || path[j] == PATH_SEP[0]))
+        {
+          found = 1;
+          break;
+        }
+      else
+        {
+          /* Advance to next PATH_SEP.  */
+          while (path[i] && path[i] != PATH_SEP[0])
+            i++;
+
+          if (!path[i])
+            break;
+        }
+    }
+
+  if (found)
+    {
+      /* Build infopath from the environment variable PATH */
+      char *temp = build_infopath_from_path ();
+
+      if (i || path[j])
+        {
+          char *old_path = path;
+
+          /* Splice it into OLD_PATH */
+          path = xmalloc (1 + strlen (temp) + strlen (old_path) - strlen 
("PATH"));
+          if (i)
+            strncpy (path, old_path, i);
+          strcpy (path + i, temp);
+          if (old_path[j])
+            strcat (path, old_path + j);
+
+          free (temp);
+        }
+      else
+        path = temp;
+    }
 
   if (!infopath)
     {
@@ -397,6 +535,9 @@
       strcat (infopath, temp);
       free (temp);
     }
+
+  if (found)
+    free (path);
 }
 
 /* Make INFOPATH have absolutely nothing in it. */

Index: info/filesys.h
===================================================================
RCS file: /sources/texinfo/texinfo/info/filesys.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- info/filesys.h      1 Jul 2007 21:20:29 -0000       1.7
+++ info/filesys.h      14 Mar 2009 17:31:30 -0000      1.8
@@ -1,7 +1,7 @@
 /* filesys.h -- external declarations for filesys.c.
-   $Id: filesys.h,v 1.7 2007/07/01 21:20:29 karl Exp $
+   $Id: filesys.h,v 1.8 2009/03/14 17:31:30 karl Exp $
 
-   Copyright (C) 1993, 1997, 1998, 2002, 2004, 2005, 2007 Free Software
+   Copyright 1993, 1997, 1998, 2002, 2004, 2005, 2007, 2009 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -17,7 +17,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-   Written by Brian Fox (address@hidden). */
+   Originally written by Brian Fox. */
 
 #ifndef INFO_FILESYS_H
 #define INFO_FILESYS_H
@@ -78,7 +78,7 @@
 
 /* The default value of INFOPATH. */
 #if !defined (DEFAULT_INFOPATH)
-#  define DEFAULT_INFOPATH 
".:/usr/local/info:/usr/info:/usr/local/lib/info:/usr/lib/info:/usr/local/gnu/info:/usr/local/gnu/lib/info:/usr/gnu/info:/usr/gnu/lib/info:/opt/gnu/info:/usr/share/info:/usr/share/lib/info:/usr/local/share/info:/usr/local/share/lib/info:/usr/gnu/lib/emacs/info:/usr/local/gnu/lib/emacs/info:/usr/local/lib/emacs/info:/usr/local/emacs/info"
+#  define DEFAULT_INFOPATH 
".:PATH:/usr/local/info:/usr/info:/usr/local/lib/info:/usr/lib/info:/usr/local/gnu/info:/usr/local/gnu/lib/info:/usr/gnu/info:/usr/gnu/lib/info:/opt/gnu/info:/usr/share/info:/usr/share/lib/info:/usr/local/share/info:/usr/local/share/lib/info:/usr/gnu/lib/emacs/info:/usr/local/gnu/lib/emacs/info:/usr/local/lib/emacs/info:/usr/local/emacs/info"
 #endif /* !DEFAULT_INFOPATH */
 
 #if !defined (S_ISREG) && defined (S_IFREG)

Index: doc/info-stnd.texi
===================================================================
RCS file: /sources/texinfo/texinfo/doc/info-stnd.texi,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- doc/info-stnd.texi  29 Aug 2008 17:27:18 -0000      1.24
+++ doc/info-stnd.texi  14 Mar 2009 17:31:30 -0000      1.25
@@ -1,5 +1,5 @@
 vb\input texinfo.tex    @c -*-texinfo-*-
address@hidden $Id: info-stnd.texi,v 1.24 2008/08/29 17:27:18 karl Exp $
address@hidden $Id: info-stnd.texi,v 1.25 2009/03/14 17:31:30 karl Exp $
 @c We must \input texinfo.tex instead of texinfo, otherwise make
 @c distcheck in the Texinfo distribution fails, because the texinfo Info
 @c file is made first, and texi2dvi must include . first in the path.
@@ -151,10 +151,11 @@
 @itemx -d @var{directory-path}
 Prepend @var{directory-path} to the list of directory paths searched
 when Info needs to find a file.  You may issue @code{--directory}
-multiple times; once for each directory which contains Info files.  The
-list of directories searched by Info is constructed from the value of
-the environment variable @code{INFOPATH}; @code{--directory} causes the
-named @var{directory-path} to be prepended to that list.  The value of
+multiple times; once for each directory which contains Info files,
+or with a list of such directories separated by a colon (or semicolon
+on MS-DOS/MS-Windows).  In the absence of @code{--directory} options
+the list of directories searched by Info is constructed from the
+value of the environment variable @code{INFOPATH}.  The value of
 @code{INFOPATH} is a list of directories usually separated by a colon;
 on MS-DOS/MS-Windows systems, the semicolon is used.  If you do not
 define @code{INFOPATH}, Info uses a default path defined when Info was
@@ -163,6 +164,12 @@
 the initial list of directories is constructed by appending the
 build-time default to the value of @code{INFOPATH}.
 
+If the list of directories contains the element @code{PATH}, that
+element is replaced by a list of directories derived from the value of
+the environment variable @code{PATH}.  Each path element of the form
address@hidden/base} is replaced by @address@hidden/share/info} or
address@hidden@code{/info}, provided that directory exists.
+
 @cindex keystrokes, recording
 @cindex remembering user keystrokes
 @item address@hidden




reply via email to

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