sprintf behaves strangely when given empty input cell

John W. Eaton jwe at bevo.che.wisc.edu
Sun Jan 6 16:24:27 CST 2008


On  5-Jan-2008, Muthiah Annamalai wrote:

| The larger question is what do we want to treat {:} for empty cells, and 
| I think
| that is something JWE must address. Infact Octave behaves similarly even 
| if you
| sprintf("\'%s\'",{}{:})

The expression

  {}{:}

returns an empty comma-separated-list, so the sprintf call above is
equivalent to

  sprintf ("\'%s\'")

For compatibility with Matlab, this must produce the single character '.

| so one easy way to solve this is make the 
| octave_base_stream::do_printf() forgiving
| and continue with other elements of the format-list hoping they are not 
| conversions.

I don't think that is desirable, but even if I did, we can't do it
because it would create compatibility problems.

| Also similar problems exist due because of the treatment / choices at 
| parsing stage.

?

jwe


More information about the Bug-octave mailing list