Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#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@…


The attached example program demonstrates the problem.

Attachments (2)

test.cpp (514 bytes) - added by anonymous 9 years ago.
Run to see the broken help output.
patch_ticket2613.diff (2.7 KB) - added by s.ochsenknecht@… 8 years ago.

Download all attachments as: .zip

Change History (9)

Changed 9 years ago by anonymous

Attachment: test.cpp added

Run to see the broken help output.

comment:1 Changed 9 years ago by Vladimir Prus

Please specify how the produced output differs from expected output, and why you expect the output you expect.

comment:2 in reply to:  1 Changed 9 years ago by Peter Simons

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 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.

Changed 8 years ago by s.ochsenknecht@…

Attachment: patch_ticket2613.diff added


comment:3 Changed 8 years ago by s.ochsenknecht@…

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 Changed 8 years ago by s.ochsenknecht@…

Cc: s.ochsenknecht@… added

comment:5 Changed 8 years ago by simons

Milestone: Boost 1.38.0Boost 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 Changed 8 years ago by Vladimir Prus

Resolution: fixed
Status: newclosed

(In [57517]) Fix wordwrapping in presense of default parameters.

Fixes #2613. Patch from Sascha Ochsenknecht.

comment:7 Changed 8 years ago by Sascha Ochsenknecht

Milestone: Boost 1.41.0Boost 1.42.0

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Vladimir Prus.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.