allow for info files and dir entries with subdirs
patch by Gavin Smith on the bug-texinfo and debbug 792328
---
 ChangeLog      |   16 ++++++++++++++++
 info/filesys.c |   31 +++++++++++++++++++++----------
 info/info.c    |   29 ++++++++++++++++++++++++-----
 info/nodes.c   |    3 ++-
 4 files changed, 63 insertions(+), 16 deletions(-)

--- texinfo.orig/ChangeLog
+++ texinfo/ChangeLog
@@ -1,3 +1,19 @@
+2015-07-15  Gavin Smith  <gavinsmith0123@gmail.com>
+
+	* info/nodes.c (info_find_file): If filename has slash, look for
+	it in search path if it does not begin "./".
+	* info/filesys.c (info_find_fullpath): Don't look for a filename 
+	beginning "./" in the search path, but otherwise look for the 
+	filename in the search path even if it contains a slash.
+	(info_file_find_next_in_path): Prefix returned path with "./" if 
+	it is relative to the current directory.
+	(info_add_extension): Allow second argument to be null.
+
+	* info/info.c (main) <--file or slash in argument>: If argument 
+	not an absolute path, prefix it with "./".  Call 
+	info_add_extension instead of info_find_fullpath for arguments 
+	other than simple filenames.
+
 2015-07-05  Patrice Dumas  <pertusus@free.fr>
 
 	* tp/Texinfo/Structuring.pm (_sort_index_entries,
--- texinfo.orig/info/filesys.c
+++ texinfo/info/filesys.c
@@ -77,8 +77,7 @@
   { NULL, NULL }
 };
 
-/* Expand the filename in PARTIAL to make a real name for this operating
-   system.  This looks in INFOPATH in order to find the correct file.
+/* Look for the filename PARTIAL 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. */
@@ -101,7 +100,8 @@
   /* IS_SLASH and IS_ABSOLUTE defined in ../system.h. */
 
   /* If path is absolute already, see if it needs an extension. */
-  if (IS_ABSOLUTE (partial))
+  if (IS_ABSOLUTE (partial)
+      || partial[0] == '.' && IS_SLASH(partial[1]))
     {
       fullpath = info_add_extension (0, partial, finfo);
     }
@@ -113,12 +113,6 @@
       fullpath = info_add_extension (0, partial, finfo);
     }
 
-  /* If filename has a slash in it (for example, begins with "./" or "../", or
-     if there are intermediate directories) interpret it as relative to current
-     directory.  This may be from the command line, or in the subfiles table of
-     a split file. */
-  else if (HAS_SLASH (partial))
-    fullpath = info_add_extension (0, partial, finfo);
   /* If just a simple name element, look for it in the path. */
   else
     fullpath = info_file_in_path (partial, finfo);
@@ -168,11 +162,24 @@
       with_extension = info_add_extension (dirname, filename, finfo);
 
       if (with_extension)
-        return with_extension;
+        {
+          if (!IS_ABSOLUTE (with_extension))
+            {
+              /* Prefix "./" to it. */
+              char *s;
+              asprintf (&s, "%s%s", "./", with_extension);
+              free (with_extension);
+              return s;
+            }
+          else
+            return with_extension;
+        }
     }
   return NULL;
 }
 
+/* Return full path of first Info file known as FILENAME in
+   search path.  If relative to current directory, precede it with './'. */
 static char *
 info_file_in_path (char *filename, struct stat *finfo)
 {
@@ -189,6 +196,10 @@
 {
   char *try_filename;
   register int i, pre_suffix_length = 0;
+  struct stat dummy;
+
+  if (!finfo)
+    finfo = &dummy;
 
   if (dirname)
     pre_suffix_length += strlen (dirname);
--- texinfo.orig/info/info.c
+++ texinfo/info/info.c
@@ -825,7 +825,7 @@
      for a matching entry. */
   if (!user_filename && argv[0] && HAS_SLASH (argv[0]))
     {
-      user_filename = argv[0];
+      user_filename = xstrdup (argv[0]);
       argv++; /* Advance past first remaining argument. */
       argc--;
     }
@@ -873,7 +873,7 @@
       /* --all */
       if (!user_filename && argv[0])
         {
-          user_filename = argv[0];
+          user_filename = xstrdup (argv[0]);
           argv++; argc--;
         }
       else if (!user_filename)
@@ -904,9 +904,28 @@
       /* User used "--file". */
       if (user_filename)
         {
-          initial_file = info_find_fullpath (user_filename, 0);
-          if (!initial_file && filesys_error_number)
-            error = filesys_error_string (user_filename, filesys_error_number);
+          if (!IS_ABSOLUTE(user_filename) && HAS_SLASH(user_filename)
+              && !(user_filename[0] == '.' && IS_SLASH(user_filename[1])))
+            {
+              /* Prefix "./" to the filename to prevent a lookup
+                 in INFOPATH.  */
+              char *s;
+              asprintf (&s, "%s%s", "./", user_filename);
+              free (user_filename);
+              user_filename = s;
+            }
+          if (IS_ABSOLUTE(user_filename) || HAS_SLASH(user_filename))
+            initial_file = info_add_extension (0, user_filename, 0);
+          else
+            initial_file = info_find_fullpath (user_filename, 0);
+
+          if (!initial_file)
+            {
+              if (!filesys_error_number)
+                filesys_error_number = ENOENT;
+              error = filesys_error_string (user_filename, 
+                                            filesys_error_number);
+            }
           else
             add_pointer_to_array (info_new_reference (initial_file, "Top"),
                                   ref_index, ref_list, ref_slots, 2);
--- texinfo.orig/info/nodes.c
+++ texinfo/info/nodes.c
@@ -559,7 +559,8 @@
   int is_fullpath;
   
   /* If full path to the file has been given, we must find it exactly. */
-  is_fullpath = IS_ABSOLUTE (filename) || HAS_SLASH (filename);
+  is_fullpath = IS_ABSOLUTE (filename)
+                || filename[0] == '.' && IS_SLASH(filename[1]);
 
   /* First try to find the file in our list of already loaded files. */
   if (info_loaded_files)
