From patchwork Mon May 21 19:38:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 136500 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp702713lji; Mon, 21 May 2018 12:39:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrQ+C7TFIpOqNi4B7XvaKGQmGfV5AJcrGiLxOS4gZjcW440HQverp0eV0YMzGw5focIyF81 X-Received: by 2002:a63:79ca:: with SMTP id u193-v6mr1964288pgc.112.1526931560795; Mon, 21 May 2018 12:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526931560; cv=none; d=google.com; s=arc-20160816; b=Rz25FZen5z7tLC6XyOHYt6IL0i2nQB47ECzWmM5uwJoo/HQhIypU5IiTCjLLqAc/vR UZxqhw5C6urnsvCBluXMtkIQDdz9mr5c6gEb33A3AFTCI3knZZVMe2VmA3/KuLhvcO5l 2c9hf78sy8YyxGlKuTCAYpQKTZDoRi9VYW3anwyspB+YEsw6w/4D7r5G67FK5YmFDJGu /c/czl5wN2zRLGTmCt1T8/9LZRtDRf4WqqqXRTB2Q5e9VjPw3n+gpokTFV6WqYYrO3E1 fyLpOE971iCKg5z7RkvXyFqcO1plfy8M4uHuxCzR0xWz+35XwctexkfpHTcH2/PN+qf/ C4uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=t6tLHHFPliihImvApzBvEuwsQoCMvyeyA2wBNAnDSiI=; b=CmvQgrgtSPLng0jChxXkuuiOTIboxXHAWlQ+TFgCV474GnYpfqiLv1lFtXpef5Saa1 k5n8EwGhrYUYZTZGuUtBGS+26nAh2GGPdWf8ZaA7LJeAJ77PhRfT1P2LJTAi+pW/33Em R2CjSg2jqSo3rtx3851F8qFFuPWp1UUpNEToT29+zzlsiTlo07FzRg1d7XKGGl+DwgOo YPLC5nqorOacxyirUqfE0Gvf67mir8tfFx9fCOhn0VQZjLgpJcwtkVFzIMsJi7qTNUIR ud9KF5Y4RgC51kNn8JvZXFzB+vhCt43bacZwbAEZqU8zqtv7mc5ehDtFoNGQ9kw+K2z5 IN7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=afZ275Cj; spf=pass (google.com: domain of libc-alpha-return-92643-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-92643-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g7-v6si11235211pgq.372.2018.05.21.12.39.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 May 2018 12:39:20 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-92643-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=afZ275Cj; spf=pass (google.com: domain of libc-alpha-return-92643-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-92643-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=HPzH5gOn5KBDRBTLvGCiqs7EIlj3G0804pKAg8f5nqx6fAHD2hJCR +HBWTqsulQnYQ6iMFuHacZkc7pHMryZb7FVfbY/Zah25V+fHnGSjkd0Jl41BrLr1 K1nPKbPePJiBn/sa/uecHCgl/QPueTVgLqKQfj6H5xZuhVSoUQXlWg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=Hgu8SaIREnxtQUWoAv8R+oT+RIc=; b=afZ275CjEmGSpUgRWLRPAB7VEXWx bx4GUU+qxh4SO9w3JRKbWxhhSMHyZ48Uf9Lg0IPZJiGp5+q1dIlECh1tt7EWcqh/ RDDTvoo22hymZ21qMv7EROjI2LeFw/IXhGq85GFc/sH0h7UuQbfMEkGfj5/ZiU2+ NHukaZnsXXuijrk= Received: (qmail 19872 invoked by alias); 21 May 2018 19:39:12 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 19845 invoked by uid 89); 21 May 2018 19:39:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=states X-HELO: mail-qt0-f182.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=t6tLHHFPliihImvApzBvEuwsQoCMvyeyA2wBNAnDSiI=; b=CJ6sOY95qaTwUqgVWD+knBnmPrYPPu9NJGqk8MEV5ACrDNj0HAF3Z4mdNR0oIkG+so IGD5V/Yi84Lu7ETAvMCwnceWfBq666/NcaSf6pm4gLB+VHIdjH/5Zs6NzleQbY/KCxYu bfs3p85fWHbNCefgU2nOvMbBxu3j5PsVJcR70s/UkHgsYjfZuRZBzwne1T9QvfVEeWhN BaqATcG8kJ1BTQmVh7crfOGHx5uAt0RLSFs7I+hcoL+ybT65hVNSyiTS0txGbOO0zaWf Wh/Yo4rG7x2Ke5E401a2jx0BjLsv7rjPSyolsGf5eV6upVbdxNS1TIkcmOSsVzjfyyiv FkGQ== X-Gm-Message-State: ALKqPwfQ07aHc69/4nQXbMzJnINrlDjqUb/toOWBo54iIUeeuUuEr8RY ADRNaKA3PkFllgmRyxaHh3AYOVU/RXw= X-Received: by 2002:ac8:19bd:: with SMTP id u58-v6mr18852005qtj.390.1526931548319; Mon, 21 May 2018 12:39:08 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH] manual: Document optind zero set behaviour (BZ#23157) Date: Mon, 21 May 2018 16:38:59 -0300 Message-Id: <1526931539-11863-1-git-send-email-adhemerval.zanella@linaro.org> POSIX [1] does not explicit state the expected way to rescans the same vector more than once. FreeBSD [2], for instance, exports a non-standard variable 'optreset' which must be set to '1' prior the second and each additional call to 'getopt'. GLIBC in turn requires the program to reset 'optind' to 0 instead (and POSIX states the behavior is unspecified). Unfortunately this is not documented on the manual, only on man-pages [3] (on NOTES). This patch adds an explanation of this behavior on manual. * manual/getopt.texi: Document optind zero set behaviour. [1] http://pubs.opengroup.org/onlinepubs/9699919799/ [2] https://www.freebsd.org/cgi/man.cgi?getopt(3) [3] http://man7.org/linux/man-pages/man3/getopt.3.html --- ChangeLog | 4 ++++ manual/getopt.texi | 6 ++++++ 2 files changed, 10 insertions(+) -- 2.7.4 diff --git a/manual/getopt.texi b/manual/getopt.texi index 5485fc4..a4f6366 100644 --- a/manual/getopt.texi +++ b/manual/getopt.texi @@ -45,6 +45,12 @@ of the @var{argv} array to be processed. Once @code{getopt} has found all of the option arguments, you can use this variable to determine where the remaining non-option arguments begin. The initial value of this variable is @code{1}. + +Resetting the variable value to @code{0} forces the invocation of an +internal initialization routine and it is used mainly when a program +wants to rescan the same vector more than once. It also should be used +to scan multiple argument vectors or if @code{POSIXLY_CORRECT} is changed +between scans. @end deftypevar @deftypevar {char *} optarg