This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

lineio and hcons broken (aargh!)



In the 19980615 core snapshot (and previous snapshots for about a
year) lineio.scm and hcons.scm fail to work (primarily due to the
change in (eq? #f '())).  They are both needed for the lang package to
function. 

I have fixed the problems, although my fix to lineio.scm simply
ignores ungetc-char-ready? since I was not able to find any evidence
of such a function.  

More of ice-9 probably needs fixing. 

As examples:
guile <<EOF
(use-modules (ice-9 hcons))
(define fox (hashq-conser 7))
(display (fox 'foo 'bar))
EOF
guile> guile> guile> ERROR: In procedure cdr in expression (cdr l):
ERROR: Wrong type argument in position 1: ()
ABORT: (wrong-type-arg)

Type "(backtrace)" to get more information.
guile> 
guile <<EOF
(use-modules (ice-9 lineio))
(with-input-from-string "(foo bar baz)"
 (lambda () 
   (let ((lp (make-line-buffering-input-port (current-input-port))))
     (read lp))))
EOF
guile> guile> ERROR: In procedure car in expression (car buffers):
ERROR: Wrong type argument in position 1: ()
ABORT: (wrong-type-arg)

Type "(backtrace)" to get more information.
guile> 

The fixes are fairly straightforward.

*** ice-9/lineio.scm	Mon Jul  6 23:01:25 1998
--- /roo/usr/guile-core-19980424/ice-9/lineio.scm	Tue Jun 24 12:26:23 1997
***************
*** 90,99 ****
  
  	 (unread-string (lambda (str)
  			  (and (< 0 (string-length str))
! ;;			       (if (ungetc-char-ready? self)
! ;;				   (set! buffers (append! (list str (string (read-char self))) buffers))
! ;;				   (set! buffers (cons str buffers))))))
! 				   (set! buffers (cons str buffers)))))
  
  	 (read-string (lambda ()
  		       (cond
--- 90,98 ----
  
  	 (unread-string (lambda (str)
  			  (and (< 0 (string-length str))
! 			       (if (ungetc-char-ready? self)
! 				   (set! buffers (append! (list str (string (read-char self))) buffers))
! 				   (set! buffers (cons str buffers))))))
  
  	 (read-string (lambda ()
  		       (cond
***************
*** 101,115 ****
  			 (let ((answer (car buffers)))
  			   (set! buffers (cdr buffers))
  			   answer))
! ;;			((ungetc-char-ready? self)
! ;;			 (read-line self 'concat))
  			(else
! 			 (read-line underlying-port 'concat)))))) ;handle-newline->concat
  
      (set-object-property! self 'unread-string unread-string)
      (set-object-property! self 'read-string read-string)
      self))
- 
- 
  
  
--- 100,112 ----
  			 (let ((answer (car buffers)))
  			   (set! buffers (cdr buffers))
  			   answer))
! 			((ungetc-char-ready? self)
! 			 (read-line self 'include-newline))
  			(else
! 			 (read-line underlying-port 'include-newline))))))
  
      (set-object-property! self 'unread-string unread-string)
      (set-object-property! self 'read-string read-string)
      self))
  
  
*** ice-9/hcons.scm	Mon Jul  6 23:01:25 1998
--- /roo/usr/guile-core-19980424/ice-9/hcons.scm	Tue Jun 24 12:26:22 1997
***************
*** 36,50 ****
  	  n))
  
  (define-public (hashq-cons-assoc key l)
!     (if (eq? l '()) '()			; (not (eq? #f '()))
! 	(and l 
! 	     (or (and (pair? l)		; If not a pair, use its cdr?
! 		      (pair? (car l))
! 		      (pair? (caar l))
! 		      (eq? (car key) (caaar l))
! 		      (eq? (cdr key) (cdaar l))
! 		      (car l))
! 		 (hashq-cons-assoc key (cdr l))))))
  
  (define-public (hashq-cons-get-handle table key)
    (hashx-get-handle hashq-cons-hash hashq-cons-assoc table key #f))
--- 36,48 ----
  	  n))
  
  (define-public (hashq-cons-assoc key l)
!   (and l (or (and (pair? l)
! 		  (pair? (car l))
! 		  (pair? (caar l))
! 		  (eq? (car key) (caaar l))
! 		  (eq? (cdr key) (cdaar l))
! 		  (car l))
! 	     (hashq-cons-assoc key (cdr l)))))
  
  (define-public (hashq-cons-get-handle table key)
    (hashx-get-handle hashq-cons-hash hashq-cons-assoc table key #f))

Andrew
aarchiba@undergrad.math.uwaterloo.ca