Fix error handling in port's getopt_long() for missing argument

In the long option error path, the code previously returned BADARG
immediately when optstring[0] == ':' for a missing required argument,
without advancing "optind" or resetting "place".  This error handling
was inconsistent with the short option path, where both updates are
performed before returning BADARG (and inconsistent with libc,
additionally..).

This affects platforms where our port version of getopt_long() is used,
a concept that should be limited to WIN32 these days.  An argument could
be made in favor of a backpatch, but this could lead to a slight
different error handling, for a report that would only show up when
using incorrect option combinations.

Author: Japin Li <[email protected]>
Discussion: 
https://postgr.es/m/sy7pr01mb10921af81f18a8bcfa06388beb6...@sy7pr01mb10921.ausprd01.prod.outlook.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/745becce3321267a4530af286433d1dc6f043360

Modified Files
--------------
src/port/getopt_long.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

Reply via email to