From ce2002271034469dc3ccdcaef7d13db76403b90d Mon Sep 17 00:00:00 2001 From: Rudi Schlatte Date: Fri, 26 Oct 2007 04:33:34 +0000 Subject: [PATCH] 1.0.11.1: Handle set-but-empty environment variables ... SBCL_HOME= sbcl crashed on startup ... Patch by Michael Weber --- contrib/asdf-install/installer.lisp | 5 +++-- contrib/asdf/asdf.lisp | 4 ++-- contrib/sb-grovel/def-to-lisp.lisp | 3 ++- src/code/filesys.lisp | 5 ++--- src/runtime/runtime.c | 8 +++++--- version.lisp-expr | 2 +- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/contrib/asdf-install/installer.lisp b/contrib/asdf-install/installer.lisp index 0af1455..b43f15a 100644 --- a/contrib/asdf-install/installer.lisp +++ b/contrib/asdf-install/installer.lisp @@ -2,8 +2,9 @@ (defvar *proxy* (posix-getenv "http_proxy")) (defvar *cclan-mirror* - (or (posix-getenv "CCLAN_MIRROR") - "http://ftp.linux.org.uk/pub/lisp/cclan/")) + (let ((mirror (posix-getenv "CCLAN_MIRROR"))) + (or (and (not (string= mirror "")) mirror) + "http://ftp.linux.org.uk/pub/lisp/cclan/"))) (defun directorify (name) ;; input name may or may not have a training #\/, but we know we diff --git a/contrib/asdf/asdf.lisp b/contrib/asdf/asdf.lisp index 4005dc8..b1ad184 100644 --- a/contrib/asdf/asdf.lisp +++ b/contrib/asdf/asdf.lisp @@ -1191,7 +1191,7 @@ output to *VERBOSE-OUT*. Returns the shell's exit code." (defun contrib-sysdef-search (system) (let ((home (sb-ext:posix-getenv "SBCL_HOME"))) - (when home + (when (and home (not (string= home ""))) (let* ((name (coerce-name system)) (home (truename home)) (contrib (merge-pathnames @@ -1205,7 +1205,7 @@ output to *VERBOSE-OUT*. Returns the shell's exit code." (pushnew '(let ((home (sb-ext:posix-getenv "SBCL_HOME"))) - (when home + (when (and home (not (string= home ""))) (merge-pathnames "site-systems/" (truename home)))) *central-registry*) diff --git a/contrib/sb-grovel/def-to-lisp.lisp b/contrib/sb-grovel/def-to-lisp.lisp index 30265a0..aa13f2e 100644 --- a/contrib/sb-grovel/def-to-lisp.lisp +++ b/contrib/sb-grovel/def-to-lisp.lisp @@ -187,7 +187,8 @@ code: (funcall (intern "C-CONSTANTS-EXTRACT" (find-package "SB-GROVEL")) filename tmp-c-source (constants-package component)) (unless (do-not-grovel component) - (let* ((cc (or (sb-ext:posix-getenv "CC") + (let* ((cc (or (and (string/= (sb-ext:posix-getenv "CC") "") + (sb-ext:posix-getenv "CC")) ;; It might be nice to include a CONTINUE or ;; USE-VALUE restart here, but ASDF seems to insist ;; on handling the errors itself. diff --git a/src/code/filesys.lisp b/src/code/filesys.lisp index 53ff874..b166710 100644 --- a/src/code/filesys.lisp +++ b/src/code/filesys.lisp @@ -572,7 +572,7 @@ otherwise. An error of type FILE-ERROR is signaled if pathname is wild." (defun sbcl-homedir-pathname () (let ((sbcl-home (posix-getenv "SBCL_HOME"))) ;; SBCL_HOME isn't set for :EXECUTABLE T embedded cores - (when sbcl-home + (when (and sbcl-home (not (string= sbcl-home ""))) (parse-native-namestring (ensure-trailing-slash sbcl-home))))) @@ -587,8 +587,7 @@ system." (let ((env-home (posix-getenv "HOME"))) (parse-native-namestring (ensure-trailing-slash - (if (and env-home - (not (equal env-home ""))) + (if (and env-home (not (string= env-home ""))) env-home #!-win32 (sb!unix:uid-homedir (sb!unix:unix-getuid)) diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index 5db1453..a4fc68a 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -194,7 +194,7 @@ search_for_core () char *stem = "/sbcl.core"; char *core; - if(!sbcl_home) sbcl_home = SBCL_HOME; + if (!(sbcl_home && *sbcl_home)) sbcl_home = SBCL_HOME; lookhere = (char *) calloc(strlen(sbcl_home) + strlen(stem) + 1, @@ -234,6 +234,7 @@ main(int argc, char *argv[], char *envp[]) boolean end_runtime_options = 0; lispobj initial_function; + const char *sbcl_home = getenv("SBCL_HOME"); interrupt_init(); block_blockable_signals(); @@ -361,8 +362,9 @@ main(int argc, char *argv[], char *envp[]) } } - /* Make sure that SBCL_HOME is set, unless loading an embedded core. */ - if (!getenv("SBCL_HOME") && embedded_core_offset == 0) { + /* Make sure that SBCL_HOME is set and not the empty string, + unless loading an embedded core. */ + if (!(sbcl_home && *sbcl_home) && embedded_core_offset == 0) { char *envstring, *copied_core, *dir; char *stem = "SBCL_HOME="; copied_core = copied_string(core); diff --git a/version.lisp-expr b/version.lisp-expr index 083bda7..687c82f 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.11" +"1.0.11.1" -- 1.7.10.4