Branch: Tag:

2014-11-26

2014-11-26 21:22:02 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Stdio.Buffer: LFUN::_sprintf() must not have side effects!

sprintf("%s", buf) and sprintf("%q", buf) had the side effect
of emptying the buffer (which is not what you expect when you
use them for debug output...).

1650:    PIKEFUN string(0..255) _sprintf(int o, mapping UNUSED)    flags ID_PROTECTED;    { +  size_t bytes;    pop_n_elems(args-1);    Pike_sp--;    switch( o )
1676:    break;       case 's': -  push_string( io_read_string( THIS, io_len(THIS)) ); +  bytes = io_len(THIS); +  push_string( io_read_string(THIS, bytes) ); +  io_rewind(THIS, bytes);    break;       case 'q':    push_text("%q"); -  push_string( io_read_string( THIS, io_len(THIS)) ); +  bytes = io_len(THIS); +  push_string( io_read_string(THIS, bytes) ); +  io_rewind(THIS, bytes);    f_sprintf(2);    break;    default: