texinfo-commits
[Top][All Lists]
Advanced

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

[5497] info_find_fullpath changes


From: Gavin D. Smith
Subject: [5497] info_find_fullpath changes
Date: Wed, 30 Apr 2014 22:16:57 +0000

Revision: 5497
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5497
Author:   gavin
Date:     2014-04-30 22:16:55 +0000 (Wed, 30 Apr 2014)
Log Message:
-----------
info_find_fullpath changes

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/filesys.c
    trunk/info/filesys.h
    trunk/info/footnotes.c
    trunk/info/indices.c
    trunk/info/info.c
    trunk/info/infopath.c
    trunk/info/nodes.c
    trunk/info/session.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-04-29 23:18:06 UTC (rev 5496)
+++ trunk/ChangeLog     2014-04-30 22:16:55 UTC (rev 5497)
@@ -1,3 +1,39 @@
+2014-04-29  Gavin Smith  <address@hidden>
+
+       * info/indices.c (info_indices_of_file_buffer, index_entry_exists):
+       Comments added.
+
+       * info/infopath.c (infopath_clear)
+       * info/filesys.c (convert_eols, filesys_read_compressed)
+       (compressed_filename_p, filesys_decompressor_for_file): Declared
+       static.
+
+       * info/nodes.c (info_load_file): Deleted.
+       (info_load_file_internal, info_load_file): Renamed.
+
+       * info/footnotes.c (make_footnotes_node): Copy parent field
+       to footnotes field.  This caused problems with automatic-footnotes=On
+       in split files.
+
+       * info/filesys.c (info_find_fullpath). Return 0 on failure
+       as documented, instead of the partial filename.  Set
+       filesys_error_number.  Set new struct stat argument for loaded
+       file.  Don't limit length of path.
+       (local_temp_filename, local_temp_filename_size): Removed.
+       (info_file_find_next_in_path, info_file_in_path)
+       (info_absolute_file): New argument struct stat *finfo. All
+       callers updated.
+
+       * info/nodes.c (info_find_file_internal, info_load_file):
+       Call info_find_fullpath.  This allows finding new files added
+       earlier in the INFOPATH.  Don't call stat directly or set
+       filesys_error_number.
+
+       * info/filesys.c (FILENAME_LIST, names_and_files)
+       (names_and_files_index, names_and_files_slots, lookup_info_filename)
+       (remember_info_filename, forget_file_names): Deleted.  All accesses
+       removed.
+
 2014-04-29  Alexis Hildebrandt <address@hidden> (tiny change)
 
        * doc/refcard/txirefcard.tex: use \raise instead of $^...

Modified: trunk/info/filesys.c
===================================================================
--- trunk/info/filesys.c        2014-04-29 23:18:06 UTC (rev 5496)
+++ trunk/info/filesys.c        2014-04-30 22:16:55 UTC (rev 5497)
@@ -26,12 +26,23 @@
 #include "tag.h"
 
 /* Local to this file. */
-static char *info_file_in_path (char *filename, char *path);
+static char *info_file_in_path (char *filename, char *path, struct stat 
*finfo);
 static char *lookup_info_filename (char *filename);
-static char *info_absolute_file (char *fname);
+static char *info_absolute_file (char *fname, struct stat *finfo);
 
 static void remember_info_filename (char *filename, char *expansion);
 
+static char *filesys_read_compressed (char *pathname, size_t *filesize);
+
+/* Given a chunk of text and its length, convert all CRLF pairs at the
+   EOLs into a single Newline character.  Return the length of produced
+   text.  */
+static long convert_eols (char *text, long textlen);
+
+/* Return the command string that would be used to decompress FILENAME. */
+static char *filesys_decompressor_for_file (char *filename);
+static int compressed_filename_p (char *filename);
+
 typedef struct
 {
   char *suffix;
@@ -74,97 +85,95 @@
 };
 
 /* Expand the filename in PARTIAL to make a real name for this operating
-   system.  This looks in INFO_PATHS in order to find the correct file.
-   If it can't find the file, it returns NULL. */
-static char *local_temp_filename = NULL;
-static int local_temp_filename_size = 0;
-
+   system.  This looks in INFOPATH in order to find the correct file.
+   Return file name and set *FINFO with information about file.  If it
+   can't find the file, it returns NULL, and sets filesys_error_number.
+   Return value should be freed by caller. */
 char *
-info_find_fullpath (char *partial)
+info_find_fullpath (char *partial, struct stat *finfo)
 {
-  int initial_character;
-  char *temp;
+  char *fullpath = 0;
 
   debug(1, (_("looking for file \"%s\""), partial));
 
   filesys_error_number = 0;
 
-  if (partial && (initial_character = *partial))
-    {
-      char *expansion;
+  if (!partial || !*partial)
+    return 0;
+  
+  /* IS_SLASH and IS_ABSOLUTE defined in ../system.h. */
 
-      expansion = lookup_info_filename (partial);
+  if (IS_ABSOLUTE (partial))
+    fullpath = xstrdup (partial);
 
-      if (expansion)
-        return expansion;
+  else if (partial[0] == '~')
+    {
+      fullpath = tilde_expand_word (partial);
+    }
 
-      /* If we have the full path to this file, we still may have to add
-         various extensions to it.  I guess we have to stat this file
-         after all. */
-      if (IS_ABSOLUTE (partial))
-       temp = info_absolute_file (partial);
-      else if (initial_character == '~')
-        {
-          expansion = tilde_expand_word (partial);
-          if (IS_ABSOLUTE (expansion))
-            {
-              temp = info_absolute_file (expansion);
-              free (expansion);
-            }
-          else
-            temp = expansion;
-        }
-      else if (initial_character == '.' &&
-               (IS_SLASH (partial[1]) ||
-               (partial[1] == '.' && IS_SLASH (partial[2]))))
-        {
-          if (local_temp_filename_size < 1024)
-            local_temp_filename = xrealloc
-              (local_temp_filename, (local_temp_filename_size = 1024));
+  /* If filename begins with "./" or "../", view it relative to
+     current directory. */
+  else if (partial[0] == '.'
+           && (IS_SLASH (partial[1])
+               || (partial[1] == '.' && IS_SLASH (partial[2]))))
+    {
+      fullpath = xstrdup (partial);
+#if 0
+      /* Don't limit paths to 1023 bytes, and don't ask for
+         1024 bytes when it isn't needed. 
+         This isn't really necessary, anyway: just do
+         fullpath = xstrdup (partial) and leave ".", ".." as
+         they are.  Always having the full absolute path isn't
+         necessary. */
+      fullpath = xcalloc (1, 1024);
 #if defined (HAVE_GETCWD)
-          if (!getcwd (local_temp_filename, local_temp_filename_size))
+      if (!getcwd (fullpath, 1024))
 #else /*  !HAVE_GETCWD */
-          if (!getwd (local_temp_filename))
+      if (!getwd (fullpath))
 #endif /* !HAVE_GETCWD */
-            {
-              filesys_error_number = errno;
-              return partial;
-            }
-
-          strcat (local_temp_filename, "/");
-          strcat (local_temp_filename, partial);
-         temp = info_absolute_file (local_temp_filename); /* try extensions */
-         if (!temp)
-           partial = local_temp_filename;
-        }
-      else
-        temp = info_file_in_path (partial, infopath ());
-
-      if (temp)
         {
-          remember_info_filename (partial, temp);
-          if (strlen (temp) > (unsigned int) local_temp_filename_size)
-            local_temp_filename = xrealloc
-              (local_temp_filename,
-               (local_temp_filename_size = (50 + strlen (temp))));
-          strcpy (local_temp_filename, temp);
-          free (temp);
-          return local_temp_filename;
+          filesys_error_number = errno;
+          return partial;
         }
+
+      strcat (fullpath, "/");
+      strcat (fullpath, partial);
+#endif
     }
-  return partial;
+
+  else
+    fullpath = info_file_in_path (partial, infopath (), finfo);
+
+  /* If we have the full path to this file, we still may have to add
+     various extensions to it. */
+  if (fullpath)
+    {
+      char *tmp = fullpath;
+      fullpath = info_absolute_file (fullpath, finfo);
+      free (tmp);
+      return fullpath;
+    }
+
+  filesys_error_number = ENOENT;
+  return 0;
 }
 
 /* Scan the list of directories in PATH looking for FILENAME.  If we find
    one that is a regular file, return it as a new string.  Otherwise, return
-   a NULL pointer. */
+   a NULL pointer.  Set *FINFO with information about file. */
 char *
-info_file_find_next_in_path (char *filename, char *path, int *diridx)
+info_file_find_next_in_path (char *filename, char *path, int *diridx,
+                             struct stat *finfo)
 {
-  struct stat finfo;
   char *temp_dirname;
   int statable;
+  struct stat dummy;
 
+  /* Used for output of fstat in case the caller doesn't care about
+     its value. */
+  if (!finfo)
+    finfo = &dummy;
+
   /* Reject ridiculous cases up front, to prevent infinite recursion
      later on.  E.g., someone might say "info '(.)foo'"...  */
   if (!*filename || STREQ (filename, ".") || STREQ (filename, ".."))
@@ -198,24 +207,24 @@
         {
           strcpy (temp + pre_suffix_length, info_suffixes[i]);
 
-          statable = (stat (temp, &finfo) == 0);
+          statable = (stat (temp, finfo) == 0);
 
           /* If we have found a regular file, then use that.  Else, if we
              have found a directory, look in that directory for this file. */
           if (statable)
             {
-              if (S_ISREG (finfo.st_mode))
+              if (S_ISREG (finfo->st_mode))
                 {
                  debug(1, (_("found file %s"), temp));
                   return temp;
                 }
-              else if (S_ISDIR (finfo.st_mode))
+              else if (S_ISDIR (finfo->st_mode))
                 {
                   char *newpath, *filename_only, *newtemp;
 
                   newpath = xstrdup (temp);
                   filename_only = filename_non_directory (filename);
-                  newtemp = info_file_in_path (filename_only, newpath);
+                  newtemp = info_file_in_path (filename_only, newpath, finfo);
 
                   free (newpath);
                   if (newtemp)
@@ -239,8 +248,8 @@
                   strcpy (temp + pre_compress_suffix_length,
                           compress_suffixes[j].suffix);
 
-                  statable = (stat (temp, &finfo) == 0);
-                  if (statable && (S_ISREG (finfo.st_mode)))
+                  statable = (stat (temp, finfo) == 0);
+                  if (statable && (S_ISREG (finfo->st_mode)))
                    {
                      debug(1, (_("found file %s"), temp));
                      return temp;
@@ -254,18 +263,18 @@
 }
 
 static char *
-info_file_in_path (char *filename, char *path)
+info_file_in_path (char *filename, char *path, struct stat *finfo)
 {
   int i = 0;
-  return info_file_find_next_in_path (filename, path, &i);
+  return info_file_find_next_in_path (filename, path, &i, finfo);
 }
 
-/* Assume FNAME is an absolute file name, and check whether it is
-   a regular file.  If it is, return it as a new string; otherwise
+/* Assume FNAME is an absolute file name, and look for it, adding
+   file extensions if necessary.  Return it as a new string; otherwise
    return a NULL pointer.  We do it by taking the file name apart
    into its directory and basename parts, and calling info_file_in_path.*/
 static char *
-info_absolute_file (char *fname)
+info_absolute_file (char *fname, struct stat *finfo)
 {
   char *containing_dir = xstrdup (fname);
   char *base = filename_non_directory (containing_dir);
@@ -273,10 +282,10 @@
   if (base > containing_dir)
     base[-1] = '\0';
 
-  return info_file_in_path (filename_non_directory (fname), containing_dir);
+  return info_file_in_path (filename_non_directory (fname), containing_dir,
+                            finfo);
 }
 
-
 /* Given a string containing units of information separated by the
    PATH_SEP character, return the next one after IDX, or NULL if there
    are no more.  Advance IDX to the character after the colon. */
@@ -307,74 +316,6 @@
     return value;
   }
 }
-
-/* A structure which associates a filename with its expansion. */
-typedef struct
-{
-  char *filename;
-  char *expansion;
-} FILENAME_LIST;
-
-/* An array of remembered arguments and results. */
-static FILENAME_LIST **names_and_files = NULL;
-static int names_and_files_index = 0;
-static int names_and_files_slots = 0;
-
-/* Find the result for having already called info_find_fullpath () with
-   FILENAME. */
-static char *
-lookup_info_filename (char *filename)
-{
-  if (filename && names_and_files)
-    {
-      register int i;
-      for (i = 0; names_and_files[i]; i++)
-        {
-          if (FILENAME_CMP (names_and_files[i]->filename, filename) == 0)
-            return names_and_files[i]->expansion;
-        }
-    }
-  return NULL;
-}
-
-/* Add a filename and its expansion to our list. */
-static void
-remember_info_filename (char *filename, char *expansion)
-{
-  FILENAME_LIST *new;
-
-  if (names_and_files_index + 2 > names_and_files_slots)
-    {
-      int alloc_size;
-      names_and_files_slots += 10;
-
-      alloc_size = names_and_files_slots * sizeof (FILENAME_LIST *);
-
-      names_and_files = xrealloc (names_and_files, alloc_size);
-    }
-
-  new = xmalloc (sizeof (FILENAME_LIST));
-  new->filename = xstrdup (filename);
-  new->expansion = expansion ? xstrdup (expansion) : NULL;
-
-  names_and_files[names_and_files_index++] = new;
-  names_and_files[names_and_files_index] = NULL;
-}
-
-void
-forget_file_names (void)
-{
-  int i;
-
-  for (i = 0; i < names_and_files_index; i++)
-    {
-      free (names_and_files[i]->filename);
-      free (names_and_files[i]->expansion);
-      free (names_and_files[i]);
-      names_and_files[i] = NULL;
-    }
-  names_and_files_index = 0;
-}
 
 /* Given a chunk of text and its length, convert all CRLF pairs at every
    end-of-line into a single Newline character.  Return the length of
@@ -391,7 +332,7 @@
    heuristics here, like in Emacs 20.
 
    FIXME: is it a good idea to show the EOL type on the modeline?  */
-long
+static long
 convert_eols (char *text, long int textlen)
 {
   register char *s = text;
@@ -414,7 +355,8 @@
    that file in it, and returning the size of that buffer in FILESIZE.
    FINFO is a stat struct which has already been filled in by the caller.
    If the file turns out to be compressed, set IS_COMPRESSED to non-zero.
-   If the file cannot be read, return a NULL pointer. */
+   If the file cannot be read, return a NULL pointer.  Set *FINFO with
+   information about file. */
 char *
 filesys_read_info_file (char *pathname, size_t *filesize,
                        struct stat *finfo, int *is_compressed)
@@ -476,7 +418,7 @@
 /* We use some large multiple of that. */
 #define FILESYS_PIPE_BUFFER_SIZE (16 * BASIC_PIPE_BUFFER)
 
-char *
+static char *
 filesys_read_compressed (char *pathname, size_t *filesize)
 {
   FILE *stream;
@@ -564,7 +506,7 @@
 }
 
 /* Return non-zero if FILENAME belongs to a compressed file. */
-int
+static int
 compressed_filename_p (char *filename)
 {
   char *decompressor;
@@ -580,7 +522,7 @@
 }
 
 /* Return the command string that would be used to decompress FILENAME. */
-char *
+static char *
 filesys_decompressor_for_file (char *filename)
 {
   register int i;

Modified: trunk/info/filesys.h
===================================================================
--- trunk/info/filesys.h        2014-04-29 23:18:06 UTC (rev 5496)
+++ trunk/info/filesys.h        2014-04-30 22:16:55 UTC (rev 5497)
@@ -31,9 +31,6 @@
 /* Initialize INFOPATH */
 void infopath_init (void);
 
-/* Make INFOPATH have absolutely nothing in it. */
-extern void infopath_clear (void);
-
 /* Add PATH to the list of paths found in INFOPATH.  2nd argument says
    whether to put PATH at the front or end of INFOPATH. */
 extern void infopath_add (char *path, int where);
@@ -50,16 +47,14 @@
 /* Expand the filename in PARTIAL to make a real name for this operating
    system.  This looks in INFO_PATHS in order to find the correct file.
    If it can't find the file, it returns NULL. */
-extern char *info_find_fullpath (char *partial);
+extern char *info_find_fullpath (char *partial, struct stat *finfo);
 
-/* Forget all cached file names */
-extern void forget_file_names (void);
+/* Scan the list of directories in PATH looking for FILENAME.  If we find
+   one that is a regular file, return it as a new string.  Otherwise, return
+   a NULL pointer. */
+extern char *info_file_find_next_in_path (char *filename, char *path,
+                                         int *diridx, struct stat *finfo);
 
-/* Given a chunk of text and its length, convert all CRLF pairs at the
-   EOLs into a single Newline character.  Return the length of produced
-   text.  */
-long convert_eols (char *text, long textlen);
-
 /* Read the contents of PATHNAME, returning a buffer with the contents of
    that file in it, and returning the size of that buffer in FILESIZE.
    FINFO is a stat struct which has already been filled in by the caller.
@@ -67,12 +62,6 @@
 extern char *filesys_read_info_file (char *pathname, size_t *filesize,
     struct stat *finfo, int *is_compressed);
 
-extern char *filesys_read_compressed (char *pathname, size_t *filesize);
-
-/* Return the command string that would be used to decompress FILENAME. */
-extern char *filesys_decompressor_for_file (char *filename);
-extern int compressed_filename_p (char *filename);
-
 /* A function which returns a pointer to a static buffer containing
    an error message for FILENAME and ERROR_NUM. */
 extern char *filesys_error_string (char *filename, int error_num);
@@ -88,12 +77,6 @@
 /* Return true if FILENAME is `dir', with a possible compression suffix.  */
 extern int is_dir_name (char *filename);
 
-/* Scan the list of directories in PATH looking for FILENAME.  If we find
-   one that is a regular file, return it as a new string.  Otherwise, return
-   a NULL pointer. */
-extern char *info_file_find_next_in_path (char *filename, char *path,
-                                         int *diridx);
-
 /* The default value of INFOPATH. */
 #if !defined (DEFAULT_INFOPATH)
 #  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"

Modified: trunk/info/footnotes.c
===================================================================
--- trunk/info/footnotes.c      2014-04-29 23:18:06 UTC (rev 5496)
+++ trunk/info/footnotes.c      2014-04-30 22:16:55 UTC (rev 5497)
@@ -164,11 +164,11 @@
         }
     }
 
-    node->parent = NULL;
     name_internal_node (result, footnote_nodename);
 
     /* Needed in case the user follows a reference in the footnotes window. */
     result->filename = fn_node->filename;
+    result->parent = fn_node->parent;
 
     free (header);
   }

Modified: trunk/info/indices.c
===================================================================
--- trunk/info/indices.c        2014-04-29 23:18:06 UTC (rev 5496)
+++ trunk/info/indices.c        2014-04-30 22:16:55 UTC (rev 5497)
@@ -102,6 +102,7 @@
   return info_indices_of_file_buffer (fb);
 }
 
+/* Search for index nodes in FILE_BUFFER and built up composite menu. */
 REFERENCE **
 info_indices_of_file_buffer (FILE_BUFFER *file_buffer)
 {
@@ -296,6 +297,8 @@
   }
 }
 
+/* Return 1 if STRING appears in indicies of file_buffer_of_window (WINDOW),
+   0 otherwise. */
 int
 index_entry_exists (WINDOW *window, char *string)
 {

Modified: trunk/info/info.c
===================================================================
--- trunk/info/info.c   2014-04-29 23:18:06 UTC (rev 5496)
+++ trunk/info/info.c   2014-04-30 22:16:55 UTC (rev 5497)
@@ -356,7 +356,7 @@
   
   while (1)
     {
-      p = info_file_find_next_in_path (filename, infopath (), &i);
+      p = info_file_find_next_in_path (filename, infopath (), &i, 0);
       if (argc == argn)
        {
          if (argn == 0)
@@ -404,7 +404,6 @@
     {
       NODE *node;
       
-      forget_file_names ();
       if (!user_filename)
        {
          char *p = dirname (fref[i]->filename);

Modified: trunk/info/infopath.c
===================================================================
--- trunk/info/infopath.c       2014-04-29 23:18:06 UTC (rev 5496)
+++ trunk/info/infopath.c       2014-04-30 22:16:55 UTC (rev 5497)
@@ -31,6 +31,9 @@
 /* If 1, infopath_base has been modified and needs compaction */
 static int infopath_dirty = 0;
 
+/* Make INFOPATH have absolutely nothing in it. */
+static void infopath_clear (void);
+
 /* Return a pointer to the next directory in STR (having length LEN).
    *IDX points to the offset in STR where to start searching.  Return
    NULL if *IDX points at or after the trailing null character.  Otherwise,
@@ -136,7 +139,7 @@
 }
 
 /* Make INFOPATH have absolutely nothing in it. */
-void
+static void
 infopath_clear (void)
 {
   if (infopath_base)

Modified: trunk/info/nodes.c
===================================================================
--- trunk/info/nodes.c  2014-04-29 23:18:06 UTC (rev 5496)
+++ trunk/info/nodes.c  2014-04-30 22:16:55 UTC (rev 5497)
@@ -565,15 +565,15 @@
 
 /* Functions for retrieving files. */
 
-/* Passed to *_internal functions.  INFO_GET_TAGS says to do what is
-   neccessary to fill in the nodes or tags arrays in FILE_BUFFER. */
+/* Passed to info_find_file_internal and info_load_file.  INFO_GET_TAGS
+   says to do what is neccessary to fill in the nodes or tags arrays in
+   FILE_BUFFER. */
 #define INFO_NO_TAGS  0
 #define INFO_GET_TAGS 1
 
 static FILE_BUFFER *info_find_file_internal (char *filename, int get_tags);
 static void get_file_character_encoding (FILE_BUFFER *fb);
-static FILE_BUFFER *info_load_file (char *filename);
-static FILE_BUFFER *info_load_file_internal (char *filename, int get_tags);
+static FILE_BUFFER *info_load_file (char *filename, int get_tags);
 static void remember_info_file (FILE_BUFFER *file_buffer);
 static void info_reload_file_buffer_contents (FILE_BUFFER *fb);
 
@@ -588,15 +588,6 @@
   return info_find_file_internal (filename, INFO_GET_TAGS);
 }
 
-/* Force load the file named FILENAME, and return the information structure
-   describing this file.  Even if the file was already loaded, this loads
-   a new buffer, rebuilds tags and nodes, and returns a new FILE_BUFFER *. */
-static FILE_BUFFER *
-info_load_file (char *filename)
-{
-  return info_load_file_internal (filename, INFO_GET_TAGS);
-}
-
 /* The workhorse for info_find_file ().  Non-zero 2nd argument says to
    try to build a tags table (or otherwise glean the nodes) for this
    file once found.  By default, we build the tags table, but when this
@@ -620,17 +611,16 @@
                     == 0))
           {
             struct stat new_info, *old_info;
+            char *fullpath;
 
+            fullpath = info_find_fullpath (file_buffer->filename, &new_info);
+            if (!fullpath)
+              return NULL;
+            free (fullpath);
+
             /* Check to see if the file has changed since the last
                time it was loaded.  */
-            if (stat (file_buffer->fullpath, &new_info) == -1)
-              {
-                filesys_error_number = errno;
-                return NULL;
-              }
-
             old_info = &file_buffer->finfo;
-
             if (new_info.st_size != old_info->st_size
                 || new_info.st_mtime != old_info->st_mtime)
               {
@@ -663,7 +653,7 @@
     }
 
   /* The file wasn't loaded.  Try to load it now. */
-  file_buffer = info_load_file_internal (filename, get_tags);
+  file_buffer = info_load_file (filename, get_tags);
 
   /* If the file was loaded, remember the name under which it was found. */
   if (file_buffer)
@@ -719,33 +709,31 @@
   fb->encoding = enc_string;
 }
 
-/* The workhorse function for info_load_file ().  Non-zero second argument
-   says to build a list of tags (or nodes) for this file.  This is the
-   default behaviour when info_load_file () is called, but it is not
-   necessary when loading a subfile for which we already have tags. */
+/* Force load the file named FILENAME, and return the information structure
+   describing this file, even if the file was already loaded.  Non-zero
+   second argument says to build a list of tags (or nodes) for this file.
+   This is not necessary when loading a subfile for which we already have
+   tags. */
 static FILE_BUFFER *
-info_load_file_internal (char *filename, int get_tags)
+info_load_file (char *filename, int get_tags)
 {
   char *fullpath, *contents;
   size_t filesize;
   struct stat finfo;
-  int retcode, compressed;
+  int compressed;
   FILE_BUFFER *file_buffer = NULL;
   
   /* Get the full pathname of this file, as known by the info system.
      That is to say, search along INFOPATH and expand tildes, etc. */
-  fullpath = info_find_fullpath (filename);
+  fullpath = info_find_fullpath (filename, &finfo);
 
-  /* Did we actually find the file? */
-  retcode = stat (fullpath, &finfo);
-
   /* If the file referenced by the name returned from info_find_fullpath ()
      doesn't exist, then try again with the last part of the filename
      appearing in lowercase. */
   /* This is probably not needed at all on those systems which define
      FILENAME_CMP to be mbscasecmp.  But let's do it anyway, lest some
      network redirector supports case sensitivity.  */
-  if (retcode < 0)
+  if (!fullpath)
     {
       char *lowered_name;
       char *tmp_basename;
@@ -761,18 +749,14 @@
           tmp_basename++;
         }
 
-      fullpath = info_find_fullpath (lowered_name);
+      fullpath = info_find_fullpath (lowered_name, &finfo);
 
-      retcode = stat (fullpath, &finfo);
       free (lowered_name);
     }
 
   /* If the file wasn't found, give up, returning a NULL pointer. */
-  if (retcode < 0)
-    {
-      filesys_error_number = errno;
-      return NULL;
-    }
+  if (!fullpath)
+    return NULL;
 
   /* Otherwise, try to load the file. */
   contents = filesys_read_info_file (fullpath, &filesize, &finfo, &compressed);
@@ -784,7 +768,7 @@
      in the various members. */
   file_buffer = make_file_buffer ();
   file_buffer->filename = xstrdup (filename);
-  file_buffer->fullpath = xstrdup (fullpath);
+  file_buffer->fullpath = fullpath;
   file_buffer->finfo = finfo;
   file_buffer->filesize = filesize;
   file_buffer->contents = contents;
@@ -977,6 +961,7 @@
 
   /* Find the correct info file, or give up.  */
   file_buffer = info_find_file (filename);
+
   if (file_buffer)
     {
       /* Look for the node.  */

Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c        2014-04-29 23:18:06 UTC (rev 5496)
+++ trunk/info/session.c        2014-04-30 22:16:55 UTC (rev 5497)
@@ -3583,6 +3583,7 @@
 {
   FILE *output_stream;
   char *nodes_filename;
+  char *fullpath;
 
   debug (1, (_("writing file %s"), filename));
   
@@ -3608,8 +3609,11 @@
   
   if (flags & DUMP_APPEND)
     fputc ('\f', output_stream);
-  fprintf (output_stream, "%s\n", info_find_fullpath (node->filename));
 
+  fullpath = info_find_fullpath (node->filename, 0);
+  fprintf (output_stream, "%s\n", fullpath);
+  free (fullpath);
+
   if (dump_node_to_stream (nodes_filename, node->nodename,
                           output_stream, flags & DUMP_SUBNODES)
       == DUMP_SYS_ERROR)
@@ -5235,7 +5239,7 @@
 DECLARE_INFO_COMMAND (info_display_file_info,
                      _("Show full file name of node being displayed"))
 {
-  const char *fname = info_find_fullpath (window->node->filename);
+  char *fname = info_find_fullpath (window->node->filename, 0);
   if (fname)
     {
       int line = window_line_of_point (window);
@@ -5243,6 +5247,7 @@
                                   fname, line,
                                   (unsigned long) window->line_count,
                                   line * 100 / window->line_count);
+      free (fname);
     }
   else
     window_message_in_echo_area ("Internal node");




reply via email to

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