bugGNU Octave - Bugs: bug #40904, WHAT function should return all...


bug #40904: WHAT function should return all available results for MATLAB compatibility

Submitter:  Ben Kurtz <bkurtz>
Submitted:  Sun 15 Dec 2013 11:39:40 PM UTC
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Ben Kurtz Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Fri 03 Jan 2020 07:23:19 PM UTC, comment #2: 

This bug is ancient but I have been doing a lot of work today to clean up what.m ahead of the 6.1 release.  I made changes along the lines suggested in this report and checked things in here https://hg.savannah.gnu.org/hgweb/octave/rev/121d33ab44bc.

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Mon 11 Jul 2016 12:44:27 PM UTC, comment #1: 

I've freshened this patch, made formatting compliant with Octave's standards, and updated the docstring.

I haven't (yet) verified that this behaviour matches Matlab's.

(file #37801)

Lachlan Andrew <lachlan>
Sun 15 Dec 2013 11:39:40 PM UTC, original submission:  

In matlab, the what() function returns a struct array with items that correspond to 1) any matching directories in the matlab path, 2) a matching directory relative to the current directory if one exists.  If there are no matching items, it returns an empty struct array.

Octave's current implementation returns the matching path (#2) if it exists, or else the first of the matching directories in the path, per (#1).  If nothing is found, octave throws an error.

Attached is a patch that I believe replicates MATLAB's functionality, including:
1) creating a subfunction for extracting the info that 'what' reports to make it easier to report for multiple matches
2) concatenating (with unique()) the available matches rather than taking the first one
3) omitting the error message if no matches occur and instead returning the empty struct array.

Ben Kurtz <bkurtz>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #37801:  bug_40904_what.cset added by lachlan (3KiB - text/x-diff)
file #29930:  what_multi.patch added by bkurtz (2KiB - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by lachlan (Updated the item)
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by bkurtz (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.


    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-01-03 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2016-07-11 lachlan Attached File- Added bug_40904_what.cset, #37801
    2013-12-16 rik5 StatusNone Patch Submitted
    2013-12-15 bkurtz Attached File- Added what_multi.patch, #29930

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code