From owner-freebsd-arch@FreeBSD.ORG Thu Jul 31 20:07:41 2014 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0A5AA45B; Thu, 31 Jul 2014 20:07:41 +0000 (UTC) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.freebsd.org (Postfix) with ESMTP id C3FD3211D; Thu, 31 Jul 2014 20:07:40 +0000 (UTC) Received: from critter.freebsd.dk (unknown [192.168.48.2]) by phk.freebsd.dk (Postfix) with ESMTP id EF9011578; Thu, 31 Jul 2014 20:07:38 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.14.9/8.14.9) with ESMTP id s6VK7b9K058088; Thu, 31 Jul 2014 20:07:38 GMT (envelope-from phk@phk.freebsd.dk) To: John-Mark Gurney Subject: Re: XML Output: libxo - provide single API to output TXT, XML, JSON and HTML In-reply-to: <20140731175547.GO43962@funkthat.com> From: "Poul-Henning Kamp" References: <20140730193819.GM43962@funkthat.com> <201407302324.s6UNOB2H087915@idle.juniper.net> <20140731175547.GO43962@funkthat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <58086.1406837257.1@critter.freebsd.dk> Date: Thu, 31 Jul 2014 20:07:37 +0000 Message-ID: <58087.1406837257@critter.freebsd.dk> Cc: sjg@freebsd.org, arch@freebsd.org, marcel@freebsd.org, Phil Shafer X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jul 2014 20:07:41 -0000 -------- In message <20140731175547.GO43962@funkthat.com>, John-Mark Gurney writes: >Phil Shafer wrote this message on Wed, Jul 30, 2014 at 19:24 -0400: >> John-Mark Gurney writes: >> >My vote would be to use and *enforce* UTF-8 by the API. That means if >> >someone passes a string in, it must be properly formed UTF-8... >> >> I can certainly see making this an option, detecting the high-bit >> and inspecting the following 1-5 bytes to ensure the corresponding >> high two bits are set appropriately. But what action would you >> expect the library to take when invalid strings are passed in? > >Return an error? printf can return an error, yet most people don't >check it.. so no real difference in API/bugs... This is why we ended up with SIGPIPE in the first place. Can I point discreetely at sbuf(3)'s accumulative error handling and suggest that libxo does something similar ? That way applications only need to check for errors once, rather than after every single call to every single function in the libxo library. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.