- return fn_tilde_expand (base_name);
-
- /* Interpolate environment variables. */
- ds_create (&path, path_);
- fn_interp_vars (&path, fn_getenv);
-
- verbose_msg (2, _("searching for \"%s\" in path \"%s\""),
- base_name, ds_c_str (&path));
- while (ds_separate (&path, &dir, PATH_DELIMITER_STRING, &save_idx))
- {
- /* Do tilde expansion. */
- if (ds_first (&dir) == '~')
- {
- char *tmp_str = fn_tilde_expand (ds_c_str (&dir));
- ds_assign_c_str (&dir, tmp_str);
- free (tmp_str);
- }
-
- /* Construct file name. */
- ds_clear (&file);
- if (prefix != NULL && !fn_is_absolute (ds_c_str (&dir)))
- {
- ds_puts (&file, prefix);
- ds_putc (&file, DIR_SEPARATOR);
- }
- ds_puts (&file, ds_c_str (&dir));
- if (ds_length (&dir) && ds_last (&file) != DIR_SEPARATOR)
- ds_putc (&file, DIR_SEPARATOR);
- ds_puts (&file, base_name);
-
- /* Check whether file exists. */
- if (fn_exists (ds_c_str (&file)))
- {
- verbose_msg (2, _("...found \"%s\""), ds_c_str (&file));
- ds_destroy (&path);
- ds_destroy (&dir);
- return ds_c_str (&file);
- }
- }
-
- /* Failure. */
- verbose_msg (2, _("...not found"));
- ds_destroy (&path);
- ds_destroy (&dir);
- ds_destroy (&file);
- return NULL;
-}
-
-/* fn_normalize(): This very OS-dependent routine canonicalizes
- filename FN1. The filename should not need to be the name of an
- existing file. Returns a malloc()'d copy of the canonical name.
- This function must always succeed; if it needs to bail out then it
- should return xstrdup(FN1). */
-#ifdef unix
-char *
-fn_normalize (const char *filename)
-{
- const char *src;
- char *fn1, *fn2, *dest;
- int maxlen;
-
- if (fn_is_special (filename))
- return xstrdup (filename);
-
- fn1 = fn_tilde_expand (filename);