From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Elad Lahav Newsgroups: gmane.emacs.devel Subject: getopt() and POSIX Date: Tue, 16 May 2023 13:59:29 -0400 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32843"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue May 16 20:00:37 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 1pyyyR-0008J1-L0 for ged-emacs-devel@m.gmane-mx.org; Tue, 16 May 2023 20:00:35 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyyxd-0004HI-Rf; Tue, 16 May 2023 13:59:45 -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 1pyyxc-0004HA-NR for emacs-devel@gnu.org; Tue, 16 May 2023 13:59:44 -0400 Original-Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pyyxb-0005Qi-5H for emacs-devel@gnu.org; Tue, 16 May 2023 13:59:44 -0400 Original-Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-965d2749e2eso2202824066b.1 for ; Tue, 16 May 2023 10:59:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684259981; x=1686851981; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=uL1UhgwC2o+6WLueKxX/ILLqJs3m/CuvKLzzgShnmvY=; b=ZjBFFvStpemDAuOCaS1nVOnpQ+4FAzzrcd5hi88uj5E6yEMCsEGLHnSWxL/MMVRIce 3OLytjCbEEeGI/NPSO492si3uhbK35KUW6RO4AhNWgG1R+D7hrCnXMrcINK+jPmJfxQw Fwzhe/rO9qi+oipTwI7dJMpldfDbE70JdIj6/nm1vBgxh/8eppMaVK7DGkYVLrz9QZgv si2pJ/nO7KhxJinvcv558kN8v3YRKBmFAMwlwuFRW0tlRLHGgGs+6GPLiLbx+vRg1zIj uX3fQmf6NkHrOoTKhIic9H0EYwCuEDBfzDKrThtYjzhkuWqWcccdZo8xCNNI7qFFpQLi PwIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684259981; x=1686851981; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=uL1UhgwC2o+6WLueKxX/ILLqJs3m/CuvKLzzgShnmvY=; b=CP+sKBTAnAkgXNNqeOJtmcRNKJndEjkgT0SQfCyBTDkuEUhWQ9F/1ss/xuKqcCCKLv sB6Nu5t3UxXhB261sh6nauvOEPkdpLU0Y/zJtIX7DzFPqJd9A2C6zw3w3cjO7/uinxWH Gvveo2GRFHXC5/45NaDgZhZnX4zxhOxvoskJTyesFLUvnisrVWrwrOEVQWMXldU0+fhc 6EaOVvg3B3MjoEITioBEy4t5z0eXNxyL9eefQv/VXBNrm/RbfYQjhhSsMVikOSbG1uQf jDWqTVUjYvYbdTXBygqvc5OXOkJJcSw3oMYkzUZ/KsM+3nKKLT99Mvl94gFV2FpQ0YyT ZtWg== X-Gm-Message-State: AC+VfDx3j3+0vJ2zUphIFyFcPoJWWLVKTsLuVPBQzFNdcdIqxGtnL+N0 O1+OUmMIAyF/7yE+imROwl1pZdD0zC7uKR+pFrI/MPJQUPE= X-Google-Smtp-Source: ACHHUZ6bFgFJEKCH3M4Q1Wlj1Op/kVhcXHaPc/9T91eX8mpOO0zfzUclte8ICwVvQciSKQnuAkoxCm8Y4J7jvAXCB1s= X-Received: by 2002:a17:906:ef09:b0:95e:d3f5:3d47 with SMTP id f9-20020a170906ef0900b0095ed3f53d47mr33210636ejs.48.1684259980716; Tue, 16 May 2023 10:59:40 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::632; envelope-from=e2lahav@gmail.com; helo=mail-ej1-x632.google.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, 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:306142 Archived-At: 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). Thoughts? --Elad