From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,RDNS_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: (qmail 9616 invoked from network); 12 Mar 2020 00:13:49 -0000 Received-SPF: pass (minnie.tuhs.org: domain of minnie.tuhs.org designates 45.79.103.53 as permitted sender) receiver=inbox.vuxu.org; client-ip=45.79.103.53 envelope-from= Received: from unknown (HELO minnie.tuhs.org) (45.79.103.53) by inbox.vuxu.org with ESMTP; 12 Mar 2020 00:13:49 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 97F669BC11; Thu, 12 Mar 2020 10:13:46 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 9ABBE9BB47; Thu, 12 Mar 2020 10:13:26 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="j2fjrz+k"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 5ED419BB47; Thu, 12 Mar 2020 10:13:25 +1000 (AEST) Received: from mail-ua1-f48.google.com (mail-ua1-f48.google.com [209.85.222.48]) by minnie.tuhs.org (Postfix) with ESMTPS id BD4129BB46 for ; Thu, 12 Mar 2020 10:13:24 +1000 (AEST) Received: by mail-ua1-f48.google.com with SMTP id g21so1460690uaj.1 for ; Wed, 11 Mar 2020 17:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zb4pLksHW19a/LWVNebAOwrzKo2uOBfYMsvKhaB58EM=; b=j2fjrz+kDRmw5ib1PCeqDS85Cp757TQTCTREyr5Z+JhUpX1ui6pg3IAsZGptWIlE/d Oo2U4l/lXyDluF6vYae4Q/63DCN7riu/CDTSiZygK2uyeUPZHCcLFRRU/zZTYhfVOrDx aFi96Q+KC7mTjiFMZNu9gXQqmwhY6zza/gem/KBliHq9j3P/FEbiOscsFPDq98/TNfoS xxQTMn5OlPKzaw005/+FATJktNKMH+j8gY8tHfa0Thd9yWzJOVjdHec6zpDdF71tj+rK B57BaWl5ZCxWD1Ml5gJKwN1XLfHKKSeHeiDQZO+NLCOQDMnMlLmRb1yfjpJtS7x9mnxu /+Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zb4pLksHW19a/LWVNebAOwrzKo2uOBfYMsvKhaB58EM=; b=nDlCwCjAsUz6DbrNqQwrntGWLip3S5u+TWr/EGss0dX0OA18ht0a1BCt56xeZ755sK 7oTVSekswZLtmleGRyk8Ak4UZ3MhFtFwrvj5vtH0M8zMcZdbFXGPzVMJvhvuhcWdY3ak 31rPJdifoFri6M9glU35U7lt1fUOPh1AOwZDhtJO4mj2igBywGn2BkveLmeV5TcZmt4c LSIMkUeRbuDoyHQnoBrgZZr+wQGKdIDcH5xGNxZv2O1BZcnPobdB1AEkwyApL9KG/ovl 1ZXybhUy4lgJKkwU1/wDGY9bPeqyLxQIxULVq4XUAaqxscX1HZX6S5Sc+Dr6pN/BQn5R ylmA== X-Gm-Message-State: ANhLgQ2bqd3+gtQVIQ+qLsMkettxzDadkqs95vHYCIgJ7kvGjYO7pLHp AfWi2gvyEVf6lxl/nxZAuputmCq6ZFTTQ1cLNkw= X-Google-Smtp-Source: ADFU+vvvCgnT6Roxc5WBGKBkLMkeBiVe+x6iWFzvmzgMOUOynwUR7i+BYX7/WYlTeW8FHDHb91xZEA8Be5Athu4czcY= X-Received: by 2002:ab0:6212:: with SMTP id m18mr3287755uao.120.1583972003728; Wed, 11 Mar 2020 17:13:23 -0700 (PDT) MIME-Version: 1.0 References: <20200305020517.GA13872@wopr> <20200308052632.GD20478@eureka.lemis.com> <202003080532.0285WcWn1544496@darkstar.fourwinds.com> <20200309212257.GB39634@wopr> In-Reply-To: From: "John P. Linderman" Date: Wed, 11 Mar 2020 20:13:11 -0400 Message-ID: To: Warner Losh Content-Type: multipart/alternative; boundary="0000000000009dd2ae05a09d38ac" Subject: Re: [TUHS] Command line options and complexity X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: The Unix Heritage Society Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" --0000000000009dd2ae05a09d38ac Content-Type: text/plain; charset="UTF-8" I wasn't running FreeBSD. Linux has nothing to say about it. The wonderful thing about standards is that there are so many to choose from. On Wed, Mar 11, 2020 at 5:29 PM Warner Losh wrote: > > > On Wed, Mar 11, 2020 at 11:43 AM John P. Linderman > wrote: > >> This is *great*, Kurt. The source in src/runtime/hrs/src for rsort.c is >> their version of my external sort, modified to be a subroutine. There's >> some lessons to be learned about "software hygiene". I was cavalier about >> freeing what I allocated dynamically. As a result, their version leaks like >> a sieve if the subroutine is called repeatedly. Apropos of which, they came >> to me having noted that only the first call was acting as expected. There's >> a wonderful irony (I'm big on irony). I had replaced my do-it-yourself >> argument processing with getopt. The code has the following comment >> >> ** Use getopt() for portability. >> >> A few lines later, you see >> >> optind = 1; /* reset after use in Hancock program * >> while ((c = getopt(argc, argv, "cCiIjmrsSuvb:f:D:o:p:T:x:y:z:")) != >> EOF) { >> >> optind??? Seems getopt has an undocumented global flag to prevent >> reprocessing the arguments. How portable:-) >> > > It's documented: > > The variables opterr and optind are both initialized to 1. The optind > variable may be set to another value before a set of calls to > getopt() in > order to skip over more or less argv entries. > > is what the FreeBSD man page has to say about it. So this just resets any > scanning that had happened before this... > > Warner > --0000000000009dd2ae05a09d38ac Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I w= asn't running FreeBSD. Linux has nothing to say about it. The wonderful= thing about standards is that there are so many to choose from.

On We= d, Mar 11, 2020 at 5:29 PM Warner Losh <imp@bsdimp.com> wrote:


On Wed, Mar 11, 2020= at 11:43 AM John P. Linderman <jpl.jpl@gmail.com> wrote:
This is great, Kurt. The source in=C2=A0src/runtime/hrs/src fo= r rsort.c is their version of my external sort, modified to be a subroutine= . There's some lessons to be learned about "software hygiene"= . I was cavalier about freeing what I allocated dynamically. As a result, t= heir version leaks like a sieve if the subroutine is called repeatedly. Apr= opos of which, they came to me having noted that only the first call was ac= ting as expected. There's a wonderful irony (I'm big on irony). I h= ad replaced my do-it-yourself argument processing with getopt. The code has= the following comment

** Use getopt() for porta= bility.

A few lines later, you see

=C2= =A0 =C2=A0 optind =3D 1; =C2=A0/* reset after use in Hancock program *
=C2=A0 =C2= =A0=C2=A0while ((c =3D getopt(argc, argv, "cCiIjmrsSuvb:f:D:o:p:T:x:y:= z:")) !=3D EOF) {
=C2=A0 =C2=A0=C2=A0
optind??? Seems getopt has an undocumented global flag to prevent repro= cessing the arguments. How portable:-)

It's documented:

=C2=A0 =C2=A0 =C2=A0T= he variables opterr and optind are both initialized to 1.=C2=A0 The optind<= br>=C2=A0 =C2=A0 =C2=A0variable may be set to another value before a set of= calls to getopt() in
=C2=A0 =C2=A0 =C2=A0order to skip over more or les= s argv entries.

is what the FreeBSD man page h= as to say about it. So this just resets any scanning that had happened befo= re this...

Warner
--0000000000009dd2ae05a09d38ac--