[Changeset]: Re: cla() ?

Ben Abbott bpabbott at mac.com
Mon Oct 6 14:15:03 CDT 2008


On Monday, October 06, 2008, at 02:02PM, "John W. Eaton" <jwe at bevo.che.wisc.edu> wrote:
>On  6-Oct-2008, Ben Abbott wrote:
>
>| Everything compiled and make check had no problem.
>| 
>| Given that I don't see any failures, does it make sense to also apply  
>| a changeset such as the one I've attached?
>| 
>| As my c++ skill is wanting, please review this proposal before  
>| committing.
>
>I don't see any C++ in this patch.
>
>| diff --git a/scripts/plot/__plt_get_axis_arg__.m b/scripts/plot/__plt_get_axis_arg__.m
>| --- a/scripts/plot/__plt_get_axis_arg__.m
>| +++ b/scripts/plot/__plt_get_axis_arg__.m
>| @@ -32,8 +32,8 @@
>|  
>|    ## Figure handles are integers, but object handles are non integer,
>|    ## therefore ignore integer scalars.
>| -  if (nargin > 1 && length (varargin) > 0 && ishandle (varargin{1})
>| -      && floor(varargin{1}) != varargin{1})
>| +  if (nargin > 1 && length (varargin) > 0 && numel(varargin{1}) == 1 && ishandle (varargin{1}(1))
>| +      && floor(varargin{1}(1)) != varargin{1}(1))
>
>I think a test like
>
>  floor(varargin{1}(1)) != varargin{1}(1))
>
>depends too much on the current implementation of figure handles.
>Maybe it would be better to use "! isfigure (varargin{1}(1))" instead?
>
>| diff --git a/scripts/plot/hold.m b/scripts/plot/hold.m
>| --- a/scripts/plot/hold.m
>| +++ b/scripts/plot/hold.m
>| @@ -44,8 +44,10 @@
>|  
>|  function hold (varargin)
>|  
>| -  if (nargin > 0 && ishandle (varargin{1}))
>| +  if (nargin > 0 && numel (varargin{1}) == 1 && ishandle (varargin{1}(1)))
>|      [h, varargin, nargs] = __plt_get_axis_arg__ ("hold", varargin{:});
>| +  elseif (nargin > 0 && numel (varargin{1}) > 1 && ishandle (varargin{1}(1)))
>| +    error ('Invalid input or option')
>
>Unless you can provide a better diagnostic, I think this should just
>be a call to print_usage.
>
>jwe

ok. I've made those changes ... "make check" went fine.

Ben

-------------- next part --------------
# HG changeset patch
# User Ben Abbott <bpabbott at mac.com>
# Date 1223319773 14400
# Node ID bc0e9f539265ce5c9fd0d782305a751b7d1bcc35
# Parent  277218396978303b29d49502590d507afd47dc9f
Remove reliance on ishandle(vec) == false.

diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,10 @@
+2008-09-24 Ben Abbott <bpabbott at mac.com>
+
+	* plot/orient.m: Fig handle must be scalar.
+	* plot/hold.m: Axis handle must be scalar.
+	* plot/axes.m: Axis handle must be scalar.
+	* plot/__plt_get_axis_arg__.m: Handle must be scalar.
+
 2008-10-02  John W. Eaton  <jwe at octave.org>
 
 	* pkg/pkg.m (configure_make): Handle filenames with spaces.
diff --git a/scripts/plot/__plt_get_axis_arg__.m b/scripts/plot/__plt_get_axis_arg__.m
--- a/scripts/plot/__plt_get_axis_arg__.m
+++ b/scripts/plot/__plt_get_axis_arg__.m
@@ -32,8 +32,8 @@
 
   ## Figure handles are integers, but object handles are non integer,
   ## therefore ignore integer scalars.
-  if (nargin > 1 && length (varargin) > 0 && ishandle (varargin{1})
-      && floor(varargin{1}) != varargin{1})
+  if (nargin > 1 && length (varargin) > 0 && numel(varargin{1}) == 1 && ishandle (varargin{1}(1))
+      && ! isfigure (varargin{1}(1)))
     tmp = varargin{1};
     obj = get (tmp);
     if (strcmp (obj.type, "axes") || strcmp (obj.type, "hggroup"))
diff --git a/scripts/plot/axes.m b/scripts/plot/axes.m
--- a/scripts/plot/axes.m
+++ b/scripts/plot/axes.m
@@ -43,12 +43,12 @@
     ## arg is axes handle, make it the current axes for the current
     ## figure.
     tmp = varargin{1};
-    if (ishandle (tmp) && strcmp (get (tmp, "type"), "axes"))
+    if (length(tmp) == 1 && ishandle (tmp) && strcmp (get (tmp, "type"), "axes"))
       parent = ancestor (tmp, "figure");
       set (0, "currentfigure", parent);
       set (parent, "currentaxes", tmp);
     else
-      error ("axes: expecting argument to be axes handle");
+      error ("axes: expecting argument to be a scalar axes handle");
     endif
   endif
 
diff --git a/scripts/plot/hold.m b/scripts/plot/hold.m
--- a/scripts/plot/hold.m
+++ b/scripts/plot/hold.m
@@ -44,8 +44,10 @@
 
 function hold (varargin)
 
-  if (nargin > 0 && ishandle (varargin{1}))
+  if (nargin > 0 && numel (varargin{1}) == 1 && ishandle (varargin{1}(1)))
     [h, varargin, nargs] = __plt_get_axis_arg__ ("hold", varargin{:});
+  elseif (nargin > 0 && numel (varargin{1}) > 1 && ishandle (varargin{1}(1)))
+    print_usage ();
   else
     h = gcf ();
     nargs = numel (varargin);
diff --git a/scripts/plot/orient.m b/scripts/plot/orient.m
--- a/scripts/plot/orient.m
+++ b/scripts/plot/orient.m
@@ -32,7 +32,7 @@
 
   nargs = nargin;
 
-  if (nargs > 0 && ishandle (varargin{1}))
+  if (nargs > 0 && numel (varargin{1}) == 1 && ishandle (varargin{1}))
     cf = varargin{1};
     varargin(1) = [];
     nargs--;


More information about the Octave-maintainers mailing list