bugGNU Octave - Bugs: bug #42111, ans = [] for input()

 
 

bug #42111: ans = [] for input()

Submitter:  Ben Abbott <bpabbott>
Submitted:  Sun 13 Apr 2014 09:34:35 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Ben Abbott Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 24 Apr 2014 09:10:28 PM UTC, comment #2: 

I pushed a patch that handles nargout=0 as well as preserving an arbitrary number for nargout (http://hg.savannah.gnu.org/hgweb/octave/rev/1dcc9539234c).  I also cleaned up the documentation to expand on the fact that the number of outputs, their size, and their class depend on the expression that is input.

Rik <rik5>
Group administrator
Tue 15 Apr 2014 10:33:41 AM UTC, comment #1: 

FYI:

>> [a b] = input('Give me nargout=2: ')
Give me nargout=2: deal(1,2)

a =

     1


b =

     2


works in Matlab 2012b and Octave 3.8.0. I did not try out your patch, but nargout>1 should be kept working.

By the way: Contrary to the behavior above, the documentation in 3.8.0 still states that "Currently, `input' only returns one value, regardless of the number of values produced by the evaluation of the expression."

Markus Appel <mappel>
Sun 13 Apr 2014 09:34:35 PM UTC, original submission:  

The "input()" function returns an empty result when nargout = 0.

This was originally reported on the help list.

http://lists.gnu.org/archive/html/help-octave/2014-04/msg00131.html

The patch below works for me, but I'm not sure if this is a proper fix.


diff --git a/libinterp/corefcn/input.cc b/libinterp/corefcn/input.cc
--- a/libinterp/corefcn/input.cc
+++ b/libinterp/corefcn/input.cc
@@ -770,7 +770,7 @@
   int nargin = args.length ();

   if (nargin == 1 || nargin == 2)
-    retval = get_user_input (args, nargout);
+    retval = get_user_input (args, 1);
   else
     print_usage ();


Should "get_user_input ()" be modified to always return at least one arg?

Ben Abbott <bpabbott>
Group Member

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mappel (Posted a comment)
  • -email is unavailable- added by bpabbott (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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-04-24 rik5 StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code