Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/prefix:master commit in: sys-apps/debianutils/files/, sys-apps/debianutils/
Date: Sun, 27 Dec 2020 11:07:12
Message-Id: 1609066711.7d119f602f4b49f45956c98d08f2f1e7e0f2ded5.grobian@gentoo
1 commit: 7d119f602f4b49f45956c98d08f2f1e7e0f2ded5
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Sun Dec 27 10:58:31 2020 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Sun Dec 27 10:58:31 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=7d119f60
7
8 sys-apps/debianutils: drop ~m68k-mint
9
10 Package-Manager: Portage-3.0.12-prefix, Repoman-3.0.2
11 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
12
13 sys-apps/debianutils/Manifest | 1 +
14 sys-apps/debianutils/debianutils-4.11.2.ebuild | 7 +-
15 .../debianutils/files/debianutils-4-nongnu.patch | 1629 --------------------
16 3 files changed, 5 insertions(+), 1632 deletions(-)
17
18 diff --git a/sys-apps/debianutils/Manifest b/sys-apps/debianutils/Manifest
19 index 05cf701556..0cd6876323 100644
20 --- a/sys-apps/debianutils/Manifest
21 +++ b/sys-apps/debianutils/Manifest
22 @@ -1 +1,2 @@
23 +DIST debianutils-4-nongnu.patch 48187 BLAKE2B 880ad9221aacfb24321f0f5354c358d814d296d430c0ea8380fbcc4b7262a1dee0cfbcf439946785224f42483119305f857c5bb2e5482ba1dff06467bfc5beca SHA512 0e8c3ccd1ca59e0106d9c6cf9be64b38ecc0a5a5d84f898fea72e19f40d5e819e7a5d3ef9e4a2dc6f8620a8c5fb9708e66193f4af906a95ff0f7d1708d1b8e1f
24 DIST debianutils_4.11.2.tar.xz 158132 BLAKE2B c2a95c90b4267e3b1d61c21db562f960b4666982c488e69a757fb0a7a42e8e739d44f553edd8cf532df30c492e999920ab63ec3580479de7de5d901d75de76fc SHA512 0bd9098beee78b3c8dae839f0c29e9f142cbb22f2ced473cf7ae47a14d9493ba882c1829eba213780392a87a3223b3689729754c8ded80a091efaef3f6f903fd
25
26 diff --git a/sys-apps/debianutils/debianutils-4.11.2.ebuild b/sys-apps/debianutils/debianutils-4.11.2.ebuild
27 index ae0eae50f9..51fab4f491 100644
28 --- a/sys-apps/debianutils/debianutils-4.11.2.ebuild
29 +++ b/sys-apps/debianutils/debianutils-4.11.2.ebuild
30 @@ -7,11 +7,12 @@ inherit flag-o-matic autotools
31
32 DESCRIPTION="A selection of tools from Debian"
33 HOMEPAGE="https://packages.qa.debian.org/d/debianutils.html"
34 -SRC_URI="mirror://debian/pool/main/d/${PN}/${PN}_${PV}.tar.xz"
35 +SRC_URI="mirror://debian/pool/main/d/${PN}/${PN}_${PV}.tar.xz
36 + https://dev.gentoo.org/~grobian/distfiles/${PN}-4-nongnu.patch"
37
38 LICENSE="BSD GPL-2 SMAIL"
39 SLOT="0"
40 -KEYWORDS="~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
41 +KEYWORDS="~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
42 IUSE="+installkernel static"
43
44 PDEPEND="
45 @@ -26,7 +27,7 @@ S="${WORKDIR}/${PN}"
46
47 PATCHES=(
48 "${FILESDIR}"/${PN}-3.4.2-no-bs-namespace.patch
49 - "${FILESDIR}"/${PN}-4-nongnu.patch
50 + "${DISTDIR}"/${PN}-4-nongnu.patch
51 )
52
53 src_prepare() {
54
55 diff --git a/sys-apps/debianutils/files/debianutils-4-nongnu.patch b/sys-apps/debianutils/files/debianutils-4-nongnu.patch
56 deleted file mode 100644
57 index 714c9daf1a..0000000000
58 --- a/sys-apps/debianutils/files/debianutils-4-nongnu.patch
59 +++ /dev/null
60 @@ -1,1629 +0,0 @@
61 -diff -ur debianutils-4.orig/Makefile.am debianutils-4/Makefile.am
62 ---- debianutils-4.orig/Makefile.am 2011-05-18 21:13:00.000000000 +0200
63 -+++ debianutils-4/Makefile.am 2011-05-22 13:03:31.000000000 +0200
64 -@@ -3,9 +3,9 @@
65 - SUBDIRS = po4a
66 -
67 - bin_PROGRAMS = run-parts tempfile ischroot
68 --run_parts_SOURCES = run-parts.c
69 --tempfile_SOURCES = tempfile.c
70 --ischroot_SOURCES = ischroot.c
71 -+run_parts_SOURCES = run-parts.c getopt_long.c getopt_long.h
72 -+tempfile_SOURCES = tempfile.c getopt_long.c getopt_long.h
73 -+ischroot_SOURCES = ischroot.c getopt_long.c getopt_long.h
74 -
75 - bin_SCRIPTS = which savelog
76 -
77 -diff -ur debianutils-4.orig/configure.ac debianutils-4/configure.ac
78 ---- debianutils-4.orig/configure.ac 2011-05-18 21:13:00.000000000 +0200
79 -+++ debianutils-4/configure.ac 2011-05-22 13:02:53.000000000 +0200
80 -@@ -3,8 +3,12 @@
81 -
82 - AC_PROG_CC
83 -
84 -+AC_CONFIG_HEADERS([config.h])
85 - AC_HEADER_STDC
86 - AC_CHECK_HEADERS(paths.h getopt.h)
87 -+AC_CHECK_FUNCS(mkdtemp gettimeofday scandir getopt_long)
88 -+AC_FUNC_CLOSEDIR_VOID
89 -+AC_HEADER_DIRENT
90 -
91 - AC_CONFIG_FILES([Makefile po4a/Makefile po4a/fr/Makefile po4a/sl/Makefile po4a/de/Makefile po4a/es/Makefile])
92 - AC_OUTPUT
93 -diff -ur debianutils-4.orig/ischroot.c debianutils-4/ischroot.c
94 ---- debianutils-4.orig/ischroot.c 2011-05-18 21:13:00.000000000 +0200
95 -+++ debianutils-4/ischroot.c 2011-05-22 13:05:11.000000000 +0200
96 -@@ -7,6 +7,7 @@
97 - * or later for copying conditions. There is NO warranty.
98 - */
99 -
100 -+#include "config.h"
101 - #include <stdio.h>
102 - #include <stdint.h>
103 - #include <stdlib.h>
104 -@@ -17,6 +18,8 @@
105 - #include <getopt.h>
106 - #endif /* HAVE_GETOPT_H */
107 -
108 -+#include "getopt_long.h"
109 -+
110 - void version()
111 - {
112 - fprintf(stderr, "Debian ischroot, version " PACKAGE_VERSION
113 -diff -ur debianutils-4.orig/run-parts.c debianutils-4/run-parts.c
114 ---- debianutils-4.orig/run-parts.c 2011-05-22 13:02:07.000000000 +0200
115 -+++ debianutils-4/run-parts.c 2011-05-22 13:02:53.000000000 +0200
116 -@@ -12,12 +12,27 @@
117 - *
118 - */
119 -
120 -+#include "config.h"
121 -+
122 - #include <stdio.h>
123 - #include <stdarg.h>
124 - #include <stdlib.h>
125 - #include <sys/types.h>
126 - #include <sys/wait.h>
127 --#include <dirent.h>
128 -+#if defined(HAVE_DIRENT_H)
129 -+# include <dirent.h>
130 -+# define NAMLEN(dirent) strlen((dirent)->d_name)
131 -+#else /* ! define HAVE_DIRENT_H */
132 -+# define dirent direct
133 -+# define NAMLEN(dirent) ((dirent)->d_namlen)
134 -+# if defined(HAVE_SYS_NDIR_H)
135 -+# include <sys/ndir.h>
136 -+# elif defined(HAVE_SYS_DIR_H)
137 -+# include <sys/dir.h>
138 -+# elif defined(HAVE_NDIR_H)
139 -+# include <ndir.h>
140 -+# endif
141 -+#endif
142 - #include <sys/stat.h>
143 - #include <unistd.h>
144 - #include <fcntl.h>
145 -@@ -35,6 +50,8 @@
146 - #define RUNPARTS_ERE 1
147 - #define RUNPARTS_LSBSYSINIT 100
148 -
149 -+#include "getopt_long.h"
150 -+
151 - int test_mode = 0;
152 - int list_mode = 0;
153 - int verbose_mode = 0;
154 -@@ -284,6 +301,94 @@
155 - }
156 - }
157 -
158 -+#ifndef HAVE_SCANDIR
159 -+int alphasort(void const* a, void const* b)
160 -+{
161 -+ return strcoll( (*(struct dirent const **) a)->d_name,
162 -+ (*(struct dirent const **) b)->d_name);
163 -+}
164 -+
165 -+int scandir(char const* dir, struct dirent ***namelist,
166 -+ int (*select) (struct dirent const*),
167 -+ int (*cmp) (void const*, void const*))
168 -+{
169 -+ DIR *dp = opendir(dir);
170 -+ struct dirent **v = NULL;
171 -+ size_t vsize = 0;
172 -+ size_t cnt = 0;
173 -+ struct dirent *d;
174 -+ int save_errno;
175 -+
176 -+ if (dp == NULL)
177 -+ return -1;
178 -+
179 -+ save_errno = errno;
180 -+ errno = 0;
181 -+
182 -+ while((d = readdir(dp)) != NULL) {
183 -+ int use_it = select == NULL;
184 -+
185 -+ if (! use_it) {
186 -+ use_it = select(d);
187 -+ errno = 0;
188 -+ }
189 -+ if (use_it) {
190 -+ struct dirent *vnew;
191 -+ size_t dsize;
192 -+
193 -+ errno = 0;
194 -+
195 -+ if (cnt == vsize) {
196 -+ struct dirent **new;
197 -+ if (vsize == 0) {
198 -+ vsize = 10;
199 -+ } else {
200 -+ vsize *= 2;
201 -+ }
202 -+ new = (struct dirent **)realloc(v, vsize * sizeof(*v));
203 -+ if (new == NULL) {
204 -+ break;
205 -+ }
206 -+ v = new;
207 -+ }
208 -+
209 -+ dsize = &d->d_name[0] - (char*)d + NAMLEN(d) + 1;
210 -+ vnew = (struct dirent*)malloc(dsize);
211 -+ if (vnew == NULL) {
212 -+ break;
213 -+ }
214 -+
215 -+ v[cnt++] = (struct dirent*) memcpy(vnew, d, dsize);
216 -+ }
217 -+ }
218 -+
219 -+ if (errno != 0) {
220 -+ save_errno = errno;
221 -+
222 -+ while(cnt > 0) {
223 -+ free(v[--cnt]);
224 -+ }
225 -+ if (v != NULL) {
226 -+ free(v);
227 -+ }
228 -+ cnt = -1;
229 -+ } else {
230 -+ if (cmp != NULL) {
231 -+ qsort(v, cnt, sizeof(*v), cmp);
232 -+ }
233 -+
234 -+ *namelist = v;
235 -+ }
236 -+
237 -+#ifndef CLOSEDIR_VOID
238 -+ (void)
239 -+#endif /* CLOSEDIR_VOID */
240 -+ closedir(dp);
241 -+ errno = save_errno;
242 -+
243 -+ return cnt;
244 -+}
245 -+#endif /* ! HAVE_SCANDIR */
246 -
247 - /* Find the parts to run & call run_part() */
248 - void run_parts(char *dirname)
249 -diff -ur debianutils-4.orig/tempfile.c debianutils-4/tempfile.c
250 ---- debianutils-4.orig/tempfile.c 2011-05-18 21:13:00.000000000 +0200
251 -+++ debianutils-4/tempfile.c 2011-05-22 13:02:53.000000000 +0200
252 -@@ -1,3 +1,4 @@
253 -+#include "config.h"
254 - #include <stdio.h>
255 - #include <unistd.h>
256 - #include <stdlib.h>
257 -@@ -10,6 +11,8 @@
258 - #include <fcntl.h>
259 - #include <string.h>
260 -
261 -+#include "getopt_long.h"
262 -+
263 - char *progname;
264 -
265 - void usage(int);
266 -diff -ruN debianutils-4.orig/getopt_long.c debianutils-4/getopt_long.c
267 ---- debianutils-4.orig/getopt_long.c 1970-01-01 01:00:00.000000000 +0100
268 -+++ debianutils-4/getopt_long.c 2007-04-02 11:47:57.000000000 +0200
269 -@@ -0,0 +1,1237 @@
270 -+/*
271 -+ * THIS IS NOT A CLEAN COPY OF GETOPT.C AND GETOPT1.C
272 -+ * -- that is, do not use it in other projects.
273 -+ *
274 -+ * Implementation of getopt_long, cobbled together from getopt.c and
275 -+ * getopt1.c from the GNU binutils distribution. This is more-or-less
276 -+ * getopt.c inserted into getopt1.c, with the definition of getopt()
277 -+ * commented out.
278 -+ *
279 -+ * Need to ifdef out optarg, optind, opterr, optopt, to handle the
280 -+ * case where these are already defined for the benefit of system
281 -+ * getopt()
282 -+ *
283 -+ * No, it's not pretty.
284 -+ */
285 -+
286 -+/* getopt_long and getopt_long_only entry points for GNU getopt.
287 -+ Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
288 -+ Free Software Foundation, Inc.
289 -+
290 -+ NOTE: This source is derived from an old version taken from the GNU C
291 -+ Library (glibc).
292 -+
293 -+ This program is free software; you can redistribute it and/or modify it
294 -+ under the terms of the GNU General Public License as published by the
295 -+ Free Software Foundation; either version 2, or (at your option) any
296 -+ later version.
297 -+
298 -+ This program is distributed in the hope that it will be useful,
299 -+ but WITHOUT ANY WARRANTY; without even the implied warranty of
300 -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
301 -+ GNU General Public License for more details.
302 -+
303 -+ You should have received a copy of the GNU General Public License
304 -+ along with this program; if not, write to the Free Software
305 -+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
306 -+ USA. */
307 -+
308 -+#include <config.h>
309 -+
310 -+#ifndef HAVE_GETOPT_LONG
311 -+/* We shouldn't be compiling this module in this case, but we clearly
312 -+ are (damned configuration tools!), so avoid messing up. */
313 -+
314 -+#include "getopt_long.h"
315 -+/* See getopt_long.h for discussion of THIS_IS__STDC__ */
316 -+
317 -+
318 -+#if !defined THIS_IS__STDC__ || !THIS_IS__STDC__
319 -+/* This is a separate conditional since some stdc systems
320 -+ reject `defined (const)'. */
321 -+#ifndef const
322 -+#define const
323 -+#endif
324 -+#endif
325 -+
326 -+#include <stdio.h>
327 -+
328 -+
329 -+
330 -+/* ******************** getopt.c ******************** */
331 -+/* Getopt for GNU.
332 -+ NOTE: getopt is now part of the C library, so if you don't know what
333 -+ "Keep this file name-space clean" means, talk to drepper@×××.org
334 -+ before changing it!
335 -+
336 -+ Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98
337 -+ Free Software Foundation, Inc.
338 -+
339 -+ NOTE: This source is derived from an old version taken from the GNU C
340 -+ Library (glibc).
341 -+
342 -+ This program is free software; you can redistribute it and/or modify it
343 -+ under the terms of the GNU General Public License as published by the
344 -+ Free Software Foundation; either version 2, or (at your option) any
345 -+ later version.
346 -+
347 -+ This program is distributed in the hope that it will be useful,
348 -+ but WITHOUT ANY WARRANTY; without even the implied warranty of
349 -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
350 -+ GNU General Public License for more details.
351 -+
352 -+ You should have received a copy of the GNU General Public License
353 -+ along with this program; if not, write to the Free Software
354 -+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
355 -+ USA. */
356 -+
357 -+/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
358 -+ Ditto for AIX 3.2 and <stdlib.h>. */
359 -+#ifndef _NO_PROTO
360 -+# define _NO_PROTO
361 -+#endif
362 -+
363 -+
364 -+#if !defined THIS_IS__STDC__ || !THIS_IS__STDC__
365 -+/* This is a separate conditional since some stdc systems
366 -+ reject `defined (const)'. */
367 -+# ifndef const
368 -+# define const
369 -+# endif
370 -+#endif
371 -+
372 -+#include <stdio.h>
373 -+
374 -+/* Comment out all this code if we are using the GNU C Library, and are not
375 -+ actually compiling the library itself. This code is part of the GNU C
376 -+ Library, but also included in many other GNU distributions. Compiling
377 -+ and linking in this code is a waste when using the GNU C library
378 -+ (especially if it is a shared library). Rather than having every GNU
379 -+ program understand `configure --with-gnu-libc' and omit the object files,
380 -+ it is simpler to just do this in the source for each such file. */
381 -+
382 -+#define GETOPT_INTERFACE_VERSION 2
383 -+#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
384 -+# include <gnu-versions.h>
385 -+# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
386 -+# define ELIDE_CODE
387 -+# endif
388 -+#endif
389 -+
390 -+#ifndef ELIDE_CODE
391 -+
392 -+
393 -+/* This needs to come after some library #include
394 -+ to get __GNU_LIBRARY__ defined. */
395 -+#ifdef __GNU_LIBRARY__
396 -+/* Don't include stdlib.h for non-GNU C libraries because some of them
397 -+ contain conflicting prototypes for getopt. */
398 -+# include <stdlib.h>
399 -+# include <unistd.h>
400 -+#endif /* GNU C library. */
401 -+
402 -+#ifdef VMS
403 -+# include <unixlib.h>
404 -+# if HAVE_STRING_H - 0
405 -+# include <string.h>
406 -+# endif
407 -+#endif
408 -+
409 -+#ifndef _
410 -+/* This is for other GNU distributions with internationalized messages.
411 -+ When compiling libc, the _ macro is predefined. */
412 -+# ifdef HAVE_LIBINTL_H
413 -+# include <libintl.h>
414 -+# define _(msgid) gettext (msgid)
415 -+# else
416 -+# define _(msgid) (msgid)
417 -+# endif
418 -+#endif
419 -+
420 -+/* This version of `getopt' appears to the caller like standard Unix `getopt'
421 -+ but it behaves differently for the user, since it allows the user
422 -+ to intersperse the options with the other arguments.
423 -+
424 -+ As `getopt' works, it permutes the elements of ARGV so that,
425 -+ when it is done, all the options precede everything else. Thus
426 -+ all application programs are extended to handle flexible argument order.
427 -+
428 -+ Setting the environment variable POSIXLY_CORRECT disables permutation.
429 -+ Then the behavior is completely standard.
430 -+
431 -+ GNU application programs can use a third alternative mode in which
432 -+ they can distinguish the relative order of options and other arguments. */
433 -+
434 -+
435 -+
436 -+/* Define HAVE_GETOPT if the getopt function (and thus, which is more
437 -+ * important to us, the getopt globals, optarg, optind, opterr and
438 -+ * optopt) is defined by the system. Leave undefined if they should be
439 -+ * defined here instead.
440 -+ */
441 -+#ifndef HAVE_GETOPT
442 -+
443 -+/* For communication from `getopt' to the caller.
444 -+ When `getopt' finds an option that takes an argument,
445 -+ the argument value is returned here.
446 -+ Also, when `ordering' is RETURN_IN_ORDER,
447 -+ each non-option ARGV-element is returned here. */
448 -+
449 -+char *optarg = NULL;
450 -+
451 -+/* Index in ARGV of the next element to be scanned.
452 -+ This is used for communication to and from the caller
453 -+ and for communication between successive calls to `getopt'.
454 -+
455 -+ On entry to `getopt', zero means this is the first call; initialize.
456 -+
457 -+ When `getopt' returns -1, this is the index of the first of the
458 -+ non-option elements that the caller should itself scan.
459 -+
460 -+ Otherwise, `optind' communicates from one call to the next
461 -+ how much of ARGV has been scanned so far. */
462 -+
463 -+/* 1003.2 says this must be 1 before any call. */
464 -+int optind = 1;
465 -+
466 -+/* Callers store zero here to inhibit the error message
467 -+ for unrecognized options. */
468 -+
469 -+int opterr = 1;
470 -+
471 -+/* Set to an option character which was unrecognized.
472 -+ This must be initialized on some systems to avoid linking in the
473 -+ system's own getopt implementation. */
474 -+
475 -+int optopt = '?';
476 -+
477 -+#endif /* #ifndef HAVE_GETOPT */
478 -+
479 -+/* Formerly, initialization of getopt depended on optind==0, which
480 -+ causes problems with re-calling getopt as programs generally don't
481 -+ know that. */
482 -+
483 -+int __getopt_initialized = 0;
484 -+
485 -+/* The next char to be scanned in the option-element
486 -+ in which the last option character we returned was found.
487 -+ This allows us to pick up the scan where we left off.
488 -+
489 -+ If this is zero, or a null string, it means resume the scan
490 -+ by advancing to the next ARGV-element. */
491 -+
492 -+static char *nextchar;
493 -+
494 -+/* Describe how to deal with options that follow non-option ARGV-elements.
495 -+
496 -+ If the caller did not specify anything,
497 -+ the default is REQUIRE_ORDER if the environment variable
498 -+ POSIXLY_CORRECT is defined, PERMUTE otherwise.
499 -+
500 -+ REQUIRE_ORDER means don't recognize them as options;
501 -+ stop option processing when the first non-option is seen.
502 -+ This is what Unix does.
503 -+ This mode of operation is selected by either setting the environment
504 -+ variable POSIXLY_CORRECT, or using `+' as the first character
505 -+ of the list of option characters.
506 -+
507 -+ PERMUTE is the default. We permute the contents of ARGV as we scan,
508 -+ so that eventually all the non-options are at the end. This allows options
509 -+ to be given in any order, even with programs that were not written to
510 -+ expect this.
511 -+
512 -+ RETURN_IN_ORDER is an option available to programs that were written
513 -+ to expect options and other ARGV-elements in any order and that care about
514 -+ the ordering of the two. We describe each non-option ARGV-element
515 -+ as if it were the argument of an option with character code 1.
516 -+ Using `-' as the first character of the list of option characters
517 -+ selects this mode of operation.
518 -+
519 -+ The special argument `--' forces an end of option-scanning regardless
520 -+ of the value of `ordering'. In the case of RETURN_IN_ORDER, only
521 -+ `--' can cause `getopt' to return -1 with `optind' != ARGC. */
522 -+
523 -+static enum
524 -+{
525 -+ REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
526 -+} ordering;
527 -+
528 -+/* Value of POSIXLY_CORRECT environment variable. */
529 -+static char *posixly_correct;
530 -+
531 -+#ifdef __GNU_LIBRARY__
532 -+/* We want to avoid inclusion of string.h with non-GNU libraries
533 -+ because there are many ways it can cause trouble.
534 -+ On some systems, it contains special magic macros that don't work
535 -+ in GCC. */
536 -+# include <string.h>
537 -+# define my_index strchr
538 -+#else
539 -+
540 -+# if HAVE_STRING_H
541 -+# include <string.h>
542 -+# else
543 -+# if HAVE_STRINGS_H
544 -+# include <strings.h>
545 -+# endif
546 -+# endif
547 -+
548 -+/* Avoid depending on library functions or files
549 -+ whose names are inconsistent. */
550 -+
551 -+#ifndef getenv
552 -+extern char *getenv ();
553 -+#endif
554 -+
555 -+static char *
556 -+my_index (str, chr)
557 -+ const char *str;
558 -+ int chr;
559 -+{
560 -+ while (*str)
561 -+ {
562 -+ if (*str == chr)
563 -+ return (char *) str;
564 -+ str++;
565 -+ }
566 -+ return 0;
567 -+}
568 -+
569 -+/* If using GCC, we can safely declare strlen this way.
570 -+ If not using GCC, it is ok not to declare it. */
571 -+#ifdef __GNUC__
572 -+/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
573 -+ That was relevant to code that was here before. */
574 -+# if (!defined THIS_IS__STDC__ || !THIS_IS__STDC__) && !defined strlen
575 -+/* gcc with -traditional declares the built-in strlen to return int,
576 -+ and has done so at least since version 2.4.5. -- rms. */
577 -+extern int strlen (const char *);
578 -+# endif /* not THIS_IS__STDC__ */
579 -+#endif /* __GNUC__ */
580 -+
581 -+#endif /* not __GNU_LIBRARY__ */
582 -+
583 -+/* Handle permutation of arguments. */
584 -+
585 -+/* Describe the part of ARGV that contains non-options that have
586 -+ been skipped. `first_nonopt' is the index in ARGV of the first of them;
587 -+ `last_nonopt' is the index after the last of them. */
588 -+
589 -+static int first_nonopt;
590 -+static int last_nonopt;
591 -+
592 -+#ifdef _LIBC
593 -+/* Bash 2.0 gives us an environment variable containing flags
594 -+ indicating ARGV elements that should not be considered arguments. */
595 -+
596 -+/* Defined in getopt_init.c */
597 -+extern char *__getopt_nonoption_flags;
598 -+
599 -+static int nonoption_flags_max_len;
600 -+static int nonoption_flags_len;
601 -+
602 -+static int original_argc;
603 -+static char *const *original_argv;
604 -+
605 -+/* Make sure the environment variable bash 2.0 puts in the environment
606 -+ is valid for the getopt call we must make sure that the ARGV passed
607 -+ to getopt is that one passed to the process. */
608 -+static void
609 -+__attribute__ ((unused))
610 -+store_args_and_env (int argc, char *const *argv)
611 -+{
612 -+ /* XXX This is no good solution. We should rather copy the args so
613 -+ that we can compare them later. But we must not use malloc(3). */
614 -+ original_argc = argc;
615 -+ original_argv = argv;
616 -+}
617 -+# ifdef text_set_element
618 -+text_set_element (__libc_subinit, store_args_and_env);
619 -+# endif /* text_set_element */
620 -+
621 -+# define SWAP_FLAGS(ch1, ch2) \
622 -+ if (nonoption_flags_len > 0) \
623 -+ { \
624 -+ char __tmp = __getopt_nonoption_flags[ch1]; \
625 -+ __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
626 -+ __getopt_nonoption_flags[ch2] = __tmp; \
627 -+ }
628 -+#else /* !_LIBC */
629 -+# define SWAP_FLAGS(ch1, ch2)
630 -+#endif /* _LIBC */
631 -+
632 -+/* Exchange two adjacent subsequences of ARGV.
633 -+ One subsequence is elements [first_nonopt,last_nonopt)
634 -+ which contains all the non-options that have been skipped so far.
635 -+ The other is elements [last_nonopt,optind), which contains all
636 -+ the options processed since those non-options were skipped.
637 -+
638 -+ `first_nonopt' and `last_nonopt' are relocated so that they describe
639 -+ the new indices of the non-options in ARGV after they are moved. */
640 -+
641 -+#if defined THIS_IS__STDC__ && THIS_IS__STDC__
642 -+static void exchange (char **);
643 -+#endif
644 -+
645 -+static void
646 -+exchange (argv)
647 -+ char **argv;
648 -+{
649 -+ int bottom = first_nonopt;
650 -+ int middle = last_nonopt;
651 -+ int top = optind;
652 -+ char *tem;
653 -+
654 -+ /* Exchange the shorter segment with the far end of the longer segment.
655 -+ That puts the shorter segment into the right place.
656 -+ It leaves the longer segment in the right place overall,
657 -+ but it consists of two parts that need to be swapped next. */
658 -+
659 -+#ifdef _LIBC
660 -+ /* First make sure the handling of the `__getopt_nonoption_flags'
661 -+ string can work normally. Our top argument must be in the range
662 -+ of the string. */
663 -+ if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len)
664 -+ {
665 -+ /* We must extend the array. The user plays games with us and
666 -+ presents new arguments. */
667 -+ char *new_str = malloc (top + 1);
668 -+ if (new_str == NULL)
669 -+ nonoption_flags_len = nonoption_flags_max_len = 0;
670 -+ else
671 -+ {
672 -+ memset (__mempcpy (new_str, __getopt_nonoption_flags,
673 -+ nonoption_flags_max_len),
674 -+ '\0', top + 1 - nonoption_flags_max_len);
675 -+ nonoption_flags_max_len = top + 1;
676 -+ __getopt_nonoption_flags = new_str;
677 -+ }
678 -+ }
679 -+#endif
680 -+
681 -+ while (top > middle && middle > bottom)
682 -+ {
683 -+ if (top - middle > middle - bottom)
684 -+ {
685 -+ /* Bottom segment is the short one. */
686 -+ int len = middle - bottom;
687 -+ register int i;
688 -+
689 -+ /* Swap it with the top part of the top segment. */
690 -+ for (i = 0; i < len; i++)
691 -+ {
692 -+ tem = argv[bottom + i];
693 -+ argv[bottom + i] = argv[top - (middle - bottom) + i];
694 -+ argv[top - (middle - bottom) + i] = tem;
695 -+ SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
696 -+ }
697 -+ /* Exclude the moved bottom segment from further swapping. */
698 -+ top -= len;
699 -+ }
700 -+ else
701 -+ {
702 -+ /* Top segment is the short one. */
703 -+ int len = top - middle;
704 -+ register int i;
705 -+
706 -+ /* Swap it with the bottom part of the bottom segment. */
707 -+ for (i = 0; i < len; i++)
708 -+ {
709 -+ tem = argv[bottom + i];
710 -+ argv[bottom + i] = argv[middle + i];
711 -+ argv[middle + i] = tem;
712 -+ SWAP_FLAGS (bottom + i, middle + i);
713 -+ }
714 -+ /* Exclude the moved top segment from further swapping. */
715 -+ bottom += len;
716 -+ }
717 -+ }
718 -+
719 -+ /* Update records for the slots the non-options now occupy. */
720 -+
721 -+ first_nonopt += (optind - last_nonopt);
722 -+ last_nonopt = optind;
723 -+}
724 -+
725 -+/* Initialize the internal data when the first call is made. */
726 -+
727 -+#if defined THIS_IS__STDC__ && THIS_IS__STDC__
728 -+static const char *_getopt_initialize (int, char *const *, const char *);
729 -+#endif
730 -+static const char *
731 -+_getopt_initialize (argc, argv, optstring)
732 -+ int argc;
733 -+ char *const *argv;
734 -+ const char *optstring;
735 -+{
736 -+ /* Start processing options with ARGV-element 1 (since ARGV-element 0
737 -+ is the program name); the sequence of previously skipped
738 -+ non-option ARGV-elements is empty. */
739 -+
740 -+ first_nonopt = last_nonopt = optind;
741 -+
742 -+ nextchar = NULL;
743 -+
744 -+ posixly_correct = getenv ("POSIXLY_CORRECT");
745 -+
746 -+ /* Determine how to handle the ordering of options and nonoptions. */
747 -+
748 -+ if (optstring[0] == '-')
749 -+ {
750 -+ ordering = RETURN_IN_ORDER;
751 -+ ++optstring;
752 -+ }
753 -+ else if (optstring[0] == '+')
754 -+ {
755 -+ ordering = REQUIRE_ORDER;
756 -+ ++optstring;
757 -+ }
758 -+ else if (posixly_correct != NULL)
759 -+ ordering = REQUIRE_ORDER;
760 -+ else
761 -+ ordering = PERMUTE;
762 -+
763 -+#ifdef _LIBC
764 -+ if (posixly_correct == NULL
765 -+ && argc == original_argc && argv == original_argv)
766 -+ {
767 -+ if (nonoption_flags_max_len == 0)
768 -+ {
769 -+ if (__getopt_nonoption_flags == NULL
770 -+ || __getopt_nonoption_flags[0] == '\0')
771 -+ nonoption_flags_max_len = -1;
772 -+ else
773 -+ {
774 -+ const char *orig_str = __getopt_nonoption_flags;
775 -+ int len = nonoption_flags_max_len = strlen (orig_str);
776 -+ if (nonoption_flags_max_len < argc)
777 -+ nonoption_flags_max_len = argc;
778 -+ __getopt_nonoption_flags =
779 -+ (char *) malloc (nonoption_flags_max_len);
780 -+ if (__getopt_nonoption_flags == NULL)
781 -+ nonoption_flags_max_len = -1;
782 -+ else
783 -+ memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
784 -+ '\0', nonoption_flags_max_len - len);
785 -+ }
786 -+ }
787 -+ nonoption_flags_len = nonoption_flags_max_len;
788 -+ }
789 -+ else
790 -+ nonoption_flags_len = 0;
791 -+#endif
792 -+
793 -+ return optstring;
794 -+}
795 -+
796 -+/* Scan elements of ARGV (whose length is ARGC) for option characters
797 -+ given in OPTSTRING.
798 -+
799 -+ If an element of ARGV starts with '-', and is not exactly "-" or "--",
800 -+ then it is an option element. The characters of this element
801 -+ (aside from the initial '-') are option characters. If `getopt'
802 -+ is called repeatedly, it returns successively each of the option characters
803 -+ from each of the option elements.
804 -+
805 -+ If `getopt' finds another option character, it returns that character,
806 -+ updating `optind' and `nextchar' so that the next call to `getopt' can
807 -+ resume the scan with the following option character or ARGV-element.
808 -+
809 -+ If there are no more option characters, `getopt' returns -1.
810 -+ Then `optind' is the index in ARGV of the first ARGV-element
811 -+ that is not an option. (The ARGV-elements have been permuted
812 -+ so that those that are not options now come last.)
813 -+
814 -+ OPTSTRING is a string containing the legitimate option characters.
815 -+ If an option character is seen that is not listed in OPTSTRING,
816 -+ return '?' after printing an error message. If you set `opterr' to
817 -+ zero, the error message is suppressed but we still return '?'.
818 -+
819 -+ If a char in OPTSTRING is followed by a colon, that means it wants an arg,
820 -+ so the following text in the same ARGV-element, or the text of the following
821 -+ ARGV-element, is returned in `optarg'. Two colons mean an option that
822 -+ wants an optional arg; if there is text in the current ARGV-element,
823 -+ it is returned in `optarg', otherwise `optarg' is set to zero.
824 -+
825 -+ If OPTSTRING starts with `-' or `+', it requests different methods of
826 -+ handling the non-option ARGV-elements.
827 -+ See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
828 -+
829 -+ Long-named options begin with `--' instead of `-'.
830 -+ Their names may be abbreviated as long as the abbreviation is unique
831 -+ or is an exact match for some defined option. If they have an
832 -+ argument, it follows the option name in the same ARGV-element, separated
833 -+ from the option name by a `=', or else the in next ARGV-element.
834 -+ When `getopt' finds a long-named option, it returns 0 if that option's
835 -+ `flag' field is nonzero, the value of the option's `val' field
836 -+ if the `flag' field is zero.
837 -+
838 -+ The elements of ARGV aren't really const, because we permute them.
839 -+ But we pretend they're const in the prototype to be compatible
840 -+ with other systems.
841 -+
842 -+ LONGOPTS is a vector of `struct option' terminated by an
843 -+ element containing a name which is zero.
844 -+
845 -+ LONGIND returns the index in LONGOPT of the long-named option found.
846 -+ It is only valid when a long-named option has been found by the most
847 -+ recent call.
848 -+
849 -+ If LONG_ONLY is nonzero, '-' as well as '--' can introduce
850 -+ long-named options. */
851 -+
852 -+#if 0
853 -+int
854 -+_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
855 -+ int argc;
856 -+ char *const *argv;
857 -+ const char *optstring;
858 -+ const struct option *longopts;
859 -+ int *longind;
860 -+ int long_only;
861 -+#endif
862 -+int
863 -+_getopt_internal (int argc,
864 -+ char *const *argv,
865 -+ const char *optstring,
866 -+ const struct option *longopts,
867 -+ int *longind,
868 -+ int long_only)
869 -+{
870 -+ optarg = NULL;
871 -+
872 -+ if (optind == 0 || !__getopt_initialized)
873 -+ {
874 -+ if (optind == 0)
875 -+ optind = 1; /* Don't scan ARGV[0], the program name. */
876 -+ optstring = _getopt_initialize (argc, argv, optstring);
877 -+ __getopt_initialized = 1;
878 -+ }
879 -+
880 -+ /* Test whether ARGV[optind] points to a non-option argument.
881 -+ Either it does not have option syntax, or there is an environment flag
882 -+ from the shell indicating it is not an option. The later information
883 -+ is only used when the used in the GNU libc. */
884 -+#ifdef _LIBC
885 -+# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
886 -+ || (optind < nonoption_flags_len \
887 -+ && __getopt_nonoption_flags[optind] == '1'))
888 -+#else
889 -+# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
890 -+#endif
891 -+
892 -+ if (nextchar == NULL || *nextchar == '\0')
893 -+ {
894 -+ /* Advance to the next ARGV-element. */
895 -+
896 -+ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
897 -+ moved back by the user (who may also have changed the arguments). */
898 -+ if (last_nonopt > optind)
899 -+ last_nonopt = optind;
900 -+ if (first_nonopt > optind)
901 -+ first_nonopt = optind;
902 -+
903 -+ if (ordering == PERMUTE)
904 -+ {
905 -+ /* If we have just processed some options following some non-options,
906 -+ exchange them so that the options come first. */
907 -+
908 -+ if (first_nonopt != last_nonopt && last_nonopt != optind)
909 -+ exchange ((char **) argv);
910 -+ else if (last_nonopt != optind)
911 -+ first_nonopt = optind;
912 -+
913 -+ /* Skip any additional non-options
914 -+ and extend the range of non-options previously skipped. */
915 -+
916 -+ while (optind < argc && NONOPTION_P)
917 -+ optind++;
918 -+ last_nonopt = optind;
919 -+ }
920 -+
921 -+ /* The special ARGV-element `--' means premature end of options.
922 -+ Skip it like a null option,
923 -+ then exchange with previous non-options as if it were an option,
924 -+ then skip everything else like a non-option. */
925 -+
926 -+ if (optind != argc && !strcmp (argv[optind], "--"))
927 -+ {
928 -+ optind++;
929 -+
930 -+ if (first_nonopt != last_nonopt && last_nonopt != optind)
931 -+ exchange ((char **) argv);
932 -+ else if (first_nonopt == last_nonopt)
933 -+ first_nonopt = optind;
934 -+ last_nonopt = argc;
935 -+
936 -+ optind = argc;
937 -+ }
938 -+
939 -+ /* If we have done all the ARGV-elements, stop the scan
940 -+ and back over any non-options that we skipped and permuted. */
941 -+
942 -+ if (optind == argc)
943 -+ {
944 -+ /* Set the next-arg-index to point at the non-options
945 -+ that we previously skipped, so the caller will digest them. */
946 -+ if (first_nonopt != last_nonopt)
947 -+ optind = first_nonopt;
948 -+ return -1;
949 -+ }
950 -+
951 -+ /* If we have come to a non-option and did not permute it,
952 -+ either stop the scan or describe it to the caller and pass it by. */
953 -+
954 -+ if (NONOPTION_P)
955 -+ {
956 -+ if (ordering == REQUIRE_ORDER)
957 -+ return -1;
958 -+ optarg = argv[optind++];
959 -+ return 1;
960 -+ }
961 -+
962 -+ /* We have found another option-ARGV-element.
963 -+ Skip the initial punctuation. */
964 -+
965 -+ nextchar = (argv[optind] + 1
966 -+ + (longopts != NULL && argv[optind][1] == '-'));
967 -+ }
968 -+
969 -+ /* Decode the current option-ARGV-element. */
970 -+
971 -+ /* Check whether the ARGV-element is a long option.
972 -+
973 -+ If long_only and the ARGV-element has the form "-f", where f is
974 -+ a valid short option, don't consider it an abbreviated form of
975 -+ a long option that starts with f. Otherwise there would be no
976 -+ way to give the -f short option.
977 -+
978 -+ On the other hand, if there's a long option "fubar" and
979 -+ the ARGV-element is "-fu", do consider that an abbreviation of
980 -+ the long option, just like "--fu", and not "-f" with arg "u".
981 -+
982 -+ This distinction seems to be the most useful approach. */
983 -+
984 -+ if (longopts != NULL
985 -+ && (argv[optind][1] == '-'
986 -+ || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
987 -+ {
988 -+ char *nameend;
989 -+ const struct option *p;
990 -+ const struct option *pfound = NULL;
991 -+ int exact = 0;
992 -+ int ambig = 0;
993 -+ int indfound = -1;
994 -+ int option_index;
995 -+
996 -+ for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
997 -+ /* Do nothing. */ ;
998 -+
999 -+ /* Test all long options for either exact match
1000 -+ or abbreviated matches. */
1001 -+ for (p = longopts, option_index = 0; p->name; p++, option_index++)
1002 -+ if (!strncmp (p->name, nextchar, nameend - nextchar))
1003 -+ {
1004 -+ if ((unsigned int) (nameend - nextchar)
1005 -+ == (unsigned int) strlen (p->name))
1006 -+ {
1007 -+ /* Exact match found. */
1008 -+ pfound = p;
1009 -+ indfound = option_index;
1010 -+ exact = 1;
1011 -+ break;
1012 -+ }
1013 -+ else if (pfound == NULL)
1014 -+ {
1015 -+ /* First nonexact match found. */
1016 -+ pfound = p;
1017 -+ indfound = option_index;
1018 -+ }
1019 -+ else
1020 -+ /* Second or later nonexact match found. */
1021 -+ ambig = 1;
1022 -+ }
1023 -+
1024 -+ if (ambig && !exact)
1025 -+ {
1026 -+ if (opterr)
1027 -+ fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
1028 -+ argv[0], argv[optind]);
1029 -+ nextchar += strlen (nextchar);
1030 -+ optind++;
1031 -+ optopt = 0;
1032 -+ return '?';
1033 -+ }
1034 -+
1035 -+ if (pfound != NULL)
1036 -+ {
1037 -+ option_index = indfound;
1038 -+ optind++;
1039 -+ if (*nameend)
1040 -+ {
1041 -+ /* Don't test has_arg with >, because some C compilers don't
1042 -+ allow it to be used on enums. */
1043 -+ if (pfound->has_arg)
1044 -+ optarg = nameend + 1;
1045 -+ else
1046 -+ {
1047 -+ if (opterr)
1048 -+ {
1049 -+ if (argv[optind - 1][1] == '-')
1050 -+ /* --option */
1051 -+ fprintf (stderr,
1052 -+ _("%s: option `--%s' doesn't allow an argument\n"),
1053 -+ argv[0], pfound->name);
1054 -+ else
1055 -+ /* +option or -option */
1056 -+ fprintf (stderr,
1057 -+ _("%s: option `%c%s' doesn't allow an argument\n"),
1058 -+ argv[0], argv[optind - 1][0], pfound->name);
1059 -+
1060 -+ nextchar += strlen (nextchar);
1061 -+
1062 -+ optopt = pfound->val;
1063 -+ return '?';
1064 -+ }
1065 -+ }
1066 -+ }
1067 -+ else if (pfound->has_arg == 1)
1068 -+ {
1069 -+ if (optind < argc)
1070 -+ optarg = argv[optind++];
1071 -+ else
1072 -+ {
1073 -+ if (opterr)
1074 -+ fprintf (stderr,
1075 -+ _("%s: option `%s' requires an argument\n"),
1076 -+ argv[0], argv[optind - 1]);
1077 -+ nextchar += strlen (nextchar);
1078 -+ optopt = pfound->val;
1079 -+ return optstring[0] == ':' ? ':' : '?';
1080 -+ }
1081 -+ }
1082 -+ nextchar += strlen (nextchar);
1083 -+ if (longind != NULL)
1084 -+ *longind = option_index;
1085 -+ if (pfound->flag)
1086 -+ {
1087 -+ *(pfound->flag) = pfound->val;
1088 -+ return 0;
1089 -+ }
1090 -+ return pfound->val;
1091 -+ }
1092 -+
1093 -+ /* Can't find it as a long option. If this is not getopt_long_only,
1094 -+ or the option starts with '--' or is not a valid short
1095 -+ option, then it's an error.
1096 -+ Otherwise interpret it as a short option. */
1097 -+ if (!long_only || argv[optind][1] == '-'
1098 -+ || my_index (optstring, *nextchar) == NULL)
1099 -+ {
1100 -+ if (opterr)
1101 -+ {
1102 -+ if (argv[optind][1] == '-')
1103 -+ /* --option */
1104 -+ fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
1105 -+ argv[0], nextchar);
1106 -+ else
1107 -+ /* +option or -option */
1108 -+ fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
1109 -+ argv[0], argv[optind][0], nextchar);
1110 -+ }
1111 -+ nextchar = (char *) "";
1112 -+ optind++;
1113 -+ optopt = 0;
1114 -+ return '?';
1115 -+ }
1116 -+ }
1117 -+
1118 -+ /* Look at and handle the next short option-character. */
1119 -+
1120 -+ {
1121 -+ char c = *nextchar++;
1122 -+ char *temp = my_index (optstring, c);
1123 -+
1124 -+ /* Increment `optind' when we start to process its last character. */
1125 -+ if (*nextchar == '\0')
1126 -+ ++optind;
1127 -+
1128 -+ if (temp == NULL || c == ':')
1129 -+ {
1130 -+ if (opterr)
1131 -+ {
1132 -+ if (posixly_correct)
1133 -+ /* 1003.2 specifies the format of this message. */
1134 -+ fprintf (stderr, _("%s: illegal option -- %c\n"),
1135 -+ argv[0], c);
1136 -+ else
1137 -+ fprintf (stderr, _("%s: invalid option -- %c\n"),
1138 -+ argv[0], c);
1139 -+ }
1140 -+ optopt = c;
1141 -+ return '?';
1142 -+ }
1143 -+ /* Convenience. Treat POSIX -W foo same as long option --foo */
1144 -+ if (temp[0] == 'W' && temp[1] == ';')
1145 -+ {
1146 -+ char *nameend;
1147 -+ const struct option *p;
1148 -+ const struct option *pfound = NULL;
1149 -+ int exact = 0;
1150 -+ int ambig = 0;
1151 -+ int indfound = 0;
1152 -+ int option_index;
1153 -+
1154 -+ /* This is an option that requires an argument. */
1155 -+ if (*nextchar != '\0')
1156 -+ {
1157 -+ optarg = nextchar;
1158 -+ /* If we end this ARGV-element by taking the rest as an arg,
1159 -+ we must advance to the next element now. */
1160 -+ optind++;
1161 -+ }
1162 -+ else if (optind == argc)
1163 -+ {
1164 -+ if (opterr)
1165 -+ {
1166 -+ /* 1003.2 specifies the format of this message. */
1167 -+ fprintf (stderr, _("%s: option requires an argument -- %c\n"),
1168 -+ argv[0], c);
1169 -+ }
1170 -+ optopt = c;
1171 -+ if (optstring[0] == ':')
1172 -+ c = ':';
1173 -+ else
1174 -+ c = '?';
1175 -+ return c;
1176 -+ }
1177 -+ else
1178 -+ /* We already incremented `optind' once;
1179 -+ increment it again when taking next ARGV-elt as argument. */
1180 -+ optarg = argv[optind++];
1181 -+
1182 -+ /* optarg is now the argument, see if it's in the
1183 -+ table of longopts. */
1184 -+
1185 -+ for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++)
1186 -+ /* Do nothing. */ ;
1187 -+
1188 -+ /* Test all long options for either exact match
1189 -+ or abbreviated matches. */
1190 -+ for (p = longopts, option_index = 0; p->name; p++, option_index++)
1191 -+ if (!strncmp (p->name, nextchar, nameend - nextchar))
1192 -+ {
1193 -+ if ((unsigned int) (nameend - nextchar) == strlen (p->name))
1194 -+ {
1195 -+ /* Exact match found. */
1196 -+ pfound = p;
1197 -+ indfound = option_index;
1198 -+ exact = 1;
1199 -+ break;
1200 -+ }
1201 -+ else if (pfound == NULL)
1202 -+ {
1203 -+ /* First nonexact match found. */
1204 -+ pfound = p;
1205 -+ indfound = option_index;
1206 -+ }
1207 -+ else
1208 -+ /* Second or later nonexact match found. */
1209 -+ ambig = 1;
1210 -+ }
1211 -+ if (ambig && !exact)
1212 -+ {
1213 -+ if (opterr)
1214 -+ fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
1215 -+ argv[0], argv[optind]);
1216 -+ nextchar += strlen (nextchar);
1217 -+ optind++;
1218 -+ return '?';
1219 -+ }
1220 -+ if (pfound != NULL)
1221 -+ {
1222 -+ option_index = indfound;
1223 -+ if (*nameend)
1224 -+ {
1225 -+ /* Don't test has_arg with >, because some C compilers don't
1226 -+ allow it to be used on enums. */
1227 -+ if (pfound->has_arg)
1228 -+ optarg = nameend + 1;
1229 -+ else
1230 -+ {
1231 -+ if (opterr)
1232 -+ fprintf (stderr, _("\
1233 -+%s: option `-W %s' doesn't allow an argument\n"),
1234 -+ argv[0], pfound->name);
1235 -+
1236 -+ nextchar += strlen (nextchar);
1237 -+ return '?';
1238 -+ }
1239 -+ }
1240 -+ else if (pfound->has_arg == 1)
1241 -+ {
1242 -+ if (optind < argc)
1243 -+ optarg = argv[optind++];
1244 -+ else
1245 -+ {
1246 -+ if (opterr)
1247 -+ fprintf (stderr,
1248 -+ _("%s: option `%s' requires an argument\n"),
1249 -+ argv[0], argv[optind - 1]);
1250 -+ nextchar += strlen (nextchar);
1251 -+ return optstring[0] == ':' ? ':' : '?';
1252 -+ }
1253 -+ }
1254 -+ nextchar += strlen (nextchar);
1255 -+ if (longind != NULL)
1256 -+ *longind = option_index;
1257 -+ if (pfound->flag)
1258 -+ {
1259 -+ *(pfound->flag) = pfound->val;
1260 -+ return 0;
1261 -+ }
1262 -+ return pfound->val;
1263 -+ }
1264 -+ nextchar = NULL;
1265 -+ return 'W'; /* Let the application handle it. */
1266 -+ }
1267 -+ if (temp[1] == ':')
1268 -+ {
1269 -+ if (temp[2] == ':')
1270 -+ {
1271 -+ /* This is an option that accepts an argument optionally. */
1272 -+ if (*nextchar != '\0')
1273 -+ {
1274 -+ optarg = nextchar;
1275 -+ optind++;
1276 -+ }
1277 -+ else
1278 -+ optarg = NULL;
1279 -+ nextchar = NULL;
1280 -+ }
1281 -+ else
1282 -+ {
1283 -+ /* This is an option that requires an argument. */
1284 -+ if (*nextchar != '\0')
1285 -+ {
1286 -+ optarg = nextchar;
1287 -+ /* If we end this ARGV-element by taking the rest as an arg,
1288 -+ we must advance to the next element now. */
1289 -+ optind++;
1290 -+ }
1291 -+ else if (optind == argc)
1292 -+ {
1293 -+ if (opterr)
1294 -+ {
1295 -+ /* 1003.2 specifies the format of this message. */
1296 -+ fprintf (stderr,
1297 -+ _("%s: option requires an argument -- %c\n"),
1298 -+ argv[0], c);
1299 -+ }
1300 -+ optopt = c;
1301 -+ if (optstring[0] == ':')
1302 -+ c = ':';
1303 -+ else
1304 -+ c = '?';
1305 -+ }
1306 -+ else
1307 -+ /* We already incremented `optind' once;
1308 -+ increment it again when taking next ARGV-elt as argument. */
1309 -+ optarg = argv[optind++];
1310 -+ nextchar = NULL;
1311 -+ }
1312 -+ }
1313 -+ return c;
1314 -+ }
1315 -+}
1316 -+
1317 -+/*
1318 -+int
1319 -+getopt (argc, argv, optstring)
1320 -+ int argc;
1321 -+ char *const *argv;
1322 -+ const char *optstring;
1323 -+{
1324 -+ return _getopt_internal (argc, argv, optstring,
1325 -+ (const struct option *) 0,
1326 -+ (int *) 0,
1327 -+ 0);
1328 -+}
1329 -+*/
1330 -+
1331 -+#endif /* Not ELIDE_CODE. */
1332 -+/* ******************** ...getopt.c ******************** */
1333 -+
1334 -+
1335 -+
1336 -+/* Comment out all this code if we are using the GNU C Library, and are not
1337 -+ actually compiling the library itself. This code is part of the GNU C
1338 -+ Library, but also included in many other GNU distributions. Compiling
1339 -+ and linking in this code is a waste when using the GNU C library
1340 -+ (especially if it is a shared library). Rather than having every GNU
1341 -+ program understand `configure --with-gnu-libc' and omit the object files,
1342 -+ it is simpler to just do this in the source for each such file. */
1343 -+
1344 -+#define GETOPT_INTERFACE_VERSION 2
1345 -+#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
1346 -+#include <gnu-versions.h>
1347 -+#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
1348 -+#define ELIDE_CODE
1349 -+#endif
1350 -+#endif
1351 -+
1352 -+#ifndef ELIDE_CODE
1353 -+
1354 -+
1355 -+/* This needs to come after some library #include
1356 -+ to get __GNU_LIBRARY__ defined. */
1357 -+#ifdef __GNU_LIBRARY__
1358 -+#include <stdlib.h>
1359 -+#endif
1360 -+
1361 -+#ifndef NULL
1362 -+#define NULL 0
1363 -+#endif
1364 -+
1365 -+/* K&R declarations!? C'mon... */
1366 -+/* Just say no to all this gymnastics */
1367 -+#if 0
1368 -+int
1369 -+getopt_long (argc, argv, options, long_options, opt_index)
1370 -+ int argc;
1371 -+ char *const *argv;
1372 -+ const char *options;
1373 -+ const struct option *long_options;
1374 -+ int *opt_index;
1375 -+#endif
1376 -+int getopt_long (int argc,
1377 -+ char *const *argv,
1378 -+ const char *options,
1379 -+ const struct option *long_options,
1380 -+ int *opt_index)
1381 -+{
1382 -+ return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
1383 -+}
1384 -+
1385 -+/* Like getopt_long, but '-' as well as '--' can indicate a long option.
1386 -+ If an option that starts with '-' (not '--') doesn't match a long option,
1387 -+ but does match a short option, it is parsed as a short option
1388 -+ instead. */
1389 -+
1390 -+#if 0
1391 -+int
1392 -+getopt_long_only (argc, argv, options, long_options, opt_index)
1393 -+ int argc;
1394 -+ char *const *argv;
1395 -+ const char *options;
1396 -+ const struct option *long_options;
1397 -+ int *opt_index;
1398 -+#endif
1399 -+int
1400 -+getopt_long_only (int argc,
1401 -+ char *const *argv,
1402 -+ const char *options,
1403 -+ const struct option *long_options,
1404 -+ int *opt_index)
1405 -+{
1406 -+ return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
1407 -+}
1408 -+
1409 -+
1410 -+#endif /* Not ELIDE_CODE. */
1411 -+
1412 -+#ifdef TEST
1413 -+
1414 -+#include <stdio.h>
1415 -+
1416 -+int
1417 -+main (argc, argv)
1418 -+ int argc;
1419 -+ char **argv;
1420 -+{
1421 -+ int c;
1422 -+ int digit_optind = 0;
1423 -+
1424 -+ while (1)
1425 -+ {
1426 -+ int this_option_optind = optind ? optind : 1;
1427 -+ int option_index = 0;
1428 -+ static struct option long_options[] =
1429 -+ {
1430 -+ {"add", 1, 0, 0},
1431 -+ {"append", 0, 0, 0},
1432 -+ {"delete", 1, 0, 0},
1433 -+ {"verbose", 0, 0, 0},
1434 -+ {"create", 0, 0, 0},
1435 -+ {"file", 1, 0, 0},
1436 -+ {0, 0, 0, 0}
1437 -+ };
1438 -+
1439 -+ c = getopt_long (argc, argv, "abc:d:0123456789",
1440 -+ long_options, &option_index);
1441 -+ if (c == -1)
1442 -+ break;
1443 -+
1444 -+ switch (c)
1445 -+ {
1446 -+ case 0:
1447 -+ printf ("option %s", long_options[option_index].name);
1448 -+ if (optarg)
1449 -+ printf (" with arg %s", optarg);
1450 -+ printf ("\n");
1451 -+ break;
1452 -+
1453 -+ case '0':
1454 -+ case '1':
1455 -+ case '2':
1456 -+ case '3':
1457 -+ case '4':
1458 -+ case '5':
1459 -+ case '6':
1460 -+ case '7':
1461 -+ case '8':
1462 -+ case '9':
1463 -+ if (digit_optind != 0 && digit_optind != this_option_optind)
1464 -+ printf ("digits occur in two different argv-elements.\n");
1465 -+ digit_optind = this_option_optind;
1466 -+ printf ("option %c\n", c);
1467 -+ break;
1468 -+
1469 -+ case 'a':
1470 -+ printf ("option a\n");
1471 -+ break;
1472 -+
1473 -+ case 'b':
1474 -+ printf ("option b\n");
1475 -+ break;
1476 -+
1477 -+ case 'c':
1478 -+ printf ("option c with value `%s'\n", optarg);
1479 -+ break;
1480 -+
1481 -+ case 'd':
1482 -+ printf ("option d with value `%s'\n", optarg);
1483 -+ break;
1484 -+
1485 -+ case '?':
1486 -+ break;
1487 -+
1488 -+ default:
1489 -+ printf ("?? getopt returned character code 0%o ??\n", c);
1490 -+ }
1491 -+ }
1492 -+
1493 -+ if (optind < argc)
1494 -+ {
1495 -+ printf ("non-option ARGV-elements: ");
1496 -+ while (optind < argc)
1497 -+ printf ("%s ", argv[optind++]);
1498 -+ printf ("\n");
1499 -+ }
1500 -+
1501 -+ exit (0);
1502 -+}
1503 -+
1504 -+#endif /* TEST */
1505 -+
1506 -+#endif /* #ifndef HAVE_GETOPT_LONG */
1507 -diff -ruN debianutils-4.orig/getopt_long.h debianutils-4/getopt_long.h
1508 ---- debianutils-4.orig/getopt_long.h 1970-01-01 01:00:00.000000000 +0100
1509 -+++ debianutils-4/getopt_long.h 2007-04-02 11:47:57.000000000 +0200
1510 -@@ -0,0 +1,179 @@
1511 -+/* Declarations for getopt.
1512 -+ Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 2000
1513 -+ Free Software Foundation, Inc.
1514 -+
1515 -+ NOTE: The canonical source of this file is maintained with the GNU C Library.
1516 -+ Bugs can be reported to bug-glibc@×××.org.
1517 -+
1518 -+ This program is free software; you can redistribute it and/or modify it
1519 -+ under the terms of the GNU General Public License as published by the
1520 -+ Free Software Foundation; either version 2, or (at your option) any
1521 -+ later version.
1522 -+
1523 -+ This program is distributed in the hope that it will be useful,
1524 -+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1525 -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1526 -+ GNU General Public License for more details.
1527 -+
1528 -+ You should have received a copy of the GNU General Public License
1529 -+ along with this program; if not, write to the Free Software
1530 -+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
1531 -+ USA. */
1532 -+
1533 -+#ifndef _GETOPT_LONG
1534 -+#define _GETOPT_LONG 1
1535 -+
1536 -+#include <config.h>
1537 -+
1538 -+#ifndef HAVE_GETOPT_LONG
1539 -+
1540 -+#if HAVE_UNISTD_H
1541 -+/* Declares getopt, if present */
1542 -+#include <unistd.h>
1543 -+#endif
1544 -+
1545 -+#ifdef __cplusplus
1546 -+extern "C" {
1547 -+#endif
1548 -+
1549 -+/* We're building this with a C++ compiler, essentially. Such
1550 -+ compilers are not required to define __STDC__, but the path we
1551 -+ should follow, below, is indeed that marked by __STDC__. We don't
1552 -+ want to force a definition of __STDC__ (though that works), because
1553 -+ (a) that feels bad, and (b) some compilers perfectly reasonable
1554 -+ complain bitterly about it. So define THIS_IS__STDC__, and replace
1555 -+ occurrences of __STDC__ throughout with that.
1556 -+
1557 -+ That means that all of the occurrences of THIS_IS__STDC__ in this
1558 -+ file and in getopt_long.c are redundant, but I'm leaving them here
1559 -+ in case it becomes necessary to do cleverer things with it than
1560 -+ simply define it to be 1, and also as a sort of warped documentation. */
1561 -+#define THIS_IS__STDC__ 1
1562 -+
1563 -+#if !HAVE_DECL_GETOPT
1564 -+/* For communication from `getopt' to the caller.
1565 -+ When `getopt' finds an option that takes an argument,
1566 -+ the argument value is returned here.
1567 -+ Also, when `ordering' is RETURN_IN_ORDER,
1568 -+ each non-option ARGV-element is returned here. */
1569 -+
1570 -+extern char *optarg;
1571 -+
1572 -+/* Index in ARGV of the next element to be scanned.
1573 -+ This is used for communication to and from the caller
1574 -+ and for communication between successive calls to `getopt'.
1575 -+
1576 -+ On entry to `getopt', zero means this is the first call; initialize.
1577 -+
1578 -+ When `getopt' returns -1, this is the index of the first of the
1579 -+ non-option elements that the caller should itself scan.
1580 -+
1581 -+ Otherwise, `optind' communicates from one call to the next
1582 -+ how much of ARGV has been scanned so far. */
1583 -+
1584 -+extern int optind;
1585 -+
1586 -+/* Callers store zero here to inhibit the error message `getopt' prints
1587 -+ for unrecognized options. */
1588 -+
1589 -+extern int opterr;
1590 -+
1591 -+/* Set to an option character which was unrecognized. */
1592 -+
1593 -+extern int optopt;
1594 -+
1595 -+#endif /* ifndef HAVE_DECL_GETOPT */
1596 -+
1597 -+#if !HAVE_DECL_GETOPT_LONG
1598 -+/* Describe the long-named options requested by the application.
1599 -+ The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
1600 -+ of `struct option' terminated by an element containing a name which is
1601 -+ zero.
1602 -+
1603 -+ The field `has_arg' is:
1604 -+ no_argument (or 0) if the option does not take an argument,
1605 -+ required_argument (or 1) if the option requires an argument,
1606 -+ optional_argument (or 2) if the option takes an optional argument.
1607 -+
1608 -+ If the field `flag' is not NULL, it points to a variable that is set
1609 -+ to the value given in the field `val' when the option is found, but
1610 -+ left unchanged if the option is not found.
1611 -+
1612 -+ To have a long-named option do something other than set an `int' to
1613 -+ a compiled-in constant, such as set a value from `optarg', set the
1614 -+ option's `flag' field to zero and its `val' field to a nonzero
1615 -+ value (the equivalent single-letter option character, if there is
1616 -+ one). For long options that have a zero `flag' field, `getopt'
1617 -+ returns the contents of the `val' field. */
1618 -+
1619 -+struct option
1620 -+{
1621 -+#if defined (THIS_IS__STDC__) && THIS_IS__STDC__
1622 -+ const char *name;
1623 -+#else
1624 -+ char *name;
1625 -+#endif
1626 -+ /* has_arg can't be an enum because some compilers complain about
1627 -+ type mismatches in all the code that assumes it is an int. */
1628 -+ int has_arg;
1629 -+ int *flag;
1630 -+ int val;
1631 -+};
1632 -+
1633 -+/* Names for the values of the `has_arg' field of `struct option'. */
1634 -+
1635 -+#define no_argument 0
1636 -+#define required_argument 1
1637 -+#define optional_argument 2
1638 -+
1639 -+#endif /* #if !HAVE_DECL_GETOPT_LONG */
1640 -+
1641 -+#if defined (THIS_IS__STDC__) && THIS_IS__STDC__
1642 -+/* HAVE_DECL_* is a three-state macro: undefined, 0 or 1. If it is
1643 -+ undefined, we haven't run the autoconf check so provide the
1644 -+ declaration without arguments. If it is 0, we checked and failed
1645 -+ to find the declaration so provide a fully prototyped one. If it
1646 -+ is 1, we found it so don't provide any declaration at all. */
1647 -+#if defined (__GNU_LIBRARY__) || (defined (HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT)
1648 -+/* Many other libraries have conflicting prototypes for getopt, with
1649 -+ differences in the consts, in stdlib.h. To avoid compilation
1650 -+ errors, only prototype getopt for the GNU C library. */
1651 -+extern int getopt (int argc, char *const *argv, const char *shortopts);
1652 -+#else /* not __GNU_LIBRARY__ */
1653 -+# if !defined (HAVE_DECL_GETOPT)
1654 -+extern int getopt ();
1655 -+# endif
1656 -+#endif /* __GNU_LIBRARY__ */
1657 -+#if !HAVE_DECL_GETOPT_LONG
1658 -+extern int getopt_long (int argc, char *const *argv, const char *shortopts,
1659 -+ const struct option *longopts, int *longind);
1660 -+extern int getopt_long_only (int argc, char *const *argv,
1661 -+ const char *shortopts,
1662 -+ const struct option *longopts, int *longind);
1663 -+
1664 -+/* Internal only. Users should not call this directly. */
1665 -+extern int _getopt_internal (int argc, char *const *argv,
1666 -+ const char *shortopts,
1667 -+ const struct option *longopts, int *longind,
1668 -+ int long_only);
1669 -+#endif /* HAVE_DECL_GETOPT_LONG */
1670 -+#else /* not THIS_IS__STDC__ */
1671 -+#if !HAVE_DECL_GETOPT
1672 -+extern int getopt ();
1673 -+#endif /* HAVE_DECL_GETOPT */
1674 -+#if !HAVE_DECL_GETOPT_LONG
1675 -+extern int getopt_long ();
1676 -+extern int getopt_long_only ();
1677 -+
1678 -+extern int _getopt_internal ();
1679 -+#endif /* HAVE_DECL_GETOPT_LONG */
1680 -+#endif /* THIS_IS__STDC__ */
1681 -+
1682 -+
1683 -+#ifdef __cplusplus
1684 -+}
1685 -+#endif
1686 -+
1687 -+#endif /* !HAVE_GETOPT_LONG */
1688 -+
1689 -+#endif /* getopt_long.h */