X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=kpath-guile%2Fkpath.c;h=64cdb187d921169796a82de363ac7afe3e858792;hb=06a3702503b1edfdee635717a9d92906d2ad3f99;hp=01f340e4f8305302d37e838acd8b34efcd7ab991;hpb=92ee5a5e2dfa180b153666f560ea75c3dcb96290;p=lilypond.git diff --git a/kpath-guile/kpath.c b/kpath-guile/kpath.c index 01f340e4f8..64cdb187d9 100644 --- a/kpath-guile/kpath.c +++ b/kpath-guile/kpath.c @@ -15,44 +15,52 @@ #include "guile-compatibility.hh" +#if !HAVE_GETTEXT +inline char * +gettext (char const *s) +{ + return (char *)s; +} +#else +#include +#endif + +#define _(x) gettext (x) + #include #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 -in other places. is included by kpathsea.h, so you end up -renaming both conflicting prototypes to YAKLUDGE. +/* 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 in other places. is included by + kpathsea.h, so you end up renaming both conflicting prototypes to + KPATHSEA_HAS_GETOPT_PROTOTYPE_PROBLEM. -I found a somewhat more elegant patch for this: Just #include - before defining YAKLUDGE. - -*/ + I (?) found a somewhat more elegant patch for this: Just #include + before defining KPATHSEA_HAS_GETOPT_PROTOTYPE_PROBLEM. */ #include -#define popen REALLYUGLYKLUDGE -#define pclose ANOTHERREALLYUGLYKLUDGE -#define getopt YAKLUDGE +#define popen KPATHSEA_HAS_POPEN_PROTOTYPE_PROBLEM +#define pclose KPATHSEA_HAS_PCLOSE_PROTOTYPE_PROBLEM +#define getopt KPATHSEA_HAS_GETOPT_PROTOTYPE_PROBLEM +#if HAVE_KPATHSEA_KPATHSEA_H #include #include +#endif - - - -static void *kpathsea_handle = 0; -static char *(*dl_kpse_find_file) (char const*, kpse_file_format_type, boolean) = 0; -static void (*dl_kpse_maketex_option) (char const*, boolean) = 0; -static void (*dl_kpse_set_program_name) (char const*) = 0; -static char const *(*dl_kpse_init_format) (kpse_file_format_type) = 0; -static char *(*dl_kpse_var_expand) (char const*) = 0; -static kpse_format_info_type (*dl_kpse_format_info)[kpse_last_format] = 0; +static void *kpathsea_handle = 0; +static char *(*dl_kpse_find_file) (char const*, kpse_file_format_type, boolean) = 0; +static void (*dl_kpse_maketex_option) (char const*, boolean) = 0; +static void (*dl_kpse_set_program_name) (char const*, char const*) = 0; +static char const *(*dl_kpse_init_format) (kpse_file_format_type) = 0; +static char *(*dl_kpse_var_expand) (char const*) = 0; +static kpse_format_info_type (*dl_kpse_format_info)[kpse_last_format] = 0; kpse_file_format_type -kpathsea_find_format (const char* name) +kpathsea_find_format (char const* name) { int i; int len = strlen (name); @@ -78,38 +86,41 @@ kpathsea_find_format (const char* name) // "Return the absolute file name of @var{name}, " // "or @code{#f} if not found.") SCM -ly_kpathsea_find_file(SCM name) +ly_kpathsea_find_file (SCM name) { SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__, "string"); - char const * nm = scm_i_string_chars (name); - char *p = (*dl_kpse_find_file) (nm, kpathsea_find_format (nm), - true); + char const *nm = scm_i_string_chars (name); + char *p = (*dl_kpse_find_file) (nm, kpathsea_find_format (nm), true); if (p) return scm_makfrom0str (p); return SCM_BOOL_F; } // "Return the expanded version @var{var}.") -SCM ly_kpathsea_expand_variable(SCM var) +SCM ly_kpathsea_expand_variable (SCM var) { SCM_ASSERT_TYPE (scm_is_string (var), var, SCM_ARG1, __FUNCTION__, "string"); - char const * nm = scm_i_string_chars (var); - char *result = kpse_var_expand (nm); - SCM ret = scm_makfrom0str (result); + char const *nm = scm_i_string_chars (var); + char *result = (*dl_kpse_var_expand) (nm); + SCM ret = scm_makfrom0str (result); free (result); return ret; } +#ifndef DYNAMIC_OBJECT_EXTENSION +#define DYNAMIC_OBJECT_EXTENSION ".so" +#endif + -static char const* LIBKPATHSEA = "libkpathsea.so"; +static char const* LIBKPATHSEA = "libkpathsea" DYNAMIC_OBJECT_EXTENSION; int -open_dynamic_library () +open_library () { -#if HAVE_DYNAMIC_LIBKPATHSEA +#if HAVE_LIBKPATHSEA_SO struct { void **func_pointer; @@ -132,8 +143,8 @@ open_dynamic_library () /* todo i18n. */ - fprintf (stderr, "can't dlopen: %s: %s", LIBKPATHSEA, dlerror ()); - fprintf (stderr,"install package: %s or %s", + fprintf (stderr, _ ("can't dlopen: %s: %s"), LIBKPATHSEA, dlerror ()); + fprintf (stderr, _ ("install package: %s or %s"), "libkpathsea3 (teTeX 2.x)", "libkpathsea4 (teTeX 3.x)"); @@ -146,13 +157,20 @@ open_dynamic_library () *symbols[i].func_pointer = dlsym (kpathsea_handle, symbols[i].name); if (!symbols[i].func_pointer) { - fprintf(stderr, "no such symbol: %s: %s", - symbols[i].name, - dlerror ()); + fprintf (stderr, _ ("no such symbol: %s: %s"), + symbols[i].name, + dlerror ()); return 1; } } - + return 0; +#else + dl_kpse_find_file = &kpse_find_file; + dl_kpse_set_program_name = &kpse_set_program_name; + dl_kpse_format_info = &kpse_format_info; + dl_kpse_init_format = &kpse_init_format; + dl_kpse_maketex_option = &kpse_maketex_option; + dl_kpse_var_expand = &kpse_var_expand; return 0; #endif } @@ -160,18 +178,21 @@ open_dynamic_library () void initialize_kpathsea () { - if (open_dynamic_library ()) + if (open_library ()) { - fprintf (stderr, "Error opening kpathsea library. Aborting"); + fprintf (stderr, _ ("error opening kpathsea library")); + fprintf (stderr, _ ("aborting")); exit (1); } - (*dl_kpse_set_program_name) ("lilypond"); + (*dl_kpse_set_program_name) ("lilypond", "lilypond"); (*dl_kpse_maketex_option) ("tfm", TRUE); - SCM find = scm_c_define_gsubr ("ly:kpathsea-find-file", 1, 0, 0, ly_kpathsea_find_file); + SCM find = scm_c_define_gsubr ("ly:kpathsea-find-file", 1, 0, 0, + ly_kpathsea_find_file); scm_c_export ("ly:kpathsea-find-file", NULL); - SCM expand = scm_c_define_gsubr ("ly:kpathsea-expand-variable", 1, 0, 0, ly_kpathsea_find_file); + SCM expand = scm_c_define_gsubr ("ly:kpathsea-expand-variable", 1, 0, 0, + ly_kpathsea_expand_variable); scm_c_export ("ly:kpathsea-expand-variable", NULL); }