net.lisp: Print addresses and nets usefully when `*print-escape*' is off.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 3 May 2024 00:11:25 +0000 (01:11 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 4 May 2024 23:56:24 +0000 (00:56 +0100)
net.lisp

index aa7e395..7996827 100644 (file)
--- a/net.lisp
+++ b/net.lisp
   (:documentation "Transform the address IP into a numeric textual form."))
 
 (defmethod print-object ((addr ipaddr) stream)
-  (print-unreadable-object (addr stream :type t)
-    (write-string (ipaddr-string addr) stream)))
+  (if *print-escape*
+      (print-unreadable-object (addr stream :type t)
+       (write-string (ipaddr-string addr) stream))
+      (write-string (ipaddr-string addr) stream)))
 
 (export 'ipaddrp)
 (defun ipaddrp (ip)
                (ipaddr-string (make-instance (class-of net) :addr mask))))))
 
 (defmethod print-object ((ipn ipnet) stream)
-  (print-unreadable-object (ipn stream :type t)
-    (write-string (ipnet-string ipn) stream)))
+  (if *print-escape*
+      (print-unreadable-object (ipn stream :type t)
+       (write-string (ipnet-string ipn) stream))
+      (write-string (ipnet-string ipn) stream)))
 
 (defun parse-subnet (class width max str &key (start 0) (end nil) (slashp t))
   "Parse a subnet description from (a substring of) STR.