From owner-freebsd-current@FreeBSD.ORG Tue Feb 5 20:46:50 2013 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 2DF215DC for ; Tue, 5 Feb 2013 20:46:50 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id EB93877D for ; Tue, 5 Feb 2013 20:46:49 +0000 (UTC) Received: from pakbsde14.localnet (unknown [38.105.238.108]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id CED5BB91A for ; Tue, 5 Feb 2013 15:46:48 -0500 (EST) From: John Baldwin To: current@freebsd.org Subject: [PATCH] open_memstream() and open_wmemstream() Date: Tue, 5 Feb 2013 15:46:43 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p22; KDE/4.5.5; amd64; ; ) MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201302051546.43839.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Tue, 05 Feb 2013 15:46:48 -0500 (EST) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Feb 2013 20:46:50 -0000 I've written an implementation of open_memstream() and open_wmemstream() along with a set of regression tests. I'm pretty sure open_memstream() is correct, and I believe open_wmemstream() is correct for expected usage. The latter might even do the right thing if you split a multi-byte character across multiple writes. One question I have is if my choice to discard any pending multi-byte state in the stream anytime a seek changes the effective position in the output stream. I think this is correct as stdio will flush any pending data before doing a seek, so if there is a partially parsed character we aren't going to get the rest of it. http://www.FreeBSD.org/~jhb/patches/open_memstream.patch -- John Baldwin