--- ../../../sbcl-mt-0.8.28+really.0.8.9/src/code/reader.lisp	2004-03-18 05:28:21.000000000 +0800
+++ reader.lisp	2004-05-05 14:13:07.000000000 +0800
@@ -306,17 +306,26 @@
 
 ;;;; implementation of the read buffer
 
-(defvar *read-buffer*)
-(defvar *read-buffer-length*)
+
+;;; creating *read-buffer* on a per-process basis to avoid thread issues
+#!+sb-thread (defvar *read-buffer* (make-hash-table))
+#!-sb-thread (defvar *read-buffer*)
+;; (defvar *read-buffer-length*)
 ;;; FIXME: Is it really helpful to have *READ-BUFFER-LENGTH* be a
 ;;; separate variable instead of just calculating it on the fly as
 ;;; (LENGTH *READ-BUFFER*)?
+;;; Probably not. I'm trying it without since it eases the use of the hash
 
 (defvar *inch-ptr*)
 (defvar *ouch-ptr*)
 
-(declaim (type index *read-buffer-length* *inch-ptr* *ouch-ptr*))
-(declaim (type (simple-array character (*)) *read-buffer*))
+(declaim (type index *inch-ptr* *ouch-ptr*))
+;(declaim (type (simple-array character (*)) *read-buffer*))
+
+
+(defmacro get-read-buffer ()
+  #!+sb-thread `(gethash (sb!thread:current-thread-id) *read-buffer*)
+  #!-sb-thread `*read-buffer*)
 
 (defmacro reset-read-buffer ()
   ;; Turn *READ-BUFFER* into an empty read buffer.
@@ -327,8 +336,8 @@
      (setq *inch-ptr* 0)))
 
 (defun !cold-init-read-buffer ()
-  (setq *read-buffer* (make-string 512)) ; initial bufsize
-  (setq *read-buffer-length* 512)
+  (setf (get-read-buffer) (make-string 512)) ; initial bufsize
+;  (setq *read-buffer-length* 512)
   (reset-read-buffer))
 
 ;;; FIXME I removed "THE FIXNUM"'s from OUCH-READ-BUFFER and
@@ -337,13 +346,14 @@
 ;;; converting them from macros to inline functions might be good,
 ;;; too.
 
-(defmacro ouch-read-buffer (char)
+(defmacro ouch-read-buffer (char &optional (read-buffer (get-read-buffer)))
   `(progn
      ;; When buffer overflow
-     (when (>= *ouch-ptr* *read-buffer-length*)
+     (when (>= *ouch-ptr* (length ,read-buffer))
        ;; Size should be doubled.
-       (grow-read-buffer))
-     (setf (elt (the simple-string *read-buffer*) *ouch-ptr*) ,char)
+       (grow-read-buffer ,read-buffer))
+     (setf (elt (the simple-string ,read-buffer) *ouch-ptr*) ,char
+	   (get-read-buffer) ,read-buffer)
      (setq *ouch-ptr* (1+ *ouch-ptr*))))
 
 ;;; macro to move *ouch-ptr* back one.
@@ -351,24 +361,23 @@
   '(when (> *ouch-ptr* *inch-ptr*)
      (setq *ouch-ptr* (1- (the fixnum *ouch-ptr*)))))
 
-(defun grow-read-buffer ()
-  (let ((rbl (length (the simple-string *read-buffer*))))
-    (setq *read-buffer*
+(defun grow-read-buffer (&optional (read-buffer (get-read-buffer)))
+  (let ((rbl (length (the simple-string read-buffer))))
+    (setf (get-read-buffer)
 	  (concatenate 'simple-string
-		       *read-buffer*
-		       (make-string rbl)))
-    (setq *read-buffer-length* (* 2 rbl))))
+		       read-buffer
+		       (make-string rbl)))))
 
-(defun inchpeek-read-buffer ()
+(defun inchpeek-read-buffer (&optional (read-buffer (get-read-buffer)))
   (if (>= (the fixnum *inch-ptr*) (the fixnum *ouch-ptr*))
       *eof-object*
-      (elt *read-buffer* *inch-ptr*)))
+      (elt read-buffer *inch-ptr*)))
 
-(defun inch-read-buffer ()
+(defun inch-read-buffer (&optional (read-buffer (get-read-buffer)))
   (if (>= *inch-ptr* *ouch-ptr*)
       *eof-object*
       (prog1
-	  (elt *read-buffer* *inch-ptr*)
+	  (elt read-buffer *inch-ptr*)
 	(incf *inch-ptr*))))
 
 (defmacro unread-buffer ()
@@ -378,8 +387,8 @@
   ;; Keep contents, but make next (INCH..) return first character.
   (setq *inch-ptr* 0))
 
-(defun read-buffer-to-string ()
-  (subseq *read-buffer* 0 *ouch-ptr*))
+(defun read-buffer-to-string (&optional (read-buffer (get-read-buffer)))
+  (subseq read-buffer 0 *ouch-ptr*))
 
 ;;;; READ-PRESERVING-WHITESPACE, READ-DELIMITED-LIST, and READ
 
@@ -539,14 +548,15 @@
   ;; This accumulates chars until it sees same char that invoked it.
   ;; For a very long string, this could end up bloating the read buffer.
   (reset-read-buffer)
-  (let ((stream (in-synonym-of stream)))
+  (let ((stream (in-synonym-of stream))
+	(read-buffer (get-read-buffer)))
     (if (ansi-stream-p stream)
 	(prepare-for-fast-read-char stream
 	  (do ((char (fast-read-char t) (fast-read-char t)))
 	      ((char= char closech)
 	       (done-with-fast-read-char))
 	    (if (escapep char) (setq char (fast-read-char t)))
-	    (ouch-read-buffer char)))
+	    (ouch-read-buffer char read-buffer)))
 	;; CLOS stream
 	(do ((char (read-char stream nil :eof) (read-char stream nil :eof)))
 	    ((or (eq char :eof) (char= char closech))
@@ -556,8 +566,8 @@
 	    (setq char (read-char stream nil :eof))
 	    (if (eq char :eof)
 		(error 'end-of-file :stream stream)))
-	  (ouch-read-buffer char))))
-  (read-buffer-to-string))
+	  (ouch-read-buffer char read-buffer)))
+    (read-buffer-to-string read-buffer)))
 
 (defun read-right-paren (stream ignore)
   (declare (ignore ignore))
@@ -569,53 +579,54 @@
 ;;; -- The position of the first package delimiter (or NIL).
 (defun internal-read-extended-token (stream firstchar escape-firstchar)
   (reset-read-buffer)
-  (let ((escapes '()))
+  (let ((escapes '())
+	(read-buffer (get-read-buffer)))
     (when escape-firstchar
       (push *ouch-ptr* escapes)
-      (ouch-read-buffer firstchar)
+      (ouch-read-buffer firstchar read-buffer)
       (setq firstchar (read-char stream nil *eof-object*)))
-  (do ((char firstchar (read-char stream nil *eof-object*))
-       (colon nil))
-      ((cond ((eofp char) t)
-	     ((token-delimiterp char)
-	      (unread-char char stream)
-	      t)
-	     (t nil))
-       (values escapes colon))
-    (cond ((escapep char)
-	   ;; It can't be a number, even if it's 1\23.
-	   ;; Read next char here, so it won't be casified.
-	   (push *ouch-ptr* escapes)
-	   (let ((nextchar (read-char stream nil *eof-object*)))
-	     (if (eofp nextchar)
-		 (reader-eof-error stream "after escape character")
-		 (ouch-read-buffer nextchar))))
-	  ((multiple-escape-p char)
-	   ;; Read to next multiple-escape, escaping single chars
-	   ;; along the way.
-	   (loop
-	     (let ((ch (read-char stream nil *eof-object*)))
-	       (cond
-		((eofp ch)
-		 (reader-eof-error stream "inside extended token"))
-		((multiple-escape-p ch) (return))
-		((escapep ch)
-		 (let ((nextchar (read-char stream nil *eof-object*)))
-		   (cond ((eofp nextchar)
-			  (reader-eof-error stream "after escape character"))
-			 (t
-			  (push *ouch-ptr* escapes)
-			  (ouch-read-buffer nextchar)))))
-		(t
-		 (push *ouch-ptr* escapes)
-		 (ouch-read-buffer ch))))))
-	  (t
-	   (when (and (constituentp char)
+    (do ((char firstchar (read-char stream nil *eof-object*))
+	 (colon nil))
+	((cond ((eofp char) t)
+	       ((token-delimiterp char)
+		(unread-char char stream)
+		t)
+	       (t nil))
+	 (values escapes colon))
+      (cond ((escapep char)
+	     ;; It can't be a number, even if it's 1\23.
+	     ;; Read next char here, so it won't be casified.
+	     (push *ouch-ptr* escapes)
+	     (let ((nextchar (read-char stream nil *eof-object*)))
+	       (if (eofp nextchar)
+		   (reader-eof-error stream "after escape character")
+		 (ouch-read-buffer nextchar read-buffer))))
+	    ((multiple-escape-p char)
+	     ;; Read to next multiple-escape, escaping single chars
+	     ;; along the way.
+	     (loop
+	      (let ((ch (read-char stream nil *eof-object*)))
+		(cond
+		 ((eofp ch)
+		  (reader-eof-error stream "inside extended token"))
+		 ((multiple-escape-p ch) (return))
+		 ((escapep ch)
+		  (let ((nextchar (read-char stream nil *eof-object*)))
+		    (cond ((eofp nextchar)
+			   (reader-eof-error stream "after escape character"))
+			  (t
+			   (push *ouch-ptr* escapes)
+			   (ouch-read-buffer nextchar read-buffer)))))
+		 (t
+		  (push *ouch-ptr* escapes)
+		  (ouch-read-buffer ch read-buffer))))))
+	    (t
+	     (when (and (constituentp char)
 			(eql (get-secondary-attribute char)
                              +char-attr-package-delimiter+)
-		      (not colon))
-	     (setq colon *ouch-ptr*))
-	   (ouch-read-buffer char))))))
+			(not colon))
+	       (setq colon *ouch-ptr*))
+	     (ouch-read-buffer char read-buffer))))))
 
 ;;;; character classes
 
@@ -678,13 +689,15 @@
 ;;; Modify the read buffer according to READTABLE-CASE, ignoring
 ;;; ESCAPES. ESCAPES is a list of the escaped indices, in reverse
 ;;; order.
-(defun casify-read-buffer (escapes)
-  (let ((case (readtable-case *readtable*)))
+(defun casify-read-buffer (escapes &optional (read-buffer (get-read-buffer)))
+  (let ((case (readtable-case *readtable*))
+	(read-buffer (get-read-buffer)))
     (cond
      ((and (null escapes) (eq case :upcase))
       (dotimes (i *ouch-ptr*)
-	(setf (schar *read-buffer* i)
-	      (char-upcase (schar *read-buffer* i)))))
+	(setf (schar read-buffer i)
+	      (char-upcase (schar read-buffer i))))
+      (setf (get-read-buffer) read-buffer))
      ((eq case :preserve))
      (t
       (macrolet ((skip-esc (&body body)
@@ -700,12 +713,12 @@
 					 (aver (= esc i))
 					 (pop escapes)
 					 nil))))
-			(let ((ch (schar *read-buffer* i)))
+			(let ((ch (schar read-buffer i)))
 			  ,@body)))))
 	(flet ((lower-em ()
-		 (skip-esc (setf (schar *read-buffer* i) (char-downcase ch))))
+		 (skip-esc (setf (schar read-buffer i) (char-downcase ch))))
 	       (raise-em ()
-		 (skip-esc (setf (schar *read-buffer* i) (char-upcase ch)))))
+		 (skip-esc (setf (schar read-buffer i) (char-upcase ch)))))
 	  (ecase case
 	    (:upcase (raise-em))
 	    (:downcase (lower-em))
@@ -718,7 +731,9 @@
 		       (setq all-lower nil)
 		       (setq all-upper nil))))
 	       (cond (all-lower (raise-em))
-		     (all-upper (lower-em))))))))))))
+		     (all-upper (lower-em))))))
+	  (setf (get-read-buffer) read-buffer)))))))
+
 
 (defun read-token (stream firstchar)
   #!+sb-doc
@@ -733,6 +748,7 @@
   (when *read-suppress*
     (internal-read-extended-token stream firstchar nil)
     (return-from read-token nil))
+  (reset-read-buffer)
   (let ((attribute-table (character-attribute-table *readtable*))
 	(package-designator nil)
 	(colons 0)
@@ -741,8 +757,8 @@
 	(possibly-float t)
 	(was-possibly-float nil)
 	(escapes ())
-	(seen-multiple-escapes nil))
-    (reset-read-buffer)
+	(seen-multiple-escapes nil)
+	(read-buffer (get-read-buffer)))
     (prog ((char firstchar))
       (case (char-class3 char attribute-table)
 	(#.+char-attr-constituent-sign+ (go SIGN))
@@ -758,7 +774,7 @@
 	;; can't have eof, whitespace, or terminating macro as first char!
 	(t (go SYMBOL)))
      SIGN ; saw "sign"
-      (ouch-read-buffer char)
+      (ouch-read-buffer char read-buffer)
       (setq char (read-char stream nil nil))
       (unless char (go RETURN-SYMBOL))
       (setq possibly-rational t
@@ -776,7 +792,7 @@
 	(#.+char-attr-delimiter+ (unread-char char stream) (go RETURN-SYMBOL))
 	(t (go SYMBOL)))
      LEFTDIGIT ; saw "[sign] {digit}+"
-      (ouch-read-buffer char)
+      (ouch-read-buffer char read-buffer)
       (setq char (read-char stream nil nil))
       (unless char (return (make-integer)))
       (setq was-possibly-float possibly-float)
@@ -806,7 +822,7 @@
 	(#.+char-attr-package-delimiter+ (go COLON))
 	(t (go SYMBOL)))
      LEFTDIGIT-OR-EXPT
-      (ouch-read-buffer char)
+      (ouch-read-buffer char read-buffer)
       (setq char (read-char stream nil nil))
       (unless char (return (make-integer)))
       (case (char-class3 char attribute-table)
@@ -827,7 +843,7 @@
 	(t (go SYMBOL)))
      LEFTDECIMALDIGIT ; saw "[sign] {decimal-digit}+"
       (aver possibly-float)
-      (ouch-read-buffer char)
+      (ouch-read-buffer char read-buffer)
       (setq char (read-char stream nil nil))
       (unless char (go RETURN-SYMBOL))
       (case (char-class char attribute-table)
@@ -843,7 +859,7 @@
 	(#.+char-attr-package-delimiter+ (go COLON))
 	(t (go SYMBOL)))
      MIDDLEDOT ; saw "[sign] {digit}+ dot"
-      (ouch-read-buffer char)
+      (ouch-read-buffer char read-buffer)
       (setq char (read-char stream nil nil))
       (unless char (return (let ((*read-base* 10))
 			     (make-integer))))
@@ -859,7 +875,7 @@
 	(#.+char-attr-package-delimiter+ (go COLON))
 	(t (go SYMBOL)))
      RIGHTDIGIT ; saw "[sign] {decimal-digit}* dot {digit}+"
-      (ouch-read-buffer char)
+      (ouch-read-buffer char read-buffer)
       (setq char (read-char stream nil nil))
       (unless char (return (make-float stream)))
       (case (char-class char attribute-table)
@@ -873,7 +889,7 @@
 	(#.+char-attr-package-delimiter+ (go COLON))
 	(t (go SYMBOL)))
      SIGNDOT ; saw "[sign] dot"
-      (ouch-read-buffer char)
+      (ouch-read-buffer char read-buffer)
       (setq char (read-char stream nil nil))
       (unless char (go RETURN-SYMBOL))
       (case (char-class char attribute-table)
@@ -883,7 +899,7 @@
 	(#.+char-attr-multiple-escape+ (go MULT-ESCAPE))
 	(t (go SYMBOL)))
      FRONTDOT ; saw "dot"
-      (ouch-read-buffer char)
+      (ouch-read-buffer char read-buffer)
       (setq char (read-char stream nil nil))
       (unless char (%reader-error stream "dot context error"))
       (case (char-class char attribute-table)
@@ -895,7 +911,7 @@
 	(#.+char-attr-package-delimiter+ (go COLON))
 	(t (go SYMBOL)))
      EXPONENT
-      (ouch-read-buffer char)
+      (ouch-read-buffer char read-buffer)
       (setq char (read-char stream nil nil))
       (unless char (go RETURN-SYMBOL))
       (setq possibly-float t)
@@ -908,7 +924,7 @@
 	(#.+char-attr-package-delimiter+ (go COLON))
 	(t (go SYMBOL)))
      EXPTSIGN ; got to EXPONENT, and saw a sign character
-      (ouch-read-buffer char)
+      (ouch-read-buffer char read-buffer)
       (setq char (read-char stream nil nil))
       (unless char (go RETURN-SYMBOL))
       (case (char-class char attribute-table)
@@ -919,7 +935,7 @@
 	(#.+char-attr-package-delimiter+ (go COLON))
 	(t (go SYMBOL)))
      EXPTDIGIT ; got to EXPONENT, saw "[sign] {digit}+"
-      (ouch-read-buffer char)
+      (ouch-read-buffer char read-buffer)
       (setq char (read-char stream nil nil))
       (unless char (return (make-float stream)))
       (case (char-class char attribute-table)
@@ -932,7 +948,7 @@
 	(#.+char-attr-package-delimiter+ (go COLON))
 	(t (go SYMBOL)))
      RATIO ; saw "[sign] {digit}+ slash"
-      (ouch-read-buffer char)
+      (ouch-read-buffer char read-buffer)
       (setq char (read-char stream nil nil))
       (unless char (go RETURN-SYMBOL))
       (case (char-class2 char attribute-table)
@@ -943,7 +959,7 @@
 	(#.+char-attr-package-delimiter+ (go COLON))
 	(t (go SYMBOL)))
      RATIODIGIT ; saw "[sign] {digit}+ slash {digit}+"
-      (ouch-read-buffer char)
+      (ouch-read-buffer char read-buffer)
       (setq char (read-char stream nil nil))
       (unless char (return (make-ratio stream)))
       (case (char-class2 char attribute-table)
@@ -956,7 +972,7 @@
 	(#.+char-attr-package-delimiter+ (go COLON))
 	(t (go SYMBOL)))
      DOTS ; saw "dot {dot}+"
-      (ouch-read-buffer char)
+      (ouch-read-buffer char read-buffer)
       (setq char (read-char stream nil nil))
       (unless char (%reader-error stream "too many dots"))
       (case (char-class char attribute-table)
@@ -974,7 +990,7 @@
 	    (prepare-for-fast-read-char stream
 	      (prog ()
 	       SYMBOL-LOOP
-	       (ouch-read-buffer char)
+	       (ouch-read-buffer char read-buffer)
 	       (setq char (fast-read-char nil nil))
 	       (unless char (go RETURN-SYMBOL))
 	       (case (char-class char attribute-table)
@@ -991,7 +1007,7 @@
 	    ;; CLOS stream
 	    (prog ()
 	     SYMBOL-LOOP
-	     (ouch-read-buffer char)
+	     (ouch-read-buffer char read-buffer)
 	     (setq char (read-char stream nil :eof))
 	     (when (eq char :eof) (go RETURN-SYMBOL))
 	     (case (char-class char attribute-table)
@@ -1008,7 +1024,7 @@
 	(unless nextchar
 	  (reader-eof-error stream "after escape character"))
 	(push *ouch-ptr* escapes)
-	(ouch-read-buffer nextchar))
+	(ouch-read-buffer nextchar read-buffer))
       (setq char (read-char stream nil nil))
       (unless char (go RETURN-SYMBOL))
       (case (char-class char attribute-table)
@@ -1023,7 +1039,7 @@
 	  ((multiple-escape-p char))
 	(if (escapep char) (setq char (read-char stream t)))
 	(push *ouch-ptr* escapes)
-	(ouch-read-buffer char))
+	(ouch-read-buffer char read-buffer))
       (setq char (read-char stream nil nil))
       (unless char (go RETURN-SYMBOL))
       (case (char-class char attribute-table)
@@ -1033,10 +1049,10 @@
 	(#.+char-attr-package-delimiter+ (go COLON))
 	(t (go SYMBOL)))
       COLON
-      (casify-read-buffer escapes)
+      (casify-read-buffer escapes read-buffer)
       (unless (zerop colons)
 	(%reader-error stream "too many colons in ~S"
-		      (read-buffer-to-string)))
+		      (read-buffer-to-string read-buffer)))
       (setq colons 1)
       (setq package-designator
 	    (if (plusp *ouch-ptr*)
@@ -1045,9 +1061,9 @@
 		;; explicit package prefix. Perhaps we could implement
 		;; a FIND-PACKAGE* function analogous to INTERN*
 		;; and friends?
-		(read-buffer-to-string)
+		(read-buffer-to-string read-buffer)
 		(if seen-multiple-escapes
-		    (read-buffer-to-string)
+		    (read-buffer-to-string read-buffer)
 		    *keyword-package*)))
       (reset-read-buffer)
       (setq escapes ())
@@ -1082,7 +1098,7 @@
 			package-designator))
 	(t (go SYMBOL)))
       RETURN-SYMBOL
-      (casify-read-buffer escapes)
+      (casify-read-buffer escapes read-buffer)
       (let ((found (if package-designator
 		       (find-package package-designator)
 		       (sane-package))))
@@ -1092,11 +1108,11 @@
 		 :format-control "package ~S not found"))
 
 	(if (or (zerop colons) (= colons 2) (eq found *keyword-package*))
-	    (return (intern* *read-buffer* *ouch-ptr* found))
+	    (return (intern* read-buffer *ouch-ptr* found))
 	    (multiple-value-bind (symbol test)
-		(find-symbol* *read-buffer* *ouch-ptr* found)
+		(find-symbol* read-buffer *ouch-ptr* found)
 	      (when (eq test :external) (return symbol))
-	      (let ((name (read-buffer-to-string)))
+	      (let ((name (read-buffer-to-string read-buffer)))
 		(with-simple-restart (continue "Use symbol anyway.")
 		  (error 'reader-package-error :stream stream
 			 :format-arguments (list name (package-name found))
@@ -1112,12 +1128,14 @@
 ;;; a flag for whether there was an escape char, and the position of
 ;;; any package delimiter.
 (defun read-extended-token (stream &optional (*readtable* *readtable*))
-  (let ((first-char (read-char stream nil nil t)))
+  (let ((first-char (read-char stream nil nil t))
+	(read-buffer (get-read-buffer)))
     (cond (first-char
 	   (multiple-value-bind (escapes colon)
                (internal-read-extended-token stream first-char nil)
-	     (casify-read-buffer escapes)
-	     (values (read-buffer-to-string) (not (null escapes)) colon)))
+	     (casify-read-buffer escapes read-buffer)
+	     (values (read-buffer-to-string read-buffer)
+		     (not (null escapes)) colon)))
 	  (t
 	   (values "" nil nil)))))
 
@@ -1126,11 +1144,12 @@
 ;;; Read an extended token with the first character escaped. Return
 ;;; the string for the token.
 (defun read-extended-token-escaped (stream &optional (*readtable* *readtable*))
-  (let ((first-char (read-char stream nil nil)))
+  (let ((first-char (read-char stream nil nil))
+	(read-buffer (get-read-buffer)))
     (cond (first-char
             (let ((escapes (internal-read-extended-token stream first-char t)))
-              (casify-read-buffer escapes)
-              (read-buffer-to-string)))
+              (casify-read-buffer escapes read-buffer)
+              (read-buffer-to-string read-buffer)))
           (t
             (reader-eof-error stream "after escape")))))
 
@@ -1181,17 +1200,18 @@
 |#
 
 (defun make-integer ()
-  #!+sb-doc
+  #!+sb-doc 
   "Minimizes bignum-fixnum multiplies by reading a 'safe' number of digits,
   then multiplying by a power of the base and adding."
   (let* ((base *read-base*)
 	 (digits-per (aref *integer-reader-safe-digits* base))
 	 (base-power (aref *integer-reader-base-power* base))
 	 (negativep nil)
-	 (number 0))
+	 (number 0)
+	 (read-buffer (get-read-buffer)))
     (declare (type index digits-per base-power))
     (read-unwind-read-buffer)
-    (let ((char (inch-read-buffer)))
+    (let ((char (inch-read-buffer read-buffer)))
       (cond ((char= char #\-)
 	     (setq negativep t))
 	    ((char= char #\+))
@@ -1200,7 +1220,7 @@
      (let ((num 0))
        (declare (type index num))
        (dotimes (digit digits-per)
-	 (let* ((ch (inch-read-buffer)))
+	 (let* ((ch (inch-read-buffer read-buffer)))
 	   (cond ((or (eofp ch) (char= ch #\.))
 		  (return-from make-integer
 			       (let ((res
@@ -1216,27 +1236,28 @@
   ;; Assume that the contents of *read-buffer* are a legal float, with nothing
   ;; else after it.
   (read-unwind-read-buffer)
-  (let ((negative-fraction nil)
-	(number 0)
-	(divisor 1)
-	(negative-exponent nil)
-	(exponent 0)
-	(float-char ())
-	(char (inch-read-buffer)))
+  (let* ((negative-fraction nil)
+	 (number 0)
+	 (divisor 1)
+	 (negative-exponent nil)
+	 (exponent 0)
+	 (float-char ())
+	 (read-buffer (get-read-buffer))
+	 (char (inch-read-buffer read-buffer)))
     (if (cond ((char= char #\+) t)
 	      ((char= char #\-) (setq negative-fraction t)))
 	;; Flush it.
-	(setq char (inch-read-buffer)))
+	(setq char (inch-read-buffer read-buffer)))
     ;; Read digits before the dot.
-    (do* ((ch char (inch-read-buffer))
+    (do* ((ch char (inch-read-buffer read-buffer))
 	  (dig (digit-char-p ch) (digit-char-p ch)))
 	 ((not dig) (setq char ch))
       (setq number (+ (* number 10) dig)))
     ;; Deal with the dot, if it's there.
     (when (char= char #\.)
-      (setq char (inch-read-buffer))
+      (setq char (inch-read-buffer read-buffer))
       ;; Read digits after the dot.
-      (do* ((ch char (inch-read-buffer))
+      (do* ((ch char (inch-read-buffer read-buffer))
 	    (dig (and (not (eofp ch)) (digit-char-p ch))
 		 (and (not (eofp ch)) (digit-char-p ch))))
 	   ((not dig) (setq char ch))
@@ -1252,14 +1273,14 @@
 	  ((exponent-letterp char)
 	   (setq float-char char)
 	   ;; Build exponent.
-	   (setq char (inch-read-buffer))
+	   (setq char (inch-read-buffer read-buffer))
 	   ;; Check leading sign.
 	   (if (cond ((char= char #\+) t)
 		     ((char= char #\-) (setq negative-exponent t)))
 	       ;; Flush sign.
-	       (setq char (inch-read-buffer)))
+	       (setq char (inch-read-buffer read-buffer)))
 	   ;; Read digits for exponent.
-	   (do* ((ch char (inch-read-buffer))
+	   (do* ((ch char (inch-read-buffer read-buffer))
 		 (dig (and (not (eofp ch)) (digit-char-p ch))
 		      (and (not (eofp ch)) (digit-char-p ch))))
 		((not dig)
@@ -1327,22 +1348,26 @@
   ;; the string.
   ;;
   ;; Look for optional "+" or "-".
-  (let ((numerator 0) (denominator 0) (char ()) (negative-number nil))
+  (let ((numerator 0)
+	(denominator 0)
+	(char ())
+	(negative-number nil)
+	(read-buffer (get-read-buffer)))
     (read-unwind-read-buffer)
-    (setq char (inch-read-buffer))
+    (setq char (inch-read-buffer read-buffer))
     (cond ((char= char #\+)
-	   (setq char (inch-read-buffer)))
+	   (setq char (inch-read-buffer read-buffer)))
 	  ((char= char #\-)
-	   (setq char (inch-read-buffer))
+	   (setq char (inch-read-buffer read-buffer))
 	   (setq negative-number t)))
     ;; Get numerator.
-    (do* ((ch char (inch-read-buffer))
+    (do* ((ch char (inch-read-buffer read-buffer))
 	  (dig (digit-char-p ch *read-base*)
 	       (digit-char-p ch *read-base*)))
 	 ((not dig))
 	 (setq numerator (+ (* numerator *read-base*) dig)))
     ;; Get denominator.
-    (do* ((ch (inch-read-buffer) (inch-read-buffer))
+    (do* ((ch (inch-read-buffer read-buffer) (inch-read-buffer read-buffer))
 	  (dig ()))
 	 ((or (eofp ch) (not (setq dig (digit-char-p ch *read-base*)))))
 	 (setq denominator (+ (* denominator *read-base*) dig)))
@@ -1545,7 +1570,7 @@
   (!cold-init-secondary-attribute-table)
   (!cold-init-standard-readtable)
   ;; FIXME: This was commented out, but should probably be restored.
-  #+nil (!cold-init-integer-reader))
+  #!+nil (!cold-init-integer-reader))
 
 (def!method print-object ((readtable readtable) stream)
   (print-unreadable-object (readtable stream :identity t :type t)))
