Mercurial > octave
changeset 23330:1eb2706a6125
Handle second argument in classes with overridden display function (bug #49794).
* scripts/@ftp/display.m: Display variable name, if passed as second argument.
* scripts/audio/@audioplayer/display.m, scripts/audio/@audiorecorder/display.m:
nargin can no longer assumed to be exactly one. Therefore display the variable
name if passed as second argument. This change happened for inputParser before
https://hg.savannah.gnu.org/hgweb/octave/rev/05cfbffd5f79.
author | Kai T. Ohlhus <k.ohlhus@gmail.com> |
---|---|
date | Tue, 28 Mar 2017 11:43:43 +0200 |
parents | 2613334bafb2 |
children | 665f0a73429a |
files | scripts/@ftp/display.m scripts/audio/@audioplayer/display.m scripts/audio/@audiorecorder/display.m |
diffstat | 3 files changed, 18 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/@ftp/display.m Tue Mar 28 10:36:02 2017 +0200 +++ b/scripts/@ftp/display.m Tue Mar 28 11:43:43 2017 +0200 @@ -16,7 +16,14 @@ ## along with Octave; see the file COPYING. If not, see ## <http://www.gnu.org/licenses/>. -function display (obj) +function display (obj, name) + if ((nargin > 2) || ((nargin == 2) && ~ischar (name))) + print_usage (); + endif + if (nargin == 2) + printf ("%s = ", name); + endif + printf ("FTP Object\n"); printf (" host: %s\n", obj.host); printf (" user: %s\n", obj.username);
--- a/scripts/audio/@audioplayer/display.m Tue Mar 28 10:36:02 2017 +0200 +++ b/scripts/audio/@audioplayer/display.m Tue Mar 28 11:43:43 2017 +0200 @@ -21,12 +21,13 @@ ## Display the properties of the audioplayer object @var{player}. ## @end deftypefn -function display (player) - - if (nargin != 1) +function display (player, name) + if ((nargin > 2) || ((nargin == 2) && ~ischar (name))) print_usage (); endif + if (nargin == 2) + printf ("%s = ", name); + endif disp (__get_properties__ (player)); - endfunction
--- a/scripts/audio/@audiorecorder/display.m Tue Mar 28 10:36:02 2017 +0200 +++ b/scripts/audio/@audiorecorder/display.m Tue Mar 28 11:43:43 2017 +0200 @@ -21,12 +21,13 @@ ## Display the properties of the audiorecorder object @var{recorder}. ## @end deftypefn -function display (recorder) - - if (nargin != 1) +function display (recorder, name) + if ((nargin > 2) || ((nargin == 2) && ~ischar (name))) print_usage (); endif + if (nargin == 2) + printf ("%s = ", name); + endif disp (__get_properties__ (recorder)); - endfunction