[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



Hello!  Our version of lxref didn't work right when it was passed the -a
option, so I fixed it.  Someone may want to use the -a option on lxref one
of these days, so I am mailing you my fixes in hopes that you will
distribute them.  

Things are kind of chaotic around here, so I am not sure that I was working
with the most current version of lxref.  Make sure that your current version
of lxref matches the code that I changed before you edit in my changes.

The origional definition of the function process-annotate-file left files
open.  Because the lisp interpreter can only have a finite number of files
open at once, this caused lxref to bomb when it was given a large job to do.
To fix this, I changed the definition of process-annotate-file from:

(defun process-annotate-file (filename)
   (let (sourcep outp)
      ; make sure file exists and write annotate file as a
      ; file with the prefix #,
      (if (null (errset (setq sourcep (infile filename))))
	 then (msg "will ignore that file " N)
	 else ; will write to file.A (erasing the final l)
	      (let ((filen (concat "#," filename)))
		 (setq outp (outfile filen))
		 (anno-it sourcep outp)
		 (close outp)
		 ; now mv the original filename to #dfilename
		 ; and the annotated file to the original file
		 (let ((oldcopy (concat "#." filename)))
		    (if (null (errset
				 (progn (if (probef oldcopy)
					   then (sys:unlink oldcopy))
					(sys:link filename oldcopy)
					(sys:unlink filename)
					(sys:link filen filename)
					(sys:unlink filen))))
		       then (msg "An error occured while mving files around "
				 N
				 "files possibly affected "
				 filename oldcopy filen)))))))

to:

(defun process-annotate-file (filename)
   (let (sourcep outp)
      ; make sure file exists and write annotate file as a
      ; file with the prefix #,
      (if (null (errset (setq sourcep (infile filename))))
	 then (msg "will ignore that file " N)
	 else ; will write to file.A (erasing the final l)
	      (let ((filen (concat "#," filename)))
		 (setq outp (outfile filen))
		 (anno-it sourcep outp)
		 (close outp)
		 (close sourcep)
		 ; now mv the original filename to #dfilename
		 ; and the annotated file to the original file
		 (let ((oldcopy (concat "#." filename)))
		    (if (null (errset
				 (progn (if (probef oldcopy)
					   then (sys:unlink oldcopy))
					(sys:link filename oldcopy)
					(sys:unlink filename)
					(sys:link filen filename)
					(sys:unlink filen))))
		       then (msg "An error occured while mving files around "
				 N
				 "files possibly affected "
				 filename oldcopy filen)))))))

Note that the only change is the insertion of one close statement.

The other bug I found was that find-func miserably failed to do its job
right.  The origional version of the function looked like this:

(defun find-func (buf)
   ; first locate first space or tab
   (do ((i 1 (1+ i))
	(max (cxr 0 buf))
	(die))
       ((or (setq die (not (<& i max)))
	    (memq (cxr i buf) '(#\space #\tab)))
	(if die
	   then nil	; can find it, so give up
	   else ; find first non blank
		(do ((ii i (1+ ii)))
		    ((or (setq die (not (<& ii max)))
			 (not (memq (cxr ii buf) '(#\space #\tab))))
		     (if (or die (eq (cxr ii buf) #\lpar))
			then nil
			else ; fid first sep or left paren
			     (do ((iii (1+ ii) (1+ iii)))
				 ((or (not (<& iii max))
				      (memq (cxr iii buf)
					    '(#\space #\tab #\lpar)))
				  (implode-fun buf ii (1- iii)))))))))))

Not unsurprisingly, this code didn't work.  I discarded it and rewrote the
function in a much simpler fashion:

(defun find-func (buf)
    (let ((i 1)
	  (max (cxr 0 buf))
	  (result nil))
	 (loop until (or (greaterp i max) (memq (cxr i buf) '(#\space #\tab)))
	       do (setq i (+ i 1)))
	 (loop while (and (not (greaterp i max))
			  (memq (cxr i buf) '(#\space #\tab))) do
	       (setq i (+ i 1)))
	 (loop until (or (greaterp i max)
			 (memq (cxr i buf) 
			       '(#\space #\tab #.(getcharn '|(| 1)))) do
	       (setq result (cons (cxr i buf) result))
	       (setq i (+ i 1)))
	 (if result then (implode (reverse result)) else nil)))

The error in the origional definition of find-func caused the -a option to
always do nothing.  It is surprising that no one caught the fact that the -a
option was useless earlier.  (However, I am not sure that the source that I
was looking at came from your tape, so perhaps it isn't your fault.)  In any
case, my version works.

Bye!
					Tim Freeman
					freemant@rpi