GOption: stop calling getopt()
authorRyan Lortie <desrt@desrt.ca>
Mon, 20 Oct 2014 12:28:10 +0000 (14:28 +0200)
committerRyan Lortie <desrt@desrt.ca>
Mon, 20 Oct 2014 12:34:52 +0000 (14:34 +0200)
commit817f82da6c92d8a2ef0e0582037fd2bbd248798c
tree6db051aebe6ba85f55b020c2a9160737ecdda94f
parente9b7c702404929c415320545905dcf008c9cd666
GOption: stop calling getopt()

We called getopt() to try to find out of the platform on which we are
running defaults to strict POSIX-style argument handling (ie: flags
following the first filename are considered as further filenames rather
than flags).

This is the default case on BSDs, for example.  It is also the case on
GNU systems with the POSIXLY_CORRECT environment variable set.

Unfortunately many of our tools rely on being able to accept commandline
arguments in the non-strict ordering and the code for making these calls
is spread widely (for example in Makefile fragments invoking some of our
build tools).

For this reason we need to revert the getopt() check and only enable
strict POSIX mode in the case that the application explicitly opts into
it using the _set_strict_posix() API.

This also fixs a failure to build on Windows due to missing getopt().

https://bugzilla.gnome.org/show_bug.cgi?id=723160
glib/goption.c