]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/kpath.cc
* lily/kpath.cc:
[lilypond.git] / lily / kpath.cc
index 7ae43ce3543a4550839c7edc92ec5ea75c65172e..0a5cfc9cc317c24f58593e42c0ff51d3edd9ed46 100644 (file)
@@ -3,16 +3,18 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2000--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
-#include <stdio.h>
-#include <string.h>
+#include "kpath.hh"
+
+#include <cstdio>
+#include <cstring>
 
 /*
 
 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
+prototype in <unistd.h>, whinole 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 YAKLUDGE.
 
@@ -20,7 +22,9 @@ I found a somewhat more elegant patch for this: Just #include
 <unistd.h> before defining YAKLUDGE.
 
 */
+
 #include <unistd.h>    
+
 #include "config.hh"
 
 #define popen REALLYUGLYKLUDGE
@@ -35,29 +39,22 @@ 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, false);
 
-  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 "";
 }
@@ -65,9 +62,9 @@ kpathsea_find_afm (char const * name)
 String
 kpathsea_find_tfm (char const *name)
 {
-  String filename = global_path.find (String (name) + ".tfm");
+  String file_name = global_path.find (String (name) + ".tfm");
 #if (KPATHSEA && HAVE_KPSE_FIND_FILE)
-  if (filename.is_empty ())
+  if (file_name.is_empty ())
     {
       /* If invoked for a TeX font, we could do TRUE (must exist).
         We could also do:
@@ -78,20 +75,18 @@ kpathsea_find_tfm (char const *name)
             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. */
-      char *p = kpse_find_file (name, kpse_tfm_format, false);
-      if (!p)
-       warning (_f ("kpathsea can not find TFM file: `%s'", name));
-      else
-       filename = p;
+      if (char *tfm = kpse_find_file (name, kpse_tfm_format, false))
+       return tfm;
+      warning (_f ("kpathsea can't find %s file: `%s'", "TFM", name));
     }
 #endif
-  return filename;
+  return file_name;
 }
 
 #if KPATHSEA
 /* FIXME: this should be part of kpathsea */
 
-static kpse_file_format_type
+kpse_file_format_type
 kpathsea_find_format (String name)
 {
   for (int i = 0; i < kpse_last_format; i++)
@@ -116,32 +111,32 @@ kpathsea_find_format (String name)
 String
 kpathsea_gulp_file_to_string (String name)
 {
-  String filename = global_path.find (name);
+  String file_name = global_path.find (name);
 
 #if (KPATHSEA && HAVE_KPSE_FIND_FILE)
-  if (filename.is_empty ())
+  if (file_name.is_empty ())
     {
       char *p = kpse_find_file (name.to_str0 (), kpathsea_find_format (name),
        true);
       if (p)
-       filename = p;
+       file_name = p;
       else
-       warning (_f ("kpathsea can not find file: `%s'", name));
+       warning (_f ("kpathsea can't find file: `%s'", name));
     }
 #endif
 
-  if (filename.is_empty ())
+  if (file_name.is_empty ())
     error (_f ("can't find file: `%s'", name));
 
-  if (verbose_global_b)
-    progress_indication ("[" + filename);
+  if (be_verbose_global)
+    progress_indication ("[" + file_name);
 
   int filesize;
-  char *str = gulp_file (filename, &filesize);
+  char *str = gulp_file (file_name, &filesize);
   String string (str);
   delete[] str;
   
-  if (verbose_global_b)
+  if (be_verbose_global)
     progress_indication ("]");
 
   return string;
@@ -149,43 +144,6 @@ kpathsea_gulp_file_to_string (String name)
 
 
 
-LY_DEFINE (ly_kpathsea_expand_path, "ly:kpathsea-expand-path",
-          1, 0, 0, (SCM name),
-          "Return the expanded path of @var{name}, or"
-          "@code{#f} if not found.")
-{
-  SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
-
-  String nm = ly_scm2string (name);
-  String filename = global_path.find (nm);
-  if (filename.is_empty ())
-    {
-      char *p = kpse_find_file (nm.to_str0 (), kpathsea_find_format (nm),
-       true);
-      if (p)
-       return scm_makfrom0str (p);
-      else
-       return SCM_BOOL_F;
-    }
-  return scm_makfrom0str (filename.to_str0 ());
-}
-
-
-LY_DEFINE (ly_kpathsea_expand_variable, "ly:kpathsea-expand-variable",
-          1, 0, 0, (SCM var),
-          "Return the expanded version  @var{var}.")
-{
-  SCM_ASSERT_TYPE (scm_is_string (var), var, SCM_ARG1, __FUNCTION__, "string");
-
-  String nm = ly_scm2string (var);
-  char *result =  kpse_var_expand (nm.to_str0 ());
-  SCM ret =  scm_makfrom0str (result);
-  delete[] result;
-
-  return ret;
-}
-
-
 void
 initialize_kpathsea (char *av0)
 {