From 5f944b144b5bae019e578213d76e9bd81237c6dd Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 25 Sep 2021 09:23:02 -0700 Subject: path-search: rewrite in C with saner semantics. The new function: - just returns the name if it contains path name components. - returns nil if the name is "." or "..". - tests for existence only, not permission to execute. * lisplib.c (path_test_set_entries): Do not auto-load path-test module on the path-search symbol, since it is no longer implemented there. * stdlib/path-test.tl (path-search): Function removed. * stream.c (path_var_sep_char): New global variable. (path_search): New function. (detect_path_separators): Also set path_var_sep_char to semicolon on Cygnal. (stream-init): Register path-search intrinsic here now. * stream.h (path_var_sep_char, path_search): Declared. * tests/018/path-test.tl: New tests. * txr.1: Documentation revised for path-search. --- stdlib/path-test.tl | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'stdlib/path-test.tl') diff --git a/stdlib/path-test.tl b/stdlib/path-test.tl index 4d700167..04ed2055 100644 --- a/stdlib/path-test.tl +++ b/stdlib/path-test.tl @@ -185,16 +185,3 @@ (casequal ent (("." "..")) (t (return nil)))))))) - -(defun path-search (name : (path (getenv "PATH"))) - (if (empty name) - nil - (let ((pcomp (if (listp path) - path - (spl (if (starts-with "CYGNAL" (uname).sysname) #\; #\:) - path)))) - (each ((pc pcomp)) - (if (nequal pc "") - (let ((st (ignerr (stat (path-cat pc name))))) - (if (and st (path-executable-to-me-p st) (path-file-p st)) - (return st.path)))))))) -- cgit v1.2.3