Modify

Ticket #2613 (closed Bugs: fixed)

Opened 5 years ago

Last modified 4 years ago

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

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

Change History

Changed 5 years ago by anonymous

Run to see the broken help output.

comment:1 follow-up: ↓ 2 Changed 5 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 5 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  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.

Changed 4 years ago by s.ochsenknecht@…

patch

comment:3 Changed 4 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 4 years ago by s.ochsenknecht@…

  • Cc s.ochsenknecht@… added

comment:5 Changed 4 years ago by simons

  • Milestone changed from Boost 1.38.0 to 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 Changed 4 years ago by vladimir_prus

  • Status changed from new to closed
  • Resolution set to fixed

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

Fixes #2613. Patch from Sascha Ochsenknecht.

comment:7 Changed 4 years ago by s_ochsenknecht

  • Milestone changed from Boost 1.41.0 to Boost 1.42.0
View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


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

 
Note: See TracTickets for help on using tickets.