changeset 27076:39b4341c3376

msgbox.m: Allow OPT argument in second position (bug #56260). * msgbox.m: Redo input validation to allow OPT argument in any position after the first. Add BIST test for bug #56260.
author Rik <rik@octave.org>
date Fri, 03 May 2019 14:04:29 -0700
parents fb427fafd494
children 4e69b99978b0
files scripts/gui/msgbox.m
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/gui/msgbox.m	Wed May 01 12:33:55 2019 +0200
+++ b/scripts/gui/msgbox.m	Fri May 03 14:04:29 2019 -0700
@@ -94,9 +94,18 @@
     print_usage ();
   elseif (! ischar (msg) && ! iscellstr (msg))
     error ("msgbox: MSG must be a string or cell array of strings");
+  endif
+  if (isstruct (tit))
+    if (nargin != 2)
+      error ("msgbox: OPT must be last argument");
+    endif
+    varargin{end+1} = tit;
+    nargs += 1;
+    tit = "";
   elseif (! ischar (tit))
     error ("msgbox: TITLE must be a string");
-  elseif (isstruct (icon))
+  endif
+  if (isstruct (icon))
     varargin{end+1} = icon;
     nargs += 1;
     icon = "none";
@@ -327,6 +336,7 @@
 
 ## Test input validation
 %!error <MSG must be a string or cell array of strings> msgbox (1)
+%!error <OPT must be last argument> msgbox ("msg", struct(), "title")
 %!error <TITLE must be a string> msgbox ("msg", 1)
 %!error <unhandled value for ICON data> msgbox ("msg", "title", 1)
 %!error <missing data for 'custom' icon> msgbox ("msg", "title", "custom")