Georg Baum wrote:
If you want to debug this fdurther it might be a good idea to write a small
standalone program that simply calls boost::format with the problematic
input.

boost::basic_format() itself seems working if it is called with "ordinary" strings:

> #include <iostream>
> #include <boost/format.hpp>
>
> using namespace std;
>
> main()
> {
>         cout << boost::basic_format<char >("test %1$s \n") % "OK";
> }

which prints out

        test OK

And what is the value of *start? And how does the whole format string look
like?

They are as follows:

> (gdb) p *start
> $38 = (const wchar_t &) @0x8b1e9c0: 49
>
> (gdb) p start
> $39 = (
>     __gnu_cxx::__normal_iterator<const
> wchar_t*,std::basic_string<wchar_t, std::char_traits<wchar_t>,
> std::allocator<wchar_t> > > &) @0xbfbfe2cc: {
>   _M_current = 0x8b1e9c0}
>
> (gdb) x/25s 0xbfbfe2cc
> 0xbfbfe2cc:         "\300\351\261\b\030\033\177)\r"
> 0xbfbfe2d6:         ""
> 0xbfbfe2d7:         ""
> 0xbfbfe2d8:         "\214\351\261\bp\352\261\b"
> 0xbfbfe2e1:         ""
> 0xbfbfe2e2:         ""
> 0xbfbfe2e3:         ""
> 0xbfbfe2e4:         ""
> 0xbfbfe2e5:         ""
> 0xbfbfe2e6:         ""
> 0xbfbfe2e7:         ""
> 0xbfbfe2e8:         ""
> 0xbfbfe2e9:         ""
> 0xbfbfe2ea:         ""
> 0xbfbfe2eb:         ""
> 0xbfbfe2ec: "\234\v\177)\314;\177)8\344\277\277(\343\277\277f|v)\354;\177)\001"
> 0xbfbfe306:         ""
> 0xbfbfe307:         ""
> 0xbfbfe308: "([EMAIL PROTECTED] \037\177)%"
> 0xbfbfe32a:         ""
> 0xbfbfe32b:         ""
> 0xbfbfe32c:         "\016\312\023\001\377\377\377\377"
> 0xbfbfe335:         ""
> 0xbfbfe336:         ""
> 0xbfbfe337:         ""

I am now pretty sure that the
problem is not in any locale stuff, but in boost::format itself, because
normally this part of the code should only be reached with valid format
characters (and signed -65 == unsigned 191 == 0277 == 0xbf is not a valid
format character).

I'm not quite sure about the data structure used here, but arguments fmt and arg1 in bformat() seem to contain no data fields:

src/support/lstrings.cpp line 875
>
template<>
docstring bformat<docstring>(docstring const & fmt, docstring arg1)
{
        return (boost::basic_format<char_type>(fmt) % arg1).str();
}

Data:
fmt = $26 = (const docstring &) @0xbfbfe588: {static npos = 4294967295, _M_dataplus = {<std::allocator<wchar_t>> = {<__gnu_cxx::new_allocator<wchar_t>> = {<No data fields>}, <No data fields>}, _M_p = 0x8b1e98c}} arg1 = $27 = (docstring &) @0xbfbfe580: {static npos = 4294967295, _M_dataplus = {<std::allocator<wchar_t>> = {<__gnu_cxx::new_allocator<wchar_t>> = {<No data fields>}, <No data fields>}, _M_p = 0x8b1e70c}}

And, subsequently call in boost/format/format_implementation.hpp line 60

    template< class Ch, class Tr, class Alloc>
    basic_format<Ch, Tr, Alloc>:: basic_format(const string_type& s)
        : style_(0), cur_arg_(0), num_args_(0), dumped_(false),
          exceptions_(io::all_error_bits)
    {
parse(s); }

Data:
s = $28 = (
const std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > &) @0xbfbfe588: {static npos = 4294967295, _M_dataplus = {<std::allocator<wchar_t>> = {<__gnu_cxx::new_allocator<wchar_t>> = {<No data fields>}, <No data fields>}, _M_p = 0x8b1e98c}}

I also attach the data of arguments passed to parse_printf_directive() in boost/format/parsing.hpp which is called later:

boost/format/parsing.hpp line 437
>
bool parse_ok = io::detail::parse_printf_directive(
                it, buf.end(), &items_[cur_item], fac, i1, exceptions());

(gdb) p it
$29 = {_M_current = 0x8b1e9c0}
(gdb) p buf.end()
$30 = {_M_current = 0x8b1ea70}
(gdb) p &items_[cur_item]
$31 = (
    const class 
boost::io::detail::format_item<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
 > *) 0x8af4a80
(gdb) p items_[cur_item]
$35 = (
    const 
boost::io::detail::format_item<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
 > &) @0x8af4a80: {argN_ = -1, res_ = {
static npos = 4294967295, _M_dataplus = {<std::allocator<wchar_t>> = {<__gnu_cxx::new_allocator<wchar_t>> = {<No data fields>}, <No data fields>}, _M_p = 0x8a5a7a8}}, appendix_ = {static npos = 4294967295, _M_dataplus = {<std::allocator<wchar_t>> = {<__gnu_cxx::new_allocator<wchar_t>> = {<No data fields>}, <No data fields>}, _M_p = 0x8a5a7a8}}, fmtstate_ = {width_ = 0, precision_ = 6, fill_ = 32, flags_ = 4098, rdstate_ = std::_S_goodbit, exceptions_ = std::_S_goodbit, loc_ = {<boost::optional_detail::optional_base<std::locale>> = {<boost::optional_detail::optional_tag> = {<No data fields>}, m_initialized = false, m_storage = {dummy_ = {data = "\000\000\000", aligner_ = <incomplete type>}}}, <No data fields>}}, truncate_ = 2147483647, pad_scheme_ = 0}
(gdb) p fac
$32 = (const struct std::ctype<wchar_t> &) @0x297f1f20: <incomplete type>
(gdb) p i1
$33 = 13
(gdb) p exceptions()
$34 = 255 '\377'

Are these passed data OK?

Thank you,

Koji

Reply via email to