Home | History | Annotate | Download | only in stdlib
History log of /src/lib/libc/stdlib/getopt_long.c
RevisionDateAuthorComments
 1.28  19-Jan-2024  christos add some const
 1.27  01-Sep-2015  kamil ANSIfy getopt(3) - this is the REPLACE_GETOPT version from getopt_long(3)

For the reference, this version still passes the current set of ATF tests
for the getopt(3) function.

This version is by default unused.
 1.26  01-Sep-2015  kamil Constness correction for the getopt(3) function under REPLACE_GETOPT

Use the __UNCONST() macro, which is used in the other parts for the same
argument nargv, but under the !REPLACE_GETOPT namespace.
 1.25  20-Mar-2009  joerg ANSIfy. Remove conditionals around __RCSID.
 1.24  09-Nov-2007  christos branches: 1.24.16;
always compile getopt_long. some ifdef reduction. more to come.
 1.23  06-Nov-2007  christos Revert previous. This mess of ifdefs needs to be killed.
 1.22  06-Nov-2007  christos move the test to replace getopt higher up, before we need to include anything.
 1.21  05-Jul-2007  ginsbach branches: 1.21.4;
Fix several end cases:

o If a long option looks like an ambiguous abbreviation of two or more long
options, but all the possible interpretations would return the same
value, then just return that value without complaining that it's
ambiguous.

o If a long option could be interpreted either as an exact match for one
long option, or as an abbreviation for one or more other long options,
then treat it as the exact match.

These changes align NetBSD's getopt_long(3) with the current behavior of
GNU getopt_long(3), the de facto standard, and FreeBSD's getopt_long(3).
 1.20  04-Oct-2006  wiz Switch from 4-clause to 2-clause BSD license.
Ok dillo@, board@.
 1.19  02-Dec-2005  yamt don't make internal functions pretend to take a const argument.
 1.18  29-Nov-2005  christos WARNS=4
 1.17  20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.16  27-Oct-2003  lukem branches: 1.16.2;
Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.15  31-Jan-2002  tv Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
 1.14  29-Jan-2002  tv Make almost all tools compile and run properly on non-NetBSD hosts. (In
particular, most tools now run correctly on Solaris 7.)
 1.13  04-Nov-2001  lukem fix WARNS=2 (-Wshadow) warnings
 1.12  24-Apr-2001  joda don't claim that options are illegal, cf lib/12715
 1.11  12-Feb-2001  cgd branches: 1.11.2;
don't extern char *__progname; it's never used!
 1.10  04-Jan-2001  lukem sprinkle _DIAGASSERT() around
 1.9  26-Nov-2000  wiz Be SUS-conformant regarding return value when option argument is missing.
Handle "-" correctly.
 1.8  25-Aug-2000  thorpej Some (popular) programs expect to be able to re-initialize `optind'
to 0 and have getopt(3)/getopt_long(3) continue to function properly.
This happens to work with GNU getopt_long(3), so mimmick the behavior.

Fixes pkg/10980 (Manuel Bouyer): rsyncd was relying on this behavior.
 1.7  08-Jul-2000  sommerfeld Correct format mismatch for field widths
 1.6  09-Jun-2000  nathanw branches: 1.6.2;
Don't segfault when complaining about an invalid single-character option.

When complaining about a long option which requires an argument,
print the actual option, not some pointer-garbage.

(Hint: "%c" and "%s" are different.)
 1.5  02-Apr-2000  christos branches: 1.5.2;
Add "namespace.h" and include <getopt.h> since we moved the stuff out
of <unistd.h>
 1.4  02-Apr-2000  christos New getopt_long from Thomas Klausner and Dieter Baron
 1.3  20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.2  16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.1  23-Jul-1999  mcr getopt long functionality
 1.5.2.1  23-Jun-2000  minoura Import of most recent XPG4DL dated 2000.06.23.
 1.6.2.2  17-Oct-2000  tv Pullup 1.7 [releng]:
Correct format mismatch for field widths
 1.6.2.1  25-Aug-2000  thorpej Pull up rev. 1.8:
Some (popular) programs expect to be able to re-initialize `optind'
to 0 and have getopt(3)/getopt_long(3) continue to function properly.
This happens to work with GNU getopt_long(3), so mimmick the behavior.

Fixes pkg/10980 (Manuel Bouyer): rsyncd was relying on this behavior.
 1.11.2.4  22-Mar-2002  nathanw Catch up to -current.
 1.11.2.3  08-Mar-2002  nathanw Catch up to -current.
 1.11.2.2  14-Nov-2001  nathanw Catch up to -current.
 1.11.2.1  08-Oct-2001  nathanw Catch up to -current.
 1.16.2.1  22-Jun-2004  tron Pull up revision 1.17 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.21.4.1  09-Jan-2008  matt sync with HEAD
 1.24.16.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html

RSS XML Feed