[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-developer] $erase (Re: [Axiom-commit] SF.net SVN: axiom: [209] tr
From: |
Vanuxem Grégory |
Subject: |
[Axiom-developer] $erase (Re: [Axiom-commit] SF.net SVN: axiom: [209] trunk3) |
Date: |
Sat, 28 Oct 2006 16:40:25 +0200 |
Le jeudi 26 octobre 2006 à 22:23 -0700, address@hidden a
écrit :
> Revision: 209
> http://svn.sourceforge.net/axiom/?rev=209&view=rev
> Author: billpage
> Date: 2006-10-26 22:23:36 -0700 (Thu, 26 Oct 2006)
>
[...]
> 20060906 cxm src/interp/nlib.lisp (and (directory filearg...
> 20060901 tpd src/interp/nlib.lisp (probe-file => (directory (truename
>
> Original author: Tim Daly <address@hidden>
> Date: 2006-10-24 21:52:10-04:00
[...]
> Modified: trunk3/trunk3/src/interp/nlib.lisp.pamphlet
> ===================================================================
> --- trunk3/trunk3/src/interp/nlib.lisp.pamphlet 2006-10-27 04:37:59 UTC
> (rev 208)
> +++ trunk3/trunk3/src/interp/nlib.lisp.pamphlet 2006-10-27 05:23:36 UTC
> (rev 209)
> @@ -473,10 +473,24 @@
> (some #'(lambda (ft) (make-input-filename file-name ft))
> filetypelist)))
>
> +@
> +Apparently probe-file cannot properly handle directories and
> +treat them as regular files so we need to change the test from:
> +\begin{verbatim}
> + (if (probe-file filearg)
> +\end{verbatim}
> +to
> +\begin{verbatim}
> + (if (directory (truename filearg))
> +\end{verbatim}
> +Camm feels that we should be testing for null so the code has
> +again been changed to reflect that. And since truename was
> +the previous change we wrap it around the make-full-namestring call.
> +<<*>>=
> ;; ($ERASE filearg) -> 0 if succeeds else 1
> (defun $erase (&rest filearg)
> - (setq filearg (make-full-namestring filearg))
> - (if (probe-file filearg)
> + (setq filearg (truename (make-full-namestring filearg)))
> + (if (and (directory filearg) (not (probe-file filearg)))
> #+:CCL (delete-file filearg)
> #+:AKCL
> (if (library-file filearg) ; always true (Greg)
(delete-directory filearg)
(delete-file filearg))
1))
Grrr... you broke my code... and you introduced some bugs :-)
Here you affect a pathname to filearg but you will use delete-directory
with this pathname as argument. delete-directory want a string since its
code is:
(defun delete-directory (dirname)
(system (concat "rm -r " dirname)))
concat does not take pathname as argument.
More complicated to explain: 'erase' uses make-full-namestring which
returns approximately (concat current-directory the-argument) and calls
truename which will return a pathname even if this pathname does not
exist (I consider this as a bug in GCL). So, since 'directory' in GCL
returns a list of files or directories (more precisely pathnames) that
matches a "pattern" (see the end of this mail), 'delete-directory' will
be called if you have a file or a directory with a name "pattern
matched" even if this file or directory does not exist.
Now even if you fix the code, with 'namestring' for example, $erase will
work only on directories (~> _(not (probe-file filearg)_). If we
consider that 'probe-file' worked in the past on directories and files
the $erase function need to be able to delete file too.
$erase is used "everywhere" in the interpreter and I can not check if
this new specialisation of $erase will break the code so I can not say
that this is a bug, I can only say: "hey guys you broke my code and
possibly other part of the interpreter please allow $erase to work on
file too, in this way I'll continue to use it or I will create the old
$erase function with a different name." :-)
Here is the code that I use actually but it's no meant to be included in
Axiom, do what you want with it (directoryp can be rewritten in
"full-lisp" with the new si::stat GCL function now):
;; ($ERASE filearg) -> 0 if succeeds else 1
(defun $erase (&rest filearg)
(setq filearg (make-full-namestring filearg))
(if (or (probe-file filearg) (eql (|directoryp| filearg) 1))
; In CCL delete-file can delete a directory?
#+:CCL (delete-file filearg)
#+:AKCL
(if (library-file filearg) ; always true (can be removed)
(delete-directory filearg)
(delete-file filearg))
1))
Greg
======================================================================
(directory "/home/greg/Axiom/te") returns for me:
(#p"/home/greg/Axiom/test1.ao" #p"/home/greg/Axiom/test1.as"
#p"/home/greg/Axiom/test1.asy" #p"/home/greg/Axiom/test1.fn"
#p"/home/greg/Axiom/test1.lsp" #p"/home/greg/Axiom/test1.o"
#p"/home/greg/Axiom/test.ao" #p"/home/greg/Axiom/test.as"
#p"/home/greg/Axiom/test.asy" #p"/home/greg/Axiom/test.axh"
#p"/home/greg/Axiom/teste.spad" #p"/home/greg/Axiom/test.fn"
#p"/home/greg/Axiom/test.input" #p"/home/greg/Axiom/test.lsp"
#p"/home/greg/Axiom/test.o" #p"/home/greg/Axiom/test.spad")
note that there is no te directory nor te file.
- [Axiom-developer] $erase (Re: [Axiom-commit] SF.net SVN: axiom: [209] trunk3),
Vanuxem Grégory <=