help-octave
[Top][All Lists]
Advanced

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

Re: strcmp change?


From: John W. Eaton
Subject: Re: strcmp change?
Date: Mon, 7 Nov 2005 14:12:02 -0500

On  6-Nov-2005, Søren Hauberg wrote:

| søn, 06 11 2005 kl. 09:58 -0500, skrev John W. Eaton:
| > So probably the new function needs a bit more work.  It would be
| > useful if someone would suggest a patch.
| A quick-and-dirty hack (that appears to work just fine) is to change the
| the first line of the function body from
| 
| octave_value retval;
| 
| to
| 
| octave_value retval = false;

OK, I made a similar change.  The overall structure of strcmp was

  if (args.length () == 2)
    {
      ...

      if (s1_string && s2_string)
        {
          ...
        }
      else if ((s1_string && s2_cell) || (s1_cell && s2_string))
        {
          ...
        }
      else if (s1_cell && s2_cell)
        {
          ...
        }
    }
  else
    print_usage ("strcmp");

I changed it to

  if (args.length () == 2)
    {
      ...

      if (s1_string && s2_string)
        {
          ...
        }
      else if ((s1_string && s2_cell) || (s1_cell && s2_string))
        {
          ...
        }
      else if (s1_cell && s2_cell)
        {
          ...
        }
      else
        retval = false;
    }
  else
    print_usage ("strcmp");

I think your change had the same effect, but I prefer adding the else
clause because it seems to describe more explicitly what is happening.

Thanks,

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]