From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2038 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 20:03:08 -0400 Message-ID: <20121001000307.GU254@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 1349050308 27962 80.91.229.3 (1 Oct 2012 00:11:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 1 Oct 2012 00:11:48 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2039-gllmg-musl=m.gmane.org@lists.openwall.com Mon Oct 01 02:11:54 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 1TITc2-0002kb-Gj for gllmg-musl@plane.gmane.org; Mon, 01 Oct 2012 02:11:54 +0200 Original-Received: (qmail 16197 invoked by uid 550); 1 Oct 2012 00:11:49 -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 16189 invoked from network); 1 Oct 2012 00:11:48 -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:2038 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... I've committed a version with several additional issues addressed too. Rich