Re: Robustifying pretty-printers

Vladimir Prus
2009-06-15T13:25:42Z

On Monday 15 June 2009 Daniel Jacobowitz wrote:

> On Mon, Jun 15, 2009 at 04:38:57PM +0400, Vladimir Prus wrote:
> > On Monday 15 June 2009 Phil Muldoon wrote:
> > > + return self.val['_M_dataplus']['_M_p'].string (encoding, length = len)
> >
> > Great, this is exactly what I was looking for.
>
> Is it? This uses the length from the (possibly uninitialized)
> std::string as a maximum. I think we want something higher level,
> similar to today's "set print elements", to apply.

That's a separate matter, which I raise in the topic starter. Yes, we want
some safety net. As it stands, any IDE that automatically displays local
variables is totally broken if pretty-printing is enabled.

But at the same time, even if we assume that the variable is already
initialized, we need to terminate the string at the length, as opposed
to assuming it has some null terminator. The higher level safety net
might cut the string at 100 characters, preventing a hang. But it would
be nicer to cut it at actual string length, so avoid showing garbage.

- Volodya