Changeset 15734


Ignore:
Timestamp:
Feb 16, 2013, 1:48:35 AM (7 years ago)
Author:
gb
Message:

#nA - when n>0 - was expecting to be followed by either a list of
lists or a vector of vectors (for some reason lost in antiquity).
It should expect a sequence of sequences.

Fixes ticket:1061 in the trunk. Note that ticket:827 was actually
describing the same problem but the discussion there largely focused
on other things.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lib/read.lisp

    r15306 r15734  
    9090          (make-array nil :initial-contents (read-internal stream t nil t)))
    9191         ((and (integerp dimensions) (> dimensions 0))
    92           (let ((init-list (read-internal stream t nil t)))
    93             (cond ((not (typep init-list 'sequence))
    94                    (signal-reader-error stream "The form following a #~SA reader macro should have been a sequence, but it was: ~S" dimensions init-list))
    95                   ((= (length init-list) 0)
     92          (let ((initial-contents (read-internal stream t nil t)))
     93            (cond ((not (typep initial-contents 'sequence))
     94                   (signal-reader-error stream "The form following a #~SA reader macro should have been a sequence, but it was: ~S" dimensions initial-contents))
     95                  ((= (length initial-contents) 0)
    9696                   (make-array (make-list dimensions :initial-element 0)))
    9797                  ((= dimensions 1)
    98                    (make-array (length init-list) :initial-contents init-list))
    99                   ((vectorp init-list)
     98                   (make-array (length initial-contents) :initial-contents initial-contents))
     99                  (t
    100100                   (let ((dlist (make-list dimensions)))
    101101                     (do ((dl dlist (cdr dl))
    102                           (il init-list (svref il 0)))
     102                          (il initial-contents (if (> (length il) 0)
     103                                                 (etypecase il
     104                                                   (list (car il))
     105                                                   ((vector t) (aref il 0))))))
    103106                         ((null dl))
    104                        (if (vectorp il)
    105                            (rplaca dl (length il))
    106                            (signal-reader-error stream "Initial contents for #A is inconsistent with dimensions: #~SA~S" dimensions init-list)))
    107                      (make-array dlist :initial-contents init-list)))
    108                   ((listp init-list)
    109                    (let ((dlist (make-list dimensions)))
    110                      (do ((dl dlist (cdr dl))
    111                           (il init-list (car il)))
    112                          ((null dl))
    113                        (if (listp il)
    114                            (rplaca dl (list-length il))
    115                            (signal-reader-error stream "Initial contents for #A is inconsistent with dimensions: #~SA~S" dimensions init-list)))
    116                      (make-array dlist :initial-contents init-list)))
    117                   (t
    118                    (signal-reader-error stream "#~SA~S invalid." dimensions init-list)))))
     107                       (rplaca dl (length il)))
     108                     (make-array dlist :initial-contents initial-contents))))))
    119109         (t (signal-reader-error stream "Dimensions argument to #A not a non-negative integer: ~S" dimensions)))))
    120110
Note: See TracChangeset for help on using the changeset viewer.