changeset 17136:327862500f1c

ishold.m: Recode to follow modern Octave coding conventions. * scripts/plot/ishold.m: Put input validation first. Change error messages to reference bad input variable by name. Don't use unnecessary strcmpi when strcmp will work.
author Rik <rik@octave.org>
date Wed, 31 Jul 2013 22:28:07 -0700
parents 9d9fe4361870
children ea19ea629a09
files scripts/plot/ishold.m
diffstat 1 files changed, 13 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/ishold.m
+++ b/scripts/plot/ishold.m
@@ -30,29 +30,31 @@
 
 function retval = ishold (h)
 
+  if (nargin > 1)
+    print_usage ();
+  endif
+
   if (nargin == 0)
     fig = gcf ();
     ax = get (fig, "currentaxes");
-  elseif (nargin == 1)
+  else
     if (ishandle (h))
-      if (isfigure (h))
-        ax = get (h, "currentaxes");
+      if (strcmp (get (h, "type"), "figure"))
         fig = h;
-      elseif (strcmpi (get (h, "type"), "axes"))
+        ax = get (fig, "currentaxes");
+      elseif (strcmp (get (h, "type"), "axes"))
         ax = h;
-        fig = get (h, "parent");
+        fig = get (ax, "parent");
       else
-        error ("ishold: expecting argument to be axes or figure graphics handle");
+        error ("ishold: H must be an axes or figure graphics handle");
       endif
     else
-      error ("ishold: expecting argument to be axes or figure graphics handle");
+      error ("ishold: H must be an axes or figure graphics handle");
     endif
-  else
-    print_usage ();
   endif
 
-  retval = (strcmpi (get (fig, "nextplot"), "add")
-            && ! isempty (ax) && strcmpi (get (ax, "nextplot"), "add"));
+  retval = (strcmp (get (fig, "nextplot"), "add")
+            && ! isempty (ax) && strcmp (get (ax, "nextplot"), "add"));
 
 endfunction