Subject: broken getopt() in libnbcompat
To: None <tech-pkg@NetBSD.org>
From: Alan Barrett <firstname.lastname@example.org>
Date: 05/03/2005 13:06:42
(was Subject: Re: textproc/nbsed broken on non-NetBSD systems)
On Fri, 29 Apr 2005, Robert Lillack wrote:
> Actually I got to revoke this. nbsed did use libnbcompat's getopt.
> And that's the broken one (correct me, if I'm wrong, it's late here):
OK, I think I see the problem.
is almost identical to src/lib/libc/stdlib/getopt_long.c. These files
contains implementations of both getopt() and getopt_long(), both those
functions end up in libnbcompat, and both functions include the (IMHO
broken) gnuish behaviour. However, the getopt() in libc does not come
from that source file, it comes from src/lib/libc/stdlib/getopt.c, and
it does not include the gnuish behaviour.
I suggest changing the getopt() in libnbcompat to match the behaviour of
the getopt() in libc. I see several possible ways to do this:
* copy the getopt.c from libc to libnbcompat.
* pass a new flag to getopt_internal() in libnbcompat to tell it
whether it is being called from getopt() or from getopt_long(), and
to make it modify its behaviour as appropriate.
* as above, but also do the same work in libc, and remove the getopt.c
from libc so that we don't have a problem in future with two versions
of getopt() being out of sync.
--apb (Alan Barrett)