(using char-equal) of the two strings. Otherwise, returns ()."
(string-not-greaterp* string1 string2 start1 end1 start2 end2))
-(defun make-string (count &key element-type ((:initial-element fill-char)))
+(defun make-string (count &key
+ (element-type 'character)
+ ((:initial-element fill-char)))
#!+sb-doc
"Given a character count and an optional fill character, makes and returns
- a new string Count long filled with the fill character."
- (declare (fixnum count)
- (ignore element-type))
+ a new string COUNT long filled with the fill character."
+ (declare (fixnum count))
(if fill-char
- (do ((i 0 (1+ i))
- (string (make-string count)))
- ((= i count) string)
- (declare (fixnum i))
- (setf (schar string i) fill-char))
- (make-string count)))
+ (make-string count :element-type element-type :initial-element fill-char)
+ (make-string count :element-type element-type)))
(flet ((%upcase (string start end)
(declare (string string) (index start) (type sequence-end end))
;;; Just convert it into a MAKE-ARRAY.
(deftransform make-string ((length &key
- (element-type 'base-char)
+ (element-type 'character)
(initial-element
#.*default-init-char-form*)))
- '(make-array (the index length)
- :element-type element-type
- :initial-element initial-element))
+ `(the simple-string (make-array (the index length)
+ :element-type element-type
+ ,@(when initial-element
+ '(:initial-element initial-element)))))
(defstruct (specialized-array-element-type-properties
(:conc-name saetp-)
(assert (string= nstring "CaT"))
(nstring-capitalize nstring)
(assert (string= nstring "Cat")))
+
+;;; (VECTOR NIL)s are strings. Tests for that and issues uncovered in
+;;; the process.
+(assert (typep (make-array 1 :element-type nil) 'string))
+(assert (not (typep (make-array 2 :element-type nil) 'base-string)))
+(assert (typep (make-string 3 :element-type nil) 'simple-string))
+(assert (not (typep (make-string 4 :element-type nil) 'simple-base-string)))
+
+(assert (subtypep (class-of (make-array 1 :element-type nil))
+ (find-class 'string)))
+(assert (subtypep (class-of (make-array 2 :element-type nil :fill-pointer 1))
+ (find-class 'string)))
+
+(assert (string= "" (make-array 0 :element-type nil)))
+(assert (string/= "a" (make-array 0 :element-type nil)))
+(assert (string= "" (make-array 5 :element-type nil :fill-pointer 0)))
+
+(assert (= (sxhash "")
+ (sxhash (make-array 0 :element-type nil))
+ (sxhash (make-array 5 :element-type nil :fill-pointer 0))
+ (sxhash (make-string 0 :element-type nil))))
+(assert (subtypep (type-of (make-array 2 :element-type nil)) 'simple-string))
+(assert (subtypep (type-of (make-array 4 :element-type nil :fill-pointer t))
+ 'string))
+
+(assert (eq (intern "") (intern (make-array 0 :element-type nil))))
+(assert (eq (intern "")
+ (intern (make-array 5 :element-type nil :fill-pointer 0))))
+
+(assert (raises-error? (make-string 5 :element-type t)))
+(assert (raises-error? (let () (make-string 5 :element-type t))))
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.8.0.78.vector-nil-string.4"
+"0.8.0.78.vector-nil-string.5"