[Top][All Lists]

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

[Bug-gnulib] Re: getopt trouble on uClibc systems

From: Simon Josefsson
Subject: [Bug-gnulib] Re: getopt trouble on uClibc systems
Date: Tue, 13 Jul 2004 19:50:36 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

Paul Eggert <address@hidden> writes:

> Simon Josefsson <address@hidden> writes:
>> How about making gl_GETOPT test for _getopt_long_only_r too, instead?
> That sounds a bit extreme.  glibc doesn't export _getopt_long_only_r
> (it uses linker magic to prevent it), so it would cause (say) "cp" to
> use its own copy of getopt, even though it doesn't need
> _getopt_long_only_r.

Ah, right.

>> doesn't it seem like _getopt_long_only_r should be renamed to
>> getopt_long_only_r, if applications are supposed to be using it at
>> all?
> Only argp uses _getopt_long_only_r, and argp is part of glibc, so it's
> not a good example for why getopt_long_only_r should be public.

Still, if this is the only thing standing in the way of making argp
and getopt two truly separate modular pieces, perhaps it is worth
fixing getopt in some way to make argp only depend on public

Having thread friendly interfaces (*_r) seems to be rather common.
Although the above function is still not that thread friendly, the
global variables opterr, optind etc are still used.  Perhaps that
could be fixed, too, and a real properly thread safe getopt*_r public
API could be added.

> With this in mind I'm becoming inclined to put in a special hack for
> argp here....

Yes, if argp depend on non-public interfaces from a module, I think it
is fair to require it do something ugly.  Maybe the revised M4 below
would work?  The argp module would invoke gl_GETOPT_SUBSTITUTE (and,
perhaps, gl_PREREQ_GETOPT).  Untested.


# getopt.m4 serial 3
dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License.  As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.

# The getopt module assume you want GNU getopt, with getopt_long etc,
# rather than vanilla POSIX getopt.  This means your your code should
# always include <getopt.h> for the getopt prototypes.

  AC_DEFINE([optarg], [rpl_optarg],
    [Define to rpl_optarg if the replacement variable should be used.])
  AC_DEFINE([optind], [rpl_optind],
    [Define to rpl_optind if the replacement variable should be used.])
  AC_DEFINE([optopt], [rpl_optopt],
    [Define to rpl_optopt if the replacement variable should be used.])
  AC_DEFINE([getopt], [rpl_getopt],
    [Define to rpl_getopt if the replacement function should be used.])
  AC_DEFINE([getopt_long], [rpl_getopt_long],
    [Define to rpl_getopt_long if the replacement function should be used.])
  AC_DEFINE([getopt_long_only], [rpl_getopt_long_only],
    [Define to rpl_getopt_long_only if the replacement function should be 


  AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h])
  AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h])

  if test -n "$GETOPT_H"; then

# Prerequisites of lib/getopt*.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]