help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ylabel woes


From: John W. Eaton
Subject: Re: ylabel woes
Date: Thu, 29 May 2003 11:37:49 -0500

On 29-May-2003, Quentin Spencer <address@hidden> wrote:

| Usually putting "\\" in place of "\" works for me. As I understand it, 
| this is because some of the string processing functions use "\" as an 
| escape character as is often done in Unix.

The reason is that escape sequences are converted as the string is
read by the parser.  So when you write

  "foo\n"

you are creating a string with 4 characters: f, o, o, and newline.

This is different from Matlab, which apparently does not process the
escapes at parse time, but allows individual functions (like fprintf)
to recognize the \n specially.

Changing this for compatibility might be a big mess.  Is it worth it?
I don't know.  It seems much less consistent to have only some
functions process escape sequences instead of doing what C does, and
having the parser recognize the escape sequences when creating
character strings.

 You may have to experiment, 
| because in some cases, like in the octave-forge print function, there 
| are multiple processing steps, so I have had to use 4 or 8 backslashes 
| to get things to work.

This probably happens because those functions are using eval() or
sprintf() to further process the strings.  If so, they should probably
call undo_string_escapes() on any strings that will be passed to
eval().  This is what happens in Octave's ylabel now (actually
__axis_label__.m, which is the function used to implement the xlabel,
ylabel, and zlabel functions):

      eval (sprintf ("gset %s \"%s\"", caller,
                     undo_string_escapes (undo_string_escapes (text))));

In this case, we need undo_string_escapes twice because the string
appears in eval and the format string of sprintf.

jwe



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]