From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2037 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: better compatibility with bsd getopt() Date: Sun, 30 Sep 2012 19:54:35 -0400 Message-ID: <20120930235435.GT254@brightrain.aerifal.cx> References: <5068B362.5070408@barfooze.de> <20120930210013.GO254@brightrain.aerifal.cx> <20120930211329.GP254@brightrain.aerifal.cx> <20120930235322.GS254@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1349049855 24944 80.91.229.3 (1 Oct 2012 00:04:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 1 Oct 2012 00:04:15 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2038-gllmg-musl=m.gmane.org@lists.openwall.com Mon Oct 01 02:04:21 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1TITUe-0007zF-QP for gllmg-musl@plane.gmane.org; Mon, 01 Oct 2012 02:04:16 +0200 Original-Received: (qmail 13661 invoked by uid 550); 1 Oct 2012 00:04:08 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 13557 invoked from network); 1 Oct 2012 00:03:16 -0000 Content-Disposition: inline In-Reply-To: <20120930235322.GS254@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2037 Archived-At: On Sun, Sep 30, 2012 at 07:53:22PM -0400, Rich Felker wrote: > On Sun, Sep 30, 2012 at 11:32:44PM +0200, Daniel Cegiełka wrote: > > 2012/9/30 Rich Felker : > > > > >> OpenBSD solves gnu reset option in this way: > > >> > > >> /* > > >> * XXX Some GNU programs (like cvs) set optind to 0 instead of > > >> * XXX using optreset. Work around this braindamage. > > >> */ > > >> if (optind == 0) > > >> optind = optreset = 1; > > > > > > Except the BSD way is the braindamaged one because it violates the > > > namespace. The GNU way simply defines something that was previously > > > undefined by the standard without affecting the namespace. > > > > > > If needed, I think it's possible to support both, with some weak > > > symbol hacks... > > > > sample solution for gnu/bsd getopt() - of course this patch needs this > > weak symbol hacks... > > One more question... is optreset supposed to be declared in a header? > Or is the application responsible for declaring it? Never mind -- I missed that you had it in the header this time. :) Rich