GOption: add strict posix mode
authorRyan Lortie <desrt@desrt.ca>
Mon, 27 Jan 2014 15:42:23 +0000 (15:42 +0000)
committerLars Uebernickel <lars.uebernickel@canonical.com>
Wed, 15 Oct 2014 21:37:45 +0000 (23:37 +0200)
commitae52ab3d1170a393b0b734e9b9b37c3f107a7c03
tree51323e6babd77d7d640aaa72a70e60f7d2def7db
parentf2786908a8858ec9d063e8fae7e4b2d8d612b682
GOption: add strict posix mode

Add a "posixly correct" mode to GOption to stop parsing arguments as
soon as the first non-option argument is encountered.

We determine the default value on the basis of duplicating the behaviour
of the system getopt() implementation (which we directly check the
behaviour of at runtime).  On GNU systems this allows the user to modify
our behaviour using POSIXLY_CORRECT.

The user can change the value by g_option_context_set_strict_posix(),
which might be useful for some usecases of GOptionContext (as mentioned
in the doc string of this new function).

https://bugzilla.gnome.org/show_bug.cgi?id=723160
glib/goption.c
glib/goption.h
glib/tests/option-context.c