Index: ossp-pkg/getopt/Makefile.in RCS File: /v/ossp/cvs/ossp-pkg/getopt/Makefile.in,v rcsdiff -q -kk '-r1.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/getopt/Makefile.in,v' 2>/dev/null --- Makefile.in 2003/03/07 10:48:14 1.2 +++ Makefile.in 2005/10/05 10:11:57 1.3 @@ -46,6 +46,8 @@ $(SHTOOL) install -c -m 755 getopt-config $(DESTDIR)$(bindir)/ $(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(libdir) $(SHTOOL) install -c -m 644 libgetopt.a $(DESTDIR)$(libdir)/ + $(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(libdir)/pkgconfig + $(SHTOOL) install -c -m 644 getopt.pc $(DESTDIR)$(libdir)/pkgconfig/ $(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(includedir) $(SHTOOL) install -c -m 644 getopt.h $(DESTDIR)$(includedir)/ $(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(mandir)/man1 Index: ossp-pkg/getopt/README RCS File: /v/ossp/cvs/ossp-pkg/getopt/README,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/getopt/README,v' 2>/dev/null --- README 2003/03/07 10:35:16 1.1 +++ README 2005/10/05 10:11:57 1.2 @@ -1,33 +1,54 @@ OSSP's GNU getopt - From gcc 3.2.2 (because more stand-alone than original glibc sources): + IMPORT + ------ + + From gcc 4.0.2 (because more stand-alone than original glibc sources): [ftp://gcc.gnu.org/pub/gcc/releases/] include/getopt.h -> getopt.h libiberty/getopt.c -> getopt.c libiberty/getopt1.c -> getopt1.c - From glibc 2.3.2: + From glibc 2.3.5: [ftp://ftp.gnu.org/gnu/glibc/] posix/tstgetopt.c -> getopt_test.c manual/getopt.texi -> getopt.texi - From man-pages 1.56: + From man-pages 2.08: [ftp://ftp.kernel.org/pub/linux/docs/manpages/] man3/getopt.3 -> getopt.3 - From util-linux 2.11 or getopt 1.1.3: + From util-linux 2.12r or even getopt 1.1.3: [http://www.kernel.org/pub/linux/utils/util-linux/] [http://huizen.dds.nl/~frodol/getopt.html] - getopt.1 -> getopt.1 - getopt.c -> getopt_main.c + getopt/getopt.1 -> getopt.1 + getopt/getopt.c -> getopt_main.c + + POST-ADJUSTMENTS + ---------------- + + Apply the following adjustments after importing: + + getopt_main.c: - Plus replace in getop_main.c: + << #if LIBCGETOPT + << #include + << #else + << #include "getopt.h" + << #endif << #include "nls.h" + + >> #include "getopt.h" >> #define WITHOUT_GETTEXT 1 >> #define _(x) x + getopt_test.c: + + << #include + >> #include "getopt.h" + Index: ossp-pkg/getopt/VERSION RCS File: /v/ossp/cvs/ossp-pkg/getopt/VERSION,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/getopt/VERSION,v' 2>/dev/null --- VERSION 2003/03/07 10:35:16 1.1 +++ VERSION 2005/10/05 10:11:57 1.2 @@ -1 +1 @@ -20030307 +20051005 Index: ossp-pkg/getopt/configure.ac RCS File: /v/ossp/cvs/ossp-pkg/getopt/configure.ac,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/getopt/configure.ac,v' 2>/dev/null --- configure.ac 2003/03/07 10:35:16 1.1 +++ configure.ac 2005/10/05 10:11:57 1.2 @@ -1,5 +1,5 @@ -AC_PREREQ(2.57) +AC_PREREQ(2.59) AC_INIT AC_CONFIG_SRCDIR(Makefile.in) GETOPT_VERSION=`cat VERSION` @@ -13,7 +13,7 @@ AC_CHECK_HEADERS(string.h strings.h) AC_CONFIG_HEADERS(config.h) -AC_CONFIG_FILES([Makefile getopt-config]) +AC_CONFIG_FILES([Makefile getopt-config getopt.pc]) AC_CONFIG_COMMANDS([adjustment], [chmod a+x getopt-config]) AC_OUTPUT Index: ossp-pkg/getopt/devtool.conf RCS File: /v/ossp/cvs/ossp-pkg/getopt/devtool.conf,v rcsdiff -q -kk '-r1.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/getopt/devtool.conf,v' 2>/dev/null --- devtool.conf 2003/03/07 10:37:50 1.2 +++ devtool.conf 2005/10/05 10:11:57 1.3 @@ -3,8 +3,8 @@ ## %autogen - @autogen shtool 1.6.2 "1.[56].*" all - @autogen autoconf 2.57 "2.5[3-9]*" + @autogen shtool 2.0.3 "2.0.*" all + @autogen autoconf 2.59 "2.5[3-9]*" %autoclean @autoclean shtool @@ -29,5 +29,5 @@ %release echo "+++ copying to ftp://ftp.ossp.org/pkg/lib/getopt/" - scp getopt-*.tar.gz master.ossp.org:/e/ossp/ftp/pkg/lib/getopt/ + scp getopt-*.tar.gz ossp@master.ossp.org:/v/ossp/ftp/pkg/lib/getopt/ Index: ossp-pkg/getopt/getopt.1 RCS File: /v/ossp/cvs/ossp-pkg/getopt/getopt.1,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/getopt/getopt.1,v' 2>/dev/null --- getopt.1 2003/03/07 10:35:16 1.1 +++ getopt.1 2005/10/05 10:11:57 1.2 @@ -33,7 +33,7 @@ in the .BR SYNOPSIS). The second part will start at the first non\-option parameter -that is not an option argument, or after the first occurence of +that is not an option argument, or after the first occurrence of .RB ` \-\- '. If no .RB ` \-o ' @@ -284,7 +284,7 @@ non\-option parameter output is generated at the place they are found in the input (this is not supported if the first format of the .B SYNOPSIS -is used; in that case all preceding occurences of +is used; in that case all preceding occurrences of .RB ` \- ' and .RB ` + ' Index: ossp-pkg/getopt/getopt.3 RCS File: /v/ossp/cvs/ossp-pkg/getopt/getopt.3,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/getopt/getopt.3,v' 2>/dev/null --- getopt.3 2003/03/07 10:35:16 1.1 +++ getopt.3 2005/10/05 10:11:57 1.2 @@ -7,7 +7,7 @@ .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a -.\" permission notice identical to this one +.\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no @@ -31,10 +31,13 @@ .\" says; moreover, EOF is not defined in . .\" Modified 2002-02-16, joey: added information about non-existing .\" option character and colon as first option character +.\" Modified 2004-07-28, Michael Kerrisk +.\" Added text to explain how to order both '[-+]' and ':' at +.\" the start of optstring .\" -.TH GETOPT 3 2002-02-16 "GNU" "Linux Programmer's Manual" +.TH GETOPT 3 2004-07-28 "GNU" "Linux Programmer's Manual" .SH NAME -getopt \- Parse command line options +getopt \- Parse command-line options .SH SYNOPSIS .nf .B #include @@ -59,27 +62,28 @@ .fi .SH DESCRIPTION The -.B getopt() -function parses the command line arguments. Its arguments +.BR getopt () +function parses the command-line arguments. Its arguments .I argc and .I argv are the argument count and array as passed to the -.B main() +.I main() function on program invocation. -An element of \fIargv\fP that starts with `-' (and is not exactly "-" or "--") +An element of \fIargv\fP that starts with '\-' +(and is not exactly "\-" or "\-\-") is an option element. The characters of this element -(aside from the initial `-') are option characters. If \fBgetopt()\fP +(aside from the initial '\-') are option characters. If \fBgetopt\fP() is called repeatedly, it returns successively each of the option characters from each of the option elements. .PP -If \fBgetopt()\fP finds another option character, it returns that +If \fBgetopt\fP() finds another option character, it returns that character, updating the external variable \fIoptind\fP and a static -variable \fInextchar\fP so that the next call to \fBgetopt()\fP can +variable \fInextchar\fP so that the next call to \fBgetopt\fP() can resume the scan with the following option character or \fIargv\fP-element. .PP -If there are no more option characters, \fBgetopt()\fP returns \-1. +If there are no more option characters, \fBgetopt\fP() returns \-1. Then \fIoptind\fP is the index in \fIargv\fP of the first \fIargv\fP-element that is not an option. .PP @@ -97,54 +101,56 @@ contains .B W followed by a semicolon, then -.B -W foo +.B \-W foo is treated as the long option -.BR --foo . +.BR \-\-foo . (The -.B -W +.B \-W option is reserved by POSIX.2 for implementation extensions.) This behaviour is a GNU extension, not available with libraries before GNU libc 2. .PP -By default, \fBgetopt()\fP permutes the contents of \fIargv\fP as it +By default, \fBgetopt\fP() permutes the contents of \fIargv\fP as it scans, so that eventually all the non-options are at the end. Two other modes are also implemented. If the first character of -\fIoptstring\fP is `+' or the environment variable POSIXLY_CORRECT is +\fIoptstring\fP is '+' or the environment variable POSIXLY_CORRECT is set, then option processing stops as soon as a non-option argument is -encountered. If the first character of \fIoptstring\fP is `-', then +encountered. If the first character of \fIoptstring\fP is '\-', then each non-option \fIargv\fP-element is handled as if it were the argument of an option with character code 1. (This is used by programs that were written to expect options and other \fIargv\fP-elements in any order and that care about the ordering of the two.) -The special argument `--' forces an end of option-scanning regardless +The special argument "\-\-" forces an end of option-scanning regardless of the scanning mode. .PP -If \fBgetopt()\fP does not recognize an option character, it prints an +If \fBgetopt\fP() does not recognize an option character, it prints an error message to stderr, stores the character in \fIoptopt\fP, and -returns `?'. The calling program may prevent the error message by +returns '?'. The calling program may prevent the error message by setting \fIopterr\fP to 0. .PP -If \fBgetopt()\fP finds an option character in \fIargv\fP that was not +If \fBgetopt\fP() finds an option character in \fIargv\fP that was not included in \fIoptstring\fP, or if it detects a missing option argument, -it returns `?' and sets the external variable \fIoptopt\fP to the -actual option character. If the first character of \fIoptstring\fP -is a colon (`:'), then \fBgetopt()\fP returns `:' instead of `?' to +it returns '?' and sets the external variable \fIoptopt\fP to the +actual option character. If the first character +(following any optional '+'or '\-' described above) +of \fIoptstring\fP +is a colon (':'), then \fBgetopt\fP() returns ':' instead of '?' to indicate a missing option argument. If an error was detected, and the first character of \fIoptstring\fP is not a colon, and -the external variable \fIopterr\fP is nonzero (which is the default), -\fBgetopt()\fP prints an error message. +the external variable \fIopterr\fP is non-zero (which is the default), +\fBgetopt\fP() prints an error message. .PP The -.B getopt_long() +.BR getopt_long () function works like -.B getopt() +.BR getopt () except that it also accepts long options, started out by two dashes. Long option names may be abbreviated if the abbreviation is unique or is an exact match for some defined option. A long option may take a parameter, of the form -.B --arg=param +.B \-\-arg=param or -.BR "--arg param" . +.BR "\-\-arg param" . .PP .I longopts is a pointer to the first element of an array of @@ -172,15 +178,15 @@ .TP .I has_arg is: -\fBno_argument\fP (or 0) if the option does not take an argument, -\fBrequired_argument\fP (or 1) if the option requires an argument, or +\fBno_argument\fP (or 0) if the option does not take an argument; +\fBrequired_argument\fP (or 1) if the option requires an argument; or \fBoptional_argument\fP (or 2) if the option takes an optional argument. .TP .I flag specifies how results are returned for a long option. If \fIflag\fP -is \fBNULL\fP, then \fBgetopt_long()\fP returns \fIval\fP. (For +is \fBNULL\fP, then \fBgetopt_long\fP() returns \fIval\fP. (For example, the calling program may set \fIval\fP to the equivalent short -option character.) Otherwise, \fBgetopt_long()\fP returns 0, and +option character.) Otherwise, \fBgetopt_long\fP() returns 0, and \fIflag\fP points to a variable which is set to \fIval\fP if the option is found, but left unchanged if the option is not found. .TP @@ -194,22 +200,33 @@ points to a variable which is set to the index of the long option relative to .IR longopts . .PP -\fBgetopt_long_only()\fP is like \fBgetopt_long()\fP, but `-' as well -as `--' can indicate a long option. If an option that starts with `-' -(not `--') doesn't match a long option, but does match a short option, +\fBgetopt_long_only\fP() is like \fBgetopt_long\fP(), but '\-' as well +as '\-\-' can indicate a long option. If an option that starts with '\-' +(not '\-\-') doesn't match a long option, but does match a short option, it is parsed as a short option instead. .SH "RETURN VALUE" -The -.B getopt() -function returns the option character if the option was found -successfully, `:' if there was a missing parameter for one of the -options, `?' for an unknown option character, or \-1 -for the end of the option list. +If an option was successfully found, then +.BR getopt () +returns the option character. +If all command-line options have been parsed, then +.BR getopt () +returns \-1. +If +.BR getopt () +encounters an option character that was not in +.IR optstring , +then '?' is returned. +If +.BR getopt () +encounters an option with a missing argument, +then the return value depends on the first character in +.IR optstring : +if it is ':', then ':' is returned; otherwise '?' is returned. .PP -\fBgetopt_long()\fP and \fBgetopt_long_only()\fP also return the option +\fBgetopt_long\fP() and \fBgetopt_long_only\fP() also return the option character when a short option is recognized. For a long option, they return \fIval\fP if \fIflag\fP is \fBNULL\fP, and 0 otherwise. Error -and \-1 returns are the same as for \fBgetopt()\fP, plus `?' for an +and \-1 returns are the same as for \fBgetopt\fP (), plus '?' for an ambiguous match or an extraneous parameter. .SH "ENVIRONMENT VARIABLES" .TP @@ -229,7 +246,7 @@ version 2.01, but the support remains in GNU libc. .SH EXAMPLE The following example program illustrates the use of -.BR getopt_long() +.BR getopt_long () with most of its features. .nf .sp @@ -257,7 +274,7 @@ c = getopt_long (argc, argv, "abc:d:012", long_options, &option_index); - if (c == -1) + if (c == \-1) break; switch (c) { @@ -286,11 +303,11 @@ break; case 'c': - printf ("option c with value `%s'\\n", optarg); + printf ("option c with value '%s'\\n", optarg); break; case 'd': - printf ("option d with value `%s'\\n", optarg); + printf ("option d with value '%s'\\n", optarg); break; case '?': @@ -313,15 +330,14 @@ .fi .SH BUGS The POSIX.2 specification of -.B getopt() +.BR getopt () has a technical error described in POSIX.2 Interpretation 150. The GNU implementation (and probably all other implementations) implements the correct behaviour rather than that specified. .SH "CONFORMING TO" .TP -\fBgetopt()\fP: +\fBgetopt\fP(): POSIX.2, provided the environment variable POSIXLY_CORRECT is set. Otherwise, the elements of \fIargv\fP aren't really const, because we permute them. We pretend they're const in the prototype to be compatible with other systems. - Index: ossp-pkg/getopt/getopt.c RCS File: /v/ossp/cvs/ossp-pkg/getopt/getopt.c,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/getopt/getopt.c,v' 2>/dev/null --- getopt.c 2003/03/07 10:35:16 1.1 +++ getopt.c 2005/10/05 10:11:57 1.2 @@ -333,8 +333,8 @@ nonoption_flags_len = nonoption_flags_max_len = 0; else { - memset (__mempcpy (new_str, __getopt_nonoption_flags, - nonoption_flags_max_len), + memset (mempcpy (new_str, __getopt_nonoption_flags, + nonoption_flags_max_len), '\0', top + 1 - nonoption_flags_max_len); nonoption_flags_max_len = top + 1; __getopt_nonoption_flags = new_str; @@ -444,7 +444,7 @@ if (__getopt_nonoption_flags == NULL) nonoption_flags_max_len = -1; else - memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), + memset (mempcpy (__getopt_nonoption_flags, orig_str, len), '\0', nonoption_flags_max_len - len); } } Index: ossp-pkg/getopt/getopt.h RCS File: /v/ossp/cvs/ossp-pkg/getopt/getopt.h,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/getopt/getopt.h,v' 2>/dev/null --- getopt.h 2003/03/07 10:35:16 1.1 +++ getopt.h 2005/10/05 10:11:57 1.2 @@ -1,6 +1,6 @@ /* Declarations for getopt. - Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 2000 - Free Software Foundation, Inc. + Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 2000, + 2002 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@gnu.org. @@ -105,16 +105,19 @@ declaration without arguments. If it is 0, we checked and failed to find the declaration so provide a fully prototyped one. If it is 1, we found it so don't provide any declaration at all. */ -#if defined (__GNU_LIBRARY__) || (defined (HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT) +#if !HAVE_DECL_GETOPT +#if defined (__GNU_LIBRARY__) || defined (HAVE_DECL_GETOPT) /* Many other libraries have conflicting prototypes for getopt, with - differences in the consts, in stdlib.h. To avoid compilation + differences in the consts, in unistd.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ extern int getopt (int argc, char *const *argv, const char *shortopts); -#else /* not __GNU_LIBRARY__ */ -# if !defined (HAVE_DECL_GETOPT) && !defined (__cplusplus) +#else +#ifndef __cplusplus extern int getopt (); -# endif -#endif /* __GNU_LIBRARY__ */ +#endif /* __cplusplus */ +#endif +#endif /* !HAVE_DECL_GETOPT */ + extern int getopt_long (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); extern int getopt_long_only (int argc, char *const *argv, Index: ossp-pkg/getopt/getopt.pc.in RCS File: /v/ossp/cvs/ossp-pkg/getopt/getopt.pc.in,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/getopt/getopt.pc.in,v' | diff -u /dev/null - -L'ossp-pkg/getopt/getopt.pc.in' 2>/dev/null --- ossp-pkg/getopt/getopt.pc.in +++ - 2024-05-16 21:52:22.697513512 +0200 @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=${prefix} +includedir=${prefix}/include +libdir=${exec_prefix}/lib + +Name: GNU getopt +Description: GNU Option Parsing Library +Version: 0.0 +Cflags: -I${includedir} +Libs: -L${libdir} -lgetopt Index: ossp-pkg/getopt/getopt_main.c RCS File: /v/ossp/cvs/ossp-pkg/getopt/getopt_main.c,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/getopt/getopt_main.c,v' 2>/dev/null --- getopt_main.c 2003/03/07 10:35:16 1.1 +++ getopt_main.c 2005/10/05 10:11:57 1.2 @@ -43,11 +43,7 @@ #include #include -#if LIBCGETOPT -#include -#else #include "getopt.h" -#endif #define WITHOUT_GETTEXT 1 #define _(x) x Index: ossp-pkg/getopt/getopt_test.c RCS File: /v/ossp/cvs/ossp-pkg/getopt/getopt_test.c,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/getopt/getopt_test.c,v' 2>/dev/null --- getopt_test.c 2003/03/07 10:35:16 1.1 +++ getopt_test.c 2005/10/05 10:11:57 1.2 @@ -1,4 +1,3 @@ - #include "getopt.h" #include #include