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_INVALID,DKIM_SIGNED, HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RDNS_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: (qmail 21198 invoked from network); 11 Mar 2020 21:29:51 -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; 11 Mar 2020 21:29:51 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id B6A0C9BC10; Thu, 12 Mar 2020 07:29:49 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id D6BA89BB47; Thu, 12 Mar 2020 07:29:20 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bsdimp-com.20150623.gappssmtp.com header.i=@bsdimp-com.20150623.gappssmtp.com header.b="Wmkzo3zN"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 662199BB47; Thu, 12 Mar 2020 07:29:18 +1000 (AEST) Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) by minnie.tuhs.org (Postfix) with ESMTPS id B0DDF9BB46 for ; Thu, 12 Mar 2020 07:29:17 +1000 (AEST) Received: by mail-qk1-f177.google.com with SMTP id e11so3632301qkg.9 for ; Wed, 11 Mar 2020 14:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pVpriQ6PCJc38dm3NtVNy1kYh30pk+JgOJiTrWPqr/U=; b=Wmkzo3zNVJR9a31uG28IkzTA/bbFZ/8sYJNIOBM9ZGuBYkdMafaYv3rEK8AM7DbMXd 1oyvKw73qASL0oq28aJvMXdxKXEKKq6nu8ugIFXbEH5UrIOvNyGU7RGJvqCM0hO21PP5 ulnFEYKWqA3aumM7zF+zX2XDNqm1W5RAkExoSmKYXquxSWCXIYeQ/uEeOHSWmdDz8nxU AKXCkwgplPHdtTHebSOIn9SDYkCl6FEvKNV5n13WmwvsODkTYs9+K3knW5/3ZhQoPKSn 84TtBBypJmnJtLQXzDSyOhqWYZvXtX6gz8I6/dOO8OLox5B4Zw9SdwdBK960NkSWIrgr JElQ== 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=pVpriQ6PCJc38dm3NtVNy1kYh30pk+JgOJiTrWPqr/U=; b=rg1L5zyGzm3hMLmYNZahqAkODQeIMRhIKqEB3cbwhTE/ND1vMgBl/NTrdwIRRPTo82 jeu8M43Wv63fpTqif/HBIxnHrnyxMzNgj7PQwtIBjF7aZ+TD0+49sC9EZtPDZFdyY0Ky tsWkRYz0X21T1t1scf2rQCtobv1nMRQaq/my1bENlcj8j27jlZhh6HPYTvVXq1fKuaLl ttNaVwlDZN3fzUUXC9BR9VltvWIF1mlSoxb7LeI8btVHY5B9RsdvkAwhqf8n6Rnr9jfY dyfXzISUWvG4UCO6LRd9tzxqLi20VVo3ihN2N4a0Wv3dykL1ySt//EQ5bfVGkTOna7vT CmEg== X-Gm-Message-State: ANhLgQ0QLu28LLSoyws11nIjNxqCatfavjIkv7lbVvXoLm4yFTyP1gIu rjitAJihpdQyzdVI0Xb4+IN6iKOPmlVTrM6Uhb4mug== X-Google-Smtp-Source: ADFU+vsb/sdTu1R9eZAfBMtNCzqnoBycsU2pC6RkzPd9+8XFc5jPI2edXTUbAwb1dNB2A5aZ+YrF6v/7x1Ujg961ZRc= X-Received: by 2002:a05:620a:200d:: with SMTP id c13mr4320932qka.240.1583962156745; Wed, 11 Mar 2020 14:29:16 -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: Warner Losh Date: Wed, 11 Mar 2020 15:29:05 -0600 Message-ID: To: "John P. Linderman" Content-Type: multipart/alternative; boundary="000000000000b0d33b05a09aed55" 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" --000000000000b0d33b05a09aed55 Content-Type: text/plain; charset="UTF-8" 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 --000000000000b0d33b05a09aed55 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable




=C2=A0 =C2=A0 =C2=A0The variables opterr and optind are bo= th initialized to 1.=C2=A0 The optind
=C2=A0 =C2=A0 =C2=A0variable may b= e set to another value before a set of calls to getopt() in
=C2=A0 =C2= =A0 =C2=A0order to skip over more or less argv entries.

<= /div>
is what the FreeBSD man page has to say about it. So this just re= sets any scanning that had happened before this...

Warner
--000000000000b0d33b05a09aed55--