octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #35911] Backslash escaping in regexprep replac


From: Rik
Subject: [Octave-bug-tracker] [bug #35911] Backslash escaping in regexprep replacement string incompatibility
Date: Thu, 29 Mar 2012 02:41:57 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0

Follow-up Comment #3, bug #35911 (project octave):

You ask a very perceptive question.  I'll speak for myself, as a frequent
Octave contributor, and say that I consider Octave's behavior to be superior. 
Computers are tools and I think it is useful to be able to say exactly what I
want to have happen ('single quotes') or have interpolation happen naturally
the way it does in all UNIX shell interfaces ("double quotes").  But, I don't
think there would be any hostility to adding a compatibility patch.  There is
already an Octave mode that attempts to be as compatible with Matlab as
possible (--traditional, also accessible as --braindead).  If interpolation
inside single quoted strings was confined to a few places in Octave, and only
when explicitly enabled, that would actually make sense.  Octave tries to be a
superset of Matlab in that we can always run their code, but they may not be
able to run ours.

If you're interested in working on this we can take the discussion to the
Octave Maintainers mailing list and work out a strategy.  Just to see how this
would go I looked at the case for regexprep.  The relevant code is line 1049
of regexp.cc in the src/DLD-FUNCTIONS directory.

const std::string replacement = args(2).string_value ();

At this point, a C++ string is created from the single-quoted, non-interpreted
string that was typed at the command prompt.  It would be easy to drop the
"const" declaration and then implement the interpolation manually.

if (matlab_traditional_mode)
  {
    // Series of replacements such as "\" => ""
   }

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?35911>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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