Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/lib/libc/stdlib Pull up rev. 1.8:



details:   https://anonhg.NetBSD.org/src/rev/5125964384c9
branches:  netbsd-1-5
changeset: 489241:5125964384c9
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Aug 25 17:17:35 2000 +0000

description:
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.

diffstat:

 lib/libc/stdlib/getopt_long.c |  12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diffs (33 lines):

diff -r 6da760862938 -r 5125964384c9 lib/libc/stdlib/getopt_long.c
--- a/lib/libc/stdlib/getopt_long.c     Fri Aug 25 03:05:19 2000 +0000
+++ b/lib/libc/stdlib/getopt_long.c     Fri Aug 25 17:17:35 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getopt_long.c,v 1.6 2000/06/09 21:35:53 nathanw Exp $  */
+/*     $NetBSD: getopt_long.c,v 1.6.2.1 2000/08/25 17:17:35 thorpej Exp $      */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getopt_long.c,v 1.6 2000/06/09 21:35:53 nathanw Exp $");
+__RCSID("$NetBSD: getopt_long.c,v 1.6.2.1 2000/08/25 17:17:35 thorpej Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -181,6 +181,14 @@
 
        optarg = NULL;
 
+       /*
+        * XXX Some programs (like rsyncd) expect to be able to
+        * XXX re-initialize optind to 0 and have getopt_long(3)
+        * XXX properly function again.  Work around this braindamage.
+        */
+       if (optind == 0)
+               optind = 1;
+
        if (optreset)
                nonopt_start = nonopt_end = -1;
 start:



Home | Main Index | Thread Index | Old Index