Opened 15 years ago

Closed 13 years ago

#1527 closed Bugs (fixed)

[program_options] Second (and subsequent) lines in tabbed text not aligned correctly

Reported by: anonymous Owned by: Vladimir Prus
Milestone: Boost 1.42.0 Component: program_options
Version: Boost 1.41.0 Severity: Cosmetic
Keywords: wrapping wrap Cc:

Description

When using the tab character to set an alignment for text output, the second (and subsequent) lines are not displayed at the correct position.

It appears that the number of characters between the newline (\n) and tab (\t) are not accounted for.

Example:

    boost::program_options::options_description options("Options");
    options.add_options()
        ("help", "help text")
        ("list",
         "a list:\n      \t"
             "item1, item2, item3, item4, item5, item6, item7, item8, item9, "
             "item10, item11, item12, item13, item14, item15, item16, item17, item18")
    ;

    std::cout << options << std::endl;

Attachments (3)

ticket1527.patch (4.1 KB ) - added by s.ochsenknecht@… 13 years ago.
testcase
options_description_test.patch (1.7 KB ) - added by Chard 13 years ago.
patch for test
options_description.patch (486 bytes ) - added by Chard 13 years ago.
patch for #1527

Download all attachments as: .zip

Change History (10)

by s.ochsenknecht@…, 13 years ago

Attachment: ticket1527.patch added

testcase

comment:1 by s.ochsenknecht@…, 13 years ago

I cannot reproduce this with current trunk. I think the behaviour is correct. I get following output of the mentioned testcase:

  --list arg            a list:
                          item1, item2, item3, item4, item5, item6, item7, 
                          item8, item9, item10, item11, item12, item13, item14, 
                          item15, item16, item17, item18

I attached an enhancement for the test cases which checks the user case.

Please comment. Thanks.

comment:2 by Vladimir Prus, 13 years ago

Resolution: fixed
Status: newclosed

(In [57515]) Test for \t-alignment of options descriptions.

Fixes #1527. Patch from Sascha Ochsenknecht.

comment:3 by Vladimir Prus, 13 years ago

Sascha, I have applied the patch, thanks!

BTW, was there a specific reason you changed std::string to just string in a couple of places? Not that it matters much.

comment:4 by s.ochsenknecht@…, 13 years ago

The source already had a "using namespace std;" and at some places were string's defined without "std::". So, I just wanted the source consistent without any redundancy.

Thanks, Sascha

comment:5 by Chard, 13 years ago

Milestone: Boost 1.36.0Boost 1.42.0
Resolution: fixed
Status: closedreopened
Version: Boost 1.34.1Boost 1.41.0

Hi Volodya,

The original issue is valid and still present.

The responding poster has not actually copied the OP's code exactly.

There should be six spaces between the newline (\n) and tab (\t). The patched test code only uses two. This affects the spacing enough to make it output correctly.

Find attached a patch for the test file (as it appears on the trunk), which does cause the failure, and also a patch with the fix, which is a simple one-liner.

by Chard, 13 years ago

patch for test

by Chard, 13 years ago

Attachment: options_description.patch added

patch for #1527

comment:6 by Sascha Ochsenknecht, 13 years ago

Hi,

I just checked in the patch on trunk. It looks ok for me. I leave the Ticket open until Volodya reviewed it.

Sorry for confusion!

Thanks,

  • Sascha

comment:7 by Vladimir Prus, 13 years ago

Resolution: fixed
Status: reopenedclosed

Seems ok to me. I'm closing this issue. Thanks for the followup, Chard!

Note: See TracTickets for help on using tickets.