help-octave
[Top][All Lists]
Advanced

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

path() & strrep() notes/fix


From: Marc Compere
Subject: path() & strrep() notes/fix
Date: Sat, 6 Jan 2001 17:22:26 -0600

Octave 2.1.32 users,

        Upon compiling octave 2.1.32 on a fresh Redhat 7.0 linux system, I 
noticed 
the Matlab compatibility options (`octave --braindead`) were causing the path 
command to output numbers instead of strings.

The original problem:
        The problem seemed to come from strrep's output (from octave's own 
path.m) 
combined with the switch define_all_return_values=1.  This switch is flipped 
when you want Matlab compatibility and execute `octave --braindead` or if 
you've got this switch set in an octaverc or .octaverc file.

The underlying problem:
        Apparantly when define_all_return_values=1 octaves strrep.m returns a 
matrix 
(of numbers) instead of a string.  This may happen because the return 
value, t, within strrep.m is not defined as a string (early enough?)

A solution:
        Simply declaring the internal variable t as a string immediately after 
the 
function declaration within strrrep.m seems to fix the problem.  This is how 
/usr/local/share/octave/2.1.32/m/strings/strrep.m looked originally:
        ...
        function t = strrep (s, x, y)
          if (nargin != 3)
           ...

This is what strrep.m looks like after my fix:
        ...
        function t = strrep (s, x, y)
          t = ""; % initialize t as a string
          if (nargin != 3)
           ...


Example output:
        Now the following works properly regardless of whether or not 
define_all_return_values is 1 or 0:
        octave --braindead
           path(":~/m")
           path
           
           LOADPATH contains the following directories:
           
             
             ~/m
           
           ans = []

whereas the second path command above used to return:
           
           LOADPATH contains the following directories:
           
                    10       32       32      126       47      109
           
           ans = []



        I'm sure this is an unsophistocated kluge fix and welcome input from 
anyone 
with a better solution.

Regards,
Marc Compere

-- 
_________________________________________________
 Marc Compere, The University of Texas at Austin
 address@hidden, (512)471-7347,   <><
 http://nerdlab.me.utexas.edu/~compere
_________________________________________________



-------------------------------------------------------------
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]