2 kpath.cc -- glue kpathsea to lily. Need some ugly kludges for gcc 2.96
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
16 The problem, as far as I can tell, is that MacOS X has its getopt
17 prototype in <unistd.h>, while I think other operating systems have it
18 in other places. <unistd.h> is included by kpathsea.h, so you end up
19 renaming both conflicting prototypes to YAKLUDGE.
21 I found a somewhat more elegant patch for this: Just #include
22 <unistd.h> before defining YAKLUDGE.
30 #define popen REALLYUGLYKLUDGE
31 #define pclose ANOTHERREALLYUGLYKLUDGE
32 #define getopt YAKLUDGE
34 #if HAVE_KPATHSEA_KPATHSEA_H
36 #include <kpathsea/kpathsea.h>
37 #include <kpathsea/tex-file.h>
41 #include "file-path.hh"
43 #include "source-file.hh"
45 #include "kpath-private.hh"
48 kpathsea_find_afm (char const *name)
50 #if (KPATHSEA && HAVE_KPSE_FIND_FILE)
52 if (char *afm = kpse_find_file (name, kpse_afm_format, false))
60 kpathsea_find_tfm (char const *name)
62 String file_name = global_path.find (String (name) + ".tfm");
63 #if (KPATHSEA && HAVE_KPSE_FIND_FILE)
64 if (file_name.is_empty ())
66 /* If invoked for a TeX font, we could do TRUE (must exist).
68 p = kpse_find_file (name, kpse_mf_format, false);
70 p = kpse_find_file (name, kpse_mf_format, true);
72 but we assume that if there is a .PFA, there is also a .TFM,
73 and it's no use generating TFMs on the fly, because PFAs cannot
74 be generated on the fly. */
75 if (char *tfm = kpse_find_file (name, kpse_tfm_format, false))
77 warning (_f ("kpathsea can't find %s file: `%s'", "TFM", name));
84 /* FIXME: this should be part of kpathsea */
87 kpathsea_find_format (String name)
89 for (int i = 0; i < kpse_last_format; i++)
91 if (!kpse_format_info[i].type)
92 kpse_init_format ((kpse_file_format_type) i);
94 char const **suffixes[] = { kpse_format_info[i].suffix,
95 kpse_format_info[i].alt_suffix };
96 for (int j = 0; j < 2; j++)
97 for (char const **p = suffixes[j]; p && *p; p++)
100 if (name.right_string (suffix.length ()) == suffix)
101 return (kpse_file_format_type) i;
104 return kpse_last_format;
111 initialize_kpathsea (char *av0)
113 #if KPATHSEA && HAVE_KPATHSEA_KPATHSEA_H
118 kpse_set_program_name (av0, NULL);
119 kpse_maketex_option ("tfm", TRUE);