]> git.lyx.org Git - lyx.git/blobdiff - src/support/filetools.C
the freespacing patch from Kayvan, draw the math empty delim with onoffdash, asure...
[lyx.git] / src / support / filetools.C
index 0c3cd19f2403783ea11327de2ee2e96fdb212e35..1efd55bffe87b1cc63660ee5568433f89cac0ab6 100644 (file)
@@ -989,7 +989,8 @@ bool LyXReadLink(string const & File, string & Link)
 
 
 typedef pair<int, string> cmdret;
-static cmdret do_popen(string const & cmd)
+static
+cmdret do_popen(string const & cmd)
 {
        // One question is if we should use popen or
        // create our own popen based on fork, exec, pipe
@@ -1008,7 +1009,7 @@ static cmdret do_popen(string const & cmd)
 }
 
 
-string findtexfile(string const & fil, string const & format)
+string findtexfile(string const & fil, string const & /*format*/)
 {
        /* There is no problem to extend this function too use other
           methods to look for files. It could be setup to look
@@ -1019,15 +1020,32 @@ string findtexfile(string const & fil, string const & format)
           Lgb
        */
        
-        // If fil is a file with absolute path we just return it
-        if (AbsolutePath(fil)) return fil;
-       
-        // Check in the current dir.
-        if (FileInfo(OnlyFilename(fil)).exist())
-               return OnlyFilename(fil);
-       
+       // If the file can be found directly, we just return a
+       // absolute path version of it. 
+        if (FileInfo(fil).exist())
+               return MakeAbsPath(fil);
+
         // No we try to find it using kpsewhich.
-        string kpsecmd = "kpsewhich --format=" + format + " " + OnlyFilename(fil);
+       // It seems from the kpsewhich manual page that it is safe to use
+       // kpsewhich without --format: "When the --format option is not
+       // given, the search path used when looking for a file is inferred
+       // from the name given, by looking for a known extension. If no
+       // known extension is found, the search path for TeX source files
+       // is used."
+       // However, we want to take advantage of the format sine almost all
+       // the different formats has environment variables that can be used
+       // to controll which paths to search. f.ex. bib looks in
+       // BIBINPUTS and TEXBIB. Small list follows:
+       // bib - BIBINPUTS, TEXBIB
+       // bst - BSTINPUTS
+       // graphic/figure - TEXPICTS, TEXINPUTS
+       // ist - TEXINDEXSTYLE, INDEXSTYLE
+       // pk - PROGRAMFONTS, PKFONTS, TEXPKS, GLYPHFONTS, TEXFONTS
+       // tex - TEXINPUTS
+       // tfm - TFMFONTS, TEXFONTS
+       // This means that to use kpsewhich in the best possible way we
+       // should help it by setting additional path in the approp. envir.var.
+        string kpsecmd = "kpsewhich " + fil;
 
         cmdret c = do_popen(kpsecmd);