Re: Re: [Axiom-mail] Re: `)read' and large inputs

Waldek Hebisch <[email protected]>
Newsgroups gmane.comp.mathematics.axiom.devel,gmane.comp.mathematics.axiom.user
Message-ID <[email protected]>
Vanuxem Grégory wrote:
> I encountered the same issue with the history of Axiom in a file which
> is buggy (see
> http://wiki.axiom-developer.org/323HandlingOfTheHistoryInAFile)
> 
> I reported the Library file problem too on IssueTracker.
> 

I applied the patch below to wh-sandbox -- so library and history
handling should now work in wh-sandbox.  The last part (adding slash)
is not needed for the testcase, but my show up in other situations.
ATM Axiom code handles slashes in ad hoc manner: sometimes directory
names end in slashes sometimes names without slashes are used and
slash is added later.  We should use uniform convention here --
probably store directory names without slases and add slases when
forming files nemes (that would agree with Lisp namestring and with
user expectation about filenames).

diff -ru wh-sandbox.bb/src/algebra/files.spad.pamphlet wh-sandbox/src/algebra/files.spad.pamphlet
--- wh-sandbox.bb/src/algebra/files.spad.pamphlet	2006-11-15 23:00:59.000000000 +0100
+++ wh-sandbox/src/algebra/files.spad.pamphlet	2006-11-17 01:54:38.000000000 +0100
@@ -389,10 +389,8 @@
  
         defstream(fn: Name, mode: IOMode): FileState ==
             mode = "input"  =>
-              not readable? fn => error ["File is not readable", fn]
               RDEFINSTREAM(fn::String)$Lisp
             mode = "output" =>
-              not writable? fn => error ["File is not writable", fn]
               RDEFOUTSTREAM(fn::String)$Lisp
             error ["IO mode must be input or output", mode]
  
@@ -409,9 +407,7 @@
             mode = "either" =>
                 exists? fname =>
                     open(fname, "input")
-                writable? fname =>
-                    reopen_!(open(fname, "output"), "input")
-                error "File does not exist and cannot be created"
+                reopen_!(open(fname, "output"), "input")
             [fname, defstream(fname, mode), mode]
         reopen_!(f, mode) ==
             close_! f
@@ -506,6 +502,10 @@
              ++ \spad{lib.k := v} saves the value \spad{v} in the library
              ++ \spad{lib}.  It can later be extracted using the key \spad{k}.
 
+         close_!: % -> %
+          ++ close!(f) returns the library f closed to input and output.
+
+
     == KeyedAccessFile(Any) add
          Rep := KeyedAccessFile(Any)
          library f == open f
diff -ru wh-sandbox.bb/src/interp/fname.lisp.pamphlet wh-sandbox/src/interp/fname.lisp.pamphlet
--- wh-sandbox.bb/src/interp/fname.lisp.pamphlet	2006-11-15 23:01:44.000000000 +0100
+++ wh-sandbox/src/interp/fname.lisp.pamphlet	2006-11-17 01:33:03.000000000 +0100
@@ -94,7 +94,7 @@
     (if s s "") ))
  
 (defun |fnameExists?| (f)
-  (if (probe-file f) 't nil))
+  (if (vmlisp::axiom-probe-file (namestring f)) 't nil))
 
 (defun |fnameReadable?| (f)
 #+:CCL (file-readablep f)
@@ -112,7 +112,8 @@
     (do ((fn))
         (nil)
         (setq fn (|fnameMake| d (string (gensym n)) e))
-        (if (not (probe-file fn)) (return-from |fnameNew| fn)) )))
+        (if (not (vmlisp::axiom-probe-file (namestring fn)))
+           (return-from |fnameNew| fn)) )))
 @
 \eject
 \begin{thebibliography}{99}
diff -ru wh-sandbox.bb/src/interp/nlib.lisp.pamphlet wh-sandbox/src/interp/nlib.lisp.pamphlet
--- wh-sandbox.bb/src/interp/nlib.lisp.pamphlet	2006-11-15 23:01:45.000000000 +0100
+++ wh-sandbox/src/interp/nlib.lisp.pamphlet	2006-11-16 22:32:36.000000000 +0100
@@ -435,9 +435,6 @@
 (defun make-full-namestring (filearg &optional (filetype nil))
   (namestring (merge-pathnames (make-filename filearg filetype))))
 
-(defun probe-name (file)
-  (if (probe-file file) (namestring file) nil))
-
 (defun get-directory-list (ft &aux (cd (namestring $current-directory)))
   (cond ((member ft '("NRLIB" "DAASE" "EXPOSED") :test #'string=)
 	   (if (eq BOOT::|$UserLevel| 'BOOT::|development|)
@@ -451,8 +448,10 @@
 (defun axiom-probe-file (file)
     (if (equal (|directoryp| file) -1)
          nil
-         (truename file))
-)
+         (truename file)))
+
+(defun probe-name (file)
+  (if (axiom-probe-file file) (namestring file) nil))
 
 (defun make-input-filename (filearg &optional (filetype nil))
    (let*
@@ -465,7 +464,7 @@
 	(dolist (dir dirs (probe-name filename))
 		(when 
 		 (axiom-probe-file 
-		  (setq newfn (concatenate 'string dir filename)))
+		  (setq newfn (concatenate 'string dir "/" filename)))
 		 (return newfn)))
         (probe-name filename))))
 


-- 
                              Waldek Hebisch
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.