Incoherent handling of '\n' in Octave 2.9.9 wrt. Octave 2.1.73
John W. Eaton
jwe at bevo.che.wisc.edu
Fri Apr 18 10:49:42 CDT 2008
On 18-Apr-2008, Paolo Giarrusso wrote:
| (Semi-automatic) Bug report for Octave 2.9.9 configured for x86_64-pc-linux-gnu
|
| Description:
| -----------
| The attached code snippet gives different result when executed with
| Octave 2.1.73 and Octave 2.9.9, as provided by Ubuntu 7.04 (and I
| consider the results of 2.9.9 to be buggy). The results of each
| command in Octave2.9 are given in comments.
|
| In particular, what puzzles me is that disp('\n') (note single quotes)
| prints literally the blackslash and the `n', while disp("\n") and
| fprintf (of either '\n' or "\n") give the expected result.
| Typing the string at the prompt behaves like disp:
|
| octave2.9:3> '\n'
| ans = \n
| octave2.9:4> "\n"
| ans =
Octave recognizes C-style backslash escapes in "" quoted character
strings. This is not done in '' quoted character strings for
compatibility with Matlab.
| But fprintf() gives the same results with both single and double
| quotes; however, it sure does not handle \n itself, because it would
| then handle:
|
| octave2.9:5> str=disp('\n')
| str = \n
|
| octave2.9:6> fprintf(str)
| \n
| octave2.9:7>
| But fprintf doesn't handle \n here, as you can see.
|
| Any hint?
I suppose that's a bug. The disp function is producing a
string that behaves as a "" quoted character string even when the
input is a '' quoted character string. I'll see about fixing that
for the upcoming 3.0.1 release.
Also, 2.9.9 is obsolete now that 3.0 has been released. I strongly
recommend upgrading to the stable 3.0 release.
jwe
More information about the Bug-octave
mailing list