[m-rev.] for review: Check availability of getopt() directly.

Peter Wang novalazy at gmail.com
Sat Jun 1 14:04:53 AEST 2019


On Fri, 31 May 2019 19:26:02 +1000 (AEST), Julien Fischer <jfischer at opturion.com> wrote:
> > +# Link in local copy of getopt() only if required.
> > +# XXX The files in runtime/GETOPT may not compile cleanly with modern
> > +# compilers. We should replace it with another implementation.
> 
> We need to replace them (certainly the one in runtime/mercury_getopt.c)
> for licensing reasons anyway.

How about this implementation?

    https://github.com/kubo/ya_getopt

It has a simple permissive licence and the code looks okay (at a glance).
It comes with a test script that checks if the implementation matches
the GNU implementation. On my system only ya_getopt_long_only() does NOT
exactly match getopt_long_only(); it may be that the GNU implementation
changed. We don't use getopt_long_only() anyway.

Other possibilities:

  - NetBSD/OpenBSD/FreeBSD getopt
  - musl getopt
  - newlib getopt
  - https://github.com/kimgr/getopt_port/

Some of them have longer licences that would need to be reproduced.

Peter


More information about the reviews mailing list