2 kpath-scheme.cc -- implement kpathsea bindings
4 source file of the GNU LilyPond music typesetter
6 (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
17 The problem, as far as I can tell, is that MacOS X has its getopt
18 prototype in <unistd.h>, while I think other operating systems have it
19 in other places. <unistd.h> is included by kpathsea.h, so you end up
20 renaming both conflicting prototypes to YAKLUDGE.
22 I found a somewhat more elegant patch for this: Just #include
23 <unistd.h> before defining YAKLUDGE.
31 #define popen REALLYUGLYKLUDGE
32 #define pclose ANOTHERREALLYUGLYKLUDGE
33 #define getopt YAKLUDGE
35 #if HAVE_KPATHSEA_KPATHSEA_H
37 #include <kpathsea/kpathsea.h>
38 #include <kpathsea/tex-file.h>
42 #include "file-path.hh"
44 #include "source-file.hh"
46 #include "kpath-private.hh"
49 LY_DEFINE (ly_kpathsea_find_file, "ly:kpathsea-find-file",
51 "Return the absolute file name of @var{name}, "
52 "or @code{#f} if not found.")
54 SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
56 String nm = ly_scm2string (name);
57 String file_name = global_path.find (nm);
58 if (file_name.is_empty ())
60 if (char *p = kpse_find_file (nm.to_str0 (), kpathsea_find_format (nm),
62 return scm_makfrom0str (p);
65 return scm_makfrom0str (file_name.to_str0 ());
68 LY_DEFINE (ly_kpathsea_expand_variable, "ly:kpathsea-expand-variable",
70 "Return the expanded version @var{var}.")
72 SCM_ASSERT_TYPE (scm_is_string (var), var, SCM_ARG1, __FUNCTION__, "string");
74 String nm = ly_scm2string (var);
75 char *result = kpse_var_expand (nm.to_str0 ());
76 SCM ret = scm_makfrom0str (result);