]> git.ipfire.org Git - thirdparty/krb5.git/commit
Fix option parsing on Windows 778/head
authorGreg Hudson <ghudson@mit.edu>
Wed, 16 May 2018 04:52:08 +0000 (21:52 -0700)
committerGreg Hudson <ghudson@mit.edu>
Tue, 12 Jun 2018 15:39:36 +0000 (11:39 -0400)
commit63246cf3513a0e8bdfc734db985af14c8c5170c5
treeec6e47586e2b45aa579f7670e57035b9e459d769
parent03531a41298d63cc12f99e70172abd6948a679e2
Fix option parsing on Windows

Commit 8f9ade8ec50cde1176411085294f85ecfb2820a4 (ticket 8391) moved
the built-in getopt() and getopt_long() implementations from a static
library in util/windows to util/support, where (on Windows) it is
built into k5sprt32.dll or k5sprt64.dll.  The getopt() interface uses
global variables opterr, optind, optopt, and optarg, each renamed via
macro to have a k5_ prefix when we use the built-in implementation.
Data objects exported from DLLs need special handling in Windows; they
must be marked as DATA in the DLL .def file, and they must be declared
with "__declspec(dllimport)" in calling code.  Without this handling,
optind begins with a garbage value and getopt_long() returns -1
immediately, so client programs always behave as if they have no
arguments.

Stop unnecessarily declaring optind and optarg in client programs.
Declare the getopt() global variables with __declspec(dllimport) on
Windows, except when compiling getopt.c itself.  When creating
libkrb5support.exports on Windows (this file is later used by
lib/Makefile.in to create k5sprt32.def), add a DATA tag to the data
objects.

ticket: 8684 (new)
tags: pullup
target_version: 1.16-next
target_version: 1.15-next
src/clients/kdestroy/kdestroy.c
src/clients/klist/klist.c
src/clients/kswitch/kswitch.c
src/clients/kvno/kvno.c
src/include/k5-platform.h
src/util/support/Makefile.in
src/util/support/getopt.c