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

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

[Octave-bug-tracker] [bug #52488] genvarname substitutes underscore to i


From: anonymous
Subject: [Octave-bug-tracker] [bug #52488] genvarname substitutes underscore to invalid characters in string
Date: Thu, 23 Nov 2017 11:16:15 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0

URL:
  <http://savannah.gnu.org/bugs/?52488>

                 Summary: genvarname substitutes underscore to invalid
characters in string
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Thu 23 Nov 2017 04:16:14 PM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: Motius
        Originator Email: address@hidden
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.2.1
        Operating System: GNU/Linux

    _______________________________________________________

Details:

= SYNOPSIS =

The following snippet illustrates diverging behaviors between Octave and
MatLab

= EXAMPLE =

genvarname("foo ")
genvarname('bar ')

= RESULTS =

Gives the following result under Octave:

'foo_'
'bar_'


and the following one under MatLab:

'foo'
'bar'


= VERSION =

Tested with Octave :
* v4.0.3;
* v4.2.1 (1a8b7b3ae5f2);

and MatLab v2017a

= PATCH =


diff -r cf33c1b910b7 scripts/miscellaneous/genvarname.m
--- a/scripts/miscellaneous/genvarname.m        Tue Nov 21 22:00:45 2017
-0800
+++ b/scripts/miscellaneous/genvarname.m        Thu Nov 23 16:49:24 2017
+0100
@@ -130,7 +130,7 @@
     ## a valid variable name.
 
     ## remove invalid characters
-    str{i}(! (isalnum (str{i}) | str{i} == "_")) = "_";
+    str{i}(! (isalnum (str{i}) | str{i} == "_")) = [];
     ## do not use keywords
     if (iskeyword (str{i}))
       firstcharacter = toupper (str{i}(1));



is a suggested patch.





    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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