]> git.donarmstrong.com Git - lilypond.git/commitdiff
* configure.in (LINK_GXX_STATICALLY): remove kpathsea checks.
authorhanwen <hanwen>
Tue, 29 Nov 2005 16:17:57 +0000 (16:17 +0000)
committerhanwen <hanwen>
Tue, 29 Nov 2005 16:17:57 +0000 (16:17 +0000)
* scm/kpathsea.scm (ly:kpathsea-expand-variable): new
file. Encapsulate kpathsea using commandline tools.

* lily/all-font-metrics.cc (kpathsea_find_file): use (scm
kpathsea) module.

13 files changed:
ChangeLog
GNUmakefile.in
buildscripts/mutopia-index.py
configure.in
kpath-guile/GNUmakefile [deleted file]
kpath-guile/SConscript [deleted file]
kpath-guile/kpath.c [deleted file]
lily/all-font-metrics.cc
lily/lily-guile.cc
scm/backend-library.scm
scm/font.scm
scm/framework-tex.scm
scm/kpathsea.scm [new file with mode: 0644]

index da784ae89955c49fb96fb9f0bc8f1c6a60bb28f6..5c2bf061de03959c519eac28a5b29ad173bad902 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2005-11-29  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * configure.in (LINK_GXX_STATICALLY): remove kpathsea checks.
+
+       * kpath-guile/: remove directory
+
+       * scm/kpathsea.scm (ly:kpathsea-expand-variable): new
+       file. Encapsulate kpathsea using commandline tools.
+
+       * lily/all-font-metrics.cc (kpathsea_find_file): use (scm
+       kpathsea) module.
+
 2005-11-29  Mats Bengtsson  <mabe@drongo.s3.kth.se>
 
        * Documentation/user/advanced-notation.itely (Setting automatic
index 7da071d5ce1cfbaa0f6fe2a8d4be15af22916afc..33c9afb21019a2ced36ba952b6dd800850e2963a 100644 (file)
@@ -3,7 +3,7 @@
 depth = .
 
 SUBDIRS = buildscripts python scripts \
-       flower kpath-guile lily \
+       flower lily \
        mf ly \
        tex ps scm \
        po make \
@@ -64,7 +64,7 @@ footifymail = MAILADDRESS=bug-lilypond@gnu.org
 local-WWW-post:
 # need UTF8 setting in case this is hosted on a website. 
        echo -e 'AddDefaultCharset utf-8\nAddCharset utf-8 .html\nAddCharset utf-8 .en\nAddCharset utf-8 .nl\nAddCharset utf-8 .txt\n' > $(top-build-dir)/.htaccess
-       $(PYTHON) $(buildscript-dir)/mutopia-index.py -o $(outdir)/examples.html ./
+       $(PYTHON) $(buildscript-dir)/mutopia-index.py -o $(outdir)/examples.html input/
        echo '<META HTTP-EQUIV="refresh" content="0;URL=Documentation/index.html">' > $(outdir)/index.html
        echo '<html><body>Redirecting to the documentation index...</body></html>' >> $(outdir)/index.html
 
index 977226317d68daa2aaed526f68b37a758d2428d1..8b02ea4ba2416294c71d63d694a216329c06047e 100644 (file)
@@ -18,6 +18,7 @@ def find (pat, dir):
        return lst
 
 
+junk_prefix = 'out-www/'
 
 headertext= r"""
 
@@ -132,7 +133,7 @@ hr { border:0; height:1; color: #000000; background-color: #000000; }\n
                def list_item (file_name, desc, type, lst = list):
                        if os.path.isfile (file_name):
                                lst.write ('<li><a href="%s">%s</a>'
-                                          % (file_name, desc))
+                                          % (re.sub (junk_prefix, '', file_name), desc))
 
                                # FIXME: include warning if it uses \include
                                # files.
index fa4569390876e4bb02c60df92f8496f99bbab6a2..ad434c03469998197cd6c0e8d83929268465a4bb 100644 (file)
@@ -46,8 +46,6 @@ AC_SUBST(LINK_GXX_STATICALLY)
 # must come before any header checks
 STEPMAKE_COMPILE
 
-STEPMAKE_KPATHSEA
-
 STEPMAKE_PYTHON(REQUIRED, 2.2)
 STEPMAKE_GCC(REQUIRED, 2.8)
 STEPMAKE_CXX(REQUIRED)
diff --git a/kpath-guile/GNUmakefile b/kpath-guile/GNUmakefile
deleted file mode 100644 (file)
index e7e92d6..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-depth = ..
-
-NAME = kpath-guile
-MODULE_NAME = kpath-guile
-MODULE_LDFLAGS= = -lkpathsea
-SCRIPTS = 
-STEPMAKE_TEMPLATES = library c po
-
-MODULE_CFLAGS = -std=c99
-
-include $(depth)/make/stepmake.make 
-
-$(outdir)/kpath.o: $(config_hh)
-
-
diff --git a/kpath-guile/SConscript b/kpath-guile/SConscript
deleted file mode 100644 (file)
index fad6933..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-# -*-python-*-
-
-Import ('env', 'src_glob')
-sources = src_glob ('*.c')
-includes = src_glob ('*.h')
-outdir = Dir ('.').path
-
-name = 'kpath-guile'
-e = env.Copy ()
-e.Append (CPPPATH = ['/#ttftool/include', '#/flower/include', outdir,],
-         CCFLAGS = '-std=c99',
-         )
-if env['static']:
-       e.Library (name, sources) 
-if not env['static'] or env['shared']:
-       e.SharedLibrary (name, sources)
-
-po = env.Command ('lilypond.po', sources + includes, env['pocommand'])
-env.Alias ('po-update', po)
diff --git a/kpath-guile/kpath.c b/kpath-guile/kpath.c
deleted file mode 100644 (file)
index 64cdb18..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
-  kpath.c --  implement kpathsea bindings
-
-  source file of the GNU LilyPond music typesetter
-
-  (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-*/
-
-
-#include <libguile.h>
-
-#include "config.hh"
-
-#if KPATHSEA
-
-#include "guile-compatibility.hh"
-
-#if !HAVE_GETTEXT
-inline char *
-gettext (char const *s)
-{
-  return (char *)s;
-}
-#else
-#include <libintl.h>
-#endif
-
-#define _(x) gettext (x)
-
-#include <dlfcn.h>
-#include <stdio.h>
-#include <string.h>
-
-/* The (?) problem, as far as I (?) can tell, is that MacOS X has its
-   getopt prototype in <unistd.h>, while I think other operating
-   systems have it in other places. <unistd.h> 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
-   <unistd.h> before defining KPATHSEA_HAS_GETOPT_PROTOTYPE_PROBLEM.  */
-
-#include <unistd.h>    
-
-#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 <kpathsea/kpathsea.h>
-#include <kpathsea/tex-file.h>
-#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*, 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 (char const* name)
-{
-  int i;
-  int len = strlen (name);
-  for (i = 0; i < kpse_last_format; i++)
-    {
-       if (!(*dl_kpse_format_info)[i].type)
-        (*dl_kpse_init_format) ((kpse_file_format_type) i);
-
-       char const **suffixes[] = { (*dl_kpse_format_info)[i].suffix,
-                                  (*dl_kpse_format_info)[i].alt_suffix };
-       for (int j = 0; j < 2; j++)
-       for (char const **p = suffixes[j]; p && *p; p++)
-         {
-           int suflen = strlen (*p);
-           
-           if (!strncmp (name + len - suflen, *p, suflen))
-             return (kpse_file_format_type) i;
-         }
-    }
-  return kpse_last_format;
-}
-
-//        "Return the absolute file name of @var{name}, "
-//        "or @code{#f} if not found.")
-SCM
-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);
-  if (p)
-    return scm_makfrom0str (p);
-  return SCM_BOOL_F;
-}
-
-//   "Return the expanded version  @var{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 = (*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" DYNAMIC_OBJECT_EXTENSION;
-
-int
-open_library ()
-{
-#if HAVE_LIBKPATHSEA_SO
-  struct
-  {
-    void **func_pointer;
-    char const *name; 
-  } symbols[] = {
-    {(void*)&dl_kpse_find_file, "kpse_find_file"},
-    {(void*)&dl_kpse_set_program_name, "kpse_set_program_name"},
-    {(void*)&dl_kpse_format_info, "kpse_format_info"},
-    {(void*)&dl_kpse_init_format, "kpse_init_format"},
-    {(void*)&dl_kpse_maketex_option, "kpse_maketex_option"},
-    {(void*)&dl_kpse_var_expand, "kpse_var_expand"},
-    {0,0}
-  };
-
-
-  dlerror ();
-  kpathsea_handle = dlopen (LIBKPATHSEA, RTLD_LAZY);
-  if (!kpathsea_handle)
-    {
-      /*
-       todo i18n.
-       */
-      fprintf (stderr, _ ("can't dlopen: %s: %s"), LIBKPATHSEA, dlerror ());
-      fprintf (stderr, _ ("install package: %s or %s"),
-              "libkpathsea3 (teTeX 2.x)",
-              "libkpathsea4 (teTeX 3.x)");
-
-      return 1;
-    }
-
-  for (int i = 0; symbols[i].func_pointer; i++)
-    {
-      dlerror ();
-      *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 ());
-         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
-}
-
-void
-initialize_kpathsea ()
-{
-  if (open_library ())
-    {
-      fprintf (stderr, _ ("error opening kpathsea library"));
-      fprintf (stderr, _ ("aborting"));
-      exit (1);
-    }
-
-  (*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_c_export ("ly:kpathsea-find-file", NULL);
-  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);
-}
-
-#endif
index e49f36c13a983df0cb5d0eeb765aa64cc17470d6..440e16ca66fc55002a11d3dfa2e2967ce89cd13a 100644 (file)
@@ -107,10 +107,17 @@ kpathsea_find_file (String name, String ext)
   if (path.length () > 0)
     return path;
 
-  SCM kpath = ly_lily_module_constant ("ly:kpathsea-find-file");
-  if (ly_is_procedure (kpath))
+  static SCM proc;
+  if (!proc)
     {
-      SCM kp_result = scm_call_1 (kpath, scm_makfrom0str (name.to_str0 ()));
+      SCM module = scm_c_resolve_module ("scm kpathsea");
+      proc = scm_c_module_lookup (module, "ly:kpathsea-find-file");
+      proc = scm_variable_ref (proc);
+    }
+
+  if (ly_is_procedure (proc))
+    {
+      SCM kp_result = scm_call_1 (proc, scm_makfrom0str (name.to_str0 ()));
       if (scm_is_string (kp_result))
        return ly_scm2string (kp_result);
     }
index 2018100d55320f9b854ddce8980bf9ba8d3151f2..c38aa9eeff35f68020ca7a80bb4ea893367908c1 100644 (file)
@@ -189,12 +189,6 @@ void add_scm_init_func (void (*f) ())
   scm_init_funcs_->push (f);
 }
 
-#if KPATHSEA
-extern "C" {
-  void initialize_kpathsea ();
-}
-#endif
-
 void
 ly_init_ly_module (void *)
 {
@@ -204,11 +198,6 @@ ly_init_ly_module (void *)
   if (be_verbose_global)
     progress_indication ("\n");
 
-#if KPATHSEA
-  if (is_TeX_format_global)
-    initialize_kpathsea ();
-#endif
-
   scm_primitive_load_path (scm_makfrom0str ("lily.scm"));
 }
 
index 18c9c0d2bcd49239b0b594e3026fd56d7be97fc2..0030b15e1e5a355a13f89f23d4f0c7a50d13cf12 100644 (file)
          (throw 'ly-file-failed)))))
 
 (define-public (sanitize-command-option str)
+  "Kill dubious shell quoting"
+  
   (string-append
    "\""
-   (regexp-substitute/global #f "[^- 0-9,.a-zA-Z'\"\\]" str 'pre 'post)
+   (regexp-substitute/global #f "[^-_ 0-9,.a-zA-Z'\"\\]" str 'pre 'post)
    "\""))
 
 (define-public (search-executable names)
index d72a8d23a197f514d51775eaf137550485a8c0ef..bc8723d4f2f2b14859b840557b870a3cec02bdf6 100644 (file)
   (add-node 'italic 'bold))
 
 (define-public (make-cmr-tree factor)
-  (let ((n (make-font-tree-node 'font-encoding 'fetaMusic)))
+  (let*
+      ((n (make-font-tree-node 'font-encoding 'fetaMusic))
+       (module (resolve-module '(scm kpathsea)))
+       (find (eval 'ly:kpathsea-find-file module))
+       )
     (add-music-fonts n factor)
     (add-cmr-fonts n factor)
-    (if (defined? 'ly:kpathsea-find-file)
-       (begin
-         (if (ly:kpathsea-find-file "lmr10.pfb")
-             (add-cork-lm-fonts n factor))
-         (if (ly:kpathsea-find-file "ecrm10.pfa")
-             (add-ec-fonts n factor))))
+    
+    (if (find "lmr10.pfb")
+       (add-cork-lm-fonts n factor))
+    (if (find "ecrm10.pfa")
+       (add-ec-fonts n factor))
     n))
 
 
index 3f2821b78390700ea3aba07f5a4f2677dc3735ea..52ce2e982c162c84c68ae8a9dc190f0a8b27cbaf 100644 (file)
@@ -15,6 +15,7 @@
             (srfi srfi-1)
             (srfi srfi-13)
             (srfi srfi-14)
+            (scm kpathsea)
             (lily))
 
 (define (output-formats)
          (string->number
           (regexp-substitute/global
            #f " *%.*\n?"
-           (ly:kpathsea-expand-variable "$extra_mem_top")
+           (ly:kpathsea-expand-variable "extra_mem_top")
            'pre "" 'post)))
         (base (basename name ".tex"))
         (cmd (format
diff --git a/scm/kpathsea.scm b/scm/kpathsea.scm
new file mode 100644 (file)
index 0000000..845abef
--- /dev/null
@@ -0,0 +1,48 @@
+;;
+;; kpathsea.scm -- implement kpath support using command-line
+;; 
+;;
+;; source file of the GNU LilyPond music typesetter
+;;
+;; (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+;;
+
+(define-module (scm kpathsea))
+
+(use-modules (ice-9 popen)
+            (lily)
+            (ice-9 rdelim))
+
+
+
+(define-public (ly:kpathsea-find-file name)
+  (let*
+      ((cmd  (format #f "kpsewhich ~a"
+                    (sanitize-command-option name)))
+       (unused (if (ly:get-option 'verbose)
+                  (ly:message "Running ~a" cmd)))
+       (pipe (open-input-pipe cmd))
+       (answer (read-line pipe)))
+
+    (if (string? answer)
+       answer
+       #f)))
+                           
+(define-public (ly:kpathsea-expand-variable var)
+  (let*
+      ((cmd (format #f "kpsexpand '$'~a"
+                   (sanitize-command-option var)))
+       (unused (if (ly:get-option 'verbose)
+                  (ly:message "Running ~a" cmd)))
+       (pipe (open-input-pipe cmd))
+       (answer (read-line pipe)))
+
+    (if (string? answer)
+       answer #f)))
+
+;; Test:
+
+;;(display (ly:kpathsea-find-file "cmr10.tfm"))
+;;
+;;(display (ly:kpathsea-expand-variable "TEXMF"))
+