Bug #449
opengetopt_long_only(3c) return wrong value
0%
Description
Copy of Opensolaris bug 6835846.
getopt_long_only() should be returning the option currently being processed, however, at least in some cases, it's returning other letters:
To test:
cc -o getopt_long_test getopt_long_test.c
./getopt_long_test -lc foo (works)
./getopt_long_test -cl foo (fails)
Expected Result
Expect it to output 'Option: X' corresponding to each option
Actual Result
In test case, using "-cl" causes it to return 'F'
Files
Updated by Yuri Pankov almost 12 years ago
- Difficulty set to Medium
- Tags set to needs-triage
Same is true for getopt_long - if specified long-style option matches the same length part of defined long-style option, it is accepted.. i.e. my changes to sed make it accept --in-place[=SUFFIX], but getopt_long will accept just --in=.bak..... The fix should be as simple as just checking that both have the same length here http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libc/port/gen/getopt_long.c#334