[armedbear-cvs] r11813 - in trunk/abcl: . src/org/armedbear/lisp

Erik Huelsmann ehuelsmann at common-lisp.net
Sat May 2 19:36:47 UTC 2009


Author: ehuelsmann
Date: Sat May  2 15:36:44 2009
New Revision: 11813

Log:
Fix building in a path with spaces.

Found by: Mark Tarver
Fixes: https://sourceforge.net/tracker/?func=detail&atid=475785&aid=2784411&group_id=55057

Modified:
   trunk/abcl/build-abcl.lisp
   trunk/abcl/src/org/armedbear/lisp/Site.java

Modified: trunk/abcl/build-abcl.lisp
==============================================================================
--- trunk/abcl/build-abcl.lisp	(original)
+++ trunk/abcl/build-abcl.lisp	Sat May  2 15:36:44 2009
@@ -13,10 +13,20 @@
 
 (in-package #:build-abcl)
 
+(defun comp (string char)
+  "Chops off the character at the end of `string' if it matches char"
+  (let ((len (length string)))
+    (if (eql char (char string (1- len)))
+        (subseq string 0 (1- len))
+        string)))
+
 (defun safe-namestring (pathname)
-  (let ((string (namestring pathname)))
+  (let* ((string (namestring pathname))
+         (len (length string)))
     (when (position #\space string)
-      (setf string (concatenate 'string "\"" string "\"")))
+      (setf string (concatenate 'string "\""
+                                (comp string #\\)
+                                "\"")))
     string))
 
 
@@ -309,13 +319,14 @@
                          (cmdline (with-output-to-string (s)
                                     (princ *java-compiler-command-line-prefix* s)
                                     (princ " -d " s)
-                                    (princ *build-root* s)
+                                    (princ (safe-namestring *build-root*) s)
                                     (princ #\Space s)
                                     (dolist (source-file source-files)
                                       (princ
-                                       (if (equal (pathname-directory source-file) dir)
-                                           (file-namestring source-file)
-                                           (namestring source-file))
+                                       (safe-namestring
+                                        (if (equal (pathname-directory source-file) dir)
+                                            (file-namestring source-file)
+                                            (namestring source-file)))
                                        s)
                                       (princ #\space s))))
                          (status (run-shell-command cmdline :directory *abcl-dir*)))
@@ -323,7 +334,7 @@
                  (t
                   (ensure-directories-exist *build-root*)
                   (dolist (source-file source-files t)
-                    (unless (java-compile-file source-file)
+                    (unless (java-compile-file (safe-namestring source-file))
                       (format t "Build failed.~%")
                       (return nil)))))))))
 

Modified: trunk/abcl/src/org/armedbear/lisp/Site.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Site.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Site.java	Sat May  2 15:36:44 2009
@@ -35,6 +35,7 @@
 
 import java.io.File;
 import java.net.URL;
+import java.net.URLDecoder;
 
 public final class Site extends Lisp
 {
@@ -47,6 +48,13 @@
             String protocol = url.getProtocol();
             if (protocol != null && protocol.equals("file")) {
                 String path = url.getPath();
+                try {
+                    path = URLDecoder.decode(path, "UTF-8");
+                }
+                catch (java.io.UnsupportedEncodingException uee) {
+                    // can't happen: Java implementations are required to
+                    // support UTF-8
+                }
                 int index = path.lastIndexOf('/');
                 if (index >= 0) {
                     lispHome = path.substring(0, index + 1);




More information about the armedbear-cvs mailing list