chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH] pretty printer shows blobs readably


From: Felix
Subject: [Chicken-hackers] [PATCH] pretty printer shows blobs readably
Date: Sun, 25 Sep 2011 14:43:58 +0200 (CEST)

Attached a patch to print the contents of blobs also in pretty-printing
mode.


cheers,
felix
>From 596d4f4642d512f24a0b7e4b1db2ea681911ab75 Mon Sep 17 00:00:00 2001
From: felix <address@hidden>
Date: Sun, 25 Sep 2011 14:23:11 +0200
Subject: [PATCH] pretty printer shows blobs readably

---
 extras.scm |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/extras.scm b/extras.scm
index 151ca95..bb9e434 100644
--- a/extras.scm
+++ b/extras.scm
@@ -380,11 +380,15 @@
               (out (get-output-string o) col) ) )
            ((port? obj) (out (string-append "#<port " (##sys#slot obj 3) ">") 
col))
            ((##core#inline "C_bytevectorp" obj)
-            (if (##core#inline "C_permanentp" obj)
-                (out "#<static blob of size" col)
-                (out "#<blob of size " col) )
-            (out (number->string (##core#inline "C_block_size" obj)) col)
-            (out ">" col) )
+            (out "#${" col)
+            (let ((len (##sys#size obj)))
+              (do ((i 0 (fx+ i 1)))
+                  ((fx>= i len))
+                (let ((b (##sys#byte obj i)))
+                  (when (fx< b 16)
+                    (out "0" col))
+                  (out (##sys#number->string b 16) col)))
+              (out "}" col)))
            ((##core#inline "C_lambdainfop" obj)
             (out "#<lambda info " col)
             (out (##sys#lambda-info->string obj) col)
-- 
1.7.0.4


reply via email to

[Prev in Thread] Current Thread [Next in Thread]