[PATCH] use canonical path for $spadroot

4 views
Skip to first unread message

Qian Yun

unread,
Sep 26, 2023, 8:17:12 PM9/26/23
to fricas-devel
Canonicalize (use absolute path and avoid double slashing) $FRICAS or
parent dir of FRICASsys before setting it to $spadroot.

- Qian

diff --git a/src/interp/util.lisp b/src/interp/util.lisp
index ffce3d1f..6acd1172 100644
--- a/src/interp/util.lisp
+++ b/src/interp/util.lisp
@@ -107,7 +107,8 @@ from scratch.
;;; of the {\bf FRICAS} shell variable at build time) if we can't.
;;; Use the parent directory of FRICASsys binary as fallback.
(defun initroot (&optional (newroot nil))
- (reroot (or (|getEnv| "FRICAS") newroot
+ (reroot (namestring (truename
+ (or (|getEnv| "FRICAS") newroot
(if (|fricas_probe_file| $spadroot) $spadroot)
(let ((bin-parent-dir
(concatenate 'string

Waldek Hebisch

unread,
Sep 27, 2023, 6:16:52 AM9/27/23
to fricas...@googlegroups.com
AFAICS this still produces name with slash at the end, which will
lead to double slashes downstream (FriCAS convention is that
directory name contains no shlash at the end). We have a trivial
utility function 'trim-directory-name' to make sure there is no
trailing slash.

Also, 'truename' may throw errors on non-existing directories, I
am not sure how we want to handle that (our directory should
exist, but it needs some testing to check if error message is
reasonable).

--
Waldek Hebisch

Qian Yun

unread,
Sep 27, 2023, 7:03:13 AM9/27/23
to fricas...@googlegroups.com
Here is updated version:

diff --git a/src/interp/util.lisp b/src/interp/util.lisp
index ffce3d1f..7459b3ef 100644
--- a/src/interp/util.lisp
+++ b/src/interp/util.lisp
@@ -107,7 +107,7 @@ from scratch.
;;; of the {\bf FRICAS} shell variable at build time) if we can't.
;;; Use the parent directory of FRICASsys binary as fallback.
(defun initroot (&optional (newroot nil))
- (reroot (or (|getEnv| "FRICAS") newroot
+ (setq spadroot (or (|getEnv| "FRICAS") newroot
(if (|fricas_probe_file| $spadroot) $spadroot)
(let ((bin-parent-dir
(concatenate 'string
@@ -116,7 +116,10 @@ from scratch.
(if (|fricas_probe_file| (concatenate 'string
bin-parent-dir

"algebra/interp.daase"))
bin-parent-dir))
- (error "setenv FRICAS or (setq $spadroot)"))))
+ (error "setenv FRICAS or (setq $spadroot)")))
+ (if (|fricas_probe_file| spadroot)
+ (reroot (trim-directory-name (namestring (truename spadroot))))
+ (error "Environment variable FRICAS is invalid.")))

;;; Gnu Common Lisp (GCL) (at least 2.6.[78]) requires some changes
;;; to the default memory setup to run FriCAS efficiently.

Qian Yun

unread,
Oct 9, 2023, 6:05:53 AM10/9/23
to fricas...@googlegroups.com
Small update after previous commit to util.lisp.

- Qian

====

diff --git a/src/interp/util.lisp b/src/interp/util.lisp
index b841a14b..4a60b338 100644
--- a/src/interp/util.lisp
+++ b/src/interp/util.lisp
@@ -105,7 +105,7 @@ from scratch.
;;; Sets up the system to use the {\bf FRICAS} shell variable if we can
;;; otherwise use the parent directory of FRICASsys binary as fallback.
(defun initroot ()
- (reroot (or (|getEnv| "FRICAS")
+ (setq spadroot (or (|getEnv| "FRICAS")
(let ((bin-parent-dir
(concatenate 'string
(directory-namestring (car
(|getCLArgs|)))
@@ -113,7 +113,10 @@ from scratch.
(if (|fricas_probe_file| (concatenate 'string
bin-parent-dir

"algebra/interp.daase"))
bin-parent-dir))
- (error "Environment variable FRICAS is not set!"))))
+ (error "Environment variable FRICAS is not set!")))
+ (if (|fricas_probe_file| spadroot)
+ (reroot (trim-directory-name (namestring (truename spadroot))))
+ (error "Environment variable FRICAS is not valid!")))

;;; Gnu Common Lisp (GCL) (at least 2.6.[78]) requires some changes
;;; to the default memory setup to run FriCAS efficiently.

Waldek Hebisch

unread,
Oct 10, 2023, 4:51:51 PM10/10/23
to fricas...@googlegroups.com
On Mon, Oct 09, 2023 at 06:05:49PM +0800, Qian Yun wrote:
> Small update after previous commit to util.lisp.

OK, please commit.

--
Waldek Hebisch

Qian Yun

unread,
Oct 10, 2023, 8:12:44 PM10/10/23
to fricas...@googlegroups.com
I guess we can replace some of 'getEnv "FRICAS"' to '$spadroot'
to utilize this canonicalized path.

- Qian
Reply all
Reply to author
Forward
0 new messages