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

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

[Octave-bug-tracker] [bug #33537] lower function returns incorect result


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #33537] lower function returns incorect result on numerical values
Date: Wed, 27 Jul 2011 18:17:55 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.19) Gecko/20110430 Iceweasel/3.5.19 (like Firefox/3.5.19)

Update of bug #33537 (project octave):

             Open/Closed:                  Closed => Open                   

    _______________________________________________________

Follow-up Comment #10:

Thanks for looking at this problem.  I apologize for not commenting on your
patch before you committed it as I maybe could have saved you some trouble.

I think it would be better to not check for types in the toupper and tolower
functions.  Note that there are similar problems with isascii, isdigit, etc.
(all the ctype functions).

Probably the right place to fix this is in the code that deals with this case
in each object.  For example, ov-scalar.cc has the following code:


octave_value
octave_scalar::map (unary_mapper_t umap) const
{
  switch (umap)
    {
    ...

    default:
      if (umap >= umap_xisalnum && umap <= umap_xtoupper)
        {
          octave_value str_conv = convert_to_str (true, true);
          return error_state ? octave_value () : str_conv.map (umap);
        }
      else
        return octave_base_value::map (umap);


If you want an error message, then you could just remove the first part of the
if condition that converts the argument to a character string before applying
the mapper.

Or, if you want Matlab-compatible behavior, you could do that here as well by
returning the value unchanged for tolower and toupper, and returning a logical
false value for the other is* functions.

Similar code appears in ov-re-mat.cc.  So I think this must have been an
attempt to handle special cases for full double matrices in a way that was
compatible with Matlab at some point in the past.  I'm still OK with having
error messages for incorrect types, but I think we should still simply forward
in the tolower and toupper functions so that we are consistent with all the
other is* mappers.

Also, forwarding for all types instead of checking types in tolower and
toupper allows other types that might be added in the future to get a chance
to do something useful with the toupper and tolower mappers without having to
modify the DEFUNs for these functions.

I'm reopining this report so these issues won't be forgotten.

    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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