From: Kevin Ryde <user42@zip.com.au>
Subject: Re: tasks call-with-output-string segv
Date: Wed, 24 Sep 2003 09:51:50 +1000 [thread overview]
Message-ID: <87d6drnjvt.fsf@zip.com.au> (raw)
In-Reply-To: 87smn1quch.fsf@raven.i.defaultvalue.org
[-- Attachment #1: Type: text/plain, Size: 666 bytes --]
Rob Browning <rlb@defaultvalue.org> 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.
[-- Attachment #2: strports.c.call-out.diff --]
[-- Type: text/plain, Size: 288 bytes --]
--- 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
[-- Attachment #3: ports.test.csc.diff --]
[-- Type: text/plain, Size: 497 bytes --]
--- 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)))
+
+
\f
;;;; Soft ports. No tests implemented yet.
[-- Attachment #4: scheme-io.texi.str-close.diff --]
[-- Type: text/plain, Size: 889 bytes --]
--- 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
[-- Attachment #5: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
next prev parent reply other threads:[~2003-09-23 23:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-13 1:25 tasks call-with-output-string segv Kevin Ryde
2003-09-13 2:45 ` Rob Browning
2003-09-23 23:51 ` Kevin Ryde [this message]
2003-10-01 17:29 ` Rob Browning
2003-10-02 1:21 ` Kevin Ryde
2003-10-02 1:41 ` Rob Browning
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d6drnjvt.fsf@zip.com.au \
--to=user42@zip.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).