[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #44745] single quoted string in sprintf is int
From: |
ederag |
Subject: |
[Octave-bug-tracker] [bug #44745] single quoted string in sprintf is interpreted |
Date: |
Mon, 06 Apr 2015 17:37:54 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0 |
URL:
<http://savannah.gnu.org/bugs/?44745>
Summary: single quoted string in sprintf is interpreted
Project: GNU Octave
Submitted by: ederag
Submitted on: Mon 06 Apr 2015 05:37:53 PM GMT
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Documentation
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 4.0.0-rc2
Operating System: GNU/Linux
_______________________________________________________
Details:
sprintf('\lambda = %.1f', 532)
yields
warning: unrecognized escape sequence '\l' -- converting to 'l'
This is unexpected, since the documentation for strings
<https://www.gnu.org/software/octave/doc/interpreter/Escape-Sequences-in-String-Constants.html#Escape-Sequences-in-String-Constants>
states that
"In single-quoted strings, backslash is not a special character"
And the sprintf documentation
<https://www.gnu.org/software/octave/doc/interpreter/Formatted-Output.html#Formatted-Output>
does not appear to mention anything about that:
"This is like printf, except that the output is returned as a string. Unlike
the C library function, which requires you to provide a suitably sized string
as an argument, Octave’s sprintf function returns the string, automatically
sized to hold all of the items converted."
Is it a bug, or is it done on purpose ?
I infer the latter, from a comment from Soren
<http://octave.1599824.n4.nabble.com/Re-Single-vs-Double-Quotes-td3907882.html>:
"deviate from this rule just as the '*printf' functions do."
Then, after
"The following functions are available for formatted output. They are modeled
after the C language functions of the same name, but they interpret the format
template differently in order to improve the performance of printing vector
and matrix values."
something like
"Beware that these functions will interpret the backslashes in the template
string, even if this is a single quote string"
could be helpful ?
Note this happens also under 3.8.2.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?44745>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #44745] single quoted string in sprintf is interpreted,
ederag <=
- [Octave-bug-tracker] [bug #44745] single quoted string in sprintf is interpreted, Rik, 2015/04/06
- [Octave-bug-tracker] [bug #44745] single quoted string in sprintf is interpreted, John W. Eaton, 2015/04/06
- [Octave-bug-tracker] [bug #44745] single quoted string in sprintf is interpreted, ederag, 2015/04/06
- [Octave-bug-tracker] [bug #44745] single quoted string in sprintf is interpreted, Mike Miller, 2015/04/06
- [Octave-bug-tracker] [bug #44745] single quoted string in sprintf is interpreted, Michael Godfrey, 2015/04/07
- [Octave-bug-tracker] [bug #44745] single quoted string in sprintf is interpreted, John W. Eaton, 2015/04/07
- [Octave-bug-tracker] [bug #44745] single quoted string in sprintf is interpreted, ederag, 2015/04/07
- [Octave-bug-tracker] [bug #44745] single quoted string in sprintf is interpreted, John W. Eaton, 2015/04/07
- [Octave-bug-tracker] [bug #44745] single quoted string in sprintf is interpreted, ederag, 2015/04/07
- [Octave-bug-tracker] [bug #44745] single quoted string in sprintf is interpreted, Rik, 2015/04/08