Ticket #3603: fix_warnings.patch

File fix_warnings.patch, 13.3 KB (added by s.ochsenknecht@…, 13 years ago)

patch

  • libs/program_options/test/parsers_test.cpp

     
    5757    BOOST_CHECK(option.value.front() == value);
    5858}
    5959
    60 vector<string> sv(char* array[], unsigned size)
     60vector<string> sv(const char* array[], unsigned size)
    6161{
    6262    vector<string> r;
    6363    for (unsigned i = 0; i < size; ++i)
     
    113113        ("baz", new untyped_value())
    114114        ("plug*", new untyped_value())
    115115        ;
    116     char* cmdline3_[] = { "--foo=12", "-f4", "--bar=11", "-b4",
     116    const char* cmdline3_[] = { "--foo=12", "-f4", "--bar=11", "-b4",
    117117                          "--plug3=10"};
    118118    vector<string> cmdline3 = sv(cmdline3_,
    119                                  sizeof(cmdline3_)/sizeof(cmdline3_[0]));
     119                                 sizeof(cmdline3_)/sizeof(const char*));
    120120    vector<option> a3 =
    121121        command_line_parser(cmdline3).options(desc).run().options;
    122122                       
     
    131131    // Regression test: check that '0' as style is interpreted as
    132132    // 'default_style'
    133133    vector<option> a4 =
    134         parse_command_line(5, cmdline3_, desc, 0, additional_parser).options;
     134        parse_command_line(sizeof(cmdline3_)/sizeof(const char*), const_cast<char**>(cmdline3_),
     135                                                               desc, 0, additional_parser).options;
    135136
    136137    BOOST_CHECK_EQUAL(a4.size(), 4u);
    137138    check_value(a4[0], "foo", "4");
    138139    check_value(a4[1], "bar", "11");
    139140
    140141    // Check that we don't crash on empty values of type 'string'
    141     char* cmdline4[] = {"", "--open", ""};
     142    const char* cmdline4[] = {"", "--open", ""};
    142143    options_description desc2;
    143144    desc2.add_options()
    144145        ("open", po::value<string>())
    145146        ;
    146147    variables_map vm;
    147     po::store(po::parse_command_line(3, cmdline4, desc2), vm);
     148    po::store(po::parse_command_line(sizeof(cmdline4)/sizeof(const char*), const_cast<char**>(cmdline4), desc2), vm);
    148149
    149     char* cmdline5[] = {"", "-p7", "-o", "1", "2", "3", "-x8"};
     150    const char* cmdline5[] = {"", "-p7", "-o", "1", "2", "3", "-x8"};
    150151    options_description desc3;
    151152    desc3.add_options()
    152153        (",p", po::value<string>())
     
    154155        (",x", po::value<string>())
    155156        ;
    156157    vector<option> a5 =
    157         parse_command_line(7, cmdline5, desc3, 0, additional_parser).options;
     158        parse_command_line(sizeof(cmdline5)/sizeof(const char*), const_cast<char**>(cmdline5),
     159                                                                     desc3, 0, additional_parser).options;
    158160    BOOST_CHECK_EQUAL(a5.size(), 3u);
    159161    check_value(a5[0], "-p", "7");
    160162    BOOST_REQUIRE(a5[1].value.size() == 3);
     
    180182    po::positional_options_description p;
    181183    p.add( "file", 1 );
    182184
    183     char* cmdline6[] = {"", "-m", "token1", "token2", "--", "some_file"};
     185    const char* cmdline6[] = {"", "-m", "token1", "token2", "--", "some_file"};
    184186    vector<option> a6 =
    185         command_line_parser(6, cmdline6).options(desc4).positional(p)
     187        command_line_parser(sizeof(cmdline6)/sizeof(const char*), const_cast<char**>(cmdline6)).options(desc4).positional(p)
    186188        .run().options;
    187189    BOOST_CHECK_EQUAL(a6.size(), 2u);
    188190    BOOST_REQUIRE(a6[0].value.size() == 2);
     
    238240#if defined(_WIN32) && ! defined(__BORLANDC__)
    239241    _putenv("PO_TEST_FOO=1");
    240242#else
    241     putenv("PO_TEST_FOO=1");
     243    putenv(const_cast<char*>("PO_TEST_FOO=1"));
    242244#endif
    243245    parsed_options p = parse_environment(desc, "PO_TEST_");
    244246
     
    255257{
    256258    options_description desc;
    257259
    258     char* cmdline1_[] = { "--foo=12", "--bar", "1"};
     260    const char* cmdline1_[] = { "--foo=12", "--bar", "1"};
    259261    vector<string> cmdline1 = sv(cmdline1_,
    260                                  sizeof(cmdline1_)/sizeof(cmdline1_[0]));
     262                                 sizeof(cmdline1_)/sizeof(const char*));
    261263    vector<option> a1 =
    262264        command_line_parser(cmdline1).options(desc).allow_unregistered().run()
    263265        .options;
  • libs/program_options/test/test_convert.cpp

     
    33// (See accompanying file LICENSE_1_0.txt
    44// or copy at http://www.boost.org/LICENSE_1_0.txt)
    55
     6#include <cstring>
    67#include <cassert>
    78#include <string>
    89#include <fstream>
     
    3839    std::wstring result;
    3940
    4041
    41     std::mbstate_t state = {0};
    42 
     42    std::mbstate_t state;
     43    memset(&state, 0, sizeof(std::mbstate_t));
     44   
    4345    const char* from = s.data();
    4446    const char* from_end = s.data() + s.size();
    4547    // The interace of cvt is not really iterator-like, and it's
  • libs/program_options/test/variable_map_test.cpp

     
    2020
    2121#include "minitest.hpp"
    2222
    23 vector<string> sv(char* array[], unsigned size)
     23vector<string> sv(const char* array[], unsigned size)
    2424{
    2525    vector<string> r;
    2626    for (unsigned i = 0; i < size; ++i)
     
    3838        ("baz", new untyped_value())
    3939        ("output,o", new untyped_value(), "")
    4040        ;
    41     char* cmdline3_[] = { "--foo='12'", "--bar=11", "-z3", "-ofoo" };
     41    const char* cmdline3_[] = { "--foo='12'", "--bar=11", "-z3", "-ofoo" };
    4242    vector<string> cmdline3 = sv(cmdline3_,
    43                                  sizeof(cmdline3_)/sizeof(cmdline3_[0]));
     43                                 sizeof(cmdline3_)/sizeof(const char*));
    4444    parsed_options a3 = command_line_parser(cmdline3).options(desc).run();
    4545    variables_map vm;
    4646    store(a3, vm);
     
    5858    ("zak", po::value<int>(&i), "")
    5959    ("opt", bool_switch(), "");
    6060
    61     char* cmdline4_[] = { "--zee", "--zak=13" };
     61    const char* cmdline4_[] = { "--zee", "--zak=13" };
    6262    vector<string> cmdline4 = sv(cmdline4_,
    63                                  sizeof(cmdline4_)/sizeof(cmdline4_[0]));
     63                                 sizeof(cmdline4_)/sizeof(const char*));
    6464    parsed_options a4 = command_line_parser(cmdline4).options(desc).run();
    6565
    6666    variables_map vm2;
     
    7878    ("voo", po::value<string>())
    7979    ("iii", po::value<int>()->default_value(123))
    8080    ;
    81     char* cmdline5_[] = { "--voo=1" };
     81    const char* cmdline5_[] = { "--voo=1" };
    8282    vector<string> cmdline5 = sv(cmdline5_,
    83                                  sizeof(cmdline5_)/sizeof(cmdline5_[0]));
     83                                 sizeof(cmdline5_)/sizeof(const char*));
    8484    parsed_options a5 = command_line_parser(cmdline5).options(desc2).run();
    8585
    8686    variables_map vm3;
     
    100100    ;
    101101    /* The -m option is implicit. It does not have value in inside the token,
    102102       and we should not grab the next token.  */
    103     char* cmdline6_[] = {  "--imp=1", "-m", "--foo=1" };
     103    const char* cmdline6_[] = {  "--imp=1", "-m", "--foo=1" };
    104104    vector<string> cmdline6 = sv(cmdline6_,
    105                                  sizeof(cmdline6_)/sizeof(cmdline6_[0]));
     105                                 sizeof(cmdline6_)/sizeof(const char*));
    106106    parsed_options a6 = command_line_parser(cmdline6).options(desc3).run();
    107107
    108108    variables_map vm4;
     
    194194    ("include", po::value< vector<int> >()->composing())
    195195    ;
    196196
    197     char* cmdline1_[] = { "--first=1", "--aux=10", "--first=3", "--include=1" };
     197    const char* cmdline1_[] = { "--first=1", "--aux=10", "--first=3", "--include=1" };
    198198    vector<string> cmdline1 = sv(cmdline1_,
    199                                  sizeof(cmdline1_)/sizeof(cmdline1_[0]));
     199                                 sizeof(cmdline1_)/sizeof(const char*));
    200200
    201201    parsed_options p1 = command_line_parser(cmdline1).options(desc).run();
    202202
    203     char* cmdline2_[] = { "--first=12", "--second=7", "--include=7" };
     203    const char* cmdline2_[] = { "--first=12", "--second=7", "--include=7" };
    204204    vector<string> cmdline2 = sv(cmdline2_,
    205                                  sizeof(cmdline2_)/sizeof(cmdline2_[0]));
     205                                 sizeof(cmdline2_)/sizeof(const char*));
    206206
    207207    parsed_options p2 = command_line_parser(cmdline2).options(desc).run();
    208208
  • libs/program_options/test/unicode_test.cpp

     
    8888    BOOST_CHECK(vm["foo"].as<wstring>() == L"\x044F");   
    8989}
    9090
    91 
    92 vector<wstring> sv(wchar_t* array[], unsigned size)
     91vector<wstring> sv(const wchar_t* array[], unsigned size)
    9392{
    9493    vector<wstring> r;
    9594    for (unsigned i = 0; i < size; ++i)
     
    115114        ("plug*", new untyped_value())
    116115        ;
    117116
    118     wchar_t* cmdline4_[] = { L"--foo=1\u0FF52", L"-f4", L"--bar=11",
     117    const wchar_t* cmdline4_[] = { L"--foo=1\u0FF52", L"-f4", L"--bar=11",
    119118                             L"-b4", L"--plug3=10"};
    120119    vector<wstring> cmdline4 = sv(cmdline4_,
    121120                                  sizeof(cmdline4_)/sizeof(cmdline4_[0]));
  • libs/program_options/test/cmdline_test.cpp

     
    183183        {"--bar", s_missing_parameter, ""},
    184184
    185185        {"--bar=123", s_success, "bar:123"},
    186         {0}
     186        {0, 0, 0}
    187187    };
    188188    test_cmdline("foo bar=", style, test_cases1);
    189189
     
    198198        // considered a value, even though it looks like
    199199        // an option.
    200200        {"--bar --foo", s_success, "bar:--foo"},
    201         {0}
     201        {0, 0, 0}
    202202    };
    203203    test_cmdline("foo bar=", style, test_cases2);
    204204    style = cmdline::style_t(
     
    208208    test_case test_cases3[] = {
    209209        {"--bar=10", s_success, "bar:10"},
    210210        {"--bar 11", s_success, "bar:11"},
    211         {0}
     211        {0, 0, 0}
    212212    };
    213213    test_cmdline("foo bar=", style, test_cases3);
    214214
     
    226226        {"--bar=Ab", s_success, "bar:Ab"},
    227227        {"--Bar=ab", s_success, "bar:ab"},
    228228        {"--giz", s_success, "Giz:"},
    229         {0}
     229        {0, 0, 0}
    230230    };
    231231    test_cmdline("foo bar= baz? Giz", style, test_cases4);
    232232#endif
     
    249249        {"-f14", s_success, "-f:14"},
    250250        {"-g -f1", s_success, "-g: -f:1"},
    251251        {"-f", s_missing_parameter, ""},
    252         {0}
     252        {0, 0, 0}
    253253    };
    254254    test_cmdline(",d ,f= ,g", style, test_cases1);
    255255
     
    263263        {"-f", s_missing_parameter, ""},
    264264        {"-f /foo", s_success, "-f:/foo"},
    265265        {"-f -d", s_success, "-f:-d"},
    266         {0}
     266        {0, 0, 0}
    267267    };
    268268    test_cmdline(",d ,f=", style, test_cases2);
    269269
     
    275275        {"-f10", s_success, "-f:10"},
    276276        {"-f 10", s_success, "-f:10"},
    277277        {"-f -d", s_success, "-f:-d"},
    278         {0}
     278        {0, 0, 0}
    279279    };
    280280    test_cmdline(",d ,f=", style, test_cases3);
    281281
     
    291291        //{"-d12", s_extra_parameter, ""},
    292292        {"-f12", s_success, "-f:12"},
    293293        {"-fe", s_success, "-f:e"},
    294         {0}
     294        {0, 0, 0}
    295295    };
    296296    test_cmdline(",d ,f= ,e", style, test_cases4);
    297297
     
    313313        {"/d13", s_extra_parameter, ""},
    314314        {"/f14", s_success, "-f:14"},
    315315        {"/f", s_missing_parameter, ""},
    316         {0}
     316        {0, 0, 0}
    317317    };
    318318    test_cmdline(",d ,f=", style, test_cases1);
    319319
     
    325325    test_case test_cases2[] = {
    326326        {"/de", s_extra_parameter, ""},
    327327        {"/fe", s_success, "-f:e"},
    328         {0}
     328        {0, 0, 0}
    329329    };
    330330    test_cmdline(",d ,f= ,e", style, test_cases2);
    331331
     
    347347        {"-foo -f", s_success, "foo: foo:"},
    348348        {"-goo=x -gy", s_success, "goo:x goo:y"},
    349349        {"-bee=x -by", s_success, "bee:x bee:y"},
    350         {0}
     350        {0, 0, 0}
    351351    };
    352352    test_cmdline("foo,f goo,g= bee,b?", style, test_cases1);
    353353
     
    355355    test_case test_cases2[] = {
    356356        {"/foo -f", s_success, "foo: foo:"},
    357357        {"/goo=x", s_success, "goo:x"},
    358         {0}
     358        {0, 0, 0}
    359359    };
    360360    test_cmdline("foo,f goo,g= bee,b?", style, test_cases2);
    361361}
     
    376376        {"--opt", s_ambiguous_option, ""},
    377377        {"--f=1", s_success, "foo:1"},
    378378        {"-far", s_success, "foo:ar"},
    379         {0}
     379        {0, 0, 0}
    380380    };
    381381    test_cmdline("opt123 opt56 foo,f=", style, test_cases1);
    382382}
     
    394394    test_case test_cases1[] = {
    395395        {"-f file -gx file2", s_success, "-f: file -g:x file2"},
    396396        {"-f - -gx - -- -e", s_success, "-f: - -g:x - -e"},
    397         {0}
     397        {0, 0, 0}
    398398    };
    399399    test_cmdline(",f ,g= ,e", style, test_cases1);
    400400
     
    407407
    408408    test_case test_cases2[] = {
    409409        {"-f - -gx - -- -e", s_success, "-f: - -g:x - -e"},
    410         {0}
     410        {0, 0, 0}
    411411    };
    412412    test_cmdline(",f ,g= ,e", style, test_cases2);
    413413}
     
    425425
    426426    test_case test_cases1[] = {
    427427        {"--foo.bar=12", s_success, "foo.bar:12"},
    428         {0}
     428        {0, 0, 0}
    429429    };
    430430
    431431    test_cmdline("foo*=", style, test_cases1);
     
    599599    // It's not clear yet, so I'm leaving the decision till later.
    600600}
    601601
    602 int main(int ac, char* av[])
     602int main(int /*ac*/, char** /*av*/)
    603603{
    604604    test_long_options();
    605605    test_short_options();