#2613 closed Bugs (fixed)
Default arguments break word-wrapping.
Reported by: | Peter Simons | Owned by: | Vladimir Prus |
---|---|---|---|
Milestone: | Boost 1.42.0 | Component: | program_options |
Version: | Boost 1.37.0 | Severity: | Problem |
Keywords: | Cc: | simons@…, s.ochsenknecht@… |
Description
The attached example program demonstrates the problem.
Attachments (2)
Change History (9)
by , 14 years ago
follow-up: 2 comment:1 by , 14 years ago
Please specify how the produced output differs from expected output, and why you expect the output you expect.
comment:2 by , 14 years ago
With Boost 1.37.0, the attached program generates the following output:
$ g++ test.cpp -lboost_program_options && ./a.out | Supported options: | --help this is a sufficiently long text to requ | ire word-wrapping
Look closely at the description of the "--help" option. You'll find that word-wrapping is performed in the middle of the word, i.e. "require" is broken apart as "requ-ire". This is contrary to what I expect because of the rules of syllabication, which you'll find described at http://en.wikipedia.org/wiki/Syllabification. Now, those rules are somewhat complex and might be considered beyond the scope of a command-line argument parsing library. Thus, most code that needs to perform word-wrapping opts to use a simpler approximation, i.e. to break lines apart at *whitespace*. If you check out your source code, "options_description.cpp", you'll find that you have implemented an algorithm that does this, but unfortunately it appears that your code fails to take the length of the default argument into account. I say this because the algorithm works just fine when there's no default argument. When there is one, word-wrapping does not work fine.
If you need further clarification, please don't hesitate to ask.
comment:3 by , 13 years ago
I just attached a patch which improves the word wrapping (small fix). I also added a test case for word wrapping.
Please comment.
comment:4 by , 13 years ago
Cc: | added |
---|
comment:5 by , 13 years ago
Milestone: | Boost 1.38.0 → Boost 1.41.0 |
---|
The patch applies cleanly to the current SVN HEAD, and it does fix the problem in my test program. Looks good to me. Thank you very much.
comment:6 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:7 by , 13 years ago
Milestone: | Boost 1.41.0 → Boost 1.42.0 |
---|
Run to see the broken help output.