changeset 14600:32e53ccdf0ca gui

Merged with remote branch.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Mon, 07 May 2012 00:56:44 +0200
parents 97cb9286919c (current diff) e4d380c01dcf (diff)
children 772ce0204b3f
files libcruft/slatec-fn/derfc.f libcruft/slatec-fn/erfc.f src/defaults.h.in src/graphics.h.in src/mkoctfile.cc.in src/mkoctfile.in src/mxarray.h.in src/oct-conf.h.in src/oct-errno.cc.in src/octave-config.cc.in src/octave-config.in src/version.h.in
diffstat 269 files changed, 16252 insertions(+), 13235 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Mon May 07 00:53:54 2012 +0200
+++ b/.hgtags	Mon May 07 00:56:44 2012 +0200
@@ -62,3 +62,5 @@
 95c43fc8dbe1a07a46fefb3372df5b2309d874fd rc-3-6-1-0
 0000000000000000000000000000000000000000 release-3-2-4
 e320928eeb3aa2370b792e83dafc3e0ddecdc871 release-3-2-4
+ba4d6343524b406b0d15aee34579f80783581c54 release-3-6-1
+704f7895eef03008dd79848eb9da4bfb40787d73 release-3-6-0
--- a/NEWS	Mon May 07 00:53:54 2012 +0200
+++ b/NEWS	Mon May 07 00:56:44 2012 +0200
@@ -6,6 +6,59 @@
 Summary of important user-visible changes for version 3.8:
 ---------------------------------------------------------
 
+ ** Octave now supports nested functions with scoping rules that are
+    compatible with Matlab.  A nested function is one declared and defined
+    within the body of another function.  The nested function is only
+    accessible from within the enclosing function which makes it one
+    method for making private functions whose names do not conflict with those
+    in the global namespace (See also subfunctions and private functions).
+    In addition, variables in the enclosing function are visible within the
+    nested function.  This makes it possible to have a pseudo-global variable
+    which can be seen by a group of functions, but which is not visible in
+    the global namespace.
+    
+    Example:
+    function outerfunc (...)
+      ...
+      function nested1 (...)
+        ...
+        function nested2 (...)
+           ...
+        endfunction
+      endfunction
+
+      function nested3 (...)
+        ...
+      endfunction
+    endfunction
+
+ ** 'emptymatch', 'noemptymatch' options added to regular expressions.
+
+    With this addition Octave now accepts the entire set of Matlab options
+    for regular expressions.  'noemptymatch' is the default, but 'emptymatch'
+    has certain uses where you need to match an assertion rather than actual
+    characters.  For example, 
+
+    regexprep ('World', '^', 'Hello ', 'emptymatch')
+      => Hello World
+
+    where the pattern is actually the assertion '^' or start-of-line.
+
+ ** For compatibility with Matlab, the regexp, regexpi, and regexprep
+    functions now process backslash escapes in single-quoted pattern
+    strings.  In addition, the regexprep function now processes backslash
+    escapes in single-quoted replacement strings.
+
+ ** Redundant terminal comma accepted by parser
+
+    A redundant terminal comma is now accepted in matrix
+    definitions which allows writing code such as 
+
+    [a,...
+     b,...
+     c,...
+    ] = deal (1,2,3)
+
  ** Warning IDs renamed:
 
     Octave:array-as-scalar => Octave:array-to-scalar
@@ -13,9 +66,10 @@
 
  ** Other new functions added in 3.8.0:
 
-      colorcube
-      lines
-      rgbplot
+      colorcube   splinefit
+      lines       tetramesh
+      rgbplot     shrinkfaces
+      findfigs
 
  ** Deprecated functions.
 
--- a/build-aux/common.mk	Mon May 07 00:53:54 2012 +0200
+++ b/build-aux/common.mk	Mon May 07 00:56:44 2012 +0200
@@ -90,6 +90,8 @@
 F77_APPEND_UNDERSCORE=@F77_TOLOWER@
 F77_APPEND_EXTRA_UNDERSCORE=@F77_TOLOWER@
 
+F77_ISNAN_MACRO=@F77_ISNAN_MACRO@
+
 X11_INCFLAGS = @X11_INCFLAGS@
 X11_LIBS = @X11_LIBS@
 
--- a/configure.ac	Mon May 07 00:53:54 2012 +0200
+++ b/configure.ac	Mon May 07 00:56:44 2012 +0200
@@ -196,7 +196,6 @@
      AC_MSG_WARN([$warn_docs])
    fi], [])
 AC_SUBST(DOCDIR)
-AM_CONDITIONAL([AMCOND_BUILD_DOCS], [test -n "$DOCDIR"])
 
 ### If possible, use a 64-bit integer type for array dimensions and indexing.
 
@@ -593,6 +592,14 @@
   AC_MSG_ERROR([in order to build octave, you must have a compatible Fortran compiler or wrapper script for f2c that functions as a Fortran compiler installed and in your path.  See the file INSTALL for more information.])
 fi
 
+OCTAVE_CHECK_FORTRAN_HAVE_ISNAN
+F77_ISNAN_MACRO=
+if test "x$octave_cv_fortran_have_isnan" = xno; then
+   AC_MSG_NOTICE([substituting ISNAN(X) with X.NE.X in fortran sources])
+   F77_ISNAN_MACRO="s|ISNAN(\(@<:@^)@:>@*\))|(\1.NE.\1)|"
+fi
+AC_SUBST(F77_ISNAN_MACRO)
+
 OCTAVE_CHECK_FORTRAN_INTEGER_SIZE
 if test "x$octave_cv_fortran_integer_size" = xno; then
   if $USE_64_BIT_IDX_T; then
@@ -2109,7 +2116,7 @@
     AC_LANG_PROGRAM([
       #include <unordered_map>
     ], [
-      std::unordered_map m;
+      std::unordered_map<int,int> m;
     ])], [], [unordered_map_requires_tr1_namespace=yes])
 elif test "$ac_cv_header_tr1_unordered_map" = "yes"; then
   unordered_map_requires_tr1_namespace=yes
@@ -2407,6 +2414,16 @@
 OCTAVE_PROG_TEXI2DVI
 OCTAVE_PROG_TEXI2PDF
 
+### Need to disable building documentation if gnuplot was not found,
+### unless it was already disabled previously.
+
+if test -n "$DOCDIR" && test -n "$warn_gnuplot"; then
+  DOCDIR=
+  warn_docs="building documentation disabled because gnuplot was not found; make dist will fail"
+  AC_MSG_WARN([$warn_docs])
+fi
+AM_CONDITIONAL([AMCOND_BUILD_DOCS], [test -n "$DOCDIR"])
+
 ### Even though we include config.h, we need to have the preprocessor
 ### defines available in a variable for the testif feature of the
 ### scripts/testfun/test.m function.  Use UGLY_DEFS to hold all the -D
--- a/doc/interpreter/contributors.in	Mon May 07 00:53:54 2012 +0200
+++ b/doc/interpreter/contributors.in	Mon May 07 00:56:44 2012 +0200
@@ -20,6 +20,7 @@
 Richard Bovey
 John Bradshaw
 Marcus Brinkmann
+Max Brister
 Remy Bruno
 Ansgar Burchard
 Marco Caliari
--- a/doc/interpreter/doccheck/aspell-octave.en.pws	Mon May 07 00:53:54 2012 +0200
+++ b/doc/interpreter/doccheck/aspell-octave.en.pws	Mon May 07 00:56:44 2012 +0200
@@ -66,6 +66,7 @@
 binopdf
 binornd
 Biomathematics
+bitmapped
 bitmax
 bitwise
 bivariate
@@ -830,6 +831,7 @@
 Spearman's
 speye
 spfun
+splinefit
 spmatrix
 spones
 spparms
@@ -1039,6 +1041,7 @@
 wp
 wspace
 xb
+xc
 xcorr
 xdigit
 xerrorbar
@@ -1060,6 +1063,7 @@
 xyerrorbar
 xyerrorbars
 xyz
+yc
 ydata
 yerrorbar
 yerrorbars
--- a/doc/interpreter/geometry.txi	Mon May 07 00:53:54 2012 +0200
+++ b/doc/interpreter/geometry.txi	Mon May 07 00:56:44 2012 +0200
@@ -96,6 +96,7 @@
 
 Octave has the functions @code{triplot}, @code{trimesh}, and @code{trisurf}
 to plot the Delaunay triangulation of a 2-dimensional set of points.
+@code{tetramesh} will plot the triangulation of a 3-dimensional set of points.
 
 @DOCSTRING(triplot)
 
@@ -103,6 +104,8 @@
 
 @DOCSTRING(trisurf)
 
+@DOCSTRING(tetramesh)
+
 The difference between @code{triplot}, and @code{trimesh} or @code{triplot},
 is that the former only plots the 2-dimensional triangulation itself, whereas
 the second two plot the value of a function @code{f (@var{x}, @var{y})}.  An
--- a/doc/interpreter/images	Mon May 07 00:53:54 2012 +0200
+++ b/doc/interpreter/images	Mon May 07 00:56:44 2012 +0200
@@ -2,3 +2,4 @@
 interpimages.m interpft interpn interpderiv1 interpderiv2
 plotimages.m plot hist errorbar polar mesh plot3 extended
 sparseimages.m gplot grid spmatrix spchol spcholperm
+splineimages.m splinefit1 splinefit2 splinefit3 splinefit4 splinefit6
--- a/doc/interpreter/install.txi	Mon May 07 00:53:54 2012 +0200
+++ b/doc/interpreter/install.txi	Mon May 07 00:56:44 2012 +0200
@@ -65,13 +65,13 @@
 yourself.
 
 @menu
-* Obtaining the Depencies Automatically::
+* Obtaining the Dependencies Automatically::
 * Build Tools::
 * External Packages::
 @end menu
 
-@node Obtaining the Depencies Automatically
-@subsection Obtaining the Depencies Automatically
+@node Obtaining the Dependencies Automatically
+@subsection Obtaining the Dependencies Automatically
 
 On some systems you can obtain many of Octave's build dependencies
 automatically. The commands for doing this vary by system. Similarly,
--- a/doc/interpreter/octave.texi	Mon May 07 00:53:54 2012 +0200
+++ b/doc/interpreter/octave.texi	Mon May 07 00:56:44 2012 +0200
@@ -890,7 +890,7 @@
 
 Build Dependencies
 
-* Obtaining the Depencies Automatically::
+* Obtaining the Dependencies Automatically::
 * Build Tools::
 * External Packages::
 
--- a/doc/interpreter/plot.txi	Mon May 07 00:53:54 2012 +0200
+++ b/doc/interpreter/plot.txi	Mon May 07 00:56:44 2012 +0200
@@ -363,6 +363,8 @@
 
 @DOCSTRING(isocolors)
 
+@DOCSTRING(shrinkfaces)
+
 @DOCSTRING(diffuse)
 
 @DOCSTRING(specular)
@@ -1152,6 +1154,8 @@
 
 @DOCSTRING(allchild)
 
+@DOCSTRING(findfigs)
+
 @node Graphics Object Properties
 @subsection Graphics Object Properties
 @cindex graphics object properties
--- a/doc/interpreter/poly.txi	Mon May 07 00:53:54 2012 +0200
+++ b/doc/interpreter/poly.txi	Mon May 07 00:56:44 2012 +0200
@@ -132,18 +132,230 @@
 Octave comes with good support for various kinds of interpolation,
 most of which are described in @ref{Interpolation}.  One simple alternative
 to the functions described in the aforementioned chapter, is to fit
-a single polynomial to some given data points.  To avoid a highly
-fluctuating polynomial, one most often wants to fit a low-order polynomial
-to data.  This usually means that it is necessary to fit the polynomial
-in a least-squares sense, which just is what the @code{polyfit} function does.
+a single polynomial, or a piecewise polynomial (spline) to some given
+data points.  To avoid a highly fluctuating polynomial, one most often
+wants to fit a low-order polynomial to data.  This usually means that it
+is necessary to fit the polynomial in a least-squares sense, which just
+is what the @code{polyfit} function does.
 
 @DOCSTRING(polyfit)
 
 In situations where a single polynomial isn't good enough, a solution
-is to use several polynomials pieced together.  The function @code{mkpp}
-creates a piecewise polynomial, @code{ppval} evaluates the function 
-created by @code{mkpp}, and @code{unmkpp} returns detailed information
-about the function.
+is to use several polynomials pieced together.  The function
+@code{splinefit} fits a peicewise polynomial (spline) to a set of
+data.
+
+@DOCSTRING(splinefit)
+
+The number of @var{breaks} (or knots) used to construct the piecewise
+polynomial is a significant factor in suppressing the noise present in
+the input data, @var{x} and @var{y}. This is demostrated by the example
+below.
+
+@example
+@group
+x = 2 * pi * rand (1, 200);
+y = sin (x) + sin (2 * x) + 0.2 * randn (size (x));
+## Uniform breaks
+breaks = linspace (0, 2 * pi, 41); % 41 breaks, 40 pieces
+pp1 = splinefit (x, y, breaks);
+## Breaks interpolated from data
+pp2 = splinefit (x, y, 10);  % 11 breaks, 10 pieces
+## Plot
+xx = linspace (0, 2 * pi, 400);
+y1 = ppval (pp1, xx);
+y2 = ppval (pp2, xx);
+plot (x, y, ".", xx, [y1; y2])
+axis tight
+ylim auto
+legend (@{"data", "41 breaks, 40 pieces", "11 breaks, 10 pieces"@})
+@end group
+@end example
+
+@ifnotinfo
+@noindent
+The result of which can be seen in @ref{fig:splinefit1}.
+
+@float Figure,fig:splinefit1
+@center @image{splinefit1,4in}
+@caption{Comparison of a fitting a piecewise polynomial with 41 breaks to one
+with 11 breaks. The fit with the large number of breaks exhibits a fast ripple
+that is not present in the underlying function.}
+@end float
+@end ifnotinfo
+
+The piece-wise polynomial fit, provided by @code{splinefit}, has
+continuous derivatives up to the @var{order}-1. For example, a cubic fit
+has continuous first and second derivatives.   This is demonstrated by
+the code
+
+@example
+@group
+## Data (200 points)
+x = 2 * pi * rand (1, 200);
+y = sin (x) + sin (2 * x) + 0.1 * randn (size (x));
+## Piecewise constant
+pp1 = splinefit (x, y, 8, "order", 0);
+## Piecewise linear
+pp2 = splinefit (x, y, 8, "order", 1);
+## Piecewise quadratic
+pp3 = splinefit (x, y, 8, "order", 2);
+## Piecewise cubic
+pp4 = splinefit (x, y, 8, "order", 3);
+## Piecewise quartic
+pp5 = splinefit (x, y, 8, "order", 4);
+## Plot
+xx = linspace (0, 2 * pi, 400);
+y1 = ppval (pp1, xx);
+y2 = ppval (pp2, xx);
+y3 = ppval (pp3, xx);
+y4 = ppval (pp4, xx);
+y5 = ppval (pp5, xx);
+plot (x, y, ".", xx, [y1; y2; y3; y4; y5])
+axis tight
+ylim auto
+legend (@{"data", "order 0", "order 1", "order 2", "order 3", "order 4"@})
+@end group
+@end example
+
+@ifnotinfo
+@noindent
+The result of which can be seen in @ref{fig:splinefit2}.
+
+@float Figure,fig:splinefit2
+@center @image{splinefit2,4in}
+@caption{Comparison of a piecewise constant, linear, quadratic, cubic, and
+quartic polynomials with 8 breaks to noisy data. The higher order solutions
+more accurately represent the underlying function, but come with the
+expense of computational complexity.}
+@end float
+@end ifnotinfo
+
+When the underlying function to provide a fit to is periodic, @code{splinefit}
+is able to apply the boundary conditions needed to manifest a periodic fit.
+This is demonstrated by the code below.
+
+@example
+@group
+## Data (100 points)
+x = 2 * pi * [0, (rand (1, 98)), 1];
+y = sin (x) - cos (2 * x) + 0.2 * randn (size (x));
+## No constraints
+pp1 = splinefit (x, y, 10, "order", 5);
+## Periodic boundaries
+pp2 = splinefit (x, y, 10, "order", 5, "periodic", true);
+## Plot
+xx = linspace (0, 2 * pi, 400);
+y1 = ppval (pp1, xx);
+y2 = ppval (pp2, xx);
+plot (x, y, ".", xx, [y1; y2])
+axis tight
+ylim auto
+legend (@{"data", "no constraints", "periodic"@})
+@end group
+@end example
+
+@ifnotinfo
+@noindent
+The result of which can be seen in @ref{fig:splinefit3}.
+
+@float Figure,fig:splinefit3
+@center @image{splinefit3,4in}
+@caption{Comparison of piecewise polynomial fits to a noisy periodic
+function with, and without, periodic boundary conditions.}
+@end float
+@end ifnotinfo
+
+More complex constraints may be added as well. For example, the code below
+illustrates a periodic fit with values that have been clamped at the end points,
+and a second periodic fit which is hinged at the end points.
+
+@example
+@group
+## Data (200 points)
+x = 2 * pi * rand (1, 200);
+y = sin (2 * x) + 0.1 * randn (size (x));
+## Breaks
+breaks = linspace (0, 2 * pi, 10);
+## Clamped endpoints, y = y' = 0
+xc = [0, 0, 2*pi, 2*pi];
+cc = [(eye (2)), (eye (2))];
+con = struct ("xc", xc, "cc", cc);
+pp1 = splinefit (x, y, breaks, "constraints", con);
+## Hinged periodic endpoints, y = 0
+con = struct ("xc", 0);
+pp2 = splinefit (x, y, breaks, "constraints", con, "periodic", true);
+## Plot
+xx = linspace (0, 2 * pi, 400);
+y1 = ppval (pp1, xx);
+y2 = ppval (pp2, xx);
+plot (x, y, ".", xx, [y1; y2])
+axis tight
+ylim auto
+legend (@{"data", "clamped", "hinged periodic"@})
+@end group
+@end example
+
+@ifnotinfo
+@noindent
+The result of which can be seen in @ref{fig:splinefit4}.
+
+@float Figure,fig:splinefit4
+@center @image{splinefit4,4in}
+@caption{Comparison of two periodic piecewise cubic fits to a noisy periodic
+signal. One fit has its end points clamped and the second has its end points
+hinged.}
+@end float
+@end ifnotinfo
+
+The @code{splinefit} function also provides the convenience of a @var{robust}
+fitting, where the effect of outlying data is reduced.  In the example below,
+three different fits are provided.  Two with differing levels of outlier
+suppression and a third illustrating the non-robust solution.
+
+@example
+@group
+## Data
+x = linspace (0, 2*pi, 200);
+y = sin (x) + sin (2 * x) + 0.05 * randn (size (x));
+## Add outliers
+x = [x, linspace(0,2*pi,60)];
+y = [y, -ones(1,60)];
+## Fit splines with hinged conditions
+con = struct ("xc", [0, 2*pi]);
+## Robust fitting, beta = 0.25
+pp1 = splinefit (x, y, 8, "constraints", con, "beta", 0.25);
+## Robust fitting, beta = 0.75
+pp2 = splinefit (x, y, 8, "constraints", con, "beta", 0.75);
+## No robust fitting
+pp3 = splinefit (x, y, 8, "constraints", con);
+## Plot
+xx = linspace (0, 2*pi, 400);
+y1 = ppval (pp1, xx);
+y2 = ppval (pp2, xx);
+y3 = ppval (pp3, xx);
+plot (x, y, ".", xx, [y1; y2; y3])
+legend (@{"data with outliers","robust, beta = 0.25", ...
+         "robust, beta = 0.75", "no robust fitting"@})
+axis tight
+ylim auto
+@end group
+@end example
+
+@ifnotinfo
+@noindent
+The result of which can be seen in @ref{fig:splinefit6}.
+
+@float Figure,fig:splinefit6
+@center @image{splinefit6,4in}
+@caption{Comparison of two different levels of robust fitting (@var{beta} = 0.25 and 0.75) to noisy data combined with outlying data. A conventional fit, without
+robust fitting (@var{beta} = 0) is also included.}
+@end float
+@end ifnotinfo
+
+The function, @code{ppval}, evaluates the piecewise polynomials, created
+by @code{mkpp} or other means, and @code{unmkpp} returns detailed
+information about the piecewise polynomial.
 
 The following example shows how to combine two linear functions and a
 quadratic into one function.  Each of these functions is expressed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/interpreter/splineimages.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,192 @@
+## Copyright (C) 2012 Ben Abbott, Jonas Lundgren
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+function splineimages (nm, typ)
+  graphics_toolkit ("gnuplot");
+  set_print_size ();
+  hide_output ();
+  if (strcmp (typ, "png"))
+    set (0, "defaulttextfontname", "*");
+  endif
+  if (strcmp (typ, "eps"))
+    d_typ = "-depsc2";
+  else
+    d_typ = cstrcat ("-d", typ);
+  endif
+
+  if (strcmp (typ, "txt"))
+    image_as_txt (nm);
+  elseif (strcmp (nm, "splinefit1")) ## Breaks and Pieces
+    x = 2 * pi * rand (1, 200);
+    y = sin (x) + sin (2 * x) + 0.2 * randn (size (x));
+    ## Uniform breaks
+    breaks = linspace (0, 2 * pi, 41); ## 41 breaks, 40 pieces
+    pp1 = splinefit (x, y, breaks);
+    ## Breaks interpolated from data
+    pp2 = splinefit (x, y, 10);  ## 11 breaks, 10 pieces
+    ## Plot
+    xx = linspace (0, 2 * pi, 400);
+    y1 = ppval (pp1, xx);
+    y2 = ppval (pp2, xx);
+    plot (x, y, ".", xx, [y1; y2])
+    axis tight
+    ylim ([-2.5 2.5])
+    legend ("data", "41 breaks, 40 pieces", "11 breaks, 10 pieces")
+    print (cstrcat (nm, ".", typ), d_typ)
+  elseif (strcmp (nm, "splinefit2")) ## Spline orders
+    ## Data (200 points)
+    x = 2 * pi * rand (1, 200);
+    y = sin (x) + sin (2 * x) + 0.1 * randn (size (x));
+    ## Splines
+    pp1 = splinefit (x, y, 8, "order", 0);  ## Piecewise constant
+    pp2 = splinefit (x, y, 8, "order", 1);  ## Piecewise linear
+    pp3 = splinefit (x, y, 8, "order", 2);  ## Piecewise quadratic
+    pp4 = splinefit (x, y, 8, "order", 3);  ## Piecewise cubic
+    pp5 = splinefit (x, y, 8, "order", 4);  ## Etc.
+    ## Plot
+    xx = linspace (0, 2 * pi, 400);
+    y1 = ppval (pp1, xx);
+    y2 = ppval (pp2, xx);
+    y3 = ppval (pp3, xx);
+    y4 = ppval (pp4, xx);
+    y5 = ppval (pp5, xx);
+    plot (x, y, ".", xx, [y1; y2; y3; y4; y5])
+    axis tight
+    ylim ([-2.5 2.5])
+    legend ({"data", "order 0", "order 1", "order 2", "order 3", "order 4"})
+    print (cstrcat (nm, ".", typ), d_typ)
+  elseif (strcmp (nm, "splinefit3"))
+    ## Data (100 points)
+    x = 2 * pi * [0, (rand (1, 98)), 1];
+    y = sin (x) - cos (2 * x) + 0.2 * randn (size (x));
+    ## No constraints
+    pp1 = splinefit (x, y, 10, "order", 5);
+    ## Periodic boundaries
+    pp2 = splinefit (x, y, 10, "order", 5, "periodic", true);
+    ## Plot
+    xx = linspace (0, 2 * pi, 400);
+    y1 = ppval (pp1, xx);
+    y2 = ppval (pp2, xx);
+    plot (x, y, ".", xx, [y1; y2])
+    axis tight
+    ylim ([-2 3])
+    legend ({"data", "no constraints", "periodic"})
+    print (cstrcat (nm, ".", typ), d_typ)
+  elseif (strcmp (nm, "splinefit4"))
+    ## Data (200 points)
+    x = 2 * pi * rand (1, 200);
+    y = sin (2 * x) + 0.1 * randn (size (x));
+    ## Breaks
+    breaks = linspace (0, 2 * pi, 10);
+    ## Clamped endpoints, y = y" = 0
+    xc = [0, 0, 2*pi, 2*pi];
+    cc = [(eye (2)), (eye (2))];
+    con = struct ("xc", xc, "cc", cc);
+    pp1 = splinefit (x, y, breaks, "constraints", con);
+    ## Hinged periodic endpoints, y = 0
+    con = struct ("xc", 0);
+    pp2 = splinefit (x, y, breaks, "constraints", con, "periodic", true);
+    ## Plot
+    xx = linspace (0, 2 * pi, 400);
+    y1 = ppval (pp1, xx);
+    y2 = ppval (pp2, xx);
+    plot (x, y, ".", xx, [y1; y2])
+    axis tight
+    ylim ([-1.5 1.5])
+    legend({"data", "clamped", "hinged periodic"})
+    print (cstrcat (nm, ".", typ), d_typ)
+  elseif (strcmp (nm, "splinefit5"))
+    ## Truncated data
+    x = [0,  1,  2,  4,  8, 16, 24, 40, 56, 72, 80] / 80;
+    y = [0, 28, 39, 53, 70, 86, 90, 79, 55, 22,  2] / 1000;
+    xy = [x; y];
+    ## Curve length parameter
+    ds = sqrt (diff (x).^2 + diff (y).^2);
+    s = [0, cumsum(ds)];
+    ## Constraints at s = 0: (x,y) = (0,0), (dx/ds,dy/ds) = (0,1)
+    con = struct ("xc", [0 0], "yc", [0 0; 0 1], "cc", eye (2));
+    ## Fit a spline with 4 pieces
+    pp = splinefit (s, xy, 4, "constraints", con);
+    ## Plot
+    ss = linspace (0, s(end), 400);
+    xyfit = ppval (pp, ss);
+    xyb = ppval(pp, pp.breaks);
+    plot (x, y, ".", xyfit(1,:), xyfit(2,:), "r", xyb(1,:), xyb(2,:), "ro")
+    legend ({"data", "spline", "breaks"})
+    axis tight
+    ylim ([0 0.1])
+    print (cstrcat (nm, ".", typ), d_typ)
+  elseif (strcmp (nm, "splinefit6"))
+    ## Data
+    x = linspace (0, 2*pi, 200);
+    y = sin (x) + sin (2 * x) + 0.05 * randn (size (x));
+    ## Add outliers
+    x = [x, linspace(0,2*pi,60)];
+    y = [y, -ones(1,60)];
+    ## Fit splines with hinged conditions
+    con = struct ("xc", [0, 2*pi]);
+    pp1 = splinefit (x, y, 8, "constraints", con, "beta", 0.25); ## Robust fitting
+    pp2 = splinefit (x, y, 8, "constraints", con, "beta", 0.75); ## Robust fitting
+    pp3 = splinefit (x, y, 8, "constraints", con); ## No robust fitting
+    ## Plot
+    xx = linspace (0, 2*pi, 400);
+    y1 = ppval (pp1, xx);
+    y2 = ppval (pp2, xx);
+    y3 = ppval (pp3, xx);
+    plot (x, y, ".", xx, [y1; y2; y3])
+    legend({"data with outliers","robust, beta = 0.25", ...
+            "robust, beta = 0.75", "no robust fitting"})
+    axis tight
+    ylim ([-2 2])
+    print (cstrcat (nm, ".", typ), d_typ)
+  endif
+  hide_output ();  
+endfunction
+
+function set_print_size ()
+  image_size = [5.0, 3.5]; # in inches, 16:9 format
+  border = 0;              # For postscript use 50/72
+  set (0, "defaultfigurepapertype", "<custom>");
+  set (0, "defaultfigurepaperorientation", "landscape");
+  set (0, "defaultfigurepapersize", image_size + 2*border);
+  set (0, "defaultfigurepaperposition", [border, border, image_size]);
+endfunction
+
+## Use this function before plotting commands and after every call to
+## print since print() resets output to stdout (unfortunately, gnpulot
+## can't pop output as it can the terminal type).
+function hide_output ()
+  f = figure (1);
+  set (f, "visible", "off");
+endfunction
+
+## generate something for the texinfo @image command to process
+function image_as_txt(nm)
+  fid = fopen (sprintf ("%s.txt", nm), "wt");
+  fputs (fid, "\n");
+  fputs (fid, "+---------------------------------+\n");
+  fputs (fid, "| Image unavailable in text mode. |\n");
+  fputs (fid, "+---------------------------------+\n");
+  fclose (fid);
+endfunction
+
+%!demo
+%! for s = 1:6
+%!   splineimages (sprintf ("splinefit##d", s), "pdf")
+%! endfor
+
--- a/doc/interpreter/system.txi	Mon May 07 00:53:54 2012 +0200
+++ b/doc/interpreter/system.txi	Mon May 07 00:56:44 2012 +0200
@@ -53,7 +53,7 @@
 Microseconds after the second (0-999999).
 
 @item sec
-Seconds after the minute (0-61).  This number can be 61 to account
+Seconds after the minute (0-60).  This number can be 60 to account
 for leap seconds.
 
 @item min
--- a/libcruft/Makefile.am	Mon May 07 00:53:54 2012 +0200
+++ b/libcruft/Makefile.am	Mon May 07 00:56:44 2012 +0200
@@ -31,6 +31,8 @@
 
 libcruft_la_SOURCES =
 
+nodist_libcruft_la_SOURCES =
+
 libcruft_la_FFLAGS = $(F77_INTEGER_8_FLAG)
 
 libcruft_la_CPPFLAGS = \
@@ -98,5 +100,5 @@
 
 EXTRA_DIST += mkf77def.in
 
-DISTCLEANFILES = cruft.def ranlib.def
+DISTCLEANFILES = cruft.def ranlib.def $(nodist_libcruft_la_SOURCES)
 
--- a/libcruft/slatec-fn/derfc.f	Mon May 07 00:53:54 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,230 +0,0 @@
-*DECK DERFC
-      DOUBLE PRECISION FUNCTION DERFC (X)
-C***BEGIN PROLOGUE  DERFC
-C***PURPOSE  Compute the complementary error function.
-C***LIBRARY   SLATEC (FNLIB)
-C***CATEGORY  C8A, L5A1E
-C***TYPE      DOUBLE PRECISION (ERFC-S, DERFC-D)
-C***KEYWORDS  COMPLEMENTARY ERROR FUNCTION, ERFC, FNLIB,
-C             SPECIAL FUNCTIONS
-C***AUTHOR  Fullerton, W., (LANL)
-C***DESCRIPTION
-C
-C DERFC(X) calculates the double precision complementary error function
-C for double precision argument X.
-C
-C Series for ERF        on the interval  0.          to  1.00000E+00
-C                                        with weighted Error   1.28E-32
-C                                         log weighted Error  31.89
-C                               significant figures required  31.05
-C                                    decimal places required  32.55
-C
-C Series for ERC2       on the interval  2.50000E-01 to  1.00000E+00
-C                                        with weighted Error   2.67E-32
-C                                         log weighted Error  31.57
-C                               significant figures required  30.31
-C                                    decimal places required  32.42
-C
-C Series for ERFC       on the interval  0.          to  2.50000E-01
-C                                        with weighted error   1.53E-31
-C                                         log weighted error  30.82
-C                               significant figures required  29.47
-C                                    decimal places required  31.70
-C
-C***REFERENCES  (NONE)
-C***ROUTINES CALLED  D1MACH, DCSEVL, INITDS, XERMSG
-C***REVISION HISTORY  (YYMMDD)
-C   770701  DATE WRITTEN
-C   890531  Changed all specific intrinsics to generic.  (WRB)
-C   890531  REVISION DATE from Version 3.2
-C   891214  Prologue converted to Version 4.0 format.  (BAB)
-C   900315  CALLs to XERROR changed to CALLs to XERMSG.  (THJ)
-C   920618  Removed space from variable names.  (RWC, WRB)
-C***END PROLOGUE  DERFC
-      DOUBLE PRECISION X, ERFCS(21), ERFCCS(59), ERC2CS(49), SQEPS,
-     1  SQRTPI, XMAX, TXMAX, XSML, Y, D1MACH, DCSEVL
-      LOGICAL FIRST
-      SAVE ERFCS, ERC2CS, ERFCCS, SQRTPI, NTERF,
-     1 NTERFC, NTERC2, XSML, XMAX, SQEPS, FIRST
-      DATA ERFCS(  1) / -.4904612123 4691808039 9845440333 76 D-1     /
-      DATA ERFCS(  2) / -.1422612051 0371364237 8247418996 31 D+0     /
-      DATA ERFCS(  3) / +.1003558218 7599795575 7546767129 33 D-1     /
-      DATA ERFCS(  4) / -.5768764699 7674847650 8270255091 67 D-3     /
-      DATA ERFCS(  5) / +.2741993125 2196061034 4221607914 71 D-4     /
-      DATA ERFCS(  6) / -.1104317550 7344507604 1353812959 05 D-5     /
-      DATA ERFCS(  7) / +.3848875542 0345036949 9613114981 74 D-7     /
-      DATA ERFCS(  8) / -.1180858253 3875466969 6317518015 81 D-8     /
-      DATA ERFCS(  9) / +.3233421582 6050909646 4029309533 54 D-10    /
-      DATA ERFCS( 10) / -.7991015947 0045487581 6073747085 95 D-12    /
-      DATA ERFCS( 11) / +.1799072511 3961455611 9672454866 34 D-13    /
-      DATA ERFCS( 12) / -.3718635487 8186926382 3168282094 93 D-15    /
-      DATA ERFCS( 13) / +.7103599003 7142529711 6899083946 66 D-17    /
-      DATA ERFCS( 14) / -.1261245511 9155225832 4954248533 33 D-18    /
-      DATA ERFCS( 15) / +.2091640694 1769294369 1705002666 66 D-20    /
-      DATA ERFCS( 16) / -.3253973102 9314072982 3641600000 00 D-22    /
-      DATA ERFCS( 17) / +.4766867209 7976748332 3733333333 33 D-24    /
-      DATA ERFCS( 18) / -.6598012078 2851343155 1999999999 99 D-26    /
-      DATA ERFCS( 19) / +.8655011469 9637626197 3333333333 33 D-28    /
-      DATA ERFCS( 20) / -.1078892517 7498064213 3333333333 33 D-29    /
-      DATA ERFCS( 21) / +.1281188399 3017002666 6666666666 66 D-31    /
-      DATA ERC2CS(  1) / -.6960134660 2309501127 3915082619 7 D-1      /
-      DATA ERC2CS(  2) / -.4110133936 2620893489 8221208466 6 D-1      /
-      DATA ERC2CS(  3) / +.3914495866 6896268815 6114370524 4 D-2      /
-      DATA ERC2CS(  4) / -.4906395650 5489791612 8093545077 4 D-3      /
-      DATA ERC2CS(  5) / +.7157479001 3770363807 6089414182 5 D-4      /
-      DATA ERC2CS(  6) / -.1153071634 1312328338 0823284791 2 D-4      /
-      DATA ERC2CS(  7) / +.1994670590 2019976350 5231486770 9 D-5      /
-      DATA ERC2CS(  8) / -.3642666471 5992228739 3611843071 1 D-6      /
-      DATA ERC2CS(  9) / +.6944372610 0050125899 3127721463 3 D-7      /
-      DATA ERC2CS( 10) / -.1371220902 1043660195 3460514121 0 D-7      /
-      DATA ERC2CS( 11) / +.2788389661 0071371319 6386034808 7 D-8      /
-      DATA ERC2CS( 12) / -.5814164724 3311615518 6479105031 6 D-9      /
-      DATA ERC2CS( 13) / +.1238920491 7527531811 8016881795 0 D-9      /
-      DATA ERC2CS( 14) / -.2690639145 3067434323 9042493788 9 D-10     /
-      DATA ERC2CS( 15) / +.5942614350 8479109824 4470968384 0 D-11     /
-      DATA ERC2CS( 16) / -.1332386735 7581195792 8775442057 0 D-11     /
-      DATA ERC2CS( 17) / +.3028046806 1771320171 7369724330 4 D-12     /
-      DATA ERC2CS( 18) / -.6966648814 9410325887 9586758895 4 D-13     /
-      DATA ERC2CS( 19) / +.1620854541 0539229698 1289322762 8 D-13     /
-      DATA ERC2CS( 20) / -.3809934465 2504919998 7691305772 9 D-14     /
-      DATA ERC2CS( 21) / +.9040487815 9788311493 6897101297 5 D-15     /
-      DATA ERC2CS( 22) / -.2164006195 0896073478 0981204700 3 D-15     /
-      DATA ERC2CS( 23) / +.5222102233 9958549846 0798024417 2 D-16     /
-      DATA ERC2CS( 24) / -.1269729602 3645553363 7241552778 0 D-16     /
-      DATA ERC2CS( 25) / +.3109145504 2761975838 3622741295 1 D-17     /
-      DATA ERC2CS( 26) / -.7663762920 3203855240 0956671481 1 D-18     /
-      DATA ERC2CS( 27) / +.1900819251 3627452025 3692973329 0 D-18     /
-      DATA ERC2CS( 28) / -.4742207279 0690395452 2565599996 5 D-19     /
-      DATA ERC2CS( 29) / +.1189649200 0765283828 8068307845 1 D-19     /
-      DATA ERC2CS( 30) / -.3000035590 3257802568 4527131306 6 D-20     /
-      DATA ERC2CS( 31) / +.7602993453 0432461730 1938527709 8 D-21     /
-      DATA ERC2CS( 32) / -.1935909447 6068728815 6981104913 0 D-21     /
-      DATA ERC2CS( 33) / +.4951399124 7733378810 0004238677 3 D-22     /
-      DATA ERC2CS( 34) / -.1271807481 3363718796 0862198988 8 D-22     /
-      DATA ERC2CS( 35) / +.3280049600 4695130433 1584165205 3 D-23     /
-      DATA ERC2CS( 36) / -.8492320176 8228965689 2479242239 9 D-24     /
-      DATA ERC2CS( 37) / +.2206917892 8075602235 1987998719 9 D-24     /
-      DATA ERC2CS( 38) / -.5755617245 6965284983 1281950719 9 D-25     /
-      DATA ERC2CS( 39) / +.1506191533 6392342503 5414405119 9 D-25     /
-      DATA ERC2CS( 40) / -.3954502959 0187969531 0428569599 9 D-26     /
-      DATA ERC2CS( 41) / +.1041529704 1515009799 8464505173 3 D-26     /
-      DATA ERC2CS( 42) / -.2751487795 2787650794 5017890133 3 D-27     /
-      DATA ERC2CS( 43) / +.7290058205 4975574089 9770368000 0 D-28     /
-      DATA ERC2CS( 44) / -.1936939645 9159478040 7750109866 6 D-28     /
-      DATA ERC2CS( 45) / +.5160357112 0514872983 7005482666 6 D-29     /
-      DATA ERC2CS( 46) / -.1378419322 1930940993 8964480000 0 D-29     /
-      DATA ERC2CS( 47) / +.3691326793 1070690422 5109333333 3 D-30     /
-      DATA ERC2CS( 48) / -.9909389590 6243654206 5322666666 6 D-31     /
-      DATA ERC2CS( 49) / +.2666491705 1953884133 2394666666 6 D-31     /
-      DATA ERFCCS(  1) / +.7151793102 0292477450 3697709496 D-1        /
-      DATA ERFCCS(  2) / -.2653243433 7606715755 8893386681 D-1        /
-      DATA ERFCCS(  3) / +.1711153977 9208558833 2699194606 D-2        /
-      DATA ERFCCS(  4) / -.1637516634 5851788416 3746404749 D-3        /
-      DATA ERFCCS(  5) / +.1987129350 0552036499 5974806758 D-4        /
-      DATA ERFCCS(  6) / -.2843712412 7665550875 0175183152 D-5        /
-      DATA ERFCCS(  7) / +.4606161308 9631303696 9379968464 D-6        /
-      DATA ERFCCS(  8) / -.8227753025 8792084205 7766536366 D-7        /
-      DATA ERFCCS(  9) / +.1592141872 7709011298 9358340826 D-7        /
-      DATA ERFCCS( 10) / -.3295071362 2528432148 6631665072 D-8        /
-      DATA ERFCCS( 11) / +.7223439760 4005554658 1261153890 D-9        /
-      DATA ERFCCS( 12) / -.1664855813 3987295934 4695966886 D-9        /
-      DATA ERFCCS( 13) / +.4010392588 2376648207 7671768814 D-10       /
-      DATA ERFCCS( 14) / -.1004816214 4257311327 2170176283 D-10       /
-      DATA ERFCCS( 15) / +.2608275913 3003338085 9341009439 D-11       /
-      DATA ERFCCS( 16) / -.6991110560 4040248655 7697812476 D-12       /
-      DATA ERFCCS( 17) / +.1929492333 2617070862 4205749803 D-12       /
-      DATA ERFCCS( 18) / -.5470131188 7543310649 0125085271 D-13       /
-      DATA ERFCCS( 19) / +.1589663309 7626974483 9084032762 D-13       /
-      DATA ERFCCS( 20) / -.4726893980 1975548392 0369584290 D-14       /
-      DATA ERFCCS( 21) / +.1435873376 7849847867 2873997840 D-14       /
-      DATA ERFCCS( 22) / -.4449510561 8173583941 7250062829 D-15       /
-      DATA ERFCCS( 23) / +.1404810884 7682334373 7305537466 D-15       /
-      DATA ERFCCS( 24) / -.4513818387 7642108962 5963281623 D-16       /
-      DATA ERFCCS( 25) / +.1474521541 0451330778 7018713262 D-16       /
-      DATA ERFCCS( 26) / -.4892621406 9457761543 6841552532 D-17       /
-      DATA ERFCCS( 27) / +.1647612141 4106467389 5301522827 D-17       /
-      DATA ERFCCS( 28) / -.5626817176 3294080929 9928521323 D-18       /
-      DATA ERFCCS( 29) / +.1947443382 2320785142 9197867821 D-18       /
-      DATA ERFCCS( 30) / -.6826305642 9484207295 6664144723 D-19       /
-      DATA ERFCCS( 31) / +.2421988887 2986492401 8301125438 D-19       /
-      DATA ERFCCS( 32) / -.8693414133 5030704256 3800861857 D-20       /
-      DATA ERFCCS( 33) / +.3155180346 2280855712 2363401262 D-20       /
-      DATA ERFCCS( 34) / -.1157372324 0496087426 1239486742 D-20       /
-      DATA ERFCCS( 35) / +.4288947161 6056539462 3737097442 D-21       /
-      DATA ERFCCS( 36) / -.1605030742 0576168500 5737770964 D-21       /
-      DATA ERFCCS( 37) / +.6063298757 4538026449 5069923027 D-22       /
-      DATA ERFCCS( 38) / -.2311404251 6979584909 8840801367 D-22       /
-      DATA ERFCCS( 39) / +.8888778540 6618855255 4702955697 D-23       /
-      DATA ERFCCS( 40) / -.3447260576 6513765223 0718495566 D-23       /
-      DATA ERFCCS( 41) / +.1347865460 2069650682 7582774181 D-23       /
-      DATA ERFCCS( 42) / -.5311794071 1250217364 5873201807 D-24       /
-      DATA ERFCCS( 43) / +.2109341058 6197831682 8954734537 D-24       /
-      DATA ERFCCS( 44) / -.8438365587 9237891159 8133256738 D-25       /
-      DATA ERFCCS( 45) / +.3399982524 9452089062 7359576337 D-25       /
-      DATA ERFCCS( 46) / -.1379452388 0732420900 2238377110 D-25       /
-      DATA ERFCCS( 47) / +.5634490311 8332526151 3392634811 D-26       /
-      DATA ERFCCS( 48) / -.2316490434 4770654482 3427752700 D-26       /
-      DATA ERFCCS( 49) / +.9584462844 6018101526 3158381226 D-27       /
-      DATA ERFCCS( 50) / -.3990722880 3301097262 4224850193 D-27       /
-      DATA ERFCCS( 51) / +.1672129225 9444773601 7228709669 D-27       /
-      DATA ERFCCS( 52) / -.7045991522 7660138563 8803782587 D-28       /
-      DATA ERFCCS( 53) / +.2979768402 8642063541 2357989444 D-28       /
-      DATA ERFCCS( 54) / -.1262522466 4606192972 2422632994 D-28       /
-      DATA ERFCCS( 55) / +.5395438704 5424879398 5299653154 D-29       /
-      DATA ERFCCS( 56) / -.2380992882 5314591867 5346190062 D-29       /
-      DATA ERFCCS( 57) / +.1099052830 1027615735 9726683750 D-29       /
-      DATA ERFCCS( 58) / -.4867713741 6449657273 2518677435 D-30       /
-      DATA ERFCCS( 59) / +.1525877264 1103575676 3200828211 D-30       /
-      DATA SQRTPI / 1.772453850 9055160272 9816748334 115D0 /
-      DATA FIRST /.TRUE./
-C***FIRST EXECUTABLE STATEMENT  DERFC
-      IF (FIRST) THEN
-         ETA = 0.1*REAL(D1MACH(3))
-         NTERF = INITDS (ERFCS, 21, ETA)
-         NTERFC = INITDS (ERFCCS, 59, ETA)
-         NTERC2 = INITDS (ERC2CS, 49, ETA)
-C
-         XSML = -SQRT(-LOG(SQRTPI*D1MACH(3)))
-         TXMAX = SQRT(-LOG(SQRTPI*D1MACH(1)))
-         XMAX = TXMAX - 0.5D0*LOG(TXMAX)/TXMAX - 0.01D0
-         SQEPS = SQRT(2.0D0*D1MACH(3))
-      ENDIF
-      FIRST = .FALSE.
-C
-      IF (ISNAN(X)) THEN
-         DERFC = X
-         RETURN
-      ENDIF
-C
-      IF (X.GT.XSML) GO TO 20
-C
-C ERFC(X) = 1.0 - ERF(X)  FOR  X .LT. XSML
-C
-      DERFC = 2.0D0
-      RETURN
-C
- 20   IF (X.GT.XMAX) GO TO 40
-      Y = ABS(X)
-      IF (Y.GT.1.0D0) GO TO 30
-C
-C ERFC(X) = 1.0 - ERF(X)  FOR ABS(X) .LE. 1.0
-C
-      IF (Y.LT.SQEPS) DERFC = 1.0D0 - 2.0D0*X/SQRTPI
-      IF (Y.GE.SQEPS) DERFC = 1.0D0 - X*(1.0D0 + DCSEVL (2.D0*X*X-1.D0,
-     1  ERFCS, NTERF))
-      RETURN
-C
-C ERFC(X) = 1.0 - ERF(X)  FOR  1.0 .LT. ABS(X) .LE. XMAX
-C
- 30   Y = Y*Y
-      IF (Y.LE.4.D0) DERFC = EXP(-Y)/ABS(X) * (0.5D0 + DCSEVL (
-     1  (8.D0/Y-5.D0)/3.D0, ERC2CS, NTERC2) )
-      IF (Y.GT.4.D0) DERFC = EXP(-Y)/ABS(X) * (0.5D0 + DCSEVL (
-     1  8.D0/Y-1.D0, ERFCCS, NTERFC) )
-      IF (X.LT.0.D0) DERFC = 2.0D0 - DERFC
-      RETURN
-C
- 40   DERFC = 0.D0
-      RETURN
-C
-      END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libcruft/slatec-fn/derfc.in.f	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,230 @@
+*DECK DERFC
+      DOUBLE PRECISION FUNCTION DERFC (X)
+C***BEGIN PROLOGUE  DERFC
+C***PURPOSE  Compute the complementary error function.
+C***LIBRARY   SLATEC (FNLIB)
+C***CATEGORY  C8A, L5A1E
+C***TYPE      DOUBLE PRECISION (ERFC-S, DERFC-D)
+C***KEYWORDS  COMPLEMENTARY ERROR FUNCTION, ERFC, FNLIB,
+C             SPECIAL FUNCTIONS
+C***AUTHOR  Fullerton, W., (LANL)
+C***DESCRIPTION
+C
+C DERFC(X) calculates the double precision complementary error function
+C for double precision argument X.
+C
+C Series for ERF        on the interval  0.          to  1.00000E+00
+C                                        with weighted Error   1.28E-32
+C                                         log weighted Error  31.89
+C                               significant figures required  31.05
+C                                    decimal places required  32.55
+C
+C Series for ERC2       on the interval  2.50000E-01 to  1.00000E+00
+C                                        with weighted Error   2.67E-32
+C                                         log weighted Error  31.57
+C                               significant figures required  30.31
+C                                    decimal places required  32.42
+C
+C Series for ERFC       on the interval  0.          to  2.50000E-01
+C                                        with weighted error   1.53E-31
+C                                         log weighted error  30.82
+C                               significant figures required  29.47
+C                                    decimal places required  31.70
+C
+C***REFERENCES  (NONE)
+C***ROUTINES CALLED  D1MACH, DCSEVL, INITDS, XERMSG
+C***REVISION HISTORY  (YYMMDD)
+C   770701  DATE WRITTEN
+C   890531  Changed all specific intrinsics to generic.  (WRB)
+C   890531  REVISION DATE from Version 3.2
+C   891214  Prologue converted to Version 4.0 format.  (BAB)
+C   900315  CALLs to XERROR changed to CALLs to XERMSG.  (THJ)
+C   920618  Removed space from variable names.  (RWC, WRB)
+C***END PROLOGUE  DERFC
+      DOUBLE PRECISION X, ERFCS(21), ERFCCS(59), ERC2CS(49), SQEPS,
+     1  SQRTPI, XMAX, TXMAX, XSML, Y, D1MACH, DCSEVL
+      LOGICAL FIRST
+      SAVE ERFCS, ERC2CS, ERFCCS, SQRTPI, NTERF,
+     1 NTERFC, NTERC2, XSML, XMAX, SQEPS, FIRST
+      DATA ERFCS(  1) / -.4904612123 4691808039 9845440333 76 D-1     /
+      DATA ERFCS(  2) / -.1422612051 0371364237 8247418996 31 D+0     /
+      DATA ERFCS(  3) / +.1003558218 7599795575 7546767129 33 D-1     /
+      DATA ERFCS(  4) / -.5768764699 7674847650 8270255091 67 D-3     /
+      DATA ERFCS(  5) / +.2741993125 2196061034 4221607914 71 D-4     /
+      DATA ERFCS(  6) / -.1104317550 7344507604 1353812959 05 D-5     /
+      DATA ERFCS(  7) / +.3848875542 0345036949 9613114981 74 D-7     /
+      DATA ERFCS(  8) / -.1180858253 3875466969 6317518015 81 D-8     /
+      DATA ERFCS(  9) / +.3233421582 6050909646 4029309533 54 D-10    /
+      DATA ERFCS( 10) / -.7991015947 0045487581 6073747085 95 D-12    /
+      DATA ERFCS( 11) / +.1799072511 3961455611 9672454866 34 D-13    /
+      DATA ERFCS( 12) / -.3718635487 8186926382 3168282094 93 D-15    /
+      DATA ERFCS( 13) / +.7103599003 7142529711 6899083946 66 D-17    /
+      DATA ERFCS( 14) / -.1261245511 9155225832 4954248533 33 D-18    /
+      DATA ERFCS( 15) / +.2091640694 1769294369 1705002666 66 D-20    /
+      DATA ERFCS( 16) / -.3253973102 9314072982 3641600000 00 D-22    /
+      DATA ERFCS( 17) / +.4766867209 7976748332 3733333333 33 D-24    /
+      DATA ERFCS( 18) / -.6598012078 2851343155 1999999999 99 D-26    /
+      DATA ERFCS( 19) / +.8655011469 9637626197 3333333333 33 D-28    /
+      DATA ERFCS( 20) / -.1078892517 7498064213 3333333333 33 D-29    /
+      DATA ERFCS( 21) / +.1281188399 3017002666 6666666666 66 D-31    /
+      DATA ERC2CS(  1) / -.6960134660 2309501127 3915082619 7 D-1      /
+      DATA ERC2CS(  2) / -.4110133936 2620893489 8221208466 6 D-1      /
+      DATA ERC2CS(  3) / +.3914495866 6896268815 6114370524 4 D-2      /
+      DATA ERC2CS(  4) / -.4906395650 5489791612 8093545077 4 D-3      /
+      DATA ERC2CS(  5) / +.7157479001 3770363807 6089414182 5 D-4      /
+      DATA ERC2CS(  6) / -.1153071634 1312328338 0823284791 2 D-4      /
+      DATA ERC2CS(  7) / +.1994670590 2019976350 5231486770 9 D-5      /
+      DATA ERC2CS(  8) / -.3642666471 5992228739 3611843071 1 D-6      /
+      DATA ERC2CS(  9) / +.6944372610 0050125899 3127721463 3 D-7      /
+      DATA ERC2CS( 10) / -.1371220902 1043660195 3460514121 0 D-7      /
+      DATA ERC2CS( 11) / +.2788389661 0071371319 6386034808 7 D-8      /
+      DATA ERC2CS( 12) / -.5814164724 3311615518 6479105031 6 D-9      /
+      DATA ERC2CS( 13) / +.1238920491 7527531811 8016881795 0 D-9      /
+      DATA ERC2CS( 14) / -.2690639145 3067434323 9042493788 9 D-10     /
+      DATA ERC2CS( 15) / +.5942614350 8479109824 4470968384 0 D-11     /
+      DATA ERC2CS( 16) / -.1332386735 7581195792 8775442057 0 D-11     /
+      DATA ERC2CS( 17) / +.3028046806 1771320171 7369724330 4 D-12     /
+      DATA ERC2CS( 18) / -.6966648814 9410325887 9586758895 4 D-13     /
+      DATA ERC2CS( 19) / +.1620854541 0539229698 1289322762 8 D-13     /
+      DATA ERC2CS( 20) / -.3809934465 2504919998 7691305772 9 D-14     /
+      DATA ERC2CS( 21) / +.9040487815 9788311493 6897101297 5 D-15     /
+      DATA ERC2CS( 22) / -.2164006195 0896073478 0981204700 3 D-15     /
+      DATA ERC2CS( 23) / +.5222102233 9958549846 0798024417 2 D-16     /
+      DATA ERC2CS( 24) / -.1269729602 3645553363 7241552778 0 D-16     /
+      DATA ERC2CS( 25) / +.3109145504 2761975838 3622741295 1 D-17     /
+      DATA ERC2CS( 26) / -.7663762920 3203855240 0956671481 1 D-18     /
+      DATA ERC2CS( 27) / +.1900819251 3627452025 3692973329 0 D-18     /
+      DATA ERC2CS( 28) / -.4742207279 0690395452 2565599996 5 D-19     /
+      DATA ERC2CS( 29) / +.1189649200 0765283828 8068307845 1 D-19     /
+      DATA ERC2CS( 30) / -.3000035590 3257802568 4527131306 6 D-20     /
+      DATA ERC2CS( 31) / +.7602993453 0432461730 1938527709 8 D-21     /
+      DATA ERC2CS( 32) / -.1935909447 6068728815 6981104913 0 D-21     /
+      DATA ERC2CS( 33) / +.4951399124 7733378810 0004238677 3 D-22     /
+      DATA ERC2CS( 34) / -.1271807481 3363718796 0862198988 8 D-22     /
+      DATA ERC2CS( 35) / +.3280049600 4695130433 1584165205 3 D-23     /
+      DATA ERC2CS( 36) / -.8492320176 8228965689 2479242239 9 D-24     /
+      DATA ERC2CS( 37) / +.2206917892 8075602235 1987998719 9 D-24     /
+      DATA ERC2CS( 38) / -.5755617245 6965284983 1281950719 9 D-25     /
+      DATA ERC2CS( 39) / +.1506191533 6392342503 5414405119 9 D-25     /
+      DATA ERC2CS( 40) / -.3954502959 0187969531 0428569599 9 D-26     /
+      DATA ERC2CS( 41) / +.1041529704 1515009799 8464505173 3 D-26     /
+      DATA ERC2CS( 42) / -.2751487795 2787650794 5017890133 3 D-27     /
+      DATA ERC2CS( 43) / +.7290058205 4975574089 9770368000 0 D-28     /
+      DATA ERC2CS( 44) / -.1936939645 9159478040 7750109866 6 D-28     /
+      DATA ERC2CS( 45) / +.5160357112 0514872983 7005482666 6 D-29     /
+      DATA ERC2CS( 46) / -.1378419322 1930940993 8964480000 0 D-29     /
+      DATA ERC2CS( 47) / +.3691326793 1070690422 5109333333 3 D-30     /
+      DATA ERC2CS( 48) / -.9909389590 6243654206 5322666666 6 D-31     /
+      DATA ERC2CS( 49) / +.2666491705 1953884133 2394666666 6 D-31     /
+      DATA ERFCCS(  1) / +.7151793102 0292477450 3697709496 D-1        /
+      DATA ERFCCS(  2) / -.2653243433 7606715755 8893386681 D-1        /
+      DATA ERFCCS(  3) / +.1711153977 9208558833 2699194606 D-2        /
+      DATA ERFCCS(  4) / -.1637516634 5851788416 3746404749 D-3        /
+      DATA ERFCCS(  5) / +.1987129350 0552036499 5974806758 D-4        /
+      DATA ERFCCS(  6) / -.2843712412 7665550875 0175183152 D-5        /
+      DATA ERFCCS(  7) / +.4606161308 9631303696 9379968464 D-6        /
+      DATA ERFCCS(  8) / -.8227753025 8792084205 7766536366 D-7        /
+      DATA ERFCCS(  9) / +.1592141872 7709011298 9358340826 D-7        /
+      DATA ERFCCS( 10) / -.3295071362 2528432148 6631665072 D-8        /
+      DATA ERFCCS( 11) / +.7223439760 4005554658 1261153890 D-9        /
+      DATA ERFCCS( 12) / -.1664855813 3987295934 4695966886 D-9        /
+      DATA ERFCCS( 13) / +.4010392588 2376648207 7671768814 D-10       /
+      DATA ERFCCS( 14) / -.1004816214 4257311327 2170176283 D-10       /
+      DATA ERFCCS( 15) / +.2608275913 3003338085 9341009439 D-11       /
+      DATA ERFCCS( 16) / -.6991110560 4040248655 7697812476 D-12       /
+      DATA ERFCCS( 17) / +.1929492333 2617070862 4205749803 D-12       /
+      DATA ERFCCS( 18) / -.5470131188 7543310649 0125085271 D-13       /
+      DATA ERFCCS( 19) / +.1589663309 7626974483 9084032762 D-13       /
+      DATA ERFCCS( 20) / -.4726893980 1975548392 0369584290 D-14       /
+      DATA ERFCCS( 21) / +.1435873376 7849847867 2873997840 D-14       /
+      DATA ERFCCS( 22) / -.4449510561 8173583941 7250062829 D-15       /
+      DATA ERFCCS( 23) / +.1404810884 7682334373 7305537466 D-15       /
+      DATA ERFCCS( 24) / -.4513818387 7642108962 5963281623 D-16       /
+      DATA ERFCCS( 25) / +.1474521541 0451330778 7018713262 D-16       /
+      DATA ERFCCS( 26) / -.4892621406 9457761543 6841552532 D-17       /
+      DATA ERFCCS( 27) / +.1647612141 4106467389 5301522827 D-17       /
+      DATA ERFCCS( 28) / -.5626817176 3294080929 9928521323 D-18       /
+      DATA ERFCCS( 29) / +.1947443382 2320785142 9197867821 D-18       /
+      DATA ERFCCS( 30) / -.6826305642 9484207295 6664144723 D-19       /
+      DATA ERFCCS( 31) / +.2421988887 2986492401 8301125438 D-19       /
+      DATA ERFCCS( 32) / -.8693414133 5030704256 3800861857 D-20       /
+      DATA ERFCCS( 33) / +.3155180346 2280855712 2363401262 D-20       /
+      DATA ERFCCS( 34) / -.1157372324 0496087426 1239486742 D-20       /
+      DATA ERFCCS( 35) / +.4288947161 6056539462 3737097442 D-21       /
+      DATA ERFCCS( 36) / -.1605030742 0576168500 5737770964 D-21       /
+      DATA ERFCCS( 37) / +.6063298757 4538026449 5069923027 D-22       /
+      DATA ERFCCS( 38) / -.2311404251 6979584909 8840801367 D-22       /
+      DATA ERFCCS( 39) / +.8888778540 6618855255 4702955697 D-23       /
+      DATA ERFCCS( 40) / -.3447260576 6513765223 0718495566 D-23       /
+      DATA ERFCCS( 41) / +.1347865460 2069650682 7582774181 D-23       /
+      DATA ERFCCS( 42) / -.5311794071 1250217364 5873201807 D-24       /
+      DATA ERFCCS( 43) / +.2109341058 6197831682 8954734537 D-24       /
+      DATA ERFCCS( 44) / -.8438365587 9237891159 8133256738 D-25       /
+      DATA ERFCCS( 45) / +.3399982524 9452089062 7359576337 D-25       /
+      DATA ERFCCS( 46) / -.1379452388 0732420900 2238377110 D-25       /
+      DATA ERFCCS( 47) / +.5634490311 8332526151 3392634811 D-26       /
+      DATA ERFCCS( 48) / -.2316490434 4770654482 3427752700 D-26       /
+      DATA ERFCCS( 49) / +.9584462844 6018101526 3158381226 D-27       /
+      DATA ERFCCS( 50) / -.3990722880 3301097262 4224850193 D-27       /
+      DATA ERFCCS( 51) / +.1672129225 9444773601 7228709669 D-27       /
+      DATA ERFCCS( 52) / -.7045991522 7660138563 8803782587 D-28       /
+      DATA ERFCCS( 53) / +.2979768402 8642063541 2357989444 D-28       /
+      DATA ERFCCS( 54) / -.1262522466 4606192972 2422632994 D-28       /
+      DATA ERFCCS( 55) / +.5395438704 5424879398 5299653154 D-29       /
+      DATA ERFCCS( 56) / -.2380992882 5314591867 5346190062 D-29       /
+      DATA ERFCCS( 57) / +.1099052830 1027615735 9726683750 D-29       /
+      DATA ERFCCS( 58) / -.4867713741 6449657273 2518677435 D-30       /
+      DATA ERFCCS( 59) / +.1525877264 1103575676 3200828211 D-30       /
+      DATA SQRTPI / 1.772453850 9055160272 9816748334 115D0 /
+      DATA FIRST /.TRUE./
+C***FIRST EXECUTABLE STATEMENT  DERFC
+      IF (FIRST) THEN
+         ETA = 0.1*REAL(D1MACH(3))
+         NTERF = INITDS (ERFCS, 21, ETA)
+         NTERFC = INITDS (ERFCCS, 59, ETA)
+         NTERC2 = INITDS (ERC2CS, 49, ETA)
+C
+         XSML = -SQRT(-LOG(SQRTPI*D1MACH(3)))
+         TXMAX = SQRT(-LOG(SQRTPI*D1MACH(1)))
+         XMAX = TXMAX - 0.5D0*LOG(TXMAX)/TXMAX - 0.01D0
+         SQEPS = SQRT(2.0D0*D1MACH(3))
+      ENDIF
+      FIRST = .FALSE.
+C
+      IF (ISNAN(X)) THEN
+         DERFC = X
+         RETURN
+      ENDIF
+C
+      IF (X.GT.XSML) GO TO 20
+C
+C ERFC(X) = 1.0 - ERF(X)  FOR  X .LT. XSML
+C
+      DERFC = 2.0D0
+      RETURN
+C
+ 20   IF (X.GT.XMAX) GO TO 40
+      Y = ABS(X)
+      IF (Y.GT.1.0D0) GO TO 30
+C
+C ERFC(X) = 1.0 - ERF(X)  FOR ABS(X) .LE. 1.0
+C
+      IF (Y.LT.SQEPS) DERFC = 1.0D0 - 2.0D0*X/SQRTPI
+      IF (Y.GE.SQEPS) DERFC = 1.0D0 - X*(1.0D0 + DCSEVL (2.D0*X*X-1.D0,
+     1  ERFCS, NTERF))
+      RETURN
+C
+C ERFC(X) = 1.0 - ERF(X)  FOR  1.0 .LT. ABS(X) .LE. XMAX
+C
+ 30   Y = Y*Y
+      IF (Y.LE.4.D0) DERFC = EXP(-Y)/ABS(X) * (0.5D0 + DCSEVL (
+     1  (8.D0/Y-5.D0)/3.D0, ERC2CS, NTERC2) )
+      IF (Y.GT.4.D0) DERFC = EXP(-Y)/ABS(X) * (0.5D0 + DCSEVL (
+     1  8.D0/Y-1.D0, ERFCCS, NTERFC) )
+      IF (X.LT.0.D0) DERFC = 2.0D0 - DERFC
+      RETURN
+C
+ 40   DERFC = 0.D0
+      RETURN
+C
+      END
--- a/libcruft/slatec-fn/erfc.f	Mon May 07 00:53:54 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,160 +0,0 @@
-*DECK ERFC
-      FUNCTION ERFC (X)
-C***BEGIN PROLOGUE  ERFC
-C***PURPOSE  Compute the complementary error function.
-C***LIBRARY   SLATEC (FNLIB)
-C***CATEGORY  C8A, L5A1E
-C***TYPE      SINGLE PRECISION (ERFC-S, DERFC-D)
-C***KEYWORDS  COMPLEMENTARY ERROR FUNCTION, ERFC, FNLIB,
-C             SPECIAL FUNCTIONS
-C***AUTHOR  Fullerton, W., (LANL)
-C***DESCRIPTION
-C
-C ERFC(X) calculates the single precision complementary error
-C function for single precision argument X.
-C
-C Series for ERF        on the interval  0.          to  1.00000D+00
-C                                        with weighted error   7.10E-18
-C                                         log weighted error  17.15
-C                               significant figures required  16.31
-C                                    decimal places required  17.71
-C
-C Series for ERFC       on the interval  0.          to  2.50000D-01
-C                                        with weighted error   4.81E-17
-C                                         log weighted error  16.32
-C                        approx significant figures required  15.0
-C
-C
-C Series for ERC2       on the interval  2.50000D-01 to  1.00000D+00
-C                                        with weighted error   5.22E-17
-C                                         log weighted error  16.28
-C                        approx significant figures required  15.0
-C                                    decimal places required  16.96
-C
-C***REFERENCES  (NONE)
-C***ROUTINES CALLED  CSEVL, INITS, R1MACH, XERMSG
-C***REVISION HISTORY  (YYMMDD)
-C   770701  DATE WRITTEN
-C   890531  Changed all specific intrinsics to generic.  (WRB)
-C   890531  REVISION DATE from Version 3.2
-C   891214  Prologue converted to Version 4.0 format.  (BAB)
-C   900315  CALLs to XERROR changed to CALLs to XERMSG.  (THJ)
-C   920618  Removed space from variable names.  (RWC, WRB)
-C***END PROLOGUE  ERFC
-      DIMENSION ERFCS(13), ERFCCS(24), ERC2CS(23)
-      LOGICAL FIRST
-      SAVE ERFCS, ERC2CS, ERFCCS, SQRTPI, NTERF, NTERFC,
-     1 NTERC2, XSML, XMAX, SQEPS, FIRST
-      DATA ERFCS( 1) /   -.0490461212 34691808E0 /
-      DATA ERFCS( 2) /   -.1422612051 0371364E0 /
-      DATA ERFCS( 3) /    .0100355821 87599796E0 /
-      DATA ERFCS( 4) /   -.0005768764 69976748E0 /
-      DATA ERFCS( 5) /    .0000274199 31252196E0 /
-      DATA ERFCS( 6) /   -.0000011043 17550734E0 /
-      DATA ERFCS( 7) /    .0000000384 88755420E0 /
-      DATA ERFCS( 8) /   -.0000000011 80858253E0 /
-      DATA ERFCS( 9) /    .0000000000 32334215E0 /
-      DATA ERFCS(10) /   -.0000000000 00799101E0 /
-      DATA ERFCS(11) /    .0000000000 00017990E0 /
-      DATA ERFCS(12) /   -.0000000000 00000371E0 /
-      DATA ERFCS(13) /    .0000000000 00000007E0 /
-      DATA ERC2CS( 1) /   -.0696013466 02309501E0 /
-      DATA ERC2CS( 2) /   -.0411013393 62620893E0 /
-      DATA ERC2CS( 3) /    .0039144958 66689626E0 /
-      DATA ERC2CS( 4) /   -.0004906395 65054897E0 /
-      DATA ERC2CS( 5) /    .0000715747 90013770E0 /
-      DATA ERC2CS( 6) /   -.0000115307 16341312E0 /
-      DATA ERC2CS( 7) /    .0000019946 70590201E0 /
-      DATA ERC2CS( 8) /   -.0000003642 66647159E0 /
-      DATA ERC2CS( 9) /    .0000000694 43726100E0 /
-      DATA ERC2CS(10) /   -.0000000137 12209021E0 /
-      DATA ERC2CS(11) /    .0000000027 88389661E0 /
-      DATA ERC2CS(12) /   -.0000000005 81416472E0 /
-      DATA ERC2CS(13) /    .0000000001 23892049E0 /
-      DATA ERC2CS(14) /   -.0000000000 26906391E0 /
-      DATA ERC2CS(15) /    .0000000000 05942614E0 /
-      DATA ERC2CS(16) /   -.0000000000 01332386E0 /
-      DATA ERC2CS(17) /    .0000000000 00302804E0 /
-      DATA ERC2CS(18) /   -.0000000000 00069666E0 /
-      DATA ERC2CS(19) /    .0000000000 00016208E0 /
-      DATA ERC2CS(20) /   -.0000000000 00003809E0 /
-      DATA ERC2CS(21) /    .0000000000 00000904E0 /
-      DATA ERC2CS(22) /   -.0000000000 00000216E0 /
-      DATA ERC2CS(23) /    .0000000000 00000052E0 /
-      DATA ERFCCS( 1) /   0.0715179310 202925E0 /
-      DATA ERFCCS( 2) /   -.0265324343 37606719E0 /
-      DATA ERFCCS( 3) /    .0017111539 77920853E0 /
-      DATA ERFCCS( 4) /   -.0001637516 63458512E0 /
-      DATA ERFCCS( 5) /    .0000198712 93500549E0 /
-      DATA ERFCCS( 6) /   -.0000028437 12412769E0 /
-      DATA ERFCCS( 7) /    .0000004606 16130901E0 /
-      DATA ERFCCS( 8) /   -.0000000822 77530261E0 /
-      DATA ERFCCS( 9) /    .0000000159 21418724E0 /
-      DATA ERFCCS(10) /   -.0000000032 95071356E0 /
-      DATA ERFCCS(11) /    .0000000007 22343973E0 /
-      DATA ERFCCS(12) /   -.0000000001 66485584E0 /
-      DATA ERFCCS(13) /    .0000000000 40103931E0 /
-      DATA ERFCCS(14) /   -.0000000000 10048164E0 /
-      DATA ERFCCS(15) /    .0000000000 02608272E0 /
-      DATA ERFCCS(16) /   -.0000000000 00699105E0 /
-      DATA ERFCCS(17) /    .0000000000 00192946E0 /
-      DATA ERFCCS(18) /   -.0000000000 00054704E0 /
-      DATA ERFCCS(19) /    .0000000000 00015901E0 /
-      DATA ERFCCS(20) /   -.0000000000 00004729E0 /
-      DATA ERFCCS(21) /    .0000000000 00001432E0 /
-      DATA ERFCCS(22) /   -.0000000000 00000439E0 /
-      DATA ERFCCS(23) /    .0000000000 00000138E0 /
-      DATA ERFCCS(24) /   -.0000000000 00000048E0 /
-      DATA SQRTPI /1.772453850 9055160E0/
-      DATA FIRST /.TRUE./
-C***FIRST EXECUTABLE STATEMENT  ERFC
-      IF (FIRST) THEN
-         ETA = 0.1*R1MACH(3)
-         NTERF = INITS (ERFCS, 13, ETA)
-         NTERFC = INITS (ERFCCS, 24, ETA)
-         NTERC2 = INITS (ERC2CS, 23, ETA)
-C
-         XSML = -SQRT (-LOG(SQRTPI*R1MACH(3)))
-         TXMAX = SQRT (-LOG(SQRTPI*R1MACH(1)))
-         XMAX = TXMAX - 0.5*LOG(TXMAX)/TXMAX - 0.01
-         SQEPS = SQRT (2.0*R1MACH(3))
-      ENDIF
-      FIRST = .FALSE.
-C
-      IF (ISNAN(X)) THEN
-         ERFC = X
-         RETURN
-      ENDIF
-C
-      IF (X.GT.XSML) GO TO 20
-C
-C ERFC(X) = 1.0 - ERF(X) FOR X .LT. XSML
-C
-      ERFC = 2.
-      RETURN
-C
- 20   IF (X.GT.XMAX) GO TO 40
-      Y = ABS(X)
-      IF (Y.GT.1.0) GO TO 30
-C
-C ERFC(X) = 1.0 - ERF(X) FOR -1. .LE. X .LE. 1.
-C
-      IF (Y.LT.SQEPS) ERFC = 1.0 - 2.0*X/SQRTPI
-      IF (Y.GE.SQEPS) ERFC = 1.0 -
-     1  X*(1.0 + CSEVL (2.*X*X-1., ERFCS, NTERF) )
-      RETURN
-C
-C ERFC(X) = 1.0 - ERF(X) FOR 1. .LT. ABS(X) .LE. XMAX
-C
- 30   Y = Y*Y
-      IF (Y.LE.4.) ERFC = EXP(-Y)/ABS(X) * (0.5 + CSEVL ((8./Y-5.)/3.,
-     1  ERC2CS, NTERC2) )
-      IF (Y.GT.4.) ERFC = EXP(-Y)/ABS(X) * (0.5 + CSEVL (8./Y-1.,
-     1  ERFCCS, NTERFC) )
-      IF (X.LT.0.) ERFC = 2.0 - ERFC
-      RETURN
-C
- 40   ERFC = 0.
-      RETURN
-C
-      END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libcruft/slatec-fn/erfc.in.f	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,160 @@
+*DECK ERFC
+      FUNCTION ERFC (X)
+C***BEGIN PROLOGUE  ERFC
+C***PURPOSE  Compute the complementary error function.
+C***LIBRARY   SLATEC (FNLIB)
+C***CATEGORY  C8A, L5A1E
+C***TYPE      SINGLE PRECISION (ERFC-S, DERFC-D)
+C***KEYWORDS  COMPLEMENTARY ERROR FUNCTION, ERFC, FNLIB,
+C             SPECIAL FUNCTIONS
+C***AUTHOR  Fullerton, W., (LANL)
+C***DESCRIPTION
+C
+C ERFC(X) calculates the single precision complementary error
+C function for single precision argument X.
+C
+C Series for ERF        on the interval  0.          to  1.00000D+00
+C                                        with weighted error   7.10E-18
+C                                         log weighted error  17.15
+C                               significant figures required  16.31
+C                                    decimal places required  17.71
+C
+C Series for ERFC       on the interval  0.          to  2.50000D-01
+C                                        with weighted error   4.81E-17
+C                                         log weighted error  16.32
+C                        approx significant figures required  15.0
+C
+C
+C Series for ERC2       on the interval  2.50000D-01 to  1.00000D+00
+C                                        with weighted error   5.22E-17
+C                                         log weighted error  16.28
+C                        approx significant figures required  15.0
+C                                    decimal places required  16.96
+C
+C***REFERENCES  (NONE)
+C***ROUTINES CALLED  CSEVL, INITS, R1MACH, XERMSG
+C***REVISION HISTORY  (YYMMDD)
+C   770701  DATE WRITTEN
+C   890531  Changed all specific intrinsics to generic.  (WRB)
+C   890531  REVISION DATE from Version 3.2
+C   891214  Prologue converted to Version 4.0 format.  (BAB)
+C   900315  CALLs to XERROR changed to CALLs to XERMSG.  (THJ)
+C   920618  Removed space from variable names.  (RWC, WRB)
+C***END PROLOGUE  ERFC
+      DIMENSION ERFCS(13), ERFCCS(24), ERC2CS(23)
+      LOGICAL FIRST
+      SAVE ERFCS, ERC2CS, ERFCCS, SQRTPI, NTERF, NTERFC,
+     1 NTERC2, XSML, XMAX, SQEPS, FIRST
+      DATA ERFCS( 1) /   -.0490461212 34691808E0 /
+      DATA ERFCS( 2) /   -.1422612051 0371364E0 /
+      DATA ERFCS( 3) /    .0100355821 87599796E0 /
+      DATA ERFCS( 4) /   -.0005768764 69976748E0 /
+      DATA ERFCS( 5) /    .0000274199 31252196E0 /
+      DATA ERFCS( 6) /   -.0000011043 17550734E0 /
+      DATA ERFCS( 7) /    .0000000384 88755420E0 /
+      DATA ERFCS( 8) /   -.0000000011 80858253E0 /
+      DATA ERFCS( 9) /    .0000000000 32334215E0 /
+      DATA ERFCS(10) /   -.0000000000 00799101E0 /
+      DATA ERFCS(11) /    .0000000000 00017990E0 /
+      DATA ERFCS(12) /   -.0000000000 00000371E0 /
+      DATA ERFCS(13) /    .0000000000 00000007E0 /
+      DATA ERC2CS( 1) /   -.0696013466 02309501E0 /
+      DATA ERC2CS( 2) /   -.0411013393 62620893E0 /
+      DATA ERC2CS( 3) /    .0039144958 66689626E0 /
+      DATA ERC2CS( 4) /   -.0004906395 65054897E0 /
+      DATA ERC2CS( 5) /    .0000715747 90013770E0 /
+      DATA ERC2CS( 6) /   -.0000115307 16341312E0 /
+      DATA ERC2CS( 7) /    .0000019946 70590201E0 /
+      DATA ERC2CS( 8) /   -.0000003642 66647159E0 /
+      DATA ERC2CS( 9) /    .0000000694 43726100E0 /
+      DATA ERC2CS(10) /   -.0000000137 12209021E0 /
+      DATA ERC2CS(11) /    .0000000027 88389661E0 /
+      DATA ERC2CS(12) /   -.0000000005 81416472E0 /
+      DATA ERC2CS(13) /    .0000000001 23892049E0 /
+      DATA ERC2CS(14) /   -.0000000000 26906391E0 /
+      DATA ERC2CS(15) /    .0000000000 05942614E0 /
+      DATA ERC2CS(16) /   -.0000000000 01332386E0 /
+      DATA ERC2CS(17) /    .0000000000 00302804E0 /
+      DATA ERC2CS(18) /   -.0000000000 00069666E0 /
+      DATA ERC2CS(19) /    .0000000000 00016208E0 /
+      DATA ERC2CS(20) /   -.0000000000 00003809E0 /
+      DATA ERC2CS(21) /    .0000000000 00000904E0 /
+      DATA ERC2CS(22) /   -.0000000000 00000216E0 /
+      DATA ERC2CS(23) /    .0000000000 00000052E0 /
+      DATA ERFCCS( 1) /   0.0715179310 202925E0 /
+      DATA ERFCCS( 2) /   -.0265324343 37606719E0 /
+      DATA ERFCCS( 3) /    .0017111539 77920853E0 /
+      DATA ERFCCS( 4) /   -.0001637516 63458512E0 /
+      DATA ERFCCS( 5) /    .0000198712 93500549E0 /
+      DATA ERFCCS( 6) /   -.0000028437 12412769E0 /
+      DATA ERFCCS( 7) /    .0000004606 16130901E0 /
+      DATA ERFCCS( 8) /   -.0000000822 77530261E0 /
+      DATA ERFCCS( 9) /    .0000000159 21418724E0 /
+      DATA ERFCCS(10) /   -.0000000032 95071356E0 /
+      DATA ERFCCS(11) /    .0000000007 22343973E0 /
+      DATA ERFCCS(12) /   -.0000000001 66485584E0 /
+      DATA ERFCCS(13) /    .0000000000 40103931E0 /
+      DATA ERFCCS(14) /   -.0000000000 10048164E0 /
+      DATA ERFCCS(15) /    .0000000000 02608272E0 /
+      DATA ERFCCS(16) /   -.0000000000 00699105E0 /
+      DATA ERFCCS(17) /    .0000000000 00192946E0 /
+      DATA ERFCCS(18) /   -.0000000000 00054704E0 /
+      DATA ERFCCS(19) /    .0000000000 00015901E0 /
+      DATA ERFCCS(20) /   -.0000000000 00004729E0 /
+      DATA ERFCCS(21) /    .0000000000 00001432E0 /
+      DATA ERFCCS(22) /   -.0000000000 00000439E0 /
+      DATA ERFCCS(23) /    .0000000000 00000138E0 /
+      DATA ERFCCS(24) /   -.0000000000 00000048E0 /
+      DATA SQRTPI /1.772453850 9055160E0/
+      DATA FIRST /.TRUE./
+C***FIRST EXECUTABLE STATEMENT  ERFC
+      IF (FIRST) THEN
+         ETA = 0.1*R1MACH(3)
+         NTERF = INITS (ERFCS, 13, ETA)
+         NTERFC = INITS (ERFCCS, 24, ETA)
+         NTERC2 = INITS (ERC2CS, 23, ETA)
+C
+         XSML = -SQRT (-LOG(SQRTPI*R1MACH(3)))
+         TXMAX = SQRT (-LOG(SQRTPI*R1MACH(1)))
+         XMAX = TXMAX - 0.5*LOG(TXMAX)/TXMAX - 0.01
+         SQEPS = SQRT (2.0*R1MACH(3))
+      ENDIF
+      FIRST = .FALSE.
+C
+      IF (ISNAN(X)) THEN
+         ERFC = X
+         RETURN
+      ENDIF
+C
+      IF (X.GT.XSML) GO TO 20
+C
+C ERFC(X) = 1.0 - ERF(X) FOR X .LT. XSML
+C
+      ERFC = 2.
+      RETURN
+C
+ 20   IF (X.GT.XMAX) GO TO 40
+      Y = ABS(X)
+      IF (Y.GT.1.0) GO TO 30
+C
+C ERFC(X) = 1.0 - ERF(X) FOR -1. .LE. X .LE. 1.
+C
+      IF (Y.LT.SQEPS) ERFC = 1.0 - 2.0*X/SQRTPI
+      IF (Y.GE.SQEPS) ERFC = 1.0 -
+     1  X*(1.0 + CSEVL (2.*X*X-1., ERFCS, NTERF) )
+      RETURN
+C
+C ERFC(X) = 1.0 - ERF(X) FOR 1. .LT. ABS(X) .LE. XMAX
+C
+ 30   Y = Y*Y
+      IF (Y.LE.4.) ERFC = EXP(-Y)/ABS(X) * (0.5 + CSEVL ((8./Y-5.)/3.,
+     1  ERC2CS, NTERC2) )
+      IF (Y.GT.4.) ERFC = EXP(-Y)/ABS(X) * (0.5 + CSEVL (8./Y-1.,
+     1  ERFCCS, NTERFC) )
+      IF (X.LT.0.) ERFC = 2.0 - ERFC
+      RETURN
+C
+ 40   ERFC = 0.
+      RETURN
+C
+      END
--- a/libcruft/slatec-fn/module.mk	Mon May 07 00:53:54 2012 +0200
+++ b/libcruft/slatec-fn/module.mk	Mon May 07 00:56:44 2012 +0200
@@ -1,4 +1,7 @@
-EXTRA_DIST += slatec-fn/module.mk
+EXTRA_DIST += \
+  slatec-fn/module.mk \
+  slatec-fn/derfc.in.f \
+  slatec-fn/erfc.in.f
 
 libcruft_la_SOURCES += \
   slatec-fn/albeta.f \
@@ -20,7 +23,6 @@
   slatec-fn/dbetai.f \
   slatec-fn/dcsevl.f \
   slatec-fn/derf.f \
-  slatec-fn/derfc.f \
   slatec-fn/dgami.f \
   slatec-fn/dgamit.f \
   slatec-fn/dgamlm.f \
@@ -33,7 +35,6 @@
   slatec-fn/dpchim.f \
   slatec-fn/dpchst.f \
   slatec-fn/erf.f \
-  slatec-fn/erfc.f \
   slatec-fn/gami.f \
   slatec-fn/gamit.f \
   slatec-fn/gamlim.f \
@@ -65,3 +66,15 @@
   slatec-fn/xsgmainc.f \
   slatec-fn/xgamma.f \
   slatec-fn/xbetai.f
+
+nodist_libcruft_la_SOURCES += \
+  slatec-fn/derfc.f \
+  slatec-fn/erfc.f
+
+slatec-fn/erfc.f: slatec-fn/erfc.in.f Makefile
+	$(SED) -e "${F77_ISNAN_MACRO}" < $< > $@-t
+	mv $@-t $@
+
+slatec-fn/derfc.f: slatec-fn/derfc.in.f Makefile
+	$(SED) -e "${F77_ISNAN_MACRO}" < $< > $@-t
+	mv $@-t $@
--- a/liboctave/Array.cc	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/Array.cc	Mon May 07 00:56:44 2012 +0200
@@ -2524,6 +2524,26 @@
 
 template <class T>
 Array<T>
+Array<T>::diag (octave_idx_type m, octave_idx_type n) const
+{
+  Array<T> retval;
+
+  if (ndims () == 2 && (rows () == 1 || cols () == 1))
+    {
+      retval.resize (dim_vector (m, n), resize_fill_value ());
+
+      for (octave_idx_type i = 0; i < numel (); i++)
+        retval.xelem (i, i) = xelem (i);
+    }
+  else
+    (*current_liboctave_error_handler)
+      ("cat: invalid dimension");
+
+  return retval;
+}
+
+template <class T>
+Array<T>
 Array<T>::cat (int dim, octave_idx_type n, const Array<T> *array_list)
 {
   // Default concatenation.
--- a/liboctave/Array.h	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/Array.h	Mon May 07 00:56:44 2012 +0200
@@ -562,6 +562,8 @@
 
   Array<T> diag (octave_idx_type k = 0) const;
 
+  Array<T> diag (octave_idx_type m, octave_idx_type n) const;
+
   // Concatenation along a specified (0-based) dimension, equivalent to cat().
   // dim = -1 corresponds to dim = 0 and dim = -2 corresponds to dim = 1,
   // but apply the looser matching rules of vertcat/horzcat.
--- a/liboctave/CMatrix.cc	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/CMatrix.cc	Mon May 07 00:56:44 2012 +0200
@@ -3239,6 +3239,23 @@
   return MArray<Complex>::diag (k);
 }
 
+ComplexDiagMatrix
+ComplexMatrix::diag (octave_idx_type m, octave_idx_type n) const
+{
+  ComplexDiagMatrix retval;
+
+  octave_idx_type nr = rows ();
+  octave_idx_type nc = cols ();
+
+  if (nr == 1 || nc == 1)
+    retval = ComplexDiagMatrix (*this, m, n);
+  else
+    (*current_liboctave_error_handler)
+      ("diag: expecting vector argument");
+
+  return retval;
+}
+
 bool
 ComplexMatrix::row_is_real_only (octave_idx_type i) const
 {
--- a/liboctave/CMatrix.h	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/CMatrix.h	Mon May 07 00:56:44 2012 +0200
@@ -357,6 +357,8 @@
 
   ComplexMatrix diag (octave_idx_type k = 0) const;
 
+  ComplexDiagMatrix diag (octave_idx_type m, octave_idx_type n) const;
+
   bool row_is_real_only (octave_idx_type) const;
   bool column_is_real_only (octave_idx_type) const;
 
--- a/liboctave/CNDArray.cc	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/CNDArray.cc	Mon May 07 00:56:44 2012 +0200
@@ -862,6 +862,12 @@
   return MArray<Complex>::diag (k);
 }
 
+ComplexNDArray
+ComplexNDArray::diag (octave_idx_type m, octave_idx_type n) const
+{
+  return MArray<Complex>::diag (m, n);
+}
+
 // This contains no information on the array structure !!!
 std::ostream&
 operator << (std::ostream& os, const ComplexNDArray& a)
--- a/liboctave/CNDArray.h	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/CNDArray.h	Mon May 07 00:56:44 2012 +0200
@@ -142,6 +142,8 @@
 
   ComplexNDArray diag (octave_idx_type k = 0) const;
 
+  ComplexNDArray diag (octave_idx_type m, octave_idx_type n) const;
+
   ComplexNDArray& changesign (void)
     {
       MArray<Complex>::changesign ();
--- a/liboctave/DiagArray2.cc	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/DiagArray2.cc	Mon May 07 00:56:44 2012 +0200
@@ -82,16 +82,14 @@
 
 // A two-dimensional array with diagonal elements only.
 
-template <class T>
-T
-DiagArray2<T>::checkelem (octave_idx_type r, octave_idx_type c) const
+template <typename T>
+void
+DiagArray2<T>::check_idx (octave_idx_type r, octave_idx_type c) const
 {
   if (r < 0 || r >= dim1 ())
     gripe_index_out_of_range (2, 1, r+1, dim1 ());
   if (c < 0 || c >= dim2 ())
     gripe_index_out_of_range (2, 2, c+1, dim2 ());
-
-  return elem (r, c);
 }
 
 template <class T>
--- a/liboctave/DiagArray2.h	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/DiagArray2.h	Mon May 07 00:56:44 2012 +0200
@@ -119,15 +119,22 @@
   T& dgelem (octave_idx_type i)
     { return Array<T>::elem (i); }
 
-  T checkelem (octave_idx_type r, octave_idx_type c) const;
+  void check_idx (octave_idx_type r, octave_idx_type c) const;
 
   T operator () (octave_idx_type r, octave_idx_type c) const
     {
 #if defined (BOUNDS_CHECKING)
-      return checkelem (r, c);
-#else
+      check_idx (r, c);
+#endif
       return elem (r, c);
+    }
+
+  T& operator () (octave_idx_type r, octave_idx_type c)
+    {
+#if defined (BOUNDS_CHECKING)
+      check_idx (r, c);
 #endif
+      return elem (r, c);
     }
 
   // No checking.
--- a/liboctave/boolNDArray.cc	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/boolNDArray.cc	Mon May 07 00:56:44 2012 +0200
@@ -134,6 +134,12 @@
   return Array<bool>::diag (k);
 }
 
+boolNDArray
+boolNDArray::diag (octave_idx_type m, octave_idx_type n) const
+{
+  return Array<bool>::diag (m, n);
+}
+
 NDND_BOOL_OPS (boolNDArray, boolNDArray)
 NDND_CMP_OPS (boolNDArray, boolNDArray)
 
--- a/liboctave/boolNDArray.h	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/boolNDArray.h	Mon May 07 00:56:44 2012 +0200
@@ -103,6 +103,7 @@
 
   boolNDArray diag (octave_idx_type k = 0) const;
 
+  boolNDArray diag (octave_idx_type m, octave_idx_type n) const;
 };
 
 NDND_BOOL_OP_DECLS (boolNDArray, boolNDArray, OCTAVE_API)
--- a/liboctave/chNDArray.cc	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/chNDArray.cc	Mon May 07 00:56:44 2012 +0200
@@ -133,6 +133,12 @@
   return Array<char>::diag (k);
 }
 
+charNDArray
+charNDArray::diag (octave_idx_type m, octave_idx_type n) const
+{
+  return Array<char>::diag (m, n);
+}
+
 NDS_CMP_OPS (charNDArray, char)
 NDS_BOOL_OPS (charNDArray, char)
 
--- a/liboctave/chNDArray.h	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/chNDArray.h	Mon May 07 00:56:44 2012 +0200
@@ -96,6 +96,7 @@
 
   charNDArray diag (octave_idx_type k = 0) const;
 
+  charNDArray diag (octave_idx_type m, octave_idx_type n) const;
 };
 
 NDS_CMP_OP_DECLS (charNDArray, char, OCTAVE_API)
--- a/liboctave/dMatrix.cc	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/dMatrix.cc	Mon May 07 00:56:44 2012 +0200
@@ -2783,6 +2783,23 @@
   return MArray<double>::diag (k);
 }
 
+DiagMatrix
+Matrix::diag (octave_idx_type m, octave_idx_type n) const
+{
+  DiagMatrix retval;
+
+  octave_idx_type nr = rows ();
+  octave_idx_type nc = cols ();
+
+  if (nr == 1 || nc == 1)
+    retval = DiagMatrix (*this, m, n);
+  else
+    (*current_liboctave_error_handler)
+      ("diag: expecting vector argument");
+
+  return retval;
+}
+
 ColumnVector
 Matrix::row_min (void) const
 {
--- a/liboctave/dMatrix.h	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/dMatrix.h	Mon May 07 00:56:44 2012 +0200
@@ -316,6 +316,8 @@
 
   Matrix diag (octave_idx_type k = 0) const;
 
+  DiagMatrix diag (octave_idx_type m, octave_idx_type n) const;
+
   ColumnVector row_min (void) const;
   ColumnVector row_max (void) const;
 
--- a/liboctave/dNDArray.cc	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/dNDArray.cc	Mon May 07 00:56:44 2012 +0200
@@ -877,6 +877,12 @@
   return MArray<double>::diag (k);
 }
 
+NDArray
+NDArray::diag (octave_idx_type m, octave_idx_type n) const
+{
+  return MArray<double>::diag (m, n);
+}
+
 // This contains no information on the array structure !!!
 std::ostream&
 operator << (std::ostream& os, const NDArray& a)
--- a/liboctave/dNDArray.h	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/dNDArray.h	Mon May 07 00:56:44 2012 +0200
@@ -154,6 +154,8 @@
 
   NDArray diag (octave_idx_type k = 0) const;
 
+  NDArray diag (octave_idx_type m, octave_idx_type n) const;
+
   NDArray& changesign (void)
     {
       MArray<double>::changesign ();
--- a/liboctave/fCMatrix.cc	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/fCMatrix.cc	Mon May 07 00:56:44 2012 +0200
@@ -3235,6 +3235,23 @@
   return MArray<FloatComplex>::diag (k);
 }
 
+FloatComplexDiagMatrix
+FloatComplexMatrix::diag (octave_idx_type m, octave_idx_type n) const
+{
+  FloatComplexDiagMatrix retval;
+
+  octave_idx_type nr = rows ();
+  octave_idx_type nc = cols ();
+
+  if (nr == 1 || nc == 1)
+    retval = FloatComplexDiagMatrix (*this, m, n);
+  else
+    (*current_liboctave_error_handler)
+      ("diag: expecting vector argument");
+
+  return retval;
+}
+
 bool
 FloatComplexMatrix::row_is_real_only (octave_idx_type i) const
 {
--- a/liboctave/fCMatrix.h	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/fCMatrix.h	Mon May 07 00:56:44 2012 +0200
@@ -362,6 +362,8 @@
 
   FloatComplexMatrix diag (octave_idx_type k = 0) const;
 
+  FloatComplexDiagMatrix diag (octave_idx_type m, octave_idx_type n) const;
+
   bool row_is_real_only (octave_idx_type) const;
   bool column_is_real_only (octave_idx_type) const;
 
--- a/liboctave/fCNDArray.cc	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/fCNDArray.cc	Mon May 07 00:56:44 2012 +0200
@@ -859,6 +859,12 @@
   return MArray<FloatComplex>::diag (k);
 }
 
+FloatComplexNDArray
+FloatComplexNDArray::diag (octave_idx_type m, octave_idx_type n) const
+{
+  return MArray<FloatComplex>::diag (m, n);
+}
+
 // This contains no information on the array structure !!!
 std::ostream&
 operator << (std::ostream& os, const FloatComplexNDArray& a)
--- a/liboctave/fCNDArray.h	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/fCNDArray.h	Mon May 07 00:56:44 2012 +0200
@@ -142,6 +142,8 @@
 
   FloatComplexNDArray diag (octave_idx_type k = 0) const;
 
+  FloatComplexNDArray diag (octave_idx_type m, octave_idx_type n) const;
+
   FloatComplexNDArray& changesign (void)
     {
       MArray<FloatComplex>::changesign ();
--- a/liboctave/fMatrix.cc	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/fMatrix.cc	Mon May 07 00:56:44 2012 +0200
@@ -2783,6 +2783,23 @@
   return MArray<float>::diag (k);
 }
 
+FloatDiagMatrix
+FloatMatrix::diag (octave_idx_type m, octave_idx_type n) const
+{
+  FloatDiagMatrix retval;
+
+  octave_idx_type nr = rows ();
+  octave_idx_type nc = cols ();
+
+  if (nr == 1 || nc == 1)
+    retval = FloatDiagMatrix (*this, m, n);
+  else
+    (*current_liboctave_error_handler)
+      ("diag: expecting vector argument");
+
+  return retval;
+}
+
 FloatColumnVector
 FloatMatrix::row_min (void) const
 {
--- a/liboctave/fMatrix.h	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/fMatrix.h	Mon May 07 00:56:44 2012 +0200
@@ -316,6 +316,8 @@
 
   FloatMatrix diag (octave_idx_type k = 0) const;
 
+  FloatDiagMatrix diag (octave_idx_type m, octave_idx_type n) const;
+
   FloatColumnVector row_min (void) const;
   FloatColumnVector row_max (void) const;
 
--- a/liboctave/fNDArray.cc	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/fNDArray.cc	Mon May 07 00:56:44 2012 +0200
@@ -837,6 +837,12 @@
   return MArray<float>::diag (k);
 }
 
+FloatNDArray
+FloatNDArray::diag (octave_idx_type m, octave_idx_type n) const
+{
+  return MArray<float>::diag (m, n);
+}
+
 // This contains no information on the array structure !!!
 std::ostream&
 operator << (std::ostream& os, const FloatNDArray& a)
--- a/liboctave/fNDArray.h	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/fNDArray.h	Mon May 07 00:56:44 2012 +0200
@@ -151,6 +151,8 @@
 
   FloatNDArray diag (octave_idx_type k = 0) const;
 
+  FloatNDArray diag (octave_idx_type m, octave_idx_type n) const;
+
   FloatNDArray& changesign (void)
     {
       MArray<float>::changesign ();
--- a/liboctave/intNDArray.cc	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/intNDArray.cc	Mon May 07 00:56:44 2012 +0200
@@ -69,6 +69,13 @@
   return MArray<T>::diag (k);
 }
 
+template <class T>
+intNDArray<T>
+intNDArray<T>::diag (octave_idx_type m, octave_idx_type n) const
+{
+  return MArray<T>::diag (m, n);
+}
+
 // FIXME -- this is not quite the right thing.
 
 template <class T>
--- a/liboctave/intNDArray.h	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/intNDArray.h	Mon May 07 00:56:44 2012 +0200
@@ -66,6 +66,8 @@
 
   intNDArray diag (octave_idx_type k = 0) const;
 
+  intNDArray diag (octave_idx_type m, octave_idx_type n) const;
+
   intNDArray& changesign (void)
     {
       MArray<T>::changesign ();
--- a/liboctave/oct-norm.cc	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/oct-norm.cc	Mon May 07 00:56:44 2012 +0200
@@ -415,7 +415,7 @@
   // the OSE part
   VectorT y(m.rows (), 1, 0), z(m.rows (), 1);
   typedef typename VectorT::element_type RR;
-  RR lambda = 0, mu = 0;
+  RR lambda = 0, mu = 1;
   for (octave_idx_type k = 0; k < m.columns (); k++)
     {
       octave_quit ();
--- a/liboctave/regexp.cc	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/regexp.cc	Mon May 07 00:56:44 2012 +0200
@@ -148,7 +148,7 @@
           size_t tmp_pos1 = new_pos + 2;
           size_t tmp_pos2 = tmp_pos1;
 
-          while (tmp_pos1 <= pattern.length () && brackets > 0)
+          while (tmp_pos1 < pattern.length () && brackets > 0)
             {
               char ch = pattern.at (tmp_pos1);
 
@@ -315,9 +315,9 @@
         }
       else if (matches == PCRE_ERROR_NOMATCH)
         break;
-      else if (ovector[1] <= ovector[0])
+      else if (ovector[1] <= ovector[0] && ! options.emptymatch ())
         {
-          // Zero sized match.  Skip to next char.
+          // Zero length match.  Skip to next char.
           idx = ovector[0] + 1;
           if (idx < buffer.length ())
             continue;
@@ -400,7 +400,16 @@
           regexp::match_element new_elem (named_tokens, tokens, match_string,
                                           token_extents, start, end);
           lst.push_back (new_elem);
-          idx = ovector[1];
+
+          if (ovector[1] <= ovector[0])
+          {
+            // Zero length match.  Skip to next char.
+            idx = ovector[0] + 1;
+            if (idx <= buffer.length ())
+              continue;
+          }
+          else 
+            idx = ovector[1];
 
           if (options.once () || idx >= buffer.length ())
             break;
--- a/liboctave/regexp.h	Mon May 07 00:53:54 2012 +0200
+++ b/liboctave/regexp.h	Mon May 07 00:56:44 2012 +0200
@@ -95,11 +95,13 @@
 
     opts (void)
       : x_case_insensitive (false), x_dotexceptnewline (false),
-        x_freespacing (false), x_lineanchors (false), x_once (false) { }
+        x_emptymatch (false), x_freespacing (false), x_lineanchors (false),
+        x_once (false) { }
 
     opts (const opts& o)
       : x_case_insensitive (o.x_case_insensitive),
         x_dotexceptnewline (o.x_dotexceptnewline),
+        x_emptymatch (o.x_emptymatch),
         x_freespacing (o.x_freespacing),
         x_lineanchors (o.x_lineanchors),
         x_once (o.x_once)
@@ -111,6 +113,7 @@
         {
           x_case_insensitive = o.x_case_insensitive;
           x_dotexceptnewline = o.x_dotexceptnewline;
+          x_emptymatch = o.x_emptymatch;
           x_freespacing = o.x_freespacing;
           x_lineanchors = o.x_lineanchors;
           x_once = o.x_once;
@@ -123,12 +126,14 @@
 
     void case_insensitive (bool val) { x_case_insensitive = val; }
     void dotexceptnewline (bool val) { x_dotexceptnewline = val; }
+    void emptymatch (bool val) { x_emptymatch = val; }
     void freespacing (bool val) { x_freespacing = val; }
     void lineanchors (bool val) { x_lineanchors = val; }
     void once (bool val) { x_once = val; }
 
     bool case_insensitive (void) const { return x_case_insensitive; }
     bool dotexceptnewline (void) const { return x_dotexceptnewline; }
+    bool emptymatch (void) const { return x_emptymatch; }
     bool freespacing (void) const { return x_freespacing; }
     bool lineanchors (void) const { return x_lineanchors; }
     bool once (void) const { return x_once; }
@@ -137,6 +142,7 @@
 
     bool x_case_insensitive;
     bool x_dotexceptnewline;
+    bool x_emptymatch;
     bool x_freespacing;
     bool x_lineanchors;
     bool x_once;
--- a/m4/acinclude.m4	Mon May 07 00:53:54 2012 +0200
+++ b/m4/acinclude.m4	Mon May 07 00:56:44 2012 +0200
@@ -329,6 +329,28 @@
   fi
 ])
 dnl
+dnl Check to see whether Fortran compiler has the intrinsic function ISNAN.
+dnl
+AC_DEFUN([OCTAVE_CHECK_FORTRAN_HAVE_ISNAN], [
+  AC_LANG_PUSH(Fortran 77)
+  AC_CACHE_CHECK([whether $F77 has the intrinsic function ISNAN],
+                 [octave_cv_fortran_have_isnan],
+[AC_COMPILE_IFELSE(
+[      program foo
+      implicit none
+      real x
+      double precision y
+      if (isnan(x)) then
+         print *, 'x is NaN'
+      end if
+      if (isnan(y)) then
+         print *, 'y is NaN'
+      end if
+      end program], [octave_cv_fortran_have_isnan=yes], [octave_cv_fortran_have_isnan=no]
+)])
+  AC_LANG_POP(Fortran 77)      
+])
+dnl
 dnl Check to see whether the default Fortran INTEGER is 64 bits wide.
 dnl
 AC_DEFUN([OCTAVE_CHECK_FORTRAN_INTEGER_SIZE], [
--- a/scripts/audio/mu2lin.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/audio/mu2lin.m	Mon May 07 00:56:44 2012 +0200
@@ -41,21 +41,21 @@
     print_usage ();
   endif
 
-  ulaw = [32124, 31100, 30076, 29052, 28028, 27004, 25980, 24956, \
-          23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764, \
-          15996, 15484, 14972, 14460, 13948, 13436, 12924, 12412, \
-          11900, 11388, 10876, 10364,  9852,  9340,  8828,  8316, \
-           7932,  7676,  7420,  7164,  6908,  6652,  6396,  6140, \
-           5884,  5628,  5372,  5116,  4860,  4604,  4348,  4092, \
-           3900,  3772,  3644,  3516,  3388,  3260,  3132,  3004, \
-           2876,  2748,  2620,  2492,  2364,  2236,  2108,  1980, \
-           1884,  1820,  1756,  1692,  1628,  1564,  1500,  1436, \
-           1372,  1308,  1244,  1180,  1116,  1052,   988,   924, \
-            876,   844,   812,   780,   748,   716,   684,   652, \
-            620,   588,   556,   524,   492,   460,   428,   396, \
-            372,   356,   340,   324,   308,   292,   276,   260, \
-            244,   228,   212,   196,   180,   164,   148,   132, \
-            120,   112,   104,    96,    88,    80,    72,    64, \
+  ulaw = [32124, 31100, 30076, 29052, 28028, 27004, 25980, 24956, ...
+          23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764, ...
+          15996, 15484, 14972, 14460, 13948, 13436, 12924, 12412, ...
+          11900, 11388, 10876, 10364,  9852,  9340,  8828,  8316, ...
+           7932,  7676,  7420,  7164,  6908,  6652,  6396,  6140, ...
+           5884,  5628,  5372,  5116,  4860,  4604,  4348,  4092, ...
+           3900,  3772,  3644,  3516,  3388,  3260,  3132,  3004, ...
+           2876,  2748,  2620,  2492,  2364,  2236,  2108,  1980, ...
+           1884,  1820,  1756,  1692,  1628,  1564,  1500,  1436, ...
+           1372,  1308,  1244,  1180,  1116,  1052,   988,   924, ...
+            876,   844,   812,   780,   748,   716,   684,   652, ...
+            620,   588,   556,   524,   492,   460,   428,   396, ...
+            372,   356,   340,   324,   308,   292,   276,   260, ...
+            244,   228,   212,   196,   180,   164,   148,   132, ...
+            120,   112,   104,    96,    88,    80,    72,    64, ...
              56,    48,    40,    32,    24,    16,     8,     0 ];
 
   ulaw = [ -ulaw, ulaw ];
--- a/scripts/deprecated/cut.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/deprecated/cut.m	Mon May 07 00:56:44 2012 +0200
@@ -51,10 +51,10 @@
   if (!isvector (x))
     error ("cut: X must be a vector");
   endif
-  if isscalar (breaks)
+  if (isscalar (breaks))
     breaks = linspace (min (x), max (x), breaks + 1);
     breaks(1) = breaks(1) - 1;
-  elseif isvector (breaks)
+  elseif (isvector (breaks))
     breaks = sort (breaks);
   else
     error ("cut: BREAKS must be a scalar or vector");
@@ -62,7 +62,7 @@
 
   group = NaN (size (x));
   m = length (breaks);
-  if any (k = find ((x >= min (breaks)) & (x < max (breaks))))
+  if (any (k = find ((x >= min (breaks)) & (x < max (breaks)))))
     n = length (k);
     group(k) = sum ((ones (m, 1) * reshape (x(k), 1, n))
                     >= (reshape (breaks, m, 1) * ones (1, n)));
--- a/scripts/general/cplxpair.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/general/cplxpair.m	Mon May 07 00:56:44 2012 +0200
@@ -52,7 +52,7 @@
 
 function y = cplxpair (z, tol, dim)
 
-  if nargin < 1 || nargin > 3
+  if (nargin < 1 || nargin > 3)
     print_usage ();
   endif
 
--- a/scripts/general/genvarname.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/general/genvarname.m	Mon May 07 00:56:44 2012 +0200
@@ -158,7 +158,7 @@
     endif
     varname(i) = str(i);
     idx = 0;
-    while excluded
+    while (excluded)
       idx++;
       varname{i} = sprintf("%s%d", str{i}, idx);
       excluded = any (strcmp (varname{i}, exclusions));
@@ -166,7 +166,7 @@
     exclusions(end+1) = varname(i);
   endfor
 
-  if strinput
+  if (strinput)
     varname = varname{1};
   endif
 
--- a/scripts/general/logspace.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/general/logspace.m	Mon May 07 00:56:44 2012 +0200
@@ -18,7 +18,7 @@
 
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {} logspace (@var{a}, @var{b})
-## @deftypefnx {Function File} {} logspace (@var{b}, @var{b}, @var{n})
+## @deftypefnx {Function File} {} logspace (@var{a}, @var{b}, @var{n})
 ## @deftypefnx {Function File} {} logspace (@var{a}, pi, @var{n})
 ## Return a row vector with @var{n} elements logarithmically spaced from
 ## @tex
--- a/scripts/general/num2str.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/general/num2str.m	Mon May 07 00:56:44 2012 +0200
@@ -64,54 +64,82 @@
 
   if (nargin != 1 && nargin != 2)
     print_usage ();
+  elseif (! ismatrix (x))
+    error ("num2str: X must be a numeric, logical, or character array");
   endif
 
   if (ischar (x))
     retval = x;
   elseif (isempty (x))
     retval = "";
-  elseif (iscomplex (x))
+  elseif (isreal (x))
+    if (nargin == 2)
+      if (ischar (arg))
+        fmt = arg;
+      elseif (isnumeric (arg) && isscalar (arg) && arg >= 0)
+        fmt = sprintf ("%%%d.%dg", arg+7, arg);
+      else
+        error ("num2str: PRECISION must be a scalar integer >= 0");
+      endif
+    else
+      if (isnumeric (x))
+        ## Setup a suitable format string
+        dgt = floor (log10 (max (abs (x(:)))));
+        if (any (x(:) != fix (x(:))))
+          ## Floating point input
+          dgt = max (dgt + 4, 5);   # Keep 4 sig. figures after decimal point
+          dgt = min (dgt, 16);      # Cap significant digits at 16
+          fmt = sprintf ("%%%d.%dg", dgt+7+any (x(:) < 0), dgt);
+        else
+          ## Integer input
+          dgt = max (dgt + 1, 1);
+          ## FIXME: Integers should be masked to show only 16 significant digits
+          ##        See %!xtest below
+          fmt = sprintf ("%%%d.%dg", dgt+2+any (x(:) < 0), dgt);
+        endif
+      else
+        ## Logical input
+        fmt = "%3d";
+      endif
+    endif
+    fmt = cstrcat (deblank (repmat (fmt, 1, columns (x))), "\n");
+    nd = ndims (x);
+    tmp = sprintf (fmt, permute (x, [2, 1, 3:nd]));
+    retval = strtrim (char (strsplit (tmp(1:end-1), "\n")));
+  else   # Complex matrix input
     if (nargin == 2)
       if (ischar (arg))
         fmt = cstrcat (arg, "%-+", arg(2:end), "i");
+      elseif (isnumeric (arg) && isscalar (arg) && arg >= 0)
+        fmt = sprintf ("%%%d.%dg%%-+%d.%dgi", arg+7, arg, arg+7, arg);
       else
-        if (isnumeric (x) && x == fix (x) && abs (x) < (10 .^ arg))
-          fmt = sprintf ("%%%dd%%-+%ddi  ", arg, arg);
-        else
-          fmt = sprintf ("%%%d.%dg%%-+%d.%dgi", arg+7, arg, arg+7, arg);
-        endif
+        error ("num2str: PRECISION must be a scalar integer >= 0");
       endif
     else
       ## Setup a suitable format string
-      if (isnumeric (x) && x == fix (x) && abs (x) < 1e10)
-        if (max (abs (real (x(:)))) == 0)
-          dgt1 = 2;
-        else
-          dgt1 = ceil (log10 (max (max (abs (real (x(:)))),
-                                   max (abs (imag (x(:))))))) + 2;
-        endif
-        dgt2 = dgt1 - (min (real (x(:))) >= 0);
-
-        if (length (abs (x) == x) > 0)
-          fmt = sprintf("%%%dg%%+-%dgi  ", dgt2, dgt1);
-        else
-          fmt = sprintf("%%%dd%%+-%ddi  ", dgt2, dgt1);
-        endif
-      elseif (isscalar (x))
-        fmt = "%.6g%-+.6gi";
+      dgt = floor (log10 (max (max (abs (real (x(:)))),
+                               max (abs (imag (x(:)))))));
+      if (any (x(:) != fix (x(:))))
+        ## Floating point input
+          dgt = max (dgt + 4, 5);   # Keep 4 sig. figures after decimal point
+          dgt = min (dgt, 16);      # Cap significant digits at 16
+          fmt = sprintf ("%%%d.%dg%%-+%d.%dgi", dgt+7, dgt, dgt+7, dgt);
       else
-        fmt = "%11.6g%-+11.6gi";
+        ## Integer input
+        dgt = max (1 + dgt, 1);
+        ## FIXME: Integers should be masked to show only 16 significant digits
+        ##        See %!xtest below
+        fmt = sprintf ("%%%d.%dg%%-+%d.%dgi", dgt+2, dgt, dgt+2, dgt);
       endif
     endif
 
     ## Manipulate the complex value to have real values in the odd
     ## columns and imaginary values in the even columns.
-    sz = size (x);
-    nc = sz(2);
+    nc = columns (x);
     nd = ndims (x);
-    perm = fix ([1:0.5:nc+0.5]);
-    perm(2:2:2*nc) = perm(2:2:2*nc) + nc;
     idx = repmat ({':'}, nd, 1);
+    perm(1:2:2*nc) = 1:nc;
+    perm(2:2:2*nc) = nc + (1:nc);
     idx{2} = perm;
     x = horzcat (real (x), imag (x));
     x = x(idx{:});
@@ -120,59 +148,10 @@
     tmp = sprintf (fmt, permute (x, [2, 1, 3:nd]));
 
     ## Put the "i"'s where they are supposed to be.
-    while (true)
-      tmp2 = strrep (tmp, " i\n", "i\n");
-      if (length (tmp) == length (tmp2))
-        break;
-      else
-        tmp = tmp2;
-      endif
-    endwhile
-    while (true)
-      tmp2 = strrep (tmp, " i", "i ");
-      if (tmp == tmp2)
-        break;
-      else
-        tmp = tmp2;
-      endif
-    endwhile
+    tmp = regexprep (tmp, " +i\n", "i\n");
+    tmp = regexprep (tmp, "( +)i", "i$1");
 
-    tmp(length (tmp)) = "";
-    retval = char (strtrim (strsplit (tmp, "\n")));
-  else
-    if (nargin == 2)
-      if (ischar (arg))
-        fmt = arg;
-      else
-        if (isnumeric (x) && x == fix (x) && abs (x) < (10 .^ arg))
-          fmt = sprintf ("%%%dd  ", arg);
-        else
-          fmt = sprintf ("%%%d.%dg", arg+7, arg);
-        endif
-      endif
-    else
-      if (isnumeric (x) && x == fix (x) && abs (x) < 1e10)
-        if (max (abs (x(:))) == 0)
-          dgt = 2;
-        else
-          dgt = floor (log10 (max (abs(x(:))))) + (min (real (x(:))) < 0) + 2;
-        endif
-        if (length (abs (x) == x) > 0)
-          fmt = sprintf ("%%%dg  ", dgt);
-        else
-          fmt = sprintf ("%%%dd  ", dgt);
-        endif
-      elseif (isscalar (x))
-        fmt = "%11.5g";
-      else
-        fmt = "%11.5g";
-      endif
-    endif
-    fmt = cstrcat (deblank (repmat (fmt, 1, columns (x))), "\n");
-    nd = ndims (x);
-    tmp = sprintf (fmt, permute (x, [2, 1, 3:nd]));
-    tmp(length (tmp)) = "";
-    retval = strtrim (char (strsplit (tmp, "\n")));
+    retval = strtrim (char (strsplit (tmp(1:end-1), "\n")));
   endif
 
 endfunction
@@ -183,7 +162,26 @@
 %!assert (num2str (123.456, 4), "123.5")
 %!assert (num2str ([1, 1.34; 3, 3.56], "%5.1f"),  ["1.0  1.3"; "3.0  3.6"])
 %!assert (num2str (1.234 + 27.3i), "1.234+27.3i")
+%!assert (num2str ([true false true]), "1  0  1");
+
+%!assert (num2str (19440606), "19440606")
+%!assert (num2str (2^33), "8589934592")
+%!assert (num2str (-2^33), "-8589934592")
+%!assert (num2str (2^33+1i), "8589934592+1i")
+%!assert (num2str (-2^33+1i), "-8589934592+1i")
+
+## FIXME: Integers greater than bitmax() should be masked to show just
+##        16 digits of precision.
+%!xtest
+%! assert (num2str (1e23), "100000000000000000000000");
 
 %!error num2str ()
 %!error num2str (1, 2, 3)
+%!error <X must be a numeric> num2str ({1})
+%!error <PRECISION must be a scalar integer> num2str (1, {1})
+%!error <PRECISION must be a scalar integer> num2str (1, ones (2))
+%!error <PRECISION must be a scalar integer> num2str (1, -1)
+%!error <PRECISION must be a scalar integer> num2str (1+1i, {1})
+%!error <PRECISION must be a scalar integer> num2str (1+1i, ones (2))
+%!error <PRECISION must be a scalar integer> num2str (1+1i, -1)
 
--- a/scripts/geometry/delaunay.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/geometry/delaunay.m	Mon May 07 00:56:44 2012 +0200
@@ -56,7 +56,7 @@
 ## plot (VX, VY, "b", x, y, "r*");
 ## @end group
 ## @end example
-## @seealso{delaunay3, delaunayn, convhull, voronoi}
+## @seealso{delaunay3, delaunayn, convhull, voronoi, triplot, trimesh, trisurf}
 ## @end deftypefn
 
 ## Author: Kai Habel <kai.habel@gmx.de>
--- a/scripts/geometry/delaunay3.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/geometry/delaunay3.m	Mon May 07 00:56:44 2012 +0200
@@ -42,7 +42,7 @@
 ## To append user options to the defaults it is necessary to repeat the 
 ## default arguments in @var{options}.  Use a null string to pass no arguments.
 ##
-## @seealso{delaunay, delaunayn, convhull, voronoi}
+## @seealso{delaunay, delaunayn, convhull, voronoi, tetramesh}
 ## @end deftypefn
 
 ## Author: Kai Habel <kai.habel@gmx.de>
--- a/scripts/geometry/delaunayn.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/geometry/delaunayn.m	Mon May 07 00:56:44 2012 +0200
@@ -47,7 +47,7 @@
 ## To append user options to the defaults it is necessary to repeat the 
 ## default arguments in @var{options}.  Use a null string to pass no arguments.
 ##
-## @seealso{delaunay, delaunay3, convhulln, voronoin}
+## @seealso{delaunay, delaunay3, convhulln, voronoin, trimesh, tetramesh}
 ## @end deftypefn
 
 function T = delaunayn (pts, varargin)
--- a/scripts/geometry/rectint.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/geometry/rectint.m	Mon May 07 00:56:44 2012 +0200
@@ -43,7 +43,7 @@
     error ("rectint: A must have 4 columns");
   elseif (columns (b) != 4)
     error ("rectint: B must have 4 columns");
-  elseif any ([a(:,3:4);b(:,3:4)](:) < 0)
+  elseif (any ([a(:,3:4);b(:,3:4)](:) < 0))
     error ("rectint: all widths and heights must be > 0");
   endif
 
@@ -105,7 +105,7 @@
 
   endfor
 
-  if swapinputs
+  if (swapinputs)
     area = area';
   endif
 
--- a/scripts/help/gen_doc_cache.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/help/gen_doc_cache.m	Mon May 07 00:56:44 2012 +0200
@@ -34,7 +34,7 @@
 function gen_doc_cache (out_file = "doc-cache", directory = [])
 
   ## Check input
-  if (!ischar (out_file))
+  if (! ischar (out_file))
     print_usage ();
   endif
 
@@ -42,11 +42,11 @@
   if (isempty (directory))
     cache = gen_builtin_cache ();
   elseif (iscell (directory))
-    if all(cellfun (@ischar, directory))
+    if (all (cellfun (@ischar, directory)))
       cache = gen_doc_cache_in_dir (directory);
     else
       error ("gen_doc_cache: cell must contain only strings");
-    end
+    endif
   elseif (ischar (directory))
      cache = gen_doc_cache_in_dir (directory);
   else
@@ -120,15 +120,15 @@
   dir_in_path = ismember (directory, strsplit (path (), pathsep ()));
 
   # dirs not in path
-  if !iscell (directory)
+  if (! iscell (directory))
     directory = {directory};
-  end
+  endif
   dirs_notpath = {directory{!dir_in_path}};
 
   # add them
-  if !isempty (dirs_notpath)
+  if (! isempty (dirs_notpath))
     cellfun (@addpath, dirs_notpath);
-  end
+  endif
 
   # create cache
   func = @(s_) create_cache (__list_functions__ (s_));
@@ -138,9 +138,9 @@
   cache = [cache{:}];
 
   #remove dirs form path
-  if !isempty (dirs_notpath)
+  if (! isempty (dirs_notpath))
     cellfun (@rmpath, dirs_notpath);
-  end
+  endif
 
 endfunction
 
--- a/scripts/help/unimplemented.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/help/unimplemented.m	Mon May 07 00:56:44 2012 +0200
@@ -178,7 +178,6 @@
   "figurepalette",
   "filebrowser",
   "fill3",
-  "findfigs",
   "fitsinfo",
   "fitsread",
   "flow",
@@ -191,7 +190,6 @@
   "gco",
   "getframe",
   "getpixelposition",
-  "gmres",
   "grabcode",
   "graymon",
   "gsvd",
@@ -340,7 +338,6 @@
   "serial",
   "setpixelposition",
   "showplottool",
-  "shrinkfaces",
   "smooth3",
   "snapnow",
   "sound",
@@ -360,7 +357,6 @@
   "surf2patch",
   "symmlq",
   "syntax",
-  "tetramesh",
   "texlabel",
   "textwrap",
   "tfqmr",
--- a/scripts/image/hsv2rgb.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/image/hsv2rgb.m	Mon May 07 00:56:44 2012 +0200
@@ -59,7 +59,7 @@
   endif
 
   ## set values <0 to 0 and >1 to 1
-  hsv_map = (hsv_map >= 0 & hsv_map <= 1) .* hsv_map \
+  hsv_map = (hsv_map >= 0 & hsv_map <= 1) .* hsv_map ...
       + (hsv_map < 0) .* 0 + (hsv_map > 1);
 
   ## fill rgb map with v*(1-s)
--- a/scripts/image/rainbow.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/image/rainbow.m	Mon May 07 00:56:44 2012 +0200
@@ -48,16 +48,15 @@
   elseif (n > 1)
     x = linspace (0, 1, n)';
 
-    r = (x < 2/5) \
-        + (x >= 2/5 & x < 3/5) .* (-5 * x + 3) \
-        + (x >= 4/5) .* (10/3 * x - 8/3);
+    r = ((x < 2/5)
+         + (x >= 2/5 & x < 3/5) .* (-5 * x + 3)
+         + (x >= 4/5) .* (10/3 * x - 8/3));
 
-    g = (x < 2/5) .* (5/2 * x) \
-        + (x >= 2/5 & x < 3/5) \
-        + (x >= 3/5 & x < 4/5) .* (-5 * x + 4);
+    g = ((x < 2/5) .* (5/2 * x)
+         + (x >= 2/5 & x < 3/5)
+         + (x >= 3/5 & x < 4/5) .* (-5 * x + 4));
 
-    b = (x >= 3/5 & x < 4/5) .* (5 * x - 3) \
-        + (x >= 4/5);
+    b = (x >= 3/5 & x < 4/5) .* (5 * x - 3) + (x >= 4/5);
 
     map = [r, g, b];
   else
--- a/scripts/io/strread.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/io/strread.m	Mon May 07 00:56:44 2012 +0200
@@ -1,5 +1,5 @@
 ## Copyright (C) 2009-2012 Eric Chassande-Mottin, CNRS (France)
-## Copyright (C) 2012 Philip Nienhuis
+## Parts Copyright (C) 2012 Philip Nienhuis
 ##
 ## This file is part of Octave.
 ##
--- a/scripts/io/textread.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/io/textread.m	Mon May 07 00:56:44 2012 +0200
@@ -41,14 +41,16 @@
 ## delimiters.
 ## @end itemize
 ##
-## The optional input @var{n} specifes the number of times to use
-## @var{format} when parsing, i.e., the format repeat count.
+## The optional input @var{n} specifes the number of data lines to read; in
+## this sense it differs slightly from the format repeat count in strread.
 ##
 ## @seealso{strread, load, dlmread, fscanf, textscan}
 ## @end deftypefn
 
 function varargout = textread (filename, format = "%f", varargin)
 
+  BUFLENGTH = 4096;       # Read buffer to speed up processing @var{n}
+
   ## Check input
   if (nargin < 1)
     print_usage ();
@@ -58,6 +60,17 @@
     error ("textread: FILENAME and FORMAT arguments must be strings");
   endif
 
+  if (! isempty (varargin) && isnumeric (varargin{1}))
+    nlines = varargin{1};
+  else
+    nlines = Inf;
+  endif
+  if (nlines < 1)
+    printf ("textread: N = 0, no data read\n");
+    varargout = cell (1, nargout);
+    return
+  endif
+
   ## Read file
   fid = fopen (filename, "r");
   if (fid == -1)
@@ -71,28 +84,13 @@
     fskipl (fid, varargin{headerlines + 1});
     varargin(headerlines:headerlines+1) = [];
   endif
-  
-  if (! isempty (varargin) && isnumeric (varargin{1}))
-    nlines = varargin{1};
-  else
-    nlines = Inf;
-  endif
+  st_pos = ftell (fid);
 
-  if (isfinite (nlines) && (nlines >= 0))
-    str = tmp_str = "";
-    n = 0;
-    ## FIXME: Can this be done without slow loop?
-    while (ischar (tmp_str) && n++ <= nlines)
-      str = strcat (str, tmp_str);
-      tmp_str = fgets (fid);
-    endwhile
-  else
-    str = fread (fid, "char=>char").';
-  endif
-  fclose (fid);
-
-  if (isempty (str))
+  ## Read a first file chunk. Rest follows after endofline processing
+  [str, count] = fscanf (fid, "%c", BUFLENGTH);
+  if (isempty (str) || count < 1)
     warning ("textread: empty file");
+    varargout = cell (1, nargout);
     return;
   endif
 
@@ -103,8 +101,8 @@
       error ("textread: character value required for EndOfLine");
     endif
   else
-    ## Determine EOL from file.  Search for EOL candidates in first 3000 chars
-    eol_srch_len = min (length (str), 3000);
+    ## Determine EOL from file.  Search for EOL candidates in first BUFLENGTH chars
+    eol_srch_len = min (length (str), BUFLENGTH);
     ## First try DOS (CRLF)
     if (! isempty (strfind ("\r\n", str(1 : eol_srch_len))))
       eol_char = "\r\n";
@@ -116,12 +114,49 @@
       eol_char = "\n";
     endif
     ## Set up default endofline param value
-    varargin(end+1:end+2) = {'endofline', eol_char};
+    varargin(end+1:end+2) = {"endofline", eol_char};
   endif
-
+ 
+  ## Now that we know what EOL looks like, we can process format_repeat_count.
+  ## FIXME The below isn't ML-compatible: counts lines, not format string uses
+  if (isfinite (nlines) && (nlines > 0))
+    l_eol_char = length (eol_char);
+    eoi = findstr (str, eol_char);
+    n_eoi = length (eoi);
+    nblks = 0;
+    ## Avoid slow repeated str concatenation, first seek requested end of data
+    while (n_eoi < nlines && count == BUFLENGTH)
+      [nstr, count] = fscanf (fid, "%c", BUFLENGTH);
+      if (count > 0)
+        ## Watch out for multichar EOL being missed across buffer boundaries
+        if (l_eol_char > 1)
+          str = [str(end - length (eol_char) + 2 : end) nstr];
+        else
+          str = nstr;
+        endif
+        eoi = findstr (str, eol_char);
+        n_eoi += numel (eoi);
+        ++nblks;
+      endif
+    endwhile
+    ## Found EOL delimiting last requested line. Compute ptr (incl. EOL)
+    if (isempty (eoi))
+      printf ("textread: format repeat count specified but no endofline found\n");
+      eoi_pos = nblks * BUFLENGTH + count;
+    else
+      eoi_pos = (nblks * BUFLENGTH) + eoi(end + min (nlines, n_eoi) - n_eoi);
+    endif
+    fseek (fid, st_pos, "bof");
+    str = fscanf (fid, "%c", eoi_pos);
+  else
+    fseek (fid, st_pos, "bof");
+    str = fread(fid, "char=>char").';
+  endif
+  fclose (fid);
+ 
   ## Set up default whitespace param value if needed
-  if (isempty (find (strcmpi ('whitespace', varargin))))
-    varargin(end+1:end+2) = {'whitespace', " \b\t"};
+  if (isempty (find (strcmpi ("whitespace", varargin))))
+    varargin(end+1:end+2) = {"whitespace", " \b\t"};
   endif
 
   ## Call strread to make it do the real work
--- a/scripts/io/textscan.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/io/textscan.m	Mon May 07 00:56:44 2012 +0200
@@ -52,8 +52,11 @@
 ## have been encountered.  If set to 0 or false, return an error and no data.
 ## @end itemize
 ##
-## The optional input @var{n} specifes the number of times to use
-## @var{format} when parsing, i.e., the format repeat count.
+## When reading from a character string, optional input argument @var{n}
+## specifes the number of times @var{format} should be used (i.e., to limit
+## the amount of data read).
+## When reading fro file, @var{n} specifes the number of data lines to read;
+## in this sense it differs slightly from the format repeat count in strread.
 ##
 ## The output @var{C} is a cell array whose length is given by the number
 ## of format specifiers.
@@ -66,6 +69,8 @@
 
 function [C, position] = textscan (fid, format = "%f", varargin)
 
+  BUFLENGTH = 4096;               ## Read buffer
+  
   ## Check input
   if (nargin < 1)
     print_usage ();
@@ -89,6 +94,11 @@
   else
     nlines = Inf;
   endif
+  if (nlines < 1)
+    printf ("textscan: N = 0, no data read\n");
+    C = [];
+    return
+  endif
 
   if (! any (strcmpi (args, "emptyvalue")))
     ## Matlab returns NaNs for missing values
@@ -148,26 +158,17 @@
     endif
     str = fid;
   else
+    st_pos = ftell (fid);
     ## Skip header lines if requested
     headerlines = find (strcmpi (args, "headerlines"), 1);
     ## Beware of zero valued headerline, fskipl would skip to EOF
     if (! isempty (headerlines) && (args{headerlines + 1} > 0))
-      fskipl (fid, varargin{headerlines + 1});
+      fskipl (fid, args{headerlines + 1});
       args(headerlines:headerlines+1) = [];
+      st_pos = ftell (fid);
     endif
-    if (isfinite (nlines) && (nlines >= 0))
-      str = tmp_str = "";
-      n = 0;
-      ## FIXME: Can this be done without slow loop?
-      while (ischar (tmp_str) && n++ < nlines)
-        tmp_str = fgets (fid);
-        if (ischar (tmp_str))
-          str = strcat (str, tmp_str);
-        endif
-      endwhile
-    else
-      str = fread (fid, "char=>char").';
-    endif
+    ## Read a first file chunk. Rest follows after endofline processing
+    [str, count] = fscanf (fid, "%c", BUFLENGTH);
   endif
 
   ## Check for empty result
@@ -189,8 +190,8 @@
       error ("textscan: character value required for EndOfLine");
     endif
   else
-    ## Determine EOL from file.  Search for EOL candidates in first 3000 chars
-    eol_srch_len = min (length (str), 3000);
+    ## Determine EOL from file.  Search for EOL candidates in first BUFLENGTH chars
+    eol_srch_len = min (length (str), BUFLENGTH);
     ## First try DOS (CRLF)
     if (! isempty (strfind ("\r\n", str(1 : eol_srch_len))))
       eol_char = "\r\n";
@@ -202,7 +203,47 @@
       eol_char = "\n";
     endif
     ## Set up the default endofline param value
-    args(end+1:end+2) = {'endofline', eol_char};
+    args(end+1:end+2) = {"endofline", eol_char};
+  endif
+
+  if (!ischar (fid))
+    ## Now that we know what EOL looks like, we can process format_repeat_count.
+    ## FIXME The below isn't ML-compatible: counts lines, not format string uses
+    if (isfinite (nlines) && (nlines >= 0))
+      l_eol_char = length (eol_char);
+      eoi = findstr (str, eol_char);
+      n_eoi = length (eoi);
+      nblks = 0;
+      ## Avoid slow repeated str concatenation, first seek requested end of data
+      while (n_eoi < nlines && count == BUFLENGTH)
+        [nstr, count] = fscanf (fid, "%c", BUFLENGTH);
+        if (count > 0)
+          ## Watch out for multichar EOL being missed across buffer boundaries
+          if (l_eol_char > 1)
+            str = [str(end - length (eol_char) + 2 : end) nstr];
+          else
+            str = nstr;
+          endif
+          eoi = findstr (str, eol_char);
+          n_eoi += numel (eoi);
+          ++nblks;
+        endif
+      endwhile
+      ## OK, found EOL delimiting last requested line. Compute ptr (incl. EOL)
+      if (isempty (eoi))
+        printf ("textscan: format repeat count specified but no endofline found\n");
+        data_size = nblks * BUFLENGTH + count;
+      else
+        ## Compute data size to read incl complete EOL
+        data_size = (nblks * BUFLENGTH) + eoi(end + min (nlines, n_eoi) - n_eoi) \
+                    + l_eol_char - 1;
+      endif
+      fseek (fid, st_pos, "bof");
+      str = fscanf (fid, "%c", data_size);
+    else
+      fseek (fid, st_pos, "bof");
+      str = fread (fid, "char=>char").';
+    endif
   endif
 
   ## Determine the number of data fields
@@ -223,6 +264,7 @@
   endif
 
   if (nargout == 2)
+    ## Remember file position (persistent var)
     position = ftell (fid);
   endif
 
@@ -234,10 +276,10 @@
 
   ## Start at rightmost column and work backwards to avoid ptr mixup
   ii = numel (C);
-  while ii > 1
+  while (ii > 1)
     clss1 = class (C{ii});
     jj = ii;
-    while  (jj > 1 && strcmp (clss1, class (C{jj - 1})))
+    while (jj > 1 && strcmp (clss1, class (C{jj - 1})))
       ## Column to the left is still same class; check next column to the left
       --jj;
     endwhile
--- a/scripts/linear-algebra/condest.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/linear-algebra/condest.m	Mon May 07 00:56:44 2012 +0200
@@ -132,7 +132,7 @@
     have_A = true;
 
     if (nargin > 1)
-      if (isscalar (varargin{2}))
+      if (! is_function_handle (varargin{2}))
         t = varargin{2};
         have_t = true;
       elseif (nargin > 2)
--- a/scripts/linear-algebra/onenormest.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/linear-algebra/onenormest.m	Mon May 07 00:56:44 2012 +0200
@@ -95,7 +95,7 @@
 
 function [est, v, w, iter] = onenormest (varargin)
 
-  if (size (varargin, 2) < 1 || size (varargin, 2) > 4)
+  if (nargin < 1 || nargin > 4)
     print_usage ();
   endif
 
@@ -103,31 +103,31 @@
   itmax = 10;
 
   if (ismatrix (varargin{1}))
-    n = size (varargin{1}, 1);
-    if n != size (varargin{1}, 2),
+    [n, nc] = size (varargin{1});
+    if (n != nc)
       error ("onenormest: matrix must be square");
     endif
     apply = @(x) varargin{1} * x;
     apply_t = @(x) varargin{1}' * x;
-    if (size (varargin) > 1)
+    if (nargin > 1)
       t = varargin{2};
     else
       t = min (n, default_t);
     endif
-    issing = isa (varargin {1}, "single");
+    issing = isa (varargin{1}, "single");
   else
-    if (size (varargin, 2) < 3)
-      print_usage();
+    if (nargin < 3)
+      print_usage ();
     endif
-    n = varargin{3};
     apply = varargin{1};
     apply_t = varargin{2};
-    if (size (varargin) > 3)
+    n = varargin{3};
+    if (nargin > 3)
       t = varargin{4};
     else
       t = default_t;
     endif
-    issing = isa (varargin {3}, "single");
+    issing = isa (n, "single");
   endif
 
   ## Initial test vectors X.
@@ -175,7 +175,7 @@
 
     ## Test if any of S are approximately parallel to previous S
     ## vectors or current S vectors.  If everything is parallel,
-    ## stop. Otherwise, replace any parallel vectors with
+    ## stop.  Otherwise, replace any parallel vectors with
     ## rand{-1,+1}.
     partest = any (abs (S_old' * S - n) < 4*eps*n);
     if (all (partest))
@@ -201,8 +201,7 @@
 
     Z = feval (apply_t, S);
 
-    ## Now find the largest non-previously-visted index per
-    ## vector.
+    ## Now find the largest non-previously-visted index per vector.
     h = max (abs (Z),2);
     [mh, mhi] = max (h);
     if (iter >= 2 && mhi == ind_best)
@@ -216,10 +215,10 @@
         ## Visited all these before, so stop.
         break;
       endif
-      ind = ind (!been_there (ind));
+      ind = ind(! been_there(ind));
       if (length (ind) < t)
         ## There aren't enough new vectors, so we're practically
-        ## in a cycle. Stop.
+        ## in a cycle.  Stop.
         break;
       endif
     endif
@@ -229,13 +228,14 @@
     for zz = 1 : t
       X(ind(zz),zz) = 1;
     endfor
-    been_there (ind (1 : t)) = 1;
+    been_there(ind(1 : t)) = 1;
   endfor
 
-  ## The estimate est and vector w are set in the loop above. The
-  ## vector v selects the ind_best column of A.
+  ## The estimate est and vector w are set in the loop above.
+  ## The vector v selects the ind_best column of A.
   v = zeros (n, 1);
   v(ind_best) = 1;
+
 endfunction
 
 
--- a/scripts/miscellaneous/bzip2.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/miscellaneous/bzip2.m	Mon May 07 00:56:44 2012 +0200
@@ -31,7 +31,7 @@
 function entries = bzip2 (varargin)
 
   if (nargin == 1 || nargin == 2)
-    if nargout == 0
+    if (nargout == 0)
       __xzip__ ("bzip2", "bz2", "bzip2 %s", varargin{:});
     else
       entries = __xzip__ ("bzip2", "bz2", "bzip2 %s", varargin{:});
--- a/scripts/miscellaneous/compare_versions.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/miscellaneous/compare_versions.m	Mon May 07 00:56:44 2012 +0200
@@ -141,22 +141,22 @@
   endif
 
   ## Determine the operator.
-  if any (ismember (operator, "="))
+  if (any (ismember (operator, "=")))
     equal_op = true;
   else
     equal_op = false;
   endif
-  if any (ismember (operator, "~!"))
+  if (any (ismember (operator, "~!")))
     not_op = true;
   else
     not_op = false;
   endif
-  if any (ismember (operator, "<"))
+  if (any (ismember (operator, "<")))
     lt_op = true;
   else
     lt_op = false;
   endif
-  if any (ismember (operator, ">"))
+  if (any (ismember (operator, ">")))
     gt_op = true;
   else
     gt_op = false;
--- a/scripts/miscellaneous/fact.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/miscellaneous/fact.m	Mon May 07 00:56:44 2012 +0200
@@ -24,8 +24,8 @@
 ## @end deftypefn
 
 
-function f = fact()
-  persistent wisdom = \
+function f = fact ()
+  persistent wisdom = ...
       {
        "Richard Stallman takes notes in binary.";
        "Richard Stallman doesn't need sudo. I will make him a sandwich anyway.";
@@ -240,7 +240,7 @@
        };
 
   w = wisdom{randi([1, numel(wisdom)])};
-  if nargout > 0
+  if (nargout > 0)
     f = w;
   else
     w = wordwrap (w);
@@ -254,14 +254,15 @@
   out = "\n";
   i = 1;
   numwords = numel (wc);
-  while i <= numwords;
+  while (i <= numwords);
     line = wc{i};
-    while (i < numwords && length (newline = cstrcat (line, " ", wc{i+1})) < cols)
+    while (i < numwords
+           && length (newline = cstrcat (line, " ", wc{i+1})) < cols)
       line = newline;
       i++;
     endwhile
     out = cstrcat (out, line, "\n");
     i++;
   endwhile
-  out = cstrcat(out, "\n");
+  out = cstrcat (out, "\n");
 endfunction
\ No newline at end of file
--- a/scripts/miscellaneous/menu.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/miscellaneous/menu.m	Mon May 07 00:56:44 2012 +0200
@@ -44,13 +44,41 @@
 
   page_screen_output (0, "local");
 
+  ## Process Supplied Options
+  if (nargin == 2)
+    ## List in a cell array
+    if (iscell (varargin{1}))
+      varargin = varargin{1};
+      nopt = length (varargin);
+      for i = 1:nopt
+        while (iscell (varargin{i}))
+          varargin{i} = varargin{i}{1};
+        endwhile
+      endfor
+    else
+      nopt = nargin - 1;
+    endif
+  else
+    ## List with random elements in it - pick the first always
+    for i = 1:nargin - 1
+      if (iscell (varargin{i}))
+        while (iscell (varargin{i}))
+          varargin{i} = varargin{i}{1};
+        endwhile
+      else
+        if (! ischar (varargin{i}))
+          varargin{i} = varargin{i}(1);
+        endif
+      endif
+    endfor
+    nopt = length (varargin);
+  endif
+
   if (! isempty (title))
     disp (title);
     printf ("\n");
   endif
 
-  nopt = nargin - 1;
-
   while (1)
     for i = 1:nopt
       printf ("  [%2d] ", i);
--- a/scripts/optimization/fminbnd.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/optimization/fminbnd.m	Mon May 07 00:56:44 2012 +0200
@@ -56,8 +56,8 @@
 
   ## Get default options if requested.
   if (nargin == 1 && ischar (fun) && strcmp (fun, 'defaults'))
-    x = optimset ("MaxIter", Inf, "MaxFunEvals", Inf, "TolX", 1e-8, \
-    "OutputFcn", [], "FunValCheck", "off");
+    x = optimset ("MaxIter", Inf, "MaxFunEvals", Inf, "TolX", 1e-8,
+                  "OutputFcn", [], "FunValCheck", "off");
     return;
   endif
 
--- a/scripts/optimization/fminunc.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/optimization/fminunc.m	Mon May 07 00:56:44 2012 +0200
@@ -84,11 +84,11 @@
 
   ## Get default options if requested.
   if (nargin == 1 && ischar (fcn) && strcmp (fcn, 'defaults'))
-    x = optimset ("MaxIter", 400, "MaxFunEvals", Inf, \
-    "GradObj", "off", "TolX", 1e-7, "TolFun", 1e-7,
-    "OutputFcn", [], "FunValCheck", "off",
-    "FinDiffType", "central",
-    "TypicalX", [], "AutoScaling", "off");
+    x = optimset ("MaxIter", 400, "MaxFunEvals", Inf,
+                  "GradObj", "off", "TolX", 1e-7, "TolFun", 1e-7,
+                  "OutputFcn", [], "FunValCheck", "off",
+                  "FinDiffType", "central",
+                  "TypicalX", [], "AutoScaling", "off");
     return;
   endif
 
--- a/scripts/optimization/fzero.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/optimization/fzero.m	Mon May 07 00:56:44 2012 +0200
@@ -100,8 +100,8 @@
 
   ## Get default options if requested.
   if (nargin == 1 && ischar (fun) && strcmp (fun, 'defaults'))
-    x = optimset ("MaxIter", Inf, "MaxFunEvals", Inf, "TolX", 1e-8, \
-    "OutputFcn", [], "FunValCheck", "off");
+    x = optimset ("MaxIter", Inf, "MaxFunEvals", Inf, "TolX", 1e-8,
+                  "OutputFcn", [], "FunValCheck", "off");
     return;
   endif
 
--- a/scripts/optimization/sqp.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/optimization/sqp.m	Mon May 07 00:56:44 2012 +0200
@@ -697,8 +697,8 @@
   if (isempty (__sqp_cifcn__))
     res = [x(lbidx,1)-__sqp_lb__; __sqp_ub__-x(ubidx,1)];
   else
-    res = [feval(__sqp_cifcn__,x); \
-           x(lbidx,1)-__sqp_lb__; __sqp_ub__-x(ubidx,1)];
+    res = [feval(__sqp_cifcn__,x); x(lbidx,1)-__sqp_lb__;
+           __sqp_ub__-x(ubidx,1)];
   endif
 
 endfunction
--- a/scripts/pkg/private/configure_make.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/pkg/private/configure_make.m	Mon May 07 00:56:44 2012 +0200
@@ -91,7 +91,7 @@
       if (filenames(end) == "\n")
         filenames(end) = [];
       endif
-      filenames = split_by (filenames, "\n");
+      filenames = strtrim (strsplit (filenames, "\n"));
       delete_idx =  [];
       for i = 1:length (filenames)
         if (! all (isspace (filenames{i})))
--- a/scripts/pkg/private/install.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/pkg/private/install.m	Mon May 07 00:56:44 2012 +0200
@@ -268,7 +268,7 @@
                            && any (strcmpi (a, str_true))));
     endif
 
-    if (autoload > 0 || desc_autoload)
+    if (autoload > 0 || (autoload == 0 && desc_autoload))
       fclose (fopen (fullfile (descriptions{i}.dir, "packinfo",
                                ".autoload"), "wt"));
       descriptions{i}.autoload = 1;
--- a/scripts/pkg/private/unload_packages.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/pkg/private/unload_packages.m	Mon May 07 00:56:44 2012 +0200
@@ -35,7 +35,7 @@
   endfor
 
   ## Get the current octave path.
-  p = split_by (path(), pathsep ());
+  p = strtrim (strsplit (path(), pathsep ()));
 
   if (length (files) == 1 && strcmp (files{1}, "all"))
     ## Unload all.
--- a/scripts/pkg/private/write_index.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/pkg/private/write_index.m	Mon May 07 00:56:44 2012 +0200
@@ -74,7 +74,7 @@
   if (! isfield (desc, "categories"))
     error ("the DESCRIPTION file must have a Categories field, when no INDEX file is given");
   endif
-  categories = split_by (desc.categories, ",");
+  categories = strtrim (strsplit (desc.categories, ","));
   if (length (categories) < 1)
       error ("the Category field is empty");
   endif
--- a/scripts/plot/__gnuplot_drawnow__.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/plot/__gnuplot_drawnow__.m	Mon May 07 00:56:44 2012 +0200
@@ -259,9 +259,9 @@
         size_str = "";
       endif
     else
-      if isempty (h)
+      if (isempty (h))
         disp ("gnuplot_set_term: figure handle is empty");
-      elseif !isfigure(h)
+      elseif (! isfigure (h))
         disp ("gnuplot_set_term: not a figure handle");
       endif
       title_str = "";
--- a/scripts/plot/axis.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/plot/axis.m	Mon May 07 00:56:44 2012 +0200
@@ -180,7 +180,7 @@
       __do_tight_option__ (ca);
     elseif (strcmpi (ax, "square"))
       set (ca, "plotboxaspectratio", [1, 1, 1]);
-    elseif  (strcmp (ax, "equal"))
+    elseif (strcmp (ax, "equal"))
       if (strcmp (get (get (ca, "parent"), "__graphics_toolkit__"), "gnuplot"))
         ## FIXME - gnuplot applies the aspect ratio activepostionproperty.
         set (ca, "activepositionproperty", "position");
@@ -321,7 +321,7 @@
     scale = get (ca, strcat (ax, "scale"));
     if (! iscell (data))
       data = {data};
-    end
+    endif
     if (strcmp (scale, "log"))
       tmp = data;
       data = cellfun (@(x) x(x>0), tmp, "uniformoutput", false);
@@ -346,7 +346,7 @@
   set (ca,
        "xlim", __get_tight_lims__ (ca, "x"),
        "ylim", __get_tight_lims__ (ca, "y"));
-  if __calc_dimensions__ (ca) > 2
+  if (__calc_dimensions__ (ca) > 2)
     set (ca, "zlim", __get_tight_lims__ (ca, "z"));
   endif
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/findfigs.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,81 @@
+## Copyright (C) 2008 Bill Denney
+## Copyright (C) 2012 Carnë Draug
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} findfigs ()
+## Find all visible figures that are currently off the screen and move them
+## onto the screen.
+## @seealso{allchild, figure, get, set}
+## @end deftypefn
+
+## Author: Bill Denney <bill@denney.ws>
+## Modified by: Carnë Draug <carandraug+dev@gmail.com>
+
+function findfigs ()
+
+  figh  = allchild (0);
+  units = get (0, "units");
+  unwind_protect
+    if (!strcmp (units, "pixels"))
+      set (0, "units", "pixels");
+    endif
+    screensize = get (0, "screensize");
+  unwind_protect_cleanup
+    set (0, "units", units);
+  end_unwind_protect
+
+  ## give the monitor a margin so that the figure must not just
+  ## marginally be on the monitor.
+  margin = 30;
+  screensize(1:2) += margin;
+  screensize(3:4) -= margin;
+
+  for i = 1:numel (figh)
+    if strcmp (get (figh(i), "visible"), "on")
+
+      units = get (figh(i), "units");
+      unwind_protect
+        if (!strcmp (units, "pixels"))
+          set (figh(i), "units", "pixels");
+        endif
+        pos = get (figh(i), "position");
+        ## Test if (in order):
+        ## The left side is outside the right side of the screen
+        ## The bottom is above the top of the screen
+        ## The right side is outside the left of the screen
+        ## the top is below the bottom of the screen
+        if (pos(1) > screensize(3)
+            || pos(2) > screensize(4)
+            || pos(1)+pos(3) < screensize(1)
+            || pos(2)+pos(4) < screensize(2))
+
+          ## the new position will be at the top left of the screen
+          ## (all moved figures will overlap).  The bottom left is chosen
+          ## instead of the top left because that allows for the unknown
+          ## amount of space for the menu bar and the title bar.
+          pos(1) = screensize(1);
+          pos(2) = screensize(2);
+          set (figh(i), "position", pos);
+        endif
+      unwind_protect_cleanup
+        set (figh(i), "units", units);
+      end_unwind_protect
+    endif
+  endfor
+endfunction
--- a/scripts/plot/findobj.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/plot/findobj.m	Mon May 07 00:56:44 2012 +0200
@@ -148,16 +148,16 @@
           na = na + 1;
           if (na <= numel(args))
             if (ischar (args{na}))
-              if strcmpi(args{na}, "-and")
+              if (strcmpi (args{na}, "-and"))
                 logicaloperator{np} = "and";
                 na = na+1;
-              elseif strcmpi(args{na}, "-or")
+              elseif (strcmpi (args{na}, "-or"))
                 logicaloperator{np} = "or";
                 na = na+1;
-              elseif strcmpi(args{na}, "-xor")
+              elseif (strcmpi (args{na}, "-xor"))
                 logicaloperator{np} = "xor";
                 na = na+1;
-              elseif strcmpi(args{na}, "-not")
+              elseif (strcmpi (args{na}, "-not"))
                 logicaloperator{np} = "not";
                 na = na+1;
               endif
@@ -173,7 +173,7 @@
         endif
       else
         ## This is sloppy ... but works like Matlab.
-        if strcmpi(args{na}, "-not")
+        if (strcmpi (args{na}, "-not"))
           h = [];
           return
         endif
@@ -213,7 +213,7 @@
           else
             if (regularexpression(np))
               match = regexp (p.(pname{np}), pvalue{np});
-              if isempty (match)
+              if (isempty (match))
                 match = 0;
               endif
             elseif (numel (p.(pname{np})) == numel (pvalue{np}))
--- a/scripts/plot/legend.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/plot/legend.m	Mon May 07 00:56:44 2012 +0200
@@ -272,11 +272,14 @@
     else
       error ("legend: expecting argument to be a character string");
     endif
+  elseif (nargs > 1 && iscellstr (varargin{1}))
+    varargin = {varargin{1}{:}, varargin{2:end}};
+    nargs = numel (varargin);
   endif
 
   if (strcmp (show, "off"))
     if (! isempty (hlegend))
-      set (get (hlegend, "children"), "visible", "off");
+      set (findobj (hlegend), "visible", "off");
       hlegend = [];
     endif
     hobjects = [];
@@ -284,7 +287,9 @@
     text_strings = {};
   elseif (strcmp (show, "on"))
     if (! isempty (hlegend))
-      set (get (hlegend, "children"), "visible", "on");
+      set (findobj (hlegend), "visible", "on");
+      ## NOTE - Matlab sets both "visible", and "box" to "on"
+      set (hlegend, "visible", get (hlegend, "box"));
     else
       hobjects = [];
       hplots  = [];
@@ -304,7 +309,7 @@
       hax = getfield (get (hlegend, "userdata"), "handle");
       [hplots, text_strings] = __getlegenddata__ (hlegend);
 
-      if  (strcmp (position, "default"))
+      if (strcmp (position, "default"))
         h = legend (hax, hplots, text_strings, "orientation", orientation);
       elseif (strcmp (orientation, "default"))
         if (outside)
@@ -435,7 +440,7 @@
         text_strings = {};
       endif
     else
-      ## Delete the old legend if it exists
+      ## Preserve the old legend if it exists
       if (! isempty (hlegend))
         if (strcmp (textpos, "default"))
           textpos = get (hlegend, "textposition");
@@ -454,10 +459,6 @@
           orientation = get (hlegend, "orientation");
         endif
         box = get (hlegend, "box");
-        fkids = get (fig, "children");
-
-        delete (hlegend);
-        hlegend = [];
       else
         if (strcmp (textpos, "default"))
           textpos = "left";
@@ -468,7 +469,7 @@
         if (strcmp (orientation, "default"))
           orientation = "vertical";
         endif
-        box = "off";
+        box = "on";
       endif
 
       ## Get axis size and fontsize in points.
@@ -505,16 +506,16 @@
           addprops = true;
           hlegend = axes ("tag", "legend", "userdata", struct ("handle", ud),
                           "box", box,
-                          "xtick", [], "ytick", [], "xticklabel", "",
-                          "yticklabel", "", "zticklabel", "",
-                          "xlim", [0, 1], "ylim", [0, 1], "visible", "off",
+                          "xtick", [], "ytick", [],
+                          "xticklabel", "", "yticklabel", "", "zticklabel", "",
+                          "xlim", [0, 1], "ylim", [0, 1],
+                          "visible", ifelse (strcmp (box, "on"), "on", "off"),
                           "activepositionproperty", "position");
         else
           addprops = false;
           axes (hlegend);
           delete (get (hlegend, "children"));
         endif
-
         ## Add text label to the axis first, checking their extents
         nentries = numel (hplots);
         texthandle = [];
@@ -823,9 +824,7 @@
   text_kids = findobj (kids, "-property", "interpreter", "type", "text");
   interpreter = get (h, "interpreter");
   textcolor = get (h, "textcolor");
-  set (kids, "interpreter", interpreter, "color", textcolor);
-  hobj = cell2mat (get (kids, "userdata"));
-  set (hobj, "interpreter", interpreter);
+  set (text_kids, "interpreter", interpreter, "color", textcolor);
 endfunction
 
 function hideshowlegend (h, d, ca, pos1, pos2)
@@ -972,11 +971,26 @@
   endif
 endfunction
 
+%!demo
+%! plot (rand (2))
+%! legend ({'foo'}, 'bar', 'boxoff')
+%! title ('legend() should warn about an extra label')
+
+%!demo
+%! plot (rand (2,2)) ;
+%! h = legend ('a', 'b') ;
+%! legend ('right') ;
+%! set (h, 'textposition', 'left')
+%! set (h, 'textposition', 'right')
+%! set (h, 'textcolor', [1 0 1])
 
 %!demo
 %! clf;
 %! x = 0:1;
 %! plot (x,x,';I am Blue;', x,2*x,';I am Green;', x,3*x,';I am Red;');
+%! legend boxon
+%! legend hide
+%! legend show
 
 %!demo
 %! clf;
@@ -1007,9 +1021,9 @@
 %!demo
 %! clf;
 %! plot (1:10, 1:10, 1:10, fliplr (1:10));
-%! title ('Legend with box on');
+%! title ('Legend with box off');
 %! legend ({'I am blue', 'I am green'}, 'location', 'east');
-%! legend boxon;
+%! legend boxoff;
 
 %!demo
 %! clf;
@@ -1043,7 +1057,6 @@
 %! title ('Signals with random offset and uniform noise');
 %! xlabel ('Sample Nr [k]'); ylabel ('Amplitude [V]');
 %! legend (labels, 'location', 'southoutside');
-%! legend ('boxon');
 
 %!demo
 %! clf;
@@ -1122,19 +1135,15 @@
 %! subplot (2,2,1);
 %!  plot (x, rand (numel (x)));
 %!  legend (cellstr (num2str (x)), 'location', 'northwestoutside');
-%!  legend boxon;
 %! subplot (2,2,2);
 %!  plot (x, rand (numel (x)));
 %!  legend (cellstr (num2str (x)), 'location', 'northeastoutside');
-%!  legend boxon;
 %! subplot (2,2,3);
 %!  plot (x, rand (numel (x)));
 %!  legend (cellstr (num2str (x)), 'location', 'southwestoutside');
-%!  legend boxon;
 %! subplot (2,2,4);
 %!  plot (x, rand (numel (x)));
 %!  legend (cellstr (num2str (x)), 'location', 'southeastoutside');
-%!  legend boxon;
 
 %!demo
 %! clf;
--- a/scripts/plot/line.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/plot/line.m	Mon May 07 00:56:44 2012 +0200
@@ -43,6 +43,21 @@
 
 endfunction
 
+%!demo
+%! clf
+%! x = 0:0.3:10;
+%! y1 = cos (x);
+%! y2 = sin (x);
+%! subplot (3, 1, 1)
+%! args = {"color", "b", "marker", "s"};
+%! line ([x(:), x(:)], [y1(:), y2(:)], args{:})
+%! title ("Test broadcasting for line()")
+%! subplot (3, 1, 2)
+%! line (x(:), [y1(:), y2(:)], args{:})
+%! subplot (3, 1, 3)
+%! line ([x(:), x(:)+pi/2], y1(:), args{:})
+%! xlim ([0 10])
+
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
--- a/scripts/plot/module.mk	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/plot/module.mk	Mon May 07 00:56:44 2012 +0200
@@ -98,6 +98,7 @@
   plot/figure.m \
   plot/fill.m \
   plot/findall.m \
+  plot/findfigs.m \
   plot/findobj.m \
   plot/fplot.m \
   plot/gca.m \
@@ -162,6 +163,7 @@
   plot/semilogyerr.m \
   plot/shading.m \
   plot/shg.m \
+  plot/shrinkfaces.m \
   plot/slice.m \
   plot/sombrero.m \
   plot/specular.m \
@@ -175,6 +177,7 @@
   plot/surfc.m \
   plot/surfl.m \
   plot/surfnorm.m \
+  plot/tetramesh.m \
   plot/text.m \
   plot/title.m \
   plot/trimesh.m \
--- a/scripts/plot/peaks.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/plot/peaks.m	Mon May 07 00:56:44 2012 +0200
@@ -55,7 +55,7 @@
   if (nargin == 0)
     x = y = linspace (-3, 3, 49);
   elseif (nargin == 1)
-    if length(x) > 1
+    if (length (x) > 1)
       y = x;
     else
       x = y = linspace (-3, 3, x);
@@ -69,8 +69,8 @@
     Y = y;
   endif
 
-  Z = 3 * (1 - X) .^ 2 .* exp(- X .^ 2 - (Y + 1) .^ 2) \
-      - 10 * (X / 5 - X .^ 3 - Y .^ 5) .* exp(- X .^ 2 - Y .^ 2) \
+  Z = 3 * (1 - X) .^ 2 .* exp(- X .^ 2 - (Y + 1) .^ 2) ...
+      - 10 * (X / 5 - X .^ 3 - Y .^ 5) .* exp(- X .^ 2 - Y .^ 2) ...
       - 1 / 3 * exp(- (X + 1) .^ 2 - Y .^ 2);
 
   if (nargout == 0)
--- a/scripts/plot/private/__errplot__.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/plot/private/__errplot__.m	Mon May 07 00:56:44 2012 +0200
@@ -219,7 +219,7 @@
     tlgnd(end+1) = fmt.key;
 
     legend (gca(), hlgnd, tlgnd);
-  end 
+  endif
 
 endfunction
 
--- a/scripts/plot/private/__fltk_print__.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/plot/private/__fltk_print__.m	Mon May 07 00:56:44 2012 +0200
@@ -153,7 +153,7 @@
   vw = get (haxes, "view");
   if (iscell (vw))
     vw = vertcat (vw{:});
-  end
+  endif
   is2D = all (abs (vw(:,2)) == 90);
   if (is2D)
     gl2ps_device{end} = [gl2ps_device{end}, "is2D"];
--- a/scripts/plot/private/__go_draw_axes__.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/plot/private/__go_draw_axes__.m	Mon May 07 00:56:44 2012 +0200
@@ -1581,8 +1581,9 @@
       else
         fontspec = "";
       endif
-      fprintf (plot_stream, "set key %s %s;\nset key %s %s %s %s;\n",
-               inout, pos, box, reverse, horzvert, fontspec);
+      colorspec = get_text_colorspec (hlgnd.textcolor, mono);
+      fprintf (plot_stream, "set key %s %s;\nset key %s %s %s %s %s;\n",
+               inout, pos, box, reverse, horzvert, fontspec, colorspec);
     else
       fputs (plot_stream, "unset key;\n");
     endif
@@ -2322,7 +2323,7 @@
       if (! isempty (n1))
         n1 = n1 + 1;
         n2 = setdiff (n2, n1);
-      end
+      endif
       for n = numel(n2):-1:1
         labels{m} = [labels{m}(1:n2(n)-1), "\\", labels{m}(n2(n):end)];
       endfor
@@ -2339,7 +2340,7 @@
   persistent sym = __setup_sym_table__ ();
   persistent flds = fieldnames (sym);
 
-  [s, e, m] = regexp(str,'\\([a-zA-Z]+|0)','start','end','matches');
+  [s, e, m] = regexp(str,'\\\\([a-zA-Z]+|0)','start','end','matches');
 
   for i = length (s) : -1 : 1
     ## special case for "\0"  and replace with "{/Symbol \306}'
--- a/scripts/plot/private/__line__.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/plot/private/__line__.m	Mon May 07 00:56:44 2012 +0200
@@ -46,7 +46,15 @@
   endif
 
   if (num_data_args > 0 && ! size_equal (varargin{1:num_data_args}))
-    error ("line: number of X, Y, and Z points must be equal");
+    n = 1:num_data_args;
+    m = cellfun (@numel, varargin(1:num_data_args));
+    [~, m] = max (m);
+    b = ones (size (varargin{m(1)}));
+    try
+      varargin(n) = cellfun (@(x) bsxfun (@times, b, x), varargin(n), "uniformoutput", false);
+    catch
+      error ("line: number of X, Y, and Z points must be equal");
+    end_try_catch
   endif
 
   if (rem (nvargs - num_data_args, 2) != 0)
--- a/scripts/plot/private/__patch__.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/plot/private/__patch__.m	Mon May 07 00:56:44 2012 +0200
@@ -326,7 +326,7 @@
   if (nr == 1 && nc > 1)
     nr = nc;
     nc = 1;
-  end
+  endif
   if (!isempty (z))
     vert = [x(:), y(:), z(:)];
   else
--- a/scripts/plot/private/__print_parse_opts__.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/plot/private/__print_parse_opts__.m	Mon May 07 00:56:44 2012 +0200
@@ -154,7 +154,7 @@
 
   if (arg_st.ghostscript.resolution == 0)
     ## Do as Matlab does.
-    arg_st.ghostscript.resolution = num2str (get (0, "screenpixelsperinch"));
+    arg_st.ghostscript.resolution = get (0, "screenpixelsperinch");
   endif
 
   if (isempty (arg_st.orientation))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/shrinkfaces.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,215 @@
+## Copyright (C) 2012 Martin Helm
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {} shrinkfaces (@var{p}, @var{sf})
+## @deftypefnx {Function File} {@var{nfv} =} shrinkfaces (@var{p}, @var{sf})
+## @deftypefnx {Function File} {@var{nfv} =} shrinkfaces (@var{fv}, @var{sf})
+## @deftypefnx {Function File} {@var{nfv} =} shrinkfaces (@var{f}, @var{v}, @var{sf})
+## @deftypefnx {Function File} {[@var{nf}, @var{nv}] =} shrinkfaces (@dots{})
+##
+## Reduce the faces area for a given patch, structure or explicit faces
+## and points matrices by a scale factor @var{sf}.  The structure
+## @var{fv} must contain the fields 'faces' and 'vertices'.  If the
+## factor @var{sf} is omitted then a default of 0.3 is used.
+##
+## Given a patch handle as the first input argument and no output
+## parameters, perform the shrinking of the patch faces in place and
+## redraw the patch.
+##
+## If called with one output argument, return a structure with fields
+## 'faces', 'vertices', and 'facevertexcdata' containing the data after
+## shrinking which can then directly be used as an input argument for the
+## @command{patch} function.
+##
+## Performing the shrinking on faces which are not convex can lead to
+## undesired results.
+##
+## For example
+##
+## @example
+## @group
+## [phi r] = meshgrid (linspace (0, 1.5*pi, 16), linspace (1, 2, 4));
+## tri = delaunay (phi(:), r(:));
+## v = [r(:).*sin(phi(:)) r(:).*cos(phi(:))];
+## clf ()
+## p = patch ("Faces", tri, "Vertices", v, "FaceColor", "none");
+## fv = shrinkfaces (p);
+## patch (fv)
+## axis equal
+## grid on
+## @end group
+## @end example
+##
+## @noindent
+## draws a triangulated 3/4 circle and the corresponding shrinked
+## version.
+## @seealso{patch}
+## @end deftypefn
+
+## Author: Martin Helm <martin@mhelm.de>
+
+function [nf, nv] = shrinkfaces (varargin)
+
+  if (nargin < 1 || nargin > 3 || nargout > 2)
+    print_usage ();
+  endif
+  
+  sf = 0.3;
+  p = varargin{1};
+  colors = [];
+
+  if (ishandle (p) && nargin < 3)
+    faces = get (p, "Faces");
+    vertices = get (p, "Vertices");
+    colors = get (p, "FaceVertexCData");
+    if (nargin == 2)
+      sf = varargin{2};
+    endif
+  elseif (isstruct (p) && nargin < 3)
+    faces = p.faces;
+    vertices = p.vertices;
+    if (isfield (p, "facevertexcdata"))
+      colors = p.facevertexcdata;
+    endif
+    if (nargin == 2)
+      sf = varargin{2};
+    endif
+  elseif (ismatrix (p) && nargin >= 2 && ismatrix (varargin{2}))
+    faces = p;
+    vertices = varargin{2};
+    if (nargin == 3)
+      sf = varargin{3};
+    endif
+  else
+    print_usage ();
+  endif
+  
+  if (! isscalar (sf) || sf <= 0)
+    error ("shrinkfaces: scale factor must be a positive scalar")
+  endif
+
+  n = size (vertices, 2);
+  if (n < 2 || n > 3)
+    error ("shrinkfaces: only 2D and 3D patches are supported")
+  endif
+
+  m = size (faces, 2);
+  if (m < 3)
+    error ("shrinkfaces: faces must consist of at least 3 vertices")
+  endif
+
+  v = vertices(faces'(:), :);
+  if (isempty (colors) || size (colors, 1) == size (faces, 1))
+    c = colors;
+  elseif (size (colors, 1) == size (vertices, 1))
+    c = colors(faces'(:), :);
+  else
+    ## Discard inconsistent color data.
+    c = [];
+  endif
+  sv = size (v, 1);
+  ## we have to deal with a probably very large number of vertices, so
+  ## use sparse we use as midpoint (1/m, ..., 1/m) in generalized
+  ## barycentric coordinates.
+  midpoints = full (kron ( speye (sv / m), ones (m, m) / m) * sparse (v));
+  v = sqrt (sf) * (v - midpoints) + midpoints;
+  f = reshape (1:sv, m, sv / m)';
+  
+  switch (nargout)
+    case 0
+      if (ishandle (p))
+        set (p, "FaceVertexCData", [], "CData", []) # avoid exceptions
+        set (p, "Vertices", v, "Faces", f, "FaceVertexCData", c)
+      else
+        nf = struct ("faces", f, "vertices", v, "facevertexcdata", c);
+      endif
+    case 1
+      nf = struct ("faces", f, "vertices", v, "facevertexcdata", c);
+    case 2
+      nf = f;
+      nv = v;
+  endswitch
+
+endfunction
+
+%!demo
+%! faces = [1 2 3; 1 3 4];
+%! vertices = [0 0; 1 0; 1 1; 0 1];
+%! clf ()
+%! patch ("Faces", faces, "Vertices", vertices, "FaceColor", "none")
+%! fv = shrinkfaces (faces, vertices, 0.25);
+%! patch (fv)
+%! axis equal
+
+%!demo
+%! faces = [1 2 3 4; 5 6 7 8];
+%! vertices = [0 0; 1 0; 2 1; 1 1; 2 0; 3 0; 4 1; 3.5 1];
+%! clf ()
+%! patch ("Faces", faces, "Vertices", vertices, "FaceColor", "none")
+%! fv = shrinkfaces (faces, vertices, 0.25);
+%! patch (fv)
+%! axis equal
+%! grid on
+
+%!demo
+%! faces = [1 2 3 4];
+%! vertices = [-1 2; 0 0; 1 2; 0 1];
+%! clf ()
+%! patch ("Faces", faces, "Vertices", vertices, "FaceColor", "none")
+%! fv = shrinkfaces (faces, vertices, 0.25);
+%! patch (fv)
+%! axis equal
+%! grid on
+%! title "faces which are not convex are clearly not allowed"
+
+%!demo
+%! [phi r] = meshgrid (linspace (0, 1.5*pi, 16), linspace (1, 2, 4));
+%! tri = delaunay (phi(:), r(:));
+%! v = [r(:).*sin(phi(:)) r(:).*cos(phi(:))];
+%! clf ()
+%! p = patch ("Faces", tri, "Vertices", v, "FaceColor", "none");
+%! fv = shrinkfaces (p);
+%! patch (fv)
+%! axis equal
+%! grid on
+
+%!demo
+%! N = 10; # N intervals per axis
+%! [x, y, z] = meshgrid (linspace (-4,4,N+1));
+%! val = x.^3 + y.^3 + z.^3;
+%! fv = isosurface (x, y, z, val, 3, z);
+%!
+%! clf ()
+%! p = patch ("Faces", fv.faces, "Vertices", fv.vertices, "FaceVertexCData", ...
+%!            fv.facevertexcdata, "FaceColor", "interp", "EdgeColor", "black");
+%! axis equal
+%! view (115, 30)
+%! drawnow
+%! shrinkfaces (p, 0.6);
+
+%!shared faces, vertices, nfv, nfv2
+%! faces = [1 2 3];
+%! vertices = [0 0 0; 1 0 0; 1 1 0];
+%! nfv = shrinkfaces (faces, vertices, 0.7);
+%! nfv2 = shrinkfaces (nfv, 1/0.7);
+%!assert (isfield (nfv, "faces"));
+%!assert (isfield (nfv, "vertices"));
+%!assert (size (nfv.faces), [1 3]);
+%!assert (size (nfv.vertices), [3 3]);
+%!assert (norm (nfv2.vertices - vertices), 0, 2*eps);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/tetramesh.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,148 @@
+## Copyright (C) 2012 Martin Helm
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn  {Function File} tetramesh (@var{T}, @var{X})
+## @deftypefnx {Function File} tetramesh (@var{T}, @var{X}, @var{C})
+## @deftypefnx {Function File} tetramesh (@dots{}, @var{property}, @var{val}, @dots{})
+## @deftypefnx {Function File} {@var{h} =} tetramesh (@dots{})
+##
+## Display the tetrahedrons defined in the m-by-4 matrix @var{T}
+## as 3-D patches.  @var{T} is typically the output of a Delaunay triangulation
+## of a 3-D set of points.  Every row of @var{T} contains four indices into
+## the n-by-3 matrix @var{X} of the vertices of a tetrahedron.  Every row in
+## @var{X} represents one point in 3-D space. 
+##
+## The vector @var{C} specifies the color of each tetrahedron as an index
+## into the current colormap.  The default value is 1:m where m is the number
+## of tetrahedrons; the indices are scaled to map to the full range of the
+## colormap.  If there are more tetrahedrons than colors in the colormap then
+## the values in @var{C} are cyclically repeated.
+## 
+## Calling @code{tetramesh (@dots{}, "property", "value", @dots{})} passes all
+## property/value pairs directly to the patch function as additional arguments.
+##
+## The optional return value @var{h} is a vector of patch handles where each
+## handle represents one tetrahedron in the order given by @var{T}. 
+## A typical use case for @var{h} is to turn the respective patch "visible"
+## property "on" or "off".
+##
+## Type @code{demo tetramesh} to see examples on using @code{tetramesh}.
+## @seealso{delaunay3, delaunayn, trimesh, patch}
+## @end deftypefn
+
+## Author: Martin Helm <martin@mhelm.de>
+
+function h = tetramesh (varargin)
+
+  [reg, prop] = parseparams (varargin);
+
+  if (length (reg) < 2 || length (reg) > 3)
+    print_usage ();
+  endif
+
+  T = reg{1};
+  X = reg{2};
+
+  if (! ismatrix (T) || columns (T) != 4)
+    error ("tetramesh: T must be a n-by-4 matrix");
+  endif
+  if (! ismatrix (X) || columns (X) != 3)
+    error ("tetramesh: X must be a n-by-3 matrix");
+  endif
+
+  size_T = rows (T);
+  colmap = colormap ();
+  
+  if (length (reg) < 3)
+    size_colmap = size (colmap, 1);
+    C = mod ((1:size_T)' - 1, size_colmap) + 1;
+    if (size_T < size_colmap && size_T > 1) 
+      ## expand to the available range of colors
+      C = floor ((C - 1) * (size_colmap - 1) / (size_T - 1)) + 1;
+    endif
+  else
+    C = reg{3};
+    if (! isvector (C) || size_T != length (C))
+      error ("tetramesh: C must be a vector of the same length as T");
+    endif
+  endif
+
+  h = zeros (1, size_T);
+  if (strcmp (graphics_toolkit (), "gnuplot"))
+    ## tiny reduction of the tetrahedron size to help gnuplot by
+    ## avoiding identical faces with different colors
+    for i = 1:size_T
+      [th, p] = __shrink__ ([1 2 3 4], X(T(i, :), :), 1 - 1e-7);
+      hvec(i) = patch ("Faces", th, "Vertices", p, 
+                       "FaceColor", colmap(C(i), :), prop{:});
+    endfor
+  else
+    for i = 1:size_T
+      th = [1 2 3; 2 3 4; 3 4 1; 4 1 2];
+      hvec(i) = patch ("Faces", th, "Vertices", X(T(i, :), :), 
+                       "FaceColor", colmap(C(i), :), prop{:});
+    endfor
+  endif
+
+  if (nargout > 0)
+    h = hvec;
+  endif
+
+endfunction
+
+## shrink the tetrahedron relative to its center of gravity
+function [tri, p] = __shrink__ (T, X, sf)
+  midpoint = repmat (sum (X(T, :), 1) / 4, 12, 1);
+  p = [X([1 2 3], :); X([2 3 4], :); X([3 4 1], :); X([4 1 2], :)];
+  p = sf * (p - midpoint) + midpoint;
+  tri = reshape (1:12, 3, 4)';
+endfunction
+
+
+%!demo
+%! clf;
+%! d = [-1 1];
+%! [x,y,z] = meshgrid (d, d, d);
+%! x = [x(:); 0];
+%! y = [y(:); 0];
+%! z = [z(:); 0];
+%! tetra = delaunay3 (x, y, z);
+%! X = [x(:) y(:) z(:)];
+%! colormap (jet (64));
+%! h = tetramesh (tetra, X);
+%! set (h(1:2:end), "Visible", "off");
+%! axis equal;
+%! view (30, 20);
+%! title ("Using jet (64), every other tetrahedron invisible");
+
+%!demo
+%! clf;
+%! d = [-1 1];
+%! [x,y,z] = meshgrid (d, d, d);
+%! x = [x(:); 0];
+%! y = [y(:); 0];
+%! z = [z(:); 0];
+%! tetra = delaunay3 (x, y, z);
+%! X = [x(:) y(:) z(:)];
+%! colormap (gray (256));
+%! tetramesh (tetra, X, 21:20:241, "EdgeColor", "w");
+%! axis equal;
+%! view (30, 20);
+%! title ("Using gray (256) and white edges");
+
--- a/scripts/polynomial/module.mk	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/polynomial/module.mk	Mon May 07 00:56:44 2012 +0200
@@ -1,5 +1,8 @@
 FCN_FILE_DIRS += polynomial
 
+polynomial_PRIVATE_FCN_FILES = \
+	polynomial/private/__splinefit__.m
+
 polynomial_FCN_FILES = \
   polynomial/compan.m \
   polynomial/conv.m \
@@ -24,6 +27,7 @@
   polynomial/residue.m \
   polynomial/roots.m \
   polynomial/spline.m \
+  polynomial/splinefit.m \
   polynomial/unmkpp.m
 
 FCN_FILES += $(polynomial_FCN_FILES)
--- a/scripts/polynomial/pchip.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/polynomial/pchip.m	Mon May 07 00:56:44 2012 +0200
@@ -79,7 +79,7 @@
   if (isvector (y))
     y = y(:).'; ##row vector
     szy = size (y);
-    if !(size_equal (x, y))
+    if (! size_equal (x, y))
       error ("pchip: length of X and Y must match")
     endif
   else
@@ -96,7 +96,7 @@
     h = diff (x);
     y = fliplr (y);
   elseif (any (h <= 0))
-    error("pchip: X must be strictly monotonic");
+    error ("pchip: X must be strictly monotonic");
   endif
 
   f1 = y(:, 1:n-1);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/polynomial/private/__splinefit__.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,624 @@
+## This function is private because it is maintained by Jonas Lundgren
+## separtely from Octave.  Please do not reformat to match Octave coding
+## conventions as that would make it harder to integrate upstream
+## changes.
+
+% Copyright (c) 2010, Jonas Lundgren
+% All rights reserved.
+% 
+% Redistribution and use in source and binary forms, with or without 
+% modification, are permitted provided that the following conditions are 
+% met:
+% 
+%     * Redistributions of source code must retain the above copyright 
+%       notice, this list of conditions and the following disclaimer.
+%     * Redistributions in binary form must reproduce the above copyright 
+%       notice, this list of conditions and the following disclaimer in 
+%       the documentation and/or other materials provided with the distribution
+%       
+% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
+% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
+% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+% POSSIBILITY OF SUCH DAMAGE.
+function pp = __splinefit__(varargin)
+%SPLINEFIT Fit a spline to noisy data.
+%   PP = SPLINEFIT(X,Y,BREAKS) fits a piecewise cubic spline with breaks
+%   (knots) BREAKS to the noisy data (X,Y). X is a vector and Y is a vector
+%   or an ND array. If Y is an ND array, then X(j) and Y(:,...,:,j) are
+%   matched. Use PPVAL to evaluate PP.
+%
+%   PP = SPLINEFIT(X,Y,P) where P is a positive integer interpolates the
+%   breaks linearly from the sorted locations of X. P is the number of
+%   spline pieces and P+1 is the number of breaks.
+%
+%   OPTIONAL INPUT
+%   Argument places 4 to 8 are reserved for optional input.
+%   These optional arguments can be given in any order:
+%
+%   PP = SPLINEFIT(...,'p') applies periodic boundary conditions to
+%   the spline. The period length is MAX(BREAKS)-MIN(BREAKS).
+%
+%   PP = SPLINEFIT(...,'r') uses robust fitting to reduce the influence
+%   from outlying data points. Three iterations of weighted least squares
+%   are performed. Weights are computed from previous residuals.
+%
+%   PP = SPLINEFIT(...,BETA), where 0 < BETA < 1, sets the robust fitting
+%   parameter BETA and activates robust fitting ('r' can be omitted).
+%   Default is BETA = 1/2. BETA close to 0 gives all data equal weighting.
+%   Increase BETA to reduce the influence from outlying data. BETA close
+%   to 1 may cause instability or rank deficiency.
+%
+%   PP = SPLINEFIT(...,N) sets the spline order to N. Default is a cubic
+%   spline with order N = 4. A spline with P pieces has P+N-1 degrees of
+%   freedom. With periodic boundary conditions the degrees of freedom are
+%   reduced to P.
+%
+%   PP = SPLINEFIT(...,CON) applies linear constraints to the spline.
+%   CON is a structure with fields 'xc', 'yc' and 'cc':
+%       'xc', x-locations (vector)
+%       'yc', y-values (vector or ND array)
+%       'cc', coefficients (matrix).
+%
+%   Constraints are linear combinations of derivatives of order 0 to N-2
+%   according to
+%
+%     cc(1,j)*y(x) + cc(2,j)*y'(x) + ... = yc(:,...,:,j),  x = xc(j).
+%
+%   The maximum number of rows for 'cc' is N-1. If omitted or empty 'cc'
+%   defaults to a single row of ones. Default for 'yc' is a zero array.
+%
+%   EXAMPLES
+%
+%       % Noisy data
+%       x = linspace(0,2*pi,100);
+%       y = sin(x) + 0.1*randn(size(x));
+%       % Breaks
+%       breaks = [0:5,2*pi];
+%
+%       % Fit a spline of order 5
+%       pp = splinefit(x,y,breaks,5);
+%
+%       % Fit a spline of order 3 with periodic boundary conditions
+%       pp = splinefit(x,y,breaks,3,'p');
+%
+%       % Constraints: y(0) = 0, y'(0) = 1 and y(3) + y"(3) = 0
+%       xc = [0 0 3];
+%       yc = [0 1 0];
+%       cc = [1 0 1; 0 1 0; 0 0 1];
+%       con = struct('xc',xc,'yc',yc,'cc',cc);
+%
+%       % Fit a cubic spline with 8 pieces and constraints
+%       pp = splinefit(x,y,8,con);
+%
+%       % Fit a spline of order 6 with constraints and periodicity
+%       pp = splinefit(x,y,breaks,con,6,'p');
+%
+%   See also SPLINE, PPVAL, PPDIFF, PPINT
+
+%   Author: Jonas Lundgren <splinefit@gmail.com> 2010
+
+%   2009-05-06  Original SPLINEFIT.
+%   2010-06-23  New version of SPLINEFIT based on B-splines.
+%   2010-09-01  Robust fitting scheme added.
+%   2010-09-01  Support for data containing NaNs.
+%   2011-07-01  Robust fitting parameter added.
+
+% Check number of arguments
+error(nargchk(3,7,nargin));
+
+% Check arguments
+[x,y,dim,breaks,n,periodic,beta,constr] = arguments(varargin{:});
+
+% Evaluate B-splines
+base = splinebase(breaks,n);
+pieces = base.pieces;
+A = ppval(base,x);
+
+% Bin data
+[junk,ibin] = histc(x,[-inf,breaks(2:end-1),inf]); %#ok
+
+% Sparse system matrix
+mx = numel(x);
+ii = [ibin; ones(n-1,mx)];
+ii = cumsum(ii,1);
+jj = repmat(1:mx,n,1);
+if periodic
+    ii = mod(ii-1,pieces) + 1;
+    A = sparse(ii,jj,A,pieces,mx);
+else
+    A = sparse(ii,jj,A,pieces+n-1,mx);
+end
+
+% Don't use the sparse solver for small problems
+if pieces < 20*n/log(1.7*n)
+    A = full(A);
+end
+
+% Solve
+if isempty(constr)
+    % Solve Min norm(u*A-y)
+    u = lsqsolve(A,y,beta);
+else
+    % Evaluate constraints
+    B = evalcon(base,constr,periodic);
+    % Solve constraints
+    [Z,u0] = solvecon(B,constr);
+    % Solve Min norm(u*A-y), subject to u*B = yc
+    y = y - u0*A;
+    A = Z*A;
+    v = lsqsolve(A,y,beta);
+    u = u0 + v*Z;
+end
+
+% Periodic expansion of solution
+if periodic
+    jj = mod(0:pieces+n-2,pieces) + 1;
+    u = u(:,jj);
+end
+
+% Compute polynomial coefficients
+ii = [repmat(1:pieces,1,n); ones(n-1,n*pieces)];
+ii = cumsum(ii,1);
+jj = repmat(1:n*pieces,n,1);
+C = sparse(ii,jj,base.coefs,pieces+n-1,n*pieces);
+coefs = u*C;
+coefs = reshape(coefs,[],n);
+
+% Make piecewise polynomial
+pp = mkpp(breaks,coefs,dim);
+
+
+%--------------------------------------------------------------------------
+function [x,y,dim,breaks,n,periodic,beta,constr] = arguments(varargin)
+%ARGUMENTS Lengthy input checking
+%   x           Noisy data x-locations (1 x mx)
+%   y           Noisy data y-values (prod(dim) x mx)
+%   dim         Leading dimensions of y
+%   breaks      Breaks (1 x (pieces+1))
+%   n           Spline order
+%   periodic    True if periodic boundary conditions
+%   beta        Robust fitting parameter, no robust fitting if beta = 0
+%   constr      Constraint structure
+%   constr.xc   x-locations (1 x nx)
+%   constr.yc   y-values (prod(dim) x nx)
+%   constr.cc   Coefficients (?? x nx)
+
+% Reshape x-data
+x = varargin{1};
+mx = numel(x);
+x = reshape(x,1,mx);
+
+% Remove trailing singleton dimensions from y
+y = varargin{2};
+dim = size(y);
+while numel(dim) > 1 && dim(end) == 1
+    dim(end) = [];
+end
+my = dim(end);
+
+% Leading dimensions of y
+if numel(dim) > 1
+    dim(end) = [];
+else
+    dim = 1;
+end
+
+% Reshape y-data
+pdim = prod(dim);
+y = reshape(y,pdim,my);
+
+% Check data size
+if mx ~= my
+    mess = 'Last dimension of array y must equal length of vector x.';
+    error('arguments:datasize',mess)
+end
+
+% Treat NaNs in x-data
+inan = find(isnan(x));
+if ~isempty(inan)
+    x(inan) = [];
+    y(:,inan) = [];
+    mess = 'All data points with NaN as x-location will be ignored.';
+    warning('arguments:nanx',mess)
+end
+
+% Treat NaNs in y-data
+inan = find(any(isnan(y),1));
+if ~isempty(inan)
+    x(inan) = [];
+    y(:,inan) = [];
+    mess = 'All data points with NaN in their y-value will be ignored.';
+    warning('arguments:nany',mess)
+end
+
+% Check number of data points
+mx = numel(x);
+if mx == 0
+    error('arguments:nodata','There must be at least one data point.')
+end
+
+% Sort data
+if any(diff(x) < 0)
+    [x,isort] = sort(x);
+    y = y(:,isort);
+end
+
+% Breaks
+if isscalar(varargin{3})
+    % Number of pieces
+    p = varargin{3};
+    if ~isreal(p) || ~isfinite(p) || p < 1 || fix(p) < p
+        mess = 'Argument #3 must be a vector or a positive integer.';
+        error('arguments:breaks1',mess)
+    end
+    if x(1) < x(end)
+        % Interpolate breaks linearly from x-data
+        dx = diff(x);
+        ibreaks = linspace(1,mx,p+1);
+        [junk,ibin] = histc(ibreaks,[0,2:mx-1,mx+1]); %#ok
+        breaks = x(ibin) + dx(ibin).*(ibreaks-ibin);
+    else
+        breaks = x(1) + linspace(0,1,p+1);
+    end
+else
+    % Vector of breaks
+    breaks = reshape(varargin{3},1,[]);
+    if isempty(breaks) || min(breaks) == max(breaks)
+        mess = 'At least two unique breaks are required.';
+        error('arguments:breaks2',mess);
+    end
+end
+
+% Unique breaks
+if any(diff(breaks) <= 0)
+    breaks = unique(breaks);
+end
+
+% Optional input defaults
+n = 4;                      % Cubic splines
+periodic = false;           % No periodic boundaries
+robust = false;             % No robust fitting scheme
+beta = 0.5;                 % Robust fitting parameter
+constr = [];                % No constraints
+
+% Loop over optional arguments
+for k = 4:nargin
+    a = varargin{k};
+    if ischar(a) && isscalar(a) && lower(a) == 'p'
+        % Periodic conditions
+        periodic = true;
+    elseif ischar(a) && isscalar(a) && lower(a) == 'r'
+        % Robust fitting scheme
+        robust = true;
+    elseif isreal(a) && isscalar(a) && isfinite(a) && a > 0 && a < 1
+        % Robust fitting parameter
+        beta = a;
+        robust = true;
+    elseif isreal(a) && isscalar(a) && isfinite(a) && a > 0 && fix(a) == a
+        % Spline order
+        n = a;
+    elseif isstruct(a) && isscalar(a)
+        % Constraint structure
+        constr = a;
+    else
+        error('arguments:nonsense','Failed to interpret argument #%d.',k)
+    end
+end
+
+% No robust fitting
+if ~robust
+    beta = 0;
+end
+
+% Check exterior data
+h = diff(breaks);
+xlim1 = breaks(1) - 0.01*h(1);
+xlim2 = breaks(end) + 0.01*h(end);
+if x(1) < xlim1 || x(end) > xlim2
+    if periodic
+        % Move data inside domain
+        P = breaks(end) - breaks(1);
+        x = mod(x-breaks(1),P) + breaks(1);
+        % Sort
+        [x,isort] = sort(x);
+        y = y(:,isort);
+    else
+        mess = 'Some data points are outside the spline domain.';
+        warning('arguments:exteriordata',mess)
+    end
+end
+
+% Return
+if isempty(constr)
+    return
+end
+
+% Unpack constraints
+xc = [];
+yc = [];
+cc = [];
+names = fieldnames(constr);
+for k = 1:numel(names)
+    switch names{k}
+        case {'xc'}
+            xc = constr.xc;
+        case {'yc'}
+            yc = constr.yc;
+        case {'cc'}
+            cc = constr.cc;
+        otherwise
+            mess = 'Unknown field ''%s'' in constraint structure.';
+            warning('arguments:unknownfield',mess,names{k})
+    end
+end
+
+% Check xc
+if isempty(xc)
+    mess = 'Constraints contains no x-locations.';
+    error('arguments:emptyxc',mess)
+else
+    nx = numel(xc);
+    xc = reshape(xc,1,nx);
+end
+
+% Check yc
+if isempty(yc)
+    % Zero array
+    yc = zeros(pdim,nx);
+elseif numel(yc) == 1
+    % Constant array
+    yc = zeros(pdim,nx) + yc;
+elseif numel(yc) ~= pdim*nx
+    % Malformed array
+    error('arguments:ycsize','Cannot reshape yc to size %dx%d.',pdim,nx)
+else
+    % Reshape array
+    yc = reshape(yc,pdim,nx);
+end
+
+% Check cc
+if isempty(cc)
+    cc = ones(size(xc));
+elseif numel(size(cc)) ~= 2
+    error('arguments:ccsize1','Constraint coefficients cc must be 2D.')
+elseif size(cc,2) ~= nx
+    mess = 'Last dimension of cc must equal length of xc.';
+    error('arguments:ccsize2',mess)
+end
+
+% Check high order derivatives
+if size(cc,1) >= n
+    if any(any(cc(n:end,:)))
+        mess = 'Constraints involve derivatives of order %d or larger.';
+        error('arguments:difforder',mess,n-1)
+    end
+    cc = cc(1:n-1,:);
+end
+
+% Check exterior constraints
+if min(xc) < xlim1 || max(xc) > xlim2
+    if periodic
+        % Move constraints inside domain
+        P = breaks(end) - breaks(1);
+        xc = mod(xc-breaks(1),P) + breaks(1);
+    else
+        mess = 'Some constraints are outside the spline domain.';
+        warning('arguments:exteriorconstr',mess)
+    end
+end
+
+% Pack constraints
+constr = struct('xc',xc,'yc',yc,'cc',cc);
+
+
+%--------------------------------------------------------------------------
+function pp = splinebase(breaks,n)
+%SPLINEBASE Generate B-spline base PP of order N for breaks BREAKS
+
+breaks = breaks(:);     % Breaks
+breaks0 = breaks';      % Initial breaks
+h = diff(breaks);       % Spacing
+pieces = numel(h);      % Number of pieces
+deg = n - 1;            % Polynomial degree
+
+% Extend breaks periodically
+if deg > 0
+    if deg <= pieces
+        hcopy = h;
+    else
+        hcopy = repmat(h,ceil(deg/pieces),1);
+    end
+    % to the left
+    hl = hcopy(end:-1:end-deg+1);
+    bl = breaks(1) - cumsum(hl);
+    % and to the right
+    hr = hcopy(1:deg);
+    br = breaks(end) + cumsum(hr);
+    % Add breaks
+    breaks = [bl(deg:-1:1); breaks; br];
+    h = diff(breaks);
+    pieces = numel(h);
+end
+
+% Initiate polynomial coefficients
+coefs = zeros(n*pieces,n);
+coefs(1:n:end,1) = 1;
+
+% Expand h
+ii = [1:pieces; ones(deg,pieces)];
+ii = cumsum(ii,1);
+ii = min(ii,pieces);
+H = h(ii(:));
+
+% Recursive generation of B-splines
+for k = 2:n
+    % Antiderivatives of splines
+    for j = 1:k-1
+        coefs(:,j) = coefs(:,j).*H/(k-j);
+    end
+    Q = sum(coefs,2);
+    Q = reshape(Q,n,pieces);
+    Q = cumsum(Q,1);
+    c0 = [zeros(1,pieces); Q(1:deg,:)];
+    coefs(:,k) = c0(:);
+    % Normalize antiderivatives by max value
+    fmax = repmat(Q(n,:),n,1);
+    fmax = fmax(:);
+    for j = 1:k
+        coefs(:,j) = coefs(:,j)./fmax;
+    end
+    % Diff of adjacent antiderivatives
+    coefs(1:end-deg,1:k) = coefs(1:end-deg,1:k) - coefs(n:end,1:k);
+    coefs(1:n:end,k) = 0;
+end
+
+% Scale coefficients
+scale = ones(size(H));
+for k = 1:n-1
+    scale = scale./H;
+    coefs(:,n-k) = scale.*coefs(:,n-k);
+end
+
+% Reduce number of pieces
+pieces = pieces - 2*deg;
+
+% Sort coefficients by interval number
+ii = [n*(1:pieces); deg*ones(deg,pieces)];
+ii = cumsum(ii,1);
+coefs = coefs(ii(:),:);
+
+% Make piecewise polynomial
+pp = mkpp(breaks0,coefs,n);
+
+
+%--------------------------------------------------------------------------
+function B = evalcon(base,constr,periodic)
+%EVALCON Evaluate linear constraints
+
+% Unpack structures
+breaks = base.breaks;
+pieces = base.pieces;
+n = base.order;
+xc = constr.xc;
+cc = constr.cc;
+
+% Bin data
+[junk,ibin] = histc(xc,[-inf,breaks(2:end-1),inf]); %#ok
+
+% Evaluate constraints
+nx = numel(xc);
+B0 = zeros(n,nx);
+for k = 1:size(cc,1)
+    if any(cc(k,:))
+        B0 = B0 + repmat(cc(k,:),n,1).*ppval(base,xc);
+    end
+    % Differentiate base
+    coefs = base.coefs(:,1:n-k);
+    for j = 1:n-k-1
+        coefs(:,j) = (n-k-j+1)*coefs(:,j);
+    end
+    base.coefs = coefs;
+    base.order = n-k;
+end
+
+% Sparse output
+ii = [ibin; ones(n-1,nx)];
+ii = cumsum(ii,1);
+jj = repmat(1:nx,n,1);
+if periodic
+    ii = mod(ii-1,pieces) + 1;
+    B = sparse(ii,jj,B0,pieces,nx);
+else
+    B = sparse(ii,jj,B0,pieces+n-1,nx);
+end
+
+
+%--------------------------------------------------------------------------
+function [Z,u0] = solvecon(B,constr)
+%SOLVECON Find a particular solution u0 and null space Z (Z*B = 0)
+%         for constraint equation u*B = yc.
+
+yc = constr.yc;
+tol = 1000*eps;
+
+% Remove blank rows
+ii = any(B,2);
+B2 = full(B(ii,:));
+
+% Null space of B2
+if isempty(B2)
+    Z2 = [];
+else
+    % QR decomposition with column permutation
+    [Q,R,dummy] = qr(B2); %#ok
+    R = abs(R);
+    jj = all(R < R(1)*tol, 2);
+    Z2 = Q(:,jj)';
+end
+
+% Sizes
+[m,ncon] = size(B);
+m2 = size(B2,1);
+nz = size(Z2,1);
+
+% Sparse null space of B
+Z = sparse(nz+1:nz+m-m2,find(~ii),1,nz+m-m2,m);
+Z(1:nz,ii) = Z2;
+
+% Warning rank deficient
+if nz + ncon > m2
+	mess = 'Rank deficient constraints, rank = %d.';
+	warning('solvecon:deficient',mess,m2-nz);
+end
+
+% Particular solution
+u0 = zeros(size(yc,1),m);
+if any(yc(:))
+    % Non-homogeneous case
+	u0(:,ii) = yc/B2;
+    % Check solution
+	if norm(u0*B - yc,'fro') > norm(yc,'fro')*tol
+        mess = 'Inconsistent constraints. No solution within tolerance.';
+        error('solvecon:inconsistent',mess)
+	end
+end
+
+
+%--------------------------------------------------------------------------
+function u = lsqsolve(A,y,beta)
+%LSQSOLVE Solve Min norm(u*A-y)
+
+% Avoid sparse-complex limitations
+if issparse(A) && ~isreal(y)
+    A = full(A);
+end
+
+% Solution
+u = y/A;
+
+% Robust fitting
+if beta > 0
+    [m,n] = size(y);
+    alpha = 0.5*beta/(1-beta)/m;
+    for k = 1:3
+        % Residual
+        r = u*A - y;
+        rr = r.*conj(r);
+        rrmean = sum(rr,2)/n;
+        rrmean(~rrmean) = 1;
+        rrhat = (alpha./rrmean)'*rr;
+        % Weights
+        w = exp(-rrhat);
+        spw = spdiags(w',0,n,n);
+        % Solve weighted problem
+        u = (y*spw)/(A*spw);
+    end
+end
+
--- a/scripts/polynomial/residue.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/polynomial/residue.m	Mon May 07 00:56:44 2012 +0200
@@ -285,7 +285,7 @@
     k = [];
   endif
 
-  if numel (e)
+  if (numel (e))
     indx = 1:numel(p);
   else
     [e, indx] = mpoles (p, toler, 0);
@@ -297,7 +297,7 @@
 
   for n = indx
     pn = [1, -p(n)];
-    if n == 1
+    if (n == 1)
       pden = pn;
     else
       pden = conv (pden, pn);
--- a/scripts/polynomial/spline.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/polynomial/spline.m	Mon May 07 00:56:44 2012 +0200
@@ -131,31 +131,12 @@
       b = b(1:n-1,:);
       a = a(1:n-1,:);
     else
-      if (n == 3)
-        dg = 1.5 * h(1) - 0.5 * h(2);
-        c(2:n-1,:) = 1/dg(1);
-      else
-        dg = 2 * (h(1:n-2) .+ h(2:n-1));
-        dg(1) = dg(1) - 0.5 * h(1);
-        dg(n-2) = dg(n-2) - 0.5 * h(n-1);
-
-        e = h(2:n-2);
-
-        g = 3 * diff (a(2:n,:)) ./ h(2:n-1,idx) ...
-          - 3 * diff (a(1:n-1,:)) ./ h(1:n-2,idx);
-        g(1,:) = 3 * (a(3,:) - a(2,:)) / h(2) ...
-          - 3 / 2 * (3 * (a(2,:) - a(1,:)) / h(1) - dfs);
-        g(n-2,:) = 3 / 2 * (3 * (a(n,:) - a(n-1,:)) / h(n-1) - dfe) ...
-          - 3 * (a(n-1,:) - a(n-2,:)) / h(n-2);
-
-        c(2:n-1,:) = spdiags ([[e(:); 0], dg, [0; e(:)]],
-                              [-1, 0, 1], n-2, n-2) \ g;
-      endif
-
-      c(1,:) = (3 / h(1) * (a(2,:) - a(1,:)) - 3 * dfs
-             - c(2,:) * h(1)) / (2 * h(1));
-      c(n,:) = - (3 / h(n-1) * (a(n,:) - a(n-1,:)) - 3 * dfe
-             + c(n-1,:) * h(n-1)) / (2 * h(n-1));
+      g(1,:) = (a(2,:) - a(1,:)) / h(1) - dfs;
+      g(2:n-1,:) = (a(3:n,:) - a(2:n-1,:)) ./ h(2:n-1) - ...
+                   (a(2:n-1,:) - a(1:n-2,:)) ./ h(1:n-2);
+      g(n,:) = dfe - (a(n,:) - a(n-1,:)) / h(n-1);
+      c = spdiags([[h/6;0],[h(1)/3;(h(1:n-2)+h(2:n-1))/3;h(n-1)/3],[0;h/6]],...
+                  [-1,0,1],n,n) \ (g / 2);
       b(1:n-1,:) = diff (a) ./ h(1:n-1, idx) ...
         - h(1:n-1,idx) / 3 .* (c(2:n,:) + 2 * c(1:n-1,:));
       d = diff (c) ./ (3 * h(1:n-1, idx));
@@ -297,11 +278,23 @@
 %! y = [1,2,3,4];
 %! pp = spline (x,y);
 %! [x,P] = unmkpp (pp);
-%! assert (norm (P-[3,-3,1,2]), 0, abserr);
+%! assert (P, [3,-3,1,2], abserr);
 %!test
 %! x = [2,1];
 %! y = [1,2,3,4];
 %! pp = spline (x,y);
 %! [x,P] = unmkpp (pp);
-%! assert (norm (P-[7,-9,1,3]), 0, abserr);
+%! assert (P, [7,-9,1,3], abserr);
+%!test
+%! x = [0,1,2];
+%! y = [0,0,1,0,0];
+%! pp = spline (x,y);
+%! [x,P] = unmkpp (pp);
+%! assert (P, [-2,3,0,0;2,-3,0,1], abserr);
+%!test
+%! x = [0,1,2,3];
+%! y = [0,0,1,1,0,0];
+%! pp = spline (x,y);
+%! [x,P] = unmkpp (pp);
+%! assert (P, [-1,2,0,0;0,-1,1,1;1,-1,-1,1], abserr);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/polynomial/splinefit.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,237 @@
+## Copyright (C) 2012 Ben Abbott, Jonas Lundgren
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn  {Function File} {@var{pp} =} splinefit (@var{x}, @var{y}, @var{breaks})
+## Fits a piecewise cubic spline with breaks (knots) @var{breaks} to the
+## noisy data, @var{x} and @var{y}.  @var{x} is a vector, and @var{y}
+## a vector or ND array.  If @var{y} is an ND array, then @var{x}(j)
+## is matched to @var{y}(:,...,:,j).
+##
+## The fitted spline is returned as a piece-wise polynomial, @var{pp}, and
+## may be evaluated using @code{ppval}.
+##
+## @deftypefnx {Function File} {@var{pp} =} splinefit (@var{x}, @var{y}, @var{p})
+## @var{p} is a positive integer defining the number of intervals along @var{x},
+## and @var{p}+1 is the number of breaks. The number of points in each interval
+## differ by no more than 1.
+##
+## @deftypefnx {Function File} {@var{pp} =} splinefit (@dots{}, "periodic", @var{periodic})
+## @deftypefnx {Function File} {@var{pp} =} splinefit (@dots{}, "robust", @var{robust})
+## @deftypefnx {Function File} {@var{pp} =} splinefit (@dots{}, "beta", @var{beta})
+## @deftypefnx {Function File} {@var{pp} =} splinefit (@dots{}, "order", @var{order})
+## @deftypefnx {Function File} {@var{pp} =} splinefit (@dots{}, "constraints", @var{constraints})
+##
+## The optional property @var{periodic} is a logical value which specifies
+## whether a periodic boundary condition is applied to the spline.  The
+## length of the period  is @code{max(@var{breaks})-min(@var{breaks})}.
+## The default value is @code{false}.
+##
+## The optional property @var{robust} is a logical value which specifies
+## if robust fitting is to be applied to reduce the influence of outlying
+## data points.  Three iterations of weighted least squares are performed.
+## Weights are computed from previous residuals.  The sensitivity of outlier
+## identification is controlled by the property @var{beta}.  The value of
+## @var{beta} is stricted to the range, 0 < @var{beta} < 1.  The default
+## value is @var{beta} = 1/2.  Values close to 0 give all data equal
+## weighting.  Increasing values of @var{beta} reduce the influence of
+## outlying data.  Values close to unity may cause instability or rank
+## deficiency.
+##
+## The splines are constructed of polynomials with degree @var{order}.
+## The default is a cubic, @var{order}=3.  A spline with P pieces has
+## P+@var{order} degrees of freedom.  With periodic boundary conditions
+## the degrees of freedom are reduced to P.
+##
+## The optional property, @var{constaints}, is a structure specifying
+## linear constraints on the fit.  The structure has three fields, "xc",
+## "yc", and "cc".
+##
+## @table @asis
+## @item "xc"
+## Vector of the x-locations of the constraints.
+## @item "yc"
+## Constaining values at the locations, @var{xc}.
+## The default is an array of zeros.
+## @item "cc"
+## Coefficients (matrix).  The default is an array of ones.  The number of
+## rows is limited to the order of the piece-wise polynomials, @var{order}.
+## @end table
+##
+## Constraints are linear combinations of derivatives of order 0 to
+## @var{order}-1 according to
+##
+## @example
+## @group
+## @tex
+## $cc(1,j) \cdot y(xc(j)) + cc(2,j) \cdot y\prime(xc(j)) + ... = yc(:,\dots,:,j)$.
+## @end tex
+## @ifnottex
+## cc(1,j) * y(xc(j)) + cc(2,j) * y'(xc(j)) + ... = yc(:,...,:,j).
+## @end ifnottex
+## @end group
+## @end example
+##
+## @seealso{interp1, unmkpp, ppval, spline, pchip, ppder, ppint, ppjumps}
+## @end deftypefn
+
+%!demo
+%! % Noisy data
+%! x = linspace (0, 2*pi, 100);
+%! y = sin (x) + 0.1 * randn (size (x));
+%! % Breaks
+%! breaks = [0:5, 2*pi];
+%! % Fit a spline of order 5
+%! pp = splinefit (x, y, breaks, "order", 4);
+%! clf ()
+%! plot (x, y, "s", x, ppval (pp, x), "r", breaks, ppval (pp, breaks), "+r")
+%! xlabel ("Independent Variable")
+%! ylabel ("Dependent Variable")
+%! title ("Fit a piece-wise polynomial of order 4");
+%! legend ({"data", "fit", "breaks"})
+%! axis tight
+%! ylim auto
+
+%!demo
+%! % Noisy data
+%! x = linspace (0,2*pi, 100);
+%! y = sin (x) + 0.1 * randn (size (x));
+%! % Breaks
+%! breaks = [0:5, 2*pi];
+%! % Fit a spline of order 3 with periodic boundary conditions
+%! pp = splinefit (x, y, breaks, "order", 2, "periodic", true);
+%! clf ()
+%! plot (x, y, "s", x, ppval (pp, x), "r", breaks, ppval (pp, breaks), "+r")
+%! xlabel ("Independent Variable")
+%! ylabel ("Dependent Variable")
+%! title ("Fit a periodic piece-wise polynomial of order 2");
+%! legend ({"data", "fit", "breaks"})
+%! axis tight
+%! ylim auto
+
+%!demo
+%! % Noisy data
+%! x = linspace (0, 2*pi, 100);
+%! y = sin (x) + 0.1 * randn (size (x));
+%! % Breaks
+%! breaks = [0:5, 2*pi];
+%! % Constraints: y(0) = 0, y'(0) = 1 and y(3) + y"(3) = 0
+%! xc = [0 0 3];
+%! yc = [0 1 0];
+%! cc = [1 0 1; 0 1 0; 0 0 1];
+%! con = struct ("xc", xc, "yc", yc, "cc", cc);
+%! % Fit a cubic spline with 8 pieces and constraints
+%! pp = splinefit (x, y, 8, "constraints", con);
+%! clf ()
+%! plot (x, y, "s", x, ppval (pp, x), "r", breaks, ppval (pp, breaks), "+r")
+%! xlabel ("Independent Variable")
+%! ylabel ("Dependent Variable")
+%! title ("Fit a cubic spline with constraints")
+%! legend ({"data", "fit", "breaks"})
+%! axis tight
+%! ylim auto
+
+%!demo
+%! % Noisy data
+%! x = linspace (0, 2*pi, 100);
+%! y = sin (x) + 0.1 * randn (size (x));
+%! % Breaks
+%! breaks = [0:5, 2*pi];
+%! xc = [0 0 3];
+%! yc = [0 1 0];
+%! cc = [1 0 1; 0 1 0; 0 0 1];
+%! con = struct ("xc", xc, "yc", yc, "cc", cc);
+%! % Fit a spline of order 6 with constraints and periodicity
+%! pp = splinefit (x, y, breaks, "constraints", con, "order", 5, "periodic", true);
+%! clf ()
+%! plot (x, y, "s", x, ppval (pp, x), "r", breaks, ppval (pp, breaks), "+r")
+%! xlabel ("Independent Variable")
+%! ylabel ("Dependent Variable")
+%! title ("Fit a 5th order piece-wise periodic polynomial with constraints")
+%! legend ({"data", "fit", "breaks"})
+%! axis tight
+%! ylim auto
+
+function pp = splinefit (x, y, breaks, varargin)
+  if (nargin > 3)
+    n = cellfun (@ischar, varargin, "uniformoutput", true);
+    varargin(n) = lower (varargin(n));
+    try
+      props = struct (varargin{:});
+    catch
+      print_usage ();
+    end_try_catch
+  else
+    props = struct ();
+  endif
+  fields = fieldnames (props);
+  for f = 1:numel(fields)
+    if (! any (strcmp (fields{f},
+                       {"periodic", "robust", "beta", "order", "constraints"})))
+      error ("splinefit:invalidproperty",
+             "unrecognized property '%s'", fields{f});
+    endif
+  endfor
+  args = {};
+  if (isfield (props, "periodic") && props.periodic)
+    args{end+1} = "p";
+  endif
+  if (isfield (props, "robust") && props.robust)
+    args{end+1} = "r";
+  endif
+  if (isfield (props, "beta"))
+    if (0 < props.beta && props.beta < 1)
+      args{end+1} = props.beta;
+    else
+      error ("splinefit:invalidbeta", "invalid beta parameter (0 < beta < 1)");
+    endif
+  endif
+  if (isfield (props, "order"))
+    if (props.order >= 0)
+      args{end+1} = props.order + 1;
+    else
+      error ("splinefit:invalidorder", "invalid order");
+    endif
+  endif
+  if (isfield (props, "constraints"))
+    args{end+1} = props.constraints;
+  endif
+  if (nargin < 3)
+    print_usage ();
+  elseif (! isnumeric (breaks) || ! isvector (breaks))
+    print_usage ();
+  endif
+  pp = __splinefit__ (x, y, breaks, args{:});
+endfunction
+
+%!shared xb, yb, x
+%! xb = 0:2:10;
+%! yb = randn (size (xb));
+%! x = 0:0.1:10;
+
+%!test
+%! y = interp1 (xb, yb, x, "linear");
+%! assert (ppval (splinefit (x, y, xb, "order", 1), x), y, 10 * eps ());
+%!test
+%! y = interp1 (xb, yb, x, "spline");
+%! assert (ppval (splinefit (x, y, xb, "order", 3), x), y, 10 * eps ());
+%!test
+%! y = interp1 (xb, yb, x, "spline");
+%! assert (ppval (splinefit (x, y, xb), x), y, 10 * eps ());
+
+
--- a/scripts/prefs/rmpref.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/prefs/rmpref.m	Mon May 07 00:56:44 2012 +0200
@@ -17,14 +17,15 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {} rmpref (@var{group}, @var{pref})
+## @deftypefn  {Function File} {} rmpref (@var{group})
+## @deftypefnx {Function File} {} rmpref (@var{group}, @var{pref})
 ## Remove the named preference @var{pref} from the preference group
 ## @var{group}.
 ##
 ## The named preference group must be a character string.
 ##
-## The preference @var{pref} may be a character string or a cell array
-## of character strings.
+## The preference @var{pref} may be a character string or cell array
+## of strings.
 ##
 ## If @var{pref} is not specified, remove the preference group
 ## @var{group}.
@@ -37,25 +38,48 @@
 
 function retval = rmpref (group, pref)
 
-  prefs = loadprefs ();
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+  elseif (! ischar (group))
+    error ("rmpref: GROUP must be a string");
+  elseif (nargin == 2 && ! (ischar (pref) || iscellstr (pref)))
+    error ("rmpref: PREF must be a string or cell array of strings");
+  endif
 
   if (nargin == 1)
-    if (ischar (group))
-      retval = isfield (prefs, group);
+    if (ispref (group))
+      prefs = loadprefs ();
+      prefs = rmfield (prefs, group);
+      saveprefs (prefs);
     else
-      error ("expecting group to be a character array");
-    endif
-  elseif (nargin == 2)
-    grp = getpref (group, pref);
-    if (ischar (pref) || iscellstr (pref))
-      retval = isfield (grp, pref);
+      error ("rmpref: group <%s> does not exist", group);
     endif
   else
-    print_usage ();
+    valid = ispref (group, pref);
+    if (all (valid))
+      prefs = loadprefs ();
+      prefs.(group) = rmfield (prefs.(group), pref);
+      saveprefs (prefs);
+    else
+      if (! ispref (group))
+        error ("rmpref: group <%s> does not exist", group);
+      else
+        idx = find (! valid, 1); 
+        error ("rmpref: pref <%s> does not exist", (cellstr (pref)){idx} );
+      endif
+    endif
   endif
 
 endfunction
 
-%% Testing these functions will require some care to avoid wiping out
-%% existing (or creating unwanted) preferences for the user running the
-%% tests.
+
+## Testing these functions will require some care to avoid wiping out
+## existing (or creating unwanted) preferences for the user running the
+## tests.
+
+## Test input validation
+%!error rmpref ()
+%!error rmpref (1,2,3)
+%!error rmpref ({"__group1__"})
+%!error rmpref ("__group1__", 1)
+
--- a/scripts/signal/periodogram.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/signal/periodogram.m	Mon May 07 00:56:44 2012 +0200
@@ -122,7 +122,7 @@
 
   if (strcmp (range, "onesided"))
     range = 1;
-  elseif strcmp (range, "twosided")
+  elseif (strcmp (range, "twosided"))
     range = 2;
   else
     range = 2-isreal (x);
--- a/scripts/sparse/sprandsym.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/sparse/sprandsym.m	Mon May 07 00:56:44 2012 +0200
@@ -119,7 +119,7 @@
   ## numerically to avoid overflow.
 
   ## Degenerate case
-  if k == 1
+  if (k == 1)
     r = 1;
     return
   endif
--- a/scripts/statistics/base/moment.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/statistics/base/moment.m	Mon May 07 00:56:44 2012 +0200
@@ -165,7 +165,7 @@
   if (any (type == "c"))
     x = center (x, dim);
   endif
-  if any (type == "a")
+  if (any (type == "a"))
     x = abs (x);
   endif
 
--- a/scripts/statistics/distributions/expcdf.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/statistics/distributions/expcdf.m	Mon May 07 00:56:44 2012 +0200
@@ -59,10 +59,10 @@
   cdf(k) = 1;
 
   k = (x > 0) & (x < Inf) & (lambda > 0);
-  if isscalar (lambda)
-    cdf(k) = 1 - exp (- x(k) / lambda);
+  if (isscalar (lambda))
+    cdf(k) = 1 - exp (-x(k) / lambda);
   else
-    cdf(k) = 1 - exp (- x(k) ./ lambda(k));
+    cdf(k) = 1 - exp (-x(k) ./ lambda(k));
   endif
 
 endfunction
--- a/scripts/statistics/distributions/expinv.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/statistics/distributions/expinv.m	Mon May 07 00:56:44 2012 +0200
@@ -63,7 +63,7 @@
   inv(k) = Inf;
 
   k = (x >= 0) & (x < 1) & (lambda > 0);
-  if isscalar (lambda)
+  if (isscalar (lambda))
     inv(k) = - lambda * log (1 - x(k));
   else
     inv(k) = - lambda(k) .* log (1 - x(k));
--- a/scripts/statistics/distributions/exppdf.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/statistics/distributions/exppdf.m	Mon May 07 00:56:44 2012 +0200
@@ -53,10 +53,10 @@
   pdf(k) = NaN;
 
   k = (x >= 0) & (x < Inf) & (lambda > 0);
-  if isscalar (lambda)
-    pdf(k) = exp (- x(k) / lambda) / lambda;
+  if (isscalar (lambda))
+    pdf(k) = exp (-x(k) / lambda) / lambda;
   else
-    pdf(k) = exp (- x(k) ./ lambda(k)) ./ lambda(k);
+    pdf(k) = exp (-x(k) ./ lambda(k)) ./ lambda(k);
   endif
 
 endfunction
--- a/scripts/statistics/distributions/poissrnd.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/statistics/distributions/poissrnd.m	Mon May 07 00:56:44 2012 +0200
@@ -76,7 +76,7 @@
   endif
 
   if (isscalar (lambda))
-    if (lambda > 0 && lambda < Inf)
+    if (lambda >= 0 && lambda < Inf)
       rnd = randp (lambda, sz);
       if (strcmp (cls, "single"))
         rnd = single (rnd);
@@ -87,7 +87,7 @@
   else
     rnd = NaN (sz, cls);
 
-    k = (lambda > 0) & (lambda < Inf);
+    k = (lambda >= 0) & (lambda < Inf);
     rnd(k) = randp (lambda(k));
   endif
 
@@ -118,3 +118,6 @@
 %!error poissrnd (ones (2,2), [3, 2])
 %!error poissrnd (ones (2,2), 2, 3)
 
+%!assert (poissrnd (0, 1, 1), 0)
+%!assert (poissrnd ([0, 0, 0], [1, 3]), [0 0 0])
+
--- a/scripts/statistics/tests/prop_test_2.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/statistics/tests/prop_test_2.m	Mon May 07 00:56:44 2012 +0200
@@ -65,9 +65,9 @@
   endif
   if (strcmp (alt, "!=") || strcmp (alt, "<>"))
     pval = 2 * min (cdf, 1 - cdf);
-  elseif strcmp (alt, ">")
+  elseif (strcmp (alt, ">"))
     pval = 1 - cdf;
-  elseif strcmp (alt, "<")
+  elseif (strcmp (alt, "<"))
     pval = cdf;
   else
     error ("prop_test_2: option %s not recognized", alt);
--- a/scripts/statistics/tests/sign_test.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/statistics/tests/sign_test.m	Mon May 07 00:56:44 2012 +0200
@@ -68,9 +68,9 @@
   endif
   if (strcmp (alt, "!=") || strcmp (alt, "<>"))
     pval = 2 * min (cdf, 1 - cdf);
-  elseif strcmp (alt, ">")
+  elseif (strcmp (alt, ">"))
     pval = 1 - cdf;
-  elseif strcmp (alt, "<")
+  elseif (strcmp (alt, "<"))
     pval = cdf;
   else
     error ("sign_test: option %s not recognized", alt);
--- a/scripts/statistics/tests/t_test.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/statistics/tests/t_test.m	Mon May 07 00:56:44 2012 +0200
@@ -68,9 +68,9 @@
   endif
   if (strcmp (alt, "!=") || strcmp (alt, "<>"))
     pval = 2 * min (cdf, 1 - cdf);
-  elseif strcmp (alt, ">")
+  elseif (strcmp (alt, ">"))
     pval = 1 - cdf;
-  elseif strcmp (alt, "<")
+  elseif (strcmp (alt, "<"))
     pval = cdf;
   else
     error ("t_test: option %s not recognized", alt);
--- a/scripts/statistics/tests/t_test_2.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/statistics/tests/t_test_2.m	Mon May 07 00:56:44 2012 +0200
@@ -69,9 +69,9 @@
   endif
   if (strcmp (alt, "!=") || strcmp (alt, "<>"))
     pval = 2 * min (cdf, 1 - cdf);
-  elseif strcmp (alt, ">")
+  elseif (strcmp (alt, ">"))
     pval = 1 - cdf;
-  elseif strcmp (alt, "<")
+  elseif (strcmp (alt, "<"))
     pval = cdf;
   else
     error ("t_test_2: option %s not recognized", alt);
--- a/scripts/statistics/tests/t_test_regression.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/statistics/tests/t_test_regression.m	Mon May 07 00:56:44 2012 +0200
@@ -81,9 +81,9 @@
 
   if (strcmp (alt, "!=") || strcmp (alt, "<>"))
     pval = 2 * min (cdf, 1 - cdf);
-  elseif strcmp (alt, ">")
+  elseif (strcmp (alt, ">"))
     pval = 1 - cdf;
-  elseif strcmp (alt, "<")
+  elseif (strcmp (alt, "<"))
     pval = cdf;
   else
     error ("t_test_regression: the value `%s' for alt is not possible", alt);
--- a/scripts/strings/regexptranslate.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/strings/regexptranslate.m	Mon May 07 00:56:44 2012 +0200
@@ -53,7 +53,7 @@
 
 function y = regexptranslate (op, s)
 
-  if nargin != 2
+  if (nargin != 2)
     print_usage ();
   endif
 
@@ -67,7 +67,7 @@
                                             '\*', '.*'), 
                                             '\?', '.');
   elseif (strcmp ("escape", op))
-    y = regexprep (s, '([^\w])', '\$1');
+    y = regexprep (s, '([^\w])', '\\$1');
   else
     error ("regexptranslate: invalid operation OP");
   endif
--- a/scripts/time/datetick.m	Mon May 07 00:53:54 2012 +0200
+++ b/scripts/time/datetick.m	Mon May 07 00:56:44 2012 +0200
@@ -199,22 +199,22 @@
   endif
 
   if (isempty (form))
-    r = max(ticks) - min(ticks);
-    if r < 10/60/24
+    r = max (ticks) - min (ticks);
+    if (r < 10/60/24)
       ## minutes and seconds
       form = 13;
-    elseif r < 2
+    elseif (r < 2)
       ## hours
       form = 15;
-    elseif r < 15
+    elseif (r < 15)
       ## days
       form = 8;
-    elseif r < 365
+    elseif (r < 365)
       ## FIXME -- FORM should be 19 for European users who use dd/mm
       ## instead of mm/dd.  How can that be determined automatically?
       ## months
       form = 6;
-    elseif r < 90*12
+    elseif (r < 90*12)
       ## quarters
       form = 27;
     else
--- a/src/Cell.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/Cell.cc	Mon May 07 00:56:44 2012 +0200
@@ -315,3 +315,9 @@
 {
   return Array<octave_value>::diag (k);
 }
+
+Cell
+Cell::diag (octave_idx_type m, octave_idx_type n) const
+{
+  return Array<octave_value>::diag (m, n);
+}
--- a/src/Cell.h	Mon May 07 00:53:54 2012 +0200
+++ b/src/Cell.h	Mon May 07 00:56:44 2012 +0200
@@ -114,6 +114,8 @@
 
   Cell diag (octave_idx_type k = 0) const;
 
+  Cell diag (octave_idx_type m, octave_idx_type n) const;
+
   Cell xisalnum (void) const { return map (&octave_value::xisalnum); }
   Cell xisalpha (void) const { return map (&octave_value::xisalpha); }
   Cell xisascii (void) const { return map (&octave_value::xisascii); }
--- a/src/DLD-FUNCTIONS/__contourc__.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/__contourc__.cc	Mon May 07 00:56:44 2012 +0200
@@ -335,8 +335,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/__delaunayn__.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/__delaunayn__.cc	Mon May 07 00:56:44 2012 +0200
@@ -224,8 +224,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/__dispatch__.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/__dispatch__.cc	Mon May 07 00:56:44 2012 +0200
@@ -131,8 +131,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/__dsearchn__.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/__dsearchn__.cc	Mon May 07 00:56:44 2012 +0200
@@ -110,8 +110,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/__fltk_uigetfile__.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/__fltk_uigetfile__.cc	Mon May 07 00:56:44 2012 +0200
@@ -135,10 +135,8 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
 
 #endif
--- a/src/DLD-FUNCTIONS/__glpk__.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/__glpk__.cc	Mon May 07 00:56:44 2012 +0200
@@ -856,8 +856,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/__lin_interpn__.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/__lin_interpn__.cc	Mon May 07 00:56:44 2012 +0200
@@ -357,8 +357,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/__magick_read__.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/__magick_read__.cc	Mon May 07 00:56:44 2012 +0200
@@ -533,10 +533,8 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
 
 #ifdef HAVE_MAGICK
@@ -925,10 +923,8 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
 
 #ifdef HAVE_MAGICK
@@ -1150,10 +1146,8 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
 
 #undef GET_PARAM
@@ -1217,8 +1211,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/__pchip_deriv__.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/__pchip_deriv__.cc	Mon May 07 00:56:44 2012 +0200
@@ -163,8 +163,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/__qp__.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/__qp__.cc	Mon May 07 00:56:44 2012 +0200
@@ -530,8 +530,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/__voronoi__.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/__voronoi__.cc	Mon May 07 00:56:44 2012 +0200
@@ -329,8 +329,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/besselj.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/besselj.cc	Mon May 07 00:56:44 2012 +0200
@@ -654,92 +654,92 @@
 %!shared alpha, x, jx, yx, ix, kx, nix
 %!
 %! # Bessel functions, even order, positive and negative x
-%! alpha = 2; x = 1.25;
+%! alpha = 2;  x = 1.25;
 %! jx = 0.1710911312405234823613091417;
 %! yx = -1.193199310178553861283790424;
 %! ix = 0.2220184483766341752692212604;
 %! kx = 0.9410016167388185767085460540;
 %!
-%!assert(besselj(alpha,x), jx, 100*eps)
-%!assert(bessely(alpha,x), yx, 100*eps)
-%!assert(besseli(alpha,x), ix, 100*eps)
-%!assert(besselk(alpha,x), kx, 100*eps)
-%!assert(besselh(alpha,1,x), jx + I*yx, 100*eps)
-%!assert(besselh(alpha,2,x), jx - I*yx, 100*eps)
+%!assert (besselj (alpha,x), jx, 100*eps)
+%!assert (bessely (alpha,x), yx, 100*eps)
+%!assert (besseli (alpha,x), ix, 100*eps)
+%!assert (besselk (alpha,x), kx, 100*eps)
+%!assert (besselh (alpha,1,x), jx + I*yx, 100*eps)
+%!assert (besselh (alpha,2,x), jx - I*yx, 100*eps)
 %!
-%!assert(besselj(alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
-%!assert(bessely(alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
-%!assert(besseli(alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
-%!assert(besselk(alpha,x,1), kx*exp(x), 100*eps)
-%!assert(besselh(alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
-%!assert(besselh(alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
+%!assert (besselj (alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
+%!assert (bessely (alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
+%!assert (besseli (alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
+%!assert (besselk (alpha,x,1), kx*exp(x), 100*eps)
+%!assert (besselh (alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
+%!assert (besselh (alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
 %!
-%!assert(besselj(-alpha,x), jx, 100*eps)
-%!assert(bessely(-alpha,x), yx, 100*eps)
-%!assert(besseli(-alpha,x), ix, 100*eps)
-%!assert(besselk(-alpha,x), kx, 100*eps)
-%!assert(besselh(-alpha,1,x), jx + I*yx, 100*eps)
-%!assert(besselh(-alpha,2,x), jx - I*yx, 100*eps)
+%!assert (besselj (-alpha,x), jx, 100*eps)
+%!assert (bessely (-alpha,x), yx, 100*eps)
+%!assert (besseli (-alpha,x), ix, 100*eps)
+%!assert (besselk (-alpha,x), kx, 100*eps)
+%!assert (besselh (-alpha,1,x), jx + I*yx, 100*eps)
+%!assert (besselh (-alpha,2,x), jx - I*yx, 100*eps)
 %!
-%!assert(besselj(-alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
-%!assert(bessely(-alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
-%!assert(besseli(-alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
-%!assert(besselk(-alpha,x,1), kx*exp(x), 100*eps)
-%!assert(besselh(-alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
-%!assert(besselh(-alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
+%!assert (besselj (-alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
+%!assert (bessely (-alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
+%!assert (besseli (-alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
+%!assert (besselk (-alpha,x,1), kx*exp(x), 100*eps)
+%!assert (besselh (-alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
+%!assert (besselh (-alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
 %!
 %! x *= -1;
 %! yx = -1.193199310178553861283790424 + 0.3421822624810469647226182835*I;
 %! kx = 0.9410016167388185767085460540 - 0.6974915263814386815610060884*I;
 %!
-%!assert(besselj(alpha,x), jx, 100*eps)
-%!assert(bessely(alpha,x), yx, 100*eps)
-%!assert(besseli(alpha,x), ix, 100*eps)
-%!assert(besselk(alpha,x), kx, 100*eps)
-%!assert(besselh(alpha,1,x), jx + I*yx, 100*eps)
-%!assert(besselh(alpha,2,x), jx - I*yx, 100*eps)
+%!assert (besselj (alpha,x), jx, 100*eps)
+%!assert (bessely (alpha,x), yx, 100*eps)
+%!assert (besseli (alpha,x), ix, 100*eps)
+%!assert (besselk (alpha,x), kx, 100*eps)
+%!assert (besselh (alpha,1,x), jx + I*yx, 100*eps)
+%!assert (besselh (alpha,2,x), jx - I*yx, 100*eps)
 %!
-%!assert(besselj(alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
-%!assert(bessely(alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
-%!assert(besseli(alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
-%!assert(besselk(alpha,x,1), kx*exp(x), 100*eps)
-%!assert(besselh(alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
-%!assert(besselh(alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
+%!assert (besselj (alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
+%!assert (bessely (alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
+%!assert (besseli (alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
+%!assert (besselk (alpha,x,1), kx*exp(x), 100*eps)
+%!assert (besselh (alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
+%!assert (besselh (alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
 %!
 %! # Bessel functions, odd order, positive and negative x
-%! alpha = 3; x = 2.5;
+%! alpha = 3;  x = 2.5;
 %! jx = 0.2166003910391135247666890035;
 %! yx = -0.7560554967536709968379029772;
 %! ix = 0.4743704087780355895548240179;
 %! kx = 0.2682271463934492027663765197;
 %!
-%!assert(besselj(alpha,x), jx, 100*eps)
-%!assert(bessely(alpha,x), yx, 100*eps)
-%!assert(besseli(alpha,x), ix, 100*eps)
-%!assert(besselk(alpha,x), kx, 100*eps)
-%!assert(besselh(alpha,1,x), jx + I*yx, 100*eps)
-%!assert(besselh(alpha,2,x), jx - I*yx, 100*eps)
+%!assert (besselj (alpha,x), jx, 100*eps)
+%!assert (bessely (alpha,x), yx, 100*eps)
+%!assert (besseli (alpha,x), ix, 100*eps)
+%!assert (besselk (alpha,x), kx, 100*eps)
+%!assert (besselh (alpha,1,x), jx + I*yx, 100*eps)
+%!assert (besselh (alpha,2,x), jx - I*yx, 100*eps)
 %!
-%!assert(besselj(alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
-%!assert(bessely(alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
-%!assert(besseli(alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
-%!assert(besselk(alpha,x,1), kx*exp(x), 100*eps)
-%!assert(besselh(alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
-%!assert(besselh(alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
+%!assert (besselj (alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
+%!assert (bessely (alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
+%!assert (besseli (alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
+%!assert (besselk (alpha,x,1), kx*exp(x), 100*eps)
+%!assert (besselh (alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
+%!assert (besselh (alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
 %!
-%!assert(besselj(-alpha,x), -jx, 100*eps)
-%!assert(bessely(-alpha,x), -yx, 100*eps)
-%!assert(besseli(-alpha,x), ix, 100*eps)
-%!assert(besselk(-alpha,x), kx, 100*eps)
-%!assert(besselh(-alpha,1,x), -(jx + I*yx), 100*eps)
-%!assert(besselh(-alpha,2,x), -(jx - I*yx), 100*eps)
+%!assert (besselj (-alpha,x), -jx, 100*eps)
+%!assert (bessely (-alpha,x), -yx, 100*eps)
+%!assert (besseli (-alpha,x), ix, 100*eps)
+%!assert (besselk (-alpha,x), kx, 100*eps)
+%!assert (besselh (-alpha,1,x), -(jx + I*yx), 100*eps)
+%!assert (besselh (-alpha,2,x), -(jx - I*yx), 100*eps)
 %!
-%!assert(besselj(-alpha,x,1), -jx*exp(-abs(imag(x))), 100*eps)
-%!assert(bessely(-alpha,x,1), -yx*exp(-abs(imag(x))), 100*eps)
-%!assert(besseli(-alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
-%!assert(besselk(-alpha,x,1), kx*exp(x), 100*eps)
-%!assert(besselh(-alpha,1,x,1), -(jx + I*yx)*exp(-I*x), 100*eps)
-%!assert(besselh(-alpha,2,x,1), -(jx - I*yx)*exp(I*x), 100*eps)
+%!assert (besselj (-alpha,x,1), -jx*exp(-abs(imag(x))), 100*eps)
+%!assert (bessely (-alpha,x,1), -yx*exp(-abs(imag(x))), 100*eps)
+%!assert (besseli (-alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
+%!assert (besselk (-alpha,x,1), kx*exp(x), 100*eps)
+%!assert (besselh (-alpha,1,x,1), -(jx + I*yx)*exp(-I*x), 100*eps)
+%!assert (besselh (-alpha,2,x,1), -(jx - I*yx)*exp(I*x), 100*eps)
 %!
 %! x *= -1;
 %! jx = -jx;
@@ -747,57 +747,57 @@
 %! ix = -ix;
 %! kx = -0.2682271463934492027663765197 - 1.490278591297463775542004240*I;
 %!
-%!assert(besselj(alpha,x), jx, 100*eps)
-%!assert(bessely(alpha,x), yx, 100*eps)
-%!assert(besseli(alpha,x), ix, 100*eps)
-%!assert(besselk(alpha,x), kx, 100*eps)
-%!assert(besselh(alpha,1,x), jx + I*yx, 100*eps)
-%!assert(besselh(alpha,2,x), jx - I*yx, 100*eps)
+%!assert (besselj (alpha,x), jx, 100*eps)
+%!assert (bessely (alpha,x), yx, 100*eps)
+%!assert (besseli (alpha,x), ix, 100*eps)
+%!assert (besselk (alpha,x), kx, 100*eps)
+%!assert (besselh (alpha,1,x), jx + I*yx, 100*eps)
+%!assert (besselh (alpha,2,x), jx - I*yx, 100*eps)
 %!
-%!assert(besselj(alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
-%!assert(bessely(alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
-%!assert(besseli(alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
-%!assert(besselk(alpha,x,1), kx*exp(x), 100*eps)
-%!assert(besselh(alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
-%!assert(besselh(alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
+%!assert (besselj (alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
+%!assert (bessely (alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
+%!assert (besseli (alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
+%!assert (besselk (alpha,x,1), kx*exp(x), 100*eps)
+%!assert (besselh (alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
+%!assert (besselh (alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
 %!
 %! # Bessel functions, fractional order, positive and negative x
 %!
-%! alpha = 3.5; x = 2.75;
+%! alpha = 3.5;  x = 2.75;
 %! jx = 0.1691636439842384154644784389;
 %! yx = -0.8301381935499356070267953387;
 %! ix = 0.3930540878794826310979363668;
 %! kx = 0.2844099013460621170288192503;
 %!
-%!assert(besselj(alpha,x), jx, 100*eps)
-%!assert(bessely(alpha,x), yx, 100*eps)
-%!assert(besseli(alpha,x), ix, 100*eps)
-%!assert(besselk(alpha,x), kx, 100*eps)
-%!assert(besselh(alpha,1,x), jx + I*yx, 100*eps)
-%!assert(besselh(alpha,2,x), jx - I*yx, 100*eps)
+%!assert (besselj (alpha,x), jx, 100*eps)
+%!assert (bessely (alpha,x), yx, 100*eps)
+%!assert (besseli (alpha,x), ix, 100*eps)
+%!assert (besselk (alpha,x), kx, 100*eps)
+%!assert (besselh (alpha,1,x), jx + I*yx, 100*eps)
+%!assert (besselh (alpha,2,x), jx - I*yx, 100*eps)
 %!
-%!assert(besselj(alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
-%!assert(bessely(alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
-%!assert(besseli(alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
-%!assert(besselk(alpha,x,1), kx*exp(x), 100*eps)
-%!assert(besselh(alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
-%!assert(besselh(alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
+%!assert (besselj (alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
+%!assert (bessely (alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
+%!assert (besseli (alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
+%!assert (besselk (alpha,x,1), kx*exp(x), 100*eps)
+%!assert (besselh (alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
+%!assert (besselh (alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
 %!
 %! nix = 0.2119931212254662995364461998;
 %!
-%!assert(besselj(-alpha,x), yx, 100*eps)
-%!assert(bessely(-alpha,x), -jx, 100*eps)
-%!assert(besseli(-alpha,x), nix, 100*eps)
-%!assert(besselk(-alpha,x), kx, 100*eps)
-%!assert(besselh(-alpha,1,x), -I*(jx + I*yx), 100*eps)
-%!assert(besselh(-alpha,2,x), I*(jx - I*yx), 100*eps)
+%!assert (besselj (-alpha,x), yx, 100*eps)
+%!assert (bessely (-alpha,x), -jx, 100*eps)
+%!assert (besseli (-alpha,x), nix, 100*eps)
+%!assert (besselk (-alpha,x), kx, 100*eps)
+%!assert (besselh (-alpha,1,x), -I*(jx + I*yx), 100*eps)
+%!assert (besselh (-alpha,2,x), I*(jx - I*yx), 100*eps)
 %!
-%!assert(besselj(-alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
-%!assert(bessely(-alpha,x,1), -jx*exp(-abs(imag(x))), 100*eps)
-%!assert(besseli(-alpha,x,1), nix*exp(-abs(real(x))), 100*eps)
-%!assert(besselk(-alpha,x,1), kx*exp(x), 100*eps)
-%!assert(besselh(-alpha,1,x,1), -I*(jx + I*yx)*exp(-I*x), 100*eps)
-%!assert(besselh(-alpha,2,x,1), I*(jx - I*yx)*exp(I*x), 100*eps)
+%!assert (besselj (-alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
+%!assert (bessely (-alpha,x,1), -jx*exp(-abs(imag(x))), 100*eps)
+%!assert (besseli (-alpha,x,1), nix*exp(-abs(real(x))), 100*eps)
+%!assert (besselk (-alpha,x,1), kx*exp(x), 100*eps)
+%!assert (besselh (-alpha,1,x,1), -I*(jx + I*yx)*exp(-I*x), 100*eps)
+%!assert (besselh (-alpha,2,x,1), I*(jx - I*yx)*exp(I*x), 100*eps)
 %!
 %! x *= -1;
 %! jx *= -I;
@@ -805,55 +805,55 @@
 %! ix *= -I;
 %! kx = -0.9504059335995575096509874508*I;
 %!
-%!assert(besselj(alpha,x), jx, 100*eps)
-%!assert(bessely(alpha,x), yx, 100*eps)
-%!assert(besseli(alpha,x), ix, 100*eps)
-%!assert(besselk(alpha,x), kx, 100*eps)
-%!assert(besselh(alpha,1,x), jx + I*yx, 100*eps)
-%!assert(besselh(alpha,2,x), jx - I*yx, 100*eps)
+%!assert (besselj (alpha,x), jx, 100*eps)
+%!assert (bessely (alpha,x), yx, 100*eps)
+%!assert (besseli (alpha,x), ix, 100*eps)
+%!assert (besselk (alpha,x), kx, 100*eps)
+%!assert (besselh (alpha,1,x), jx + I*yx, 100*eps)
+%!assert (besselh (alpha,2,x), jx - I*yx, 100*eps)
 %!
-%!assert(besselj(alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
-%!assert(bessely(alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
-%!assert(besseli(alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
-%!assert(besselk(alpha,x,1), kx*exp(x), 100*eps)
-%!assert(besselh(alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
-%!assert(besselh(alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
+%!assert (besselj (alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
+%!assert (bessely (alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
+%!assert (besseli (alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
+%!assert (besselk (alpha,x,1), kx*exp(x), 100*eps)
+%!assert (besselh (alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
+%!assert (besselh (alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
 %!
 %! # Bessel functions, even order, complex x
 %!
-%! alpha = 2; x = 1.25 + 3.625 * I;
+%! alpha = 2;  x = 1.25 + 3.625 * I;
 %! jx = -1.299533366810794494030065917 + 4.370833116012278943267479589*I;
 %! yx = -4.370357232383223896393056727 - 1.283083391453582032688834041*I;
 %! ix = -0.6717801680341515541002273932 - 0.2314623443930774099910228553*I;
 %! kx = -0.01108009888623253515463783379 + 0.2245218229358191588208084197*I;
 %!
-%!assert(besselj(alpha,x), jx, 100*eps)
-%!assert(bessely(alpha,x), yx, 100*eps)
-%!assert(besseli(alpha,x), ix, 100*eps)
-%!assert(besselk(alpha,x), kx, 100*eps)
-%!assert(besselh(alpha,1,x), jx + I*yx, 100*eps)
-%!assert(besselh(alpha,2,x), jx - I*yx, 100*eps)
+%!assert (besselj (alpha,x), jx, 100*eps)
+%!assert (bessely (alpha,x), yx, 100*eps)
+%!assert (besseli (alpha,x), ix, 100*eps)
+%!assert (besselk (alpha,x), kx, 100*eps)
+%!assert (besselh (alpha,1,x), jx + I*yx, 100*eps)
+%!assert (besselh (alpha,2,x), jx - I*yx, 100*eps)
 %!
-%!assert(besselj(alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
-%!assert(bessely(alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
-%!assert(besseli(alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
-%!assert(besselk(alpha,x,1), kx*exp(x), 100*eps)
-%!assert(besselh(alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
-%!assert(besselh(alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
+%!assert (besselj (alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
+%!assert (bessely (alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
+%!assert (besseli (alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
+%!assert (besselk (alpha,x,1), kx*exp(x), 100*eps)
+%!assert (besselh (alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
+%!assert (besselh (alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
 %!
-%!assert(besselj(-alpha,x), jx, 100*eps)
-%!assert(bessely(-alpha,x), yx, 100*eps)
-%!assert(besseli(-alpha,x), ix, 100*eps)
-%!assert(besselk(-alpha,x), kx, 100*eps)
-%!assert(besselh(-alpha,1,x), jx + I*yx, 100*eps)
-%!assert(besselh(-alpha,2,x), jx - I*yx, 100*eps)
+%!assert (besselj (-alpha,x), jx, 100*eps)
+%!assert (bessely (-alpha,x), yx, 100*eps)
+%!assert (besseli (-alpha,x), ix, 100*eps)
+%!assert (besselk (-alpha,x), kx, 100*eps)
+%!assert (besselh (-alpha,1,x), jx + I*yx, 100*eps)
+%!assert (besselh (-alpha,2,x), jx - I*yx, 100*eps)
 %!
-%!assert(besselj(-alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
-%!assert(bessely(-alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
-%!assert(besseli(-alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
-%!assert(besselk(-alpha,x,1), kx*exp(x), 100*eps)
-%!assert(besselh(-alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
-%!assert(besselh(-alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
+%!assert (besselj (-alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
+%!assert (bessely (-alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
+%!assert (besseli (-alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
+%!assert (besselk (-alpha,x,1), kx*exp(x), 100*eps)
+%!assert (besselh (-alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
+%!assert (besselh (-alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
 %!
 %! # Bessel functions, odd order, complex x
 %!
@@ -863,71 +863,71 @@
 %! ix = -0.6182064685486998097516365709 + 0.4677561094683470065767989920*I;
 %! kx = -0.1568585587733540007867882337 - 0.05185853709490846050505141321*I;
 %!
-%!assert(besselj(alpha,x), jx, 100*eps)
-%!assert(bessely(alpha,x), yx, 100*eps)
-%!assert(besseli(alpha,x), ix, 100*eps)
-%!assert(besselk(alpha,x), kx, 100*eps)
-%!assert(besselh(alpha,1,x), jx + I*yx, 100*eps)
-%!assert(besselh(alpha,2,x), jx - I*yx, 100*eps)
+%!assert (besselj (alpha,x), jx, 100*eps)
+%!assert (bessely (alpha,x), yx, 100*eps)
+%!assert (besseli (alpha,x), ix, 100*eps)
+%!assert (besselk (alpha,x), kx, 100*eps)
+%!assert (besselh (alpha,1,x), jx + I*yx, 100*eps)
+%!assert (besselh (alpha,2,x), jx - I*yx, 100*eps)
 %!
-%!assert(besselj(alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
-%!assert(bessely(alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
-%!assert(besseli(alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
-%!assert(besselk(alpha,x,1), kx*exp(x), 100*eps)
-%!assert(besselh(alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
-%!assert(besselh(alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
+%!assert (besselj (alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
+%!assert (bessely (alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
+%!assert (besseli (alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
+%!assert (besselk (alpha,x,1), kx*exp(x), 100*eps)
+%!assert (besselh (alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
+%!assert (besselh (alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
 %!
-%!assert(besselj(-alpha,x), -jx, 100*eps)
-%!assert(bessely(-alpha,x), -yx, 100*eps)
-%!assert(besseli(-alpha,x), ix, 100*eps)
-%!assert(besselk(-alpha,x), kx, 100*eps)
-%!assert(besselh(-alpha,1,x), -(jx + I*yx), 100*eps)
-%!assert(besselh(-alpha,2,x), -(jx - I*yx), 100*eps)
+%!assert (besselj (-alpha,x), -jx, 100*eps)
+%!assert (bessely (-alpha,x), -yx, 100*eps)
+%!assert (besseli (-alpha,x), ix, 100*eps)
+%!assert (besselk (-alpha,x), kx, 100*eps)
+%!assert (besselh (-alpha,1,x), -(jx + I*yx), 100*eps)
+%!assert (besselh (-alpha,2,x), -(jx - I*yx), 100*eps)
 %!
-%!assert(besselj(-alpha,x,1), -jx*exp(-abs(imag(x))), 100*eps)
-%!assert(bessely(-alpha,x,1), -yx*exp(-abs(imag(x))), 100*eps)
-%!assert(besseli(-alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
-%!assert(besselk(-alpha,x,1), kx*exp(x), 100*eps)
-%!assert(besselh(-alpha,1,x,1), -(jx + I*yx)*exp(-I*x), 100*eps)
-%!assert(besselh(-alpha,2,x,1), -(jx - I*yx)*exp(I*x), 100*eps)
+%!assert (besselj (-alpha,x,1), -jx*exp(-abs(imag(x))), 100*eps)
+%!assert (bessely (-alpha,x,1), -yx*exp(-abs(imag(x))), 100*eps)
+%!assert (besseli (-alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
+%!assert (besselk (-alpha,x,1), kx*exp(x), 100*eps)
+%!assert (besselh (-alpha,1,x,1), -(jx + I*yx)*exp(-I*x), 100*eps)
+%!assert (besselh (-alpha,2,x,1), -(jx - I*yx)*exp(I*x), 100*eps)
 %!
 %! # Bessel functions, fractional order, complex x
 %!
-%! alpha = 3.5; x = 1.75 + 4.125 * I;
+%! alpha = 3.5;  x = 1.75 + 4.125 * I;
 %! jx = -3.018566131370455929707009100 - 0.7585648436793900607704057611*I;
 %! yx = 0.7772278839106298215614791107 - 3.018518722313849782683792010*I;
 %! ix = 0.2100873577220057189038160913 - 0.6551765604618246531254970926*I;
 %! kx = 0.1757147290513239935341488069 + 0.08772348296883849205562558311*I;
 %!
-%!assert(besselj(alpha,x), jx, 100*eps)
-%!assert(bessely(alpha,x), yx, 100*eps)
-%!assert(besseli(alpha,x), ix, 100*eps)
-%!assert(besselk(alpha,x), kx, 100*eps)
-%!assert(besselh(alpha,1,x), jx + I*yx, 100*eps)
-%!assert(besselh(alpha,2,x), jx - I*yx, 100*eps)
+%!assert (besselj (alpha,x), jx, 100*eps)
+%!assert (bessely (alpha,x), yx, 100*eps)
+%!assert (besseli (alpha,x), ix, 100*eps)
+%!assert (besselk (alpha,x), kx, 100*eps)
+%!assert (besselh (alpha,1,x), jx + I*yx, 100*eps)
+%!assert (besselh (alpha,2,x), jx - I*yx, 100*eps)
 %!
-%!assert(besselj(alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
-%!assert(bessely(alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
-%!assert(besseli(alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
-%!assert(besselk(alpha,x,1), kx*exp(x), 100*eps)
-%!assert(besselh(alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
-%!assert(besselh(alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
+%!assert (besselj (alpha,x,1), jx*exp(-abs(imag(x))), 100*eps)
+%!assert (bessely (alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
+%!assert (besseli (alpha,x,1), ix*exp(-abs(real(x))), 100*eps)
+%!assert (besselk (alpha,x,1), kx*exp(x), 100*eps)
+%!assert (besselh (alpha,1,x,1), (jx + I*yx)*exp(-I*x), 100*eps)
+%!assert (besselh (alpha,2,x,1), (jx - I*yx)*exp(I*x), 100*eps)
 %!
 %!  nix = 0.09822388691172060573913739253 - 0.7110230642207380127317227407*I;
 %!
-%!assert(besselj(-alpha,x), yx, 100*eps)
-%!assert(bessely(-alpha,x), -jx, 100*eps)
-%!assert(besseli(-alpha,x), nix, 100*eps)
-%!assert(besselk(-alpha,x), kx, 100*eps)
-%!assert(besselh(-alpha,1,x), -I*(jx + I*yx), 100*eps)
-%!assert(besselh(-alpha,2,x), I*(jx - I*yx), 100*eps)
+%!assert (besselj (-alpha,x), yx, 100*eps)
+%!assert (bessely (-alpha,x), -jx, 100*eps)
+%!assert (besseli (-alpha,x), nix, 100*eps)
+%!assert (besselk (-alpha,x), kx, 100*eps)
+%!assert (besselh (-alpha,1,x), -I*(jx + I*yx), 100*eps)
+%!assert (besselh (-alpha,2,x), I*(jx - I*yx), 100*eps)
 %!
-%!assert(besselj(-alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
-%!assert(bessely(-alpha,x,1), -jx*exp(-abs(imag(x))), 100*eps)
-%!assert(besseli(-alpha,x,1), nix*exp(-abs(real(x))), 100*eps)
-%!assert(besselk(-alpha,x,1), kx*exp(x), 100*eps)
-%!assert(besselh(-alpha,1,x,1), -I*(jx + I*yx)*exp(-I*x), 100*eps)
-%!assert(besselh(-alpha,2,x,1), I*(jx - I*yx)*exp(I*x), 100*eps)
+%!assert (besselj (-alpha,x,1), yx*exp(-abs(imag(x))), 100*eps)
+%!assert (bessely (-alpha,x,1), -jx*exp(-abs(imag(x))), 100*eps)
+%!assert (besseli (-alpha,x,1), nix*exp(-abs(real(x))), 100*eps)
+%!assert (besselk (-alpha,x,1), kx*exp(x), 100*eps)
+%!assert (besselh (-alpha,1,x,1), -I*(jx + I*yx)*exp(-I*x), 100*eps)
+%!assert (besselh (-alpha,2,x,1), I*(jx - I*yx)*exp(I*x), 100*eps)
 
 
 Tests contributed by Robert T. Short.
@@ -973,7 +973,7 @@
 %!       [-0.014224472826781,  0.2051040386,  0.0415716780];
 %!       [-0.103110398228686, -0.1634199694,  0.0844338303]];
 %!
-%! Yt = [[-Inf,          -Inf,         -Inf         ];
+%! Yt = [[-Inf,          -Inf,          -Inf        ];
 %!       [ 0.4980703596,  0.1459181380, -0.38133585 ];
 %!       [-0.3085176252,  0.1478631434,  0.36766288 ];
 %!       [ 0.1173132861, -0.2591285105, -0.18641422 ];
@@ -982,51 +982,51 @@
 %!       [ 0.2054642960,  0.0210736280, -0.20265448 ];
 %!       [-0.1604111925,  0.0985727987,  0.17167666 ]];
 %!
-%! J = besselj(n,z);
-%! Y = bessely(n,z);
-%! assert(Jt(:,1), J(:,1), 0.5e-10);
-%! assert(Yt(:,1), Y(:,1), 0.5e-10);
-%! assert(Jt(:,2:3), J(:,2:3), 0.5e-10);
+%! J = besselj (n,z);
+%! Y = bessely (n,z);
+%! assert (Jt(:,1), J(:,1), 0.5e-10);
+%! assert (Yt(:,1), Y(:,1), 0.5e-10);
+%! assert (Jt(:,2:3), J(:,2:3), 0.5e-10);
 
 Table 9.2 - J and Y for integer orders 3-9.
 
 %!test
-%!  n = (3:9);
-%!  z = (0:2:20).';
+%! n = (3:9);
+%! z = (0:2:20).';
 %!
-%!  Jt = [[ 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00];
-%!        [ 1.2894e-01, 3.3996e-02, 7.0396e-03, 1.2024e-03, 1.7494e-04, 2.2180e-05, 2.4923e-06];
-%!        [ 4.3017e-01, 2.8113e-01, 1.3209e-01, 4.9088e-02, 1.5176e-02, 4.0287e-03, 9.3860e-04];
-%!        [ 1.1477e-01, 3.5764e-01, 3.6209e-01, 2.4584e-01, 1.2959e-01, 5.6532e-02, 2.1165e-02];
-%!        [-2.9113e-01,-1.0536e-01, 1.8577e-01, 3.3758e-01, 3.2059e-01, 2.2345e-01, 1.2632e-01];
-%!        [ 5.8379e-02,-2.1960e-01,-2.3406e-01,-1.4459e-02, 2.1671e-01, 3.1785e-01, 2.9186e-01];
-%!        [ 1.9514e-01, 1.8250e-01,-7.3471e-02,-2.4372e-01,-1.7025e-01, 4.5095e-02, 2.3038e-01];
-%!        [-1.7681e-01, 7.6244e-02, 2.2038e-01, 8.1168e-02,-1.5080e-01,-2.3197e-01,-1.1431e-01];
-%!        [-4.3847e-02,-2.0264e-01,-5.7473e-02, 1.6672e-01, 1.8251e-01,-7.0211e-03,-1.8953e-01];
-%!        [ 1.8632e-01, 6.9640e-02,-1.5537e-01,-1.5596e-01, 5.1399e-02, 1.9593e-01, 1.2276e-01];
-%!        [-9.8901e-02, 1.3067e-01, 1.5117e-01,-5.5086e-02,-1.8422e-01,-7.3869e-02, 1.2513e-01]];
+%! Jt = [[ 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00];
+%!       [ 1.2894e-01, 3.3996e-02, 7.0396e-03, 1.2024e-03, 1.7494e-04, 2.2180e-05, 2.4923e-06];
+%!       [ 4.3017e-01, 2.8113e-01, 1.3209e-01, 4.9088e-02, 1.5176e-02, 4.0287e-03, 9.3860e-04];
+%!       [ 1.1477e-01, 3.5764e-01, 3.6209e-01, 2.4584e-01, 1.2959e-01, 5.6532e-02, 2.1165e-02];
+%!       [-2.9113e-01,-1.0536e-01, 1.8577e-01, 3.3758e-01, 3.2059e-01, 2.2345e-01, 1.2632e-01];
+%!       [ 5.8379e-02,-2.1960e-01,-2.3406e-01,-1.4459e-02, 2.1671e-01, 3.1785e-01, 2.9186e-01];
+%!       [ 1.9514e-01, 1.8250e-01,-7.3471e-02,-2.4372e-01,-1.7025e-01, 4.5095e-02, 2.3038e-01];
+%!       [-1.7681e-01, 7.6244e-02, 2.2038e-01, 8.1168e-02,-1.5080e-01,-2.3197e-01,-1.1431e-01];
+%!       [-4.3847e-02,-2.0264e-01,-5.7473e-02, 1.6672e-01, 1.8251e-01,-7.0211e-03,-1.8953e-01];
+%!       [ 1.8632e-01, 6.9640e-02,-1.5537e-01,-1.5596e-01, 5.1399e-02, 1.9593e-01, 1.2276e-01];
+%!       [-9.8901e-02, 1.3067e-01, 1.5117e-01,-5.5086e-02,-1.8422e-01,-7.3869e-02, 1.2513e-01]];
 %!
-%!  Yt = [[       -Inf,       -Inf,       -Inf,       -Inf,       -Inf,       -Inf,       -Inf];
-%!        [-1.1278e+00,-2.7659e+00,-9.9360e+00,-4.6914e+01,-2.7155e+02,-1.8539e+03,-1.4560e+04];
-%!        [-1.8202e-01,-4.8894e-01,-7.9585e-01,-1.5007e+00,-3.7062e+00,-1.1471e+01,-4.2178e+01];
-%!        [ 3.2825e-01, 9.8391e-02,-1.9706e-01,-4.2683e-01,-6.5659e-01,-1.1052e+00,-2.2907e+00];
-%!        [ 2.6542e-02, 2.8294e-01, 2.5640e-01, 3.7558e-02,-2.0006e-01,-3.8767e-01,-5.7528e-01];
-%!        [-2.5136e-01,-1.4495e-01, 1.3540e-01, 2.8035e-01, 2.0102e-01, 1.0755e-03,-1.9930e-01];
-%!        [ 1.2901e-01,-1.5122e-01,-2.2982e-01,-4.0297e-02, 1.8952e-01, 2.6140e-01, 1.5902e-01];
-%!        [ 1.2350e-01, 2.0393e-01,-6.9717e-03,-2.0891e-01,-1.7209e-01, 3.6816e-02, 2.1417e-01];
-%!        [-1.9637e-01,-7.3222e-05, 1.9633e-01, 1.2278e-01,-1.0425e-01,-2.1399e-01,-1.0975e-01];
-%!        [ 3.3724e-02,-1.7722e-01,-1.1249e-01, 1.1472e-01, 1.8897e-01, 3.2253e-02,-1.6030e-01];
-%!        [ 1.4967e-01, 1.2409e-01,-1.0004e-01,-1.7411e-01,-4.4312e-03, 1.7101e-01, 1.4124e-01]];
+%! Yt = [[       -Inf,       -Inf,       -Inf,       -Inf,       -Inf,       -Inf,       -Inf];
+%!       [-1.1278e+00,-2.7659e+00,-9.9360e+00,-4.6914e+01,-2.7155e+02,-1.8539e+03,-1.4560e+04];
+%!       [-1.8202e-01,-4.8894e-01,-7.9585e-01,-1.5007e+00,-3.7062e+00,-1.1471e+01,-4.2178e+01];
+%!       [ 3.2825e-01, 9.8391e-02,-1.9706e-01,-4.2683e-01,-6.5659e-01,-1.1052e+00,-2.2907e+00];
+%!       [ 2.6542e-02, 2.8294e-01, 2.5640e-01, 3.7558e-02,-2.0006e-01,-3.8767e-01,-5.7528e-01];
+%!       [-2.5136e-01,-1.4495e-01, 1.3540e-01, 2.8035e-01, 2.0102e-01, 1.0755e-03,-1.9930e-01];
+%!       [ 1.2901e-01,-1.5122e-01,-2.2982e-01,-4.0297e-02, 1.8952e-01, 2.6140e-01, 1.5902e-01];
+%!       [ 1.2350e-01, 2.0393e-01,-6.9717e-03,-2.0891e-01,-1.7209e-01, 3.6816e-02, 2.1417e-01];
+%!       [-1.9637e-01,-7.3222e-05, 1.9633e-01, 1.2278e-01,-1.0425e-01,-2.1399e-01,-1.0975e-01];
+%!       [ 3.3724e-02,-1.7722e-01,-1.1249e-01, 1.1472e-01, 1.8897e-01, 3.2253e-02,-1.6030e-01];
+%!       [ 1.4967e-01, 1.2409e-01,-1.0004e-01,-1.7411e-01,-4.4312e-03, 1.7101e-01, 1.4124e-01]];
 %!
-%!  n = (3:9);
-%!  z = (0:2:20).';
-%!  J=besselj(n,z);
-%!  Y=bessely(n,z);
+%! n = (3:9);
+%! z = (0:2:20).';
+%! J = besselj (n,z);
+%! Y = bessely (n,z);
 %!
-%!  assert(J(1,:), zeros (1, columns (J)));
-%!  assert(J(2:end,:), Jt(2:end,:), -5e-5);
-%!  assert(Yt(1,:), Y(1,:));
-%!  assert(Y(2:end,:), Yt(2:end,:), -5e-5);
+%! assert (J(1,:), zeros (1, columns (J)));
+%! assert (J(2:end,:), Jt(2:end,:), -5e-5);
+%! assert (Yt(1,:), Y(1,:));
+%! assert (Y(2:end,:), Yt(2:end,:), -5e-5);
 
 Table 9.4 - J and Y for various integer orders and arguments.
 
@@ -1053,10 +1053,10 @@
 %!
 %! n = [(0:5:20).';30;40;50;100];
 %! z = [1,2,5,10,50,100];
-%! J = besselj(n.',z.').';
-%! Y = bessely(n.',z.').';
-%!  assert(J, Jt, -1e-9);
-%!  assert(Y, Yt, -1e-9);
+%! J = besselj (n.', z.').';
+%! Y = bessely (n.', z.').';
+%! assert (J, Jt, -1e-9);
+%! assert (Y, Yt, -1e-9);
 
 Table 9.8 - I and K for integer orders 0, 1, 2.
 
@@ -1064,20 +1064,20 @@
 %! n  = 0:2;
 %! z1 = [0.1;2.5;5.0];
 %! z2 = [7.5;10.0;15.0;20.0];
-%! rtbl = [ [ 0.9071009258   0.0452984468   0.1251041992   2.6823261023  10.890182683    1.995039646  ];
-%!          [ 0.2700464416   0.2065846495   0.2042345837   0.7595486903   0.9001744239   0.759126289  ];
-%!          [ 0.1835408126   0.1639722669   0.7002245988   0.5478075643   0.6002738588   0.132723593  ];
-%!          [ 0.1483158301   0.1380412115   0.111504840    0.4505236991   0.4796689336   0.57843541   ];
-%!          [ 0.1278333372   0.1212626814   0.103580801    0.3916319344   0.4107665704   0.47378525   ];
-%!          [ 0.1038995314   0.1003741751   0.090516308    0.3210023535   0.3315348950   0.36520701   ];
-%!          [ 0.0897803119   0.0875062222   0.081029690    0.2785448768   0.2854254970   0.30708743   ]];
+%! rtbl = [[ 0.9071009258   0.0452984468   0.1251041992   2.6823261023  10.890182683    1.995039646  ];
+%!         [ 0.2700464416   0.2065846495   0.2042345837   0.7595486903   0.9001744239   0.759126289  ];
+%!         [ 0.1835408126   0.1639722669   0.7002245988   0.5478075643   0.6002738588   0.132723593  ];
+%!         [ 0.1483158301   0.1380412115   0.111504840    0.4505236991   0.4796689336   0.57843541   ];
+%!         [ 0.1278333372   0.1212626814   0.103580801    0.3916319344   0.4107665704   0.47378525   ];
+%!         [ 0.1038995314   0.1003741751   0.090516308    0.3210023535   0.3315348950   0.36520701   ];
+%!         [ 0.0897803119   0.0875062222   0.081029690    0.2785448768   0.2854254970   0.30708743   ]];
 %!
 %! tbl = [besseli(n,z1,1), besselk(n,z1,1)];
-%! tbl(:,3) = tbl(:,3).*(exp(z1).*z1.^(-2));
-%! tbl(:,6) = tbl(:,6).*(exp(-z1).*z1.^(2));
+%! tbl(:,3) = tbl(:,3) .* (exp(z1).*z1.^(-2));
+%! tbl(:,6) = tbl(:,6) .* (exp(-z1).*z1.^(2));
 %! tbl = [tbl;[besseli(n,z2,1),besselk(n,z2,1)]];
 %!
-%! assert(tbl, rtbl, -2e-8);
+%! assert (tbl, rtbl, -2e-8);
 
 Table 9.9 - I and K for orders 3-9.
 
@@ -1094,8 +1094,7 @@
 %!       [  7.3263e-02  6.0059e-02  4.6571e-02  3.4186e-02  2.3780e-02  1.5691e-02  9.8324e-03];
 %!       [  7.1300e-02  5.9640e-02  4.7444e-02  3.5917e-02  2.5894e-02  1.7792e-02  1.1661e-02]];
 %!
-%! Kt = [
-%!      [         Inf         Inf         Inf         Inf         Inf         Inf         Inf];
+%! Kt = [[ Inf         Inf         Inf         Inf         Inf         Inf         Inf];
 %!      [  4.7836e+00  1.6226e+01  6.9687e+01  3.6466e+02  2.2576e+03  1.6168e+04  1.3160e+05];
 %!      [  1.6317e+00  3.3976e+00  8.4268e+00  2.4465e+01  8.1821e+01  3.1084e+02  1.3252e+03];
 %!      [  9.9723e-01  1.6798e+00  3.2370e+00  7.0748e+00  1.7387e+01  4.7644e+01  1.4444e+02];
@@ -1109,13 +1108,13 @@
 %!
 %! n = (3:9);
 %! z = (0:2:20).';
-%! I=besseli(n,z,1);
-%! K=besselk(n,z,1);
+%! I = besseli (n,z,1);
+%! K = besselk (n,z,1);
 %!
-%! assert(abs (I(1,:)), zeros(1, columns(I)));
-%! assert(I(2:end,:), It(2:end,:), -5e-5);
-%! assert(Kt(1,:), K(1,:));
-%! assert(K(2:end,:), Kt(2:end,:), -5e-5);
+%! assert (abs (I(1,:)), zeros (1, columns(I)));
+%! assert (I(2:end,:), It(2:end,:), -5e-5);
+%! assert (Kt(1,:), K(1,:));
+%! assert (K(2:end,:), Kt(2:end,:), -5e-5);
 
 Table 9.11 - I and K for various integer orders and arguments.
 
@@ -1142,24 +1141,24 @@
 %!
 %! n = [(0:5:20).';30;40;50;100];
 %! z = [1,2,5,10,50,100];
-%! I = besseli(n.',z.').';
-%! K = besselk(n.',z.').';
-%! assert(I, It, -5e-9);
-%! assert(K, Kt, -5e-9);
+%! I = besseli (n.', z.').';
+%! K = besselk (n.', z.').';
+%! assert (I, It, -5e-9);
+%! assert (K, Kt, -5e-9);
 
 The next section checks that negative integer orders and positive
 integer orders are appropriately related.
 
 %!test
-%! n=(0:2:20);
-%! assert(besselj(n,1), besselj(-n,1), 1e-8);
-%! assert(-besselj(n+1,1), besselj(-n-1,1), 1e-8);
+%! n = (0:2:20);
+%! assert (besselj (n,1), besselj (-n,1), 1e-8);
+%! assert (-besselj (n+1,1), besselj (-n-1,1), 1e-8);
 
 besseli(n,z) = besseli(-n,z);
 
 %!test
-%! n=(0:2:20);
-%! assert(besseli(n,1), besseli(-n,1), 1e-8);
+%! n = (0:2:20);
+%! assert (besseli (n,1), besseli (-n,1), 1e-8);
 
 Table 10.1 - j and y for integer orders 0, 1, 2.
 Compare against excerpts of Table 10.1, Abramowitz and Stegun.
@@ -1195,7 +1194,7 @@
 
 %!test
 %! n = (3:8);
-%! z = (0:2.5:10).'; z(1)=0.1;
+%! z = (0:2.5:10).';  z(1)=0.1;
 %!
 %! jt = [[ 9.5185e-06  1.0577e-07  9.6163e-10  7.3975e-12  4.9319e-14  2.9012e-16];
 %!       [ 1.0392e-01  3.0911e-02  7.3576e-03  1.4630e-03  2.5009e-04  3.7516e-05];
@@ -1209,11 +1208,11 @@
 %!       [ 1.2705e-01  1.2485e-01  2.2774e-02 -9.1449e-02 -1.8129e-01 -2.7112e-01];
 %!       [-9.5327e-02 -1.6599e-03  9.3834e-02  1.0488e-01  4.2506e-02 -4.1117e-02]];
 %!
-%! j = sqrt((pi/2)./z).*besselj(n+1/2,z);
-%! y = sqrt((pi/2)./z).*bessely(n+1/2,z);
+%! j = sqrt ((pi/2)./z) .* besselj (n+1/2,z);
+%! y = sqrt ((pi/2)./z) .* bessely (n+1/2,z);
 %!
-%! assert(jt, j, -5e-5);
-%! assert(yt, y, -5e-5);
+%! assert (jt, j, -5e-5);
+%! assert (yt, y, -5e-5);
 
 Table 10.4 - j and y for various integer orders and arguments.
 
@@ -1240,11 +1239,8 @@
 %!
 %! n = [(0:5:20).';30;40;50;100];
 %! z = [1,2,5,10,50,100];
-%! j = sqrt((pi/2)./z).*besselj((n+1/2).',z.').';
-%! y = sqrt((pi/2)./z).*bessely((n+1/2).',z.').';
-%! assert(j, jt, -1e-9);
-%! assert(y, yt, -1e-9);
-
-
-
+%! j = sqrt ((pi/2)./z) .* besselj ((n+1/2).', z.').';
+%! y = sqrt ((pi/2)./z) .* bessely ((n+1/2).', z.').';
+%! assert (j, jt, -1e-9);
+%! assert (y, yt, -1e-9);
 */
--- a/src/DLD-FUNCTIONS/betainc.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/betainc.cc	Mon May 07 00:56:44 2012 +0200
@@ -283,50 +283,48 @@
 }
 
 /*
-
 %% test/octave.test/arith/betainc-1.m
 %!test
-%! a=[1, 1.5, 2, 3];
-%! b=[4, 3, 2, 1];
-%! v1=betainc(1,a,b);
-%! v2=[1,1,1,1];
+%! a = [1, 1.5, 2, 3];
+%! b = [4, 3, 2, 1];
+%! v1 = betainc (1,a,b);
+%! v2 = [1,1,1,1];
 %! x = [.2, .4, .6, .8];
-%! v3=betainc(x, a, b);
-%! v4 = 1-betainc(1.-x, b, a);
-%! assert(v1, v2, sqrt(eps));
-%! assert(v3, v4, sqrt(eps));
+%! v3 = betainc (x, a, b);
+%! v4 = 1 - betainc (1.-x, b, a);
+%! assert (v1, v2, sqrt (eps));
+%! assert (v3, v4, sqrt (eps));
 
 %% Single precision
 %!test
-%! a=single ([1, 1.5, 2, 3]);
-%! b=single ([4, 3, 2, 1]);
-%! v1=betainc(1,a,b);
-%! v2=single ([1,1,1,1]);
+%! a = single ([1, 1.5, 2, 3]);
+%! b = single ([4, 3, 2, 1]);
+%! v1 = betainc (1,a,b);
+%! v2 = single ([1,1,1,1]);
 %! x = single ([.2, .4, .6, .8]);
-%! v3=betainc(x, a, b);
-%! v4 = 1-betainc(1.-x, b, a);
-%! assert(v1, v2, sqrt(eps ('single')));
-%! assert(v3, v4, sqrt(eps ('single')));
+%! v3 = betainc (x, a, b);
+%! v4 = 1 - betainc (1.-x, b, a);
+%! assert (v1, v2, sqrt (eps ("single")));
+%! assert (v3, v4, sqrt (eps ("single")));
 
 %% Mixed double/single precision
 %!test
-%! a=single ([1, 1.5, 2, 3]);
-%! b=[4, 3, 2, 1];
-%! v1=betainc(1,a,b);
-%! v2=single ([1,1,1,1]);
+%! a = single ([1, 1.5, 2, 3]);
+%! b = [4, 3, 2, 1];
+%! v1 = betainc (1,a,b);
+%! v2 = single ([1,1,1,1]);
 %! x = [.2, .4, .6, .8];
-%! v3=betainc(x, a, b);
-%! v4 = 1-betainc(1.-x, b, a);
-%! assert(v1, v2, sqrt(eps ('single')));
-%! assert(v3, v4, sqrt(eps ('single')));
+%! v3 = betainc (x, a, b);
+%! v4 = 1-betainc (1.-x, b, a);
+%! assert (v1, v2, sqrt (eps ('single')));
+%! assert (v3, v4, sqrt (eps ('single')));
 
 %% test/octave.test/arith/betainc-2.m
-%!error <Invalid call to betainc> betainc();
+%!error betainc ()
 
 %% test/octave.test/arith/betainc-3.m
-%!error <Invalid call to betainc> betainc(1);
+%!error betainc> betainc (1)
 
 %% test/octave.test/arith/betainc-4.m
-%!error <Invalid call to betainc> betainc(1,2);
-
+%!error betainc> betainc (1,2)
 */
--- a/src/DLD-FUNCTIONS/bsxfun.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/bsxfun.cc	Mon May 07 00:56:44 2012 +0200
@@ -662,17 +662,17 @@
 %! b = mean (a, 1);
 %! c = mean (a, 2);
 %! f = @minus;
-%!error(bsxfun (f));
-%!error(bsxfun (f, a));
-%!error(bsxfun (a, b));
-%!error(bsxfun (a, b, c));
-%!error(bsxfun (f, a, b, c));
-%!error(bsxfun (f, ones(4, 0), ones(4, 4)))
-%!assert(bsxfun (f, ones(4, 0), ones(4, 1)), zeros(4, 0));
-%!assert(bsxfun (f, ones(1, 4), ones(4, 1)), zeros(4, 4));
-%!assert(bsxfun (f, a, b), a - repmat(b, 4, 1));
-%!assert(bsxfun (f, a, c), a - repmat(c, 1, 4));
-%!assert(bsxfun ("minus", ones(1, 4), ones(4, 1)), zeros(4, 4));
+%!error (bsxfun (f))
+%!error (bsxfun (f, a))
+%!error (bsxfun (a, b))
+%!error (bsxfun (a, b, c))
+%!error (bsxfun (f, a, b, c))
+%!error (bsxfun (f, ones (4, 0), ones (4, 4)))
+%!assert (bsxfun (f, ones (4, 0), ones (4, 1)), zeros (4, 0))
+%!assert (bsxfun (f, ones (1, 4), ones (4, 1)), zeros (4, 4))
+%!assert (bsxfun (f, a, b), a - repmat (b, 4, 1))
+%!assert (bsxfun (f, a, c), a - repmat (c, 1, 4))
+%!assert (bsxfun ("minus", ones (1, 4), ones (4, 1)), zeros (4, 4))
 
 %!shared a, b, c, f
 %! a = randn (4, 4);
@@ -680,17 +680,17 @@
 %! b = mean (a, 1);
 %! c = mean (a, 2);
 %! f = @minus;
-%!error(bsxfun (f));
-%!error(bsxfun (f, a));
-%!error(bsxfun (a, b));
-%!error(bsxfun (a, b, c));
-%!error(bsxfun (f, a, b, c));
-%!error(bsxfun (f, ones(4, 0), ones(4, 4)))
-%!assert(bsxfun (f, ones(4, 0), ones(4, 1)), zeros(4, 0));
-%!assert(bsxfun (f, ones(1, 4), ones(4, 1)), zeros(4, 4));
-%!assert(bsxfun (f, a, b), a - repmat(b, 4, 1));
-%!assert(bsxfun (f, a, c), a - repmat(c, 1, 4));
-%!assert(bsxfun ("minus", ones(1, 4), ones(4, 1)), zeros(4, 4));
+%!error (bsxfun (f))
+%!error (bsxfun (f, a))
+%!error (bsxfun (a, b))
+%!error (bsxfun (a, b, c))
+%!error (bsxfun (f, a, b, c))
+%!error (bsxfun (f, ones (4, 0), ones (4, 4)))
+%!assert (bsxfun (f, ones (4, 0), ones (4, 1)), zeros (4, 0))
+%!assert (bsxfun (f, ones (1, 4), ones (4, 1)), zeros (4, 4))
+%!assert (bsxfun (f, a, b), a - repmat (b, 4, 1))
+%!assert (bsxfun (f, a, c), a - repmat (c, 1, 4))
+%!assert (bsxfun ("minus", ones (1, 4), ones (4, 1)), zeros (4, 4))
 
 %!shared a, b, c, f
 %! a = randn (4, 4);
@@ -698,33 +698,33 @@
 %! b = mean (a, 1);
 %! c = mean (a, 2);
 %! f = @minus;
-%!error(bsxfun (f));
-%!error(bsxfun (f, a));
-%!error(bsxfun (a, b));
-%!error(bsxfun (a, b, c));
-%!error(bsxfun (f, a, b, c));
-%!error(bsxfun (f, ones(4, 0), ones(4, 4)))
-%!assert(bsxfun (f, ones(4, 0), ones(4, 1)), zeros(4, 0));
-%!assert(bsxfun (f, ones(1, 4), ones(4, 1)), zeros(4, 4));
-%!assert(bsxfun (f, a, b), a - repmat(b, 4, 1));
-%!assert(bsxfun (f, a, c), a - repmat(c, 1, 4));
-%!assert(bsxfun ("minus", ones(1, 4), ones(4, 1)), zeros(4, 4));
+%!error (bsxfun (f))
+%!error (bsxfun (f, a))
+%!error (bsxfun (a, b))
+%!error (bsxfun (a, b, c))
+%!error (bsxfun (f, a, b, c))
+%!error (bsxfun (f, ones (4, 0), ones (4, 4)))
+%!assert (bsxfun (f, ones (4, 0), ones (4, 1)), zeros (4, 0))
+%!assert (bsxfun (f, ones (1, 4), ones (4, 1)), zeros (4, 4))
+%!assert (bsxfun (f, a, b), a - repmat (b, 4, 1))
+%!assert (bsxfun (f, a, c), a - repmat (c, 1, 4))
+%!assert (bsxfun ("minus", ones (1, 4), ones (4, 1)), zeros (4, 4))
 
 %!shared a, b, c, f
 %! a = randn (4, 4);
 %! b = a (1, :);
 %! c = a (:, 1);
 %! f = @(x, y) x == y;
-%!error(bsxfun (f));
-%!error(bsxfun (f, a));
-%!error(bsxfun (a, b));
-%!error(bsxfun (a, b, c));
-%!error(bsxfun (f, a, b, c));
-%!error(bsxfun (f, ones(4, 0), ones(4, 4)))
-%!assert(bsxfun (f, ones(4, 0), ones(4, 1)), zeros(4, 0, "logical"));
-%!assert(bsxfun (f, ones(1, 4), ones(4, 1)), ones(4, 4, "logical"));
-%!assert(bsxfun (f, a, b), a == repmat(b, 4, 1));
-%!assert(bsxfun (f, a, c), a == repmat(c, 1, 4));
+%!error (bsxfun (f))
+%!error (bsxfun (f, a))
+%!error (bsxfun (a, b))
+%!error (bsxfun (a, b, c))
+%!error (bsxfun (f, a, b, c))
+%!error (bsxfun (f, ones (4, 0), ones (4, 4)))
+%!assert (bsxfun (f, ones (4, 0), ones (4, 1)), zeros (4, 0, "logical"))
+%!assert (bsxfun (f, ones (1, 4), ones (4, 1)), ones (4, 4, "logical"))
+%!assert (bsxfun (f, a, b), a == repmat (b, 4, 1))
+%!assert (bsxfun (f, a, c), a == repmat (c, 1, 4))
 
 %!shared a, b, c, d, f
 %! a = randn (4, 4, 4);
@@ -732,43 +732,43 @@
 %! c = mean (a, 2);
 %! d = mean (a, 3);
 %! f = @minus;
-%!error(bsxfun (f, ones([4, 0, 4]), ones([4, 4, 4])));
-%!assert(bsxfun (f, ones([4, 0, 4]), ones([4, 1, 4])), zeros([4, 0, 4]));
-%!assert(bsxfun (f, ones([4, 4, 0]), ones([4, 1, 1])), zeros([4, 4, 0]));
-%!assert(bsxfun (f, ones([1, 4, 4]), ones([4, 1, 4])), zeros([4, 4, 4]));
-%!assert(bsxfun (f, ones([4, 4, 1]), ones([4, 1, 4])), zeros([4, 4, 4]));
-%!assert(bsxfun (f, ones([4, 1, 4]), ones([1, 4, 4])), zeros([4, 4, 4]));
-%!assert(bsxfun (f, ones([4, 1, 4]), ones([1, 4, 1])), zeros([4, 4, 4]));
-%!assert(bsxfun (f, a, b), a - repmat(b, [4, 1, 1]));
-%!assert(bsxfun (f, a, c), a - repmat(c, [1, 4, 1]));
-%!assert(bsxfun (f, a, d), a - repmat(d, [1, 1, 4]));
-%!assert(bsxfun ("minus", ones([4, 0, 4]), ones([4, 1, 4])), zeros([4, 0, 4]));
+%!error (bsxfun (f, ones ([4, 0, 4]), ones ([4, 4, 4])))
+%!assert (bsxfun (f, ones ([4, 0, 4]), ones ([4, 1, 4])), zeros ([4, 0, 4]))
+%!assert (bsxfun (f, ones ([4, 4, 0]), ones ([4, 1, 1])), zeros ([4, 4, 0]))
+%!assert (bsxfun (f, ones ([1, 4, 4]), ones ([4, 1, 4])), zeros ([4, 4, 4]))
+%!assert (bsxfun (f, ones ([4, 4, 1]), ones ([4, 1, 4])), zeros ([4, 4, 4]))
+%!assert (bsxfun (f, ones ([4, 1, 4]), ones ([1, 4, 4])), zeros ([4, 4, 4]))
+%!assert (bsxfun (f, ones ([4, 1, 4]), ones ([1, 4, 1])), zeros ([4, 4, 4]))
+%!assert (bsxfun (f, a, b), a - repmat (b, [4, 1, 1]))
+%!assert (bsxfun (f, a, c), a - repmat (c, [1, 4, 1]))
+%!assert (bsxfun (f, a, d), a - repmat (d, [1, 1, 4]))
+%!assert (bsxfun ("minus", ones ([4, 0, 4]), ones ([4, 1, 4])), zeros ([4, 0, 4]))
 
-%% The below is a very hard case to treat
-%!assert(bsxfun (f, ones([4, 1, 4, 1]), ones([1, 4, 1, 4])), zeros([4, 4, 4, 4]));
+%% The test below is a very hard case to treat
+%!assert (bsxfun (f, ones ([4, 1, 4, 1]), ones ([1, 4, 1, 4])), zeros ([4, 4, 4, 4]));
 
 %!shared a, b, aa, bb
 %! a = randn (3, 1, 3);
 %! aa = a(:, ones (1, 3), :, ones (1, 3));
 %! b = randn (1, 3, 3, 3);
 %! bb = b(ones (1, 3), :, :, :);
-%!assert (bsxfun (@plus, a, b), aa + bb);
-%!assert (bsxfun (@minus, a, b), aa - bb);
-%!assert (bsxfun (@times, a, b), aa .* bb);
-%!assert (bsxfun (@rdivide, a, b), aa ./ bb);
-%!assert (bsxfun (@ldivide, a, b), aa .\ bb);
-%!assert (bsxfun (@power, a, b), aa .^ bb);
-%!assert (bsxfun (@power, abs (a), b), abs (aa) .^ bb);
-%!assert (bsxfun (@eq, round (a), round (b)), round (aa) == round (bb));
-%!assert (bsxfun (@ne, round (a), round (b)), round (aa) != round (bb));
-%!assert (bsxfun (@lt, a, b), aa < bb);
-%!assert (bsxfun (@le, a, b), aa <= bb);
-%!assert (bsxfun (@gt, a, b), aa > bb);
-%!assert (bsxfun (@ge, a, b), aa >= bb);
-%!assert (bsxfun (@min, a, b), min (aa, bb));
-%!assert (bsxfun (@max, a, b), max (aa, bb));
-%!assert (bsxfun (@and, a > 0, b > 0), (aa > 0) & (bb > 0));
-%!assert (bsxfun (@or, a > 0, b > 0), (aa > 0) | (bb > 0));
+%!assert (bsxfun (@plus, a, b), aa + bb)
+%!assert (bsxfun (@minus, a, b), aa - bb)
+%!assert (bsxfun (@times, a, b), aa .* bb)
+%!assert (bsxfun (@rdivide, a, b), aa ./ bb)
+%!assert (bsxfun (@ldivide, a, b), aa .\ bb)
+%!assert (bsxfun (@power, a, b), aa .^ bb)
+%!assert (bsxfun (@power, abs (a), b), abs (aa) .^ bb)
+%!assert (bsxfun (@eq, round (a), round (b)), round (aa) == round (bb))
+%!assert (bsxfun (@ne, round (a), round (b)), round (aa) != round (bb))
+%!assert (bsxfun (@lt, a, b), aa < bb)
+%!assert (bsxfun (@le, a, b), aa <= bb)
+%!assert (bsxfun (@gt, a, b), aa > bb)
+%!assert (bsxfun (@ge, a, b), aa >= bb)
+%!assert (bsxfun (@min, a, b), min (aa, bb))
+%!assert (bsxfun (@max, a, b), max (aa, bb))
+%!assert (bsxfun (@and, a > 0, b > 0), (aa > 0) & (bb > 0))
+%!assert (bsxfun (@or, a > 0, b > 0), (aa > 0) | (bb > 0))
 
 %% Test automatic bsxfun
 %
@@ -779,10 +779,10 @@
 %!
 %! float_types = {@single, @double};
 %! int_types = {@int8, @int16, @int32, @int64, \
-%!             @uint8, @uint16, @uint32, @uint64};
+%!              @uint8, @uint16, @uint32, @uint64};
 %!
-%! x = rand (3)*10-5;
-%! y = rand (3,1)*10-5;
+%! x = rand (3) * 10-5;
+%! y = rand (3,1) * 10-5;
 %!
 %! for i=1:length (funs)
 %!   for j = 1:length(float_types)
--- a/src/DLD-FUNCTIONS/cellfun.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/cellfun.cc	Mon May 07 00:56:44 2012 +0200
@@ -712,301 +712,302 @@
 /*
 
 %!function r = __f11 (x)
-%!  global __cellfun_test_num_outputs__
+%!  global __cellfun_test_num_outputs__;
 %!  __cellfun_test_num_outputs__ = nargout;
 %!  r = x;
 %!endfunction
 
 %!function __f01 (x)
-%!  global __cellfun_test_num_outputs__
+%!  global __cellfun_test_num_outputs__;
 %!  __cellfun_test_num_outputs__ = nargout;
 %!endfunction
 
 %!test
-%! global __cellfun_test_num_outputs__
+%! global __cellfun_test_num_outputs__;
 %! cellfun (@__f11, {1});
-%! assert (__cellfun_test_num_outputs__, 0)
+%! assert (__cellfun_test_num_outputs__, 0);
 %! x = cellfun (@__f11, {1});
-%! assert (__cellfun_test_num_outputs__, 1)
+%! assert (__cellfun_test_num_outputs__, 1);
 
 %!test
-%! global __cellfun_test_num_outputs__
+%! global __cellfun_test_num_outputs__;
 %! cellfun (@__f01, {1});
-%! assert (__cellfun_test_num_outputs__, 0)
+%! assert (__cellfun_test_num_outputs__, 0);
 
 %!error x = cellfun (@__f01, {1, 2});
 
 %!test
-%! assert (cellfun (@__f11, {1, 2}), [1, 2])
-%! assert (cellfun (@__f11, {1, 2}, 'uniformoutput', false), {1, 2})
+%! assert (cellfun (@__f11, {1, 2}), [1, 2]);
+%! assert (cellfun (@__f11, {1, 2}, 'uniformoutput', false), {1, 2});
 
 %!test
-%!  [a,b] = cellfun (@(x) x, cell (2, 0));
-%!  assert (a, zeros (2, 0));
-%!  assert (b, zeros (2, 0));
+%! [a,b] = cellfun (@(x) x, cell (2, 0));
+%! assert (a, zeros (2, 0));
+%! assert (b, zeros (2, 0));
 
 %!test
-%!  [a,b] = cellfun (@(x) x, cell (2, 0), "uniformoutput", false);
-%!  assert (a, cell (2, 0));
-%!  assert (b, cell (2, 0));
+%! [a,b] = cellfun (@(x) x, cell (2, 0), "uniformoutput", false);
+%! assert (a, cell (2, 0));
+%! assert (b, cell (2, 0));
 
 %% Test function to check the "Errorhandler" option
-%!function [z] = __cellfunerror (S, varargin)
+%!function z = __cellfunerror (S, varargin)
 %!  z = S;
 %!endfunction
 
 %% First input argument can be a string, an inline function,
 %% a function_handle or an anonymous function
 %!test
-%!  A = cellfun ("islogical", {true, 0.1, false, i*2});
-%!  assert (A, [true, false, true, false]);
+%! A = cellfun ("islogical", {true, 0.1, false, i*2});
+%! assert (A, [true, false, true, false]);
 %!test
-%!  A = cellfun (inline ("islogical (x)", "x"), {true, 0.1, false, i*2});
-%!  assert (A, [true, false, true, false]);
+%! A = cellfun (inline ("islogical (x)", "x"), {true, 0.1, false, i*2});
+%! assert (A, [true, false, true, false]);
 %!test
-%!  A = cellfun (@islogical, {true, 0.1, false, i*2});
-%!  assert (A, [true, false, true, false]);
+%! A = cellfun (@islogical, {true, 0.1, false, i*2});
+%! assert (A, [true, false, true, false]);
 %!test
-%!  A = cellfun (@(x) islogical(x), {true, 0.1, false, i*2});
-%!  assert (A, [true, false, true, false]);
+%! A = cellfun (@(x) islogical(x), {true, 0.1, false, i*2});
+%! assert (A, [true, false, true, false]);
 
 %% First input argument can be the special string "isreal",
 %% "isempty", "islogical", "length", "ndims" or "prodofsize"
 %!test
-%!  A = cellfun ("isreal", {true, 0.1, {}, i*2, [], "abc"});
-%!  assert (A, [true, true, false, false, true, true]);
+%! A = cellfun ("isreal", {true, 0.1, {}, i*2, [], "abc"});
+%! assert (A, [true, true, false, false, true, true]);
 %!test
-%!  A = cellfun ("isempty", {true, 0.1, false, i*2, [], "abc"});
-%!  assert (A, [false, false, false, false, true, false]);
+%! A = cellfun ("isempty", {true, 0.1, false, i*2, [], "abc"});
+%! assert (A, [false, false, false, false, true, false]);
 %!test
-%!  A = cellfun ("islogical", {true, 0.1, false, i*2, [], "abc"});
-%!  assert (A, [true, false, true, false, false, false]);
+%! A = cellfun ("islogical", {true, 0.1, false, i*2, [], "abc"});
+%! assert (A, [true, false, true, false, false, false]);
 %!test
-%!  A = cellfun ("length", {true, 0.1, false, i*2, [], "abc"});
-%!  assert (A, [1, 1, 1, 1, 0, 3]);
+%! A = cellfun ("length", {true, 0.1, false, i*2, [], "abc"});
+%! assert (A, [1, 1, 1, 1, 0, 3]);
 %!test
-%!  A = cellfun ("ndims", {[1, 2; 3, 4]; (cell (1,2,3,4))});
-%!  assert (A, [2; 4]);
+%! A = cellfun ("ndims", {[1, 2; 3, 4]; (cell (1,2,3,4))});
+%! assert (A, [2; 4]);
 %!test
-%!  A = cellfun ("prodofsize", {[1, 2; 3, 4], (cell (1,2,3,4))});
-%!  assert (A, [4, 24]);
+%! A = cellfun ("prodofsize", {[1, 2; 3, 4], (cell (1,2,3,4))});
+%! assert (A, [4, 24]);
 
 %% Number of input and output arguments may not be limited to one
 %!test
-%!  A = cellfun (@(x,y,z) x + y + z, {1, 1, 1}, {2, 2, 2}, {3, 4, 5});
-%!  assert (A, [6, 7, 8]);
+%! A = cellfun (@(x,y,z) x + y + z, {1, 1, 1}, {2, 2, 2}, {3, 4, 5});
+%! assert (A, [6, 7, 8]);
 %!test
-%!  A = cellfun (@(x,y,z) x + y + z, {1, 1, 1}, {2, 2, 2}, {3, 4, 5}, \
-%!    "UniformOutput", false);
-%!  assert (A, {6, 7, 8});
+%! A = cellfun (@(x,y,z) x + y + z, {1, 1, 1}, {2, 2, 2}, {3, 4, 5}, \
+%!              "UniformOutput", false);
+%! assert (A, {6, 7, 8});
 %!test %% Two input arguments of different types
-%!  A = cellfun (@(x,y) islogical (x) && ischar (y), {false, true}, {"a", 3});
-%!  assert (A, [true, false]);
+%! A = cellfun (@(x,y) islogical (x) && ischar (y), {false, true}, {"a", 3});
+%! assert (A, [true, false]);
 %!test %% Pass another variable to the anonymous function
-%!  y = true; A = cellfun (@(x) islogical (x) && y, {false, 0.3});
-%!  assert (A, [true, false]);
+%! y = true;
+%! A = cellfun (@(x) islogical (x) && y, {false, 0.3});
+%! assert (A, [true, false]);
 %!test %% Three ouptut arguments of different type
-%!  [A, B, C] = cellfun (@find, {10, 11; 0, 12}, "UniformOutput", false);
-%!  assert (isequal (A, {true, true; [], true}));
-%!  assert (isequal (B, {true, true; [], true}));
-%!  assert (isequal (C, {10, 11; [], 12}));
+%! [A, B, C] = cellfun (@find, {10, 11; 0, 12}, "UniformOutput", false);
+%! assert (isequal (A, {true, true; [], true}));
+%! assert (isequal (B, {true, true; [], true}));
+%! assert (isequal (C, {10, 11; [], 12}));
 
 %% Input arguments can be of type cell array of logical
 %!test
-%!  A = cellfun (@(x,y) x == y, {false, true}, {true, true});
-%!  assert (A, [false, true]);
+%! A = cellfun (@(x,y) x == y, {false, true}, {true, true});
+%! assert (A, [false, true]);
 %!test
-%!  A = cellfun (@(x,y) x == y, {false; true}, {true; true}, \
-%!    "UniformOutput", true);
-%!  assert (A, [false; true]);
+%! A = cellfun (@(x,y) x == y, {false; true}, {true; true}, \
+%!              "UniformOutput", true);
+%! assert (A, [false; true]);
 %!test
-%!  A = cellfun (@(x) x, {false, true; false, true}, "UniformOutput", false);
-%!  assert (A, {false, true; false, true});
+%! A = cellfun (@(x) x, {false, true; false, true}, "UniformOutput", false);
+%! assert (A, {false, true; false, true});
 %!test %% Three ouptut arguments of same type
-%!  [A, B, C] = cellfun (@find, {true, false; false, true}, \
-%!    "UniformOutput", false);
-%!  assert (isequal (A, {true, []; [], true}));
-%!  assert (isequal (B, {true, []; [], true}));
-%!  assert (isequal (C, {true, []; [], true}));
+%! [A, B, C] = cellfun (@find, {true, false; false, true}, \
+%!                      "UniformOutput", false);
+%! assert (isequal (A, {true, []; [], true}));
+%! assert (isequal (B, {true, []; [], true}));
+%! assert (isequal (C, {true, []; [], true}));
 %!test
-%!  A = cellfun (@(x,y) cell2str (x,y), {true}, {true}, \
-%!    "ErrorHandler", @__cellfunerror);
-%!  assert (isfield (A, "identifier"), true);
-%!  assert (isfield (A, "message"), true);
-%!  assert (isfield (A, "index"), true);
-%!  assert (isempty (A.message), false);
-%!  assert (A.index, 1);
+%! A = cellfun (@(x,y) cell2str (x,y), {true}, {true}, \
+%!              "ErrorHandler", @__cellfunerror);
+%! assert (isfield (A, "identifier"), true);
+%! assert (isfield (A, "message"), true);
+%! assert (isfield (A, "index"), true);
+%! assert (isempty (A.message), false);
+%! assert (A.index, 1);
 %!test %% Overwriting setting of "UniformOutput" true
-%!  A = cellfun (@(x,y) cell2str (x,y), {true}, {true}, \
-%!    "UniformOutput", true, "ErrorHandler", @__cellfunerror);
-%!  assert (isfield (A, "identifier"), true);
-%!  assert (isfield (A, "message"), true);
-%!  assert (isfield (A, "index"), true);
-%!  assert (isempty (A.message), false);
-%!  assert (A.index, 1);
+%! A = cellfun (@(x,y) cell2str (x,y), {true}, {true}, \
+%!              "UniformOutput", true, "ErrorHandler", @__cellfunerror);
+%! assert (isfield (A, "identifier"), true);
+%! assert (isfield (A, "message"), true);
+%! assert (isfield (A, "index"), true);
+%! assert (isempty (A.message), false);
+%! assert (A.index, 1);
 
 %% Input arguments can be of type cell array of numeric
 %!test
-%!  A = cellfun (@(x,y) x>y, {1.1, 4.2}, {3.1, 2+3*i});
-%!  assert (A, [false, true]);
+%! A = cellfun (@(x,y) x>y, {1.1, 4.2}, {3.1, 2+3*i});
+%! assert (A, [false, true]);
 %!test
-%!  A = cellfun (@(x,y) x>y, {1.1, 4.2; 2, 4}, {3.1, 2; 2, 4+2*i}, \
-%!    "UniformOutput", true);
-%!  assert (A, [false, true; false, false]);
+%! A = cellfun (@(x,y) x>y, {1.1, 4.2; 2, 4}, {3.1, 2; 2, 4+2*i}, \
+%!              "UniformOutput", true);
+%! assert (A, [false, true; false, false]);
 %!test
-%!  A = cellfun (@(x,y) x:y, {1.1, 4}, {3.1, 6}, "UniformOutput", false);
-%!  assert (isequal (A{1}, [1.1, 2.1, 3.1]));
-%!  assert (isequal (A{2}, [4, 5, 6]));
+%! A = cellfun (@(x,y) x:y, {1.1, 4}, {3.1, 6}, "UniformOutput", false);
+%! assert (isequal (A{1}, [1.1, 2.1, 3.1]));
+%! assert (isequal (A{2}, [4, 5, 6]));
 %!test %% Three ouptut arguments of different type
-%!  [A, B, C] = cellfun (@find, {10, 11; 0, 12}, "UniformOutput", false);
-%!  assert (isequal (A, {true, true; [], true}));
-%!  assert (isequal (B, {true, true; [], true}));
-%!  assert (isequal (C, {10, 11; [], 12}));
+%! [A, B, C] = cellfun (@find, {10, 11; 0, 12}, "UniformOutput", false);
+%! assert (isequal (A, {true, true; [], true}));
+%! assert (isequal (B, {true, true; [], true}));
+%! assert (isequal (C, {10, 11; [], 12}));
 %!test
-%!  A = cellfun (@(x,y) cell2str(x,y), {1.1, 4}, {3.1, 6}, \
-%!    "ErrorHandler", @__cellfunerror);
-%!  B = isfield (A(1), "message") && isfield (A(1), "index");
-%!  assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
-%!  assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
-%!  assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
-%!  assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
-%!  assert ([A(1).index, A(2).index], [1, 2]);
+%! A = cellfun (@(x,y) cell2str(x,y), {1.1, 4}, {3.1, 6}, \
+%!              "ErrorHandler", @__cellfunerror);
+%! B = isfield (A(1), "message") && isfield (A(1), "index");
+%! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
+%! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
+%! assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
+%! assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
+%! assert ([A(1).index, A(2).index], [1, 2]);
 %!test %% Overwriting setting of "UniformOutput" true
-%!  A = cellfun (@(x,y) cell2str(x,y), {1.1, 4}, {3.1, 6}, \
-%!    "UniformOutput", true, "ErrorHandler", @__cellfunerror);
-%!  B = isfield (A(1), "message") && isfield (A(1), "index");
-%!  assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
-%!  assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
-%!  assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
-%!  assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
-%!  assert ([A(1).index, A(2).index], [1, 2]);
+%! A = cellfun (@(x,y) cell2str(x,y), {1.1, 4}, {3.1, 6}, \
+%!              "UniformOutput", true, "ErrorHandler", @__cellfunerror);
+%! B = isfield (A(1), "message") && isfield (A(1), "index");
+%! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
+%! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
+%! assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
+%! assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
+%! assert ([A(1).index, A(2).index], [1, 2]);
 
 %% Input arguments can be of type cell arrays of character or strings
 %!error %% "UniformOutput" false should be used
-%!  A = cellfun (@(x,y) x>y, {"ad", "c", "ghi"}, {"cc", "d", "fgh"});
+%! A = cellfun (@(x,y) x>y, {"ad", "c", "ghi"}, {"cc", "d", "fgh"});
 %!test
-%!  A = cellfun (@(x,y) x>y, {"a"; "f"}, {"c"; "d"}, "UniformOutput", true);
-%!  assert (A, [false; true]);
+%! A = cellfun (@(x,y) x>y, {"a"; "f"}, {"c"; "d"}, "UniformOutput", true);
+%! assert (A, [false; true]);
 %!test
-%!  A = cellfun (@(x,y) x:y, {"a", "d"}, {"c", "f"}, "UniformOutput", false);
-%!  assert (A, {"abc", "def"});
+%! A = cellfun (@(x,y) x:y, {"a", "d"}, {"c", "f"}, "UniformOutput", false);
+%! assert (A, {"abc", "def"});
 %!test
-%!  A = cellfun (@(x,y) cell2str(x,y), {"a", "d"}, {"c", "f"}, \
-%!    "ErrorHandler", @__cellfunerror);
-%!  assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
-%!  assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
-%!  assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
-%!  assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
-%!  assert ([A(1).index, A(2).index], [1, 2]);
+%! A = cellfun (@(x,y) cell2str(x,y), {"a", "d"}, {"c", "f"}, \
+%!              "ErrorHandler", @__cellfunerror);
+%! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
+%! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
+%! assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
+%! assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
+%! assert ([A(1).index, A(2).index], [1, 2]);
 %!test %% Overwriting setting of "UniformOutput" true
-%!  A = cellfun (@(x,y) cell2str(x,y), {"a", "d"}, {"c", "f"}, \
-%!    "UniformOutput", true, "ErrorHandler", @__cellfunerror);
-%!  assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
-%!  assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
-%!  assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
-%!  assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
-%!  assert ([A(1).index, A(2).index], [1, 2]);
+%! A = cellfun (@(x,y) cell2str(x,y), {"a", "d"}, {"c", "f"}, \
+%!              "UniformOutput", true, "ErrorHandler", @__cellfunerror);
+%! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
+%! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
+%! assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
+%! assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
+%! assert ([A(1).index, A(2).index], [1, 2]);
 
 %% Structures cannot be handled by cellfun
 %!error
-%!  vst1.a = 1.1; vst1.b = 4.2; vst2.a = 3.1; vst2.b = 2;
-%!  A = cellfun (@(x,y) (x.a < y.a) && (x.b > y.b), vst1, vst2);
+%! vst1.a = 1.1;  vst1.b = 4.2;  vst2.a = 3.1;  vst2.b = 2;
+%! A = cellfun (@(x,y) (x.a < y.a) && (x.b > y.b), vst1, vst2);
 
 %% Input arguments can be of type cell array of cell arrays
 %!test
-%!  A = cellfun (@(x,y) x{1} < y{1}, {{1.1}, {4.2}}, {{3.1}, {2}});
-%!  assert (A, [1, 0], 1e-16);
+%! A = cellfun (@(x,y) x{1} < y{1}, {{1.1}, {4.2}}, {{3.1}, {2}});
+%! assert (A, [1, 0], 1e-16);
 %!test
-%!  A = cellfun (@(x,y) x{1} < y{1}, {{1.1}; {4.2}}, {{3.1}; {2}}, \
-%!    "UniformOutput", true);
-%!  assert (A, [1; 0], 1e-16);
+%! A = cellfun (@(x,y) x{1} < y{1}, {{1.1}; {4.2}}, {{3.1}; {2}}, \
+%!              "UniformOutput", true);
+%! assert (A, [1; 0], 1e-16);
 %!test
-%!  A = cellfun (@(x,y) x{1} < y{1}, {{1.1}, {4.2}}, {{3.1}, {2}}, \
-%!    "UniformOutput", false);
-%!  assert (A, {true, false});
+%! A = cellfun (@(x,y) x{1} < y{1}, {{1.1}, {4.2}}, {{3.1}, {2}}, \
+%!              "UniformOutput", false);
+%! assert (A, {true, false});
 %!test
-%!  A = cellfun (@(x,y) mat2str(x,y), {{1.1}, {4.2}}, {{3.1}, {2}}, \
-%!    "ErrorHandler", @__cellfunerror);
-%!  assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
-%!  assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
-%!  assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
-%!  assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
-%!  assert ([A(1).index, A(2).index], [1, 2]);
+%! A = cellfun (@(x,y) mat2str(x,y), {{1.1}, {4.2}}, {{3.1}, {2}}, \
+%!              "ErrorHandler", @__cellfunerror);
+%! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
+%! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
+%! assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
+%! assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
+%! assert ([A(1).index, A(2).index], [1, 2]);
 %!test %% Overwriting setting of "UniformOutput" true
-%!  A = cellfun (@(x,y) mat2str(x,y), {{1.1}, {4.2}}, {{3.1}, {2}}, \
-%!    "UniformOutput", true, "ErrorHandler", @__cellfunerror);
-%!  assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
-%!  assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
-%!  assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
-%!  assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
-%!  assert ([A(1).index, A(2).index], [1, 2]);
+%! A = cellfun (@(x,y) mat2str(x,y), {{1.1}, {4.2}}, {{3.1}, {2}}, \
+%!              "UniformOutput", true, "ErrorHandler", @__cellfunerror);
+%! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
+%! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
+%! assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
+%! assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
+%! assert ([A(1).index, A(2).index], [1, 2]);
 
 %% Input arguments can be of type cell array of structure arrays
 %!test
-%!  a = struct ("a", 1, "b", 2); b = struct ("a", 1, "b", 3);
-%!  A = cellfun (@(x,y) (x.a == y.a) && (x.b < y.b), {a}, {b});
-%!  assert (A, true);
+%! a = struct ("a", 1, "b", 2);  b = struct ("a", 1, "b", 3);
+%! A = cellfun (@(x,y) (x.a == y.a) && (x.b < y.b), {a}, {b});
+%! assert (A, true);
 %!test
-%!  a = struct ("a", 1, "b", 2); b = struct ("a", 1, "b", 3);
-%!  A = cellfun (@(x,y) (x.a == y.a) && (x.b < y.b) , {a}, {b}, \
-%!    "UniformOutput", true);
-%!  assert (A, true);
+%! a = struct ("a", 1, "b", 2);  b = struct ("a", 1, "b", 3);
+%! A = cellfun (@(x,y) (x.a == y.a) && (x.b < y.b) , {a}, {b}, \
+%!              "UniformOutput", true);
+%! assert (A, true);
 %!test
-%!  a = struct ("a", 1, "b", 2); b = struct ("a", 1, "b", 3);
-%!  A = cellfun (@(x,y) (x.a == y.a) && (x.b < y.b) , {a}, {b}, \
-%!    "UniformOutput", false);
-%!  assert (A, {true});
+%! a = struct ("a", 1, "b", 2);  b = struct ("a", 1, "b", 3);
+%! A = cellfun (@(x,y) (x.a == y.a) && (x.b < y.b) , {a}, {b}, \
+%!              "UniformOutput", false);
+%! assert (A, {true});
 %!test
-%!  a = struct ("a", 1, "b", 2); b = struct ("a", 1, "b", 3);
-%!  A = cellfun (@(x,y) cell2str (x.a, y.a), {a}, {b}, \
-%!    "ErrorHandler", @__cellfunerror);
-%!  assert (isfield (A, "identifier"), true);
-%!  assert (isfield (A, "message"), true);
-%!  assert (isfield (A, "index"), true);
-%!  assert (isempty (A.message), false);
-%!  assert (A.index, 1);
+%! a = struct ("a", 1, "b", 2);  b = struct ("a", 1, "b", 3);
+%! A = cellfun (@(x,y) cell2str (x.a, y.a), {a}, {b}, \
+%!              "ErrorHandler", @__cellfunerror);
+%! assert (isfield (A, "identifier"), true);
+%! assert (isfield (A, "message"), true);
+%! assert (isfield (A, "index"), true);
+%! assert (isempty (A.message), false);
+%! assert (A.index, 1);
 %!test %% Overwriting setting of "UniformOutput" true
-%!  a = struct ("a", 1, "b", 2); b = struct ("a", 1, "b", 3);
-%!  A = cellfun (@(x,y) cell2str (x.a, y.a), {a}, {b}, \
-%!    "UniformOutput", true, "ErrorHandler", @__cellfunerror);
-%!  assert (isfield (A, "identifier"), true);
-%!  assert (isfield (A, "message"), true);
-%!  assert (isfield (A, "index"), true);
-%!  assert (isempty (A.message), false);
-%!  assert (A.index, 1);
+%! a = struct ("a", 1, "b", 2);  b = struct ("a", 1, "b", 3);
+%! A = cellfun (@(x,y) cell2str (x.a, y.a), {a}, {b}, \
+%!              "UniformOutput", true, "ErrorHandler", @__cellfunerror);
+%! assert (isfield (A, "identifier"), true);
+%! assert (isfield (A, "message"), true);
+%! assert (isfield (A, "index"), true);
+%! assert (isempty (A.message), false);
+%! assert (A.index, 1);
 
 %% A lot of other tests
-%!error(cellfun(1))
-%!error(cellfun('isclass',1))
-%!error(cellfun('size',1))
-%!error(cellfun(@sin,{[]},'BadParam',false))
-%!error(cellfun(@sin,{[]},'UniformOuput'))
-%!error(cellfun(@sin,{[]},'ErrorHandler'))
-%!assert(cellfun(@sin,{0,1}),sin([0,1]))
-%!assert(cellfun(inline('sin(x)'),{0,1}),sin([0,1]))
-%!assert(cellfun('sin',{0,1}),sin([0,1]))
-%!assert(cellfun('isempty',{1,[]}),[false,true])
-%!assert(cellfun('islogical',{false,pi}),[true,false])
-%!assert(cellfun('isreal',{1i,1}),[false,true])
-%!assert(cellfun('length',{zeros(2,2),1}),[2,1])
-%!assert(cellfun('prodofsize',{zeros(2,2),1}),[4,1])
-%!assert(cellfun('ndims',{zeros([2,2,2]),1}),[3,2])
-%!assert(cellfun('isclass',{zeros([2,2,2]),'test'},'double'),[true,false])
-%!assert(cellfun('size',{zeros([1,2,3]),1},1),[1,1])
-%!assert(cellfun('size',{zeros([1,2,3]),1},2),[2,1])
-%!assert(cellfun('size',{zeros([1,2,3]),1},3),[3,1])
-%!assert(cellfun(@atan2,{1,1},{1,2}),[atan2(1,1),atan2(1,2)])
-%!assert(cellfun(@atan2,{1,1},{1,2},'UniformOutput',false),{atan2(1,1),atan2(1,2)})
-%!assert(cellfun(@sin,{1,2;3,4}),sin([1,2;3,4]))
-%!assert(cellfun(@atan2,{1,1;1,1},{1,2;1,2}),atan2([1,1;1,1],[1,2;1,2]))
-%!error(cellfun(@factorial,{-1,3}))
-%!assert(cellfun(@factorial,{-1,3},'ErrorHandler',@(x,y) NaN),[NaN,6])
+%!assert (cellfun (@sin, {0,1}), sin ([0,1]))
+%!assert (cellfun (inline ("sin (x)"), {0,1}), sin ([0,1]))
+%!assert (cellfun ("sin", {0,1}), sin ([0,1]))
+%!assert (cellfun ("isempty", {1,[]}), [false,true])
+%!assert (cellfun ("islogical", {false,pi}), [true,false])
+%!assert (cellfun ("isreal", {1i,1}), [false,true])
+%!assert (cellfun ("length", {zeros(2,2),1}), [2,1])
+%!assert (cellfun ("prodofsize", {zeros(2,2),1}), [4,1])
+%!assert (cellfun ("ndims", {zeros([2,2,2]),1}), [3,2])
+%!assert (cellfun ("isclass", {zeros([2,2,2]),"test"}, "double"), [true,false])
+%!assert (cellfun ("size", {zeros([1,2,3]),1}, 1), [1,1])
+%!assert (cellfun ("size", {zeros([1,2,3]),1}, 2), [2,1])
+%!assert (cellfun ("size", {zeros([1,2,3]),1}, 3), [3,1])
+%!assert (cellfun (@atan2, {1,1}, {1,2}), [atan2(1,1), atan2(1,2)])
+%!assert (cellfun (@atan2, {1,1}, {1,2},"UniformOutput", false), {atan2(1,1), atan2(1,2)})
+%!assert (cellfun (@sin, {1,2;3,4}), sin ([1,2;3,4]))
+%!assert (cellfun (@atan2, {1,1;1,1}, {1,2;1,2}), atan2 ([1,1;1,1],[1,2;1,2]))
+%!error cellfun (@factorial, {-1,3})
+%!assert (cellfun (@factorial,{-1,3},"ErrorHandler",@(x,y) NaN), [NaN,6])
 %!test
-%! [a,b,c]=cellfun(@fileparts,{fullfile("a","b","c.d"),fullfile("e","f","g.h")},'UniformOutput',false);
-%! assert(a,{fullfile("a","b"),fullfile("e","f")})
-%! assert(b,{'c','g'})
-%! assert(c,{'.d','.h'})
+%! [a,b,c] = cellfun (@fileparts, {fullfile("a","b","c.d"), fullfile("e","f","g.h")}, "UniformOutput", false);
+%! assert (a, {fullfile("a","b"), fullfile("e","f")});
+%! assert (b, {"c", "g"});
+%! assert (c, {".d", ".h"});
 
+%!error cellfun (1)
+%!error cellfun ("isclass", 1)
+%!error cellfun ("size", 1)
+%!error cellfun (@sin, {[]}, "BadParam", false)
+%!error cellfun (@sin, {[]}, "UniformOuput")
+%!error cellfun (@sin, {[]}, "ErrorHandler")
 */
 
 // Arrayfun was originally a .m file written by Bill Denney and Jaroslav
@@ -1436,214 +1437,218 @@
 
 /*
 %!function r = __f11 (x)
-%!  global __arrayfun_test_num_outputs__
+%!  global __arrayfun_test_num_outputs__;
 %!  __arrayfun_test_num_outputs__ = nargout;
 %!  r = x;
 %!endfunction
 
 %!function __f01 (x)
-%!  global __arrayfun_test_num_outputs__
+%!  global __arrayfun_test_num_outputs__;
 %!  __arrayfun_test_num_outputs__ = nargout;
 %!endfunction
 
 %!test
-%! global __arrayfun_test_num_outputs__
+%! global __arrayfun_test_num_outputs__;
 %! arrayfun (@__f11, {1});
-%! assert (__arrayfun_test_num_outputs__, 0)
+%! assert (__arrayfun_test_num_outputs__, 0);
 %! x = arrayfun (@__f11, {1});
-%! assert (__arrayfun_test_num_outputs__, 1)
+%! assert (__arrayfun_test_num_outputs__, 1);
 
 %!test
-%! global __arrayfun_test_num_outputs__
+%! global __arrayfun_test_num_outputs__;
 %! arrayfun (@__f01, {1});
-%! assert (__arrayfun_test_num_outputs__, 0)
+%! assert (__arrayfun_test_num_outputs__, 0);
 
 %!error x = arrayfun (@__f01, [1, 2]);
 
 %!test
-%! assert (arrayfun (@__f11, [1, 2]), [1, 2])
-%! assert (arrayfun (@__f11, [1, 2], 'uniformoutput', false), {1, 2});
-%! assert (arrayfun (@__f11, {1, 2}), {1, 2})
-%! assert (arrayfun (@__f11, {1, 2}, 'uniformoutput', false), {{1}, {2}});
+%! assert (arrayfun (@__f11, [1, 2]), [1, 2]);
+%! assert (arrayfun (@__f11, [1, 2], "uniformoutput", false), {1, 2});
+%! assert (arrayfun (@__f11, {1, 2}), {1, 2});
+%! assert (arrayfun (@__f11, {1, 2}, "uniformoutput", false), {{1}, {2}});
 
-%!assert (arrayfun (@ones, 1, [2,3], 'uniformoutput', false), {[1,1], [1,1,1]});
+%!assert (arrayfun (@ones, 1, [2,3], "uniformoutput", false), {[1,1], [1,1,1]})
 
 %% Test function to check the "Errorhandler" option
-%!function [z] = __arrayfunerror (S, varargin)
-%!      z = S;
+%!function z = __arrayfunerror (S, varargin)
+%!  z = S;
 %!endfunction
 %% First input argument can be a string, an inline function, a
 %% function_handle or an anonymous function
 %!test
-%!  arrayfun (@isequal, [false, true], [true, true]); %% No output argument
+%! arrayfun (@isequal, [false, true], [true, true]); %% No output argument
 %!error
-%!  arrayfun (@isequal); %% One or less input arguments
+%! arrayfun (@isequal); %% One or less input arguments
 %!test
-%!  A = arrayfun ("isequal", [false, true], [true, true]);
-%!  assert (A, [false, true]);
+%! A = arrayfun ("isequal", [false, true], [true, true]);
+%! assert (A, [false, true]);
 %!test
-%!  A = arrayfun (inline ("(x == y)", "x", "y"), [false, true], [true, true]);
-%!  assert (A, [false, true]);
+%! A = arrayfun (inline ("(x == y)", "x", "y"), [false, true], [true, true]);
+%! assert (A, [false, true]);
 %!test
-%!  A = arrayfun (@isequal, [false, true], [true, true]);
-%!  assert (A, [false, true]);
+%! A = arrayfun (@isequal, [false, true], [true, true]);
+%! assert (A, [false, true]);
 %!test
-%!  A = arrayfun (@(x,y) isequal(x,y), [false, true], [true, true]);
-%!  assert (A, [false, true]);
+%! A = arrayfun (@(x,y) isequal(x,y), [false, true], [true, true]);
+%! assert (A, [false, true]);
 
 %% Number of input and output arguments may be greater than one
 %#!test
-%!  A = arrayfun (@(x) islogical (x), false);
-%!  assert (A, true);
+%! A = arrayfun (@(x) islogical (x), false);
+%! assert (A, true);
 %!test
-%!  A = arrayfun (@(x,y,z) x + y + z, [1, 1, 1], [2, 2, 2], [3, 4, 5]);
-%!  assert (A, [6, 7, 8], 1e-16);
+%! A = arrayfun (@(x,y,z) x + y + z, [1, 1, 1], [2, 2, 2], [3, 4, 5]);
+%! assert (A, [6, 7, 8], 1e-16);
 %!test %% Two input arguments of different types
-%!  A = arrayfun (@(x,y) islogical (x) && ischar (y), false, "a");
-%!  assert (A, true);
+%! A = arrayfun (@(x,y) islogical (x) && ischar (y), false, "a");
+%! assert (A, true);
 %!test %% Pass another variable to the anonymous function
-%!  y = true; A = arrayfun (@(x) islogical (x && y), false);
-%!  assert (A, true);
+%! y = true;
+%! A = arrayfun (@(x) islogical (x && y), false);
+%! assert (A, true);
 %!test %% Three ouptut arguments of different type
-%!  [A, B, C] = arrayfun (@find, [10, 11; 0, 12], "UniformOutput", false);
-%!  assert (isequal (A, {true, true; [], true}));
-%!  assert (isequal (B, {true, true; [], true}));
-%!  assert (isequal (C, {10, 11; [], 12}));
+%! [A, B, C] = arrayfun (@find, [10, 11; 0, 12], "UniformOutput", false);
+%! assert (isequal (A, {true, true; [], true}));
+%! assert (isequal (B, {true, true; [], true}));
+%! assert (isequal (C, {10, 11; [], 12}));
 
 %% Input arguments can be of type logical
 %!test
-%!  A = arrayfun (@(x,y) x == y, [false, true], [true, true]);
-%!  assert (A, [false, true]);
+%! A = arrayfun (@(x,y) x == y, [false, true], [true, true]);
+%! assert (A, [false, true]);
 %!test
-%!  A = arrayfun (@(x,y) x == y, [false; true], [true; true], "UniformOutput", true);
-%!  assert (A, [false; true]);
+%! A = arrayfun (@(x,y) x == y, [false; true], [true; true], "UniformOutput", true);
+%! assert (A, [false; true]);
 %!test
-%!  A = arrayfun (@(x) x, [false, true, false, true], "UniformOutput", false);
-%!  assert (A, {false, true, false, true});
+%! A = arrayfun (@(x) x, [false, true, false, true], "UniformOutput", false);
+%! assert (A, {false, true, false, true});
 %!test %% Three ouptut arguments of same type
-%!  [A, B, C] = arrayfun (@find, [true, false; false, true], "UniformOutput", false);
-%!  assert (isequal (A, {true, []; [], true}));
-%!  assert (isequal (B, {true, []; [], true}));
-%!  assert (isequal (C, {true, []; [], true}));
+%! [A, B, C] = arrayfun (@find, [true, false; false, true], "UniformOutput", false);
+%! assert (isequal (A, {true, []; [], true}));
+%! assert (isequal (B, {true, []; [], true}));
+%! assert (isequal (C, {true, []; [], true}));
 %!test
-%!  A = arrayfun (@(x,y) array2str (x,y), true, true, "ErrorHandler", @__arrayfunerror);
-%!  assert (isfield (A, "identifier"), true);
-%!  assert (isfield (A, "message"), true);
-%!  assert (isfield (A, "index"), true);
-%!  assert (isempty (A.message), false);
-%!  assert (A.index, 1);
+%! A = arrayfun (@(x,y) array2str (x,y), true, true, \
+%!               "ErrorHandler", @__arrayfunerror);
+%! assert (isfield (A, "identifier"), true);
+%! assert (isfield (A, "message"), true);
+%! assert (isfield (A, "index"), true);
+%! assert (isempty (A.message), false);
+%! assert (A.index, 1);
 %!test %% Overwriting setting of "UniformOutput" true
-%!  A = arrayfun (@(x,y) array2str (x,y), true, true, \
-%!                "UniformOutput", true, "ErrorHandler", @__arrayfunerror);
-%!  assert (isfield (A, "identifier"), true);
-%!  assert (isfield (A, "message"), true);
-%!  assert (isfield (A, "index"), true);
-%!  assert (isempty (A.message), false);
-%!  assert (A.index, 1);
+%! A = arrayfun (@(x,y) array2str (x,y), true, true, "UniformOutput", true, \
+%!               "ErrorHandler", @__arrayfunerror);
+%! assert (isfield (A, "identifier"), true);
+%! assert (isfield (A, "message"), true);
+%! assert (isfield (A, "index"), true);
+%! assert (isempty (A.message), false);
+%! assert (A.index, 1);
 
 %% Input arguments can be of type numeric
 %!test
-%!  A = arrayfun (@(x,y) x>y, [1.1, 4.2], [3.1, 2+3*i]);
-%!  assert (A, [false, true]);
+%! A = arrayfun (@(x,y) x>y, [1.1, 4.2], [3.1, 2+3*i]);
+%! assert (A, [false, true]);
 %!test
-%!  A = arrayfun (@(x,y) x>y, [1.1, 4.2; 2, 4], [3.1, 2; 2, 4+2*i], "UniformOutput", true);
-%!  assert (A, [false, true; false, false]);
+%! A = arrayfun (@(x,y) x>y, [1.1, 4.2; 2, 4], [3.1, 2; 2, 4+2*i], "UniformOutput", true);
+%! assert (A, [false, true; false, false]);
 %!test
-%!  A = arrayfun (@(x,y) x:y, [1.1, 4], [3.1, 6], "UniformOutput", false);
-%!  assert (isequal (A{1}, [1.1, 2.1, 3.1]));
-%!  assert (isequal (A{2}, [4, 5, 6]));
+%! A = arrayfun (@(x,y) x:y, [1.1, 4], [3.1, 6], "UniformOutput", false);
+%! assert (isequal (A{1}, [1.1, 2.1, 3.1]));
+%! assert (isequal (A{2}, [4, 5, 6]));
 %!test %% Three ouptut arguments of different type
-%!  [A, B, C] = arrayfun (@find, [10, 11; 0, 12], "UniformOutput", false);
-%!  assert (isequal (A, {true, true; [], true}));
-%!  assert (isequal (B, {true, true; [], true}));
-%!  assert (isequal (C, {10, 11; [], 12}));
+%! [A, B, C] = arrayfun (@find, [10, 11; 0, 12], "UniformOutput", false);
+%! assert (isequal (A, {true, true; [], true}));
+%! assert (isequal (B, {true, true; [], true}));
+%! assert (isequal (C, {10, 11; [], 12}));
 %!test
-%!  A = arrayfun (@(x,y) array2str(x,y), {1.1, 4}, {3.1, 6}, "ErrorHandler", @__arrayfunerror);
-%!  B = isfield (A(1), "message") && isfield (A(1), "index");
-%!  assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
-%!  assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
-%!  assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
-%!  assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
-%!  assert ([A(1).index, A(2).index], [1, 2]);
+%! A = arrayfun (@(x,y) array2str(x,y), {1.1, 4}, {3.1, 6}, \
+%!               "ErrorHandler", @__arrayfunerror);
+%! B = isfield (A(1), "message") && isfield (A(1), "index");
+%! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
+%! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
+%! assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
+%! assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
+%! assert ([A(1).index, A(2).index], [1, 2]);
 %!test %% Overwriting setting of "UniformOutput" true
-%!  A = arrayfun (@(x,y) array2str(x,y), {1.1, 4}, {3.1, 6}, \
-%!                "UniformOutput", true, "ErrorHandler", @__arrayfunerror);
-%!  B = isfield (A(1), "message") && isfield (A(1), "index");
-%!  assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
-%!  assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
-%!  assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
-%!  assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
-%!  assert ([A(1).index, A(2).index], [1, 2]);
+%! A = arrayfun (@(x,y) array2str(x,y), {1.1, 4}, {3.1, 6}, \
+%!               "UniformOutput", true, "ErrorHandler", @__arrayfunerror);
+%! B = isfield (A(1), "message") && isfield (A(1), "index");
+%! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
+%! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
+%! assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
+%! assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
+%! assert ([A(1).index, A(2).index], [1, 2]);
 
 %% Input arguments can be of type character or strings
 %!test
-%!  A = arrayfun (@(x,y) x>y, ["ad", "c", "ghi"], ["cc", "d", "fgh"]);
-%!  assert (A, [false, true, false, true, true, true]);
+%! A = arrayfun (@(x,y) x>y, ["ad", "c", "ghi"], ["cc", "d", "fgh"]);
+%! assert (A, [false, true, false, true, true, true]);
 %!test
-%!  A = arrayfun (@(x,y) x>y, ["a"; "f"], ["c"; "d"], "UniformOutput", true);
-%!  assert (A, [false; true]);
+%! A = arrayfun (@(x,y) x>y, ["a"; "f"], ["c"; "d"], "UniformOutput", true);
+%! assert (A, [false; true]);
 %!test
-%!  A = arrayfun (@(x,y) x:y, ["a", "d"], ["c", "f"], "UniformOutput", false);
-%!  assert (A, {"abc", "def"});
-%! %#!test
-%!   A = arrayfun (@(x,y) cell2str(x,y), ["a", "d"], ["c", "f"], "ErrorHandler", @__arrayfunerror);
-%!   B = isfield (A(1), "identifier") && isfield (A(1), "message") && isfield (A(1), "index");
-%!   assert (B, true);
+%! A = arrayfun (@(x,y) x:y, ["a", "d"], ["c", "f"], "UniformOutput", false);
+%! assert (A, {"abc", "def"});
+%!test
+%! A = arrayfun (@(x,y) cell2str(x,y), ["a", "d"], ["c", "f"], \
+%!               "ErrorHandler", @__arrayfunerror);
+%! B = isfield (A(1), "identifier") && isfield (A(1), "message") && isfield (A(1), "index");
+%! assert (B, true);
 
 %% Input arguments can be of type structure
 %!test
-%!  a = struct ("a", 1.1, "b", 4.2); b = struct ("a", 3.1, "b", 2);
-%!  A = arrayfun (@(x,y) (x.a < y.a) && (x.b > y.b), a, b);
-%!  assert (A, true);
+%! a = struct ("a", 1.1, "b", 4.2);  b = struct ("a", 3.1, "b", 2);
+%! A = arrayfun (@(x,y) (x.a < y.a) && (x.b > y.b), a, b);
+%! assert (A, true);
 %!test
-%!  a = struct ("a", 1.1, "b", 4.2); b = struct ("a", 3.1, "b", 2);
-%!  A = arrayfun (@(x,y) (x.a < y.a) && (x.b > y.b), a, b, "UniformOutput", true);
-%!  assert (A, true);
+%! a = struct ("a", 1.1, "b", 4.2);  b = struct ("a", 3.1, "b", 2);
+%! A = arrayfun (@(x,y) (x.a < y.a) && (x.b > y.b), a, b, "UniformOutput", true);
+%! assert (A, true);
 %!test
-%!  a = struct ("a", 1.1, "b", 4.2); b = struct ("a", 3.1, "b", 2);
-%!  A = arrayfun (@(x,y) x.a:y.a, a, b, "UniformOutput", false);
-%!  assert (isequal (A, {[1.1, 2.1, 3.1]}));
+%! a = struct ("a", 1.1, "b", 4.2);  b = struct ("a", 3.1, "b", 2);
+%! A = arrayfun (@(x,y) x.a:y.a, a, b, "UniformOutput", false);
+%! assert (isequal (A, {[1.1, 2.1, 3.1]}));
 %!test
-%!  A = arrayfun (@(x) mat2str(x), "a", "ErrorHandler", @__arrayfunerror);
-%!  assert (isfield (A, "identifier"), true);
-%!  assert (isfield (A, "message"), true);
-%!  assert (isfield (A, "index"), true);
-%!  assert (isempty (A.message), false);
-%!  assert (A.index, 1);
+%! A = arrayfun (@(x) mat2str(x), "a", "ErrorHandler", @__arrayfunerror);
+%! assert (isfield (A, "identifier"), true);
+%! assert (isfield (A, "message"), true);
+%! assert (isfield (A, "index"), true);
+%! assert (isempty (A.message), false);
+%! assert (A.index, 1);
 %!test %% Overwriting setting of "UniformOutput" true
-%!  A = arrayfun (@(x) mat2str(x), "a", "UniformOutput", true, \
-%!                "ErrorHandler", @__arrayfunerror);
-%!  assert (isfield (A, "identifier"), true);
-%!  assert (isfield (A, "message"), true);
-%!  assert (isfield (A, "index"), true);
-%!  assert (isempty (A.message), false);
-%!  assert (A.index, 1);
+%! A = arrayfun (@(x) mat2str(x), "a", "UniformOutput", true, \
+%!               "ErrorHandler", @__arrayfunerror);
+%! assert (isfield (A, "identifier"), true);
+%! assert (isfield (A, "message"), true);
+%! assert (isfield (A, "index"), true);
+%! assert (isempty (A.message), false);
+%! assert (A.index, 1);
 
 %% Input arguments can be of type cell array
 %!test
-%!  A = arrayfun (@(x,y) x{1} < y{1}, {1.1, 4.2}, {3.1, 2});
-%!  assert (A, [true, false]);
+%! A = arrayfun (@(x,y) x{1} < y{1}, {1.1, 4.2}, {3.1, 2});
+%! assert (A, [true, false]);
 %!test
-%!  A = arrayfun (@(x,y) x{1} < y{1}, {1.1; 4.2}, {3.1; 2}, "UniformOutput", true);
-%!  assert (A, [true; false]);
+%! A = arrayfun (@(x,y) x{1} < y{1}, {1.1; 4.2}, {3.1; 2}, "UniformOutput", true);
+%! assert (A, [true; false]);
 %!test
-%!  A = arrayfun (@(x,y) x{1} < y{1}, {1.1, 4.2}, {3.1, 2}, "UniformOutput", false);
-%!  assert (A, {true, false});
+%! A = arrayfun (@(x,y) x{1} < y{1}, {1.1, 4.2}, {3.1, 2}, "UniformOutput", false);
+%! assert (A, {true, false});
 %!test
-%!  A = arrayfun (@(x,y) num2str(x,y), {1.1, 4.2}, {3.1, 2}, "ErrorHandler", @__arrayfunerror);
-%!  assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
-%!  assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
-%!  assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
-%!  assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
-%!  assert ([A(1).index, A(2).index], [1, 2]);
+%! A = arrayfun (@(x,y) num2str(x,y), {1.1, 4.2}, {3.1, 2}, "ErrorHandler", @__arrayfunerror);
+%! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
+%! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
+%! assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
+%! assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
+%! assert ([A(1).index, A(2).index], [1, 2]);
 %!test
-%!  A = arrayfun (@(x,y) num2str(x,y), {1.1, 4.2}, {3.1, 2}, \
-%!                "UniformOutput", true, "ErrorHandler", @__arrayfunerror);
-%!  assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
-%!  assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
-%!  assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
-%!  assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
-%!  assert ([A(1).index, A(2).index], [1, 2]);
+%! A = arrayfun (@(x,y) num2str(x,y), {1.1, 4.2}, {3.1, 2}, \
+%!               "UniformOutput", true, "ErrorHandler", @__arrayfunerror);
+%! assert ([(isfield (A(1), "identifier")), (isfield (A(2), "identifier"))], [true, true]);
+%! assert ([(isfield (A(1), "message")), (isfield (A(2), "message"))], [true, true]);
+%! assert ([(isfield (A(1), "index")), (isfield (A(2), "index"))], [true, true]);
+%! assert ([(isempty (A(1).message)), (isempty (A(2).message))], [false, false]);
+%! assert ([A(1).index, A(2).index], [1, 2]);
 */
 
 static void
@@ -1904,11 +1909,9 @@
 }
 
 /*
-
-%!assert(num2cell([1,2;3,4]),{1,2;3,4})
-%!assert(num2cell([1,2;3,4],1),{[1;3],[2;4]})
-%!assert(num2cell([1,2;3,4],2),{[1,2];[3,4]})
-
+%!assert (num2cell ([1,2;3,4]), {1,2;3,4})
+%!assert (num2cell ([1,2;3,4], 1), {[1;3],[2;4]})
+%!assert (num2cell ([1,2;3,4], 2), {[1,2];[3,4]})
 */
 
 static bool
@@ -2252,18 +2255,16 @@
 }
 
 /*
+%!test
+%! x = reshape (1:20, 5, 4);
+%! c = mat2cell (x, [3,2], [3,1]);
+%! assert (c, {[1,6,11;2,7,12;3,8,13],[16;17;18];[4,9,14;5,10,15],[19;20]});
 
 %!test
-%! x = reshape(1:20,5,4);
-%! c = mat2cell(x,[3,2],[3,1]);
-%! assert(c,{[1,6,11;2,7,12;3,8,13],[16;17;18];[4,9,14;5,10,15],[19;20]})
-
-%!test
-%! x = 'abcdefghij';
-%! c = mat2cell(x,1,[0,4,2,0,4,0]);
-%! empty1by0str = resize('',1,0);
-%! assert(c,{empty1by0str,'abcd','ef',empty1by0str,'ghij',empty1by0str})
-
+%! x = "abcdefghij";
+%! c = mat2cell (x, 1, [0,4,2,0,4,0]);
+%! empty1by0str = resize ("", 1, 0);
+%! assert (c, {empty1by0str,"abcd","ef",empty1by0str,"ghij",empty1by0str});
 */
 
 // FIXME: it would be nice to allow ranges being handled without a conversion.
--- a/src/DLD-FUNCTIONS/chol.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/chol.cc	Mon May 07 00:56:44 2012 +0200
@@ -371,16 +371,14 @@
 }
 
 /*
-
-%!assert(chol ([2, 1; 1, 1]), [sqrt(2), 1/sqrt(2); 0, 1/sqrt(2)], sqrt (eps));
-%!assert(chol (single([2, 1; 1, 1])), single([sqrt(2), 1/sqrt(2); 0, 1/sqrt(2)]), sqrt (eps('single')));
+%!assert (chol ([2, 1; 1, 1]), [sqrt(2), 1/sqrt(2); 0, 1/sqrt(2)], sqrt (eps))
+%!assert (chol (single([2, 1; 1, 1])), single([sqrt(2), 1/sqrt(2); 0, 1/sqrt(2)]), sqrt (eps ("single")))
 
-%!error chol ([1, 2; 3, 4]);
-%!error chol ([1, 2; 3, 4; 5, 6]);
-%!error <Invalid call to chol> chol ();
-%!error <unexpected second or third input> chol (1, 2);
-
- */
+%!error <matrix must be positive definite> chol ([1, 2; 3, 4])
+%!error <requires square matrix> chol ([1, 2; 3, 4; 5, 6])
+%!error chol ()
+%!error <unexpected second or third input> chol (1, 2)
+*/
 
 DEFUN_DLD (cholinv, args, ,
   "-*- texinfo -*-\n\
@@ -513,20 +511,18 @@
 }
 
 /*
-
 %!shared A, Ainv
 %! A = [2,0.2;0.2,1];
-%! Ainv = inv(A);
+%! Ainv = inv (A);
 %!test
-%! Ainv1 = cholinv(A);
-%! assert (norm(Ainv-Ainv1),0,1e-10)
+%! Ainv1 = cholinv (A);
+%! assert (norm (Ainv-Ainv1), 0, 1e-10);
 %!testif HAVE_CHOLMOD
-%! Ainv2 = inv(sparse(A));
-%! assert (norm(Ainv-Ainv2),0,1e-10)
+%! Ainv2 = inv (sparse (A));
+%! assert (norm (Ainv-Ainv2), 0, 1e-10);
 %!testif HAVE_CHOLMOD
-%! Ainv3 = cholinv(sparse(A));
-%! assert (norm(Ainv-Ainv3),0,1e-10)
-
+%! Ainv3 = cholinv (sparse (A));
+%! assert (norm (Ainv-Ainv3), 0, 1e-10);
 */
 
 DEFUN_DLD (chol2inv, args, ,
@@ -786,59 +782,45 @@
 %!        0.83760 + 0.68977i ;
 %!        0.39160 + 0.90378i ];
 
-
+%!test
+%! R = chol (A);
+%! R1 = cholupdate (R, u);
+%! assert (norm (triu (R1)-R1, Inf), 0);
+%! assert (norm (R1'*R1 - R'*R - u*u', Inf) < 1e1*eps);
+%!
+%! R1 = cholupdate (R1, u, "-");
+%! assert (norm (triu (R1)-R1, Inf), 0);
+%! assert (norm (R1 - R, Inf) < 1e1*eps);
 
 %!test
-%! R = chol(A);
-%!
-%! R1 = cholupdate(R,u);
-%!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1'*R1 - R'*R - u*u',Inf) < 1e1*eps)
-%!
-%! R1 = cholupdate(R1,u,"-");
-%!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1 - R,Inf) < 1e1*eps)
+%! R = chol (Ac);
+%! R1 = cholupdate (R, uc);
+%! assert (norm (triu (R1)-R1, Inf), 0);
+%! assert (norm (R1'*R1 - R'*R - uc*uc', Inf) < 1e1*eps);
 %!
-%!test
-%! R = chol(Ac);
-%!
-%! R1 = cholupdate(R,uc);
-%!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1'*R1 - R'*R - uc*uc',Inf) < 1e1*eps)
-%!
-%! R1 = cholupdate(R1,uc,"-");
-%!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1 - R,Inf) < 1e1*eps)
+%! R1 = cholupdate (R1, uc, "-");
+%! assert (norm (triu (R1)-R1, Inf), 0);
+%! assert (norm (R1 - R, Inf) < 1e1*eps);
 
 %!test
-%! R = chol(single(A));
-%!
-%! R1 = cholupdate(R,single(u));
-%!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1'*R1 - R'*R - single(u*u'),Inf) < 1e1*eps('single'))
-%!
-%! R1 = cholupdate(R1,single(u),"-");
-%!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1 - R,Inf) < 2e1*eps('single'))
+%! R = chol (single (A));
+%! R1 = cholupdate (R, single (u));
+%! assert (norm (triu (R1)-R1, Inf), single (0));
+%! assert (norm (R1'*R1 - R'*R - single (u*u'), Inf) < 1e1*eps ("single"));
 %!
+%! R1 = cholupdate (R1, single (u), "-");
+%! assert (norm (triu (R1)-R1, Inf), single (0));
+%! assert (norm (R1 - R, Inf) < 2e1*eps ("single"));
+
 %!test
-%! R = chol(single(Ac));
-%!
-%! R1 = cholupdate(R,single(uc));
+%! R = chol (single (Ac));
+%! R1 = cholupdate (R, single (uc));
+%! assert (norm (triu (R1)-R1, Inf), single (0));
+%! assert (norm (R1'*R1 - R'*R - single (uc*uc'), Inf) < 1e1*eps ("single"));
 %!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1'*R1 - R'*R - single(uc*uc'),Inf) < 1e1*eps('single'))
-%!
-%! R1 = cholupdate(R1,single(uc),"-");
-%!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1 - R,Inf) < 2e1*eps('single'))
+%! R1 = cholupdate (R1, single (uc), "-");
+%! assert (norm (triu (R1)-R1, Inf), single (0));
+%! assert (norm (R1 - R, Inf) < 2e1*eps ("single"));
 */
 
 DEFUN_DLD (cholinsert, args, nargout,
@@ -972,14 +954,15 @@
 %!        -0.13825 ;
 %!         0.45266 ];
 %!
-%! R = chol(A);
+%! R = chol (A);
 %!
-%! j = 3; p = [1:j-1, j+1:5];
-%! R1 = cholinsert(R,j,u2); A1 = R1'*R1;
+%! j = 3;  p = [1:j-1, j+1:5];
+%! R1 = cholinsert (R, j, u2);
+%! A1 = R1'*R1;
 %!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(A1(p,p) - A,Inf) < 1e1*eps)
-%!
+%! assert (norm (triu (R1)-R1, Inf), 0);
+%! assert (norm (A1(p,p) - A, Inf) < 1e1*eps);
+
 %!test
 %! u2 = [  0.35080  + 0.04298i;
 %!         0.63930  + 0.23778i;
@@ -987,14 +970,14 @@
 %!        -0.13825  + 0.19879i;
 %!         0.45266  + 0.50020i];
 %!
-%! R = chol(Ac);
+%! R = chol (Ac);
 %!
-%! j = 3; p = [1:j-1, j+1:5];
-%! R1 = cholinsert(R,j,u2); A1 = R1'*R1;
+%! j = 3;  p = [1:j-1, j+1:5];
+%! R1 = cholinsert (R, j, u2);
+%! A1 = R1'*R1;
 %!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(A1(p,p) - Ac,Inf) < 1e1*eps)
-%!
+%! assert (norm (triu (R1)-R1, Inf), 0);
+%! assert (norm (A1(p,p) - Ac, Inf) < 1e1*eps);
 
 %!test
 %! u2 = single ([  0.35080 ;
@@ -1005,12 +988,13 @@
 %!
 %! R = chol(single(A));
 %!
-%! j = 3; p = [1:j-1, j+1:5];
-%! R1 = cholinsert(R,j,u2); A1 = R1'*R1;
+%! j = 3;  p = [1:j-1, j+1:5];
+%! R1 = cholinsert (R, j, u2);
+%! A1 = R1'*R1;
 %!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(A1(p,p) - A,Inf) < 1e1*eps('single'))
-%!
+%! assert (norm (triu (R1)-R1, Inf), single (0));
+%! assert (norm (A1(p,p) - A, Inf) < 1e1*eps ("single"));
+
 %!test
 %! u2 = single ([  0.35080  + 0.04298i;
 %!                 0.63930  + 0.23778i;
@@ -1018,55 +1002,55 @@
 %!                -0.13825  + 0.19879i;
 %!                 0.45266  + 0.50020i]);
 %!
-%! R = chol(single(Ac));
+%! R = chol (single (Ac));
 %!
-%! j = 3; p = [1:j-1, j+1:5];
-%! R1 = cholinsert(R,j,u2); A1 = R1'*R1;
+%! j = 3;  p = [1:j-1, j+1:5];
+%! R1 = cholinsert (R, j, u2);
+%! A1 = R1'*R1;
 %!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(A1(p,p) - single(Ac),Inf) < 2e1*eps('single'))
-%!
+%! assert (norm (triu (R1)-R1, Inf), single (0));
+%! assert (norm (A1(p,p) - single (Ac), Inf) < 2e1*eps ("single"));
 
 %!test
-%! cu = chol (triu (A), 'upper');
-%! cl = chol (tril (A), 'lower');
-%! assert (cu, cl', eps)
-%!
+%! cu = chol (triu (A), "upper");
+%! cl = chol (tril (A), "lower");
+%! assert (cu, cl', eps);
+
 %!test
 %! cca  = chol (Ac);
 %!
-%! ccal  = chol (Ac, 'lower');
-%! ccal2 = chol (tril (Ac), 'lower');
+%! ccal  = chol (Ac, "lower");
+%! ccal2 = chol (tril (Ac), "lower");
 %!
-%! ccau  = chol (Ac, 'upper');
-%! ccau2 = chol (triu (Ac), 'upper');
+%! ccau  = chol (Ac, "upper");
+%! ccau2 = chol (triu (Ac), "upper");
 %!
-%! assert (cca'*cca,     Ac, eps)
-%! assert (ccau'*ccau,   Ac, eps)
-%! assert (ccau2'*ccau2, Ac, eps)
+%! assert (cca'*cca,     Ac, eps);
+%! assert (ccau'*ccau,   Ac, eps);
+%! assert (ccau2'*ccau2, Ac, eps);
 %!
-%! assert (cca, ccal',  eps)
-%! assert (cca, ccau,   eps)
-%! assert (cca, ccal2', eps)
-%! assert (cca, ccau2,  eps)
-%!
+%! assert (cca, ccal',  eps);
+%! assert (cca, ccau,   eps);
+%! assert (cca, ccal2', eps);
+%! assert (cca, ccau2,  eps);
+
 %!test
 %! cca  = chol (single (Ac));
 %!
-%! ccal  = chol (single (Ac), 'lower');
-%! ccal2 = chol (tril (single (Ac)), 'lower');
+%! ccal  = chol (single (Ac), "lower");
+%! ccal2 = chol (tril (single (Ac)), "lower");
 %!
-%! ccau  = chol (single (Ac), 'upper');
-%! ccau2 = chol (triu (single (Ac)), 'upper');
+%! ccau  = chol (single (Ac), "upper");
+%! ccau2 = chol (triu (single (Ac)), "upper");
 %!
-%! assert (cca'*cca,     single (Ac), eps ('single'))
-%! assert (ccau'*ccau,   single (Ac), eps ('single'))
-%! assert (ccau2'*ccau2, single (Ac), eps ('single'))
+%! assert (cca'*cca,     single (Ac), eps ("single"));
+%! assert (ccau'*ccau,   single (Ac), eps ("single"));
+%! assert (ccau2'*ccau2, single (Ac), eps ("single"));
 %!
-%! assert (cca, ccal',  eps ('single'))
-%! assert (cca, ccau,   eps ('single'))
-%! assert (cca, ccal2', eps ('single'))
-%! assert (cca, ccau2,  eps ('single'))
+%! assert (cca, ccal',  eps ("single"));
+%! assert (cca, ccau,   eps ("single"));
+%! assert (cca, ccal2', eps ("single"));
+%! assert (cca, ccau2,  eps ("single"));
 
 %!test
 %! a = [12,  2,  3,  4;
@@ -1083,21 +1067,20 @@
 %!   
 %! cca  = chol (ca);
 %!
-%! ccal  = chol (ca, 'lower');
-%! ccal2 = chol (tril (ca), 'lower');
+%! ccal  = chol (ca, "lower");
+%! ccal2 = chol (tril (ca), "lower");
 %!
-%! ccau  = chol (ca, 'upper');
-%! ccau2 = chol (triu (ca), 'upper');
+%! ccau  = chol (ca, "upper");
+%! ccau2 = chol (triu (ca), "upper");
 %!
-%! assert (cca'*cca,     ca, 16*eps)
-%! assert (ccau'*ccau,   ca, 16*eps)
-%! assert (ccau2'*ccau2, ca, 16*eps)
+%! assert (cca'*cca,     ca, 16*eps);
+%! assert (ccau'*ccau,   ca, 16*eps);
+%! assert (ccau2'*ccau2, ca, 16*eps);
 %!
-%! assert (cca, ccal',  16*eps)
-%! assert (cca, ccau,   16*eps)
-%! assert (cca, ccal2', 16*eps)
-%! assert (cca, ccau2,  16*eps)
-
+%! assert (cca, ccal',  16*eps);
+%! assert (cca, ccau,   16*eps);
+%! assert (cca, ccal2', 16*eps);
+%! assert (cca, ccau2,  16*eps);
 */
 
 DEFUN_DLD (choldelete, args, ,
@@ -1199,38 +1182,38 @@
 %!test
 %! R = chol(A);
 %!
-%! j = 3; p = [1:j-1,j+1:4];
-%! R1 = choldelete(R,j);
-%!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1'*R1 - A(p,p),Inf) < 1e1*eps)
+%! j = 3;  p = [1:j-1,j+1:4];
+%! R1 = choldelete (R, j);
 %!
-%!test
-%! R = chol(Ac);
-%!
-%! j = 3; p = [1:j-1,j+1:4];
-%! R1 = choldelete(R,j);
-%!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1'*R1 - Ac(p,p),Inf) < 1e1*eps)
+%! assert (norm (triu (R1)-R1, Inf), 0);
+%! assert (norm (R1'*R1 - A(p,p), Inf) < 1e1*eps);
 
 %!test
-%! R = chol(single(A));
+%! R = chol (Ac);
+%!
+%! j = 3;  p = [1:j-1,j+1:4];
+%! R1 = choldelete (R, j);
 %!
-%! j = 3; p = [1:j-1,j+1:4];
-%! R1 = choldelete(R,j);
+%! assert (norm (triu (R1)-R1, Inf), 0);
+%! assert (norm (R1'*R1 - Ac(p,p), Inf) < 1e1*eps);
+
+%!test
+%! R = chol (single (A));
 %!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1'*R1 - single(A(p,p)),Inf) < 1e1*eps('single'))
+%! j = 3;  p = [1:j-1,j+1:4];
+%! R1 = choldelete (R, j);
 %!
+%! assert (norm (triu (R1)-R1, Inf), single (0));
+%! assert (norm (R1'*R1 - single (A(p,p)), Inf) < 1e1*eps ("single"));
+
 %!test
 %! R = chol(single(Ac));
 %!
-%! j = 3; p = [1:j-1,j+1:4];
+%! j = 3;  p = [1:j-1,j+1:4];
 %! R1 = choldelete(R,j);
 %!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1'*R1 - single(Ac(p,p)),Inf) < 1e1*eps('single'))
+%! assert (norm (triu (R1)-R1, Inf), single (0));
+%! assert (norm (R1'*R1 - single (Ac(p,p)), Inf) < 1e1*eps ("single"));
 */
 
 DEFUN_DLD (cholshift, args, ,
@@ -1338,62 +1321,62 @@
 
 /*
 %!test
-%! R = chol(A);
+%! R = chol (A);
 %!
-%! i = 1; j = 3; p = [1:i-1, shift(i:j,-1), j+1:4];
-%! R1 = cholshift(R,i,j);
+%! i = 1;  j = 3;  p = [1:i-1, shift(i:j,-1), j+1:4];
+%! R1 = cholshift (R, i, j);
 %!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1'*R1 - A(p,p),Inf) < 1e1*eps)
+%! assert (norm (triu (R1)-R1, Inf), 0);
+%! assert (norm (R1'*R1 - A(p,p), Inf) < 1e1*eps);
 %!
-%! j = 1; i = 3; p = [1:j-1, shift(j:i,+1), i+1:4];
-%! R1 = cholshift(R,i,j);
-%!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1'*R1 - A(p,p),Inf) < 1e1*eps)
+%! j = 1;  i = 3;  p = [1:j-1, shift(j:i,+1), i+1:4];
+%! R1 = cholshift (R, i, j);
 %!
+%! assert (norm(triu(R1)-R1, Inf), 0);
+%! assert (norm(R1'*R1 - A(p,p), Inf) < 1e1*eps);
+
 %!test
-%! R = chol(Ac);
+%! R = chol (Ac);
 %!
-%! i = 1; j = 3; p = [1:i-1, shift(i:j,-1), j+1:4];
-%! R1 = cholshift(R,i,j);
+%! i = 1;  j = 3;  p = [1:i-1, shift(i:j,-1), j+1:4];
+%! R1 = cholshift (R, i, j);
 %!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1'*R1 - Ac(p,p),Inf) < 1e1*eps)
+%! assert (norm (triu (R1)-R1, Inf), 0);
+%! assert (norm (R1'*R1 - Ac(p,p), Inf) < 1e1*eps);
 %!
-%! j = 1; i = 3; p = [1:j-1, shift(j:i,+1), i+1:4];
-%! R1 = cholshift(R,i,j);
+%! j = 1;  i = 3;  p = [1:j-1, shift(j:i,+1), i+1:4];
+%! R1 = cholshift (R, i, j);
 %!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1'*R1 - Ac(p,p),Inf) < 1e1*eps)
+%! assert (norm (triu (R1)-R1, Inf), 0);
+%! assert (norm (R1'*R1 - Ac(p,p), Inf) < 1e1*eps);
 
 %!test
-%! R = chol(single(A));
+%! R = chol (single (A));
+%! 
+%! i = 1;  j = 3;  p = [1:i-1, shift(i:j,-1), j+1:4];
+%! R1 = cholshift (R, i, j);
+%!
+%! assert (norm (triu (R1)-R1, Inf), 0);
+%! assert (norm (R1'*R1 - single (A(p,p)), Inf) < 1e1*eps ("single"));
+%!
+%! j = 1;  i = 3;  p = [1:j-1, shift(j:i,+1), i+1:4];
+%! R1 = cholshift (R, i, j);
 %!
-%! i = 1; j = 3; p = [1:i-1, shift(i:j,-1), j+1:4];
-%! R1 = cholshift(R,i,j);
+%! assert (norm (triu (R1)-R1, Inf), 0);
+%! assert (norm (R1'*R1 - single (A(p,p)), Inf) < 1e1*eps ("single"));
+
+%!test
+%! R = chol (single (Ac));
 %!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1'*R1 - single(A(p,p)),Inf) < 1e1*eps('single'))
+%! i = 1;  j = 3;  p = [1:i-1, shift(i:j,-1), j+1:4];
+%! R1 = cholshift (R, i, j);
+%!
+%! assert (norm (triu (R1)-R1, Inf), 0);
+%! assert (norm (R1'*R1 - single (Ac(p,p)), Inf) < 1e1*eps ("single"));
 %!
 %! j = 1; i = 3; p = [1:j-1, shift(j:i,+1), i+1:4];
-%! R1 = cholshift(R,i,j);
-%!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1'*R1 - single(A(p,p)),Inf) < 1e1*eps('single'))
-%!
-%!test
-%! R = chol(single(Ac));
+%! R1 = cholshift (R, i, j);
 %!
-%! i = 1; j = 3; p = [1:i-1, shift(i:j,-1), j+1:4];
-%! R1 = cholshift(R,i,j);
-%!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1'*R1 - single(Ac(p,p)),Inf) < 1e1*eps('single'))
-%!
-%! j = 1; i = 3; p = [1:j-1, shift(j:i,+1), i+1:4];
-%! R1 = cholshift(R,i,j);
-%!
-%! assert(norm(triu(R1)-R1,Inf) == 0)
-%! assert(norm(R1'*R1 - single(Ac(p,p)),Inf) < 1e1*eps('single'))
+%! assert (norm (triu (R1)-R1, Inf), 0);
+%! assert (norm (R1'*R1 - single (Ac(p,p)), Inf) < 1e1*eps ("single"));
 */
--- a/src/DLD-FUNCTIONS/conv2.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/conv2.cc	Mon May 07 00:56:44 2012 +0200
@@ -260,10 +260,10 @@
 %!shared
 
 %% Test cases from Bug #34893
-%!assert (conv2 ([1:5;1:5], [1:2], 'same'), [4 7 10 13 10; 4 7 10 13 10])
-%!assert (conv2 ([1:5;1:5]', [1:2]', 'same'), [4 7 10 13 10; 4 7 10 13 10]')
-%!#assert (conv2 ([1:5;1:5], [1:2], 'valid'), [4 7 10 13; 4 7 10 13])
-%!assert (conv2 ([1:5;1:5]', [1:2]', 'valid'), [4 7 10 13; 4 7 10 13]')
+%!assert (conv2 ([1:5;1:5], [1:2], "same"), [4 7 10 13 10; 4 7 10 13 10])
+%!assert (conv2 ([1:5;1:5]', [1:2]', "same"), [4 7 10 13 10; 4 7 10 13 10]')
+%!#assert (conv2 ([1:5;1:5], [1:2], "valid"), [4 7 10 13; 4 7 10 13])
+%!assert (conv2 ([1:5;1:5]', [1:2]', "valid"), [4 7 10 13; 4 7 10 13]')
 
 %% Test input validation
 %!error conv2 ()
@@ -272,7 +272,6 @@
 %% Test alternate calling form which should be 2 vectors and a matrix
 %!error conv2 (ones (2), 1, 1)
 %!error conv2 (1, ones (2), 1)
-
 */
 
 DEFUN_DLD (convn, args, ,
--- a/src/DLD-FUNCTIONS/convhulln.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/convhulln.cc	Mon May 07 00:56:44 2012 +0200
@@ -295,7 +295,7 @@
 %! assert (h, [1 2 4; 1 2 6; 1 4 8; 1 5 6; 1 5 8; 2 3 4; 2 3 7; 2 6 7; 3 4 7; 4 7 8; 5 6 7; 5 7 8]);
 %! assert (v, 1, 10*eps);
 %! [h2, v2] = convhulln (cube); % Test defaut option = "Qt"
-%! assert (size (h2), size (h))
+%! assert (size (h2), size (h));
 %! h2 = sortrows (sort (h2, 2), [1:3]);
 %! assert (h2, h);
 %! assert (v2, v, 10*eps);
--- a/src/DLD-FUNCTIONS/dassl.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/dassl.cc	Mon May 07 00:56:44 2012 +0200
@@ -482,25 +482,24 @@
 }
 
 /*
-
-%% dassl-1.m
-%%
-%% Test dassl() function
-%%
-%% Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
-%%         Comalco Research and Technology
-%%         20 May 1998
-%%
-%% Problem
-%%
-%%    y1' = -y2,   y1(0) = 1
-%%    y2' =  y1,   y2(0) = 0
-%%
-%% Solution
-%%
-%%    y1(t) = cos(t)
-%%    y2(t) = sin(t)
-
+## dassl-1.m
+##
+## Test dassl() function
+##
+## Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
+##         Comalco Research and Technology
+##         20 May 1998
+##
+## Problem
+##
+##    y1' = -y2,   y1(0) = 1
+##    y2' =  y1,   y2(0) = 0
+##
+## Solution
+##
+##    y1(t) = cos(t)
+##    y2(t) = sin(t)
+##
 %!function res = __f (x, xdot, t)
 %!  res = [xdot(1)+x(2); xdot(2)-x(1)];
 %!endfunction
@@ -513,34 +512,33 @@
 %!
 %! tol = 100 * dassl_options ("relative tolerance");
 %!
-%!
 %! [x, xdot] = dassl ("__f", x0, xdot0, t);
 %!
 %! y = [cos(t), sin(t)];
 %!
-%! assert(all (all (abs (x - y) < tol)));
+%! assert (x, y, tol);
 
-%% dassl-2.m
-%%
-%% Test dassl() function
-%%
-%% Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
-%%         Comalco Research and Technology
-%%         20 May 1998
-%%
-%% Based on SLATEC quick check for DASSL by Linda Petzold
-%%
-%% Problem
-%%
-%%   x1' + 10*x1 = 0,   x1(0) = 1
-%%   x1  + x2    = 1,   x2(0) = 0
-%%
-%%
-%% Solution
-%%
-%%  x1(t) = exp(-10*t)
-%%  x2(t) = 1 - x(1)
-
+## dassl-2.m
+##
+## Test dassl() function
+##
+## Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
+##         Comalco Research and Technology
+##         20 May 1998
+##
+## Based on SLATEC quick check for DASSL by Linda Petzold
+##
+## Problem
+##
+##   x1' + 10*x1 = 0,   x1(0) = 1
+##   x1  + x2    = 1,   x2(0) = 0
+##
+##
+## Solution
+##
+##  x1(t) = exp(-10*t)
+##  x2(t) = 1 - x(1)
+##
 %!function res = __f (x, xdot, t)
 %!  res = [xdot(1)+10*x(1); x(1)+x(2)-1];
 %!endfunction
@@ -553,17 +551,15 @@
 %!
 %! tol = 500 * dassl_options ("relative tolerance");
 %!
-%!
 %! [x, xdot] = dassl ("__f", x0, xdot0, t);
 %!
 %! y = [exp(-10*t), 1-exp(-10*t)];
 %!
-%! assert(all (all (abs (x - y) < tol)));
+%! assert (x, y, tol);
 
 %!test
 %! dassl_options ("absolute tolerance", eps);
-%! assert(dassl_options ("absolute tolerance") == eps);
+%! assert (dassl_options ("absolute tolerance") == eps);
 
-%!error <Invalid call to dassl_options> dassl_options ("foo", 1, 2);
-
+%!error dassl_options ("foo", 1, 2)
 */
--- a/src/DLD-FUNCTIONS/det.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/det.cc	Mon May 07 00:56:44 2012 +0200
@@ -245,11 +245,9 @@
 }
 
 /*
-
-%!assert(det ([1, 2; 3, 4]), -2, 10 * eps);
-%!assert(det (single([1, 2; 3, 4])), single(-2), 10 * eps ('single'));
-%!error <Invalid call to det> det ();
-%!error <Invalid call to det> det (1, 2);
-%!error det ([1, 2; 3, 4; 5, 6]);
-
+%!assert (det ([1, 2; 3, 4]), -2, 10*eps)
+%!assert (det (single ([1, 2; 3, 4])), single (-2), 10*eps ("single"))
+%!error det ()
+%!error det (1, 2)
+%!error <argument must be a square matrix> det ([1, 2; 3, 4; 5, 6])
 */
--- a/src/DLD-FUNCTIONS/dlmread.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/dlmread.cc	Mon May 07 00:56:44 2012 +0200
@@ -480,21 +480,20 @@
 }
 
 /*
-
 %!shared file
 %! file = tmpnam ();
 %! fid = fopen (file, "wt");
 %! fwrite (fid, "1, 2, 3\n4, 5, 6\n7, 8, 9\n10, 11, 12");
 %! fclose (fid);
 
-%!assert (dlmread (file), [1, 2, 3; 4, 5, 6; 7, 8, 9;10, 11, 12]);
-%!assert (dlmread (file, ","), [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12]);
-%!assert (dlmread (file, ",", [1, 0, 2, 1]), [4, 5; 7, 8]);
-%!assert (dlmread (file, ",", "B1..C2"), [2, 3; 5, 6]);
-%!assert (dlmread (file, ",", "B1:C2"), [2, 3; 5, 6]);
-%!assert (dlmread (file, ",", "..C2"), [1, 2, 3; 4, 5, 6]);
-%!assert (dlmread (file, ",", 0, 1), [2, 3; 5, 6; 8, 9; 11, 12]);
-%!assert (dlmread (file, ",", "B1.."), [2, 3; 5, 6; 8, 9; 11, 12]);
+%!assert (dlmread (file), [1, 2, 3; 4, 5, 6; 7, 8, 9;10, 11, 12])
+%!assert (dlmread (file, ","), [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12])
+%!assert (dlmread (file, ",", [1, 0, 2, 1]), [4, 5; 7, 8])
+%!assert (dlmread (file, ",", "B1..C2"), [2, 3; 5, 6])
+%!assert (dlmread (file, ",", "B1:C2"), [2, 3; 5, 6])
+%!assert (dlmread (file, ",", "..C2"), [1, 2, 3; 4, 5, 6])
+%!assert (dlmread (file, ",", 0, 1), [2, 3; 5, 6; 8, 9; 11, 12])
+%!assert (dlmread (file, ",", "B1.."), [2, 3; 5, 6; 8, 9; 11, 12])
 %!error (dlmread (file, ",", [0 1]))
 
 %!test
@@ -506,17 +505,16 @@
 %! fwrite (fid, "1, 2, 3\n4+4i, 5, 6\n7, 8, 9\n10, 11, 12");
 %! fclose (fid);
 
-%!assert (dlmread (file), [1, 2, 3; 4 + 4i, 5, 6; 7, 8, 9; 10, 11, 12]);
-%!assert (dlmread (file, ","), [1, 2, 3; 4 + 4i, 5, 6; 7, 8, 9; 10, 11, 12]);
-%!assert (dlmread (file, ",", [1, 0, 2, 1]), [4 + 4i, 5; 7, 8]);
-%!assert (dlmread (file, ",", "A2..B3"), [4 + 4i, 5; 7, 8]);
-%!assert (dlmread (file, ",", "A2:B3"), [4 + 4i, 5; 7, 8]);
-%!assert (dlmread (file, ",", "..B3"), [1, 2; 4 + 4i, 5; 7, 8]);
-%!assert (dlmread (file, ",", 1, 0), [4 + 4i, 5, 6; 7, 8, 9; 10, 11, 12]);
-%!assert (dlmread (file, ",", "A2.."), [4 + 4i, 5, 6; 7, 8, 9; 10, 11, 12]);
+%!assert (dlmread (file), [1, 2, 3; 4 + 4i, 5, 6; 7, 8, 9; 10, 11, 12])
+%!assert (dlmread (file, ","), [1, 2, 3; 4 + 4i, 5, 6; 7, 8, 9; 10, 11, 12])
+%!assert (dlmread (file, ",", [1, 0, 2, 1]), [4 + 4i, 5; 7, 8])
+%!assert (dlmread (file, ",", "A2..B3"), [4 + 4i, 5; 7, 8])
+%!assert (dlmread (file, ",", "A2:B3"), [4 + 4i, 5; 7, 8])
+%!assert (dlmread (file, ",", "..B3"), [1, 2; 4 + 4i, 5; 7, 8])
+%!assert (dlmread (file, ",", 1, 0), [4 + 4i, 5, 6; 7, 8, 9; 10, 11, 12])
+%!assert (dlmread (file, ",", "A2.."), [4 + 4i, 5, 6; 7, 8, 9; 10, 11, 12])
 %!error (dlmread (file, ",", [0 1]))
 
 %!test
 %! unlink (file);
-
 */
--- a/src/DLD-FUNCTIONS/dmperm.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/dmperm.cc	Mon May 07 00:56:44 2012 +0200
@@ -172,20 +172,19 @@
 }
 
 /*
-
 %!testif HAVE_CXSPARSE
-%! n=20;
-%! a=speye(n,n);a=a(randperm(n),:);
-%! assert(a(dmperm(a),:),speye(n))
+%! n = 20;
+%! a = speye (n,n);
+%! a = a(randperm (n),:);
+%! assert (a(dmperm (a),:), speye (n));
 
 %!testif HAVE_CXSPARSE
-%! n=20;
-%! d=0.2;
-%! a=tril(sprandn(n,n,d),-1)+speye(n,n);
-%! a=a(randperm(n),randperm(n));
-%! [p,q,r,s]=dmperm(a);
-%! assert(tril(a(p,q),-1),sparse(n,n))
-
+%! n = 20;
+%! d = 0.2;
+%! a = tril (sprandn (n,n,d), -1) + speye (n,n);
+%! a = a(randperm (n), randperm (n));
+%! [p,q,r,s] = dmperm (a);
+%! assert (tril (a(p,q), -1), sparse (n, n));
 */
 
 DEFUN_DLD (sprank, args, nargout,
@@ -221,11 +220,10 @@
 }
 
 /*
-
-%!error(sprank(1,2));
+%!testif HAVE_CXSPARSE
+%! assert (sprank (speye (20)), 20)
 %!testif HAVE_CXSPARSE
-%! assert(sprank(speye(20)), 20)
-%!testif HAVE_CXSPARSE
-%! assert(sprank([1,0,2,0;2,0,4,0]),2)
+%! assert (sprank ([1,0,2,0;2,0,4,0]), 2)
 
+%!error sprank (1,2)
 */
--- a/src/DLD-FUNCTIONS/dot.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/dot.cc	Mon May 07 00:56:44 2012 +0200
@@ -237,18 +237,16 @@
 }
 
 /*
-
-%! assert(dot ([1, 2], [2, 3]), 11);
+%!assert (dot ([1, 2], [2, 3]), 8)
 
 %!test
 %! x = [2, 1; 2, 1];
 %! y = [-0.5, 2; 0.5, -2];
-%! assert(dot (x, y), [0 0]);
+%! assert (dot (x, y), [0 0]);
 
 %!test
-%! x = [ 1+i, 3-i; 1-i, 3-i];
-%! assert(dot (x, x), [4, 20]);
-
+%! x = [1+i, 3-i; 1-i, 3-i];
+%! assert (dot (x, x), [4, 20]);
 */
 
 DEFUN_DLD (blkmm, args, ,
@@ -357,12 +355,10 @@
 }
 
 /*
-
 %!test
 %! x(:,:,1) = [1 2; 3 4];
 %! x(:,:,2) = [1 1; 1 1];
 %! z(:,:,1) = [7 10; 15 22];
 %! z(:,:,2) = [2 2; 2 2];
-%! assert(blkmm (x,x),z);
-
+%! assert (blkmm (x,x), z);
 */
--- a/src/DLD-FUNCTIONS/eig.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/eig.cc	Mon May 07 00:56:44 2012 +0200
@@ -254,83 +254,81 @@
 }
 
 /*
-
-%!assert(eig ([1, 2; 2, 1]), [-1; 3], sqrt (eps));
+%!assert (eig ([1, 2; 2, 1]), [-1; 3], sqrt (eps))
 
 %!test
 %! [v, d] = eig ([1, 2; 2, 1]);
 %! x = 1 / sqrt (2);
-%! assert(d, [-1, 0; 0, 3], sqrt (eps));
-%! assert(v, [-x, x; x, x], sqrt (eps));
+%! assert (d, [-1, 0; 0, 3], sqrt (eps));
+%! assert (v, [-x, x; x, x], sqrt (eps));
 
-%!assert(eig (single ([1, 2; 2, 1])), single([-1; 3]), sqrt (eps('single')));
+%!assert (eig (single ([1, 2; 2, 1])), single ([-1; 3]), sqrt (eps ("single")))
 
 %!test
-%! [v, d] = eig (single([1, 2; 2, 1]));
-%! x = single(1 / sqrt (2));
-%! assert(d, single([-1, 0; 0, 3]), sqrt (eps('single')));
-%! assert(v, [-x, x; x, x], sqrt (eps('single')));
+%! [v, d] = eig (single ([1, 2; 2, 1]));
+%! x = single (1 / sqrt (2));
+%! assert (d, single ([-1, 0; 0, 3]), sqrt (eps ("single")));
+%! assert (v, [-x, x; x, x], sqrt (eps ("single")));
 
 %!test
-%! A = [1, 2; -1, 1]; B = [3, 3; 1, 2];
+%! A = [1, 2; -1, 1];  B = [3, 3; 1, 2];
 %! [v, d] = eig (A, B);
-%! assert(A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps));
-%! assert(A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps));
+%! assert (A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps));
+%! assert (A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps));
 
 %!test
-%! A = single([1, 2; -1, 1]); B = single([3, 3; 1, 2]);
+%! A = single ([1, 2; -1, 1]);  B = single ([3, 3; 1, 2]);
 %! [v, d] = eig (A, B);
-%! assert(A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps('single')));
-%! assert(A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps('single')));
+%! assert (A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps ("single")));
+%! assert (A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps ("single")));
 
 %!test
-%! A = [1, 2; 2, 1]; B = [3, -2; -2, 3];
+%! A = [1, 2; 2, 1];  B = [3, -2; -2, 3];
 %! [v, d] = eig (A, B);
-%! assert(A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps));
-%! assert(A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps));
+%! assert (A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps));
+%! assert (A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps));
 
 %!test
-%! A = single([1, 2; 2, 1]); B = single([3, -2; -2, 3]);
+%! A = single ([1, 2; 2, 1]);  B = single ([3, -2; -2, 3]);
 %! [v, d] = eig (A, B);
-%! assert(A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps('single')));
-%! assert(A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps('single')));
+%! assert (A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps ("single")));
+%! assert (A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps ("single")));
 
 %!test
-%! A = [1+3i, 2+i; 2-i, 1+3i]; B = [5+9i, 2+i; 2-i, 5+9i];
+%! A = [1+3i, 2+i; 2-i, 1+3i];  B = [5+9i, 2+i; 2-i, 5+9i];
 %! [v, d] = eig (A, B);
-%! assert(A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps));
-%! assert(A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps));
+%! assert (A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps));
+%! assert (A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps));
 
 %!test
-%! A = single([1+3i, 2+i; 2-i, 1+3i]); B = single([5+9i, 2+i; 2-i, 5+9i]);
+%! A = single ([1+3i, 2+i; 2-i, 1+3i]);  B = single ([5+9i, 2+i; 2-i, 5+9i]);
 %! [v, d] = eig (A, B);
-%! assert(A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps('single')));
-%! assert(A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps('single')));
+%! assert (A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps ("single")));
+%! assert (A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps ("single")));
 
 %!test
-%! A = [1+3i, 2+3i; 3-8i, 8+3i]; B = [8+i, 3+i; 4-9i, 3+i];
+%! A = [1+3i, 2+3i; 3-8i, 8+3i];  B = [8+i, 3+i; 4-9i, 3+i];
 %! [v, d] = eig (A, B);
-%! assert(A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps));
-%! assert(A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps));
+%! assert (A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps));
+%! assert (A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps));
 
 %!test
-%! A = single([1+3i, 2+3i; 3-8i, 8+3i]); B = single([8+i, 3+i; 4-9i, 3+i]);
+%! A = single ([1+3i, 2+3i; 3-8i, 8+3i]);  B = single ([8+i, 3+i; 4-9i, 3+i]);
 %! [v, d] = eig (A, B);
-%! assert(A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps('single')));
-%! assert(A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps('single')));
+%! assert (A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps ("single")));
+%! assert (A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps ("single")));
 
 %!test
-%! A = [1, 2; 3, 8]; B = [8, 3; 4, 3];
+%! A = [1, 2; 3, 8];  B = [8, 3; 4, 3];
 %! [v, d] = eig (A, B);
-%! assert(A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps));
-%! assert(A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps));
+%! assert (A * v(:, 1), d(1, 1) * B * v(:, 1), sqrt (eps));
+%! assert (A * v(:, 2), d(2, 2) * B * v(:, 2), sqrt (eps));
 
-%!error <Invalid call to eig> eig ();
-%!error <Invalid call to eig> eig ([1, 2; 3, 4], [4, 3; 2, 1], 1);
-%!error eig ([1, 2; 3, 4], 2);
-%!error eig ([1, 2; 3, 4; 5, 6]);
-%!error eig ("abcd");
-%!error eig ([1 2 ; 2 3], "abcd");
-%!error eig (false, [1 2 ; 2 3]);
-
+%!error eig ()
+%!error eig ([1, 2; 3, 4], [4, 3; 2, 1], 1)
+%!error <EIG requires same size matrices> eig ([1, 2; 3, 4], 2)
+%!error <argument must be a square matrix> eig ([1, 2; 3, 4; 5, 6])
+%!error <wrong type argument> eig ("abcd")
+%!error <wrong type argument> eig ([1 2 ; 2 3], "abcd")
+%!error <wrong type argument> eig (false, [1 2 ; 2 3])
 */
--- a/src/DLD-FUNCTIONS/eigs.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/eigs.cc	Mon May 07 00:56:44 2012 +0200
@@ -769,764 +769,752 @@
 /* #### SPARSE MATRIX VERSIONS #### */
 
 /*
-
-%% Real positive definite tests, n must be even
+## Real positive definite tests, n must be even
 %!shared n, k, A, d0, d2
 %! n = 20;
 %! k = 4;
-%! A = sparse([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),4*ones(1,n),ones(1,n-2)]);
+%! A = sparse ([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),4*ones(1,n),ones(1,n-2)]);
 %! d0 = eig (A);
 %! d2 = sort (d0);
-%! [~, idx] = sort (abs(d0));
+%! [~, idx] = sort (abs (d0));
 %! d0 = d0(idx);
-%! rand("state", 42); % initialize generator to make eigs behavior reproducible
+%! rand ("state", 42); # initialize generator to make eigs behavior reproducible
 %!testif HAVE_ARPACK
 %! d1 = eigs (A, k);
 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A,k+1);
-%! assert (d1, d0(end:-1:(end-k)),1e-11);
+%! d1 = eigs (A, k+1);
+%! assert (d1, d0(end:-1:(end-k)), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'lm');
+%! d1 = eigs (A, k, "lm");
 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! d1 = eigs (A, k, 'sm');
+%! d1 = eigs (A, k, "sm");
 %! assert (d1, d0(k:-1:1), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'la');
+%! d1 = eigs (A, k, "la");
 %! assert (d1, d2(end:-1:(end-k+1)), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'sa');
+%! d1 = eigs (A, k, "sa");
 %! assert (d1, d2(1:k), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'be');
+%! d1 = eigs (A, k, "be");
 %! assert (d1, d2([1:floor(k/2), (end - ceil(k/2) + 1):end]), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k+1, 'be');
+%! d1 = eigs (A, k+1, "be");
 %! assert (d1, d2([1:floor((k+1)/2), (end - ceil((k+1)/2) + 1):end]), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
 %! d1 = eigs (A, k, 4.1);
-%! [~,idx0] = sort (abs(d0 - 4.1));
-%! [~,idx1] = sort (abs(d1 - 4.1));
+%! [~, idx0] = sort (abs (d0 - 4.1));
+%! [~, idx1] = sort (abs (d1 - 4.1));
 %! assert (d1(idx1), d0(idx0(1:k)), 1e-11);
 %!testif HAVE_ARPACK, HAVE_CHOLMOD
-%! d1 = eigs(A, speye(n), k, 'lm');
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! d1 = eigs (A, speye (n), k, "lm");
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! assert (eigs(A,k,4.1), eigs(A,speye(n),k,4.1), 1e-11);
+%! assert (eigs (A, k, 4.1), eigs (A, speye (n), k, 4.1), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
-%! d1 = eigs(A, speye(n), k, 'lm', opts);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! opts.cholB = true;
+%! d1 = eigs (A, speye (n), k, "lm", opts);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
+%! opts.cholB = true;
 %! q = [2:n,1];
-%! opts.permB=q;
-%! d1 = eigs(A, speye(n)(q,q), k, 'lm', opts);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! opts.permB = q;
+%! d1 = eigs (A, speye (n)(q,q), k, "lm", opts);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! opts.cholB=true;
-%! d1 = eigs(A, speye(n), k, 4.1, opts);
-%! assert (abs(d1), eigs(A,k,4.1), 1e-11);
+%! opts.cholB = true;
+%! d1 = eigs (A, speye (n), k, 4.1, opts);
+%! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! opts.cholB=true;
+%! opts.cholB = true;
 %! q = [2:n,1];
-%! opts.permB=q;
-%! d1 = eigs(A, speye(n)(q,q), k, 4.1, opts);
-%! assert (abs(d1), eigs(A,k,4.1), 1e-11);
+%! opts.permB = q;
+%! d1 = eigs (A, speye (n)(q,q), k, 4.1, opts);
+%! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! assert (eigs(A,k,4.1), eigs(A,speye(n),k,4.1), 1e-11);
+%! assert (eigs (A, k, 4.1), eigs (A, speye (n), k, 4.1), 1e-11);
 %!testif HAVE_ARPACK
 %! fn = @(x) A * x;
-%! opts.issym = 1; opts.isreal = 1;
-%! d1 = eigs (fn, n, k, 'lm', opts);
+%! opts.issym = 1;  opts.isreal = 1;
+%! d1 = eigs (fn, n, k, "lm", opts);
 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11);
 %!testif HAVE_ARPACK
 %! fn = @(x) A \ x;
-%! opts.issym = 1; opts.isreal = 1;
-%! d1 = eigs (fn, n, k, 'sm', opts);
+%! opts.issym = 1;  opts.isreal = 1;
+%! d1 = eigs (fn, n, k, "sm", opts);
 %! assert (d1, d0(k:-1:1), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! fn = @(x) (A - 4.1 * eye(n)) \ x;
-%! opts.issym = 1; opts.isreal = 1;
+%! fn = @(x) (A - 4.1 * eye (n)) \ x;
+%! opts.issym = 1;  opts.isreal = 1;
 %! d1 = eigs (fn, n, k, 4.1, opts);
-%! assert (d1, eigs(A,k,4.1), 1e-11);
+%! assert (d1, eigs (A, k, 4.1), 1e-11);
 %!testif HAVE_ARPACK
 %! AA = speye (10);
 %! fn = @(x) AA * x;
-%! opts.issym = 1; opts.isreal = 1;
-%! assert (eigs (fn, 10, AA, 3, 'lm', opts), [1; 1; 1],10*eps);
+%! opts.issym = 1;  opts.isreal = 1;
+%! assert (eigs (fn, 10, AA, 3, "lm", opts), [1; 1; 1], 10*eps);
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'lm');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "lm");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*speye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! [v1,d1] = eigs(A, k, 'sm');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "sm");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*speye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'la');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "la");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*speye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'sa');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "sa");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*speye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'be');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "be");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*speye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
-
 */
 
 /*
-
-%% Real unsymmetric tests
+## Real unsymmetric tests
 %!shared n, k, A, d0
 %! n = 20;
 %! k = 4;
-%! A =  sparse([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),1:n,-ones(1,n-2)]);
+%! A =  sparse ([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),1:n,-ones(1,n-2)]);
 %! d0 = eig (A);
-%! [~, idx] = sort (abs(d0));
+%! [~, idx] = sort (abs (d0));
 %! d0 = d0(idx);
-%! rand("state", 42); % initialize generator to make eigs behavior reproducible
+%! rand ("state", 42); % initialize generator to make eigs behavior reproducible
 %!testif HAVE_ARPACK
 %! d1 = eigs (A, k);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A,k+1);
-%! assert (abs(d1), abs(d0(end:-1:(end-k))),1e-11);
+%! d1 = eigs (A, k+1);
+%! assert (abs (d1), abs (d0(end:-1:(end-k))),1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'lm');
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! d1 = eigs (A, k, "lm");
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! d1 = eigs (A, k, 'sm');
-%! assert (abs(d1), abs(d0(1:k)), 1e-11);
+%! d1 = eigs (A, k, "sm");
+%! assert (abs (d1), abs (d0(1:k)), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'lr');
-%! [~, idx] = sort (real(d0));
+%! d1 = eigs (A, k, "lr");
+%! [~, idx] = sort (real (d0));
 %! d2 = d0(idx);
-%! assert (real(d1), real(d2(end:-1:(end-k+1))), 1e-11);
+%! assert (real (d1), real (d2(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'sr');
-%! [~, idx] = sort (real(abs(d0)));
+%! d1 = eigs (A, k, "sr");
+%! [~, idx] = sort (real (abs (d0)));
 %! d2 = d0(idx);
-%! assert (real(d1), real(d2(1:k)), 1e-11);
+%! assert (real (d1), real (d2(1:k)), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'li');
-%! [~, idx] = sort (imag(abs(d0)));
+%! d1 = eigs (A, k, "li");
+%! [~, idx] = sort (imag (abs (d0)));
 %! d2 = d0(idx);
-%! assert (sort(imag(d1)), sort(imag(d2(end:-1:(end-k+1)))), 1e-11);
+%! assert (sort (imag (d1)), sort (imag (d2(end:-1:(end-k+1)))), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'si');
-%! [~, idx] = sort (imag(abs(d0)));
+%! d1 = eigs (A, k, "si");
+%! [~, idx] = sort (imag (abs (d0)));
 %! d2 = d0(idx);
-%! assert (sort(imag(d1)), sort(imag(d2(1:k))), 1e-11);
+%! assert (sort (imag (d1)), sort (imag (d2(1:k))), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
 %! d1 = eigs (A, k, 4.1);
-%! [~,idx0] = sort (abs(d0 - 4.1));
-%! [~,idx1] = sort (abs(d1 - 4.1));
-%! assert (abs(d1(idx1)), abs(d0(idx0(1:k))), 1e-11);
-%! assert (sort(imag(d1(idx1))), sort(imag(d0(idx0(1:k)))), 1e-11);
+%! [~, idx0] = sort (abs (d0 - 4.1));
+%! [~, idx1] = sort (abs (d1 - 4.1));
+%! assert (abs (d1(idx1)), abs (d0(idx0(1:k))), 1e-11);
+%! assert (sort (imag (d1(idx1))), sort (imag (d0(idx0(1:k)))), 1e-11);
 %!testif HAVE_ARPACK, HAVE_CHOLMOD
-%! d1 = eigs(A, speye(n), k, 'lm');
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! d1 = eigs (A, speye (n), k, "lm");
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
-%! d1 = eigs(A, speye(n), k, 'lm', opts);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! opts.cholB = true;
+%! d1 = eigs (A, speye (n), k, "lm", opts);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
+%! opts.cholB = true;
 %! q = [2:n,1];
-%! opts.permB=q;
-%! d1 = eigs(A, speye(n)(q,q), k, 'lm', opts);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! opts.permB = q;
+%! d1 = eigs (A, speye (n)(q,q), k, "lm", opts);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! opts.cholB=true;
-%! d1 = eigs(A, speye(n), k, 4.1, opts);
-%! assert (abs(d1), eigs(A,k,4.1), 1e-11);
+%! opts.cholB = true;
+%! d1 = eigs (A, speye (n), k, 4.1, opts);
+%! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! opts.cholB=true;
+%! opts.cholB = true;
 %! q = [2:n,1];
-%! opts.permB=q;
-%! d1 = eigs(A, speye(n)(q,q), k, 4.1, opts);
-%! assert (abs(d1), eigs(A,k,4.1), 1e-11);
+%! opts.permB = q;
+%! d1 = eigs (A, speye (n)(q,q), k, 4.1, opts);
+%! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! assert (abs(eigs(A,k,4.1)), abs(eigs(A,speye(n),k,4.1)), 1e-11);
+%! assert (abs (eigs (A, k, 4.1)), abs (eigs (A, speye (n), k, 4.1)), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! assert (sort(imag(eigs(A,k,4.1))), sort(imag(eigs(A,speye(n),k,4.1))), 1e-11);
+%! assert (sort (imag (eigs (A, k, 4.1))), sort (imag (eigs (A, speye (n), k, 4.1))), 1e-11);
 %!testif HAVE_ARPACK
 %! fn = @(x) A * x;
-%! opts.issym = 0; opts.isreal = 1;
-%! d1 = eigs (fn, n, k, 'lm', opts);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! opts.issym = 0;  opts.isreal = 1;
+%! d1 = eigs (fn, n, k, "lm", opts);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
 %! fn = @(x) A \ x;
-%! opts.issym = 0; opts.isreal = 1;
-%! d1 = eigs (fn, n, k, 'sm', opts);
-%! assert (abs(d1), d0(1:k), 1e-11);
+%! opts.issym = 0;  opts.isreal = 1;
+%! d1 = eigs (fn, n, k, "sm", opts);
+%! assert (abs (d1), d0(1:k), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! fn = @(x) (A - 4.1 * eye(n)) \ x;
-%! opts.issym = 0; opts.isreal = 1;
+%! fn = @(x) (A - 4.1 * eye (n)) \ x;
+%! opts.issym = 0;  opts.isreal = 1;
 %! d1 = eigs (fn, n, k, 4.1, opts);
-%! assert (abs(d1), eigs(A,k,4.1), 1e-11);
+%! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'lm');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "lm");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*speye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! [v1,d1] = eigs(A, k, 'sm');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "sm");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*speye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'lr');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "lr");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*speye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'sr');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "sr");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*speye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'li');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "li");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*speye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'si');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "si");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*speye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
-
 */
 
 /*
-
-%% Complex hermitian tests
+## Complex hermitian tests
 %!shared n, k, A, d0
 %! n = 20;
 %! k = 4;
-%! A = sparse([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[1i*ones(1,n-2),4*ones(1,n),-1i*ones(1,n-2)]);
+%! A = sparse ([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[1i*ones(1,n-2),4*ones(1,n),-1i*ones(1,n-2)]);
 %! d0 = eig (A);
-%! [~, idx] = sort (abs(d0));
+%! [~, idx] = sort (abs (d0));
 %! d0 = d0(idx);
-%! rand("state", 42); % initialize generator to make eigs behavior reproducible
+%! rand ("state", 42); % initialize generator to make eigs behavior reproducible
 %!testif HAVE_ARPACK
 %! d1 = eigs (A, k);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A,k+1);
-%! assert (abs(d1), abs(d0(end:-1:(end-k))),1e-11);
+%! d1 = eigs (A, k+1);
+%! assert (abs (d1), abs (d0(end:-1:(end-k))),1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'lm');
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! d1 = eigs (A, k, "lm");
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! d1 = eigs (A, k, 'sm');
-%! assert (abs(d1), abs(d0(1:k)), 1e-11);
+%! d1 = eigs (A, k, "sm");
+%! assert (abs (d1), abs (d0(1:k)), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'lr');
-%! [~, idx] = sort (real(abs(d0)));
+%! d1 = eigs (A, k, "lr");
+%! [~, idx] = sort (real (abs (d0)));
 %! d2 = d0(idx);
-%! assert (real(d1), real(d2(end:-1:(end-k+1))), 1e-11);
+%! assert (real (d1), real (d2(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'sr');
-%! [~, idx] = sort (real(abs(d0)));
+%! d1 = eigs (A, k, "sr");
+%! [~, idx] = sort (real (abs (d0)));
 %! d2 = d0(idx);
-%! assert (real(d1), real(d2(1:k)), 1e-11);
+%! assert (real (d1), real (d2(1:k)), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'li');
-%! [~, idx] = sort (imag(abs(d0)));
+%! d1 = eigs (A, k, "li");
+%! [~, idx] = sort (imag (abs (d0)));
 %! d2 = d0(idx);
-%! assert (sort(imag(d1)), sort(imag(d2(end:-1:(end-k+1)))), 1e-11);
+%! assert (sort (imag (d1)), sort (imag (d2(end:-1:(end-k+1)))), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'si');
-%! [~, idx] = sort (imag(abs(d0)));
+%! d1 = eigs (A, k, "si");
+%! [~, idx] = sort (imag (abs (d0)));
 %! d2 = d0(idx);
-%! assert (sort(imag(d1)), sort(imag(d2(1:k))), 1e-11);
+%! assert (sort (imag (d1)), sort (imag (d2(1:k))), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
 %! d1 = eigs (A, k, 4.1);
-%! [~,idx0] = sort (abs(d0 - 4.1));
-%! [~,idx1] = sort (abs(d1 - 4.1));
-%! assert (abs(d1(idx1)), abs(d0(idx0(1:k))), 1e-11);
-%! assert (sort(imag(d1(idx1))), sort(imag(d0(idx0(1:k)))), 1e-11);
+%! [~, idx0] = sort (abs (d0 - 4.1));
+%! [~, idx1] = sort (abs (d1 - 4.1));
+%! assert (abs (d1(idx1)), abs (d0(idx0(1:k))), 1e-11);
+%! assert (sort (imag (d1(idx1))), sort (imag (d0(idx0(1:k)))), 1e-11);
 %!testif HAVE_ARPACK, HAVE_CHOLMOD
-%! d1 = eigs(A, speye(n), k, 'lm');
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! d1 = eigs (A, speye (n), k, "lm");
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
-%! d1 = eigs(A, speye(n), k, 'lm', opts);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! opts.cholB = true;
+%! d1 = eigs (A, speye (n), k, "lm", opts);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
+%! opts.cholB = true;
 %! q = [2:n,1];
-%! opts.permB=q;
-%! d1 = eigs(A, speye(n)(q,q), k, 'lm', opts);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! opts.permB = q;
+%! d1 = eigs (A, speye (n)(q,q), k, "lm", opts);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! opts.cholB=true;
-%! d1 = eigs(A, speye(n), k, 4.1, opts);
-%! assert (abs(abs(d1)), abs(eigs(A,k,4.1)), 1e-11);
-%! assert (sort(imag(abs(d1))), sort(imag(eigs(A,k,4.1))), 1e-11);
+%! opts.cholB = true;
+%! d1 = eigs (A, speye (n), k, 4.1, opts);
+%! assert (abs (abs (d1)), abs (eigs (A, k, 4.1)), 1e-11);
+%! assert (sort (imag (abs (d1))), sort (imag (eigs (A, k, 4.1))), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! opts.cholB=true;
+%! opts.cholB = true;
 %! q = [2:n,1];
-%! opts.permB=q;
-%! d1 = eigs(A, speye(n)(q,q), k, 4.1, opts);
-%! assert (abs(abs(d1)), abs(eigs(A,k,4.1)), 1e-11);
-%! assert (sort(imag(abs(d1))), sort(imag(eigs(A,k,4.1))), 1e-11);
+%! opts.permB = q;
+%! d1 = eigs (A, speye (n)(q,q), k, 4.1, opts);
+%! assert (abs (abs (d1)), abs (eigs (A, k, 4.1)), 1e-11);
+%! assert (sort (imag (abs (d1))), sort (imag (eigs (A, k, 4.1))), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! assert (abs(eigs(A,k,4.1)), abs(eigs(A,speye(n),k,4.1)), 1e-11);
+%! assert (abs (eigs (A, k, 4.1)), abs (eigs (A, speye (n), k, 4.1)), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! assert (sort(imag(eigs(A,k,4.1))), sort(imag(eigs(A,speye(n),k,4.1))), 1e-11);
+%! assert (sort (imag (eigs (A, k, 4.1))), sort (imag (eigs (A, speye (n), k, 4.1))), 1e-11);
 %!testif HAVE_ARPACK
 %! fn = @(x) A * x;
-%! opts.issym = 0; opts.isreal = 0;
-%! d1 = eigs (fn, n, k, 'lm', opts);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! opts.issym = 0;  opts.isreal = 0;
+%! d1 = eigs (fn, n, k, "lm", opts);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
 %! fn = @(x) A \ x;
-%! opts.issym = 0; opts.isreal = 0;
-%! d1 = eigs (fn, n, k, 'sm', opts);
-%! assert (abs(d1), d0(1:k), 1e-11);
+%! opts.issym = 0;  opts.isreal = 0;
+%! d1 = eigs (fn, n, k, "sm", opts);
+%! assert (abs (d1), d0(1:k), 1e-11);
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! fn = @(x) (A - 4.1 * eye(n)) \ x;
-%! opts.issym = 0; opts.isreal = 0;
+%! fn = @(x) (A - 4.1 * eye (n)) \ x;
+%! opts.issym = 0;  opts.isreal = 0;
 %! d1 = eigs (fn, n, k, 4.1, opts);
-%! assert (abs(d1), eigs(A,k,4.1), 1e-11);
+%! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'lm');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "lm");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*speye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! [v1,d1] = eigs(A, k, 'sm');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "sm");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*speye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'lr');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "lr");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*speye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'sr');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "sr");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*speye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'li');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "li");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*speye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'si');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "si");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*speye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*speye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
-
 */
 
 /* #### FULL MATRIX VERSIONS #### */
 
 /*
-
-%% Real positive definite tests, n must be even
+## Real positive definite tests, n must be even
 %!shared n, k, A, d0, d2
 %! n = 20;
 %! k = 4;
-%! A = full(sparse([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),4*ones(1,n),ones(1,n-2)]));
+%! A = full (sparse ([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),4*ones(1,n),ones(1,n-2)]));
 %! d0 = eig (A);
 %! d2 = sort (d0);
-%! [~, idx] = sort (abs(d0));
+%! [~, idx] = sort (abs (d0));
 %! d0 = d0(idx);
-%! rand("state", 42); % initialize generator to make eigs behavior reproducible
+%! rand ("state", 42); % initialize generator to make eigs behavior reproducible
 %!testif HAVE_ARPACK
 %! d1 = eigs (A, k);
 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A,k+1);
+%! d1 = eigs (A, k+1);
 %! assert (d1, d0(end:-1:(end-k)),1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'lm');
+%! d1 = eigs (A, k, "lm");
 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'sm');
+%! d1 = eigs (A, k, "sm");
 %! assert (d1, d0(k:-1:1), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'la');
+%! d1 = eigs (A, k, "la");
 %! assert (d1, d2(end:-1:(end-k+1)), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'sa');
+%! d1 = eigs (A, k, "sa");
 %! assert (d1, d2(1:k), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'be');
+%! d1 = eigs (A, k, "be");
 %! assert (d1, d2([1:floor(k/2), (end - ceil(k/2) + 1):end]), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k+1, 'be');
+%! d1 = eigs (A, k+1, "be");
 %! assert (d1, d2([1:floor((k+1)/2), (end - ceil((k+1)/2) + 1):end]), 1e-11);
 %!testif HAVE_ARPACK
 %! d1 = eigs (A, k, 4.1);
-%! [~,idx0] = sort (abs(d0 - 4.1));
-%! [~,idx1] = sort (abs(d1 - 4.1));
+%! [~, idx0] = sort (abs (d0 - 4.1));
+%! [~, idx1] = sort (abs (d1 - 4.1));
 %! assert (d1(idx1), d0(idx0(1:k)), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs(A, eye(n), k, 'lm');
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! d1 = eigs (A, eye (n), k, "lm");
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! assert (eigs(A,k,4.1), eigs(A,eye(n),k,4.1), 1e-11);
+%! assert (eigs (A, k, 4.1), eigs (A, eye (n), k, 4.1), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
-%! d1 = eigs(A, eye(n), k, 'lm', opts);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! opts.cholB = true;
+%! d1 = eigs (A, eye (n), k, "lm", opts);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
+%! opts.cholB = true;
 %! q = [2:n,1];
-%! opts.permB=q;
-%! d1 = eigs(A, eye(n)(q,q), k, 'lm', opts);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! opts.permB = q;
+%! d1 = eigs (A, eye (n)(q,q), k, "lm", opts);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
-%! d1 = eigs(A, eye(n), k, 4.1, opts);
-%! assert (abs(d1), eigs(A,k,4.1), 1e-11);
+%! opts.cholB = true;
+%! d1 = eigs (A, eye (n), k, 4.1, opts);
+%! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
+%! opts.cholB = true;
 %! q = [2:n,1];
-%! opts.permB=q;
-%! d1 = eigs(A, eye(n)(q,q), k, 4.1, opts);
-%! assert (abs(d1), eigs(A,k,4.1), 1e-11);
+%! opts.permB = q;
+%! d1 = eigs (A, eye (n)(q,q), k, 4.1, opts);
+%! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
 %!testif HAVE_ARPACK
-%! assert (eigs(A,k,4.1), eigs(A,eye(n),k,4.1), 1e-11);
+%! assert (eigs (A, k, 4.1), eigs (A, eye (n), k, 4.1), 1e-11);
 %!testif HAVE_ARPACK
 %! fn = @(x) A * x;
-%! opts.issym = 1; opts.isreal = 1;
-%! d1 = eigs (fn, n, k, 'lm', opts);
+%! opts.issym = 1;  opts.isreal = 1;
+%! d1 = eigs (fn, n, k, "lm", opts);
 %! assert (d1, d0(end:-1:(end-k+1)), 1e-11);
 %!testif HAVE_ARPACK
 %! fn = @(x) A \ x;
-%! opts.issym = 1; opts.isreal = 1;
-%! d1 = eigs (fn, n, k, 'sm', opts);
+%! opts.issym = 1;  opts.isreal = 1;
+%! d1 = eigs (fn, n, k, "sm", opts);
 %! assert (d1, d0(k:-1:1), 1e-11);
 %!testif HAVE_ARPACK
-%! fn = @(x) (A - 4.1 * eye(n)) \ x;
-%! opts.issym = 1; opts.isreal = 1;
+%! fn = @(x) (A - 4.1 * eye (n)) \ x;
+%! opts.issym = 1;  opts.isreal = 1;
 %! d1 = eigs (fn, n, k, 4.1, opts);
-%! assert (d1, eigs(A,k,4.1), 1e-11);
+%! assert (d1, eigs (A, k, 4.1), 1e-11);
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'lm');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "lm");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*eye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'sm');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "sm");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*eye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'la');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "la");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*eye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'sa');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "sa");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*eye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'be');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "be");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*eye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
-
 */
 
 /*
-
-%% Real unsymmetric tests
+## Real unsymmetric tests
 %!shared n, k, A, d0
 %! n = 20;
 %! k = 4;
-%! A =  full(sparse([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),1:n,-ones(1,n-2)]));
+%! A =  full (sparse ([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),1:n,-ones(1,n-2)]));
 %! d0 = eig (A);
-%! [~, idx] = sort (abs(d0));
+%! [~, idx] = sort (abs (d0));
 %! d0 = d0(idx);
-%! rand("state", 42); % initialize generator to make eigs behavior reproducible
+%! rand ("state", 42); % initialize generator to make eigs behavior reproducible
 %!testif HAVE_ARPACK
 %! d1 = eigs (A, k);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A,k+1);
-%! assert (abs(d1), abs(d0(end:-1:(end-k))),1e-11);
+%! d1 = eigs (A, k+1);
+%! assert (abs (d1), abs (d0(end:-1:(end-k))),1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'lm');
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! d1 = eigs (A, k, "lm");
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'sm');
-%! assert (abs(d1), abs(d0(1:k)), 1e-11);
+%! d1 = eigs (A, k, "sm");
+%! assert (abs (d1), abs (d0(1:k)), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'lr');
-%! [~, idx] = sort (real(d0));
+%! d1 = eigs (A, k, "lr");
+%! [~, idx] = sort (real (d0));
 %! d2 = d0(idx);
-%! assert (real(d1), real(d2(end:-1:(end-k+1))), 1e-11);
+%! assert (real (d1), real (d2(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'sr');
-%! [~, idx] = sort (real(abs(d0)));
+%! d1 = eigs (A, k, "sr");
+%! [~, idx] = sort (real (abs (d0)));
 %! d2 = d0(idx);
-%! assert (real(d1), real(d2(1:k)), 1e-11);
+%! assert (real (d1), real (d2(1:k)), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'li');
-%! [~, idx] = sort (imag(abs(d0)));
+%! d1 = eigs (A, k, "li");
+%! [~, idx] = sort (imag (abs (d0)));
 %! d2 = d0(idx);
-%! assert (sort(imag(d1)), sort(imag(d2(end:-1:(end-k+1)))), 1e-11);
+%! assert (sort (imag (d1)), sort (imag (d2(end:-1:(end-k+1)))), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'si');
-%! [~, idx] = sort (imag(abs(d0)));
+%! d1 = eigs (A, k, "si");
+%! [~, idx] = sort (imag (abs (d0)));
 %! d2 = d0(idx);
-%! assert (sort(imag(d1)), sort(imag(d2(1:k))), 1e-11);
+%! assert (sort (imag (d1)), sort (imag (d2(1:k))), 1e-11);
 %!testif HAVE_ARPACK
 %! d1 = eigs (A, k, 4.1);
-%! [~,idx0] = sort (abs(d0 - 4.1));
-%! [~,idx1] = sort (abs(d1 - 4.1));
-%! assert (abs(d1(idx1)), abs(d0(idx0(1:k))), 1e-11);
-%! assert (sort(imag(d1(idx1))), sort(imag(d0(idx0(1:k)))), 1e-11);
+%! [~, idx0] = sort (abs (d0 - 4.1));
+%! [~, idx1] = sort (abs (d1 - 4.1));
+%! assert (abs (d1(idx1)), abs (d0(idx0(1:k))), 1e-11);
+%! assert (sort (imag (d1(idx1))), sort (imag (d0(idx0(1:k)))), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs(A, eye(n), k, 'lm');
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! d1 = eigs (A, eye (n), k, "lm");
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
-%! d1 = eigs(A, eye(n), k, 'lm', opts);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! opts.cholB = true;
+%! d1 = eigs (A, eye (n), k, "lm", opts);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
+%! opts.cholB = true;
 %! q = [2:n,1];
-%! opts.permB=q;
-%! d1 = eigs(A, eye(n)(q,q), k, 'lm', opts);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! opts.permB = q;
+%! d1 = eigs (A, eye (n)(q,q), k, "lm", opts);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
-%! d1 = eigs(A, eye(n), k, 4.1, opts);
-%! assert (abs(d1), eigs(A,k,4.1), 1e-11);
+%! opts.cholB = true;
+%! d1 = eigs (A, eye (n), k, 4.1, opts);
+%! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
+%! opts.cholB = true;
 %! q = [2:n,1];
-%! opts.permB=q;
-%! d1 = eigs(A, eye(n)(q,q), k, 4.1, opts);
-%! assert (abs(d1), eigs(A,k,4.1), 1e-11);
+%! opts.permB = q;
+%! d1 = eigs (A, eye (n)(q,q), k, 4.1, opts);
+%! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
 %!testif HAVE_ARPACK
-%! assert (abs(eigs(A,k,4.1)), abs(eigs(A,eye(n),k,4.1)), 1e-11);
+%! assert (abs (eigs (A, k, 4.1)), abs (eigs (A, eye (n), k, 4.1)), 1e-11);
 %!testif HAVE_ARPACK
-%! assert (sort(imag(eigs(A,k,4.1))), sort(imag(eigs(A,eye(n),k,4.1))), 1e-11);
+%! assert (sort (imag (eigs (A, k, 4.1))), sort (imag (eigs (A, eye (n), k, 4.1))), 1e-11);
 %!testif HAVE_ARPACK
 %! fn = @(x) A * x;
-%! opts.issym = 0; opts.isreal = 1;
-%! d1 = eigs (fn, n, k, 'lm', opts);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! opts.issym = 0;  opts.isreal = 1;
+%! d1 = eigs (fn, n, k, "lm", opts);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
 %! fn = @(x) A \ x;
-%! opts.issym = 0; opts.isreal = 1;
-%! d1 = eigs (fn, n, k, 'sm', opts);
-%! assert (abs(d1), d0(1:k), 1e-11);
+%! opts.issym = 0;  opts.isreal = 1;
+%! d1 = eigs (fn, n, k, "sm", opts);
+%! assert (abs (d1), d0(1:k), 1e-11);
 %!testif HAVE_ARPACK
-%! fn = @(x) (A - 4.1 * eye(n)) \ x;
-%! opts.issym = 0; opts.isreal = 1;
+%! fn = @(x) (A - 4.1 * eye (n)) \ x;
+%! opts.issym = 0;  opts.isreal = 1;
 %! d1 = eigs (fn, n, k, 4.1, opts);
-%! assert (abs(d1), eigs(A,k,4.1), 1e-11);
+%! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'lm');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "lm");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*eye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'sm');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "sm");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*eye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'lr');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "lr");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*eye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'sr');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "sr");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*eye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'li');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "li");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*eye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'si');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "si");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*eye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
-
 */
 
 /*
-
-%% Complex hermitian tests
+## Complex hermitian tests
 %!shared n, k, A, d0
 %! n = 20;
 %! k = 4;
-%! A = full(sparse([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[1i*ones(1,n-2),4*ones(1,n),-1i*ones(1,n-2)]));
+%! A = full (sparse ([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[1i*ones(1,n-2),4*ones(1,n),-1i*ones(1,n-2)]));
 %! d0 = eig (A);
-%! [~, idx] = sort (abs(d0));
+%! [~, idx] = sort (abs (d0));
 %! d0 = d0(idx);
-%! rand("state", 42); % initialize generator to make eigs behavior reproducible
+%! rand ("state", 42); % initialize generator to make eigs behavior reproducible
 %!testif HAVE_ARPACK
 %! d1 = eigs (A, k);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A,k+1);
-%! assert (abs(d1), abs(d0(end:-1:(end-k))),1e-11);
+%! d1 = eigs (A, k+1);
+%! assert (abs (d1), abs (d0(end:-1:(end-k))),1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'lm');
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! d1 = eigs (A, k, "lm");
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'sm');
-%! assert (abs(d1), abs(d0(1:k)), 1e-11);
+%! d1 = eigs (A, k, "sm");
+%! assert (abs (d1), abs (d0(1:k)), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'lr');
-%! [~, idx] = sort (real(abs(d0)));
+%! d1 = eigs (A, k, "lr");
+%! [~, idx] = sort (real (abs (d0)));
 %! d2 = d0(idx);
-%! assert (real(d1), real(d2(end:-1:(end-k+1))), 1e-11);
+%! assert (real (d1), real (d2(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'sr');
-%! [~, idx] = sort (real(abs(d0)));
+%! d1 = eigs (A, k, "sr");
+%! [~, idx] = sort (real (abs (d0)));
 %! d2 = d0(idx);
-%! assert (real(d1), real(d2(1:k)), 1e-11);
+%! assert (real (d1), real (d2(1:k)), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'li');
-%! [~, idx] = sort (imag(abs(d0)));
+%! d1 = eigs (A, k, "li");
+%! [~, idx] = sort (imag (abs (d0)));
 %! d2 = d0(idx);
-%! assert (sort(imag(d1)), sort(imag(d2(end:-1:(end-k+1)))), 1e-11);
+%! assert (sort (imag (d1)), sort (imag (d2(end:-1:(end-k+1)))), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs (A, k, 'si');
-%! [~, idx] = sort (imag(abs(d0)));
+%! d1 = eigs (A, k, "si");
+%! [~, idx] = sort (imag (abs (d0)));
 %! d2 = d0(idx);
-%! assert (sort(imag(d1)), sort(imag(d2(1:k))), 1e-11);
+%! assert (sort (imag (d1)), sort (imag (d2(1:k))), 1e-11);
 %!testif HAVE_ARPACK
 %! d1 = eigs (A, k, 4.1);
-%! [~,idx0] = sort (abs(d0 - 4.1));
-%! [~,idx1] = sort (abs(d1 - 4.1));
-%! assert (abs(d1(idx1)), abs(d0(idx0(1:k))), 1e-11);
-%! assert (sort(imag(d1(idx1))), sort(imag(d0(idx0(1:k)))), 1e-11);
+%! [~, idx0] = sort (abs (d0 - 4.1));
+%! [~, idx1] = sort (abs (d1 - 4.1));
+%! assert (abs (d1(idx1)), abs (d0(idx0(1:k))), 1e-11);
+%! assert (sort (imag (d1(idx1))), sort (imag (d0(idx0(1:k)))), 1e-11);
 %!testif HAVE_ARPACK
-%! d1 = eigs(A, eye(n), k, 'lm');
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! d1 = eigs (A, eye (n), k, "lm");
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
-%! d1 = eigs(A, eye(n), k, 'lm', opts);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! opts.cholB = true;
+%! d1 = eigs (A, eye (n), k, "lm", opts);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
+%! opts.cholB = true;
 %! q = [2:n,1];
-%! opts.permB=q;
-%! d1 = eigs(A, eye(n)(q,q), k, 'lm', opts);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! opts.permB = q;
+%! d1 = eigs (A, eye (n)(q,q), k, "lm", opts);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
-%! d1 = eigs(A, eye(n), k, 4.1, opts);
-%! assert (abs(abs(d1)), abs(eigs(A,k,4.1)), 1e-11);
-%! assert (sort(imag(abs(d1))), sort(imag(eigs(A,k,4.1))), 1e-11);
+%! opts.cholB = true;
+%! d1 = eigs (A, eye (n), k, 4.1, opts);
+%! assert (abs (abs (d1)), abs (eigs (A, k, 4.1)), 1e-11);
+%! assert (sort (imag (abs (d1))), sort (imag (eigs (A, k, 4.1))), 1e-11);
 %!testif HAVE_ARPACK
-%! opts.cholB=true;
+%! opts.cholB = true;
 %! q = [2:n,1];
-%! opts.permB=q;
-%! d1 = eigs(A, eye(n)(q,q), k, 4.1, opts);
-%! assert (abs(abs(d1)), abs(eigs(A,k,4.1)), 1e-11);
-%! assert (sort(imag(abs(d1))), sort(imag(eigs(A,k,4.1))), 1e-11);
+%! opts.permB = q;
+%! d1 = eigs (A, eye (n)(q,q), k, 4.1, opts);
+%! assert (abs (abs (d1)), abs (eigs (A, k, 4.1)), 1e-11);
+%! assert (sort (imag (abs (d1))), sort (imag (eigs (A, k, 4.1))), 1e-11);
 %!testif HAVE_ARPACK
-%! assert (abs(eigs(A,k,4.1)), abs(eigs(A,eye(n),k,4.1)), 1e-11);
+%! assert (abs (eigs (A, k, 4.1)), abs (eigs (A, eye (n), k, 4.1)), 1e-11);
 %!testif HAVE_ARPACK
-%! assert (sort(imag(eigs(A,k,4.1))), sort(imag(eigs(A,eye(n),k,4.1))), 1e-11);
+%! assert (sort (imag (eigs (A, k, 4.1))), sort (imag (eigs (A, eye (n), k, 4.1))), 1e-11);
 %!testif HAVE_ARPACK
 %! fn = @(x) A * x;
-%! opts.issym = 0; opts.isreal = 0;
-%! d1 = eigs (fn, n, k, 'lm', opts);
-%! assert (abs(d1), abs(d0(end:-1:(end-k+1))), 1e-11);
+%! opts.issym = 0;  opts.isreal = 0;
+%! d1 = eigs (fn, n, k, "lm", opts);
+%! assert (abs (d1), abs (d0(end:-1:(end-k+1))), 1e-11);
 %!testif HAVE_ARPACK
 %! fn = @(x) A \ x;
-%! opts.issym = 0; opts.isreal = 0;
-%! d1 = eigs (fn, n, k, 'sm', opts);
-%! assert (abs(d1), d0(1:k), 1e-11);
+%! opts.issym = 0;  opts.isreal = 0;
+%! d1 = eigs (fn, n, k, "sm", opts);
+%! assert (abs (d1), d0(1:k), 1e-11);
 %!testif HAVE_ARPACK
-%! fn = @(x) (A - 4.1 * eye(n)) \ x;
-%! opts.issym = 0; opts.isreal = 0;
+%! fn = @(x) (A - 4.1 * eye (n)) \ x;
+%! opts.issym = 0;  opts.isreal = 0;
 %! d1 = eigs (fn, n, k, 4.1, opts);
-%! assert (abs(d1), eigs(A,k,4.1), 1e-11);
+%! assert (abs (d1), eigs (A, k, 4.1), 1e-11);
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'lm');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "lm");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*eye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'sm');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "sm");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*eye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'lr');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "lr");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*eye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'sr');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "sr");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*eye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'li');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "li");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*eye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
 %!testif HAVE_ARPACK
-%! [v1,d1] = eigs(A, k, 'si');
-%! d1 = diag(d1);
+%! [v1,d1] = eigs (A, k, "si");
+%! d1 = diag (d1);
 %! for i=1:k
-%!  assert(max(abs((A - d1(i)*eye(n))*v1(:,i))),0.,1e-11)
+%!   assert (max (abs ((A - d1(i)*eye (n))*v1(:,i))), 0, 1e-11);
 %! endfor
-
 */
--- a/src/DLD-FUNCTIONS/fft.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/fft.cc	Mon May 07 00:56:44 2012 +0200
@@ -177,24 +177,23 @@
 }
 
 /*
+%!assert (fft ([]), [])
+%!assert (fft (zeros (10,0)), zeros (10,0))
+%!assert (fft (zeros (0,10)), zeros (0,10))
+%!assert (fft (0), 0)
+%!assert (fft (1), 1)
+%!assert (fft (ones (2,2)), [2,2; 0,0])
+%!assert (fft (eye (2,2)), [1,1; 1,-1])
 
-%!error(fft())
-%!assert(fft([]), [])
-%!assert(fft(zeros(10,0)), zeros(10,0))
-%!assert(fft(zeros(0,10)), zeros(0,10))
-%!assert(fft(0), 0)
-%!assert(fft(1), 1)
-%!assert(fft(ones(2,2)), [2,2; 0,0])
-%!assert(fft(eye(2,2)), [1,1; 1,-1])
+%!assert (fft (single ([])), single ([]))
+%!assert (fft (zeros (10,0,"single")), zeros (10,0,"single"))
+%!assert (fft (zeros (0,10,"single")), zeros (0,10,"single"))
+%!assert (fft (single (0)), single (0))
+%!assert (fft (single (1)), single (1))
+%!assert (fft (ones (2,2,"single")), single ([2,2; 0,0]))
+%!assert (fft (eye (2,2,"single")), single ([1,1; 1,-1]))
 
-%!assert(fft(single([])), single([]))
-%!assert(fft(zeros(10,0,'single')), zeros(10,0,'single'))
-%!assert(fft(zeros(0,10,'single')), zeros(0,10,'single'))
-%!assert(fft(single(0)), single(0))
-%!assert(fft(single(1)), single(1))
-%!assert(fft(ones(2,2,'single')), single([2,2; 0,0]))
-%!assert(fft(eye(2,2,'single')), single([1,1; 1,-1]))
-
+%!error (fft ())
 */
 
 
@@ -256,67 +255,65 @@
 }
 
 /*
+%% Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
+%%         Comalco Research and Technology
+%%         02 May 2000
+%!test
+%! N = 64;
+%! n = 4;
+%! t = 2*pi*(0:1:N-1)/N;
+%! s = cos (n*t);
+%! S = fft (s);
+%!
+%! answer = zeros (size (t));
+%! answer(n+1) = N/2;
+%! answer(N-n+1) = N/2;
+%!
+%! assert (S, answer, 4*N*eps);
 
 %% Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
 %%         Comalco Research and Technology
 %%         02 May 2000
 %!test
-%! N=64;
-%! n=4;
+%! N = 64;
+%! n = 7;
 %! t = 2*pi*(0:1:N-1)/N;
-%! s = cos(n*t);
-%! S = fft(s);
-%!
-%! answer = zeros (size(t));
-%! answer(n+1) = N/2;
-%! answer(N-n+1) = N/2;
-%!
-%! assert(S, answer, 4*N*eps);
-
-%% Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
-%%         Comalco Research and Technology
-%%         02 May 2000
-%!test
-%! N=64;
-%! n=7;
-%! t = 2*pi*(0:1:N-1)/N;
-%! s = cos(n*t);
+%! s = cos (n*t);
 %!
 %! S = zeros (size(t));
 %! S(n+1) = N/2;
 %! S(N-n+1) = N/2;
 %!
-%! assert(ifft(S), s, 4*N*eps);
+%! assert (ifft (S), s, 4*N*eps);
 
 %% Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
 %%         Comalco Research and Technology
 %%         02 May 2000
 %!test
-%! N=64;
-%! n=4;
+%! N = 64;
+%! n = 4;
 %! t = single (2*pi*(0:1:N-1)/N);
-%! s = cos(n*t);
-%! S = fft(s);
+%! s = cos (n*t);
+%! S = fft (s);
 %!
-%! answer = zeros (size(t),'single');
+%! answer = zeros (size (t), "single");
 %! answer(n+1) = N/2;
 %! answer(N-n+1) = N/2;
 %!
-%! assert(S, answer, 4*N*eps('single'));
+%! assert (S, answer, 4*N*eps ("single"));
 
 %% Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
 %%         Comalco Research and Technology
 %%         02 May 2000
 %!test
-%! N=64;
-%! n=7;
+%! N = 64;
+%! n = 7;
 %! t = 2*pi*(0:1:N-1)/N;
-%! s = cos(n*t);
+%! s = cos (n*t);
 %!
-%! S = zeros (size(t),'single');
+%! S = zeros (size (t), "single");
 %! S(n+1) = N/2;
 %! S(N-n+1) = N/2;
 %!
-%! assert(ifft(S), s, 4*N*eps('single'));
-
+%! assert (ifft (S), s, 4*N*eps ("single"));
 */
--- a/src/DLD-FUNCTIONS/fft2.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/fft2.cc	Mon May 07 00:56:44 2012 +0200
@@ -209,88 +209,86 @@
 }
 
 /*
+%% Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
+%%         Comalco Research and Technology
+%%         02 May 2000
+%!test
+%! M = 16;
+%! N = 8;
+%!
+%! m = 5;
+%! n = 3;
+%!
+%! x = 2*pi*(0:1:M-1)/M;
+%! y = 2*pi*(0:1:N-1)/N;
+%! sx = cos (m*x);
+%! sy = sin (n*y);
+%! s = kron (sx',sy);
+%! S = fft2 (s);
+%! answer = kron (fft (sx)', fft (sy));
+%! assert (S, answer, 4*M*N*eps);
 
 %% Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
 %%         Comalco Research and Technology
 %%         02 May 2000
 %!test
-%! M=16;
-%! N=8;
-%!
-%! m=5;
-%! n=3;
+%! M = 12;
+%! N = 7;
 %!
-%! x = 2*pi*(0:1:M-1)/M;
-%! y = 2*pi*(0:1:N-1)/N;
-%! sx = cos(m*x);
-%! sy = sin(n*y);
-%! s=kron(sx',sy);
-%! S = fft2(s);
-%! answer = kron(fft(sx)',fft(sy));
-%! assert(S, answer, 4*M*N*eps);
-
-%% Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
-%%         Comalco Research and Technology
-%%         02 May 2000
-%!test
-%! M=12;
-%! N=7;
-%!
-%! m=3;
-%! n=2;
+%! m = 3;
+%! n = 2;
 %!
 %! x = 2*pi*(0:1:M-1)/M;
 %! y = 2*pi*(0:1:N-1)/N;
 %!
-%! sx = cos(m*x);
-%! sy = cos(n*y);
+%! sx = cos (m*x);
+%! sy = cos (n*y);
 %!
-%! S = kron(fft(sx)',fft(sy));
-%! answer=kron(sx',sy);
-%! s = ifft2(S);
+%! S = kron (fft (sx)', fft (sy));
+%! answer = kron (sx', sy);
+%! s = ifft2 (S);
 %!
-%! assert(s, answer, 30*eps);
+%! assert (s, answer, 30*eps);
 
 
 %% Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
 %%         Comalco Research and Technology
 %%         02 May 2000
 %!test
-%! M=16;
-%! N=8;
+%! M = 16;
+%! N = 8;
 %!
-%! m=5;
-%! n=3;
+%! m = 5;
+%! n = 3;
 %!
 %! x = 2*pi*(0:1:M-1)/M;
 %! y = 2*pi*(0:1:N-1)/N;
-%! sx = single(cos(m*x));
-%! sy = single(sin(n*y));
-%! s=kron(sx',sy);
-%! S = fft2(s);
-%! answer = kron(fft(sx)',fft(sy));
-%! assert(S, answer, 4*M*N*eps('single'));
+%! sx = single (cos (m*x));
+%! sy = single (sin (n*y));
+%! s = kron (sx', sy);
+%! S = fft2 (s);
+%! answer = kron (fft (sx)', fft (sy));
+%! assert (S, answer, 4*M*N*eps ("single"));
 
 %% Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
 %%         Comalco Research and Technology
 %%         02 May 2000
 %!test
-%! M=12;
-%! N=7;
+%! M = 12;
+%! N = 7;
 %!
-%! m=3;
-%! n=2;
+%! m = 3;
+%! n = 2;
 %!
-%! x = single(2*pi*(0:1:M-1)/M);
-%! y = single(2*pi*(0:1:N-1)/N);
+%! x = single (2*pi*(0:1:M-1)/M);
+%! y = single (2*pi*(0:1:N-1)/N);
 %!
-%! sx = cos(m*x);
-%! sy = cos(n*y);
+%! sx = cos (m*x);
+%! sy = cos (n*y);
 %!
-%! S = kron(fft(sx)',fft(sy));
-%! answer=kron(sx',sy);
-%! s = ifft2(S);
+%! S = kron (fft (sx)', fft (sy));
+%! answer = kron (sx', sy);
+%! s = ifft2 (S);
 %!
-%! assert(s, answer, 30*eps('single'));
-
+%! assert (s, answer, 30*eps ("single"));
 */
--- a/src/DLD-FUNCTIONS/filter.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/filter.cc	Mon May 07 00:56:44 2012 +0200
@@ -661,73 +661,76 @@
 /*
 %!shared a, b, x, r
 %!test
-%!  a = [1 1];
-%!  b = [1 1];
-%!  x = zeros (1,10); x(1) = 1;
-%!  assert(filter(b,   [1], x  ), [1 1 0 0 0 0 0 0 0 0]);
-%!  assert(filter(b,   [1], x.'), [1 1 0 0 0 0 0 0 0 0].');
-%!  assert(filter(b.', [1], x  ), [1 1 0 0 0 0 0 0 0 0]  );
-%!  assert(filter(b.', [1], x.'), [1 1 0 0 0 0 0 0 0 0].');
-%!  assert(filter([1], a,   x  ), [+1 -1 +1 -1 +1 -1 +1 -1 +1 -1]  );
-%!  assert(filter([1], a,   x.'), [+1 -1 +1 -1 +1 -1 +1 -1 +1 -1].');
-%!  assert(filter([1], a.', x  ), [+1 -1 +1 -1 +1 -1 +1 -1 +1 -1]  );
-%!  assert(filter([1], a.', x.'), [+1 -1 +1 -1 +1 -1 +1 -1 +1 -1].');
-%!  assert(filter(b,   a,   x  ), [1 0 0 0 0 0 0 0 0 0]  );
-%!  assert(filter(b.', a,   x  ), [1 0 0 0 0 0 0 0 0 0]  );
-%!  assert(filter(b,   a.', x  ), [1 0 0 0 0 0 0 0 0 0]  );
-%!  assert(filter(b.', a,   x  ), [1 0 0 0 0 0 0 0 0 0]  );
-%!  assert(filter(b,   a,   x.'), [1 0 0 0 0 0 0 0 0 0].');
-%!  assert(filter(b.', a,   x.'), [1 0 0 0 0 0 0 0 0 0].');
-%!  assert(filter(b,   a.', x.'), [1 0 0 0 0 0 0 0 0 0].');
-%!  assert(filter(b.', a,   x.'), [1 0 0 0 0 0 0 0 0 0].');
-%!
+%! a = [1 1];
+%! b = [1 1];
+%! x = zeros (1,10);  x(1) = 1;
+%! assert (filter (b,   [1], x  ), [1 1 0 0 0 0 0 0 0 0]);
+%! assert (filter (b,   [1], x.'), [1 1 0 0 0 0 0 0 0 0].');
+%! assert (filter (b.', [1], x  ), [1 1 0 0 0 0 0 0 0 0]  );
+%! assert (filter (b.', [1], x.'), [1 1 0 0 0 0 0 0 0 0].');
+%! assert (filter ([1], a,   x  ), [+1 -1 +1 -1 +1 -1 +1 -1 +1 -1]  );
+%! assert (filter ([1], a,   x.'), [+1 -1 +1 -1 +1 -1 +1 -1 +1 -1].');
+%! assert (filter ([1], a.', x  ), [+1 -1 +1 -1 +1 -1 +1 -1 +1 -1]  );
+%! assert (filter ([1], a.', x.'), [+1 -1 +1 -1 +1 -1 +1 -1 +1 -1].');
+%! assert (filter (b,   a,   x  ), [1 0 0 0 0 0 0 0 0 0]  );
+%! assert (filter (b.', a,   x  ), [1 0 0 0 0 0 0 0 0 0]  );
+%! assert (filter (b,   a.', x  ), [1 0 0 0 0 0 0 0 0 0]  );
+%! assert (filter (b.', a,   x  ), [1 0 0 0 0 0 0 0 0 0]  );
+%! assert (filter (b,   a,   x.'), [1 0 0 0 0 0 0 0 0 0].');
+%! assert (filter (b.', a,   x.'), [1 0 0 0 0 0 0 0 0 0].');
+%! assert (filter (b,   a.', x.'), [1 0 0 0 0 0 0 0 0 0].');
+%! assert (filter (b.', a,   x.'), [1 0 0 0 0 0 0 0 0 0].');
+
 %!test
-%!  r = sqrt(1/2)*(1+i);
-%!  a = a*r;
-%!  b = b*r;
-%!  assert(filter(b, [1], x   ), r*[1 1 0 0 0 0 0 0 0 0]   );
-%!  assert(filter(b, [1], r*x ), r*r*[1 1 0 0 0 0 0 0 0 0] );
-%!  assert(filter(b, [1], x.' ), r*[1 1 0 0 0 0 0 0 0 0].' );
-%!  assert(filter(b, a,   x   ),   [1 0 0 0 0 0 0 0 0 0]   );
-%!  assert(filter(b, a,   r*x ), r*[1 0 0 0 0 0 0 0 0 0]   );
-%!
+%! r = sqrt (1/2) * (1+i);
+%! a = a*r;
+%! b = b*r;
+%! assert (filter (b, [1], x   ), r*[1 1 0 0 0 0 0 0 0 0]   );
+%! assert (filter (b, [1], r*x ), r*r*[1 1 0 0 0 0 0 0 0 0] );
+%! assert (filter (b, [1], x.' ), r*[1 1 0 0 0 0 0 0 0 0].' );
+%! assert (filter (b, a,   x   ),   [1 0 0 0 0 0 0 0 0 0]   );
+%! assert (filter (b, a,   r*x ), r*[1 0 0 0 0 0 0 0 0 0]   );
+
 %!shared a, b, x, y, so
 %!test
-%!  a = [1,1]; b = [1,1];
-%!  x = zeros (1,10); x(1) = 1;
-%!  [y, so] = filter (b, [1], x, [-1]);
-%!  assert(y, [0 1 0 0 0 0 0 0 0 0]);
-%!  assert(so,0);
-%!
+%! a = [1,1];
+%! b = [1,1];
+%! x = zeros (1,10);  x(1) = 1;
+%! [y, so] = filter (b, [1], x, [-1]);
+%! assert (y, [0 1 0 0 0 0 0 0 0 0]);
+%! assert (so, 0);
+
 %!test
-%!  x  = zeros (10,3); x(1,1)=-1; x(1,2)=1;
-%!  y0 = zeros (10,3); y0(1:2,1)=-1; y0(1:2,2)=1;
-%!  y = filter (b, [1], x);
-%!  assert(y,y0);
-%!
+%! x  = zeros (10,3);  x(1,1) = -1;  x(1,2) = 1;
+%! y0 = zeros (10,3); y0(1:2,1) = -1;  y0(1:2,2) = 1;
+%! y = filter (b, [1], x);
+%! assert (y, y0);
+
 %!test
-%!  a = [1,1]; b=[1,1];
-%!  x = zeros (4,4,2); x(1,1:4,1) = +1; x(1,1:4,2) = -1;
-%!  y0 = zeros (4,4,2); y0(1:2,1:4,1) = +1; y0(1:2,1:4,2) = -1;
-%!  y = filter (b, [1], x);
-%!  assert(y, y0);
-%!
-%!assert(filter (1, ones(10,1)/10, []), []);
-%!assert(filter (1, ones(10,1)/10, zeros(0,10)), zeros(0,10));
-%!assert(filter (1, ones(10,1)/10, single (1:5)), repmat (single (10), 1, 5));
+%! a = [1,1];
+%! b=[1,1];
+%! x = zeros (4,4,2);  x(1,1:4,1) = +1;  x(1,1:4,2) = -1;
+%! y0 = zeros (4,4,2);  y0(1:2,1:4,1) = +1;  y0(1:2,1:4,2) = -1;
+%! y = filter (b, [1], x);
+%! assert (y, y0);
+
+%!assert (filter (1, ones(10,1)/10, []), [])
+%!assert (filter (1, ones(10,1)/10, zeros(0,10)), zeros(0,10))
+%!assert (filter (1, ones(10,1)/10, single (1:5)), repmat (single (10), 1, 5))
+
 %% Test using initial conditions
-%!assert(filter([1, 1, 1], [1, 1], [1 2], [1, 1]), [2 2]);
-%!assert(filter([1, 1, 1], [1, 1], [1 2], [1, 1]'), [2 2]);
-%!assert(filter([1, 3], [1], [1 2; 3 4; 5 6], [4, 5]), [5 7; 6 10; 14 18]);
-%!error (filter([1, 3], [1], [1 2; 3 4; 5 6], [4, 5]'));
-%!assert(filter([1, 3, 2], [1], [1 2; 3 4; 5 6], [1 0 0; 1 0 0], 2), [2 6; 3 13; 5 21]);
-%% Test of DIM parameter
+%!assert (filter ([1, 1, 1], [1, 1], [1 2], [1, 1]), [2 2])
+%!assert (filter ([1, 1, 1], [1, 1], [1 2], [1, 1]'), [2 2])
+%!assert (filter ([1, 3], [1], [1 2; 3 4; 5 6], [4, 5]), [5 7; 6 10; 14 18])
+%!error (filter ([1, 3], [1], [1 2; 3 4; 5 6], [4, 5]'))
+%!assert (filter ([1, 3, 2], [1], [1 2; 3 4; 5 6], [1 0 0; 1 0 0], 2), [2 6; 3 13; 5 21])
+
+## Test of DIM parameter
 %!test
 %! x = ones (2, 1, 3, 4);
 %! x(1,1,:,:) = [1 2 3 4; 5 6 7 8; 9 10 11 12];
 %! y0 = [1 1 6 2 15 3 2 1 8 2 18 3 3 1 10 2 21 3 4 1 12 2 24 3];
 %! y0 = reshape (y0, size (x));
-%! y = filter([1 1 1], 1, x, [], 3);
+%! y = filter ([1 1 1], 1, x, [], 3);
 %! assert (y, y0);
-
 */
--- a/src/DLD-FUNCTIONS/find.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/find.cc	Mon May 07 00:56:44 2012 +0200
@@ -570,28 +570,28 @@
 }
 
 /*
-%!assert(find (char ([0, 97])), 2);
-%!assert(find ([1, 0, 1, 0, 1]), [1, 3, 5]);
-%!assert(find ([1; 0; 3; 0; 1]), [1; 3; 5]);
-%!assert(find ([0, 0, 2; 0, 3, 0; -1, 0, 0]), [3; 5; 7]);
+%!assert (find (char ([0, 97])), 2)
+%!assert (find ([1, 0, 1, 0, 1]), [1, 3, 5])
+%!assert (find ([1; 0; 3; 0; 1]), [1; 3; 5])
+%!assert (find ([0, 0, 2; 0, 3, 0; -1, 0, 0]), [3; 5; 7])
 
 %!test
 %! [i, j, v] = find ([0, 0, 2; 0, 3, 0; -1, 0, 0]);
 %!
-%! assert(i, [3; 2; 1]);
-%! assert(j, [1; 2; 3]);
-%! assert(v, [-1; 3; 2]);
+%! assert (i, [3; 2; 1]);
+%! assert (j, [1; 2; 3]);
+%! assert (v, [-1; 3; 2]);
 
-%!assert(find (single([1, 0, 1, 0, 1])), [1, 3, 5]);
-%!assert(find (single([1; 0; 3; 0; 1])), [1; 3; 5]);
-%!assert(find (single([0, 0, 2; 0, 3, 0; -1, 0, 0])), [3; 5; 7]);
+%!assert (find (single ([1, 0, 1, 0, 1])), [1, 3, 5])
+%!assert (find (single ([1; 0; 3; 0; 1])), [1; 3; 5])
+%!assert (find (single ([0, 0, 2; 0, 3, 0; -1, 0, 0])), [3; 5; 7])
 
 %!test
-%! [i, j, v] = find (single([0, 0, 2; 0, 3, 0; -1, 0, 0]));
+%! [i, j, v] = find (single ([0, 0, 2; 0, 3, 0; -1, 0, 0]));
 %!
-%! assert(i, [3; 2; 1]);
-%! assert(j, [1; 2; 3]);
-%! assert(v, single([-1; 3; 2]));
+%! assert (i, [3; 2; 1]);
+%! assert (j, [1; 2; 3]);
+%! assert (v, single ([-1; 3; 2]));
 
 %!test
 %! pcol = [5 1 4 3 2];
@@ -617,6 +617,5 @@
 %!assert (find ([2 0 1 0 5 0], Inf), [1, 3, 5])
 %!assert (find ([2 0 1 0 5 0], Inf, "last"), [1, 3, 5])
 
-%!error <Invalid call to find> find ();
-
+%!error find ()
 */
--- a/src/DLD-FUNCTIONS/gammainc.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/gammainc.cc	Mon May 07 00:56:44 2012 +0200
@@ -208,23 +208,23 @@
 }
 
 /*
-
 %!test
 %! a = [.5 .5 .5 .5 .5];
 %! x = [0 1 2 3 4];
-%! v1 = sqrt(pi)*erf(x)./gamma(a);
-%! v3 = gammainc(x.*x,a);
-%! assert(v1, v3, sqrt(eps));
+%! v1 = sqrt (pi)*erf (x)./gamma (a);
+%! v3 = gammainc (x.*x, a);
+%! assert (v1, v3, sqrt (eps));
 
-%!assert (gammainc(0:4,0.5,"upper"), 1-gammainc(0:4,0.5),1e-10)
+%!assert (gammainc (0:4,0.5, "upper"), 1-gammainc (0:4,0.5), 1e-10)
 
 %!test
 %! a = single ([.5 .5 .5 .5 .5]);
-%! x = single([0 1 2 3 4]);
-%! v1 = sqrt(pi('single'))*erf(x)./gamma(a);
-%! v3 = gammainc(x.*x,a);
-%! assert(v1, v3, sqrt(eps('single')));
+%! x = single ([0 1 2 3 4]);
+%! v1 = sqrt (pi ("single"))*erf (x)./gamma (a);
+%! v3 = gammainc (x.*x, a);
+%! assert (v1, v3, sqrt (eps ("single")));
 
-%!assert (gammainc(single(0:4),single(0.5),"upper"), single(1)-gammainc(single(0:4),single(0.5)),single(1e-7))
-
+%!assert (gammainc (single (0:4), single (0.5), "upper"), 
+%!        single (1)-gammainc (single (0:4), single (0.5)),
+%!        single (1e-7))
 */
--- a/src/DLD-FUNCTIONS/gcd.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/gcd.cc	Mon May 07 00:56:44 2012 +0200
@@ -515,16 +515,14 @@
 }
 
 /*
+%!assert (gcd (200, 300, 50, 35), 5)
+%!assert (gcd (int16 (200), int16 (300), int16 (50), int16 (35)), int16 (5))
+%!assert (gcd (uint64 (200), uint64 (300), uint64 (50), uint64 (35)), uint64 (5))
+%!assert (gcd (18-i, -29+3i), -3-4i)
 
-%!assert(gcd (200, 300, 50, 35), 5)
-%!assert(gcd (int16(200), int16(300), int16(50), int16(35)), int16(5))
-%!assert(gcd (uint64(200), uint64(300), uint64(50), uint64(35)), uint64(5))
-%!assert(gcd (18-i, -29+3i), -3-4i)
-
-%!error <Invalid call to gcd> gcd ();
+%!error gcd ()
 
 %!test
 %! s.a = 1;
-%! fail("gcd (s)");
-
+%! fail ("gcd (s)");
 */
--- a/src/DLD-FUNCTIONS/givens.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/givens.cc	Mon May 07 00:56:44 2012 +0200
@@ -205,11 +205,10 @@
 }
 
 /*
+%!assert (givens (1,1), [1, 1; -1, 1] / sqrt (2), 2*eps)
+%!assert (givens (1,0), eye (2))
+%!assert (givens (0,1), [0, 1; -1 0])
 
-%!assert (givens (1,1), [1, 1; -1, 1]/sqrt(2), 2*eps);
-%!assert (givens (1,0), eye(2));
-%!assert (givens (0,1), [0, 1; -1 0]);
-%!error givens(1);
-%!error givens()
-
+%!error givens ()
+%!error givens (1)
 */
--- a/src/DLD-FUNCTIONS/hess.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/hess.cc	Mon May 07 00:56:44 2012 +0200
@@ -173,19 +173,17 @@
 }
 
 /*
-
 %!test
 %! a = [1, 2, 3; 5, 4, 6; 8, 7, 9];
 %! [p, h] = hess (a);
-%! assert(p * h * p', a, sqrt(eps));
+%! assert (p * h * p', a, sqrt (eps));
 
 %!test
-%! a = single([1, 2, 3; 5, 4, 6; 8, 7, 9]);
+%! a = single ([1, 2, 3; 5, 4, 6; 8, 7, 9]);
 %! [p, h] = hess (a);
-%! assert(p * h * p', a, sqrt(eps ('single')));
+%! assert (p * h * p', a, sqrt (eps ("single")));
 
-%!error <Invalid call to hess> hess ();
-%!error <Invalid call to hess> hess ([1, 2; 3, 4], 2);
-%!error hess ([1, 2; 3, 4; 5, 6]);
-
+%!error hess ()
+%!error hess ([1, 2; 3, 4], 2)
+%!error <argument must be a square matrix> hess ([1, 2; 3, 4; 5, 6])
 */
--- a/src/DLD-FUNCTIONS/hex2num.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/hex2num.cc	Mon May 07 00:56:44 2012 +0200
@@ -119,7 +119,7 @@
 }
 
 /*
-%!assert (hex2num(['c00';'bff';'000';'3ff';'400']),[-2:2]')
+%!assert (hex2num (["c00";"bff";"000";"3ff";"400"]), [-2:2]')
 */
 
 DEFUN_DLD (num2hex, args, ,
@@ -188,5 +188,5 @@
 }
 
 /*
-%!assert (num2hex (-2:2),['c000000000000000';'bff0000000000000';'0000000000000000';'3ff0000000000000';'4000000000000000'])
+%!assert (num2hex (-2:2), ["c000000000000000";"bff0000000000000";"0000000000000000";"3ff0000000000000";"4000000000000000"])
 */
--- a/src/DLD-FUNCTIONS/inv.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/inv.cc	Mon May 07 00:56:44 2012 +0200
@@ -224,15 +224,13 @@
 }
 
 /*
-
-%!assert(inv ([1, 2; 3, 4]), [-2, 1; 1.5, -0.5], sqrt (eps))
-%!assert(inv (single([1, 2; 3, 4])), single([-2, 1; 1.5, -0.5]), sqrt (eps ('single')))
+%!assert (inv ([1, 2; 3, 4]), [-2, 1; 1.5, -0.5], sqrt (eps))
+%!assert (inv (single ([1, 2; 3, 4])), single ([-2, 1; 1.5, -0.5]), sqrt (eps ("single")))
 
-%!error <Invalid call to inv> inv ();
-%!error <Invalid call to inv> inv ([1, 2; 3, 4], 2);
-%!error inv ([1, 2; 3, 4; 5, 6]);
-
- */
+%!error inv ()
+%!error inv ([1, 2; 3, 4], 2)
+%!error <argument must be a square matrix> inv ([1, 2; 3, 4; 5, 6])
+*/
 
 // FIXME -- this should really be done with an alias, but
 // alias_builtin() won't do the right thing if we are actually using
--- a/src/DLD-FUNCTIONS/kron.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/kron.cc	Mon May 07 00:56:44 2012 +0200
@@ -162,7 +162,6 @@
   return c;
 }
 
-
 template <class MTA, class MTB>
 octave_value
 do_kron (const octave_value& a, const octave_value& b)
@@ -183,12 +182,18 @@
       if (b.is_diag_matrix () && a.rows () == a.columns ()
           && b.rows () == b.columns ())
         {
-          octave_value_list tmp;
-          tmp(0) = a.diag ();
-          tmp(1) = b.diag ();
-          tmp = dispatch_kron (tmp, 1);
-          if (tmp.length () == 1)
-            retval = tmp(0).diag ();
+          // We have two diagonal matrices, the product of those will be
+          // another diagonal matrix.  To do that efficiently, extract
+          // the diagonals as vectors and compute the product.  That
+          // will be another vector, which we then use to construct a
+          // diagonal matrix object.  Note that this will fail if our
+          // digaonal matrix object is modified to allow the non-zero
+          // values to be stored off of the principal diagonal (i.e., if
+          // diag ([1,2], 3) is modified to return a diagonal matrix
+          // object instead of a full matrix object).
+
+          octave_value tmp = dispatch_kron (a.diag (), b.diag ());
+          retval = tmp.diag ();
         }
       else if (a.is_single_type () || b.is_single_type ())
         {
@@ -289,10 +294,9 @@
 
 
 /*
-
 %!test
-%! x = ones(2);
-%! assert( kron (x, x), ones (4));
+%! x = ones (2);
+%! assert (kron (x, x), ones (4));
 
 %!shared x, y, z
 %! x =  [1, 2];
@@ -302,4 +306,16 @@
 %!assert (kron (x, y, z), kron (kron (x, y), z))
 %!assert (kron (x, y, z), kron (x, kron (y, z)))
 
+%!assert (kron (diag ([1, 2]), diag ([3, 4])), diag ([3, 4, 6, 8]))
+
+%% Test for two diag matrices.  See the comments above in
+%% dispatch_kron for this case.
+%%
+%!test
+%! expected = zeros (16, 16);
+%! expected (1, 11) = 3;
+%! expected (2, 12) = 4;
+%! expected (5, 15) = 6;
+%! expected (6, 16) = 8;
+%! assert (kron (diag ([1, 2], 2), diag ([3, 4], 2)), expected)
 */
--- a/src/DLD-FUNCTIONS/lookup.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/lookup.cc	Mon May 07 00:56:44 2012 +0200
@@ -373,25 +373,25 @@
 }
 
 /*
-%!assert (lookup(1:3, 0.5), 0)     # value before table
-%!assert (lookup(1:3, 3.5), 3)     # value after table error
-%!assert (lookup(1:3, 1.5), 1)     # value within table error
-%!assert (lookup(1:3, [3,2,1]), [3,2,1])
-%!assert (lookup([1:4]', [1.2, 3.5]'), [1, 3]');
-%!assert (lookup([1:4], [1.2, 3.5]'), [1, 3]');
-%!assert (lookup([1:4]', [1.2, 3.5]), [1, 3]);
-%!assert (lookup([1:4], [1.2, 3.5]), [1, 3]);
-%!assert (lookup(1:3, [3, 2, 1]), [3, 2, 1]);
-%!assert (lookup([3:-1:1], [3.5, 3, 1.2, 2.5, 2.5]), [0, 1, 2, 1, 1])
-%!assert (isempty(lookup([1:3], [])))
-%!assert (isempty(lookup([1:3]', [])))
-%!assert (lookup(1:3, [1, 2; 3, 0.5]), [1, 2; 3, 0]);
-%!assert (lookup(1:4, [1, 1.2; 3, 2.5], "m"), [1, 0; 3, 0]);
-%!assert (lookup(4:-1:1, [1, 1.2; 3, 2.5], "m"), [4, 0; 2, 0]);
-%!assert (lookup(1:4, [1, 1.2; 3, 2.5], "b"), logical ([1, 0; 3, 0]));
-%!assert (lookup(4:-1:1, [1, 1.2; 3, 2.5], "b"), logical ([4, 0; 2, 0]));
+%!assert (lookup (1:3, 0.5), 0)     # value before table
+%!assert (lookup (1:3, 3.5), 3)     # value after table error
+%!assert (lookup (1:3, 1.5), 1)     # value within table error
+%!assert (lookup (1:3, [3,2,1]), [3,2,1])
+%!assert (lookup ([1:4]', [1.2, 3.5]'), [1, 3]')
+%!assert (lookup ([1:4], [1.2, 3.5]'), [1, 3]')
+%!assert (lookup ([1:4]', [1.2, 3.5]), [1, 3])
+%!assert (lookup ([1:4], [1.2, 3.5]), [1, 3])
+%!assert (lookup (1:3, [3, 2, 1]), [3, 2, 1])
+%!assert (lookup ([3:-1:1], [3.5, 3, 1.2, 2.5, 2.5]), [0, 1, 2, 1, 1])
+%!assert (isempty (lookup ([1:3], [])))
+%!assert (isempty (lookup ([1:3]', [])))
+%!assert (lookup (1:3, [1, 2; 3, 0.5]), [1, 2; 3, 0])
+%!assert (lookup (1:4, [1, 1.2; 3, 2.5], "m"), [1, 0; 3, 0])
+%!assert (lookup (4:-1:1, [1, 1.2; 3, 2.5], "m"), [4, 0; 2, 0])
+%!assert (lookup (1:4, [1, 1.2; 3, 2.5], "b"), logical ([1, 0; 3, 0]))
+%!assert (lookup (4:-1:1, [1, 1.2; 3, 2.5], "b"), logical ([4, 0; 2, 0]))
 %!
-%!assert (lookup({"apple","lemon","orange"}, {"banana","kiwi"; "ananas","mango"}), [1,1;0,2])
-%!assert (lookup({"apple","lemon","orange"}, "potato"), 3)
-%!assert (lookup({"orange","lemon","apple"}, "potato"), 0)
+%!assert (lookup ({"apple","lemon","orange"}, {"banana","kiwi"; "ananas","mango"}), [1,1;0,2])
+%!assert (lookup ({"apple","lemon","orange"}, "potato"), 3)
+%!assert (lookup ({"orange","lemon","apple"}, "potato"), 0)
 */
--- a/src/DLD-FUNCTIONS/lsode.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/lsode.cc	Mon May 07 00:56:44 2012 +0200
@@ -475,25 +475,27 @@
 
 /*
 
-%% dassl-1.m
-%%
-%% Test lsode() function
-%%
-%% Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
-%%         Comalco Research and Technology
-%%         20 May 1998
-%%
-%% Problem
-%%
-%%    y1' = -y2,   y1(0) = 1
-%%    y2' =  y1,   y2(0) = 0
-%%
-%% Solution
-%%
-%%    y1(t) = cos(t)
-%%    y2(t) = sin(t)
+## dassl-1.m
+##
+## Test lsode() function
+##
+## Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
+##         Comalco Research and Technology
+##         20 May 1998
+##
+## Problem
+##
+##    y1' = -y2,   y1(0) = 1
+##    y2' =  y1,   y2(0) = 0
+##
+## Solution
+##
+##    y1(t) = cos(t)
+##    y2(t) = sin(t)
+##
 %!function xdot = __f (x, t)
 %!  xdot = [-x(2); x(1)];
+%!endfunction
 %!test
 %!
 %! x0 = [1; 0];
@@ -502,15 +504,15 @@
 %!
 %! tol = 500 * lsode_options ("relative tolerance");
 %!
-%!
 %! x = lsode ("__f", x0, t);
 %!
 %! y = [cos(t), sin(t)];
 %!
-%! assert(all (all (abs (x - y) < tol)));
+%! assert (x, y, tol);
 
 %!function xdotdot = __f (x, t)
 %!  xdotdot = [x(2); -x(1)];
+%!endfunction
 %!test
 %!
 %! x0 = [1; 0];
@@ -521,10 +523,11 @@
 %!
 %! y = [1, 0; 1, 0];
 %!
-%! assert(all (all (abs (x - y) < tol)));
+%! assert (x, y, tol);
 
 %!function xdot = __f (x, t)
 %!  xdot = x;
+%!endfunction
 %!test
 %!
 %! x0 = 1;
@@ -535,12 +538,11 @@
 %!
 %! y = [1; e];
 %!
-%! assert(all (all (abs (x - y) < tol)));
+%! assert (x, y, tol);
 
 %!test
 %! lsode_options ("absolute tolerance", eps);
-%! assert(lsode_options ("absolute tolerance") == eps);
+%! assert (lsode_options ("absolute tolerance") == eps);
 
-%!error <Invalid call to lsode_options> lsode_options ("foo", 1, 2);
-
+%!error lsode_options ("foo", 1, 2)
 */
--- a/src/DLD-FUNCTIONS/lu.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/lu.cc	Mon May 07 00:56:44 2012 +0200
@@ -529,61 +529,59 @@
 }
 
 /*
-
 %!assert(lu ([1, 2; 3, 4]), [3, 4; 1/3, 2/3], eps);
 
 %!test
 %! [l, u] = lu ([1, 2; 3, 4]);
-%! assert(l, [1/3, 1; 1, 0], sqrt (eps));
-%! assert(u, [3, 4; 0, 2/3], sqrt (eps));
+%! assert (l, [1/3, 1; 1, 0], sqrt (eps));
+%! assert (u, [3, 4; 0, 2/3], sqrt (eps));
 
 %!test
 %! [l, u, p] = lu ([1, 2; 3, 4]);
-%! assert(l, [1, 0; 1/3, 1], sqrt (eps));
-%! assert(u, [3, 4; 0, 2/3], sqrt (eps));
-%! assert(p(:,:), [0, 1; 1, 0], sqrt (eps));
+%! assert (l, [1, 0; 1/3, 1], sqrt (eps));
+%! assert (u, [3, 4; 0, 2/3], sqrt (eps));
+%! assert (p(:,:), [0, 1; 1, 0], sqrt (eps));
 
 %!test
-%! [l, u, p] = lu ([1, 2; 3, 4],'vector');
-%! assert(l, [1, 0; 1/3, 1], sqrt (eps));
-%! assert(u, [3, 4; 0, 2/3], sqrt (eps));
-%! assert(p, [2;1], sqrt (eps));
+%! [l, u, p] = lu ([1, 2; 3, 4], "vector");
+%! assert (l, [1, 0; 1/3, 1], sqrt (eps));
+%! assert (u, [3, 4; 0, 2/3], sqrt (eps));
+%! assert (p, [2;1], sqrt (eps));
 
 %!test
-%! [l u p] = lu ([1, 2; 3, 4; 5, 6]);
-%! assert(l, [1, 0; 1/5, 1; 3/5, 1/2], sqrt (eps));
-%! assert(u, [5, 6; 0, 4/5], sqrt (eps));
-%! assert(p(:,:), [0, 0, 1; 1, 0, 0; 0 1 0], sqrt (eps));
+%! [l, u, p] = lu ([1, 2; 3, 4; 5, 6]);
+%! assert (l, [1, 0; 1/5, 1; 3/5, 1/2], sqrt (eps));
+%! assert (u, [5, 6; 0, 4/5], sqrt (eps));
+%! assert (p(:,:), [0, 0, 1; 1, 0, 0; 0 1 0], sqrt (eps));
 
-%!assert(lu (single([1, 2; 3, 4])), single([3, 4; 1/3, 2/3]), eps('single'));
+%!assert (lu (single ([1, 2; 3, 4])), single ([3, 4; 1/3, 2/3]), eps ("single"))
 
 %!test
-%! [l, u] = lu (single([1, 2; 3, 4]));
-%! assert(l, single([1/3, 1; 1, 0]), sqrt (eps('single')));
-%! assert(u, single([3, 4; 0, 2/3]), sqrt (eps('single')));
+%! [l, u] = lu (single ([1, 2; 3, 4]));
+%! assert (l, single ([1/3, 1; 1, 0]), sqrt (eps ("single")));
+%! assert (u, single ([3, 4; 0, 2/3]), sqrt (eps ("single")));
 
 %!test
-%! [l, u, p] = lu (single([1, 2; 3, 4]));
-%! assert(l, single([1, 0; 1/3, 1]), sqrt (eps('single')));
-%! assert(u, single([3, 4; 0, 2/3]), sqrt (eps('single')));
-%! assert(p(:,:), single([0, 1; 1, 0]), sqrt (eps('single')));
+%! [l, u, p] = lu (single ([1, 2; 3, 4]));
+%! assert (l, single ([1, 0; 1/3, 1]), sqrt (eps ("single")));
+%! assert (u, single ([3, 4; 0, 2/3]), sqrt (eps ("single")));
+%! assert (p(:,:), single ([0, 1; 1, 0]), sqrt (eps ("single")));
 
 %!test
-%! [l, u, p] = lu (single([1, 2; 3, 4]),'vector');
-%! assert(l, single([1, 0; 1/3, 1]), sqrt (eps('single')));
-%! assert(u, single([3, 4; 0, 2/3]), sqrt (eps('single')));
-%! assert(p, single([2;1]), sqrt (eps('single')));
+%! [l, u, p] = lu (single ([1, 2; 3, 4]), "vector");
+%! assert (l, single ([1, 0; 1/3, 1]), sqrt (eps ("single")));
+%! assert (u, single ([3, 4; 0, 2/3]), sqrt (eps ("single")));
+%! assert (p, single ([2;1]), sqrt (eps ("single")));
 
 %!test
-%! [l u p] = lu (single([1, 2; 3, 4; 5, 6]));
-%! assert(l, single([1, 0; 1/5, 1; 3/5, 1/2]), sqrt (eps('single')));
-%! assert(u, single([5, 6; 0, 4/5]), sqrt (eps('single')));
-%! assert(p(:,:), single([0, 0, 1; 1, 0, 0; 0 1 0]), sqrt (eps('single')));
+%! [l u p] = lu (single ([1, 2; 3, 4; 5, 6]));
+%! assert (l, single ([1, 0; 1/5, 1; 3/5, 1/2]), sqrt (eps ("single")));
+%! assert (u, single ([5, 6; 0, 4/5]), sqrt (eps ("single")));
+%! assert (p(:,:), single ([0, 0, 1; 1, 0, 0; 0 1 0]), sqrt (eps ("single")));
 
-%!error <Invalid call to lu> lu ();
-%!error lu ([1, 2; 3, 4], 2);
-
- */
+%!error lu ()
+%!error <can not define pivoting threshold> lu ([1, 2; 3, 4], 2)
+*/
 
 static
 bool check_lu_dims (const octave_value& l, const octave_value& u,
@@ -785,75 +783,75 @@
 %!      0.43167 ];
 %!
 %! Ac = [0.620405 + 0.956953i  0.480013 + 0.048806i  0.402627 + 0.338171i;
-%!      0.589077 + 0.658457i  0.013205 + 0.279323i  0.229284 + 0.721929i;
-%!      0.092758 + 0.345687i  0.928679 + 0.241052i  0.764536 + 0.832406i;
-%!      0.912098 + 0.721024i  0.049018 + 0.269452i  0.730029 + 0.796517i;
-%!      0.112849 + 0.603871i  0.486352 + 0.142337i  0.355646 + 0.151496i ];
+%!       0.589077 + 0.658457i  0.013205 + 0.279323i  0.229284 + 0.721929i;
+%!       0.092758 + 0.345687i  0.928679 + 0.241052i  0.764536 + 0.832406i;
+%!       0.912098 + 0.721024i  0.049018 + 0.269452i  0.730029 + 0.796517i;
+%!       0.112849 + 0.603871i  0.486352 + 0.142337i  0.355646 + 0.151496i ];
 %!
 %! uc = [0.20351 + 0.05401i;
-%!      0.13141 + 0.43708i;
-%!      0.29808 + 0.08789i;
-%!      0.69821 + 0.38844i;
-%!      0.74871 + 0.25821i ];
+%!       0.13141 + 0.43708i;
+%!       0.29808 + 0.08789i;
+%!       0.69821 + 0.38844i;
+%!       0.74871 + 0.25821i ];
 %!
 %! vc = [0.85839 + 0.29468i;
-%!      0.20820 + 0.93090i;
-%!      0.86184 + 0.34689i ];
+%!       0.20820 + 0.93090i;
+%!       0.86184 + 0.34689i ];
 %!
 
 %!testif HAVE_QRUPDATE_LUU
-%! [L,U,P] = lu(A);
-%! [L,U] = luupdate(L,U,P*u,v);
-%! assert(norm(vec(tril(L)-L),Inf) == 0)
-%! assert(norm(vec(triu(U)-U),Inf) == 0)
-%! assert(norm(vec(P'*L*U - A - u*v.'),Inf) < norm(A)*1e1*eps)
+%! [L,U,P] = lu (A);
+%! [L,U] = luupdate (L,U,P*u,v);
+%! assert (norm (vec (tril (L)-L), Inf) == 0);
+%! assert (norm (vec (triu (U)-U), Inf) == 0);
+%! assert (norm (vec (P'*L*U - A - u*v.'), Inf) < norm (A)*1e1*eps);
 %!
 %!testif HAVE_QRUPDATE_LUU
-%! [L,U,P] = lu(Ac);
-%! [L,U] = luupdate(L,U,P*uc,vc);
-%! assert(norm(vec(tril(L)-L),Inf) == 0)
-%! assert(norm(vec(triu(U)-U),Inf) == 0)
-%! assert(norm(vec(P'*L*U - Ac - uc*vc.'),Inf) < norm(Ac)*1e1*eps)
+%! [L,U,P] = lu (Ac);
+%! [L,U] = luupdate (L,U,P*uc,vc);
+%! assert (norm (vec (tril (L)-L), Inf) == 0);
+%! assert (norm (vec (triu (U)-U), Inf) == 0);
+%! assert (norm (vec (P'*L*U - Ac - uc*vc.'), Inf) < norm (Ac)*1e1*eps);
 
 %!testif HAVE_QRUPDATE_LUU
-%! [L,U,P] = lu(single(A));
-%! [L,U] = luupdate(L,U,P*single(u),single(v));
-%! assert(norm(vec(tril(L)-L),Inf) == 0)
-%! assert(norm(vec(triu(U)-U),Inf) == 0)
-%! assert(norm(vec(P'*L*U - single(A) - single(u)*single(v).'),Inf) < norm(single(A))*1e1*eps('single'))
+%! [L,U,P] = lu (single (A));
+%! [L,U] = luupdate (L,U,P*single (u), single (v));
+%! assert (norm (vec (tril (L)-L), Inf) == 0);
+%! assert (norm (vec (triu (U)-U), Inf) == 0);
+%! assert (norm (vec (P'*L*U - single (A) - single (u)*single (v).'), Inf) < norm (single (A))*1e1*eps ("single"));
 %!
 %!testif HAVE_QRUPDATE_LUU
-%! [L,U,P] = lu(single(Ac));
-%! [L,U] = luupdate(L,U,P*single(uc),single(vc));
-%! assert(norm(vec(tril(L)-L),Inf) == 0)
-%! assert(norm(vec(triu(U)-U),Inf) == 0)
-%! assert(norm(vec(P'*L*U - single(Ac) - single(uc)*single(vc).'),Inf) < norm(single(Ac))*1e1*eps('single'))
+%! [L,U,P] = lu (single (Ac));
+%! [L,U] = luupdate (L,U,P*single (uc),single (vc));
+%! assert (norm (vec (tril (L)-L), Inf) == 0);
+%! assert (norm (vec (triu (U)-U), Inf) == 0);
+%! assert (norm (vec (P'*L*U - single (Ac) - single (uc)*single (vc).'), Inf) < norm (single (Ac))*1e1*eps ("single"));
 
 %!testif HAVE_QRUPDATE_LUU
-%! [L,U,P] = lu(A);
-%! [L,U,P] = luupdate(L,U,P,u,v);
-%! assert(norm(vec(tril(L)-L),Inf) == 0)
-%! assert(norm(vec(triu(U)-U),Inf) == 0)
-%! assert(norm(vec(P'*L*U - A - u*v.'),Inf) < norm(A)*1e1*eps)
+%! [L,U,P] = lu (A);
+%! [L,U,P] = luupdate (L,U,P,u,v);
+%! assert (norm (vec (tril (L)-L), Inf) == 0);
+%! assert (norm (vec (triu (U)-U), Inf) == 0);
+%! assert (norm (vec (P'*L*U - A - u*v.'), Inf) < norm (A)*1e1*eps);
 %!
 %!testif HAVE_QRUPDATE_LUU
-%! [L,U,P] = lu(Ac);
-%! [L,U,P] = luupdate(L,U,P,uc,vc);
-%! assert(norm(vec(tril(L)-L),Inf) == 0)
-%! assert(norm(vec(triu(U)-U),Inf) == 0)
-%! assert(norm(vec(P'*L*U - Ac - uc*vc.'),Inf) < norm(Ac)*1e1*eps)
+%! [L,U,P] = lu (Ac);
+%! [L,U,P] = luupdate (L,U,P,uc,vc);
+%! assert (norm (vec (tril (L)-L), Inf) == 0);
+%! assert (norm (vec (triu (U)-U), Inf) == 0);
+%! assert (norm (vec (P'*L*U - Ac - uc*vc.'), Inf) < norm (Ac)*1e1*eps);
 
 %!testif HAVE_QRUPDATE_LUU
-%! [L,U,P] = lu(single(A));
-%! [L,U,P] = luupdate(L,U,P,single(u),single(v));
-%! assert(norm(vec(tril(L)-L),Inf) == 0)
-%! assert(norm(vec(triu(U)-U),Inf) == 0)
-%! assert(norm(vec(P'*L*U - single(A) - single(u)*single(v).'),Inf) < norm(single(A))*1e1*eps('single'))
+%! [L,U,P] = lu (single (A));
+%! [L,U,P] = luupdate (L,U,P,single (u),single (v));
+%! assert (norm (vec (tril (L)-L), Inf) == 0);
+%! assert (norm (vec (triu (U)-U), Inf) == 0);
+%! assert (norm (vec (P'*L*U - single (A) - single (u)*single (v).'), Inf) < norm (single (A))*1e1*eps ("single"));
 %!
 %!testif HAVE_QRUPDATE_LUU
-%! [L,U,P] = lu(single(Ac));
-%! [L,U,P] = luupdate(L,U,P,single(uc),single(vc));
-%! assert(norm(vec(tril(L)-L),Inf) == 0)
-%! assert(norm(vec(triu(U)-U),Inf) == 0)
-%! assert(norm(vec(P'*L*U - single(Ac) - single(uc)*single(vc).'),Inf) < norm(single(Ac))*1e1*eps('single'))
+%! [L,U,P] = lu (single (Ac));
+%! [L,U,P] = luupdate (L,U,P,single (uc),single (vc));
+%! assert (norm (vec (tril (L)-L), Inf) == 0);
+%! assert (norm (vec (triu (U)-U), Inf) == 0);
+%! assert (norm (vec (P'*L*U - single (Ac) - single (uc)*single (vc).'), Inf) < norm (single (Ac))*1e1*eps ("single"));
 */
--- a/src/DLD-FUNCTIONS/luinc.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/luinc.cc	Mon May 07 00:56:44 2012 +0200
@@ -365,21 +365,19 @@
 }
 
 /*
+%!testif HAVE_UMFPACK
+%! a = sparse ([1,2,0,0;0,1,2,0;1e-14,0,3,0;0,0,0,1]);
+%! [l,u] = luinc (a, 1e-10);
+%! assert (l*u, sparse ([1,2,0,0;0,1,2,0;0,0,3,0;0,0,0,1]), 1e-10);
+%! opts.droptol = 1e-10;
+%! [l,u] = luinc (a, opts);
+%! assert (l*u, sparse ([1,2,0,0;0,1,2,0;0,0,3,0;0,0,0,1]), 1e-10);
 
 %!testif HAVE_UMFPACK
-%! a=sparse([1,2,0,0;0,1,2,0;1e-14,0,3,0;0,0,0,1]);
-%! [l,u]=luinc(a,1e-10);
-%! assert(l*u, sparse([1,2,0,0;0,1,2,0;0,0,3,0;0,0,0,1]),1e-10);
-%! opts.droptol=1e-10;
-%! [l,u]=luinc(a,opts);
-%! assert(l*u, sparse([1,2,0,0;0,1,2,0;0,0,3,0;0,0,0,1]),1e-10);
-
-%!testif HAVE_UMFPACK
-%! a=sparse([1i,2,0,0;0,1,2,0;1e-14,0,3,0;0,0,0,1]);
-%! [l,u]=luinc(a,1e-10);
-%! assert(l*u, sparse([1i,2,0,0;0,1,2,0;0,0,3,0;0,0,0,1]),1e-10);
-%! opts.droptol=1e-10;
-%! [l,u]=luinc(a,opts);
-%! assert(l*u, sparse([1i,2,0,0;0,1,2,0;0,0,3,0;0,0,0,1]),1e-10);
-
+%! a = sparse ([1i,2,0,0;0,1,2,0;1e-14,0,3,0;0,0,0,1]);
+%! [l,u] = luinc (a, 1e-10);
+%! assert (l*u, sparse ([1i,2,0,0;0,1,2,0;0,0,3,0;0,0,0,1]), 1e-10);
+%! opts.droptol = 1e-10;
+%! [l,u] = luinc (a, opts);
+%! assert (l*u, sparse ([1i,2,0,0;0,1,2,0;0,0,3,0;0,0,0,1]), 1e-10);
 */
--- a/src/DLD-FUNCTIONS/matrix_type.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/matrix_type.cc	Mon May 07 00:56:44 2012 +0200
@@ -508,110 +508,114 @@
 }
 
 /*
-
-## FIXME
+## FIXME:
 ## Disable tests for lower under-determined and upper over-determined
 ## matrices as this detection is disabled in MatrixType due to issues
 ## of non minimum norm solution being found.
 
-%!assert(matrix_type(speye(10,10)),"Diagonal");
-%!assert(matrix_type(speye(10,10)([2:10,1],:)),"Permuted Diagonal");
-%!assert(matrix_type([[speye(10,10);sparse(1,10)],[1;sparse(9,1);1]]),"Upper");
-%!assert(matrix_type([[speye(10,10);sparse(1,10)],[1;sparse(9,1);1]](:,[2,1,3:11])),"Permuted Upper");
-%!assert(matrix_type([speye(10,10),sparse(10,1);1,sparse(1,9),1]),"Lower");
-%!assert(matrix_type([speye(10,10),sparse(10,1);1,sparse(1,9),1]([2,1,3:11],:)),"Permuted Lower");
-%!test
-%! bnd=spparms("bandden");
-%! spparms("bandden",0.5);
-%! a = spdiags(rand(10,3)-0.5,[-1,0,1],10,10);
-%! assert(matrix_type(a),"Tridiagonal");
-%! assert(matrix_type(a'+a+2*speye(10)),"Tridiagonal Positive Definite");
-%! spparms("bandden",bnd);
-%!test
-%! bnd=spparms("bandden");
-%! spparms("bandden",0.5);
-%! a = spdiags(randn(10,4),[-2:1],10,10);
-%! assert(matrix_type(a),"Banded");
-%! assert(matrix_type(a'*a),"Banded Positive Definite");
-%! spparms("bandden",bnd);
-%!test
-%! a=[speye(10,10),[sparse(9,1);1];-1,sparse(1,9),1];
-%! assert(matrix_type(a),"Full");
-%! assert(matrix_type(a'*a),"Positive Definite");
-%!assert(matrix_type(speye(10,11)),"Diagonal");
-%!assert(matrix_type(speye(10,11)([2:10,1],:)),"Permuted Diagonal");
-%!assert(matrix_type(speye(11,10)),"Diagonal");
-%!assert(matrix_type(speye(11,10)([2:11,1],:)),"Permuted Diagonal");
-%#!assert(matrix_type([[speye(10,10);sparse(1,10)],[[1,1];sparse(9,2);[1,1]]]),"Upper");
-%#!assert(matrix_type([[speye(10,10);sparse(1,10)],[[1,1];sparse(9,2);[1,1]]](:,[2,1,3:12])),"Permuted Upper");
-%!assert(matrix_type([speye(11,9),[1;sparse(8,1);1;0]]),"Upper");
-%!assert(matrix_type([speye(11,9),[1;sparse(8,1);1;0]](:,[2,1,3:10])),"Permuted Upper");
-%#!assert(matrix_type([speye(10,10),sparse(10,1);[1;1],sparse(2,9),[1;1]]),"Lower");
-%#!assert(matrix_type([speye(10,10),sparse(10,1);[1;1],sparse(2,9),[1;1]]([2,1,3:12],:)),"Permuted Lower");
-%!assert(matrix_type([speye(9,11);[1,sparse(1,8),1,0]]),"Lower");
-%!assert(matrix_type([speye(9,11);[1,sparse(1,8),1,0]]([2,1,3:10],:)),"Permuted Lower");
-%!assert(matrix_type(spdiags(randn(10,4),[-2:1],10,9)),"Rectangular")
+%!assert (matrix_type (speye (10,10)), "Diagonal")
+%!assert (matrix_type (speye (10,10)([2:10,1],:)), "Permuted Diagonal")
+%!assert (matrix_type ([[speye(10,10);sparse(1,10)],[1;sparse(9,1);1]]), "Upper")
+%!assert (matrix_type ([[speye(10,10);sparse(1,10)],[1;sparse(9,1);1]](:,[2,1,3:11])), "Permuted Upper")
+%!assert (matrix_type ([speye(10,10),sparse(10,1);1,sparse(1,9),1]), "Lower")
+%!assert (matrix_type ([speye(10,10),sparse(10,1);1,sparse(1,9),1]([2,1,3:11],:)), "Permuted Lower")
 
-%!assert(matrix_type(1i*speye(10,10)),"Diagonal");
-%!assert(matrix_type(1i*speye(10,10)([2:10,1],:)),"Permuted Diagonal");
-%!assert(matrix_type([[speye(10,10);sparse(1,10)],[1i;sparse(9,1);1]]),"Upper");
-%!assert(matrix_type([[speye(10,10);sparse(1,10)],[1i;sparse(9,1);1]](:,[2,1,3:11])),"Permuted Upper");
-%!assert(matrix_type([speye(10,10),sparse(10,1);1i,sparse(1,9),1]),"Lower");
-%!assert(matrix_type([speye(10,10),sparse(10,1);1i,sparse(1,9),1]([2,1,3:11],:)),"Permuted Lower");
 %!test
-%! bnd=spparms("bandden");
-%! spparms("bandden",0.5);
-%! assert(matrix_type(spdiags(1i*randn(10,3),[-1,0,1],10,10)),"Tridiagonal");
-%! a = 1i*(rand(9,1)-0.5);a=[[a;0],ones(10,1),[0;-a]];
-%! assert(matrix_type(spdiags(a,[-1,0,1],10,10)),"Tridiagonal Positive Definite");
-%! spparms("bandden",bnd);
+%! bnd = spparms ("bandden");
+%! spparms ("bandden", 0.5);
+%! a = spdiags (rand (10,3)-0.5,[-1,0,1],10,10);
+%! assert (matrix_type (a), "Tridiagonal");
+%! assert (matrix_type (a'+a+2*speye (10)), "Tridiagonal Positive Definite");
+%! spparms ("bandden", bnd);
+%!test
+%! bnd=spparms ("bandden");
+%! spparms ("bandden", 0.5);
+%! a = spdiags (randn (10,4),[-2:1],10,10);
+%! assert (matrix_type (a), "Banded");
+%! assert (matrix_type (a'*a), "Banded Positive Definite");
+%! spparms ("bandden", bnd);
 %!test
-%! bnd=spparms("bandden");
-%! spparms("bandden",0.5);
-%! assert(matrix_type(spdiags(1i*randn(10,4),[-2:1],10,10)),"Banded");
-%! a = 1i*(rand(9,2)-0.5);a=[[a;[0,0]],ones(10,1),[[0;-a(:,2)],[0;0;-a(1:8,1)]]];
-%! assert(matrix_type(spdiags(a,[-2:2],10,10)),"Banded Positive Definite");
-%! spparms("bandden",bnd);
-%!test
-%! a=[speye(10,10),[sparse(9,1);1i];-1,sparse(1,9),1];
-%! assert(matrix_type(a),"Full");
-%! assert(matrix_type(a'*a),"Positive Definite");
-%!assert(matrix_type(1i*speye(10,11)),"Diagonal");
-%!assert(matrix_type(1i*speye(10,11)([2:10,1],:)),"Permuted Diagonal");
-%!assert(matrix_type(1i*speye(11,10)),"Diagonal");
-%!assert(matrix_type(1i*speye(11,10)([2:11,1],:)),"Permuted Diagonal");
-%#!assert(matrix_type([[speye(10,10);sparse(1,10)],[[1i,1i];sparse(9,2);[1i,1i]]]),"Upper");
-%#!assert(matrix_type([[speye(10,10);sparse(1,10)],[[1i,1i];sparse(9,2);[1i,1i]]](:,[2,1,3:12])),"Permuted Upper");
-%!assert(matrix_type([speye(11,9),[1i;sparse(8,1);1i;0]]),"Upper");
-%!assert(matrix_type([speye(11,9),[1i;sparse(8,1);1i;0]](:,[2,1,3:10])),"Permuted Upper");
-%#!assert(matrix_type([speye(10,10),sparse(10,1);[1i;1i],sparse(2,9),[1i;1i]]),"Lower");
-%#!assert(matrix_type([speye(10,10),sparse(10,1);[1i;1i],sparse(2,9),[1i;1i]]([2,1,3:12],:)),"Permuted Lower");
-%!assert(matrix_type([speye(9,11);[1i,sparse(1,8),1i,0]]),"Lower");
-%!assert(matrix_type([speye(9,11);[1i,sparse(1,8),1i,0]]([2,1,3:10],:)),"Permuted Lower");
-%!assert(matrix_type(1i*spdiags(randn(10,4),[-2:1],10,9)),"Rectangular")
+%! a = [speye(10,10),[sparse(9,1);1];-1,sparse(1,9),1];
+%! assert (matrix_type (a), "Full");
+%! assert (matrix_type (a'*a), "Positive Definite");
+
+%!assert (matrix_type (speye (10,11)), "Diagonal")
+%!assert (matrix_type (speye (10,11)([2:10,1],:)), "Permuted Diagonal")
+%!assert (matrix_type (speye (11,10)), "Diagonal")
+%!assert (matrix_type (speye (11,10)([2:11,1],:)), "Permuted Diagonal")
+%#!assert (matrix_type ([[speye(10,10);sparse(1,10)],[[1,1];sparse(9,2);[1,1]]]), "Upper")
+%#!assert (matrix_type ([[speye(10,10);sparse(1,10)],[[1,1];sparse(9,2);[1,1]]](:,[2,1,3:12])), "Permuted Upper")
+%!assert (matrix_type ([speye(11,9),[1;sparse(8,1);1;0]]), "Upper")
+%!assert (matrix_type ([speye(11,9),[1;sparse(8,1);1;0]](:,[2,1,3:10])), "Permuted Upper")
+%#!assert (matrix_type ([speye(10,10),sparse(10,1);[1;1],sparse(2,9),[1;1]]), "Lower")
+%#!assert (matrix_type ([speye(10,10),sparse(10,1);[1;1],sparse(2,9),[1;1]]([2,1,3:12],:)), "Permuted Lower")
+%!assert (matrix_type ([speye(9,11);[1,sparse(1,8),1,0]]), "Lower")
+%!assert (matrix_type ([speye(9,11);[1,sparse(1,8),1,0]]([2,1,3:10],:)), "Permuted Lower")
+%!assert (matrix_type (spdiags (randn (10,4),[-2:1],10,9)), "Rectangular")
+
+%!assert (matrix_type (1i*speye (10,10)), "Diagonal")
+%!assert (matrix_type (1i*speye (10,10)([2:10,1],:)), "Permuted Diagonal")
+%!assert (matrix_type ([[speye(10,10);sparse(1,10)],[1i;sparse(9,1);1]]), "Upper")
+%!assert (matrix_type ([[speye(10,10);sparse(1,10)],[1i;sparse(9,1);1]](:,[2,1,3:11])), "Permuted Upper")
+%!assert (matrix_type ([speye(10,10),sparse(10,1);1i,sparse(1,9),1]), "Lower")
+%!assert (matrix_type ([speye(10,10),sparse(10,1);1i,sparse(1,9),1]([2,1,3:11],:)), "Permuted Lower")
 
 %!test
-%! a = matrix_type(spdiags(randn(10,3),[-1,0,1],10,10),"Singular");
-%! assert(matrix_type(a),"Singular");
-
-%!assert(matrix_type(triu(ones(10,10))),"Upper");
-%!assert(matrix_type(triu(ones(10,10),-1)),"Full");
-%!assert(matrix_type(tril(ones(10,10))),"Lower");
-%!assert(matrix_type(tril(ones(10,10),1)),"Full");
-%!assert(matrix_type(10*eye(10,10) + ones(10,10)), "Positive Definite");
-%!assert(matrix_type(ones(11,10)),"Rectangular")
+%! bnd = spparms ("bandden");
+%! spparms ("bandden", 0.5);
+%! assert (matrix_type (spdiags (1i*randn (10,3),[-1,0,1],10,10)), "Tridiagonal");
+%! a = 1i*(rand (9,1)-0.5);
+%! a = [[a;0],ones(10,1),[0;-a]];
+%! assert (matrix_type (spdiags (a,[-1,0,1],10,10)), "Tridiagonal Positive Definite");
+%! spparms ("bandden", bnd);
+%!test
+%! bnd = spparms ("bandden");
+%! spparms ("bandden", 0.5);
+%! assert (matrix_type (spdiags (1i*randn (10,4),[-2:1],10,10)), "Banded");
+%! a = 1i*(rand (9,2)-0.5);
+%! a = [[a;[0,0]],ones(10,1),[[0;-a(:,2)],[0;0;-a(1:8,1)]]];
+%! assert (matrix_type (spdiags (a,[-2:2],10,10)), "Banded Positive Definite");
+%! spparms ("bandden", bnd);
 %!test
-%! a = matrix_type(ones(10,10),"Singular");
-%! assert(matrix_type(a),"Singular");
+%! a = [speye(10,10),[sparse(9,1);1i];-1,sparse(1,9),1];
+%! assert (matrix_type (a), "Full");
+%! assert (matrix_type (a'*a), "Positive Definite");
+
+%!assert (matrix_type (1i*speye (10,11)), "Diagonal")
+%!assert (matrix_type (1i*speye (10,11)([2:10,1],:)), "Permuted Diagonal")
+%!assert (matrix_type (1i*speye (11,10)), "Diagonal")
+%!assert (matrix_type (1i*speye (11,10)([2:11,1],:)), "Permuted Diagonal")
+%#!assert (matrix_type ([[speye(10,10);sparse(1,10)],[[1i,1i];sparse(9,2);[1i,1i]]]), "Upper")
+%#!assert (matrix_type ([[speye(10,10);sparse(1,10)],[[1i,1i];sparse(9,2);[1i,1i]]](:,[2,1,3:12])), "Permuted Upper")
+%!assert (matrix_type ([speye(11,9),[1i;sparse(8,1);1i;0]]), "Upper")
+%!assert (matrix_type ([speye(11,9),[1i;sparse(8,1);1i;0]](:,[2,1,3:10])), "Permuted Upper")
+%#!assert (matrix_type ([speye(10,10),sparse(10,1);[1i;1i],sparse(2,9),[1i;1i]]), "Lower")
+%#!assert (matrix_type ([speye(10,10),sparse(10,1);[1i;1i],sparse(2,9),[1i;1i]]([2,1,3:12],:)), "Permuted Lower")
+%!assert (matrix_type ([speye(9,11);[1i,sparse(1,8),1i,0]]), "Lower")
+%!assert (matrix_type ([speye(9,11);[1i,sparse(1,8),1i,0]]([2,1,3:10],:)), "Permuted Lower")
+%!assert (matrix_type (1i*spdiags(randn(10,4),[-2:1],10,9)), "Rectangular")
 
-%!assert(matrix_type(triu(1i*ones(10,10))),"Upper");
-%!assert(matrix_type(triu(1i*ones(10,10),-1)),"Full");
-%!assert(matrix_type(tril(1i*ones(10,10))),"Lower");
-%!assert(matrix_type(tril(1i*ones(10,10),1)),"Full");
-%!assert(matrix_type(10*eye(10,10) + 1i*triu(ones(10,10),1) -1i*tril(ones(10,10),-1)), "Positive Definite");
-%!assert(matrix_type(ones(11,10)),"Rectangular")
+%!test
+%! a = matrix_type (spdiags (randn (10,3),[-1,0,1],10,10), "Singular");
+%! assert (matrix_type (a), "Singular");
+
+%!assert (matrix_type (triu (ones(10,10))), "Upper")
+%!assert (matrix_type (triu (ones(10,10),-1)), "Full")
+%!assert (matrix_type (tril (ones(10,10))), "Lower")
+%!assert (matrix_type (tril (ones(10,10),1)), "Full")
+%!assert (matrix_type (10*eye (10,10) + ones (10,10)), "Positive Definite")
+%!assert (matrix_type (ones (11,10)), "Rectangular")
 %!test
-%! a = matrix_type(ones(10,10),"Singular");
-%! assert(matrix_type(a),"Singular");
+%! a = matrix_type (ones (10,10), "Singular");
+%! assert (matrix_type (a), "Singular");
 
+%!assert (matrix_type (triu (1i*ones (10,10))), "Upper")
+%!assert (matrix_type (triu (1i*ones (10,10),-1)), "Full")
+%!assert (matrix_type (tril (1i*ones (10,10))), "Lower")
+%!assert (matrix_type (tril (1i*ones (10,10),1)), "Full")
+%!assert (matrix_type (10*eye (10,10) + 1i*triu (ones (10,10),1) -1i*tril (ones (10,10),-1)), "Positive Definite")
+%!assert (matrix_type (ones (11,10)), "Rectangular")
+%!test
+%! a = matrix_type (ones (10,10), "Singular");
+%! assert (matrix_type (a), "Singular");
 */
--- a/src/DLD-FUNCTIONS/max.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/max.cc	Mon May 07 00:56:44 2012 +0200
@@ -358,30 +358,22 @@
 }
 
 /*
-
-%% test/octave.test/arith/min-1.m
-%!assert (min ([1, 4, 2, 3]) == 1);
-%!assert (min ([1; -10; 5; -2]) == -10);
-
-%% test/octave.test/arith/min-2.m
-%!assert(all (min ([4, i; -2, 2]) == [-2, i]));
-
-%% test/octave.test/arith/min-3.m
-%!error <Invalid call to min> min ();
-
-%% test/octave.test/arith/min-4.m
-%!error <Invalid call to min> min (1, 2, 3, 4);
+%!assert (min ([1, 4, 2, 3]), 1)
+%!assert (min ([1; -10; 5; -2]), -10)
+%!assert (min ([4, i; -2, 2]), [-2, i])
 
 %!test
-%! x = reshape (1:8,[2,2,2]);
-%! assert (max (x,[],1), reshape ([2, 4, 6, 8], [1,2,2]));
-%! assert (max (x,[],2), reshape ([3, 4, 7, 8], [2,1,2]));
-%! [y, i ] = max (x, [], 3);
+%! x = reshape (1:8, [2,2,2]);
+%! assert (max (x, [], 1), reshape ([2, 4, 6, 8], [1,2,2]));
+%! assert (max (x, [], 2), reshape ([3, 4, 7, 8], [2,1,2]));
+%! [y, i] = max (x, [], 3);
+%! assert (ndims (y), 2);
 %! assert (y, [5, 7; 6, 8]);
-%! assert (ndims(y), 2);
+%! assert (ndims (i), 2);
 %! assert (i, [2, 2; 2, 2]);
-%! assert (ndims(i), 2);
 
+%!error min ()
+%!error min (1, 2, 3, 4)
 */
 
 DEFUN_DLD (max, args, nargout,
@@ -437,31 +429,22 @@
 }
 
 /*
-
-%% test/octave.test/arith/max-1.m
-%!assert (max ([1, 4, 2, 3]) == 4);
-%!assert (max ([1; -10; 5; -2]) == 5);
-
-%% test/octave.test/arith/max-2.m
-%!assert(all (max ([4, i 4.999; -2, 2, 3+4i]) == [4, 2, 3+4i]));
-
-%% test/octave.test/arith/max-3.m
-%!error <Invalid call to max> max ();
-
-%% test/octave.test/arith/max-4.m
-%!error <Invalid call to max> max (1, 2, 3, 4);
+%!assert (max ([1, 4, 2, 3]), 4)
+%!assert (max ([1; -10; 5; -2]), 5)
+%!assert (max ([4, i 4.999; -2, 2, 3+4i]), [4, 2, 3+4i])
 
 %!test
-%! x = reshape (1:8,[2,2,2]);
-%! assert (min (x,[],1), reshape ([1, 3, 5, 7], [1,2,2]));
-%! assert (min (x,[],2), reshape ([1, 2, 5, 6], [2,1,2]));
-%! [y, i ] = min (x, [], 3);
+%! x = reshape (1:8, [2,2,2]);
+%! assert (min (x, [], 1), reshape ([1, 3, 5, 7], [1,2,2]));
+%! assert (min (x, [], 2), reshape ([1, 2, 5, 6], [2,1,2]));
+%! [y, i] = min (x, [], 3);
+%! assert (ndims(y), 2);
 %! assert (y, [1, 3; 2, 4]);
-%! assert (ndims(y), 2);
+%! assert (ndims(i), 2);
 %! assert (i, [1, 1; 1, 1]);
-%! assert (ndims(i), 2);
 
-
+%!error max ()
+%!error max (1, 2, 3, 4)
 */
 
 template <class ArrayType>
--- a/src/DLD-FUNCTIONS/mgorth.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/mgorth.cc	Mon May 07 00:56:44 2012 +0200
@@ -139,9 +139,10 @@
 }
 
 /*
-
 %!test
-%! for ii=1:100; assert (abs (mgorth (randn (5, 1), eye (5, 4))), [0 0 0 0 1]', eps); endfor
+%! for ii=1:100
+%!   assert (abs (mgorth (randn (5, 1), eye (5, 4))), [0 0 0 0 1]', eps);
+%! endfor
 
 %!test
 %! a = hilb (5);
@@ -150,5 +151,4 @@
 %!   a(:, ii) = mgorth (a(:, ii), a(:, 1:ii-1));
 %! endfor
 %! assert (a' * a, eye (5), 1e10);
-
 */
--- a/src/DLD-FUNCTIONS/nproc.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/nproc.cc	Mon May 07 00:56:44 2012 +0200
@@ -85,8 +85,6 @@
 }
 
 /*
-
-%% Must always report at least 1 cpu available
+## Must always report at least 1 cpu available
 %!assert (nproc () >= 1);
-
 */
--- a/src/DLD-FUNCTIONS/qr.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/qr.cc	Mon May 07 00:56:44 2012 +0200
@@ -456,12 +456,10 @@
 }
 
 /*
-
 %!test
 %! a = [0, 2, 1; 2, 1, 2];
 %!
 %! [q, r] = qr (a);
-%!
 %! [qe, re] = qr (a, 0);
 %!
 %! assert (q * r, a, sqrt (eps));
@@ -470,8 +468,7 @@
 %!test
 %! a = [0, 2, 1; 2, 1, 2];
 %!
-%! [q, r, p] = qr (a);  # not giving right dimensions. FIXME
-%!
+%! [q, r, p] = qr (a);  # FIXME: not giving right dimensions. 
 %! [qe, re, pe] = qr (a, 0);
 %!
 %! assert (q * r, a * p, sqrt (eps));
@@ -481,7 +478,6 @@
 %! a = [0, 2; 2, 1; 1, 2];
 %!
 %! [q, r] = qr (a);
-%!
 %! [qe, re] = qr (a, 0);
 %!
 %! assert (q * r, a, sqrt (eps));
@@ -491,27 +487,26 @@
 %! a = [0, 2; 2, 1; 1, 2];
 %!
 %! [q, r, p] = qr (a);
-%!
 %! [qe, re, pe] = qr (a, 0);
 %!
 %! assert (q * r, a * p, sqrt (eps));
 %! assert (qe * re, a(:, pe), sqrt (eps));
 
-%!error <Invalid call to qr> qr ();
-%!error <Invalid call to qr> qr ([1, 2; 3, 4], 0, 2);
+%!error qr ()
+%!error qr ([1, 2; 3, 4], 0, 2)
 
 %!function retval = __testqr (q, r, a, p)
-%!  tol = 100*eps (class(q));
+%!  tol = 100*eps (class (q));
 %!  retval = 0;
 %!  if (nargin == 3)
-%!    n1 = norm (q*r-a);
-%!    n2 = norm (q'*q-eye(columns(q)));
+%!    n1 = norm (q*r - a);
+%!    n2 = norm (q'*q - eye (columns (q)));
 %!    retval = (n1 < tol && n2 < tol);
 %!  else
-%!    n1 = norm (q'*q-eye(columns(q)));
+%!    n1 = norm (q'*q - eye (columns (q)));
 %!    retval = (n1 < tol);
 %!    if (isvector (p))
-%!      n2 = norm (q*r-a(:,p));
+%!      n2 = norm (q*r - a(:,p));
 %!      retval = (retval && n2 < tol);
 %!    else
 %!      n2 = norm (q*r - a*p);
@@ -521,237 +516,226 @@
 %!endfunction
 
 %!test
-%!
 %! t = ones (24, 1);
 %! j = 1;
 %!
-%! if false # eliminate big matrix tests
-%!   a = rand(5000,20);
-%!   [q,r]=qr(a,0); t(j++) = __testqr(q,r,a);
-%!   [q,r]=qr(a',0); t(j++) = __testqr(q,r,a');
-%!   [q,r,p]=qr(a,0); t(j++) = __testqr(q,r,a,p);
-%!   [q,r,p]=qr(a',0); t(j++) = __testqr(q,r,a',p);
+%! if (false)  # eliminate big matrix tests
+%!   a = rand (5000, 20);
+%!   [q,r]   = qr (a, 0);  t(j++) = __testqr (q, r, a);
+%!   [q,r]   = qr (a',0);  t(j++) = __testqr (q, r, a');
+%!   [q,r,p] = qr (a, 0);  t(j++) = __testqr (q, r, a, p);
+%!   [q,r,p] = qr (a',0);  t(j++) = __testqr (q, r, a', p);
 %!
 %!   a = a+1i*eps;
-%!   [q,r]=qr(a,0); t(j++) = __testqr(q,r,a);
-%!   [q,r]=qr(a',0); t(j++) = __testqr(q,r,a');
-%!   [q,r,p]=qr(a,0); t(j++) = __testqr(q,r,a,p);
-%!   [q,r,p]=qr(a',0); t(j++) = __testqr(q,r,a',p);
+%!   [q,r]   = qr (a, 0);  t(j++) = __testqr (q, r, a);
+%!   [q,r]   = qr (a',0);  t(j++) = __testqr (q, r, a');
+%!   [q,r,p] = qr (a, 0);  t(j++) = __testqr (q, r, a, p);
+%!   [q,r,p] = qr (a',0);  t(j++) = __testqr (q, r, a', p);
 %! endif
 %!
 %! a = [ ones(1,15); sqrt(eps)*eye(15) ];
-%! [q,r]=qr(a); t(j++) = __testqr(q,r,a);
-%! [q,r]=qr(a'); t(j++) = __testqr(q,r,a');
-%! [q,r,p]=qr(a); t(j++) = __testqr(q,r,a,p);
-%! [q,r,p]=qr(a'); t(j++) = __testqr(q,r,a',p);
-%!
-%! a = a+1i*eps;
-%! [q,r]=qr(a); t(j++) = __testqr(q,r,a);
-%! [q,r]=qr(a'); t(j++) = __testqr(q,r,a');
-%! [q,r,p]=qr(a); t(j++) = __testqr(q,r,a,p);
-%! [q,r,p]=qr(a'); t(j++) = __testqr(q,r,a',p);
-%!
-%! a = [ ones(1,15); sqrt(eps)*eye(15) ];
-%! [q,r]=qr(a,0); t(j++) = __testqr(q,r,a);
-%! [q,r]=qr(a',0); t(j++) = __testqr(q,r,a');
-%! [q,r,p]=qr(a,0); t(j++) = __testqr(q,r,a,p);
-%! [q,r,p]=qr(a',0); t(j++) = __testqr(q,r,a',p);
+%! [q,r]   = qr (a);   t(j++) = __testqr (q, r, a);
+%! [q,r]   = qr (a');  t(j++) = __testqr (q, r, a');
+%! [q,r,p] = qr (a);   t(j++) = __testqr (q, r, a, p);
+%! [q,r,p] = qr (a');  t(j++) = __testqr (q, r, a', p);
 %!
 %! a = a+1i*eps;
-%! [q,r]=qr(a,0); t(j++) = __testqr(q,r,a);
-%! [q,r]=qr(a',0); t(j++) = __testqr(q,r,a');
-%! [q,r,p]=qr(a,0); t(j++) = __testqr(q,r,a,p);
-%! [q,r,p]=qr(a',0); t(j++) = __testqr(q,r,a',p);
+%! [q,r]   = qr (a);   t(j++) = __testqr (q, r, a);
+%! [q,r]   = qr (a');  t(j++) = __testqr (q, r, a');
+%! [q,r,p] = qr (a);   t(j++) = __testqr (q, r, a, p);
+%! [q,r,p] = qr (a');  t(j++) = __testqr (q, r, a', p);
+%!
+%! a = [ ones(1,15); sqrt(eps)*eye(15) ];
+%! [q,r]   = qr (a, 0);  t(j++) = __testqr (q, r, a);
+%! [q,r]   = qr (a',0);  t(j++) = __testqr (q, r, a');
+%! [q,r,p] = qr (a, 0);  t(j++) = __testqr (q, r, a, p);
+%! [q,r,p] = qr (a',0);  t(j++) = __testqr (q, r, a', p);
 %!
-%! a = [
-%! 611   196  -192   407    -8   -52   -49    29
-%! 196   899   113  -192   -71   -43    -8   -44
-%! -192   113   899   196    61    49     8    52
-%! 407  -192   196   611     8    44    59   -23
-%! -8   -71    61     8   411  -599   208   208
-%! -52   -43    49    44  -599   411   208   208
-%! -49    -8     8    59   208   208    99  -911
-%! 29   -44    52   -23   208   208  -911    99
-%! ];
-%! [q,r] = qr(a);
+%! a = a+1i*eps;
+%! [q,r]   = qr (a, 0);  t(j++) = __testqr (q, r, a);
+%! [q,r]   = qr (a',0);  t(j++) = __testqr (q, r, a');
+%! [q,r,p] = qr (a, 0);  t(j++) = __testqr (q, r, a, p);
+%! [q,r,p] = qr (a',0);  t(j++) = __testqr (q, r, a', p);
 %!
-%! assert(all (t) && norm(q*r-a) < 5000*eps);
+%! a = [ 611   196  -192   407    -8   -52   -49    29
+%!       196   899   113  -192   -71   -43    -8   -44
+%!      -192   113   899   196    61    49     8    52
+%!       407  -192   196   611     8    44    59   -23
+%!        -8   -71    61     8   411  -599   208   208
+%!       -52   -43    49    44  -599   411   208   208
+%!       -49    -8     8    59   208   208    99  -911
+%!        29   -44    52   -23   208   208  -911    99 ];
+%! [q,r] = qr (a);
+%!
+%! assert (all (t) && norm (q*r - a) < 5000*eps);
 
 %!test
 %! a = single ([0, 2, 1; 2, 1, 2]);
 %!
 %! [q, r] = qr (a);
-%!
 %! [qe, re] = qr (a, 0);
 %!
-%! assert (q * r, a, sqrt (eps ('single')));
-%! assert (qe * re, a, sqrt (eps ('single')));
+%! assert (q * r, a, sqrt (eps ("single")));
+%! assert (qe * re, a, sqrt (eps ("single")));
 
 %!test
-%! a = single([0, 2, 1; 2, 1, 2]);
+%! a = single ([0, 2, 1; 2, 1, 2]);
 %!
-%! [q, r, p] = qr (a);  # not giving right dimensions. FIXME
-%!
+%! [q, r, p] = qr (a);  # FIXME: not giving right dimensions.
 %! [qe, re, pe] = qr (a, 0);
 %!
-%! assert (q * r, a * p, sqrt (eps('single')));
-%! assert (qe * re, a(:, pe), sqrt (eps('single')));
+%! assert (q * r, a * p, sqrt (eps ("single")));
+%! assert (qe * re, a(:, pe), sqrt (eps ("single")));
 
 %!test
-%! a = single([0, 2; 2, 1; 1, 2]);
+%! a = single ([0, 2; 2, 1; 1, 2]);
 %!
 %! [q, r] = qr (a);
-%!
 %! [qe, re] = qr (a, 0);
 %!
-%! assert (q * r, a, sqrt (eps('single')));
-%! assert (qe * re, a, sqrt (eps('single')));
+%! assert (q * r, a, sqrt (eps ("single")));
+%! assert (qe * re, a, sqrt (eps ("single")));
 
 %!test
-%! a = single([0, 2; 2, 1; 1, 2]);
+%! a = single ([0, 2; 2, 1; 1, 2]);
 %!
 %! [q, r, p] = qr (a);
-%!
 %! [qe, re, pe] = qr (a, 0);
 %!
-%! assert (q * r, a * p, sqrt (eps('single')));
-%! assert (qe * re, a(:, pe), sqrt (eps('single')));
+%! assert (q * r, a * p, sqrt (eps ("single")));
+%! assert (qe * re, a(:, pe), sqrt (eps ("single")));
 
-%!error <Invalid call to qr> qr ();
-%!error <Invalid call to qr> qr ([1, 2; 3, 4], 0, 2);
+%!error qr ()
+%!error qr ([1, 2; 3, 4], 0, 2)
 
 %!test
-%!
 %! t = ones (24, 1);
 %! j = 1;
 %!
-%! if false # eliminate big matrix tests
-%!   a = rand(5000,20);
-%!   [q,r]=qr(a,0); t(j++) = __testqr(q,r,a);
-%!   [q,r]=qr(a',0); t(j++) = __testqr(q,r,a');
-%!   [q,r,p]=qr(a,0); t(j++) = __testqr(q,r,a,p);
-%!   [q,r,p]=qr(a',0); t(j++) = __testqr(q,r,a',p);
+%! if (false)  # eliminate big matrix tests
+%!   a = rand (5000,20);
+%!   [q,r]   = qr (a, 0);  t(j++) = __testqr (q, r, a);
+%!   [q,r]   = qr (a',0);  t(j++) = __testqr (q, r, a');
+%!   [q,r,p] = qr (a, 0);  t(j++) = __testqr (q, r, a, p);
+%!   [q,r,p] = qr (a',0);  t(j++) = __testqr (q, r, a', p);
 %!
-%!   a = a+1i*eps('single');
-%!   [q,r]=qr(a,0); t(j++) = __testqr(q,r,a);
-%!   [q,r]=qr(a',0); t(j++) = __testqr(q,r,a');
-%!   [q,r,p]=qr(a,0); t(j++) = __testqr(q,r,a,p);
-%!   [q,r,p]=qr(a',0); t(j++) = __testqr(q,r,a',p);
+%!   a = a+1i*eps ("single");
+%!   [q,r]   = qr (a, 0);  t(j++) = __testqr (q, r, a);
+%!   [q,r]   = qr (a',0);  t(j++) = __testqr (q, r, a');
+%!   [q,r,p] = qr (a, 0);  t(j++) = __testqr (q, r, a, p);
+%!   [q,r,p] = qr (a',0);  t(j++) = __testqr (q, r, a', p);
 %! endif
 %!
-%! a = [ ones(1,15); sqrt(eps('single'))*eye(15) ];
-%! [q,r]=qr(a); t(j++) = __testqr(q,r,a);
-%! [q,r]=qr(a'); t(j++) = __testqr(q,r,a');
-%! [q,r,p]=qr(a); t(j++) = __testqr(q,r,a,p);
-%! [q,r,p]=qr(a'); t(j++) = __testqr(q,r,a',p);
+%! a = [ ones(1,15); sqrt(eps("single"))*eye(15) ];
+%! [q,r]   = qr (a);   t(j++) = __testqr (q, r, a);
+%! [q,r]   = qr (a');  t(j++) = __testqr (q, r, a');
+%! [q,r,p] = qr (a);   t(j++) = __testqr (q, r, a, p);
+%! [q,r,p] = qr (a');  t(j++) = __testqr (q, r, a', p);
 %!
-%! a = a+1i*eps('single');
-%! [q,r]=qr(a); t(j++) = __testqr(q,r,a);
-%! [q,r]=qr(a'); t(j++) = __testqr(q,r,a');
-%! [q,r,p]=qr(a); t(j++) = __testqr(q,r,a,p);
-%! [q,r,p]=qr(a'); t(j++) = __testqr(q,r,a',p);
+%! a = a+1i*eps ("single");
+%! [q,r]   = qr (a);   t(j++) = __testqr (q, r, a);
+%! [q,r]   = qr (a');  t(j++) = __testqr (q, r, a');
+%! [q,r,p] = qr (a);   t(j++) = __testqr (q, r, a, p);
+%! [q,r,p] = qr (a');  t(j++) = __testqr (q, r, a', p);
 %!
-%! a = [ ones(1,15); sqrt(eps('single'))*eye(15) ];
-%! [q,r]=qr(a,0); t(j++) = __testqr(q,r,a);
-%! [q,r]=qr(a',0); t(j++) = __testqr(q,r,a');
-%! [q,r,p]=qr(a,0); t(j++) = __testqr(q,r,a,p);
-%! [q,r,p]=qr(a',0); t(j++) = __testqr(q,r,a',p);
+%! a = [ ones(1,15); sqrt(eps("single"))*eye(15) ];
+%! [q,r]   = qr (a, 0);  t(j++) = __testqr (q, r, a);
+%! [q,r]   = qr (a',0);  t(j++) = __testqr (q, r, a');
+%! [q,r,p] = qr (a, 0);  t(j++) = __testqr (q, r, a, p);
+%! [q,r,p] = qr (a',0);  t(j++) = __testqr (q, r, a', p);
 %!
-%! a = a+1i*eps('single');
-%! [q,r]=qr(a,0); t(j++) = __testqr(q,r,a);
-%! [q,r]=qr(a',0); t(j++) = __testqr(q,r,a');
-%! [q,r,p]=qr(a,0); t(j++) = __testqr(q,r,a,p);
-%! [q,r,p]=qr(a',0); t(j++) = __testqr(q,r,a',p);
+%! a = a+1i*eps ("single");
+%! [q,r]   = qr (a, 0);  t(j++) = __testqr (q, r, a);
+%! [q,r]   = qr (a',0);  t(j++) = __testqr (q, r, a');
+%! [q,r,p] = qr (a, 0);  t(j++) = __testqr (q, r, a, p);
+%! [q,r,p] = qr (a',0);  t(j++) = __testqr (q, r, a',p);
 %!
-%! a = [
-%! 611   196  -192   407    -8   -52   -49    29
-%! 196   899   113  -192   -71   -43    -8   -44
-%! -192   113   899   196    61    49     8    52
-%! 407  -192   196   611     8    44    59   -23
-%! -8   -71    61     8   411  -599   208   208
-%! -52   -43    49    44  -599   411   208   208
-%! -49    -8     8    59   208   208    99  -911
-%! 29   -44    52   -23   208   208  -911    99
-%! ];
-%! [q,r] = qr(a);
+%! a = [ 611   196  -192   407    -8   -52   -49    29
+%!       196   899   113  -192   -71   -43    -8   -44
+%!      -192   113   899   196    61    49     8    52
+%!       407  -192   196   611     8    44    59   -23
+%!        -8   -71    61     8   411  -599   208   208
+%!       -52   -43    49    44  -599   411   208   208
+%!       -49    -8     8    59   208   208    99  -911
+%!        29   -44    52   -23   208   208  -911    99 ];
+%! [q,r] = qr (a);
 %!
-%! assert(all (t) && norm(q*r-a) < 5000*eps('single'));
+%! assert (all (t) && norm (q*r-a) < 5000*eps ("single"));
 
-%% The deactivated tests below can't be tested till rectangular back-subs is
-%% implemented for sparse matrices.
+## The deactivated tests below can't be tested till rectangular back-subs is
+## implemented for sparse matrices.
 
 %!testif HAVE_CXSPARSE
-%! n = 20; d= 0.2;
-%! a = sprandn(n,n,d)+speye(n,n);
-%! r = qr(a);
-%! assert(r'*r,a'*a,1e-10)
+%! n = 20;  d = 0.2;
+%! a = sprandn (n,n,d) + speye (n,n);
+%! r = qr (a);
+%! assert (r'*r, a'*a, 1e-10)
 
 %!testif HAVE_COLAMD
-%! n = 20; d= 0.2;
-%! a = sprandn(n,n,d)+speye(n,n);
-%! q = symamd(a);
+%! n = 20;  d = 0.2;
+%! a = sprandn (n,n,d) + speye (n,n);
+%! q = symamd (a);
 %! a = a(q,q);
-%! r = qr(a);
-%! assert(r'*r,a'*a,1e-10)
+%! r = qr (a);
+%! assert (r'*r, a'*a, 1e-10)
 
 %!testif HAVE_CXSPARSE
-%! n = 20; d= 0.2;
-%! a = sprandn(n,n,d)+speye(n,n);
-%! [c,r] = qr(a,ones(n,1));
-%! assert (r\c,full(a)\ones(n,1),10e-10)
+%! n = 20;  d = 0.2;
+%! a = sprandn (n,n,d) + speye (n,n);
+%! [c,r] = qr (a, ones (n,1));
+%! assert (r\c, full (a)\ones (n,1), 10e-10)
 
 %!testif HAVE_CXSPARSE
-%! n = 20; d= 0.2;
-%! a = sprandn(n,n,d)+speye(n,n);
-%! b = randn(n,2);
-%! [c,r] = qr(a,b);
-%! assert (r\c,full(a)\b,10e-10)
+%! n = 20;  d = 0.2;
+%! a = sprandn (n,n,d) + speye (n,n);
+%! b = randn (n,2);
+%! [c,r] = qr (a, b);
+%! assert (r\c, full (a)\b, 10e-10)
 
 %% Test under-determined systems!!
 %!#testif HAVE_CXSPARSE
-%! n = 20; d= 0.2;
-%! a = sprandn(n,n+1,d)+speye(n,n+1);
-%! b = randn(n,2);
-%! [c,r] = qr(a,b);
-%! assert (r\c,full(a)\b,10e-10)
+%! n = 20;  d = 0.2;
+%! a = sprandn (n,n+1,d) + speye (n,n+1);
+%! b = randn (n,2);
+%! [c,r] = qr (a, b);
+%! assert (r\c, full (a)\b, 10e-10)
 
 %!testif HAVE_CXSPARSE
-%! n = 20; d= 0.2;
-%! a = 1i*sprandn(n,n,d)+speye(n,n);
-%! r = qr(a);
-%! assert(r'*r,a'*a,1e-10)
+%! n = 20;  d = 0.2;
+%! a = 1i*sprandn (n,n,d) + speye (n,n);
+%! r = qr (a);
+%! assert (r'*r,a'*a,1e-10)
 
 %!testif HAVE_COLAMD
-%! n = 20; d= 0.2;
-%! a = 1i*sprandn(n,n,d)+speye(n,n);
-%! q = symamd(a);
+%! n = 20;  d = 0.2;
+%! a = 1i*sprandn (n,n,d) + speye (n,n);
+%! q = symamd (a);
 %! a = a(q,q);
-%! r = qr(a);
-%! assert(r'*r,a'*a,1e-10)
+%! r = qr (a);
+%! assert (r'*r, a'*a, 1e-10)
 
 %!testif HAVE_CXSPARSE
-%! n = 20; d= 0.2;
-%! a = 1i*sprandn(n,n,d)+speye(n,n);
-%! [c,r] = qr(a,ones(n,1));
-%! assert (r\c,full(a)\ones(n,1),10e-10)
+%! n = 20;  d = 0.2;
+%! a = 1i*sprandn (n,n,d) + speye (n,n);
+%! [c,r] = qr (a, ones (n,1));
+%! assert (r\c, full (a)\ones (n,1), 10e-10)
 
 %!testif HAVE_CXSPARSE
-%! n = 20; d= 0.2;
-%! a = 1i*sprandn(n,n,d)+speye(n,n);
-%! b = randn(n,2);
-%! [c,r] = qr(a,b);
-%! assert (r\c,full(a)\b,10e-10)
+%! n = 20;  d = 0.2;
+%! a = 1i*sprandn (n,n,d) + speye (n,n);
+%! b = randn (n,2);
+%! [c,r] = qr (a, b);
+%! assert (r\c, full (a)\b, 10e-10)
 
 %% Test under-determined systems!!
 %!#testif HAVE_CXSPARSE
-%! n = 20; d= 0.2;
-%! a = 1i*sprandn(n,n+1,d)+speye(n,n+1);
-%! b = randn(n,2);
-%! [c,r] = qr(a,b);
-%! assert (r\c,full(a)\b,10e-10)
+%! n = 20;  d = 0.2;
+%! a = 1i*sprandn (n,n+1,d) + speye (n,n+1);
+%! b = randn (n,2);
+%! [c,r] = qr (a, b);
+%! assert (r\c, full (a)\b, 10e-10)
 
-%!error qr(sprandn(10,10,0.2),ones(10,1));
-
+%!error qr (sprandn (10,10,0.2), ones (10,1))
 */
 
 static
@@ -885,6 +869,7 @@
 
   return retval;
 }
+
 /*
 %!shared A, u, v, Ac, uc, vc
 %! A = [0.091364  0.613038  0.999083;
@@ -921,32 +906,32 @@
 %!
 
 %!test
-%! [Q,R] = qr(A);
-%! [Q,R] = qrupdate(Q,R,u,v);
-%! assert(norm(vec(Q'*Q - eye(5)),Inf) < 1e1*eps)
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - A - u*v'),Inf) < norm(A)*1e1*eps)
+%! [Q,R] = qr (A);
+%! [Q,R] = qrupdate (Q, R, u, v);
+%! assert (norm (vec (Q'*Q - eye (5)), Inf) < 1e1*eps);
+%! assert (norm (vec (triu (R)-R), Inf) == 0);
+%! assert (norm (vec (Q*R - A - u*v'), Inf) < norm (A)*1e1*eps);
 %!
 %!test
-%! [Q,R] = qr(Ac);
-%! [Q,R] = qrupdate(Q,R,uc,vc);
-%! assert(norm(vec(Q'*Q - eye(5)),Inf) < 1e1*eps)
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - Ac - uc*vc'),Inf) < norm(Ac)*1e1*eps)
+%! [Q,R] = qr (Ac);
+%! [Q,R] = qrupdate (Q, R, uc, vc);
+%! assert (norm (vec (Q'*Q - eye (5)), Inf) < 1e1*eps);
+%! assert (norm (vec (triu (R)-R), Inf) == 0);
+%! assert (norm (vec (Q*R - Ac - uc*vc'), Inf) < norm (Ac)*1e1*eps);
 
 %!test
-%! [Q,R] = qr(single(A));
-%! [Q,R] = qrupdate(Q,R,single(u),single(v));
-%! assert(norm(vec(Q'*Q - eye(5,'single')),Inf) < 1e1*eps('single'))
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - single(A) - single(u)*single(v)'),Inf) < norm(single(A))*1e1*eps('single'))
+%! [Q,R] = qr (single (A));
+%! [Q,R] = qrupdate (Q, R, single (u), single (v));
+%! assert (norm (vec (Q'*Q - eye (5,"single")), Inf) < 1e1*eps ("single"));
+%! assert (norm (vec (triu (R)-R), Inf) == 0);
+%! assert (norm (vec (Q*R - single (A) - single (u)*single (v)'), Inf) < norm (single (A))*1e1*eps ("single"));
 %!
 %!test
-%! [Q,R] = qr(single(Ac));
-%! [Q,R] = qrupdate(Q,R,single(uc),single(vc));
-%! assert(norm(vec(Q'*Q - eye(5,'single')),Inf) < 1e1*eps('single'))
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - single(Ac) - single(uc)*single(vc)'),Inf) < norm(single(Ac))*1e1*eps('single'))
+%! [Q,R] = qr (single (Ac));
+%! [Q,R] = qrupdate (Q, R, single (uc), single (vc));
+%! assert (norm (vec (Q'*Q - eye (5,"single")), Inf) < 1e1*eps ("single"));
+%! assert (norm (vec (triu (R)-R), Inf) == 0);
+%! assert (norm (vec (Q*R - single (Ac) - single (uc)*single (vc)'), Inf) < norm (single (Ac))*1e1*eps ("single"));
 */
 
 DEFUN_DLD (qrinsert, args, ,
@@ -1110,62 +1095,62 @@
 
 /*
 %!test
-%! [Q,R] = qr(A);
-%! [Q,R] = qrinsert(Q,R,3,u);
-%! assert(norm(vec(Q'*Q - eye(5)),Inf) < 1e1*eps)
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - [A(:,1:2) u A(:,3)]),Inf) < norm(A)*1e1*eps)
+%! [Q,R] = qr (A);
+%! [Q,R] = qrinsert (Q, R, 3, u);
+%! assert (norm (vec (Q'*Q - eye (5)), Inf) < 1e1*eps);
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - [A(:,1:2) u A(:,3)]), Inf) < norm (A)*1e1*eps);
 %!test
-%! [Q,R] = qr(Ac);
-%! [Q,R] = qrinsert(Q,R,3,uc);
-%! assert(norm(vec(Q'*Q - eye(5)),Inf) < 1e1*eps)
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - [Ac(:,1:2) uc Ac(:,3)]),Inf) < norm(Ac)*1e1*eps)
+%! [Q,R] = qr (Ac);
+%! [Q,R] = qrinsert (Q, R, 3, uc);
+%! assert (norm (vec (Q'*Q - eye (5)), Inf) < 1e1*eps);
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - [Ac(:,1:2) uc Ac(:,3)]), Inf) < norm (Ac)*1e1*eps);
 %!test
 %! x = [0.85082  0.76426  0.42883 ];
 %!
-%! [Q,R] = qr(A);
-%! [Q,R] = qrinsert(Q,R,3,x,'row');
-%! assert(norm(vec(Q'*Q - eye(6)),Inf) < 1e1*eps)
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - [A(1:2,:);x;A(3:5,:)]),Inf) < norm(A)*1e1*eps)
+%! [Q,R] = qr (A);
+%! [Q,R] = qrinsert (Q, R, 3, x, "row");
+%! assert (norm (vec (Q'*Q - eye (6)), Inf) < 1e1*eps);
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - [A(1:2,:);x;A(3:5,:)]), Inf) < norm (A)*1e1*eps);
 %!test
 %! x = [0.20351 + 0.05401i  0.13141 + 0.43708i  0.29808 + 0.08789i ];
 %!
-%! [Q,R] = qr(Ac);
-%! [Q,R] = qrinsert(Q,R,3,x,'row');
-%! assert(norm(vec(Q'*Q - eye(6)),Inf) < 1e1*eps)
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - [Ac(1:2,:);x;Ac(3:5,:)]),Inf) < norm(Ac)*1e1*eps)
+%! [Q,R] = qr (Ac);
+%! [Q,R] = qrinsert (Q, R, 3, x, "row");
+%! assert (norm (vec (Q'*Q - eye (6)), Inf) < 1e1*eps);
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - [Ac(1:2,:);x;Ac(3:5,:)]), Inf) < norm (Ac)*1e1*eps);
 
 %!test
-%! [Q,R] = qr(single(A));
-%! [Q,R] = qrinsert(Q,R,3,single(u));
-%! assert(norm(vec(Q'*Q - eye(5,'single')),Inf) < 1e1*eps('single'))
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - single([A(:,1:2) u A(:,3)])),Inf) < norm(single(A))*1e1*eps('single'))
+%! [Q,R] = qr (single (A));
+%! [Q,R] = qrinsert (Q, R, 3, single (u));
+%! assert (norm (vec (Q'*Q - eye (5,"single")), Inf) < 1e1*eps ("single"));
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - single ([A(:,1:2) u A(:,3)])), Inf) < norm (single (A))*1e1*eps ("single"));
 %!test
-%! [Q,R] = qr(single(Ac));
-%! [Q,R] = qrinsert(Q,R,3,single(uc));
-%! assert(norm(vec(Q'*Q - eye(5,'single')),Inf) < 1e1*eps('single'))
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - single([Ac(:,1:2) uc Ac(:,3)])),Inf) < norm(single(Ac))*1e1*eps('single'))
+%! [Q,R] = qr (single (Ac));
+%! [Q,R] = qrinsert (Q, R, 3, single (uc));
+%! assert (norm (vec (Q'*Q - eye (5,"single")), Inf) < 1e1*eps ("single"));
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - single ([Ac(:,1:2) uc Ac(:,3)])), Inf) < norm (single (Ac))*1e1*eps ("single"));
 %!test
-%! x = single([0.85082  0.76426  0.42883 ]);
+%! x = single ([0.85082  0.76426  0.42883 ]);
 %!
-%! [Q,R] = qr(single(A));
-%! [Q,R] = qrinsert(Q,R,3,x,'row');
-%! assert(norm(vec(Q'*Q - eye(6,'single')),Inf) < 1e1*eps('single'))
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - single([A(1:2,:);x;A(3:5,:)])),Inf) < norm(single(A))*1e1*eps('single'))
+%! [Q,R] = qr (single (A));
+%! [Q,R] = qrinsert (Q, R, 3, x, "row");
+%! assert (norm (vec (Q'*Q - eye (6,"single")), Inf) < 1e1*eps ("single"));
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - single ([A(1:2,:);x;A(3:5,:)])), Inf) < norm (single (A))*1e1*eps ("single"));
 %!test
-%! x = single([0.20351 + 0.05401i  0.13141 + 0.43708i  0.29808 + 0.08789i ]);
+%! x = single ([0.20351 + 0.05401i  0.13141 + 0.43708i  0.29808 + 0.08789i ]);
 %!
-%! [Q,R] = qr(single(Ac));
-%! [Q,R] = qrinsert(Q,R,3,x,'row');
-%! assert(norm(vec(Q'*Q - eye(6,'single')),Inf) < 1e1*eps('single'))
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - single([Ac(1:2,:);x;Ac(3:5,:)])),Inf) < norm(single(Ac))*1e1*eps('single'))
+%! [Q,R] = qr (single (Ac));
+%! [Q,R] = qrinsert (Q, R, 3, x, "row");
+%! assert (norm (vec (Q'*Q - eye (6,"single")), Inf) < 1e1*eps ("single"));
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - single ([Ac(1:2,:);x;Ac(3:5,:)])), Inf) < norm (single (Ac))*1e1*eps ("single"));
 */
 
 DEFUN_DLD (qrdelete, args, ,
@@ -1322,11 +1307,11 @@
 %!       0.265712  0.268003  0.783553  0.238409;
 %!       0.669966  0.743851  0.457255  0.445057 ];
 %!
-%! [Q,R] = qr(AA);
-%! [Q,R] = qrdelete(Q,R,3);
-%! assert(norm(vec(Q'*Q - eye(5)),Inf) < 16*eps)
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - [AA(:,1:2) AA(:,4)]),Inf) < norm(AA)*1e1*eps)
+%! [Q,R] = qr (AA);
+%! [Q,R] = qrdelete (Q, R, 3);
+%! assert (norm (vec (Q'*Q - eye (5)), Inf) < 16*eps);
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - [AA(:,1:2) AA(:,4)]), Inf) < norm (AA)*1e1*eps);
 %!
 %!test
 %! AA = [0.364554 + 0.993117i  0.669818 + 0.510234i  0.426568 + 0.041337i  0.847051 + 0.233291i;
@@ -1335,11 +1320,11 @@
 %!       0.694986 + 0.000571i  0.682327 + 0.841712i  0.807537 + 0.166086i  0.192767 + 0.358098i;
 %!       0.945002 + 0.066788i  0.350492 + 0.642638i  0.579629 + 0.048102i  0.600170 + 0.636938i ] * I;
 %!
-%! [Q,R] = qr(AA);
-%! [Q,R] = qrdelete(Q,R,3);
-%! assert(norm(vec(Q'*Q - eye(5)),Inf) < 16*eps)
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - [AA(:,1:2) AA(:,4)]),Inf) < norm(AA)*1e1*eps)
+%! [Q,R] = qr (AA);
+%! [Q,R] = qrdelete (Q, R, 3);
+%! assert (norm (vec (Q'*Q - eye (5)), Inf) < 16*eps);
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - [AA(:,1:2) AA(:,4)]), Inf) < norm (AA)*1e1*eps);
 %!
 %!test
 %! AA = [0.091364  0.613038  0.027504  0.999083;
@@ -1348,11 +1333,11 @@
 %!       0.265712  0.268003  0.783553  0.238409;
 %!       0.669966  0.743851  0.457255  0.445057 ];
 %!
-%! [Q,R] = qr(AA);
-%! [Q,R] = qrdelete(Q,R,3,'row');
-%! assert(norm(vec(Q'*Q - eye(4)),Inf) < 1e1*eps)
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - [AA(1:2,:);AA(4:5,:)]),Inf) < norm(AA)*1e1*eps)
+%! [Q,R] = qr (AA);
+%! [Q,R] = qrdelete (Q, R, 3, "row");
+%! assert (norm (vec (Q'*Q - eye (4)), Inf) < 1e1*eps);
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - [AA(1:2,:);AA(4:5,:)]), Inf) < norm (AA)*1e1*eps);
 %!
 %!test
 %! AA = [0.364554 + 0.993117i  0.669818 + 0.510234i  0.426568 + 0.041337i  0.847051 + 0.233291i;
@@ -1361,76 +1346,76 @@
 %!       0.694986 + 0.000571i  0.682327 + 0.841712i  0.807537 + 0.166086i  0.192767 + 0.358098i;
 %!       0.945002 + 0.066788i  0.350492 + 0.642638i  0.579629 + 0.048102i  0.600170 + 0.636938i ] * I;
 %!
-%! [Q,R] = qr(AA);
-%! [Q,R] = qrdelete(Q,R,3,'row');
-%! assert(norm(vec(Q'*Q - eye(4)),Inf) < 1e1*eps)
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - [AA(1:2,:);AA(4:5,:)]),Inf) < norm(AA)*1e1*eps)
+%! [Q,R] = qr (AA);
+%! [Q,R] = qrdelete (Q, R, 3, "row");
+%! assert (norm (vec (Q'*Q - eye (4)), Inf) < 1e1*eps);
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - [AA(1:2,:);AA(4:5,:)]), Inf) < norm (AA)*1e1*eps);
 
 %!test
-%! AA = single([0.091364  0.613038  0.027504  0.999083;
-%!              0.594638  0.425302  0.562834  0.603537;
-%!              0.383594  0.291238  0.742073  0.085574;
-%!              0.265712  0.268003  0.783553  0.238409;
-%!              0.669966  0.743851  0.457255  0.445057 ]);
+%! AA = single ([0.091364  0.613038  0.027504  0.999083;
+%!               0.594638  0.425302  0.562834  0.603537;
+%!               0.383594  0.291238  0.742073  0.085574;
+%!               0.265712  0.268003  0.783553  0.238409;
+%!               0.669966  0.743851  0.457255  0.445057 ]);
+%!
+%! [Q,R] = qr (AA);
+%! [Q,R] = qrdelete (Q, R, 3);
+%! assert (norm (vec (Q'*Q - eye (5,"single")), Inf) < 1e1*eps ("single"));
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - [AA(:,1:2) AA(:,4)]), Inf) < norm (AA)*1e1*eps ("single"));
 %!
-%! [Q,R] = qr(AA);
-%! [Q,R] = qrdelete(Q,R,3);
-%! assert(norm(vec(Q'*Q - eye(5,'single')),Inf) < 1e1*eps('single'))
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - [AA(:,1:2) AA(:,4)]),Inf) < norm(AA)*1e1*eps('single'))
+%!test
+%! AA = single ([0.364554 + 0.993117i  0.669818 + 0.510234i  0.426568 + 0.041337i  0.847051 + 0.233291i;
+%!               0.049600 + 0.242783i  0.448946 + 0.484022i  0.141155 + 0.074420i  0.446746 + 0.392706i;
+%!               0.581922 + 0.657416i  0.581460 + 0.030016i  0.219909 + 0.447288i  0.201144 + 0.069132i;
+%!               0.694986 + 0.000571i  0.682327 + 0.841712i  0.807537 + 0.166086i  0.192767 + 0.358098i;
+%!               0.945002 + 0.066788i  0.350492 + 0.642638i  0.579629 + 0.048102i  0.600170 + 0.636938i ]) * I;
+%!
+%! [Q,R] = qr (AA);
+%! [Q,R] = qrdelete (Q, R, 3);
+%! assert (norm (vec (Q'*Q - eye (5,"single")), Inf) < 1e1*eps ("single"));
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - [AA(:,1:2) AA(:,4)]), Inf) < norm (AA)*1e1*eps ("single"));
 %!
 %!test
-%! AA = single([0.364554 + 0.993117i  0.669818 + 0.510234i  0.426568 + 0.041337i  0.847051 + 0.233291i;
+%! AA = single ([0.091364  0.613038  0.027504  0.999083;
+%!               0.594638  0.425302  0.562834  0.603537;
+%!               0.383594  0.291238  0.742073  0.085574;
+%!               0.265712  0.268003  0.783553  0.238409;
+%!               0.669966  0.743851  0.457255  0.445057 ]);
+%!
+%! [Q,R] = qr (AA);
+%! [Q,R] = qrdelete (Q, R, 3, "row");
+%! assert (norm (vec (Q'*Q - eye (4,"single")), Inf) < 1.5e1*eps ("single"));
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - [AA(1:2,:);AA(4:5,:)]), Inf) < norm (AA)*1e1*eps ("single"));
+%!testif HAVE_QRUPDATE
+%! # Same test as above but with more precicision
+%! AA = single ([0.091364  0.613038  0.027504  0.999083;
+%!               0.594638  0.425302  0.562834  0.603537;
+%!               0.383594  0.291238  0.742073  0.085574;
+%!               0.265712  0.268003  0.783553  0.238409;
+%!               0.669966  0.743851  0.457255  0.445057 ]);
+%!
+%! [Q,R] = qr (AA);
+%! [Q,R] = qrdelete (Q, R, 3, "row");
+%! assert (norm (vec (Q'*Q - eye (4,"single")), Inf) < 1e1*eps ("single"));
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - [AA(1:2,:);AA(4:5,:)]), Inf) < norm (AA)*1e1*eps ("single"));
+%!
+%!test
+%! AA = single ([0.364554 + 0.993117i  0.669818 + 0.510234i  0.426568 + 0.041337i  0.847051 + 0.233291i;
 %!              0.049600 + 0.242783i  0.448946 + 0.484022i  0.141155 + 0.074420i  0.446746 + 0.392706i;
 %!              0.581922 + 0.657416i  0.581460 + 0.030016i  0.219909 + 0.447288i  0.201144 + 0.069132i;
 %!              0.694986 + 0.000571i  0.682327 + 0.841712i  0.807537 + 0.166086i  0.192767 + 0.358098i;
 %!              0.945002 + 0.066788i  0.350492 + 0.642638i  0.579629 + 0.048102i  0.600170 + 0.636938i ]) * I;
 %!
-%! [Q,R] = qr(AA);
-%! [Q,R] = qrdelete(Q,R,3);
-%! assert(norm(vec(Q'*Q - eye(5,'single')),Inf) < 1e1*eps('single'))
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - [AA(:,1:2) AA(:,4)]),Inf) < norm(AA)*1e1*eps('single'))
-%!
-%!test
-%! AA = single([0.091364  0.613038  0.027504  0.999083;
-%!              0.594638  0.425302  0.562834  0.603537;
-%!              0.383594  0.291238  0.742073  0.085574;
-%!              0.265712  0.268003  0.783553  0.238409;
-%!              0.669966  0.743851  0.457255  0.445057 ]);
-%!
-%! [Q,R] = qr(AA);
-%! [Q,R] = qrdelete(Q,R,3,'row');
-%! assert(norm(vec(Q'*Q - eye(4,'single')),Inf) < 1.5e1*eps('single'))
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - [AA(1:2,:);AA(4:5,:)]),Inf) < norm(AA)*1e1*eps('single'))
-%!testif HAVE_QRUPDATE
-%! # Same test as above but with more precicision
-%! AA = single([0.091364  0.613038  0.027504  0.999083;
-%!              0.594638  0.425302  0.562834  0.603537;
-%!              0.383594  0.291238  0.742073  0.085574;
-%!              0.265712  0.268003  0.783553  0.238409;
-%!              0.669966  0.743851  0.457255  0.445057 ]);
-%!
-%! [Q,R] = qr(AA);
-%! [Q,R] = qrdelete(Q,R,3,'row');
-%! assert(norm(vec(Q'*Q - eye(4,'single')),Inf) < 1e1*eps('single'))
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - [AA(1:2,:);AA(4:5,:)]),Inf) < norm(AA)*1e1*eps('single'))
-%!
-%!test
-%! AA = single([0.364554 + 0.993117i  0.669818 + 0.510234i  0.426568 + 0.041337i  0.847051 + 0.233291i;
-%!              0.049600 + 0.242783i  0.448946 + 0.484022i  0.141155 + 0.074420i  0.446746 + 0.392706i;
-%!              0.581922 + 0.657416i  0.581460 + 0.030016i  0.219909 + 0.447288i  0.201144 + 0.069132i;
-%!              0.694986 + 0.000571i  0.682327 + 0.841712i  0.807537 + 0.166086i  0.192767 + 0.358098i;
-%!              0.945002 + 0.066788i  0.350492 + 0.642638i  0.579629 + 0.048102i  0.600170 + 0.636938i ]) * I;
-%!
-%! [Q,R] = qr(AA);
-%! [Q,R] = qrdelete(Q,R,3,'row');
-%! assert(norm(vec(Q'*Q - eye(4,'single')),Inf) < 1e1*eps('single'))
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - [AA(1:2,:);AA(4:5,:)]),Inf) < norm(AA)*1e1*eps('single'))
+%! [Q,R] = qr (AA);
+%! [Q,R] = qrdelete (Q, R, 3, "row");
+%! assert (norm (vec (Q'*Q - eye (4,"single")), Inf) < 1e1*eps ("single"));
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - [AA(1:2,:);AA(4:5,:)]), Inf) < norm (AA)*1e1*eps ("single"));
 */
 
 DEFUN_DLD (qrshift, args, ,
@@ -1537,77 +1522,77 @@
 
   return retval;
 }
+
 /*
 %!test
 %! AA = A.';
-%! i = 2; j = 4; p = [1:i-1, shift(i:j,-1), j+1:5];
+%! i = 2;  j = 4;  p = [1:i-1, shift(i:j,-1), j+1:5];
 %!
-%! [Q,R] = qr(AA);
-%! [Q,R] = qrshift(Q,R,i,j);
-%! assert(norm(vec(Q'*Q - eye(3)),Inf) < 1e1*eps)
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - AA(:,p)),Inf) < norm(AA)*1e1*eps)
+%! [Q,R] = qr (AA);
+%! [Q,R] = qrshift (Q, R, i, j);
+%! assert (norm (vec (Q'*Q - eye (3)), Inf) < 1e1*eps);
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - AA(:,p)), Inf) < norm (AA)*1e1*eps);
 %!
-%! j = 2; i = 4; p = [1:j-1, shift(j:i,+1), i+1:5];
+%! j = 2;  i = 4;  p = [1:j-1, shift(j:i,+1), i+1:5];
 %!
-%! [Q,R] = qr(AA);
-%! [Q,R] = qrshift(Q,R,i,j);
-%! assert(norm(vec(Q'*Q - eye(3)),Inf) < 1e1*eps)
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - AA(:,p)),Inf) < norm(AA)*1e1*eps)
+%! [Q,R] = qr (AA);
+%! [Q,R] = qrshift (Q, R, i, j);
+%! assert (norm (vec (Q'*Q - eye (3)), Inf) < 1e1*eps);
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - AA(:,p)), Inf) < norm (AA)*1e1*eps);
 %!
 %!test
 %! AA = Ac.';
-%! i = 2; j = 4; p = [1:i-1, shift(i:j,-1), j+1:5];
+%! i = 2;  j = 4;  p = [1:i-1, shift(i:j,-1), j+1:5];
 %!
-%! [Q,R] = qr(AA);
-%! [Q,R] = qrshift(Q,R,i,j);
-%! assert(norm(vec(Q'*Q - eye(3)),Inf) < 1e1*eps)
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - AA(:,p)),Inf) < norm(AA)*1e1*eps)
+%! [Q,R] = qr (AA);
+%! [Q,R] = qrshift (Q, R, i, j);
+%! assert (norm (vec (Q'*Q - eye (3)), Inf) < 1e1*eps);
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - AA(:,p)), Inf) < norm (AA)*1e1*eps);
 %!
-%! j = 2; i = 4; p = [1:j-1, shift(j:i,+1), i+1:5];
+%! j = 2;  i = 4;  p = [1:j-1, shift(j:i,+1), i+1:5];
 %!
-%! [Q,R] = qr(AA);
-%! [Q,R] = qrshift(Q,R,i,j);
-%! assert(norm(vec(Q'*Q - eye(3)),Inf) < 1e1*eps)
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - AA(:,p)),Inf) < norm(AA)*1e1*eps)
-
+%! [Q,R] = qr (AA);
+%! [Q,R] = qrshift (Q, R, i, j);
+%! assert (norm (vec (Q'*Q - eye (3)), Inf) < 1e1*eps);
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - AA(:,p)), Inf) < norm (AA)*1e1*eps);
 
 %!test
 %! AA = single (A).';
-%! i = 2; j = 4; p = [1:i-1, shift(i:j,-1), j+1:5];
+%! i = 2;  j = 4;  p = [1:i-1, shift(i:j,-1), j+1:5];
 %!
-%! [Q,R] = qr(AA);
-%! [Q,R] = qrshift(Q,R,i,j);
-%! assert(norm(vec(Q'*Q - eye(3,'single')),Inf) < 1e1*eps('single'))
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - AA(:,p)),Inf) < norm(AA)*1e1*eps('single'))
+%! [Q,R] = qr (AA);
+%! [Q,R] = qrshift (Q, R, i, j);
+%! assert (norm (vec (Q'*Q - eye (3,"single")), Inf) < 1e1*eps ("single"));
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - AA(:,p)), Inf) < norm (AA)*1e1*eps ("single"));
 %!
-%! j = 2; i = 4; p = [1:j-1, shift(j:i,+1), i+1:5];
+%! j = 2;  i = 4;  p = [1:j-1, shift(j:i,+1), i+1:5];
 %!
-%! [Q,R] = qr(AA);
-%! [Q,R] = qrshift(Q,R,i,j);
-%! assert(norm(vec(Q'*Q - eye(3,'single')),Inf) < 1e1*eps('single'))
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - AA(:,p)),Inf) < norm(AA)*1e1*eps('single'))
+%! [Q,R] = qr (AA);
+%! [Q,R] = qrshift (Q, R, i, j);
+%! assert (norm (vec (Q'*Q - eye (3,"single")), Inf) < 1e1*eps ("single"));
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - AA(:,p)), Inf) < norm (AA)*1e1*eps ("single"));
 %!
 %!test
-%! AA = single(Ac).';
-%! i = 2; j = 4; p = [1:i-1, shift(i:j,-1), j+1:5];
+%! AA = single (Ac).';
+%! i = 2;  j = 4;  p = [1:i-1, shift(i:j,-1), j+1:5];
 %!
-%! [Q,R] = qr(AA);
-%! [Q,R] = qrshift(Q,R,i,j);
-%! assert(norm(vec(Q'*Q - eye(3,'single')),Inf) < 1e1*eps('single'))
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - AA(:,p)),Inf) < norm(AA)*1e1*eps('single'))
+%! [Q,R] = qr (AA);
+%! [Q,R] = qrshift (Q, R, i, j);
+%! assert (norm (vec (Q'*Q - eye (3,"single")), Inf) < 1e1*eps ("single"));
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - AA(:,p)), Inf) < norm (AA)*1e1*eps ("single"));
 %!
-%! j = 2; i = 4; p = [1:j-1, shift(j:i,+1), i+1:5];
+%! j = 2;  i = 4;  p = [1:j-1, shift(j:i,+1), i+1:5];
 %!
-%! [Q,R] = qr(AA);
-%! [Q,R] = qrshift(Q,R,i,j);
-%! assert(norm(vec(Q'*Q - eye(3,'single')),Inf) < 1e1*eps('single'))
-%! assert(norm(vec(triu(R)-R),Inf) == 0)
-%! assert(norm(vec(Q*R - AA(:,p)),Inf) < norm(AA)*1e1*eps('single'))
+%! [Q,R] = qr (AA);
+%! [Q,R] = qrshift (Q, R, i, j);
+%! assert (norm (vec (Q'*Q - eye (3,"single")), Inf) < 1e1*eps ("single"));
+%! assert (norm (vec (triu (R) - R), Inf) == 0);
+%! assert (norm (vec (Q*R - AA(:,p)), Inf) < norm (AA)*1e1*eps ("single"));
 */
--- a/src/DLD-FUNCTIONS/quad.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/quad.cc	Mon May 07 00:56:44 2012 +0200
@@ -473,19 +473,23 @@
 }
 
 /*
-
 %!function y = __f (x)
-%! y = x + 1;
+%!  y = x + 1;
 %!endfunction
 
 %!test
 %! [v, ier, nfun, err] = quad ("__f", 0, 5);
-%! assert(ier == 0 && abs (v - 17.5) < sqrt (eps) && nfun > 0 &&
-%!        err < sqrt (eps))
+%! assert (ier, 0);
+%! assert (v, 17.5, sqrt (eps));
+%! assert (nfun > 0);
+%! assert (err < sqrt (eps));
+
 %!test
-%! [v, ier, nfun, err] = quad ("__f", single(0), single(5));
-%! assert(ier == 0 && abs (v - 17.5) < sqrt (eps ("single")) && nfun > 0 &&
-%!        err < sqrt (eps ("single")))
+%! [v, ier, nfun, err] = quad ("__f", single (0), single (5));
+%! assert (ier, 0);
+%! assert (v, 17.5, sqrt (eps ("single")));
+%! assert (nfun > 0);
+%! assert (err < sqrt (eps ("single")));
 
 %!function y = __f (x)
 %!  y = x .* sin (1 ./ x) .* sqrt (abs (1 - x));
@@ -493,19 +497,22 @@
 
 %!test
 %!  [v, ier, nfun, err] = quad ("__f", 0.001, 3);
-%! assert((ier == 0 || ier == 1) && abs (v - 1.98194120273598) < sqrt (eps) && nfun > 0);
+%! assert (ier == 0 || ier == 1);
+%! assert (v, 1.98194120273598, sqrt (eps));
+%! assert (nfun > 0);
+
 %!test
-%!  [v, ier, nfun, err] = quad ("__f", single(0.001), single(3));
-%! assert((ier == 0 || ier == 1) && abs (v - 1.98194120273598) < sqrt (eps ("single")) && nfun > 0);
+%!  [v, ier, nfun, err] = quad ("__f", single (0.001), single (3));
+%! assert (ier == 0 || ier == 1);
+%! assert (v, 1.98194120273598, sqrt (eps ("single")));
+%! assert (nfun > 0);
 
-%!error <Invalid call to quad> quad ();
-
-%!error <Invalid call to quad> quad ("__f", 1, 2, 3, 4, 5);
+%!error quad ()
+%!error quad ("__f", 1, 2, 3, 4, 5)
 
 %!test
 %! quad_options ("absolute tolerance", eps);
-%! assert(quad_options ("absolute tolerance") == eps);
+%! assert (quad_options ("absolute tolerance") == eps);
 
-%!error <Invalid call to quad_options> quad_options (1, 2, 3);
-
+%!error quad_options (1, 2, 3)
 */
--- a/src/DLD-FUNCTIONS/quadcc.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/quadcc.cc	Mon May 07 00:56:44 2012 +0200
@@ -2238,28 +2238,26 @@
 
 
 /*
-
-%!assert (quadcc(@sin,-pi,pi), 0, 1e-6)
-%!assert (quadcc(inline('sin'),-pi,pi), 0, 1e-6)
-%!assert (quadcc('sin',-pi,pi), 0, 1e-6)
+%!assert (quadcc (@sin, -pi, pi), 0, 1e-6)
+%!assert (quadcc (inline ("sin"),- pi, pi), 0, 1e-6)
+%!assert (quadcc ("sin", -pi, pi), 0, 1e-6)
 
-%!assert (quadcc(@sin,-pi,0), -2, 1e-6)
-%!assert (quadcc(@sin,0,pi), 2, 1e-6)
-%!assert (quadcc(@(x) 1./sqrt(x), 0, 1), 2, 1e-6)
-%!assert (quadcc(@(x) 1./(sqrt(x).*(x+1)), 0, Inf), pi, 1e-6)
+%!assert (quadcc (@sin, -pi, 0), -2, 1e-6)
+%!assert (quadcc (@sin, 0, pi), 2, 1e-6)
+%!assert (quadcc (@(x) 1./sqrt (x), 0, 1), 2, 1e-6)
+%!assert (quadcc (@(x) 1./(sqrt (x).*(x+1)), 0, Inf), pi, 1e-6)
 
-%!assert (quadcc (@(x) exp(-x .^ 2), -Inf, Inf), sqrt(pi), 1e-6)
-%!assert (quadcc (@(x) exp(-x .^ 2), -Inf, 0), sqrt(pi)/2, 1e-6)
+%!assert (quadcc (@(x) exp (-x .^ 2), -Inf, Inf), sqrt (pi), 1e-6)
+%!assert (quadcc (@(x) exp (-x .^ 2), -Inf, 0), sqrt (pi)/2, 1e-6)
 
 %% Test input validation
 %!error (quadcc ())
 %!error (quadcc (@sin))
 %!error (quadcc (@sin, 0))
-%!error (quadcc (@sin, ones(2), pi))
+%!error (quadcc (@sin, ones (2), pi))
 %!error (quadcc (@sin, -i, pi))
-%!error (quadcc (@sin, 0, ones(2)))
+%!error (quadcc (@sin, 0, ones (2)))
 %!error (quadcc (@sin, 0, i))
 %!error (quadcc (@sin, 0, pi, 0))
 %!error (quadcc (@sin, 0, pi, 1e-6, [ i ]))
-
 */
--- a/src/DLD-FUNCTIONS/qz.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/qz.cc	Mon May 07 00:56:44 2012 +0200
@@ -1243,27 +1243,26 @@
 
 /*
 %!shared a, b, c
-%!  a = [1 2; 0 3];
-%!  b = [1 0; 0 0];
-%!  c = [0 1; 0 0];
-%!assert(qz (a,b), 1);
-%!assert(isempty (qz (a,c)));
+%! a = [1 2; 0 3];
+%! b = [1 0; 0 0];
+%! c = [0 1; 0 0];
+%!assert (qz (a,b), 1)
+%!assert (isempty (qz (a,c)))
 
-%% Exaple 7.7.3 in Golub & Van Loan
+## Exaple 7.7.3 in Golub & Van Loan
 %!test
 %! a = [ 10  1  2;
 %!        1  2 -1;
 %!        1  1  2];
-%! b = reshape(1:9,3,3);
+%! b = reshape (1:9,3,3);
 %! [aa, bb, q, z, v, w, lambda] = qz (a, b);
-%! sz = length(lambda);
-%! observed =  (b * v * diag ([lambda;0])) (:, 1:sz);
+%! sz = length (lambda);
+%! observed = (b * v * diag ([lambda;0])) (:, 1:sz);
 %! assert ( (a*v) (:, 1:sz), observed, norm (observed) * 1e-14);
 %! observed = (diag ([lambda;0]) * w' * b) (1:sz, :);
 %! assert ( (w'*a) (1:sz, :) , observed, norm (observed) * 1e-13);
 %! assert (q * a * z, aa, norm (aa) * 1e-14);
 %! assert (q * b * z, bb, norm (bb) * 1e-14);
 
-%% FIXME: Still need a test for third form of calling qz
-
+## FIXME: Still need a test for third form of calling qz
 */
--- a/src/DLD-FUNCTIONS/rand.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/rand.cc	Mon May 07 00:56:44 2012 +0200
@@ -48,7 +48,7 @@
 
 /*
 %!shared __random_statistical_tests__
-%! % Flag whether the statistical tests should be run in "make check" or not
+%! # Flag whether the statistical tests should be run in "make check" or not
 %! __random_statistical_tests__ = 0;
 */
 
@@ -415,75 +415,74 @@
 // work properly if compiled to use 64-bit integers.
 
 /*
-%!test # 'state' can be a scalar
-%! rand('state',12); x = rand(1,4);
-%! rand('state',12); y = rand(1,4);
-%! assert(x,y);
-%!test # 'state' can be a vector
-%! rand('state',[12,13]); x=rand(1,4);
-%! rand('state',[12;13]); y=rand(1,4);
-%! assert(x,y);
-%!test # querying 'state' doesn't disturb sequence
-%! rand('state',12); rand(1,2); x=rand(1,2);
-%! rand('state',12); rand(1,2);
-%! s=rand('state'); y=rand(1,2);
-%! assert(x,y);
-%! rand('state',s); z=rand(1,2);
-%! assert(x,z);
-%!test # 'seed' must be a scalar
-%! rand('seed',12); x = rand(1,4);
-%! rand('seed',12); y = rand(1,4);
-%! assert(x,y);
-%!error(rand('seed',[12,13]))
-%!test # querying 'seed' returns a value which can be used later
-%! s=rand('seed'); x=rand(1,2);
-%! rand('seed',s); y=rand(1,2);
-%! assert(x,y);
-%!test # querying 'seed' doesn't disturb sequence
-%! rand('seed',12); rand(1,2); x=rand(1,2);
-%! rand('seed',12); rand(1,2);
-%! s=rand('seed'); y=rand(1,2);
-%! assert(x,y);
-%! rand('seed',s); z=rand(1,2);
-%! assert(x,z);
+%!test  # "state" can be a scalar
+%! rand ("state", 12);  x = rand (1,4);
+%! rand ("state", 12);  y = rand (1,4);
+%! assert (x, y);
+%!test  # "state" can be a vector
+%! rand ("state", [12,13]);  x = rand (1,4);
+%! rand ("state", [12;13]);  y = rand (1,4);
+%! assert (x, y);
+%!test  # querying "state" doesn't disturb sequence
+%! rand ("state", 12);  rand (1,2);  x = rand (1,2);
+%! rand ("state", 12);  rand (1,2);
+%! s = rand ("state");  y = rand (1,2);
+%! assert (x, y);
+%! rand ("state", s);  z = rand (1,2);
+%! assert (x, z);
+%!test  # "seed" must be a scalar
+%! rand ("seed", 12);  x = rand (1,4);
+%! rand ("seed", 12);  y = rand (1,4);
+%! assert (x, y);
+%!error <seed must be a real scalar> rand ("seed", [12,13])
+%!test  # querying "seed" returns a value which can be used later
+%! s = rand ("seed");  x = rand (1,2);
+%! rand ("seed", s);  y = rand (1,2);
+%! assert (x, y);
+%!test  # querying "seed" doesn't disturb sequence
+%! rand ("seed", 12);  rand (1,2);  x = rand (1,2);
+%! rand ("seed", 12);  rand (1,2);
+%! s = rand ("seed");  y = rand (1,2);
+%! assert (x, y);
+%! rand ("seed", s);  z = rand (1,2);
+%! assert (x, z);
 */
 
 /*
 %!test
-%! % Test fixed state
-%! rand("state",1);
-%! assert (rand(1,6), [0.1343642441124013 0.8474337369372327 0.763774618976614 0.2550690257394218 0.495435087091941 0.4494910647887382],1e-6);
+%! # Test fixed state
+%! rand ("state", 1);
+%! assert (rand (1,6), [0.1343642441124013 0.8474337369372327 0.763774618976614 0.2550690257394218 0.495435087091941 0.4494910647887382], 1e-6);
 %!test
-%! % Test fixed seed
-%! rand("seed",1);
-%! assert (rand(1,6), [0.8668024251237512 0.9126510815694928 0.09366085007786751 0.1664607301354408 0.7408077004365623 0.7615650338120759],1e-6);
+%! # Test fixed seed
+%! rand ("seed", 1);
+%! assert (rand (1,6), [0.8668024251237512 0.9126510815694928 0.09366085007786751 0.1664607301354408 0.7408077004365623 0.7615650338120759], 1e-6);
 %!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   rand("state",12);
-%!   x = rand(100000,1);
-%!   assert(max(x)<1.); %*** Please report this!!! ***
-%!   assert(min(x)>0.); %*** Please report this!!! ***
-%!   assert(mean(x),0.5,0.0024);
-%!   assert(var(x),1/48,0.0632);
-%!   assert(skewness(x),0,0.012);
-%!   assert(kurtosis(x),-6/5,0.0094);
+%!   # statistical tests may fail occasionally.
+%!   rand ("state", 12);
+%!   x = rand (100000, 1);
+%!   assert (max (x) < 1);   #*** Please report this!!! ***
+%!   assert (min (x) > 0);   #*** Please report this!!! ***
+%!   assert (mean (x), 0.5, 0.0024);
+%!   assert (var (x), 1/48, 0.0632);
+%!   assert (skewness (x), 0, 0.012);
+%!   assert (kurtosis (x), -6/5, 0.0094);
 %! endif
 %!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   rand("seed",12);
-%!   x = rand(100000,1);
-%!   assert(max(x)<1.); %*** Please report this!!! ***
-%!   assert(min(x)>0.); %*** Please report this!!! ***
-%!   assert(mean(x),0.5,0.0024);
-%!   assert(var(x),1/48,0.0632);
-%!   assert(skewness(x),0,0.012);
-%!   assert(kurtosis(x),-6/5,0.0094);
+%!   # statistical tests may fail occasionally.
+%!   rand ("seed", 12);
+%!   x = rand (100000, 1);
+%!   assert (max (x) < 1);   #*** Please report this!!! ***
+%!   assert (min (x) > 0);   #*** Please report this!!! ***
+%!   assert (mean (x), 0.5, 0.0024);
+%!   assert (var (x), 1/48, 0.0632);
+%!   assert (skewness (x), 0, 0.012);
+%!   assert (kurtosis (x), -6/5, 0.0094);
 %! endif
 */
 
-
 static std::string current_distribution = octave_rand::distribution ();
 
 DEFUN_DLD (randn, args, ,
@@ -523,32 +522,32 @@
 
 /*
 %!test
-%! % Test fixed state
-%! randn("state",1);
-%! assert (randn(1,6), [-2.666521678978671 -0.7381719971724564 1.507903992673601 0.6019427189162239 -0.450661261143348 -0.7054431351574116],1e-6);
+%! # Test fixed state
+%! randn ("state", 1);
+%! assert (randn (1, 6), [-2.666521678978671 -0.7381719971724564 1.507903992673601 0.6019427189162239 -0.450661261143348 -0.7054431351574116], 1e-6);
 %!test
-%! % Test fixed seed
-%! randn("seed",1);
-%! assert (randn(1,6), [-1.039402365684509 -1.25938892364502 0.1968704611063004 0.3874166905879974 -0.5976632833480835 -0.6615074276924133],1e-6);
+%! # Test fixed seed
+%! randn ("seed", 1);
+%! assert (randn (1, 6), [-1.039402365684509 -1.25938892364502 0.1968704611063004 0.3874166905879974 -0.5976632833480835 -0.6615074276924133], 1e-6);
 %!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   randn("state",12);
-%!   x = randn(100000,1);
-%!   assert(mean(x),0,0.01);
-%!   assert(var(x),1,0.02);
-%!   assert(skewness(x),0,0.02);
-%!   assert(kurtosis(x),0,0.04);
+%!   # statistical tests may fail occasionally.
+%!   randn ("state", 12);
+%!   x = randn (100000, 1);
+%!   assert (mean (x), 0, 0.01);
+%!   assert (var (x), 1, 0.02);
+%!   assert (skewness (x), 0, 0.02);
+%!   assert (kurtosis (x), 0, 0.04);
 %! endif
 %!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   randn("seed",12);
-%!   x = randn(100000,1);
-%!   assert(mean(x),0,0.01);
-%!   assert(var(x),1,0.02);
-%!   assert(skewness(x),0,0.02);
-%!   assert(kurtosis(x),0,0.04);
+%!   # statistical tests may fail occasionally.
+%!   randn ("seed", 12);
+%!   x = randn (100000, 1);
+%!   assert (mean (x), 0, 0.01);
+%!   assert (var (x), 1, 0.02);
+%!   assert (skewness (x), 0, 0.02);
+%!   assert (kurtosis (x), 0, 0.04);
 %! endif
 */
 
@@ -588,34 +587,34 @@
 
 /*
 %!test
-%! % Test fixed state
-%! rande("state",1);
-%! assert (rande(1,6), [3.602973885835625 0.1386190677555021 0.6743112889616958 0.4512830847258422 0.7255744741233175 0.3415969205292291],1e-6);
+%! # Test fixed state
+%! rande ("state", 1);
+%! assert (rande (1, 6), [3.602973885835625 0.1386190677555021 0.6743112889616958 0.4512830847258422 0.7255744741233175 0.3415969205292291], 1e-6);
 %!test
-%! % Test fixed seed
-%! rande("seed",1);
-%! assert (rande(1,6), [0.06492075175653866 1.717980206012726 0.4816154008731246 0.5231300676241517 0.103910739364359 1.668931916356087],1e-6);
+%! # Test fixed seed
+%! rande ("seed", 1);
+%! assert (rande (1, 6), [0.06492075175653866 1.717980206012726 0.4816154008731246 0.5231300676241517 0.103910739364359 1.668931916356087], 1e-6);
 %!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally
-%!   rande("state",1);
-%!   x = rande(100000,1);
-%!   assert(min(x)>0); % *** Please report this!!! ***
-%!   assert(mean(x),1,0.01);
-%!   assert(var(x),1,0.03);
-%!   assert(skewness(x),2,0.06);
-%!   assert(kurtosis(x),6,0.7);
+%!   # statistical tests may fail occasionally
+%!   rande ("state", 1);
+%!   x = rande (100000, 1);
+%!   assert (min (x) > 0);   # *** Please report this!!! ***
+%!   assert (mean (x), 1, 0.01);
+%!   assert (var (x), 1, 0.03);
+%!   assert (skewness (x), 2, 0.06);
+%!   assert (kurtosis (x), 6, 0.7);
 %! endif
 %!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally
-%!   rande("seed",1);
-%!   x = rande(100000,1);
-%!   assert(min(x)>0); % *** Please report this!!! ***
-%!   assert(mean(x),1,0.01);
-%!   assert(var(x),1,0.03);
-%!   assert(skewness(x),2,0.06);
-%!   assert(kurtosis(x),6,0.7);
+%!   # statistical tests may fail occasionally
+%!   rande ("seed", 1);
+%!   x = rande (100000, 1);
+%!   assert (min (x)>0);   # *** Please report this!!! ***
+%!   assert (mean (x), 1, 0.01);
+%!   assert (var (x), 1, 0.03);
+%!   assert (skewness (x), 2, 0.06);
+%!   assert (kurtosis (x), 6, 0.7);
 %! endif
 */
 
@@ -726,156 +725,165 @@
 
 /*
 %!test
-%! randg("state",12)
-%!assert(randg([-inf,-1,0,inf,nan]),[nan,nan,nan,nan,nan]) % *** Please report
-
+%! randg ("state", 12)
+%! assert (randg ([-inf, -1, 0, inf, nan]), [nan, nan, nan, nan, nan]); # *** Please report
 
 %!test
-%! % Test fixed state
-%! randg("state",1);
-%! assert (randg(0.1,1,6), [0.0103951513331241 8.335671459898252e-05 0.00138691397249762 0.000587308416993855 0.495590518784736 2.3921917414795e-12],1e-6);
+%! # Test fixed state
+%! randg ("state", 1);
+%! assert (randg (0.1, 1, 6), [0.0103951513331241 8.335671459898252e-05 0.00138691397249762 0.000587308416993855 0.495590518784736 2.3921917414795e-12], 1e-6);
 %!test
-%! % Test fixed state
-%! randg("state",1);
-%! assert (randg(0.95,1,6), [3.099382433255327 0.3974529788871218 0.644367450750855 1.143261091802246 1.964111762696822 0.04011915547957939],1e-6);
+%! # Test fixed state
+%! randg ("state", 1);
+%! assert (randg (0.95, 1, 6), [3.099382433255327 0.3974529788871218 0.644367450750855 1.143261091802246 1.964111762696822 0.04011915547957939], 1e-6);
 %!test
-%! % Test fixed state
-%! randg("state",1);
-%! assert (randg(1,1,6), [0.2273389379645993 1.288822625058359 0.2406335209340746 1.218869553370733 1.024649860162554 0.09631230343599533],1e-6);
+%! # Test fixed state
+%! randg ("state", 1);
+%! assert (randg (1, 1, 6), [0.2273389379645993 1.288822625058359 0.2406335209340746 1.218869553370733 1.024649860162554 0.09631230343599533], 1e-6);
 %!test
-%! % Test fixed state
-%! randg("state",1);
-%! assert (randg(10,1,6), [3.520369644331133 15.15369864472106 8.332112081991205 8.406211067432674 11.81193475187611 10.88792728177059],1e-5);
+%! # Test fixed state
+%! randg ("state", 1);
+%! assert (randg (10, 1, 6), [3.520369644331133 15.15369864472106 8.332112081991205 8.406211067432674 11.81193475187611 10.88792728177059], 1e-5);
 %!test
-%! % Test fixed state
-%! randg("state",1);
-%! assert (randg(100,1,6), [75.34570255262264 115.4911985594699 95.23493031356388 95.48926019250911 106.2397448229803 103.4813150404118],1e-4);
+%! # Test fixed state
+%! randg ("state", 1);
+%! assert (randg (100, 1, 6), [75.34570255262264 115.4911985594699 95.23493031356388 95.48926019250911 106.2397448229803 103.4813150404118], 1e-4);
 %!test
-%! % Test fixed seed
-%! randg("seed",1);
-%! assert (randg(0.1,1,6), [0.07144210487604141 0.460641473531723 0.4749028384685516 0.06823389977216721 0.000293838675133884 1.802567535340305e-12],1e-6);
+%! # Test fixed seed
+%! randg ("seed", 1);
+%! assert (randg (0.1, 1, 6), [0.07144210487604141 0.460641473531723 0.4749028384685516 0.06823389977216721 0.000293838675133884 1.802567535340305e-12], 1e-6);
 %!test
-%! % Test fixed seed
-%! randg("seed",1);
-%! assert (randg(0.95,1,6), [1.664905071258545 1.879976987838745 1.905677795410156 0.9948706030845642 0.5606933236122131 0.0766092911362648],1e-6);
+%! # Test fixed seed
+%! randg ("seed", 1);
+%! assert (randg (0.95, 1, 6), [1.664905071258545 1.879976987838745 1.905677795410156 0.9948706030845642 0.5606933236122131 0.0766092911362648], 1e-6);
 %!test
-%! % Test fixed seed
-%! randg("seed",1);
-%! assert (randg(1,1,6), [0.03512085229158401 0.6488978862762451 0.8114678859710693 0.1666885763406754 1.60791552066803 1.90356981754303],1e-6);
+%! # Test fixed seed
+%! randg ("seed", 1);
+%! assert (randg (1, 1, 6), [0.03512085229158401 0.6488978862762451 0.8114678859710693 0.1666885763406754 1.60791552066803 1.90356981754303], 1e-6);
 %!test
-%! % Test fixed seed
-%! randg("seed",1);
-%! assert (randg(10,1,6), [6.566435813903809 10.11648464202881 10.73162078857422 7.747178077697754 6.278522491455078 6.240195751190186],1e-5);
+%! # Test fixed seed
+%! randg ("seed", 1);
+%! assert (randg (10, 1, 6), [6.566435813903809 10.11648464202881 10.73162078857422 7.747178077697754 6.278522491455078 6.240195751190186], 1e-5);
 %!test
-%! % Test fixed seed
-%! randg("seed",1);
-%! assert (randg(100,1,6), [89.40208435058594 101.4734725952148 103.4020004272461 93.62763214111328 88.33104705810547 88.1871337890625],1e-4);
+%! # Test fixed seed
+%! randg ("seed", 1);
+%! assert (randg (100, 1, 6), [89.40208435058594 101.4734725952148 103.4020004272461 93.62763214111328 88.33104705810547 88.1871337890625], 1e-4);
+
 %!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   randg("state",12)
-%!   a=0.1; x = randg(a,100000,1);
-%!   assert(mean(x),    a,         0.01);
-%!   assert(var(x),     a,         0.01);
-%!   assert(skewness(x),2/sqrt(a), 1.);
-%!   assert(kurtosis(x),6/a,       50.);
+%!   # statistical tests may fail occasionally.
+%!   randg ("state", 12);
+%!   a = 0.1;
+%!   x = randg (a, 100000, 1);
+%!   assert (mean (x),     a,          0.01);
+%!   assert (var (x),      a,          0.01);
+%!   assert (skewness (x), 2/sqrt (a), 1);
+%!   assert (kurtosis (x), 6/a,        50);
 %! endif
 %!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   randg("state",12)
-%!   a=0.95; x = randg(a,100000,1);
-%!   assert(mean(x),    a,         0.01);
-%!   assert(var(x),     a,         0.04);
-%!   assert(skewness(x),2/sqrt(a), 0.2);
-%!   assert(kurtosis(x),6/a,       2.);
+%!   # statistical tests may fail occasionally.
+%!   randg ("state", 12);
+%!   a = 0.95;
+%!   x = randg (a, 100000, 1);
+%!   assert (mean (x),     a,          0.01);
+%!   assert (var (x),      a,          0.04);
+%!   assert (skewness (x), 2/sqrt (a), 0.2);
+%!   assert (kurtosis (x), 6/a,        2);
+%! endif
+%!test
+%! if (__random_statistical_tests__)
+%!   # statistical tests may fail occasionally.
+%!   randg ("state", 12);
+%!   a = 1;
+%!   x = randg (a, 100000, 1);
+%!   assert (mean (x),     a,          0.01);
+%!   assert (var (x),      a,          0.04);
+%!   assert (skewness (x), 2/sqrt (a), 0.2);
+%!   assert (kurtosis (x), 6/a,        2);
 %! endif
 %!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   randg("state",12)
-%!   a=1; x = randg(a,100000,1);
-%!   assert(mean(x),a,             0.01);
-%!   assert(var(x),a,              0.04);
-%!   assert(skewness(x),2/sqrt(a), 0.2);
-%!   assert(kurtosis(x),6/a,       2.);
+%!   # statistical tests may fail occasionally.
+%!   randg ("state", 12);
+%!   a = 10;
+%!   x = randg (a, 100000, 1);
+%!   assert (mean (x),     a,          0.1);
+%!   assert (var (x),      a,          0.5);
+%!   assert (skewness (x), 2/sqrt (a), 0.1);
+%!   assert (kurtosis (x), 6/a,        0.5);
 %! endif
 %!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   randg("state",12)
-%!   a=10; x = randg(a,100000,1);
-%!   assert(mean(x),    a,         0.1);
-%!   assert(var(x),     a,         0.5);
-%!   assert(skewness(x),2/sqrt(a), 0.1);
-%!   assert(kurtosis(x),6/a,       0.5);
+%!   # statistical tests may fail occasionally.
+%!   randg ("state", 12);
+%!   a = 100;
+%!   x = randg (a, 100000, 1);
+%!   assert (mean (x),     a,          0.2);
+%!   assert (var (x),      a,          2);
+%!   assert (skewness (x), 2/sqrt (a), 0.05);
+%!   assert (kurtosis (x), 6/a,        0.2);
+%! endif
+%!test
+%! randg ("seed", 12);
+%!assert (randg ([-inf, -1, 0, inf, nan]), [nan, nan, nan, nan, nan]) # *** Please report
+%!test
+%! if (__random_statistical_tests__)
+%!   # statistical tests may fail occasionally.
+%!   randg ("seed", 12);
+%!   a = 0.1;
+%!   x = randg (a, 100000, 1);
+%!   assert (mean (x),     a,          0.01);
+%!   assert (var (x),      a,          0.01);
+%!   assert (skewness (x), 2/sqrt (a), 1);
+%!   assert (kurtosis (x), 6/a,        50);
 %! endif
 %!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   randg("state",12)
-%!   a=100; x = randg(a,100000,1);
-%!   assert(mean(x),    a,         0.2);
-%!   assert(var(x),     a,         2.);
-%!   assert(skewness(x),2/sqrt(a), 0.05);
-%!   assert(kurtosis(x),6/a,       0.2);
+%!   # statistical tests may fail occasionally.
+%!   randg ("seed", 12);
+%!   a = 0.95;
+%!   x = randg (a, 100000, 1);
+%!   assert (mean (x),     a,          0.01);
+%!   assert (var (x),      a,          0.04);
+%!   assert (skewness (x), 2/sqrt (a), 0.2);
+%!   assert (kurtosis (x), 6/a,        2);
 %! endif
 %!test
-%! randg("seed",12)
-%!assert(randg([-inf,-1,0,inf,nan]),[nan,nan,nan,nan,nan]) % *** Please report
-%!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   randg("seed",12)
-%!   a=0.1; x = randg(a,100000,1);
-%!   assert(mean(x),    a,         0.01);
-%!   assert(var(x),     a,         0.01);
-%!   assert(skewness(x),2/sqrt(a), 1.);
-%!   assert(kurtosis(x),6/a,       50.);
+%!   # statistical tests may fail occasionally.
+%!   randg ("seed", 12);
+%!   a = 1;
+%!   x = randg (a, 100000, 1);
+%!   assert (mean (x),     a,          0.01);
+%!   assert (var (x),      a,          0.04);
+%!   assert (skewness (x), 2/sqrt (a), 0.2);
+%!   assert (kurtosis (x), 6/a,        2);
 %! endif
 %!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   randg("seed",12)
-%!   a=0.95; x = randg(a,100000,1);
-%!   assert(mean(x),    a,         0.01);
-%!   assert(var(x),     a,         0.04);
-%!   assert(skewness(x),2/sqrt(a), 0.2);
-%!   assert(kurtosis(x),6/a,       2.);
-%! endif
-%!test
-%! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   randg("seed",12)
-%!   a=1; x = randg(a,100000,1);
-%!   assert(mean(x),a,             0.01);
-%!   assert(var(x),a,              0.04);
-%!   assert(skewness(x),2/sqrt(a), 0.2);
-%!   assert(kurtosis(x),6/a,       2.);
+%!   # statistical tests may fail occasionally.
+%!   randg ("seed", 12);
+%!   a = 10;
+%!   x = randg (a, 100000, 1);
+%!   assert (mean (x),     a,          0.1);
+%!   assert (var (x),      a,          0.5);
+%!   assert (skewness (x), 2/sqrt (a), 0.1);
+%!   assert (kurtosis (x), 6/a,        0.5);
 %! endif
 %!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   randg("seed",12)
-%!   a=10; x = randg(a,100000,1);
-%!   assert(mean(x),    a,         0.1);
-%!   assert(var(x),     a,         0.5);
-%!   assert(skewness(x),2/sqrt(a), 0.1);
-%!   assert(kurtosis(x),6/a,       0.5);
-%! endif
-%!test
-%! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   randg("seed",12)
-%!   a=100; x = randg(a,100000,1);
-%!   assert(mean(x),    a,         0.2);
-%!   assert(var(x),     a,         2.);
-%!   assert(skewness(x),2/sqrt(a), 0.05);
-%!   assert(kurtosis(x),6/a,       0.2);
+%!   # statistical tests may fail occasionally.
+%!   randg ("seed", 12);
+%!   a = 100;
+%!   x = randg (a, 100000, 1);
+%!   assert (mean (x),     a,          0.2);
+%!   assert (var (x),      a,          2);
+%!   assert (skewness (x), 2/sqrt (a), 0.05);
+%!   assert (kurtosis (x), 6/a,        0.2);
 %! endif
 */
 
-
 DEFUN_DLD (randp, args, ,
   "-*- texinfo -*-\n\
 @deftypefn  {Loadable Function} {} randp (@var{l}, @var{n})\n\
@@ -934,86 +942,86 @@
 
 /*
 %!test
-%! randp("state",12)
-%!assert(randp([-inf,-1,0,inf,nan]),[nan,nan,0,nan,nan]); % *** Please report
+%! randp ("state", 12);
+%! assert (randp ([-inf, -1, 0, inf, nan]), [nan, nan, 0, nan, nan]);   # *** Please report
 %!test
-%! % Test fixed state
-%! randp("state",1);
-%! assert(randp(5,1,6),[5 5 3 7 7 3])
+%! # Test fixed state
+%! randp ("state", 1);
+%! assert (randp (5, 1, 6), [5 5 3 7 7 3])
 %!test
-%! % Test fixed state
-%! randp("state",1);
-%! assert(randp(15,1,6),[13 15 8 18 18 15])
+%! # Test fixed state
+%! randp ("state", 1);
+%! assert (randp (15, 1, 6), [13 15 8 18 18 15])
 %!test
-%! % Test fixed state
-%! randp("state",1);
-%! assert(randp(1e9,1,6),[999915677 999976657 1000047684 1000019035 999985749 999977692],-1e-6)
+%! # Test fixed state
+%! randp ("state", 1);
+%! assert (randp (1e9, 1, 6), [999915677 999976657 1000047684 1000019035 999985749 999977692], -1e-6)
 %!test
-%! % Test fixed state
-%! randp("seed",1);
-%! %%assert(randp(5,1,6),[8 2 3 6 6 8])
-%! assert(randp(5,1,5),[8 2 3 6 6])
+%! # Test fixed state
+%! randp ("seed", 1);
+%! %%assert (randp (5, 1, 6), [8 2 3 6 6 8])
+%! assert (randp (5, 1, 5), [8 2 3 6 6])
 %!test
-%! % Test fixed state
-%! randp("seed",1);
-%! assert(randp(15,1,6),[15 16 12 10 10 12])
+%! # Test fixed state
+%! randp ("seed", 1);
+%! assert (randp (15, 1, 6), [15 16 12 10 10 12])
 %!test
-%! % Test fixed state
-%! randp("seed",1);
-%! assert(randp(1e9,1,6),[1000006208 1000012224 999981120 999963520 999963072 999981440],-1e-6)
+%! # Test fixed state
+%! randp ("seed", 1);
+%! assert (randp (1e9, 1, 6), [1000006208 1000012224 999981120 999963520 999963072 999981440], -1e-6)
 %!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   randp("state",12)
-%!   for a=[5, 15, 1e9; 0.03, 0.03, -5e-3; 0.03, 0.03, 0.03]
-%!     x = randp(a(1),100000,1);
-%!     assert(min(x)>=0); % *** Please report this!!! ***
-%!     assert(mean(x),a(1),a(2));
-%!     assert(var(x),a(1),0.02*a(1));
-%!     assert(skewness(x),1/sqrt(a(1)),a(3));
-%!     assert(kurtosis(x),1/a(1),3*a(3));
+%!   # statistical tests may fail occasionally.
+%!   randp ("state", 12);
+%!   for a = [5, 15, 1e9; 0.03, 0.03, -5e-3; 0.03, 0.03, 0.03]
+%!     x = randp (a (1), 100000, 1);
+%!     assert (min (x) >= 0);   # *** Please report this!!! ***
+%!     assert (mean (x), a(1), a(2));
+%!     assert (var (x), a(1), 0.02*a(1));
+%!     assert (skewness (x), 1/sqrt (a(1)), a(3));
+%!     assert (kurtosis (x), 1/a(1), 3*a(3));
 %!   endfor
 %! endif
 %!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   randp("state",12)
-%!   for a=[5, 15, 1e9; 0.03, 0.03, -5e-3; 0.03, 0.03, 0.03]
-%!     x = randp(a(1)*ones(100000,1),100000,1);
-%!     assert(min(x)>=0); % *** Please report this!!! ***
-%!     assert(mean(x),a(1),a(2));
-%!     assert(var(x),a(1),0.02*a(1));
-%!     assert(skewness(x),1/sqrt(a(1)),a(3));
-%!     assert(kurtosis(x),1/a(1),3*a(3));
+%!   # statistical tests may fail occasionally.
+%!   randp ("state", 12);
+%!   for a = [5, 15, 1e9; 0.03, 0.03, -5e-3; 0.03, 0.03, 0.03]
+%!     x = randp (a(1)*ones (100000, 1), 100000, 1);
+%!     assert (min (x) >= 0);   # *** Please report this!!! ***
+%!     assert (mean (x), a(1), a(2));
+%!     assert (var (x), a(1), 0.02*a(1));
+%!     assert (skewness (x), 1/sqrt (a(1)), a(3));
+%!     assert (kurtosis (x), 1/a(1), 3*a(3));
 %!   endfor
 %! endif
 %!test
-%! randp("seed",12)
-%!assert(randp([-inf,-1,0,inf,nan]),[nan,nan,0,nan,nan]); % *** Please report
+%! randp ("seed", 12);
+%! assert (randp ([-inf, -1, 0, inf, nan]), [nan, nan, 0, nan, nan]);   # *** Please report
 %!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   randp("seed",12)
-%!   for a=[5, 15, 1e9; 0.03, 0.03, -5e-3; 0.03, 0.03, 0.03]
-%!     x = randp(a(1),100000,1);
-%!     assert(min(x)>=0); % *** Please report this!!! ***
-%!     assert(mean(x),a(1),a(2));
-%!     assert(var(x),a(1),0.02*a(1));
-%!     assert(skewness(x),1/sqrt(a(1)),a(3));
-%!     assert(kurtosis(x),1/a(1),3*a(3));
+%!   # statistical tests may fail occasionally.
+%!   randp ("seed", 12);
+%!   for a = [5, 15, 1e9; 0.03, 0.03, -5e-3; 0.03, 0.03, 0.03]
+%!     x = randp (a(1), 100000, 1);
+%!     assert (min (x) >= 0);   # *** Please report this!!! ***
+%!     assert (mean (x), a(1), a(2));
+%!     assert (var (x), a(1), 0.02*a(1));
+%!     assert (skewness (x), 1/sqrt (a(1)), a(3));
+%!     assert (kurtosis (x), 1/a(1), 3*a(3));
 %!   endfor
 %! endif
 %!test
 %! if (__random_statistical_tests__)
-%!   % statistical tests may fail occasionally.
-%!   randp("seed",12)
-%!   for a=[5, 15, 1e9; 0.03, 0.03, -5e-3; 0.03, 0.03, 0.03]
-%!     x = randp(a(1)*ones(100000,1),100000,1);
-%!     assert(min(x)>=0); % *** Please report this!!! ***
-%!     assert(mean(x),a(1),a(2));
-%!     assert(var(x),a(1),0.02*a(1));
-%!     assert(skewness(x),1/sqrt(a(1)),a(3));
-%!     assert(kurtosis(x),1/a(1),3*a(3));
+%!   # statistical tests may fail occasionally.
+%!   randp ("seed", 12);
+%!   for a = [5, 15, 1e9; 0.03, 0.03, -5e-3; 0.03, 0.03, 0.03]
+%!     x = randp (a(1)*ones (100000, 1), 100000, 1);
+%!     assert (min (x) >= 0);   # *** Please report this!!! ***
+%!     assert (mean (x), a(1), a(2));
+%!     assert (var (x), a(1), 0.02*a(1));
+%!     assert (skewness (x), 1/sqrt (a(1)), a(3));
+%!     assert (kurtosis (x), 1/a(1), 3*a(3));
 %!   endfor
 %! endif
 */
@@ -1126,6 +1134,6 @@
 }
 
 /*
-%!assert(sort (randperm (20)),1:20)
-%!assert(length (randperm (20,10)), 10)
+%!assert (sort (randperm (20)), 1:20)
+%!assert (length (randperm (20,10)), 10)
 */
--- a/src/DLD-FUNCTIONS/rcond.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/rcond.cc	Mon May 07 00:56:44 2012 +0200
@@ -87,10 +87,8 @@
 }
 
 /*
-
-%!assert( rcond (eye (2)), 1)
-%!assert( rcond (ones (2)), 0)
-%!assert( rcond ([1 1; 2 1]), 1/9)
-%!assert( rcond (magic (4)), 0, eps)
-
+%!assert (rcond (eye (2)), 1)
+%!assert (rcond (ones (2)), 0)
+%!assert (rcond ([1 1; 2 1]), 1/9)
+%!assert (rcond (magic (4)), 0, eps)
 */
--- a/src/DLD-FUNCTIONS/regexp.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/regexp.cc	Mon May 07 00:56:44 2012 +0200
@@ -44,6 +44,93 @@
 #include "oct-obj.h"
 #include "utils.h"
 
+// Replace backslash escapes in a string with the real values.  We need
+// this special function instead of the one in utils.cc because the set
+// of escape sequences used in regexps is different from those used in
+// the *printf functions.
+
+static std::string
+do_regexp_string_escapes (const std::string& s)
+{
+  std::string retval;
+
+  size_t i = 0;
+  size_t j = 0;
+  size_t len = s.length ();
+
+  retval.resize (len);
+
+  while (j < len)
+    {
+      if (s[j] == '\\' && j+1 < len)
+        {
+          switch (s[++j])
+            {
+            case '$':
+              retval[i] = '$';
+              break;
+
+            case 'a':
+              retval[i] = '\a';
+              break;
+
+            case 'b': // backspace
+              retval[i] = '\b';
+              break;
+
+            case 'f': // formfeed
+              retval[i] = '\f';
+              break;
+
+            case 'n': // newline
+              retval[i] = '\n';
+              break;
+
+            case 'r': // carriage return
+              retval[i] = '\r';
+              break;
+
+            case 't': // horizontal tab
+              retval[i] = '\t';
+              break;
+
+            case 'v': // vertical tab
+              retval[i] = '\v';
+              break;
+
+            case '\\': // backslash
+              retval[i] = '\\';
+              break;
+
+#if 0
+// FIXME -- to be complete, we need to handle \oN, \o{N}, \xN, and
+// \x{N}.  Hex digits may be upper or lower case.  Brackets are
+// optional, so \x5Bz is the same as \x{5B}z.
+
+            case 'o': // octal number
+            case 'x': // hex number
+#endif
+
+            default:
+              retval[i] = '\\';
+              retval[++i] = s[j];
+              break;
+            }
+        }
+      else
+        {
+          retval[i] = s[j];
+        }
+
+      i++;
+      j++;
+    }
+
+  retval.resize (i);
+
+  return retval;
+}
+
 static void
 parse_options (regexp::opts& options, const octave_value_list& args,
                const std::string& who, int skip, bool& extra_args)
@@ -77,12 +164,16 @@
         options.lineanchors (false);
       else if (str.find ("literalspacing", 0) == 0)
         options.freespacing (false);
+      else if (str.find ("noemptymatch", 0) == 0)
+        options.emptymatch (false);
       else if (str.find ("dotexceptnewline", 0) == 0)
         options.dotexceptnewline (true);
       else if (str.find ("lineanchors", 0) == 0)
         options.lineanchors (true);
       else if (str.find ("freespacing", 0) == 0)
         options.freespacing (true);
+      else if (str.find ("emptymatch", 0) == 0)
+        options.emptymatch (true);
       else if (str.find ("start", 0) == 0
                || str.find ("end", 0) == 0
                || str.find ("tokenextents", 0) == 0
@@ -109,9 +200,12 @@
   if (error_state)
     return retval;
 
-  const std::string pattern = args(1).string_value ();
+  std::string pattern = args(1).string_value ();
   if (error_state)
     return retval;
+  // Matlab compatibility.
+  if (args(1).is_sq_string ())
+    pattern = do_regexp_string_escapes (pattern);
 
   regexp::opts options;
   options.case_insensitive (case_insensitive);
@@ -257,7 +351,9 @@
                   || str.find ("dotall", 0) == 0
                   || str.find ("dotexceptnewline", 0) == 0
                   || str.find ("literalspacing", 0) == 0
-                  || str.find ("freespacing", 0) == 0)
+                  || str.find ("freespacing", 0) == 0
+                  || str.find ("noemptymatch", 0) == 0
+                  || str.find ("emptymatch", 0) == 0)
                 continue;
               else if (str.find ("start", 0) == 0)
                 k = 0;
@@ -488,8 +584,8 @@
 operators.  For example, a template for a floating point number might be\n\
 @code{[-+.\\d]+}.\n\
 \n\
-@item ()\n\
-Grouping operator\n\
+@item () (?:)\n\
+Grouping operator.  The first form, parentheses only, also creates a token.\n\
 \n\
 @item |\n\
 Alternation operator.  Match one of a choice of regular expressions.  The\n\
@@ -562,7 +658,8 @@
 @code{(?<name>@dots{})}.\n\
 \n\
 @item sp\n\
-A cell array of the text not returned by match.\n\
+A cell array of the text not returned by match, i.e., what remains if you\n\
+split the string based on @var{pat}.\n\
 @end table\n\
 \n\
 Particular output arguments, or the order of the output arguments, can be\n\
@@ -630,6 +727,15 @@
 \n\
 Alternatively, use (?x) in the pattern.\n\
 \n\
+@item noemptymatch\n\
+Zero-length matches are not returned.  (default)\n\
+\n\
+@item emptymatch\n\
+Return zero-length matches.\n\
+\n\
+@code{regexp ('a', 'b*', 'emptymatch'} returns @code{[1 2]} because there are\n\
+zero or more 'b' characters at positions 1 and end-of-string.\n\
+\n\
 @end table\n\
 @seealso{regexpi, strfind, regexprep}\n\
 @end deftypefn")
@@ -649,130 +755,129 @@
 }
 
 /*
-
 ## PCRE_ERROR_MATCHLIMIT test
 %!test
-%! s=sprintf('\t4\n0000\t-0.00\t-0.0000\t4\t-0.00\t-0.0000\t4\n0000\t-0.00\t-0.0000\t0\t-0.00\t-');
-%! ws = warning("query");
+%! s = sprintf ('\t4\n0000\t-0.00\t-0.0000\t4\t-0.00\t-0.0000\t4\n0000\t-0.00\t-0.0000\t0\t-0.00\t-');
+%! ws = warning ("query");
 %! unwind_protect
-%!   warning("off");
-%!   regexp(s, '(\s*-*\d+[.]*\d*\s*)+\n');
+%!   warning ("off");
+%!   regexp (s, '(\s*-*\d+[.]*\d*\s*)+\n');
 %! unwind_protect_cleanup
-%!   warning(ws);
+%!   warning (ws);
 %! end_unwind_protect
 
-## seg-fault test
-%!assert(regexp("abcde","."),[1,2,3,4,5])
+## segfault test
+%!assert (regexp ("abcde", "."), [1,2,3,4,5])
 ## Infinite loop test
-%!assert (isempty (regexp("abcde", "")))
+%!assert (isempty (regexp ("abcde", "")))
 
 ## Check that anchoring of pattern works correctly
-%!assert(regexp('abcabc','^abc'),1);
-%!assert(regexp('abcabc','abc$'),4);
-%!assert(regexp('abcabc','^abc$'),zeros(1,0));
+%!assert (regexp ('abcabc', '^abc'), 1)
+%!assert (regexp ('abcabc', 'abc$'), 4)
+%!assert (regexp ('abcabc', '^abc$'), zeros (1,0))
 
 %!test
-%! [s, e, te, m, t] = regexp(' No Match ', 'f(.*)uck');
-%! assert (s,zeros(1,0))
-%! assert (e,zeros(1,0))
-%! assert (te,cell(1,0))
-%! assert (m, cell(1,0))
-%! assert (t, cell(1,0))
+%! [s, e, te, m, t] = regexp (' No Match ', 'f(.*)uck');
+%! assert (s, zeros (1,0));
+%! assert (e, zeros (1,0));
+%! assert (te, cell (1,0));
+%! assert (m, cell (1,0));
+%! assert (t, cell (1,0));
 
 %!test
-%! [s, e, te, m, t] = regexp(' FiRetrUck ', 'f(.*)uck');
-%! assert (s,zeros(1,0))
-%! assert (e,zeros(1,0))
-%! assert (te,cell(1,0))
-%! assert (m, cell(1,0))
-%! assert (t, cell(1,0))
+%! [s, e, te, m, t] = regexp (' FiRetrUck ', 'f(.*)uck');
+%! assert (s, zeros (1,0));
+%! assert (e, zeros (1,0));
+%! assert (te, cell (1,0));
+%! assert (m, cell (1,0));
+%! assert (t, cell (1,0));
 
 %!test
-%! [s, e, te, m, t] = regexp(' firetruck ', 'f(.*)uck');
-%! assert (s,2)
-%! assert (e,10)
-%! assert (te{1},[3,7])
-%! assert (m{1}, 'firetruck')
-%! assert (t{1}{1}, 'iretr')
+%! [s, e, te, m, t] = regexp (' firetruck ', 'f(.*)uck');
+%! assert (s, 2);
+%! assert (e, 10);
+%! assert (te{1}, [3, 7]);
+%! assert (m{1}, 'firetruck');
+%! assert (t{1}{1}, 'iretr');
 
 %!test
-%! [s, e, te, m, t] = regexp('short test string','\w*r\w*');
-%! assert (s,[1,12])
-%! assert (e,[5,17])
-%! assert (size(te), [1,2])
-%! assert (isempty(te{1}))
-%! assert (isempty(te{2}))
-%! assert (m{1},'short')
-%! assert (m{2},'string')
-%! assert (size(t), [1,2])
-%! assert (isempty(t{1}))
-%! assert (isempty(t{2}))
+%! [s, e, te, m, t] = regexp ('short test string', '\w*r\w*');
+%! assert (s, [1, 12]);
+%! assert (e, [5, 17]);
+%! assert (size (te), [1, 2]);
+%! assert (isempty (te{1}));
+%! assert (isempty (te{2}));
+%! assert (m{1}, 'short');
+%! assert (m{2}, 'string');
+%! assert (size (t), [1, 2]);
+%! assert (isempty (t{1}));
+%! assert (isempty (t{2}));
 
 %!test
-%! [s, e, te, m, t] = regexp('short test string','\w*r\w*','once');
-%! assert (s,1)
-%! assert (e,5)
-%! assert (isempty(te))
-%! assert (m,'short')
-%! assert (isempty(t))
+%! [s, e, te, m, t] = regexp ('short test string', '\w*r\w*', 'once');
+%! assert (s, 1);
+%! assert (e, 5);
+%! assert (isempty (te));
+%! assert (m, 'short');
+%! assert (isempty (t));
 
 %!test
-%! [m, te, e, s, t] = regexp('short test string','\w*r\w*','once', 'match', 'tokenExtents', 'end', 'start', 'tokens');
-%! assert (s,1)
-%! assert (e,5)
-%! assert (isempty(te))
-%! assert (m,'short')
-%! assert (isempty(t))
+%! [m, te, e, s, t] = regexp ('short test string', '\w*r\w*', 'once', 'match', 'tokenExtents', 'end', 'start', 'tokens');
+%! assert (s, 1);
+%! assert (e, 5);
+%! assert (isempty (te));
+%! assert (m, 'short');
+%! assert (isempty (t));
 
 %!test
-%! [s, e, te, m, t, nm] = regexp('short test string','(?<word1>\w*t)\s*(?<word2>\w*t)');
-%! assert (s,1)
-%! assert (e,10)
-%! assert (size(te), [1,1])
-%! assert (te{1}, [1 5; 7, 10])
-%! assert (m{1},'short test')
-%! assert (size(t),[1,1])
-%! assert (t{1}{1},'short')
-%! assert (t{1}{2},'test')
-%! assert (size(nm), [1,1])
-%! assert (!isempty(fieldnames(nm)))
-%! assert (sort(fieldnames(nm)),{'word1';'word2'})
-%! assert (nm.word1,'short')
-%! assert (nm.word2,'test')
+%! [s, e, te, m, t, nm] = regexp ('short test string', '(?<word1>\w*t)\s*(?<word2>\w*t)');
+%! assert (s, 1);
+%! assert (e, 10);
+%! assert (size (te), [1, 1]);
+%! assert (te{1}, [1,5; 7,10]);
+%! assert (m{1}, 'short test');
+%! assert (size (t), [1, 1]);
+%! assert (t{1}{1}, 'short');
+%! assert (t{1}{2}, 'test');
+%! assert (size (nm), [1, 1]);
+%! assert (! isempty (fieldnames (nm)));
+%! assert (sort (fieldnames (nm)), {'word1';'word2'});
+%! assert (nm.word1, 'short');
+%! assert (nm.word2, 'test');
 
 %!test
-%! [nm, m, te, e, s, t] = regexp('short test string','(?<word1>\w*t)\s*(?<word2>\w*t)', 'names', 'match', 'tokenExtents', 'end', 'start', 'tokens');
-%! assert (s,1)
-%! assert (e,10)
-%! assert (size(te), [1,1])
-%! assert (te{1}, [1 5; 7, 10])
-%! assert (m{1},'short test')
-%! assert (size(t),[1,1])
-%! assert (t{1}{1},'short')
-%! assert (t{1}{2},'test')
-%! assert (size(nm), [1,1])
-%! assert (!isempty(fieldnames(nm)))
-%! assert (sort(fieldnames(nm)),{'word1';'word2'})
-%! assert (nm.word1,'short')
-%! assert (nm.word2,'test')
+%! [nm, m, te, e, s, t] = regexp ('short test string', '(?<word1>\w*t)\s*(?<word2>\w*t)', 'names', 'match', 'tokenExtents', 'end', 'start', 'tokens');
+%! assert (s, 1);
+%! assert (e, 10);
+%! assert (size (te), [1, 1]);
+%! assert (te{1}, [1,5; 7,10]);
+%! assert (m{1}, 'short test');
+%! assert (size (t), [1, 1]);
+%! assert (t{1}{1}, 'short');
+%! assert (t{1}{2}, 'test');
+%! assert (size (nm), [1, 1]);
+%! assert (!isempty (fieldnames (nm)));
+%! assert (sort (fieldnames (nm)), {'word1';'word2'});
+%! assert (nm.word1, 'short');
+%! assert (nm.word2, 'test');
 
 %!test
-%! [t, nm] = regexp("John Davis\nRogers, James",'(?<first>\w+)\s+(?<last>\w+)|(?<last>\w+),\s+(?<first>\w+)','tokens','names');
-%! assert (size(t), [1,2]);
-%! assert (t{1}{1},'John');
-%! assert (t{1}{2},'Davis');
-%! assert (t{2}{1},'Rogers');
-%! assert (t{2}{2},'James');
-%! assert (size(nm), [1,1]);
-%! assert (nm.first{1},'John');
-%! assert (nm.first{2},'James');
-%! assert (nm.last{1},'Davis');
-%! assert (nm.last{2},'Rogers');
+%! [t, nm] = regexp ("John Davis\nRogers, James", '(?<first>\w+)\s+(?<last>\w+)|(?<last>\w+),\s+(?<first>\w+)', 'tokens', 'names');
+%! assert (size (t), [1, 2]);
+%! assert (t{1}{1}, 'John');
+%! assert (t{1}{2}, 'Davis');
+%! assert (t{2}{1}, 'Rogers');
+%! assert (t{2}{2}, 'James');
+%! assert (size (nm), [1, 1]);
+%! assert (nm.first{1}, 'John');
+%! assert (nm.first{2}, 'James');
+%! assert (nm.last{1}, 'Davis');
+%! assert (nm.last{2}, 'Rogers');
 
 ## Tests for named tokens
 %!test
 %! # Parenthesis in named token (ie (int)) causes a problem
-%! assert (regexp('qwe int asd', ['(?<typestr>(int))'], 'names'), struct ('typestr', 'int'));
+%! assert (regexp ('qwe int asd', ['(?<typestr>(int))'], 'names'), struct ('typestr', 'int'));
 
 %!test
 %! ## Mix of named and unnamed tokens can cause segfault (bug #35683)
@@ -783,51 +888,90 @@
 %! assert (tokens.T1, "a");
 %! assert (tokens.T2, "de");
 
-%!assert(regexp("abc\nabc",'.'),[1:7])
-%!assert(regexp("abc\nabc",'.','dotall'),[1:7])
+%!assert (regexp ("abc\nabc", '.'), [1:7])
+%!assert (regexp ("abc\nabc", '.', 'dotall'), [1:7])
 %!test
-%! assert(regexp("abc\nabc",'(?s).'),[1:7])
-%! assert(regexp("abc\nabc",'.','dotexceptnewline'),[1,2,3,5,6,7])
-%! assert(regexp("abc\nabc",'(?-s).'),[1,2,3,5,6,7])
+%! assert (regexp ("abc\nabc", '(?s).'), [1:7]);
+%! assert (regexp ("abc\nabc", '.', 'dotexceptnewline'), [1,2,3,5,6,7]);
+%! assert (regexp ("abc\nabc", '(?-s).'), [1,2,3,5,6,7]);
+
+%!assert (regexp ("caseCaSe", 'case'), 1)
+%!assert (regexp ("caseCaSe", 'case', "matchcase"), 1)
+%!assert (regexp ("caseCaSe", 'case', "ignorecase"), [1,5])
+%!test
+%! assert (regexp ("caseCaSe", '(?-i)case'), 1);
+%! assert (regexp ("caseCaSe", '(?i)case'), [1, 5]);
 
-%!assert(regexp("caseCaSe",'case'),1)
-%!assert(regexp("caseCaSe",'case',"matchcase"),1)
-%!assert(regexp("caseCaSe",'case',"ignorecase"),[1,5])
+%!assert (regexp ("abc\nabc", 'c$'), 7)
+%!assert (regexp ("abc\nabc", 'c$', "stringanchors"), 7)
 %!test
-%! assert(regexp("caseCaSe",'(?-i)case'),1)
-%! assert(regexp("caseCaSe",'(?i)case'),[1,5])
+%! assert (regexp ("abc\nabc", '(?-m)c$'), 7);
+%! assert (regexp ("abc\nabc", 'c$',"lineanchors"), [3, 7]);
+%! assert (regexp ("abc\nabc", '(?m)c$'), [3,7]);
 
-%!assert (regexp("abc\nabc",'c$'),7)
-%!assert (regexp("abc\nabc",'c$',"stringanchors"),7)
+%!assert (regexp ("this word", 's w'), 4)
+%!assert (regexp ("this word", 's w', 'literalspacing'), 4)
+%!test
+%! assert (regexp ("this word", '(?-x)s w', 'literalspacing'), 4);
+%! assert (regexp ("this word", 's w', 'freespacing'), zeros (1,0));
+%! assert (regexp ("this word", '(?x)s w'), zeros (1,0));
+
 %!test
-%! assert (regexp("abc\nabc",'(?-m)c$'),7)
-%! assert (regexp("abc\nabc",'c$',"lineanchors"),[3,7])
-%! assert (regexp("abc\nabc",'(?m)c$'),[3,7])
+%! [s, e, te, m, t, nm, sp] = regexp ('OCTAVE', '[VOCT]*', 'noemptymatch');
+%! assert (s, [1 5]);
+%! assert (e, [3 5]);
+%! assert (te, { zeros(0,2), zeros(0,2) });
+%! assert (m, { "OCT", "V" });
+%! assert (t, { cell(1,0), cell(1,0) });
+%! assert (isempty (fieldnames (nm)));
+%! assert (sp, { "", "A", "E" });
 
-%!assert (regexp("this word",'s w'),4)
-%!assert (regexp("this word",'s w','literalspacing'),4)
+%!test
+%! [s, e, te, m, t, nm, sp] = regexp ('OCTAVE', '([VOCT]*)', 'noemptymatch');
+%! assert (s, [1 5]);
+%! assert (e, [3 5]);
+%! assert (te, { [1 3], [5 5] });
+%! assert (m, { "OCT", "V" });
+%! assert (t, { {"OCT"}, {"V"} });
+%! assert (isempty (fieldnames (nm)));
+%! assert (sp, { "", "A", "E" });
+
 %!test
-%! assert (regexp("this word",'(?-x)s w','literalspacing'),4)
-%! assert (regexp("this word",'s w','freespacing'),zeros(1,0))
-%! assert (regexp("this word",'(?x)s w'),zeros(1,0))
+%! [s, e, te, m, t, nm, sp] = regexp ('OCTAVE', '[VOCT]*', 'emptymatch');
+%! assert (s, [1 4 5 6 7]);
+%! assert (e, [3 3 5 5 6]);
+%! assert (te, repmat ({zeros(0,2)}, [1, 5]));
+%! assert (m, { "OCT", "", "V", "", "" });
+%! assert (t, repmat({cell(1,0)}, [1, 5]));
+%! assert (isempty (fieldnames (nm)));
+%! assert (sp, { "", "", "A", "", "E", "" });
 
-%!error regexp('string', 'tri', 'BadArg');
-%!error regexp('string');
+%!test
+%! [s, e, te, m, t, nm, sp] = regexp ('OCTAVE', '([VOCT]*)', 'emptymatch');
+%! assert (s, [1 4 5 6 7]);
+%! assert (e, [3 3 5 5 6]);
+%! assert (te, { [1 3], [4 3], [5 5], [6 5], [7 6] });
+%! assert (m, { "OCT", "", "V", "", "" });
+%! assert (t, { {"OCT"}, {""}, {"V"}, {""}, {""} });
+%! assert (isempty (fieldnames (nm)));
+%! assert (sp, { "", "", "A", "", "E", "" });
 
-%!assert(regexp({'asdfg-dfd';'-dfd-dfd-';'qasfdfdaq'},'-'),{6;[1,5,9];zeros(1,0)})
-%!assert(regexp({'asdfg-dfd','-dfd-dfd-','qasfdfdaq'},'-'),{6,[1,5,9],zeros(1,0)})
-%!assert(regexp({'asdfg-dfd';'-dfd-dfd-';'qasfdfdaq'},{'-';'f';'q'}),{6;[3,7];[1,9]})
-%!assert(regexp('Strings',{'t','s'}),{2,7})
+%!error regexp ('string', 'tri', 'BadArg')
+%!error regexp ('string')
+
+%!assert (regexp ({'asdfg-dfd';'-dfd-dfd-';'qasfdfdaq'}, '-'), {6;[1,5,9];zeros(1,0)})
+%!assert (regexp ({'asdfg-dfd';'-dfd-dfd-';'qasfdfdaq'}, {'-';'f';'q'}), {6;[3,7];[1,9]})
+%!assert (regexp ('Strings', {'t','s'}), {2, 7})
 
 ## Test case for lookaround operators
 %!test
-%! assert(regexp('Iraq','q(?!u)'),4)
-%! assert(regexp('quit','q(?!u)'), zeros(1,0))
-%! assert(regexp('quit','q(?=u)','match'), {'q'})
-%! assert(regexp("quit",'q(?=u+)','match'), {'q'})
-%! assert(regexp("qit",'q(?=u+)','match'), cell(1,0))
-%! assert(regexp("qit",'q(?=u*)','match'), {'q'})
-%! assert(regexp('thingamabob','(?<=a)b'), 9)
+%! assert (regexp ('Iraq', 'q(?!u)'), 4);
+%! assert (regexp ('quit', 'q(?!u)'), zeros (1, 0));
+%! assert (regexp ('quit', 'q(?=u)' , 'match'), {'q'});
+%! assert (regexp ("quit", 'q(?=u+)', 'match'), {'q'});
+%! assert (regexp ("qit",  'q(?=u+)', 'match'), cell (1, 0));
+%! assert (regexp ("qit",  'q(?=u*)', 'match'), {'q'});
+%! assert (regexp ('thingamabob', '(?<=a)b'), 9);
 
 ## Tests for split option.
 %!shared str
@@ -846,8 +990,8 @@
 %! assert (b, {"foo bar foo"});
 %!test
 %! [a, b] = regexp (str, "fx.", "match", "split", "once");
-%! assert (a, "");
-%! assert (b, "foo bar foo")
+%! assert (a, "");;
+%! assert (b, "foo bar foo");
 
 %!shared str
 %! str = "foo bar";
@@ -868,6 +1012,8 @@
 %! assert (a, {"oo"});
 %! assert (b, {"f", " bar"});
 
+%!assert (regexp ("\n", '\n'), 1);
+%!assert (regexp ("\n", "\n"), 1);
 */
 
 DEFUN_DLD (regexpi, args, nargout,
@@ -897,139 +1043,139 @@
 }
 
 /*
-
-## seg-fault test
-%!assert(regexpi("abcde","."),[1,2,3,4,5])
+## segfault test
+%!assert (regexpi ("abcde", "."), [1,2,3,4,5])
 
 ## Check that anchoring of pattern works correctly
-%!assert(regexpi('abcabc','^ABC'),1);
-%!assert(regexpi('abcabc','ABC$'),4);
-%!assert(regexpi('abcabc','^ABC$'),zeros(1,0));
+%!assert (regexpi ('abcabc', '^ABC'), 1)
+%!assert (regexpi ('abcabc', 'ABC$'), 4)
+%!assert (regexpi ('abcabc', '^ABC$'), zeros (1,0))
 
 %!test
-%! [s, e, te, m, t] = regexpi(' No Match ', 'f(.*)uck');
-%! assert (s,zeros(1,0))
-%! assert (e,zeros(1,0))
-%! assert (te,cell(1,0))
-%! assert (m, cell(1,0))
-%! assert (t, cell(1,0))
+%! [s, e, te, m, t] = regexpi (' No Match ', 'f(.*)uck');
+%! assert (s, zeros (1,0));
+%! assert (e, zeros (1,0));
+%! assert (te, cell (1,0));
+%! assert (m, cell (1,0));
+%! assert (t, cell (1,0));
 
 %!test
-%! [s, e, te, m, t] = regexpi(' FiRetrUck ', 'f(.*)uck');
-%! assert (s,2)
-%! assert (e,10)
-%! assert (te{1},[3,7])
-%! assert (m{1}, 'FiRetrUck')
-%! assert (t{1}{1}, 'iRetr')
+%! [s, e, te, m, t] = regexpi (' FiRetrUck ', 'f(.*)uck');
+%! assert (s, 2);
+%! assert (e, 10);
+%! assert (te{1}, [3, 7]);
+%! assert (m{1}, 'FiRetrUck');
+%! assert (t{1}{1}, 'iRetr');
 
 %!test
-%! [s, e, te, m, t] = regexpi(' firetruck ', 'f(.*)uck');
-%! assert (s,2)
-%! assert (e,10)
-%! assert (te{1},[3,7])
-%! assert (m{1}, 'firetruck')
-%! assert (t{1}{1}, 'iretr')
+%! [s, e, te, m, t] = regexpi (' firetruck ', 'f(.*)uck');
+%! assert (s, 2);
+%! assert (e, 10);
+%! assert (te{1}, [3, 7]);
+%! assert (m{1}, 'firetruck');
+%! assert (t{1}{1}, 'iretr');
 
 %!test
-%! [s, e, te, m, t] = regexpi('ShoRt Test String','\w*r\w*');
-%! assert (s,[1,12])
-%! assert (e,[5,17])
-%! assert (size(te), [1,2])
-%! assert (isempty(te{1}))
-%! assert (isempty(te{2}))
-%! assert (m{1},'ShoRt')
-%! assert (m{2},'String')
-%! assert (size(t), [1,2])
-%! assert (isempty(t{1}))
-%! assert (isempty(t{2}))
+%! [s, e, te, m, t] = regexpi ('ShoRt Test String', '\w*r\w*');
+%! assert (s, [1, 12]);
+%! assert (e, [5, 17]);
+%! assert (size (te), [1, 2]);
+%! assert (isempty (te{1}));
+%! assert (isempty (te{2}));
+%! assert (m{1}, 'ShoRt');
+%! assert (m{2}, 'String');
+%! assert (size (t), [1, 2]);
+%! assert (isempty (t{1}));
+%! assert (isempty (t{2}));
 
 %!test
-%! [s, e, te, m, t] = regexpi('ShoRt Test String','\w*r\w*','once');
-%! assert (s,1)
-%! assert (e,5)
-%! assert (isempty(te))
-%! assert (m,'ShoRt')
-%! assert (isempty(t))
+%! [s, e, te, m, t] = regexpi ('ShoRt Test String', '\w*r\w*', 'once');
+%! assert (s, 1);
+%! assert (e, 5);
+%! assert (isempty (te));
+%! assert (m, 'ShoRt');
+%! assert (isempty (t));
 
 %!test
-%! [m, te, e, s, t] = regexpi('ShoRt Test String','\w*r\w*','once', 'match', 'tokenExtents', 'end', 'start', 'tokens');
-%! assert (s,1)
-%! assert (e,5)
-%! assert (isempty(te))
-%! assert (m,'ShoRt')
-%! assert (isempty(t))
+%! [m, te, e, s, t] = regexpi ('ShoRt Test String', '\w*r\w*', 'once', 'match', 'tokenExtents', 'end', 'start', 'tokens');
+%! assert (s, 1);
+%! assert (e, 5);
+%! assert (isempty (te));
+%! assert (m, 'ShoRt');
+%! assert (isempty (t));
 
 %!test
-%! [s, e, te, m, t, nm] = regexpi('ShoRt Test String','(?<word1>\w*t)\s*(?<word2>\w*t)');
-%! assert (s,1)
-%! assert (e,10)
-%! assert (size(te), [1,1])
-%! assert (te{1}, [1 5; 7, 10])
-%! assert (m{1},'ShoRt Test')
-%! assert (size(t),[1,1])
-%! assert (t{1}{1},'ShoRt')
-%! assert (t{1}{2},'Test')
-%! assert (size(nm), [1,1])
-%! assert (!isempty(fieldnames(nm)))
-%! assert (sort(fieldnames(nm)),{'word1';'word2'})
-%! assert (nm.word1,'ShoRt')
-%! assert (nm.word2,'Test')
+%! [s, e, te, m, t, nm] = regexpi ('ShoRt Test String', '(?<word1>\w*t)\s*(?<word2>\w*t)');
+%! assert (s, 1);
+%! assert (e, 10);
+%! assert (size (te), [1, 1]);
+%! assert (te{1}, [1,5; 7,10]);
+%! assert (m{1}, 'ShoRt Test');
+%! assert (size (t), [1, 1]);
+%! assert (t{1}{1}, 'ShoRt');
+%! assert (t{1}{2}, 'Test');
+%! assert (size (nm), [1, 1]);
+%! assert (! isempty (fieldnames (nm)));
+%! assert (sort (fieldnames (nm)), {'word1';'word2'});
+%! assert (nm.word1, 'ShoRt');
+%! assert (nm.word2, 'Test');
 
 %!test
-%! [nm, m, te, e, s, t] = regexpi('ShoRt Test String','(?<word1>\w*t)\s*(?<word2>\w*t)', 'names', 'match', 'tokenExtents', 'end', 'start', 'tokens');
-%! assert (s,1)
-%! assert (e,10)
-%! assert (size(te), [1,1])
-%! assert (te{1}, [1 5; 7, 10])
-%! assert (m{1},'ShoRt Test')
-%! assert (size(t),[1,1])
-%! assert (t{1}{1},'ShoRt')
-%! assert (t{1}{2},'Test')
-%! assert (size(nm), [1,1])
-%! assert (!isempty(fieldnames(nm)))
-%! assert (sort(fieldnames(nm)),{'word1';'word2'})
-%! assert (nm.word1,'ShoRt')
-%! assert (nm.word2,'Test')
+%! [nm, m, te, e, s, t] = regexpi ('ShoRt Test String', '(?<word1>\w*t)\s*(?<word2>\w*t)', 'names', 'match', 'tokenExtents', 'end', 'start', 'tokens');
+%! assert (s, 1);
+%! assert (e, 10);
+%! assert (size (te), [1, 1]);
+%! assert (te{1}, [1,5; 7,10]);
+%! assert (m{1}, 'ShoRt Test');
+%! assert (size (t), [1, 1]);
+%! assert (t{1}{1}, 'ShoRt');
+%! assert (t{1}{2}, 'Test');
+%! assert (size (nm), [1, 1]);
+%! assert (!isempty (fieldnames (nm)));
+%! assert (sort (fieldnames (nm)), {'word1';'word2'});
+%! assert (nm.word1, 'ShoRt');
+%! assert (nm.word2, 'Test');
 
-%!assert(regexpi("abc\nabc",'.'),[1:7])
-%!assert(regexpi("abc\nabc",'.','dotall'),[1:7])
+%!assert (regexpi ("abc\nabc", '.'), [1:7])
+%!assert (regexpi ("abc\nabc", '.', 'dotall'), [1:7])
 %!test
-%! assert(regexpi("abc\nabc",'(?s).'),[1:7])
-%! assert(regexpi("abc\nabc",'.','dotexceptnewline'),[1,2,3,5,6,7])
-%! assert(regexpi("abc\nabc",'(?-s).'),[1,2,3,5,6,7])
+%! assert (regexpi ("abc\nabc", '(?s).'), [1:7]);
+%! assert (regexpi ("abc\nabc", '.', 'dotexceptnewline'), [1,2,3,5,6,7]);
+%! assert (regexpi ("abc\nabc", '(?-s).'), [1,2,3,5,6,7]);
 
-%!assert(regexpi("caseCaSe",'case'),[1,5])
-%!assert(regexpi("caseCaSe",'case',"matchcase"),1)
-%!assert(regexpi("caseCaSe",'case',"ignorecase"),[1,5])
+%!assert (regexpi ("caseCaSe", 'case'), [1, 5])
+%!assert (regexpi ("caseCaSe", 'case', "matchcase"), 1)
+%!assert (regexpi ("caseCaSe", 'case', "ignorecase"), [1, 5])
 %!test
-%! assert(regexpi("caseCaSe",'(?-i)case'),1)
-%! assert(regexpi("caseCaSe",'(?i)case'),[1,5])
+%! assert (regexpi ("caseCaSe", '(?-i)case'), 1);
+%! assert (regexpi ("caseCaSe", '(?i)case'), [1, 5]);
 
-%!assert (regexpi("abc\nabc",'C$'),7)
-%!assert (regexpi("abc\nabc",'C$',"stringanchors"),7)
+%!assert (regexpi ("abc\nabc", 'C$'), 7)
+%!assert (regexpi ("abc\nabc", 'C$', "stringanchors"), 7)
 %!test
-%! assert (regexpi("abc\nabc",'(?-m)C$'),7)
-%! assert (regexpi("abc\nabc",'C$',"lineanchors"),[3,7])
-%! assert (regexpi("abc\nabc",'(?m)C$'),[3,7])
+%! assert (regexpi ("abc\nabc", '(?-m)C$'), 7);
+%! assert (regexpi ("abc\nabc", 'C$', "lineanchors"), [3, 7]);
+%! assert (regexpi ("abc\nabc", '(?m)C$'), [3, 7]);
 
-%!assert (regexpi("this word",'S w'),4)
-%!assert (regexpi("this word",'S w','literalspacing'),4)
+%!assert (regexpi ("this word", 'S w'), 4)
+%!assert (regexpi ("this word", 'S w', 'literalspacing'), 4)
 %!test
-%! assert (regexpi("this word",'(?-x)S w','literalspacing'),4)
-%! assert (regexpi("this word",'S w','freespacing'),zeros(1,0))
-%! assert (regexpi("this word",'(?x)S w'),zeros(1,0))
+%! assert (regexpi ("this word", '(?-x)S w', 'literalspacing'), 4);
+%! assert (regexpi ("this word", 'S w', 'freespacing'), zeros (1,0));
+%! assert (regexpi ("this word", '(?x)S w'), zeros (1,0));
 
-%!error regexpi('string', 'tri', 'BadArg');
-%!error regexpi('string');
+%!error regexpi ('string', 'tri', 'BadArg')
+%!error regexpi ('string')
 
-%!assert(regexpi({'asdfg-dfd';'-dfd-dfd-';'qasfdfdaq'},'-'),{6;[1,5,9];zeros(1,0)})
-%!assert(regexpi({'asdfg-dfd','-dfd-dfd-','qasfdfdaq'},'-'),{6,[1,5,9],zeros(1,0)})
-%!assert(regexpi({'asdfg-dfd';'-dfd-dfd-';'qasfdfdaq'},{'-';'f';'q'}),{6;[3,7];[1,9]})
-%!assert(regexpi('Strings',{'t','s'}),{2,[1,7]})
+%!assert (regexpi ({'asdfg-dfd';'-dfd-dfd-';'qasfdfdaq'}, '-'), {6;[1,5,9];zeros(1, 0)})
+%!assert (regexpi ({'asdfg-dfd', '-dfd-dfd-', 'qasfdfdaq'}, '-'), {6, [1,5,9], zeros(1,0)})
+%!assert (regexpi ({'asdfg-dfd';'-dfd-dfd-';'qasfdfdaq'}, {'-';'f';'q'}), {6;[3,7];[1,9]})
+%!assert (regexpi ('Strings', {'t', 's'}), {2, [1, 7]})
 
+%!assert (regexpi ("\n", '\n'), 1);
+%!assert (regexpi ("\n", "\n"), 1);
 */
 
-
 static octave_value
 octregexprep (const octave_value_list &args, const std::string &who)
 {
@@ -1042,13 +1188,19 @@
   if (error_state)
     return retval;
 
-  const std::string pattern = args(1).string_value ();
+  std::string pattern = args(1).string_value ();
   if (error_state)
     return retval;
+  // Matlab compatibility.
+  if (args(1).is_sq_string ())
+    pattern = do_regexp_string_escapes (pattern);
 
-  const std::string replacement = args(2).string_value ();
+  std::string replacement = args(2).string_value ();
   if (error_state)
     return retval;
+  // Matlab compatibility.
+  if (args(2).is_sq_string ())
+    replacement = do_regexp_string_escapes (replacement);
 
   // Pack options excluding 'tokenize' and various output
   // reordering strings into regexp arg list
@@ -1196,56 +1348,61 @@
 /*
 %!test  # Replace with empty
 %! xml = '<!-- This is some XML --> <tag v="hello">some stuff<!-- sample tag--></tag>';
-%! t = regexprep(xml,'<[!?][^>]*>','');
-%! assert(t,' <tag v="hello">some stuff</tag>')
+%! t = regexprep (xml, '<[!?][^>]*>', '');
+%! assert (t, ' <tag v="hello">some stuff</tag>');
 
 %!test  # Replace with non-empty
 %! xml = '<!-- This is some XML --> <tag v="hello">some stuff<!-- sample tag--></tag>';
-%! t = regexprep(xml,'<[!?][^>]*>','?');
-%! assert(t,'? <tag v="hello">some stuff?</tag>')
+%! t = regexprep (xml, '<[!?][^>]*>', '?');
+%! assert (t, '? <tag v="hello">some stuff?</tag>');
 
 %!test  # Check that 'tokenize' is ignored
 %! xml = '<!-- This is some XML --> <tag v="hello">some stuff<!-- sample tag--></tag>';
-%! t = regexprep(xml,'<[!?][^>]*>','','tokenize');
-%! assert(t,' <tag v="hello">some stuff</tag>')
+%! t = regexprep (xml, '<[!?][^>]*>', '', 'tokenize');
+%! assert (t, ' <tag v="hello">some stuff</tag>');
 
 ## Test capture replacement
 %!test
 %! data = "Bob Smith\nDavid Hollerith\nSam Jenkins";
 %! result = "Smith, Bob\nHollerith, David\nJenkins, Sam";
-%! t = regexprep(data,'(?m)^(\w+)\s+(\w+)$','$2, $1');
-%! assert(t,result)
+%! t = regexprep (data, '(?m)^(\w+)\s+(\w+)$', '$2, $1');
+%! assert (t, result);
 
 ## Return the original if no match
-%!assert(regexprep('hello','world','earth'),'hello')
+%!assert (regexprep ('hello', 'world', 'earth'), 'hello')
+
+## Test emptymatch
+%!assert (regexprep ('World', '^', 'Hello '), 'World')
+%!assert (regexprep ('World', '^', 'Hello ', 'emptymatch'), 'Hello World')
 
 ## Test a general replacement
-%!assert(regexprep("a[b]c{d}e-f=g", "[^A-Za-z0-9_]", "_"), "a_b_c_d_e_f_g");
+%!assert (regexprep ("a[b]c{d}e-f=g", "[^A-Za-z0-9_]", "_"), "a_b_c_d_e_f_g")
 
 ## Make sure it works at the beginning and end
-%!assert(regexprep("a[b]c{d}e-f=g", "a", "_"), "_[b]c{d}e-f=g");
-%!assert(regexprep("a[b]c{d}e-f=g", "g", "_"), "a[b]c{d}e-f=_");
+%!assert (regexprep ("a[b]c{d}e-f=g", "a", "_"), "_[b]c{d}e-f=g")
+%!assert (regexprep ("a[b]c{d}e-f=g", "g", "_"), "a[b]c{d}e-f=_")
 
 ## Options
-%!assert(regexprep("a[b]c{d}e-f=g", "[^A-Za-z0-9_]", "_", "once"), "a_b]c{d}e-f=g");
-%!assert(regexprep("a[b]c{d}e-f=g", "[^A-Z0-9_]", "_", "ignorecase"), "a_b_c_d_e_f_g");
+%!assert (regexprep ("a[b]c{d}e-f=g", "[^A-Za-z0-9_]", "_", "once"), "a_b]c{d}e-f=g")
+%!assert (regexprep ("a[b]c{d}e-f=g", "[^A-Z0-9_]", "_", "ignorecase"), "a_b_c_d_e_f_g")
 
 ## Option combinations
-%!assert(regexprep("a[b]c{d}e-f=g", "[^A-Z0-9_]", "_", "once", "ignorecase"), "a_b]c{d}e-f=g");
+%!assert (regexprep ("a[b]c{d}e-f=g", "[^A-Z0-9_]", "_", "once", "ignorecase"), "a_b]c{d}e-f=g")
 
 ## End conditions on replacement
-%!assert(regexprep("abc","(b)",".$1"),"a.bc");
-%!assert(regexprep("abc","(b)","$1"),"abc");
-%!assert(regexprep("abc","(b)","$1."),"ab.c");
-%!assert(regexprep("abc","(b)","$1.."),"ab..c");
+%!assert (regexprep ("abc", "(b)", ".$1"), "a.bc");
+%!assert (regexprep ("abc", "(b)", "$1"), "abc");
+%!assert (regexprep ("abc", "(b)", "$1."), "ab.c");
+%!assert (regexprep ("abc", "(b)", "$1.."), "ab..c");
 
 ## Test cell array arguments
-%!assert(regexprep("abc",{"b","a"},"?"),"??c")
-%!assert(regexprep({"abc","cba"},"b","?"),{"a?c","c?a"})
-%!assert(regexprep({"abc","cba"},{"b","a"},{"?","!"}),{"!?c","c?!"})
+%!assert (regexprep ("abc", {"b","a"}, "?"), "??c")
+%!assert (regexprep ({"abc","cba"}, "b", "?"), {"a?c","c?a"})
+%!assert (regexprep ({"abc","cba"}, {"b","a"}, {"?","!"}), {"!?c","c?!"})
 
 # Nasty lookbehind expression
-%!test
-%! assert(regexprep('x^(-1)+y(-1)+z(-1)=0','(?<=[a-z]+)\(\-[1-9]*\)','_minus1'),'x^(-1)+y_minus1+z_minus1=0')
+%!assert (regexprep ('x^(-1)+y(-1)+z(-1)=0', '(?<=[a-z]+)\(\-[1-9]*\)', '_minus1'),'x^(-1)+y_minus1+z_minus1=0')
 
+%!assert (regexprep ("\n", '\n', "X"), "X");
+%!assert (regexprep ("\n", "\n", "X"), "X");
 */
--- a/src/DLD-FUNCTIONS/schur.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/schur.cc	Mon May 07 00:56:44 2012 +0200
@@ -275,23 +275,21 @@
 }
 
 /*
-
 %!test
 %! a = [1, 2, 3; 4, 5, 9; 7, 8, 6];
 %! [u, s] = schur (a);
-%! assert(u' * a * u, s, sqrt (eps));
+%! assert (u' * a * u, s, sqrt (eps));
 
 %!test
-%! a = single([1, 2, 3; 4, 5, 9; 7, 8, 6]);
+%! a = single ([1, 2, 3; 4, 5, 9; 7, 8, 6]);
 %! [u, s] = schur (a);
-%! assert(u' * a * u, s, sqrt (eps('single')));
+%! assert (u' * a * u, s, sqrt (eps ("single")));
 
 %!test
-%! fail("schur ([1, 2; 3, 4], 2)","warning");
+%! fail("schur ([1, 2; 3, 4], 2)", "warning");
 
-%!error <Invalid call to schur> schur ();
-%!error schur ([1, 2, 3; 4, 5, 6]);
-
+%!error schur ()
+%!error <argument must be a square matrix> schur ([1, 2, 3; 4, 5, 6])
 */
 
 DEFUN_DLD (rsf2csf, args, nargout,
@@ -361,24 +359,23 @@
 }
 
 /*
-
 %!test
 %! A = [1, 1, 1, 2; 1, 2, 1, 1; 1, 1, 3, 1; -2, 1, 1, 1];
 %! [u, t] = schur (A);
 %! [U, T] = rsf2csf (u, t);
-%! assert (norm (u * t * u' - U * T * U'), 0, 1e-12)
-%! assert (norm (A - U * T * U'), 0, 1e-12)
+%! assert (norm (u * t * u' - U * T * U'), 0, 1e-12);
+%! assert (norm (A - U * T * U'), 0, 1e-12);
 
 %!test
 %! A = rand (10);
 %! [u, t] = schur (A);
 %! [U, T] = rsf2csf (u, t);
-%! assert (norm (tril (T, -1)), 0)
-%! assert (norm (U * U'), 1, 1e-14)
+%! assert (norm (tril (T, -1)), 0);
+%! assert (norm (U * U'), 1, 1e-14);
 
 %!test
 %! A = [0, 1;-1, 0];
 %! [u, t] = schur (A);
 %! [U, T] = rsf2csf (u,t);
-%! assert (U * T * U', A, 1e-14)
+%! assert (U * T * U', A, 1e-14);
 */
--- a/src/DLD-FUNCTIONS/spparms.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/spparms.cc	Mon May 07 00:56:44 2012 +0200
@@ -178,7 +178,6 @@
 }
 
 /*
-
 %!test
 %! old_vals = spparms ();  # save state
 %! spparms ("defaults");
@@ -196,13 +195,14 @@
 %! spparms (old_vals);     # restore state
 
 %% Test input validation
-%!error (spparms (1, 2, 3))
-%!error ([x, y, z] = spparms ())
-%!error (spparms ("UNKNOWN_KEY"))
-%!error (spparms ({1, 2, 3}))
-%!error (spparms (ones (14, 1)))
-%!error (spparms (1, 1))
-%!error (spparms ("ths_rel", "hello"))
-%!error (spparms ("UNKNOWN_KEY", 1))
-
+%!error <too many input arguments> spparms (1, 2, 3)
+%!error <too many output arguments> [x, y, z] = spparms ()
+%!error <KEY not recognized> spparms ("UNKNOWN_KEY")
+%!#error <input must be a string> spparms ({1, 2, 3})
+%!error spparms ({1, 2, 3})
+%!error <too many elements in vector VALS> spparms (ones (14, 1))
+%!error <first argument must be a string> spparms (1, 1)
+%!#error <second argument must be a real scalar> spparms ("ths_rel", "hello")
+%!error spparms ("ths_rel", "hello")
+%!error <KEY not found> spparms ("UNKNOWN_KEY", 1)
 */
--- a/src/DLD-FUNCTIONS/sqrtm.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/sqrtm.cc	Mon May 07 00:56:44 2012 +0200
@@ -260,20 +260,17 @@
 }
 
 /*
-
 %!assert (sqrtm (2*ones (2)), ones (2), 3*eps)
 
 ## The following two tests are from the reference in the docstring above.
-
 %!test
 %! x = [0 1; 0 0];
-%! assert (any (isnan (sqrtm (x))(:) ))
+%! assert (any (isnan (sqrtm (x))(:)));
 
 %!test
-%! x = eye (4); x(2,2) = x(3,3) = 2^-26; x(1,4) = 1;
-%! z = eye (4); z(2,2) = z(3,3) = 2^-13; z(1,4) = 0.5;
-%! [y, err] = sqrtm(x);
-%! assert (y, z)
-%! assert (err, 0)   ## Yes, this one has to hold exactly
-
+%! x = eye (4);  x(2,2) = x(3,3) = 2^-26;  x(1,4) = 1;
+%! z = eye (4);  z(2,2) = z(3,3) = 2^-13;  z(1,4) = 0.5;
+%! [y, err] = sqrtm (x);
+%! assert (y, z);
+%! assert (err, 0);   ## Yes, this one has to hold exactly
 */
--- a/src/DLD-FUNCTIONS/str2double.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/str2double.cc	Mon May 07 00:56:44 2012 +0200
@@ -350,10 +350,9 @@
 }
 
 /*
-
 %!assert (str2double ("1"), 1)
 %!assert (str2double ("-.1e-5"), -1e-6)
-%!assert (str2double (char ("1", "2 3", "4i")), [1; NaN; 4i]);
+%!assert (str2double (char ("1", "2 3", "4i")), [1; NaN; 4i])
 %!assert (str2double ("-.1e-5"), -1e-6)
 %!assert (str2double ("1,222.5"), 1222.5)
 %!assert (str2double ("i"), i)
@@ -378,5 +377,4 @@
 %!assert (str2double ({"abc", "4i"}), [NaN + 0i, 4i])
 %!assert (str2double ({2, "4i"}), [NaN + 0i, 4i])
 %!assert (str2double (zeros(3,1,2)), NaN (3,1,2))
-
 */
--- a/src/DLD-FUNCTIONS/strfind.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/strfind.cc	Mon May 07 00:56:44 2012 +0200
@@ -247,17 +247,15 @@
 }
 
 /*
-
-%!error strfind ();
-%!error strfind ("foo", "bar", 1);
-%!error strfind ("foo", 100);
-%!error strfind (100, "foo");
+%!assert (strfind ("abababa", "aba"), [1, 3, 5])
+%!assert (strfind ("abababa", "aba", "overlaps", false), [1, 5])
+%!assert (strfind ({"abababa", "bla", "bla"}, "a"), {[1, 3, 5, 7], 3, 3})
+%!assert (strfind ("Linux _is_ user-friendly. It just isn't ignorant-friendly or idiot-friendly.", "friendly"), [17, 50, 68])
 
-%!assert (strfind ("abababa", "aba"), [1, 3, 5]);
-%!assert (strfind ("abababa", "aba", "overlaps", false), [1, 5]);
-%!assert (strfind ({"abababa", "bla", "bla"}, "a"), {[1, 3, 5, 7], 3, 3});
-%!assert (strfind ("Linux _is_ user-friendly. It just isn't ignorant-friendly or idiot-friendly.", "friendly"), [17, 50, 68]);
-
+%!error strfind ()
+%!error strfind ("foo", "bar", 1)
+%!error <PATTERN must be a string> strfind ("foo", 100)
+%!error <first argument must be a string> strfind (100, "foo")
 */
 
 static Array<char>
@@ -407,14 +405,11 @@
 }
 
 /*
-
-%!assert(strcmp (strrep ("This is a test string", "is", "&%$"),
-%! "Th&%$ &%$ a test string"));
-%!assert(strrep ("abababc", "abab", "xyz"), "xyzxyzc");
-%!assert(strrep ("abababc", "abab", "xyz", "overlaps", false), "xyzabc");
+%!assert (strrep ("This is a test string", "is", "&%$"),
+%!                "Th&%$ &%$ a test string")
+%!assert (strrep ("abababc", "abab", "xyz"), "xyzxyzc")
+%!assert (strrep ("abababc", "abab", "xyz", "overlaps", false), "xyzabc")
 
-%!error strrep ();
-
-%!error strrep ("foo", "bar", 3, 4);
-
+%!error strrep ()
+%!error strrep ("foo", "bar", 3, 4)
 */
--- a/src/DLD-FUNCTIONS/sub2ind.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/sub2ind.cc	Mon May 07 00:56:44 2012 +0200
@@ -123,51 +123,48 @@
 }
 
 /*
-
-# Test input validation
-%!error <sub2ind: dimension vector > sub2ind([10 10.5], 1, 1);
-%!error <subscript indices > sub2ind([10 10], 1.5, 1);
-%!error <subscript indices > sub2ind([10 10], 1, 1.5);
-
-# Test evaluation
-%!shared s1, s2, s3, in
-%! s1 = [   1   1   1   1 ;   2   2   2   2 ];
-%! s2 = [   1   1   2   2 ;   1   1   2   2 ];
-%! s3 = [   1   2   1   2 ;   1   2   1   2 ];
-%! in = [   1 101  11 111 ;   2 102  12 112 ];
-%!assert (sub2ind([10 10 10], s1, s2, s3), in);
-%!shared
+## Test evaluation
+%!test
+%! s1 = [ 1   1   1   1 ; 2   2   2   2 ];
+%! s2 = [ 1   1   2   2 ; 1   1   2   2 ];
+%! s3 = [ 1   2   1   2 ; 1   2   1   2 ];
+%! in = [ 1 101  11 111 ; 2 102  12 112 ];
+%! assert (sub2ind ([10 10 10], s1, s2, s3), in);
 
 # Test low index
-%!assert (sub2ind([10 10 10], 1, 1, 1), 1);
-%!error <subscript indices > sub2ind([10 10 10], 0, 1, 1);
-%!error <subscript indices > sub2ind([10 10 10], 1, 0, 1);
-%!error <subscript indices > sub2ind([10 10 10], 1, 1, 0);
+%!assert (sub2ind ([10 10 10], 1, 1, 1), 1)
+%!error <subscript indices> sub2ind ([10 10 10], 0, 1, 1)
+%!error <subscript indices> sub2ind ([10 10 10], 1, 0, 1)
+%!error <subscript indices> sub2ind ([10 10 10], 1, 1, 0)
 
 # Test high index
-%!assert (sub2ind([10 10 10], 10, 10, 10), 1000);
-%!error <sub2ind: index out of range> sub2ind([10 10 10], 11, 10, 10);
-%!error <sub2ind: index out of range> sub2ind([10 10 10], 10, 11, 10);
-%!error <sub2ind: index out of range> sub2ind([10 10 10], 10, 10, 11);
+%!assert (sub2ind ([10 10 10], 10, 10, 10), 1000)
+%!error <index out of range> sub2ind ([10 10 10], 11, 10, 10)
+%!error <index out of range> sub2ind ([10 10 10], 10, 11, 10)
+%!error <index out of range> sub2ind ([10 10 10], 10, 10, 11)
 
 # Test high index in the trailing dimensions
-%!assert (sub2ind([10, 1], 2, 1, 1), 2);
-%!error <sub2ind: index out of range> sub2ind([10, 1], 1, 2, 1);
-%!error <sub2ind: index out of range> sub2ind([10, 1], 1, 1, 2);
-%!assert (sub2ind([10 10], 2, 2, 1), 12);
-%!error <sub2ind: index out of range> sub2ind([10 10], 2, 1, 2);
-%!error <sub2ind: index out of range> sub2ind([10 10], 1, 2, 2);
+%!assert (sub2ind ([10, 1], 2, 1, 1), 2)
+%!error <index out of range> sub2ind ([10, 1], 1, 2, 1)
+%!error <index out of range> sub2ind ([10, 1], 1, 1, 2)
+%!assert (sub2ind ([10 10], 2, 2, 1), 12)
+%!error <index out of range> sub2ind ([10 10], 2, 1, 2)
+%!error <index out of range> sub2ind ([10 10], 1, 2, 2)
 
 # Test handling of empty arguments
-%!assert (sub2ind([10 10], zeros(0,0), zeros(0,0)), zeros(0,0));
-%!assert (sub2ind([10 10], zeros(2,0), zeros(2,0)), zeros(2,0));
-%!assert (sub2ind([10 10], zeros(0,2), zeros(0,2)), zeros(0,2));
-%!error <sub2ind: all subscripts .* same size> sub2ind([10 10 10], zeros(0,2), zeros(2,0));
+%!assert (sub2ind ([10 10], zeros (0,0), zeros (0,0)), zeros (0,0))
+%!assert (sub2ind ([10 10], zeros (2,0), zeros (2,0)), zeros (2,0))
+%!assert (sub2ind ([10 10], zeros (0,2), zeros (0,2)), zeros (0,2))
+%!error <all subscripts .* same size> sub2ind ([10 10 10], zeros (0,2), zeros (2,0))
 
 # Test handling of arguments of different size
-%!error <sub2ind: all subscripts .* same size> sub2ind([10 10], ones(1,2), ones(1,3));
-%!error <sub2ind: all subscripts .* same size> sub2ind([10 10], ones(1,2), ones(2,1));
+%!error <all subscripts .* same size> sub2ind ([10 10], ones (1,2), ones (1,3))
+%!error <all subscripts .* same size> sub2ind ([10 10], ones (1,2), ones (2,1))
 
+## Test input validation
+%!error <dimension vector> sub2ind ([10 10.5], 1, 1)
+%!error <subscript indices> sub2ind ([10 10], 1.5, 1)
+%!error <subscript indices> sub2ind ([10 10], 1, 1.5)
 */
 
 DEFUN_DLD (ind2sub, args, nargout,
--- a/src/DLD-FUNCTIONS/svd.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/svd.cc	Mon May 07 00:56:44 2012 +0200
@@ -325,8 +325,7 @@
 }
 
 /*
-
-%!assert(svd ([1, 2; 2, 1]), [3; 1], sqrt (eps));
+%!assert (svd ([1, 2; 2, 1]), [3; 1], sqrt (eps))
 
 %!test
 %! [u, s, v] = svd ([1, 2; 2, 1]);
@@ -355,34 +354,34 @@
 %! [u, s, v] = svd (a, 1);
 %! assert (u * s * v', a, sqrt (eps));
 
-%!assert(svd (single([1, 2; 2, 1])), single([3; 1]), sqrt (eps('single')));
+%!assert (svd (single ([1, 2; 2, 1])), single ([3; 1]), sqrt (eps ("single")))
 
 %!test
-%! [u, s, v] = svd (single([1, 2; 2, 1]));
+%! [u, s, v] = svd (single ([1, 2; 2, 1]));
 %! x = single (1 / sqrt (2));
-%! assert (u, [-x, -x; -x, x], sqrt (eps('single')));
-%! assert (s, single([3, 0; 0, 1]), sqrt (eps('single')));
-%! assert (v, [-x, x; -x, -x], sqrt (eps('single')));
+%! assert (u, [-x, -x; -x, x], sqrt (eps ("single")));
+%! assert (s, single ([3, 0; 0, 1]), sqrt (eps ("single")));
+%! assert (v, [-x, x; -x, -x], sqrt (eps ("single")));
 
 %!test
-%! a = single([1, 2, 3; 4, 5, 6]);
+%! a = single ([1, 2, 3; 4, 5, 6]);
 %! [u, s, v] = svd (a);
-%! assert (u * s * v', a, sqrt (eps('single')));
+%! assert (u * s * v', a, sqrt (eps ("single")));
 
 %!test
-%! a = single([1, 2; 3, 4; 5, 6]);
+%! a = single ([1, 2; 3, 4; 5, 6]);
 %! [u, s, v] = svd (a);
-%! assert (u * s * v', a, sqrt (eps('single')));
+%! assert (u * s * v', a, sqrt (eps ("single")));
 
 %!test
-%! a = single([1, 2, 3; 4, 5, 6]);
+%! a = single ([1, 2, 3; 4, 5, 6]);
 %! [u, s, v] = svd (a, 1);
-%! assert (u * s * v', a, sqrt (eps('single')));
+%! assert (u * s * v', a, sqrt (eps ("single")));
 
 %!test
-%! a = single([1, 2; 3, 4; 5, 6]);
+%! a = single ([1, 2; 3, 4; 5, 6]);
 %! [u, s, v] = svd (a, 1);
-%! assert (u * s * v', a, sqrt (eps('single')));
+%! assert (u * s * v', a, sqrt (eps ("single")));
 
 %!test
 %! a = zeros (0, 5);
@@ -398,10 +397,9 @@
 %! assert (size (s), [0, 0]);
 %! assert (size (v), [0, 0]);
 
-%!error <Invalid call to svd> svd ();
-%!error <Invalid call to svd> svd ([1, 2; 4, 5], 2, 3);
-%!error <Invalid call to svd> [u, v] = svd ([1, 2; 3, 4]);
-
+%!error svd ()
+%!error svd ([1, 2; 4, 5], 2, 3)
+%!error [u, v] = svd ([1, 2; 3, 4])
 */
 
 DEFUN_DLD (svd_driver, args, nargout,
--- a/src/DLD-FUNCTIONS/syl.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/syl.cc	Mon May 07 00:56:44 2012 +0200
@@ -209,12 +209,10 @@
 }
 
 /*
-
-%!assert(syl ([1, 2; 3, 4], [5, 6; 7, 8], [9, 10; 11, 12]), [-1/2, -2/3; -2/3, -1/2], sqrt (eps));
-%!assert(syl (single([1, 2; 3, 4]), single([5, 6; 7, 8]), single([9, 10; 11, 12])), single([-1/2, -2/3; -2/3, -1/2]), sqrt (eps('single')));
+%!assert (syl ([1, 2; 3, 4], [5, 6; 7, 8], [9, 10; 11, 12]), [-1/2, -2/3; -2/3, -1/2], sqrt (eps))
+%!assert (syl (single ([1, 2; 3, 4]), single ([5, 6; 7, 8]), single ([9, 10; 11, 12])), single ([-1/2, -2/3; -2/3, -1/2]), sqrt (eps ("single")))
 
-%!error <Invalid call to syl> syl ();
-%!error <Invalid call to syl> syl (1, 2, 3, 4);
-%!error syl ([1, 2; 3, 4], [1, 2, 3; 4, 5, 6], [4, 3]);
-
+%!error syl ()
+%!error syl (1, 2, 3, 4)
+%!error <must be a square matrix> syl ([1, 2; 3, 4], [1, 2, 3; 4, 5, 6], [4, 3])
 */
--- a/src/DLD-FUNCTIONS/time.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/time.cc	Mon May 07 00:56:44 2012 +0200
@@ -122,9 +122,7 @@
 }
 
 /*
-
-%!assert(time () > 0);
-
+%!assert (time () > 0)
 */
 
 DEFUN_DLD (gmtime, args, ,
@@ -171,25 +169,22 @@
 }
 
 /*
-
 %!test
 %! ts = gmtime (time ());
-%! assert((isstruct (ts)
-%! && isfield (ts, "usec")
-%! && isfield (ts, "year")
-%! && isfield (ts, "mon")
-%! && isfield (ts, "mday")
-%! && isfield (ts, "sec")
-%! && isfield (ts, "min")
-%! && isfield (ts, "wday")
-%! && isfield (ts, "hour")
-%! && isfield (ts, "isdst")
-%! && isfield (ts, "yday")));
+%! assert (isstruct (ts));
+%! assert (isfield (ts, "usec"));
+%! assert (isfield (ts, "year"));
+%! assert (isfield (ts, "mon"));
+%! assert (isfield (ts, "mday"));
+%! assert (isfield (ts, "sec"));
+%! assert (isfield (ts, "min"));
+%! assert (isfield (ts, "wday"));
+%! assert (isfield (ts, "hour"));
+%! assert (isfield (ts, "isdst"));
+%! assert (isfield (ts, "yday"));
 
-%!error <Invalid call to gmtime> gmtime ();
-
-%!error <Invalid call to gmtime> gmtime (1, 2);
-
+%!error gmtime ()
+%!error gmtime (1, 2)
 */
 
 DEFUN_DLD (localtime, args, ,
@@ -235,25 +230,22 @@
 }
 
 /*
-
 %!test
 %! ts = localtime (time ());
-%! assert((isstruct (ts)
-%! && isfield (ts, "usec")
-%! && isfield (ts, "year")
-%! && isfield (ts, "mon")
-%! && isfield (ts, "mday")
-%! && isfield (ts, "sec")
-%! && isfield (ts, "min")
-%! && isfield (ts, "wday")
-%! && isfield (ts, "hour")
-%! && isfield (ts, "isdst")
-%! && isfield (ts, "yday")));
+%! assert (isstruct (ts));
+%! assert (isfield (ts, "usec"));
+%! assert (isfield (ts, "year"));
+%! assert (isfield (ts, "mon"));
+%! assert (isfield (ts, "mday"));
+%! assert (isfield (ts, "sec"));
+%! assert (isfield (ts, "min"));
+%! assert (isfield (ts, "wday"));
+%! assert (isfield (ts, "hour"));
+%! assert (isfield (ts, "isdst"));
+%! assert (isfield (ts, "yday"));
 
-%!error <Invalid call to localtime> localtime ();
-
-%!error <Invalid call to localtime> localtime (1, 2);
-
+%!error localtime ()
+%!error localtime (1, 2)
 */
 
 DEFUN_DLD (mktime, args, ,
@@ -296,21 +288,18 @@
 }
 
 /*
-
 %!test
 %! t = time ();
-%! assert(fix (mktime (localtime (t))) == fix (t));
-
-%!error <Invalid call to mktime> mktime ();
+%! assert (fix (mktime (localtime (t))) == fix (t));
 
-%!error <Invalid call to mktime> mktime (1, 2, 3);
-
-%% These tests fail on systems with mktime functions of limited
-%% intelligence:
+## These tests fail on systems with mktime functions of limited
+## intelligence:
 %!assert (datestr (datenum (1969, 1, 1), 0), "01-Jan-1969 00:00:00")
 %!assert (datestr (datenum (1901, 1, 1), 0), "01-Jan-1901 00:00:00")
 %!assert (datestr (datenum (1795, 1, 1), 0), "01-Jan-1795 00:00:00")
 
+%!error mktime ()
+%!error mktime (1, 2, 3)
 */
 
 DEFUN_DLD (strftime, args, ,
@@ -498,17 +487,14 @@
 }
 
 /*
+%!assert (ischar (strftime ("%%%n%t%H%I%k%l", localtime (time ()))));
+%!assert (ischar (strftime ("%M%p%r%R%s%S%T", localtime (time ()))));
+%!assert (ischar (strftime ("%X%Z%z%a%A%b%B", localtime (time ()))));
+%!assert (ischar (strftime ("%c%C%d%e%D%h%j", localtime (time ()))));
+%!assert (ischar (strftime ("%m%U%w%W%x%y%Y", localtime (time ()))));
 
-%!assert((ischar (strftime ("%%%n%t%H%I%k%l", localtime (time ())))
-%! && ischar (strftime ("%M%p%r%R%s%S%T", localtime (time ())))
-%! && ischar (strftime ("%X%Z%z%a%A%b%B", localtime (time ())))
-%! && ischar (strftime ("%c%C%d%e%D%h%j", localtime (time ())))
-%! && ischar (strftime ("%m%U%w%W%x%y%Y", localtime (time ())))));
-
-%!error <Invalid call to strftime> strftime ();
-
-%!error <Invalid call to strftime> strftime ("foo", localtime (time ()), 1);
-
+%!error strftime ()
+%!error strftime ("foo", localtime (time ()), 1)
 */
 
 DEFUN_DLD (strptime, args, ,
--- a/src/DLD-FUNCTIONS/tril.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/tril.cc	Mon May 07 00:56:44 2012 +0200
@@ -407,7 +407,6 @@
 }
 
 /*
-
 %!test
 %! a = [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12];
 %!
@@ -419,10 +418,13 @@
 %! lm3 = [0, 0, 0; 0, 0, 0; 0, 0, 0; 10, 0, 0];
 %! lm4 = [0, 0, 0; 0, 0, 0; 0, 0, 0; 0, 0, 0];
 %!
-%! assert((tril (a, -4) == lm4 && tril (a, -3) == lm3
-%! && tril (a, -2) == lm2 && tril (a, -1) == lm1
-%! && tril (a) == l0 && tril (a, 1) == l1 && tril (a, 2) == l2));
+%! assert (tril (a, -4), lm4); 
+%! assert (tril (a, -3), lm3);
+%! assert (tril (a, -2), lm2);
+%! assert (tril (a, -1), lm1);
+%! assert (tril (a), l0);
+%! assert (tril (a, 1), l1);
+%! assert (tril (a, 2), l2);
 
-%!error tril ();
-
+%!error tril ()
 */
--- a/src/DLD-FUNCTIONS/tsearch.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/DLD-FUNCTIONS/tsearch.cc	Mon May 07 00:56:44 2012 +0200
@@ -176,11 +176,11 @@
 %! x = [-1;-1;1];
 %! y = [-1;1;-1];
 %! tri = [1, 2, 3];
-%!error (tsearch())
 %!assert (tsearch (x,y,tri,-1,-1), 1)
 %!assert (tsearch (x,y,tri, 1,-1), 1)
 %!assert (tsearch (x,y,tri,-1, 1), 1)
 %!assert (tsearch (x,y,tri,-1/3, -1/3), 1)
 %!assert (tsearch (x,y,tri, 1, 1), NaN)
 
+%!error tsearch ()
 */
--- a/src/Makefile.am	Mon May 07 00:53:54 2012 +0200
+++ b/src/Makefile.am	Mon May 07 00:56:44 2012 +0200
@@ -97,27 +97,27 @@
 
 EXTRA_DIST = \
   Makefile.in \
-  defaults.h.in \
+  defaults.in.h \
   DOCSTRINGS \
   find-defun-files.sh \
   genprops.awk \
   gl2ps.c \
-  graphics.h.in \
+  graphics.in.h \
   mk-errno-list \
   mk-pkg-add \
   mkbuiltins \
   mkdefs \
   mkgendoc \
-  mkoctfile.cc.in \
-  mkoctfile.in \
+  mkoctfile.in.cc \
+  mkoctfile.in.sh \
   mkops \
-  mxarray.h.in \
-  oct-conf.h.in \
-  oct-errno.cc.in \
-  octave-config.cc.in \
-  octave-config.in \
+  mxarray.in.h \
+  oct-conf.in.h \
+  oct-errno.in.cc \
+  octave-config.in.cc \
+  octave-config.in.sh \
   octave.gperf \
-  version.h.in \
+  version.in.h \
   $(BUILT_DISTFILES)
 
 OPT_HANDLERS = \
@@ -581,14 +581,14 @@
 ## defaults.h and oct-conf.h must depend on Makefile.  Calling configure
 ## may change default/config values.  However, calling configure will also
 ## regenerate the Makefiles from Makefile.am and trigger the rules below.
-defaults.h: defaults.h.in Makefile
+defaults.h: defaults.in.h Makefile
 	@$(do_subst_default_vals)
 
-graphics.h: graphics.h.in genprops.awk Makefile
+graphics.h: graphics.in.h genprops.awk Makefile
 	$(AWK) -f $(srcdir)/genprops.awk $< > $@-t
 	mv $@-t $@
 
-oct-conf.h: oct-conf.h.in Makefile
+oct-conf.h: oct-conf.in.h Makefile
 	@$(do_subst_config_vals)
 
 ## Don't use a pipeline to process gperf output since if gperf
@@ -601,12 +601,12 @@
 	mv $@-t $@
 	rm -f $@-t1
 
-mxarray.h: mxarray.h.in Makefile
+mxarray.h: mxarray.in.h Makefile
 	$(SED) < $< \
 	  -e "s|%OCTAVE_IDX_TYPE%|${OCTAVE_IDX_TYPE}|" > $@-t
 	mv $@-t $@
 
-version.h: version.h.in Makefile
+version.h: version.in.h Makefile
 	$(SED) < $< \
 	  -e "s|%OCTAVE_API_VERSION_NUMBER%|${OCTAVE_API_VERSION_NUMBER}|" \
 	  -e "s|%OCTAVE_API_VERSION%|\"${OCTAVE_API_VERSION}\"|" \
@@ -619,7 +619,7 @@
 	$(srcdir)/mkbuiltins $(DEF_FILES) > $@-t
 	mv $@-t $@
 
-graphics-props.cc: graphics.h.in genprops.awk Makefile
+graphics-props.cc: graphics.in.h genprops.awk Makefile
 	$(AWK) -v emit_graphics_props=1 -f $(srcdir)/genprops.awk $< > $@-t
 	mv $@-t $@
 
@@ -627,7 +627,7 @@
 	$(srcdir)/mkops $(OPERATORS_SRC) > $@-t
 	mv $@-t $@
 
-oct-errno.cc: oct-errno.cc.in Makefile
+oct-errno.cc: oct-errno.in.cc Makefile
 	if test -n "$(PERL)"; then \
 	  $(srcdir)/mk-errno-list --perl "$(PERL)" < $< > $@-t; \
 	elif test -n "$(PYTHON)"; then \
@@ -689,17 +689,17 @@
 endif
 
 if AMCOND_BUILD_COMPILED_AUX_PROGRAMS
-octave-config.cc: octave-config.cc.in Makefile
+octave-config.cc: octave-config.in.cc Makefile
 	@$(do_subst_default_vals)
 
-mkoctfile.cc: mkoctfile.cc.in Makefile
+mkoctfile.cc: mkoctfile.in.cc Makefile
 	@$(do_subst_config_vals)
 else
-octave-config: octave-config.in Makefile
+octave-config: octave-config.in.sh Makefile
 	@$(do_subst_default_vals)
 	chmod a+rx $@
 
-mkoctfile: mkoctfile.in Makefile
+mkoctfile: mkoctfile.in.sh Makefile
 	@$(do_subst_config_vals)
 	chmod a+rx $@
 endif
--- a/src/data.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/data.cc	Mon May 07 00:56:44 2012 +0200
@@ -1281,11 +1281,14 @@
   else if (nargin == 3)
     {
       octave_value arg0 = args(0);
-      if (arg0.ndims () == 2 && (args(0).rows () == 1 || args(0).columns () == 1))
+
+      if (arg0.ndims () == 2 && (arg0.rows () == 1 || arg0.columns () == 1))
         {
-          octave_idx_type m = args(1).int_value (), n = args(2).int_value ();
+          octave_idx_type m = args(1).int_value ();
+          octave_idx_type n = args(2).int_value ();
+
           if (! error_state)
-            retval = arg0.diag ().resize (dim_vector (m, n), true);
+            retval = arg0.diag (m, n);
           else
             error ("diag: invalid dimensions");
         }
@@ -1334,6 +1337,9 @@
 
 ## Test non-square size
 %!assert(diag ([1,2,3], 6, 3), [1 0 0; 0 2 0; 0 0 3; 0 0 0; 0 0 0; 0 0 0])
+%!assert (diag (1, 2, 3), [1,0,0; 0,0,0]);
+%!assert (diag ({1}, 2, 3), {1,[],[]; [],[],[]});
+%!assert (diag ({1,2}, 3, 4), {1,[],[],[]; [],2,[],[]; [],[],[],[]});
 
 %% Test input validation
 %!error <Invalid call to diag> diag ()
@@ -1341,7 +1347,15 @@
 %!error diag (ones (2), 3, 3)
 %!error diag (1:3, -4, 3)
 
- */
+%!assert (diag (1, 3, 3), diag ([1, 0, 0]))
+%!assert (diag (i, 3, 3), diag ([i, 0, 0]))
+%!assert (diag (single (1), 3, 3), diag ([single(1), 0, 0]))
+%!assert (diag (single (i), 3, 3), diag ([single(i), 0, 0]))
+%!assert (diag ([1, 2], 3, 3), diag ([1, 2, 0]))
+%!assert (diag ([1, 2]*i, 3, 3), diag ([1, 2, 0]*i))
+%!assert (diag (single ([1, 2]), 3, 3), diag (single ([1, 2, 0])))
+%!assert (diag (single ([1, 2]*i), 3, 3), diag (single ([1, 2, 0]*i)))
+*/
 
 DEFUN (prod, args, ,
   "-*- texinfo -*-\n\
@@ -4719,9 +4733,7 @@
 %! assert (size (x2) == [1, 10] && x2(1) == 1 && x2(10) == 2);
 %! assert (size (x3) == [1, 10] && x3(1) == 1 && x3(10) == -2);
 
-%#assert (linspace ([1, 2; 3, 4], 5, 6), linspace (1, 5, 6))
-
-%!fail ("linspace ([1, 2; 3, 4], 5, 6)", "warning")
+%assert (linspace ([1, 2; 3, 4], 5, 6), linspace (1, 5, 6))
 
 %!error linspace ()
 %!error linspace (1, 2, 3, 4)
@@ -5233,6 +5245,12 @@
 %! fhi = single (1e+300);
 %!assert (norm (flo*m2,"fro"), single (sqrt (30)*flo), -eps ("single"))
 %!assert (norm (fhi*m2,"fro"), single (sqrt (30)*fhi), -eps ("single"))
+
+%!test
+%! ## Test for norm returning NaN on sparse matrix (bug #30631)
+%! A = sparse (2,2); 
+%! A(2,1) = 1;
+%! assert (norm (A), 1);
 */
 
 static octave_value
--- a/src/defaults.h.in	Mon May 07 00:53:54 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,214 +0,0 @@
-// defaults.h.in
-/*
-
-Copyright (C) 1993-2012 John W. Eaton
-
-This file is part of Octave.
-
-Octave is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 3 of the License, or (at your
-option) any later version.
-
-Octave is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with Octave; see the file COPYING.  If not, see
-<http://www.gnu.org/licenses/>.
-
-*/
-
-#if !defined (octave_defaults_h)
-#define octave_defaults_h 1
-
-#include <string>
-
-#include "pathsearch.h"
-
-#ifndef OCTAVE_CANONICAL_HOST_TYPE
-#define OCTAVE_CANONICAL_HOST_TYPE %OCTAVE_CANONICAL_HOST_TYPE%
-#endif
-
-#ifndef OCTAVE_DEFAULT_PAGER
-#define OCTAVE_DEFAULT_PAGER %OCTAVE_DEFAULT_PAGER%
-#endif
-
-#ifndef OCTAVE_ARCHLIBDIR
-#define OCTAVE_ARCHLIBDIR %OCTAVE_ARCHLIBDIR%
-#endif
-
-#ifndef OCTAVE_BINDIR
-#define OCTAVE_BINDIR %OCTAVE_BINDIR%
-#endif
-
-#ifndef OCTAVE_DATADIR
-#define OCTAVE_DATADIR %OCTAVE_DATADIR%
-#endif
-
-#ifndef OCTAVE_DATAROOTDIR
-#define OCTAVE_DATAROOTDIR %OCTAVE_DATAROOTDIR%
-#endif
-
-#ifndef OCTAVE_DOC_CACHE_FILE
-#define OCTAVE_DOC_CACHE_FILE %OCTAVE_DOC_CACHE_FILE%
-#endif
-
-#ifndef OCTAVE_EXEC_PREFIX
-#define OCTAVE_EXEC_PREFIX %OCTAVE_EXEC_PREFIX%
-#endif
-
-#ifndef OCTAVE_FCNFILEDIR
-#define OCTAVE_FCNFILEDIR %OCTAVE_FCNFILEDIR%
-#endif
-
-#ifndef OCTAVE_IMAGEDIR
-#define OCTAVE_IMAGEDIR %OCTAVE_IMAGEDIR%
-#endif
-
-#ifndef OCTAVE_INCLUDEDIR
-#define OCTAVE_INCLUDEDIR %OCTAVE_INCLUDEDIR%
-#endif
-
-#ifndef OCTAVE_INFODIR
-#define OCTAVE_INFODIR %OCTAVE_INFODIR%
-#endif
-
-#ifndef OCTAVE_INFOFILE
-#define OCTAVE_INFOFILE %OCTAVE_INFOFILE%
-#endif
-
-#ifndef OCTAVE_LIBDIR
-#define OCTAVE_LIBDIR %OCTAVE_LIBDIR%
-#endif
-
-#ifndef OCTAVE_LIBEXECDIR
-#define OCTAVE_LIBEXECDIR %OCTAVE_LIBEXECDIR%
-#endif
-
-#ifndef OCTAVE_LIBEXECDIR
-#define OCTAVE_LIBEXECDIR %OCTAVE_LIBEXECDIR%
-#endif
-
-#ifndef OCTAVE_LOCALAPIFCNFILEDIR
-#define OCTAVE_LOCALAPIFCNFILEDIR %OCTAVE_LOCALAPIFCNFILEDIR%
-#endif
-
-#ifndef OCTAVE_LOCALAPIOCTFILEDIR
-#define OCTAVE_LOCALAPIOCTFILEDIR %OCTAVE_LOCALAPIOCTFILEDIR%
-#endif
-
-#ifndef OCTAVE_LOCALARCHLIBDIR
-#define OCTAVE_LOCALARCHLIBDIR %OCTAVE_LOCALARCHLIBDIR%
-#endif
-
-#ifndef OCTAVE_LOCALFCNFILEDIR
-#define OCTAVE_LOCALFCNFILEDIR %OCTAVE_LOCALFCNFILEDIR%
-#endif
-
-#ifndef OCTAVE_LOCALOCTFILEDIR
-#define OCTAVE_LOCALOCTFILEDIR %OCTAVE_LOCALOCTFILEDIR%
-#endif
-
-#ifndef OCTAVE_LOCALSTARTUPFILEDIR
-#define OCTAVE_LOCALSTARTUPFILEDIR %OCTAVE_LOCALSTARTUPFILEDIR%
-#endif
-
-#ifndef OCTAVE_LOCALAPIARCHLIBDIR
-#define OCTAVE_LOCALAPIARCHLIBDIR %OCTAVE_LOCALAPIARCHLIBDIR%
-#endif
-
-#ifndef OCTAVE_LOCALVERARCHLIBDIR
-#define OCTAVE_LOCALVERARCHLIBDIR %OCTAVE_LOCALVERARCHLIBDIR%
-#endif
-
-#ifndef OCTAVE_LOCALVERFCNFILEDIR
-#define OCTAVE_LOCALVERFCNFILEDIR %OCTAVE_LOCALVERFCNFILEDIR%
-#endif
-
-#ifndef OCTAVE_LOCALVEROCTFILEDIR
-#define OCTAVE_LOCALVEROCTFILEDIR %OCTAVE_LOCALVEROCTFILEDIR%
-#endif
-
-#ifndef OCTAVE_MAN1DIR
-#define OCTAVE_MAN1DIR %OCTAVE_MAN1DIR%
-#endif
-
-#ifndef OCTAVE_MAN1EXT
-#define OCTAVE_MAN1EXT %OCTAVE_MAN1EXT%
-#endif
-
-#ifndef OCTAVE_MANDIR
-#define OCTAVE_MANDIR %OCTAVE_MANDIR%
-#endif
-
-#ifndef OCTAVE_OCTFILEDIR
-#define OCTAVE_OCTFILEDIR %OCTAVE_OCTFILEDIR%
-#endif
-
-#ifndef OCTAVE_OCTETCDIR
-#define OCTAVE_OCTETCDIR %OCTAVE_OCTETCDIR%
-#endif
-
-#ifndef OCTAVE_OCTINCLUDEDIR
-#define OCTAVE_OCTINCLUDEDIR %OCTAVE_OCTINCLUDEDIR%
-#endif
-
-#ifndef OCTAVE_OCTLIBDIR
-#define OCTAVE_OCTLIBDIR %OCTAVE_OCTLIBDIR%
-#endif
-
-#ifndef OCTAVE_PREFIX
-#define OCTAVE_PREFIX %OCTAVE_PREFIX%
-#endif
-
-#ifndef OCTAVE_STARTUPFILEDIR
-#define OCTAVE_STARTUPFILEDIR %OCTAVE_STARTUPFILEDIR%
-#endif
-
-#ifndef OCTAVE_RELEASE
-#define OCTAVE_RELEASE %OCTAVE_RELEASE%
-#endif
-
-extern std::string Voctave_home;
-
-extern std::string Vbin_dir;
-extern std::string Vinfo_dir;
-extern std::string Vdata_dir;
-extern std::string Vlibexec_dir;
-extern std::string Varch_lib_dir;
-extern std::string Vlocal_arch_lib_dir;
-extern std::string Vlocal_ver_arch_lib_dir;
-
-extern std::string Vlocal_ver_oct_file_dir;
-extern std::string Vlocal_api_oct_file_dir;
-extern std::string Vlocal_oct_file_dir;
-
-extern std::string Vlocal_ver_fcn_file_dir;
-extern std::string Vlocal_api_fcn_file_dir;
-extern std::string Vlocal_fcn_file_dir;
-
-extern std::string Voct_file_dir;
-extern std::string Vfcn_file_dir;
-
-extern std::string Vimage_dir;
-
-// Name of the editor to be invoked by the edit_history command.
-extern std::string VEDITOR;
-
-extern std::string Vlocal_site_defaults_file;
-extern std::string Vsite_defaults_file;
-
-// Name of the FFTW wisdom program.
-extern OCTINTERP_API std::string Vfftw_wisdom_program;
-
-extern std::string subst_octave_home (const std::string&);
-
-extern void install_defaults (void);
-
-extern void set_exec_path (const std::string& path = std::string ());
-extern void set_image_path (const std::string& path = std::string ());
-
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/defaults.in.h	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,214 @@
+// defaults.h.in
+/*
+
+Copyright (C) 1993-2012 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+#if !defined (octave_defaults_h)
+#define octave_defaults_h 1
+
+#include <string>
+
+#include "pathsearch.h"
+
+#ifndef OCTAVE_CANONICAL_HOST_TYPE
+#define OCTAVE_CANONICAL_HOST_TYPE %OCTAVE_CANONICAL_HOST_TYPE%
+#endif
+
+#ifndef OCTAVE_DEFAULT_PAGER
+#define OCTAVE_DEFAULT_PAGER %OCTAVE_DEFAULT_PAGER%
+#endif
+
+#ifndef OCTAVE_ARCHLIBDIR
+#define OCTAVE_ARCHLIBDIR %OCTAVE_ARCHLIBDIR%
+#endif
+
+#ifndef OCTAVE_BINDIR
+#define OCTAVE_BINDIR %OCTAVE_BINDIR%
+#endif
+
+#ifndef OCTAVE_DATADIR
+#define OCTAVE_DATADIR %OCTAVE_DATADIR%
+#endif
+
+#ifndef OCTAVE_DATAROOTDIR
+#define OCTAVE_DATAROOTDIR %OCTAVE_DATAROOTDIR%
+#endif
+
+#ifndef OCTAVE_DOC_CACHE_FILE
+#define OCTAVE_DOC_CACHE_FILE %OCTAVE_DOC_CACHE_FILE%
+#endif
+
+#ifndef OCTAVE_EXEC_PREFIX
+#define OCTAVE_EXEC_PREFIX %OCTAVE_EXEC_PREFIX%
+#endif
+
+#ifndef OCTAVE_FCNFILEDIR
+#define OCTAVE_FCNFILEDIR %OCTAVE_FCNFILEDIR%
+#endif
+
+#ifndef OCTAVE_IMAGEDIR
+#define OCTAVE_IMAGEDIR %OCTAVE_IMAGEDIR%
+#endif
+
+#ifndef OCTAVE_INCLUDEDIR
+#define OCTAVE_INCLUDEDIR %OCTAVE_INCLUDEDIR%
+#endif
+
+#ifndef OCTAVE_INFODIR
+#define OCTAVE_INFODIR %OCTAVE_INFODIR%
+#endif
+
+#ifndef OCTAVE_INFOFILE
+#define OCTAVE_INFOFILE %OCTAVE_INFOFILE%
+#endif
+
+#ifndef OCTAVE_LIBDIR
+#define OCTAVE_LIBDIR %OCTAVE_LIBDIR%
+#endif
+
+#ifndef OCTAVE_LIBEXECDIR
+#define OCTAVE_LIBEXECDIR %OCTAVE_LIBEXECDIR%
+#endif
+
+#ifndef OCTAVE_LIBEXECDIR
+#define OCTAVE_LIBEXECDIR %OCTAVE_LIBEXECDIR%
+#endif
+
+#ifndef OCTAVE_LOCALAPIFCNFILEDIR
+#define OCTAVE_LOCALAPIFCNFILEDIR %OCTAVE_LOCALAPIFCNFILEDIR%
+#endif
+
+#ifndef OCTAVE_LOCALAPIOCTFILEDIR
+#define OCTAVE_LOCALAPIOCTFILEDIR %OCTAVE_LOCALAPIOCTFILEDIR%
+#endif
+
+#ifndef OCTAVE_LOCALARCHLIBDIR
+#define OCTAVE_LOCALARCHLIBDIR %OCTAVE_LOCALARCHLIBDIR%
+#endif
+
+#ifndef OCTAVE_LOCALFCNFILEDIR
+#define OCTAVE_LOCALFCNFILEDIR %OCTAVE_LOCALFCNFILEDIR%
+#endif
+
+#ifndef OCTAVE_LOCALOCTFILEDIR
+#define OCTAVE_LOCALOCTFILEDIR %OCTAVE_LOCALOCTFILEDIR%
+#endif
+
+#ifndef OCTAVE_LOCALSTARTUPFILEDIR
+#define OCTAVE_LOCALSTARTUPFILEDIR %OCTAVE_LOCALSTARTUPFILEDIR%
+#endif
+
+#ifndef OCTAVE_LOCALAPIARCHLIBDIR
+#define OCTAVE_LOCALAPIARCHLIBDIR %OCTAVE_LOCALAPIARCHLIBDIR%
+#endif
+
+#ifndef OCTAVE_LOCALVERARCHLIBDIR
+#define OCTAVE_LOCALVERARCHLIBDIR %OCTAVE_LOCALVERARCHLIBDIR%
+#endif
+
+#ifndef OCTAVE_LOCALVERFCNFILEDIR
+#define OCTAVE_LOCALVERFCNFILEDIR %OCTAVE_LOCALVERFCNFILEDIR%
+#endif
+
+#ifndef OCTAVE_LOCALVEROCTFILEDIR
+#define OCTAVE_LOCALVEROCTFILEDIR %OCTAVE_LOCALVEROCTFILEDIR%
+#endif
+
+#ifndef OCTAVE_MAN1DIR
+#define OCTAVE_MAN1DIR %OCTAVE_MAN1DIR%
+#endif
+
+#ifndef OCTAVE_MAN1EXT
+#define OCTAVE_MAN1EXT %OCTAVE_MAN1EXT%
+#endif
+
+#ifndef OCTAVE_MANDIR
+#define OCTAVE_MANDIR %OCTAVE_MANDIR%
+#endif
+
+#ifndef OCTAVE_OCTFILEDIR
+#define OCTAVE_OCTFILEDIR %OCTAVE_OCTFILEDIR%
+#endif
+
+#ifndef OCTAVE_OCTETCDIR
+#define OCTAVE_OCTETCDIR %OCTAVE_OCTETCDIR%
+#endif
+
+#ifndef OCTAVE_OCTINCLUDEDIR
+#define OCTAVE_OCTINCLUDEDIR %OCTAVE_OCTINCLUDEDIR%
+#endif
+
+#ifndef OCTAVE_OCTLIBDIR
+#define OCTAVE_OCTLIBDIR %OCTAVE_OCTLIBDIR%
+#endif
+
+#ifndef OCTAVE_PREFIX
+#define OCTAVE_PREFIX %OCTAVE_PREFIX%
+#endif
+
+#ifndef OCTAVE_STARTUPFILEDIR
+#define OCTAVE_STARTUPFILEDIR %OCTAVE_STARTUPFILEDIR%
+#endif
+
+#ifndef OCTAVE_RELEASE
+#define OCTAVE_RELEASE %OCTAVE_RELEASE%
+#endif
+
+extern std::string Voctave_home;
+
+extern std::string Vbin_dir;
+extern std::string Vinfo_dir;
+extern std::string Vdata_dir;
+extern std::string Vlibexec_dir;
+extern std::string Varch_lib_dir;
+extern std::string Vlocal_arch_lib_dir;
+extern std::string Vlocal_ver_arch_lib_dir;
+
+extern std::string Vlocal_ver_oct_file_dir;
+extern std::string Vlocal_api_oct_file_dir;
+extern std::string Vlocal_oct_file_dir;
+
+extern std::string Vlocal_ver_fcn_file_dir;
+extern std::string Vlocal_api_fcn_file_dir;
+extern std::string Vlocal_fcn_file_dir;
+
+extern std::string Voct_file_dir;
+extern std::string Vfcn_file_dir;
+
+extern std::string Vimage_dir;
+
+// Name of the editor to be invoked by the edit_history command.
+extern std::string VEDITOR;
+
+extern std::string Vlocal_site_defaults_file;
+extern std::string Vsite_defaults_file;
+
+// Name of the FFTW wisdom program.
+extern OCTINTERP_API std::string Vfftw_wisdom_program;
+
+extern std::string subst_octave_home (const std::string&);
+
+extern void install_defaults (void);
+
+extern void set_exec_path (const std::string& path = std::string ());
+extern void set_image_path (const std::string& path = std::string ());
+
+#endif
--- a/src/error.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/error.cc	Mon May 07 00:56:44 2012 +0200
@@ -764,7 +764,7 @@
 
 static std::string
 handle_message (error_fun f, const char *id, const char *msg,
-                const octave_value_list& args)
+                const octave_value_list& args, bool have_fmt)
 {
   std::string retval;
 
@@ -776,7 +776,7 @@
     {
       octave_value arg;
 
-      if (nargin > 1)
+      if (have_fmt)
         {
           octave_value_list tmp = Fsprintf (args, 1);
           arg = tmp(0);
@@ -962,6 +962,57 @@
   return retval;
 }
 
+// Determine whether the first argument to error or warning function
+// should be handled as the message identifier or as the format string.
+
+static bool
+maybe_extract_message_id (const std::string& caller,
+                          const octave_value_list& args,
+                          octave_value_list& nargs,
+                          std::string& id)
+{
+  nargs = args;
+  id = std::string ();
+
+  int nargin = args.length ();
+
+  bool have_fmt = nargin > 1;
+
+  if (nargin > 0)
+    {
+      std::string arg1 = args(0).string_value ();
+
+      if (! error_state)
+        {
+          // For compatibility with Matlab, an identifier must contain
+          // ':', but not at the beginning or the end, and it must not
+          // contain '%' (even if it is not a valid conversion
+          // operator) or whitespace.
+
+          if (arg1.find_first_of ("% \f\n\r\t\v") == std::string::npos
+              && arg1.find (':') != std::string::npos
+              && arg1[0] != ':'
+              && arg1[arg1.length()-1] != ':')
+            {
+              if (nargin > 1)
+                {
+                  id = arg1;
+
+                  nargs.resize (nargin-1);
+
+                  for (int i = 1; i < nargin; i++)
+                    nargs(i-1) = args(i);
+                }
+              else
+                nargs(0) = "call to " + caller
+                  + " with message identifier requires message";
+            }
+        }
+    }
+
+  return have_fmt;
+}
+
 DEFUN (error, args, ,
   "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {} error (@var{template}, @dots{})\n\
@@ -1031,26 +1082,9 @@
     print_usage ();
   else
     {
-      if (nargin > 1)
-        {
-          std::string arg1 = args(0).string_value ();
-
-          if (! error_state)
-            {
-              if (arg1.find ('%') == std::string::npos)
-                {
-                  id = arg1;
+      bool have_fmt = false;
 
-                  nargs.resize (nargin-1);
-
-                  for (int i = 1; i < nargin; i++)
-                    nargs(i-1) = args(i);
-                }
-            }
-          else
-            return retval;
-        }
-      else if (nargin == 1 && args(0).is_map ())
+      if (nargin == 1 && args(0).is_map ())
         {
           // empty struct is not an error.  return and resume calling function.
           if (args(0).is_empty ())
@@ -1084,8 +1118,16 @@
           // structure, but that will require some more significant
           // surgery on handle_message, error_with_id, etc.
         }
+      else
+        {
+          have_fmt = maybe_extract_message_id ("error", args, nargs, id);
 
-      handle_message (error_with_id, id.c_str (), "unspecified error", nargs);
+          if (error_state)
+            return retval;
+        }
+
+      handle_message (error_with_id, id.c_str (), "unspecified error",
+                      nargs, have_fmt);
     }
 
   return retval;
@@ -1399,30 +1441,16 @@
 
       std::string id;
 
-      if (nargin > 1)
-        {
-          std::string arg1 = args(0).string_value ();
-
-          if (! error_state)
-            {
-              if (arg1.find ('%') == std::string::npos)
-                {
-                  id = arg1;
+      bool have_fmt = maybe_extract_message_id ("warning", args, nargs, id);
 
-                  nargs.resize (nargin-1);
-
-                  for (int i = 1; i < nargin; i++)
-                    nargs(i-1) = args(i);
-                }
-            }
-          else
-            return retval;
-        }
+      if (error_state)
+        return retval;
 
       std::string prev_msg = Vlast_warning_message;
 
       std::string curr_msg = handle_message (warning_with_id, id.c_str (),
-                                             "unspecified warning", nargs);
+                                             "unspecified warning", nargs,
+                                             have_fmt);
 
       if (nargout > 0)
         retval = prev_msg;
@@ -1765,7 +1793,7 @@
 @end deftypefn")
 {
   octave_value_list retval;
-  handle_message (usage_with_id, "", "unknown", args);
+  handle_message (usage_with_id, "", "unknown", args, true);
   return retval;
 }
 
--- a/src/graphics.h.in	Mon May 07 00:53:54 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5830 +0,0 @@
-/*
-
-Copyright (C) 2007-2012 John W. Eaton
-
-This file is part of Octave.
-
-Octave is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 3 of the License, or (at your
-option) any later version.
-
-Octave is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with Octave; see the file COPYING.  If not, see
-<http://www.gnu.org/licenses/>.
-
-*/
-
-#if !defined (graphics_h)
-#define graphics_h 1
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <cctype>
-
-#include <algorithm>
-#include <list>
-#include <map>
-#include <set>
-#include <sstream>
-#include <string>
-
-#include "caseless-str.h"
-#include "lo-ieee.h"
-
-#include "gripes.h"
-#include "oct-map.h"
-#include "oct-mutex.h"
-#include "oct-refcount.h"
-#include "ov.h"
-#include "txt-eng-ft.h"
-
-// FIXME -- maybe this should be a configure option?
-// Matlab defaults to "Helvetica", but that causes problems for many
-// gnuplot users.
-#if !defined (OCTAVE_DEFAULT_FONTNAME)
-#define OCTAVE_DEFAULT_FONTNAME "*"
-#endif
-
-// ---------------------------------------------------------------------
-
-class graphics_handle
-{
-public:
-  graphics_handle (void) : val (octave_NaN) { }
-
-  graphics_handle (const octave_value& a);
-
-  graphics_handle (int a) : val (a) { }
-
-  graphics_handle (double a) : val (a) { }
-
-  graphics_handle (const graphics_handle& a) : val (a.val) { }
-
-  graphics_handle& operator = (const graphics_handle& a)
-  {
-    if (&a != this)
-      val = a.val;
-
-    return *this;
-  }
-
-  ~graphics_handle (void) { }
-
-  double value (void) const { return val; }
-
-  octave_value as_octave_value (void) const
-  {
-    return ok () ? octave_value (val) : octave_value (Matrix ());
-  }
-
-  // Prefix increment/decrement operators.
-  graphics_handle& operator ++ (void)
-  {
-    ++val;
-    return *this;
-  }
-
-  graphics_handle& operator -- (void)
-  {
-    --val;
-    return *this;
-  }
-
-  // Postfix increment/decrement operators.
-  const graphics_handle operator ++ (int)
-  {
-    graphics_handle old_value = *this;
-    ++(*this);
-    return old_value;
-  }
-
-  const graphics_handle operator -- (int)
-  {
-    graphics_handle old_value = *this;
-    --(*this);
-    return old_value;
-  }
-
-  bool ok (void) const { return ! xisnan (val); }
-
-private:
-  double val;
-};
-
-inline bool
-operator == (const graphics_handle& a, const graphics_handle& b)
-{
-  return a.value () == b.value ();
-}
-
-inline bool
-operator != (const graphics_handle& a, const graphics_handle& b)
-{
-  return a.value () != b.value ();
-}
-
-inline bool
-operator < (const graphics_handle& a, const graphics_handle& b)
-{
-  return a.value () < b.value ();
-}
-
-inline bool
-operator <= (const graphics_handle& a, const graphics_handle& b)
-{
-  return a.value () <= b.value ();
-}
-
-inline bool
-operator >= (const graphics_handle& a, const graphics_handle& b)
-{
-  return a.value () >= b.value ();
-}
-
-inline bool
-operator > (const graphics_handle& a, const graphics_handle& b)
-{
-  return a.value () > b.value ();
-}
-
-// ---------------------------------------------------------------------
-
-class base_scaler
-{
-public:
-  base_scaler (void) { }
-
-  virtual ~base_scaler (void) { }
-
-  virtual Matrix scale (const Matrix& m) const
-    {
-      error ("invalid axis scale");
-      return m;
-    }
-
-  virtual NDArray scale (const NDArray& m) const
-    {
-      error ("invalid axis scale");
-      return m;
-    }
-
-  virtual double scale (double d) const
-    {
-      error ("invalid axis scale");
-      return d;
-    }
-
-  virtual double unscale (double d) const
-    {
-      error ("invalid axis scale");
-      return d;
-    }
-
-  virtual base_scaler* clone () const
-    { return new base_scaler (); }
-
-  virtual bool is_linear (void) const
-    { return false; }
-};
-
-class lin_scaler : public base_scaler
-{
-public:
-  lin_scaler (void) { }
-
-  Matrix scale (const Matrix& m) const { return m; }
-
-  NDArray scale (const NDArray& m) const { return m; }
-
-  double scale (double d) const { return d; }
-
-  double unscale (double d) const { return d; }
-
-  base_scaler* clone (void) const { return new lin_scaler (); }
-
-  bool is_linear (void) const { return true; }
-};
-
-class log_scaler : public base_scaler
-{
-public:
-  log_scaler (void) { }
-
-  Matrix scale (const Matrix& m) const
-    {
-      Matrix retval (m.rows (), m.cols ());
-
-      do_scale (m.data (), retval.fortran_vec (), m.numel ());
-
-      return retval;
-    }
-
-  NDArray scale (const NDArray& m) const
-    {
-      NDArray retval (m.dims ());
-
-      do_scale (m.data (), retval.fortran_vec (), m.numel ());
-
-      return retval;
-    }
-
-  double scale (double d) const
-    { return log10 (d); }
-
-  double unscale (double d) const
-    { return pow (10.0, d); }
-
-  base_scaler* clone (void) const
-    { return new log_scaler (); }
-
-private:
-  void do_scale (const double *src, double *dest, int n) const
-    {
-      for (int i = 0; i < n; i++)
-        dest[i] = log10 (src[i]);
-    }
-};
-
-class neg_log_scaler : public base_scaler
-{
-public:
-  neg_log_scaler (void) { }
-
-  Matrix scale (const Matrix& m) const
-    {
-      Matrix retval (m.rows (), m.cols ());
-
-      do_scale (m.data (), retval.fortran_vec (), m.numel ());
-
-      return retval;
-    }
-
-  NDArray scale (const NDArray& m) const
-    {
-      NDArray retval (m.dims ());
-
-      do_scale (m.data (), retval.fortran_vec (), m.numel ());
-
-      return retval;
-    }
-
-  double scale (double d) const
-    { return -log10 (-d); }
-
-  double unscale (double d) const
-    { return -pow (10.0, -d); }
-
-  base_scaler* clone (void) const
-    { return new neg_log_scaler (); }
-
-private:
-  void do_scale (const double *src, double *dest, int n) const
-    {
-      for (int i = 0; i < n; i++)
-        dest[i] = -log10 (-src[i]);
-    }
-};
-
-class scaler
-{
-public:
-  scaler (void) : rep (new base_scaler ()) { }
-
-  scaler (const scaler& s) : rep (s.rep->clone()) { }
-
-  scaler (const std::string& s)
-    : rep (s == "log"
-           ? new log_scaler ()
-           : (s == "neglog" ? new neg_log_scaler ()
-              : (s == "linear" ? new lin_scaler () : new base_scaler ())))
-    { }
-
-  ~scaler (void) { delete rep; }
-
-  Matrix scale (const Matrix& m) const
-    { return rep->scale (m); }
-
-  NDArray scale (const NDArray& m) const
-    { return rep->scale (m); }
-
-  double scale (double d) const
-    { return rep->scale (d); }
-
-  double unscale (double d) const
-    { return rep->unscale (d); }
-
-  bool is_linear (void) const
-    { return rep->is_linear (); }
-
-  scaler& operator = (const scaler& s)
-    {
-      if (rep)
-        {
-          delete rep;
-          rep = 0;
-        }
-
-      rep = s.rep->clone ();
-
-      return *this;
-    }
-
-  scaler& operator = (const std::string& s)
-    {
-      if (rep)
-        {
-          delete rep;
-          rep = 0;
-        }
-
-      if (s == "log")
-        rep = new log_scaler ();
-      else if (s == "neglog")
-        rep = new neg_log_scaler ();
-      else if (s == "linear")
-        rep = new lin_scaler ();
-      else
-        rep = new base_scaler ();
-
-      return *this;
-    }
-
-private:
-  base_scaler *rep;
-};
-
-// ---------------------------------------------------------------------
-
-class property;
-
-enum listener_mode { POSTSET, PERSISTENT, PREDELETE };
-
-class base_property
-{
-public:
-  friend class property;
-
-public:
-  base_property (void)
-    : id (-1), count (1), name (), parent (), hidden (), listeners ()
-    { }
-
-  base_property (const std::string& s, const graphics_handle& h)
-    : id (-1), count (1), name (s), parent (h), hidden (false), listeners ()
-    { }
-
-  base_property (const base_property& p)
-    : id (-1), count (1), name (p.name), parent (p.parent),
-      hidden (p.hidden), listeners ()
-    { }
-
-  virtual ~base_property (void) { }
-
-  bool ok (void) const { return parent.ok (); }
-
-  std::string get_name (void) const { return name; }
-
-  void set_name (const std::string& s) { name = s; }
-
-  graphics_handle get_parent (void) const { return parent; }
-
-  void set_parent (const graphics_handle &h) { parent = h; }
-
-  bool is_hidden (void) const { return hidden; }
-
-  void set_hidden (bool flag) { hidden = flag; }
-
-  virtual bool is_radio (void) const { return false; }
-
-  int get_id (void) const { return id; }
-
-  void set_id (int d) { id = d; }
-
-  // Sets property value, notifies graphics toolkit.
-  // If do_run is true, runs associated listeners.
-  OCTINTERP_API bool set (const octave_value& v, bool do_run = true,
-                          bool do_notify_toolkit = true);
-
-  virtual octave_value get (void) const
-    {
-      error ("get: invalid property \"%s\"", name.c_str ());
-      return octave_value ();
-    }
-
-
-  virtual std::string values_as_string (void) const
-    {
-      error ("values_as_string: invalid property \"%s\"", name.c_str ());
-      return std::string ();
-    }
-
-  virtual Cell values_as_cell (void) const
-    {
-      error ("values_as_cell: invalid property \"%s\"", name.c_str ());
-      return Cell ();
-    }
-
-  base_property& operator = (const octave_value& val)
-    {
-      set (val);
-      return *this;
-    }
-
-  void add_listener (const octave_value& v, listener_mode mode = POSTSET)
-    {
-      octave_value_list& l = listeners[mode];
-      l.resize (l.length () + 1, v);
-    }
-
-  void delete_listener (const octave_value& v = octave_value (),
-                        listener_mode mode = POSTSET)
-    {
-      octave_value_list& l = listeners[mode];
-
-      if (v.is_defined ())
-        {
-          bool found = false;
-          int i;
-
-          for (i = 0; i < l.length (); i++)
-            {
-              if (v.internal_rep () == l(i).internal_rep ())
-                {
-                  found = true;
-                  break;
-                }
-            }
-          if (found)
-            {
-              for (int j = i; j < l.length() - 1; j++)
-                l(j) = l (j + 1);
-
-              l.resize (l.length () - 1);
-            }
-        }
-      else
-        {
-          if (mode == PERSISTENT)
-            l.resize (0);
-          else
-            {
-              octave_value_list lnew (0);
-              octave_value_list& lp = listeners[PERSISTENT];
-              for (int i = l.length () - 1; i >= 0 ; i--)
-                {
-                  for (int j = 0; j < lp.length (); j++)
-                    {
-                      if (l(i).internal_rep () == lp(j).internal_rep ())
-                        {
-                          lnew.resize (lnew.length () + 1, l(i));
-                          break;
-                        }
-                    }
-                }
-              l = lnew;
-            }
-        }
-
-    }
-
-  OCTINTERP_API void run_listeners (listener_mode mode = POSTSET);
-
-  virtual base_property* clone (void) const
-    { return new base_property (*this); }
-
-protected:
-  virtual bool do_set (const octave_value&)
-    {
-      error ("set: invalid property \"%s\"", name.c_str ());
-      return false;
-    }
-
-private:
-  typedef std::map<listener_mode, octave_value_list> listener_map;
-  typedef std::map<listener_mode, octave_value_list>::iterator listener_map_iterator;
-  typedef std::map<listener_mode, octave_value_list>::const_iterator listener_map_const_iterator;
-
-private:
-  int id;
-  octave_refcount<int> count;
-  std::string name;
-  graphics_handle parent;
-  bool hidden;
-  listener_map listeners;
-};
-
-// ---------------------------------------------------------------------
-
-class string_property : public base_property
-{
-public:
-  string_property (const std::string& s, const graphics_handle& h,
-                   const std::string& val = "")
-    : base_property (s, h), str (val) { }
-
-  string_property (const string_property& p)
-    : base_property (p), str (p.str) { }
-
-  octave_value get (void) const
-    { return octave_value (str); }
-
-  std::string string_value (void) const { return str; }
-
-  string_property& operator = (const octave_value& val)
-    {
-      set (val);
-      return *this;
-    }
-
-  base_property* clone (void) const { return new string_property (*this); }
-
-protected:
-  bool do_set (const octave_value& val)
-    {
-      if (val.is_string ())
-        {
-          std::string new_str = val.string_value ();
-
-          if (new_str != str)
-            {
-              str = new_str;
-              return true;
-            }
-        }
-      else
-        error ("set: invalid string property value for \"%s\"",
-               get_name ().c_str ());
-      return false;
-    }
-
-private:
-  std::string str;
-};
-
-// ---------------------------------------------------------------------
-
-class string_array_property : public base_property
-{
-public:
-  enum desired_enum { string_t, cell_t };
-
-  string_array_property (const std::string& s, const graphics_handle& h,
-                  const std::string& val = "", const char& sep = '|',
-                  const desired_enum& typ = string_t)
-    : base_property (s, h), desired_type (typ), separator (sep), str ()
-    {
-      size_t pos = 0;
-
-      while (true)
-        {
-          size_t new_pos = val.find_first_of (separator, pos);
-
-          if (new_pos == std::string::npos)
-            {
-              str.append (val.substr (pos));
-              break;
-            }
-          else
-            str.append (val.substr (pos, new_pos - pos));
-
-          pos = new_pos + 1;
-        }
-    }
-
-  string_array_property (const std::string& s, const graphics_handle& h,
-                  const Cell& c, const char& sep = '|',
-                  const desired_enum& typ = string_t)
-    : base_property (s, h), desired_type (typ), separator (sep), str ()
-    {
-      if (c.is_cellstr ())
-        {
-          string_vector strings (c.numel ());
-
-          for (octave_idx_type i = 0; i < c.numel (); i++)
-            strings[i] = c(i).string_value ();
-
-          str = strings;
-        }
-      else
-        error ("set: invalid order property value for \"%s\"",
-               get_name ().c_str ());
-    }
-
-  string_array_property (const string_array_property& p)
-    : base_property (p), desired_type (p.desired_type),
-      separator (p.separator), str (p.str) { }
-
-  octave_value get (void) const
-    {
-      if (desired_type == string_t)
-        return octave_value (string_value ());
-      else
-        return octave_value (cell_value ());
-    }
-
-  std::string string_value (void) const
-    {
-      std::string s;
-
-      for (octave_idx_type i = 0; i < str.length (); i++)
-        {
-          s += str[i];
-          if (i != str.length () - 1)
-            s += separator;
-        }
-
-      return s;
-    }
-
-  Cell cell_value (void) const {return Cell (str);}
-
-  string_vector string_vector_value (void) const { return str; }
-
-  string_array_property& operator = (const octave_value& val)
-    {
-      set (val);
-      return *this;
-    }
-
-  base_property* clone (void) const { return new string_array_property (*this); }
-
-protected:
-  bool do_set (const octave_value& val)
-    {
-      if (val.is_string ())
-        {
-          bool replace = false;
-          std::string new_str = val.string_value ();
-          string_vector strings;
-          size_t pos = 0;
-
-          while (pos != std::string::npos)
-            {
-              size_t new_pos = new_str.find_first_of (separator, pos);
-
-              if (new_pos == std::string::npos)
-                {
-                  strings.append (new_str.substr (pos));
-                  break;
-                }
-              else
-                strings.append (new_str.substr (pos, new_pos - pos));
-
-              pos = new_pos + 1;
-            }
-
-          if (str.numel () == strings.numel ())
-            {
-              for (octave_idx_type i = 0; i < str.numel (); i++)
-                if (strings[i] != str[i])
-                  {
-                    replace = true;
-                    break;
-                  }
-            }
-          else
-            replace = true;
-
-          desired_type = string_t;
-
-          if (replace)
-            {
-              str = strings;
-              return true;
-            }
-        }
-      else if (val.is_cellstr ())
-        {
-          bool replace = false;
-          Cell new_cell = val.cell_value ();
-
-          string_vector strings = new_cell.cellstr_value ();
-
-          octave_idx_type nel = strings.length ();
-
-          if (nel != str.length ())
-            replace = true;
-          else
-            {
-              for (octave_idx_type i = 0; i < nel; i++)
-                {
-                  if (strings[i] != str[i])
-                    {
-                      replace = true;
-                      break;
-                    }
-                }
-            }
-
-          desired_type = cell_t;
-
-          if (replace)
-            {
-              str = strings;
-              return true;
-            }
-        }
-      else
-        error ("set: invalid string property value for \"%s\"",
-               get_name ().c_str ());
-      return false;
-    }
-
-private:
-  desired_enum desired_type;
-  char separator;
-  string_vector str;
-};
-
-// ---------------------------------------------------------------------
-
-class text_label_property : public base_property
-{
-public:
-  enum type { char_t, cellstr_t };
-
-  text_label_property (const std::string& s, const graphics_handle& h,
-                       const std::string& val = "")
-    : base_property (s, h), value (val), stored_type (char_t)
-  { }
-
-  text_label_property (const std::string& s, const graphics_handle& h,
-                       const NDArray& nda)
-    : base_property (s, h), stored_type (char_t)
-  {
-    octave_idx_type nel = nda.numel ();
-
-    value.resize (nel);
-
-    for (octave_idx_type i = 0; i < nel; i++)
-      {
-        std::ostringstream buf;
-        buf << nda(i);
-        value[i] = buf.str ();
-      }
-  }
-
-  text_label_property (const std::string& s, const graphics_handle& h,
-                       const Cell& c)
-    : base_property (s, h), stored_type (cellstr_t)
-  {
-    octave_idx_type nel = c.numel ();
-
-    value.resize (nel);
-
-    for (octave_idx_type i = 0; i < nel; i++)
-      {
-        octave_value tmp = c(i);
-
-        if (tmp.is_string ())
-          value[i] = c(i).string_value ();
-        else
-          {
-            double d = c(i).double_value ();
-
-            if (! error_state)
-              {
-                std::ostringstream buf;
-                buf << d;
-                value[i] = buf.str ();
-              }
-            else
-              break;
-          }
-      }
-  }
-
-  text_label_property (const text_label_property& p)
-    : base_property (p), value (p.value), stored_type (p.stored_type)
-  { }
-
-  bool empty (void) const
-  {
-    octave_value tmp = get ();
-    return tmp.is_empty ();
-  }
-
-  octave_value get (void) const
-  {
-    if (stored_type == char_t)
-      return octave_value (char_value ());
-    else
-      return octave_value (cell_value ());
-  }
-
-  std::string string_value (void) const
-  {
-    return value.empty () ? std::string () : value[0];
-  }
-
-  string_vector string_vector_value (void) const { return value; }
-
-  charMatrix char_value (void) const { return charMatrix (value, ' '); }
-
-  Cell cell_value (void) const {return Cell (value); }
-
-  text_label_property& operator = (const octave_value& val)
-  {
-    set (val);
-    return *this;
-  }
-
-  base_property* clone (void) const { return new text_label_property (*this); }
-
-protected:
-
-  bool do_set (const octave_value& val)
-  {
-    if (val.is_string ())
-      {
-        value = val.all_strings ();
-
-        stored_type = char_t;
-      }
-    else if (val.is_cell ())
-      {
-        Cell c = val.cell_value ();
-
-        octave_idx_type nel = c.numel ();
-
-        value.resize (nel);
-
-        for (octave_idx_type i = 0; i < nel; i++)
-          {
-            octave_value tmp = c(i);
-
-            if (tmp.is_string ())
-              value[i] = c(i).string_value ();
-            else
-              {
-                double d = c(i).double_value ();
-
-                if (! error_state)
-                  {
-                    std::ostringstream buf;
-                    buf << d;
-                    value[i] = buf.str ();
-                  }
-                else
-                  return false;
-              }
-          }
-
-        stored_type = cellstr_t;
-      }
-    else
-      {
-        NDArray nda = val.array_value ();
-
-        if (! error_state)
-          {
-            octave_idx_type nel = nda.numel ();
-
-            value.resize (nel);
-
-            for (octave_idx_type i = 0; i < nel; i++)
-              {
-                std::ostringstream buf;
-                buf << nda(i);
-                value[i] = buf.str ();
-              }
-
-            stored_type = char_t;
-          }
-        else
-          {
-            error ("set: invalid string property value for \"%s\"",
-                   get_name ().c_str ());
-
-            return false;
-          }
-      }
-
-    return true;
-  }
-
-private:
-  string_vector value;
-  type stored_type;
-};
-
-// ---------------------------------------------------------------------
-
-class radio_values
-{
-public:
-  OCTINTERP_API radio_values (const std::string& opt_string = std::string ());
-
-  radio_values (const radio_values& a)
-    : default_val (a.default_val), possible_vals (a.possible_vals) { }
-
-  radio_values& operator = (const radio_values& a)
-  {
-    if (&a != this)
-      {
-        default_val = a.default_val;
-        possible_vals = a.possible_vals;
-      }
-
-    return *this;
-  }
-
-  std::string default_value (void) const { return default_val; }
-
-  bool validate (const std::string& val, std::string& match)
-  {
-    bool retval = true;
-
-    if (! contains (val, match))
-      {
-        error ("invalid value = %s", val.c_str ());
-        retval = false;
-      }
-
-    return retval;
-  }
-
-  bool contains (const std::string& val, std::string& match)
-  {
-    size_t k = 0;
-
-    size_t len = val.length ();
-
-    std::string first_match;
-
-    for (std::set<caseless_str>::const_iterator p = possible_vals.begin ();
-         p != possible_vals.end (); p++)
-      {
-        if (p->compare (val, len))
-          {
-            if (len == p->length ())
-              {
-                // We found a full match (consider the case of val ==
-                // "replace" with possible values "replace" and
-                // "replacechildren").  Any other matches are
-                // irrelevant, so set match and return now.
-
-                match = *p;
-                return true;
-              }
-            else
-              {
-                if (k == 0)
-                  first_match = *p;
-
-                k++;
-              }
-          }
-      }
-
-    if (k == 1)
-      {
-        match = first_match;
-        return true;
-      }
-    else
-      return false;
-  }
-
-  std::string values_as_string (void) const;
-
-  Cell values_as_cell (void) const;
-
-  octave_idx_type nelem (void) const { return possible_vals.size (); }
-
-private:
-  // Might also want to cache
-  std::string default_val;
-  std::set<caseless_str> possible_vals;
-};
-
-class radio_property : public base_property
-{
-public:
-  radio_property (const std::string& nm, const graphics_handle& h,
-                  const radio_values& v = radio_values ())
-    : base_property (nm, h),
-      vals (v), current_val (v.default_value ()) { }
-
-  radio_property (const std::string& nm, const graphics_handle& h,
-                  const std::string& v)
-    : base_property (nm, h),
-      vals (v), current_val (vals.default_value ()) { }
-
-  radio_property (const std::string& nm, const graphics_handle& h,
-                  const radio_values& v, const std::string& def)
-    : base_property (nm, h),
-      vals (v), current_val (def) { }
-
-  radio_property (const radio_property& p)
-    : base_property (p), vals (p.vals), current_val (p.current_val) { }
-
-  octave_value get (void) const { return octave_value (current_val); }
-
-  const std::string& current_value (void) const { return current_val; }
-
-  std::string values_as_string (void) const { return vals.values_as_string (); }
-
-  Cell values_as_cell (void) const { return vals.values_as_cell (); }
-
-  bool is (const caseless_str& v) const
-    { return v.compare (current_val); }
-
-  bool is_radio (void) const { return true; }
-
-  radio_property& operator = (const octave_value& val)
-    {
-      set (val);
-      return *this;
-    }
-
-  base_property* clone (void) const { return new radio_property (*this); }
-
-protected:
-  bool do_set (const octave_value& newval)
-  {
-    if (newval.is_string ())
-      {
-        std::string s = newval.string_value ();
-
-        std::string match;
-
-        if (vals.validate (s, match))
-          {
-            if (match != current_val)
-              {
-                if (s.length () != match.length ())
-                  warning_with_id ("Octave:abbreviated-property-match",
-                                   "%s: allowing %s to match %s value %s",
-                                   "set", s.c_str (), get_name ().c_str (),
-                                   match.c_str ());
-                current_val = match;
-                return true;
-              }
-          }
-        else
-          error ("set: invalid value for radio property \"%s\" (value = %s)",
-              get_name ().c_str (), s.c_str ());
-      }
-    else
-      error ("set: invalid value for radio property \"%s\"",
-          get_name ().c_str ());
-    return false;
-  }
-
-private:
-  radio_values vals;
-  std::string current_val;
-};
-
-// ---------------------------------------------------------------------
-
-class color_values
-{
-public:
-  color_values (double r = 0, double g = 0, double b = 1)
-    : xrgb (1, 3)
-  {
-    xrgb(0) = r;
-    xrgb(1) = g;
-    xrgb(2) = b;
-
-    validate ();
-  }
-
-  color_values (std::string str)
-    : xrgb (1, 3)
-  {
-    if (! str2rgb (str))
-      error ("invalid color specification: %s", str.c_str ());
-  }
-
-  color_values (const color_values& c)
-    : xrgb (c.xrgb)
-  { }
-
-  color_values& operator = (const color_values& c)
-  {
-    if (&c != this)
-      xrgb = c.xrgb;
-
-    return *this;
-  }
-
-  bool operator == (const color_values& c) const
-    {
-      return (xrgb(0) == c.xrgb(0)
-              && xrgb(1) == c.xrgb(1)
-              && xrgb(2) == c.xrgb(2));
-    }
-
-  bool operator != (const color_values& c) const
-    { return ! (*this == c); }
-
-  Matrix rgb (void) const { return xrgb; }
-
-  operator octave_value (void) const { return xrgb; }
-
-  void validate (void) const
-  {
-    for (int i = 0; i < 3; i++)
-      {
-        if (xrgb(i) < 0 ||  xrgb(i) > 1)
-          {
-            error ("invalid RGB color specification");
-            break;
-          }
-      }
-  }
-
-private:
-  Matrix xrgb;
-
-  OCTINTERP_API bool str2rgb (std::string str);
-};
-
-class color_property : public base_property
-{
-public:
-  color_property (const color_values& c, const radio_values& v)
-    : base_property ("", graphics_handle ()),
-      current_type (color_t), color_val (c), radio_val (v),
-      current_val (v.default_value ())
-  { }
-
-  color_property (const std::string& nm, const graphics_handle& h,
-                  const color_values& c = color_values (),
-                  const radio_values& v = radio_values ())
-    : base_property (nm, h),
-      current_type (color_t), color_val (c), radio_val (v),
-      current_val (v.default_value ())
-  { }
-
-  color_property (const std::string& nm, const graphics_handle& h,
-                  const radio_values& v)
-    : base_property (nm, h),
-      current_type (radio_t), color_val (color_values ()), radio_val (v),
-      current_val (v.default_value ())
-  { }
-
-  color_property (const std::string& nm, const graphics_handle& h,
-                  const std::string& v)
-    : base_property (nm, h),
-      current_type (radio_t), color_val (color_values ()), radio_val (v),
-      current_val (radio_val.default_value ())
-  { }
-
-  color_property (const std::string& nm, const graphics_handle& h,
-                  const color_property& v)
-    : base_property (nm, h),
-      current_type (v.current_type), color_val (v.color_val),
-      radio_val (v.radio_val), current_val (v.current_val)
-  { }
-
-  color_property (const color_property& p)
-    : base_property (p), current_type (p.current_type),
-      color_val (p.color_val), radio_val (p.radio_val),
-      current_val (p.current_val) { }
-
-  octave_value get (void) const
-  {
-    if (current_type == color_t)
-      return color_val.rgb ();
-
-    return current_val;
-  }
-
-  bool is_rgb (void) const { return (current_type == color_t); }
-
-  bool is_radio (void) const { return (current_type == radio_t); }
-
-  bool is (const std::string& v) const
-    { return (is_radio () && current_val == v); }
-
-  Matrix rgb (void) const
-  {
-    if (current_type != color_t)
-      error ("color has no rgb value");
-
-    return color_val.rgb ();
-  }
-
-  const std::string& current_value (void) const
-  {
-    if (current_type != radio_t)
-      error ("color has no radio value");
-
-    return current_val;
-  }
-
-  color_property& operator = (const octave_value& val)
-    {
-      set (val);
-      return *this;
-    }
-
-  operator octave_value (void) const { return get (); }
-
-  base_property* clone (void) const { return new color_property (*this); }
-
-  std::string values_as_string (void) const { return radio_val.values_as_string (); }
-
-  Cell values_as_cell (void) const { return radio_val.values_as_cell (); }
-
-protected:
-  OCTINTERP_API bool do_set (const octave_value& newval);
-
-private:
-  enum current_enum { color_t, radio_t } current_type;
-  color_values color_val;
-  radio_values radio_val;
-  std::string current_val;
-};
-
-// ---------------------------------------------------------------------
-
-class double_property : public base_property
-{
-public:
-  double_property (const std::string& nm, const graphics_handle& h,
-                   double d = 0)
-    : base_property (nm, h),
-      current_val (d) { }
-
-  double_property (const double_property& p)
-    : base_property (p), current_val (p.current_val) { }
-
-  octave_value get (void) const { return octave_value (current_val); }
-
-  double double_value (void) const { return current_val; }
-
-  double_property& operator = (const octave_value& val)
-    {
-      set (val);
-      return *this;
-    }
-
-  base_property* clone (void) const { return new double_property (*this); }
-
-protected:
-  bool do_set (const octave_value& v)
-    {
-      if (v.is_scalar_type () && v.is_real_type ())
-        {
-          double new_val = v.double_value ();
-
-          if (new_val != current_val)
-            {
-              current_val = new_val;
-              return true;
-            }
-        }
-      else
-        error ("set: invalid value for double property \"%s\"",
-               get_name ().c_str ());
-      return false;
-    }
-
-private:
-  double current_val;
-};
-
-// ---------------------------------------------------------------------
-
-class double_radio_property : public base_property
-{
-public:
-  double_radio_property (double d, const radio_values& v)
-      : base_property ("", graphics_handle ()),
-        current_type (double_t), dval (d), radio_val (v),
-        current_val (v.default_value ())
-  { }
-
-  double_radio_property (const std::string& nm, const graphics_handle& h,
-                         const std::string& v)
-      : base_property (nm, h),
-        current_type (radio_t), dval (0), radio_val (v),
-        current_val (radio_val.default_value ())
-  { }
-
-  double_radio_property (const std::string& nm, const graphics_handle& h,
-                         const double_radio_property& v)
-      : base_property (nm, h),
-        current_type (v.current_type), dval (v.dval),
-        radio_val (v.radio_val), current_val (v.current_val)
-  { }
-
-  double_radio_property (const double_radio_property& p)
-    : base_property (p), current_type (p.current_type),
-      dval (p.dval), radio_val (p.radio_val),
-      current_val (p.current_val) { }
-
-  octave_value get (void) const
-  {
-    if (current_type == double_t)
-      return dval;
-
-    return current_val;
-  }
-
-  bool is_double (void) const { return (current_type == double_t); }
-
-  bool is_radio (void) const { return (current_type == radio_t); }
-
-  bool is (const std::string& v) const
-    { return (is_radio () && current_val == v); }
-
-  double double_value (void) const
-  {
-    if (current_type != double_t)
-      error ("%s: property has no double", get_name ().c_str ());
-
-    return dval;
-  }
-
-  const std::string& current_value (void) const
-  {
-    if (current_type != radio_t)
-      error ("%s: property has no radio value");
-
-    return current_val;
-  }
-
-  double_radio_property& operator = (const octave_value& val)
-    {
-      set (val);
-      return *this;
-    }
-
-  operator octave_value (void) const { return get (); }
-
-  base_property* clone (void) const
-    { return new double_radio_property (*this); }
-
-protected:
-  OCTINTERP_API bool do_set (const octave_value& v);
-
-private:
-  enum current_enum { double_t, radio_t } current_type;
-  double dval;
-  radio_values radio_val;
-  std::string current_val;
-};
-
-// ---------------------------------------------------------------------
-
-class array_property : public base_property
-{
-public:
-  array_property (void)
-    : base_property ("", graphics_handle ()), data (Matrix ()),
-      xmin (), xmax (), xminp (), xmaxp (),
-      type_constraints (), size_constraints ()
-    {
-      get_data_limits ();
-    }
-
-  array_property (const std::string& nm, const graphics_handle& h,
-                  const octave_value& m)
-    : base_property (nm, h), data (m),
-      xmin (), xmax (), xminp (), xmaxp (),
-      type_constraints (), size_constraints ()
-    {
-      get_data_limits ();
-    }
-
-  // This copy constructor is only intended to be used
-  // internally to access min/max values; no need to
-  // copy constraints.
-  array_property (const array_property& p)
-    : base_property (p), data (p.data),
-      xmin (p.xmin), xmax (p.xmax), xminp (p.xminp), xmaxp (p.xmaxp),
-      type_constraints (), size_constraints ()
-    { }
-
-  octave_value get (void) const { return data; }
-
-  void add_constraint (const std::string& type)
-    { type_constraints.push_back (type); }
-
-  void add_constraint (const dim_vector& dims)
-    { size_constraints.push_back (dims); }
-
-  double min_val (void) const { return xmin; }
-  double max_val (void) const { return xmax; }
-  double min_pos (void) const { return xminp; }
-  double max_neg (void) const { return xmaxp; }
-
-  Matrix get_limits (void) const
-    {
-      Matrix m (1, 4);
-
-      m(0) = min_val ();
-      m(1) = max_val ();
-      m(2) = min_pos ();
-      m(3) = max_neg ();
-
-      return m;
-    }
-
-  array_property& operator = (const octave_value& val)
-    {
-      set (val);
-      return *this;
-    }
-
-  base_property* clone (void) const
-    {
-      array_property *p = new array_property (*this);
-
-      p->type_constraints = type_constraints;
-      p->size_constraints = size_constraints;
-
-      return p;
-    }
-
-protected:
-  bool do_set (const octave_value& v)
-    {
-      if (validate (v))
-        {
-          // FIXME -- should we check for actual data change?
-          if (! is_equal (v))
-            {
-              data = v;
-
-              get_data_limits ();
-
-              return true;
-            }
-        }
-      else
-        error ("invalid value for array property \"%s\"",
-               get_name ().c_str ());
-
-      return false;
-    }
-
-private:
-  OCTINTERP_API bool validate (const octave_value& v);
-
-  OCTINTERP_API bool is_equal (const octave_value& v) const;
-
-  OCTINTERP_API void get_data_limits (void);
-
-protected:
-  octave_value data;
-  double xmin;
-  double xmax;
-  double xminp;
-  double xmaxp;
-  std::list<std::string> type_constraints;
-  std::list<dim_vector> size_constraints;
-};
-
-class row_vector_property : public array_property
-{
-public:
-  row_vector_property (const std::string& nm, const graphics_handle& h,
-                       const octave_value& m)
-    : array_property (nm, h, m)
-  {
-    add_constraint (dim_vector (-1, 1));
-    add_constraint (dim_vector (1, -1));
-  }
-
-  row_vector_property (const row_vector_property& p)
-    : array_property (p)
-  {
-    add_constraint (dim_vector (-1, 1));
-    add_constraint (dim_vector (1, -1));
-  }
-
-  void add_constraint (const std::string& type)
-  {
-    array_property::add_constraint (type);
-  }
-
-  void add_constraint (const dim_vector& dims)
-  {
-    array_property::add_constraint (dims);
-  }
-
-  void add_constraint (octave_idx_type len)
-  {
-    size_constraints.remove (dim_vector (1, -1));
-    size_constraints.remove (dim_vector (-1, 1));
-
-    add_constraint (dim_vector (1, len));
-    add_constraint (dim_vector (len, 1));
-  }
-
-  row_vector_property& operator = (const octave_value& val)
-  {
-    set (val);
-    return *this;
-  }
-
-  base_property* clone (void) const
-    {
-      row_vector_property *p = new row_vector_property (*this);
-
-      p->type_constraints = type_constraints;
-      p->size_constraints = size_constraints;
-
-      return p;
-    }
-
-protected:
-  bool do_set (const octave_value& v)
-  {
-    bool retval = array_property::do_set (v);
-
-    if (! error_state)
-      {
-        dim_vector dv = data.dims ();
-
-        if (dv(0) > 1 && dv(1) == 1)
-          {
-            int tmp = dv(0);
-            dv(0) = dv(1);
-            dv(1) = tmp;
-
-            data = data.reshape (dv);
-          }
-
-        return retval;
-      }
-
-    return false;
-  }
-
-private:
-  OCTINTERP_API bool validate (const octave_value& v);
-};
-
-// ---------------------------------------------------------------------
-
-class bool_property : public radio_property
-{
-public:
-  bool_property (const std::string& nm, const graphics_handle& h,
-                 bool val)
-    : radio_property (nm, h, radio_values (val ? "{on}|off" : "on|{off}"))
-    { }
-
-  bool_property (const std::string& nm, const graphics_handle& h,
-                 const char* val)
-    : radio_property (nm, h, radio_values ("on|off"), val)
-    { }
-
-  bool_property (const bool_property& p)
-    : radio_property (p) { }
-
-  bool is_on (void) const { return is ("on"); }
-
-  bool_property& operator = (const octave_value& val)
-    {
-      set (val);
-      return *this;
-    }
-
-  base_property* clone (void) const { return new bool_property (*this); }
-
-protected:
-  bool do_set (const octave_value& val)
-    {
-      if (val.is_bool_scalar ())
-        return radio_property::do_set (val.bool_value () ? "on" : "off");
-      else
-        return radio_property::do_set (val);
-    }
-};
-
-// ---------------------------------------------------------------------
-
-class handle_property : public base_property
-{
-public:
-  handle_property (const std::string& nm, const graphics_handle& h,
-                   const graphics_handle& val = graphics_handle ())
-    : base_property (nm, h),
-      current_val (val) { }
-
-  handle_property (const handle_property& p)
-    : base_property (p), current_val (p.current_val) { }
-
-  octave_value get (void) const { return current_val.as_octave_value (); }
-
-  graphics_handle handle_value (void) const { return current_val; }
-
-  handle_property& operator = (const octave_value& val)
-    {
-      set (val);
-      return *this;
-    }
-
-  handle_property& operator = (const graphics_handle& h)
-    {
-      set (octave_value (h.value ()));
-      return *this;
-    }
-
-  base_property* clone (void) const { return new handle_property (*this); }
-
-protected:
-  OCTINTERP_API bool do_set (const octave_value& v);
-
-private:
-  graphics_handle current_val;
-};
-
-// ---------------------------------------------------------------------
-
-class any_property : public base_property
-{
-public:
-  any_property (const std::string& nm, const graphics_handle& h,
-                  const octave_value& m = Matrix ())
-    : base_property (nm, h), data (m) { }
-
-  any_property (const any_property& p)
-    : base_property (p), data (p.data) { }
-
-  octave_value get (void) const { return data; }
-
-  any_property& operator = (const octave_value& val)
-    {
-      set (val);
-      return *this;
-    }
-
-  base_property* clone (void) const { return new any_property (*this); }
-
-protected:
-  bool do_set (const octave_value& v)
-    {
-      data = v;
-      return true;
-    }
-
-private:
-  octave_value data;
-};
-
-// ---------------------------------------------------------------------
-
-class children_property : public base_property
-{
-public:
-  children_property (void)
-    : base_property ("", graphics_handle ()), children_list ()
-    {
-      do_init_children (Matrix ());
-    }
-
-  children_property (const std::string& nm, const graphics_handle& h,
-                     const Matrix &val)
-    : base_property (nm, h), children_list ()
-    {
-      do_init_children (val);
-    }
-
-  children_property (const children_property& p)
-    : base_property (p), children_list ()
-    {
-      do_init_children (p.children_list);
-    }
-
-  children_property& operator = (const octave_value& val)
-    {
-      set (val);
-      return *this;
-    }
-
-  base_property* clone (void) const { return new children_property (*this); }
-
-  bool remove_child (const double &val)
-    {
-      return do_remove_child (val);
-    }
-
-  void adopt (const double &val)
-    {
-      do_adopt_child (val);
-    }
-
-  Matrix get_children (void) const
-    {
-      return do_get_children (false);
-    }
-
-  Matrix get_hidden (void) const
-    {
-      return do_get_children (true);
-    }
-
-  Matrix get_all (void) const
-   {
-     return do_get_all_children ();
-   }
-
-  octave_value get (void) const
-    {
-      return octave_value (get_children ());
-    }
-
-  void delete_children (bool clear = false)
-    {
-      do_delete_children (clear);
-    }
-
-  void renumber (graphics_handle old_gh, graphics_handle new_gh)
-    {
-      for (children_list_iterator p = children_list.begin ();
-           p != children_list.end (); p++)
-        {
-          if (*p == old_gh)
-            {
-              *p = new_gh.value ();
-              return;
-            }
-        }
-
-      error ("children_list::renumber: child not found!");
-    }
-
-private:
-  typedef std::list<double>::iterator children_list_iterator;
-  typedef std::list<double>::const_iterator const_children_list_iterator;
-  std::list<double> children_list;
-
-protected:
-  bool do_set (const octave_value& val)
-    {
-      const Matrix new_kids = val.matrix_value ();
-
-      octave_idx_type nel = new_kids.numel ();
-
-      const Matrix new_kids_column = new_kids.reshape (dim_vector (nel, 1));
-
-      bool is_ok = true;
-
-      if (! error_state)
-        {
-          const Matrix visible_kids = do_get_children (false);
-
-          if (visible_kids.numel () == new_kids.numel ())
-            {
-              Matrix t1 = visible_kids.sort ();
-              Matrix t2 = new_kids_column.sort ();
-
-              if (t1 != t2)
-                is_ok = false;
-            }
-          else
-            is_ok = false;
-
-          if (! is_ok)
-            error ("set: new children must be a permutation of existing children");
-        }
-      else
-        {
-          is_ok = false;
-          error ("set: expecting children to be array of graphics handles");
-        }
-
-      if (is_ok)
-        {
-          Matrix tmp = new_kids_column.stack (get_hidden ());
-
-          children_list.clear ();
-
-          // Don't use do_init_children here, as that reverses the
-          // order of the list, and we don't want to do that if setting
-          // the child list directly.
-
-          for (octave_idx_type i = 0; i < tmp.numel (); i++)
-            children_list.push_back (tmp.xelem (i));
-        }
-
-      return is_ok;
-    }
-
-private:
-  void do_init_children (const Matrix &val)
-    {
-      children_list.clear ();
-      for (octave_idx_type i = 0; i < val.numel (); i++)
-        children_list.push_front (val.xelem (i));
-    }
-
-  void do_init_children (const std::list<double> &val)
-    {
-      children_list.clear ();
-      for (const_children_list_iterator p = val.begin (); p != val.end (); p++)
-        children_list.push_front (*p);
-    }
-
-  Matrix do_get_children (bool return_hidden) const;
-
-  Matrix do_get_all_children (void) const
-    {
-      Matrix retval (children_list.size (), 1);
-      octave_idx_type i  = 0;
-
-      for (const_children_list_iterator p = children_list.begin ();
-           p != children_list.end (); p++)
-        retval(i++) = *p;
-      return retval;
-    }
-
-  bool do_remove_child (double child)
-    {
-      for (children_list_iterator p = children_list.begin ();
-           p != children_list.end (); p++)
-        {
-          if (*p == child)
-            {
-              children_list.erase (p);
-              return true;
-            }
-        }
-      return false;
-    }
-
-  void do_adopt_child (const double &val)
-    {
-      children_list.push_front (val);
-    }
-
-  void do_delete_children (bool clear);
-};
-
-
-
-// ---------------------------------------------------------------------
-
-class callback_property : public base_property
-{
-public:
-  callback_property (const std::string& nm, const graphics_handle& h,
-                     const octave_value& m)
-    : base_property (nm, h), callback (m), executing (false) { }
-
-  callback_property (const callback_property& p)
-    : base_property (p), callback (p.callback), executing (false) { }
-
-  octave_value get (void) const { return callback; }
-
-  OCTINTERP_API void execute (const octave_value& data = octave_value ()) const;
-
-  bool is_defined (void) const
-    {
-      return (callback.is_defined () && ! callback.is_empty ());
-    }
-
-  callback_property& operator = (const octave_value& val)
-    {
-      set (val);
-      return *this;
-    }
-
-  base_property* clone (void) const { return new callback_property (*this); }
-
-protected:
-  bool do_set (const octave_value& v)
-    {
-      if (validate (v))
-        {
-          callback = v;
-          return true;
-        }
-      else
-        error ("invalid value for callback property \"%s\"",
-               get_name ().c_str ());
-      return false;
-    }
-
-private:
-  OCTINTERP_API bool validate (const octave_value& v) const;
-
-private:
-  octave_value callback;
-
-  // If TRUE, we are executing this callback.
-  mutable bool executing;
-};
-
-// ---------------------------------------------------------------------
-
-class property
-{
-public:
-  property (void) : rep (new base_property ("", graphics_handle ()))
-    { }
-
-  property (base_property *bp, bool persist = false) : rep (bp)
-    { if (persist) rep->count++; }
-
-  property (const property& p) : rep (p.rep)
-    {
-      rep->count++;
-    }
-
-  ~property (void)
-    {
-      if (--rep->count == 0)
-        delete rep;
-    }
-
-  bool ok (void) const
-    { return rep->ok (); }
-
-  std::string get_name (void) const
-    { return rep->get_name (); }
-
-  void set_name (const std::string& name)
-    { rep->set_name (name); }
-
-  graphics_handle get_parent (void) const
-    { return rep->get_parent (); }
-
-  void set_parent (const graphics_handle& h)
-    { rep->set_parent (h); }
-
-  bool is_hidden (void) const
-    { return rep->is_hidden (); }
-
-  void set_hidden (bool flag)
-    { rep->set_hidden (flag); }
-
-  bool is_radio (void) const
-    { return rep->is_radio (); }
-
-  int get_id (void) const
-    { return rep->get_id (); }
-
-  void set_id (int d)
-    { rep->set_id (d); }
-
-  octave_value get (void) const
-    { return rep->get (); }
-
-  bool set (const octave_value& val, bool do_run = true,
-            bool do_notify_toolkit = true)
-    { return rep->set (val, do_run, do_notify_toolkit); }
-
-  std::string values_as_string (void) const
-    { return rep->values_as_string (); }
-
-  Cell values_as_cell (void) const
-    { return rep->values_as_cell (); }
-
-  property& operator = (const octave_value& val)
-    {
-      *rep = val;
-      return *this;
-    }
-
-  property& operator = (const property& p)
-    {
-      if (rep && --rep->count == 0)
-        delete rep;
-
-      rep = p.rep;
-      rep->count++;
-
-      return *this;
-    }
-
-  void add_listener (const octave_value& v, listener_mode mode = POSTSET)
-    { rep->add_listener (v, mode); }
-
-  void delete_listener (const octave_value& v = octave_value (),
-                        listener_mode mode = POSTSET)
-  { rep->delete_listener (v, mode); }
-
-  void run_listeners (listener_mode mode = POSTSET)
-    { rep->run_listeners (mode); }
-
-  OCTINTERP_API static
-      property create (const std::string& name, const graphics_handle& parent,
-                       const caseless_str& type,
-                       const octave_value_list& args);
-
-  property clone (void) const
-    { return property (rep->clone ()); }
-
-  /*
-  const string_property& as_string_property (void) const
-    { return *(dynamic_cast<string_property*> (rep)); }
-
-  const radio_property& as_radio_property (void) const
-    { return *(dynamic_cast<radio_property*> (rep)); }
-
-  const color_property& as_color_property (void) const
-    { return *(dynamic_cast<color_property*> (rep)); }
-
-  const double_property& as_double_property (void) const
-    { return *(dynamic_cast<double_property*> (rep)); }
-
-  const bool_property& as_bool_property (void) const
-    { return *(dynamic_cast<bool_property*> (rep)); }
-
-  const handle_property& as_handle_property (void) const
-    { return *(dynamic_cast<handle_property*> (rep)); }
-    */
-
-private:
-  base_property *rep;
-};
-
-// ---------------------------------------------------------------------
-
-class property_list
-{
-public:
-  typedef std::map<std::string, octave_value> pval_map_type;
-  typedef std::map<std::string, pval_map_type> plist_map_type;
-
-  typedef pval_map_type::iterator pval_map_iterator;
-  typedef pval_map_type::const_iterator pval_map_const_iterator;
-
-  typedef plist_map_type::iterator plist_map_iterator;
-  typedef plist_map_type::const_iterator plist_map_const_iterator;
-
-  property_list (const plist_map_type& m = plist_map_type ())
-    : plist_map (m) { }
-
-  ~property_list (void) { }
-
-  void set (const caseless_str& name, const octave_value& val);
-
-  octave_value lookup (const caseless_str& name) const;
-
-  plist_map_iterator begin (void) { return plist_map.begin (); }
-  plist_map_const_iterator begin (void) const { return plist_map.begin (); }
-
-  plist_map_iterator end (void) { return plist_map.end (); }
-  plist_map_const_iterator end (void) const { return plist_map.end (); }
-
-  plist_map_iterator find (const std::string& go_name)
-  {
-    return plist_map.find (go_name);
-  }
-
-  plist_map_const_iterator find (const std::string& go_name) const
-  {
-    return plist_map.find (go_name);
-  }
-
-  octave_scalar_map as_struct (const std::string& prefix_arg) const;
-
-private:
-  plist_map_type plist_map;
-};
-
-// ---------------------------------------------------------------------
-
-class graphics_toolkit;
-class graphics_object;
-
-class base_graphics_toolkit
-{
-public:
-  friend class graphics_toolkit;
-
-public:
-  base_graphics_toolkit (const std::string& nm)
-      : name (nm), count (0) { }
-
-  virtual ~base_graphics_toolkit (void) { }
-
-  std::string get_name (void) const { return name; }
-
-  virtual bool is_valid (void) const { return false; }
-
-  virtual void redraw_figure (const graphics_object&) const
-    { gripe_invalid ("redraw_figure"); }
-
-  virtual void print_figure (const graphics_object&, const std::string&,
-                             const std::string&, bool,
-                             const std::string& = "") const
-    { gripe_invalid ("print_figure"); }
-
-  virtual Matrix get_canvas_size (const graphics_handle&) const
-    {
-      gripe_invalid ("get_canvas_size");
-      return Matrix (1, 2, 0.0);
-    }
-
-  virtual double get_screen_resolution (void) const
-    {
-      gripe_invalid ("get_screen_resolution");
-      return 72.0;
-    }
-
-  virtual Matrix get_screen_size (void) const
-    {
-      gripe_invalid ("get_screen_size");
-      return Matrix (1, 2, 0.0);
-    }
-
-  // Callback function executed when the given graphics object
-  // changes.  This allows the graphics toolkit to act on property
-  // changes if needed.
-  virtual void update (const graphics_object&, int)
-    { gripe_invalid ("base_graphics_toolkit::update"); }
-
-  void update (const graphics_handle&, int);
-
-  // Callback function executed when the given graphics object is
-  // created.  This allows the graphics toolkit to do toolkit-specific
-  // initializations for a newly created object.
-  virtual bool initialize (const graphics_object&)
-    { gripe_invalid ("base_graphics_toolkit::initialize"); return false; }
-
-  bool initialize (const graphics_handle&);
-
-  // Callback function executed just prior to deleting the given
-  // graphics object.  This allows the graphics toolkit to perform
-  // toolkit-specific cleanup operations before an object is deleted.
-  virtual void finalize (const graphics_object&)
-    { gripe_invalid ("base_graphics_toolkit::finalize"); }
-
-  void finalize (const graphics_handle&);
-
-  // Close the graphics toolkit.
-  virtual void close (void)
-  { gripe_invalid ("base_graphics_toolkit::close"); }
-
-private:
-  std::string name;
-  octave_refcount<int> count;
-
-private:
-  void gripe_invalid (const std::string& fname) const
-    {
-      if (! is_valid ())
-        error ("%s: invalid graphics toolkit", fname.c_str ());
-    }
-};
-
-class graphics_toolkit
-{
-public:
-  graphics_toolkit (void)
-      : rep (new base_graphics_toolkit ("unknown"))
-    {
-      rep->count++;
-    }
-
-  graphics_toolkit (base_graphics_toolkit* b)
-      : rep (b)
-    {
-      rep->count++;
-    }
-
-  graphics_toolkit (const graphics_toolkit& b)
-      : rep (b.rep)
-    {
-      rep->count++;
-    }
-
-  ~graphics_toolkit (void)
-    {
-      if (--rep->count == 0)
-        delete rep;
-    }
-
-  graphics_toolkit& operator = (const graphics_toolkit& b)
-    {
-      if (rep != b.rep)
-        {
-          if (--rep->count == 0)
-            delete rep;
-
-          rep = b.rep;
-          rep->count++;
-        }
-
-      return *this;
-    }
-
-  operator bool (void) const { return rep->is_valid (); }
-
-  std::string get_name (void) const { return rep->get_name (); }
-
-  void redraw_figure (const graphics_object& go) const
-    { rep->redraw_figure (go); }
-
-  void print_figure (const graphics_object& go, const std::string& term,
-                     const std::string& file, bool mono,
-                     const std::string& debug_file = "") const
-    { rep->print_figure (go, term, file, mono, debug_file); }
-
-  Matrix get_canvas_size (const graphics_handle& fh) const
-    { return rep->get_canvas_size (fh); }
-
-  double get_screen_resolution (void) const
-    { return rep->get_screen_resolution (); }
-
-  Matrix get_screen_size (void) const
-    { return rep->get_screen_size (); }
-
-  // Notifies graphics toolkit that object't property has changed.
-  void update (const graphics_object& go, int id)
-    { rep->update (go, id); }
-
-  void update (const graphics_handle& h, int id)
-    { rep->update (h, id); }
-
-  // Notifies graphics toolkit that new object was created.
-  bool initialize (const graphics_object& go)
-    { return rep->initialize (go); }
-
-  bool initialize (const graphics_handle& h)
-    { return rep->initialize (h); }
-
-  // Notifies graphics toolkit that object was destroyed.
-  // This is called only for explicitly deleted object. Children are
-  // deleted implicitly and graphics toolkit isn't notified.
-  void finalize (const graphics_object& go)
-    { rep->finalize (go); }
-
-  void finalize (const graphics_handle& h)
-    { rep->finalize (h); }
-
-  // Close the graphics toolkit.
-  void close (void) { rep->close (); }
-
-private:
-
-  base_graphics_toolkit *rep;
-};
-
-class gtk_manager
-{
-public:
-
-  static graphics_toolkit get_toolkit (void)
-  {
-    return instance_ok () ? instance->do_get_toolkit () : graphics_toolkit ();
-  }
-
-  static void register_toolkit (const std::string& name)
-  {
-    if (instance_ok ())
-      instance->do_register_toolkit (name);
-  }
-
-  static void unregister_toolkit (const std::string& name)
-  {
-    if (instance_ok ())
-      instance->do_unregister_toolkit (name);
-  }
-
-  static void load_toolkit (const graphics_toolkit& tk)
-  {
-    if (instance_ok ())
-      instance->do_load_toolkit (tk);
-  }
-
-  static void unload_toolkit (const std::string& name)
-  {
-    if (instance_ok ())
-      instance->do_unload_toolkit (name);
-  }
-
-  static graphics_toolkit find_toolkit (const std::string& name)
-  {
-    return instance_ok ()
-      ? instance->do_find_toolkit (name) : graphics_toolkit ();
-  }
-
-  static Cell available_toolkits_list (void)
-  {
-    return instance_ok () ? instance->do_available_toolkits_list () : Cell ();
-  }
-
-  static Cell loaded_toolkits_list (void)
-  {
-    return instance_ok () ? instance->do_loaded_toolkits_list () : Cell ();
-  }
-
-  static void unload_all_toolkits (void)
-  {
-    if (instance_ok ())
-      instance->do_unload_all_toolkits ();
-  }
-
-  static std::string default_toolkit (void)
-  {
-    return instance_ok () ? instance->do_default_toolkit () : std::string ();
-  }
-
-private:
-
-  // FIXME -- default toolkit should be configurable.
-
-  gtk_manager (void)
-    : dtk ("gnuplot"), available_toolkits (), loaded_toolkits () { }
-
-  ~gtk_manager (void) { }
-
-  OCTINTERP_API static void create_instance (void);
-
-  static bool instance_ok (void)
-  {
-    bool retval = true;
-
-    if (! instance)
-      create_instance ();
-
-    if (! instance)
-      {
-        ::error ("unable to create gh_manager!");
-
-        retval = false;
-      }
-
-    return retval;
-  }
-
-  static void cleanup_instance (void) { delete instance; instance = 0; }
-
-  OCTINTERP_API static gtk_manager *instance;
-
-  // The name of the default toolkit.
-  std::string dtk;
-
-  // The list of toolkits that we know about.
-  std::set<std::string> available_toolkits;
-
-  // The list of toolkits we have actually loaded.
-  std::map<std::string, graphics_toolkit> loaded_toolkits;
-
-  typedef std::set<std::string>::iterator available_toolkits_iterator;
-
-  typedef std::set<std::string>::const_iterator
-    const_available_toolkits_iterator;
-
-  typedef std::map<std::string, graphics_toolkit>::iterator
-    loaded_toolkits_iterator;
-
-  typedef std::map<std::string, graphics_toolkit>::const_iterator
-    const_loaded_toolkits_iterator;
-
-  graphics_toolkit do_get_toolkit (void) const;
-
-  void do_register_toolkit (const std::string& name)
-  {
-    available_toolkits.insert (name);
-  }
-
-  void do_unregister_toolkit (const std::string& name)
-  {
-    available_toolkits.erase (name);
-  }
-
-  void do_load_toolkit (const graphics_toolkit& tk)
-  {
-    loaded_toolkits[tk.get_name ()] = tk;
-  }
-
-  void do_unload_toolkit (const std::string& name)
-  {
-    loaded_toolkits.erase (name);
-  }
-
-  graphics_toolkit do_find_toolkit (const std::string& name) const
-  {
-    const_loaded_toolkits_iterator p = loaded_toolkits.find (name);
-
-    if (p != loaded_toolkits.end ())
-      return p->second;
-    else
-      return graphics_toolkit ();
-  }
-
-  Cell do_available_toolkits_list (void) const
-  {
-    Cell m (1 , available_toolkits.size ());
-    
-    octave_idx_type i = 0;
-    for (const_available_toolkits_iterator p = available_toolkits.begin ();
-         p !=  available_toolkits.end (); p++)
-      m(i++) = *p;
-
-    return m;
-  }
-
-  Cell do_loaded_toolkits_list (void) const
-  {
-    Cell m (1 , loaded_toolkits.size ());
-    
-    octave_idx_type i = 0;
-    for (const_loaded_toolkits_iterator p = loaded_toolkits.begin ();
-         p !=  loaded_toolkits.end (); p++)
-      m(i++) = p->first;
-
-    return m;
-  }
-
-  void do_unload_all_toolkits (void)
-  {
-    while (! loaded_toolkits.empty ())
-      {
-        loaded_toolkits_iterator p = loaded_toolkits.begin ();
-
-        std::string name = p->first;
-
-        p->second.close ();
-
-        // The toolkit may have unloaded itself.  If not, we'll do
-        // it here.
-        if (loaded_toolkits.find (name) != loaded_toolkits.end ())
-          unload_toolkit (name);
-      }
-  }
-
-  std::string do_default_toolkit (void) { return dtk; }
-};
-
-// ---------------------------------------------------------------------
-
-class base_graphics_object;
-class graphics_object;
-
-class OCTINTERP_API base_properties
-{
-public:
-  base_properties (const std::string& ty = "unknown",
-                   const graphics_handle& mh = graphics_handle (),
-                   const graphics_handle& p = graphics_handle ());
-
-  virtual ~base_properties (void) { }
-
-  virtual std::string graphics_object_name (void) const { return "unknonwn"; }
-
-  void mark_modified (void);
-
-  void override_defaults (base_graphics_object& obj);
-
-  virtual void init_integerhandle (const octave_value&)
-    {
-      panic_impossible ();
-    }
-
-  // Look through DEFAULTS for properties with given CLASS_NAME, and
-  // apply them to the current object with set (virtual method).
-
-  void set_from_list (base_graphics_object& obj, property_list& defaults);
-
-  void insert_property (const std::string& name, property p)
-    {
-      p.set_name (name);
-      p.set_parent (__myhandle__);
-      all_props[name] = p;
-    }
-
-  virtual void set (const caseless_str&, const octave_value&);
-
-  virtual octave_value get (const caseless_str& pname) const;
-
-  virtual octave_value get (const std::string& pname) const
-  {
-    return get (caseless_str (pname));
-  }
-
-  virtual octave_value get (const char *pname) const
-  {
-    return get (caseless_str (pname));
-  }
-
-  virtual octave_value get (bool all = false) const;
-
-  virtual property get_property (const caseless_str& pname);
-
-  virtual bool has_property (const caseless_str&) const
-  {
-    panic_impossible ();
-    return false;
-  }
-
-  bool is_modified (void) const { return is___modified__ (); }
-
-  virtual void remove_child (const graphics_handle& h)
-    {
-      if (children.remove_child (h.value ()))
-        mark_modified ();
-    }
-
-  virtual void adopt (const graphics_handle& h)
-  {
-    children.adopt (h.value ());
-    mark_modified ();
-  }
-
-  virtual graphics_toolkit get_toolkit (void) const;
-
-  virtual Matrix get_boundingbox (bool /*internal*/ = false,
-                                  const Matrix& /*parent_pix_size*/ = Matrix ()) const
-    { return Matrix (1, 4, 0.0); }
-
-  virtual void update_boundingbox (void);
-
-  virtual void update_autopos (const std::string& elem_type);
-
-  virtual void add_listener (const caseless_str&, const octave_value&,
-                             listener_mode = POSTSET);
-
-  virtual void delete_listener (const caseless_str&, const octave_value&,
-                                listener_mode = POSTSET);
-
-  void set_tag (const octave_value& val) { tag = val; }
-
-  void set_parent (const octave_value& val);
-
-  Matrix get_children (void) const
-    {
-      return children.get_children ();
-    }
-
-  Matrix get_all_children (void) const
-    {
-      return children.get_all ();
-    }
-
-  Matrix get_hidden_children (void) const
-    {
-      return children.get_hidden ();
-    }
-
-  void set_modified (const octave_value& val) { set___modified__ (val); }
-
-  void set___modified__ (const octave_value& val) { __modified__ = val; }
-
-  void reparent (const graphics_handle& new_parent) { parent = new_parent; }
-
-  // Update data limits for AXIS_TYPE (xdata, ydata, etc.) in the parent
-  // axes object.
-
-  virtual void update_axis_limits (const std::string& axis_type) const;
-
-  virtual void update_axis_limits (const std::string& axis_type,
-                                   const graphics_handle& h) const;
-
-  virtual void delete_children (bool clear = false)
-    {
-      children.delete_children (clear);
-    }
-
-  void renumber_child (graphics_handle old_gh, graphics_handle new_gh)
-    {
-      children.renumber (old_gh, new_gh);
-    }
-
-  void renumber_parent (graphics_handle new_gh)
-    {
-      parent = new_gh;
-    }
-
-  static property_list::pval_map_type factory_defaults (void);
-
-  // FIXME -- these functions should be generated automatically by the
-  // genprops.awk script.
-  //
-  // EMIT_BASE_PROPERTIES_GET_FUNCTIONS
-
-  virtual octave_value get_xlim (void) const { return octave_value (); }
-  virtual octave_value get_ylim (void) const { return octave_value (); }
-  virtual octave_value get_zlim (void) const { return octave_value (); }
-  virtual octave_value get_clim (void) const { return octave_value (); }
-  virtual octave_value get_alim (void) const { return octave_value (); }
-
-  virtual bool is_xliminclude (void) const { return false; }
-  virtual bool is_yliminclude (void) const { return false; }
-  virtual bool is_zliminclude (void) const { return false; }
-  virtual bool is_climinclude (void) const { return false; }
-  virtual bool is_aliminclude (void) const { return false; }
-
-  bool is_handle_visible (void) const;
-
-  std::set<std::string> dynamic_property_names (void) const;
-
-  bool has_dynamic_property (const std::string& pname);
-
-protected:
-  std::set<std::string> dynamic_properties;
-
-  void set_dynamic (const caseless_str& pname, const octave_value& val);
-
-  octave_value get_dynamic (const caseless_str& pname) const;
-
-  octave_value get_dynamic (bool all = false) const;
-
-  property get_property_dynamic (const caseless_str& pname);
-
-  BEGIN_BASE_PROPERTIES
-    // properties common to all objects
-    bool_property beingdeleted , "off"
-    radio_property busyaction , "{queue}|cancel"
-    callback_property buttondownfcn , Matrix ()
-    children_property children gf , Matrix ()
-    bool_property clipping , "on"
-    callback_property createfcn , Matrix ()
-    callback_property deletefcn , Matrix ()
-    radio_property handlevisibility , "{on}|callback|off"
-    bool_property hittest , "on"
-    bool_property interruptible , "on"
-    handle_property parent fs , p
-    bool_property selected , "off"
-    bool_property selectionhighlight , "on"
-    string_property tag s , ""
-    string_property type frs , ty
-    any_property userdata , Matrix ()
-    bool_property visible , "on"
-    // additional (octave-specific) properties
-    bool_property __modified__ s , "on"
-    graphics_handle __myhandle__ fhrs , mh
-    // FIXME -- should this really be here?
-    handle_property uicontextmenu , graphics_handle ()
-  END_PROPERTIES
-
-protected:
-  struct cmp_caseless_str
-    {
-      bool operator () (const caseless_str &a, const caseless_str &b) const
-        {
-          std::string a1 = a;
-          std::transform (a1.begin (), a1.end (), a1.begin (), tolower);
-          std::string b1 = b;
-          std::transform (b1.begin (), b1.end (), b1.begin (), tolower);
-
-          return a1 < b1;
-        }
-    };
-
-  std::map<caseless_str, property, cmp_caseless_str> all_props;
-
-protected:
-  void insert_static_property (const std::string& name, base_property& p)
-    { insert_property (name, property (&p, true)); }
-
-  virtual void init (void) { }
-};
-
-class OCTINTERP_API base_graphics_object
-{
-public:
-  friend class graphics_object;
-
-  base_graphics_object (void) : count (1), toolkit_flag (false) { }
-
-  virtual ~base_graphics_object (void) { }
-
-  virtual void mark_modified (void)
-  {
-    if (valid_object ())
-      get_properties ().mark_modified ();
-    else
-      error ("base_graphics_object::mark_modified: invalid graphics object");
-  }
-
-  virtual void override_defaults (base_graphics_object& obj)
-  {
-    if (valid_object ())
-      get_properties ().override_defaults (obj);
-    else
-      error ("base_graphics_object::override_defaults: invalid graphics object");
-  }
-
-  virtual void set_from_list (property_list& plist)
-  {
-    if (valid_object ())
-      get_properties ().set_from_list (*this, plist);
-    else
-      error ("base_graphics_object::set_from_list: invalid graphics object");
-  }
-
-  virtual void set (const caseless_str& pname, const octave_value& pval)
-  {
-    if (valid_object ())
-      get_properties ().set (pname, pval);
-    else
-      error ("base_graphics_object::set: invalid graphics object");
-  }
-
-  virtual void set_defaults (const std::string&)
-  {
-    error ("base_graphics_object::set_defaults: invalid graphics object");
-  }
-
-  virtual octave_value get (bool all = false) const
-  {
-    if (valid_object ())
-      return get_properties ().get (all);
-    else
-      {
-        error ("base_graphics_object::get: invalid graphics object");
-        return octave_value ();
-      }
-  }
-
-  virtual octave_value get (const caseless_str& pname) const
-  {
-    if (valid_object ())
-      return get_properties ().get (pname);
-    else
-      {
-        error ("base_graphics_object::get: invalid graphics object");
-        return octave_value ();
-      }
-  }
-
-  virtual octave_value get_default (const caseless_str&) const;
-
-  virtual octave_value get_factory_default (const caseless_str&) const;
-
-  virtual octave_value get_defaults (void) const
-  {
-    error ("base_graphics_object::get_defaults: invalid graphics object");
-    return octave_value ();
-  }
-
-  virtual octave_value get_factory_defaults (void) const
-  {
-    error ("base_graphics_object::get_factory_defaults: invalid graphics object");
-    return octave_value ();
-  }
-
-  virtual std::string values_as_string (void);
-
-  virtual octave_scalar_map values_as_struct (void);
-
-  virtual graphics_handle get_parent (void) const
-  {
-    if (valid_object ())
-      return get_properties ().get_parent ();
-    else
-      {
-        error ("base_graphics_object::get_parent: invalid graphics object");
-        return graphics_handle ();
-      }
-  }
-
-  graphics_handle get_handle (void) const
-  {
-    if (valid_object ())
-      return get_properties ().get___myhandle__ ();
-    else
-      {
-        error ("base_graphics_object::get_handle: invalid graphics object");
-        return graphics_handle ();
-      }
-  }
-
-  virtual void remove_child (const graphics_handle& h)
-  {
-    if (valid_object ())
-      get_properties ().remove_child (h);
-    else
-      error ("base_graphics_object::remove_child: invalid graphics object");
-  }
-
-  virtual void adopt (const graphics_handle& h)
-  {
-    if (valid_object ())
-      get_properties ().adopt (h);
-    else
-      error ("base_graphics_object::adopt: invalid graphics object");
-  }
-
-  virtual void reparent (const graphics_handle& np)
-  {
-    if (valid_object ())
-      get_properties ().reparent (np);
-    else
-      error ("base_graphics_object::reparent: invalid graphics object");
-  }
-
-  virtual void defaults (void) const
-  {
-    if (valid_object ())
-      {
-        std::string msg = (type () + "::defaults");
-        gripe_not_implemented (msg.c_str ());
-      }
-    else
-      error ("base_graphics_object::default: invalid graphics object");
-  }
-
-  virtual base_properties& get_properties (void)
-  {
-    static base_properties properties;
-    error ("base_graphics_object::get_properties: invalid graphics object");
-    return properties;
-  }
-
-  virtual const base_properties& get_properties (void) const
-  {
-    static base_properties properties;
-    error ("base_graphics_object::get_properties: invalid graphics object");
-    return properties;
-  }
-
-  virtual void update_axis_limits (const std::string& axis_type);
-
-  virtual void update_axis_limits (const std::string& axis_type,
-                                   const graphics_handle& h);
-
-  virtual bool valid_object (void) const { return false; }
-
-  bool valid_toolkit_object (void) const { return toolkit_flag; }
-
-  virtual std::string type (void) const
-  {
-    return (valid_object () ? get_properties ().graphics_object_name ()
-        : "unknown");
-  }
-
-  bool isa (const std::string& go_name) const
-  {
-    return type () == go_name;
-  }
-
-  virtual graphics_toolkit get_toolkit (void) const
-  {
-    if (valid_object ())
-      return get_properties ().get_toolkit ();
-    else
-      {
-        error ("base_graphics_object::get_toolkit: invalid graphics object");
-        return graphics_toolkit ();
-      }
-  }
-
-  virtual void add_property_listener (const std::string& nm,
-                                      const octave_value& v,
-                                      listener_mode mode = POSTSET)
-    {
-      if (valid_object ())
-        get_properties ().add_listener (nm, v, mode);
-    }
-
-  virtual void delete_property_listener (const std::string& nm,
-                                         const octave_value& v,
-                                         listener_mode mode = POSTSET)
-    {
-      if (valid_object ())
-        get_properties ().delete_listener (nm, v, mode);
-    }
-
-  virtual void remove_all_listeners (void);
-
-  virtual void reset_default_properties (void)
-    {
-      if (valid_object ())
-        {
-          std::string msg = (type () + "::reset_default_properties");
-          gripe_not_implemented (msg.c_str ());
-        }
-      else
-        error ("base_graphics_object::default: invalid graphics object");
-    }
-
-protected:
-  virtual void initialize (const graphics_object& go)
-    {
-      if (! toolkit_flag)
-        toolkit_flag = get_toolkit ().initialize (go);
-    }
-
-  virtual void finalize (const graphics_object& go)
-    {
-      if (toolkit_flag)
-        {
-          get_toolkit ().finalize (go);
-          toolkit_flag = false;
-        }
-    }
-
-  virtual void update (const graphics_object& go, int id)
-    {
-      if (toolkit_flag)
-        get_toolkit ().update (go, id);
-    }
-
-protected:
-  // A reference count.
-  octave_refcount<int> count;
-
-  // A flag telling whether this object is a valid object
-  // in the backend context.
-  bool toolkit_flag;
-
-  // No copying!
-
-  base_graphics_object (const base_graphics_object&) : count (0) { }
-
-  base_graphics_object& operator = (const base_graphics_object&)
-  {
-    return *this;
-  }
-};
-
-class OCTINTERP_API graphics_object
-{
-public:
-  graphics_object (void) : rep (new base_graphics_object ()) { }
-
-  graphics_object (base_graphics_object *new_rep)
-    : rep (new_rep) { }
-
-  graphics_object (const graphics_object& obj) : rep (obj.rep)
-  {
-    rep->count++;
-  }
-
-  graphics_object& operator = (const graphics_object& obj)
-  {
-    if (rep != obj.rep)
-      {
-        if (--rep->count == 0)
-          delete rep;
-
-        rep = obj.rep;
-        rep->count++;
-      }
-
-    return *this;
-  }
-
-  ~graphics_object (void)
-  {
-    if (--rep->count == 0)
-      delete rep;
-  }
-
-  void mark_modified (void) { rep->mark_modified (); }
-
-  void override_defaults (base_graphics_object& obj)
-  {
-    rep->override_defaults (obj);
-  }
-
-  void set_from_list (property_list& plist) { rep->set_from_list (plist); }
-
-  void set (const caseless_str& name, const octave_value& val)
-  {
-    rep->set (name, val);
-  }
-
-  void set (const octave_value_list& args);
-
-  void set (const Array<std::string>& names, const Cell& values,
-            octave_idx_type row);
-
-  void set (const octave_map& m);
-
-  void set_value_or_default (const caseless_str& name,
-                             const octave_value& val);
-
-  void set_defaults (const std::string& mode) { rep->set_defaults (mode); }
-
-  octave_value get (bool all = false) const { return rep->get (all); }
-
-  octave_value get (const caseless_str& name) const
-  {
-    return name.compare ("default")
-      ? get_defaults ()
-      : (name.compare ("factory")
-         ? get_factory_defaults () : rep->get (name));
-  }
-
-  octave_value get (const std::string& name) const
-  {
-    return get (caseless_str (name));
-  }
-
-  octave_value get (const char *name) const
-  {
-    return get (caseless_str (name));
-  }
-
-  octave_value get_default (const caseless_str& name) const
-  {
-    return rep->get_default (name);
-  }
-
-  octave_value get_factory_default (const caseless_str& name) const
-  {
-    return rep->get_factory_default (name);
-  }
-
-  octave_value get_defaults (void) const { return rep->get_defaults (); }
-
-  octave_value get_factory_defaults (void) const
-  {
-    return rep->get_factory_defaults ();
-  }
-
-  std::string values_as_string (void) { return rep->values_as_string (); }
-
-  octave_map values_as_struct (void) { return rep->values_as_struct (); }
-
-  graphics_handle get_parent (void) const { return rep->get_parent (); }
-
-  graphics_handle get_handle (void) const { return rep->get_handle (); }
-
-  graphics_object get_ancestor (const std::string& type) const;
-
-  void remove_child (const graphics_handle& h) { rep->remove_child (h); }
-
-  void adopt (const graphics_handle& h) { rep->adopt (h); }
-
-  void reparent (const graphics_handle& h) { rep->reparent (h); }
-
-  void defaults (void) const { rep->defaults (); }
-
-  bool isa (const std::string& go_name) const { return rep->isa (go_name); }
-
-  base_properties& get_properties (void) { return rep->get_properties (); }
-
-  const base_properties& get_properties (void) const
-  {
-    return rep->get_properties ();
-  }
-
-  void update_axis_limits (const std::string& axis_type)
-  {
-    rep->update_axis_limits (axis_type);
-  }
-
-  void update_axis_limits (const std::string& axis_type,
-                           const graphics_handle& h)
-  {
-    rep->update_axis_limits (axis_type, h);
-  }
-
-  bool valid_object (void) const { return rep->valid_object (); }
-
-  std::string type (void) const { return rep->type (); }
-
-  operator bool (void) const { return rep->valid_object (); }
-
-  // FIXME -- these functions should be generated automatically by the
-  // genprops.awk script.
-  //
-  // EMIT_GRAPHICS_OBJECT_GET_FUNCTIONS
-
-  octave_value get_xlim (void) const
-  { return get_properties ().get_xlim (); }
-
-  octave_value get_ylim (void) const
-  { return get_properties ().get_ylim (); }
-
-  octave_value get_zlim (void) const
-  { return get_properties ().get_zlim (); }
-
-  octave_value get_clim (void) const
-  { return get_properties ().get_clim (); }
-
-  octave_value get_alim (void) const
-  { return get_properties ().get_alim (); }
-
-  bool is_xliminclude (void) const
-  { return get_properties ().is_xliminclude (); }
-
-  bool is_yliminclude (void) const
-  { return get_properties ().is_yliminclude (); }
-
-  bool is_zliminclude (void) const
-  { return get_properties ().is_zliminclude (); }
-
-  bool is_climinclude (void) const
-  { return get_properties ().is_climinclude (); }
-
-  bool is_aliminclude (void) const
-  { return get_properties ().is_aliminclude (); }
-
-  bool is_handle_visible (void) const
-  { return get_properties ().is_handle_visible (); }
-
-  graphics_toolkit get_toolkit (void) const { return rep->get_toolkit (); }
-
-  void add_property_listener (const std::string& nm, const octave_value& v,
-                              listener_mode mode = POSTSET)
-    { rep->add_property_listener (nm, v, mode); }
-
-  void delete_property_listener (const std::string& nm, const octave_value& v,
-                                 listener_mode mode = POSTSET)
-    { rep->delete_property_listener (nm, v, mode); }
-
-  void initialize (void) { rep->initialize (*this); }
-  
-  void finalize (void) { rep->finalize (*this); }
-
-  void update (int id) { rep->update (*this, id); }
-
-  void reset_default_properties (void)
-  { rep->reset_default_properties (); }
-
-private:
-  base_graphics_object *rep;
-};
-
-// ---------------------------------------------------------------------
-
-class OCTINTERP_API root_figure : public base_graphics_object
-{
-public:
-  class OCTINTERP_API properties : public base_properties
-  {
-  public:
-    void remove_child (const graphics_handle& h);
-
-    Matrix get_boundingbox (bool internal = false,
-                            const Matrix& parent_pix_size = Matrix ()) const;
-
-    // See the genprops.awk script for an explanation of the
-    // properties declarations.
-
-    // FIXME -- it seems strange to me that the diary, diaryfile,
-    // echo, format, formatspacing, language, and recursionlimit
-    // properties are here.  WTF do they have to do with graphics?
-    // Also note that these properties (and the monitorpositions,
-    // pointerlocation, and pointerwindow properties) are not yet used
-    // by Octave, so setting them will have no effect, and changes
-    // made elswhere (say, the diary or format functions) will not
-    // cause these properties to be updated.
-
-    BEGIN_PROPERTIES (root_figure, root)
-      handle_property callbackobject Sr , graphics_handle ()
-      array_property commandwindowsize r , Matrix (1, 2, 0)
-      handle_property currentfigure S , graphics_handle ()
-      bool_property diary , "off"
-      string_property diaryfile , "diary"
-      bool_property echo , "off"
-      radio_property format , "+|bank|bit|debug|hex|long|longe|longeng|longg|native-bit|native-hex|rational|{short}|shorte|shorteng|shortg"
-      radio_property formatspacing , "{loose}|compact"
-      string_property language , "ascii"
-      array_property monitorpositions , Matrix (1, 4, 0)
-      array_property pointerlocation , Matrix (1, 2, 0)
-      double_property pointerwindow , 0.0
-      double_property recursionlimit , 256.0
-      double_property screendepth r , default_screendepth ()
-      double_property screenpixelsperinch r , default_screenpixelsperinch ()
-      array_property screensize r , default_screensize ()
-      bool_property showhiddenhandles , "off"
-      radio_property units U , "inches|centimeters|normalized|points|{pixels}"
-    END_PROPERTIES
-
-  private:
-    std::list<graphics_handle> cbo_stack;
-  };
-
-private:
-  properties xproperties;
-
-public:
-
-  root_figure (void) : xproperties (0, graphics_handle ()), default_properties () { }
-
-  ~root_figure (void) { }
-
-  void mark_modified (void) { }
-
-  void override_defaults (base_graphics_object& obj)
-  {
-    // Now override with our defaults.  If the default_properties
-    // list includes the properties for all defaults (line,
-    // surface, etc.) then we don't have to know the type of OBJ
-    // here, we just call its set function and let it decide which
-    // properties from the list to use.
-    obj.set_from_list (default_properties);
-  }
-
-  void set (const caseless_str& name, const octave_value& value)
-  {
-    if (name.compare ("default", 7))
-      // strip "default", pass rest to function that will
-      // parse the remainder and add the element to the
-      // default_properties map.
-      default_properties.set (name.substr (7), value);
-    else
-      xproperties.set (name, value);
-  }
-
-  octave_value get (const caseless_str& name) const
-  {
-    octave_value retval;
-
-    if (name.compare ("default", 7))
-      return get_default (name.substr (7));
-    else if (name.compare ("factory", 7))
-      return get_factory_default (name.substr (7));
-    else
-      retval = xproperties.get (name);
-
-    return retval;
-  }
-
-  octave_value get_default (const caseless_str& name) const
-  {
-    octave_value retval = default_properties.lookup (name);
-
-    if (retval.is_undefined ())
-      {
-        // no default property found, use factory default
-        retval = factory_properties.lookup (name);
-
-        if (retval.is_undefined ())
-          error ("get: invalid default property `%s'", name.c_str ());
-      }
-
-    return retval;
-  }
-
-  octave_value get_factory_default (const caseless_str& name) const
-  {
-    octave_value retval = factory_properties.lookup (name);
-
-    if (retval.is_undefined ())
-      error ("get: invalid factory default property `%s'", name.c_str ());
-
-    return retval;
-  }
-
-  octave_value get_defaults (void) const
-  {
-    return default_properties.as_struct ("default");
-  }
-
-  octave_value get_factory_defaults (void) const
-  {
-    return factory_properties.as_struct ("factory");
-  }
-
-  base_properties& get_properties (void) { return xproperties; }
-
-  const base_properties& get_properties (void) const { return xproperties; }
-
-  bool valid_object (void) const { return true; }
-
-  void reset_default_properties (void);
-
-private:
-  property_list default_properties;
-
-  static property_list factory_properties;
-
-  static property_list::plist_map_type init_factory_properties (void);
-};
-
-// ---------------------------------------------------------------------
-
-class OCTINTERP_API figure : public base_graphics_object
-{
-public:
-  class OCTINTERP_API properties : public base_properties
-  {
-  public:
-    void init_integerhandle (const octave_value& val)
-      {
-        integerhandle = val;
-      }
-
-    void remove_child (const graphics_handle& h);
-
-    void set_visible (const octave_value& val);
-
-    graphics_toolkit get_toolkit (void) const
-      {
-        if (! toolkit)
-          toolkit = gtk_manager::get_toolkit ();
-
-        return toolkit;
-      }
-
-    void set_toolkit (const graphics_toolkit& b);
-
-    void set___graphics_toolkit__ (const octave_value& val)
-    {
-      if (! error_state)
-        {
-          if (val.is_string ())
-            {
-              std::string nm = val.string_value ();
-              graphics_toolkit b = gtk_manager::find_toolkit (nm);
-              if (b.get_name () != nm)
-                {
-                  error ("set___graphics_toolkit__: invalid graphics toolkit");
-                }
-              else
-                {
-                  set_toolkit (b);
-                  mark_modified ();
-                }
-            }
-          else
-            error ("set___graphics_toolkit__ must be a string");
-        }
-    }
-
-    void set_position (const octave_value& val,
-                       bool do_notify_toolkit = true);
-
-    void set_outerposition (const octave_value& val,
-                            bool do_notify_toolkit = true);
-
-    Matrix get_boundingbox (bool internal = false,
-                            const Matrix& parent_pix_size = Matrix ()) const;
-
-    void set_boundingbox (const Matrix& bb, bool internal = false,
-                          bool do_notify_toolkit = true);
-
-    Matrix map_from_boundingbox (double x, double y) const;
-
-    Matrix map_to_boundingbox (double x, double y) const;
-
-    void update_units (const caseless_str& old_units);
-
-    void update_paperunits (const caseless_str& old_paperunits);
-
-    std::string get_title (void) const;
-
-    // See the genprops.awk script for an explanation of the
-    // properties declarations.
-
-    BEGIN_PROPERTIES (figure)
-      any_property __plot_stream__ h , Matrix ()
-      bool_property __enhanced__ h , "on"
-      radio_property nextplot , "new|{add}|replacechildren|replace"
-      callback_property closerequestfcn , "closereq"
-      handle_property currentaxes S , graphics_handle ()
-      array_property colormap , jet_colormap ()
-      radio_property paperorientation U , "{portrait}|landscape|rotated"
-      color_property color , color_property (color_values (1, 1, 1), radio_values ("none"))
-      array_property alphamap , Matrix (64, 1, 1)
-      string_property currentcharacter r , ""
-      handle_property currentobject r , graphics_handle ()
-      array_property currentpoint r , Matrix (2, 1, 0)
-      bool_property dockcontrols , "off"
-      bool_property doublebuffer , "on"
-      string_property filename , ""
-      bool_property integerhandle S , "on"
-      bool_property inverthardcopy , "off"
-      callback_property keypressfcn , Matrix ()
-      callback_property keyreleasefcn , Matrix ()
-      radio_property menubar , "none|{figure}"
-      double_property mincolormap , 64
-      string_property name , ""
-      bool_property numbertitle , "on"
-      array_property outerposition s , Matrix (1, 4, -1.0)
-      radio_property paperunits Su , "{inches}|centimeters|normalized|points"
-      array_property paperposition , default_figure_paperposition ()
-      radio_property paperpositionmode , "auto|{manual}"
-      array_property papersize U , default_figure_papersize ()
-      radio_property papertype SU , "{usletter}|uslegal|a0|a1|a2|a3|a4|a5|b0|b1|b2|b3|b4|b5|arch-a|arch-b|arch-c|arch-d|arch-e|a|b|c|d|e|tabloid|<custom>"
-      radio_property pointer , "crosshair|fullcrosshair|{arrow}|ibeam|watch|topl|topr|botl|botr|left|top|right|bottom|circle|cross|fleur|custom|hand"
-      array_property pointershapecdata , Matrix (16, 16, 0)
-      array_property pointershapehotspot , Matrix (1, 2, 0)
-      array_property position s , default_figure_position ()
-      radio_property renderer , "{painters}|zbuffer|opengl|none"
-      radio_property renderermode , "{auto}|manual"
-      bool_property resize , "on"
-      callback_property resizefcn , Matrix ()
-      radio_property selectiontype , "{normal}|open|alt|extend"
-      radio_property toolbar , "none|{auto}|figure"
-      radio_property units Su , "inches|centimeters|normalized|points|{pixels}|characters"
-      callback_property windowbuttondownfcn , Matrix ()
-      callback_property windowbuttonmotionfcn , Matrix ()
-      callback_property windowbuttonupfcn , Matrix ()
-      callback_property windowbuttonwheelfcn , Matrix ()
-      radio_property windowstyle , "{normal}|modal|docked"
-      string_property wvisual , ""
-      radio_property wvisualmode , "{auto}|manual"
-      string_property xdisplay , ""
-      string_property xvisual , ""
-      radio_property xvisualmode , "{auto}|manual"
-      callback_property buttondownfcn , Matrix ()
-      string_property __graphics_toolkit__ s , "gnuplot"
-      any_property __guidata__ h , Matrix ()
-    END_PROPERTIES
-
-  protected:
-    void init (void)
-      {
-        colormap.add_constraint (dim_vector (-1, 3));
-        alphamap.add_constraint (dim_vector (-1, 1));
-        paperposition.add_constraint (dim_vector (1, 4));
-        pointershapecdata.add_constraint (dim_vector (16, 16));
-        pointershapehotspot.add_constraint (dim_vector (1, 2));
-        position.add_constraint (dim_vector (1, 4));
-        outerposition.add_constraint (dim_vector (1, 4));
-      }
-
-  private:
-    mutable graphics_toolkit toolkit;
-  };
-
-private:
-  properties xproperties;
-
-public:
-  figure (const graphics_handle& mh, const graphics_handle& p)
-    : base_graphics_object (), xproperties (mh, p), default_properties ()
-  {
-    xproperties.override_defaults (*this);
-  }
-
-  ~figure (void) { }
-
-  void override_defaults (base_graphics_object& obj)
-  {
-    // Allow parent (root figure) to override first (properties knows how
-    // to find the parent object).
-    xproperties.override_defaults (obj);
-
-    // Now override with our defaults.  If the default_properties
-    // list includes the properties for all defaults (line,
-    // surface, etc.) then we don't have to know the type of OBJ
-    // here, we just call its set function and let it decide which
-    // properties from the list to use.
-    obj.set_from_list (default_properties);
-  }
-
-  void set (const caseless_str& name, const octave_value& value)
-  {
-    if (name.compare ("default", 7))
-      // strip "default", pass rest to function that will
-      // parse the remainder and add the element to the
-      // default_properties map.
-      default_properties.set (name.substr (7), value);
-    else
-      xproperties.set (name, value);
-  }
-
-  octave_value get (const caseless_str& name) const
-  {
-    octave_value retval;
-
-    if (name.compare ("default", 7))
-      retval = get_default (name.substr (7));
-    else
-      retval = xproperties.get (name);
-
-    return retval;
-  }
-
-  octave_value get_default (const caseless_str& name) const;
-
-  octave_value get_defaults (void) const
-  {
-    return default_properties.as_struct ("default");
-  }
-
-  base_properties& get_properties (void) { return xproperties; }
-
-  const base_properties& get_properties (void) const { return xproperties; }
-
-  bool valid_object (void) const { return true; }
-
-  void reset_default_properties (void);
-
-private:
-  property_list default_properties;
-};
-
-// ---------------------------------------------------------------------
-
-class OCTINTERP_API graphics_xform
-{
-public:
-  graphics_xform (void)
-    : xform (xform_eye ()), xform_inv (xform_eye ()),
-      sx ("linear"), sy ("linear"), sz ("linear"),  zlim (1, 2, 0.0)
-    {
-      zlim(1) = 1.0;
-    }
-
-  graphics_xform (const Matrix& xm, const Matrix& xim,
-                  const scaler& x, const scaler& y, const scaler& z,
-                  const Matrix& zl)
-      : xform (xm), xform_inv (xim), sx (x), sy (y), sz (z), zlim (zl) { }
-
-  graphics_xform (const graphics_xform& g)
-      : xform (g.xform), xform_inv (g.xform_inv), sx (g.sx),
-        sy (g.sy), sz (g.sz), zlim (g.zlim) { }
-
-  ~graphics_xform (void) { }
-
-  graphics_xform& operator = (const graphics_xform& g)
-    {
-      xform = g.xform;
-      xform_inv = g.xform_inv;
-      sx = g.sx;
-      sy = g.sy;
-      sz = g.sz;
-      zlim = g.zlim;
-
-      return *this;
-    }
-
-  static ColumnVector xform_vector (double x, double y, double z);
-
-  static Matrix xform_eye (void);
-
-  ColumnVector transform (double x, double y, double z,
-                          bool use_scale = true) const;
-
-  ColumnVector untransform (double x, double y, double z,
-                            bool use_scale = true) const;
-
-  ColumnVector untransform (double x, double y, bool use_scale = true) const
-    { return untransform (x, y, (zlim(0)+zlim(1))/2, use_scale); }
-
-  Matrix xscale (const Matrix& m) const { return sx.scale (m); }
-  Matrix yscale (const Matrix& m) const { return sy.scale (m); }
-  Matrix zscale (const Matrix& m) const { return sz.scale (m); }
-
-  Matrix scale (const Matrix& m) const
-    {
-      bool has_z = (m.columns () > 2);
-
-      if (sx.is_linear () && sy.is_linear ()
-          && (! has_z || sz.is_linear ()))
-        return m;
-
-      Matrix retval (m.dims ());
-
-      int r = m.rows ();
-
-      for (int i = 0; i < r; i++)
-        {
-          retval(i,0) = sx.scale (m(i,0));
-          retval(i,1) = sy.scale (m(i,1));
-          if (has_z)
-            retval(i,2) = sz.scale (m(i,2));
-        }
-
-      return retval;
-    }
-
-private:
-  Matrix xform;
-  Matrix xform_inv;
-  scaler sx, sy, sz;
-  Matrix zlim;
-};
-
-enum {
-  AXE_ANY_DIR   = 0,
-  AXE_DEPTH_DIR = 1,
-  AXE_HORZ_DIR  = 2,
-  AXE_VERT_DIR  = 3
-};
-
-class OCTINTERP_API axes : public base_graphics_object
-{
-public:
-  class OCTINTERP_API properties : public base_properties
-  {
-  public:
-    void set_defaults (base_graphics_object& obj, const std::string& mode);
-
-    void remove_child (const graphics_handle& h);
-
-    const scaler& get_x_scaler (void) const { return sx; }
-    const scaler& get_y_scaler (void) const { return sy; }
-    const scaler& get_z_scaler (void) const { return sz; }
-
-    Matrix get_boundingbox (bool internal = false,
-                            const Matrix& parent_pix_size = Matrix ()) const;
-    Matrix get_extent (bool with_text = false, bool only_text_height=false) const;
-
-    double get_fontsize_points (double box_pix_height = 0) const;
-
-    void update_boundingbox (void)
-      {
-        if (units_is ("normalized"))
-          {
-            sync_positions ();
-            base_properties::update_boundingbox ();
-          }
-      }
-
-    void update_camera (void);
-    void update_axes_layout (void);
-    void update_aspectratios (void);
-    void update_transform (void)
-      {
-        update_aspectratios ();
-        update_camera ();
-        update_axes_layout ();
-      }
-
-    void update_autopos (const std::string& elem_type);
-    void update_xlabel_position (void);
-    void update_ylabel_position (void);
-    void update_zlabel_position (void);
-    void update_title_position (void);
-
-    graphics_xform get_transform (void) const
-      { return graphics_xform (x_render, x_render_inv, sx, sy, sz, x_zlim); }
-
-    Matrix get_transform_matrix (void) const { return x_render; }
-    Matrix get_inverse_transform_matrix (void) const { return x_render_inv; }
-    Matrix get_opengl_matrix_1 (void) const { return x_gl_mat1; }
-    Matrix get_opengl_matrix_2 (void) const { return x_gl_mat2; }
-    Matrix get_transform_zlim (void) const { return x_zlim; }
-
-    int get_xstate (void) const { return xstate; }
-    int get_ystate (void) const { return ystate; }
-    int get_zstate (void) const { return zstate; }
-    double get_xPlane (void) const { return xPlane; }
-    double get_xPlaneN (void) const { return xPlaneN; }
-    double get_yPlane (void) const { return yPlane; }
-    double get_yPlaneN (void) const { return yPlaneN; }
-    double get_zPlane (void) const { return zPlane; }
-    double get_zPlaneN (void) const { return zPlaneN; }
-    double get_xpTick (void) const { return xpTick; }
-    double get_xpTickN (void) const { return xpTickN; }
-    double get_ypTick (void) const { return ypTick; }
-    double get_ypTickN (void) const { return ypTickN; }
-    double get_zpTick (void) const { return zpTick; }
-    double get_zpTickN (void) const { return zpTickN; }
-    double get_x_min (void) const { return std::min (xPlane, xPlaneN); }
-    double get_x_max (void) const { return std::max (xPlane, xPlaneN); }
-    double get_y_min (void) const { return std::min (yPlane, yPlaneN); }
-    double get_y_max (void) const { return std::max (yPlane, yPlaneN); }
-    double get_z_min (void) const { return std::min (zPlane, zPlaneN); }
-    double get_z_max (void) const { return std::max (zPlane, zPlaneN); }
-    double get_fx (void) const { return fx; }
-    double get_fy (void) const { return fy; }
-    double get_fz (void) const { return fz; }
-    double get_xticklen (void) const { return xticklen; }
-    double get_yticklen (void) const { return yticklen; }
-    double get_zticklen (void) const { return zticklen; }
-    double get_xtickoffset (void) const { return xtickoffset; }
-    double get_ytickoffset (void) const { return ytickoffset; }
-    double get_ztickoffset (void) const { return ztickoffset; }
-    bool get_x2Dtop (void) const { return x2Dtop; }
-    bool get_y2Dright (void) const { return y2Dright; }
-    bool get_layer2Dtop (void) const { return layer2Dtop; }
-    bool get_xySym (void) const { return xySym; }
-    bool get_xyzSym (void) const { return xyzSym; }
-    bool get_zSign (void) const { return zSign; }
-    bool get_nearhoriz (void) const { return nearhoriz; }
-
-    ColumnVector pixel2coord (double px, double py) const
-    { return get_transform ().untransform (px, py, (x_zlim(0)+x_zlim(1))/2); }
-
-    ColumnVector coord2pixel (double x, double y, double z) const
-    { return get_transform ().transform (x, y, z); }
-
-    void zoom_about_point (double x, double y, double factor,
-                           bool push_to_zoom_stack = true);
-    void zoom (const Matrix& xl, const Matrix& yl, bool push_to_zoom_stack = true);
-    void translate_view (double x0, double x1, double y0, double y1);
-    void rotate_view (double delta_az, double delta_el);
-    void unzoom (void);
-    void clear_zoom_stack (void);
-
-    void update_units (const caseless_str& old_units);
-
-    void update_fontunits (const caseless_str& old_fontunits);
-
-  private:
-    scaler sx, sy, sz;
-    Matrix x_render, x_render_inv;
-    Matrix x_gl_mat1, x_gl_mat2;
-    Matrix x_zlim;
-    std::list<octave_value> zoom_stack;
-
-    // Axes layout data
-    int xstate, ystate, zstate;
-    double xPlane, xPlaneN, yPlane, yPlaneN, zPlane, zPlaneN;
-    double xpTick, xpTickN, ypTick, ypTickN, zpTick, zpTickN;
-    double fx, fy, fz;
-    double xticklen, yticklen, zticklen;
-    double xtickoffset, ytickoffset, ztickoffset;
-    bool x2Dtop, y2Dright, layer2Dtop;
-    bool xySym, xyzSym, zSign, nearhoriz;
-
-#if HAVE_FREETYPE
-    // freetype renderer, used for calculation of text (tick labels) size
-    ft_render text_renderer;
-#endif
-
-    void set_text_child (handle_property& h, const std::string& who,
-                         const octave_value& v);
-
-    void delete_text_child (handle_property& h);
-
-    // See the genprops.awk script for an explanation of the
-    // properties declarations.
-
-    // properties which are not in matlab: interpreter
-
-    BEGIN_PROPERTIES (axes)
-      array_property position u , default_axes_position ()
-      bool_property box , "on"
-      array_property colororder , default_colororder ()
-      array_property dataaspectratio mu , Matrix (1, 3, 1.0)
-      radio_property dataaspectratiomode u , "{auto}|manual"
-      radio_property layer u , "{bottom}|top"
-      row_vector_property xlim mu , default_lim ()
-      row_vector_property ylim mu , default_lim ()
-      row_vector_property zlim mu , default_lim ()
-      row_vector_property clim m , default_lim ()
-      row_vector_property alim m , default_lim ()
-      radio_property xlimmode al , "{auto}|manual"
-      radio_property ylimmode al , "{auto}|manual"
-      radio_property zlimmode al , "{auto}|manual"
-      radio_property climmode al , "{auto}|manual"
-      radio_property alimmode    , "{auto}|manual"
-      handle_property xlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false)
-      handle_property ylabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false)
-      handle_property zlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false)
-      handle_property title SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false)
-      bool_property xgrid , "off"
-      bool_property ygrid , "off"
-      bool_property zgrid , "off"
-      bool_property xminorgrid , "off"
-      bool_property yminorgrid , "off"
-      bool_property zminorgrid , "off"
-      row_vector_property xtick mu , default_axes_tick ()
-      row_vector_property ytick mu , default_axes_tick ()
-      row_vector_property ztick mu , default_axes_tick ()
-      radio_property xtickmode u , "{auto}|manual"
-      radio_property ytickmode u , "{auto}|manual"
-      radio_property ztickmode u , "{auto}|manual"
-      bool_property xminortick , "off"
-      bool_property yminortick , "off"
-      bool_property zminortick , "off"
-      // FIXME -- should be kind of string array.
-      any_property xticklabel m , ""
-      any_property yticklabel m , ""
-      any_property zticklabel m , ""
-      radio_property xticklabelmode u , "{auto}|manual"
-      radio_property yticklabelmode u , "{auto}|manual"
-      radio_property zticklabelmode u , "{auto}|manual"
-      radio_property interpreter , "tex|{none}|latex"
-      color_property color , color_property (color_values (1, 1, 1), radio_values ("none"))
-      color_property xcolor , color_values (0, 0, 0)
-      color_property ycolor , color_values (0, 0, 0)
-      color_property zcolor , color_values (0, 0, 0)
-      radio_property xscale alu , "{linear}|log"
-      radio_property yscale alu , "{linear}|log"
-      radio_property zscale alu , "{linear}|log"
-      radio_property xdir u , "{normal}|reverse"
-      radio_property ydir u , "{normal}|reverse"
-      radio_property zdir u , "{normal}|reverse"
-      radio_property yaxislocation u , "{left}|right|zero"
-      radio_property xaxislocation u , "{bottom}|top|zero"
-      array_property view u , Matrix ()
-      bool_property __hold_all__ h , "off"
-      radio_property nextplot , "new|add|replacechildren|{replace}"
-      array_property outerposition u , default_axes_outerposition ()
-      radio_property activepositionproperty , "{outerposition}|position"
-      color_property ambientlightcolor , color_values (1, 1, 1)
-      array_property cameraposition m , Matrix (1, 3, 0.0)
-      array_property cameratarget m , Matrix (1, 3, 0.0)
-      array_property cameraupvector m , Matrix ()
-      double_property cameraviewangle m , 10.0
-      radio_property camerapositionmode , "{auto}|manual"
-      radio_property cameratargetmode , "{auto}|manual"
-      radio_property cameraupvectormode , "{auto}|manual"
-      radio_property cameraviewanglemode , "{auto}|manual"
-      array_property currentpoint , Matrix (2, 3, 0.0)
-      radio_property drawmode , "{normal}|fast"
-      radio_property fontangle u , "{normal}|italic|oblique"
-      string_property fontname u , OCTAVE_DEFAULT_FONTNAME
-      double_property fontsize u , 10
-      radio_property fontunits SU , "{points}|normalized|inches|centimeters|pixels"
-      radio_property fontweight u , "{normal}|light|demi|bold"
-      radio_property gridlinestyle , "-|--|{:}|-.|none"
-      string_array_property linestyleorder , "-"
-      double_property linewidth , 0.5
-      radio_property minorgridlinestyle , "-|--|{:}|-.|none"
-      array_property plotboxaspectratio mu , Matrix (1, 3, 1.0)
-      radio_property plotboxaspectratiomode u , "{auto}|manual"
-      radio_property projection , "{orthographic}|perpective"
-      radio_property tickdir mu , "{in}|out"
-      radio_property tickdirmode u , "{auto}|manual"
-      array_property ticklength u , default_axes_ticklength ()
-      array_property tightinset r , Matrix (1, 4, 0.0)
-      // FIXME -- uicontextmenu should be moved here.
-      radio_property units SU , "{normalized}|inches|centimeters|points|pixels|characters"
-      // hidden properties for transformation computation
-      array_property x_viewtransform h , Matrix (4, 4, 0.0)
-      array_property x_projectiontransform h , Matrix (4, 4, 0.0)
-      array_property x_viewporttransform h , Matrix (4, 4, 0.0)
-      array_property x_normrendertransform h , Matrix (4, 4, 0.0)
-      array_property x_rendertransform h , Matrix (4, 4, 0.0)
-      // hidden properties for minor ticks
-      row_vector_property xmtick h , Matrix ()
-      row_vector_property ymtick h , Matrix ()
-      row_vector_property zmtick h , Matrix ()
-      // hidden properties for inset
-      array_property looseinset hu , Matrix (1, 4, 0.0)
-      // hidden properties for alignment of subplots
-      radio_property autopos_tag h , "{none}|subplot"
-   END_PROPERTIES
-
-  protected:
-    void init (void);
-
-  private:
-
-    std::string
-    get_scale (const std::string& scale, const Matrix& lims)
-    {
-      std::string retval = scale;
-
-      if (scale == "log" && lims.numel () > 1 && lims(0) < 0 && lims(1) < 0)
-        retval = "neglog";
-
-      return retval;
-    }
-
-    void update_xscale (void)
-    {
-      sx = get_scale (get_xscale (), xlim.get ().matrix_value ());
-    }
-
-    void update_yscale (void)
-    {
-      sy = get_scale (get_yscale (), ylim.get ().matrix_value ());
-    }
-
-    void update_zscale (void)
-    {
-      sz = get_scale (get_zscale (), zlim.get ().matrix_value ());
-    }
-
-    void update_view (void) { sync_positions (); }
-    void update_dataaspectratio (void) { sync_positions (); }
-    void update_dataaspectratiomode (void) { sync_positions (); }
-    void update_plotboxaspectratio (void) { sync_positions (); }
-    void update_plotboxaspectratiomode (void) { sync_positions (); }
-
-    void update_layer (void) { update_axes_layout (); }
-    void update_yaxislocation (void)
-      {
-        update_axes_layout ();
-        update_ylabel_position ();
-      }
-    void update_xaxislocation (void)
-      {
-        update_axes_layout ();
-        update_xlabel_position ();
-      }
-
-    void update_xdir (void) { update_camera (); update_axes_layout (); }
-    void update_ydir (void) { update_camera (); update_axes_layout (); }
-    void update_zdir (void) { update_camera (); update_axes_layout (); }
-
-    void update_ticklength (void);
-    void update_tickdir (void) { update_ticklength (); }
-    void update_tickdirmode (void) { update_ticklength (); }
-
-    void update_xtick (void)
-      {
-        if (xticklabelmode.is ("auto"))
-          calc_ticklabels (xtick, xticklabel, xscale.is ("log"));
-      }
-    void update_ytick (void)
-      {
-        if (yticklabelmode.is ("auto"))
-          calc_ticklabels (ytick, yticklabel, yscale.is ("log"));
-      }
-    void update_ztick (void)
-      {
-        if (zticklabelmode.is ("auto"))
-          calc_ticklabels (ztick, zticklabel, zscale.is ("log"));
-      }
-
-    void update_xtickmode (void)
-      {
-      if (xtickmode.is ("auto"))
-        {
-          calc_ticks_and_lims (xlim, xtick, xmtick, xlimmode.is ("auto"), xscale.is ("log"));
-          update_xtick ();
-        }
-      }
-    void update_ytickmode (void)
-      {
-      if (ytickmode.is ("auto"))
-        {
-          calc_ticks_and_lims (ylim, ytick, ymtick, ylimmode.is ("auto"), yscale.is ("log"));
-          update_ytick ();
-        }
-      }
-    void update_ztickmode (void)
-      {
-      if (ztickmode.is ("auto"))
-        {
-          calc_ticks_and_lims (zlim, ztick, zmtick, zlimmode.is ("auto"), zscale.is ("log"));
-          update_ztick ();
-        }
-      }
-
-    void update_xticklabelmode (void)
-      {
-        if (xticklabelmode.is ("auto"))
-          calc_ticklabels (xtick, xticklabel, xscale.is ("log"));
-      }
-    void update_yticklabelmode (void)
-      {
-        if (yticklabelmode.is ("auto"))
-          calc_ticklabels (ytick, yticklabel, yscale.is ("log"));
-      }
-    void update_zticklabelmode (void)
-      {
-        if (zticklabelmode.is ("auto"))
-          calc_ticklabels (ztick, zticklabel, zscale.is ("log"));
-      }
-
-    void update_font (void);
-    void update_fontname (void) { update_font (); }
-    void update_fontsize (void) { update_font (); }
-    void update_fontangle (void) { update_font (); }
-    void update_fontweight (void) { update_font (); }
-
-    void sync_positions (const Matrix& linset);
-    void sync_positions (void);
-
-    void update_outerposition (void)
-    {
-      set_activepositionproperty ("outerposition");
-      sync_positions ();
-    }
-
-    void update_position (void)
-    {
-      set_activepositionproperty ("position");
-      sync_positions ();
-    }
-
-    void update_looseinset (void) { sync_positions (); }
-
-    double calc_tick_sep (double minval, double maxval);
-    void calc_ticks_and_lims (array_property& lims, array_property& ticks, array_property& mticks,
-                              bool limmode_is_auto, bool is_logscale);
-    void calc_ticklabels (const array_property& ticks, any_property& labels, bool is_logscale);
-    Matrix get_ticklabel_extents (const Matrix& ticks,
-                                  const string_vector& ticklabels,
-                                  const Matrix& limits);
-
-    void fix_limits (array_property& lims)
-    {
-      if (lims.get ().is_empty ())
-        return;
-
-      Matrix l = lims.get ().matrix_value ();
-      if (l(0) > l(1))
-        {
-          l(0) = 0;
-          l(1) = 1;
-          lims = l;
-        }
-      else if (l(0) == l(1))
-        {
-          l(0) -= 0.5;
-          l(1) += 0.5;
-          lims = l;
-        }
-    }
-
-    Matrix calc_tightbox (const Matrix& init_pos);
-
-  public:
-    Matrix get_axis_limits (double xmin, double xmax,
-                            double min_pos, double max_neg,
-                            bool logscale);
-
-    void update_xlim (bool do_clr_zoom = true)
-    {
-      if (xtickmode.is ("auto"))
-        calc_ticks_and_lims (xlim, xtick, xmtick, xlimmode.is ("auto"), xscale.is ("log"));
-      if (xticklabelmode.is ("auto"))
-        calc_ticklabels (xtick, xticklabel, xscale.is ("log"));
-
-      fix_limits (xlim);
-
-      update_xscale ();
-
-      if (do_clr_zoom)
-        zoom_stack.clear ();
-
-      update_axes_layout ();
-    }
-
-    void update_ylim (bool do_clr_zoom = true)
-    {
-      if (ytickmode.is ("auto"))
-        calc_ticks_and_lims (ylim, ytick, ymtick, ylimmode.is ("auto"), yscale.is ("log"));
-      if (yticklabelmode.is ("auto"))
-        calc_ticklabels (ytick, yticklabel, yscale.is ("log"));
-
-      fix_limits (ylim);
-
-      update_yscale ();
-
-      if (do_clr_zoom)
-        zoom_stack.clear ();
-
-      update_axes_layout ();
-    }
-
-    void update_zlim (void)
-    {
-      if (ztickmode.is ("auto"))
-        calc_ticks_and_lims (zlim, ztick, zmtick, zlimmode.is ("auto"), zscale.is ("log"));
-      if (zticklabelmode.is ("auto"))
-        calc_ticklabels (ztick, zticklabel, zscale.is ("log"));
-
-      fix_limits (zlim);
-
-      update_zscale ();
-
-      zoom_stack.clear ();
-
-      update_axes_layout ();
-    }
-
-  };
-
-private:
-  properties xproperties;
-
-public:
-  axes (const graphics_handle& mh, const graphics_handle& p)
-    : base_graphics_object (), xproperties (mh, p), default_properties ()
-  {
-    xproperties.override_defaults (*this);
-    xproperties.update_transform ();
-  }
-
-  ~axes (void) { }
-
-  void override_defaults (base_graphics_object& obj)
-  {
-    // Allow parent (figure) to override first (properties knows how
-    // to find the parent object).
-    xproperties.override_defaults (obj);
-
-    // Now override with our defaults.  If the default_properties
-    // list includes the properties for all defaults (line,
-    // surface, etc.) then we don't have to know the type of OBJ
-    // here, we just call its set function and let it decide which
-    // properties from the list to use.
-    obj.set_from_list (default_properties);
-  }
-
-  void set (const caseless_str& name, const octave_value& value)
-  {
-    if (name.compare ("default", 7))
-      // strip "default", pass rest to function that will
-      // parse the remainder and add the element to the
-      // default_properties map.
-      default_properties.set (name.substr (7), value);
-    else
-      xproperties.set (name, value);
-  }
-
-  void set_defaults (const std::string& mode)
-  {
-    remove_all_listeners ();
-    xproperties.set_defaults (*this, mode);
-  }
-
-  octave_value get (const caseless_str& name) const
-  {
-    octave_value retval;
-
-    // FIXME -- finish this.
-    if (name.compare ("default", 7))
-      retval = get_default (name.substr (7));
-    else
-      retval = xproperties.get (name);
-
-    return retval;
-  }
-
-  octave_value get_default (const caseless_str& name) const;
-
-  octave_value get_defaults (void) const
-  {
-    return default_properties.as_struct ("default");
-  }
-
-  base_properties& get_properties (void) { return xproperties; }
-
-  const base_properties& get_properties (void) const { return xproperties; }
-
-  void update_axis_limits (const std::string& axis_type);
-
-  void update_axis_limits (const std::string& axis_type,
-                           const graphics_handle& h);
-
-  bool valid_object (void) const { return true; }
-
-  void reset_default_properties (void);
-
-protected:
-  void initialize (const graphics_object& go);
-
-private:
-  property_list default_properties;
-};
-
-// ---------------------------------------------------------------------
-
-class OCTINTERP_API line : public base_graphics_object
-{
-public:
-  class OCTINTERP_API properties : public base_properties
-  {
-  public:
-    // See the genprops.awk script for an explanation of the
-    // properties declarations.
-
-    // properties which are not in matlab: interpreter
-
-    BEGIN_PROPERTIES (line)
-      row_vector_property xdata u , default_data ()
-      row_vector_property ydata u , default_data ()
-      row_vector_property zdata u , Matrix ()
-      string_property xdatasource , ""
-      string_property ydatasource , ""
-      string_property zdatasource , ""
-      color_property color , color_values (0, 0, 0)
-      radio_property linestyle , "{-}|--|:|-.|none"
-      double_property linewidth , 0.5
-      radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h|@"
-      color_property markeredgecolor , "{auto}|none"
-      color_property markerfacecolor , "auto|{none}"
-      double_property markersize , 6
-      radio_property interpreter , "{tex}|none|latex"
-      string_property displayname , ""
-      radio_property erasemode , "{normal}|none|xor|background"
-      // hidden properties for limit computation
-      row_vector_property xlim hlr , Matrix ()
-      row_vector_property ylim hlr , Matrix ()
-      row_vector_property zlim hlr , Matrix ()
-      bool_property xliminclude hl , "on"
-      bool_property yliminclude hl , "on"
-      bool_property zliminclude hl , "off"
-    END_PROPERTIES
-
-  private:
-    Matrix compute_xlim (void) const;
-    Matrix compute_ylim (void) const;
-
-    void update_xdata (void) { set_xlim (compute_xlim ()); }
-
-    void update_ydata (void) { set_ylim (compute_ylim ()); }
-
-    void update_zdata (void)
-      {
-        set_zlim (zdata.get_limits ());
-        set_zliminclude (get_zdata ().numel () > 0);
-      }
-  };
-
-private:
-  properties xproperties;
-
-public:
-  line (const graphics_handle& mh, const graphics_handle& p)
-    : base_graphics_object (), xproperties (mh, p)
-  {
-    xproperties.override_defaults (*this);
-  }
-
-  ~line (void) { }
-
-  base_properties& get_properties (void) { return xproperties; }
-
-  const base_properties& get_properties (void) const { return xproperties; }
-
-  bool valid_object (void) const { return true; }
-};
-
-// ---------------------------------------------------------------------
-
-class OCTINTERP_API text : public base_graphics_object
-{
-public:
-  class OCTINTERP_API properties : public base_properties
-  {
-  public:
-    double get_fontsize_points (double box_pix_height = 0) const;
-
-    void set_position (const octave_value& val)
-    {
-      if (! error_state)
-        {
-          octave_value new_val (val);
-    
-          if (new_val.numel () == 2)
-            {
-              dim_vector dv (1, 3);
-    
-              new_val = new_val.resize (dv, true);
-            }
-
-          if (position.set (new_val, false))
-            {
-              set_positionmode ("manual");
-              update_position ();
-              position.run_listeners (POSTSET);
-              mark_modified ();
-            }
-          else
-            set_positionmode ("manual");
-        }
-    }
-
-    // See the genprops.awk script for an explanation of the
-    // properties declarations.
-
-    BEGIN_PROPERTIES (text)
-      text_label_property string u , ""
-      radio_property units u , "{data}|pixels|normalized|inches|centimeters|points"
-      array_property position smu , Matrix (1, 3, 0.0)
-      double_property rotation mu , 0
-      radio_property horizontalalignment mu , "{left}|center|right"
-      color_property color u , color_values (0, 0, 0)
-      string_property fontname u , OCTAVE_DEFAULT_FONTNAME
-      double_property fontsize u , 10
-      radio_property fontangle u , "{normal}|italic|oblique"
-      radio_property fontweight u , "light|{normal}|demi|bold"
-      radio_property interpreter u , "{tex}|none|latex"
-      color_property backgroundcolor , "{none}"
-      string_property displayname , ""
-      color_property edgecolor , "{none}"
-      radio_property erasemode , "{normal}|none|xor|background"
-      bool_property editing , "off"
-      radio_property fontunits , "inches|centimeters|normalized|{points}|pixels"
-      radio_property linestyle , "{-}|--|:|-.|none"
-      double_property linewidth , 0.5
-      double_property margin , 1
-      radio_property verticalalignment mu , "top|cap|{middle}|baseline|bottom"
-      array_property extent rG , Matrix (1, 4, 0.0)
-      // hidden properties for limit computation
-      row_vector_property xlim hlr , Matrix ()
-      row_vector_property ylim hlr , Matrix ()
-      row_vector_property zlim hlr , Matrix ()
-      bool_property xliminclude hl , "off"
-      bool_property yliminclude hl , "off"
-      bool_property zliminclude hl , "off"
-      // hidden properties for auto-positioning
-      radio_property positionmode hu , "{auto}|manual"
-      radio_property rotationmode hu , "{auto}|manual"
-      radio_property horizontalalignmentmode hu , "{auto}|manual"
-      radio_property verticalalignmentmode hu , "{auto}|manual"
-      radio_property autopos_tag h , "{none}|xlabel|ylabel|zlabel|title"
-    END_PROPERTIES
-
-    Matrix get_data_position (void) const;
-    Matrix get_extent_matrix (void) const;
-    const uint8NDArray& get_pixels (void) const { return pixels; }
-#if HAVE_FREETYPE
-    // freetype renderer, used for calculation of text size
-    ft_render renderer;
-#endif
-
-  protected:
-    void init (void)
-      {
-        position.add_constraint (dim_vector (1, 3));
-        cached_units = get_units ();
-        update_font ();
-      }
-
-  private:
-    void update_position (void)
-      {
-        Matrix pos = get_data_position ();
-        Matrix lim;
-
-        lim = Matrix (1, 3, pos(0));
-        lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2));
-        set_xlim (lim);
-
-        lim = Matrix (1, 3, pos(1));
-        lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2));
-        set_ylim (lim);
-
-        if (pos.numel () == 3)
-          {
-            lim = Matrix (1, 3, pos(2));
-            lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2));
-            set_zliminclude ("on");
-            set_zlim (lim);
-          }
-        else
-          set_zliminclude ("off");
-      }
-
-    void update_text_extent (void);
-
-    void request_autopos (void);
-    void update_positionmode (void) { request_autopos (); }
-    void update_rotationmode (void) { request_autopos (); }
-    void update_horizontalalignmentmode (void) { request_autopos (); }
-    void update_verticalalignmentmode (void) { request_autopos (); }
-
-    void update_font (void);
-    void update_string (void) { request_autopos (); update_text_extent (); }
-    void update_rotation (void) { update_text_extent (); }
-    void update_color (void) { update_font (); }
-    void update_fontname (void) { update_font (); update_text_extent (); }
-    void update_fontsize (void) { update_font (); update_text_extent (); }
-    void update_fontangle (void) { update_font (); update_text_extent (); }
-    void update_fontweight (void) { update_font (); update_text_extent (); }
-    void update_interpreter (void) { update_text_extent (); }
-    void update_horizontalalignment (void) { update_text_extent (); }
-    void update_verticalalignment (void) { update_text_extent (); }
-
-    void update_units (void);
-
-  private:
-    std::string cached_units;
-    uint8NDArray pixels;
-  };
-
-private:
-  properties xproperties;
-
-public:
-  text (const graphics_handle& mh, const graphics_handle& p)
-    : base_graphics_object (), xproperties (mh, p)
-  {
-    xproperties.set_clipping ("off");
-    xproperties.override_defaults (*this);
-  }
-
-  ~text (void) { }
-
-  base_properties& get_properties (void) { return xproperties; }
-
-  const base_properties& get_properties (void) const { return xproperties; }
-
-  bool valid_object (void) const { return true; }
-};
-
-// ---------------------------------------------------------------------
-
-class OCTINTERP_API image : public base_graphics_object
-{
-public:
-  class OCTINTERP_API properties : public base_properties
-  {
-  public:
-    bool is_climinclude (void) const
-      { return (climinclude.is_on () && cdatamapping.is ("scaled")); }
-    std::string get_climinclude (void) const
-      { return climinclude.current_value (); }
-
-    octave_value get_color_data (void) const;
-
-    // See the genprops.awk script for an explanation of the
-    // properties declarations.
-
-    BEGIN_PROPERTIES (image)
-      row_vector_property xdata u , Matrix ()
-      row_vector_property ydata u , Matrix ()
-      array_property cdata u , Matrix ()
-      radio_property cdatamapping al , "{scaled}|direct"
-      // hidden properties for limit computation
-      row_vector_property xlim hlr , Matrix()
-      row_vector_property ylim hlr , Matrix()
-      row_vector_property clim hlr , Matrix()
-      bool_property xliminclude hl , "on"
-      bool_property yliminclude hl , "on"
-      bool_property climinclude hlg , "on"
-    END_PROPERTIES
-
-  protected:
-    void init (void)
-      {
-        xdata.add_constraint (2);
-        ydata.add_constraint (2);
-        cdata.add_constraint ("double");
-        cdata.add_constraint ("single");
-        cdata.add_constraint ("logical");
-        cdata.add_constraint ("uint8");
-        cdata.add_constraint ("uint16");
-        cdata.add_constraint ("int16");
-        cdata.add_constraint (dim_vector (-1, -1));
-        cdata.add_constraint (dim_vector (-1, -1, 3));
-      }
-
-  private:
-    void update_xdata (void)
-    {
-      Matrix limits = xdata.get_limits ();
-      float dp = pixel_xsize ();
-
-      limits(0) = limits(0) - dp;
-      limits(1) = limits(1) + dp;
-      set_xlim (limits);
-    }
-
-    void update_ydata (void)
-    {
-      Matrix limits = ydata.get_limits ();
-      float dp = pixel_ysize ();
-
-      limits(0) = limits(0) - dp;
-      limits(1) = limits(1) + dp;
-      set_ylim (limits);
-    }
-
-    void update_cdata (void)
-      {
-        if (cdatamapping_is ("scaled"))
-          set_clim (cdata.get_limits ());
-        else
-          clim = cdata.get_limits ();
-      }
-
-    float pixel_size (octave_idx_type dim, const Matrix limits)
-    {
-      octave_idx_type l = dim - 1;
-      float dp;
-
-      if (l > 0 && limits(0) != limits(1))
-        dp = (limits(1) - limits(0))/(2*l);
-      else
-        {
-          if (limits(1) == limits(2))
-            dp = 0.5;
-          else
-            dp = (limits(1) - limits(0))/2;
-        }
-      return dp;
-    }
-
-  public:
-    float  pixel_xsize (void)
-    {
-      return pixel_size ((get_cdata ().dims ())(1), xdata.get_limits ());
-    }
-
-    float pixel_ysize (void)
-    {
-      return pixel_size ((get_cdata ().dims ())(0), ydata.get_limits ());
-    }
-  };
-
-private:
-  properties xproperties;
-
-public:
-  image (const graphics_handle& mh, const graphics_handle& p)
-    : base_graphics_object (), xproperties (mh, p)
-  {
-    xproperties.override_defaults (*this);
-  }
-
-  ~image (void) { }
-
-  base_properties& get_properties (void) { return xproperties; }
-
-  const base_properties& get_properties (void) const { return xproperties; }
-
-  bool valid_object (void) const { return true; }
-};
-
-// ---------------------------------------------------------------------
-
-class OCTINTERP_API patch : public base_graphics_object
-{
-public:
-  class OCTINTERP_API properties : public base_properties
-  {
-  public:
-    octave_value get_color_data (void) const;
-
-    bool is_climinclude (void) const
-      { return (climinclude.is_on () && cdatamapping.is ("scaled")); }
-    std::string get_climinclude (void) const
-      { return climinclude.current_value (); }
-
-    bool is_aliminclude (void) const
-      { return (aliminclude.is_on () && alphadatamapping.is ("scaled")); }
-    std::string get_aliminclude (void) const
-      { return aliminclude.current_value (); }
-
-    // See the genprops.awk script for an explanation of the
-    // properties declarations.
-
-    BEGIN_PROPERTIES (patch)
-      array_property xdata u , Matrix ()
-      array_property ydata u , Matrix ()
-      array_property zdata u , Matrix ()
-      array_property cdata u , Matrix ()
-      radio_property cdatamapping l , "{scaled}|direct"
-      array_property faces , Matrix ()
-      array_property facevertexalphadata , Matrix ()
-      array_property facevertexcdata , Matrix ()
-      array_property vertices , Matrix ()
-      array_property vertexnormals , Matrix ()
-      radio_property normalmode , "{auto}|manual"
-      color_property facecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp"))
-      double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp"))
-      radio_property facelighting , "flat|{none}|gouraud|phong"
-      color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp"))
-      double_radio_property edgealpha , double_radio_property (1.0, radio_values ("flat|interp"))
-      radio_property edgelighting , "{none}|flat|gouraud|phong"
-      radio_property backfacelighting , "{reverselit}|unlit|lit"
-      double_property ambientstrength , 0.3
-      double_property diffusestrength , 0.6
-      double_property specularstrength , 0.6
-      double_property specularexponent , 10.0
-      double_property specularcolorreflectance , 1.0
-      radio_property erasemode , "{normal}|background|xor|none"
-      radio_property linestyle , "{-}|--|:|-.|none"
-      double_property linewidth , 0.5
-      radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h|@"
-      color_property markeredgecolor , "{auto}|none|flat"
-      color_property markerfacecolor , "auto|{none}|flat"
-      double_property markersize , 6
-      radio_property interpreter , "{tex}|none|latex"
-      string_property displayname , ""
-      radio_property alphadatamapping l , "none|{scaled}|direct"
-      // hidden properties for limit computation
-      row_vector_property xlim hlr , Matrix ()
-      row_vector_property ylim hlr , Matrix ()
-      row_vector_property zlim hlr , Matrix ()
-      row_vector_property clim hlr , Matrix ()
-      row_vector_property alim hlr , Matrix ()
-      bool_property xliminclude hl , "on"
-      bool_property yliminclude hl , "on"
-      bool_property zliminclude hl , "on"
-      bool_property climinclude hlg , "on"
-      bool_property aliminclude hlg , "on"
-    END_PROPERTIES
-
-  protected:
-    void init (void)
-      {
-        xdata.add_constraint (dim_vector (-1, -1));
-        ydata.add_constraint (dim_vector (-1, -1));
-        zdata.add_constraint (dim_vector (-1, -1));
-        vertices.add_constraint (dim_vector (-1, 2));
-        vertices.add_constraint (dim_vector (-1, 3));
-        cdata.add_constraint (dim_vector (-1, -1));
-        cdata.add_constraint (dim_vector (-1, -1, 3));
-        facevertexcdata.add_constraint (dim_vector (-1, 1));
-        facevertexcdata.add_constraint (dim_vector (-1, 3));
-        facevertexalphadata.add_constraint (dim_vector (-1, 1));
-      }
-
-  private:
-    void update_xdata (void) { set_xlim (xdata.get_limits ()); }
-    void update_ydata (void) { set_ylim (ydata.get_limits ()); }
-    void update_zdata (void) { set_zlim (zdata.get_limits ()); }
-
-    void update_cdata (void)
-      {
-        if (cdatamapping_is ("scaled"))
-          set_clim (cdata.get_limits ());
-        else
-          clim = cdata.get_limits ();
-      }
-  };
-
-private:
-  properties xproperties;
-
-public:
-  patch (const graphics_handle& mh, const graphics_handle& p)
-    : base_graphics_object (), xproperties (mh, p)
-  {
-    xproperties.override_defaults (*this);
-  }
-
-  ~patch (void) { }
-
-  base_properties& get_properties (void) { return xproperties; }
-
-  const base_properties& get_properties (void) const { return xproperties; }
-
-  bool valid_object (void) const { return true; }
-};
-
-// ---------------------------------------------------------------------
-
-class OCTINTERP_API surface : public base_graphics_object
-{
-public:
-  class OCTINTERP_API properties : public base_properties
-  {
-  public:
-    octave_value get_color_data (void) const;
-
-    bool is_climinclude (void) const
-      { return (climinclude.is_on () && cdatamapping.is ("scaled")); }
-    std::string get_climinclude (void) const
-      { return climinclude.current_value (); }
-
-    bool is_aliminclude (void) const
-      { return (aliminclude.is_on () && alphadatamapping.is ("scaled")); }
-    std::string get_aliminclude (void) const
-      { return aliminclude.current_value (); }
-
-    // See the genprops.awk script for an explanation of the
-    // properties declarations.
-
-    BEGIN_PROPERTIES (surface)
-      array_property xdata u , Matrix ()
-      array_property ydata u , Matrix ()
-      array_property zdata u , Matrix ()
-      array_property cdata u , Matrix ()
-      radio_property cdatamapping al , "{scaled}|direct"
-      string_property xdatasource , ""
-      string_property ydatasource , ""
-      string_property zdatasource , ""
-      string_property cdatasource , ""
-      color_property facecolor , "{flat}|none|interp"
-      double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp"))
-      color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp"))
-      radio_property linestyle , "{-}|--|:|-.|none"
-      double_property linewidth , 0.5
-      radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h|@"
-      color_property markeredgecolor , "{auto}|none"
-      color_property markerfacecolor , "auto|{none}"
-      double_property markersize , 6
-      radio_property interpreter , "{tex}|none|latex"
-      string_property displayname , ""
-      array_property alphadata u , Matrix ()
-      radio_property alphadatamapping l , "none|direct|{scaled}"
-      double_property ambientstrength , 0.3
-      radio_property backfacelighting , "unlit|lit|{reverselit}"
-      double_property diffusestrength , 0.6
-      double_radio_property edgealpha , double_radio_property (1.0, radio_values ("flat|interp"))
-      radio_property edgelighting , "{none}|flat|gouraud|phong"
-      radio_property erasemode , "{normal}|none|xor|background"
-      radio_property facelighting , "{none}|flat|gouraud|phong"
-      radio_property meshstyle , "{both}|row|column"
-      radio_property normalmode u , "{auto}|manual"
-      double_property specularcolorreflectance , 1
-      double_property specularexponent , 10
-      double_property specularstrength , 0.9
-      array_property vertexnormals u , Matrix ()
-      // hidden properties for limit computation
-      row_vector_property xlim hlr , Matrix ()
-      row_vector_property ylim hlr , Matrix ()
-      row_vector_property zlim hlr , Matrix ()
-      row_vector_property clim hlr , Matrix ()
-      row_vector_property alim hlr , Matrix ()
-      bool_property xliminclude hl , "on"
-      bool_property yliminclude hl , "on"
-      bool_property zliminclude hl , "on"
-      bool_property climinclude hlg , "on"
-      bool_property aliminclude hlg , "on"
-    END_PROPERTIES
-
-  protected:
-    void init (void)
-      {
-        xdata.add_constraint (dim_vector (-1, -1));
-        ydata.add_constraint (dim_vector (-1, -1));
-        zdata.add_constraint (dim_vector (-1, -1));
-        alphadata.add_constraint ("single");
-        alphadata.add_constraint ("double");
-        alphadata.add_constraint ("uint8");
-        alphadata.add_constraint (dim_vector (-1, -1));
-        vertexnormals.add_constraint (dim_vector (-1, -1, 3));
-        cdata.add_constraint ("single");
-        cdata.add_constraint ("double");
-        cdata.add_constraint ("uint8");
-        cdata.add_constraint (dim_vector (-1, -1));
-        cdata.add_constraint (dim_vector (-1, -1, 3));
-      }
-
-  private:
-    void update_normals (void);
-
-    void update_xdata (void)
-      {
-        update_normals ();
-        set_xlim (xdata.get_limits ());
-      }
-
-    void update_ydata (void)
-      {
-        update_normals ();
-        set_ylim (ydata.get_limits ());
-      }
-
-    void update_zdata (void)
-      {
-        update_normals ();
-        set_zlim (zdata.get_limits ());
-      }
-
-    void update_cdata (void)
-      {
-        if (cdatamapping_is ("scaled"))
-          set_clim (cdata.get_limits ());
-        else
-          clim = cdata.get_limits ();
-      }
-
-    void update_alphadata (void)
-      {
-        if (alphadatamapping_is ("scaled"))
-          set_alim (alphadata.get_limits ());
-        else
-          alim = alphadata.get_limits ();
-      }
-
-    void update_normalmode (void)
-      { update_normals (); }
-
-    void update_vertexnormals (void)
-      { set_normalmode ("manual"); }
-  };
-
-private:
-  properties xproperties;
-
-public:
-  surface (const graphics_handle& mh, const graphics_handle& p)
-    : base_graphics_object (), xproperties (mh, p)
-  {
-    xproperties.override_defaults (*this);
-  }
-
-  ~surface (void) { }
-
-  base_properties& get_properties (void) { return xproperties; }
-
-  const base_properties& get_properties (void) const { return xproperties; }
-
-  bool valid_object (void) const { return true; }
-};
-
-// ---------------------------------------------------------------------
-
-class OCTINTERP_API hggroup : public base_graphics_object
-{
-public:
-  class OCTINTERP_API properties : public base_properties
-  {
-  public:
-    void remove_child (const graphics_handle& h)
-      {
-        base_properties::remove_child (h);
-        update_limits ();
-      }
-
-    void adopt (const graphics_handle& h)
-      {
-
-        base_properties::adopt (h);
-        update_limits (h);
-      }
-
-    // See the genprops.awk script for an explanation of the
-    // properties declarations.
-
-    BEGIN_PROPERTIES (hggroup)
-      // hidden properties for limit computation
-      row_vector_property xlim hr , Matrix()
-      row_vector_property ylim hr , Matrix()
-      row_vector_property zlim hr , Matrix()
-      row_vector_property clim hr , Matrix()
-      row_vector_property alim hr , Matrix()
-      bool_property xliminclude h , "on"
-      bool_property yliminclude h , "on"
-      bool_property zliminclude h , "on"
-      bool_property climinclude h , "on"
-      bool_property aliminclude h , "on"
-    END_PROPERTIES
-
-  private:
-      void update_limits (void) const;
-
-      void update_limits (const graphics_handle& h) const;
-
-  protected:
-    void init (void)
-      { }
-
-  };
-
-private:
-  properties xproperties;
-
-public:
-  hggroup (const graphics_handle& mh, const graphics_handle& p)
-    : base_graphics_object (), xproperties (mh, p)
-  {
-    xproperties.override_defaults (*this);
-  }
-
-  ~hggroup (void) { }
-
-  base_properties& get_properties (void) { return xproperties; }
-
-  const base_properties& get_properties (void) const { return xproperties; }
-
-  bool valid_object (void) const { return true; }
-
-  void update_axis_limits (const std::string& axis_type);
-
-  void update_axis_limits (const std::string& axis_type,
-                           const graphics_handle& h);
-
-};
-
-// ---------------------------------------------------------------------
-
-class OCTINTERP_API uimenu : public base_graphics_object
-{
-public:
-  class OCTINTERP_API properties : public base_properties
-  {
-  public:
-    void remove_child (const graphics_handle& h)
-      {
-        base_properties::remove_child (h);
-      }
-
-    void adopt (const graphics_handle& h)
-      {
-        base_properties::adopt (h);
-      }
-
-    // See the genprops.awk script for an explanation of the
-    // properties declarations.
-
-    BEGIN_PROPERTIES (uimenu)
-      any_property __object__ , Matrix ()
-      string_property accelerator , ""
-      callback_property callback , Matrix()
-      bool_property checked , "off"
-      bool_property enable , "on"
-      color_property foregroundcolor , color_values (0, 0, 0)
-      string_property label , ""
-      double_property position , 9
-      bool_property separator , "off"
-      string_property fltk_label h , ""
-    END_PROPERTIES
-
-  protected:
-    void init (void)
-      { }
-  };
-
-private:
-  properties xproperties;
-
-public:
-  uimenu (const graphics_handle& mh, const graphics_handle& p)
-    : base_graphics_object (), xproperties (mh, p)
-  {
-    xproperties.override_defaults (*this);
-  }
-
-  ~uimenu (void) { }
-
-  base_properties& get_properties (void) { return xproperties; }
-
-  const base_properties& get_properties (void) const { return xproperties; }
-
-  bool valid_object (void) const { return true; }
-
-};
-
-// ---------------------------------------------------------------------
-
-class OCTINTERP_API uicontextmenu : public base_graphics_object
-{
-public:
-  class OCTINTERP_API properties : public base_properties
-  {
-  public:
-    // See the genprops.awk script for an explanation of the
-    // properties declarations.
-
-    BEGIN_PROPERTIES (uicontextmenu)
-      any_property __object__ , Matrix ()
-      callback_property callback , Matrix()
-      array_property position , Matrix (1, 2, 0.0)
-    END_PROPERTIES
-
-  protected:
-    void init (void)
-      {
-        position.add_constraint (dim_vector (1, 2));
-        position.add_constraint (dim_vector (2, 1));
-        visible.set (octave_value (true));
-      }
-  };
-
-private:
-  properties xproperties;
-
-public:
-  uicontextmenu (const graphics_handle& mh, const graphics_handle& p)
-    : base_graphics_object (), xproperties (mh, p)
-  {
-    xproperties.override_defaults (*this);
-  }
-
-  ~uicontextmenu (void) { }
-
-  base_properties& get_properties (void) { return xproperties; }
-
-  const base_properties& get_properties (void) const { return xproperties; }
-
-  bool valid_object (void) const { return true; }
-
-};
-
-// ---------------------------------------------------------------------
-
-class OCTINTERP_API uicontrol : public base_graphics_object
-{
-public:
-  class OCTINTERP_API properties : public base_properties
-  {
-  public:
-    Matrix get_boundingbox (bool internal = false,
-                            const Matrix& parent_pix_size = Matrix ()) const;
-
-    double get_fontsize_points (double box_pix_height = 0) const;
-
-    // See the genprops.awk script for an explanation of the
-    // properties declarations.
-
-    BEGIN_PROPERTIES (uicontrol)
-      any_property __object__ , Matrix ()
-      color_property backgroundcolor , color_values (1, 1, 1)
-      callback_property callback , Matrix ()
-      array_property cdata , Matrix ()
-      bool_property clipping , "on"
-      radio_property enable , "{on}|inactive|off"
-      array_property extent rG , Matrix (1, 4, 0.0)
-      radio_property fontangle u , "{normal}|italic|oblique"
-      string_property fontname u , OCTAVE_DEFAULT_FONTNAME
-      double_property fontsize u , 10
-      radio_property fontunits S , "inches|centimeters|normalized|{points}|pixels"
-      radio_property fontweight u , "light|{normal}|demi|bold"
-      color_property foregroundcolor , color_values (0, 0, 0)
-      radio_property horizontalalignment , "{left}|center|right"
-      callback_property keypressfcn , Matrix ()
-      double_property listboxtop , 1
-      double_property max , 1
-      double_property min , 0
-      array_property position , default_control_position ()
-      array_property sliderstep , default_control_sliderstep ()
-      string_array_property string u , ""
-      radio_property style S , "{pushbutton}|togglebutton|radiobutton|checkbox|edit|text|slider|frame|listbox|popupmenu"
-      string_property tooltipstring , ""
-      radio_property units u , "normalized|inches|centimeters|points|{pixels}|characters"
-      row_vector_property value , Matrix (1, 1, 1.0)
-      radio_property verticalalignment , "top|{middle}|bottom"
-    END_PROPERTIES
-
-  private:
-    std::string cached_units;
-
-  protected:
-    void init (void)
-      {
-        cdata.add_constraint ("double");
-        cdata.add_constraint ("single");
-        cdata.add_constraint ("uint8");
-        cdata.add_constraint (dim_vector (-1, -1, 3));
-        position.add_constraint (dim_vector (1, 4));
-        sliderstep.add_constraint (dim_vector (1, 2));
-        cached_units = get_units ();
-      }
-    
-    void update_text_extent (void);
-
-    void update_string (void) { update_text_extent (); }
-    void update_fontname (void) { update_text_extent (); }
-    void update_fontsize (void) { update_text_extent (); }
-    void update_fontangle (void) { update_text_extent (); }
-    void update_fontweight (void) { update_text_extent (); }
-    void update_fontunits (const caseless_str& old_units);
-
-    void update_units (void);
-
-  };
-
-private:
-  properties xproperties;
-
-public:
-  uicontrol (const graphics_handle& mh, const graphics_handle& p)
-    : base_graphics_object (), xproperties (mh, p)
-  {
-    xproperties.override_defaults (*this);
-  }
-
-  ~uicontrol (void) { }
-
-  base_properties& get_properties (void) { return xproperties; }
-
-  const base_properties& get_properties (void) const { return xproperties; }
-
-  bool valid_object (void) const { return true; }
-};
-
-// ---------------------------------------------------------------------
-
-class OCTINTERP_API uipanel : public base_graphics_object
-{
-public:
-  class OCTINTERP_API properties : public base_properties
-  {
-  public:
-    Matrix get_boundingbox (bool internal = false,
-                            const Matrix& parent_pix_size = Matrix ()) const;
-
-    double get_fontsize_points (double box_pix_height = 0) const;
-
-    // See the genprops.awk script for an explanation of the
-    // properties declarations.
-
-    BEGIN_PROPERTIES (uipanel)
-      any_property __object__ , Matrix ()
-      color_property backgroundcolor , color_values (1, 1, 1)
-      radio_property bordertype , "none|{etchedin}|etchedout|beveledin|beveledout|line"
-      double_property borderwidth , 1
-      radio_property fontangle , "{normal}|italic|oblique"
-      string_property fontname , OCTAVE_DEFAULT_FONTNAME
-      double_property fontsize , 10
-      radio_property fontunits S , "inches|centimeters|normalized|{points}|pixels"
-      radio_property fontweight , "light|{normal}|demi|bold"
-      color_property foregroundcolor , color_values (0, 0, 0)
-      color_property highlightcolor , color_values (1, 1, 1)
-      array_property position , default_panel_position ()
-      callback_property resizefcn , Matrix ()
-      color_property shadowcolor , color_values (0, 0, 0)
-      string_property title , ""
-      radio_property titleposition , "{lefttop}|centertop|righttop|leftbottom|centerbottom|rightbottom"
-      radio_property units S , "{normalized}|inches|centimeters|points|pixels|characters"
-    END_PROPERTIES
-
-  protected:
-    void init (void)
-      {
-        position.add_constraint (dim_vector (1, 4));
-      }
-    
-    void update_units (const caseless_str& old_units);
-    void update_fontunits (const caseless_str& old_units);
-
-  };
-
-private:
-  properties xproperties;
-
-public:
-  uipanel (const graphics_handle& mh, const graphics_handle& p)
-    : base_graphics_object (), xproperties (mh, p)
-  {
-    xproperties.override_defaults (*this);
-  }
-
-  ~uipanel (void) { }
-
-  base_properties& get_properties (void) { return xproperties; }
-
-  const base_properties& get_properties (void) const { return xproperties; }
-
-  bool valid_object (void) const { return true; }
-};
-
-// ---------------------------------------------------------------------
-
-class OCTINTERP_API uitoolbar : public base_graphics_object
-{
-public:
-  class OCTINTERP_API properties : public base_properties
-  {
-  public:
-    // See the genprops.awk script for an explanation of the
-    // properties declarations.
-
-    BEGIN_PROPERTIES (uitoolbar)
-      any_property __object__ , Matrix ()
-    END_PROPERTIES
-
-  protected:
-    void init (void)
-      { }
-  };
-
-private:
-  properties xproperties;
-
-public:
-  uitoolbar (const graphics_handle& mh, const graphics_handle& p)
-    : base_graphics_object (), xproperties (mh, p), default_properties ()
-  {
-    xproperties.override_defaults (*this);
-  }
-
-  ~uitoolbar (void) { }
-
-  void override_defaults (base_graphics_object& obj)
-  {
-    // Allow parent (figure) to override first (properties knows how
-    // to find the parent object).
-    xproperties.override_defaults (obj);
-
-    // Now override with our defaults.  If the default_properties
-    // list includes the properties for all defaults (line,
-    // surface, etc.) then we don't have to know the type of OBJ
-    // here, we just call its set function and let it decide which
-    // properties from the list to use.
-    obj.set_from_list (default_properties);
-  }
-
-  void set (const caseless_str& name, const octave_value& value)
-  {
-    if (name.compare ("default", 7))
-      // strip "default", pass rest to function that will
-      // parse the remainder and add the element to the
-      // default_properties map.
-      default_properties.set (name.substr (7), value);
-    else
-      xproperties.set (name, value);
-  }
-
-  octave_value get (const caseless_str& name) const
-  {
-    octave_value retval;
-
-    if (name.compare ("default", 7))
-      retval = get_default (name.substr (7));
-    else
-      retval = xproperties.get (name);
-
-    return retval;
-  }
-
-  octave_value get_default (const caseless_str& name) const;
-
-  octave_value get_defaults (void) const
-  {
-    return default_properties.as_struct ("default");
-  }
-
-  base_properties& get_properties (void) { return xproperties; }
-
-  const base_properties& get_properties (void) const { return xproperties; }
-
-  bool valid_object (void) const { return true; }
-
-  void reset_default_properties (void);
-
-private:
-  property_list default_properties;
-};
-
-// ---------------------------------------------------------------------
-
-class OCTINTERP_API uipushtool : public base_graphics_object
-{
-public:
-  class OCTINTERP_API properties : public base_properties
-  {
-  public:
-    // See the genprops.awk script for an explanation of the
-    // properties declarations.
-
-    BEGIN_PROPERTIES (uipushtool)
-      any_property __object__ , Matrix ()
-      array_property cdata , Matrix ()
-      callback_property clickedcallback , Matrix()
-      bool_property enable , "on"
-      bool_property separator , "off"
-      string_property tooltipstring , ""
-    END_PROPERTIES
-
-  protected:
-    void init (void)
-      {
-        cdata.add_constraint ("double");
-        cdata.add_constraint ("single");
-        cdata.add_constraint ("uint8");
-        cdata.add_constraint (dim_vector (-1, -1, 3));
-      }
-  };
-
-private:
-  properties xproperties;
-
-public:
-  uipushtool (const graphics_handle& mh, const graphics_handle& p)
-    : base_graphics_object (), xproperties (mh, p)
-  {
-    xproperties.override_defaults (*this);
-  }
-
-  ~uipushtool (void) { }
-
-  base_properties& get_properties (void) { return xproperties; }
-
-  const base_properties& get_properties (void) const { return xproperties; }
-
-  bool valid_object (void) const { return true; }
-
-};
-
-// ---------------------------------------------------------------------
-
-class OCTINTERP_API uitoggletool : public base_graphics_object
-{
-public:
-  class OCTINTERP_API properties : public base_properties
-  {
-  public:
-    // See the genprops.awk script for an explanation of the
-    // properties declarations.
-
-    BEGIN_PROPERTIES (uitoggletool)
-      any_property __object__ , Matrix ()
-      array_property cdata , Matrix ()
-      callback_property clickedcallback , Matrix()
-      bool_property enable , "on"
-      callback_property offcallback , Matrix()
-      callback_property oncallback , Matrix()
-      bool_property separator , "off"
-      bool_property state , "off"
-      string_property tooltipstring , ""
-    END_PROPERTIES
-
-  protected:
-    void init (void)
-      {
-        cdata.add_constraint ("double");
-        cdata.add_constraint ("single");
-        cdata.add_constraint ("uint8");
-        cdata.add_constraint (dim_vector (-1, -1, 3));
-      }
-  };
-
-private:
-  properties xproperties;
-
-public:
-  uitoggletool (const graphics_handle& mh, const graphics_handle& p)
-    : base_graphics_object (), xproperties (mh, p)
-  {
-    xproperties.override_defaults (*this);
-  }
-
-  ~uitoggletool (void) { }
-
-  base_properties& get_properties (void) { return xproperties; }
-
-  const base_properties& get_properties (void) const { return xproperties; }
-
-  bool valid_object (void) const { return true; }
-
-};
-
-// ---------------------------------------------------------------------
-
-octave_value
-get_property_from_handle (double handle, const std::string &property,
-                          const std::string &func);
-bool
-set_property_in_handle (double handle, const std::string &property,
-                        const octave_value &arg, const std::string &func);
-
-// ---------------------------------------------------------------------
-
-class graphics_event;
-
-class
-base_graphics_event
-{
-public:
-  friend class graphics_event;
-
-  base_graphics_event (void) : count (1) { }
-
-  virtual ~base_graphics_event (void) { }
-
-  virtual void execute (void) = 0;
-
-private:
-  octave_refcount<int> count;
-};
-
-class
-graphics_event
-{
-public:
-  typedef void (*event_fcn) (void*);
-
-  graphics_event (void) : rep (0) { }
-
-  graphics_event (const graphics_event& e) : rep (e.rep)
-    {
-      rep->count++;
-    }
-
-  ~graphics_event (void)
-    {
-      if (rep && --rep->count == 0)
-        delete rep;
-    }
-
-  graphics_event& operator = (const graphics_event& e)
-    {
-      if (rep != e.rep)
-        {
-          if (rep && --rep->count == 0)
-            delete rep;
-
-          rep = e.rep;
-          if (rep)
-            rep->count++;
-        }
-
-      return *this;
-    }
-
-  void execute (void)
-    { if (rep) rep->execute (); }
-
-  bool ok (void) const
-    { return (rep != 0); }
-
-  static graphics_event
-      create_callback_event (const graphics_handle& h,
-                             const std::string& name,
-                             const octave_value& data = Matrix ());
-  
-  static graphics_event
-      create_callback_event (const graphics_handle& h,
-                             const octave_value& cb,
-                             const octave_value& data = Matrix ());
-
-  static graphics_event
-      create_function_event (event_fcn fcn, void *data = 0);
-
-  static graphics_event
-      create_set_event (const graphics_handle& h, const std::string& name,
-                        const octave_value& value,
-                        bool notify_toolkit = true);
-private:
-  base_graphics_event *rep;
-};
-
-class OCTINTERP_API gh_manager
-{
-protected:
-
-  gh_manager (void);
-
-public:
-
-  static void create_instance (void);
-
-  static bool instance_ok (void)
-  {
-    bool retval = true;
-
-    if (! instance)
-      create_instance ();
-
-    if (! instance)
-      {
-        ::error ("unable to create gh_manager!");
-
-        retval = false;
-      }
-
-    return retval;
-  }
-
-  static void cleanup_instance (void) { delete instance; instance = 0; }
-
-  static graphics_handle get_handle (bool integer_figure_handle)
-  {
-    return instance_ok ()
-      ? instance->do_get_handle (integer_figure_handle) : graphics_handle ();
-  }
-
-  static void free (const graphics_handle& h)
-  {
-    if (instance_ok ())
-      instance->do_free (h);
-  }
-
-  static void renumber_figure (const graphics_handle& old_gh,
-                               const graphics_handle& new_gh)
-  {
-    if (instance_ok ())
-      instance->do_renumber_figure (old_gh, new_gh);
-  }
-
-  static graphics_handle lookup (double val)
-  {
-    return instance_ok () ? instance->do_lookup (val) : graphics_handle ();
-  }
-
-  static graphics_handle lookup (const octave_value& val)
-  {
-    return val.is_real_scalar ()
-      ? lookup (val.double_value ()) : graphics_handle ();
-  }
-
-  static graphics_object get_object (double val)
-  {
-    return get_object (lookup (val));
-  }
-
-  static graphics_object get_object (const graphics_handle& h)
-  {
-    return instance_ok () ? instance->do_get_object (h) : graphics_object ();
-  }
-
-  static graphics_handle
-  make_graphics_handle (const std::string& go_name,
-                        const graphics_handle& parent,
-                        bool integer_figure_handle = false,
-                        bool do_createfcn = true,
-                        bool do_notify_toolkit = true)
-  {
-    return instance_ok ()
-      ? instance->do_make_graphics_handle (go_name, parent,
-                                           integer_figure_handle,
-                                           do_createfcn, do_notify_toolkit)
-      : graphics_handle ();
-  }
-
-  static graphics_handle make_figure_handle (double val,
-                                             bool do_notify_toolkit = true)
-  {
-    return instance_ok ()
-      ? instance->do_make_figure_handle (val, do_notify_toolkit)
-      : graphics_handle ();
-  }
-
-  static void push_figure (const graphics_handle& h)
-  {
-    if (instance_ok ())
-      instance->do_push_figure (h);
-  }
-
-  static void pop_figure (const graphics_handle& h)
-  {
-    if (instance_ok ())
-      instance->do_pop_figure (h);
-  }
-
-  static graphics_handle current_figure (void)
-  {
-    return instance_ok ()
-      ? instance->do_current_figure () : graphics_handle ();
-  }
-
-  static Matrix handle_list (bool show_hidden = false)
-  {
-    return instance_ok ()
-      ? instance->do_handle_list (show_hidden) : Matrix ();
-  }
-
-  static void lock (void)
-  {
-    if (instance_ok ())
-      instance->do_lock ();
-  }
-
-  static bool try_lock (void)
-  {
-    if (instance_ok ())
-      return instance->do_try_lock ();
-    else
-      return false;
-  }
-
-  static void unlock (void)
-  {
-    if (instance_ok ())
-      instance->do_unlock ();
-  }
-  
-  static Matrix figure_handle_list (bool show_hidden = false)
-  {
-    return instance_ok ()
-      ? instance->do_figure_handle_list (show_hidden) : Matrix ();
-  }
-
-  static void execute_listener (const graphics_handle& h,
-                                const octave_value& l)
-  {
-    if (instance_ok ())
-      instance->do_execute_listener (h, l);
-  }
-
-  static void execute_callback (const graphics_handle& h,
-                                const std::string& name,
-                                const octave_value& data = Matrix ())
-  {
-    octave_value cb;
-
-    if (true)
-      {
-        gh_manager::auto_lock lock;
-
-        graphics_object go = get_object (h);
-
-        if (go.valid_object ())
-          cb = go.get (name);
-      }
-
-    if (! error_state)
-      execute_callback (h, cb, data);
-  }
-
-  static void execute_callback (const graphics_handle& h,
-                                const octave_value& cb,
-                                const octave_value& data = Matrix ())
-  {
-    if (instance_ok ())
-      instance->do_execute_callback (h, cb, data);
-  }
-
-  static void post_callback (const graphics_handle& h,
-                             const std::string& name,
-                             const octave_value& data = Matrix ())
-  {
-    if (instance_ok ())
-      instance->do_post_callback (h, name, data);
-  }
-  
-  static void post_function (graphics_event::event_fcn fcn, void* data = 0)
-  {
-    if (instance_ok ())
-      instance->do_post_function (fcn, data);
-  }
-
-  static void post_set (const graphics_handle& h, const std::string& name,
-                        const octave_value& value, bool notify_toolkit = true)
-  {
-    if (instance_ok ())
-      instance->do_post_set (h, name, value, notify_toolkit);
-  }
-
-  static int process_events (void)
-  {
-    return (instance_ok () ?  instance->do_process_events () : 0);
-  }
-
-  static int flush_events (void)
-  {
-    return (instance_ok () ?  instance->do_process_events (true) : 0);
-  }
-
-  static void enable_event_processing (bool enable = true)
-    {
-      if (instance_ok ())
-        instance->do_enable_event_processing (enable);
-    }
-
-  static bool is_handle_visible (const graphics_handle& h)
-  {
-    bool retval = false;
-
-    graphics_object go = get_object (h);
-
-    if (go.valid_object ())
-      retval = go.is_handle_visible ();
-
-    return retval;
-  }
-
-  static void close_all_figures (void)
-  {
-    if (instance_ok ())
-      instance->do_close_all_figures ();
-  }
-
-public:
-  class auto_lock : public octave_autolock
-  {
-  public:
-    auto_lock (bool wait = true)
-      : octave_autolock (instance_ok ()
-                         ? instance->graphics_lock
-                         : octave_mutex (),
-                         wait)
-      { }
-
-  private:
-
-    // No copying!
-    auto_lock (const auto_lock&);
-    auto_lock& operator = (const auto_lock&);
-  };
-
-private:
-
-  static gh_manager *instance;
-
-  typedef std::map<graphics_handle, graphics_object>::iterator iterator;
-  typedef std::map<graphics_handle, graphics_object>::const_iterator const_iterator;
-
-  typedef std::set<graphics_handle>::iterator free_list_iterator;
-  typedef std::set<graphics_handle>::const_iterator const_free_list_iterator;
-
-  typedef std::list<graphics_handle>::iterator figure_list_iterator;
-  typedef std::list<graphics_handle>::const_iterator const_figure_list_iterator;
-
-  // A map of handles to graphics objects.
-  std::map<graphics_handle, graphics_object> handle_map;
-
-  // The available graphics handles.
-  std::set<graphics_handle> handle_free_list;
-
-  // The next handle available if handle_free_list is empty.
-  double next_handle;
-
-  // The allocated figure handles.  Top of the stack is most recently
-  // created.
-  std::list<graphics_handle> figure_list;
-
-  // The lock for accessing the graphics sytsem.
-  octave_mutex graphics_lock;
-
-  // The list of events queued by graphics toolkits.
-  std::list<graphics_event> event_queue;
-
-  // The stack of callback objects.
-  std::list<graphics_object> callback_objects;
-
-  // A flag telling whether event processing must be constantly on.
-  int event_processing;
-
-  graphics_handle do_get_handle (bool integer_figure_handle);
-
-  void do_free (const graphics_handle& h);
-
-  void do_renumber_figure (const graphics_handle& old_gh,
-                           const graphics_handle& new_gh);
-
-  graphics_handle do_lookup (double val)
-  {
-    iterator p = (xisnan (val) ? handle_map.end () : handle_map.find (val));
-
-    return (p != handle_map.end ()) ? p->first : graphics_handle ();
-  }
-
-  graphics_object do_get_object (const graphics_handle& h)
-  {
-    iterator p = (h.ok () ? handle_map.find (h) : handle_map.end ());
-
-    return (p != handle_map.end ()) ? p->second : graphics_object ();
-  }
-
-  graphics_handle do_make_graphics_handle (const std::string& go_name,
-                                           const graphics_handle& p,
-                                           bool integer_figure_handle,
-                                           bool do_createfcn,
-                                           bool do_notify_toolkit);
-
-  graphics_handle do_make_figure_handle (double val, bool do_notify_toolkit);
-
-  Matrix do_handle_list (bool show_hidden)
-  {
-    Matrix retval (1, handle_map.size ());
-
-    octave_idx_type i = 0;
-    for (const_iterator p = handle_map.begin (); p != handle_map.end (); p++)
-      {
-        graphics_handle h = p->first;
-
-        if (show_hidden || is_handle_visible (h))
-          retval(i++) = h.value ();
-      }
-
-    retval.resize (1, i);
-
-    return retval;
-  }
-
-  Matrix do_figure_handle_list (bool show_hidden)
-  {
-    Matrix retval (1, figure_list.size ());
-
-    octave_idx_type i = 0;
-    for (const_figure_list_iterator p = figure_list.begin ();
-         p != figure_list.end ();
-         p++)
-      {
-        graphics_handle h = *p;
-
-        if (show_hidden || is_handle_visible (h))
-          retval(i++) = h.value ();
-      }
-
-    retval.resize (1, i);
-
-    return retval;
-  }
-
-  void do_push_figure (const graphics_handle& h);
-
-  void do_pop_figure (const graphics_handle& h);
-
-  graphics_handle do_current_figure (void) const
-  {
-    graphics_handle retval;
-
-    for (const_figure_list_iterator p = figure_list.begin ();
-         p != figure_list.end ();
-         p++)
-      {
-        graphics_handle h = *p;
-
-        if (is_handle_visible (h))
-          retval = h;
-      }
-
-    return retval;
-  }
-
-  void do_lock (void) { graphics_lock.lock (); }
-
-  bool do_try_lock (void) { return graphics_lock.try_lock (); }
-
-  void do_unlock (void) { graphics_lock.unlock (); }
-
-  void do_execute_listener (const graphics_handle& h, const octave_value& l);
-
-  void do_execute_callback (const graphics_handle& h, const octave_value& cb,
-                            const octave_value& data);
-
-  void do_post_callback (const graphics_handle& h, const std::string name,
-                         const octave_value& data);
-  
-  void do_post_function (graphics_event::event_fcn fcn, void* fcn_data);
-
-  void do_post_set (const graphics_handle& h, const std::string name,
-                    const octave_value& value, bool notify_toolkit = true);
-
-  int do_process_events (bool force = false);
-
-  void do_close_all_figures (void);
-
-  static void restore_gcbo (void)
-  {
-    if (instance_ok ())
-      instance->do_restore_gcbo ();
-  }
-
-  void do_restore_gcbo (void);
-
-  void do_post_event (const graphics_event& e);
-
-  void do_enable_event_processing (bool enable = true);
-};
-
-void get_children_limits (double& min_val, double& max_val,
-                          double& min_pos, double& max_neg,
-                          const Matrix& kids, char limit_type);
-
-OCTINTERP_API int calc_dimensions (const graphics_object& gh);
-
-// This function is NOT equivalent to the scripting language function gcf.
-OCTINTERP_API graphics_handle gcf (void);
-
-// This function is NOT equivalent to the scripting language function gca.
-OCTINTERP_API graphics_handle gca (void);
-
-OCTINTERP_API void close_all_figures (void);
-
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/graphics.in.h	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,5830 @@
+/*
+
+Copyright (C) 2007-2012 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+#if !defined (graphics_h)
+#define graphics_h 1
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cctype>
+
+#include <algorithm>
+#include <list>
+#include <map>
+#include <set>
+#include <sstream>
+#include <string>
+
+#include "caseless-str.h"
+#include "lo-ieee.h"
+
+#include "gripes.h"
+#include "oct-map.h"
+#include "oct-mutex.h"
+#include "oct-refcount.h"
+#include "ov.h"
+#include "txt-eng-ft.h"
+
+// FIXME -- maybe this should be a configure option?
+// Matlab defaults to "Helvetica", but that causes problems for many
+// gnuplot users.
+#if !defined (OCTAVE_DEFAULT_FONTNAME)
+#define OCTAVE_DEFAULT_FONTNAME "*"
+#endif
+
+// ---------------------------------------------------------------------
+
+class graphics_handle
+{
+public:
+  graphics_handle (void) : val (octave_NaN) { }
+
+  graphics_handle (const octave_value& a);
+
+  graphics_handle (int a) : val (a) { }
+
+  graphics_handle (double a) : val (a) { }
+
+  graphics_handle (const graphics_handle& a) : val (a.val) { }
+
+  graphics_handle& operator = (const graphics_handle& a)
+  {
+    if (&a != this)
+      val = a.val;
+
+    return *this;
+  }
+
+  ~graphics_handle (void) { }
+
+  double value (void) const { return val; }
+
+  octave_value as_octave_value (void) const
+  {
+    return ok () ? octave_value (val) : octave_value (Matrix ());
+  }
+
+  // Prefix increment/decrement operators.
+  graphics_handle& operator ++ (void)
+  {
+    ++val;
+    return *this;
+  }
+
+  graphics_handle& operator -- (void)
+  {
+    --val;
+    return *this;
+  }
+
+  // Postfix increment/decrement operators.
+  const graphics_handle operator ++ (int)
+  {
+    graphics_handle old_value = *this;
+    ++(*this);
+    return old_value;
+  }
+
+  const graphics_handle operator -- (int)
+  {
+    graphics_handle old_value = *this;
+    --(*this);
+    return old_value;
+  }
+
+  bool ok (void) const { return ! xisnan (val); }
+
+private:
+  double val;
+};
+
+inline bool
+operator == (const graphics_handle& a, const graphics_handle& b)
+{
+  return a.value () == b.value ();
+}
+
+inline bool
+operator != (const graphics_handle& a, const graphics_handle& b)
+{
+  return a.value () != b.value ();
+}
+
+inline bool
+operator < (const graphics_handle& a, const graphics_handle& b)
+{
+  return a.value () < b.value ();
+}
+
+inline bool
+operator <= (const graphics_handle& a, const graphics_handle& b)
+{
+  return a.value () <= b.value ();
+}
+
+inline bool
+operator >= (const graphics_handle& a, const graphics_handle& b)
+{
+  return a.value () >= b.value ();
+}
+
+inline bool
+operator > (const graphics_handle& a, const graphics_handle& b)
+{
+  return a.value () > b.value ();
+}
+
+// ---------------------------------------------------------------------
+
+class base_scaler
+{
+public:
+  base_scaler (void) { }
+
+  virtual ~base_scaler (void) { }
+
+  virtual Matrix scale (const Matrix& m) const
+    {
+      error ("invalid axis scale");
+      return m;
+    }
+
+  virtual NDArray scale (const NDArray& m) const
+    {
+      error ("invalid axis scale");
+      return m;
+    }
+
+  virtual double scale (double d) const
+    {
+      error ("invalid axis scale");
+      return d;
+    }
+
+  virtual double unscale (double d) const
+    {
+      error ("invalid axis scale");
+      return d;
+    }
+
+  virtual base_scaler* clone () const
+    { return new base_scaler (); }
+
+  virtual bool is_linear (void) const
+    { return false; }
+};
+
+class lin_scaler : public base_scaler
+{
+public:
+  lin_scaler (void) { }
+
+  Matrix scale (const Matrix& m) const { return m; }
+
+  NDArray scale (const NDArray& m) const { return m; }
+
+  double scale (double d) const { return d; }
+
+  double unscale (double d) const { return d; }
+
+  base_scaler* clone (void) const { return new lin_scaler (); }
+
+  bool is_linear (void) const { return true; }
+};
+
+class log_scaler : public base_scaler
+{
+public:
+  log_scaler (void) { }
+
+  Matrix scale (const Matrix& m) const
+    {
+      Matrix retval (m.rows (), m.cols ());
+
+      do_scale (m.data (), retval.fortran_vec (), m.numel ());
+
+      return retval;
+    }
+
+  NDArray scale (const NDArray& m) const
+    {
+      NDArray retval (m.dims ());
+
+      do_scale (m.data (), retval.fortran_vec (), m.numel ());
+
+      return retval;
+    }
+
+  double scale (double d) const
+    { return log10 (d); }
+
+  double unscale (double d) const
+    { return pow (10.0, d); }
+
+  base_scaler* clone (void) const
+    { return new log_scaler (); }
+
+private:
+  void do_scale (const double *src, double *dest, int n) const
+    {
+      for (int i = 0; i < n; i++)
+        dest[i] = log10 (src[i]);
+    }
+};
+
+class neg_log_scaler : public base_scaler
+{
+public:
+  neg_log_scaler (void) { }
+
+  Matrix scale (const Matrix& m) const
+    {
+      Matrix retval (m.rows (), m.cols ());
+
+      do_scale (m.data (), retval.fortran_vec (), m.numel ());
+
+      return retval;
+    }
+
+  NDArray scale (const NDArray& m) const
+    {
+      NDArray retval (m.dims ());
+
+      do_scale (m.data (), retval.fortran_vec (), m.numel ());
+
+      return retval;
+    }
+
+  double scale (double d) const
+    { return -log10 (-d); }
+
+  double unscale (double d) const
+    { return -pow (10.0, -d); }
+
+  base_scaler* clone (void) const
+    { return new neg_log_scaler (); }
+
+private:
+  void do_scale (const double *src, double *dest, int n) const
+    {
+      for (int i = 0; i < n; i++)
+        dest[i] = -log10 (-src[i]);
+    }
+};
+
+class scaler
+{
+public:
+  scaler (void) : rep (new base_scaler ()) { }
+
+  scaler (const scaler& s) : rep (s.rep->clone()) { }
+
+  scaler (const std::string& s)
+    : rep (s == "log"
+           ? new log_scaler ()
+           : (s == "neglog" ? new neg_log_scaler ()
+              : (s == "linear" ? new lin_scaler () : new base_scaler ())))
+    { }
+
+  ~scaler (void) { delete rep; }
+
+  Matrix scale (const Matrix& m) const
+    { return rep->scale (m); }
+
+  NDArray scale (const NDArray& m) const
+    { return rep->scale (m); }
+
+  double scale (double d) const
+    { return rep->scale (d); }
+
+  double unscale (double d) const
+    { return rep->unscale (d); }
+
+  bool is_linear (void) const
+    { return rep->is_linear (); }
+
+  scaler& operator = (const scaler& s)
+    {
+      if (rep)
+        {
+          delete rep;
+          rep = 0;
+        }
+
+      rep = s.rep->clone ();
+
+      return *this;
+    }
+
+  scaler& operator = (const std::string& s)
+    {
+      if (rep)
+        {
+          delete rep;
+          rep = 0;
+        }
+
+      if (s == "log")
+        rep = new log_scaler ();
+      else if (s == "neglog")
+        rep = new neg_log_scaler ();
+      else if (s == "linear")
+        rep = new lin_scaler ();
+      else
+        rep = new base_scaler ();
+
+      return *this;
+    }
+
+private:
+  base_scaler *rep;
+};
+
+// ---------------------------------------------------------------------
+
+class property;
+
+enum listener_mode { POSTSET, PERSISTENT, PREDELETE };
+
+class base_property
+{
+public:
+  friend class property;
+
+public:
+  base_property (void)
+    : id (-1), count (1), name (), parent (), hidden (), listeners ()
+    { }
+
+  base_property (const std::string& s, const graphics_handle& h)
+    : id (-1), count (1), name (s), parent (h), hidden (false), listeners ()
+    { }
+
+  base_property (const base_property& p)
+    : id (-1), count (1), name (p.name), parent (p.parent),
+      hidden (p.hidden), listeners ()
+    { }
+
+  virtual ~base_property (void) { }
+
+  bool ok (void) const { return parent.ok (); }
+
+  std::string get_name (void) const { return name; }
+
+  void set_name (const std::string& s) { name = s; }
+
+  graphics_handle get_parent (void) const { return parent; }
+
+  void set_parent (const graphics_handle &h) { parent = h; }
+
+  bool is_hidden (void) const { return hidden; }
+
+  void set_hidden (bool flag) { hidden = flag; }
+
+  virtual bool is_radio (void) const { return false; }
+
+  int get_id (void) const { return id; }
+
+  void set_id (int d) { id = d; }
+
+  // Sets property value, notifies graphics toolkit.
+  // If do_run is true, runs associated listeners.
+  OCTINTERP_API bool set (const octave_value& v, bool do_run = true,
+                          bool do_notify_toolkit = true);
+
+  virtual octave_value get (void) const
+    {
+      error ("get: invalid property \"%s\"", name.c_str ());
+      return octave_value ();
+    }
+
+
+  virtual std::string values_as_string (void) const
+    {
+      error ("values_as_string: invalid property \"%s\"", name.c_str ());
+      return std::string ();
+    }
+
+  virtual Cell values_as_cell (void) const
+    {
+      error ("values_as_cell: invalid property \"%s\"", name.c_str ());
+      return Cell ();
+    }
+
+  base_property& operator = (const octave_value& val)
+    {
+      set (val);
+      return *this;
+    }
+
+  void add_listener (const octave_value& v, listener_mode mode = POSTSET)
+    {
+      octave_value_list& l = listeners[mode];
+      l.resize (l.length () + 1, v);
+    }
+
+  void delete_listener (const octave_value& v = octave_value (),
+                        listener_mode mode = POSTSET)
+    {
+      octave_value_list& l = listeners[mode];
+
+      if (v.is_defined ())
+        {
+          bool found = false;
+          int i;
+
+          for (i = 0; i < l.length (); i++)
+            {
+              if (v.internal_rep () == l(i).internal_rep ())
+                {
+                  found = true;
+                  break;
+                }
+            }
+          if (found)
+            {
+              for (int j = i; j < l.length() - 1; j++)
+                l(j) = l (j + 1);
+
+              l.resize (l.length () - 1);
+            }
+        }
+      else
+        {
+          if (mode == PERSISTENT)
+            l.resize (0);
+          else
+            {
+              octave_value_list lnew (0);
+              octave_value_list& lp = listeners[PERSISTENT];
+              for (int i = l.length () - 1; i >= 0 ; i--)
+                {
+                  for (int j = 0; j < lp.length (); j++)
+                    {
+                      if (l(i).internal_rep () == lp(j).internal_rep ())
+                        {
+                          lnew.resize (lnew.length () + 1, l(i));
+                          break;
+                        }
+                    }
+                }
+              l = lnew;
+            }
+        }
+
+    }
+
+  OCTINTERP_API void run_listeners (listener_mode mode = POSTSET);
+
+  virtual base_property* clone (void) const
+    { return new base_property (*this); }
+
+protected:
+  virtual bool do_set (const octave_value&)
+    {
+      error ("set: invalid property \"%s\"", name.c_str ());
+      return false;
+    }
+
+private:
+  typedef std::map<listener_mode, octave_value_list> listener_map;
+  typedef std::map<listener_mode, octave_value_list>::iterator listener_map_iterator;
+  typedef std::map<listener_mode, octave_value_list>::const_iterator listener_map_const_iterator;
+
+private:
+  int id;
+  octave_refcount<int> count;
+  std::string name;
+  graphics_handle parent;
+  bool hidden;
+  listener_map listeners;
+};
+
+// ---------------------------------------------------------------------
+
+class string_property : public base_property
+{
+public:
+  string_property (const std::string& s, const graphics_handle& h,
+                   const std::string& val = "")
+    : base_property (s, h), str (val) { }
+
+  string_property (const string_property& p)
+    : base_property (p), str (p.str) { }
+
+  octave_value get (void) const
+    { return octave_value (str); }
+
+  std::string string_value (void) const { return str; }
+
+  string_property& operator = (const octave_value& val)
+    {
+      set (val);
+      return *this;
+    }
+
+  base_property* clone (void) const { return new string_property (*this); }
+
+protected:
+  bool do_set (const octave_value& val)
+    {
+      if (val.is_string ())
+        {
+          std::string new_str = val.string_value ();
+
+          if (new_str != str)
+            {
+              str = new_str;
+              return true;
+            }
+        }
+      else
+        error ("set: invalid string property value for \"%s\"",
+               get_name ().c_str ());
+      return false;
+    }
+
+private:
+  std::string str;
+};
+
+// ---------------------------------------------------------------------
+
+class string_array_property : public base_property
+{
+public:
+  enum desired_enum { string_t, cell_t };
+
+  string_array_property (const std::string& s, const graphics_handle& h,
+                  const std::string& val = "", const char& sep = '|',
+                  const desired_enum& typ = string_t)
+    : base_property (s, h), desired_type (typ), separator (sep), str ()
+    {
+      size_t pos = 0;
+
+      while (true)
+        {
+          size_t new_pos = val.find_first_of (separator, pos);
+
+          if (new_pos == std::string::npos)
+            {
+              str.append (val.substr (pos));
+              break;
+            }
+          else
+            str.append (val.substr (pos, new_pos - pos));
+
+          pos = new_pos + 1;
+        }
+    }
+
+  string_array_property (const std::string& s, const graphics_handle& h,
+                  const Cell& c, const char& sep = '|',
+                  const desired_enum& typ = string_t)
+    : base_property (s, h), desired_type (typ), separator (sep), str ()
+    {
+      if (c.is_cellstr ())
+        {
+          string_vector strings (c.numel ());
+
+          for (octave_idx_type i = 0; i < c.numel (); i++)
+            strings[i] = c(i).string_value ();
+
+          str = strings;
+        }
+      else
+        error ("set: invalid order property value for \"%s\"",
+               get_name ().c_str ());
+    }
+
+  string_array_property (const string_array_property& p)
+    : base_property (p), desired_type (p.desired_type),
+      separator (p.separator), str (p.str) { }
+
+  octave_value get (void) const
+    {
+      if (desired_type == string_t)
+        return octave_value (string_value ());
+      else
+        return octave_value (cell_value ());
+    }
+
+  std::string string_value (void) const
+    {
+      std::string s;
+
+      for (octave_idx_type i = 0; i < str.length (); i++)
+        {
+          s += str[i];
+          if (i != str.length () - 1)
+            s += separator;
+        }
+
+      return s;
+    }
+
+  Cell cell_value (void) const {return Cell (str);}
+
+  string_vector string_vector_value (void) const { return str; }
+
+  string_array_property& operator = (const octave_value& val)
+    {
+      set (val);
+      return *this;
+    }
+
+  base_property* clone (void) const { return new string_array_property (*this); }
+
+protected:
+  bool do_set (const octave_value& val)
+    {
+      if (val.is_string ())
+        {
+          bool replace = false;
+          std::string new_str = val.string_value ();
+          string_vector strings;
+          size_t pos = 0;
+
+          while (pos != std::string::npos)
+            {
+              size_t new_pos = new_str.find_first_of (separator, pos);
+
+              if (new_pos == std::string::npos)
+                {
+                  strings.append (new_str.substr (pos));
+                  break;
+                }
+              else
+                strings.append (new_str.substr (pos, new_pos - pos));
+
+              pos = new_pos + 1;
+            }
+
+          if (str.numel () == strings.numel ())
+            {
+              for (octave_idx_type i = 0; i < str.numel (); i++)
+                if (strings[i] != str[i])
+                  {
+                    replace = true;
+                    break;
+                  }
+            }
+          else
+            replace = true;
+
+          desired_type = string_t;
+
+          if (replace)
+            {
+              str = strings;
+              return true;
+            }
+        }
+      else if (val.is_cellstr ())
+        {
+          bool replace = false;
+          Cell new_cell = val.cell_value ();
+
+          string_vector strings = new_cell.cellstr_value ();
+
+          octave_idx_type nel = strings.length ();
+
+          if (nel != str.length ())
+            replace = true;
+          else
+            {
+              for (octave_idx_type i = 0; i < nel; i++)
+                {
+                  if (strings[i] != str[i])
+                    {
+                      replace = true;
+                      break;
+                    }
+                }
+            }
+
+          desired_type = cell_t;
+
+          if (replace)
+            {
+              str = strings;
+              return true;
+            }
+        }
+      else
+        error ("set: invalid string property value for \"%s\"",
+               get_name ().c_str ());
+      return false;
+    }
+
+private:
+  desired_enum desired_type;
+  char separator;
+  string_vector str;
+};
+
+// ---------------------------------------------------------------------
+
+class text_label_property : public base_property
+{
+public:
+  enum type { char_t, cellstr_t };
+
+  text_label_property (const std::string& s, const graphics_handle& h,
+                       const std::string& val = "")
+    : base_property (s, h), value (val), stored_type (char_t)
+  { }
+
+  text_label_property (const std::string& s, const graphics_handle& h,
+                       const NDArray& nda)
+    : base_property (s, h), stored_type (char_t)
+  {
+    octave_idx_type nel = nda.numel ();
+
+    value.resize (nel);
+
+    for (octave_idx_type i = 0; i < nel; i++)
+      {
+        std::ostringstream buf;
+        buf << nda(i);
+        value[i] = buf.str ();
+      }
+  }
+
+  text_label_property (const std::string& s, const graphics_handle& h,
+                       const Cell& c)
+    : base_property (s, h), stored_type (cellstr_t)
+  {
+    octave_idx_type nel = c.numel ();
+
+    value.resize (nel);
+
+    for (octave_idx_type i = 0; i < nel; i++)
+      {
+        octave_value tmp = c(i);
+
+        if (tmp.is_string ())
+          value[i] = c(i).string_value ();
+        else
+          {
+            double d = c(i).double_value ();
+
+            if (! error_state)
+              {
+                std::ostringstream buf;
+                buf << d;
+                value[i] = buf.str ();
+              }
+            else
+              break;
+          }
+      }
+  }
+
+  text_label_property (const text_label_property& p)
+    : base_property (p), value (p.value), stored_type (p.stored_type)
+  { }
+
+  bool empty (void) const
+  {
+    octave_value tmp = get ();
+    return tmp.is_empty ();
+  }
+
+  octave_value get (void) const
+  {
+    if (stored_type == char_t)
+      return octave_value (char_value ());
+    else
+      return octave_value (cell_value ());
+  }
+
+  std::string string_value (void) const
+  {
+    return value.empty () ? std::string () : value[0];
+  }
+
+  string_vector string_vector_value (void) const { return value; }
+
+  charMatrix char_value (void) const { return charMatrix (value, ' '); }
+
+  Cell cell_value (void) const {return Cell (value); }
+
+  text_label_property& operator = (const octave_value& val)
+  {
+    set (val);
+    return *this;
+  }
+
+  base_property* clone (void) const { return new text_label_property (*this); }
+
+protected:
+
+  bool do_set (const octave_value& val)
+  {
+    if (val.is_string ())
+      {
+        value = val.all_strings ();
+
+        stored_type = char_t;
+      }
+    else if (val.is_cell ())
+      {
+        Cell c = val.cell_value ();
+
+        octave_idx_type nel = c.numel ();
+
+        value.resize (nel);
+
+        for (octave_idx_type i = 0; i < nel; i++)
+          {
+            octave_value tmp = c(i);
+
+            if (tmp.is_string ())
+              value[i] = c(i).string_value ();
+            else
+              {
+                double d = c(i).double_value ();
+
+                if (! error_state)
+                  {
+                    std::ostringstream buf;
+                    buf << d;
+                    value[i] = buf.str ();
+                  }
+                else
+                  return false;
+              }
+          }
+
+        stored_type = cellstr_t;
+      }
+    else
+      {
+        NDArray nda = val.array_value ();
+
+        if (! error_state)
+          {
+            octave_idx_type nel = nda.numel ();
+
+            value.resize (nel);
+
+            for (octave_idx_type i = 0; i < nel; i++)
+              {
+                std::ostringstream buf;
+                buf << nda(i);
+                value[i] = buf.str ();
+              }
+
+            stored_type = char_t;
+          }
+        else
+          {
+            error ("set: invalid string property value for \"%s\"",
+                   get_name ().c_str ());
+
+            return false;
+          }
+      }
+
+    return true;
+  }
+
+private:
+  string_vector value;
+  type stored_type;
+};
+
+// ---------------------------------------------------------------------
+
+class radio_values
+{
+public:
+  OCTINTERP_API radio_values (const std::string& opt_string = std::string ());
+
+  radio_values (const radio_values& a)
+    : default_val (a.default_val), possible_vals (a.possible_vals) { }
+
+  radio_values& operator = (const radio_values& a)
+  {
+    if (&a != this)
+      {
+        default_val = a.default_val;
+        possible_vals = a.possible_vals;
+      }
+
+    return *this;
+  }
+
+  std::string default_value (void) const { return default_val; }
+
+  bool validate (const std::string& val, std::string& match)
+  {
+    bool retval = true;
+
+    if (! contains (val, match))
+      {
+        error ("invalid value = %s", val.c_str ());
+        retval = false;
+      }
+
+    return retval;
+  }
+
+  bool contains (const std::string& val, std::string& match)
+  {
+    size_t k = 0;
+
+    size_t len = val.length ();
+
+    std::string first_match;
+
+    for (std::set<caseless_str>::const_iterator p = possible_vals.begin ();
+         p != possible_vals.end (); p++)
+      {
+        if (p->compare (val, len))
+          {
+            if (len == p->length ())
+              {
+                // We found a full match (consider the case of val ==
+                // "replace" with possible values "replace" and
+                // "replacechildren").  Any other matches are
+                // irrelevant, so set match and return now.
+
+                match = *p;
+                return true;
+              }
+            else
+              {
+                if (k == 0)
+                  first_match = *p;
+
+                k++;
+              }
+          }
+      }
+
+    if (k == 1)
+      {
+        match = first_match;
+        return true;
+      }
+    else
+      return false;
+  }
+
+  std::string values_as_string (void) const;
+
+  Cell values_as_cell (void) const;
+
+  octave_idx_type nelem (void) const { return possible_vals.size (); }
+
+private:
+  // Might also want to cache
+  std::string default_val;
+  std::set<caseless_str> possible_vals;
+};
+
+class radio_property : public base_property
+{
+public:
+  radio_property (const std::string& nm, const graphics_handle& h,
+                  const radio_values& v = radio_values ())
+    : base_property (nm, h),
+      vals (v), current_val (v.default_value ()) { }
+
+  radio_property (const std::string& nm, const graphics_handle& h,
+                  const std::string& v)
+    : base_property (nm, h),
+      vals (v), current_val (vals.default_value ()) { }
+
+  radio_property (const std::string& nm, const graphics_handle& h,
+                  const radio_values& v, const std::string& def)
+    : base_property (nm, h),
+      vals (v), current_val (def) { }
+
+  radio_property (const radio_property& p)
+    : base_property (p), vals (p.vals), current_val (p.current_val) { }
+
+  octave_value get (void) const { return octave_value (current_val); }
+
+  const std::string& current_value (void) const { return current_val; }
+
+  std::string values_as_string (void) const { return vals.values_as_string (); }
+
+  Cell values_as_cell (void) const { return vals.values_as_cell (); }
+
+  bool is (const caseless_str& v) const
+    { return v.compare (current_val); }
+
+  bool is_radio (void) const { return true; }
+
+  radio_property& operator = (const octave_value& val)
+    {
+      set (val);
+      return *this;
+    }
+
+  base_property* clone (void) const { return new radio_property (*this); }
+
+protected:
+  bool do_set (const octave_value& newval)
+  {
+    if (newval.is_string ())
+      {
+        std::string s = newval.string_value ();
+
+        std::string match;
+
+        if (vals.validate (s, match))
+          {
+            if (match != current_val)
+              {
+                if (s.length () != match.length ())
+                  warning_with_id ("Octave:abbreviated-property-match",
+                                   "%s: allowing %s to match %s value %s",
+                                   "set", s.c_str (), get_name ().c_str (),
+                                   match.c_str ());
+                current_val = match;
+                return true;
+              }
+          }
+        else
+          error ("set: invalid value for radio property \"%s\" (value = %s)",
+              get_name ().c_str (), s.c_str ());
+      }
+    else
+      error ("set: invalid value for radio property \"%s\"",
+          get_name ().c_str ());
+    return false;
+  }
+
+private:
+  radio_values vals;
+  std::string current_val;
+};
+
+// ---------------------------------------------------------------------
+
+class color_values
+{
+public:
+  color_values (double r = 0, double g = 0, double b = 1)
+    : xrgb (1, 3)
+  {
+    xrgb(0) = r;
+    xrgb(1) = g;
+    xrgb(2) = b;
+
+    validate ();
+  }
+
+  color_values (std::string str)
+    : xrgb (1, 3)
+  {
+    if (! str2rgb (str))
+      error ("invalid color specification: %s", str.c_str ());
+  }
+
+  color_values (const color_values& c)
+    : xrgb (c.xrgb)
+  { }
+
+  color_values& operator = (const color_values& c)
+  {
+    if (&c != this)
+      xrgb = c.xrgb;
+
+    return *this;
+  }
+
+  bool operator == (const color_values& c) const
+    {
+      return (xrgb(0) == c.xrgb(0)
+              && xrgb(1) == c.xrgb(1)
+              && xrgb(2) == c.xrgb(2));
+    }
+
+  bool operator != (const color_values& c) const
+    { return ! (*this == c); }
+
+  Matrix rgb (void) const { return xrgb; }
+
+  operator octave_value (void) const { return xrgb; }
+
+  void validate (void) const
+  {
+    for (int i = 0; i < 3; i++)
+      {
+        if (xrgb(i) < 0 ||  xrgb(i) > 1)
+          {
+            error ("invalid RGB color specification");
+            break;
+          }
+      }
+  }
+
+private:
+  Matrix xrgb;
+
+  OCTINTERP_API bool str2rgb (std::string str);
+};
+
+class color_property : public base_property
+{
+public:
+  color_property (const color_values& c, const radio_values& v)
+    : base_property ("", graphics_handle ()),
+      current_type (color_t), color_val (c), radio_val (v),
+      current_val (v.default_value ())
+  { }
+
+  color_property (const std::string& nm, const graphics_handle& h,
+                  const color_values& c = color_values (),
+                  const radio_values& v = radio_values ())
+    : base_property (nm, h),
+      current_type (color_t), color_val (c), radio_val (v),
+      current_val (v.default_value ())
+  { }
+
+  color_property (const std::string& nm, const graphics_handle& h,
+                  const radio_values& v)
+    : base_property (nm, h),
+      current_type (radio_t), color_val (color_values ()), radio_val (v),
+      current_val (v.default_value ())
+  { }
+
+  color_property (const std::string& nm, const graphics_handle& h,
+                  const std::string& v)
+    : base_property (nm, h),
+      current_type (radio_t), color_val (color_values ()), radio_val (v),
+      current_val (radio_val.default_value ())
+  { }
+
+  color_property (const std::string& nm, const graphics_handle& h,
+                  const color_property& v)
+    : base_property (nm, h),
+      current_type (v.current_type), color_val (v.color_val),
+      radio_val (v.radio_val), current_val (v.current_val)
+  { }
+
+  color_property (const color_property& p)
+    : base_property (p), current_type (p.current_type),
+      color_val (p.color_val), radio_val (p.radio_val),
+      current_val (p.current_val) { }
+
+  octave_value get (void) const
+  {
+    if (current_type == color_t)
+      return color_val.rgb ();
+
+    return current_val;
+  }
+
+  bool is_rgb (void) const { return (current_type == color_t); }
+
+  bool is_radio (void) const { return (current_type == radio_t); }
+
+  bool is (const std::string& v) const
+    { return (is_radio () && current_val == v); }
+
+  Matrix rgb (void) const
+  {
+    if (current_type != color_t)
+      error ("color has no rgb value");
+
+    return color_val.rgb ();
+  }
+
+  const std::string& current_value (void) const
+  {
+    if (current_type != radio_t)
+      error ("color has no radio value");
+
+    return current_val;
+  }
+
+  color_property& operator = (const octave_value& val)
+    {
+      set (val);
+      return *this;
+    }
+
+  operator octave_value (void) const { return get (); }
+
+  base_property* clone (void) const { return new color_property (*this); }
+
+  std::string values_as_string (void) const { return radio_val.values_as_string (); }
+
+  Cell values_as_cell (void) const { return radio_val.values_as_cell (); }
+
+protected:
+  OCTINTERP_API bool do_set (const octave_value& newval);
+
+private:
+  enum current_enum { color_t, radio_t } current_type;
+  color_values color_val;
+  radio_values radio_val;
+  std::string current_val;
+};
+
+// ---------------------------------------------------------------------
+
+class double_property : public base_property
+{
+public:
+  double_property (const std::string& nm, const graphics_handle& h,
+                   double d = 0)
+    : base_property (nm, h),
+      current_val (d) { }
+
+  double_property (const double_property& p)
+    : base_property (p), current_val (p.current_val) { }
+
+  octave_value get (void) const { return octave_value (current_val); }
+
+  double double_value (void) const { return current_val; }
+
+  double_property& operator = (const octave_value& val)
+    {
+      set (val);
+      return *this;
+    }
+
+  base_property* clone (void) const { return new double_property (*this); }
+
+protected:
+  bool do_set (const octave_value& v)
+    {
+      if (v.is_scalar_type () && v.is_real_type ())
+        {
+          double new_val = v.double_value ();
+
+          if (new_val != current_val)
+            {
+              current_val = new_val;
+              return true;
+            }
+        }
+      else
+        error ("set: invalid value for double property \"%s\"",
+               get_name ().c_str ());
+      return false;
+    }
+
+private:
+  double current_val;
+};
+
+// ---------------------------------------------------------------------
+
+class double_radio_property : public base_property
+{
+public:
+  double_radio_property (double d, const radio_values& v)
+      : base_property ("", graphics_handle ()),
+        current_type (double_t), dval (d), radio_val (v),
+        current_val (v.default_value ())
+  { }
+
+  double_radio_property (const std::string& nm, const graphics_handle& h,
+                         const std::string& v)
+      : base_property (nm, h),
+        current_type (radio_t), dval (0), radio_val (v),
+        current_val (radio_val.default_value ())
+  { }
+
+  double_radio_property (const std::string& nm, const graphics_handle& h,
+                         const double_radio_property& v)
+      : base_property (nm, h),
+        current_type (v.current_type), dval (v.dval),
+        radio_val (v.radio_val), current_val (v.current_val)
+  { }
+
+  double_radio_property (const double_radio_property& p)
+    : base_property (p), current_type (p.current_type),
+      dval (p.dval), radio_val (p.radio_val),
+      current_val (p.current_val) { }
+
+  octave_value get (void) const
+  {
+    if (current_type == double_t)
+      return dval;
+
+    return current_val;
+  }
+
+  bool is_double (void) const { return (current_type == double_t); }
+
+  bool is_radio (void) const { return (current_type == radio_t); }
+
+  bool is (const std::string& v) const
+    { return (is_radio () && current_val == v); }
+
+  double double_value (void) const
+  {
+    if (current_type != double_t)
+      error ("%s: property has no double", get_name ().c_str ());
+
+    return dval;
+  }
+
+  const std::string& current_value (void) const
+  {
+    if (current_type != radio_t)
+      error ("%s: property has no radio value");
+
+    return current_val;
+  }
+
+  double_radio_property& operator = (const octave_value& val)
+    {
+      set (val);
+      return *this;
+    }
+
+  operator octave_value (void) const { return get (); }
+
+  base_property* clone (void) const
+    { return new double_radio_property (*this); }
+
+protected:
+  OCTINTERP_API bool do_set (const octave_value& v);
+
+private:
+  enum current_enum { double_t, radio_t } current_type;
+  double dval;
+  radio_values radio_val;
+  std::string current_val;
+};
+
+// ---------------------------------------------------------------------
+
+class array_property : public base_property
+{
+public:
+  array_property (void)
+    : base_property ("", graphics_handle ()), data (Matrix ()),
+      xmin (), xmax (), xminp (), xmaxp (),
+      type_constraints (), size_constraints ()
+    {
+      get_data_limits ();
+    }
+
+  array_property (const std::string& nm, const graphics_handle& h,
+                  const octave_value& m)
+    : base_property (nm, h), data (m),
+      xmin (), xmax (), xminp (), xmaxp (),
+      type_constraints (), size_constraints ()
+    {
+      get_data_limits ();
+    }
+
+  // This copy constructor is only intended to be used
+  // internally to access min/max values; no need to
+  // copy constraints.
+  array_property (const array_property& p)
+    : base_property (p), data (p.data),
+      xmin (p.xmin), xmax (p.xmax), xminp (p.xminp), xmaxp (p.xmaxp),
+      type_constraints (), size_constraints ()
+    { }
+
+  octave_value get (void) const { return data; }
+
+  void add_constraint (const std::string& type)
+    { type_constraints.push_back (type); }
+
+  void add_constraint (const dim_vector& dims)
+    { size_constraints.push_back (dims); }
+
+  double min_val (void) const { return xmin; }
+  double max_val (void) const { return xmax; }
+  double min_pos (void) const { return xminp; }
+  double max_neg (void) const { return xmaxp; }
+
+  Matrix get_limits (void) const
+    {
+      Matrix m (1, 4);
+
+      m(0) = min_val ();
+      m(1) = max_val ();
+      m(2) = min_pos ();
+      m(3) = max_neg ();
+
+      return m;
+    }
+
+  array_property& operator = (const octave_value& val)
+    {
+      set (val);
+      return *this;
+    }
+
+  base_property* clone (void) const
+    {
+      array_property *p = new array_property (*this);
+
+      p->type_constraints = type_constraints;
+      p->size_constraints = size_constraints;
+
+      return p;
+    }
+
+protected:
+  bool do_set (const octave_value& v)
+    {
+      if (validate (v))
+        {
+          // FIXME -- should we check for actual data change?
+          if (! is_equal (v))
+            {
+              data = v;
+
+              get_data_limits ();
+
+              return true;
+            }
+        }
+      else
+        error ("invalid value for array property \"%s\"",
+               get_name ().c_str ());
+
+      return false;
+    }
+
+private:
+  OCTINTERP_API bool validate (const octave_value& v);
+
+  OCTINTERP_API bool is_equal (const octave_value& v) const;
+
+  OCTINTERP_API void get_data_limits (void);
+
+protected:
+  octave_value data;
+  double xmin;
+  double xmax;
+  double xminp;
+  double xmaxp;
+  std::list<std::string> type_constraints;
+  std::list<dim_vector> size_constraints;
+};
+
+class row_vector_property : public array_property
+{
+public:
+  row_vector_property (const std::string& nm, const graphics_handle& h,
+                       const octave_value& m)
+    : array_property (nm, h, m)
+  {
+    add_constraint (dim_vector (-1, 1));
+    add_constraint (dim_vector (1, -1));
+  }
+
+  row_vector_property (const row_vector_property& p)
+    : array_property (p)
+  {
+    add_constraint (dim_vector (-1, 1));
+    add_constraint (dim_vector (1, -1));
+  }
+
+  void add_constraint (const std::string& type)
+  {
+    array_property::add_constraint (type);
+  }
+
+  void add_constraint (const dim_vector& dims)
+  {
+    array_property::add_constraint (dims);
+  }
+
+  void add_constraint (octave_idx_type len)
+  {
+    size_constraints.remove (dim_vector (1, -1));
+    size_constraints.remove (dim_vector (-1, 1));
+
+    add_constraint (dim_vector (1, len));
+    add_constraint (dim_vector (len, 1));
+  }
+
+  row_vector_property& operator = (const octave_value& val)
+  {
+    set (val);
+    return *this;
+  }
+
+  base_property* clone (void) const
+    {
+      row_vector_property *p = new row_vector_property (*this);
+
+      p->type_constraints = type_constraints;
+      p->size_constraints = size_constraints;
+
+      return p;
+    }
+
+protected:
+  bool do_set (const octave_value& v)
+  {
+    bool retval = array_property::do_set (v);
+
+    if (! error_state)
+      {
+        dim_vector dv = data.dims ();
+
+        if (dv(0) > 1 && dv(1) == 1)
+          {
+            int tmp = dv(0);
+            dv(0) = dv(1);
+            dv(1) = tmp;
+
+            data = data.reshape (dv);
+          }
+
+        return retval;
+      }
+
+    return false;
+  }
+
+private:
+  OCTINTERP_API bool validate (const octave_value& v);
+};
+
+// ---------------------------------------------------------------------
+
+class bool_property : public radio_property
+{
+public:
+  bool_property (const std::string& nm, const graphics_handle& h,
+                 bool val)
+    : radio_property (nm, h, radio_values (val ? "{on}|off" : "on|{off}"))
+    { }
+
+  bool_property (const std::string& nm, const graphics_handle& h,
+                 const char* val)
+    : radio_property (nm, h, radio_values ("on|off"), val)
+    { }
+
+  bool_property (const bool_property& p)
+    : radio_property (p) { }
+
+  bool is_on (void) const { return is ("on"); }
+
+  bool_property& operator = (const octave_value& val)
+    {
+      set (val);
+      return *this;
+    }
+
+  base_property* clone (void) const { return new bool_property (*this); }
+
+protected:
+  bool do_set (const octave_value& val)
+    {
+      if (val.is_bool_scalar ())
+        return radio_property::do_set (val.bool_value () ? "on" : "off");
+      else
+        return radio_property::do_set (val);
+    }
+};
+
+// ---------------------------------------------------------------------
+
+class handle_property : public base_property
+{
+public:
+  handle_property (const std::string& nm, const graphics_handle& h,
+                   const graphics_handle& val = graphics_handle ())
+    : base_property (nm, h),
+      current_val (val) { }
+
+  handle_property (const handle_property& p)
+    : base_property (p), current_val (p.current_val) { }
+
+  octave_value get (void) const { return current_val.as_octave_value (); }
+
+  graphics_handle handle_value (void) const { return current_val; }
+
+  handle_property& operator = (const octave_value& val)
+    {
+      set (val);
+      return *this;
+    }
+
+  handle_property& operator = (const graphics_handle& h)
+    {
+      set (octave_value (h.value ()));
+      return *this;
+    }
+
+  base_property* clone (void) const { return new handle_property (*this); }
+
+protected:
+  OCTINTERP_API bool do_set (const octave_value& v);
+
+private:
+  graphics_handle current_val;
+};
+
+// ---------------------------------------------------------------------
+
+class any_property : public base_property
+{
+public:
+  any_property (const std::string& nm, const graphics_handle& h,
+                  const octave_value& m = Matrix ())
+    : base_property (nm, h), data (m) { }
+
+  any_property (const any_property& p)
+    : base_property (p), data (p.data) { }
+
+  octave_value get (void) const { return data; }
+
+  any_property& operator = (const octave_value& val)
+    {
+      set (val);
+      return *this;
+    }
+
+  base_property* clone (void) const { return new any_property (*this); }
+
+protected:
+  bool do_set (const octave_value& v)
+    {
+      data = v;
+      return true;
+    }
+
+private:
+  octave_value data;
+};
+
+// ---------------------------------------------------------------------
+
+class children_property : public base_property
+{
+public:
+  children_property (void)
+    : base_property ("", graphics_handle ()), children_list ()
+    {
+      do_init_children (Matrix ());
+    }
+
+  children_property (const std::string& nm, const graphics_handle& h,
+                     const Matrix &val)
+    : base_property (nm, h), children_list ()
+    {
+      do_init_children (val);
+    }
+
+  children_property (const children_property& p)
+    : base_property (p), children_list ()
+    {
+      do_init_children (p.children_list);
+    }
+
+  children_property& operator = (const octave_value& val)
+    {
+      set (val);
+      return *this;
+    }
+
+  base_property* clone (void) const { return new children_property (*this); }
+
+  bool remove_child (const double &val)
+    {
+      return do_remove_child (val);
+    }
+
+  void adopt (const double &val)
+    {
+      do_adopt_child (val);
+    }
+
+  Matrix get_children (void) const
+    {
+      return do_get_children (false);
+    }
+
+  Matrix get_hidden (void) const
+    {
+      return do_get_children (true);
+    }
+
+  Matrix get_all (void) const
+   {
+     return do_get_all_children ();
+   }
+
+  octave_value get (void) const
+    {
+      return octave_value (get_children ());
+    }
+
+  void delete_children (bool clear = false)
+    {
+      do_delete_children (clear);
+    }
+
+  void renumber (graphics_handle old_gh, graphics_handle new_gh)
+    {
+      for (children_list_iterator p = children_list.begin ();
+           p != children_list.end (); p++)
+        {
+          if (*p == old_gh)
+            {
+              *p = new_gh.value ();
+              return;
+            }
+        }
+
+      error ("children_list::renumber: child not found!");
+    }
+
+private:
+  typedef std::list<double>::iterator children_list_iterator;
+  typedef std::list<double>::const_iterator const_children_list_iterator;
+  std::list<double> children_list;
+
+protected:
+  bool do_set (const octave_value& val)
+    {
+      const Matrix new_kids = val.matrix_value ();
+
+      octave_idx_type nel = new_kids.numel ();
+
+      const Matrix new_kids_column = new_kids.reshape (dim_vector (nel, 1));
+
+      bool is_ok = true;
+
+      if (! error_state)
+        {
+          const Matrix visible_kids = do_get_children (false);
+
+          if (visible_kids.numel () == new_kids.numel ())
+            {
+              Matrix t1 = visible_kids.sort ();
+              Matrix t2 = new_kids_column.sort ();
+
+              if (t1 != t2)
+                is_ok = false;
+            }
+          else
+            is_ok = false;
+
+          if (! is_ok)
+            error ("set: new children must be a permutation of existing children");
+        }
+      else
+        {
+          is_ok = false;
+          error ("set: expecting children to be array of graphics handles");
+        }
+
+      if (is_ok)
+        {
+          Matrix tmp = new_kids_column.stack (get_hidden ());
+
+          children_list.clear ();
+
+          // Don't use do_init_children here, as that reverses the
+          // order of the list, and we don't want to do that if setting
+          // the child list directly.
+
+          for (octave_idx_type i = 0; i < tmp.numel (); i++)
+            children_list.push_back (tmp.xelem (i));
+        }
+
+      return is_ok;
+    }
+
+private:
+  void do_init_children (const Matrix &val)
+    {
+      children_list.clear ();
+      for (octave_idx_type i = 0; i < val.numel (); i++)
+        children_list.push_front (val.xelem (i));
+    }
+
+  void do_init_children (const std::list<double> &val)
+    {
+      children_list.clear ();
+      for (const_children_list_iterator p = val.begin (); p != val.end (); p++)
+        children_list.push_front (*p);
+    }
+
+  Matrix do_get_children (bool return_hidden) const;
+
+  Matrix do_get_all_children (void) const
+    {
+      Matrix retval (children_list.size (), 1);
+      octave_idx_type i  = 0;
+
+      for (const_children_list_iterator p = children_list.begin ();
+           p != children_list.end (); p++)
+        retval(i++) = *p;
+      return retval;
+    }
+
+  bool do_remove_child (double child)
+    {
+      for (children_list_iterator p = children_list.begin ();
+           p != children_list.end (); p++)
+        {
+          if (*p == child)
+            {
+              children_list.erase (p);
+              return true;
+            }
+        }
+      return false;
+    }
+
+  void do_adopt_child (const double &val)
+    {
+      children_list.push_front (val);
+    }
+
+  void do_delete_children (bool clear);
+};
+
+
+
+// ---------------------------------------------------------------------
+
+class callback_property : public base_property
+{
+public:
+  callback_property (const std::string& nm, const graphics_handle& h,
+                     const octave_value& m)
+    : base_property (nm, h), callback (m), executing (false) { }
+
+  callback_property (const callback_property& p)
+    : base_property (p), callback (p.callback), executing (false) { }
+
+  octave_value get (void) const { return callback; }
+
+  OCTINTERP_API void execute (const octave_value& data = octave_value ()) const;
+
+  bool is_defined (void) const
+    {
+      return (callback.is_defined () && ! callback.is_empty ());
+    }
+
+  callback_property& operator = (const octave_value& val)
+    {
+      set (val);
+      return *this;
+    }
+
+  base_property* clone (void) const { return new callback_property (*this); }
+
+protected:
+  bool do_set (const octave_value& v)
+    {
+      if (validate (v))
+        {
+          callback = v;
+          return true;
+        }
+      else
+        error ("invalid value for callback property \"%s\"",
+               get_name ().c_str ());
+      return false;
+    }
+
+private:
+  OCTINTERP_API bool validate (const octave_value& v) const;
+
+private:
+  octave_value callback;
+
+  // If TRUE, we are executing this callback.
+  mutable bool executing;
+};
+
+// ---------------------------------------------------------------------
+
+class property
+{
+public:
+  property (void) : rep (new base_property ("", graphics_handle ()))
+    { }
+
+  property (base_property *bp, bool persist = false) : rep (bp)
+    { if (persist) rep->count++; }
+
+  property (const property& p) : rep (p.rep)
+    {
+      rep->count++;
+    }
+
+  ~property (void)
+    {
+      if (--rep->count == 0)
+        delete rep;
+    }
+
+  bool ok (void) const
+    { return rep->ok (); }
+
+  std::string get_name (void) const
+    { return rep->get_name (); }
+
+  void set_name (const std::string& name)
+    { rep->set_name (name); }
+
+  graphics_handle get_parent (void) const
+    { return rep->get_parent (); }
+
+  void set_parent (const graphics_handle& h)
+    { rep->set_parent (h); }
+
+  bool is_hidden (void) const
+    { return rep->is_hidden (); }
+
+  void set_hidden (bool flag)
+    { rep->set_hidden (flag); }
+
+  bool is_radio (void) const
+    { return rep->is_radio (); }
+
+  int get_id (void) const
+    { return rep->get_id (); }
+
+  void set_id (int d)
+    { rep->set_id (d); }
+
+  octave_value get (void) const
+    { return rep->get (); }
+
+  bool set (const octave_value& val, bool do_run = true,
+            bool do_notify_toolkit = true)
+    { return rep->set (val, do_run, do_notify_toolkit); }
+
+  std::string values_as_string (void) const
+    { return rep->values_as_string (); }
+
+  Cell values_as_cell (void) const
+    { return rep->values_as_cell (); }
+
+  property& operator = (const octave_value& val)
+    {
+      *rep = val;
+      return *this;
+    }
+
+  property& operator = (const property& p)
+    {
+      if (rep && --rep->count == 0)
+        delete rep;
+
+      rep = p.rep;
+      rep->count++;
+
+      return *this;
+    }
+
+  void add_listener (const octave_value& v, listener_mode mode = POSTSET)
+    { rep->add_listener (v, mode); }
+
+  void delete_listener (const octave_value& v = octave_value (),
+                        listener_mode mode = POSTSET)
+  { rep->delete_listener (v, mode); }
+
+  void run_listeners (listener_mode mode = POSTSET)
+    { rep->run_listeners (mode); }
+
+  OCTINTERP_API static
+      property create (const std::string& name, const graphics_handle& parent,
+                       const caseless_str& type,
+                       const octave_value_list& args);
+
+  property clone (void) const
+    { return property (rep->clone ()); }
+
+  /*
+  const string_property& as_string_property (void) const
+    { return *(dynamic_cast<string_property*> (rep)); }
+
+  const radio_property& as_radio_property (void) const
+    { return *(dynamic_cast<radio_property*> (rep)); }
+
+  const color_property& as_color_property (void) const
+    { return *(dynamic_cast<color_property*> (rep)); }
+
+  const double_property& as_double_property (void) const
+    { return *(dynamic_cast<double_property*> (rep)); }
+
+  const bool_property& as_bool_property (void) const
+    { return *(dynamic_cast<bool_property*> (rep)); }
+
+  const handle_property& as_handle_property (void) const
+    { return *(dynamic_cast<handle_property*> (rep)); }
+    */
+
+private:
+  base_property *rep;
+};
+
+// ---------------------------------------------------------------------
+
+class property_list
+{
+public:
+  typedef std::map<std::string, octave_value> pval_map_type;
+  typedef std::map<std::string, pval_map_type> plist_map_type;
+
+  typedef pval_map_type::iterator pval_map_iterator;
+  typedef pval_map_type::const_iterator pval_map_const_iterator;
+
+  typedef plist_map_type::iterator plist_map_iterator;
+  typedef plist_map_type::const_iterator plist_map_const_iterator;
+
+  property_list (const plist_map_type& m = plist_map_type ())
+    : plist_map (m) { }
+
+  ~property_list (void) { }
+
+  void set (const caseless_str& name, const octave_value& val);
+
+  octave_value lookup (const caseless_str& name) const;
+
+  plist_map_iterator begin (void) { return plist_map.begin (); }
+  plist_map_const_iterator begin (void) const { return plist_map.begin (); }
+
+  plist_map_iterator end (void) { return plist_map.end (); }
+  plist_map_const_iterator end (void) const { return plist_map.end (); }
+
+  plist_map_iterator find (const std::string& go_name)
+  {
+    return plist_map.find (go_name);
+  }
+
+  plist_map_const_iterator find (const std::string& go_name) const
+  {
+    return plist_map.find (go_name);
+  }
+
+  octave_scalar_map as_struct (const std::string& prefix_arg) const;
+
+private:
+  plist_map_type plist_map;
+};
+
+// ---------------------------------------------------------------------
+
+class graphics_toolkit;
+class graphics_object;
+
+class base_graphics_toolkit
+{
+public:
+  friend class graphics_toolkit;
+
+public:
+  base_graphics_toolkit (const std::string& nm)
+      : name (nm), count (0) { }
+
+  virtual ~base_graphics_toolkit (void) { }
+
+  std::string get_name (void) const { return name; }
+
+  virtual bool is_valid (void) const { return false; }
+
+  virtual void redraw_figure (const graphics_object&) const
+    { gripe_invalid ("redraw_figure"); }
+
+  virtual void print_figure (const graphics_object&, const std::string&,
+                             const std::string&, bool,
+                             const std::string& = "") const
+    { gripe_invalid ("print_figure"); }
+
+  virtual Matrix get_canvas_size (const graphics_handle&) const
+    {
+      gripe_invalid ("get_canvas_size");
+      return Matrix (1, 2, 0.0);
+    }
+
+  virtual double get_screen_resolution (void) const
+    {
+      gripe_invalid ("get_screen_resolution");
+      return 72.0;
+    }
+
+  virtual Matrix get_screen_size (void) const
+    {
+      gripe_invalid ("get_screen_size");
+      return Matrix (1, 2, 0.0);
+    }
+
+  // Callback function executed when the given graphics object
+  // changes.  This allows the graphics toolkit to act on property
+  // changes if needed.
+  virtual void update (const graphics_object&, int)
+    { gripe_invalid ("base_graphics_toolkit::update"); }
+
+  void update (const graphics_handle&, int);
+
+  // Callback function executed when the given graphics object is
+  // created.  This allows the graphics toolkit to do toolkit-specific
+  // initializations for a newly created object.
+  virtual bool initialize (const graphics_object&)
+    { gripe_invalid ("base_graphics_toolkit::initialize"); return false; }
+
+  bool initialize (const graphics_handle&);
+
+  // Callback function executed just prior to deleting the given
+  // graphics object.  This allows the graphics toolkit to perform
+  // toolkit-specific cleanup operations before an object is deleted.
+  virtual void finalize (const graphics_object&)
+    { gripe_invalid ("base_graphics_toolkit::finalize"); }
+
+  void finalize (const graphics_handle&);
+
+  // Close the graphics toolkit.
+  virtual void close (void)
+  { gripe_invalid ("base_graphics_toolkit::close"); }
+
+private:
+  std::string name;
+  octave_refcount<int> count;
+
+private:
+  void gripe_invalid (const std::string& fname) const
+    {
+      if (! is_valid ())
+        error ("%s: invalid graphics toolkit", fname.c_str ());
+    }
+};
+
+class graphics_toolkit
+{
+public:
+  graphics_toolkit (void)
+      : rep (new base_graphics_toolkit ("unknown"))
+    {
+      rep->count++;
+    }
+
+  graphics_toolkit (base_graphics_toolkit* b)
+      : rep (b)
+    {
+      rep->count++;
+    }
+
+  graphics_toolkit (const graphics_toolkit& b)
+      : rep (b.rep)
+    {
+      rep->count++;
+    }
+
+  ~graphics_toolkit (void)
+    {
+      if (--rep->count == 0)
+        delete rep;
+    }
+
+  graphics_toolkit& operator = (const graphics_toolkit& b)
+    {
+      if (rep != b.rep)
+        {
+          if (--rep->count == 0)
+            delete rep;
+
+          rep = b.rep;
+          rep->count++;
+        }
+
+      return *this;
+    }
+
+  operator bool (void) const { return rep->is_valid (); }
+
+  std::string get_name (void) const { return rep->get_name (); }
+
+  void redraw_figure (const graphics_object& go) const
+    { rep->redraw_figure (go); }
+
+  void print_figure (const graphics_object& go, const std::string& term,
+                     const std::string& file, bool mono,
+                     const std::string& debug_file = "") const
+    { rep->print_figure (go, term, file, mono, debug_file); }
+
+  Matrix get_canvas_size (const graphics_handle& fh) const
+    { return rep->get_canvas_size (fh); }
+
+  double get_screen_resolution (void) const
+    { return rep->get_screen_resolution (); }
+
+  Matrix get_screen_size (void) const
+    { return rep->get_screen_size (); }
+
+  // Notifies graphics toolkit that object't property has changed.
+  void update (const graphics_object& go, int id)
+    { rep->update (go, id); }
+
+  void update (const graphics_handle& h, int id)
+    { rep->update (h, id); }
+
+  // Notifies graphics toolkit that new object was created.
+  bool initialize (const graphics_object& go)
+    { return rep->initialize (go); }
+
+  bool initialize (const graphics_handle& h)
+    { return rep->initialize (h); }
+
+  // Notifies graphics toolkit that object was destroyed.
+  // This is called only for explicitly deleted object. Children are
+  // deleted implicitly and graphics toolkit isn't notified.
+  void finalize (const graphics_object& go)
+    { rep->finalize (go); }
+
+  void finalize (const graphics_handle& h)
+    { rep->finalize (h); }
+
+  // Close the graphics toolkit.
+  void close (void) { rep->close (); }
+
+private:
+
+  base_graphics_toolkit *rep;
+};
+
+class gtk_manager
+{
+public:
+
+  static graphics_toolkit get_toolkit (void)
+  {
+    return instance_ok () ? instance->do_get_toolkit () : graphics_toolkit ();
+  }
+
+  static void register_toolkit (const std::string& name)
+  {
+    if (instance_ok ())
+      instance->do_register_toolkit (name);
+  }
+
+  static void unregister_toolkit (const std::string& name)
+  {
+    if (instance_ok ())
+      instance->do_unregister_toolkit (name);
+  }
+
+  static void load_toolkit (const graphics_toolkit& tk)
+  {
+    if (instance_ok ())
+      instance->do_load_toolkit (tk);
+  }
+
+  static void unload_toolkit (const std::string& name)
+  {
+    if (instance_ok ())
+      instance->do_unload_toolkit (name);
+  }
+
+  static graphics_toolkit find_toolkit (const std::string& name)
+  {
+    return instance_ok ()
+      ? instance->do_find_toolkit (name) : graphics_toolkit ();
+  }
+
+  static Cell available_toolkits_list (void)
+  {
+    return instance_ok () ? instance->do_available_toolkits_list () : Cell ();
+  }
+
+  static Cell loaded_toolkits_list (void)
+  {
+    return instance_ok () ? instance->do_loaded_toolkits_list () : Cell ();
+  }
+
+  static void unload_all_toolkits (void)
+  {
+    if (instance_ok ())
+      instance->do_unload_all_toolkits ();
+  }
+
+  static std::string default_toolkit (void)
+  {
+    return instance_ok () ? instance->do_default_toolkit () : std::string ();
+  }
+
+private:
+
+  // FIXME -- default toolkit should be configurable.
+
+  gtk_manager (void)
+    : dtk ("gnuplot"), available_toolkits (), loaded_toolkits () { }
+
+  ~gtk_manager (void) { }
+
+  OCTINTERP_API static void create_instance (void);
+
+  static bool instance_ok (void)
+  {
+    bool retval = true;
+
+    if (! instance)
+      create_instance ();
+
+    if (! instance)
+      {
+        ::error ("unable to create gh_manager!");
+
+        retval = false;
+      }
+
+    return retval;
+  }
+
+  static void cleanup_instance (void) { delete instance; instance = 0; }
+
+  OCTINTERP_API static gtk_manager *instance;
+
+  // The name of the default toolkit.
+  std::string dtk;
+
+  // The list of toolkits that we know about.
+  std::set<std::string> available_toolkits;
+
+  // The list of toolkits we have actually loaded.
+  std::map<std::string, graphics_toolkit> loaded_toolkits;
+
+  typedef std::set<std::string>::iterator available_toolkits_iterator;
+
+  typedef std::set<std::string>::const_iterator
+    const_available_toolkits_iterator;
+
+  typedef std::map<std::string, graphics_toolkit>::iterator
+    loaded_toolkits_iterator;
+
+  typedef std::map<std::string, graphics_toolkit>::const_iterator
+    const_loaded_toolkits_iterator;
+
+  graphics_toolkit do_get_toolkit (void) const;
+
+  void do_register_toolkit (const std::string& name)
+  {
+    available_toolkits.insert (name);
+  }
+
+  void do_unregister_toolkit (const std::string& name)
+  {
+    available_toolkits.erase (name);
+  }
+
+  void do_load_toolkit (const graphics_toolkit& tk)
+  {
+    loaded_toolkits[tk.get_name ()] = tk;
+  }
+
+  void do_unload_toolkit (const std::string& name)
+  {
+    loaded_toolkits.erase (name);
+  }
+
+  graphics_toolkit do_find_toolkit (const std::string& name) const
+  {
+    const_loaded_toolkits_iterator p = loaded_toolkits.find (name);
+
+    if (p != loaded_toolkits.end ())
+      return p->second;
+    else
+      return graphics_toolkit ();
+  }
+
+  Cell do_available_toolkits_list (void) const
+  {
+    Cell m (1 , available_toolkits.size ());
+    
+    octave_idx_type i = 0;
+    for (const_available_toolkits_iterator p = available_toolkits.begin ();
+         p !=  available_toolkits.end (); p++)
+      m(i++) = *p;
+
+    return m;
+  }
+
+  Cell do_loaded_toolkits_list (void) const
+  {
+    Cell m (1 , loaded_toolkits.size ());
+    
+    octave_idx_type i = 0;
+    for (const_loaded_toolkits_iterator p = loaded_toolkits.begin ();
+         p !=  loaded_toolkits.end (); p++)
+      m(i++) = p->first;
+
+    return m;
+  }
+
+  void do_unload_all_toolkits (void)
+  {
+    while (! loaded_toolkits.empty ())
+      {
+        loaded_toolkits_iterator p = loaded_toolkits.begin ();
+
+        std::string name = p->first;
+
+        p->second.close ();
+
+        // The toolkit may have unloaded itself.  If not, we'll do
+        // it here.
+        if (loaded_toolkits.find (name) != loaded_toolkits.end ())
+          unload_toolkit (name);
+      }
+  }
+
+  std::string do_default_toolkit (void) { return dtk; }
+};
+
+// ---------------------------------------------------------------------
+
+class base_graphics_object;
+class graphics_object;
+
+class OCTINTERP_API base_properties
+{
+public:
+  base_properties (const std::string& ty = "unknown",
+                   const graphics_handle& mh = graphics_handle (),
+                   const graphics_handle& p = graphics_handle ());
+
+  virtual ~base_properties (void) { }
+
+  virtual std::string graphics_object_name (void) const { return "unknonwn"; }
+
+  void mark_modified (void);
+
+  void override_defaults (base_graphics_object& obj);
+
+  virtual void init_integerhandle (const octave_value&)
+    {
+      panic_impossible ();
+    }
+
+  // Look through DEFAULTS for properties with given CLASS_NAME, and
+  // apply them to the current object with set (virtual method).
+
+  void set_from_list (base_graphics_object& obj, property_list& defaults);
+
+  void insert_property (const std::string& name, property p)
+    {
+      p.set_name (name);
+      p.set_parent (__myhandle__);
+      all_props[name] = p;
+    }
+
+  virtual void set (const caseless_str&, const octave_value&);
+
+  virtual octave_value get (const caseless_str& pname) const;
+
+  virtual octave_value get (const std::string& pname) const
+  {
+    return get (caseless_str (pname));
+  }
+
+  virtual octave_value get (const char *pname) const
+  {
+    return get (caseless_str (pname));
+  }
+
+  virtual octave_value get (bool all = false) const;
+
+  virtual property get_property (const caseless_str& pname);
+
+  virtual bool has_property (const caseless_str&) const
+  {
+    panic_impossible ();
+    return false;
+  }
+
+  bool is_modified (void) const { return is___modified__ (); }
+
+  virtual void remove_child (const graphics_handle& h)
+    {
+      if (children.remove_child (h.value ()))
+        mark_modified ();
+    }
+
+  virtual void adopt (const graphics_handle& h)
+  {
+    children.adopt (h.value ());
+    mark_modified ();
+  }
+
+  virtual graphics_toolkit get_toolkit (void) const;
+
+  virtual Matrix get_boundingbox (bool /*internal*/ = false,
+                                  const Matrix& /*parent_pix_size*/ = Matrix ()) const
+    { return Matrix (1, 4, 0.0); }
+
+  virtual void update_boundingbox (void);
+
+  virtual void update_autopos (const std::string& elem_type);
+
+  virtual void add_listener (const caseless_str&, const octave_value&,
+                             listener_mode = POSTSET);
+
+  virtual void delete_listener (const caseless_str&, const octave_value&,
+                                listener_mode = POSTSET);
+
+  void set_tag (const octave_value& val) { tag = val; }
+
+  void set_parent (const octave_value& val);
+
+  Matrix get_children (void) const
+    {
+      return children.get_children ();
+    }
+
+  Matrix get_all_children (void) const
+    {
+      return children.get_all ();
+    }
+
+  Matrix get_hidden_children (void) const
+    {
+      return children.get_hidden ();
+    }
+
+  void set_modified (const octave_value& val) { set___modified__ (val); }
+
+  void set___modified__ (const octave_value& val) { __modified__ = val; }
+
+  void reparent (const graphics_handle& new_parent) { parent = new_parent; }
+
+  // Update data limits for AXIS_TYPE (xdata, ydata, etc.) in the parent
+  // axes object.
+
+  virtual void update_axis_limits (const std::string& axis_type) const;
+
+  virtual void update_axis_limits (const std::string& axis_type,
+                                   const graphics_handle& h) const;
+
+  virtual void delete_children (bool clear = false)
+    {
+      children.delete_children (clear);
+    }
+
+  void renumber_child (graphics_handle old_gh, graphics_handle new_gh)
+    {
+      children.renumber (old_gh, new_gh);
+    }
+
+  void renumber_parent (graphics_handle new_gh)
+    {
+      parent = new_gh;
+    }
+
+  static property_list::pval_map_type factory_defaults (void);
+
+  // FIXME -- these functions should be generated automatically by the
+  // genprops.awk script.
+  //
+  // EMIT_BASE_PROPERTIES_GET_FUNCTIONS
+
+  virtual octave_value get_xlim (void) const { return octave_value (); }
+  virtual octave_value get_ylim (void) const { return octave_value (); }
+  virtual octave_value get_zlim (void) const { return octave_value (); }
+  virtual octave_value get_clim (void) const { return octave_value (); }
+  virtual octave_value get_alim (void) const { return octave_value (); }
+
+  virtual bool is_xliminclude (void) const { return false; }
+  virtual bool is_yliminclude (void) const { return false; }
+  virtual bool is_zliminclude (void) const { return false; }
+  virtual bool is_climinclude (void) const { return false; }
+  virtual bool is_aliminclude (void) const { return false; }
+
+  bool is_handle_visible (void) const;
+
+  std::set<std::string> dynamic_property_names (void) const;
+
+  bool has_dynamic_property (const std::string& pname);
+
+protected:
+  std::set<std::string> dynamic_properties;
+
+  void set_dynamic (const caseless_str& pname, const octave_value& val);
+
+  octave_value get_dynamic (const caseless_str& pname) const;
+
+  octave_value get_dynamic (bool all = false) const;
+
+  property get_property_dynamic (const caseless_str& pname);
+
+  BEGIN_BASE_PROPERTIES
+    // properties common to all objects
+    bool_property beingdeleted , "off"
+    radio_property busyaction , "{queue}|cancel"
+    callback_property buttondownfcn , Matrix ()
+    children_property children gf , Matrix ()
+    bool_property clipping , "on"
+    callback_property createfcn , Matrix ()
+    callback_property deletefcn , Matrix ()
+    radio_property handlevisibility , "{on}|callback|off"
+    bool_property hittest , "on"
+    bool_property interruptible , "on"
+    handle_property parent fs , p
+    bool_property selected , "off"
+    bool_property selectionhighlight , "on"
+    string_property tag s , ""
+    string_property type frs , ty
+    any_property userdata , Matrix ()
+    bool_property visible , "on"
+    // additional (octave-specific) properties
+    bool_property __modified__ s , "on"
+    graphics_handle __myhandle__ fhrs , mh
+    // FIXME -- should this really be here?
+    handle_property uicontextmenu , graphics_handle ()
+  END_PROPERTIES
+
+protected:
+  struct cmp_caseless_str
+    {
+      bool operator () (const caseless_str &a, const caseless_str &b) const
+        {
+          std::string a1 = a;
+          std::transform (a1.begin (), a1.end (), a1.begin (), tolower);
+          std::string b1 = b;
+          std::transform (b1.begin (), b1.end (), b1.begin (), tolower);
+
+          return a1 < b1;
+        }
+    };
+
+  std::map<caseless_str, property, cmp_caseless_str> all_props;
+
+protected:
+  void insert_static_property (const std::string& name, base_property& p)
+    { insert_property (name, property (&p, true)); }
+
+  virtual void init (void) { }
+};
+
+class OCTINTERP_API base_graphics_object
+{
+public:
+  friend class graphics_object;
+
+  base_graphics_object (void) : count (1), toolkit_flag (false) { }
+
+  virtual ~base_graphics_object (void) { }
+
+  virtual void mark_modified (void)
+  {
+    if (valid_object ())
+      get_properties ().mark_modified ();
+    else
+      error ("base_graphics_object::mark_modified: invalid graphics object");
+  }
+
+  virtual void override_defaults (base_graphics_object& obj)
+  {
+    if (valid_object ())
+      get_properties ().override_defaults (obj);
+    else
+      error ("base_graphics_object::override_defaults: invalid graphics object");
+  }
+
+  virtual void set_from_list (property_list& plist)
+  {
+    if (valid_object ())
+      get_properties ().set_from_list (*this, plist);
+    else
+      error ("base_graphics_object::set_from_list: invalid graphics object");
+  }
+
+  virtual void set (const caseless_str& pname, const octave_value& pval)
+  {
+    if (valid_object ())
+      get_properties ().set (pname, pval);
+    else
+      error ("base_graphics_object::set: invalid graphics object");
+  }
+
+  virtual void set_defaults (const std::string&)
+  {
+    error ("base_graphics_object::set_defaults: invalid graphics object");
+  }
+
+  virtual octave_value get (bool all = false) const
+  {
+    if (valid_object ())
+      return get_properties ().get (all);
+    else
+      {
+        error ("base_graphics_object::get: invalid graphics object");
+        return octave_value ();
+      }
+  }
+
+  virtual octave_value get (const caseless_str& pname) const
+  {
+    if (valid_object ())
+      return get_properties ().get (pname);
+    else
+      {
+        error ("base_graphics_object::get: invalid graphics object");
+        return octave_value ();
+      }
+  }
+
+  virtual octave_value get_default (const caseless_str&) const;
+
+  virtual octave_value get_factory_default (const caseless_str&) const;
+
+  virtual octave_value get_defaults (void) const
+  {
+    error ("base_graphics_object::get_defaults: invalid graphics object");
+    return octave_value ();
+  }
+
+  virtual octave_value get_factory_defaults (void) const
+  {
+    error ("base_graphics_object::get_factory_defaults: invalid graphics object");
+    return octave_value ();
+  }
+
+  virtual std::string values_as_string (void);
+
+  virtual octave_scalar_map values_as_struct (void);
+
+  virtual graphics_handle get_parent (void) const
+  {
+    if (valid_object ())
+      return get_properties ().get_parent ();
+    else
+      {
+        error ("base_graphics_object::get_parent: invalid graphics object");
+        return graphics_handle ();
+      }
+  }
+
+  graphics_handle get_handle (void) const
+  {
+    if (valid_object ())
+      return get_properties ().get___myhandle__ ();
+    else
+      {
+        error ("base_graphics_object::get_handle: invalid graphics object");
+        return graphics_handle ();
+      }
+  }
+
+  virtual void remove_child (const graphics_handle& h)
+  {
+    if (valid_object ())
+      get_properties ().remove_child (h);
+    else
+      error ("base_graphics_object::remove_child: invalid graphics object");
+  }
+
+  virtual void adopt (const graphics_handle& h)
+  {
+    if (valid_object ())
+      get_properties ().adopt (h);
+    else
+      error ("base_graphics_object::adopt: invalid graphics object");
+  }
+
+  virtual void reparent (const graphics_handle& np)
+  {
+    if (valid_object ())
+      get_properties ().reparent (np);
+    else
+      error ("base_graphics_object::reparent: invalid graphics object");
+  }
+
+  virtual void defaults (void) const
+  {
+    if (valid_object ())
+      {
+        std::string msg = (type () + "::defaults");
+        gripe_not_implemented (msg.c_str ());
+      }
+    else
+      error ("base_graphics_object::default: invalid graphics object");
+  }
+
+  virtual base_properties& get_properties (void)
+  {
+    static base_properties properties;
+    error ("base_graphics_object::get_properties: invalid graphics object");
+    return properties;
+  }
+
+  virtual const base_properties& get_properties (void) const
+  {
+    static base_properties properties;
+    error ("base_graphics_object::get_properties: invalid graphics object");
+    return properties;
+  }
+
+  virtual void update_axis_limits (const std::string& axis_type);
+
+  virtual void update_axis_limits (const std::string& axis_type,
+                                   const graphics_handle& h);
+
+  virtual bool valid_object (void) const { return false; }
+
+  bool valid_toolkit_object (void) const { return toolkit_flag; }
+
+  virtual std::string type (void) const
+  {
+    return (valid_object () ? get_properties ().graphics_object_name ()
+        : "unknown");
+  }
+
+  bool isa (const std::string& go_name) const
+  {
+    return type () == go_name;
+  }
+
+  virtual graphics_toolkit get_toolkit (void) const
+  {
+    if (valid_object ())
+      return get_properties ().get_toolkit ();
+    else
+      {
+        error ("base_graphics_object::get_toolkit: invalid graphics object");
+        return graphics_toolkit ();
+      }
+  }
+
+  virtual void add_property_listener (const std::string& nm,
+                                      const octave_value& v,
+                                      listener_mode mode = POSTSET)
+    {
+      if (valid_object ())
+        get_properties ().add_listener (nm, v, mode);
+    }
+
+  virtual void delete_property_listener (const std::string& nm,
+                                         const octave_value& v,
+                                         listener_mode mode = POSTSET)
+    {
+      if (valid_object ())
+        get_properties ().delete_listener (nm, v, mode);
+    }
+
+  virtual void remove_all_listeners (void);
+
+  virtual void reset_default_properties (void)
+    {
+      if (valid_object ())
+        {
+          std::string msg = (type () + "::reset_default_properties");
+          gripe_not_implemented (msg.c_str ());
+        }
+      else
+        error ("base_graphics_object::default: invalid graphics object");
+    }
+
+protected:
+  virtual void initialize (const graphics_object& go)
+    {
+      if (! toolkit_flag)
+        toolkit_flag = get_toolkit ().initialize (go);
+    }
+
+  virtual void finalize (const graphics_object& go)
+    {
+      if (toolkit_flag)
+        {
+          get_toolkit ().finalize (go);
+          toolkit_flag = false;
+        }
+    }
+
+  virtual void update (const graphics_object& go, int id)
+    {
+      if (toolkit_flag)
+        get_toolkit ().update (go, id);
+    }
+
+protected:
+  // A reference count.
+  octave_refcount<int> count;
+
+  // A flag telling whether this object is a valid object
+  // in the backend context.
+  bool toolkit_flag;
+
+  // No copying!
+
+  base_graphics_object (const base_graphics_object&) : count (0) { }
+
+  base_graphics_object& operator = (const base_graphics_object&)
+  {
+    return *this;
+  }
+};
+
+class OCTINTERP_API graphics_object
+{
+public:
+  graphics_object (void) : rep (new base_graphics_object ()) { }
+
+  graphics_object (base_graphics_object *new_rep)
+    : rep (new_rep) { }
+
+  graphics_object (const graphics_object& obj) : rep (obj.rep)
+  {
+    rep->count++;
+  }
+
+  graphics_object& operator = (const graphics_object& obj)
+  {
+    if (rep != obj.rep)
+      {
+        if (--rep->count == 0)
+          delete rep;
+
+        rep = obj.rep;
+        rep->count++;
+      }
+
+    return *this;
+  }
+
+  ~graphics_object (void)
+  {
+    if (--rep->count == 0)
+      delete rep;
+  }
+
+  void mark_modified (void) { rep->mark_modified (); }
+
+  void override_defaults (base_graphics_object& obj)
+  {
+    rep->override_defaults (obj);
+  }
+
+  void set_from_list (property_list& plist) { rep->set_from_list (plist); }
+
+  void set (const caseless_str& name, const octave_value& val)
+  {
+    rep->set (name, val);
+  }
+
+  void set (const octave_value_list& args);
+
+  void set (const Array<std::string>& names, const Cell& values,
+            octave_idx_type row);
+
+  void set (const octave_map& m);
+
+  void set_value_or_default (const caseless_str& name,
+                             const octave_value& val);
+
+  void set_defaults (const std::string& mode) { rep->set_defaults (mode); }
+
+  octave_value get (bool all = false) const { return rep->get (all); }
+
+  octave_value get (const caseless_str& name) const
+  {
+    return name.compare ("default")
+      ? get_defaults ()
+      : (name.compare ("factory")
+         ? get_factory_defaults () : rep->get (name));
+  }
+
+  octave_value get (const std::string& name) const
+  {
+    return get (caseless_str (name));
+  }
+
+  octave_value get (const char *name) const
+  {
+    return get (caseless_str (name));
+  }
+
+  octave_value get_default (const caseless_str& name) const
+  {
+    return rep->get_default (name);
+  }
+
+  octave_value get_factory_default (const caseless_str& name) const
+  {
+    return rep->get_factory_default (name);
+  }
+
+  octave_value get_defaults (void) const { return rep->get_defaults (); }
+
+  octave_value get_factory_defaults (void) const
+  {
+    return rep->get_factory_defaults ();
+  }
+
+  std::string values_as_string (void) { return rep->values_as_string (); }
+
+  octave_map values_as_struct (void) { return rep->values_as_struct (); }
+
+  graphics_handle get_parent (void) const { return rep->get_parent (); }
+
+  graphics_handle get_handle (void) const { return rep->get_handle (); }
+
+  graphics_object get_ancestor (const std::string& type) const;
+
+  void remove_child (const graphics_handle& h) { rep->remove_child (h); }
+
+  void adopt (const graphics_handle& h) { rep->adopt (h); }
+
+  void reparent (const graphics_handle& h) { rep->reparent (h); }
+
+  void defaults (void) const { rep->defaults (); }
+
+  bool isa (const std::string& go_name) const { return rep->isa (go_name); }
+
+  base_properties& get_properties (void) { return rep->get_properties (); }
+
+  const base_properties& get_properties (void) const
+  {
+    return rep->get_properties ();
+  }
+
+  void update_axis_limits (const std::string& axis_type)
+  {
+    rep->update_axis_limits (axis_type);
+  }
+
+  void update_axis_limits (const std::string& axis_type,
+                           const graphics_handle& h)
+  {
+    rep->update_axis_limits (axis_type, h);
+  }
+
+  bool valid_object (void) const { return rep->valid_object (); }
+
+  std::string type (void) const { return rep->type (); }
+
+  operator bool (void) const { return rep->valid_object (); }
+
+  // FIXME -- these functions should be generated automatically by the
+  // genprops.awk script.
+  //
+  // EMIT_GRAPHICS_OBJECT_GET_FUNCTIONS
+
+  octave_value get_xlim (void) const
+  { return get_properties ().get_xlim (); }
+
+  octave_value get_ylim (void) const
+  { return get_properties ().get_ylim (); }
+
+  octave_value get_zlim (void) const
+  { return get_properties ().get_zlim (); }
+
+  octave_value get_clim (void) const
+  { return get_properties ().get_clim (); }
+
+  octave_value get_alim (void) const
+  { return get_properties ().get_alim (); }
+
+  bool is_xliminclude (void) const
+  { return get_properties ().is_xliminclude (); }
+
+  bool is_yliminclude (void) const
+  { return get_properties ().is_yliminclude (); }
+
+  bool is_zliminclude (void) const
+  { return get_properties ().is_zliminclude (); }
+
+  bool is_climinclude (void) const
+  { return get_properties ().is_climinclude (); }
+
+  bool is_aliminclude (void) const
+  { return get_properties ().is_aliminclude (); }
+
+  bool is_handle_visible (void) const
+  { return get_properties ().is_handle_visible (); }
+
+  graphics_toolkit get_toolkit (void) const { return rep->get_toolkit (); }
+
+  void add_property_listener (const std::string& nm, const octave_value& v,
+                              listener_mode mode = POSTSET)
+    { rep->add_property_listener (nm, v, mode); }
+
+  void delete_property_listener (const std::string& nm, const octave_value& v,
+                                 listener_mode mode = POSTSET)
+    { rep->delete_property_listener (nm, v, mode); }
+
+  void initialize (void) { rep->initialize (*this); }
+  
+  void finalize (void) { rep->finalize (*this); }
+
+  void update (int id) { rep->update (*this, id); }
+
+  void reset_default_properties (void)
+  { rep->reset_default_properties (); }
+
+private:
+  base_graphics_object *rep;
+};
+
+// ---------------------------------------------------------------------
+
+class OCTINTERP_API root_figure : public base_graphics_object
+{
+public:
+  class OCTINTERP_API properties : public base_properties
+  {
+  public:
+    void remove_child (const graphics_handle& h);
+
+    Matrix get_boundingbox (bool internal = false,
+                            const Matrix& parent_pix_size = Matrix ()) const;
+
+    // See the genprops.awk script for an explanation of the
+    // properties declarations.
+
+    // FIXME -- it seems strange to me that the diary, diaryfile,
+    // echo, format, formatspacing, language, and recursionlimit
+    // properties are here.  WTF do they have to do with graphics?
+    // Also note that these properties (and the monitorpositions,
+    // pointerlocation, and pointerwindow properties) are not yet used
+    // by Octave, so setting them will have no effect, and changes
+    // made elswhere (say, the diary or format functions) will not
+    // cause these properties to be updated.
+
+    BEGIN_PROPERTIES (root_figure, root)
+      handle_property callbackobject Sr , graphics_handle ()
+      array_property commandwindowsize r , Matrix (1, 2, 0)
+      handle_property currentfigure S , graphics_handle ()
+      bool_property diary , "off"
+      string_property diaryfile , "diary"
+      bool_property echo , "off"
+      radio_property format , "+|bank|bit|debug|hex|long|longe|longeng|longg|native-bit|native-hex|rational|{short}|shorte|shorteng|shortg"
+      radio_property formatspacing , "{loose}|compact"
+      string_property language , "ascii"
+      array_property monitorpositions , Matrix (1, 4, 0)
+      array_property pointerlocation , Matrix (1, 2, 0)
+      double_property pointerwindow , 0.0
+      double_property recursionlimit , 256.0
+      double_property screendepth r , default_screendepth ()
+      double_property screenpixelsperinch r , default_screenpixelsperinch ()
+      array_property screensize r , default_screensize ()
+      bool_property showhiddenhandles , "off"
+      radio_property units U , "inches|centimeters|normalized|points|{pixels}"
+    END_PROPERTIES
+
+  private:
+    std::list<graphics_handle> cbo_stack;
+  };
+
+private:
+  properties xproperties;
+
+public:
+
+  root_figure (void) : xproperties (0, graphics_handle ()), default_properties () { }
+
+  ~root_figure (void) { }
+
+  void mark_modified (void) { }
+
+  void override_defaults (base_graphics_object& obj)
+  {
+    // Now override with our defaults.  If the default_properties
+    // list includes the properties for all defaults (line,
+    // surface, etc.) then we don't have to know the type of OBJ
+    // here, we just call its set function and let it decide which
+    // properties from the list to use.
+    obj.set_from_list (default_properties);
+  }
+
+  void set (const caseless_str& name, const octave_value& value)
+  {
+    if (name.compare ("default", 7))
+      // strip "default", pass rest to function that will
+      // parse the remainder and add the element to the
+      // default_properties map.
+      default_properties.set (name.substr (7), value);
+    else
+      xproperties.set (name, value);
+  }
+
+  octave_value get (const caseless_str& name) const
+  {
+    octave_value retval;
+
+    if (name.compare ("default", 7))
+      return get_default (name.substr (7));
+    else if (name.compare ("factory", 7))
+      return get_factory_default (name.substr (7));
+    else
+      retval = xproperties.get (name);
+
+    return retval;
+  }
+
+  octave_value get_default (const caseless_str& name) const
+  {
+    octave_value retval = default_properties.lookup (name);
+
+    if (retval.is_undefined ())
+      {
+        // no default property found, use factory default
+        retval = factory_properties.lookup (name);
+
+        if (retval.is_undefined ())
+          error ("get: invalid default property `%s'", name.c_str ());
+      }
+
+    return retval;
+  }
+
+  octave_value get_factory_default (const caseless_str& name) const
+  {
+    octave_value retval = factory_properties.lookup (name);
+
+    if (retval.is_undefined ())
+      error ("get: invalid factory default property `%s'", name.c_str ());
+
+    return retval;
+  }
+
+  octave_value get_defaults (void) const
+  {
+    return default_properties.as_struct ("default");
+  }
+
+  octave_value get_factory_defaults (void) const
+  {
+    return factory_properties.as_struct ("factory");
+  }
+
+  base_properties& get_properties (void) { return xproperties; }
+
+  const base_properties& get_properties (void) const { return xproperties; }
+
+  bool valid_object (void) const { return true; }
+
+  void reset_default_properties (void);
+
+private:
+  property_list default_properties;
+
+  static property_list factory_properties;
+
+  static property_list::plist_map_type init_factory_properties (void);
+};
+
+// ---------------------------------------------------------------------
+
+class OCTINTERP_API figure : public base_graphics_object
+{
+public:
+  class OCTINTERP_API properties : public base_properties
+  {
+  public:
+    void init_integerhandle (const octave_value& val)
+      {
+        integerhandle = val;
+      }
+
+    void remove_child (const graphics_handle& h);
+
+    void set_visible (const octave_value& val);
+
+    graphics_toolkit get_toolkit (void) const
+      {
+        if (! toolkit)
+          toolkit = gtk_manager::get_toolkit ();
+
+        return toolkit;
+      }
+
+    void set_toolkit (const graphics_toolkit& b);
+
+    void set___graphics_toolkit__ (const octave_value& val)
+    {
+      if (! error_state)
+        {
+          if (val.is_string ())
+            {
+              std::string nm = val.string_value ();
+              graphics_toolkit b = gtk_manager::find_toolkit (nm);
+              if (b.get_name () != nm)
+                {
+                  error ("set___graphics_toolkit__: invalid graphics toolkit");
+                }
+              else
+                {
+                  set_toolkit (b);
+                  mark_modified ();
+                }
+            }
+          else
+            error ("set___graphics_toolkit__ must be a string");
+        }
+    }
+
+    void set_position (const octave_value& val,
+                       bool do_notify_toolkit = true);
+
+    void set_outerposition (const octave_value& val,
+                            bool do_notify_toolkit = true);
+
+    Matrix get_boundingbox (bool internal = false,
+                            const Matrix& parent_pix_size = Matrix ()) const;
+
+    void set_boundingbox (const Matrix& bb, bool internal = false,
+                          bool do_notify_toolkit = true);
+
+    Matrix map_from_boundingbox (double x, double y) const;
+
+    Matrix map_to_boundingbox (double x, double y) const;
+
+    void update_units (const caseless_str& old_units);
+
+    void update_paperunits (const caseless_str& old_paperunits);
+
+    std::string get_title (void) const;
+
+    // See the genprops.awk script for an explanation of the
+    // properties declarations.
+
+    BEGIN_PROPERTIES (figure)
+      any_property __plot_stream__ h , Matrix ()
+      bool_property __enhanced__ h , "on"
+      radio_property nextplot , "new|{add}|replacechildren|replace"
+      callback_property closerequestfcn , "closereq"
+      handle_property currentaxes S , graphics_handle ()
+      array_property colormap , jet_colormap ()
+      radio_property paperorientation U , "{portrait}|landscape|rotated"
+      color_property color , color_property (color_values (1, 1, 1), radio_values ("none"))
+      array_property alphamap , Matrix (64, 1, 1)
+      string_property currentcharacter r , ""
+      handle_property currentobject r , graphics_handle ()
+      array_property currentpoint r , Matrix (2, 1, 0)
+      bool_property dockcontrols , "off"
+      bool_property doublebuffer , "on"
+      string_property filename , ""
+      bool_property integerhandle S , "on"
+      bool_property inverthardcopy , "off"
+      callback_property keypressfcn , Matrix ()
+      callback_property keyreleasefcn , Matrix ()
+      radio_property menubar , "none|{figure}"
+      double_property mincolormap , 64
+      string_property name , ""
+      bool_property numbertitle , "on"
+      array_property outerposition s , Matrix (1, 4, -1.0)
+      radio_property paperunits Su , "{inches}|centimeters|normalized|points"
+      array_property paperposition , default_figure_paperposition ()
+      radio_property paperpositionmode , "auto|{manual}"
+      array_property papersize U , default_figure_papersize ()
+      radio_property papertype SU , "{usletter}|uslegal|a0|a1|a2|a3|a4|a5|b0|b1|b2|b3|b4|b5|arch-a|arch-b|arch-c|arch-d|arch-e|a|b|c|d|e|tabloid|<custom>"
+      radio_property pointer , "crosshair|fullcrosshair|{arrow}|ibeam|watch|topl|topr|botl|botr|left|top|right|bottom|circle|cross|fleur|custom|hand"
+      array_property pointershapecdata , Matrix (16, 16, 0)
+      array_property pointershapehotspot , Matrix (1, 2, 0)
+      array_property position s , default_figure_position ()
+      radio_property renderer , "{painters}|zbuffer|opengl|none"
+      radio_property renderermode , "{auto}|manual"
+      bool_property resize , "on"
+      callback_property resizefcn , Matrix ()
+      radio_property selectiontype , "{normal}|open|alt|extend"
+      radio_property toolbar , "none|{auto}|figure"
+      radio_property units Su , "inches|centimeters|normalized|points|{pixels}|characters"
+      callback_property windowbuttondownfcn , Matrix ()
+      callback_property windowbuttonmotionfcn , Matrix ()
+      callback_property windowbuttonupfcn , Matrix ()
+      callback_property windowbuttonwheelfcn , Matrix ()
+      radio_property windowstyle , "{normal}|modal|docked"
+      string_property wvisual , ""
+      radio_property wvisualmode , "{auto}|manual"
+      string_property xdisplay , ""
+      string_property xvisual , ""
+      radio_property xvisualmode , "{auto}|manual"
+      callback_property buttondownfcn , Matrix ()
+      string_property __graphics_toolkit__ s , "gnuplot"
+      any_property __guidata__ h , Matrix ()
+    END_PROPERTIES
+
+  protected:
+    void init (void)
+      {
+        colormap.add_constraint (dim_vector (-1, 3));
+        alphamap.add_constraint (dim_vector (-1, 1));
+        paperposition.add_constraint (dim_vector (1, 4));
+        pointershapecdata.add_constraint (dim_vector (16, 16));
+        pointershapehotspot.add_constraint (dim_vector (1, 2));
+        position.add_constraint (dim_vector (1, 4));
+        outerposition.add_constraint (dim_vector (1, 4));
+      }
+
+  private:
+    mutable graphics_toolkit toolkit;
+  };
+
+private:
+  properties xproperties;
+
+public:
+  figure (const graphics_handle& mh, const graphics_handle& p)
+    : base_graphics_object (), xproperties (mh, p), default_properties ()
+  {
+    xproperties.override_defaults (*this);
+  }
+
+  ~figure (void) { }
+
+  void override_defaults (base_graphics_object& obj)
+  {
+    // Allow parent (root figure) to override first (properties knows how
+    // to find the parent object).
+    xproperties.override_defaults (obj);
+
+    // Now override with our defaults.  If the default_properties
+    // list includes the properties for all defaults (line,
+    // surface, etc.) then we don't have to know the type of OBJ
+    // here, we just call its set function and let it decide which
+    // properties from the list to use.
+    obj.set_from_list (default_properties);
+  }
+
+  void set (const caseless_str& name, const octave_value& value)
+  {
+    if (name.compare ("default", 7))
+      // strip "default", pass rest to function that will
+      // parse the remainder and add the element to the
+      // default_properties map.
+      default_properties.set (name.substr (7), value);
+    else
+      xproperties.set (name, value);
+  }
+
+  octave_value get (const caseless_str& name) const
+  {
+    octave_value retval;
+
+    if (name.compare ("default", 7))
+      retval = get_default (name.substr (7));
+    else
+      retval = xproperties.get (name);
+
+    return retval;
+  }
+
+  octave_value get_default (const caseless_str& name) const;
+
+  octave_value get_defaults (void) const
+  {
+    return default_properties.as_struct ("default");
+  }
+
+  base_properties& get_properties (void) { return xproperties; }
+
+  const base_properties& get_properties (void) const { return xproperties; }
+
+  bool valid_object (void) const { return true; }
+
+  void reset_default_properties (void);
+
+private:
+  property_list default_properties;
+};
+
+// ---------------------------------------------------------------------
+
+class OCTINTERP_API graphics_xform
+{
+public:
+  graphics_xform (void)
+    : xform (xform_eye ()), xform_inv (xform_eye ()),
+      sx ("linear"), sy ("linear"), sz ("linear"),  zlim (1, 2, 0.0)
+    {
+      zlim(1) = 1.0;
+    }
+
+  graphics_xform (const Matrix& xm, const Matrix& xim,
+                  const scaler& x, const scaler& y, const scaler& z,
+                  const Matrix& zl)
+      : xform (xm), xform_inv (xim), sx (x), sy (y), sz (z), zlim (zl) { }
+
+  graphics_xform (const graphics_xform& g)
+      : xform (g.xform), xform_inv (g.xform_inv), sx (g.sx),
+        sy (g.sy), sz (g.sz), zlim (g.zlim) { }
+
+  ~graphics_xform (void) { }
+
+  graphics_xform& operator = (const graphics_xform& g)
+    {
+      xform = g.xform;
+      xform_inv = g.xform_inv;
+      sx = g.sx;
+      sy = g.sy;
+      sz = g.sz;
+      zlim = g.zlim;
+
+      return *this;
+    }
+
+  static ColumnVector xform_vector (double x, double y, double z);
+
+  static Matrix xform_eye (void);
+
+  ColumnVector transform (double x, double y, double z,
+                          bool use_scale = true) const;
+
+  ColumnVector untransform (double x, double y, double z,
+                            bool use_scale = true) const;
+
+  ColumnVector untransform (double x, double y, bool use_scale = true) const
+    { return untransform (x, y, (zlim(0)+zlim(1))/2, use_scale); }
+
+  Matrix xscale (const Matrix& m) const { return sx.scale (m); }
+  Matrix yscale (const Matrix& m) const { return sy.scale (m); }
+  Matrix zscale (const Matrix& m) const { return sz.scale (m); }
+
+  Matrix scale (const Matrix& m) const
+    {
+      bool has_z = (m.columns () > 2);
+
+      if (sx.is_linear () && sy.is_linear ()
+          && (! has_z || sz.is_linear ()))
+        return m;
+
+      Matrix retval (m.dims ());
+
+      int r = m.rows ();
+
+      for (int i = 0; i < r; i++)
+        {
+          retval(i,0) = sx.scale (m(i,0));
+          retval(i,1) = sy.scale (m(i,1));
+          if (has_z)
+            retval(i,2) = sz.scale (m(i,2));
+        }
+
+      return retval;
+    }
+
+private:
+  Matrix xform;
+  Matrix xform_inv;
+  scaler sx, sy, sz;
+  Matrix zlim;
+};
+
+enum {
+  AXE_ANY_DIR   = 0,
+  AXE_DEPTH_DIR = 1,
+  AXE_HORZ_DIR  = 2,
+  AXE_VERT_DIR  = 3
+};
+
+class OCTINTERP_API axes : public base_graphics_object
+{
+public:
+  class OCTINTERP_API properties : public base_properties
+  {
+  public:
+    void set_defaults (base_graphics_object& obj, const std::string& mode);
+
+    void remove_child (const graphics_handle& h);
+
+    const scaler& get_x_scaler (void) const { return sx; }
+    const scaler& get_y_scaler (void) const { return sy; }
+    const scaler& get_z_scaler (void) const { return sz; }
+
+    Matrix get_boundingbox (bool internal = false,
+                            const Matrix& parent_pix_size = Matrix ()) const;
+    Matrix get_extent (bool with_text = false, bool only_text_height=false) const;
+
+    double get_fontsize_points (double box_pix_height = 0) const;
+
+    void update_boundingbox (void)
+      {
+        if (units_is ("normalized"))
+          {
+            sync_positions ();
+            base_properties::update_boundingbox ();
+          }
+      }
+
+    void update_camera (void);
+    void update_axes_layout (void);
+    void update_aspectratios (void);
+    void update_transform (void)
+      {
+        update_aspectratios ();
+        update_camera ();
+        update_axes_layout ();
+      }
+
+    void update_autopos (const std::string& elem_type);
+    void update_xlabel_position (void);
+    void update_ylabel_position (void);
+    void update_zlabel_position (void);
+    void update_title_position (void);
+
+    graphics_xform get_transform (void) const
+      { return graphics_xform (x_render, x_render_inv, sx, sy, sz, x_zlim); }
+
+    Matrix get_transform_matrix (void) const { return x_render; }
+    Matrix get_inverse_transform_matrix (void) const { return x_render_inv; }
+    Matrix get_opengl_matrix_1 (void) const { return x_gl_mat1; }
+    Matrix get_opengl_matrix_2 (void) const { return x_gl_mat2; }
+    Matrix get_transform_zlim (void) const { return x_zlim; }
+
+    int get_xstate (void) const { return xstate; }
+    int get_ystate (void) const { return ystate; }
+    int get_zstate (void) const { return zstate; }
+    double get_xPlane (void) const { return xPlane; }
+    double get_xPlaneN (void) const { return xPlaneN; }
+    double get_yPlane (void) const { return yPlane; }
+    double get_yPlaneN (void) const { return yPlaneN; }
+    double get_zPlane (void) const { return zPlane; }
+    double get_zPlaneN (void) const { return zPlaneN; }
+    double get_xpTick (void) const { return xpTick; }
+    double get_xpTickN (void) const { return xpTickN; }
+    double get_ypTick (void) const { return ypTick; }
+    double get_ypTickN (void) const { return ypTickN; }
+    double get_zpTick (void) const { return zpTick; }
+    double get_zpTickN (void) const { return zpTickN; }
+    double get_x_min (void) const { return std::min (xPlane, xPlaneN); }
+    double get_x_max (void) const { return std::max (xPlane, xPlaneN); }
+    double get_y_min (void) const { return std::min (yPlane, yPlaneN); }
+    double get_y_max (void) const { return std::max (yPlane, yPlaneN); }
+    double get_z_min (void) const { return std::min (zPlane, zPlaneN); }
+    double get_z_max (void) const { return std::max (zPlane, zPlaneN); }
+    double get_fx (void) const { return fx; }
+    double get_fy (void) const { return fy; }
+    double get_fz (void) const { return fz; }
+    double get_xticklen (void) const { return xticklen; }
+    double get_yticklen (void) const { return yticklen; }
+    double get_zticklen (void) const { return zticklen; }
+    double get_xtickoffset (void) const { return xtickoffset; }
+    double get_ytickoffset (void) const { return ytickoffset; }
+    double get_ztickoffset (void) const { return ztickoffset; }
+    bool get_x2Dtop (void) const { return x2Dtop; }
+    bool get_y2Dright (void) const { return y2Dright; }
+    bool get_layer2Dtop (void) const { return layer2Dtop; }
+    bool get_xySym (void) const { return xySym; }
+    bool get_xyzSym (void) const { return xyzSym; }
+    bool get_zSign (void) const { return zSign; }
+    bool get_nearhoriz (void) const { return nearhoriz; }
+
+    ColumnVector pixel2coord (double px, double py) const
+    { return get_transform ().untransform (px, py, (x_zlim(0)+x_zlim(1))/2); }
+
+    ColumnVector coord2pixel (double x, double y, double z) const
+    { return get_transform ().transform (x, y, z); }
+
+    void zoom_about_point (double x, double y, double factor,
+                           bool push_to_zoom_stack = true);
+    void zoom (const Matrix& xl, const Matrix& yl, bool push_to_zoom_stack = true);
+    void translate_view (double x0, double x1, double y0, double y1);
+    void rotate_view (double delta_az, double delta_el);
+    void unzoom (void);
+    void clear_zoom_stack (void);
+
+    void update_units (const caseless_str& old_units);
+
+    void update_fontunits (const caseless_str& old_fontunits);
+
+  private:
+    scaler sx, sy, sz;
+    Matrix x_render, x_render_inv;
+    Matrix x_gl_mat1, x_gl_mat2;
+    Matrix x_zlim;
+    std::list<octave_value> zoom_stack;
+
+    // Axes layout data
+    int xstate, ystate, zstate;
+    double xPlane, xPlaneN, yPlane, yPlaneN, zPlane, zPlaneN;
+    double xpTick, xpTickN, ypTick, ypTickN, zpTick, zpTickN;
+    double fx, fy, fz;
+    double xticklen, yticklen, zticklen;
+    double xtickoffset, ytickoffset, ztickoffset;
+    bool x2Dtop, y2Dright, layer2Dtop;
+    bool xySym, xyzSym, zSign, nearhoriz;
+
+#if HAVE_FREETYPE
+    // freetype renderer, used for calculation of text (tick labels) size
+    ft_render text_renderer;
+#endif
+
+    void set_text_child (handle_property& h, const std::string& who,
+                         const octave_value& v);
+
+    void delete_text_child (handle_property& h);
+
+    // See the genprops.awk script for an explanation of the
+    // properties declarations.
+
+    // properties which are not in matlab: interpreter
+
+    BEGIN_PROPERTIES (axes)
+      array_property position u , default_axes_position ()
+      bool_property box , "on"
+      array_property colororder , default_colororder ()
+      array_property dataaspectratio mu , Matrix (1, 3, 1.0)
+      radio_property dataaspectratiomode u , "{auto}|manual"
+      radio_property layer u , "{bottom}|top"
+      row_vector_property xlim mu , default_lim ()
+      row_vector_property ylim mu , default_lim ()
+      row_vector_property zlim mu , default_lim ()
+      row_vector_property clim m , default_lim ()
+      row_vector_property alim m , default_lim ()
+      radio_property xlimmode al , "{auto}|manual"
+      radio_property ylimmode al , "{auto}|manual"
+      radio_property zlimmode al , "{auto}|manual"
+      radio_property climmode al , "{auto}|manual"
+      radio_property alimmode    , "{auto}|manual"
+      handle_property xlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false)
+      handle_property ylabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false)
+      handle_property zlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false)
+      handle_property title SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false)
+      bool_property xgrid , "off"
+      bool_property ygrid , "off"
+      bool_property zgrid , "off"
+      bool_property xminorgrid , "off"
+      bool_property yminorgrid , "off"
+      bool_property zminorgrid , "off"
+      row_vector_property xtick mu , default_axes_tick ()
+      row_vector_property ytick mu , default_axes_tick ()
+      row_vector_property ztick mu , default_axes_tick ()
+      radio_property xtickmode u , "{auto}|manual"
+      radio_property ytickmode u , "{auto}|manual"
+      radio_property ztickmode u , "{auto}|manual"
+      bool_property xminortick , "off"
+      bool_property yminortick , "off"
+      bool_property zminortick , "off"
+      // FIXME -- should be kind of string array.
+      any_property xticklabel m , ""
+      any_property yticklabel m , ""
+      any_property zticklabel m , ""
+      radio_property xticklabelmode u , "{auto}|manual"
+      radio_property yticklabelmode u , "{auto}|manual"
+      radio_property zticklabelmode u , "{auto}|manual"
+      radio_property interpreter , "tex|{none}|latex"
+      color_property color , color_property (color_values (1, 1, 1), radio_values ("none"))
+      color_property xcolor , color_values (0, 0, 0)
+      color_property ycolor , color_values (0, 0, 0)
+      color_property zcolor , color_values (0, 0, 0)
+      radio_property xscale alu , "{linear}|log"
+      radio_property yscale alu , "{linear}|log"
+      radio_property zscale alu , "{linear}|log"
+      radio_property xdir u , "{normal}|reverse"
+      radio_property ydir u , "{normal}|reverse"
+      radio_property zdir u , "{normal}|reverse"
+      radio_property yaxislocation u , "{left}|right|zero"
+      radio_property xaxislocation u , "{bottom}|top|zero"
+      array_property view u , Matrix ()
+      bool_property __hold_all__ h , "off"
+      radio_property nextplot , "new|add|replacechildren|{replace}"
+      array_property outerposition u , default_axes_outerposition ()
+      radio_property activepositionproperty , "{outerposition}|position"
+      color_property ambientlightcolor , color_values (1, 1, 1)
+      array_property cameraposition m , Matrix (1, 3, 0.0)
+      array_property cameratarget m , Matrix (1, 3, 0.0)
+      array_property cameraupvector m , Matrix ()
+      double_property cameraviewangle m , 10.0
+      radio_property camerapositionmode , "{auto}|manual"
+      radio_property cameratargetmode , "{auto}|manual"
+      radio_property cameraupvectormode , "{auto}|manual"
+      radio_property cameraviewanglemode , "{auto}|manual"
+      array_property currentpoint , Matrix (2, 3, 0.0)
+      radio_property drawmode , "{normal}|fast"
+      radio_property fontangle u , "{normal}|italic|oblique"
+      string_property fontname u , OCTAVE_DEFAULT_FONTNAME
+      double_property fontsize u , 10
+      radio_property fontunits SU , "{points}|normalized|inches|centimeters|pixels"
+      radio_property fontweight u , "{normal}|light|demi|bold"
+      radio_property gridlinestyle , "-|--|{:}|-.|none"
+      string_array_property linestyleorder , "-"
+      double_property linewidth , 0.5
+      radio_property minorgridlinestyle , "-|--|{:}|-.|none"
+      array_property plotboxaspectratio mu , Matrix (1, 3, 1.0)
+      radio_property plotboxaspectratiomode u , "{auto}|manual"
+      radio_property projection , "{orthographic}|perpective"
+      radio_property tickdir mu , "{in}|out"
+      radio_property tickdirmode u , "{auto}|manual"
+      array_property ticklength u , default_axes_ticklength ()
+      array_property tightinset r , Matrix (1, 4, 0.0)
+      // FIXME -- uicontextmenu should be moved here.
+      radio_property units SU , "{normalized}|inches|centimeters|points|pixels|characters"
+      // hidden properties for transformation computation
+      array_property x_viewtransform h , Matrix (4, 4, 0.0)
+      array_property x_projectiontransform h , Matrix (4, 4, 0.0)
+      array_property x_viewporttransform h , Matrix (4, 4, 0.0)
+      array_property x_normrendertransform h , Matrix (4, 4, 0.0)
+      array_property x_rendertransform h , Matrix (4, 4, 0.0)
+      // hidden properties for minor ticks
+      row_vector_property xmtick h , Matrix ()
+      row_vector_property ymtick h , Matrix ()
+      row_vector_property zmtick h , Matrix ()
+      // hidden properties for inset
+      array_property looseinset hu , Matrix (1, 4, 0.0)
+      // hidden properties for alignment of subplots
+      radio_property autopos_tag h , "{none}|subplot"
+   END_PROPERTIES
+
+  protected:
+    void init (void);
+
+  private:
+
+    std::string
+    get_scale (const std::string& scale, const Matrix& lims)
+    {
+      std::string retval = scale;
+
+      if (scale == "log" && lims.numel () > 1 && lims(0) < 0 && lims(1) < 0)
+        retval = "neglog";
+
+      return retval;
+    }
+
+    void update_xscale (void)
+    {
+      sx = get_scale (get_xscale (), xlim.get ().matrix_value ());
+    }
+
+    void update_yscale (void)
+    {
+      sy = get_scale (get_yscale (), ylim.get ().matrix_value ());
+    }
+
+    void update_zscale (void)
+    {
+      sz = get_scale (get_zscale (), zlim.get ().matrix_value ());
+    }
+
+    void update_view (void) { sync_positions (); }
+    void update_dataaspectratio (void) { sync_positions (); }
+    void update_dataaspectratiomode (void) { sync_positions (); }
+    void update_plotboxaspectratio (void) { sync_positions (); }
+    void update_plotboxaspectratiomode (void) { sync_positions (); }
+
+    void update_layer (void) { update_axes_layout (); }
+    void update_yaxislocation (void)
+      {
+        update_axes_layout ();
+        update_ylabel_position ();
+      }
+    void update_xaxislocation (void)
+      {
+        update_axes_layout ();
+        update_xlabel_position ();
+      }
+
+    void update_xdir (void) { update_camera (); update_axes_layout (); }
+    void update_ydir (void) { update_camera (); update_axes_layout (); }
+    void update_zdir (void) { update_camera (); update_axes_layout (); }
+
+    void update_ticklength (void);
+    void update_tickdir (void) { update_ticklength (); }
+    void update_tickdirmode (void) { update_ticklength (); }
+
+    void update_xtick (void)
+      {
+        if (xticklabelmode.is ("auto"))
+          calc_ticklabels (xtick, xticklabel, xscale.is ("log"));
+      }
+    void update_ytick (void)
+      {
+        if (yticklabelmode.is ("auto"))
+          calc_ticklabels (ytick, yticklabel, yscale.is ("log"));
+      }
+    void update_ztick (void)
+      {
+        if (zticklabelmode.is ("auto"))
+          calc_ticklabels (ztick, zticklabel, zscale.is ("log"));
+      }
+
+    void update_xtickmode (void)
+      {
+      if (xtickmode.is ("auto"))
+        {
+          calc_ticks_and_lims (xlim, xtick, xmtick, xlimmode.is ("auto"), xscale.is ("log"));
+          update_xtick ();
+        }
+      }
+    void update_ytickmode (void)
+      {
+      if (ytickmode.is ("auto"))
+        {
+          calc_ticks_and_lims (ylim, ytick, ymtick, ylimmode.is ("auto"), yscale.is ("log"));
+          update_ytick ();
+        }
+      }
+    void update_ztickmode (void)
+      {
+      if (ztickmode.is ("auto"))
+        {
+          calc_ticks_and_lims (zlim, ztick, zmtick, zlimmode.is ("auto"), zscale.is ("log"));
+          update_ztick ();
+        }
+      }
+
+    void update_xticklabelmode (void)
+      {
+        if (xticklabelmode.is ("auto"))
+          calc_ticklabels (xtick, xticklabel, xscale.is ("log"));
+      }
+    void update_yticklabelmode (void)
+      {
+        if (yticklabelmode.is ("auto"))
+          calc_ticklabels (ytick, yticklabel, yscale.is ("log"));
+      }
+    void update_zticklabelmode (void)
+      {
+        if (zticklabelmode.is ("auto"))
+          calc_ticklabels (ztick, zticklabel, zscale.is ("log"));
+      }
+
+    void update_font (void);
+    void update_fontname (void) { update_font (); }
+    void update_fontsize (void) { update_font (); }
+    void update_fontangle (void) { update_font (); }
+    void update_fontweight (void) { update_font (); }
+
+    void sync_positions (const Matrix& linset);
+    void sync_positions (void);
+
+    void update_outerposition (void)
+    {
+      set_activepositionproperty ("outerposition");
+      sync_positions ();
+    }
+
+    void update_position (void)
+    {
+      set_activepositionproperty ("position");
+      sync_positions ();
+    }
+
+    void update_looseinset (void) { sync_positions (); }
+
+    double calc_tick_sep (double minval, double maxval);
+    void calc_ticks_and_lims (array_property& lims, array_property& ticks, array_property& mticks,
+                              bool limmode_is_auto, bool is_logscale);
+    void calc_ticklabels (const array_property& ticks, any_property& labels, bool is_logscale);
+    Matrix get_ticklabel_extents (const Matrix& ticks,
+                                  const string_vector& ticklabels,
+                                  const Matrix& limits);
+
+    void fix_limits (array_property& lims)
+    {
+      if (lims.get ().is_empty ())
+        return;
+
+      Matrix l = lims.get ().matrix_value ();
+      if (l(0) > l(1))
+        {
+          l(0) = 0;
+          l(1) = 1;
+          lims = l;
+        }
+      else if (l(0) == l(1))
+        {
+          l(0) -= 0.5;
+          l(1) += 0.5;
+          lims = l;
+        }
+    }
+
+    Matrix calc_tightbox (const Matrix& init_pos);
+
+  public:
+    Matrix get_axis_limits (double xmin, double xmax,
+                            double min_pos, double max_neg,
+                            bool logscale);
+
+    void update_xlim (bool do_clr_zoom = true)
+    {
+      if (xtickmode.is ("auto"))
+        calc_ticks_and_lims (xlim, xtick, xmtick, xlimmode.is ("auto"), xscale.is ("log"));
+      if (xticklabelmode.is ("auto"))
+        calc_ticklabels (xtick, xticklabel, xscale.is ("log"));
+
+      fix_limits (xlim);
+
+      update_xscale ();
+
+      if (do_clr_zoom)
+        zoom_stack.clear ();
+
+      update_axes_layout ();
+    }
+
+    void update_ylim (bool do_clr_zoom = true)
+    {
+      if (ytickmode.is ("auto"))
+        calc_ticks_and_lims (ylim, ytick, ymtick, ylimmode.is ("auto"), yscale.is ("log"));
+      if (yticklabelmode.is ("auto"))
+        calc_ticklabels (ytick, yticklabel, yscale.is ("log"));
+
+      fix_limits (ylim);
+
+      update_yscale ();
+
+      if (do_clr_zoom)
+        zoom_stack.clear ();
+
+      update_axes_layout ();
+    }
+
+    void update_zlim (void)
+    {
+      if (ztickmode.is ("auto"))
+        calc_ticks_and_lims (zlim, ztick, zmtick, zlimmode.is ("auto"), zscale.is ("log"));
+      if (zticklabelmode.is ("auto"))
+        calc_ticklabels (ztick, zticklabel, zscale.is ("log"));
+
+      fix_limits (zlim);
+
+      update_zscale ();
+
+      zoom_stack.clear ();
+
+      update_axes_layout ();
+    }
+
+  };
+
+private:
+  properties xproperties;
+
+public:
+  axes (const graphics_handle& mh, const graphics_handle& p)
+    : base_graphics_object (), xproperties (mh, p), default_properties ()
+  {
+    xproperties.override_defaults (*this);
+    xproperties.update_transform ();
+  }
+
+  ~axes (void) { }
+
+  void override_defaults (base_graphics_object& obj)
+  {
+    // Allow parent (figure) to override first (properties knows how
+    // to find the parent object).
+    xproperties.override_defaults (obj);
+
+    // Now override with our defaults.  If the default_properties
+    // list includes the properties for all defaults (line,
+    // surface, etc.) then we don't have to know the type of OBJ
+    // here, we just call its set function and let it decide which
+    // properties from the list to use.
+    obj.set_from_list (default_properties);
+  }
+
+  void set (const caseless_str& name, const octave_value& value)
+  {
+    if (name.compare ("default", 7))
+      // strip "default", pass rest to function that will
+      // parse the remainder and add the element to the
+      // default_properties map.
+      default_properties.set (name.substr (7), value);
+    else
+      xproperties.set (name, value);
+  }
+
+  void set_defaults (const std::string& mode)
+  {
+    remove_all_listeners ();
+    xproperties.set_defaults (*this, mode);
+  }
+
+  octave_value get (const caseless_str& name) const
+  {
+    octave_value retval;
+
+    // FIXME -- finish this.
+    if (name.compare ("default", 7))
+      retval = get_default (name.substr (7));
+    else
+      retval = xproperties.get (name);
+
+    return retval;
+  }
+
+  octave_value get_default (const caseless_str& name) const;
+
+  octave_value get_defaults (void) const
+  {
+    return default_properties.as_struct ("default");
+  }
+
+  base_properties& get_properties (void) { return xproperties; }
+
+  const base_properties& get_properties (void) const { return xproperties; }
+
+  void update_axis_limits (const std::string& axis_type);
+
+  void update_axis_limits (const std::string& axis_type,
+                           const graphics_handle& h);
+
+  bool valid_object (void) const { return true; }
+
+  void reset_default_properties (void);
+
+protected:
+  void initialize (const graphics_object& go);
+
+private:
+  property_list default_properties;
+};
+
+// ---------------------------------------------------------------------
+
+class OCTINTERP_API line : public base_graphics_object
+{
+public:
+  class OCTINTERP_API properties : public base_properties
+  {
+  public:
+    // See the genprops.awk script for an explanation of the
+    // properties declarations.
+
+    // properties which are not in matlab: interpreter
+
+    BEGIN_PROPERTIES (line)
+      row_vector_property xdata u , default_data ()
+      row_vector_property ydata u , default_data ()
+      row_vector_property zdata u , Matrix ()
+      string_property xdatasource , ""
+      string_property ydatasource , ""
+      string_property zdatasource , ""
+      color_property color , color_values (0, 0, 0)
+      radio_property linestyle , "{-}|--|:|-.|none"
+      double_property linewidth , 0.5
+      radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h|@"
+      color_property markeredgecolor , "{auto}|none"
+      color_property markerfacecolor , "auto|{none}"
+      double_property markersize , 6
+      radio_property interpreter , "{tex}|none|latex"
+      string_property displayname , ""
+      radio_property erasemode , "{normal}|none|xor|background"
+      // hidden properties for limit computation
+      row_vector_property xlim hlr , Matrix ()
+      row_vector_property ylim hlr , Matrix ()
+      row_vector_property zlim hlr , Matrix ()
+      bool_property xliminclude hl , "on"
+      bool_property yliminclude hl , "on"
+      bool_property zliminclude hl , "off"
+    END_PROPERTIES
+
+  private:
+    Matrix compute_xlim (void) const;
+    Matrix compute_ylim (void) const;
+
+    void update_xdata (void) { set_xlim (compute_xlim ()); }
+
+    void update_ydata (void) { set_ylim (compute_ylim ()); }
+
+    void update_zdata (void)
+      {
+        set_zlim (zdata.get_limits ());
+        set_zliminclude (get_zdata ().numel () > 0);
+      }
+  };
+
+private:
+  properties xproperties;
+
+public:
+  line (const graphics_handle& mh, const graphics_handle& p)
+    : base_graphics_object (), xproperties (mh, p)
+  {
+    xproperties.override_defaults (*this);
+  }
+
+  ~line (void) { }
+
+  base_properties& get_properties (void) { return xproperties; }
+
+  const base_properties& get_properties (void) const { return xproperties; }
+
+  bool valid_object (void) const { return true; }
+};
+
+// ---------------------------------------------------------------------
+
+class OCTINTERP_API text : public base_graphics_object
+{
+public:
+  class OCTINTERP_API properties : public base_properties
+  {
+  public:
+    double get_fontsize_points (double box_pix_height = 0) const;
+
+    void set_position (const octave_value& val)
+    {
+      if (! error_state)
+        {
+          octave_value new_val (val);
+    
+          if (new_val.numel () == 2)
+            {
+              dim_vector dv (1, 3);
+    
+              new_val = new_val.resize (dv, true);
+            }
+
+          if (position.set (new_val, false))
+            {
+              set_positionmode ("manual");
+              update_position ();
+              position.run_listeners (POSTSET);
+              mark_modified ();
+            }
+          else
+            set_positionmode ("manual");
+        }
+    }
+
+    // See the genprops.awk script for an explanation of the
+    // properties declarations.
+
+    BEGIN_PROPERTIES (text)
+      text_label_property string u , ""
+      radio_property units u , "{data}|pixels|normalized|inches|centimeters|points"
+      array_property position smu , Matrix (1, 3, 0.0)
+      double_property rotation mu , 0
+      radio_property horizontalalignment mu , "{left}|center|right"
+      color_property color u , color_values (0, 0, 0)
+      string_property fontname u , OCTAVE_DEFAULT_FONTNAME
+      double_property fontsize u , 10
+      radio_property fontangle u , "{normal}|italic|oblique"
+      radio_property fontweight u , "light|{normal}|demi|bold"
+      radio_property interpreter u , "{tex}|none|latex"
+      color_property backgroundcolor , "{none}"
+      string_property displayname , ""
+      color_property edgecolor , "{none}"
+      radio_property erasemode , "{normal}|none|xor|background"
+      bool_property editing , "off"
+      radio_property fontunits , "inches|centimeters|normalized|{points}|pixels"
+      radio_property linestyle , "{-}|--|:|-.|none"
+      double_property linewidth , 0.5
+      double_property margin , 1
+      radio_property verticalalignment mu , "top|cap|{middle}|baseline|bottom"
+      array_property extent rG , Matrix (1, 4, 0.0)
+      // hidden properties for limit computation
+      row_vector_property xlim hlr , Matrix ()
+      row_vector_property ylim hlr , Matrix ()
+      row_vector_property zlim hlr , Matrix ()
+      bool_property xliminclude hl , "off"
+      bool_property yliminclude hl , "off"
+      bool_property zliminclude hl , "off"
+      // hidden properties for auto-positioning
+      radio_property positionmode hu , "{auto}|manual"
+      radio_property rotationmode hu , "{auto}|manual"
+      radio_property horizontalalignmentmode hu , "{auto}|manual"
+      radio_property verticalalignmentmode hu , "{auto}|manual"
+      radio_property autopos_tag h , "{none}|xlabel|ylabel|zlabel|title"
+    END_PROPERTIES
+
+    Matrix get_data_position (void) const;
+    Matrix get_extent_matrix (void) const;
+    const uint8NDArray& get_pixels (void) const { return pixels; }
+#if HAVE_FREETYPE
+    // freetype renderer, used for calculation of text size
+    ft_render renderer;
+#endif
+
+  protected:
+    void init (void)
+      {
+        position.add_constraint (dim_vector (1, 3));
+        cached_units = get_units ();
+        update_font ();
+      }
+
+  private:
+    void update_position (void)
+      {
+        Matrix pos = get_data_position ();
+        Matrix lim;
+
+        lim = Matrix (1, 3, pos(0));
+        lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2));
+        set_xlim (lim);
+
+        lim = Matrix (1, 3, pos(1));
+        lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2));
+        set_ylim (lim);
+
+        if (pos.numel () == 3)
+          {
+            lim = Matrix (1, 3, pos(2));
+            lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2));
+            set_zliminclude ("on");
+            set_zlim (lim);
+          }
+        else
+          set_zliminclude ("off");
+      }
+
+    void update_text_extent (void);
+
+    void request_autopos (void);
+    void update_positionmode (void) { request_autopos (); }
+    void update_rotationmode (void) { request_autopos (); }
+    void update_horizontalalignmentmode (void) { request_autopos (); }
+    void update_verticalalignmentmode (void) { request_autopos (); }
+
+    void update_font (void);
+    void update_string (void) { request_autopos (); update_text_extent (); }
+    void update_rotation (void) { update_text_extent (); }
+    void update_color (void) { update_font (); }
+    void update_fontname (void) { update_font (); update_text_extent (); }
+    void update_fontsize (void) { update_font (); update_text_extent (); }
+    void update_fontangle (void) { update_font (); update_text_extent (); }
+    void update_fontweight (void) { update_font (); update_text_extent (); }
+    void update_interpreter (void) { update_text_extent (); }
+    void update_horizontalalignment (void) { update_text_extent (); }
+    void update_verticalalignment (void) { update_text_extent (); }
+
+    void update_units (void);
+
+  private:
+    std::string cached_units;
+    uint8NDArray pixels;
+  };
+
+private:
+  properties xproperties;
+
+public:
+  text (const graphics_handle& mh, const graphics_handle& p)
+    : base_graphics_object (), xproperties (mh, p)
+  {
+    xproperties.set_clipping ("off");
+    xproperties.override_defaults (*this);
+  }
+
+  ~text (void) { }
+
+  base_properties& get_properties (void) { return xproperties; }
+
+  const base_properties& get_properties (void) const { return xproperties; }
+
+  bool valid_object (void) const { return true; }
+};
+
+// ---------------------------------------------------------------------
+
+class OCTINTERP_API image : public base_graphics_object
+{
+public:
+  class OCTINTERP_API properties : public base_properties
+  {
+  public:
+    bool is_climinclude (void) const
+      { return (climinclude.is_on () && cdatamapping.is ("scaled")); }
+    std::string get_climinclude (void) const
+      { return climinclude.current_value (); }
+
+    octave_value get_color_data (void) const;
+
+    // See the genprops.awk script for an explanation of the
+    // properties declarations.
+
+    BEGIN_PROPERTIES (image)
+      row_vector_property xdata u , Matrix ()
+      row_vector_property ydata u , Matrix ()
+      array_property cdata u , Matrix ()
+      radio_property cdatamapping al , "{scaled}|direct"
+      // hidden properties for limit computation
+      row_vector_property xlim hlr , Matrix()
+      row_vector_property ylim hlr , Matrix()
+      row_vector_property clim hlr , Matrix()
+      bool_property xliminclude hl , "on"
+      bool_property yliminclude hl , "on"
+      bool_property climinclude hlg , "on"
+    END_PROPERTIES
+
+  protected:
+    void init (void)
+      {
+        xdata.add_constraint (2);
+        ydata.add_constraint (2);
+        cdata.add_constraint ("double");
+        cdata.add_constraint ("single");
+        cdata.add_constraint ("logical");
+        cdata.add_constraint ("uint8");
+        cdata.add_constraint ("uint16");
+        cdata.add_constraint ("int16");
+        cdata.add_constraint (dim_vector (-1, -1));
+        cdata.add_constraint (dim_vector (-1, -1, 3));
+      }
+
+  private:
+    void update_xdata (void)
+    {
+      Matrix limits = xdata.get_limits ();
+      float dp = pixel_xsize ();
+
+      limits(0) = limits(0) - dp;
+      limits(1) = limits(1) + dp;
+      set_xlim (limits);
+    }
+
+    void update_ydata (void)
+    {
+      Matrix limits = ydata.get_limits ();
+      float dp = pixel_ysize ();
+
+      limits(0) = limits(0) - dp;
+      limits(1) = limits(1) + dp;
+      set_ylim (limits);
+    }
+
+    void update_cdata (void)
+      {
+        if (cdatamapping_is ("scaled"))
+          set_clim (cdata.get_limits ());
+        else
+          clim = cdata.get_limits ();
+      }
+
+    float pixel_size (octave_idx_type dim, const Matrix limits)
+    {
+      octave_idx_type l = dim - 1;
+      float dp;
+
+      if (l > 0 && limits(0) != limits(1))
+        dp = (limits(1) - limits(0))/(2*l);
+      else
+        {
+          if (limits(1) == limits(2))
+            dp = 0.5;
+          else
+            dp = (limits(1) - limits(0))/2;
+        }
+      return dp;
+    }
+
+  public:
+    float  pixel_xsize (void)
+    {
+      return pixel_size ((get_cdata ().dims ())(1), xdata.get_limits ());
+    }
+
+    float pixel_ysize (void)
+    {
+      return pixel_size ((get_cdata ().dims ())(0), ydata.get_limits ());
+    }
+  };
+
+private:
+  properties xproperties;
+
+public:
+  image (const graphics_handle& mh, const graphics_handle& p)
+    : base_graphics_object (), xproperties (mh, p)
+  {
+    xproperties.override_defaults (*this);
+  }
+
+  ~image (void) { }
+
+  base_properties& get_properties (void) { return xproperties; }
+
+  const base_properties& get_properties (void) const { return xproperties; }
+
+  bool valid_object (void) const { return true; }
+};
+
+// ---------------------------------------------------------------------
+
+class OCTINTERP_API patch : public base_graphics_object
+{
+public:
+  class OCTINTERP_API properties : public base_properties
+  {
+  public:
+    octave_value get_color_data (void) const;
+
+    bool is_climinclude (void) const
+      { return (climinclude.is_on () && cdatamapping.is ("scaled")); }
+    std::string get_climinclude (void) const
+      { return climinclude.current_value (); }
+
+    bool is_aliminclude (void) const
+      { return (aliminclude.is_on () && alphadatamapping.is ("scaled")); }
+    std::string get_aliminclude (void) const
+      { return aliminclude.current_value (); }
+
+    // See the genprops.awk script for an explanation of the
+    // properties declarations.
+
+    BEGIN_PROPERTIES (patch)
+      array_property xdata u , Matrix ()
+      array_property ydata u , Matrix ()
+      array_property zdata u , Matrix ()
+      array_property cdata u , Matrix ()
+      radio_property cdatamapping l , "{scaled}|direct"
+      array_property faces , Matrix ()
+      array_property facevertexalphadata , Matrix ()
+      array_property facevertexcdata , Matrix ()
+      array_property vertices , Matrix ()
+      array_property vertexnormals , Matrix ()
+      radio_property normalmode , "{auto}|manual"
+      color_property facecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp"))
+      double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp"))
+      radio_property facelighting , "flat|{none}|gouraud|phong"
+      color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp"))
+      double_radio_property edgealpha , double_radio_property (1.0, radio_values ("flat|interp"))
+      radio_property edgelighting , "{none}|flat|gouraud|phong"
+      radio_property backfacelighting , "{reverselit}|unlit|lit"
+      double_property ambientstrength , 0.3
+      double_property diffusestrength , 0.6
+      double_property specularstrength , 0.6
+      double_property specularexponent , 10.0
+      double_property specularcolorreflectance , 1.0
+      radio_property erasemode , "{normal}|background|xor|none"
+      radio_property linestyle , "{-}|--|:|-.|none"
+      double_property linewidth , 0.5
+      radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h|@"
+      color_property markeredgecolor , "{auto}|none|flat"
+      color_property markerfacecolor , "auto|{none}|flat"
+      double_property markersize , 6
+      radio_property interpreter , "{tex}|none|latex"
+      string_property displayname , ""
+      radio_property alphadatamapping l , "none|{scaled}|direct"
+      // hidden properties for limit computation
+      row_vector_property xlim hlr , Matrix ()
+      row_vector_property ylim hlr , Matrix ()
+      row_vector_property zlim hlr , Matrix ()
+      row_vector_property clim hlr , Matrix ()
+      row_vector_property alim hlr , Matrix ()
+      bool_property xliminclude hl , "on"
+      bool_property yliminclude hl , "on"
+      bool_property zliminclude hl , "on"
+      bool_property climinclude hlg , "on"
+      bool_property aliminclude hlg , "on"
+    END_PROPERTIES
+
+  protected:
+    void init (void)
+      {
+        xdata.add_constraint (dim_vector (-1, -1));
+        ydata.add_constraint (dim_vector (-1, -1));
+        zdata.add_constraint (dim_vector (-1, -1));
+        vertices.add_constraint (dim_vector (-1, 2));
+        vertices.add_constraint (dim_vector (-1, 3));
+        cdata.add_constraint (dim_vector (-1, -1));
+        cdata.add_constraint (dim_vector (-1, -1, 3));
+        facevertexcdata.add_constraint (dim_vector (-1, 1));
+        facevertexcdata.add_constraint (dim_vector (-1, 3));
+        facevertexalphadata.add_constraint (dim_vector (-1, 1));
+      }
+
+  private:
+    void update_xdata (void) { set_xlim (xdata.get_limits ()); }
+    void update_ydata (void) { set_ylim (ydata.get_limits ()); }
+    void update_zdata (void) { set_zlim (zdata.get_limits ()); }
+
+    void update_cdata (void)
+      {
+        if (cdatamapping_is ("scaled"))
+          set_clim (cdata.get_limits ());
+        else
+          clim = cdata.get_limits ();
+      }
+  };
+
+private:
+  properties xproperties;
+
+public:
+  patch (const graphics_handle& mh, const graphics_handle& p)
+    : base_graphics_object (), xproperties (mh, p)
+  {
+    xproperties.override_defaults (*this);
+  }
+
+  ~patch (void) { }
+
+  base_properties& get_properties (void) { return xproperties; }
+
+  const base_properties& get_properties (void) const { return xproperties; }
+
+  bool valid_object (void) const { return true; }
+};
+
+// ---------------------------------------------------------------------
+
+class OCTINTERP_API surface : public base_graphics_object
+{
+public:
+  class OCTINTERP_API properties : public base_properties
+  {
+  public:
+    octave_value get_color_data (void) const;
+
+    bool is_climinclude (void) const
+      { return (climinclude.is_on () && cdatamapping.is ("scaled")); }
+    std::string get_climinclude (void) const
+      { return climinclude.current_value (); }
+
+    bool is_aliminclude (void) const
+      { return (aliminclude.is_on () && alphadatamapping.is ("scaled")); }
+    std::string get_aliminclude (void) const
+      { return aliminclude.current_value (); }
+
+    // See the genprops.awk script for an explanation of the
+    // properties declarations.
+
+    BEGIN_PROPERTIES (surface)
+      array_property xdata u , Matrix ()
+      array_property ydata u , Matrix ()
+      array_property zdata u , Matrix ()
+      array_property cdata u , Matrix ()
+      radio_property cdatamapping al , "{scaled}|direct"
+      string_property xdatasource , ""
+      string_property ydatasource , ""
+      string_property zdatasource , ""
+      string_property cdatasource , ""
+      color_property facecolor , "{flat}|none|interp|texturemap"
+      double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp"))
+      color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp"))
+      radio_property linestyle , "{-}|--|:|-.|none"
+      double_property linewidth , 0.5
+      radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h|@"
+      color_property markeredgecolor , "{auto}|none"
+      color_property markerfacecolor , "auto|{none}"
+      double_property markersize , 6
+      radio_property interpreter , "{tex}|none|latex"
+      string_property displayname , ""
+      array_property alphadata u , Matrix ()
+      radio_property alphadatamapping l , "none|direct|{scaled}"
+      double_property ambientstrength , 0.3
+      radio_property backfacelighting , "unlit|lit|{reverselit}"
+      double_property diffusestrength , 0.6
+      double_radio_property edgealpha , double_radio_property (1.0, radio_values ("flat|interp"))
+      radio_property edgelighting , "{none}|flat|gouraud|phong"
+      radio_property erasemode , "{normal}|none|xor|background"
+      radio_property facelighting , "{none}|flat|gouraud|phong"
+      radio_property meshstyle , "{both}|row|column"
+      radio_property normalmode u , "{auto}|manual"
+      double_property specularcolorreflectance , 1
+      double_property specularexponent , 10
+      double_property specularstrength , 0.9
+      array_property vertexnormals u , Matrix ()
+      // hidden properties for limit computation
+      row_vector_property xlim hlr , Matrix ()
+      row_vector_property ylim hlr , Matrix ()
+      row_vector_property zlim hlr , Matrix ()
+      row_vector_property clim hlr , Matrix ()
+      row_vector_property alim hlr , Matrix ()
+      bool_property xliminclude hl , "on"
+      bool_property yliminclude hl , "on"
+      bool_property zliminclude hl , "on"
+      bool_property climinclude hlg , "on"
+      bool_property aliminclude hlg , "on"
+    END_PROPERTIES
+
+  protected:
+    void init (void)
+      {
+        xdata.add_constraint (dim_vector (-1, -1));
+        ydata.add_constraint (dim_vector (-1, -1));
+        zdata.add_constraint (dim_vector (-1, -1));
+        alphadata.add_constraint ("single");
+        alphadata.add_constraint ("double");
+        alphadata.add_constraint ("uint8");
+        alphadata.add_constraint (dim_vector (-1, -1));
+        vertexnormals.add_constraint (dim_vector (-1, -1, 3));
+        cdata.add_constraint ("single");
+        cdata.add_constraint ("double");
+        cdata.add_constraint ("uint8");
+        cdata.add_constraint (dim_vector (-1, -1));
+        cdata.add_constraint (dim_vector (-1, -1, 3));
+      }
+
+  private:
+    void update_normals (void);
+
+    void update_xdata (void)
+      {
+        update_normals ();
+        set_xlim (xdata.get_limits ());
+      }
+
+    void update_ydata (void)
+      {
+        update_normals ();
+        set_ylim (ydata.get_limits ());
+      }
+
+    void update_zdata (void)
+      {
+        update_normals ();
+        set_zlim (zdata.get_limits ());
+      }
+
+    void update_cdata (void)
+      {
+        if (cdatamapping_is ("scaled"))
+          set_clim (cdata.get_limits ());
+        else
+          clim = cdata.get_limits ();
+      }
+
+    void update_alphadata (void)
+      {
+        if (alphadatamapping_is ("scaled"))
+          set_alim (alphadata.get_limits ());
+        else
+          alim = alphadata.get_limits ();
+      }
+
+    void update_normalmode (void)
+      { update_normals (); }
+
+    void update_vertexnormals (void)
+      { set_normalmode ("manual"); }
+  };
+
+private:
+  properties xproperties;
+
+public:
+  surface (const graphics_handle& mh, const graphics_handle& p)
+    : base_graphics_object (), xproperties (mh, p)
+  {
+    xproperties.override_defaults (*this);
+  }
+
+  ~surface (void) { }
+
+  base_properties& get_properties (void) { return xproperties; }
+
+  const base_properties& get_properties (void) const { return xproperties; }
+
+  bool valid_object (void) const { return true; }
+};
+
+// ---------------------------------------------------------------------
+
+class OCTINTERP_API hggroup : public base_graphics_object
+{
+public:
+  class OCTINTERP_API properties : public base_properties
+  {
+  public:
+    void remove_child (const graphics_handle& h)
+      {
+        base_properties::remove_child (h);
+        update_limits ();
+      }
+
+    void adopt (const graphics_handle& h)
+      {
+
+        base_properties::adopt (h);
+        update_limits (h);
+      }
+
+    // See the genprops.awk script for an explanation of the
+    // properties declarations.
+
+    BEGIN_PROPERTIES (hggroup)
+      // hidden properties for limit computation
+      row_vector_property xlim hr , Matrix()
+      row_vector_property ylim hr , Matrix()
+      row_vector_property zlim hr , Matrix()
+      row_vector_property clim hr , Matrix()
+      row_vector_property alim hr , Matrix()
+      bool_property xliminclude h , "on"
+      bool_property yliminclude h , "on"
+      bool_property zliminclude h , "on"
+      bool_property climinclude h , "on"
+      bool_property aliminclude h , "on"
+    END_PROPERTIES
+
+  private:
+      void update_limits (void) const;
+
+      void update_limits (const graphics_handle& h) const;
+
+  protected:
+    void init (void)
+      { }
+
+  };
+
+private:
+  properties xproperties;
+
+public:
+  hggroup (const graphics_handle& mh, const graphics_handle& p)
+    : base_graphics_object (), xproperties (mh, p)
+  {
+    xproperties.override_defaults (*this);
+  }
+
+  ~hggroup (void) { }
+
+  base_properties& get_properties (void) { return xproperties; }
+
+  const base_properties& get_properties (void) const { return xproperties; }
+
+  bool valid_object (void) const { return true; }
+
+  void update_axis_limits (const std::string& axis_type);
+
+  void update_axis_limits (const std::string& axis_type,
+                           const graphics_handle& h);
+
+};
+
+// ---------------------------------------------------------------------
+
+class OCTINTERP_API uimenu : public base_graphics_object
+{
+public:
+  class OCTINTERP_API properties : public base_properties
+  {
+  public:
+    void remove_child (const graphics_handle& h)
+      {
+        base_properties::remove_child (h);
+      }
+
+    void adopt (const graphics_handle& h)
+      {
+        base_properties::adopt (h);
+      }
+
+    // See the genprops.awk script for an explanation of the
+    // properties declarations.
+
+    BEGIN_PROPERTIES (uimenu)
+      any_property __object__ , Matrix ()
+      string_property accelerator , ""
+      callback_property callback , Matrix()
+      bool_property checked , "off"
+      bool_property enable , "on"
+      color_property foregroundcolor , color_values (0, 0, 0)
+      string_property label , ""
+      double_property position , 9
+      bool_property separator , "off"
+      string_property fltk_label h , ""
+    END_PROPERTIES
+
+  protected:
+    void init (void)
+      { }
+  };
+
+private:
+  properties xproperties;
+
+public:
+  uimenu (const graphics_handle& mh, const graphics_handle& p)
+    : base_graphics_object (), xproperties (mh, p)
+  {
+    xproperties.override_defaults (*this);
+  }
+
+  ~uimenu (void) { }
+
+  base_properties& get_properties (void) { return xproperties; }
+
+  const base_properties& get_properties (void) const { return xproperties; }
+
+  bool valid_object (void) const { return true; }
+
+};
+
+// ---------------------------------------------------------------------
+
+class OCTINTERP_API uicontextmenu : public base_graphics_object
+{
+public:
+  class OCTINTERP_API properties : public base_properties
+  {
+  public:
+    // See the genprops.awk script for an explanation of the
+    // properties declarations.
+
+    BEGIN_PROPERTIES (uicontextmenu)
+      any_property __object__ , Matrix ()
+      callback_property callback , Matrix()
+      array_property position , Matrix (1, 2, 0.0)
+    END_PROPERTIES
+
+  protected:
+    void init (void)
+      {
+        position.add_constraint (dim_vector (1, 2));
+        position.add_constraint (dim_vector (2, 1));
+        visible.set (octave_value (true));
+      }
+  };
+
+private:
+  properties xproperties;
+
+public:
+  uicontextmenu (const graphics_handle& mh, const graphics_handle& p)
+    : base_graphics_object (), xproperties (mh, p)
+  {
+    xproperties.override_defaults (*this);
+  }
+
+  ~uicontextmenu (void) { }
+
+  base_properties& get_properties (void) { return xproperties; }
+
+  const base_properties& get_properties (void) const { return xproperties; }
+
+  bool valid_object (void) const { return true; }
+
+};
+
+// ---------------------------------------------------------------------
+
+class OCTINTERP_API uicontrol : public base_graphics_object
+{
+public:
+  class OCTINTERP_API properties : public base_properties
+  {
+  public:
+    Matrix get_boundingbox (bool internal = false,
+                            const Matrix& parent_pix_size = Matrix ()) const;
+
+    double get_fontsize_points (double box_pix_height = 0) const;
+
+    // See the genprops.awk script for an explanation of the
+    // properties declarations.
+
+    BEGIN_PROPERTIES (uicontrol)
+      any_property __object__ , Matrix ()
+      color_property backgroundcolor , color_values (1, 1, 1)
+      callback_property callback , Matrix ()
+      array_property cdata , Matrix ()
+      bool_property clipping , "on"
+      radio_property enable , "{on}|inactive|off"
+      array_property extent rG , Matrix (1, 4, 0.0)
+      radio_property fontangle u , "{normal}|italic|oblique"
+      string_property fontname u , OCTAVE_DEFAULT_FONTNAME
+      double_property fontsize u , 10
+      radio_property fontunits S , "inches|centimeters|normalized|{points}|pixels"
+      radio_property fontweight u , "light|{normal}|demi|bold"
+      color_property foregroundcolor , color_values (0, 0, 0)
+      radio_property horizontalalignment , "{left}|center|right"
+      callback_property keypressfcn , Matrix ()
+      double_property listboxtop , 1
+      double_property max , 1
+      double_property min , 0
+      array_property position , default_control_position ()
+      array_property sliderstep , default_control_sliderstep ()
+      string_array_property string u , ""
+      radio_property style S , "{pushbutton}|togglebutton|radiobutton|checkbox|edit|text|slider|frame|listbox|popupmenu"
+      string_property tooltipstring , ""
+      radio_property units u , "normalized|inches|centimeters|points|{pixels}|characters"
+      row_vector_property value , Matrix (1, 1, 1.0)
+      radio_property verticalalignment , "top|{middle}|bottom"
+    END_PROPERTIES
+
+  private:
+    std::string cached_units;
+
+  protected:
+    void init (void)
+      {
+        cdata.add_constraint ("double");
+        cdata.add_constraint ("single");
+        cdata.add_constraint ("uint8");
+        cdata.add_constraint (dim_vector (-1, -1, 3));
+        position.add_constraint (dim_vector (1, 4));
+        sliderstep.add_constraint (dim_vector (1, 2));
+        cached_units = get_units ();
+      }
+    
+    void update_text_extent (void);
+
+    void update_string (void) { update_text_extent (); }
+    void update_fontname (void) { update_text_extent (); }
+    void update_fontsize (void) { update_text_extent (); }
+    void update_fontangle (void) { update_text_extent (); }
+    void update_fontweight (void) { update_text_extent (); }
+    void update_fontunits (const caseless_str& old_units);
+
+    void update_units (void);
+
+  };
+
+private:
+  properties xproperties;
+
+public:
+  uicontrol (const graphics_handle& mh, const graphics_handle& p)
+    : base_graphics_object (), xproperties (mh, p)
+  {
+    xproperties.override_defaults (*this);
+  }
+
+  ~uicontrol (void) { }
+
+  base_properties& get_properties (void) { return xproperties; }
+
+  const base_properties& get_properties (void) const { return xproperties; }
+
+  bool valid_object (void) const { return true; }
+};
+
+// ---------------------------------------------------------------------
+
+class OCTINTERP_API uipanel : public base_graphics_object
+{
+public:
+  class OCTINTERP_API properties : public base_properties
+  {
+  public:
+    Matrix get_boundingbox (bool internal = false,
+                            const Matrix& parent_pix_size = Matrix ()) const;
+
+    double get_fontsize_points (double box_pix_height = 0) const;
+
+    // See the genprops.awk script for an explanation of the
+    // properties declarations.
+
+    BEGIN_PROPERTIES (uipanel)
+      any_property __object__ , Matrix ()
+      color_property backgroundcolor , color_values (1, 1, 1)
+      radio_property bordertype , "none|{etchedin}|etchedout|beveledin|beveledout|line"
+      double_property borderwidth , 1
+      radio_property fontangle , "{normal}|italic|oblique"
+      string_property fontname , OCTAVE_DEFAULT_FONTNAME
+      double_property fontsize , 10
+      radio_property fontunits S , "inches|centimeters|normalized|{points}|pixels"
+      radio_property fontweight , "light|{normal}|demi|bold"
+      color_property foregroundcolor , color_values (0, 0, 0)
+      color_property highlightcolor , color_values (1, 1, 1)
+      array_property position , default_panel_position ()
+      callback_property resizefcn , Matrix ()
+      color_property shadowcolor , color_values (0, 0, 0)
+      string_property title , ""
+      radio_property titleposition , "{lefttop}|centertop|righttop|leftbottom|centerbottom|rightbottom"
+      radio_property units S , "{normalized}|inches|centimeters|points|pixels|characters"
+    END_PROPERTIES
+
+  protected:
+    void init (void)
+      {
+        position.add_constraint (dim_vector (1, 4));
+      }
+    
+    void update_units (const caseless_str& old_units);
+    void update_fontunits (const caseless_str& old_units);
+
+  };
+
+private:
+  properties xproperties;
+
+public:
+  uipanel (const graphics_handle& mh, const graphics_handle& p)
+    : base_graphics_object (), xproperties (mh, p)
+  {
+    xproperties.override_defaults (*this);
+  }
+
+  ~uipanel (void) { }
+
+  base_properties& get_properties (void) { return xproperties; }
+
+  const base_properties& get_properties (void) const { return xproperties; }
+
+  bool valid_object (void) const { return true; }
+};
+
+// ---------------------------------------------------------------------
+
+class OCTINTERP_API uitoolbar : public base_graphics_object
+{
+public:
+  class OCTINTERP_API properties : public base_properties
+  {
+  public:
+    // See the genprops.awk script for an explanation of the
+    // properties declarations.
+
+    BEGIN_PROPERTIES (uitoolbar)
+      any_property __object__ , Matrix ()
+    END_PROPERTIES
+
+  protected:
+    void init (void)
+      { }
+  };
+
+private:
+  properties xproperties;
+
+public:
+  uitoolbar (const graphics_handle& mh, const graphics_handle& p)
+    : base_graphics_object (), xproperties (mh, p), default_properties ()
+  {
+    xproperties.override_defaults (*this);
+  }
+
+  ~uitoolbar (void) { }
+
+  void override_defaults (base_graphics_object& obj)
+  {
+    // Allow parent (figure) to override first (properties knows how
+    // to find the parent object).
+    xproperties.override_defaults (obj);
+
+    // Now override with our defaults.  If the default_properties
+    // list includes the properties for all defaults (line,
+    // surface, etc.) then we don't have to know the type of OBJ
+    // here, we just call its set function and let it decide which
+    // properties from the list to use.
+    obj.set_from_list (default_properties);
+  }
+
+  void set (const caseless_str& name, const octave_value& value)
+  {
+    if (name.compare ("default", 7))
+      // strip "default", pass rest to function that will
+      // parse the remainder and add the element to the
+      // default_properties map.
+      default_properties.set (name.substr (7), value);
+    else
+      xproperties.set (name, value);
+  }
+
+  octave_value get (const caseless_str& name) const
+  {
+    octave_value retval;
+
+    if (name.compare ("default", 7))
+      retval = get_default (name.substr (7));
+    else
+      retval = xproperties.get (name);
+
+    return retval;
+  }
+
+  octave_value get_default (const caseless_str& name) const;
+
+  octave_value get_defaults (void) const
+  {
+    return default_properties.as_struct ("default");
+  }
+
+  base_properties& get_properties (void) { return xproperties; }
+
+  const base_properties& get_properties (void) const { return xproperties; }
+
+  bool valid_object (void) const { return true; }
+
+  void reset_default_properties (void);
+
+private:
+  property_list default_properties;
+};
+
+// ---------------------------------------------------------------------
+
+class OCTINTERP_API uipushtool : public base_graphics_object
+{
+public:
+  class OCTINTERP_API properties : public base_properties
+  {
+  public:
+    // See the genprops.awk script for an explanation of the
+    // properties declarations.
+
+    BEGIN_PROPERTIES (uipushtool)
+      any_property __object__ , Matrix ()
+      array_property cdata , Matrix ()
+      callback_property clickedcallback , Matrix()
+      bool_property enable , "on"
+      bool_property separator , "off"
+      string_property tooltipstring , ""
+    END_PROPERTIES
+
+  protected:
+    void init (void)
+      {
+        cdata.add_constraint ("double");
+        cdata.add_constraint ("single");
+        cdata.add_constraint ("uint8");
+        cdata.add_constraint (dim_vector (-1, -1, 3));
+      }
+  };
+
+private:
+  properties xproperties;
+
+public:
+  uipushtool (const graphics_handle& mh, const graphics_handle& p)
+    : base_graphics_object (), xproperties (mh, p)
+  {
+    xproperties.override_defaults (*this);
+  }
+
+  ~uipushtool (void) { }
+
+  base_properties& get_properties (void) { return xproperties; }
+
+  const base_properties& get_properties (void) const { return xproperties; }
+
+  bool valid_object (void) const { return true; }
+
+};
+
+// ---------------------------------------------------------------------
+
+class OCTINTERP_API uitoggletool : public base_graphics_object
+{
+public:
+  class OCTINTERP_API properties : public base_properties
+  {
+  public:
+    // See the genprops.awk script for an explanation of the
+    // properties declarations.
+
+    BEGIN_PROPERTIES (uitoggletool)
+      any_property __object__ , Matrix ()
+      array_property cdata , Matrix ()
+      callback_property clickedcallback , Matrix()
+      bool_property enable , "on"
+      callback_property offcallback , Matrix()
+      callback_property oncallback , Matrix()
+      bool_property separator , "off"
+      bool_property state , "off"
+      string_property tooltipstring , ""
+    END_PROPERTIES
+
+  protected:
+    void init (void)
+      {
+        cdata.add_constraint ("double");
+        cdata.add_constraint ("single");
+        cdata.add_constraint ("uint8");
+        cdata.add_constraint (dim_vector (-1, -1, 3));
+      }
+  };
+
+private:
+  properties xproperties;
+
+public:
+  uitoggletool (const graphics_handle& mh, const graphics_handle& p)
+    : base_graphics_object (), xproperties (mh, p)
+  {
+    xproperties.override_defaults (*this);
+  }
+
+  ~uitoggletool (void) { }
+
+  base_properties& get_properties (void) { return xproperties; }
+
+  const base_properties& get_properties (void) const { return xproperties; }
+
+  bool valid_object (void) const { return true; }
+
+};
+
+// ---------------------------------------------------------------------
+
+octave_value
+get_property_from_handle (double handle, const std::string &property,
+                          const std::string &func);
+bool
+set_property_in_handle (double handle, const std::string &property,
+                        const octave_value &arg, const std::string &func);
+
+// ---------------------------------------------------------------------
+
+class graphics_event;
+
+class
+base_graphics_event
+{
+public:
+  friend class graphics_event;
+
+  base_graphics_event (void) : count (1) { }
+
+  virtual ~base_graphics_event (void) { }
+
+  virtual void execute (void) = 0;
+
+private:
+  octave_refcount<int> count;
+};
+
+class
+graphics_event
+{
+public:
+  typedef void (*event_fcn) (void*);
+
+  graphics_event (void) : rep (0) { }
+
+  graphics_event (const graphics_event& e) : rep (e.rep)
+    {
+      rep->count++;
+    }
+
+  ~graphics_event (void)
+    {
+      if (rep && --rep->count == 0)
+        delete rep;
+    }
+
+  graphics_event& operator = (const graphics_event& e)
+    {
+      if (rep != e.rep)
+        {
+          if (rep && --rep->count == 0)
+            delete rep;
+
+          rep = e.rep;
+          if (rep)
+            rep->count++;
+        }
+
+      return *this;
+    }
+
+  void execute (void)
+    { if (rep) rep->execute (); }
+
+  bool ok (void) const
+    { return (rep != 0); }
+
+  static graphics_event
+      create_callback_event (const graphics_handle& h,
+                             const std::string& name,
+                             const octave_value& data = Matrix ());
+  
+  static graphics_event
+      create_callback_event (const graphics_handle& h,
+                             const octave_value& cb,
+                             const octave_value& data = Matrix ());
+
+  static graphics_event
+      create_function_event (event_fcn fcn, void *data = 0);
+
+  static graphics_event
+      create_set_event (const graphics_handle& h, const std::string& name,
+                        const octave_value& value,
+                        bool notify_toolkit = true);
+private:
+  base_graphics_event *rep;
+};
+
+class OCTINTERP_API gh_manager
+{
+protected:
+
+  gh_manager (void);
+
+public:
+
+  static void create_instance (void);
+
+  static bool instance_ok (void)
+  {
+    bool retval = true;
+
+    if (! instance)
+      create_instance ();
+
+    if (! instance)
+      {
+        ::error ("unable to create gh_manager!");
+
+        retval = false;
+      }
+
+    return retval;
+  }
+
+  static void cleanup_instance (void) { delete instance; instance = 0; }
+
+  static graphics_handle get_handle (bool integer_figure_handle)
+  {
+    return instance_ok ()
+      ? instance->do_get_handle (integer_figure_handle) : graphics_handle ();
+  }
+
+  static void free (const graphics_handle& h)
+  {
+    if (instance_ok ())
+      instance->do_free (h);
+  }
+
+  static void renumber_figure (const graphics_handle& old_gh,
+                               const graphics_handle& new_gh)
+  {
+    if (instance_ok ())
+      instance->do_renumber_figure (old_gh, new_gh);
+  }
+
+  static graphics_handle lookup (double val)
+  {
+    return instance_ok () ? instance->do_lookup (val) : graphics_handle ();
+  }
+
+  static graphics_handle lookup (const octave_value& val)
+  {
+    return val.is_real_scalar ()
+      ? lookup (val.double_value ()) : graphics_handle ();
+  }
+
+  static graphics_object get_object (double val)
+  {
+    return get_object (lookup (val));
+  }
+
+  static graphics_object get_object (const graphics_handle& h)
+  {
+    return instance_ok () ? instance->do_get_object (h) : graphics_object ();
+  }
+
+  static graphics_handle
+  make_graphics_handle (const std::string& go_name,
+                        const graphics_handle& parent,
+                        bool integer_figure_handle = false,
+                        bool do_createfcn = true,
+                        bool do_notify_toolkit = true)
+  {
+    return instance_ok ()
+      ? instance->do_make_graphics_handle (go_name, parent,
+                                           integer_figure_handle,
+                                           do_createfcn, do_notify_toolkit)
+      : graphics_handle ();
+  }
+
+  static graphics_handle make_figure_handle (double val,
+                                             bool do_notify_toolkit = true)
+  {
+    return instance_ok ()
+      ? instance->do_make_figure_handle (val, do_notify_toolkit)
+      : graphics_handle ();
+  }
+
+  static void push_figure (const graphics_handle& h)
+  {
+    if (instance_ok ())
+      instance->do_push_figure (h);
+  }
+
+  static void pop_figure (const graphics_handle& h)
+  {
+    if (instance_ok ())
+      instance->do_pop_figure (h);
+  }
+
+  static graphics_handle current_figure (void)
+  {
+    return instance_ok ()
+      ? instance->do_current_figure () : graphics_handle ();
+  }
+
+  static Matrix handle_list (bool show_hidden = false)
+  {
+    return instance_ok ()
+      ? instance->do_handle_list (show_hidden) : Matrix ();
+  }
+
+  static void lock (void)
+  {
+    if (instance_ok ())
+      instance->do_lock ();
+  }
+
+  static bool try_lock (void)
+  {
+    if (instance_ok ())
+      return instance->do_try_lock ();
+    else
+      return false;
+  }
+
+  static void unlock (void)
+  {
+    if (instance_ok ())
+      instance->do_unlock ();
+  }
+  
+  static Matrix figure_handle_list (bool show_hidden = false)
+  {
+    return instance_ok ()
+      ? instance->do_figure_handle_list (show_hidden) : Matrix ();
+  }
+
+  static void execute_listener (const graphics_handle& h,
+                                const octave_value& l)
+  {
+    if (instance_ok ())
+      instance->do_execute_listener (h, l);
+  }
+
+  static void execute_callback (const graphics_handle& h,
+                                const std::string& name,
+                                const octave_value& data = Matrix ())
+  {
+    octave_value cb;
+
+    if (true)
+      {
+        gh_manager::auto_lock lock;
+
+        graphics_object go = get_object (h);
+
+        if (go.valid_object ())
+          cb = go.get (name);
+      }
+
+    if (! error_state)
+      execute_callback (h, cb, data);
+  }
+
+  static void execute_callback (const graphics_handle& h,
+                                const octave_value& cb,
+                                const octave_value& data = Matrix ())
+  {
+    if (instance_ok ())
+      instance->do_execute_callback (h, cb, data);
+  }
+
+  static void post_callback (const graphics_handle& h,
+                             const std::string& name,
+                             const octave_value& data = Matrix ())
+  {
+    if (instance_ok ())
+      instance->do_post_callback (h, name, data);
+  }
+  
+  static void post_function (graphics_event::event_fcn fcn, void* data = 0)
+  {
+    if (instance_ok ())
+      instance->do_post_function (fcn, data);
+  }
+
+  static void post_set (const graphics_handle& h, const std::string& name,
+                        const octave_value& value, bool notify_toolkit = true)
+  {
+    if (instance_ok ())
+      instance->do_post_set (h, name, value, notify_toolkit);
+  }
+
+  static int process_events (void)
+  {
+    return (instance_ok () ?  instance->do_process_events () : 0);
+  }
+
+  static int flush_events (void)
+  {
+    return (instance_ok () ?  instance->do_process_events (true) : 0);
+  }
+
+  static void enable_event_processing (bool enable = true)
+    {
+      if (instance_ok ())
+        instance->do_enable_event_processing (enable);
+    }
+
+  static bool is_handle_visible (const graphics_handle& h)
+  {
+    bool retval = false;
+
+    graphics_object go = get_object (h);
+
+    if (go.valid_object ())
+      retval = go.is_handle_visible ();
+
+    return retval;
+  }
+
+  static void close_all_figures (void)
+  {
+    if (instance_ok ())
+      instance->do_close_all_figures ();
+  }
+
+public:
+  class auto_lock : public octave_autolock
+  {
+  public:
+    auto_lock (bool wait = true)
+      : octave_autolock (instance_ok ()
+                         ? instance->graphics_lock
+                         : octave_mutex (),
+                         wait)
+      { }
+
+  private:
+
+    // No copying!
+    auto_lock (const auto_lock&);
+    auto_lock& operator = (const auto_lock&);
+  };
+
+private:
+
+  static gh_manager *instance;
+
+  typedef std::map<graphics_handle, graphics_object>::iterator iterator;
+  typedef std::map<graphics_handle, graphics_object>::const_iterator const_iterator;
+
+  typedef std::set<graphics_handle>::iterator free_list_iterator;
+  typedef std::set<graphics_handle>::const_iterator const_free_list_iterator;
+
+  typedef std::list<graphics_handle>::iterator figure_list_iterator;
+  typedef std::list<graphics_handle>::const_iterator const_figure_list_iterator;
+
+  // A map of handles to graphics objects.
+  std::map<graphics_handle, graphics_object> handle_map;
+
+  // The available graphics handles.
+  std::set<graphics_handle> handle_free_list;
+
+  // The next handle available if handle_free_list is empty.
+  double next_handle;
+
+  // The allocated figure handles.  Top of the stack is most recently
+  // created.
+  std::list<graphics_handle> figure_list;
+
+  // The lock for accessing the graphics sytsem.
+  octave_mutex graphics_lock;
+
+  // The list of events queued by graphics toolkits.
+  std::list<graphics_event> event_queue;
+
+  // The stack of callback objects.
+  std::list<graphics_object> callback_objects;
+
+  // A flag telling whether event processing must be constantly on.
+  int event_processing;
+
+  graphics_handle do_get_handle (bool integer_figure_handle);
+
+  void do_free (const graphics_handle& h);
+
+  void do_renumber_figure (const graphics_handle& old_gh,
+                           const graphics_handle& new_gh);
+
+  graphics_handle do_lookup (double val)
+  {
+    iterator p = (xisnan (val) ? handle_map.end () : handle_map.find (val));
+
+    return (p != handle_map.end ()) ? p->first : graphics_handle ();
+  }
+
+  graphics_object do_get_object (const graphics_handle& h)
+  {
+    iterator p = (h.ok () ? handle_map.find (h) : handle_map.end ());
+
+    return (p != handle_map.end ()) ? p->second : graphics_object ();
+  }
+
+  graphics_handle do_make_graphics_handle (const std::string& go_name,
+                                           const graphics_handle& p,
+                                           bool integer_figure_handle,
+                                           bool do_createfcn,
+                                           bool do_notify_toolkit);
+
+  graphics_handle do_make_figure_handle (double val, bool do_notify_toolkit);
+
+  Matrix do_handle_list (bool show_hidden)
+  {
+    Matrix retval (1, handle_map.size ());
+
+    octave_idx_type i = 0;
+    for (const_iterator p = handle_map.begin (); p != handle_map.end (); p++)
+      {
+        graphics_handle h = p->first;
+
+        if (show_hidden || is_handle_visible (h))
+          retval(i++) = h.value ();
+      }
+
+    retval.resize (1, i);
+
+    return retval;
+  }
+
+  Matrix do_figure_handle_list (bool show_hidden)
+  {
+    Matrix retval (1, figure_list.size ());
+
+    octave_idx_type i = 0;
+    for (const_figure_list_iterator p = figure_list.begin ();
+         p != figure_list.end ();
+         p++)
+      {
+        graphics_handle h = *p;
+
+        if (show_hidden || is_handle_visible (h))
+          retval(i++) = h.value ();
+      }
+
+    retval.resize (1, i);
+
+    return retval;
+  }
+
+  void do_push_figure (const graphics_handle& h);
+
+  void do_pop_figure (const graphics_handle& h);
+
+  graphics_handle do_current_figure (void) const
+  {
+    graphics_handle retval;
+
+    for (const_figure_list_iterator p = figure_list.begin ();
+         p != figure_list.end ();
+         p++)
+      {
+        graphics_handle h = *p;
+
+        if (is_handle_visible (h))
+          retval = h;
+      }
+
+    return retval;
+  }
+
+  void do_lock (void) { graphics_lock.lock (); }
+
+  bool do_try_lock (void) { return graphics_lock.try_lock (); }
+
+  void do_unlock (void) { graphics_lock.unlock (); }
+
+  void do_execute_listener (const graphics_handle& h, const octave_value& l);
+
+  void do_execute_callback (const graphics_handle& h, const octave_value& cb,
+                            const octave_value& data);
+
+  void do_post_callback (const graphics_handle& h, const std::string name,
+                         const octave_value& data);
+  
+  void do_post_function (graphics_event::event_fcn fcn, void* fcn_data);
+
+  void do_post_set (const graphics_handle& h, const std::string name,
+                    const octave_value& value, bool notify_toolkit = true);
+
+  int do_process_events (bool force = false);
+
+  void do_close_all_figures (void);
+
+  static void restore_gcbo (void)
+  {
+    if (instance_ok ())
+      instance->do_restore_gcbo ();
+  }
+
+  void do_restore_gcbo (void);
+
+  void do_post_event (const graphics_event& e);
+
+  void do_enable_event_processing (bool enable = true);
+};
+
+void get_children_limits (double& min_val, double& max_val,
+                          double& min_pos, double& max_neg,
+                          const Matrix& kids, char limit_type);
+
+OCTINTERP_API int calc_dimensions (const graphics_object& gh);
+
+// This function is NOT equivalent to the scripting language function gcf.
+OCTINTERP_API graphics_handle gcf (void);
+
+// This function is NOT equivalent to the scripting language function gca.
+OCTINTERP_API graphics_handle gca (void);
+
+OCTINTERP_API void close_all_figures (void);
+
+#endif
--- a/src/lex.ll	Mon May 07 00:53:54 2012 +0200
+++ b/src/lex.ll	Mon May 07 00:56:44 2012 +0200
@@ -1417,6 +1417,10 @@
 delete_buffer (YY_BUFFER_STATE buf)
 {
   yy_delete_buffer (buf);
+
+  // Prevent invalid yyin from being used by yyrestart.
+  if (! current_buffer ())
+    yyin = 0; 
 }
 
 // Delete all buffers from the stack.
--- a/src/mkoctfile.cc.in	Mon May 07 00:53:54 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,784 +0,0 @@
-/*
-
-Copyright (C) 2008-2012 Michael Goffioul
-
-This file is part of Octave.
-
-Octave is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 3 of the License, or (at your
-option) any later version.
-
-Octave is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with Octave; see the file COPYING.  If not, see
-<http://www.gnu.org/licenses/>.
-
-*/
-
-#if defined (HAVE_CONFIG_H)
-#include <config.h>
-#endif
-
-#include <string>
-#include <map>
-#include <list>
-#include <algorithm>
-#include <iostream>
-#include <fstream>
-#include <vector>
-#include <cstdlib>
-
-#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
-#include <windows.h>
-#ifdef _MSC_VER
-#define popen _popen
-#define pclose _pclose
-#endif
-#endif
-
-using namespace std;
-
-static bool initialized = false;
-static map<string,string> vars;
-
-static string OCTAVE_VERSION = %OCTAVE_CONF_VERSION%;
-
-static std::string
-substitute_prefix (const std::string& s, const std::string& prefix,
-                   const std::string& new_prefix)
-{
-  std::string retval = s;
-
-  if (!prefix.empty () && new_prefix != prefix)
-    {
-      int len = prefix.length ();
-      if (retval.find (prefix) == 0)
-        retval.replace (0, len, new_prefix);
-    }
-
-#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
-  std::replace (retval.begin (), retval.end (), '/', '\\');
-#endif
-
-  return retval;
-}
-
-static string
-get_line (FILE *fp)
-{
-  static vector<char> buf (100);
-  int idx = 0;
-  char c;
-
-  while (true)
-    {
-      c = static_cast<char> (fgetc (fp));
-      if (c == '\n' || c == EOF)
-        break;
-      if (buf.size () <= idx)
-        buf.resize (buf.size () + 100);
-      buf[idx++] = c;
-    }
-  if (idx == 0)
-    return string ("");
-  else
-    return string (&buf[0], idx);
-}
-
-
-static string
-get_variable (const char *name, const string& defval)
-{
-  const char *val = getenv (name);
-  if (val == NULL || val[0] == '\0')
-    return defval;
-  else
-    return string (val);
-}
-
-static string
-quote_path (const string& s)
-{
-  if (s.find (' ') != string::npos && s[0] != '"')
-    return "\"" + s + "\"";
-  else
-    return s;
-}
-
-static void
-initialize (void)
-{
-  if (initialized)
-    return;
-
-  initialized = true;
-
-  vars["OCTAVE_HOME"] = get_variable ("OCTAVE_HOME", "");
-
-#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
-  int n = 1024;
-
-  std::string bin_dir (n, '\0');
-
-  while (true)
-    {
-      int status = GetModuleFileName (0, &bin_dir[0], n);
-
-      if (status < n)
-        {
-          bin_dir.resize (status);
-          break;
-        }
-      else
-        {
-          n *= 2;
-          bin_dir.resize (n);
-        }
-    }
-
-  if (! bin_dir.empty ())
-    {
-      size_t pos = bin_dir.rfind ("\\bin\\");
-
-      if (pos != string::npos)
-        vars["OCTAVE_HOME"] = bin_dir.substr (0, pos);
-    }
-#endif
-
-  vars["SED"] = get_variable ("SED", %OCTAVE_CONF_SED%);
-
-  vars["OCTAVE_PREFIX"] = %OCTAVE_CONF_PREFIX%;
-
-  std::string DEFAULT_OCTINCLUDEDIR = %OCTAVE_CONF_OCTINCLUDEDIR%;
-  std::string DEFAULT_INCLUDEDIR = %OCTAVE_CONF_INCLUDEDIR%;
-  std::string DEFAULT_LIBDIR = %OCTAVE_CONF_LIBDIR%;
-  std::string DEFAULT_OCTLIBDIR = %OCTAVE_CONF_OCTLIBDIR%;
-
-  if (! vars["OCTAVE_HOME"].empty ())
-    {
-      DEFAULT_OCTINCLUDEDIR
-        = substitute_prefix (DEFAULT_OCTINCLUDEDIR, vars["OCTAVE_PREFIX"],
-                             vars["OCTAVE_HOME"]);
-
-      DEFAULT_INCLUDEDIR
-        = substitute_prefix (DEFAULT_INCLUDEDIR, vars["OCTAVE_PREFIX"],
-                             vars["OCTAVE_HOME"]);
-
-      DEFAULT_LIBDIR
-        = substitute_prefix (DEFAULT_LIBDIR, vars["OCTAVE_PREFIX"],
-                             vars["OCTAVE_HOME"]);
-
-      DEFAULT_OCTLIBDIR
-        = substitute_prefix (DEFAULT_OCTLIBDIR, vars["OCTAVE_PREFIX"],
-                             vars["OCTAVE_HOME"]);
-    }
-
-  vars["OCTINCLUDEDIR"] = get_variable ("OCTINCLUDEDIR", DEFAULT_OCTINCLUDEDIR);
-  vars["INCLUDEDIR"] = get_variable ("INCLUDEDIR", DEFAULT_INCLUDEDIR);
-  vars["LIBDIR"] = get_variable ("LIBDIR", DEFAULT_LIBDIR);
-  vars["OCTLIBDIR"] = get_variable ("OCTLIBDIR", DEFAULT_OCTLIBDIR);
-
-#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
-  std::string DEFAULT_INCFLAGS
-    = "-I" + quote_path (vars["OCTINCLUDEDIR"] + "\\..")
-    + " -I" + quote_path (vars["OCTINCLUDEDIR"]);
-#else
-  std::string DEFAULT_INCFLAGS
-    = "-I" + quote_path (vars["OCTINCLUDEDIR"] + "/..")
-    + " -I" + quote_path (vars["OCTINCLUDEDIR"]);
-#endif
-  if (vars["INCLUDEDIR"] != "/usr/include")
-    DEFAULT_INCFLAGS += " -I" + quote_path (vars["INCLUDEDIR"]);
-
-  std::string DEFAULT_LFLAGS = "-L" + quote_path (vars["OCTLIBDIR"]);
-  if (vars["LIBDIR"] != "/usr/lib")
-    DEFAULT_LFLAGS += " -L" + quote_path (vars["LIBDIR"]);
-
-  vars["CPPFLAGS"] = get_variable ("CPPFLAGS", %OCTAVE_CONF_CPPFLAGS%);
-  vars["INCFLAGS"] = get_variable ("INCFLAGS", DEFAULT_INCFLAGS);
-  vars["F77"] = get_variable ("F77", %OCTAVE_CONF_F77%);
-  vars["FFLAGS"] = get_variable ("FFLAGS", %OCTAVE_CONF_FFLAGS%);
-  vars["FPICFLAG"] = get_variable ("FPICFLAG", %OCTAVE_CONF_FPICFLAG%);
-  vars["CC"] = get_variable ("CC", %OCTAVE_CONF_CC%);
-  vars["CFLAGS"] = get_variable ("CFLAGS", %OCTAVE_CONF_CFLAGS%);
-  vars["CPICFLAG"] = get_variable ("CPICFLAG", %OCTAVE_CONF_CPICFLAG%);
-  vars["CXX"] = get_variable ("CXX", %OCTAVE_CONF_CXX%);
-  vars["CXXFLAGS"] = get_variable ("CXXFLAGS", %OCTAVE_CONF_CXXFLAGS%);
-  vars["CXXPICFLAG"] = get_variable ("CXXPICFLAG", %OCTAVE_CONF_CXXPICFLAG%);
-  vars["XTRA_CFLAGS"] = get_variable ("XTRA_CFLAGS", %OCTAVE_CONF_XTRA_CFLAGS%);
-  vars["XTRA_CXXFLAGS"] = get_variable ("XTRA_CXXFLAGS", %OCTAVE_CONF_XTRA_CXXFLAGS%);
-
-  vars["DEPEND_FLAGS"] = get_variable ("DEPEND_FLAGS", %OCTAVE_CONF_DEPEND_FLAGS%);
-  vars["DEPEND_EXTRA_SED_PATTERN"] = get_variable ("DEPEND_EXTRA_SED_PATTERN", %OCTAVE_CONF_DEPEND_EXTRA_SED_PATTERN%);
-
-  vars["DL_LD"] = get_variable ("DL_LD", %OCTAVE_CONF_DL_LD%);
-  vars["DL_LDFLAGS"] = get_variable ("DL_LDFLAGS", %OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS%);
-
-  vars["RDYNAMIC_FLAG"] = get_variable ("RDYNAMIC_FLAG", %OCTAVE_CONF_RDYNAMIC_FLAG%);
-  vars["LIBOCTAVE"] = "-loctave";
-  vars["LIBOCTINTERP"] = "-loctinterp";
-  vars["READLINE_LIBS"] = "-lreadline";
-  vars["LIBCRUFT"] = "-lcruft";
-  vars["LAPACK_LIBS"] = get_variable ("LAPACK_LIBS", %OCTAVE_CONF_LAPACK_LIBS%);
-  vars["BLAS_LIBS"] = get_variable ("BLAS_LIBS", %OCTAVE_CONF_BLAS_LIBS%);
-  vars["FFTW3_LDFLAGS"] = get_variable ("FFTW3_LDFLAGS", %OCTAVE_CONF_FFTW3_LDFLAGS%);
-  vars["FFTW3_LIBS"] = get_variable ("FFTW3_LIBS", %OCTAVE_CONF_FFTW3_LIBS%);
-  vars["FFTW3F_LDFLAGS"] = get_variable ("FFTW3F_LDFLAGS", %OCTAVE_CONF_FFTW3F_LDFLAGS%);
-  vars["FFTW3F_LIBS"] = get_variable ("FFTW3F_LIBS", %OCTAVE_CONF_FFTW3F_LIBS%);
-  vars["LIBS"] = get_variable ("LIBS", %OCTAVE_CONF_LIBS%);
-  vars["FLIBS"] = get_variable ("FLIBS", %OCTAVE_CONF_FLIBS%);
-  vars["OCTAVE_LINK_DEPS"] = get_variable ("FLIBS", %OCTAVE_CONF_OCTAVE_LINK_DEPS%);
-  vars["OCT_LINK_DEPS"] = get_variable ("FLIBS", %OCTAVE_CONF_OCT_LINK_DEPS%);
-  vars["FLIBS"] = get_variable ("FLIBS", %OCTAVE_CONF_FLIBS%);
-
-  vars["LD_CXX"] = get_variable ("LD_CXX", %OCTAVE_CONF_LD_CXX%);
-  vars["LDFLAGS"] = get_variable ("LDFLAGS", %OCTAVE_CONF_LDFLAGS%);
-  vars["LD_STATIC_FLAG"] = get_variable ("LD_STATIC_FLAG", %OCTAVE_CONF_LD_STATIC_FLAG%);
-  vars["LFLAGS"] = get_variable ("LFLAGS", DEFAULT_LFLAGS);
-  vars["F77_INTEGER8_FLAG"] = get_variable ("F77_INTEGER8_FLAG", %OCTAVE_CONF_F77_INTEGER_8_FLAG%);
-
-  vars["ALL_FFLAGS"] = vars["FFLAGS"] + " " + vars["F77_INTEGER8_FLAG"];
-
-  vars["ALL_CFLAGS"] = vars["INCFLAGS"] + " " + vars["XTRA_CFLAGS"]
-    + " " + vars["CFLAGS"];
-
-  vars["ALL_CXXFLAGS"] = vars["INCFLAGS"] + " " + vars["XTRA_CXXFLAGS"]
-    + " " + vars["CXXFLAGS"];
-
-  vars["ALL_LDFLAGS"] = vars["LD_STATIC_FLAG"] + " " + vars["CPICFLAG"]
-    + " " + vars["LDFLAGS"];
-
-  vars["OCTAVE_LIBS"] = vars["LIBOCTINTERP"] + " " + vars["LIBOCTAVE"]
-    + " " + vars["SPECIAL_MATH_LIB"] + " " + vars["LIBCRUFT"];
-
-  vars["FFTW_LIBS"] = vars["FFTW3_LDFLAGS"] + " " + vars["FFTW3_LIBS"]
-    + " " + vars["FFTW3F_LDFLAGS"] + " " + vars["FFTW3F_LIBS"];
-}
-
-static string usage_msg = "usage: mkoctfile [options] file ...";
-static string version_msg = "mkoctfile, version " + OCTAVE_VERSION;
-static bool debug = false;
-static string help_msg =
-"\n"
-"Options:\n"
-"\n"
-"  -h, -?, --help          Print this message.\n"
-"\n"
-"  -IDIR                   Add -IDIR to compile commands.\n"
-"\n"
-"  -idirafter DIR          Add -idirafter DIR to compile commands.\n"
-"\n"
-"  -DDEF                   Add -DDEF to compile commands.\n"
-"\n"
-"  -lLIB                   Add library LIB to link command.\n"
-"\n"
-"  -LDIR                   Add -LDIR to link command.\n"
-"\n"
-"  -M, --depend            Generate dependency files (.d) for C and C++\n"
-"                          source files.\n"
-"\n"
-"  -RDIR                   Add -RDIR to link command.\n"
-"\n"
-"  -Wl,...                 Pass flags though the linker like -Wl,-rpath=...\n"
-"\n"
-"  -W...                   Pass flags though the compiler like -Wa,OPTION.\n"
-"\n"
-"  -c, --compile           Compile, but do not link.\n"
-"\n"
-"  -o FILE, --output FILE  Output file name.  Default extension is .oct\n"
-"                          (or .mex if --mex is specified) unless linking\n"
-"                          a stand-alone executable.\n"
-"\n"
-"  -g                      Enable debugging options for compilers.\n"
-"\n"
-"  -p VAR, --print VAR     Print configuration variable VAR.  Recognized\n"
-"                          variables are:\n"
-"\n"
-"                            ALL_CFLAGS                FLIBS\n"
-"                            ALL_CXXFLAGS              FPICFLAG\n"
-"                            ALL_FFLAGS                INCFLAGS\n"
-"                            ALL_LDFLAGS               LAPACK_LIBS\n"
-"                            BLAS_LIBS                 LDFLAGS\n"
-"                            CC                        LD_CXX\n"
-"                            CFLAGS                    LD_STATIC_FLAG\n"
-"                            CPICFLAG                  LFLAGS\n"
-"                            CPPFLAGS                  LIBCRUFT\n"
-"                            CXX                       LIBOCTAVE\n"
-"                            CXXFLAGS                  LIBOCTINTERP\n"
-"                            CXXPICFLAG                LIBS\n"
-"                            DEPEND_EXTRA_SED_PATTERN  OCTAVE_LIBS\n"
-"                            DEPEND_FLAGS              OCTAVE_LINK_DEPS\n"
-"                            DL_LD                     OCTAVE_LINK_OPTS\n"
-"                            DL_LDFLAGS                OCT_LINK_DEPS\n"
-"                            EXEEXT                    OCT_LINK_OPTS\n"
-"                            F77                       RDYNAMIC_FLAG\n"
-"                            F77_INTEGER_8_FLAG        READLINE_LIBS\n"
-"                            FFLAGS                    SED\n"
-"                            FFTW3_LDFLAGS             XTRA_CFLAGS\n"
-"                            FFTW3_LIBS                XTRA_CXXFLAGS\n"
-"                            FFTW3F_LDFLAGS\n"
-"                            FFTW3F_LIBS\n"
-"\n"
-"  --link-stand-alone      Link a stand-alone executable file.\n"
-"\n"
-"  --mex                   Assume we are creating a MEX file.  Set the\n"
-"                          default output extension to \".mex\".\n"
-"\n"
-"  -s, --strip             Strip output file.\n"
-"\n"
-"  -v, --verbose           Echo commands as they are executed.\n"
-"\n"
-"  FILE                    Compile or link FILE.  Recognized file types are:\n"
-"\n"
-"                            .c    C source\n"
-"                            .cc   C++ source\n"
-"                            .C    C++ source\n"
-"                            .cpp  C++ source\n"
-"                            .f    Fortran source (fixed form)\n"
-"                            .F    Fortran source (fixed form)\n"
-"                            .f90  Fortran source (free form)\n"
-"                            .F90  Fortran source (free form)\n"
-"                            .o    object file\n"
-"                            .a    library file\n"
-#ifdef _MSC_VER
-"                            .lib  library file\n"
-#endif
-"\n";
-
-static string
-basename (const string& s, bool strip_path = false)
-{
-  size_t pos = s.rfind ('.');
-  string retval;
-
-  if (pos == string::npos)
-    retval = s;
-  else
-    retval = s.substr (0, pos);
-  if (strip_path)
-    {
-      size_t p1 = retval.rfind ('/'), p2 = retval.rfind ('\\');
-      pos = (p1 != string::npos && p2 != string::npos
-             ? max (p1, p2) : (p2 != string::npos ? p2 : p1));
-      if (pos != string::npos)
-        retval = retval.substr (0, pos);
-    }
-  return retval;
-}
-
-inline bool
-starts_with (const string& s, const string& prefix)
-{
-  return (s.length () >= prefix.length () && s.find (prefix) == 0);
-}
-
-inline bool
-ends_with (const string& s, const string& suffix)
-{
-  return (s.length () >= suffix.length ()
-          && s.rfind (suffix) == s.length () - suffix.length ());
-}
-
-static int
-run_command (const string& cmd)
-{
-  if (debug)
-    cout << cmd << endl;
-  return system (cmd.c_str ());
-}
-
-int
-main (int argc, char **argv)
-{
-  initialize ();
-
-  string file, output_option;
-  list<string> cfiles, ccfiles, f77files;
-  int result = 0;
-
-  string objfiles = "";
-  string libfiles = "";
-  string octfile = "";
-  string outputfile = "";
-  string incflags = "";
-  string defs = "";
-  string ldflags = "";
-  string pass_on_options = "";
-  bool strip = false;
-  bool no_oct_file_strip_on_this_platform = %NO_OCT_FILE_STRIP%;
-  bool link = true;
-  bool link_stand_alone = false;
-  string output_ext = ".oct";
-  bool depend = false;
-  bool compile = true;
-
-  if (argc == 1)
-    {
-      cout << usage_msg << endl;
-      return 1;
-    }
-
-  if (argc == 2 && (!strcmp (argv[1], "-v")
-                    || !strcmp (argv[1], "-version")
-                    || !strcmp (argv[1], "--version")))
-    {
-      cout << version_msg << endl;
-      return 0;
-    }
-
-  for (int i = 1; i < argc; i++)
-    {
-      string arg = argv[i];
-      size_t len = arg.length ();
-
-      if (ends_with (arg, ".c"))
-        {
-          file = arg;
-          cfiles.push_back (file);
-        }
-      else if (ends_with (arg, ".cc") || ends_with (arg, ".C")
-               || ends_with (arg, ".cpp"))
-        {
-          file = arg;
-          ccfiles.push_back (file);
-        }
-      else if (ends_with (arg, ".f") || ends_with (arg, ".F")
-               || ends_with (arg, "f90") || ends_with (arg, ".F90"))
-        {
-          file = arg;
-          f77files.push_back (file);
-        }
-      else if (ends_with (arg, ".o") || ends_with (arg, ".obj"))
-        {
-          file = arg;
-          objfiles += (" " + quote_path (arg));
-        }
-      else if (ends_with (arg, ".lib") || ends_with (arg, ".a"))
-        {
-          file = arg;
-          libfiles += (" " + quote_path (arg));
-        }
-      else if (arg == "-d" || arg == "-debug" || arg == "--debug"
-               || arg == "-v" || arg == "-verbose" ||  arg == "--verbose")
-        {
-          debug = true;
-          if (vars["CC"] == "cc-msvc")
-            vars["CC"] += " -d";
-          if (vars["CXX"] == "cc-msvc")
-            vars["CXX"] += " -d";
-          if (vars["DL_LD"] == "cc-msvc")
-            vars["DL_LD"] += " -d";
-        }
-      else if (arg == "-h" || arg == "-?" || arg == "-help" || arg == "--help")
-        {
-          cout << usage_msg << endl;
-          cout << help_msg << endl;
-          return 0;
-        }
-      else if (starts_with (arg, "-I"))
-        {
-          incflags += (" " + quote_path (arg));
-        }
-      else if (arg == "-idirafter")
-        {
-          if (i < argc-1)
-            {
-              arg = argv[++i];
-              incflags += (" -idirafter " + arg);
-            }
-          else
-            cerr << "mkoctfile: include directory name missing" << endl;
-        }
-      else if (starts_with (arg, "-D"))
-        {
-          defs += (" " + arg);
-        }
-      else if (starts_with (arg, "-Wl,") || starts_with (arg, "-l")
-               || starts_with (arg, "-L") || starts_with (arg, "-R"))
-        {
-          ldflags += (" " + arg);
-        }
-      else if (arg == "-M" || arg == "-depend" || arg == "--depend")
-        {
-          depend = true;
-          compile = false;
-        }
-      else if (arg == "-o" || arg == "-output" || arg == "--output")
-        {
-          if (i < argc-1)
-            {
-              arg = argv[++i];
-              outputfile = arg;
-            }
-          else
-            cerr << "mkoctfile: output file name missing" << endl;
-        }
-      else if (arg == "-p" || arg == "-print" || arg == "--print")
-        {
-          if (i < argc-1)
-            {
-              arg = argv[++i];
-              cout << vars[arg] << endl;
-              return 0;
-            }
-          else
-            cerr << "mkoctfile: --print requires argument" << endl;
-        }
-      else if (arg == "-s" || arg == "-strip" || arg == "--strip")
-        {
-          if (no_oct_file_strip_on_this_platform)
-            cerr << "mkoctfile: stripping disabled on this platform" << endl;
-          else
-            strip = true;
-        }
-      else if (arg == "-c" || arg == "-compile" || arg == "--compile")
-        {
-          link = false;
-        }
-      else if (arg == "-g")
-        {
-          vars["ALL_CFLAGS"] += " -g";
-          vars["ALL_CXXFLAGS"] += " -g";
-          vars["ALL_FFLAGS"] += " -g";
-        }
-      else if (arg == "-link-stand-alone" || arg == "--link-stand-alone")
-        {
-          link_stand_alone = true;
-        }
-      else if (arg == "-mex" || arg == "--mex")
-        {
-          incflags += " -I.";
-#ifdef _MSC_VER
-          ldflags += " -Wl,-export:mexFunction";
-#endif
-          output_ext = ".mex";
-        }
-      else if (starts_with (arg, "-W"))
-        {
-          pass_on_options += (" " + arg);
-        }
-      else
-        {
-          cerr << "mkoctfile: unrecognized argument " << arg;
-          return 1;
-        }
-
-      if (!file.empty () && octfile.empty ())
-        octfile = file;
-    }
-
-  if (link_stand_alone)
-    {
-      if (!outputfile.empty ())
-        output_option = "-o " + outputfile;
-    }
-  else
-    {
-      if (!outputfile.empty ())
-        {
-          octfile = outputfile;
-          size_t len = octfile.length ();
-          size_t len_ext = output_ext.length ();
-          if (octfile.substr (len-len_ext) != output_ext)
-            octfile += output_ext;
-        }
-      else
-        octfile = basename (octfile, true) + output_ext;
-    }
-
-  list<string>::const_iterator it;
-
-  if (depend)
-    {
-      for (it = cfiles.begin (); it != cfiles.end (); ++it)
-        {
-          string f = *it, dfile = basename (f, true) + ".d", line;
-
-          unlink (dfile.c_str ());
-          string cmd = vars["CC"] + " " + vars["DEPEND_FLAGS"] + " "
-            + vars["CPPFLAGS"] + " " + vars["ALL_CFLAGS"] + " "
-            + incflags  + " " + defs + " " + quote_path (f);
-
-          FILE *fd = popen (cmd.c_str (), "r");
-          ofstream fo (dfile.c_str ());
-          int pos;
-          while (!feof (fd))
-            {
-              line = get_line (fd);
-              if ((pos = line.rfind (".o:")) != string::npos)
-                {
-                  int spos = line.rfind ('/', pos);
-                  string ofile = (spos == string::npos ? line.substr (0, pos+2) : line.substr (spos+1, pos-spos+1));
-                  fo << "pic/" << ofile << " " << ofile << " " << dfile << line.substr (pos) << endl;
-                }
-              else
-                fo << line << endl;
-            }
-          pclose (fd);
-          fo.close ();
-        }
-
-      for (it = ccfiles.begin (); it != ccfiles.end (); ++it)
-        {
-          string f = *it, dfile = basename (f, true) + ".d", line;
-
-          unlink (dfile.c_str ());
-          string cmd = vars["CC"] + " " + vars["DEPEND_FLAGS"] + " "
-            + vars["CPPFLAGS"] + " " + vars["ALL_CXXFLAGS"] + " "
-            + incflags  + " " + defs + " " + quote_path (f);
-
-          FILE *fd = popen (cmd.c_str (), "r");
-          ofstream fo (dfile.c_str ());
-          int pos;
-          while (!feof (fd))
-            {
-              line = get_line (fd);
-              if ((pos = line.rfind (".o:")) != string::npos)
-                {
-                  int spos = line.rfind ('/', pos);
-                  string ofile = (spos == string::npos ? line.substr (0, pos+2) : line.substr (spos+1, pos-spos+1));
-                  fo << "pic/" << ofile << " " << ofile << " " << dfile << line.substr (pos+2) << endl;
-                }
-              else
-                fo << line << endl;
-            }
-          pclose (fd);
-          fo.close ();
-        }
-
-      return 0;
-    }
-
-  for (it = f77files.begin (); it != f77files.end (); ++it)
-    {
-      string f = *it, b = basename (f, true);
-      if (!vars["F77"].empty ())
-        {
-          string o;
-          if (!outputfile.empty ())
-            {
-              if (link)
-                o = b + ".o";
-              else
-                o = outputfile;
-            }
-          else
-            o = b + ".o";
-          objfiles += (" " + o);
-          string cmd = vars["F77"] + " -c " + vars["FPICFLAG"] + " "
-            + vars["ALL_FFLAGS"] + " " + incflags + " " + defs + " "
-            + pass_on_options + " " + f + " -o " + o;
-          result = run_command (cmd);
-        }
-      else
-        {
-          cerr << "mkoctfile: no way to compile Fortran file " << f << endl;
-          return 1;
-        }
-    }
-
-  for (it = cfiles.begin (); it != cfiles.end (); ++it)
-    {
-      string f = *it;
-      if (!vars["CC"].empty ())
-        {
-          string b = basename (f, true), o;
-          if (!outputfile.empty ())
-            {
-              if (link)
-                o = b + ".o";
-              else
-                o = outputfile;
-            }
-          else
-            o = b + ".o";
-          objfiles += (" " + o);
-          string cmd = vars["CC"] + " -c " + vars["CPPFLAGS"] + " "
-            + vars["CPICFLAG"] + " " + vars["ALL_CFLAGS"] + " "
-            + pass_on_options + " " + incflags + " " + defs + " "
-            + quote_path (f) + " -o " + quote_path (o);
-          result = run_command (cmd);
-        }
-      else
-        {
-          cerr << "mkoctfile: no way to compile C file " << f << endl;
-          return 1;
-        }
-    }
-
-  for (it = ccfiles.begin (); it != ccfiles.end (); ++it)
-    {
-      string f = *it;
-      if (!vars["CXX"].empty ())
-        {
-          string b = basename (f, true), o;
-          if (!outputfile.empty ())
-            {
-              if (link)
-                o = b + ".o";
-              else
-                o = outputfile;
-            }
-          else
-            o = b + ".o";
-          objfiles += (" " + o);
-          string cmd = vars["CXX"] + " -c " + vars["CPPFLAGS"] + " "
-            + vars["CXXPICFLAG"] + " " + vars["ALL_CXXFLAGS"] + " "
-            + pass_on_options + " " + incflags + " " + defs + " "
-            + quote_path (f) + " -o " + quote_path (o);
-          result = run_command (cmd);
-        }
-      else
-        {
-          cerr << "mkoctfile: no way to compile C++ file " << f << endl;
-          return 1;
-        }
-    }
-
-  if (link && !objfiles.empty ())
-    {
-      if (link_stand_alone)
-        {
-          if (!vars["LD_CXX"].empty ())
-            {
-              string cmd = vars["LD_CXX"] + " " + vars["CPPFLAGS"] + " "
-                + vars["ALL_CXXFLAGS"] + " " + vars["RDYNAMIC_FLAG"]
-                + " " + vars["ALL_LDFLAGS"] + " " +  pass_on_options
-                + " " + output_option + " " + objfiles + " " + libfiles
-                + " " + ldflags + " " + vars["LFLAGS"]
-                + " -loctinterp -loctave -lcruft "
-                + " " + vars["OCT_LINK_OPTS"]
-                + " " + vars["OCTAVE_LINK_DEPS"];
-              result = run_command (cmd);
-            }
-          else
-            {
-              cerr << "mkoctfile: no way to link stand-alone executable file"
-                   << endl;
-              return 1;
-            }
-        }
-      else
-        {
-          string cmd = vars["DL_LD"] + " " + vars["DL_LDFLAGS"] + " "
-            + pass_on_options + " -o " + octfile + " " + objfiles + " "
-            + libfiles + " " + ldflags + " " + vars["LFLAGS"]
-            + " -loctinterp -loctave -lcruft "
-            + vars["OCT_LINK_OPTS"] + " " + vars["OCT_LINK_DEPS"];
-          result = run_command (cmd);
-        }
-
-      if (strip)
-        {
-          string cmd = "strip " + octfile;
-          result = run_command (cmd);
-        }
-    }
-
-  return result;
-}
--- a/src/mkoctfile.in	Mon May 07 00:53:54 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,558 +0,0 @@
-#! /bin/sh
-##
-## mkoctfile -- create a .oct file suitable for dynamic linking by
-## Octave.
-##
-## Copyright (C) 1996-2012 John W. Eaton
-##
-## This file is part of Octave.
-##
-## Octave is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by the
-## Free Software Foundation; either version 3 of the License, or (at
-## your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but WITHOUT
-## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-## for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-
-# Exit immediately on any error.
-
-set -e
-
-: ${SED=%OCTAVE_CONF_SED%}
-
-OCTAVE_VERSION=%OCTAVE_CONF_VERSION%
-OCTAVE_PREFIX=%OCTAVE_CONF_PREFIX%
-
-DEFAULT_BINDIR=%OCTAVE_BINDIR%
-DEFAULT_INCLUDEDIR=%OCTAVE_CONF_INCLUDEDIR%
-DEFAULT_LIBDIR=%OCTAVE_CONF_LIBDIR%
-DEFAULT_OCTINCLUDEDIR=%OCTAVE_CONF_OCTINCLUDEDIR%
-DEFAULT_OCTLIBDIR=%OCTAVE_CONF_OCTLIBDIR%
-
-if [ -n "$OCTAVE_HOME" ]; then
-  DEFAULT_BINDIR="`echo $DEFAULT_BINDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`"
-  DEFAULT_INCLUDEDIR="`echo $DEFAULT_INCLUDEDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`"
-  DEFAULT_LIBDIR="`echo $DEFAULT_LIBDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`"
-  DEFAULT_OCTINCLUDEDIR="`echo $DEFAULT_OCTINCLUDEDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`"
-  DEFAULT_OCTLIBDIR="`echo $DEFAULT_OCTLIBDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`"
-fi
-
-: ${BINDIR=$DEFAULT_BINDIR}
-: ${INCLUDEDIR=$DEFAULT_INCLUDEDIR}
-: ${LIBDIR=$DEFAULT_LIBDIR}
-: ${OCTINCLUDEDIR=$DEFAULT_OCTINCLUDEDIR}
-: ${OCTLIBDIR=$DEFAULT_OCTLIBDIR}
-
-DEFAULT_INCFLAGS="-I$OCTINCLUDEDIR/.. -I$OCTINCLUDEDIR"
-if [ "$INCLUDEDIR" != /usr/include ]; then
-  DEFAULT_INCFLAGS="$DEFAULT_INCFLAGS -I$INCLUDEDIR"
-fi
-
-DEFAULT_LFLAGS="-L$OCTLIBDIR"
-if [ "$LIBDIR" != /usr/lib ]; then
-  DEFAULT_LFLAGS="$DEFAULT_LFLAGS -L$LIBDIR"
-fi
-
-# Default values for these variables are filled in when Octave is
-# compiled.
-
-: ${EXEEXT=%OCTAVE_CONF_EXEEXT%}
-
-: ${CPPFLAGS=%OCTAVE_CONF_CPPFLAGS%}
-: ${INCFLAGS=$DEFAULT_INCFLAGS}
-: ${F77=%OCTAVE_CONF_F77%}
-: ${FFLAGS=%OCTAVE_CONF_FFLAGS%}
-: ${FPICFLAG=%OCTAVE_CONF_FPICFLAG%}
-: ${CC=%OCTAVE_CONF_CC%}
-: ${CFLAGS=%OCTAVE_CONF_CFLAGS%}
-: ${CPICFLAG=%OCTAVE_CONF_CPICFLAG%}
-: ${CXX=%OCTAVE_CONF_CXX%}
-: ${CXXFLAGS=%OCTAVE_CONF_CXXFLAGS%}
-: ${CXXPICFLAG=%OCTAVE_CONF_CXXPICFLAG%}
-: ${XTRA_CFLAGS=%OCTAVE_CONF_XTRA_CFLAGS%}
-: ${XTRA_CXXFLAGS=%OCTAVE_CONF_XTRA_CXXFLAGS%}
-
-: ${DEPEND_FLAGS=%OCTAVE_CONF_DEPEND_FLAGS%}
-: ${DEPEND_EXTRA_SED_PATTERN=%OCTAVE_CONF_DEPEND_EXTRA_SED_PATTERN%}
-
-: ${DL_LD=%OCTAVE_CONF_DL_LD%}
-: ${DL_LDFLAGS=%OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS%}
-
-: ${RDYNAMIC_FLAG=%OCTAVE_CONF_RDYNAMIC_FLAG%}
-: ${LIBOCTAVE=-loctave}
-: ${LIBOCTINTERP=-loctinterp}
-: ${READLINE_LIBS=-lreadline}
-: ${LIBCRUFT=-lcruft}
-: ${LAPACK_LIBS=%OCTAVE_CONF_LAPACK_LIBS%}
-: ${BLAS_LIBS=%OCTAVE_CONF_BLAS_LIBS%}
-: ${FFTW3_LDFLAGS=%OCTAVE_CONF_FFTW3_LDFLAGS%}
-: ${FFTW3_LIBS=%OCTAVE_CONF_FFTW3_LIBS%}
-: ${FFTW3F_LDFLAGS=%OCTAVE_CONF_FFTW3F_LDFLAGS%}
-: ${FFTW3F_LIBS=%OCTAVE_CONF_FFTW3F_LIBS%}
-: ${LIBS=%OCTAVE_CONF_LIBS%}
-: ${FLIBS=%OCTAVE_CONF_FLIBS%}
-: ${OCTAVE_LINK_DEPS=%OCTAVE_CONF_OCTAVE_LINK_DEPS%}
-: ${OCTAVE_LINK_OPTS=%OCTAVE_CONF_OCTAVE_LINK_OPTS%}
-: ${OCT_LINK_DEPS=%OCTAVE_CONF_OCT_LINK_DEPS%}
-: ${OCT_LINK_OPTS=%OCTAVE_CONF_OCT_LINK_OPTS%}
-: ${LD_CXX=%OCTAVE_CONF_LD_CXX%}
-: ${LDFLAGS=%OCTAVE_CONF_LDFLAGS%}
-: ${LD_STATIC_FLAG=%OCTAVE_CONF_LD_STATIC_FLAG%}
-: ${LFLAGS=$DEFAULT_LFLAGS}
-: ${F77_INTEGER_8_FLAG=%OCTAVE_CONF_F77_INTEGER_8_FLAG%}
-
-: ${ALL_FFLAGS="$FFLAGS $F77_INTEGER_8_FLAG"}
-
-: ${ALL_CFLAGS="$INCFLAGS $XTRA_CFLAGS $CFLAGS"}
-
-: ${ALL_CXXFLAGS="$INCFLAGS $XTRA_CXXFLAGS $CXXFLAGS"}
-
-: ${ALL_LDFLAGS="$LD_STATIC_FLAG $CPICFLAG $LDFLAGS"}
-
-: ${OCTAVE_LIBS="$LIBOCTINTERP $LIBOCTAVE $SPECIAL_MATH_LIB $LIBCRUFT"}
-
-# Local variables.
-
-FFTW_LIBS="$FFTW3_LDFLAGS $FFTW3_LIBS $FFTW3F_LDFLAGS $FFTW3F_LIBS"
-
-usage_msg="usage: mkoctfile [options] file ..."
-
-version_msg="mkoctfile, version $OCTAVE_VERSION"
-
-cfiles=
-ccfiles=
-f77files=
-objfiles=
-libfiles=
-octfiles=
-octfile=
-outputfile=
-incflags=
-defs=
-ldflags=
-dbg=:
-pass_on_options=
-strip=false
-no_oct_file_strip_on_this_platform=%NO_OCT_FILE_STRIP%
-link=true
-link_stand_alone=false
-output_ext=".oct"
-depend=false
-compile=true
-
-if [ $# -eq 0 ]; then
-  echo $usage_msg 1>&2
-  exit 1
-fi
-
-if [ $# -eq 1 ]; then
-  case "$1" in
-    -v | -version | --version)
-      echo $version_msg 1>&2
-      exit 0
-    ;;
-  esac
-fi
-
-while [ $# -gt 0 ]; do
-  file=
-  case "$1" in
-    *.c)
-      file=$1
-      cfiles="$cfiles $file"
-    ;;
-    *.cc | *.C | *.cpp)
-      file=$1
-      ccfiles="$ccfiles $file"
-    ;;
-    *.f | *.F | *.f90 | *.F90)
-      file=$1
-      f77files="$f77files $file"
-    ;;
-    *.o)
-      file=$1
-      objfiles="$objfiles $file"
-    ;;
-    *.a)
-      file=$1
-      libfiles="$libfiles $file"
-    ;;
-    -d | -debug | --debug | -v | -verbose | --verbose)
-      dbg=echo
-    ;;
-    -h | -\? | -help | --help)
-      echo $usage_msg 1>&2
-      cat << EOF
-
-Options:
-
-  -h, -?, --help          Print this message.
-
-  -IDIR                   Add -IDIR to compile commands.
-
-  -idirafter DIR          Add -idirafter DIR to compile commands.
-
-  -DDEF                   Add -DDEF to compile commands.
-
-  -lLIB                   Add -lLIB to link command.
-
-  -LDIR                   Add -LDIR to link command.
-
-  -RDIR                   Add -RDIR to link command.
-
-  -g                      Enable debugging option for all compilers.
-
-  -pthread                Add -pthread to link command.
-
-  -W...                   Pass flags to the compiler such as -Wa,OPTION.
-
-  -Wl,...                 Pass flags to the linker such as -Wl,-rpath=...
-
-  -M, --depend            Generate dependency files (.d) for C and C++
-                          source files.
-
-  -c, --compile           Compile, but do not link.
-
-  --link-stand-alone      Link a stand-alone executable file.
-
-  -s, --strip             Strip output file.
-
-  --mex                   Create a MEX file.
-                          Set the default output extension to ".mex".
-
-  -o FILE, --output FILE  Output file name.  Default extension is .oct
-                          (or .mex if --mex is specified) unless linking
-                          a stand-alone executable.
-
-  -p VAR, --print VAR     Print configuration variable VAR.  Recognized
-                          variables are:
-
-                            ALL_CFLAGS                FFTW3F_LIBS
-                            ALL_CXXFLAGS              FLIBS
-                            ALL_FFLAGS                FPICFLAG
-                            ALL_LDFLAGS               INCFLAGS
-                            BLAS_LIBS                 LAPACK_LIBS
-                            CC                        LDFLAGS
-                            CFLAGS                    LD_CXX
-                            CPICFLAG                  LD_STATIC_FLAG
-                            CPPFLAGS                  LFLAGS
-                            CXX                       LIBCRUFT
-                            CXXFLAGS                  LIBOCTAVE
-                            CXXPICFLAG                LIBOCTINTERP
-                            DEPEND_EXTRA_SED_PATTERN  LIBS
-                            DEPEND_FLAGS              OCTAVE_LIBS
-                            DL_LD                     OCTAVE_LINK_DEPS
-                            DL_LDFLAGS                OCT_LINK_DEPS
-                            EXEEXT                    RDYNAMIC_FLAG
-                            F77                       READLINE_LIBS
-                            F77_INTEGER_8_FLAG        SED
-                            FFLAGS                    XTRA_CFLAGS
-                            FFTW3_LDFLAGS             XTRA_CXXFLAGS
-                            FFTW3_LIBS
-                            FFTW3F_LDFLAGS
-
-  -v, --verbose           Echo commands as they are executed.
-
-  FILE                    Compile or link FILE.  Recognized file types are:
-
-                            .c    C source
-                            .cc   C++ source
-                            .C    C++ source
-                            .cpp  C++ source
-                            .f    Fortran source (fixed form)
-                            .F    Fortran source (fixed form)
-                            .f90  Fortran source (free form)
-                            .F90  Fortran source (free form)
-                            .o    object file
-                            .a    library file
-
-EOF
-      exit 0
-    ;;
-    -I*)
-      incflags="$incflags $1"
-    ;;
-    -idirafter)
-      shift
-      if [ $# -gt 0 ]; then
-        incflags="$incflags -idirafter $1"
-      else
-        echo "mkoctfile: include directory name missing" 1>&2
-      fi
-    ;;
-    -D*)
-      defs="$defs $1"
-    ;;
-    -[lLR]* | -Wl,*)
-      ldflags="$ldflags $1"
-    ;;
-    -pthread)
-      ldflags="$ldflags $1"
-    ;;
-    -M | -depend | --depend)
-      depend=true
-      compile=false
-    ;;
-    -o | -ouput | --output)
-      shift
-      if [ $# -gt 0 ]; then
-        outputfile="$1"
-      else
-        echo "mkoctfile: output file name missing" 1>&2
-      fi
-    ;;
-    -p | -print | --print)
-      shift
-      if [ $# -gt 0 ]; then
-        eval echo \${$1}
-        exit 0
-      else
-        echo "mkoctfile: --print requires argument" 1>&2
-        exit 1
-      fi
-    ;;
-    -s | -strip | --strip)
-      if $no_oct_file_strip_on_this_platform; then
-        echo "mkoctfile: stripping disabled on this platform" 1>&2
-      else
-        strip=true
-      fi
-    ;;
-    -c | -compile | --compile)
-      link=false
-    ;;
-    -g)
-      ALL_CFLAGS="$ALL_CFLAGS -g"
-      ALL_CXXFLAGS="$ALL_CXXFLAGS -g"
-      ALL_FFLAGS="$ALL_FFLAGS -g"
-    ;;
-    -link-stand-alone | --link-stand-alone)
-      link_stand_alone=true
-    ;;
-    -mex | --mex)
-      incflags="$incflags -I."
-      output_ext=".mex"
-    ;;
-    -W*)
-      pass_on_options="$pass_on_options $1"
-    ;;
-    *)
-      echo "mkoctfile: unrecognized argument $1" 1>&2
-      exit 1
-    ;;
-  esac
-  if [ -n "$file" ]; then
-    if [ -z "$octfile" ]; then
-      octfile="$file"
-    fi
-  fi
-  shift
-done
-
-if $link_stand_alone; then
-  if [ -n "$outputfile" ]; then
-    output_option="-o $outputfile"
-  fi
-else
-  if [ -n "$outputfile" ]; then
-    octfile="$outputfile"
-    case "$octfile" in
-      *$output_ext)
-      ;;
-      *)
-        octfile="$octfile$output_ext"
-      ;;
-    esac
-  else
-    octfile=`basename $octfile`
-    octfile=`echo $octfile | $SED 's,\.[^.]*$,,'`$output_ext
-  fi
-fi
-
-# Generate dependency files for C and C++ files.
-
-if $depend; then
-  if [ -n "$cfiles" ]; then
-    for f in $cfiles; do
-      b=`echo $f | $SED 's,\.c$,,'`
-      d=$b.d
-      cmd="rm -f $d"
-      $dbg $cmd
-      eval $cmd
-      cmd="$CC $DEPEND_FLAGS $CPPFLAGS $ALL_CFLAGS $incflags $def $f | $SED $DEPEND_EXTRA_SED_PATTERN -e 's,^[^:]*/\(.*\.o\):,\1:,' -e 's,$b\.o,pic/& & $d,g' > $d-t && mv $d-t $d"
-      $dbg $cmd
-      eval $cmd
-    done
-  fi
-
-  if [ -n "$ccfiles" ]; then
-    for f in $ccfiles; do
-      case $f in
-        *.cc)
-          b=`echo $f | $SED 's,\.cc$,,'`
-        ;;
-        *.C)
-          b=`echo $f | $SED 's,\.C$,,'`
-        ;;
-        *.cpp)
-          b=`echo $f | $SED 's,\.cpp$,,'`
-        ;;
-      esac
-      d=$b.d
-      cmd="rm -f $d"
-      $dbg $cmd
-      eval $cmd
-      cmd="$CXX $DEPEND_FLAGS $CPPFLAGS $ALL_CXXFLAGS $incflags $defs $f | $SED $DEPEND_EXTRA_SED_PATTERN -e 's,^[^:]*/\(.*\.o\):,\1:,' -e 's,$b\.o,pic/& & $d,g' > $d-t && mv $d-t $d"
-      $dbg $cmd
-      eval $cmd
-    done
-  fi
-  # If generating dependencies, that's all we do.
-  exit 0
-fi
-
-# Compile Fortran, C, and C++ files.  Add the name of each object file
-# that is produced to the overall list of object files.
-
-if [ -n "$f77files" ]; then
-  for f in $f77files; do
-    case $f in
-      *.f)
-        b=`echo $f | $SED 's,.*/,,; s,\.f$,,'`
-      ;;
-      *.F)
-        b=`echo $f | $SED 's,.*/,,; s,\.F$,,'`
-      ;;
-      *.f90)
-        b=`echo $f | $SED 's,.*/,,; s,\.f90$,,'`
-      ;;
-      *.F90)
-        b=`echo $f | $SED 's,.*/,,; s,\.F90$,,'`
-      ;;
-    esac
-    if [ -n "$F77" ]; then
-      if [ -n "$outputfile" ]; then
-        if $link; then
-          o=$b.o
-        else
-          o=$outputfile
-        fi
-      else
-        o=$b.o
-      fi
-      objfiles="$objfiles $o"
-      cmd="$F77 -c $FPICFLAG $ALL_FFLAGS $incflags $defs $pass_on_options $f -o $o"
-      $dbg $cmd
-      eval $cmd
-    else
-      echo "mkoctfile: no way to compile Fortran file $f" 1>&2
-    fi
-  done
-fi
-
-if [ -n "$cfiles" ]; then
-  for f in $cfiles; do
-    if [ -n  "$CC" ]; then
-      b=`echo $f | $SED 's,.*/,,; s,\.c$,,'`
-      if [ -n "$outputfile" ]; then
-        if $link; then
-          o=$b.o
-        else
-          o=$outputfile
-        fi
-      else
-        o=$b.o
-      fi
-      objfiles="$objfiles $o"
-      cmd="$CC -c $CPPFLAGS $CPICFLAG $ALL_CFLAGS $pass_on_options $incflags $defs $f -o $o"
-      $dbg $cmd
-      eval $cmd
-    else
-      echo "mkoctfile: no way to compile C++ file $f" 1>&2
-    fi
-  done
-fi
-
-if [ -n "$ccfiles" ]; then
-  for f in $ccfiles; do
-    if [ -n "$CXX" ]; then
-      case $f in
-        *.cc)
-          b=`echo $f | $SED 's,.*/,,; s,\.cc$,,'`
-        ;;
-        *.C)
-          b=`echo $f | $SED 's,.*/,,; s,\.C$,,'`
-        ;;
-        *.cpp)
-          b=`echo $f | $SED 's,.*/,,; s,\.cpp$,,'`
-        ;;
-      esac
-      if [ -n "$outputfile" ]; then
-        if $link; then
-          o=$b.o
-        else
-          o=$outputfile
-        fi
-      else
-        o=$b.o
-      fi
-      objfiles="$objfiles $o"
-      cmd="$CXX -c $CPPFLAGS $CXXPICFLAG $ALL_CXXFLAGS $pass_on_options $incflags $defs $f -o $o"
-      $dbg $cmd
-      eval $cmd
-    else
-      echo "mkoctfile: no way to compile C++ file $f" 1>&2
-    fi
-  done
-fi
-
-## Uncomment the following group of lines if you get `Text file busy'
-## errors from ld.  This may happen if the .oct file is currently
-## running while you are trying to recompile it.  We try moving first,
-## since on some systems (HP-UX, maybe others) it is possible to
-## rename running programs but not remove them.
-
-## if [ -f "$octfile" ]; then
-##   cmd="mv $octfile $octfile.bak"
-##   $dbg $cmd
-##   eval $cmd
-##   cmd="rm -f $octfile.bak"
-##   $dbg $cmd
-##   eval $cmd
-## fi
-
-# Link all the object files.
-
-if $link && [ -n "$objfiles" ]; then
-  if $link_stand_alone; then
-    if [ -n "$LD_CXX" ]; then
-      cmd="$LD_CXX $CPPFLAGS $ALL_CXXFLAGS $RDYNAMIC_FLAG $ALL_LDFLAGS $pass_on_options $output_option $objfiles $libfiles $ldflags $LFLAGS -loctinterp -loctave -lcruft $OCTAVE_LINK_OPTS $OCTAVE_LINK_DEPS"
-      $dbg $cmd
-      eval $cmd
-    else
-      echo "mkoctfile: no way to link stand-alone executable file" 1>&2
-      exit 1
-    fi
-  else
-    cmd="$DL_LD $DL_LDFLAGS $pass_on_options -o $octfile $objfiles $libfiles $ldflags $LFLAGS -loctinterp -loctave -lcruft $OCT_LINK_OPTS $OCT_LINK_DEPS"
-    $dbg $cmd
-    eval $cmd
-  fi
-
-# Maybe strip it.
-
-  if $strip; then
-    cmd="strip $octfile"
-    $dbg $cmd
-    eval $cmd
-  fi
-fi
-
-exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mkoctfile.in.cc	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,784 @@
+/*
+
+Copyright (C) 2008-2012 Michael Goffioul
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+#if defined (HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#include <string>
+#include <map>
+#include <list>
+#include <algorithm>
+#include <iostream>
+#include <fstream>
+#include <vector>
+#include <cstdlib>
+
+#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
+#include <windows.h>
+#ifdef _MSC_VER
+#define popen _popen
+#define pclose _pclose
+#endif
+#endif
+
+using namespace std;
+
+static bool initialized = false;
+static map<string,string> vars;
+
+static string OCTAVE_VERSION = %OCTAVE_CONF_VERSION%;
+
+static std::string
+substitute_prefix (const std::string& s, const std::string& prefix,
+                   const std::string& new_prefix)
+{
+  std::string retval = s;
+
+  if (!prefix.empty () && new_prefix != prefix)
+    {
+      int len = prefix.length ();
+      if (retval.find (prefix) == 0)
+        retval.replace (0, len, new_prefix);
+    }
+
+#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
+  std::replace (retval.begin (), retval.end (), '/', '\\');
+#endif
+
+  return retval;
+}
+
+static string
+get_line (FILE *fp)
+{
+  static vector<char> buf (100);
+  int idx = 0;
+  char c;
+
+  while (true)
+    {
+      c = static_cast<char> (fgetc (fp));
+      if (c == '\n' || c == EOF)
+        break;
+      if (buf.size () <= idx)
+        buf.resize (buf.size () + 100);
+      buf[idx++] = c;
+    }
+  if (idx == 0)
+    return string ("");
+  else
+    return string (&buf[0], idx);
+}
+
+
+static string
+get_variable (const char *name, const string& defval)
+{
+  const char *val = getenv (name);
+  if (val == NULL || val[0] == '\0')
+    return defval;
+  else
+    return string (val);
+}
+
+static string
+quote_path (const string& s)
+{
+  if (s.find (' ') != string::npos && s[0] != '"')
+    return "\"" + s + "\"";
+  else
+    return s;
+}
+
+static void
+initialize (void)
+{
+  if (initialized)
+    return;
+
+  initialized = true;
+
+  vars["OCTAVE_HOME"] = get_variable ("OCTAVE_HOME", "");
+
+#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
+  int n = 1024;
+
+  std::string bin_dir (n, '\0');
+
+  while (true)
+    {
+      int status = GetModuleFileName (0, &bin_dir[0], n);
+
+      if (status < n)
+        {
+          bin_dir.resize (status);
+          break;
+        }
+      else
+        {
+          n *= 2;
+          bin_dir.resize (n);
+        }
+    }
+
+  if (! bin_dir.empty ())
+    {
+      size_t pos = bin_dir.rfind ("\\bin\\");
+
+      if (pos != string::npos)
+        vars["OCTAVE_HOME"] = bin_dir.substr (0, pos);
+    }
+#endif
+
+  vars["SED"] = get_variable ("SED", %OCTAVE_CONF_SED%);
+
+  vars["OCTAVE_PREFIX"] = %OCTAVE_CONF_PREFIX%;
+
+  std::string DEFAULT_OCTINCLUDEDIR = %OCTAVE_CONF_OCTINCLUDEDIR%;
+  std::string DEFAULT_INCLUDEDIR = %OCTAVE_CONF_INCLUDEDIR%;
+  std::string DEFAULT_LIBDIR = %OCTAVE_CONF_LIBDIR%;
+  std::string DEFAULT_OCTLIBDIR = %OCTAVE_CONF_OCTLIBDIR%;
+
+  if (! vars["OCTAVE_HOME"].empty ())
+    {
+      DEFAULT_OCTINCLUDEDIR
+        = substitute_prefix (DEFAULT_OCTINCLUDEDIR, vars["OCTAVE_PREFIX"],
+                             vars["OCTAVE_HOME"]);
+
+      DEFAULT_INCLUDEDIR
+        = substitute_prefix (DEFAULT_INCLUDEDIR, vars["OCTAVE_PREFIX"],
+                             vars["OCTAVE_HOME"]);
+
+      DEFAULT_LIBDIR
+        = substitute_prefix (DEFAULT_LIBDIR, vars["OCTAVE_PREFIX"],
+                             vars["OCTAVE_HOME"]);
+
+      DEFAULT_OCTLIBDIR
+        = substitute_prefix (DEFAULT_OCTLIBDIR, vars["OCTAVE_PREFIX"],
+                             vars["OCTAVE_HOME"]);
+    }
+
+  vars["OCTINCLUDEDIR"] = get_variable ("OCTINCLUDEDIR", DEFAULT_OCTINCLUDEDIR);
+  vars["INCLUDEDIR"] = get_variable ("INCLUDEDIR", DEFAULT_INCLUDEDIR);
+  vars["LIBDIR"] = get_variable ("LIBDIR", DEFAULT_LIBDIR);
+  vars["OCTLIBDIR"] = get_variable ("OCTLIBDIR", DEFAULT_OCTLIBDIR);
+
+#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
+  std::string DEFAULT_INCFLAGS
+    = "-I" + quote_path (vars["OCTINCLUDEDIR"] + "\\..")
+    + " -I" + quote_path (vars["OCTINCLUDEDIR"]);
+#else
+  std::string DEFAULT_INCFLAGS
+    = "-I" + quote_path (vars["OCTINCLUDEDIR"] + "/..")
+    + " -I" + quote_path (vars["OCTINCLUDEDIR"]);
+#endif
+  if (vars["INCLUDEDIR"] != "/usr/include")
+    DEFAULT_INCFLAGS += " -I" + quote_path (vars["INCLUDEDIR"]);
+
+  std::string DEFAULT_LFLAGS = "-L" + quote_path (vars["OCTLIBDIR"]);
+  if (vars["LIBDIR"] != "/usr/lib")
+    DEFAULT_LFLAGS += " -L" + quote_path (vars["LIBDIR"]);
+
+  vars["CPPFLAGS"] = get_variable ("CPPFLAGS", %OCTAVE_CONF_CPPFLAGS%);
+  vars["INCFLAGS"] = get_variable ("INCFLAGS", DEFAULT_INCFLAGS);
+  vars["F77"] = get_variable ("F77", %OCTAVE_CONF_F77%);
+  vars["FFLAGS"] = get_variable ("FFLAGS", %OCTAVE_CONF_FFLAGS%);
+  vars["FPICFLAG"] = get_variable ("FPICFLAG", %OCTAVE_CONF_FPICFLAG%);
+  vars["CC"] = get_variable ("CC", %OCTAVE_CONF_CC%);
+  vars["CFLAGS"] = get_variable ("CFLAGS", %OCTAVE_CONF_CFLAGS%);
+  vars["CPICFLAG"] = get_variable ("CPICFLAG", %OCTAVE_CONF_CPICFLAG%);
+  vars["CXX"] = get_variable ("CXX", %OCTAVE_CONF_CXX%);
+  vars["CXXFLAGS"] = get_variable ("CXXFLAGS", %OCTAVE_CONF_CXXFLAGS%);
+  vars["CXXPICFLAG"] = get_variable ("CXXPICFLAG", %OCTAVE_CONF_CXXPICFLAG%);
+  vars["XTRA_CFLAGS"] = get_variable ("XTRA_CFLAGS", %OCTAVE_CONF_XTRA_CFLAGS%);
+  vars["XTRA_CXXFLAGS"] = get_variable ("XTRA_CXXFLAGS", %OCTAVE_CONF_XTRA_CXXFLAGS%);
+
+  vars["DEPEND_FLAGS"] = get_variable ("DEPEND_FLAGS", %OCTAVE_CONF_DEPEND_FLAGS%);
+  vars["DEPEND_EXTRA_SED_PATTERN"] = get_variable ("DEPEND_EXTRA_SED_PATTERN", %OCTAVE_CONF_DEPEND_EXTRA_SED_PATTERN%);
+
+  vars["DL_LD"] = get_variable ("DL_LD", %OCTAVE_CONF_DL_LD%);
+  vars["DL_LDFLAGS"] = get_variable ("DL_LDFLAGS", %OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS%);
+
+  vars["RDYNAMIC_FLAG"] = get_variable ("RDYNAMIC_FLAG", %OCTAVE_CONF_RDYNAMIC_FLAG%);
+  vars["LIBOCTAVE"] = "-loctave";
+  vars["LIBOCTINTERP"] = "-loctinterp";
+  vars["READLINE_LIBS"] = "-lreadline";
+  vars["LIBCRUFT"] = "-lcruft";
+  vars["LAPACK_LIBS"] = get_variable ("LAPACK_LIBS", %OCTAVE_CONF_LAPACK_LIBS%);
+  vars["BLAS_LIBS"] = get_variable ("BLAS_LIBS", %OCTAVE_CONF_BLAS_LIBS%);
+  vars["FFTW3_LDFLAGS"] = get_variable ("FFTW3_LDFLAGS", %OCTAVE_CONF_FFTW3_LDFLAGS%);
+  vars["FFTW3_LIBS"] = get_variable ("FFTW3_LIBS", %OCTAVE_CONF_FFTW3_LIBS%);
+  vars["FFTW3F_LDFLAGS"] = get_variable ("FFTW3F_LDFLAGS", %OCTAVE_CONF_FFTW3F_LDFLAGS%);
+  vars["FFTW3F_LIBS"] = get_variable ("FFTW3F_LIBS", %OCTAVE_CONF_FFTW3F_LIBS%);
+  vars["LIBS"] = get_variable ("LIBS", %OCTAVE_CONF_LIBS%);
+  vars["FLIBS"] = get_variable ("FLIBS", %OCTAVE_CONF_FLIBS%);
+  vars["OCTAVE_LINK_DEPS"] = get_variable ("FLIBS", %OCTAVE_CONF_OCTAVE_LINK_DEPS%);
+  vars["OCT_LINK_DEPS"] = get_variable ("FLIBS", %OCTAVE_CONF_OCT_LINK_DEPS%);
+  vars["FLIBS"] = get_variable ("FLIBS", %OCTAVE_CONF_FLIBS%);
+
+  vars["LD_CXX"] = get_variable ("LD_CXX", %OCTAVE_CONF_LD_CXX%);
+  vars["LDFLAGS"] = get_variable ("LDFLAGS", %OCTAVE_CONF_LDFLAGS%);
+  vars["LD_STATIC_FLAG"] = get_variable ("LD_STATIC_FLAG", %OCTAVE_CONF_LD_STATIC_FLAG%);
+  vars["LFLAGS"] = get_variable ("LFLAGS", DEFAULT_LFLAGS);
+  vars["F77_INTEGER8_FLAG"] = get_variable ("F77_INTEGER8_FLAG", %OCTAVE_CONF_F77_INTEGER_8_FLAG%);
+
+  vars["ALL_FFLAGS"] = vars["FFLAGS"] + " " + vars["F77_INTEGER8_FLAG"];
+
+  vars["ALL_CFLAGS"] = vars["INCFLAGS"] + " " + vars["XTRA_CFLAGS"]
+    + " " + vars["CFLAGS"];
+
+  vars["ALL_CXXFLAGS"] = vars["INCFLAGS"] + " " + vars["XTRA_CXXFLAGS"]
+    + " " + vars["CXXFLAGS"];
+
+  vars["ALL_LDFLAGS"] = vars["LD_STATIC_FLAG"] + " " + vars["CPICFLAG"]
+    + " " + vars["LDFLAGS"];
+
+  vars["OCTAVE_LIBS"] = vars["LIBOCTINTERP"] + " " + vars["LIBOCTAVE"]
+    + " " + vars["SPECIAL_MATH_LIB"] + " " + vars["LIBCRUFT"];
+
+  vars["FFTW_LIBS"] = vars["FFTW3_LDFLAGS"] + " " + vars["FFTW3_LIBS"]
+    + " " + vars["FFTW3F_LDFLAGS"] + " " + vars["FFTW3F_LIBS"];
+}
+
+static string usage_msg = "usage: mkoctfile [options] file ...";
+static string version_msg = "mkoctfile, version " + OCTAVE_VERSION;
+static bool debug = false;
+static string help_msg =
+"\n"
+"Options:\n"
+"\n"
+"  -h, -?, --help          Print this message.\n"
+"\n"
+"  -IDIR                   Add -IDIR to compile commands.\n"
+"\n"
+"  -idirafter DIR          Add -idirafter DIR to compile commands.\n"
+"\n"
+"  -DDEF                   Add -DDEF to compile commands.\n"
+"\n"
+"  -lLIB                   Add library LIB to link command.\n"
+"\n"
+"  -LDIR                   Add -LDIR to link command.\n"
+"\n"
+"  -M, --depend            Generate dependency files (.d) for C and C++\n"
+"                          source files.\n"
+"\n"
+"  -RDIR                   Add -RDIR to link command.\n"
+"\n"
+"  -Wl,...                 Pass flags though the linker like -Wl,-rpath=...\n"
+"\n"
+"  -W...                   Pass flags though the compiler like -Wa,OPTION.\n"
+"\n"
+"  -c, --compile           Compile, but do not link.\n"
+"\n"
+"  -o FILE, --output FILE  Output file name.  Default extension is .oct\n"
+"                          (or .mex if --mex is specified) unless linking\n"
+"                          a stand-alone executable.\n"
+"\n"
+"  -g                      Enable debugging options for compilers.\n"
+"\n"
+"  -p VAR, --print VAR     Print configuration variable VAR.  Recognized\n"
+"                          variables are:\n"
+"\n"
+"                            ALL_CFLAGS                FLIBS\n"
+"                            ALL_CXXFLAGS              FPICFLAG\n"
+"                            ALL_FFLAGS                INCFLAGS\n"
+"                            ALL_LDFLAGS               LAPACK_LIBS\n"
+"                            BLAS_LIBS                 LDFLAGS\n"
+"                            CC                        LD_CXX\n"
+"                            CFLAGS                    LD_STATIC_FLAG\n"
+"                            CPICFLAG                  LFLAGS\n"
+"                            CPPFLAGS                  LIBCRUFT\n"
+"                            CXX                       LIBOCTAVE\n"
+"                            CXXFLAGS                  LIBOCTINTERP\n"
+"                            CXXPICFLAG                LIBS\n"
+"                            DEPEND_EXTRA_SED_PATTERN  OCTAVE_LIBS\n"
+"                            DEPEND_FLAGS              OCTAVE_LINK_DEPS\n"
+"                            DL_LD                     OCTAVE_LINK_OPTS\n"
+"                            DL_LDFLAGS                OCT_LINK_DEPS\n"
+"                            EXEEXT                    OCT_LINK_OPTS\n"
+"                            F77                       RDYNAMIC_FLAG\n"
+"                            F77_INTEGER_8_FLAG        READLINE_LIBS\n"
+"                            FFLAGS                    SED\n"
+"                            FFTW3_LDFLAGS             XTRA_CFLAGS\n"
+"                            FFTW3_LIBS                XTRA_CXXFLAGS\n"
+"                            FFTW3F_LDFLAGS\n"
+"                            FFTW3F_LIBS\n"
+"\n"
+"  --link-stand-alone      Link a stand-alone executable file.\n"
+"\n"
+"  --mex                   Assume we are creating a MEX file.  Set the\n"
+"                          default output extension to \".mex\".\n"
+"\n"
+"  -s, --strip             Strip output file.\n"
+"\n"
+"  -v, --verbose           Echo commands as they are executed.\n"
+"\n"
+"  FILE                    Compile or link FILE.  Recognized file types are:\n"
+"\n"
+"                            .c    C source\n"
+"                            .cc   C++ source\n"
+"                            .C    C++ source\n"
+"                            .cpp  C++ source\n"
+"                            .f    Fortran source (fixed form)\n"
+"                            .F    Fortran source (fixed form)\n"
+"                            .f90  Fortran source (free form)\n"
+"                            .F90  Fortran source (free form)\n"
+"                            .o    object file\n"
+"                            .a    library file\n"
+#ifdef _MSC_VER
+"                            .lib  library file\n"
+#endif
+"\n";
+
+static string
+basename (const string& s, bool strip_path = false)
+{
+  size_t pos = s.rfind ('.');
+  string retval;
+
+  if (pos == string::npos)
+    retval = s;
+  else
+    retval = s.substr (0, pos);
+  if (strip_path)
+    {
+      size_t p1 = retval.rfind ('/'), p2 = retval.rfind ('\\');
+      pos = (p1 != string::npos && p2 != string::npos
+             ? max (p1, p2) : (p2 != string::npos ? p2 : p1));
+      if (pos != string::npos)
+        retval = retval.substr (0, pos);
+    }
+  return retval;
+}
+
+inline bool
+starts_with (const string& s, const string& prefix)
+{
+  return (s.length () >= prefix.length () && s.find (prefix) == 0);
+}
+
+inline bool
+ends_with (const string& s, const string& suffix)
+{
+  return (s.length () >= suffix.length ()
+          && s.rfind (suffix) == s.length () - suffix.length ());
+}
+
+static int
+run_command (const string& cmd)
+{
+  if (debug)
+    cout << cmd << endl;
+  return system (cmd.c_str ());
+}
+
+int
+main (int argc, char **argv)
+{
+  initialize ();
+
+  string file, output_option;
+  list<string> cfiles, ccfiles, f77files;
+  int result = 0;
+
+  string objfiles = "";
+  string libfiles = "";
+  string octfile = "";
+  string outputfile = "";
+  string incflags = "";
+  string defs = "";
+  string ldflags = "";
+  string pass_on_options = "";
+  bool strip = false;
+  bool no_oct_file_strip_on_this_platform = %NO_OCT_FILE_STRIP%;
+  bool link = true;
+  bool link_stand_alone = false;
+  string output_ext = ".oct";
+  bool depend = false;
+  bool compile = true;
+
+  if (argc == 1)
+    {
+      cout << usage_msg << endl;
+      return 1;
+    }
+
+  if (argc == 2 && (!strcmp (argv[1], "-v")
+                    || !strcmp (argv[1], "-version")
+                    || !strcmp (argv[1], "--version")))
+    {
+      cout << version_msg << endl;
+      return 0;
+    }
+
+  for (int i = 1; i < argc; i++)
+    {
+      string arg = argv[i];
+      size_t len = arg.length ();
+
+      if (ends_with (arg, ".c"))
+        {
+          file = arg;
+          cfiles.push_back (file);
+        }
+      else if (ends_with (arg, ".cc") || ends_with (arg, ".C")
+               || ends_with (arg, ".cpp"))
+        {
+          file = arg;
+          ccfiles.push_back (file);
+        }
+      else if (ends_with (arg, ".f") || ends_with (arg, ".F")
+               || ends_with (arg, "f90") || ends_with (arg, ".F90"))
+        {
+          file = arg;
+          f77files.push_back (file);
+        }
+      else if (ends_with (arg, ".o") || ends_with (arg, ".obj"))
+        {
+          file = arg;
+          objfiles += (" " + quote_path (arg));
+        }
+      else if (ends_with (arg, ".lib") || ends_with (arg, ".a"))
+        {
+          file = arg;
+          libfiles += (" " + quote_path (arg));
+        }
+      else if (arg == "-d" || arg == "-debug" || arg == "--debug"
+               || arg == "-v" || arg == "-verbose" ||  arg == "--verbose")
+        {
+          debug = true;
+          if (vars["CC"] == "cc-msvc")
+            vars["CC"] += " -d";
+          if (vars["CXX"] == "cc-msvc")
+            vars["CXX"] += " -d";
+          if (vars["DL_LD"] == "cc-msvc")
+            vars["DL_LD"] += " -d";
+        }
+      else if (arg == "-h" || arg == "-?" || arg == "-help" || arg == "--help")
+        {
+          cout << usage_msg << endl;
+          cout << help_msg << endl;
+          return 0;
+        }
+      else if (starts_with (arg, "-I"))
+        {
+          incflags += (" " + quote_path (arg));
+        }
+      else if (arg == "-idirafter")
+        {
+          if (i < argc-1)
+            {
+              arg = argv[++i];
+              incflags += (" -idirafter " + arg);
+            }
+          else
+            cerr << "mkoctfile: include directory name missing" << endl;
+        }
+      else if (starts_with (arg, "-D"))
+        {
+          defs += (" " + arg);
+        }
+      else if (starts_with (arg, "-Wl,") || starts_with (arg, "-l")
+               || starts_with (arg, "-L") || starts_with (arg, "-R"))
+        {
+          ldflags += (" " + arg);
+        }
+      else if (arg == "-M" || arg == "-depend" || arg == "--depend")
+        {
+          depend = true;
+          compile = false;
+        }
+      else if (arg == "-o" || arg == "-output" || arg == "--output")
+        {
+          if (i < argc-1)
+            {
+              arg = argv[++i];
+              outputfile = arg;
+            }
+          else
+            cerr << "mkoctfile: output file name missing" << endl;
+        }
+      else if (arg == "-p" || arg == "-print" || arg == "--print")
+        {
+          if (i < argc-1)
+            {
+              arg = argv[++i];
+              cout << vars[arg] << endl;
+              return 0;
+            }
+          else
+            cerr << "mkoctfile: --print requires argument" << endl;
+        }
+      else if (arg == "-s" || arg == "-strip" || arg == "--strip")
+        {
+          if (no_oct_file_strip_on_this_platform)
+            cerr << "mkoctfile: stripping disabled on this platform" << endl;
+          else
+            strip = true;
+        }
+      else if (arg == "-c" || arg == "-compile" || arg == "--compile")
+        {
+          link = false;
+        }
+      else if (arg == "-g")
+        {
+          vars["ALL_CFLAGS"] += " -g";
+          vars["ALL_CXXFLAGS"] += " -g";
+          vars["ALL_FFLAGS"] += " -g";
+        }
+      else if (arg == "-link-stand-alone" || arg == "--link-stand-alone")
+        {
+          link_stand_alone = true;
+        }
+      else if (arg == "-mex" || arg == "--mex")
+        {
+          incflags += " -I.";
+#ifdef _MSC_VER
+          ldflags += " -Wl,-export:mexFunction";
+#endif
+          output_ext = ".mex";
+        }
+      else if (starts_with (arg, "-W"))
+        {
+          pass_on_options += (" " + arg);
+        }
+      else
+        {
+          cerr << "mkoctfile: unrecognized argument " << arg;
+          return 1;
+        }
+
+      if (!file.empty () && octfile.empty ())
+        octfile = file;
+    }
+
+  if (link_stand_alone)
+    {
+      if (!outputfile.empty ())
+        output_option = "-o " + outputfile;
+    }
+  else
+    {
+      if (!outputfile.empty ())
+        {
+          octfile = outputfile;
+          size_t len = octfile.length ();
+          size_t len_ext = output_ext.length ();
+          if (octfile.substr (len-len_ext) != output_ext)
+            octfile += output_ext;
+        }
+      else
+        octfile = basename (octfile, true) + output_ext;
+    }
+
+  list<string>::const_iterator it;
+
+  if (depend)
+    {
+      for (it = cfiles.begin (); it != cfiles.end (); ++it)
+        {
+          string f = *it, dfile = basename (f, true) + ".d", line;
+
+          unlink (dfile.c_str ());
+          string cmd = vars["CC"] + " " + vars["DEPEND_FLAGS"] + " "
+            + vars["CPPFLAGS"] + " " + vars["ALL_CFLAGS"] + " "
+            + incflags  + " " + defs + " " + quote_path (f);
+
+          FILE *fd = popen (cmd.c_str (), "r");
+          ofstream fo (dfile.c_str ());
+          int pos;
+          while (!feof (fd))
+            {
+              line = get_line (fd);
+              if ((pos = line.rfind (".o:")) != string::npos)
+                {
+                  int spos = line.rfind ('/', pos);
+                  string ofile = (spos == string::npos ? line.substr (0, pos+2) : line.substr (spos+1, pos-spos+1));
+                  fo << "pic/" << ofile << " " << ofile << " " << dfile << line.substr (pos) << endl;
+                }
+              else
+                fo << line << endl;
+            }
+          pclose (fd);
+          fo.close ();
+        }
+
+      for (it = ccfiles.begin (); it != ccfiles.end (); ++it)
+        {
+          string f = *it, dfile = basename (f, true) + ".d", line;
+
+          unlink (dfile.c_str ());
+          string cmd = vars["CC"] + " " + vars["DEPEND_FLAGS"] + " "
+            + vars["CPPFLAGS"] + " " + vars["ALL_CXXFLAGS"] + " "
+            + incflags  + " " + defs + " " + quote_path (f);
+
+          FILE *fd = popen (cmd.c_str (), "r");
+          ofstream fo (dfile.c_str ());
+          int pos;
+          while (!feof (fd))
+            {
+              line = get_line (fd);
+              if ((pos = line.rfind (".o:")) != string::npos)
+                {
+                  int spos = line.rfind ('/', pos);
+                  string ofile = (spos == string::npos ? line.substr (0, pos+2) : line.substr (spos+1, pos-spos+1));
+                  fo << "pic/" << ofile << " " << ofile << " " << dfile << line.substr (pos+2) << endl;
+                }
+              else
+                fo << line << endl;
+            }
+          pclose (fd);
+          fo.close ();
+        }
+
+      return 0;
+    }
+
+  for (it = f77files.begin (); it != f77files.end (); ++it)
+    {
+      string f = *it, b = basename (f, true);
+      if (!vars["F77"].empty ())
+        {
+          string o;
+          if (!outputfile.empty ())
+            {
+              if (link)
+                o = b + ".o";
+              else
+                o = outputfile;
+            }
+          else
+            o = b + ".o";
+          objfiles += (" " + o);
+          string cmd = vars["F77"] + " -c " + vars["FPICFLAG"] + " "
+            + vars["ALL_FFLAGS"] + " " + incflags + " " + defs + " "
+            + pass_on_options + " " + f + " -o " + o;
+          result = run_command (cmd);
+        }
+      else
+        {
+          cerr << "mkoctfile: no way to compile Fortran file " << f << endl;
+          return 1;
+        }
+    }
+
+  for (it = cfiles.begin (); it != cfiles.end (); ++it)
+    {
+      string f = *it;
+      if (!vars["CC"].empty ())
+        {
+          string b = basename (f, true), o;
+          if (!outputfile.empty ())
+            {
+              if (link)
+                o = b + ".o";
+              else
+                o = outputfile;
+            }
+          else
+            o = b + ".o";
+          objfiles += (" " + o);
+          string cmd = vars["CC"] + " -c " + vars["CPPFLAGS"] + " "
+            + vars["CPICFLAG"] + " " + vars["ALL_CFLAGS"] + " "
+            + pass_on_options + " " + incflags + " " + defs + " "
+            + quote_path (f) + " -o " + quote_path (o);
+          result = run_command (cmd);
+        }
+      else
+        {
+          cerr << "mkoctfile: no way to compile C file " << f << endl;
+          return 1;
+        }
+    }
+
+  for (it = ccfiles.begin (); it != ccfiles.end (); ++it)
+    {
+      string f = *it;
+      if (!vars["CXX"].empty ())
+        {
+          string b = basename (f, true), o;
+          if (!outputfile.empty ())
+            {
+              if (link)
+                o = b + ".o";
+              else
+                o = outputfile;
+            }
+          else
+            o = b + ".o";
+          objfiles += (" " + o);
+          string cmd = vars["CXX"] + " -c " + vars["CPPFLAGS"] + " "
+            + vars["CXXPICFLAG"] + " " + vars["ALL_CXXFLAGS"] + " "
+            + pass_on_options + " " + incflags + " " + defs + " "
+            + quote_path (f) + " -o " + quote_path (o);
+          result = run_command (cmd);
+        }
+      else
+        {
+          cerr << "mkoctfile: no way to compile C++ file " << f << endl;
+          return 1;
+        }
+    }
+
+  if (link && !objfiles.empty ())
+    {
+      if (link_stand_alone)
+        {
+          if (!vars["LD_CXX"].empty ())
+            {
+              string cmd = vars["LD_CXX"] + " " + vars["CPPFLAGS"] + " "
+                + vars["ALL_CXXFLAGS"] + " " + vars["RDYNAMIC_FLAG"]
+                + " " + vars["ALL_LDFLAGS"] + " " +  pass_on_options
+                + " " + output_option + " " + objfiles + " " + libfiles
+                + " " + ldflags + " " + vars["LFLAGS"]
+                + " -loctinterp -loctave -lcruft "
+                + " " + vars["OCT_LINK_OPTS"]
+                + " " + vars["OCTAVE_LINK_DEPS"];
+              result = run_command (cmd);
+            }
+          else
+            {
+              cerr << "mkoctfile: no way to link stand-alone executable file"
+                   << endl;
+              return 1;
+            }
+        }
+      else
+        {
+          string cmd = vars["DL_LD"] + " " + vars["DL_LDFLAGS"] + " "
+            + pass_on_options + " -o " + octfile + " " + objfiles + " "
+            + libfiles + " " + ldflags + " " + vars["LFLAGS"]
+            + " -loctinterp -loctave -lcruft "
+            + vars["OCT_LINK_OPTS"] + " " + vars["OCT_LINK_DEPS"];
+          result = run_command (cmd);
+        }
+
+      if (strip)
+        {
+          string cmd = "strip " + octfile;
+          result = run_command (cmd);
+        }
+    }
+
+  return result;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mkoctfile.in.sh	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,558 @@
+#! /bin/sh
+##
+## mkoctfile -- create a .oct file suitable for dynamic linking by
+## Octave.
+##
+## Copyright (C) 1996-2012 John W. Eaton
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by the
+## Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but WITHOUT
+## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+## for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+# Exit immediately on any error.
+
+set -e
+
+: ${SED=%OCTAVE_CONF_SED%}
+
+OCTAVE_VERSION=%OCTAVE_CONF_VERSION%
+OCTAVE_PREFIX=%OCTAVE_CONF_PREFIX%
+
+DEFAULT_BINDIR=%OCTAVE_BINDIR%
+DEFAULT_INCLUDEDIR=%OCTAVE_CONF_INCLUDEDIR%
+DEFAULT_LIBDIR=%OCTAVE_CONF_LIBDIR%
+DEFAULT_OCTINCLUDEDIR=%OCTAVE_CONF_OCTINCLUDEDIR%
+DEFAULT_OCTLIBDIR=%OCTAVE_CONF_OCTLIBDIR%
+
+if [ -n "$OCTAVE_HOME" ]; then
+  DEFAULT_BINDIR="`echo $DEFAULT_BINDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`"
+  DEFAULT_INCLUDEDIR="`echo $DEFAULT_INCLUDEDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`"
+  DEFAULT_LIBDIR="`echo $DEFAULT_LIBDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`"
+  DEFAULT_OCTINCLUDEDIR="`echo $DEFAULT_OCTINCLUDEDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`"
+  DEFAULT_OCTLIBDIR="`echo $DEFAULT_OCTLIBDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`"
+fi
+
+: ${BINDIR=$DEFAULT_BINDIR}
+: ${INCLUDEDIR=$DEFAULT_INCLUDEDIR}
+: ${LIBDIR=$DEFAULT_LIBDIR}
+: ${OCTINCLUDEDIR=$DEFAULT_OCTINCLUDEDIR}
+: ${OCTLIBDIR=$DEFAULT_OCTLIBDIR}
+
+DEFAULT_INCFLAGS="-I$OCTINCLUDEDIR/.. -I$OCTINCLUDEDIR"
+if [ "$INCLUDEDIR" != /usr/include ]; then
+  DEFAULT_INCFLAGS="$DEFAULT_INCFLAGS -I$INCLUDEDIR"
+fi
+
+DEFAULT_LFLAGS="-L$OCTLIBDIR"
+if [ "$LIBDIR" != /usr/lib ]; then
+  DEFAULT_LFLAGS="$DEFAULT_LFLAGS -L$LIBDIR"
+fi
+
+# Default values for these variables are filled in when Octave is
+# compiled.
+
+: ${EXEEXT=%OCTAVE_CONF_EXEEXT%}
+
+: ${CPPFLAGS=%OCTAVE_CONF_CPPFLAGS%}
+: ${INCFLAGS=$DEFAULT_INCFLAGS}
+: ${F77=%OCTAVE_CONF_F77%}
+: ${FFLAGS=%OCTAVE_CONF_FFLAGS%}
+: ${FPICFLAG=%OCTAVE_CONF_FPICFLAG%}
+: ${CC=%OCTAVE_CONF_CC%}
+: ${CFLAGS=%OCTAVE_CONF_CFLAGS%}
+: ${CPICFLAG=%OCTAVE_CONF_CPICFLAG%}
+: ${CXX=%OCTAVE_CONF_CXX%}
+: ${CXXFLAGS=%OCTAVE_CONF_CXXFLAGS%}
+: ${CXXPICFLAG=%OCTAVE_CONF_CXXPICFLAG%}
+: ${XTRA_CFLAGS=%OCTAVE_CONF_XTRA_CFLAGS%}
+: ${XTRA_CXXFLAGS=%OCTAVE_CONF_XTRA_CXXFLAGS%}
+
+: ${DEPEND_FLAGS=%OCTAVE_CONF_DEPEND_FLAGS%}
+: ${DEPEND_EXTRA_SED_PATTERN=%OCTAVE_CONF_DEPEND_EXTRA_SED_PATTERN%}
+
+: ${DL_LD=%OCTAVE_CONF_DL_LD%}
+: ${DL_LDFLAGS=%OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS%}
+
+: ${RDYNAMIC_FLAG=%OCTAVE_CONF_RDYNAMIC_FLAG%}
+: ${LIBOCTAVE=-loctave}
+: ${LIBOCTINTERP=-loctinterp}
+: ${READLINE_LIBS=-lreadline}
+: ${LIBCRUFT=-lcruft}
+: ${LAPACK_LIBS=%OCTAVE_CONF_LAPACK_LIBS%}
+: ${BLAS_LIBS=%OCTAVE_CONF_BLAS_LIBS%}
+: ${FFTW3_LDFLAGS=%OCTAVE_CONF_FFTW3_LDFLAGS%}
+: ${FFTW3_LIBS=%OCTAVE_CONF_FFTW3_LIBS%}
+: ${FFTW3F_LDFLAGS=%OCTAVE_CONF_FFTW3F_LDFLAGS%}
+: ${FFTW3F_LIBS=%OCTAVE_CONF_FFTW3F_LIBS%}
+: ${LIBS=%OCTAVE_CONF_LIBS%}
+: ${FLIBS=%OCTAVE_CONF_FLIBS%}
+: ${OCTAVE_LINK_DEPS=%OCTAVE_CONF_OCTAVE_LINK_DEPS%}
+: ${OCTAVE_LINK_OPTS=%OCTAVE_CONF_OCTAVE_LINK_OPTS%}
+: ${OCT_LINK_DEPS=%OCTAVE_CONF_OCT_LINK_DEPS%}
+: ${OCT_LINK_OPTS=%OCTAVE_CONF_OCT_LINK_OPTS%}
+: ${LD_CXX=%OCTAVE_CONF_LD_CXX%}
+: ${LDFLAGS=%OCTAVE_CONF_LDFLAGS%}
+: ${LD_STATIC_FLAG=%OCTAVE_CONF_LD_STATIC_FLAG%}
+: ${LFLAGS=$DEFAULT_LFLAGS}
+: ${F77_INTEGER_8_FLAG=%OCTAVE_CONF_F77_INTEGER_8_FLAG%}
+
+: ${ALL_FFLAGS="$FFLAGS $F77_INTEGER_8_FLAG"}
+
+: ${ALL_CFLAGS="$INCFLAGS $XTRA_CFLAGS $CFLAGS"}
+
+: ${ALL_CXXFLAGS="$INCFLAGS $XTRA_CXXFLAGS $CXXFLAGS"}
+
+: ${ALL_LDFLAGS="$LD_STATIC_FLAG $CPICFLAG $LDFLAGS"}
+
+: ${OCTAVE_LIBS="$LIBOCTINTERP $LIBOCTAVE $SPECIAL_MATH_LIB $LIBCRUFT"}
+
+# Local variables.
+
+FFTW_LIBS="$FFTW3_LDFLAGS $FFTW3_LIBS $FFTW3F_LDFLAGS $FFTW3F_LIBS"
+
+usage_msg="usage: mkoctfile [options] file ..."
+
+version_msg="mkoctfile, version $OCTAVE_VERSION"
+
+cfiles=
+ccfiles=
+f77files=
+objfiles=
+libfiles=
+octfiles=
+octfile=
+outputfile=
+incflags=
+defs=
+ldflags=
+dbg=:
+pass_on_options=
+strip=false
+no_oct_file_strip_on_this_platform=%NO_OCT_FILE_STRIP%
+link=true
+link_stand_alone=false
+output_ext=".oct"
+depend=false
+compile=true
+
+if [ $# -eq 0 ]; then
+  echo $usage_msg 1>&2
+  exit 1
+fi
+
+if [ $# -eq 1 ]; then
+  case "$1" in
+    -v | -version | --version)
+      echo $version_msg 1>&2
+      exit 0
+    ;;
+  esac
+fi
+
+while [ $# -gt 0 ]; do
+  file=
+  case "$1" in
+    *.c)
+      file=$1
+      cfiles="$cfiles $file"
+    ;;
+    *.cc | *.C | *.cpp)
+      file=$1
+      ccfiles="$ccfiles $file"
+    ;;
+    *.f | *.F | *.f90 | *.F90)
+      file=$1
+      f77files="$f77files $file"
+    ;;
+    *.o)
+      file=$1
+      objfiles="$objfiles $file"
+    ;;
+    *.a)
+      file=$1
+      libfiles="$libfiles $file"
+    ;;
+    -d | -debug | --debug | -v | -verbose | --verbose)
+      dbg=echo
+    ;;
+    -h | -\? | -help | --help)
+      echo $usage_msg 1>&2
+      cat << EOF
+
+Options:
+
+  -h, -?, --help          Print this message.
+
+  -IDIR                   Add -IDIR to compile commands.
+
+  -idirafter DIR          Add -idirafter DIR to compile commands.
+
+  -DDEF                   Add -DDEF to compile commands.
+
+  -lLIB                   Add -lLIB to link command.
+
+  -LDIR                   Add -LDIR to link command.
+
+  -RDIR                   Add -RDIR to link command.
+
+  -g                      Enable debugging option for all compilers.
+
+  -pthread                Add -pthread to link command.
+
+  -W...                   Pass flags to the compiler such as -Wa,OPTION.
+
+  -Wl,...                 Pass flags to the linker such as -Wl,-rpath=...
+
+  -M, --depend            Generate dependency files (.d) for C and C++
+                          source files.
+
+  -c, --compile           Compile, but do not link.
+
+  --link-stand-alone      Link a stand-alone executable file.
+
+  -s, --strip             Strip output file.
+
+  --mex                   Create a MEX file.
+                          Set the default output extension to ".mex".
+
+  -o FILE, --output FILE  Output file name.  Default extension is .oct
+                          (or .mex if --mex is specified) unless linking
+                          a stand-alone executable.
+
+  -p VAR, --print VAR     Print configuration variable VAR.  Recognized
+                          variables are:
+
+                            ALL_CFLAGS                FFTW3F_LIBS
+                            ALL_CXXFLAGS              FLIBS
+                            ALL_FFLAGS                FPICFLAG
+                            ALL_LDFLAGS               INCFLAGS
+                            BLAS_LIBS                 LAPACK_LIBS
+                            CC                        LDFLAGS
+                            CFLAGS                    LD_CXX
+                            CPICFLAG                  LD_STATIC_FLAG
+                            CPPFLAGS                  LFLAGS
+                            CXX                       LIBCRUFT
+                            CXXFLAGS                  LIBOCTAVE
+                            CXXPICFLAG                LIBOCTINTERP
+                            DEPEND_EXTRA_SED_PATTERN  LIBS
+                            DEPEND_FLAGS              OCTAVE_LIBS
+                            DL_LD                     OCTAVE_LINK_DEPS
+                            DL_LDFLAGS                OCT_LINK_DEPS
+                            EXEEXT                    RDYNAMIC_FLAG
+                            F77                       READLINE_LIBS
+                            F77_INTEGER_8_FLAG        SED
+                            FFLAGS                    XTRA_CFLAGS
+                            FFTW3_LDFLAGS             XTRA_CXXFLAGS
+                            FFTW3_LIBS
+                            FFTW3F_LDFLAGS
+
+  -v, --verbose           Echo commands as they are executed.
+
+  FILE                    Compile or link FILE.  Recognized file types are:
+
+                            .c    C source
+                            .cc   C++ source
+                            .C    C++ source
+                            .cpp  C++ source
+                            .f    Fortran source (fixed form)
+                            .F    Fortran source (fixed form)
+                            .f90  Fortran source (free form)
+                            .F90  Fortran source (free form)
+                            .o    object file
+                            .a    library file
+
+EOF
+      exit 0
+    ;;
+    -I*)
+      incflags="$incflags $1"
+    ;;
+    -idirafter)
+      shift
+      if [ $# -gt 0 ]; then
+        incflags="$incflags -idirafter $1"
+      else
+        echo "mkoctfile: include directory name missing" 1>&2
+      fi
+    ;;
+    -D*)
+      defs="$defs $1"
+    ;;
+    -[lLR]* | -Wl,*)
+      ldflags="$ldflags $1"
+    ;;
+    -pthread)
+      ldflags="$ldflags $1"
+    ;;
+    -M | -depend | --depend)
+      depend=true
+      compile=false
+    ;;
+    -o | -ouput | --output)
+      shift
+      if [ $# -gt 0 ]; then
+        outputfile="$1"
+      else
+        echo "mkoctfile: output file name missing" 1>&2
+      fi
+    ;;
+    -p | -print | --print)
+      shift
+      if [ $# -gt 0 ]; then
+        eval echo \${$1}
+        exit 0
+      else
+        echo "mkoctfile: --print requires argument" 1>&2
+        exit 1
+      fi
+    ;;
+    -s | -strip | --strip)
+      if $no_oct_file_strip_on_this_platform; then
+        echo "mkoctfile: stripping disabled on this platform" 1>&2
+      else
+        strip=true
+      fi
+    ;;
+    -c | -compile | --compile)
+      link=false
+    ;;
+    -g)
+      ALL_CFLAGS="$ALL_CFLAGS -g"
+      ALL_CXXFLAGS="$ALL_CXXFLAGS -g"
+      ALL_FFLAGS="$ALL_FFLAGS -g"
+    ;;
+    -link-stand-alone | --link-stand-alone)
+      link_stand_alone=true
+    ;;
+    -mex | --mex)
+      incflags="$incflags -I."
+      output_ext=".mex"
+    ;;
+    -W*)
+      pass_on_options="$pass_on_options $1"
+    ;;
+    *)
+      echo "mkoctfile: unrecognized argument $1" 1>&2
+      exit 1
+    ;;
+  esac
+  if [ -n "$file" ]; then
+    if [ -z "$octfile" ]; then
+      octfile="$file"
+    fi
+  fi
+  shift
+done
+
+if $link_stand_alone; then
+  if [ -n "$outputfile" ]; then
+    output_option="-o $outputfile"
+  fi
+else
+  if [ -n "$outputfile" ]; then
+    octfile="$outputfile"
+    case "$octfile" in
+      *$output_ext)
+      ;;
+      *)
+        octfile="$octfile$output_ext"
+      ;;
+    esac
+  else
+    octfile=`basename $octfile`
+    octfile=`echo $octfile | $SED 's,\.[^.]*$,,'`$output_ext
+  fi
+fi
+
+# Generate dependency files for C and C++ files.
+
+if $depend; then
+  if [ -n "$cfiles" ]; then
+    for f in $cfiles; do
+      b=`echo $f | $SED 's,\.c$,,'`
+      d=$b.d
+      cmd="rm -f $d"
+      $dbg $cmd
+      eval $cmd
+      cmd="$CC $DEPEND_FLAGS $CPPFLAGS $ALL_CFLAGS $incflags $def $f | $SED $DEPEND_EXTRA_SED_PATTERN -e 's,^[^:]*/\(.*\.o\):,\1:,' -e 's,$b\.o,pic/& & $d,g' > $d-t && mv $d-t $d"
+      $dbg $cmd
+      eval $cmd
+    done
+  fi
+
+  if [ -n "$ccfiles" ]; then
+    for f in $ccfiles; do
+      case $f in
+        *.cc)
+          b=`echo $f | $SED 's,\.cc$,,'`
+        ;;
+        *.C)
+          b=`echo $f | $SED 's,\.C$,,'`
+        ;;
+        *.cpp)
+          b=`echo $f | $SED 's,\.cpp$,,'`
+        ;;
+      esac
+      d=$b.d
+      cmd="rm -f $d"
+      $dbg $cmd
+      eval $cmd
+      cmd="$CXX $DEPEND_FLAGS $CPPFLAGS $ALL_CXXFLAGS $incflags $defs $f | $SED $DEPEND_EXTRA_SED_PATTERN -e 's,^[^:]*/\(.*\.o\):,\1:,' -e 's,$b\.o,pic/& & $d,g' > $d-t && mv $d-t $d"
+      $dbg $cmd
+      eval $cmd
+    done
+  fi
+  # If generating dependencies, that's all we do.
+  exit 0
+fi
+
+# Compile Fortran, C, and C++ files.  Add the name of each object file
+# that is produced to the overall list of object files.
+
+if [ -n "$f77files" ]; then
+  for f in $f77files; do
+    case $f in
+      *.f)
+        b=`echo $f | $SED 's,.*/,,; s,\.f$,,'`
+      ;;
+      *.F)
+        b=`echo $f | $SED 's,.*/,,; s,\.F$,,'`
+      ;;
+      *.f90)
+        b=`echo $f | $SED 's,.*/,,; s,\.f90$,,'`
+      ;;
+      *.F90)
+        b=`echo $f | $SED 's,.*/,,; s,\.F90$,,'`
+      ;;
+    esac
+    if [ -n "$F77" ]; then
+      if [ -n "$outputfile" ]; then
+        if $link; then
+          o=$b.o
+        else
+          o=$outputfile
+        fi
+      else
+        o=$b.o
+      fi
+      objfiles="$objfiles $o"
+      cmd="$F77 -c $FPICFLAG $ALL_FFLAGS $incflags $defs $pass_on_options $f -o $o"
+      $dbg $cmd
+      eval $cmd
+    else
+      echo "mkoctfile: no way to compile Fortran file $f" 1>&2
+    fi
+  done
+fi
+
+if [ -n "$cfiles" ]; then
+  for f in $cfiles; do
+    if [ -n  "$CC" ]; then
+      b=`echo $f | $SED 's,.*/,,; s,\.c$,,'`
+      if [ -n "$outputfile" ]; then
+        if $link; then
+          o=$b.o
+        else
+          o=$outputfile
+        fi
+      else
+        o=$b.o
+      fi
+      objfiles="$objfiles $o"
+      cmd="$CC -c $CPPFLAGS $CPICFLAG $ALL_CFLAGS $pass_on_options $incflags $defs $f -o $o"
+      $dbg $cmd
+      eval $cmd
+    else
+      echo "mkoctfile: no way to compile C++ file $f" 1>&2
+    fi
+  done
+fi
+
+if [ -n "$ccfiles" ]; then
+  for f in $ccfiles; do
+    if [ -n "$CXX" ]; then
+      case $f in
+        *.cc)
+          b=`echo $f | $SED 's,.*/,,; s,\.cc$,,'`
+        ;;
+        *.C)
+          b=`echo $f | $SED 's,.*/,,; s,\.C$,,'`
+        ;;
+        *.cpp)
+          b=`echo $f | $SED 's,.*/,,; s,\.cpp$,,'`
+        ;;
+      esac
+      if [ -n "$outputfile" ]; then
+        if $link; then
+          o=$b.o
+        else
+          o=$outputfile
+        fi
+      else
+        o=$b.o
+      fi
+      objfiles="$objfiles $o"
+      cmd="$CXX -c $CPPFLAGS $CXXPICFLAG $ALL_CXXFLAGS $pass_on_options $incflags $defs $f -o $o"
+      $dbg $cmd
+      eval $cmd
+    else
+      echo "mkoctfile: no way to compile C++ file $f" 1>&2
+    fi
+  done
+fi
+
+## Uncomment the following group of lines if you get `Text file busy'
+## errors from ld.  This may happen if the .oct file is currently
+## running while you are trying to recompile it.  We try moving first,
+## since on some systems (HP-UX, maybe others) it is possible to
+## rename running programs but not remove them.
+
+## if [ -f "$octfile" ]; then
+##   cmd="mv $octfile $octfile.bak"
+##   $dbg $cmd
+##   eval $cmd
+##   cmd="rm -f $octfile.bak"
+##   $dbg $cmd
+##   eval $cmd
+## fi
+
+# Link all the object files.
+
+if $link && [ -n "$objfiles" ]; then
+  if $link_stand_alone; then
+    if [ -n "$LD_CXX" ]; then
+      cmd="$LD_CXX $CPPFLAGS $ALL_CXXFLAGS $RDYNAMIC_FLAG $ALL_LDFLAGS $pass_on_options $output_option $objfiles $libfiles $ldflags $LFLAGS -loctinterp -loctave -lcruft $OCTAVE_LINK_OPTS $OCTAVE_LINK_DEPS"
+      $dbg $cmd
+      eval $cmd
+    else
+      echo "mkoctfile: no way to link stand-alone executable file" 1>&2
+      exit 1
+    fi
+  else
+    cmd="$DL_LD $DL_LDFLAGS $pass_on_options -o $octfile $objfiles $libfiles $ldflags $LFLAGS -loctinterp -loctave -lcruft $OCT_LINK_OPTS $OCT_LINK_DEPS"
+    $dbg $cmd
+    eval $cmd
+  fi
+
+# Maybe strip it.
+
+  if $strip; then
+    cmd="strip $octfile"
+    $dbg $cmd
+    eval $cmd
+  fi
+fi
+
+exit 0
--- a/src/mxarray.h.in	Mon May 07 00:53:54 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,347 +0,0 @@
-/*
-
-Copyright (C) 2001-2012 Paul Kienzle
-
-This file is part of Octave.
-
-Octave is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 3 of the License, or (at your
-option) any later version.
-
-Octave is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with Octave; see the file COPYING.  If not, see
-<http://www.gnu.org/licenses/>.
-
-*/
-
-/*
-
-Part of this code was originally distributed as part of Octave Forge under
-the following terms:
-
-Author: Paul Kienzle
-I grant this code to the public domain.
-2001-03-22
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
-*/
-
-#if ! defined (MXARRAY_H)
-#define MXARRAY_H
-
-typedef enum
-  {
-    mxREAL = 0,
-    mxCOMPLEX = 1
-  }
-  mxComplexity;
-
-typedef enum
-  {
-    mxUNKNOWN_CLASS = 0,
-    mxCELL_CLASS,
-    mxSTRUCT_CLASS,
-    mxLOGICAL_CLASS,
-    mxCHAR_CLASS,
-    mxUNUSED_CLASS,
-    mxDOUBLE_CLASS,
-    mxSINGLE_CLASS,
-    mxINT8_CLASS,
-    mxUINT8_CLASS,
-    mxINT16_CLASS,
-    mxUINT16_CLASS,
-    mxINT32_CLASS,
-    mxUINT32_CLASS,
-    mxINT64_CLASS,
-    mxUINT64_CLASS,
-    mxFUNCTION_CLASS
-  }
-  mxClassID;
-
-typedef unsigned char mxLogical;
-
-/* typedef Uint16 mxChar; */
-typedef char mxChar;
-
-/*
- * FIXME? Mathworks says these should be size_t on 64-bit system and when
- * mex is used with the -largearraydims flag, but why do that? Its better
- * to conform to the same indexing as the rest of Octave
- */
-typedef %OCTAVE_IDX_TYPE% mwSize;
-typedef %OCTAVE_IDX_TYPE% mwIndex;
-
-#if ! defined (MXARRAY_TYPEDEFS_ONLY)
-
-#include <cstring>
-
-class octave_value;
-
-#define DO_MUTABLE_METHOD(RET_T, METHOD_CALL) \
-  RET_T retval = rep->METHOD_CALL; \
- \
-  if (rep->mutation_needed ()) \
-    { \
-      maybe_mutate (); \
-      retval = rep->METHOD_CALL; \
-    } \
- \
-  return retval
-
-#define DO_VOID_MUTABLE_METHOD(METHOD_CALL) \
-  rep->METHOD_CALL; \
- \
-  if (rep->mutation_needed ()) \
-    { \
-      maybe_mutate (); \
-      rep->METHOD_CALL; \
-    }
-
-// This just provides a way to avoid infinite recursion when building
-// mxArray objects.
-
-struct
-xmxArray
-{
-  xmxArray (void) { }
-};
-
-// The main interface class.  The representation can be based on an
-// octave_value object or a separate object that tries to reproduce
-// the semantics of mxArray objects in Matlab more directly.
-
-class mxArray
-{
-public:
-
-  mxArray (const octave_value& ov);
-
-  mxArray (mxClassID id, mwSize ndims, const mwSize *dims,
-           mxComplexity flag = mxREAL);
-
-  mxArray (mxClassID id, const dim_vector& dv, mxComplexity flag = mxREAL);
-
-  mxArray (mxClassID id, mwSize m, mwSize n, mxComplexity flag = mxREAL);
-
-  mxArray (mxClassID id, double val);
-
-  mxArray (mxClassID id, mxLogical val);
-
-  mxArray (const char *str);
-
-  mxArray (mwSize m, const char **str);
-
-  mxArray (mxClassID id, mwSize m, mwSize n, mwSize nzmax,
-           mxComplexity flag = mxREAL);
-
-  mxArray (mwSize ndims, const mwSize *dims, int num_keys, const char **keys);
-
-  mxArray (const dim_vector& dv, int num_keys, const char **keys);
-
-  mxArray (mwSize m, mwSize n, int num_keys, const char **keys);
-
-  mxArray (mwSize ndims, const mwSize *dims);
-
-  mxArray (const dim_vector& dv);
-
-  mxArray (mwSize m, mwSize n);
-
-  virtual mxArray *dup (void) const
-  {
-    mxArray *new_rep = rep->dup ();
-
-    return new mxArray (new_rep, name);
-  }
-
-  virtual ~mxArray (void);
-
-  virtual bool is_octave_value (void) const { return rep->is_octave_value (); }
-
-  virtual int is_cell (void) const { return rep->is_cell (); }
-
-  virtual int is_char (void) const { return rep->is_char (); }
-
-  virtual int is_class (const char *name_arg) const { return rep->is_class (name_arg); }
-
-  virtual int is_complex (void) const { return rep->is_complex (); }
-
-  virtual int is_double (void) const { return rep->is_double (); }
-
-  virtual int is_function_handle (void) const { return rep->is_function_handle (); }
-
-  virtual int is_int16 (void) const { return rep->is_int16 (); }
-
-  virtual int is_int32 (void) const { return rep->is_int32 (); }
-
-  virtual int is_int64 (void) const { return rep->is_int64 (); }
-
-  virtual int is_int8 (void) const { return rep->is_int8 (); }
-
-  virtual int is_logical (void) const { return rep->is_logical (); }
-
-  virtual int is_numeric (void) const { return rep->is_numeric (); }
-
-  virtual int is_single (void) const { return rep->is_single (); }
-
-  virtual int is_sparse (void) const { return rep->is_sparse (); }
-
-  virtual int is_struct (void) const { return rep->is_struct (); }
-
-  virtual int is_uint16 (void) const { return rep->is_uint16 (); }
-
-  virtual int is_uint32 (void) const { return rep->is_uint32 (); }
-
-  virtual int is_uint64 (void) const { return rep->is_uint64 (); }
-
-  virtual int is_uint8 (void) const { return rep->is_uint8 (); }
-
-  virtual int is_logical_scalar (void) const { return rep->is_logical_scalar (); }
-
-  virtual int is_logical_scalar_true (void) const { return rep->is_logical_scalar_true (); }
-
-  virtual mwSize get_m (void) const { return rep->get_m (); }
-
-  virtual mwSize get_n (void) const { return rep->get_n (); }
-
-  virtual mwSize *get_dimensions (void) const { return rep->get_dimensions (); }
-
-  virtual mwSize get_number_of_dimensions (void) const { return rep->get_number_of_dimensions (); }
-
-  virtual void set_m (mwSize m) { DO_VOID_MUTABLE_METHOD (set_m (m)); }
-
-  virtual void set_n (mwSize n) { DO_VOID_MUTABLE_METHOD (set_n (n)); }
-
-  virtual void set_dimensions (mwSize *dims_arg, mwSize ndims_arg) { DO_VOID_MUTABLE_METHOD (set_dimensions (dims_arg, ndims_arg)); }
-
-  virtual mwSize get_number_of_elements (void) const { return rep->get_number_of_elements (); }
-
-  virtual int is_empty (void) const { return get_number_of_elements () == 0; }
-
-  const char *get_name (void) const { return name; }
-
-  void set_name (const char *name_arg);
-
-  virtual mxClassID get_class_id (void) const { return rep->get_class_id (); }
-
-  virtual const char *get_class_name (void) const { return rep->get_class_name (); }
-
-  virtual void set_class_name (const char *name_arg) { DO_VOID_MUTABLE_METHOD (set_class_name (name_arg)); }
-
-  virtual mxArray *get_cell (mwIndex idx) const { DO_MUTABLE_METHOD (mxArray *, get_cell (idx)); }
-
-  virtual void set_cell (mwIndex idx, mxArray *val) { DO_VOID_MUTABLE_METHOD (set_cell (idx, val)); }
-
-  virtual double get_scalar (void) const { return rep->get_scalar (); }
-
-  virtual void *get_data (void) const { DO_MUTABLE_METHOD (void *, get_data ()); }
-
-  virtual void *get_imag_data (void) const { DO_MUTABLE_METHOD (void *, get_imag_data ()); }
-
-  virtual void set_data (void *pr) { DO_VOID_MUTABLE_METHOD (set_data (pr)); }
-
-  virtual void set_imag_data (void *pi) { DO_VOID_MUTABLE_METHOD (set_imag_data (pi)); }
-
-  virtual mwIndex *get_ir (void) const { DO_MUTABLE_METHOD (mwIndex *, get_ir ()); }
-
-  virtual mwIndex *get_jc (void) const { DO_MUTABLE_METHOD (mwIndex *, get_jc ()); }
-
-  virtual mwSize get_nzmax (void) const { return rep->get_nzmax (); }
-
-  virtual void set_ir (mwIndex *ir) { DO_VOID_MUTABLE_METHOD (set_ir (ir)); }
-
-  virtual void set_jc (mwIndex *jc) { DO_VOID_MUTABLE_METHOD (set_jc (jc)); }
-
-  virtual void set_nzmax (mwSize nzmax) { DO_VOID_MUTABLE_METHOD (set_nzmax (nzmax)); }
-
-  virtual int add_field (const char *key) { DO_MUTABLE_METHOD (int, add_field (key)); }
-
-  virtual void remove_field (int key_num) { DO_VOID_MUTABLE_METHOD (remove_field (key_num)); }
-
-  virtual mxArray *get_field_by_number (mwIndex index, int key_num) const { DO_MUTABLE_METHOD (mxArray *, get_field_by_number (index, key_num)); }
-
-  virtual void set_field_by_number (mwIndex index, int key_num, mxArray *val) { DO_VOID_MUTABLE_METHOD (set_field_by_number (index, key_num, val)); }
-
-  virtual int get_number_of_fields (void) const { return rep->get_number_of_fields (); }
-
-  virtual const char *get_field_name_by_number (int key_num) const { DO_MUTABLE_METHOD (const char*, get_field_name_by_number (key_num)); }
-
-  virtual int get_field_number (const char *key) const { DO_MUTABLE_METHOD (int, get_field_number (key)); }
-
-  virtual int get_string (char *buf, mwSize buflen) const { return rep->get_string (buf, buflen); }
-
-  virtual char *array_to_string (void) const { return rep->array_to_string (); }
-
-  virtual mwIndex calc_single_subscript (mwSize nsubs, mwIndex *subs) const { return rep->calc_single_subscript (nsubs, subs); }
-
-  virtual size_t get_element_size (void) const { return rep->get_element_size (); }
-
-  virtual bool mutation_needed (void) const { return rep->mutation_needed (); }
-
-  virtual mxArray *mutate (void) const { return rep->mutate (); }
-
-  static void *malloc (size_t n);
-
-  static void *calloc (size_t n, size_t t);
-
-  static char *strsave (const char *str)
-  {
-    char *retval = 0;
-
-    if (str)
-      {
-        mwSize sz =  sizeof (mxChar) * (strlen (str) + 1);
-        retval = static_cast<char *> (mxArray::malloc (sz));
-        strcpy (retval, str);
-      }
-
-    return retval;
-  }
-
-  static octave_value as_octave_value (mxArray *ptr);
-
-protected:
-
-  virtual octave_value as_octave_value (void) const;
-
-  mxArray (const xmxArray&) : rep (0), name (0) { }
-
-private:
-
-  mutable mxArray *rep;
-
-  char *name;
-
-  mxArray (mxArray *r, const char *n)
-    : rep (r), name (strsave (n)) { }
-
-  void maybe_mutate (void) const;
-
-  // No copying!
-
-  mxArray (const mxArray&);
-
-  mxArray& operator = (const mxArray&);
-};
-
-#undef DO_MUTABLE_METHOD
-#undef DO_VOID_MUTABLE_METHOD
-
-#endif
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mxarray.in.h	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,347 @@
+/*
+
+Copyright (C) 2001-2012 Paul Kienzle
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+/*
+
+Part of this code was originally distributed as part of Octave Forge under
+the following terms:
+
+Author: Paul Kienzle
+I grant this code to the public domain.
+2001-03-22
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+*/
+
+#if ! defined (MXARRAY_H)
+#define MXARRAY_H
+
+typedef enum
+  {
+    mxREAL = 0,
+    mxCOMPLEX = 1
+  }
+  mxComplexity;
+
+typedef enum
+  {
+    mxUNKNOWN_CLASS = 0,
+    mxCELL_CLASS,
+    mxSTRUCT_CLASS,
+    mxLOGICAL_CLASS,
+    mxCHAR_CLASS,
+    mxUNUSED_CLASS,
+    mxDOUBLE_CLASS,
+    mxSINGLE_CLASS,
+    mxINT8_CLASS,
+    mxUINT8_CLASS,
+    mxINT16_CLASS,
+    mxUINT16_CLASS,
+    mxINT32_CLASS,
+    mxUINT32_CLASS,
+    mxINT64_CLASS,
+    mxUINT64_CLASS,
+    mxFUNCTION_CLASS
+  }
+  mxClassID;
+
+typedef unsigned char mxLogical;
+
+/* typedef Uint16 mxChar; */
+typedef char mxChar;
+
+/*
+ * FIXME? Mathworks says these should be size_t on 64-bit system and when
+ * mex is used with the -largearraydims flag, but why do that? Its better
+ * to conform to the same indexing as the rest of Octave
+ */
+typedef %OCTAVE_IDX_TYPE% mwSize;
+typedef %OCTAVE_IDX_TYPE% mwIndex;
+
+#if ! defined (MXARRAY_TYPEDEFS_ONLY)
+
+#include <cstring>
+
+class octave_value;
+
+#define DO_MUTABLE_METHOD(RET_T, METHOD_CALL) \
+  RET_T retval = rep->METHOD_CALL; \
+ \
+  if (rep->mutation_needed ()) \
+    { \
+      maybe_mutate (); \
+      retval = rep->METHOD_CALL; \
+    } \
+ \
+  return retval
+
+#define DO_VOID_MUTABLE_METHOD(METHOD_CALL) \
+  rep->METHOD_CALL; \
+ \
+  if (rep->mutation_needed ()) \
+    { \
+      maybe_mutate (); \
+      rep->METHOD_CALL; \
+    }
+
+// This just provides a way to avoid infinite recursion when building
+// mxArray objects.
+
+struct
+xmxArray
+{
+  xmxArray (void) { }
+};
+
+// The main interface class.  The representation can be based on an
+// octave_value object or a separate object that tries to reproduce
+// the semantics of mxArray objects in Matlab more directly.
+
+class mxArray
+{
+public:
+
+  mxArray (const octave_value& ov);
+
+  mxArray (mxClassID id, mwSize ndims, const mwSize *dims,
+           mxComplexity flag = mxREAL);
+
+  mxArray (mxClassID id, const dim_vector& dv, mxComplexity flag = mxREAL);
+
+  mxArray (mxClassID id, mwSize m, mwSize n, mxComplexity flag = mxREAL);
+
+  mxArray (mxClassID id, double val);
+
+  mxArray (mxClassID id, mxLogical val);
+
+  mxArray (const char *str);
+
+  mxArray (mwSize m, const char **str);
+
+  mxArray (mxClassID id, mwSize m, mwSize n, mwSize nzmax,
+           mxComplexity flag = mxREAL);
+
+  mxArray (mwSize ndims, const mwSize *dims, int num_keys, const char **keys);
+
+  mxArray (const dim_vector& dv, int num_keys, const char **keys);
+
+  mxArray (mwSize m, mwSize n, int num_keys, const char **keys);
+
+  mxArray (mwSize ndims, const mwSize *dims);
+
+  mxArray (const dim_vector& dv);
+
+  mxArray (mwSize m, mwSize n);
+
+  virtual mxArray *dup (void) const
+  {
+    mxArray *new_rep = rep->dup ();
+
+    return new mxArray (new_rep, name);
+  }
+
+  virtual ~mxArray (void);
+
+  virtual bool is_octave_value (void) const { return rep->is_octave_value (); }
+
+  virtual int is_cell (void) const { return rep->is_cell (); }
+
+  virtual int is_char (void) const { return rep->is_char (); }
+
+  virtual int is_class (const char *name_arg) const { return rep->is_class (name_arg); }
+
+  virtual int is_complex (void) const { return rep->is_complex (); }
+
+  virtual int is_double (void) const { return rep->is_double (); }
+
+  virtual int is_function_handle (void) const { return rep->is_function_handle (); }
+
+  virtual int is_int16 (void) const { return rep->is_int16 (); }
+
+  virtual int is_int32 (void) const { return rep->is_int32 (); }
+
+  virtual int is_int64 (void) const { return rep->is_int64 (); }
+
+  virtual int is_int8 (void) const { return rep->is_int8 (); }
+
+  virtual int is_logical (void) const { return rep->is_logical (); }
+
+  virtual int is_numeric (void) const { return rep->is_numeric (); }
+
+  virtual int is_single (void) const { return rep->is_single (); }
+
+  virtual int is_sparse (void) const { return rep->is_sparse (); }
+
+  virtual int is_struct (void) const { return rep->is_struct (); }
+
+  virtual int is_uint16 (void) const { return rep->is_uint16 (); }
+
+  virtual int is_uint32 (void) const { return rep->is_uint32 (); }
+
+  virtual int is_uint64 (void) const { return rep->is_uint64 (); }
+
+  virtual int is_uint8 (void) const { return rep->is_uint8 (); }
+
+  virtual int is_logical_scalar (void) const { return rep->is_logical_scalar (); }
+
+  virtual int is_logical_scalar_true (void) const { return rep->is_logical_scalar_true (); }
+
+  virtual mwSize get_m (void) const { return rep->get_m (); }
+
+  virtual mwSize get_n (void) const { return rep->get_n (); }
+
+  virtual mwSize *get_dimensions (void) const { return rep->get_dimensions (); }
+
+  virtual mwSize get_number_of_dimensions (void) const { return rep->get_number_of_dimensions (); }
+
+  virtual void set_m (mwSize m) { DO_VOID_MUTABLE_METHOD (set_m (m)); }
+
+  virtual void set_n (mwSize n) { DO_VOID_MUTABLE_METHOD (set_n (n)); }
+
+  virtual void set_dimensions (mwSize *dims_arg, mwSize ndims_arg) { DO_VOID_MUTABLE_METHOD (set_dimensions (dims_arg, ndims_arg)); }
+
+  virtual mwSize get_number_of_elements (void) const { return rep->get_number_of_elements (); }
+
+  virtual int is_empty (void) const { return get_number_of_elements () == 0; }
+
+  const char *get_name (void) const { return name; }
+
+  void set_name (const char *name_arg);
+
+  virtual mxClassID get_class_id (void) const { return rep->get_class_id (); }
+
+  virtual const char *get_class_name (void) const { return rep->get_class_name (); }
+
+  virtual void set_class_name (const char *name_arg) { DO_VOID_MUTABLE_METHOD (set_class_name (name_arg)); }
+
+  virtual mxArray *get_cell (mwIndex idx) const { DO_MUTABLE_METHOD (mxArray *, get_cell (idx)); }
+
+  virtual void set_cell (mwIndex idx, mxArray *val) { DO_VOID_MUTABLE_METHOD (set_cell (idx, val)); }
+
+  virtual double get_scalar (void) const { return rep->get_scalar (); }
+
+  virtual void *get_data (void) const { DO_MUTABLE_METHOD (void *, get_data ()); }
+
+  virtual void *get_imag_data (void) const { DO_MUTABLE_METHOD (void *, get_imag_data ()); }
+
+  virtual void set_data (void *pr) { DO_VOID_MUTABLE_METHOD (set_data (pr)); }
+
+  virtual void set_imag_data (void *pi) { DO_VOID_MUTABLE_METHOD (set_imag_data (pi)); }
+
+  virtual mwIndex *get_ir (void) const { DO_MUTABLE_METHOD (mwIndex *, get_ir ()); }
+
+  virtual mwIndex *get_jc (void) const { DO_MUTABLE_METHOD (mwIndex *, get_jc ()); }
+
+  virtual mwSize get_nzmax (void) const { return rep->get_nzmax (); }
+
+  virtual void set_ir (mwIndex *ir) { DO_VOID_MUTABLE_METHOD (set_ir (ir)); }
+
+  virtual void set_jc (mwIndex *jc) { DO_VOID_MUTABLE_METHOD (set_jc (jc)); }
+
+  virtual void set_nzmax (mwSize nzmax) { DO_VOID_MUTABLE_METHOD (set_nzmax (nzmax)); }
+
+  virtual int add_field (const char *key) { DO_MUTABLE_METHOD (int, add_field (key)); }
+
+  virtual void remove_field (int key_num) { DO_VOID_MUTABLE_METHOD (remove_field (key_num)); }
+
+  virtual mxArray *get_field_by_number (mwIndex index, int key_num) const { DO_MUTABLE_METHOD (mxArray *, get_field_by_number (index, key_num)); }
+
+  virtual void set_field_by_number (mwIndex index, int key_num, mxArray *val) { DO_VOID_MUTABLE_METHOD (set_field_by_number (index, key_num, val)); }
+
+  virtual int get_number_of_fields (void) const { return rep->get_number_of_fields (); }
+
+  virtual const char *get_field_name_by_number (int key_num) const { DO_MUTABLE_METHOD (const char*, get_field_name_by_number (key_num)); }
+
+  virtual int get_field_number (const char *key) const { DO_MUTABLE_METHOD (int, get_field_number (key)); }
+
+  virtual int get_string (char *buf, mwSize buflen) const { return rep->get_string (buf, buflen); }
+
+  virtual char *array_to_string (void) const { return rep->array_to_string (); }
+
+  virtual mwIndex calc_single_subscript (mwSize nsubs, mwIndex *subs) const { return rep->calc_single_subscript (nsubs, subs); }
+
+  virtual size_t get_element_size (void) const { return rep->get_element_size (); }
+
+  virtual bool mutation_needed (void) const { return rep->mutation_needed (); }
+
+  virtual mxArray *mutate (void) const { return rep->mutate (); }
+
+  static void *malloc (size_t n);
+
+  static void *calloc (size_t n, size_t t);
+
+  static char *strsave (const char *str)
+  {
+    char *retval = 0;
+
+    if (str)
+      {
+        mwSize sz =  sizeof (mxChar) * (strlen (str) + 1);
+        retval = static_cast<char *> (mxArray::malloc (sz));
+        strcpy (retval, str);
+      }
+
+    return retval;
+  }
+
+  static octave_value as_octave_value (mxArray *ptr);
+
+protected:
+
+  virtual octave_value as_octave_value (void) const;
+
+  mxArray (const xmxArray&) : rep (0), name (0) { }
+
+private:
+
+  mutable mxArray *rep;
+
+  char *name;
+
+  mxArray (mxArray *r, const char *n)
+    : rep (r), name (strsave (n)) { }
+
+  void maybe_mutate (void) const;
+
+  // No copying!
+
+  mxArray (const mxArray&);
+
+  mxArray& operator = (const mxArray&);
+};
+
+#undef DO_MUTABLE_METHOD
+#undef DO_VOID_MUTABLE_METHOD
+
+#endif
+#endif
--- a/src/oct-conf.h.in	Mon May 07 00:53:54 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,571 +0,0 @@
-// oct-conf.h.in
-/*
-
-Copyright (C) 1996-2012 John W. Eaton
-
-This file is part of Octave.
-
-Octave is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 3 of the License, or (at your
-option) any later version.
-
-Octave is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with Octave; see the file COPYING.  If not, see
-<http://www.gnu.org/licenses/>.
-
-*/
-
-#if !defined (octave_conf_h)
-#define octave_conf_h 1
-
-#ifndef OCTAVE_CONF_ALL_CFLAGS
-#define OCTAVE_CONF_ALL_CFLAGS %OCTAVE_CONF_ALL_CFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_ALL_CXXFLAGS
-#define OCTAVE_CONF_ALL_CXXFLAGS %OCTAVE_CONF_ALL_CXXFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_ALL_FFLAGS
-#define OCTAVE_CONF_ALL_FFLAGS %OCTAVE_CONF_ALL_FFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_ALL_LDFLAGS
-#define OCTAVE_CONF_ALL_LDFLAGS %OCTAVE_CONF_ALL_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_AMD_CPPFLAGS
-#define OCTAVE_CONF_AMD_CPPFLAGS %OCTAVE_CONF_AMD_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_AMD_LDFLAGS
-#define OCTAVE_CONF_AMD_LDFLAGS %OCTAVE_CONF_AMD_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_AMD_LIBS
-#define OCTAVE_CONF_AMD_LIBS %OCTAVE_CONF_AMD_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_ARFLAGS
-#define OCTAVE_CONF_ARFLAGS %OCTAVE_CONF_ARFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_AR
-#define OCTAVE_CONF_AR %OCTAVE_CONF_AR%
-#endif
-
-#ifndef OCTAVE_CONF_ARPACK_CPPFLAGS
-#define OCTAVE_CONF_ARPACK_CPPFLAGS %OCTAVE_CONF_ARPACK_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_ARPACK_LDFLAGS
-#define OCTAVE_CONF_ARPACK_LDFLAGS %OCTAVE_CONF_ARPACK_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_ARPACK_LIBS
-#define OCTAVE_CONF_ARPACK_LIBS %OCTAVE_CONF_ARPACK_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_BLAS_LIBS
-#define OCTAVE_CONF_BLAS_LIBS %OCTAVE_CONF_BLAS_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_CAMD_CPPFLAGS
-#define OCTAVE_CONF_CAMD_CPPFLAGS %OCTAVE_CONF_CAMD_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_CAMD_LDFLAGS
-#define OCTAVE_CONF_CAMD_LDFLAGS %OCTAVE_CONF_CAMD_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_CAMD_LIBS
-#define OCTAVE_CONF_CAMD_LIBS %OCTAVE_CONF_CAMD_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_CARBON_LIBS
-#define OCTAVE_CONF_CARBON_LIBS %OCTAVE_CONF_CARBON_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_CC
-#define OCTAVE_CONF_CC %OCTAVE_CONF_CC%
-#endif
-
-#ifndef OCTAVE_CONF_CC_VERSION
-#define OCTAVE_CONF_CC_VERSION %OCTAVE_CONF_CC_VERSION%
-#endif
-
-#ifndef OCTAVE_CONF_CCOLAMD_CPPFLAGS
-#define OCTAVE_CONF_CCOLAMD_CPPFLAGS %OCTAVE_CONF_CCOLAMD_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_CCOLAMD_LDFLAGS
-#define OCTAVE_CONF_CCOLAMD_LDFLAGS %OCTAVE_CONF_CCOLAMD_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_CCOLAMD_LIBS
-#define OCTAVE_CONF_CCOLAMD_LIBS %OCTAVE_CONF_CCOLAMD_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_CFLAGS
-#define OCTAVE_CONF_CFLAGS %OCTAVE_CONF_CFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_CHOLMOD_CPPFLAGS
-#define OCTAVE_CONF_CHOLMOD_CPPFLAGS %OCTAVE_CONF_CHOLMOD_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_CHOLMOD_LDFLAGS
-#define OCTAVE_CONF_CHOLMOD_LDFLAGS %OCTAVE_CONF_CHOLMOD_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_CHOLMOD_LIBS
-#define OCTAVE_CONF_CHOLMOD_LIBS %OCTAVE_CONF_CHOLMOD_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_COLAMD_CPPFLAGS
-#define OCTAVE_CONF_COLAMD_CPPFLAGS %OCTAVE_CONF_COLAMD_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_COLAMD_LDFLAGS
-#define OCTAVE_CONF_COLAMD_LDFLAGS %OCTAVE_CONF_COLAMD_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_COLAMD_LIBS
-#define OCTAVE_CONF_COLAMD_LIBS %OCTAVE_CONF_COLAMD_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_CPICFLAG
-#define OCTAVE_CONF_CPICFLAG %OCTAVE_CONF_CPICFLAG%
-#endif
-
-#ifndef OCTAVE_CONF_CPPFLAGS
-#define OCTAVE_CONF_CPPFLAGS %OCTAVE_CONF_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_CURL_CPPFLAGS
-#define OCTAVE_CONF_CURL_CPPFLAGS %OCTAVE_CONF_CURL_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_CURL_LDFLAGS
-#define OCTAVE_CONF_CURL_LDFLAGS %OCTAVE_CONF_CURL_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_CURL_LIBS
-#define OCTAVE_CONF_CURL_LIBS %OCTAVE_CONF_CURL_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_CXSPARSE_CPPFLAGS
-#define OCTAVE_CONF_CXSPARSE_CPPFLAGS %OCTAVE_CONF_CXSPARSE_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_CXSPARSE_LDFLAGS
-#define OCTAVE_CONF_CXSPARSE_LDFLAGS %OCTAVE_CONF_CXSPARSE_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_CXSPARSE_LIBS
-#define OCTAVE_CONF_CXSPARSE_LIBS %OCTAVE_CONF_CXSPARSE_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_CXXCPP
-#define OCTAVE_CONF_CXXCPP %OCTAVE_CONF_CXXCPP%
-#endif
-
-#ifndef OCTAVE_CONF_CXXFLAGS
-#define OCTAVE_CONF_CXXFLAGS %OCTAVE_CONF_CXXFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_CXXPICFLAG
-#define OCTAVE_CONF_CXXPICFLAG %OCTAVE_CONF_CXXPICFLAG%
-#endif
-
-#ifndef OCTAVE_CONF_CXX
-#define OCTAVE_CONF_CXX %OCTAVE_CONF_CXX%
-#endif
-
-#ifndef OCTAVE_CONF_CXX_VERSION
-#define OCTAVE_CONF_CXX_VERSION %OCTAVE_CONF_CXX_VERSION%
-#endif
-
-#ifndef OCTAVE_CONF_DEFAULT_PAGER
-#define OCTAVE_CONF_DEFAULT_PAGER %OCTAVE_CONF_DEFAULT_PAGER%
-#endif
-
-#ifndef OCTAVE_CONF_DEFS
-#define OCTAVE_CONF_DEFS %OCTAVE_CONF_DEFS%
-#endif
-
-#ifndef OCTAVE_CONF_DL_LD
-#define OCTAVE_CONF_DL_LD %OCTAVE_CONF_DL_LD%
-#endif
-
-#ifndef OCTAVE_CONF_DL_LDFLAGS
-#define OCTAVE_CONF_DL_LDFLAGS %OCTAVE_CONF_DL_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_DL_LIBS
-#define OCTAVE_CONF_DL_LIBS %OCTAVE_CONF_DL_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_EXEEXT
-#define OCTAVE_CONF_EXEEXT %OCTAVE_CONF_EXEEXT%
-#endif
-
-#ifndef OCTAVE_CONF_F77
-#define OCTAVE_CONF_F77 %OCTAVE_CONF_F77%
-#endif
-
-#ifndef OCTAVE_CONF_F77_FLOAT_STORE_FLAG
-#define OCTAVE_CONF_F77_FLOAT_STORE_FLAG %OCTAVE_CONF_F77_FLOAT_STORE_FLAG%
-#endif
-
-#ifndef OCTAVE_CONF_F77_INTEGER_8_FLAG
-#define OCTAVE_CONF_F77_INTEGER_8_FLAG %OCTAVE_CONF_F77_INTEGER_8_FLAG%
-#endif
-
-#ifndef OCTAVE_CONF_FC
-#define OCTAVE_CONF_FC %OCTAVE_CONF_FC%
-#endif
-
-#ifndef OCTAVE_CONF_FFLAGS
-#define OCTAVE_CONF_FFLAGS %OCTAVE_CONF_FFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_FFTW3_CPPFLAGSS
-#define OCTAVE_CONF_FFTW3_CPPFLAGS %OCTAVE_CONF_FFTW3_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_FFTW3_LDFLAGSS
-#define OCTAVE_CONF_FFTW3_LDFLAGS %OCTAVE_CONF_FFTW3_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_FFTW3_LIBS
-#define OCTAVE_CONF_FFTW3_LIBS %OCTAVE_CONF_FFTW3_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_FFTW3F_CPPFLAGSS
-#define OCTAVE_CONF_FFTW3F_CPPFLAGS %OCTAVE_CONF_FFTW3F_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_FFTW3F_LDFLAGSS
-#define OCTAVE_CONF_FFTW3F_LDFLAGS %OCTAVE_CONF_FFTW3F_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_FFTW3F_LIBS
-#define OCTAVE_CONF_FFTW3F_LIBS %OCTAVE_CONF_FFTW3F_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_FLIBS
-#define OCTAVE_CONF_FLIBS %OCTAVE_CONF_FLIBS%
-#endif
-
-#ifndef OCTAVE_CONF_FPICFLAG
-#define OCTAVE_CONF_FPICFLAG %OCTAVE_CONF_FPICFLAG%
-#endif
-
-#ifndef OCTAVE_CONF_FT2_LIBS
-#define OCTAVE_CONF_FT2_LIBS %OCTAVE_CONF_FT2_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_GLPK_CPPFLAGS
-#define OCTAVE_CONF_GLPK_CPPFLAGS %OCTAVE_CONF_GLPK_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_GLPK_LDFLAGS
-#define OCTAVE_CONF_GLPK_LDFLAGS %OCTAVE_CONF_GLPK_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_GLPK_LIBS
-#define OCTAVE_CONF_GLPK_LIBS %OCTAVE_CONF_GLPK_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_GNUPLOT
-#define OCTAVE_CONF_GNUPLOT %OCTAVE_CONF_GNUPLOT%
-#endif
-
-#ifndef OCTAVE_CONF_GRAPHICS_LIBS
-#define OCTAVE_CONF_GRAPHICS_LIBS %OCTAVE_CONF_GRAPHICS_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_HDF5_CPPFLAGS
-#define OCTAVE_CONF_HDF5_CPPFLAGS %OCTAVE_CONF_HDF5_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_HDF5_LDFLAGS
-#define OCTAVE_CONF_HDF5_LDFLAGS %OCTAVE_CONF_HDF5_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_HDF5_LIBS
-#define OCTAVE_CONF_HDF5_LIBS %OCTAVE_CONF_HDF5_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_INCFLAGS
-#define OCTAVE_CONF_INCFLAGS %OCTAVE_CONF_INCFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_INCLUDEDIR
-#define OCTAVE_CONF_INCLUDEDIR %OCTAVE_CONF_INCLUDEDIR%
-#endif
-
-#ifndef OCTAVE_CONF_LAPACK_LIBS
-#define OCTAVE_CONF_LAPACK_LIBS %OCTAVE_CONF_LAPACK_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_LDFLAGS
-#define OCTAVE_CONF_LDFLAGS %OCTAVE_CONF_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_LD_CXX
-#define OCTAVE_CONF_LD_CXX %OCTAVE_CONF_LD_CXX%
-#endif
-
-#ifndef OCTAVE_CONF_LD_STATIC_FLAG
-#define OCTAVE_CONF_LD_STATIC_FLAG %OCTAVE_CONF_LD_STATIC_FLAG%
-#endif
-
-#ifndef OCTAVE_CONF_LEXLIB
-#define OCTAVE_CONF_LEXLIB %OCTAVE_CONF_LEXLIB%
-#endif
-
-#ifndef OCTAVE_CONF_LEX
-#define OCTAVE_CONF_LEX %OCTAVE_CONF_LEX%
-#endif
-
-#ifndef OCTAVE_CONF_LFLAGS
-#define OCTAVE_CONF_LFLAGS %OCTAVE_CONF_LFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_LIBCRUFT
-#define OCTAVE_CONF_LIBCRUFT %OCTAVE_CONF_LIBCRUFT%
-#endif
-
-#ifndef OCTAVE_CONF_LIBEXT
-#define OCTAVE_CONF_LIBEXT %OCTAVE_CONF_LIBEXT%
-#endif
-
-#ifndef OCTAVE_CONF_LIBFLAGS
-#define OCTAVE_CONF_LIBFLAGS %OCTAVE_CONF_LIBFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_LIBOCTAVE
-#define OCTAVE_CONF_LIBOCTAVE %OCTAVE_CONF_LIBOCTAVE%
-#endif
-
-#ifndef OCTAVE_CONF_LIBOCTINTERP
-#define OCTAVE_CONF_LIBOCTINTERP %OCTAVE_CONF_LIBOCTINTERP%
-#endif
-
-#ifndef OCTAVE_CONF_LIBPLPLOT
-#define OCTAVE_CONF_LIBPLPLOT %OCTAVE_CONF_LIBPLPLOT%
-#endif
-
-#ifndef OCTAVE_CONF_LIBS
-#define OCTAVE_CONF_LIBS %OCTAVE_CONF_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_LN_S
-#define OCTAVE_CONF_LN_S %OCTAVE_CONF_LN_S%
-#endif
-
-#ifndef OCTAVE_CONF_MAGICK_CPPFLAGS
-#define OCTAVE_CONF_MAGICK_CPPFLAGS %OCTAVE_CONF_MAGICK_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_MAGICK_LDFLAGS
-#define OCTAVE_CONF_MAGICK_LDFLAGS %OCTAVE_CONF_MAGICK_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_MAGICK_LIBS
-#define OCTAVE_CONF_MAGICK_LIBS %OCTAVE_CONF_MAGICK_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS
-#define OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS %OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_OCTAVE_LINK_DEPS
-#define OCTAVE_CONF_OCTAVE_LINK_DEPS %OCTAVE_CONF_OCTAVE_LINK_DEPS%
-#endif
-
-#ifndef OCTAVE_CONF_OCTAVE_LINK_OPTS
-#define OCTAVE_CONF_OCTAVE_LINK_OPTS %OCTAVE_CONF_OCTAVE_LINK_OPTS%
-#endif
-
-#ifndef OCTAVE_CONF_OCTINCLUDEDIR
-#define OCTAVE_CONF_OCTINCLUDEDIR %OCTAVE_CONF_OCTINCLUDEDIR%
-#endif
-
-#ifndef OCTAVE_CONF_OCTLIBDIR
-#define OCTAVE_CONF_OCTLIBDIR %OCTAVE_CONF_OCTLIBDIR%
-#endif
-
-#ifndef OCTAVE_CONF_OCT_LINK_DEPS
-#define OCTAVE_CONF_OCT_LINK_DEPS %OCTAVE_CONF_OCT_LINK_DEPS%
-#endif
-
-#ifndef OCTAVE_CONF_OCT_LINK_OPTS
-#define OCTAVE_CONF_OCT_LINK_OPTS %OCTAVE_CONF_OCT_LINK_OPTS%
-#endif
-
-#ifndef OCTAVE_CONF_OPENGL_LIBS
-#define OCTAVE_CONF_OPENGL_LIBS %OCTAVE_CONF_OPENGL_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_PREFIX
-#define OCTAVE_CONF_PREFIX %OCTAVE_CONF_PREFIX%
-#endif
-
-#ifndef OCTAVE_CONF_PTHREAD_CFLAGS
-#define OCTAVE_CONF_PTHREAD_CFLAGS %OCTAVE_CONF_PTHREAD_CFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_PTHREAD_LIBS
-#define OCTAVE_CONF_PTHREAD_LIBS %OCTAVE_CONF_PTHREAD_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_QHULL_CPPFLAGS
-#define OCTAVE_CONF_QHULL_CPPFLAGS %OCTAVE_CONF_QHULL_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_QHULL_LDFLAGS
-#define OCTAVE_CONF_QHULL_LDFLAGS %OCTAVE_CONF_QHULL_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_QHULL_LIBS
-#define OCTAVE_CONF_QHULL_LIBS %OCTAVE_CONF_QHULL_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_QRUPDATE_CPPFLAGS
-#define OCTAVE_CONF_QRUPDATE_CPPFLAGS %OCTAVE_CONF_QRUPDATE_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_QRUPDATE_LDFLAGS
-#define OCTAVE_CONF_QRUPDATE_LDFLAGS %OCTAVE_CONF_QRUPDATE_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_QRUPDATE_LIBS
-#define OCTAVE_CONF_QRUPDATE_LIBS %OCTAVE_CONF_QRUPDATE_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_RANLIB
-#define OCTAVE_CONF_RANLIB %OCTAVE_CONF_RANLIB%
-#endif
-
-#ifndef OCTAVE_CONF_RDYNAMIC_FLAG
-#define OCTAVE_CONF_RDYNAMIC_FLAG %OCTAVE_CONF_RDYNAMIC_FLAG%
-#endif
-
-#ifndef OCTAVE_CONF_READLINE_LIBS
-#define OCTAVE_CONF_READLINE_LIBS %OCTAVE_CONF_READLINE_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_REGEX_LIBS
-#define OCTAVE_CONF_REGEX_LIBS %OCTAVE_CONF_REGEX_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_SED
-#define OCTAVE_CONF_SED %OCTAVE_CONF_SED%
-#endif
-
-#ifndef OCTAVE_CONF_SHARED_LIBS
-#define OCTAVE_CONF_SHARED_LIBS %OCTAVE_CONF_SHARED_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_SHLEXT
-#define OCTAVE_CONF_SHLEXT %OCTAVE_CONF_SHLEXT%
-#endif
-
-#ifndef OCTAVE_CONF_SHLEXT_VER
-#define OCTAVE_CONF_SHLEXT_VER %OCTAVE_CONF_SHLEXT_VER%
-#endif
-
-#ifndef OCTAVE_CONF_SH_LD
-#define OCTAVE_CONF_SH_LD %OCTAVE_CONF_SH_LD%
-#endif
-
-#ifndef OCTAVE_CONF_SH_LDFLAGS
-#define OCTAVE_CONF_SH_LDFLAGS %OCTAVE_CONF_SH_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_SONAME_FLAGS
-#define OCTAVE_CONF_SONAME_FLAGS %OCTAVE_CONF_SONAME_FLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_STATIC_LIBS
-#define OCTAVE_CONF_STATIC_LIBS %OCTAVE_CONF_STATIC_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_TERM_LIBS
-#define OCTAVE_CONF_TERM_LIBS %OCTAVE_CONF_TERM_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_UGLY_DEFS
-#define OCTAVE_CONF_UGLY_DEFS %OCTAVE_CONF_UGLY_DEFS%
-#endif
-
-#ifndef OCTAVE_CONF_UMFPACK_CPPFLAGS
-#define OCTAVE_CONF_UMFPACK_CPPFLAGS %OCTAVE_CONF_UMFPACK_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_UMFPACK_LDFLAGS
-#define OCTAVE_CONF_UMFPACK_LDFLAGS %OCTAVE_CONF_UMFPACK_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_UMFPACK_LIBS
-#define OCTAVE_CONF_UMFPACK_LIBS %OCTAVE_CONF_UMFPACK_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_USE_64_BIT_IDX_T
-#define OCTAVE_CONF_USE_64_BIT_IDX_T %OCTAVE_CONF_USE_64_BIT_IDX_T%
-#endif
-
-#ifndef OCTAVE_CONF_ENABLE_DYNAMIC_LINKING
-#define OCTAVE_CONF_ENABLE_DYNAMIC_LINKING %OCTAVE_CONF_ENABLE_DYNAMIC_LINKING%
-#endif
-
-#ifndef OCTAVE_CONF_X11_INCFLAGS
-#define OCTAVE_CONF_X11_INCFLAGS %OCTAVE_CONF_X11_INCFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_X11_LIBS
-#define OCTAVE_CONF_X11_LIBS %OCTAVE_CONF_X11_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_XTRA_CFLAGS
-#define OCTAVE_CONF_XTRA_CFLAGS %OCTAVE_CONF_XTRA_CFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_XTRA_CXXFLAGS
-#define OCTAVE_CONF_XTRA_CXXFLAGS %OCTAVE_CONF_XTRA_CXXFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_YACC
-#define OCTAVE_CONF_YACC %OCTAVE_CONF_YACC%
-#endif
-
-#ifndef OCTAVE_CONF_YFLAGS
-#define OCTAVE_CONF_YFLAGS %OCTAVE_CONF_YFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_Z_CPPFLAGS
-#define OCTAVE_CONF_Z_CPPFLAGS %OCTAVE_CONF_Z_CPPFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_Z_LDFLAGS
-#define OCTAVE_CONF_Z_LDFLAGS %OCTAVE_CONF_Z_LDFLAGS%
-#endif
-
-#ifndef OCTAVE_CONF_Z_LIBS
-#define OCTAVE_CONF_Z_LIBS %OCTAVE_CONF_Z_LIBS%
-#endif
-
-#ifndef OCTAVE_CONF_config_opts
-#define OCTAVE_CONF_config_opts %OCTAVE_CONF_config_opts%
-#endif
-
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/oct-conf.in.h	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,571 @@
+// oct-conf.h.in
+/*
+
+Copyright (C) 1996-2012 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+#if !defined (octave_conf_h)
+#define octave_conf_h 1
+
+#ifndef OCTAVE_CONF_ALL_CFLAGS
+#define OCTAVE_CONF_ALL_CFLAGS %OCTAVE_CONF_ALL_CFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_ALL_CXXFLAGS
+#define OCTAVE_CONF_ALL_CXXFLAGS %OCTAVE_CONF_ALL_CXXFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_ALL_FFLAGS
+#define OCTAVE_CONF_ALL_FFLAGS %OCTAVE_CONF_ALL_FFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_ALL_LDFLAGS
+#define OCTAVE_CONF_ALL_LDFLAGS %OCTAVE_CONF_ALL_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_AMD_CPPFLAGS
+#define OCTAVE_CONF_AMD_CPPFLAGS %OCTAVE_CONF_AMD_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_AMD_LDFLAGS
+#define OCTAVE_CONF_AMD_LDFLAGS %OCTAVE_CONF_AMD_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_AMD_LIBS
+#define OCTAVE_CONF_AMD_LIBS %OCTAVE_CONF_AMD_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_ARFLAGS
+#define OCTAVE_CONF_ARFLAGS %OCTAVE_CONF_ARFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_AR
+#define OCTAVE_CONF_AR %OCTAVE_CONF_AR%
+#endif
+
+#ifndef OCTAVE_CONF_ARPACK_CPPFLAGS
+#define OCTAVE_CONF_ARPACK_CPPFLAGS %OCTAVE_CONF_ARPACK_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_ARPACK_LDFLAGS
+#define OCTAVE_CONF_ARPACK_LDFLAGS %OCTAVE_CONF_ARPACK_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_ARPACK_LIBS
+#define OCTAVE_CONF_ARPACK_LIBS %OCTAVE_CONF_ARPACK_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_BLAS_LIBS
+#define OCTAVE_CONF_BLAS_LIBS %OCTAVE_CONF_BLAS_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_CAMD_CPPFLAGS
+#define OCTAVE_CONF_CAMD_CPPFLAGS %OCTAVE_CONF_CAMD_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_CAMD_LDFLAGS
+#define OCTAVE_CONF_CAMD_LDFLAGS %OCTAVE_CONF_CAMD_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_CAMD_LIBS
+#define OCTAVE_CONF_CAMD_LIBS %OCTAVE_CONF_CAMD_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_CARBON_LIBS
+#define OCTAVE_CONF_CARBON_LIBS %OCTAVE_CONF_CARBON_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_CC
+#define OCTAVE_CONF_CC %OCTAVE_CONF_CC%
+#endif
+
+#ifndef OCTAVE_CONF_CC_VERSION
+#define OCTAVE_CONF_CC_VERSION %OCTAVE_CONF_CC_VERSION%
+#endif
+
+#ifndef OCTAVE_CONF_CCOLAMD_CPPFLAGS
+#define OCTAVE_CONF_CCOLAMD_CPPFLAGS %OCTAVE_CONF_CCOLAMD_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_CCOLAMD_LDFLAGS
+#define OCTAVE_CONF_CCOLAMD_LDFLAGS %OCTAVE_CONF_CCOLAMD_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_CCOLAMD_LIBS
+#define OCTAVE_CONF_CCOLAMD_LIBS %OCTAVE_CONF_CCOLAMD_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_CFLAGS
+#define OCTAVE_CONF_CFLAGS %OCTAVE_CONF_CFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_CHOLMOD_CPPFLAGS
+#define OCTAVE_CONF_CHOLMOD_CPPFLAGS %OCTAVE_CONF_CHOLMOD_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_CHOLMOD_LDFLAGS
+#define OCTAVE_CONF_CHOLMOD_LDFLAGS %OCTAVE_CONF_CHOLMOD_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_CHOLMOD_LIBS
+#define OCTAVE_CONF_CHOLMOD_LIBS %OCTAVE_CONF_CHOLMOD_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_COLAMD_CPPFLAGS
+#define OCTAVE_CONF_COLAMD_CPPFLAGS %OCTAVE_CONF_COLAMD_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_COLAMD_LDFLAGS
+#define OCTAVE_CONF_COLAMD_LDFLAGS %OCTAVE_CONF_COLAMD_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_COLAMD_LIBS
+#define OCTAVE_CONF_COLAMD_LIBS %OCTAVE_CONF_COLAMD_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_CPICFLAG
+#define OCTAVE_CONF_CPICFLAG %OCTAVE_CONF_CPICFLAG%
+#endif
+
+#ifndef OCTAVE_CONF_CPPFLAGS
+#define OCTAVE_CONF_CPPFLAGS %OCTAVE_CONF_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_CURL_CPPFLAGS
+#define OCTAVE_CONF_CURL_CPPFLAGS %OCTAVE_CONF_CURL_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_CURL_LDFLAGS
+#define OCTAVE_CONF_CURL_LDFLAGS %OCTAVE_CONF_CURL_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_CURL_LIBS
+#define OCTAVE_CONF_CURL_LIBS %OCTAVE_CONF_CURL_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_CXSPARSE_CPPFLAGS
+#define OCTAVE_CONF_CXSPARSE_CPPFLAGS %OCTAVE_CONF_CXSPARSE_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_CXSPARSE_LDFLAGS
+#define OCTAVE_CONF_CXSPARSE_LDFLAGS %OCTAVE_CONF_CXSPARSE_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_CXSPARSE_LIBS
+#define OCTAVE_CONF_CXSPARSE_LIBS %OCTAVE_CONF_CXSPARSE_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_CXXCPP
+#define OCTAVE_CONF_CXXCPP %OCTAVE_CONF_CXXCPP%
+#endif
+
+#ifndef OCTAVE_CONF_CXXFLAGS
+#define OCTAVE_CONF_CXXFLAGS %OCTAVE_CONF_CXXFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_CXXPICFLAG
+#define OCTAVE_CONF_CXXPICFLAG %OCTAVE_CONF_CXXPICFLAG%
+#endif
+
+#ifndef OCTAVE_CONF_CXX
+#define OCTAVE_CONF_CXX %OCTAVE_CONF_CXX%
+#endif
+
+#ifndef OCTAVE_CONF_CXX_VERSION
+#define OCTAVE_CONF_CXX_VERSION %OCTAVE_CONF_CXX_VERSION%
+#endif
+
+#ifndef OCTAVE_CONF_DEFAULT_PAGER
+#define OCTAVE_CONF_DEFAULT_PAGER %OCTAVE_CONF_DEFAULT_PAGER%
+#endif
+
+#ifndef OCTAVE_CONF_DEFS
+#define OCTAVE_CONF_DEFS %OCTAVE_CONF_DEFS%
+#endif
+
+#ifndef OCTAVE_CONF_DL_LD
+#define OCTAVE_CONF_DL_LD %OCTAVE_CONF_DL_LD%
+#endif
+
+#ifndef OCTAVE_CONF_DL_LDFLAGS
+#define OCTAVE_CONF_DL_LDFLAGS %OCTAVE_CONF_DL_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_DL_LIBS
+#define OCTAVE_CONF_DL_LIBS %OCTAVE_CONF_DL_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_EXEEXT
+#define OCTAVE_CONF_EXEEXT %OCTAVE_CONF_EXEEXT%
+#endif
+
+#ifndef OCTAVE_CONF_F77
+#define OCTAVE_CONF_F77 %OCTAVE_CONF_F77%
+#endif
+
+#ifndef OCTAVE_CONF_F77_FLOAT_STORE_FLAG
+#define OCTAVE_CONF_F77_FLOAT_STORE_FLAG %OCTAVE_CONF_F77_FLOAT_STORE_FLAG%
+#endif
+
+#ifndef OCTAVE_CONF_F77_INTEGER_8_FLAG
+#define OCTAVE_CONF_F77_INTEGER_8_FLAG %OCTAVE_CONF_F77_INTEGER_8_FLAG%
+#endif
+
+#ifndef OCTAVE_CONF_FC
+#define OCTAVE_CONF_FC %OCTAVE_CONF_FC%
+#endif
+
+#ifndef OCTAVE_CONF_FFLAGS
+#define OCTAVE_CONF_FFLAGS %OCTAVE_CONF_FFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_FFTW3_CPPFLAGSS
+#define OCTAVE_CONF_FFTW3_CPPFLAGS %OCTAVE_CONF_FFTW3_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_FFTW3_LDFLAGSS
+#define OCTAVE_CONF_FFTW3_LDFLAGS %OCTAVE_CONF_FFTW3_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_FFTW3_LIBS
+#define OCTAVE_CONF_FFTW3_LIBS %OCTAVE_CONF_FFTW3_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_FFTW3F_CPPFLAGSS
+#define OCTAVE_CONF_FFTW3F_CPPFLAGS %OCTAVE_CONF_FFTW3F_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_FFTW3F_LDFLAGSS
+#define OCTAVE_CONF_FFTW3F_LDFLAGS %OCTAVE_CONF_FFTW3F_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_FFTW3F_LIBS
+#define OCTAVE_CONF_FFTW3F_LIBS %OCTAVE_CONF_FFTW3F_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_FLIBS
+#define OCTAVE_CONF_FLIBS %OCTAVE_CONF_FLIBS%
+#endif
+
+#ifndef OCTAVE_CONF_FPICFLAG
+#define OCTAVE_CONF_FPICFLAG %OCTAVE_CONF_FPICFLAG%
+#endif
+
+#ifndef OCTAVE_CONF_FT2_LIBS
+#define OCTAVE_CONF_FT2_LIBS %OCTAVE_CONF_FT2_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_GLPK_CPPFLAGS
+#define OCTAVE_CONF_GLPK_CPPFLAGS %OCTAVE_CONF_GLPK_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_GLPK_LDFLAGS
+#define OCTAVE_CONF_GLPK_LDFLAGS %OCTAVE_CONF_GLPK_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_GLPK_LIBS
+#define OCTAVE_CONF_GLPK_LIBS %OCTAVE_CONF_GLPK_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_GNUPLOT
+#define OCTAVE_CONF_GNUPLOT %OCTAVE_CONF_GNUPLOT%
+#endif
+
+#ifndef OCTAVE_CONF_GRAPHICS_LIBS
+#define OCTAVE_CONF_GRAPHICS_LIBS %OCTAVE_CONF_GRAPHICS_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_HDF5_CPPFLAGS
+#define OCTAVE_CONF_HDF5_CPPFLAGS %OCTAVE_CONF_HDF5_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_HDF5_LDFLAGS
+#define OCTAVE_CONF_HDF5_LDFLAGS %OCTAVE_CONF_HDF5_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_HDF5_LIBS
+#define OCTAVE_CONF_HDF5_LIBS %OCTAVE_CONF_HDF5_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_INCFLAGS
+#define OCTAVE_CONF_INCFLAGS %OCTAVE_CONF_INCFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_INCLUDEDIR
+#define OCTAVE_CONF_INCLUDEDIR %OCTAVE_CONF_INCLUDEDIR%
+#endif
+
+#ifndef OCTAVE_CONF_LAPACK_LIBS
+#define OCTAVE_CONF_LAPACK_LIBS %OCTAVE_CONF_LAPACK_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_LDFLAGS
+#define OCTAVE_CONF_LDFLAGS %OCTAVE_CONF_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_LD_CXX
+#define OCTAVE_CONF_LD_CXX %OCTAVE_CONF_LD_CXX%
+#endif
+
+#ifndef OCTAVE_CONF_LD_STATIC_FLAG
+#define OCTAVE_CONF_LD_STATIC_FLAG %OCTAVE_CONF_LD_STATIC_FLAG%
+#endif
+
+#ifndef OCTAVE_CONF_LEXLIB
+#define OCTAVE_CONF_LEXLIB %OCTAVE_CONF_LEXLIB%
+#endif
+
+#ifndef OCTAVE_CONF_LEX
+#define OCTAVE_CONF_LEX %OCTAVE_CONF_LEX%
+#endif
+
+#ifndef OCTAVE_CONF_LFLAGS
+#define OCTAVE_CONF_LFLAGS %OCTAVE_CONF_LFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_LIBCRUFT
+#define OCTAVE_CONF_LIBCRUFT %OCTAVE_CONF_LIBCRUFT%
+#endif
+
+#ifndef OCTAVE_CONF_LIBEXT
+#define OCTAVE_CONF_LIBEXT %OCTAVE_CONF_LIBEXT%
+#endif
+
+#ifndef OCTAVE_CONF_LIBFLAGS
+#define OCTAVE_CONF_LIBFLAGS %OCTAVE_CONF_LIBFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_LIBOCTAVE
+#define OCTAVE_CONF_LIBOCTAVE %OCTAVE_CONF_LIBOCTAVE%
+#endif
+
+#ifndef OCTAVE_CONF_LIBOCTINTERP
+#define OCTAVE_CONF_LIBOCTINTERP %OCTAVE_CONF_LIBOCTINTERP%
+#endif
+
+#ifndef OCTAVE_CONF_LIBPLPLOT
+#define OCTAVE_CONF_LIBPLPLOT %OCTAVE_CONF_LIBPLPLOT%
+#endif
+
+#ifndef OCTAVE_CONF_LIBS
+#define OCTAVE_CONF_LIBS %OCTAVE_CONF_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_LN_S
+#define OCTAVE_CONF_LN_S %OCTAVE_CONF_LN_S%
+#endif
+
+#ifndef OCTAVE_CONF_MAGICK_CPPFLAGS
+#define OCTAVE_CONF_MAGICK_CPPFLAGS %OCTAVE_CONF_MAGICK_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_MAGICK_LDFLAGS
+#define OCTAVE_CONF_MAGICK_LDFLAGS %OCTAVE_CONF_MAGICK_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_MAGICK_LIBS
+#define OCTAVE_CONF_MAGICK_LIBS %OCTAVE_CONF_MAGICK_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS
+#define OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS %OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_OCTAVE_LINK_DEPS
+#define OCTAVE_CONF_OCTAVE_LINK_DEPS %OCTAVE_CONF_OCTAVE_LINK_DEPS%
+#endif
+
+#ifndef OCTAVE_CONF_OCTAVE_LINK_OPTS
+#define OCTAVE_CONF_OCTAVE_LINK_OPTS %OCTAVE_CONF_OCTAVE_LINK_OPTS%
+#endif
+
+#ifndef OCTAVE_CONF_OCTINCLUDEDIR
+#define OCTAVE_CONF_OCTINCLUDEDIR %OCTAVE_CONF_OCTINCLUDEDIR%
+#endif
+
+#ifndef OCTAVE_CONF_OCTLIBDIR
+#define OCTAVE_CONF_OCTLIBDIR %OCTAVE_CONF_OCTLIBDIR%
+#endif
+
+#ifndef OCTAVE_CONF_OCT_LINK_DEPS
+#define OCTAVE_CONF_OCT_LINK_DEPS %OCTAVE_CONF_OCT_LINK_DEPS%
+#endif
+
+#ifndef OCTAVE_CONF_OCT_LINK_OPTS
+#define OCTAVE_CONF_OCT_LINK_OPTS %OCTAVE_CONF_OCT_LINK_OPTS%
+#endif
+
+#ifndef OCTAVE_CONF_OPENGL_LIBS
+#define OCTAVE_CONF_OPENGL_LIBS %OCTAVE_CONF_OPENGL_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_PREFIX
+#define OCTAVE_CONF_PREFIX %OCTAVE_CONF_PREFIX%
+#endif
+
+#ifndef OCTAVE_CONF_PTHREAD_CFLAGS
+#define OCTAVE_CONF_PTHREAD_CFLAGS %OCTAVE_CONF_PTHREAD_CFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_PTHREAD_LIBS
+#define OCTAVE_CONF_PTHREAD_LIBS %OCTAVE_CONF_PTHREAD_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_QHULL_CPPFLAGS
+#define OCTAVE_CONF_QHULL_CPPFLAGS %OCTAVE_CONF_QHULL_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_QHULL_LDFLAGS
+#define OCTAVE_CONF_QHULL_LDFLAGS %OCTAVE_CONF_QHULL_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_QHULL_LIBS
+#define OCTAVE_CONF_QHULL_LIBS %OCTAVE_CONF_QHULL_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_QRUPDATE_CPPFLAGS
+#define OCTAVE_CONF_QRUPDATE_CPPFLAGS %OCTAVE_CONF_QRUPDATE_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_QRUPDATE_LDFLAGS
+#define OCTAVE_CONF_QRUPDATE_LDFLAGS %OCTAVE_CONF_QRUPDATE_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_QRUPDATE_LIBS
+#define OCTAVE_CONF_QRUPDATE_LIBS %OCTAVE_CONF_QRUPDATE_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_RANLIB
+#define OCTAVE_CONF_RANLIB %OCTAVE_CONF_RANLIB%
+#endif
+
+#ifndef OCTAVE_CONF_RDYNAMIC_FLAG
+#define OCTAVE_CONF_RDYNAMIC_FLAG %OCTAVE_CONF_RDYNAMIC_FLAG%
+#endif
+
+#ifndef OCTAVE_CONF_READLINE_LIBS
+#define OCTAVE_CONF_READLINE_LIBS %OCTAVE_CONF_READLINE_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_REGEX_LIBS
+#define OCTAVE_CONF_REGEX_LIBS %OCTAVE_CONF_REGEX_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_SED
+#define OCTAVE_CONF_SED %OCTAVE_CONF_SED%
+#endif
+
+#ifndef OCTAVE_CONF_SHARED_LIBS
+#define OCTAVE_CONF_SHARED_LIBS %OCTAVE_CONF_SHARED_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_SHLEXT
+#define OCTAVE_CONF_SHLEXT %OCTAVE_CONF_SHLEXT%
+#endif
+
+#ifndef OCTAVE_CONF_SHLEXT_VER
+#define OCTAVE_CONF_SHLEXT_VER %OCTAVE_CONF_SHLEXT_VER%
+#endif
+
+#ifndef OCTAVE_CONF_SH_LD
+#define OCTAVE_CONF_SH_LD %OCTAVE_CONF_SH_LD%
+#endif
+
+#ifndef OCTAVE_CONF_SH_LDFLAGS
+#define OCTAVE_CONF_SH_LDFLAGS %OCTAVE_CONF_SH_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_SONAME_FLAGS
+#define OCTAVE_CONF_SONAME_FLAGS %OCTAVE_CONF_SONAME_FLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_STATIC_LIBS
+#define OCTAVE_CONF_STATIC_LIBS %OCTAVE_CONF_STATIC_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_TERM_LIBS
+#define OCTAVE_CONF_TERM_LIBS %OCTAVE_CONF_TERM_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_UGLY_DEFS
+#define OCTAVE_CONF_UGLY_DEFS %OCTAVE_CONF_UGLY_DEFS%
+#endif
+
+#ifndef OCTAVE_CONF_UMFPACK_CPPFLAGS
+#define OCTAVE_CONF_UMFPACK_CPPFLAGS %OCTAVE_CONF_UMFPACK_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_UMFPACK_LDFLAGS
+#define OCTAVE_CONF_UMFPACK_LDFLAGS %OCTAVE_CONF_UMFPACK_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_UMFPACK_LIBS
+#define OCTAVE_CONF_UMFPACK_LIBS %OCTAVE_CONF_UMFPACK_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_USE_64_BIT_IDX_T
+#define OCTAVE_CONF_USE_64_BIT_IDX_T %OCTAVE_CONF_USE_64_BIT_IDX_T%
+#endif
+
+#ifndef OCTAVE_CONF_ENABLE_DYNAMIC_LINKING
+#define OCTAVE_CONF_ENABLE_DYNAMIC_LINKING %OCTAVE_CONF_ENABLE_DYNAMIC_LINKING%
+#endif
+
+#ifndef OCTAVE_CONF_X11_INCFLAGS
+#define OCTAVE_CONF_X11_INCFLAGS %OCTAVE_CONF_X11_INCFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_X11_LIBS
+#define OCTAVE_CONF_X11_LIBS %OCTAVE_CONF_X11_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_XTRA_CFLAGS
+#define OCTAVE_CONF_XTRA_CFLAGS %OCTAVE_CONF_XTRA_CFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_XTRA_CXXFLAGS
+#define OCTAVE_CONF_XTRA_CXXFLAGS %OCTAVE_CONF_XTRA_CXXFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_YACC
+#define OCTAVE_CONF_YACC %OCTAVE_CONF_YACC%
+#endif
+
+#ifndef OCTAVE_CONF_YFLAGS
+#define OCTAVE_CONF_YFLAGS %OCTAVE_CONF_YFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_Z_CPPFLAGS
+#define OCTAVE_CONF_Z_CPPFLAGS %OCTAVE_CONF_Z_CPPFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_Z_LDFLAGS
+#define OCTAVE_CONF_Z_LDFLAGS %OCTAVE_CONF_Z_LDFLAGS%
+#endif
+
+#ifndef OCTAVE_CONF_Z_LIBS
+#define OCTAVE_CONF_Z_LIBS %OCTAVE_CONF_Z_LIBS%
+#endif
+
+#ifndef OCTAVE_CONF_config_opts
+#define OCTAVE_CONF_config_opts %OCTAVE_CONF_config_opts%
+#endif
+
+#endif
--- a/src/oct-errno.cc.in	Mon May 07 00:53:54 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,345 +0,0 @@
-// oct-errno.cc.in
-/*
-
-Copyright (C) 2005-2012 John W. Eaton
-
-This file is part of Octave.
-
-Octave is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 3 of the License, or (at your
-option) any later version.
-
-Octave is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with Octave; see the file COPYING.  If not, see
-<http://www.gnu.org/licenses/>.
-
-*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <cerrno>
-
-#include "singleton-cleanup.h"
-
-#include "oct-errno.h"
-#include "oct-map.h"
-#include "error.h"
-
-octave_errno *octave_errno::instance = 0;
-
-octave_errno::octave_errno (void)
-{
-  struct errno_struct
-  {
-    const char *name;
-    int value;
-  };
-
-  static errno_struct errno_codes[] =
-  {
-    // POSIX.
-
-#if defined (E2BIG)
-    { "E2BIG", E2BIG, },
-#endif
-#if defined (EACCES)
-    { "EACCES", EACCES, },
-#endif
-#if defined (EADDRINUSE)
-    { "EADDRINUSE", EADDRINUSE, },
-#endif
-#if defined (EADDRNOTAVAIL)
-    { "EADDRNOTAVAIL", EADDRNOTAVAIL, },
-#endif
-#if defined (EAFNOSUPPORT)
-    { "EAFNOSUPPORT", EAFNOSUPPORT, },
-#endif
-#if defined (EAGAIN)
-    { "EAGAIN", EAGAIN, },
-#endif
-#if defined (EALREADY)
-    { "EALREADY", EALREADY, },
-#endif
-#if defined (EBADF)
-    { "EBADF", EBADF, },
-#endif
-#if defined (EBUSY)
-    { "EBUSY", EBUSY, },
-#endif
-#if defined (ECHILD)
-    { "ECHILD", ECHILD, },
-#endif
-#if defined (ECONNABORTED)
-    { "ECONNABORTED", ECONNABORTED, },
-#endif
-#if defined (ECONNREFUSED)
-    { "ECONNREFUSED", ECONNREFUSED, },
-#endif
-#if defined (ECONNRESET)
-    { "ECONNRESET", ECONNRESET, },
-#endif
-#if defined (EDEADLK)
-    { "EDEADLK", EDEADLK, },
-#endif
-#if defined (EDESTADDRREQ)
-    { "EDESTADDRREQ", EDESTADDRREQ, },
-#endif
-#if defined (EDOM)
-    { "EDOM", EDOM, },
-#endif
-#if defined (EDQUOT)
-    { "EDQUOT", EDQUOT, },
-#endif
-#if defined (EEXIST)
-    { "EEXIST", EEXIST, },
-#endif
-#if defined (EFAULT)
-    { "EFAULT", EFAULT, },
-#endif
-#if defined (EFBIG)
-    { "EFBIG", EFBIG, },
-#endif
-#if defined (EHOSTDOWN)
-    { "EHOSTDOWN", EHOSTDOWN, },
-#endif
-#if defined (EHOSTUNREACH)
-    { "EHOSTUNREACH", EHOSTUNREACH, },
-#endif
-#if defined (EINPROGRESS)
-    { "EINPROGRESS", EINPROGRESS, },
-#endif
-#if defined (EINTR)
-    { "EINTR", EINTR, },
-#endif
-#if defined (EINVAL)
-    { "EINVAL", EINVAL, },
-#endif
-#if defined (EIO)
-    { "EIO", EIO, },
-#endif
-#if defined (EISCONN)
-    { "EISCONN", EISCONN, },
-#endif
-#if defined (EISDIR)
-    { "EISDIR", EISDIR, },
-#endif
-#if defined (ELOOP)
-    { "ELOOP", ELOOP, },
-#endif
-#if defined (EMFILE)
-    { "EMFILE", EMFILE, },
-#endif
-#if defined (EMLINK)
-    { "EMLINK", EMLINK, },
-#endif
-#if defined (EMSGSIZE)
-    { "EMSGSIZE", EMSGSIZE, },
-#endif
-#if defined (ENAMETOOLONG)
-    { "ENAMETOOLONG", ENAMETOOLONG, },
-#endif
-#if defined (ENETDOWN)
-    { "ENETDOWN", ENETDOWN, },
-#endif
-#if defined (ENETRESET)
-    { "ENETRESET", ENETRESET, },
-#endif
-#if defined (ENETUNREACH)
-    { "ENETUNREACH", ENETUNREACH, },
-#endif
-#if defined (ENFILE)
-    { "ENFILE", ENFILE, },
-#endif
-#if defined (ENOBUFS)
-    { "ENOBUFS", ENOBUFS, },
-#endif
-#if defined (ENODEV)
-    { "ENODEV", ENODEV, },
-#endif
-#if defined (ENOENT)
-    { "ENOENT", ENOENT, },
-#endif
-#if defined (ENOEXEC)
-    { "ENOEXEC", ENOEXEC, },
-#endif
-#if defined (ENOLCK)
-    { "ENOLCK", ENOLCK, },
-#endif
-#if defined (ENOMEM)
-    { "ENOMEM", ENOMEM, },
-#endif
-#if defined (ENOPROTOOPT)
-    { "ENOPROTOOPT", ENOPROTOOPT, },
-#endif
-#if defined (ENOSPC)
-    { "ENOSPC", ENOSPC, },
-#endif
-#if defined (ENOSYS)
-    { "ENOSYS", ENOSYS, },
-#endif
-#if defined (ENOTBLK)
-    { "ENOTBLK", ENOTBLK, },
-#endif
-#if defined (ENOTCONN)
-    { "ENOTCONN", ENOTCONN, },
-#endif
-#if defined (ENOTDIR)
-    { "ENOTDIR", ENOTDIR, },
-#endif
-#if defined (ENOTEMPTY)
-    { "ENOTEMPTY", ENOTEMPTY, },
-#endif
-#if defined (ENOTSOCK)
-    { "ENOTSOCK", ENOTSOCK, },
-#endif
-#if defined (ENOTTY)
-    { "ENOTTY", ENOTTY, },
-#endif
-#if defined (ENXIO)
-    { "ENXIO", ENXIO, },
-#endif
-#if defined (EOPNOTSUPP)
-    { "EOPNOTSUPP", EOPNOTSUPP, },
-#endif
-#if defined (EPERM)
-    { "EPERM", EPERM, },
-#endif
-#if defined (EPFNOSUPPORT)
-    { "EPFNOSUPPORT", EPFNOSUPPORT, },
-#endif
-#if defined (EPIPE)
-    { "EPIPE", EPIPE, },
-#endif
-#if defined (EPROTONOSUPPORT)
-    { "EPROTONOSUPPORT", EPROTONOSUPPORT, },
-#endif
-#if defined (EPROTOTYPE)
-    { "EPROTOTYPE", EPROTOTYPE, },
-#endif
-#if defined (ERANGE)
-    { "ERANGE", ERANGE, },
-#endif
-#if defined (EREMOTE)
-    { "EREMOTE", EREMOTE, },
-#endif
-#if defined (ERESTART)
-    { "ERESTART", ERESTART, },
-#endif
-#if defined (EROFS)
-    { "EROFS", EROFS, },
-#endif
-#if defined (ESHUTDOWN)
-    { "ESHUTDOWN", ESHUTDOWN, },
-#endif
-#if defined (ESOCKTNOSUPPORT)
-    { "ESOCKTNOSUPPORT", ESOCKTNOSUPPORT, },
-#endif
-#if defined (ESPIPE)
-    { "ESPIPE", ESPIPE, },
-#endif
-#if defined (ESRCH)
-    { "ESRCH", ESRCH, },
-#endif
-#if defined (ESTALE)
-    { "ESTALE", ESTALE, },
-#endif
-#if defined (ETIMEDOUT)
-    { "ETIMEDOUT", ETIMEDOUT, },
-#endif
-#if defined (ETOOMANYREFS)
-    { "ETOOMANYREFS", ETOOMANYREFS, },
-#endif
-#if defined (ETXTBSY)
-    { "ETXTBSY", ETXTBSY, },
-#endif
-#if defined (EUSERS)
-    { "EUSERS", EUSERS, },
-#endif
-#if defined (EWOULDBLOCK)
-    { "EWOULDBLOCK", EWOULDBLOCK, },
-#endif
-#if defined (EXDEV)
-    { "EXDEV", EXDEV, },
-#endif
-
-    // Others (duplicates are OK).
-
-@SYSDEP_ERRNO_LIST@
-
-    { 0, 0, },
-  };
-
-  // Stuff them all in a map for fast access.
-
-  errno_struct *ptr = errno_codes;
-
-  while (ptr->name)
-    {
-      errno_tbl[ptr->name] = ptr->value;
-      ptr++;
-    }
-}
-
-bool
-octave_errno::instance_ok (void)
-{
-  bool retval = true;
-
-  if (! instance)
-    {
-      instance = new octave_errno ();
-
-      if (instance)
-        singleton_cleanup_list::add (cleanup_instance);
-    }
-
-  if (! instance)
-    {
-      ::error ("unable to create errno object!");
-
-      retval = false;
-    }
-
-  return retval;
-}
-
-int
-octave_errno::lookup (const std::string& name)
-{
-  return (instance_ok ()) ? instance->do_lookup (name) : -1;
-}
-
-octave_scalar_map
-octave_errno::list (void)
-{
-  return (instance_ok ()) ? instance->do_list () : octave_scalar_map ();
-}
-
-int
-octave_errno::do_lookup (const std::string& name)
-{
-  return (errno_tbl.find (name) != errno_tbl.end ()) ? errno_tbl[name] : -1;
-}
-
-octave_scalar_map
-octave_errno::do_list (void)
-{
-  octave_scalar_map retval;
-
-  for (std::map<std::string, int>::const_iterator p = errno_tbl.begin ();
-       p != errno_tbl.end ();
-       p++)
-    {
-      retval.assign (p->first, p->second);
-    }
-
-  return retval;
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/oct-errno.in.cc	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,345 @@
+// oct-errno.cc.in
+/*
+
+Copyright (C) 2005-2012 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cerrno>
+
+#include "singleton-cleanup.h"
+
+#include "oct-errno.h"
+#include "oct-map.h"
+#include "error.h"
+
+octave_errno *octave_errno::instance = 0;
+
+octave_errno::octave_errno (void)
+{
+  struct errno_struct
+  {
+    const char *name;
+    int value;
+  };
+
+  static errno_struct errno_codes[] =
+  {
+    // POSIX.
+
+#if defined (E2BIG)
+    { "E2BIG", E2BIG, },
+#endif
+#if defined (EACCES)
+    { "EACCES", EACCES, },
+#endif
+#if defined (EADDRINUSE)
+    { "EADDRINUSE", EADDRINUSE, },
+#endif
+#if defined (EADDRNOTAVAIL)
+    { "EADDRNOTAVAIL", EADDRNOTAVAIL, },
+#endif
+#if defined (EAFNOSUPPORT)
+    { "EAFNOSUPPORT", EAFNOSUPPORT, },
+#endif
+#if defined (EAGAIN)
+    { "EAGAIN", EAGAIN, },
+#endif
+#if defined (EALREADY)
+    { "EALREADY", EALREADY, },
+#endif
+#if defined (EBADF)
+    { "EBADF", EBADF, },
+#endif
+#if defined (EBUSY)
+    { "EBUSY", EBUSY, },
+#endif
+#if defined (ECHILD)
+    { "ECHILD", ECHILD, },
+#endif
+#if defined (ECONNABORTED)
+    { "ECONNABORTED", ECONNABORTED, },
+#endif
+#if defined (ECONNREFUSED)
+    { "ECONNREFUSED", ECONNREFUSED, },
+#endif
+#if defined (ECONNRESET)
+    { "ECONNRESET", ECONNRESET, },
+#endif
+#if defined (EDEADLK)
+    { "EDEADLK", EDEADLK, },
+#endif
+#if defined (EDESTADDRREQ)
+    { "EDESTADDRREQ", EDESTADDRREQ, },
+#endif
+#if defined (EDOM)
+    { "EDOM", EDOM, },
+#endif
+#if defined (EDQUOT)
+    { "EDQUOT", EDQUOT, },
+#endif
+#if defined (EEXIST)
+    { "EEXIST", EEXIST, },
+#endif
+#if defined (EFAULT)
+    { "EFAULT", EFAULT, },
+#endif
+#if defined (EFBIG)
+    { "EFBIG", EFBIG, },
+#endif
+#if defined (EHOSTDOWN)
+    { "EHOSTDOWN", EHOSTDOWN, },
+#endif
+#if defined (EHOSTUNREACH)
+    { "EHOSTUNREACH", EHOSTUNREACH, },
+#endif
+#if defined (EINPROGRESS)
+    { "EINPROGRESS", EINPROGRESS, },
+#endif
+#if defined (EINTR)
+    { "EINTR", EINTR, },
+#endif
+#if defined (EINVAL)
+    { "EINVAL", EINVAL, },
+#endif
+#if defined (EIO)
+    { "EIO", EIO, },
+#endif
+#if defined (EISCONN)
+    { "EISCONN", EISCONN, },
+#endif
+#if defined (EISDIR)
+    { "EISDIR", EISDIR, },
+#endif
+#if defined (ELOOP)
+    { "ELOOP", ELOOP, },
+#endif
+#if defined (EMFILE)
+    { "EMFILE", EMFILE, },
+#endif
+#if defined (EMLINK)
+    { "EMLINK", EMLINK, },
+#endif
+#if defined (EMSGSIZE)
+    { "EMSGSIZE", EMSGSIZE, },
+#endif
+#if defined (ENAMETOOLONG)
+    { "ENAMETOOLONG", ENAMETOOLONG, },
+#endif
+#if defined (ENETDOWN)
+    { "ENETDOWN", ENETDOWN, },
+#endif
+#if defined (ENETRESET)
+    { "ENETRESET", ENETRESET, },
+#endif
+#if defined (ENETUNREACH)
+    { "ENETUNREACH", ENETUNREACH, },
+#endif
+#if defined (ENFILE)
+    { "ENFILE", ENFILE, },
+#endif
+#if defined (ENOBUFS)
+    { "ENOBUFS", ENOBUFS, },
+#endif
+#if defined (ENODEV)
+    { "ENODEV", ENODEV, },
+#endif
+#if defined (ENOENT)
+    { "ENOENT", ENOENT, },
+#endif
+#if defined (ENOEXEC)
+    { "ENOEXEC", ENOEXEC, },
+#endif
+#if defined (ENOLCK)
+    { "ENOLCK", ENOLCK, },
+#endif
+#if defined (ENOMEM)
+    { "ENOMEM", ENOMEM, },
+#endif
+#if defined (ENOPROTOOPT)
+    { "ENOPROTOOPT", ENOPROTOOPT, },
+#endif
+#if defined (ENOSPC)
+    { "ENOSPC", ENOSPC, },
+#endif
+#if defined (ENOSYS)
+    { "ENOSYS", ENOSYS, },
+#endif
+#if defined (ENOTBLK)
+    { "ENOTBLK", ENOTBLK, },
+#endif
+#if defined (ENOTCONN)
+    { "ENOTCONN", ENOTCONN, },
+#endif
+#if defined (ENOTDIR)
+    { "ENOTDIR", ENOTDIR, },
+#endif
+#if defined (ENOTEMPTY)
+    { "ENOTEMPTY", ENOTEMPTY, },
+#endif
+#if defined (ENOTSOCK)
+    { "ENOTSOCK", ENOTSOCK, },
+#endif
+#if defined (ENOTTY)
+    { "ENOTTY", ENOTTY, },
+#endif
+#if defined (ENXIO)
+    { "ENXIO", ENXIO, },
+#endif
+#if defined (EOPNOTSUPP)
+    { "EOPNOTSUPP", EOPNOTSUPP, },
+#endif
+#if defined (EPERM)
+    { "EPERM", EPERM, },
+#endif
+#if defined (EPFNOSUPPORT)
+    { "EPFNOSUPPORT", EPFNOSUPPORT, },
+#endif
+#if defined (EPIPE)
+    { "EPIPE", EPIPE, },
+#endif
+#if defined (EPROTONOSUPPORT)
+    { "EPROTONOSUPPORT", EPROTONOSUPPORT, },
+#endif
+#if defined (EPROTOTYPE)
+    { "EPROTOTYPE", EPROTOTYPE, },
+#endif
+#if defined (ERANGE)
+    { "ERANGE", ERANGE, },
+#endif
+#if defined (EREMOTE)
+    { "EREMOTE", EREMOTE, },
+#endif
+#if defined (ERESTART)
+    { "ERESTART", ERESTART, },
+#endif
+#if defined (EROFS)
+    { "EROFS", EROFS, },
+#endif
+#if defined (ESHUTDOWN)
+    { "ESHUTDOWN", ESHUTDOWN, },
+#endif
+#if defined (ESOCKTNOSUPPORT)
+    { "ESOCKTNOSUPPORT", ESOCKTNOSUPPORT, },
+#endif
+#if defined (ESPIPE)
+    { "ESPIPE", ESPIPE, },
+#endif
+#if defined (ESRCH)
+    { "ESRCH", ESRCH, },
+#endif
+#if defined (ESTALE)
+    { "ESTALE", ESTALE, },
+#endif
+#if defined (ETIMEDOUT)
+    { "ETIMEDOUT", ETIMEDOUT, },
+#endif
+#if defined (ETOOMANYREFS)
+    { "ETOOMANYREFS", ETOOMANYREFS, },
+#endif
+#if defined (ETXTBSY)
+    { "ETXTBSY", ETXTBSY, },
+#endif
+#if defined (EUSERS)
+    { "EUSERS", EUSERS, },
+#endif
+#if defined (EWOULDBLOCK)
+    { "EWOULDBLOCK", EWOULDBLOCK, },
+#endif
+#if defined (EXDEV)
+    { "EXDEV", EXDEV, },
+#endif
+
+    // Others (duplicates are OK).
+
+@SYSDEP_ERRNO_LIST@
+
+    { 0, 0, },
+  };
+
+  // Stuff them all in a map for fast access.
+
+  errno_struct *ptr = errno_codes;
+
+  while (ptr->name)
+    {
+      errno_tbl[ptr->name] = ptr->value;
+      ptr++;
+    }
+}
+
+bool
+octave_errno::instance_ok (void)
+{
+  bool retval = true;
+
+  if (! instance)
+    {
+      instance = new octave_errno ();
+
+      if (instance)
+        singleton_cleanup_list::add (cleanup_instance);
+    }
+
+  if (! instance)
+    {
+      ::error ("unable to create errno object!");
+
+      retval = false;
+    }
+
+  return retval;
+}
+
+int
+octave_errno::lookup (const std::string& name)
+{
+  return (instance_ok ()) ? instance->do_lookup (name) : -1;
+}
+
+octave_scalar_map
+octave_errno::list (void)
+{
+  return (instance_ok ()) ? instance->do_list () : octave_scalar_map ();
+}
+
+int
+octave_errno::do_lookup (const std::string& name)
+{
+  return (errno_tbl.find (name) != errno_tbl.end ()) ? errno_tbl[name] : -1;
+}
+
+octave_scalar_map
+octave_errno::do_list (void)
+{
+  octave_scalar_map retval;
+
+  for (std::map<std::string, int>::const_iterator p = errno_tbl.begin ();
+       p != errno_tbl.end ();
+       p++)
+    {
+      retval.assign (p->first, p->second);
+    }
+
+  return retval;
+}
--- a/src/oct-map.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/oct-map.cc	Mon May 07 00:56:44 2012 +0200
@@ -971,7 +971,7 @@
       octave_idx_type nf = nfields ();
 
       for (octave_idx_type k = 0; k < nf; k++)
-        xvals[k].assign (i, rhs.xvals[k]);
+        xvals[k].assign (i, rhs.xvals[k], Matrix ());
 
       if (nf > 0)
         dimensions = xvals[0].dims ();
@@ -1014,7 +1014,7 @@
       octave_idx_type nf = nfields ();
 
       for (octave_idx_type k = 0; k < nf; k++)
-        xvals[k].assign (i, j, rhs.xvals[k]);
+        xvals[k].assign (i, j, rhs.xvals[k], Matrix ());
 
       if (nf > 0)
         dimensions = xvals[0].dims ();
@@ -1057,7 +1057,7 @@
       octave_idx_type nf = nfields ();
 
       for (octave_idx_type k = 0; k < nf; k++)
-        xvals[k].assign (ia, rhs.xvals[k]);
+        xvals[k].assign (ia, rhs.xvals[k], Matrix ());
 
       if (nf > 0)
         dimensions = xvals[0].dims ();
@@ -1170,6 +1170,13 @@
     setfield (k, tmp);
 }
 
+/*
+%!test
+%! rhs.b = 1;
+%! a(3) = rhs;
+%! assert ({a.b}, {[], [], 1})
+*/
+
 void
 octave_map::delete_elements (const idx_vector& i)
 {
--- a/src/oct-parse.yy	Mon May 07 00:53:54 2012 +0200
+++ b/src/oct-parse.yy	Mon May 07 00:56:44 2012 +0200
@@ -115,6 +115,11 @@
 //     nested function.
 static int current_function_depth = 0;
 
+// A stack holding the nested function scopes being parsed.
+// We don't use std::stack, because we want the clear method. Also, we
+// must access one from the top
+static std::vector<symbol_table::scope_id> function_scopes;
+
 // Maximum function depth detected. Just here to determine whether
 // we have nested functions or just implicitly ended subfunctions.
 static int max_function_depth = 0;
@@ -368,7 +373,8 @@
       yyerrok; \
       if (! parser_symtab_context.empty ()) \
         parser_symtab_context.pop (); \
-      if (interactive || forced_interactive) \
+      if ((interactive || forced_interactive)   \
+          && ! get_input_from_eval_string)      \
         YYACCEPT; \
       else \
         YYABORT; \
@@ -460,7 +466,7 @@
 // Nonterminals we construct.
 %type <comment_type> stash_comment function_beg classdef_beg
 %type <comment_type> properties_beg methods_beg events_beg enum_beg
-%type <sep_type> sep_no_nl opt_sep_no_nl sep opt_sep
+%type <sep_type> sep_no_nl opt_sep_no_nl sep opt_sep opt_comma
 %type <tree_type> input
 %type <tree_constant_type> string constant magic_colon
 %type <tree_anon_fcn_handle_type> anon_fcn_handle
@@ -906,7 +912,7 @@
                     $$ = new tree_argument_list ($1);
                     $$->mark_as_simple_assign_lhs ();
                   }
-                | '[' arg_list CLOSE_BRACE
+                | '[' arg_list opt_comma CLOSE_BRACE
                   {
                     $$ = $2;
                     lexer_flags.looking_at_matrix_or_assign_lhs = false;
@@ -1226,6 +1232,8 @@
 
                     symbol_table::set_scope (symbol_table::alloc_scope ());
 
+                    function_scopes.push_back (symbol_table::current_scope ());
+
                     if (! reading_script_file && current_function_depth == 1
                         && ! parsing_subfunctions)
                       primary_fcn_scope = symbol_table::current_scope ();
@@ -1672,6 +1680,12 @@
                   { $$ = $1; }
                 ;
 
+opt_comma       : // empty
+                  { $$ = 0; }
+                | ','
+                  { $$ = ','; }
+                ;
+
 %%
 
 // Generic error messages.
@@ -2823,8 +2837,7 @@
   // file.  Matlab doesn't provide a diagnostic (it ignores the stated
   // name).
   if (! autoloading && reading_fcn_file
-      && (current_function_depth == 1
-          && ! (parsing_subfunctions || lexer_flags.parsing_class_method)))
+      && current_function_depth == 1 && ! parsing_subfunctions)
   {
     // FIXME -- should curr_fcn_file_name already be
     // preprocessed when we get here?  It seems to only be a
@@ -2862,7 +2875,11 @@
       if (current_function_depth > 1 || parsing_subfunctions)
         {
           fcn->stash_parent_fcn_name (curr_fcn_file_name);
-          fcn->stash_parent_fcn_scope (primary_fcn_scope);
+
+          if (current_function_depth > 1)
+            fcn->stash_parent_fcn_scope (function_scopes[function_scopes.size()-2]);
+          else
+            fcn->stash_parent_fcn_scope (primary_fcn_scope);
         }
 
       if (lexer_flags.parsing_class_method)
@@ -2938,19 +2955,32 @@
         {
           fcn->mark_as_subfunction ();
 
-          symbol_table::install_subfunction (nm, octave_value (fcn),
-                                             primary_fcn_scope);
+          if (endfunction_found && function_scopes.size () > 1)
+            {
+              symbol_table::scope_id pscope
+                = function_scopes[function_scopes.size()-2];
+
+              symbol_table::install_nestfunction (nm, octave_value (fcn),
+                                                  pscope);
+            }
+          else
+            symbol_table::install_subfunction (nm, octave_value (fcn),
+                                               primary_fcn_scope);
         }
 
-      if (! reading_fcn_file)
+      if (current_function_depth == 1 && fcn)
+        symbol_table::update_nest (fcn->scope ());
+
+      if (! reading_fcn_file && current_function_depth == 1)
         {
           // We are either reading a script file or defining a function
           // at the command line, so this definition creates a
           // tree_function object that is placed in the parse tree.
           // Otherwise, it is just inserted in the symbol table,
-          // either as a subfunction (see above), or as the primary
-          // function for the file, via primary_fcn_ptr (see also
-          // load_fcn_from_file,, parse_fcn_file, and
+          // either as a subfunction or nested function (see above),
+          // or as the primary function for the file, via
+          // primary_fcn_ptr (see also load_fcn_from_file,,
+          // parse_fcn_file, and
           // symbol_table::fcn_info::fcn_info_rep::find_user_function).
 
           retval = new tree_function_def (fcn);
@@ -2979,6 +3009,7 @@
     parsing_subfunctions = true;
 
   current_function_depth--;
+  function_scopes.pop_back ();
 
   lexer_flags.defining_func--;
   lexer_flags.parsed_function_name.pop ();
@@ -3448,6 +3479,7 @@
   frame.protect_var (line_editing);
   frame.protect_var (current_class_name);
   frame.protect_var (current_function_depth);
+  frame.protect_var (function_scopes);
   frame.protect_var (max_function_depth);
   frame.protect_var (parsing_subfunctions);
   frame.protect_var (endfunction_found);
@@ -3458,6 +3490,7 @@
   line_editing = false;
   current_class_name = dispatch_type;
   current_function_depth = 0;
+  function_scopes.clear ();
   max_function_depth = 0;
   parsing_subfunctions = false;
   endfunction_found = false;
@@ -3576,11 +3609,6 @@
           if (status != 0)
             error ("parse error while reading %s file %s",
                    file_type.c_str(), ff.c_str ());
-          else if (reading_fcn_file && endfunction_found
-                   && max_function_depth > 1)
-            warning_with_id ("Octave:nested-functions-coerced",
-                             "nested functions are coerced into subfunctions "
-                             "in file %s", ff.c_str ());
         }
       else
         {
@@ -4292,6 +4320,7 @@
   frame.protect_var (line_editing);
   frame.protect_var (current_eval_string);
   frame.protect_var (current_function_depth);
+  frame.protect_var (function_scopes);
   frame.protect_var (max_function_depth);
   frame.protect_var (parsing_subfunctions);
   frame.protect_var (endfunction_found);
@@ -4306,6 +4335,7 @@
   parser_end_of_input = false;
   line_editing = false;
   current_function_depth = 0;
+  function_scopes.clear ();
   max_function_depth = 0;
   parsing_subfunctions = false;
   endfunction_found = false;
@@ -4553,6 +4583,11 @@
 %!endfunction
 %!assert (__f(), 2)
 
+% bug #35645
+%!test
+%! [a,] = gcd (1,2);
+%! [a,b,] = gcd (1, 2);
+
 */
 
 DEFUN (assignin, args, ,
--- a/src/octave-config.cc.in	Mon May 07 00:53:54 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,224 +0,0 @@
-/*
-
-Copyright (C) 2008-2012 Michael Goffioul
-
-This file is part of Octave.
-
-Octave is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 3 of the License, or (at your
-option) any later version.
-
-Octave is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with Octave; see the file COPYING.  If not, see
-<http://www.gnu.org/licenses/>.
-
-*/
-
-#if defined (HAVE_CONFIG_H)
-#include <config.h>
-#endif
-
-#include <string>
-#include <map>
-#include <iostream>
-#include <algorithm>
-#include <cstdlib>
-
-#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
-#include <windows.h>
-#endif
-
-static bool initialized = false;
-static std::map<std::string,std::string> vars;
-static std::string OCTAVE_HOME, PREFIX;
-static std::string usage_msg = "usage: octave-config [options]";
-static std::string help_msg =
-"\n"
-"Options:\n"
-"\n"
-"  -h, -?, --help        Print this message.\n"
-"\n"
-"  --m-site-dir          Print the name of the directory where Octave\n"
-"                        expects to find locally installed .m files.\n"
-"\n"
-"  --oct-site-dir        Print the name of the directory where Octave\n"
-"                        expects to find locally installed .oct files.\n"
-"\n"
-"  -p VAR, --print VAR   Print the value of the given configuration\n"
-"		        variable VAR.  Recognized variables are:\n"
-"\n"
-"			  API_VERSION	         LOCALAPIARCHLIBDIR\n"
-"			  CANONICAL_HOST_TYPE	 LOCALAPIFCNFILEDIR\n"
-"			  DEFAULT_PAGER	         LOCALAPIOCTFILEDIR\n"
-"			  ARCHLIBDIR	         LOCALARCHLIBDIR\n"
-"			  BINDIR	         LOCALFCNFILEDIR\n"
-"			  DATADIR	         LOCALOCTFILEDIR\n"
-"			  DATAROOTDIR	         LOCALSTARTUPFILEDIR\n"
-"			  EXEC_PREFIX	         LOCALVERARCHLIBDIR\n"
-"			  FCNFILEDIR		 LOCALVERFCNFILEDIR\n"
-"			  LOCALVEROCTFILEDIR	 MAN1DIR\n"
-"			  IMAGEDIR	         MANDIR\n"
-"			  MAN1EXT	         OCTFILEDIR\n"
-"			  INCLUDEDIR	         OCTINCLUDEDIR\n"
-"			  INFODIR	         OCTLIBDIR\n"
-"			  INFOFILE	         PREFIX\n"
-"			  LIBDIR	         STARTUPFILEDIR\n"
-"			  LIBEXECDIR		 VERSION\n"
-"\n"
-"  -v, --version         Print the Octave version number.\n"
-"\n";
-
-static std::string
-substitute_prefix (const std::string& s, const std::string& prefix,
-		   const std::string new_prefix)
-{
-  std::string retval = s;
-
-  if (!prefix.empty () && new_prefix != prefix)
-    {
-      int len = prefix.length ();
-      if (retval.find (prefix) == 0)
-	retval.replace (0, len, new_prefix);
-    }
-
-#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
-  std::replace (retval.begin (), retval.end (), '/', '\\');
-#endif
-
-  return retval;
-}
-
-static void
-initialize (void)
-{
-  if (initialized)
-    return;
-
-  initialized = true;
-
-  const char *homestr = getenv ("OCTAVE_HOME");
-  OCTAVE_HOME = (homestr ? homestr : "");
-  PREFIX = %OCTAVE_PREFIX%;
-
-#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
-  int n = 1024;
-
-  std::string bin_dir (n, '\0');
-
-  while (true)
-    {
-      int status = GetModuleFileName (0, &bin_dir[0], n);
-
-      if (status < n)
-	{
-	  bin_dir.resize (status);
-	  break;
-	}
-      else
-	{
-	  n *= 2;
-	  bin_dir.resize (n);
-	}
-    }
-
-  if (! bin_dir.empty ())
-    {
-      size_t pos = bin_dir.rfind ("\\bin\\");
-
-      if (pos != std::string::npos)
-	OCTAVE_HOME = bin_dir.substr (0, pos);
-    }
-#endif
-
-  vars["API_VERSION"] = %OCTAVE_API_VERSION%;
-  vars["CANONICAL_HOST_TYPE"] = %OCTAVE_CANONICAL_HOST_TYPE%;
-  vars["DEFAULT_PAGER"] = %OCTAVE_DEFAULT_PAGER%;
-  vars["ARCHLIBDIR"] = substitute_prefix (%OCTAVE_ARCHLIBDIR%, PREFIX, OCTAVE_HOME);
-  vars["BINDIR"] = substitute_prefix (%OCTAVE_BINDIR%, PREFIX, OCTAVE_HOME);
-  vars["DATADIR"] =substitute_prefix (%OCTAVE_DATADIR%, PREFIX, OCTAVE_HOME);
-  vars["DATAROOTDIR"] =substitute_prefix (%OCTAVE_DATAROOTDIR%, PREFIX, OCTAVE_HOME);
-  vars["EXEC_PREFIX"] =substitute_prefix (%OCTAVE_EXEC_PREFIX%, PREFIX, OCTAVE_HOME);
-  vars["FCNFILEDIR"] =substitute_prefix (%OCTAVE_FCNFILEDIR%, PREFIX, OCTAVE_HOME);
-  vars["IMAGEDIR"] =substitute_prefix (%OCTAVE_IMAGEDIR%, PREFIX, OCTAVE_HOME);
-  vars["INCLUDEDIR"] =substitute_prefix (%OCTAVE_INCLUDEDIR%, PREFIX, OCTAVE_HOME);
-  vars["INFODIR"] =substitute_prefix (%OCTAVE_INFODIR%, PREFIX, OCTAVE_HOME);
-  vars["INFOFILE"] =substitute_prefix (%OCTAVE_INFOFILE%, PREFIX, OCTAVE_HOME);
-  vars["LIBDIR"] =substitute_prefix (%OCTAVE_LIBDIR%, PREFIX, OCTAVE_HOME);
-  vars["LIBEXECDIR"] =substitute_prefix (%OCTAVE_LIBEXECDIR%, PREFIX, OCTAVE_HOME);
-  vars["LOCALAPIARCHLIBDIR"] =substitute_prefix (%OCTAVE_LOCALAPIARCHLIBDIR%, PREFIX, OCTAVE_HOME);
-  vars["LOCALAPIFCNFILEDIR"] =substitute_prefix (%OCTAVE_LOCALAPIFCNFILEDIR%, PREFIX, OCTAVE_HOME);
-  vars["LOCALAPIOCTFILEDIR"] =substitute_prefix (%OCTAVE_LOCALAPIOCTFILEDIR%, PREFIX, OCTAVE_HOME);
-  vars["LOCALARCHLIBDIR"] =substitute_prefix (%OCTAVE_LOCALARCHLIBDIR%, PREFIX, OCTAVE_HOME);
-  vars["LOCALFCNFILEDIR"] =substitute_prefix (%OCTAVE_LOCALFCNFILEDIR%, PREFIX, OCTAVE_HOME);
-  vars["LOCALOCTFILEDIR"] =substitute_prefix (%OCTAVE_LOCALOCTFILEDIR%, PREFIX, OCTAVE_HOME);
-  vars["LOCALSTARTUPFILEDIR"] =substitute_prefix (%OCTAVE_LOCALSTARTUPFILEDIR%, PREFIX, OCTAVE_HOME);
-  vars["LOCALVERARCHLIBDIR"] =substitute_prefix (%OCTAVE_LOCALVERARCHLIBDIR%, PREFIX, OCTAVE_HOME);
-  vars["LOCALVERFCNFILEDIR"] =substitute_prefix (%OCTAVE_LOCALVERFCNFILEDIR%, PREFIX, OCTAVE_HOME);
-  vars["LOCALVEROCTFILEDIR"] =substitute_prefix (%OCTAVE_LOCALVEROCTFILEDIR%, PREFIX, OCTAVE_HOME);
-  vars["MAN1DIR"] =substitute_prefix (%OCTAVE_MAN1DIR%, PREFIX, OCTAVE_HOME);
-  vars["MAN1EXT"] = %OCTAVE_MAN1EXT%;
-  vars["MANDIR"] =substitute_prefix (%OCTAVE_MANDIR%, PREFIX, OCTAVE_HOME);
-  vars["OCTFILEDIR"] =substitute_prefix (%OCTAVE_OCTFILEDIR%, PREFIX, OCTAVE_HOME);
-  vars["OCTINCLUDEDIR"] =substitute_prefix (%OCTAVE_OCTINCLUDEDIR%, PREFIX, OCTAVE_HOME);
-  vars["OCTLIBDIR"] =substitute_prefix (%OCTAVE_OCTLIBDIR%, PREFIX, OCTAVE_HOME);
-  vars["PREFIX"] = (OCTAVE_HOME.empty() ? PREFIX : OCTAVE_HOME);
-  vars["STARTUPFILEDIR"] =substitute_prefix (%OCTAVE_STARTUPFILEDIR%, PREFIX, OCTAVE_HOME);
-  vars["VERSION"] = %OCTAVE_VERSION%;
-}
-
-int
-main (int argc, char **argv)
-{
-  initialize ();
-
-  if (argc == 1)
-    {
-      std::cout << usage_msg << std::endl;
-      return 1;
-    }
-
-  for (int i = 1; i < argc; i++)
-    {
-      std::string arg (argv[i]);
-
-      if (arg == "-h" || arg == "-?" || arg == "--help")
-	{
-	  std::cout << usage_msg << std::endl;
-	  std::cout << help_msg;
-	  return 0;
-	}
-      else if (arg == "--m-site-dir")
-	std::cout << vars["LOCALVERFCNFILEDIR"] << std::endl;
-      else if (arg == "--oct-site-dir")
-	std::cout << vars["LOCALVEROCTFILEDIR"] << std::endl;
-      else if (arg == "-v" || arg == "--version")
-	std::cout << vars["VERSION"] << std::endl;
-      else if (arg == "-p" || arg == "--print")
-	{
-	  if (i < argc-1)
-	    {
-	      arg = argv[++i];
-	      std::cout << vars[arg] << std::endl;
-	    }
-	  else
-	    {
-	      std::cerr << "octave-config: " << arg
-			<< " options requires argument" << std::endl;
-	      return 1;
-	    }
-	}
-      else
-	{
-	  std::cerr << "octave-config: unrecognized argument " << arg << std::endl;
-	  return 1;
-	}
-    }
-
-  return 0;
-}
--- a/src/octave-config.in	Mon May 07 00:53:54 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,168 +0,0 @@
-#! /bin/sh -
-##
-## octave-config - reports some configuration values for Octave
-##
-## Copyright (C) 2001-2012 John W. Eaton
-##
-## This file is part of Octave.
-##
-## Octave is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 3 of the License, or (at
-## your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-##
-## Original version by Rafael Laboissiere <rafael@laboissiere.net>
-## distributed as free software in the public domain.
-
-API_VERSION=%OCTAVE_API_VERSION%
-CANONICAL_HOST_TYPE=%OCTAVE_CANONICAL_HOST_TYPE%
-DEFAULT_PAGER=%OCTAVE_DEFAULT_PAGER%
-ARCHLIBDIR=%OCTAVE_ARCHLIBDIR%
-BINDIR=%OCTAVE_BINDIR%
-DATADIR=%OCTAVE_DATADIR%
-DATAROOTDIR=%OCTAVE_DATAROOTDIR%
-EXEC_PREFIX=%OCTAVE_EXEC_PREFIX%
-FCNFILEDIR=%OCTAVE_FCNFILEDIR%
-IMAGEDIR=%OCTAVE_IMAGEDIR%
-INCLUDEDIR=%OCTAVE_INCLUDEDIR%
-INFODIR=%OCTAVE_INFODIR%
-INFOFILE=%OCTAVE_INFOFILE%
-LIBDIR=%OCTAVE_LIBDIR%
-LIBEXECDIR=%OCTAVE_LIBEXECDIR%
-LOCALAPIARCHLIBDIR=%OCTAVE_LOCALAPIARCHLIBDIR%
-LOCALAPIFCNFILEDIR=%OCTAVE_LOCALAPIFCNFILEDIR%
-LOCALAPIOCTFILEDIR=%OCTAVE_LOCALAPIOCTFILEDIR%
-LOCALARCHLIBDIR=%OCTAVE_LOCALARCHLIBDIR%
-LOCALFCNFILEDIR=%OCTAVE_LOCALFCNFILEDIR%
-LOCALOCTFILEDIR=%OCTAVE_LOCALOCTFILEDIR%
-LOCALSTARTUPFILEDIR=%OCTAVE_LOCALSTARTUPFILEDIR%
-LOCALVERARCHLIBDIR=%OCTAVE_LOCALVERARCHLIBDIR%
-LOCALVERFCNFILEDIR=%OCTAVE_LOCALVERFCNFILEDIR%
-LOCALVEROCTFILEDIR=%OCTAVE_LOCALVEROCTFILEDIR%
-MAN1DIR=%OCTAVE_MAN1DIR%
-MAN1EXT=%OCTAVE_MAN1EXT%
-MANDIR=%OCTAVE_MANDIR%
-OCTFILEDIR=%OCTAVE_OCTFILEDIR%
-OCTINCLUDEDIR=%OCTAVE_OCTINCLUDEDIR%
-OCTLIBDIR=%OCTAVE_OCTLIBDIR%
-PREFIX=%OCTAVE_PREFIX%
-STARTUPFILEDIR=%OCTAVE_STARTUPFILEDIR%
-VERSION=%OCTAVE_VERSION%
-
-if [ -n "$OCTAVE_HOME" ]; then
-  ARCHLIBDIR="`echo $ARCHLIBDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  BINDIR="`echo $BINDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  DATADIR="`echo $DATADIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  DATAROOTDIR="`echo $DATAROOTDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  EXEC_PREFIX="`echo $EXEC_PREFIX | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  FCNFILEDIR="`echo $FCNFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  IMAGEDIR="`echo $IMAGEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  INCLUDEDIR="`echo $INCLUDEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  INFODIR="`echo $INFODIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  INFOFILE="`echo $INFOFILE | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  LIBDIR="`echo $LIBDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  LIBEXECDIR="`echo $LIBEXECDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  LOCALAPIARCHLIBDIR="`echo $LOCALAPIARCHLIBDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  LOCALAPIFCNFILEDIR="`echo $LOCALAPIFCNFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  LOCALAPIOCTFILEDIR="`echo $LOCALAPIOCTFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  LOCALARCHLIBDIR="`echo $LOCALARCHLIBDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  LOCALFCNFILEDIR="`echo $LOCALFCNFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  LOCALOCTFILEDIR="`echo $LOCALOCTFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  LOCALSTARTUPFILEDIR="`echo $LOCALSTARTUPFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  LOCALVERARCHLIBDIR="`echo $LOCALVERARCHLIBDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  LOCALVERFCNFILEDIR="`echo $LOCALVERFCNFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  LOCALVEROCTFILEDIR="`echo $LOCALVEROCTFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  MAN1DIR="`echo $MAN1DIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  MANDIR="`echo $MANDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  OCTFILEDIR="`echo $OCTFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  OCTINCLUDEDIR="`echo $OCTINCLUDEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  OCTLIBDIR="`echo $OCTLIBDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-  STARTUPFILEDIR="`echo $STARTUPFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
-
-  PREFIX="$OCTAVE_HOME"
-fi
-
-usage_msg="usage: octave-config [options]"
-
-if [ $# -eq 0 ]; then
-  echo "$usage_msg" 1>&2
-  exit 1
-fi
-
-while [ $# -gt 0 ]
-do
-  case "$1" in
-    -h | -\? | --help)
-      echo "$usage_msg"
-      cat << EOF
-
-Options:
-
-  -h, -?, --help        Print this message.
-
-  --m-site-dir          Print the name of the directory where Octave
-                        expects to find locally installed .m files.
-
-  --oct-site-dir        Print the name of the directory where Octave
-                        expects to find locally installed .oct files.
-
-  -p VAR, --print VAR   Print the value of the given configuration
-		        variable VAR.  Recognized variables are:
-
-                          API_VERSION             LOCALAPIOCTFILEDIR
-                          ARCHLIBDIR              LOCALARCHLIBDIR
-                          BINDIR                  LOCALFCNFILEDIR
-                          CANONICAL_HOST_TYPE     LOCALOCTFILEDIR
-                          DATADIR                 LOCALSTARTUPFILEDIR
-                          DATAROOTDIR             LOCALVERARCHLIBDIR
-                          DEFAULT_PAGER           LOCALVERFCNFILEDIR
-                          EXEC_PREFIX             LOCALVEROCTFILEDIR
-                          FCNFILEDIR              MAN1DIR
-                          IMAGEDIR                MAN1EXT
-                          INCLUDEDIR              MANDIR
-                          INFODIR                 OCTFILEDIR
-                          INFOFILE                OCTINCLUDEDIR
-                          LIBDIR                  OCTLIBDIR
-                          LIBEXECDIR              PREFIX
-                          LOCALAPIARCHLIBDIR      STARTUPFILEDIR
-                          LOCALAPIFCNFILEDIR      VERSION
-
-  -v, --version         Print the Octave version number.
-
-EOF
-      exit 0
-    ;;
-    --m-site-dir)
-      echo $LOCALVERFCNFILEDIR
-    ;;
-    --oct-site-dir)
-      echo $LOCALVEROCTFILEDIR
-    ;;
-    -v | --version)
-      echo $VERSION
-    ;;
-    -p | --print)
-      opt="$1"
-      shift
-      if [ $# -eq 0 ]; then
-        echo "octave-config: $opt option requires argument" 1>&2
-        exit 1
-      fi
-      eval echo \${$1}
-    ;;
-    *)
-      echo "octave-config: unrecognized argument $1" 2>&1
-      exit 1
-    ;;
-  esac
-  shift
-done
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/octave-config.in.cc	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,224 @@
+/*
+
+Copyright (C) 2008-2012 Michael Goffioul
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+#if defined (HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#include <string>
+#include <map>
+#include <iostream>
+#include <algorithm>
+#include <cstdlib>
+
+#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
+#include <windows.h>
+#endif
+
+static bool initialized = false;
+static std::map<std::string,std::string> vars;
+static std::string OCTAVE_HOME, PREFIX;
+static std::string usage_msg = "usage: octave-config [options]";
+static std::string help_msg =
+"\n"
+"Options:\n"
+"\n"
+"  -h, -?, --help        Print this message.\n"
+"\n"
+"  --m-site-dir          Print the name of the directory where Octave\n"
+"                        expects to find locally installed .m files.\n"
+"\n"
+"  --oct-site-dir        Print the name of the directory where Octave\n"
+"                        expects to find locally installed .oct files.\n"
+"\n"
+"  -p VAR, --print VAR   Print the value of the given configuration\n"
+"		        variable VAR.  Recognized variables are:\n"
+"\n"
+"			  API_VERSION	         LOCALAPIARCHLIBDIR\n"
+"			  CANONICAL_HOST_TYPE	 LOCALAPIFCNFILEDIR\n"
+"			  DEFAULT_PAGER	         LOCALAPIOCTFILEDIR\n"
+"			  ARCHLIBDIR	         LOCALARCHLIBDIR\n"
+"			  BINDIR	         LOCALFCNFILEDIR\n"
+"			  DATADIR	         LOCALOCTFILEDIR\n"
+"			  DATAROOTDIR	         LOCALSTARTUPFILEDIR\n"
+"			  EXEC_PREFIX	         LOCALVERARCHLIBDIR\n"
+"			  FCNFILEDIR		 LOCALVERFCNFILEDIR\n"
+"			  LOCALVEROCTFILEDIR	 MAN1DIR\n"
+"			  IMAGEDIR	         MANDIR\n"
+"			  MAN1EXT	         OCTFILEDIR\n"
+"			  INCLUDEDIR	         OCTINCLUDEDIR\n"
+"			  INFODIR	         OCTLIBDIR\n"
+"			  INFOFILE	         PREFIX\n"
+"			  LIBDIR	         STARTUPFILEDIR\n"
+"			  LIBEXECDIR		 VERSION\n"
+"\n"
+"  -v, --version         Print the Octave version number.\n"
+"\n";
+
+static std::string
+substitute_prefix (const std::string& s, const std::string& prefix,
+		   const std::string new_prefix)
+{
+  std::string retval = s;
+
+  if (!prefix.empty () && new_prefix != prefix)
+    {
+      int len = prefix.length ();
+      if (retval.find (prefix) == 0)
+	retval.replace (0, len, new_prefix);
+    }
+
+#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
+  std::replace (retval.begin (), retval.end (), '/', '\\');
+#endif
+
+  return retval;
+}
+
+static void
+initialize (void)
+{
+  if (initialized)
+    return;
+
+  initialized = true;
+
+  const char *homestr = getenv ("OCTAVE_HOME");
+  OCTAVE_HOME = (homestr ? homestr : "");
+  PREFIX = %OCTAVE_PREFIX%;
+
+#if defined (__WIN32__) && ! defined (_POSIX_VERSION)
+  int n = 1024;
+
+  std::string bin_dir (n, '\0');
+
+  while (true)
+    {
+      int status = GetModuleFileName (0, &bin_dir[0], n);
+
+      if (status < n)
+	{
+	  bin_dir.resize (status);
+	  break;
+	}
+      else
+	{
+	  n *= 2;
+	  bin_dir.resize (n);
+	}
+    }
+
+  if (! bin_dir.empty ())
+    {
+      size_t pos = bin_dir.rfind ("\\bin\\");
+
+      if (pos != std::string::npos)
+	OCTAVE_HOME = bin_dir.substr (0, pos);
+    }
+#endif
+
+  vars["API_VERSION"] = %OCTAVE_API_VERSION%;
+  vars["CANONICAL_HOST_TYPE"] = %OCTAVE_CANONICAL_HOST_TYPE%;
+  vars["DEFAULT_PAGER"] = %OCTAVE_DEFAULT_PAGER%;
+  vars["ARCHLIBDIR"] = substitute_prefix (%OCTAVE_ARCHLIBDIR%, PREFIX, OCTAVE_HOME);
+  vars["BINDIR"] = substitute_prefix (%OCTAVE_BINDIR%, PREFIX, OCTAVE_HOME);
+  vars["DATADIR"] =substitute_prefix (%OCTAVE_DATADIR%, PREFIX, OCTAVE_HOME);
+  vars["DATAROOTDIR"] =substitute_prefix (%OCTAVE_DATAROOTDIR%, PREFIX, OCTAVE_HOME);
+  vars["EXEC_PREFIX"] =substitute_prefix (%OCTAVE_EXEC_PREFIX%, PREFIX, OCTAVE_HOME);
+  vars["FCNFILEDIR"] =substitute_prefix (%OCTAVE_FCNFILEDIR%, PREFIX, OCTAVE_HOME);
+  vars["IMAGEDIR"] =substitute_prefix (%OCTAVE_IMAGEDIR%, PREFIX, OCTAVE_HOME);
+  vars["INCLUDEDIR"] =substitute_prefix (%OCTAVE_INCLUDEDIR%, PREFIX, OCTAVE_HOME);
+  vars["INFODIR"] =substitute_prefix (%OCTAVE_INFODIR%, PREFIX, OCTAVE_HOME);
+  vars["INFOFILE"] =substitute_prefix (%OCTAVE_INFOFILE%, PREFIX, OCTAVE_HOME);
+  vars["LIBDIR"] =substitute_prefix (%OCTAVE_LIBDIR%, PREFIX, OCTAVE_HOME);
+  vars["LIBEXECDIR"] =substitute_prefix (%OCTAVE_LIBEXECDIR%, PREFIX, OCTAVE_HOME);
+  vars["LOCALAPIARCHLIBDIR"] =substitute_prefix (%OCTAVE_LOCALAPIARCHLIBDIR%, PREFIX, OCTAVE_HOME);
+  vars["LOCALAPIFCNFILEDIR"] =substitute_prefix (%OCTAVE_LOCALAPIFCNFILEDIR%, PREFIX, OCTAVE_HOME);
+  vars["LOCALAPIOCTFILEDIR"] =substitute_prefix (%OCTAVE_LOCALAPIOCTFILEDIR%, PREFIX, OCTAVE_HOME);
+  vars["LOCALARCHLIBDIR"] =substitute_prefix (%OCTAVE_LOCALARCHLIBDIR%, PREFIX, OCTAVE_HOME);
+  vars["LOCALFCNFILEDIR"] =substitute_prefix (%OCTAVE_LOCALFCNFILEDIR%, PREFIX, OCTAVE_HOME);
+  vars["LOCALOCTFILEDIR"] =substitute_prefix (%OCTAVE_LOCALOCTFILEDIR%, PREFIX, OCTAVE_HOME);
+  vars["LOCALSTARTUPFILEDIR"] =substitute_prefix (%OCTAVE_LOCALSTARTUPFILEDIR%, PREFIX, OCTAVE_HOME);
+  vars["LOCALVERARCHLIBDIR"] =substitute_prefix (%OCTAVE_LOCALVERARCHLIBDIR%, PREFIX, OCTAVE_HOME);
+  vars["LOCALVERFCNFILEDIR"] =substitute_prefix (%OCTAVE_LOCALVERFCNFILEDIR%, PREFIX, OCTAVE_HOME);
+  vars["LOCALVEROCTFILEDIR"] =substitute_prefix (%OCTAVE_LOCALVEROCTFILEDIR%, PREFIX, OCTAVE_HOME);
+  vars["MAN1DIR"] =substitute_prefix (%OCTAVE_MAN1DIR%, PREFIX, OCTAVE_HOME);
+  vars["MAN1EXT"] = %OCTAVE_MAN1EXT%;
+  vars["MANDIR"] =substitute_prefix (%OCTAVE_MANDIR%, PREFIX, OCTAVE_HOME);
+  vars["OCTFILEDIR"] =substitute_prefix (%OCTAVE_OCTFILEDIR%, PREFIX, OCTAVE_HOME);
+  vars["OCTINCLUDEDIR"] =substitute_prefix (%OCTAVE_OCTINCLUDEDIR%, PREFIX, OCTAVE_HOME);
+  vars["OCTLIBDIR"] =substitute_prefix (%OCTAVE_OCTLIBDIR%, PREFIX, OCTAVE_HOME);
+  vars["PREFIX"] = (OCTAVE_HOME.empty() ? PREFIX : OCTAVE_HOME);
+  vars["STARTUPFILEDIR"] =substitute_prefix (%OCTAVE_STARTUPFILEDIR%, PREFIX, OCTAVE_HOME);
+  vars["VERSION"] = %OCTAVE_VERSION%;
+}
+
+int
+main (int argc, char **argv)
+{
+  initialize ();
+
+  if (argc == 1)
+    {
+      std::cout << usage_msg << std::endl;
+      return 1;
+    }
+
+  for (int i = 1; i < argc; i++)
+    {
+      std::string arg (argv[i]);
+
+      if (arg == "-h" || arg == "-?" || arg == "--help")
+	{
+	  std::cout << usage_msg << std::endl;
+	  std::cout << help_msg;
+	  return 0;
+	}
+      else if (arg == "--m-site-dir")
+	std::cout << vars["LOCALVERFCNFILEDIR"] << std::endl;
+      else if (arg == "--oct-site-dir")
+	std::cout << vars["LOCALVEROCTFILEDIR"] << std::endl;
+      else if (arg == "-v" || arg == "--version")
+	std::cout << vars["VERSION"] << std::endl;
+      else if (arg == "-p" || arg == "--print")
+	{
+	  if (i < argc-1)
+	    {
+	      arg = argv[++i];
+	      std::cout << vars[arg] << std::endl;
+	    }
+	  else
+	    {
+	      std::cerr << "octave-config: " << arg
+			<< " options requires argument" << std::endl;
+	      return 1;
+	    }
+	}
+      else
+	{
+	  std::cerr << "octave-config: unrecognized argument " << arg << std::endl;
+	  return 1;
+	}
+    }
+
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/octave-config.in.sh	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,168 @@
+#! /bin/sh -
+##
+## octave-config - reports some configuration values for Octave
+##
+## Copyright (C) 2001-2012 John W. Eaton
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+##
+## Original version by Rafael Laboissiere <rafael@laboissiere.net>
+## distributed as free software in the public domain.
+
+API_VERSION=%OCTAVE_API_VERSION%
+CANONICAL_HOST_TYPE=%OCTAVE_CANONICAL_HOST_TYPE%
+DEFAULT_PAGER=%OCTAVE_DEFAULT_PAGER%
+ARCHLIBDIR=%OCTAVE_ARCHLIBDIR%
+BINDIR=%OCTAVE_BINDIR%
+DATADIR=%OCTAVE_DATADIR%
+DATAROOTDIR=%OCTAVE_DATAROOTDIR%
+EXEC_PREFIX=%OCTAVE_EXEC_PREFIX%
+FCNFILEDIR=%OCTAVE_FCNFILEDIR%
+IMAGEDIR=%OCTAVE_IMAGEDIR%
+INCLUDEDIR=%OCTAVE_INCLUDEDIR%
+INFODIR=%OCTAVE_INFODIR%
+INFOFILE=%OCTAVE_INFOFILE%
+LIBDIR=%OCTAVE_LIBDIR%
+LIBEXECDIR=%OCTAVE_LIBEXECDIR%
+LOCALAPIARCHLIBDIR=%OCTAVE_LOCALAPIARCHLIBDIR%
+LOCALAPIFCNFILEDIR=%OCTAVE_LOCALAPIFCNFILEDIR%
+LOCALAPIOCTFILEDIR=%OCTAVE_LOCALAPIOCTFILEDIR%
+LOCALARCHLIBDIR=%OCTAVE_LOCALARCHLIBDIR%
+LOCALFCNFILEDIR=%OCTAVE_LOCALFCNFILEDIR%
+LOCALOCTFILEDIR=%OCTAVE_LOCALOCTFILEDIR%
+LOCALSTARTUPFILEDIR=%OCTAVE_LOCALSTARTUPFILEDIR%
+LOCALVERARCHLIBDIR=%OCTAVE_LOCALVERARCHLIBDIR%
+LOCALVERFCNFILEDIR=%OCTAVE_LOCALVERFCNFILEDIR%
+LOCALVEROCTFILEDIR=%OCTAVE_LOCALVEROCTFILEDIR%
+MAN1DIR=%OCTAVE_MAN1DIR%
+MAN1EXT=%OCTAVE_MAN1EXT%
+MANDIR=%OCTAVE_MANDIR%
+OCTFILEDIR=%OCTAVE_OCTFILEDIR%
+OCTINCLUDEDIR=%OCTAVE_OCTINCLUDEDIR%
+OCTLIBDIR=%OCTAVE_OCTLIBDIR%
+PREFIX=%OCTAVE_PREFIX%
+STARTUPFILEDIR=%OCTAVE_STARTUPFILEDIR%
+VERSION=%OCTAVE_VERSION%
+
+if [ -n "$OCTAVE_HOME" ]; then
+  ARCHLIBDIR="`echo $ARCHLIBDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  BINDIR="`echo $BINDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  DATADIR="`echo $DATADIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  DATAROOTDIR="`echo $DATAROOTDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  EXEC_PREFIX="`echo $EXEC_PREFIX | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  FCNFILEDIR="`echo $FCNFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  IMAGEDIR="`echo $IMAGEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  INCLUDEDIR="`echo $INCLUDEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  INFODIR="`echo $INFODIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  INFOFILE="`echo $INFOFILE | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  LIBDIR="`echo $LIBDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  LIBEXECDIR="`echo $LIBEXECDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  LOCALAPIARCHLIBDIR="`echo $LOCALAPIARCHLIBDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  LOCALAPIFCNFILEDIR="`echo $LOCALAPIFCNFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  LOCALAPIOCTFILEDIR="`echo $LOCALAPIOCTFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  LOCALARCHLIBDIR="`echo $LOCALARCHLIBDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  LOCALFCNFILEDIR="`echo $LOCALFCNFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  LOCALOCTFILEDIR="`echo $LOCALOCTFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  LOCALSTARTUPFILEDIR="`echo $LOCALSTARTUPFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  LOCALVERARCHLIBDIR="`echo $LOCALVERARCHLIBDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  LOCALVERFCNFILEDIR="`echo $LOCALVERFCNFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  LOCALVEROCTFILEDIR="`echo $LOCALVEROCTFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  MAN1DIR="`echo $MAN1DIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  MANDIR="`echo $MANDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  OCTFILEDIR="`echo $OCTFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  OCTINCLUDEDIR="`echo $OCTINCLUDEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  OCTLIBDIR="`echo $OCTLIBDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+  STARTUPFILEDIR="`echo $STARTUPFILEDIR | sed "s,^$PREFIX,$OCTAVE_HOME,"`"
+
+  PREFIX="$OCTAVE_HOME"
+fi
+
+usage_msg="usage: octave-config [options]"
+
+if [ $# -eq 0 ]; then
+  echo "$usage_msg" 1>&2
+  exit 1
+fi
+
+while [ $# -gt 0 ]
+do
+  case "$1" in
+    -h | -\? | --help)
+      echo "$usage_msg"
+      cat << EOF
+
+Options:
+
+  -h, -?, --help        Print this message.
+
+  --m-site-dir          Print the name of the directory where Octave
+                        expects to find locally installed .m files.
+
+  --oct-site-dir        Print the name of the directory where Octave
+                        expects to find locally installed .oct files.
+
+  -p VAR, --print VAR   Print the value of the given configuration
+		        variable VAR.  Recognized variables are:
+
+                          API_VERSION             LOCALAPIOCTFILEDIR
+                          ARCHLIBDIR              LOCALARCHLIBDIR
+                          BINDIR                  LOCALFCNFILEDIR
+                          CANONICAL_HOST_TYPE     LOCALOCTFILEDIR
+                          DATADIR                 LOCALSTARTUPFILEDIR
+                          DATAROOTDIR             LOCALVERARCHLIBDIR
+                          DEFAULT_PAGER           LOCALVERFCNFILEDIR
+                          EXEC_PREFIX             LOCALVEROCTFILEDIR
+                          FCNFILEDIR              MAN1DIR
+                          IMAGEDIR                MAN1EXT
+                          INCLUDEDIR              MANDIR
+                          INFODIR                 OCTFILEDIR
+                          INFOFILE                OCTINCLUDEDIR
+                          LIBDIR                  OCTLIBDIR
+                          LIBEXECDIR              PREFIX
+                          LOCALAPIARCHLIBDIR      STARTUPFILEDIR
+                          LOCALAPIFCNFILEDIR      VERSION
+
+  -v, --version         Print the Octave version number.
+
+EOF
+      exit 0
+    ;;
+    --m-site-dir)
+      echo $LOCALVERFCNFILEDIR
+    ;;
+    --oct-site-dir)
+      echo $LOCALVEROCTFILEDIR
+    ;;
+    -v | --version)
+      echo $VERSION
+    ;;
+    -p | --print)
+      opt="$1"
+      shift
+      if [ $# -eq 0 ]; then
+        echo "octave-config: $opt option requires argument" 1>&2
+        exit 1
+      fi
+      eval echo \${$1}
+    ;;
+    *)
+      echo "octave-config: unrecognized argument $1" 2>&1
+      exit 1
+    ;;
+  esac
+  shift
+done
--- a/src/octave.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/octave.cc	Mon May 07 00:56:44 2012 +0200
@@ -317,6 +317,7 @@
   catch (std::bad_alloc)
     {
       recover_from_exception ();
+      error_state = -2;
       gripe_safe_source_exception
         (file_name,
          "memory exhausted or requested size too large for range of Octave's index type");
@@ -443,6 +444,7 @@
     }
   catch (std::bad_alloc)
     {
+      error_state = -2;
       std::cerr << "error: memory exhausted or requested size too large for range of Octave's index type -- eval failed"
                 << std::endl;
     }
--- a/src/ov-base-diag.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-base-diag.cc	Mon May 07 00:56:44 2012 +0200
@@ -82,7 +82,7 @@
 
       if (idx0.is_scalar () && idx1.is_scalar ())
         {
-          retval = matrix.checkelem (idx0(0), idx1(0));
+          retval = matrix.elem (idx0(0), idx1(0));
         }
       else
         {
--- a/src/ov-base-mat.h	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-base-mat.h	Mon May 07 00:56:44 2012 +0200
@@ -123,6 +123,9 @@
   octave_value diag (octave_idx_type k = 0) const
     { return octave_value (matrix.diag (k)); }
 
+  octave_value diag (octave_idx_type m, octave_idx_type n) const
+    { return octave_value (matrix.diag (m, n)); }
+
   octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const
     { return octave_value (matrix.sort (dim, mode)); }
   octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0,
--- a/src/ov-base-scalar.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-base-scalar.cc	Mon May 07 00:56:44 2012 +0200
@@ -121,6 +121,13 @@
 }
 
 template <class ST>
+octave_value
+octave_base_scalar<ST>::diag (octave_idx_type m, octave_idx_type n) const
+{
+  return Array<ST> (dim_vector (1, 1), scalar).diag (m, n);
+}
+
+template <class ST>
 bool
 octave_base_scalar<ST>::is_true (void) const
 {
--- a/src/ov-base-scalar.h	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-base-scalar.h	Mon May 07 00:56:44 2012 +0200
@@ -98,6 +98,8 @@
 
   octave_value diag (octave_idx_type k = 0) const;
 
+  octave_value diag (octave_idx_type m, octave_idx_type n) const;
+
   octave_value sort (octave_idx_type, sortmode) const
     { return octave_value (scalar); }
   octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type,
--- a/src/ov-base-sparse.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-base-sparse.cc	Mon May 07 00:56:44 2012 +0200
@@ -318,7 +318,13 @@
      << ", cols = " << nc
      << ", nnz = " << nz;
 
-  double dnel = matrix.numel ();
+  // Avoid calling numel here since it can easily overflow
+  // octave_idx_type even when there is no real problem storing the
+  // sparse array.
+
+  double dnr = nr;
+  double dnc = nc;
+  double dnel = dnr * dnc;
 
   if (dnel > 0)
     {
--- a/src/ov-base.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-base.cc	Mon May 07 00:56:44 2012 +0200
@@ -1121,6 +1121,14 @@
 }
 
 octave_value
+octave_base_value::diag (octave_idx_type, octave_idx_type) const
+{
+  gripe_wrong_type_arg ("octave_base_value::diag ()", type_name ());
+
+  return octave_value();
+}
+
+octave_value
 octave_base_value::sort (octave_idx_type, sortmode) const
 {
   gripe_wrong_type_arg ("octave_base_value::sort ()", type_name ());
--- a/src/ov-base.h	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-base.h	Mon May 07 00:56:44 2012 +0200
@@ -646,6 +646,8 @@
 
   virtual octave_value diag (octave_idx_type k = 0) const;
 
+  virtual octave_value diag (octave_idx_type m, octave_idx_type n) const;
+
   virtual octave_value sort (octave_idx_type dim = 0,
                              sortmode mode = ASCENDING) const;
   virtual octave_value sort (Array<octave_idx_type> &sidx,
--- a/src/ov-complex.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-complex.cc	Mon May 07 00:56:44 2012 +0200
@@ -243,6 +243,12 @@
     }
 }
 
+octave_value
+octave_complex::diag (octave_idx_type m, octave_idx_type n) const
+{
+  return ComplexDiagMatrix (Array<Complex> (dim_vector (1, 1), scalar), m, n);
+}
+
 bool
 octave_complex::save_ascii (std::ostream& os)
 {
--- a/src/ov-complex.h	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-complex.h	Mon May 07 00:56:44 2012 +0200
@@ -163,6 +163,8 @@
     return boolNDArray (dim_vector (1, 1), scalar != 0.0);
   }
 
+  octave_value diag (octave_idx_type m, octave_idx_type n) const;
+
   void increment (void) { scalar += 1.0; }
 
   void decrement (void) { scalar -= 1.0; }
--- a/src/ov-cx-diag.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-cx-diag.cc	Mon May 07 00:56:44 2012 +0200
@@ -229,3 +229,10 @@
     x = val.complex_value ();
   return retval;
 }
+
+/*
+
+%% bug #36368
+%!assert (diag ([1+i, 1-i])^2 , diag ([2i, -2i]), 4*eps);
+
+*/
--- a/src/ov-cx-mat.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-cx-mat.cc	Mon May 07 00:56:44 2012 +0200
@@ -292,6 +292,24 @@
   return retval;
 }
 
+octave_value
+octave_complex_matrix::diag (octave_idx_type m, octave_idx_type n) const
+{
+  octave_value retval;
+
+  if (matrix.ndims () == 2
+      && (matrix.rows () == 1 || matrix.columns () == 1))
+    {
+      ComplexMatrix mat = matrix.matrix_value ();
+
+      retval = mat.diag (m, n);
+    }
+  else
+    error ("diag: expecting vector argument");
+
+  return retval;
+}
+
 bool
 octave_complex_matrix::save_ascii (std::ostream& os)
 {
--- a/src/ov-cx-mat.h	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-cx-mat.h	Mon May 07 00:56:44 2012 +0200
@@ -135,6 +135,8 @@
 
   octave_value diag (octave_idx_type k = 0) const;
 
+  octave_value diag (octave_idx_type m, octave_idx_type n) const;
+
   void increment (void) { matrix += Complex (1.0); }
 
   void decrement (void) { matrix -= Complex (1.0); }
--- a/src/ov-fcn-handle.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-fcn-handle.cc	Mon May 07 00:56:44 2012 +0200
@@ -80,6 +80,9 @@
 
   if (uf && nm != anonymous)
     symbol_table::cache_name (uf->scope (), nm);
+
+  if (uf && uf->is_nested_function ())
+    ::error ("handles to nested functions are not yet supported");
 }
 
 octave_value_list
--- a/src/ov-float.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-float.cc	Mon May 07 00:56:44 2012 +0200
@@ -98,6 +98,12 @@
 }
 
 octave_value
+octave_float_scalar::diag (octave_idx_type m, octave_idx_type n) const
+{
+  return FloatDiagMatrix (Array<float> (dim_vector (1, 1), scalar), m, n);
+}
+
+octave_value
 octave_float_scalar::convert_to_str_internal (bool, bool, char type) const
 {
   octave_value retval;
--- a/src/ov-float.h	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-float.h	Mon May 07 00:56:44 2012 +0200
@@ -211,6 +211,8 @@
     return boolNDArray (dim_vector (1, 1), scalar);
   }
 
+  octave_value diag (octave_idx_type m, octave_idx_type n) const;
+
   octave_value convert_to_str_internal (bool pad, bool force, char type) const;
 
   void increment (void) { ++scalar; }
--- a/src/ov-flt-complex.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-flt-complex.cc	Mon May 07 00:56:44 2012 +0200
@@ -228,6 +228,12 @@
     }
 }
 
+octave_value
+octave_float_complex::diag (octave_idx_type m, octave_idx_type n) const
+{
+  return FloatComplexDiagMatrix (Array<FloatComplex> (dim_vector (1, 1), scalar), m, n);
+}
+
 bool
 octave_float_complex::save_ascii (std::ostream& os)
 {
--- a/src/ov-flt-complex.h	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-flt-complex.h	Mon May 07 00:56:44 2012 +0200
@@ -152,6 +152,8 @@
     return boolNDArray (dim_vector (1, 1), scalar != 1.0f);
   }
 
+  octave_value diag (octave_idx_type m, octave_idx_type n) const;
+
   void increment (void) { scalar += 1.0; }
 
   void decrement (void) { scalar -= 1.0; }
--- a/src/ov-flt-cx-mat.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-flt-cx-mat.cc	Mon May 07 00:56:44 2012 +0200
@@ -281,6 +281,24 @@
   return retval;
 }
 
+octave_value
+octave_float_complex_matrix::diag (octave_idx_type m, octave_idx_type n) const
+{
+  octave_value retval;
+
+  if (matrix.ndims () == 2
+      && (matrix.rows () == 1 || matrix.columns () == 1))
+    {
+      FloatComplexMatrix mat = matrix.matrix_value ();
+
+      retval = mat.diag (m, n);
+    }
+  else
+    error ("diag: expecting vector argument");
+
+  return retval;
+}
+
 bool
 octave_float_complex_matrix::save_ascii (std::ostream& os)
 {
--- a/src/ov-flt-cx-mat.h	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-flt-cx-mat.h	Mon May 07 00:56:44 2012 +0200
@@ -133,6 +133,8 @@
 
   octave_value diag (octave_idx_type k = 0) const;
 
+  octave_value diag (octave_idx_type m, octave_idx_type n) const;
+
   void increment (void) { matrix += FloatComplex (1.0); }
 
   void decrement (void) { matrix -= FloatComplex (1.0); }
--- a/src/ov-flt-re-mat.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-flt-re-mat.cc	Mon May 07 00:56:44 2012 +0200
@@ -264,6 +264,24 @@
 }
 
 octave_value
+octave_float_matrix::diag (octave_idx_type m, octave_idx_type n) const
+{
+  octave_value retval;
+
+  if (matrix.ndims () == 2
+      && (matrix.rows () == 1 || matrix.columns () == 1))
+    {
+      FloatMatrix mat = matrix.matrix_value ();
+
+      retval = mat.diag (m, n);
+    }
+  else
+    error ("diag: expecting vector argument");
+
+  return retval;
+}
+
+octave_value
 octave_float_matrix::convert_to_str_internal (bool, bool, char type) const
 {
   octave_value retval;
--- a/src/ov-flt-re-mat.h	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-flt-re-mat.h	Mon May 07 00:56:44 2012 +0200
@@ -164,6 +164,8 @@
 
   octave_value diag (octave_idx_type k = 0) const;
 
+  octave_value diag (octave_idx_type m, octave_idx_type n) const;
+
   // Use matrix_ref here to clear index cache.
   void increment (void) { matrix_ref () += 1.0; }
 
--- a/src/ov-range.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-range.cc	Mon May 07 00:56:44 2012 +0200
@@ -248,6 +248,13 @@
           : octave_value (range.diag (k)));
 }
 
+octave_value
+octave_range::diag (octave_idx_type m, octave_idx_type n) const
+{
+  Matrix mat = range.matrix_value ();
+
+  return mat.diag (m, n);
+}
 
 bool
 octave_range::is_true (void) const
--- a/src/ov-range.h	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-range.h	Mon May 07 00:56:44 2012 +0200
@@ -139,6 +139,8 @@
 
   octave_value diag (octave_idx_type k = 0) const;
 
+  octave_value diag (octave_idx_type m, octave_idx_type n) const;
+
   octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const
     { return range.sort (dim, mode); }
 
--- a/src/ov-re-mat.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-re-mat.cc	Mon May 07 00:56:44 2012 +0200
@@ -272,6 +272,24 @@
   return retval;
 }
 
+octave_value
+octave_matrix::diag (octave_idx_type m, octave_idx_type n) const
+{
+  octave_value retval;
+
+  if (matrix.ndims () == 2
+      && (matrix.rows () == 1 || matrix.columns () == 1))
+    {
+      Matrix mat = matrix.matrix_value ();
+
+      retval = mat.diag (m, n);
+    }
+  else
+    error ("diag: expecting vector argument");
+
+  return retval;
+}
+
 // We override these two functions to allow reshaping both
 // the matrix and the index cache.
 octave_value
--- a/src/ov-re-mat.h	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-re-mat.h	Mon May 07 00:56:44 2012 +0200
@@ -178,6 +178,8 @@
 
   octave_value diag (octave_idx_type k = 0) const;
 
+  octave_value diag (octave_idx_type m, octave_idx_type n) const;
+
   octave_value reshape (const dim_vector& new_dims) const;
 
   octave_value squeeze (void) const;
--- a/src/ov-scalar.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-scalar.cc	Mon May 07 00:56:44 2012 +0200
@@ -113,6 +113,12 @@
 }
 
 octave_value
+octave_scalar::diag (octave_idx_type m, octave_idx_type n) const
+{
+  return DiagMatrix (Array<double> (dim_vector (1, 1), scalar), m, n);
+}
+
+octave_value
 octave_scalar::convert_to_str_internal (bool, bool, char type) const
 {
   octave_value retval;
--- a/src/ov-scalar.h	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-scalar.h	Mon May 07 00:56:44 2012 +0200
@@ -212,6 +212,8 @@
     return boolNDArray (dim_vector (1, 1), scalar);
   }
 
+  octave_value diag (octave_idx_type m, octave_idx_type n) const;
+
   octave_value convert_to_str_internal (bool pad, bool force, char type) const;
 
   void increment (void) { ++scalar; }
--- a/src/ov-usr-fcn.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-usr-fcn.cc	Mon May 07 00:56:44 2012 +0200
@@ -188,8 +188,9 @@
     system_fcn_file (false), call_depth (-1),
     num_named_args (param_list ? param_list->length () : 0),
     subfunction (false), inline_function (false),
-    anonymous_function (false), class_constructor (false),
-    class_method (false), parent_scope (-1), local_scope (sid),
+    anonymous_function (false), nested_function(false),
+    class_constructor (false), class_method (false),
+    parent_scope (-1), local_scope (sid),
     curr_unwind_protect_frame (0)
 {
   if (cmd_list)
@@ -387,7 +388,7 @@
   // Save old and set current symbol table context, for
   // eval_undefined_error().
 
-  int context = is_anonymous_function () ? 0 : call_depth;
+  int context = active_context ();
 
   octave_call_stack::push (this, local_scope, context);
   frame.add_fcn (octave_call_stack::pop);
@@ -601,6 +602,9 @@
   if (takes_varargs ())
     symbol_table::varref ("varargin") = va_args.cell_value ();
 
+  // Force .ignored. variable to be undefined by default.
+  symbol_table::varref (".ignored.") = octave_value ();
+
   if (lvalue_list)
     {
       octave_idx_type nbh = 0;
@@ -622,11 +626,11 @@
             }
 
           symbol_table::varref (".ignored.") = bh;
-
-          symbol_table::mark_hidden (".ignored.");
-          symbol_table::mark_automatic (".ignored.");
         }
     }
+
+  symbol_table::mark_hidden (".ignored.");
+  symbol_table::mark_automatic (".ignored.");
 }
 
 DEFUN (nargin, args, ,
@@ -923,3 +927,40 @@
 
   return retval;
 }
+
+/*
+%!function [x, y] = try_isargout ()
+%!  if (isargout (1))
+%!    if (isargout (2))
+%!      x = 1; y = 2;
+%!    else
+%!      x = -1;
+%!    endif
+%!  else
+%!    if (isargout (2))
+%!      y = -2;
+%!    else
+%!      error ("no outputs requested");
+%!    endif
+%!  endif
+%!endfunction
+%!
+%!test
+%! [x, y] = try_isargout ();
+%! assert ([x, y], [1, 2]);
+%!
+%!test
+%! [x, ~] = try_isargout ();
+%! assert (x, -1);
+%!
+%!test
+%! [~, y] = try_isargout ();
+%! assert (y, -2);
+%!
+%!error [~, ~] = try_isargout ();
+%!
+%% Check to see that isargout isn't sticky:
+%!test
+%! [x, y] = try_isargout ();
+%! assert ([x, y], [1, 2]);
+*/
--- a/src/ov-usr-fcn.h	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov-usr-fcn.h	Mon May 07 00:56:44 2012 +0200
@@ -177,6 +177,12 @@
 
   ~octave_user_function (void);
 
+  symbol_table::context_id active_context () const
+  {
+    return is_anonymous_function ()
+      ? 0 : static_cast<symbol_table::context_id>(call_depth);
+  }
+
   octave_function *function_value (bool = false) { return this; }
 
   octave_user_function *user_function_value (bool = false) { return this; }
@@ -277,6 +283,10 @@
       : false;
   }
 
+  bool is_nested_function (void) const { return nested_function; }
+
+  void mark_as_nested_function (void) { nested_function = true; }
+
   void mark_as_class_constructor (void) { class_constructor = true; }
 
   bool is_class_constructor (const std::string& cname = std::string ()) const
@@ -400,6 +410,9 @@
   // TRUE means this is an anonymous function.
   bool anonymous_function;
 
+  // TRUE means this is a nested function. (either a child or parent)
+  bool nested_function;
+
   // TRUE means this function is the constructor for class object.
   bool class_constructor;
 
--- a/src/ov.h	Mon May 07 00:53:54 2012 +0200
+++ b/src/ov.h	Mon May 07 00:56:44 2012 +0200
@@ -1075,6 +1075,9 @@
   octave_value diag (octave_idx_type k = 0) const
     { return rep->diag (k); }
 
+  octave_value diag (octave_idx_type m, octave_idx_type n) const
+    { return rep->diag (m, n); }
+
   octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const
     { return rep->sort (dim, mode); }
   octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0,
--- a/src/pager.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/pager.cc	Mon May 07 00:56:44 2012 +0200
@@ -591,6 +591,7 @@
 Turn output pagination on or off.  Without an argument, @code{more}\n\
 toggles the current state.\n\
 The current state can be determined via @code{page_screen_output}.\n\
+@seealso{page_screen_output, page_output_immediately, PAGER, PAGER_FLAGS}\n\
 @end deftypefn")
 {
   octave_value_list retval;
@@ -650,6 +651,7 @@
 When called from inside a function with the \"local\" option, the variable is\n\
 changed locally for the function and any subroutines it calls.  The original\n\
 variable value is restored when exiting the function.\n\
+@seealso{page_screen_output, more, PAGER, PAGER_FLAGS}\n\
 @end deftypefn")
 {
   return SET_INTERNAL_VARIABLE (page_output_immediately);
@@ -669,6 +671,7 @@
 When called from inside a function with the \"local\" option, the variable is\n\
 changed locally for the function and any subroutines it calls.  The original\n\
 variable value is restored when exiting the function.\n\
+@seealso{more, page_output_immediately, PAGER, PAGER_FLAGS}\n\
 @end deftypefn")
 {
   return SET_INTERNAL_VARIABLE (page_screen_output);
@@ -688,7 +691,7 @@
 When called from inside a function with the \"local\" option, the variable is\n\
 changed locally for the function and any subroutines it calls.  The original\n\
 variable value is restored when exiting the function.\n\
-@seealso{more, page_screen_output, page_output_immediately, PAGER_FLAGS}\n\
+@seealso{PAGER_FLAGS, page_output_immediately, more, page_screen_output}\n\
 @end deftypefn")
 {
   return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (PAGER);
@@ -705,7 +708,7 @@
 When called from inside a function with the \"local\" option, the variable is\n\
 changed locally for the function and any subroutines it calls.  The original\n\
 variable value is restored when exiting the function.\n\
-@seealso{PAGER}\n\
+@seealso{PAGER, more, page_screen_output, page_output_immediately}\n\
 @end deftypefn")
 {
   return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (PAGER_FLAGS);
--- a/src/pt-assign.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/pt-assign.cc	Mon May 07 00:56:44 2012 +0200
@@ -431,7 +431,30 @@
                     }
                 }
               else
-                error ("element number %d undefined in return list", k+1);
+                {
+                  // This can happen for a function like
+                  //
+                  //   function varargout = f ()
+                  //     varargout{1} = nargout;
+                  //   endfunction
+                  //
+                  // called with
+                  //
+                  //    [a, ~] = f ();
+                  //
+                  // Then the list of of RHS values will contain one
+                  // element but we are iterating over the list of all
+                  // RHS values.  We shouldn't complain that a value we
+                  // don't need is missing from the list.
+
+                  if (ult.is_black_hole ())
+                    {
+                      k++;
+                      continue;
+                    }
+                  else
+                    error ("element number %d undefined in return list", k+1);
+                }
             }
 
           if (error_state)
@@ -467,6 +490,19 @@
   return retval;
 }
 
+/*
+%!function varargout = f ()
+%!  varargout{1} = nargout;
+%!endfunction
+%!
+%!test
+%! [a, ~] = f ();
+%! assert (a, 2);
+%!test
+%! [a, ~, ~, ~, ~] = f ();
+%! assert (a, 5);
+*/
+
 std::string
 tree_multi_assignment::oper (void) const
 {
--- a/src/pt-id.h	Mon May 07 00:53:54 2012 +0200
+++ b/src/pt-id.h	Mon May 07 00:56:44 2012 +0200
@@ -128,7 +128,7 @@
   {
     symbol_table::scope_id curr_scope = symbol_table::current_scope ();
 
-    if (scope != curr_scope)
+    if (scope != curr_scope || ! sym.is_valid ())
       {
         scope = curr_scope;
         sym = symbol_table::insert (sym.name ());
--- a/src/pt-mat.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/pt-mat.cc	Mon May 07 00:56:44 2012 +0200
@@ -784,7 +784,7 @@
         {
           // Optimize all scalars case.
           result.clear (dv);
-          assert (result.numel () == row.length ());
+          assert (static_cast<size_t> (result.numel ()) == row.length ());
           octave_idx_type i = 0;
           for (tm_row_const::iterator q = row.begin ();
                q != row.end () && ! error_state; q++)
--- a/src/symtab.cc	Mon May 07 00:53:54 2012 +0200
+++ b/src/symtab.cc	Mon May 07 00:56:44 2012 +0200
@@ -78,11 +78,25 @@
   singleton_cleanup_list::add (cleanup_instance);
 }
 
+symbol_table::context_id
+symbol_table::symbol_record::symbol_record_rep::active_context (void) const
+{
+  octave_user_function *fcn = curr_fcn;
+
+  // FIXME -- If active_context () == -1, then it does not make much
+  // sense to use this symbol_record. This means an attempt at accessing
+  // a variable from a function that has not been called yet is
+  // happening. This should be cleared up when an implementing closures.
+
+  return fcn && fcn->active_context () != static_cast<context_id> (-1)
+    ? fcn->active_context () : xcurrent_context;
+}
+
 void
 symbol_table::symbol_record::symbol_record_rep::dump
   (std::ostream& os, const std::string& prefix) const
 {
-  octave_value val = varval (xcurrent_context);
+  octave_value val = varval ();
 
   os << prefix << name;
 
@@ -625,40 +639,23 @@
       // subfunctions if we are currently executing a function defined
       // from a .m file.
 
-      scope_val_iterator r = subfunctions.find (xcurrent_scope);
-
       octave_user_function *curr_fcn = symbol_table::get_curr_fcn ();
 
-      if (r != subfunctions.end ())
+      for (scope_id scope = xcurrent_scope; scope >= 0;)
         {
-          // FIXME -- out-of-date check here.
-
-          return r->second;
-        }
-      else
-        {
-          if (curr_fcn)
+          scope_val_iterator r = subfunctions.find (scope);
+          if (r != subfunctions.end ())
             {
-              // FIXME -- maybe it would be better if we could just get
-              // a pointer to the parent function so we would have
-              // access to all info about it instead of only being able
-              // to query the current function for specific bits of info
-              // about its parent function?
+              // FIXME -- out-of-date check here.
 
-              scope_id pscope = curr_fcn->parent_fcn_scope ();
+              return r->second;
+            }
 
-              if (pscope > 0)
-                {
-                  r = subfunctions.find (pscope);
-
-                  if (r != subfunctions.end ())
-                    {
-                      // FIXME -- out-of-date check here.
-
-                      return r->second;
-                    }
-                }
-            }
+          octave_user_function *scope_curr_fcn = get_curr_fcn (scope);
+          if (scope_curr_fcn)
+            scope = scope_curr_fcn->parent_fcn_scope ();
+          else
+            scope = -1;
         }
 
       // Private function.
@@ -896,29 +893,21 @@
   // subfunctions if we are currently executing a function defined
   // from a .m file.
 
-  scope_val_iterator r = subfunctions.find (xcurrent_scope);
-
-  if (r != subfunctions.end ())
+  for (scope_id scope = xcurrent_scope; scope >= 0;)
     {
-      // FIXME -- out-of-date check here.
-
-      return r->second;
-    }
-  else if (curr_fcn)
-    {
-      scope_id pscope = curr_fcn->parent_fcn_scope ();
+      scope_val_iterator r = subfunctions.find (scope);
+      if (r != subfunctions.end ())
+        {
+          // FIXME -- out-of-date check here.
 
-      if (pscope > 0)
-        {
-          r = subfunctions.find (pscope);
+          return r->second;
+        }
 
-          if (r != subfunctions.end ())
-            {
-              // FIXME -- out-of-date check here.
-
-              return r->second;
-            }
-        }
+      octave_user_function *scope_curr_fcn = get_curr_fcn (scope);
+      if (scope_curr_fcn)
+        scope = scope_curr_fcn->parent_fcn_scope ();
+      else
+        scope = -1;
     }
 
   return octave_value ();
@@ -1144,6 +1133,23 @@
     }
 }
 
+void
+symbol_table::install_nestfunction (const std::string& name,
+                                    const octave_value& fcn,
+                                    scope_id parent_scope)
+{
+  install_subfunction (name, fcn, parent_scope);
+
+  // Stash the nest_parent for resolving variables after parsing is done.
+  octave_function *fv = fcn.function_value();
+
+  symbol_table *fcn_table = get_instance (fv->scope());
+
+  symbol_table *parent_table = get_instance (parent_scope);
+
+  parent_table->add_nest_child (*fcn_table);
+}
+
 octave_value
 symbol_table::find (const std::string& name,
                     const octave_value_list& args,
@@ -1456,6 +1462,44 @@
     }
 }
 
+void
+symbol_table::do_update_nest (void)
+{
+  if (nest_parent || nest_children.size ())
+    curr_fcn->mark_as_nested_function ();
+
+  if (nest_parent)
+    {
+      // fix bad symbol_records
+      for (table_iterator ti = table.begin (); ti != table.end (); ++ti)
+        {
+          symbol_record &ours = ti->second;
+          symbol_record parents;
+          if (! ours.is_formal ()
+              && nest_parent->look_nonlocal (ti->first, parents))
+            {
+              if (ours.is_global () || ours.is_persistent ())
+                ::error ("global and persistent may only be used in the topmost level in which a nested variable is used");
+                
+              if (! ours.is_formal ())
+                {
+                  ours.invalidate ();
+                  ti->second = parents;
+                }
+            }
+          else
+            ours.set_curr_fcn (curr_fcn);
+        }
+    }
+  else if (nest_children.size())
+    for (table_iterator ti = table.begin (); ti != table.end (); ++ti)
+      ti->second.set_curr_fcn (curr_fcn);
+
+  for (std::vector<symbol_table*>::iterator iter = nest_children.begin ();
+       iter != nest_children.end (); ++iter)
+    (*iter)->do_update_nest ();
+}
+
 DEFUN (ignore_function_time_stamp, args, nargout,
     "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {@var{val} =} ignore_function_time_stamp ()\n\
--- a/src/symtab.h	Mon May 07 00:53:54 2012 +0200
+++ b/src/symtab.h	Mon May 07 00:56:44 2012 +0200
@@ -208,22 +208,26 @@
     {
     public:
 
-      symbol_record_rep (const std::string& nm, const octave_value& v,
-                         unsigned int sc)
-        : name (nm), value_stack (), storage_class (sc), finfo (), count (1)
+      symbol_record_rep (scope_id s, const std::string& nm,
+                         const octave_value& v, unsigned int sc)
+        : decl_scope (s), curr_fcn (0), name (nm), value_stack (),
+          storage_class (sc), finfo (), valid (true), count (1)
       {
         value_stack.push_back (v);
       }
 
-      void force_variable (context_id context)
+      void force_variable (context_id context = xdefault_context)
       {
+        if (context == xdefault_context)
+          context = active_context ();
+
         octave_value& val = varref (context);
 
         if (! val.is_defined ())
           mark_forced ();
       }
 
-      octave_value& varref (context_id context)
+      octave_value& varref (context_id context = xdefault_context)
       {
         if (is_global ())
           return symbol_table::global_varref (name);
@@ -231,6 +235,9 @@
           return symbol_table::persistent_varref (name);
         else
           {
+            if (context == xdefault_context)
+              context = active_context ();
+
             context_id n = value_stack.size ();
             while (n++ <= context)
               value_stack.push_back (octave_value ());
@@ -239,7 +246,7 @@
           }
       }
 
-      octave_value varval (context_id context) const
+      octave_value varval (context_id context = xdefault_context) const
       {
         if (is_global ())
           return symbol_table::global_varval (name);
@@ -247,6 +254,9 @@
           return symbol_table::persistent_varval (name);
         else
           {
+            if (context == xdefault_context)
+              context = active_context ();
+
             if (context < value_stack.size ())
               return value_stack[context];
             else
@@ -254,9 +264,10 @@
           }
       }
 
-      void push_context (void)
+      void push_context (scope_id s)
       {
-        if (! (is_persistent () || is_global ()))
+        if (! (is_persistent () || is_global ())
+            && s == scope ())
           value_stack.push_back (octave_value ());
       }
 
@@ -274,11 +285,12 @@
       //
       // Here, X should only exist in the final stack frame.
 
-      size_t pop_context (void)
+      size_t pop_context (scope_id s)
       {
         size_t retval = 1;
 
-        if (! (is_persistent () || is_global ()))
+        if (! (is_persistent () || is_global ())
+            && s == scope ())
           {
             value_stack.pop_back ();
             retval = value_stack.size ();
@@ -287,9 +299,12 @@
         return retval;
       }
 
-      void clear (void)
+      void clear (void) { clear (scope ()); }
+
+      void clear (scope_id s)
       {
-        if (! (is_hidden () || is_inherited ()))
+        if (! (is_hidden () || is_inherited ())
+            && s == scope ())
           {
             if (is_global ())
               unmark_global ();
@@ -297,22 +312,33 @@
             if (is_persistent ())
               {
                 symbol_table::persistent_varref (name)
-                  = varval (xcurrent_context);
+                  = varval ();
 
                 unmark_persistent ();
               }
 
-            varref (xcurrent_context) = octave_value ();
+            varref () = octave_value ();
           }
       }
 
-      bool is_defined (context_id context) const
+      bool is_defined (context_id context = xdefault_context) const
       {
+        if (context == xdefault_context)
+          context = active_context ();
+
         return varval (context).is_defined ();
       }
 
+      bool is_valid (void) const
+      {
+        return valid;
+      }
+
       bool is_variable (context_id context) const
       {
+        if (context == xdefault_context)
+          context = active_context ();
+
         return (! is_local () || is_defined (context) || is_forced ());
       }
 
@@ -357,31 +383,49 @@
 
       void init_persistent (void)
       {
-        if (! is_defined (xcurrent_context))
+        if (! is_defined ())
           {
             mark_persistent ();
 
-            varref (xcurrent_context) = symbol_table::persistent_varval (name);
+            varref () = symbol_table::persistent_varval (name);
           }
         // FIXME -- this causes trouble with recursive calls.
         // else
         //   error ("unable to declare existing variable persistent");
       }
 
+      void invalidate (void)
+      {
+        valid = false;
+      }
+
       void erase_persistent (void)
       {
         unmark_persistent ();
         symbol_table::erase_persistent (name);
       }
 
-      symbol_record_rep *dup (void) const
+      context_id active_context (void) const;
+
+      scope_id scope (void) const { return decl_scope; }
+
+      void set_curr_fcn (octave_user_function *fcn)
       {
-        return new symbol_record_rep (name, varval (xcurrent_context),
+        curr_fcn = fcn;
+      }
+
+      symbol_record_rep *dup (scope_id new_scope) const
+      {
+        return new symbol_record_rep (new_scope, name, varval (),
                                       storage_class);
       }
 
       void dump (std::ostream& os, const std::string& prefix) const;
 
+      scope_id decl_scope;
+
+      octave_user_function* curr_fcn;
+
       std::string name;
 
       std::deque<octave_value> value_stack;
@@ -390,6 +434,8 @@
 
       fcn_info *finfo;
 
+      bool valid;
+
       octave_refcount<size_t> count;
 
     private:
@@ -403,10 +449,11 @@
 
   public:
 
-    symbol_record (const std::string& nm = std::string (),
+    symbol_record (scope_id s = xcurrent_scope,
+                   const std::string& nm = std::string (),
                    const octave_value& v = octave_value (),
                    unsigned int sc = local)
-      : rep (new symbol_record_rep (nm, v, sc)) { }
+      : rep (new symbol_record_rep (s, nm, v, sc)) { }
 
     symbol_record (const symbol_record& sr)
       : rep (sr.rep)
@@ -434,39 +481,50 @@
         delete rep;
     }
 
-    symbol_record dup (void) const { return symbol_record (rep->dup ()); }
+    symbol_record dup (scope_id new_scope) const
+    {
+      return symbol_record (rep->dup (new_scope));
+    }
 
     std::string name (void) const { return rep->name; }
 
-    octave_value find (const octave_value_list& args = octave_value_list ()) const;
-
-    void force_variable (context_id context = xcurrent_context)
+    octave_value
+    find (const octave_value_list& args = octave_value_list ()) const;
+
+    void force_variable (context_id context = xdefault_context)
     {
       rep->force_variable (context);
     }
 
-    octave_value& varref (context_id context = xcurrent_context)
+    octave_value& varref (context_id context = xdefault_context)
     {
       return rep->varref (context);
     }
 
-    octave_value varval (context_id context = xcurrent_context) const
+    octave_value varval (context_id context = xdefault_context) const
     {
       return rep->varval (context);
     }
 
-    void push_context (void) { rep->push_context (); }
-
-    size_t pop_context (void) { return rep->pop_context (); }
+    void push_context (scope_id s) { rep->push_context (s); }
+
+    size_t pop_context (scope_id s) { return rep->pop_context (s); }
 
     void clear (void) { rep->clear (); }
 
-    bool is_defined (context_id context = xcurrent_context) const
+    void clear (scope_id s) { rep->clear (s); }
+
+    bool is_defined (context_id context = xdefault_context) const
     {
       return rep->is_defined (context);
     }
 
-    bool is_variable (context_id context = xcurrent_context) const
+    bool is_valid (void) const
+    {
+      return rep->is_valid ();
+    }
+
+    bool is_variable (context_id context = xdefault_context) const
     {
       return rep->is_variable (context);
     }
@@ -502,8 +560,16 @@
 
     void erase_persistent (void) { rep->erase_persistent (); }
 
+    void invalidate (void) { rep->invalidate (); }
+
+    context_id active_context (void) const { return rep->active_context (); }
+
+    scope_id scope (void) const { return rep->scope (); }
+
     unsigned int xstorage_class (void) const { return rep->storage_class; }
 
+    void set_curr_fcn (octave_user_function *fcn) { rep->set_curr_fcn (fcn); }
+
     void
     dump (std::ostream& os, const std::string& prefix = std::string ()) const
     {
@@ -930,7 +996,7 @@
 
         if (p == all_instances.end ())
           {
-            symbol_table *inst = new symbol_table ();
+            symbol_table *inst = new symbol_table (scope);
 
             if (inst)
               all_instances[scope] = instance = inst;
@@ -1011,7 +1077,7 @@
       {
         scope_id new_scope = alloc_scope ();
 
-        symbol_table *new_symbol_table = new symbol_table ();
+        symbol_table *new_symbol_table = new symbol_table (scope);
 
         if (new_symbol_table)
           {
@@ -1036,7 +1102,8 @@
   {
     symbol_table *inst = get_instance (scope);
 
-    return inst ? inst->do_find_symbol (name) : symbol_record ();
+    return inst ? inst->do_find_symbol (name) :
+      symbol_record (scope);
   }
 
   static void
@@ -1076,7 +1143,7 @@
 
   static void force_variable (const std::string& name,
                               scope_id scope = xcurrent_scope,
-                              context_id context = xcurrent_context)
+                              context_id context = xdefault_context)
   {
     symbol_table *inst = get_instance (scope);
 
@@ -1086,7 +1153,7 @@
 
   static octave_value& varref (const std::string& name,
                                scope_id scope = xcurrent_scope,
-                               context_id context = xcurrent_context)
+                               context_id context = xdefault_context)
   {
     static octave_value foobar;
 
@@ -1097,7 +1164,7 @@
 
   static octave_value varval (const std::string& name,
                               scope_id scope = xcurrent_scope,
-                              context_id context = xcurrent_context)
+                              context_id context = xdefault_context)
   {
     symbol_table *inst = get_instance (scope);
 
@@ -1265,6 +1332,17 @@
       }
   }
 
+  static void install_nestfunction (const std::string& name,
+                                    const octave_value& fcn,
+                                    scope_id parent_scope);
+
+  static void update_nest (scope_id scope)
+  {
+    symbol_table *inst = get_instance (scope);
+    if (inst)
+      inst->do_update_nest ();
+  }
+
   static void install_user_function (const std::string& name,
                                      const octave_value& fcn)
   {
@@ -1622,7 +1700,7 @@
 
   static std::list<symbol_record>
   all_variables (scope_id scope = xcurrent_scope,
-                 context_id context = xcurrent_context,
+                 context_id context = xdefault_context,
                  bool defined_only = true)
   {
     symbol_table *inst = get_instance (scope);
@@ -1674,7 +1752,8 @@
         // may be handled the same way.
 
         if (pat.match (p->first))
-          retval.push_back (symbol_record (p->first, p->second,
+          retval.push_back (symbol_record (xglobal_scope, 
+                                           p->first, p->second,
                                            symbol_record::global));
       }
 
@@ -1696,7 +1775,8 @@
         // may be handled the same way.
 
         if (pat.is_match (p->first))
-          retval.push_back (symbol_record (p->first, p->second,
+          retval.push_back (symbol_record (xglobal_scope,
+                                           p->first, p->second,
                                            symbol_record::global));
       }
 
@@ -1926,7 +2006,8 @@
       symbol_table *inst = get_instance (scope);
       // FIXME: normally, functions should not usurp each other's scope.
       // If for any incredible reason this is needed, call
-      // set_user_function (0, scope) first.
+      // set_user_function (0, scope) first. This may cause problems with
+      // nested functions, as the curr_fcn of symbol_records must be updated.
       assert (inst->curr_fcn == 0 || curr_fcn == 0);
       inst->curr_fcn = curr_fcn;
     }
@@ -1955,6 +2036,9 @@
 
   typedef std::map<std::string, fcn_info>::const_iterator fcn_table_const_iterator;
   typedef std::map<std::string, fcn_info>::iterator fcn_table_iterator;
+  
+  // The scope of this symbol table.
+  scope_id my_scope;
 
   // Name for this table (usually the file name of the function
   // corresponding to the scope);
@@ -1963,8 +2047,11 @@
   // Map from symbol names to symbol info.
   std::map<std::string, symbol_record> table;
 
-  // Mutex for symbol table access.
-  octave_mutex table_mutex;
+  // Child nested functions.
+  std::vector<symbol_table*> nest_children;
+
+  // Parent nested function (may be null).
+  symbol_table *nest_parent;
 
   // The associated user code (may be null).
   octave_user_function *curr_fcn;
@@ -2005,8 +2092,11 @@
 
   static context_id xcurrent_context;
 
-  symbol_table (void)
-    : table_name (), table (), curr_fcn (0), persistent_table () { }
+  static const context_id xdefault_context = static_cast<context_id> (-1);
+
+  symbol_table (scope_id scope)
+    : my_scope (scope), table_name (), table (), nest_children (), nest_parent (0),
+    curr_fcn (0), persistent_table () { }
 
   ~symbol_table (void) { }
 
@@ -2022,7 +2112,7 @@
           {
             if (! instance && create)
               {
-                symbol_table *inst = new symbol_table ();
+                symbol_table *inst = new symbol_table (scope);
 
                 if (inst)
                   {
@@ -2046,7 +2136,7 @@
               {
                 if (create)
                   {
-                    retval = new symbol_table ();
+                    retval = new symbol_table (scope);
 
                     if (retval)
                       all_instances[scope] = retval;
@@ -2068,6 +2158,13 @@
     return retval;
   }
 
+  void add_nest_child (symbol_table& st)
+  {
+    assert (!st.nest_parent);
+    nest_children.push_back (&st);
+    st.nest_parent = this;
+  }
+
   void insert_symbol_record (const symbol_record& sr)
   {
     octave_autolock lock (table_mutex);
@@ -2079,7 +2176,7 @@
   {
 	octave_autolock lock (table_mutex);
     for (table_const_iterator p = table.begin (); p != table.end (); p++)
-      new_symbol_table.insert_symbol_record (p->second.dup ());
+      new_symbol_table.insert_symbol_record (p->second.dup (new_symbol_table.my_scope));
   }
 
   symbol_record do_find_symbol (const std::string& name)
@@ -2135,8 +2232,17 @@
     octave_autolock lock (table_mutex);
     table_iterator p = table.find (name);
 
-    return p == table.end ()
-      ? (table[name] = symbol_record (name)) : p->second;
+    if (p == table.end ())
+      {
+        symbol_record parent_symbol;
+
+        if (nest_parent && nest_parent->look_nonlocal (name, parent_symbol))
+          return table[name] = parent_symbol;
+        else
+          return table[name] = symbol_record (my_scope, name, octave_value ());
+      }
+    else
+      return p->second;
   }
 
   void do_force_variable (const std::string& name, context_id context)
@@ -2223,7 +2329,7 @@
   {
     octave_autolock lock (table_mutex);
     for (table_iterator p = table.begin (); p != table.end (); p++)
-      p->second.push_context ();
+      p->second.push_context (my_scope);
   }
 
   void do_pop_context (void)
@@ -2231,8 +2337,8 @@
     octave_autolock lock (table_mutex);
     for (table_iterator p = table.begin (); p != table.end (); )
       {
-        if (p->second.pop_context () == 0)
-          table.erase (p++);
+        if (p->second.pop_context (my_scope) == 0)
+            table.erase (p++);
         else
           p++;
       }
@@ -2242,7 +2348,7 @@
   {
     octave_autolock lock (table_mutex);
     for (table_iterator p = table.begin (); p != table.end (); p++)
-      p->second.clear ();
+      p->second.clear (my_scope);
   }
 
   void do_clear_objects (void)
@@ -2253,7 +2359,7 @@
         symbol_record& sr = p->second;
         octave_value& val = sr.varref ();
         if (val.is_object())
-          p->second.clear ();
+          p->second.clear (my_scope);
       }
   }
 
@@ -2290,7 +2396,7 @@
     table_iterator p = table.find (name);
 
     if (p != table.end ())
-      p->second.clear ();
+      p->second.clear (my_scope);
   }
 
   void do_clear_global_pattern (const std::string& pat)
@@ -2332,7 +2438,7 @@
         if (sr.is_defined () || sr.is_global ())
           {
             if (pattern.match (sr.name ()))
-              sr.clear ();
+              sr.clear (my_scope);
           }
       }
   }
@@ -2349,7 +2455,7 @@
         if (sr.is_defined () || sr.is_global ())
           {
             if (pattern.is_match (sr.name ()))
-              sr.clear ();
+              sr.clear (my_scope);
           }
       }
   }
@@ -2493,6 +2599,25 @@
   void do_dump (std::ostream& os);
 
   void do_cache_name (const std::string& name) { table_name = name; }
+
+  void do_update_nest (void);
+
+  bool look_nonlocal (const std::string& name, symbol_record& result)
+  {
+    table_iterator p = table.find (name);
+    if (p == table.end ())
+      {
+        if (nest_parent)
+          return nest_parent->look_nonlocal (name, result);
+      }
+    else if (! p->second.is_automatic ())
+      {
+        result = p->second;
+        return true;
+      }
+
+    return false;
+  }
 };
 
 extern bool out_of_date_check (octave_value& function,
--- a/src/version.h.in	Mon May 07 00:53:54 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
-
-Copyright (C) 1992-2012 John W. Eaton
-
-This file is part of Octave.
-
-Octave is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 3 of the License, or (at your
-option) any later version.
-
-Octave is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with Octave; see the file COPYING.  If not, see
-<http://www.gnu.org/licenses/>.
-
-*/
-
-#if !defined (octave_version_h)
-#define octave_version_h 1
-
-#define OCTAVE_VERSION %OCTAVE_VERSION%
-
-#define OCTAVE_API_VERSION_NUMBER %OCTAVE_API_VERSION_NUMBER%
-
-#define OCTAVE_API_VERSION %OCTAVE_API_VERSION%
-
-#define OCTAVE_RELEASE_DATE %OCTAVE_RELEASE_DATE%
-
-#define OCTAVE_COPYRIGHT %OCTAVE_COPYRIGHT%
-
-// This is the first line printed by --version.  The GNU coding
-// standards say that the version number should follow the last space
-// on the line.
-
-#define OCTAVE_NAME_AND_VERSION "GNU Octave, version " OCTAVE_VERSION
-
-#define OCTAVE_CONFIG_STATEMENT \
-  "Octave was configured for \"" OCTAVE_CANONICAL_HOST_TYPE "\"."
-
-#define OCTAVE_COPYING_STATEMENT \
-  "This is free software; see the source code for copying conditions."
-
-#define X_OCTAVE_WARRANTY_STATEMENT(ARG) \
-  "There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or\n\
-FITNESS FOR A PARTICULAR PURPOSE." ARG
-
-#define OCTAVE_WARRANTY_STATEMENT \
-  X_OCTAVE_WARRANTY_STATEMENT ("")
-
-#define OCTAVE_WWW_STATEMENT \
-  "Additional information about Octave is available at http://www.octave.org."
-
-#define OCTAVE_CONTRIB_STATEMENT \
-  "Please contribute if you find this software useful.\n\
-For more information, visit http://www.octave.org/help-wanted.html"
-
-#define OCTAVE_BUGS_STATEMENT \
-  "Read http://www.octave.org/bugs.html to learn how to submit bug reports."
-
-#define OCTAVE_NAME_VERSION_AND_COPYRIGHT \
-  OCTAVE_NAME_AND_VERSION "\n" \
-  OCTAVE_COPYRIGHT
-
-#define OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_AND_WARRANTY \
-  X_OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_AND_WARRANTY("") \
-
-#define X_OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_AND_WARRANTY(ARG) \
-  OCTAVE_NAME_VERSION_AND_COPYRIGHT "\n" \
-  OCTAVE_COPYING_STATEMENT "\n" \
-  X_OCTAVE_WARRANTY_STATEMENT (ARG) "\n\n" \
-  OCTAVE_CONFIG_STATEMENT
-
-#define X_OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_WARRANTY_AND_BUGS(ARG) \
-  X_OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_AND_WARRANTY(ARG) "\n\n" \
-  OCTAVE_WWW_STATEMENT "\n\n" \
-  OCTAVE_CONTRIB_STATEMENT "\n\n" \
-  OCTAVE_BUGS_STATEMENT
-
-#define OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_WARRANTY_AND_BUGS \
-  X_OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_WARRANTY_AND_BUGS ("")
-
-#define OCTAVE_STARTUP_MESSAGE \
-  X_OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_WARRANTY_AND_BUGS \
-    ("  For details, type `warranty'.") "\n\n" \
-  "For information about changes from previous versions, type `news'."
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/version.in.h	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,91 @@
+/*
+
+Copyright (C) 1992-2012 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+#if !defined (octave_version_h)
+#define octave_version_h 1
+
+#define OCTAVE_VERSION %OCTAVE_VERSION%
+
+#define OCTAVE_API_VERSION_NUMBER %OCTAVE_API_VERSION_NUMBER%
+
+#define OCTAVE_API_VERSION %OCTAVE_API_VERSION%
+
+#define OCTAVE_RELEASE_DATE %OCTAVE_RELEASE_DATE%
+
+#define OCTAVE_COPYRIGHT %OCTAVE_COPYRIGHT%
+
+// This is the first line printed by --version.  The GNU coding
+// standards say that the version number should follow the last space
+// on the line.
+
+#define OCTAVE_NAME_AND_VERSION "GNU Octave, version " OCTAVE_VERSION
+
+#define OCTAVE_CONFIG_STATEMENT \
+  "Octave was configured for \"" OCTAVE_CANONICAL_HOST_TYPE "\"."
+
+#define OCTAVE_COPYING_STATEMENT \
+  "This is free software; see the source code for copying conditions."
+
+#define X_OCTAVE_WARRANTY_STATEMENT(ARG) \
+  "There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or\n\
+FITNESS FOR A PARTICULAR PURPOSE." ARG
+
+#define OCTAVE_WARRANTY_STATEMENT \
+  X_OCTAVE_WARRANTY_STATEMENT ("")
+
+#define OCTAVE_WWW_STATEMENT \
+  "Additional information about Octave is available at http://www.octave.org."
+
+#define OCTAVE_CONTRIB_STATEMENT \
+  "Please contribute if you find this software useful.\n\
+For more information, visit http://www.octave.org/help-wanted.html"
+
+#define OCTAVE_BUGS_STATEMENT \
+  "Read http://www.octave.org/bugs.html to learn how to submit bug reports."
+
+#define OCTAVE_NAME_VERSION_AND_COPYRIGHT \
+  OCTAVE_NAME_AND_VERSION "\n" \
+  OCTAVE_COPYRIGHT
+
+#define OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_AND_WARRANTY \
+  X_OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_AND_WARRANTY("") \
+
+#define X_OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_AND_WARRANTY(ARG) \
+  OCTAVE_NAME_VERSION_AND_COPYRIGHT "\n" \
+  OCTAVE_COPYING_STATEMENT "\n" \
+  X_OCTAVE_WARRANTY_STATEMENT (ARG) "\n\n" \
+  OCTAVE_CONFIG_STATEMENT
+
+#define X_OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_WARRANTY_AND_BUGS(ARG) \
+  X_OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_AND_WARRANTY(ARG) "\n\n" \
+  OCTAVE_WWW_STATEMENT "\n\n" \
+  OCTAVE_CONTRIB_STATEMENT "\n\n" \
+  OCTAVE_BUGS_STATEMENT
+
+#define OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_WARRANTY_AND_BUGS \
+  X_OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_WARRANTY_AND_BUGS ("")
+
+#define OCTAVE_STARTUP_MESSAGE \
+  X_OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_WARRANTY_AND_BUGS \
+    ("  For details, type `warranty'.") "\n\n" \
+  "For information about changes from previous versions, type `news'."
+#endif
--- a/test/Makefile.am	Mon May 07 00:53:54 2012 +0200
+++ b/test/Makefile.am	Mon May 07 00:56:44 2012 +0200
@@ -51,10 +51,12 @@
   test_while.m
 
 include bug-35448/module.mk
+include bug-36025/module.mk
 include classes/module.mk
 include class-concat/module.mk
 include ctor-vs-method/module.mk
 include fcn-handle-derived-resolution/module.mk
+include nest/module.mk
 
 check: test_sparse.m test_bc_overloads.m
 	$(top_builddir)/run-octave --norc --silent --no-history $(srcdir)/fntests.m $(srcdir)
--- a/test/bug-35448/module.mk	Mon May 07 00:53:54 2012 +0200
+++ b/test/bug-35448/module.mk	Mon May 07 00:56:44 2012 +0200
@@ -2,6 +2,6 @@
   bug-35448/fA.m \
   bug-35448/fB.m \
   bug-35448/fC.m \
-  class-concat/test_bug_35448.m
+  bug-35448/test_bug_35448.m
 
 FCN_FILES += $(bug_35448_FCN_FILES)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-36025/@testclass/one.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,4 @@
+% function ONE return item "X"
+
+function a=one(m)
+  a=m.x;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-36025/@testclass/testclass.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,3 @@
+function m=testclass(x,y)
+m=struct('x',x,'y',y); 
+m=class(m,"testclass"); 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-36025/@testclass/two.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,4 @@
+% function TWO returns item "Y"
+
+function a=one(m)
+  a=m.y;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-36025/module.mk	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,7 @@
+bug_36025_FCN_FILES = \
+  bug-36025/@testclass/one.m \
+  bug-36025/@testclass/testclass.m \
+  bug-36025/@testclass/two.m \
+  bug-36025/test_bug_36025.m
+
+FCN_FILES += $(bug_36025_FCN_FILES)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-36025/test_bug_36025.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,9 @@
+%!test
+%! warning off Octave:function-name-clash
+%! f = testclass (1, 2);
+%! assert (one (f), 1);
+%! assert (two (f), 2);
+%! rehash ();
+%! assert (one (f), 1);
+%! assert (two (f), 2);
+%! assert (two (f), 2);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nest/arg_nest.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,8 @@
+# arg_nest.m
+function x = arg_nest
+  x = 1;
+  A (x);
+  function A (x)
+    x = 2;
+  endfunction
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nest/arg_ret.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,7 @@
+function a = arg_ret
+  a = 10;
+  f;
+  function a = f
+    a = 5;
+  endfunction
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nest/module.mk	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,20 @@
+nest_FCN_FILES = \
+  nest/arg_nest.m \
+  nest/arg_ret.m \
+  nest/no_closure.m \
+  nest/persistent_nest.m \
+  nest/recursive_nest.m \
+  nest/recursive_nest2.m \
+  nest/recursive_nest3.m \
+  nest/scope0.m \
+  nest/scope1.m \
+  nest/scope2.m \
+  nest/scope3.m \
+  nest/script_nest.m \
+  nest/script_nest_script.m \
+  nest/test_nest.m \
+  nest/varg_nest.m \
+  nest/varg_nest2.m
+
+FCN_FILES += $(nest_FCN_FILES)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nest/no_closure.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,11 @@
+# no_closure.m
+function no_closure (n)
+  if n == 0
+    x = @no_closure;
+  else
+    f = @no_closure;
+  endif
+
+  function f
+  endfunction
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nest/persistent_nest.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,10 @@
+# persistent_nest
+function y = persistent_nest ()
+  persistent x = 0;
+  g;
+  y = x;
+
+  function g
+    x = x + 1;
+  end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nest/recursive_nest.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,13 @@
+# recursive_nest.m
+function x = recursive_nest ()
+  global recursive_nest_inc = 1
+  x = 5;
+  f (20);
+
+  function f (n)
+    if n > 0
+      x = x + recursive_nest_inc;
+      f (n - 1);
+    end
+  endfunction
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nest/recursive_nest2.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,21 @@
+# recursive_nest2.m
+function x = recursive_nest2 ()
+  x = B (20);
+  function v = B (n)
+    Y = 0;
+    BB (n);
+    C;
+    v = Y;
+    function BB (m)
+      if m > 0
+	Y = Y + 1;
+	BB(m - 1);
+	C;
+      end
+    endfunction
+  endfunction
+
+  function C
+    Y = 0;
+  endfunction
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nest/recursive_nest3.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,13 @@
+function x = recursive_nest3 ()
+  y = 5;
+  f (y);
+  x = y;
+  g (x);
+  function f (y)
+    y = 10;
+  endfunction
+
+  function g (x)
+    x = 10;
+  endfunction
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nest/scope0.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,16 @@
+# scope0.m
+function scope0
+  C;
+  function A
+    B;
+    function B
+    endfunction
+  endfunction
+
+  function C
+    D;
+    function D
+      A;
+    endfunction
+  endfunction
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nest/scope1.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,20 @@
+# scope1.m
+function scope1 (n)
+  value = n;
+  if value
+    C;
+  end
+  function A
+    B;
+    function B
+      scope1 (0);
+    endfunction
+  endfunction
+
+  function C
+    D;
+    function D
+      A;
+    endfunction
+  endfunction
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nest/scope2.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,17 @@
+# scope2.m
+function scope2
+  C;
+  function A
+    B;
+    function B
+      D;
+    endfunction
+  endfunction
+
+  function C
+    D;
+    function D
+      A;
+    endfunction
+  endfunction
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nest/scope3.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,19 @@
+# scope3.m
+function scope3
+  C;
+  function A
+    B;
+    function B
+      E;
+    endfunction
+    function E
+    endfunction
+  endfunction
+
+  function C
+    D;
+    function D
+      A;
+    endfunction
+  endfunction
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nest/script_nest.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,11 @@
+# script_nest.m
+function x = script_nest
+  A (5)
+  function A (n)
+    if n <= 0
+      script_nest_script;
+    else
+      A (n - 1);
+    endif
+  endfunction
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nest/script_nest_script.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,2 @@
+# script_nest_script.m
+x = 5;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nest/test_nest.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,53 @@
+## Copyright (C) 2006-2012 John W. Eaton
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+################################################################################
+## This file actually executes the tests on nested functions.
+##
+## It relies on the function files defined in the nest/ directory.
+################################################################################
+
+%!assert (recursive_nest (), 25)
+
+%!assert (recursive_nest2 (), 20)
+
+%!assert (recursive_nest3 (), 5)
+
+%!assert (script_nest (), 5)
+
+%!assert (arg_ret (), 10)
+
+%!assert (arg_nest, 1)
+
+%!assert (varg_nest (-1), 6)
+
+%!assert (varg_nest2, 5)
+
+%!test
+%! scope0;
+
+%!test
+%! scope1 (1);
+
+%!test
+%! scope3;
+
+%!error <D' undefined near line 7> scope2
+%!error <handles to nested functions are not yet supported> no_closure (0)
+%!error <handles to nested functions are not yet supported> no_closure (1)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nest/varg_nest.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,11 @@
+function x = varg_nest (varargin)
+  x = abs (f (-5)) + g;
+
+  function x = f (varargin)
+    x = abs (varargin{1});
+  endfunction
+
+  function x = g
+    x = abs (varargin{1});
+  endfunction
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/nest/varg_nest2.m	Mon May 07 00:56:44 2012 +0200
@@ -0,0 +1,14 @@
+function x = varg_nest2
+  [a, b] = f;
+  x = a;
+
+  if nargout == 1
+    x = a;
+  endif
+
+  function a, b = f
+    if nargout == 2
+      a = b = 5;
+    endif
+  endfunction
+endfunction