Bug 2142 – getopt() incorrectly processes bundled comman-line options

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-06-06T05:08:00Z
Last change time
2015-06-09T01:19:35Z
Assigned to
andrei
Creator
kolos80

Comments

Comment #0 by kolos80 — 2008-06-06T05:08:28Z
getopt() sees only one short option in bundled options - the one that is given to getopt() first. Example: boo f_linenum, f_filename; getopt ( args, std.getopt.config.bundling, //std.getopt.config.caseSensitive, "linenum|l", &f_linenum, "filename|n", &f_filename ); In `-ln' and `-nl' options only `l' will be recognized in this case. And if we will change the order like this: ... "filename|n", &f_filename, "linenum|l", &f_linenum ... `n' will be recognized, but `l' will be skipped I think, it's from line 538 of getopt.d: 536 if (cfg.bundling && !isLong && v.length == 1 537 && std.string.find(arg, v) >= 0) 538 return true; <--- this is wrong P.S. I cannot check my solution, because phobos doesn't compile: Error: multiple definition of object-2: _D8object.212__ModuleInfoZ and object: _ D8object.212__ModuleInfoZ
Comment #1 by kolos80 — 2008-06-26T02:23:28Z
I found that if short option is recognized, then the whole argument containing it is removed from <args>, leaving all remaining bundled options unprocessed.
Comment #2 by andrei — 2010-09-26T08:25:34Z