Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qIvNQ-0006CW-1F for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Jul 2023 18:12:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qIvNN-0001Yi-RJ for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Jul 2023 18:12:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qIvNN-0001YY-Cb for pgsql-hackers@lists.postgresql.org; Mon, 10 Jul 2023 18:12:45 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qIvNJ-0037HY-1K for pgsql-hackers@postgresql.org; Mon, 10 Jul 2023 18:12:44 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1b8b318c5a7so35805305ad.3 for ; Mon, 10 Jul 2023 11:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689012760; x=1691604760; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=DD4RFexxSdQGUoZLsmYF9ocT6F48mtwHPpLUwRM4cNE=; b=kz38KAjCKT9JvZNFOguvZPzZRbYC3aSb5Rqwr4pN5yK+XthbgsoxQ5mEP77qdE86ha UYtbPN09mUytvXjt7jOlYz9pXzp5kIkStXExcoRKr1MyCivp+Ki0er+16jhgm6eGPGgZ QJOx5lY85juvZKHPWXlagv7hQLbb+DjSHWQ9DvEB30TVWJi36yVbFaCxIx5dMobFtCG1 26qtDYOgCH3gKZvJ9+tdEpw3gOtRsPCNhDtn8ikUW05WSnI4CknSUxue47itGDkGj8xG qRPKlVT3D9EXNOemkzbZdNK7ZRXOyy404QLswrzTx5HcQe5AREN1n2cSzUJUtdYfvmWc bRvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689012760; x=1691604760; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=DD4RFexxSdQGUoZLsmYF9ocT6F48mtwHPpLUwRM4cNE=; b=Q+W/TihmrtrVylbTBtnPz8QThtEGkN+gXA/vvXMpQ7EDOF2byssnbE7aSJtDGI8n6P zAdeKwDFv0qayC0umtujtlH5qoRmAUeQvIK88Nezqy0jb2/Tl6As8QQgRyPAzLwkhicm h1DUZq4qMVymm5eunGW0ZolYzIaju+opvZTy+olcqBz087N0acDaF7G6apSiPO4kqYaO D1wE5j/QsgfA7uwngKWSc0m5NpbvjfhiHjNXpa4YZgpIPrRkAazIGkMp1GolFSz9kNyO xaXGaIRmdCiaD4WVA7rvE0DxxYvLRPcXi1n6m0bMoTjK9ZYYVqBBXoE8zvd3O5HpC3a7 PvvA== X-Gm-Message-State: ABy/qLbI2MAztdyfP+jX7vSLDIB5Tzevx54NRPLowFH4sXPB7aGuQ0ON CqmlGk0tu5Odnw5q3dcQtMs= X-Google-Smtp-Source: APBJJlEQl5jVc4ZwPQSbBySkQ8rVGiNSJ8OeptGwTRAFZ/xHrD+7/6I3NgEIEbgsm3JkU8BmSN5e1w== X-Received: by 2002:a17:903:32ce:b0:1b8:7265:9289 with SMTP id i14-20020a17090332ce00b001b872659289mr16490338plr.13.1689012760093; Mon, 10 Jul 2023 11:12:40 -0700 (PDT) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id w15-20020a1709027b8f00b001b9df74ba5asm189655pll.210.2023.07.10.11.12.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 11:12:39 -0700 (PDT) Date: Mon, 10 Jul 2023 11:12:37 -0700 From: Nathan Bossart To: Kyotaro Horiguchi Cc: michael@paquier.xyz, noah@leadboat.com, pgsql-hackers@postgresql.org Subject: Re: add non-option reordering to in-tree getopt_long Message-ID: <20230710181237.GD257945@nathanxps13> References: <20230620.141244.1061039848681375358.horikyota.ntt@gmail.com> <20230621175624.GA882103@nathanxps13> <20230708035224.GA4042213@nathanxps13> <20230710.165711.1906730109995973216.horikyota.ntt@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230710.165711.1906730109995973216.horikyota.ntt@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jul 10, 2023 at 04:57:11PM +0900, Kyotaro Horiguchi wrote: > + if (!force_nonopt && place[0] == '-' && place[1]) > + { > + if (place[1] != '-' || place[2]) > + break; > + > + optind++; > + force_nonopt = true; > + continue; > + } > > The first if looks good to me, but the second if is a bit hard to get the meaning at a glance. "!(place[1] == '-' && place[2] == 0)" is easier to read *to me*. Or I'm fine with the following structure here. I'd readily admit that it's tough to read these lines. I briefly tried to make use of strcmp() to improve readability, but I wasn't having much luck. I'll give it another try. >> if (!force_nonopt ... ) >> { >> if (place[1] == '-' && place[2] == 0) >> { >> optind+; >> force_nonopt = true; >> continue; >> } >> break; >> } > > (To be honest, I see the goto looked clear than for(;;)..) Okay. I don't mind adding it back if it improves readability. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com