bugGNU Octave - Bugs: bug #33611, Matlab-incompatible character...

 
 

bug #33611: Matlab-incompatible character string escape processing

Submitted by:  John W. Eaton <jwe>
Submitted on:  Tue 21 Jun 2011 03:10:03 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: Any

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Fri 15 Mar 2013 01:50:52 PM UTC, comment #8:

I just downloaded edit.m from:
http://hg.savannah.gnu.org/hgweb/octave/file/003100ee9e0d/scripts/miscellaneous/edit.m
(indicated as stable)

The "undo_string_escapes" seem to have fixed this problem and I am successfully able to specify the path as:
EDITOR('C:\Program Files (x86)\Vim\vim73\gvim.exe');

Thanks for following up.

Carl <costerwi>
Wed 13 Mar 2013 06:45:33 PM UTC, comment #7:

Does the problem with edit.m and '\' still exist?

I notice that edit.m has been coded to use undo_string_escapes before calling sprintf. This should mean that extra backslashes are inserted and then removed by sprintf so that the result is unchanged but the '%s' token can still be used by sprintf. I used a recent changeset on the development branch for testing (16297:00da706fba48).

Rik <rik5>
Project Administrator
Thu 04 Oct 2012 07:54:28 PM UTC, comment #6:

It's too bad Matlab compatibility has to make printf inconsistent with it's string quoting. I don't think there's a good way to make the function smarter with this constraint.

Double quote, double backslash doesn't workaround. I think the EDITOR function immediately performs escape processing and then always returns a single-quote result.

My workaround is to specify the directory using forward slash as the separator. I'm using the mingw distribution 3.6.1 and this seems to work on my Windows7 x64 machine:

Carl <costerwi>
Thu 04 Oct 2012 02:01:33 PM UTC, comment #5:

A character string using single quotes does not do any backslash escape processing.

But, when given a single quote character string, the printf functions do perform escape processing on the format argument. That is required for Matlab compatibility.

One problem is what escape sequences should be recognized, and what should we do for those that are not recognized. Maybe we shouldn't be warning about them, or dropping the \ character.

The problem with the edit function is that we want to handle %s in the EDITOR variable. The easy way to do that is to use the EDITOR variable as a format in sprintf. But as you see, that causes some trouble. Can you avoid the problem by using double quotes and double backslashes: "c:\\foo\\bar\\system\\editor"?

John W. Eaton <jwe>
Project Administrator
Thu 04 Oct 2012 01:45:29 PM UTC, comment #4:

I think this is a related issue that breaks the edit.m command on Windows since my EDITOR specifies the full path using backslashes. edit.m uses sprintf command but you can see the problem here:

Carl <costerwi>
Thu 05 Apr 2012 07:09:04 PM UTC, comment #3:

Is the particular example an actual problem? It appears that it might not even run on Matlab. For example, what does Matlab do for

I would think it would produce an error because the string delimiter in Matlab is a single quote. So it looks like the code to run would be

and the eval version would be

which very properly doesn't do escape sequences.

Rik <rik5>
Project Administrator
Tue 28 Jun 2011 11:32:49 PM UTC, comment #2:

Oops, no there is not. The first is correct. What was I thinking? Is there no way to delete a comment from the bug tracker?

John W. Eaton <jwe>
Project Administrator
Tue 28 Jun 2011 11:30:36 PM UTC, comment #1:

There is a typo in the description of the bug. It should be

John W. Eaton <jwe>
Project Administrator
Tue 21 Jun 2011 03:10:03 PM UTC, original submission:

Octave processes string escapes in the following context:

This does not happen in Matlab (Matlab only processes string escapes in the format of a call to *printf). This problem has consequences for command evaluation on Windows systems where backslash is used as a directory separator.

John W. Eaton <jwe>
Project Administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -unavailable- added by costerwi (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by jwe (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 15 Mar 2013 03:18:53 PM UTCrik5StatusNeed Info=>Fixed
      Open/ClosedOpen=>Closed
    Thu 05 Apr 2012 07:09:04 PM UTCrik5StatusNone=>Need Info
    Sun 25 Mar 2012 09:45:49 PM UTCrik5Dependencies-=>bugs #35911 is dependent

    Back to the top


    Powered by Savane 3.1-cleanup