Initial revision
[sbcl.git] / src / code / target-extensions.lisp
1 ;;;; This file contains things for the extensions package which can't
2 ;;;; be built at cross-compile time, and perhaps also some things
3 ;;;; which might as well not be built at cross-compile time because
4 ;;;; they're not needed then. Things which can't be built at
5 ;;;; cross-compile time (e.g. because they need machinery which only
6 ;;;; exists inside SBCL's implementation of the LISP package) do not
7 ;;;; belong in this file.
8
9 ;;;; This software is part of the SBCL system. See the README file for
10 ;;;; more information.
11 ;;;;
12 ;;;; This software is derived from the CMU CL system, which was
13 ;;;; written at Carnegie Mellon University and released into the
14 ;;;; public domain. The software is in the public domain and is
15 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
16 ;;;; files for more information.
17
18 (in-package "SB!EXT")
19
20 (file-comment
21   "$Header$")
22
23 ;;; INDENTING-FURTHER is a user-level macro which may be used to locally
24 ;;; increment the indentation of a stream.
25 (defmacro indenting-further (stream more &rest body)
26   #!+sb-doc
27   "Causes the output of the indenting Stream to indent More spaces. More is
28   evaluated twice."
29   `(unwind-protect
30      (progn
31       (incf (sb!impl::indenting-stream-indentation ,stream) ,more)
32       ,@body)
33      (decf (sb!impl::indenting-stream-indentation ,stream) ,more)))
34
35 (defun skip-whitespace (&optional (stream *standard-input*))
36   (loop (let ((char (read-char stream)))
37           (unless (sb!impl::whitespacep char)
38             (return (unread-char char stream))))))
39
40 (defun listen-skip-whitespace (&optional (stream *standard-input*))
41   #!+sb-doc
42   "See LISTEN. Any whitespace in the input stream will be flushed."
43   (do ((char (read-char-no-hang stream nil nil nil)
44              (read-char-no-hang stream nil nil nil)))
45       ((null char) nil)
46     (cond ((not (sb!impl::whitespace-char-p char))
47            (unread-char char stream)
48            (return t)))))