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.
9 ;;;; This software is part of the SBCL system. See the README file for
10 ;;;; more information.
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.
18 (in-package "SB!IMPL")
20 ;;;; miscellaneous I/O
22 ;;; INDENTING-FURTHER is a user-level macro which may be used to locally
23 ;;; increment the indentation of a stream.
24 (defmacro indenting-further (stream more &rest body)
26 "Causes the output of the indenting Stream to indent More spaces. More is
30 (incf (sb!impl::indenting-stream-indentation ,stream) ,more)
32 (decf (sb!impl::indenting-stream-indentation ,stream) ,more)))
34 (defun skip-whitespace (&optional (stream *standard-input*))
35 (loop (let ((char (read-char stream)))
36 (unless (sb!impl::whitespacep char)
37 (return (unread-char char stream))))))
39 ;;; like LISTEN, but any whitespace in the input stream will be flushed
40 (defun listen-skip-whitespace (&optional (stream *standard-input*))
41 (do ((char (read-char-no-hang stream nil nil nil)
42 (read-char-no-hang stream nil nil nil)))
44 (cond ((not (whitespace-char-p char))
45 (unread-char char stream)
48 ;;;; helpers for C library calls
50 ;;; Signal a SIMPLE-CONDITION/ERROR condition associated with an ANSI C
51 ;;; errno problem, arranging for the condition's print representation
52 ;;; to be similar to the ANSI C perror(3) style.
53 (defun simple-perror (prefix-string
56 (simple-error 'simple-error)
58 (declare (type symbol simple-error))
59 (aver (subtypep simple-error 'simple-condition))
60 (aver (subtypep simple-error 'error))
63 :format-control "~@<~A: ~2I~_~A~:>"
64 :format-arguments (list prefix-string (strerror errno))
65 other-condition-args))