On Sun, May 29, 2016 at 05:36:09PM +0200, [email protected] wrote:
> > What do the other core hackers think?
> 
> A fixed limit is fine. There is no need to cover every possible situation, and
> user code (exception handler) may take care of special cases like your 
> example.
> Any other solution will just introduce complexity that is never used.

I just noticed that it's only the default handler anyway.  But still, I
think a larger default makes more sense.  Attached is a signed-off
version which sets the limit to 400 characters, which should be 5 lines
on a "standard" 80 column terminal.

I added it to NEWS because this is quite noticable to the user.  I also
applied it to master and then cherry-picked it to CHICKEN 5 because the
original patch was for master.

Cheers,
Peter
From 557a5368cf25f17b023f42765f7250b877155fff Mon Sep 17 00:00:00 2001
From: LemonBoy <[email protected]>
Date: Wed, 25 May 2016 21:35:11 +0200
Subject: [PATCH] Truncate overlong lines in ##sys#error-handler

Signed-off-by: Peter Bex <[email protected]>
---
 NEWS        |  2 ++
 library.scm | 34 ++++++++++++++++++++--------------
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/NEWS b/NEWS
index 7214e7d..2c539a4 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,8 @@
 - Runtime system:
   - C_locative_ref has been deprecated in favor of C_a_i_locative_ref,
     which is faster because it is inlined (#1260, thanks to Kooda).
+  - The default error handler now truncates very long condition
+    messages (thanks to Lemonboy).
 
 4.11.0
 
diff --git a/library.scm b/library.scm
index 0d997c2..0cba1c8 100644
--- a/library.scm
+++ b/library.scm
@@ -4572,15 +4572,18 @@ EOF
 	      (when msg
 		(##sys#print ": " #f ##sys#standard-error)
 		(##sys#print msg #f ##sys#standard-error) )
-	      (cond [(fx= 1 (length args))
-		     (##sys#print ": " #f ##sys#standard-error)
-		     (##sys#print (##sys#slot args 0) #t ##sys#standard-error) ]
-		    [else
-		     (##sys#for-each
-		      (lambda (x)
-			(##sys#print #\newline #f ##sys#standard-error)
-			(##sys#print x #t ##sys#standard-error) )
-		      args) ] )
+	      (##sys#with-print-length-limit
+	       400
+	       (lambda ()
+		 (cond [(fx= 1 (length args))
+			(##sys#print ": " #f ##sys#standard-error)
+			(##sys#print (##sys#slot args 0) #t ##sys#standard-error)]
+		       [else
+			(##sys#for-each
+			 (lambda (x)
+			   (##sys#print #\newline #f ##sys#standard-error)
+			   (##sys#print x #t ##sys#standard-error))
+			 args)])))
 	      (##sys#print #\newline #f ##sys#standard-error)
 	      (print-call-chain ##sys#standard-error)
 	      (when (and ##sys#break-on-error (##sys#symbol-has-toplevel-binding? 'chicken.repl#repl))
@@ -4662,7 +4665,7 @@ EOF
        '(user-interrupt)
        '() ) ) ]
     [(#:warning #:notice)
-     (##sys#print 
+     (##sys#print
       (if (eq? mode #:warning) "\nWarning: " "\nNote: ")
       #f ##sys#standard-error)
      (##sys#print msg #f ##sys#standard-error)
@@ -4671,10 +4674,13 @@ EOF
 	 (##sys#print ": " #f ##sys#standard-error))
      (for-each
       (lambda (x)
-	(##sys#print x #t ##sys#standard-error)
-	(##sys#write-char-0 #\newline ##sys#standard-error) )
-      args) 
-     (##sys#flush-output ##sys#standard-error) ] 
+	(##sys#with-print-length-limit
+	 400
+	 (lambda ()
+	   (##sys#print x #t ##sys#standard-error)
+	   (##sys#write-char-0 #\newline ##sys#standard-error))))
+      args)
+     (##sys#flush-output ##sys#standard-error)]
     [else
      (when (and (symbol? msg) (null? args))
        (set! msg (##sys#symbol->string msg)) )
-- 
2.1.4

From dc9caee01e19ed5f55a490e64c8f626b3b453d6b Mon Sep 17 00:00:00 2001
From: LemonBoy <[email protected]>
Date: Wed, 25 May 2016 21:35:11 +0200
Subject: [PATCH] Truncate overlong lines in ##sys#error-handler

Signed-off-by: Peter Bex <[email protected]>
---
 NEWS        |  2 ++
 library.scm | 34 ++++++++++++++++++++--------------
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/NEWS b/NEWS
index 2893626..f5948ce 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@
 - Runtime system:
   - C_locative_ref has been deprecated in favor of C_a_i_locative_ref,
     which is faster because it is inlined (#1260, thanks to Kooda).
+  - The default error handler now truncates very long condition
+    messages (thanks to Lemonboy).
 
 4.11.0
 
diff --git a/library.scm b/library.scm
index a32ee8c..e95542f 100644
--- a/library.scm
+++ b/library.scm
@@ -3898,15 +3898,18 @@ EOF
 	      (when msg
 		(##sys#print ": " #f ##sys#standard-error)
 		(##sys#print msg #f ##sys#standard-error) )
-	      (cond [(fx= 1 (length args))
-		     (##sys#print ": " #f ##sys#standard-error)
-		     (##sys#print (##sys#slot args 0) #t ##sys#standard-error) ]
-		    [else
-		     (##sys#for-each
-		      (lambda (x)
-			(##sys#print #\newline #f ##sys#standard-error)
-			(##sys#print x #t ##sys#standard-error) )
-		      args) ] )
+	      (##sys#with-print-length-limit
+	       400
+	       (lambda ()
+		 (cond [(fx= 1 (length args))
+			(##sys#print ": " #f ##sys#standard-error)
+			(##sys#print (##sys#slot args 0) #t ##sys#standard-error)]
+		       [else
+			(##sys#for-each
+			 (lambda (x)
+			   (##sys#print #\newline #f ##sys#standard-error)
+			   (##sys#print x #t ##sys#standard-error))
+			 args)])))
 	      (##sys#print #\newline #f ##sys#standard-error)
 	      (print-call-chain ##sys#standard-error)
 	      (when (and ##sys#break-on-error (##sys#symbol-has-toplevel-binding? 'repl))
@@ -3988,7 +3991,7 @@ EOF
        '(user-interrupt)
        '() ) ) ]
     [(#:warning #:notice)
-     (##sys#print 
+     (##sys#print
       (if (eq? mode #:warning) "\nWarning: " "\nNote: ")
       #f ##sys#standard-error)
      (##sys#print msg #f ##sys#standard-error)
@@ -3997,10 +4000,13 @@ EOF
 	 (##sys#print ": " #f ##sys#standard-error))
      (for-each
       (lambda (x)
-	(##sys#print x #t ##sys#standard-error)
-	(##sys#write-char-0 #\newline ##sys#standard-error) )
-      args) 
-     (##sys#flush-output ##sys#standard-error) ] 
+	(##sys#with-print-length-limit
+	 400
+	 (lambda ()
+	   (##sys#print x #t ##sys#standard-error)
+	   (##sys#write-char-0 #\newline ##sys#standard-error))))
+      args)
+     (##sys#flush-output ##sys#standard-error)]
     [else
      (when (and (symbol? msg) (null? args))
        (set! msg (##sys#symbol->string msg)) )
-- 
2.1.4

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Chicken-hackers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to