changeset 32157:abce709e0b60

inputParser.m: streamline code for cset addd99059d4c (bug #64305) * inputParser.m: Use parentheses around conditional in if statement per Octave coding guidelines. Use '{ ... }' cell construction rather than creating temporary variable.
author Rik <rik@octave.org>
date Wed, 21 Jun 2023 10:47:50 -0700
parents cec8bd93ca10
children 583c0ed2bc8f
files scripts/miscellaneous/inputParser.m
diffstat 1 files changed, 3 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/miscellaneous/inputParser.m	Wed Jun 21 13:37:45 2023 -0400
+++ b/scripts/miscellaneous/inputParser.m	Wed Jun 21 10:47:50 2023 -0700
@@ -358,13 +358,9 @@
       endif
 
       this.validate_name ("Parameter", name);
-      if iscell(def)
-        ## Allow constructs like these (bug #64305)
-        ##    p = inputParser;
-        ##    p.addParameter('p3', {});
-        tmp = struct ("name", name, "def", [], "val", val);
-        tmp.def = def;
-        this.Parameter(end+1) = tmp;
+      if (iscell (def))
+        ## Accept cell default values (bug #64305).
+        this.Parameter(end+1) = struct ("name", name, "def", {def}, "val", val);
       else
         this.Parameter(end+1) = struct ("name", name, "def", def, "val", val);
       endif