From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Re: getopt() and POSIX Date: Wed, 17 May 2023 09:15:48 +0800 Message-ID: <878rdn69mj.fsf@yahoo.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35511"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: Elad Lahav Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed May 17 03:17:10 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pz5mt-0008yN-I9 for ged-emacs-devel@m.gmane-mx.org; Wed, 17 May 2023 03:17:07 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pz5lz-0003Ud-6Q; Tue, 16 May 2023 21:16:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pz5lx-0003U3-O0 for emacs-devel@gnu.org; Tue, 16 May 2023 21:16:09 -0400 Original-Received: from sonic311-25.consmr.mail.ne1.yahoo.com ([66.163.188.206]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pz5lq-0005O3-ER for emacs-devel@gnu.org; Tue, 16 May 2023 21:16:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1684286158; bh=LFpaiAO8GZuqlqyqI9qCw8Gw4qTRniS51DW6pXvFvek=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=pQeAi2uQTd1Ml3GcrQ3dI3Vm3tT3MaLEIbS2GoRwn+UMwGuFYIan8u8KBP6dhiDPa621jbIGZmOqeQT6I+v6G7q9hSc91YUPSnPtD/EdLI6WQtrl6JKYPVnmJRxgHQAy47OQXeXSkwIZf43UnMs42WiXarUa+Kaq7G8A0QWcUWf41x+CVMKLmTek1zrRe5PBw4Ze9MtnWntRf/YjsZ24jzU4PN4/PdshBGbqC9/Fn/H59N8jHvfKnMbcAMx9+5Cu8YFVdHYEZ+T62v9xR7rNqu3+e438QYe4qpJjlSY3Xtpu472Cn7tpcMHqrymmY203GbMs6eavbMMBKDAeTn22Vw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1684286158; bh=yW5Ao0/FlxGMPx+nbPPS5UymJj+JAjhyknWs+CqoN+M=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=r44NU5QnckNfR6ztXUqG/GZt2+hGlHbhul9dtc9k9mUyHtnDAnAmhMdIpCkRzVcjlG0+hFpuz4/Fkrl2FotjThLi+5Vk2ux8SIbp+W/cdYJSI6NhpJqpSQRoOeOWf1byHFYJE3c4z5lbvOi6Dj66EHRaEw0hu90r71ypaOiiCVelRYOimAu19/YdwhZkLDF+YuNoVPGDtq1YxmOSFDYkZNpE2GlHQub1AB+g2NiFhXuPXAwKXSt9itsiVWGXOjuThpOWQGJ3/B/QMJ5NCNlhyBYenGA0TEaSpHCo5BVCSBOmUINCWR1FLcVTjZtL4Pfxlafq4hVb5+hePBsJ9fMarQ== X-YMail-OSG: oQDl6HsVM1l0jpW0tA14hTdJFvsTO7_ag5s8.71RIi1rQsuOUoRTPa2D1CoMxqq yAHO4Zvnh7PgBE8dCd89FB36IiBM4j7hiMrX6gHpTUDZnmg5luSIh.tszfvm.c7VhwGbAKtCS1O2 GU5rBEI0UreWh57llGPFnHbjyIzclBnGfUzj2WdxSMcXZ1H8HjvhmBmtdKd8VBz6Xapat6o9g_Ea Xmcw33hm9ZsZPUJVHYQsnSGAuyLWwpXABpMoyzEIM9xaVFC5rrJAzOAUtvmdp.3BFaTpd.Ao_F0n RoKUdIX1rjGBCtgTPWQYks9MzknNAgYBv0dGf3Li0nvqfD97mG6rAdIq2_Dnk4pPz8MFv_0jx8Zb ne7c..WtJA6WHbs0VvkRzwy0jJnPnpUTCCiKtghad1arj6oRQS3neNRYrpA6ds_yBjZ0Ovz4xcKY ULKmTzI_tkBplxqOZBxPc4uUXdtQMyUhki8dwsvmAebrictZTsYMMUjhA.LXjxKs1r8yVBb0PTZW HrQpmL8JaJ4nX3PjGBQqie5JmLKuSNJZub6OLMOO3IZNf1tSq4j1i2AexuODMYItxnnBdjg.l52U EqYvvIxjuzDKfX3d4HxFRPVCjzFPe72ZRSI5SNxvCqkwTCZFGHdXM5VZHJuI6u5.8C8gHPJLTDhB sIocKEU03H.TXpzoEUVBLXfsLNx_tmBwphlILQVHNDxsLReIkTu_Bk2opWDno5p0vfQZ4_RSCgZa Lq13KGhqMI0KwsOzcUa.tyPyTjJPR47Hj0Ea5ir4xerMwGlCRJwXgMOh3W93Ut7A12BuqnMtBIkW cw6jvw_BgFGFvISbomTG._tVsicMot6W.OLbLO30bH X-Sonic-MF: X-Sonic-ID: 7c12486f-12d4-4eb8-af3b-2617b22a0d61 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic311.consmr.mail.ne1.yahoo.com with HTTP; Wed, 17 May 2023 01:15:58 +0000 Original-Received: by hermes--production-sg3-748897c457-v5xjh (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 328917216625158d6fe50278dfd88574; Wed, 17 May 2023 01:15:52 +0000 (UTC) In-Reply-To: (Elad Lahav's message of "Tue, 16 May 2023 13:59:29 -0400") X-Mailer: WebService/1.1.21471 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.188.206; envelope-from=luangruo@yahoo.com; helo=sonic311-25.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:306149 Archived-At: Elad Lahav writes: > Hello, > > The configure script attempts to determines whether getopt() is POSIX > compliant by compiling and running the following code: > > #include > #include > #include > > int > main () > { > static char program[] = "program"; > static char ab[] = "-ab"; > char *argv[3] = { program, ab, NULL }; > if (getopt (2, argv, "ab:") != 'a') > return 13; > if (getopt (2, argv, "ab:") != '?') > return 14; > if (optopt != 'b') > return 15; > if (optind != 2) > return 16; > return 0; > } > > This test fails on QNX for the last test point, which has optind set > to 3. However, as far as I can tell, this is what POSIX expects, and 2 > is wrong: > > https://pubs.opengroup.org/onlinepubs/9699919799/functions/getopt.html > > "If the option was the last character in the string pointed to by an > element of argv, then optarg shall contain the next element of argv, > and optind shall be incremented by 2. If the resulting value of optind > is greater than argc, this indicates a missing option-argument, and > getopt() shall return an error indication." > > In this case optind is 1 and incremented by 2, the argument is missing > and now optind is greater than argc (2), as expected. > > None of this really matters much, except that the compliance failure > leads to an attempt to use rpl_getopt(), which fails due to unresolved > symbols (which is a separate issue). Please bring this to the attention of the Gnulib developers (from whom we get these tests), at bug-gnulib@gnu.org. Thanks.