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

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

[Octave-bug-tracker] [bug #65342] replace atoi with stoi


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #65342] replace atoi with stoi
Date: Sun, 24 Mar 2024 01:01:19 -0400 (EDT)

Follow-up Comment #7, bug #65342 (group octave):

The unused variable was fixed in
https://hg.savannah.gnu.org/hgweb/octave/rev/399be7cc310f

The error function throws an octave::execution_exception, which is not derived
from either std::invalid_argument or std::out_of_range, so it won't be caught
in the two catch blocks associated with this try block.

I'm not sure what I was thinking when I started that "I'm not sure what the"
comment, but it is not wrong, LOL!  Looking at it now, I'm still not sure what
the intent is there.  The original code was


if (atoi (arg.c_str ()) == 0)
  {
    // We have class and function names but already
    // stored the class name in fcn_name.
    class_name = fcn_name;
    fcn_name = arg;
    pos++;
    break;
  }


So maybe we should be doing something like


// FIXME: we really want to distinguish number
// vs. method name here.

bool int_conv_ok = true;

try
  {
    if (std::stoi (arg) == 0)
      error ("%s: invalid integer value for ???");
  }
catch (const std::invalid_argument&)
  {
    // Assume we are looking at a function name.
    // We have class and function names but already
    // stored the class name in fcn_name.
    class_name = fcn_name;
    fcn_name = arg;
    pos++;
    break;
  }
catch (const std::out_of_range&)
  {
    error ("%s: invalid integer value for ???");
  }


but I don't understand the reason for attempting the integer conversion if the
value will never be used.

There is a comment above this function that says


// FIXME: This function probably needs to be completely overhauled to
// correctly parse the full syntax of the dbstop command and properly
// reject incorrect forms.


Seems accurate to me.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?65342>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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