From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2034 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 17:13:29 -0400 Message-ID: <20120930211329.GP254@brightrain.aerifal.cx> References: <5068B362.5070408@barfooze.de> <20120930210013.GO254@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 1349040137 25036 80.91.229.3 (30 Sep 2012 21:22:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 30 Sep 2012 21:22:17 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2035-gllmg-musl=m.gmane.org@lists.openwall.com Sun Sep 30 23:22:23 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 1TIQxs-0006HA-W9 for gllmg-musl@plane.gmane.org; Sun, 30 Sep 2012 23:22:17 +0200 Original-Received: (qmail 16210 invoked by uid 550); 30 Sep 2012 21:22:11 -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 16202 invoked from network); 30 Sep 2012 21:22:10 -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:2034 Archived-At: On Sun, Sep 30, 2012 at 11:18:33PM +0200, Daniel Cegiełka wrote: > > > > If the only need is option resetting, I think we can handle that > > without any cost, and avoid linking in duplicate code to meet > > applications' needs. > > > > Rich > > 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... Rich