From owner-freebsd-doc Thu Aug 5 17:26:13 1999 Delivered-To: freebsd-doc@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id A0ADE14F54 for ; Thu, 5 Aug 1999 17:26:09 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id RAA42103; Thu, 5 Aug 1999 17:00:06 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from po3.wam.umd.edu (po3.wam.umd.edu [128.8.10.165]) by hub.freebsd.org (Postfix) with ESMTP id EB75E155F8 for ; Thu, 5 Aug 1999 16:55:37 -0700 (PDT) (envelope-from howardjp@wam.umd.edu) Received: from rac9.wam.umd.edu (root@rac9.wam.umd.edu [128.8.10.149]) by po3.wam.umd.edu (8.9.3/8.9.3) with ESMTP id TAA10872 for ; Thu, 5 Aug 1999 19:54:36 -0400 (EDT) Received: from rac9.wam.umd.edu (sendmail@localhost [127.0.0.1]) by rac9.wam.umd.edu (8.9.3/8.9.3) with SMTP id TAA17728 for ; Thu, 5 Aug 1999 19:54:36 -0400 (EDT) Received: (from howardjp@localhost) by rac9.wam.umd.edu (8.9.3/8.9.3) id TAA17724 for FreeBSD-gnats-submit@freebsd.org; Thu, 5 Aug 1999 19:54:35 -0400 (EDT) Message-Id: <199908052354.TAA17724@rac9.wam.umd.edu> Date: Thu, 5 Aug 1999 19:54:35 -0400 (EDT) From: James Howard Reply-To: howardjp@wam.umd.edu To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: docs/12994: Update to getopt.3 to agree with style.9 Sender: owner-freebsd-doc@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 12994 >Category: docs >Synopsis: Update to getopt.3 to agree with style.9 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-doc >State: open >Quarter: >Keywords: >Date-Required: >Class: doc-bug >Submitter-Id: current-users >Arrival-Date: Thu Aug 5 17:00:06 PDT 1999 >Closed-Date: >Last-Modified: >Originator: James Howard >Release: FreeBSD 3.2-STABLE i386 >Organization: University of Maryland >Environment: FreeBSD byzantine.student.umd.edu 3.2-STABLE FreeBSD 3.2-STABLE #4: Thu Jun 17 18:40:41 GMT 1999 howardjp@byzantine.student.umd.edu:/usr/src/sys/compile/BYZANTINE i386 >Description: Getopt(3) stated that the proper way to handle converting a number in a command line to a usable int was via atoi(3). Style(9) says you should use strtol(3). Apply the diff to getopt.3 in /usr/src/lib/libc/stdlib/ to synchronise it with style(9). >How-To-Repeat: man 3 getopt man style >Fix: *** getopt.3.orig Thu Aug 5 19:31:46 1999 --- getopt.3 Thu Aug 5 19:41:08 1999 *************** *** 245,251 **** The following code fragment works in most cases. .Bd -literal -offset indent int length; ! char *p; while ((ch = getopt(argc, argv, "0123456789")) != -1) switch (ch) { --- 245,251 ---- The following code fragment works in most cases. .Bd -literal -offset indent int length; ! char *p, *ep; while ((ch = getopt(argc, argv, "0123456789")) != -1) switch (ch) { *************** *** 253,261 **** case '5': case '6': case '7': case '8': case '9': p = argv[optind - 1]; if (p[0] == '-' && p[1] == ch && !p[2]) ! length = atoi(++p); else ! length = atoi(argv[optind] + 1); break; } .Ed --- 253,263 ---- case '5': case '6': case '7': case '8': case '9': p = argv[optind - 1]; if (p[0] == '-' && p[1] == ch && !p[2]) ! length = strtol(++p, &ep, 10); else ! length = strtol(argv[optind] + 1, &ep, 10); ! if (length <= 0 || *ep != '\e0') ! err("illegal number -- %s", optarg); break; } .Ed >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-doc" in the body of the message