From owner-freebsd-i18n@FreeBSD.ORG Wed Jun 16 20:27:14 2010 Return-Path: Delivered-To: i18n@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C9251065672 for ; Wed, 16 Jun 2010 20:27:14 +0000 (UTC) (envelope-from des@des.no) Received: from smtp.des.no (smtp.des.no [194.63.250.102]) by mx1.freebsd.org (Postfix) with ESMTP id EBBD68FC12 for ; Wed, 16 Jun 2010 20:27:13 +0000 (UTC) Received: from ds4.des.no (des.no [84.49.246.2]) by smtp.des.no (Postfix) with ESMTP id 42B5B1FFC34; Wed, 16 Jun 2010 20:10:09 +0000 (UTC) Received: by ds4.des.no (Postfix, from userid 1001) id F2EF08444F; Wed, 16 Jun 2010 22:07:58 +0200 (CEST) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Jaakko Heinonen References: <4C16C5B5.1070308@FreeBSD.org> <20100616190416.GA3896@a91-153-117-195.elisa-laajakaista.fi> Date: Wed, 16 Jun 2010 22:07:58 +0200 In-Reply-To: <20100616190416.GA3896@a91-153-117-195.elisa-laajakaista.fi> (Jaakko Heinonen's message of "Wed, 16 Jun 2010 22:04:16 +0300") Message-ID: <86bpba7nc1.fsf@ds4.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.95 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: FreeBSD Current , Xin LI , Gabor Kovesdan , i18n@FreeBSD.org Subject: Re: [CFT] BSDL iconv in base system X-BeenThere: freebsd-i18n@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD Internationalization Effort List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jun 2010 20:27:14 -0000 Jaakko Heinonen writes: > iconv(3) prototype doesn't conform to POSIX.1-2008. Is it a > well-considered decision? Probably not, because it breaks the interface. Imagine that inbuf were just a char *, not a char **. It would be perfectly safe to change it to const char *, because you can always assign a char * to a const char *. However, inbuf is a char **, which is a pointer to a pointer to char. Gabor changed it to const char **, which is a pointer to a pointer to const char. Unfortunately, the two types are incompatible. If foo is a char *, you can't pass &foo as inbuf. % cat >/tmp/const.c < void fs(char *s) { puts(++s); } void gs(const char *s) { puts(++s); } void fsp(char **sp) { puts(++*sp); } void gsp(const char **sp) { puts(++*sp); } int main() { char *s =3D "xyzzy", **sp =3D &s; fs(s); gs(s); fsp(sp); gsp(s= p); } EOF % cc -Wall -Wextra -Werror -std=3Dc99 -o/dev/null /tmp/const.c cc1: warnings being treated as errors /tmp/const.c: In function =E2=80=98main=E2=80=99: /tmp/const.c:6: error: passing argument 1 of =E2=80=98gsp=E2=80=99 from inc= ompatible pointer type /tmp/const.c:5: note: expected =E2=80=98const char **=E2=80=99 but argument= is of type =E2=80=98char **=E2=80=99 This means you can't, say, read data from a file into a buffer and then pass that buffer to iconv, because the buffer is not const (otherwise you couldn't have read data into it). That seems like a pretty fundamental flaw. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no