]> git.donarmstrong.com Git - lilypond.git/commitdiff
Rewrite `ly-getcwd' for Guile 1.8 backward compat.
authorPatrick McCarty <pnorcks@gmail.com>
Sat, 17 Apr 2010 02:04:12 +0000 (19:04 -0700)
committerPatrick McCarty <pnorcks@gmail.com>
Sat, 17 Apr 2010 02:16:49 +0000 (19:16 -0700)
Guile 1.9 (and future Guile 2.0) adheres more strictly to R5RS and R6RS
in that (if ...) and (case ...) clauses cannot contain top-level
bindings created with (define ...).

This commit fixes the compatibility issue, and as an additional benefit,
simplifies the procedure `ly-getcwd'.

scm/lily.scm

index c680b0ff0a4859fcc75bd9de94697d9546e398ac..8cfebbd0db26366f405b8f93712f82470eefbd52 100644 (file)
@@ -272,25 +272,17 @@ messages into errors.")
     (if (null? (cdr platform)) #f
        (member (string-downcase (cadr platform)) '("95" "98" "me")))))
 
-(case PLATFORM
-  ((windows)
-   (define native-getcwd
-     getcwd)
-
-   (define (slashify x)
-     (if (string-index x #\\)
-        x
-        (string-regexp-substitute
-         "//*" "/"
-         (string-regexp-substitute "\\\\" "/" x))))
-
-   ;; FIXME: this prints a warning.
-   (define-public (ly-getcwd)
-     (slashify (native-getcwd))))
-
-  (else
-   (define-public ly-getcwd
-     getcwd)))
+(define (slashify x)
+  (if (string-index x #\\)
+      x
+      (string-regexp-substitute
+       "//*" "/"
+       (string-regexp-substitute "\\\\" "/" x))))
+
+(define-public (ly-getcwd)
+  (if (eq? PLATFORM 'windows)
+      (slashify (getcwd))
+      (getcwd)))
 
 (define-public (is-absolute? file-name)
   (let ((file-name-length (string-length file-name)))