X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fkpath.cc;h=0a5cfc9cc317c24f58593e42c0ff51d3edd9ed46;hb=4300e287a18cbc4569c79f8e8445609dc7d4546a;hp=cb6968aafbf3c5387a901e4c0e78db0ccac1e6b4;hpb=b1c38855c678139f2927f64873a0bc4e36985d09;p=lilypond.git diff --git a/lily/kpath.cc b/lily/kpath.cc index cb6968aafb..0a5cfc9cc3 100644 --- a/lily/kpath.cc +++ b/lily/kpath.cc @@ -3,16 +3,18 @@ source file of the GNU LilyPond music typesetter - (c) 2000--2004 Han-Wen Nienhuys + (c) 2000--2005 Han-Wen Nienhuys */ -#include -#include +#include "kpath.hh" + +#include +#include /* The problem, as far as I can tell, is that MacOS X has its getopt -prototype in , while I think other operating systems have it +prototype in , whinole I think other operating systems have it in other places. is included by kpathsea.h, so you end up renaming both conflicting prototypes to YAKLUDGE. @@ -20,8 +22,10 @@ I found a somewhat more elegant patch for this: Just #include before defining YAKLUDGE. */ + #include -#include "config.h" + +#include "config.hh" #define popen REALLYUGLYKLUDGE #define pclose ANOTHERREALLYUGLYKLUDGE @@ -35,92 +39,115 @@ extern "C" { #endif #include "file-path.hh" -#include "string.hh" #include "main.hh" -#include "kpath.hh" +#include "source-file.hh" #include "warn.hh" +#include "kpath-private.hh" String -kpathsea_find_afm (char const * name) +kpathsea_find_afm (char const *name) { #if (KPATHSEA && HAVE_KPSE_FIND_FILE) - char * name_ptr = kpse_find_file (name, kpse_afm_format, true); - if(!name_ptr) - { - /* - don't mutter about afms, since we try to find them first, and lots of - TFMs don't have AFMs. - */ - // warning (_f("kpathsea couldn't find AFM file `%s'", name)); - } - else - return name_ptr; - + if (char *afm = kpse_find_file (name, kpse_afm_format, false)) + return afm; +#if 0 /* Do not mutter about afms, since we try to find them first, and + lots of TFMs don't have AFMs. */ + warning (_f ("kpathsea can't find %s file: `%s'", "AFM", name)); +#endif #endif return ""; } String -kpathsea_find_tfm (char const * name) +kpathsea_find_tfm (char const *name) { - String p = global_path.find (String (name) + ".tfm"); - - if (p.length ()) - return p; - + String file_name = global_path.find (String (name) + ".tfm"); #if (KPATHSEA && HAVE_KPSE_FIND_FILE) - char * name_ptr = kpse_find_file (name, kpse_tfm_format, true); - if(!name_ptr) + if (file_name.is_empty ()) { - warning (_f("Kpathsea couldn't find TFM file `%s'", name)); + /* If invoked for a TeX font, we could do TRUE (must exist). + We could also do: + p = kpse_find_file (name, kpse_mf_format, false); + if (p) + p = kpse_find_file (name, kpse_mf_format, true); + + but we assume that if there is a .PFA, there is also a .TFM, + and it's no use generating TFMs on the fly, because PFAs cannot + be generated on the fly. */ + if (char *tfm = kpse_find_file (name, kpse_tfm_format, false)) + return tfm; + warning (_f ("kpathsea can't find %s file: `%s'", "TFM", name)); } - else - return name_ptr; - #endif - return ""; + return file_name; } +#if KPATHSEA +/* FIXME: this should be part of kpathsea */ -void -initialize_kpathsea (char *av0) +kpse_file_format_type +kpathsea_find_format (String name) { -#if KPATHSEA && HAVE_KPATHSEA_KPATHSEA_H - /* - We take two pronged approach to tfms: - - * the lilypond tfms (feta*.tfm) are found through our own routines. - - * the TeX tfms are found through vanilla kpathsea. - - (* other TFMs are not found, i.e. don't use them. ) + for (int i = 0; i < kpse_last_format; i++) + { + if (!kpse_format_info[i].type) + kpse_init_format ((kpse_file_format_type) i); + + char const **suffixes[] = { kpse_format_info[i].suffix, + kpse_format_info[i].alt_suffix }; + for (int j = 0; j < 2; j++) + for (char const **p = suffixes[j]; p && *p; p++) + { + String suffix = *p; + if (name.right_string (suffix.length ()) == suffix) + return (kpse_file_format_type) i; + } + } + return kpse_last_format; +} +#endif - PRO: - - - TFM and AFM checksums always match in Lily. +String +kpathsea_gulp_file_to_string (String name) +{ + String file_name = global_path.find (name); - - less hassle, no kpathsea spaghetti +#if (KPATHSEA && HAVE_KPSE_FIND_FILE) + if (file_name.is_empty ()) + { + char *p = kpse_find_file (name.to_str0 (), kpathsea_find_format (name), + true); + if (p) + file_name = p; + else + warning (_f ("kpathsea can't find file: `%s'", name)); + } +#endif - CON: + if (file_name.is_empty ()) + error (_f ("can't find file: `%s'", name)); - - feta PK files are often recreated, locally - Solution: cache PK files locally? + if (be_verbose_global) + progress_indication ("[" + file_name); - - need env. vars to make sure that TeX finds the TFMs + int filesize; + char *str = gulp_file (file_name, &filesize); + String string (str); + delete[] str; + + if (be_verbose_global) + progress_indication ("]"); - - Outdated PK (TFM?) font files are not automatically removed, - since VERSION is not part of the standard location. + return string; +} - ALTERNATIVE - we have tried to come up with schemes that leave this kind of work - to kpathsea with objective of fixing the CONs, but miserably - failed. TeX installations and kpathsea itself form a buggy, - inconsistent, and unorderly mess. - - */ +void +initialize_kpathsea (char *av0) +{ +#if KPATHSEA && HAVE_KPATHSEA_KPATHSEA_H /* initialize kpathsea @@ -129,5 +156,3 @@ initialize_kpathsea (char *av0) kpse_maketex_option ("tfm", TRUE); #endif } - -