From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: Re: tasks call-with-output-string segv Date: Wed, 24 Sep 2003 09:51:50 +1000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87d6drnjvt.fsf@zip.com.au> References: <87oexpiioa.fsf@zip.com.au> <87smn1quch.fsf@raven.i.defaultvalue.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1064361462 16198 80.91.224.253 (23 Sep 2003 23:57:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 23 Sep 2003 23:57:42 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Sep 24 01:57:40 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A1x2K-00067X-00 for ; Wed, 24 Sep 2003 01:57:40 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 1A1x1q-0001m7-Lk for guile-devel@m.gmane.org; Tue, 23 Sep 2003 19:57:10 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.22) id 1A1wyx-0000lv-JF for guile-devel@gnu.org; Tue, 23 Sep 2003 19:54:11 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.22) id 1A1wy1-0000Vv-5q for guile-devel@gnu.org; Tue, 23 Sep 2003 19:53:13 -0400 Original-Received: from [61.8.0.36] (helo=snoopy.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.22) id 1A1wwo-0000II-7Z for guile-devel@gnu.org; Tue, 23 Sep 2003 19:51:58 -0400 Original-Received: from mongrel.pacific.net.au (mongrel.pacific.net.au [61.8.0.107]) by snoopy.pacific.net.au (8.12.3/8.12.3/Debian-6.4) with ESMTP id h8NNpuG4013536 for ; Wed, 24 Sep 2003 09:51:56 +1000 Original-Received: from localhost (ppp28.dyn228.pacific.net.au [203.143.228.28]) by mongrel.pacific.net.au (8.12.3/8.12.3/Debian-6.6) with ESMTP id h8NNnNXY024253 for ; Wed, 24 Sep 2003 09:49:23 +1000 Original-Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 1A1wwg-0000KX-00; Wed, 24 Sep 2003 09:51:50 +1000 Original-To: guile-devel@gnu.org Mail-Copies-To: never User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2822 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2822 --=-=-= Rob Browning writes: > > Offhand, I'd guess some kind of exception would be in order. * strports.c (scm_call_with_output_string): scm_get_output_string rather than scm_strport_to_string, so as to guard against the port having been closed by the called procedure. * tests/ports.test (call-with-output-string): Test proc closing port. * scheme-io.texi (String Ports): In call-with-output-string, note proc should not close the port. In get-output-string, note string must be gotten before closing the port. This would be a candidate for the 1.6 branch too, if the solution seems ok. --=-=-= Content-Disposition: attachment; filename=strports.c.call-out.diff --- strports.c.~1.98.~ 1970-01-01 10:00:01.000000000 +1000 +++ strports.c 2003-09-22 13:39:47.000000000 +1000 @@ -333,7 +333,7 @@ FUNC_NAME); scm_call_1 (proc, p); - return scm_strport_to_string (p); + return scm_get_output_string (p); } #undef FUNC_NAME --=-=-= Content-Disposition: attachment; filename=ports.test.csc.diff --- ports.test.~1.28.~ 1970-01-01 10:00:01.000000000 +1000 +++ ports.test 2003-09-22 13:49:23.000000000 +1000 @@ -301,6 +301,14 @@ (pass-if "output check" (string=? text result)))) +(with-test-prefix "call-with-output-string" + + ;; In Guile 1.6.4, closing the port resulted in a segv, check that doesn't + ;; occur. + (pass-if-exception "proc closes port" exception:wrong-type-arg + (call-with-output-string close-port))) + + ;;;; Soft ports. No tests implemented yet. --=-=-= Content-Disposition: attachment; filename=scheme-io.texi.str-close.diff --- scheme-io.texi.~1.15.~ 1970-01-01 10:00:01.000000000 +1000 +++ scheme-io.texi 2003-09-22 14:56:31.000000000 +1000 @@ -798,7 +798,7 @@ @deffnx {C Function} scm_call_with_output_string (proc) Calls the one-argument procedure @var{proc} with a newly created output port. When the function returns, the string composed of the characters -written into the port is returned. +written into the port is returned. @var{proc} should not close the port. @end deffn @deffn {Scheme Procedure} call-with-input-string string proc @@ -842,6 +842,9 @@ Given an output port created by @code{open-output-string}, return a string consisting of the characters that have been output to the port so far. + +@code{get-output-string} must be used before closing @var{port}, once +closed the string cannot be obtained. @end deffn A string port can be used in many procedures which accept a port --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel --=-=-=--