From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2036 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:53:22 -0400 Message-ID: <20120930235322.GS254@brightrain.aerifal.cx> References: <5068B362.5070408@barfooze.de> <20120930210013.GO254@brightrain.aerifal.cx> <20120930211329.GP254@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 1349049731 24272 80.91.229.3 (1 Oct 2012 00:02:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 1 Oct 2012 00:02:11 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2037-gllmg-musl=m.gmane.org@lists.openwall.com Mon Oct 01 02:02:15 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 1TITSg-000754-2r for gllmg-musl@plane.gmane.org; Mon, 01 Oct 2012 02:02:14 +0200 Original-Received: (qmail 12227 invoked by uid 550); 1 Oct 2012 00:02:05 -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 12213 invoked from network); 1 Oct 2012 00:02:03 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2036 Archived-At: 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? Rich