diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-12-26 18:46:10 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-12-27 02:47:04 +0000 |
commit | 4536271c0a8105b8a84a6b29200faf5477854b26 (patch) | |
tree | 4775c2837306f541efbab070df7f12b712035f99 /tshark.c | |
parent | 0a0ce2b78f4c537e7c667080cc00181884c97057 (diff) | |
download | wireshark-4536271c0a8105b8a84a6b29200faf5477854b26.tar.gz wireshark-4536271c0a8105b8a84a6b29200faf5477854b26.tar.bz2 wireshark-4536271c0a8105b8a84a6b29200faf5477854b26.zip |
Don't use a leading - in getopt_long() option strings.
The behavior of a leading - is platform-dependent. It also means that
non-option arguments are treated in a fashion that we're not handling,
so capture filters given as non-option arguments at the end of the
command line don't work. (The Linux getopt() man page says that a
leading - "is used by programs that were written to expect options and
other argv-elements in any order and that care about the ordering of the
two." We are not such a program.)
Change-Id: I5610cf90a8218d48f7516abacc367e0affa3b549
Based-On-A-Change-From: Peter Hatina <phatina@redhat.com>
Reviewed-on: https://code.wireshark.org/review/6071
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'tshark.c')
-rw-r--r-- | tshark.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -995,7 +995,8 @@ main(int argc, char *argv[]) gchar *output_only = NULL; /* - * The leading - ensures that getopt_long() does not permute the argv[] entries. + * The leading + ensures that getopt_long() does not permute the argv[] + * entries. * * We have to make sure that the first getopt_long() preserves the content * of argv[] for the subsequent getopt_long() call. @@ -1005,10 +1006,14 @@ main(int argc, char *argv[]) * platforms, and so that, if we ever need to process a long argument before * doing further initialization, we can do so. * - * XXX - the behavior of a leading - is platform-dependent, so we shouldn't - * use it. + * Glibc and Solaris libc document that a leading + disables permutation + * of options, regardless of whether POSIXLY_CORRECT is set or not; *BSD + * and OS X don't document it, but do so anyway. + * + * We do *not* use a leading - because the behavior of a leading - is + * platform-dependent. */ -#define OPTSTRING "-2" OPTSTRING_CAPTURE_COMMON "C:d:e:E:F:gG:hH:" "K:lnN:o:O:PqQr:R:S:t:T:u:vVw:W:xX:Y:z:" +#define OPTSTRING "+2" OPTSTRING_CAPTURE_COMMON "C:d:e:E:F:gG:hH:" "K:lnN:o:O:PqQr:R:S:t:T:u:vVw:W:xX:Y:z:" static const char optstring[] = OPTSTRING; |