Index: ChangeLog =================================================================== --- ChangeLog (revision 6432) +++ ChangeLog (working copy) @@ -1,5 +1,21 @@ 2015-07-15 Gavin Smith + * 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-15 Gavin Smith + * info/t/dir-entry-to-subdir.sh: New test. 2015-07-15 Gavin Smith Index: info/filesys.c =================================================================== --- info/filesys.c (revision 6430) +++ info/filesys.c (working copy) @@ -77,8 +77,7 @@ static COMPRESSION_ALIST compress_suffixes[] = { { 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 @@ info_find_fullpath (char *partial, struct stat *fi /* 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 @@ info_find_fullpath (char *partial, struct stat *fi 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 @@ info_file_find_next_in_path (char *filename, int * 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,7 +196,11 @@ info_add_extension (char *dirname, char *filename, { char *try_filename; register int i, pre_suffix_length = 0; + struct stat dummy; + if (!finfo) + finfo = &dummy; + if (dirname) pre_suffix_length += strlen (dirname); Index: info/info.c =================================================================== --- info/info.c (revision 6430) +++ info/info.c (working copy) @@ -825,7 +825,7 @@ There is NO WARRANTY, to the extent permitted by l 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 @@ There is NO WARRANTY, to the extent permitted by l /* --all */ if (!user_filename && argv[0]) { - user_filename = argv[0]; + user_filename = xstrdup (argv[0]); argv++; argc--; } else if (!user_filename) @@ -904,10 +904,29 @@ There is NO WARRANTY, to the extent permitted by l /* 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); goto skip_get_initial_file; Index: info/nodes.c =================================================================== --- info/nodes.c (revision 6430) +++ info/nodes.c (working copy) @@ -558,7 +558,8 @@ info_find_file (char *filename) 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) Index: info/t/infodir/dir =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream