Allow string-builder to take a zero argument.
authorChris Hanson <org/chris-hanson/cph>
Tue, 19 Nov 2019 06:46:03 +0000 (22:46 -0800)
committerChris Hanson <org/chris-hanson/cph>
Wed, 20 Nov 2019 03:06:01 +0000 (19:06 -0800)
This simplifies cases where the length of the result is known in advance and
passed as the buffer size.

src/runtime/string.scm

index 5e78396e249fca4a867d2fd414210a96ca40ebe8..660da8ec5da450faf1dcb361cc5636b80ba6ac58 100644 (file)
@@ -590,8 +590,8 @@ USA.
          (if (default-object? buffer-length)
              1024
              (begin
-               (guarantee positive-fixnum? buffer-length 'string-builder)
-               buffer-length)))))
+               (guarantee non-negative-fixnum? buffer-length 'string-builder)
+               (fix:max 1 buffer-length))))))
     (let ((append-char! (builder 'append-char!))
          (append-string! (builder 'append-string!))
          (build (builder 'build)))