changeset 14882:02952657182e

maint: Periodic merge of stable to default
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Thu, 19 Jul 2012 11:48:40 -0400
parents 54a386f2ac4e (diff) 9e5df4d6cefa (current diff)
children a31a090c1628 f20312fc9046
files scripts/geometry/voronoi.m src/input.cc
diffstat 1317 files changed, 29871 insertions(+), 23066 deletions(-) [+]
line wrap: on
line diff
--- a/.hgsubstate
+++ b/.hgsubstate
@@ -1,1 +1,1 @@
-f9813bce2c06a6130a68db4478d1b16ddadaf276 gnulib
+33f823397dbb0edb57503f2f6dad2362456bc6a9 gnulib
--- a/.hgtags
+++ b/.hgtags
@@ -60,6 +60,10 @@
 64d9f33313cc8c691974bcd123357e24bccbabdc rc-3-6-0-1
 704f7895eef03008dd79848eb9da4bfb40787d73 release-3.6.0
 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
 f947d2922febf12dcd1fb6e21b356756ecb54e55 rc-3-6-2-0
 4460c4fb20e6a5d3b1972fa737d4e00eb921545a rc-3-6-2-2
 551566201318bf615b27c60ccf9368f4844008bd release-3-6-2
--- a/Makefile.am
+++ b/Makefile.am
@@ -70,8 +70,7 @@
 # Subdirectories in which to run `make all'.
 SUBDIRS = libgnu libcruft liboctave src scripts @DOCDIR@ examples test
 
-if AMCOND_BUILD_DOCS
-else
+if ! AMCOND_BUILD_DOCS
 dist-hook:
 	echo "Documentation disabled.  Cannot package distribution!" ; exit 1;
 endif
@@ -87,7 +86,9 @@
 
 CLEANFILES = $(BUILT_SOURCES)
 
-DISTCLEANFILES = .gdbinit 
+DISTCLEANFILES = \
+  .gdbinit \
+  ChangeLog
 
 MAINTAINERCLEANFILES = $(BUILT_DISTFILES)
 
@@ -119,8 +120,10 @@
 	  cp $< $@; \
 	fi
 
+if AMCOND_BUILD_DOCS
 AUTHORS BUGS INSTALL.OCTAVE:
 	$(MAKE) -C doc/interpreter ../../$@
+endif
 .PHONY: AUTHORS BUGS INSTALL.OCTAVE
 
 ChangeLog:
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,107 @@
+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
+    Octave:array-as-vector => Octave:array-to-vector
+
+ ** The colormap function now provides new options--"list", "register",
+    and "unregister"--to list all available colormap functions, and to
+    add or remove a function name from the list of known colormap
+    functions.  Packages that implement extra colormaps should use these
+    commands with PKG_ADD and PKG_DEL statements.
+
+ ** The datevec function has been extended for better Matlab compatibility.
+    It now accepts string inputs in the following numerical formats: 12, 21,
+    22, 26, 29, 31.  This is undocumented, but verifiable, Matlab behavior.
+    In addition, the default for formats which do not specify a date is
+    January 1st of the current year.  The previous default was the current day,
+    month, and year.  This may produce changes in existing scripts.
+
+ ** Other new functions added in 3.8.0:
+
+      betaincinv  lines         tetramesh
+      colorcube   rgbplot
+      erfcinv     shrinkfaces
+      findfigs    splinefit
+      
+ ** Deprecated functions.
+
+    The following functions were deprecated in Octave 3.4 and have been
+    removed from Octave 3.8.
+                                           
+      autocor    dispatch              is_global    strerror
+      autocov    fstat                 krylovb      values  
+      betai      gammai                perror               
+      cellidx    glpkmex               replot               
+      cquad      is_duplicate_entry    saveimage            
+      
+    The following functions have been deprecated in Octave 3.8 and will
+    be removed from Octave 3.12 (or whatever version is the second major
+    release after 3.8):
+
+      <none yet>
+
+    The following keywords have been deprecated in Octave 3.8 and will
+    be removed from Octave 3.12 (or whatever version is the second major
+    release after 3.8):
+
+      static
+
 Summary of important user-visible changes for version 3.6:
 ---------------------------------------------------------
 
@@ -709,9 +813,9 @@
     be removed from Octave 3.8 (or whatever version is the second major
     release after 3.4):
 
-      autocor  cellidx   gammai     krylovb  saveimage 
-      autocov  dispatch  glpkmex    perror   strerror  
-      betai    fstat     is_global  replot   values    
+      autocor  cellidx   gammai     is_global  replot     values
+      autocov  dispatch  glpkmex    krylovb    saveimage
+      betai    fstat     intwarning perror     strerror
 
 Summary of important user-visible changes for version 3.2:
 ---------------------------------------------------------
--- a/build-aux/common.mk
+++ b/build-aux/common.mk
@@ -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@
 
@@ -340,6 +342,9 @@
 # The full path to the default doc cache file.
 doc_cache_file = @doc_cache_file@
 
+# The full path to the default texi macros file.
+texi_macros_file_file = @texi_macros_file@
+
 # Where to install and expect the info files describing Octave..
 infodir = @infodir@
 
@@ -630,6 +635,7 @@
   -e "s|%OCTAVE_PREFIX%|\"${prefix}\"|" \
   -e "s|%OCTAVE_API_VERSION%|\"${api_version}\"|" \
   -e "s|%OCTAVE_RELEASE%|\"${OCTAVE_RELEASE}\"|" \
+  -e "s|%OCTAVE_TEXI_MACROS_FILE%|\"${texi_macros_file}\"|" \
   -e "s|%OCTAVE_VERSION%|\"${version}\"|"
 $(simple_move_if_change_rule)
 endef
--- a/configure.ac
+++ b/configure.ac
@@ -27,13 +27,13 @@
 EXTERN_CFLAGS="$CFLAGS"
 EXTERN_CXXFLAGS="$CXXFLAGS"
 
-AC_INIT([GNU Octave], [3.6.2], [http://octave.org/bugs.html], [octave])
+AC_INIT([GNU Octave], [3.7.0+], [http://octave.org/bugs.html], [octave])
 
 dnl PACKAGE_VERSION is set by the AC_INIT VERSION arg
 OCTAVE_VERSION="$PACKAGE_VERSION"
 OCTAVE_API_VERSION_NUMBER="48"
 OCTAVE_API_VERSION="api-v$OCTAVE_API_VERSION_NUMBER+"
-OCTAVE_RELEASE_DATE="2012-05-31"
+OCTAVE_RELEASE_DATE="2012-02-22"
 OCTAVE_COPYRIGHT="Copyright (C) 2012 John W. Eaton and others."
 AC_SUBST(OCTAVE_VERSION)
 AC_SUBST(OCTAVE_API_VERSION_NUMBER)
@@ -118,6 +118,7 @@
 OCTAVE_SET_DEFAULT(man1dir, '$(mandir)/man1')
 OCTAVE_SET_DEFAULT(man1ext, '.1')
 OCTAVE_SET_DEFAULT(doc_cache_file, '$(octetcdir)/doc-cache')
+OCTAVE_SET_DEFAULT(texi_macros_file, '$(octetcdir)/macros.texi')
 OCTAVE_SET_DEFAULT(infofile, '$(infodir)/octave.info')
 OCTAVE_SET_DEFAULT(octincludedir, '$(includedir)/octave-$(version)/octave')
 OCTAVE_SET_DEFAULT(fcnfiledir, '$(datadir)/octave/$(version)/m')
@@ -193,10 +194,9 @@
   [if test "$enableval" = no; then
      DOCDIR=
      warn_docs="building documentation disabled; make dist will fail"
-     AC_MSG_WARN([$warn_docs])
+     OCTAVE_CONFIGURE_WARNING([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.
 
@@ -218,12 +218,12 @@
       AC_DEFINE(IDX_TYPE_LONG, 1, [Define to 1 if octave index type is long])
     else
       warn_64_bit="no suitable type found for octave_idx_type so disabling 64-bit features"
-      AC_MSG_WARN([$warn_64_bit])
+      OCTAVE_CONFIGURE_WARNING([warn_64_bit])
       USE_64_BIT_IDX_T=false
     fi
   else
     warn_64_bit="pointers are not 64-bits wide so disabling 64-bit features"
-    AC_MSG_WARN([$warn_64_bit])
+    OCTAVE_CONFIGURE_WARNING([warn_64_bit])
     USE_64_BIT_IDX_T=false
   fi
 fi
@@ -287,7 +287,7 @@
 case "$gcc_version" in
   [12].*)
     warn_gcc_version="gcc version $gcc_version is likely to cause problems"
-    AC_MSG_WARN([$warn_gcc_version])
+    OCTAVE_CONFIGURE_WARNING([warn_gcc_version])
   ;;
 esac
 
@@ -593,6 +593,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
@@ -642,9 +650,12 @@
 
 OCTAVE_IEEE754_DATA_FORMAT
 
+OCTAVE_CXX_BITWISE_OP_TEMPLATES
 OCTAVE_CXX_COMPLEX_SETTERS
 OCTAVE_CXX_COMPLEX_REFERENCE_ACCESSORS
 
+OCTAVE_CARBON_CGDISPLAYBITSPERPIXEL
+
 ### Check for the QHull library
 
 OCTAVE_CHECK_LIBRARY(qhull, QHull,
@@ -827,13 +838,15 @@
 ## libraries needed for native graphics renderer
 
 warn_freetype=""
+native_graphics=true
 
 check_opengl=false
 AC_ARG_WITH([opengl],
   [AS_HELP_STRING([--without-opengl], [don't use OpenGL libraries, disable native graphics])],
   [if test "x$withval" = xno; then
      warn_opengl="--without-opengl specified.  Native graphics will be disabled."
-     AC_MSG_WARN([$warn_opengl])
+     OCTAVE_CONFIGURE_WARNING([warn_opengl])
+     native_graphics=false
    else
      check_opengl=true
    fi],
@@ -849,6 +862,8 @@
 if test -z "$OPENGL_LIBS"; then
   if $check_opengl; then
     warn_fltk_opengl="OpenGL libs (GL and GLU) not found. Native graphics will be disabled."
+    OCTAVE_CONFIGURE_WARNING([warn_fltk_opengl])
+    native_graphics=false
   fi
 fi
 
@@ -861,6 +876,11 @@
     XTRA_CXXFLAGS="$XTRA_CXXFLAGS $FT2_CFLAGS"],
     [warn_freetype="FreeType library not found.  Native graphics will be disabled."])
 
+  if test -n "$warn_freetype"; then
+    OCTAVE_CONFIGURE_WARNING([warn_freetype])
+    native_graphics=false
+  fi
+
   ## fontconfig library
 
   warn_fontconfig=""
@@ -874,6 +894,11 @@
       warn_fontconfig="Fontconfig library not found.  Native graphics will be disabled."])
   fi
 
+  if test -n "$warn_fontconfig"; then
+    OCTAVE_CONFIGURE_WARNING([warn_fontconfig])
+    native_graphics=false
+  fi
+
   ## fltk (www.fltk.org)
 
   AC_ARG_WITH([fltk-prefix], [
@@ -909,6 +934,8 @@
 
   if test "$FLTK_CONFIG" = "no" ; then
     warn_fltk_config="FLTK config script not found.  Native graphics will be disabled."
+    OCTAVE_CONFIGURE_WARNING([warn_fltk_config])
+    native_graphics=false
   else
     FLTK_CFLAGS="`$FLTK_CONFIG $fltkconf_args --use-gl --cflags`"
     FLTK_LDFLAGS="`$FLTK_CONFIG $fltkconf_args --use-gl --ldflags`"
@@ -935,6 +962,9 @@
     if test -z "$warn_fltk_opengl"; then
       GRAPHICS_CFLAGS="$FLTK_CFLAGS"
       GRAPHICS_LIBS="$FLTK_LDFLAGS"
+    else
+      OCTAVE_CONFIGURE_WARNING([warn_fltk_opengl])
+      native_graphics=false
     fi
     CFLAGS="$save_CFLAGS"
   fi
@@ -1595,7 +1625,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
@@ -1893,6 +1923,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"
+  OCTAVE_CONFIGURE_WARNING([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
@@ -2240,6 +2280,8 @@
 
 warn_msg_printed=false
 
+OCTAVE_CONFIGURE_WARNING_SUMMARY
+
 if $ENABLE_DYNAMIC_LINKING; then
   if $SHARED_LIBS; then
     true
@@ -2250,156 +2292,6 @@
   fi
 fi
 
-if test -n "$gxx_only"; then
-  AC_MSG_WARN([$gxx_only])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_gcc_version"; then
-  AC_MSG_WARN([$warn_gcc_version])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_gcc_only"; then
-  AC_MSG_WARN([$warn_gcc_only])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_readline"; then
-  AC_MSG_WARN([$warn_readline])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_termlibs"; then
-  AC_MSG_WARN([$warn_termlibs])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_gperf"; then
-  AC_MSG_WARN([$warn_gperf])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_flex"; then
-  AC_MSG_WARN([$warn_flex])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_bison"; then
-  AC_MSG_WARN([$warn_bison])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_less"; then
-  AC_MSG_WARN([$warn_less])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_umfpack"; then
-  AC_MSG_WARN([$warn_umfpack])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_qrupdate"; then
-  AC_MSG_WARN([$warn_qrupdate])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_amd"; then
-  AC_MSG_WARN([$warn_amd])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_colamd"; then
-  AC_MSG_WARN([$warn_colamd])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_ccolamd"; then
-  AC_MSG_WARN([$warn_ccolamd])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_cholmod"; then
-  AC_MSG_WARN([$warn_cholmod])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_cxsparse"; then
-  AC_MSG_WARN([$warn_cxsparse])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_curl"; then
-  AC_MSG_WARN([$warn_curl])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_fftw"; then
-  AC_MSG_WARN([$warn_fftw])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_glpk"; then
-  AC_MSG_WARN([$warn_glpk])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_magick"; then
-  AC_MSG_WARN([$warn_magick])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_hdf5"; then
-  AC_MSG_WARN([$warn_hdf5])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_regex"; then
-  AC_MSG_WARN([$warn_regex])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_pcre"; then
-  AC_MSG_WARN([$warn_pcre])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_qhull"; then
-  AC_MSG_WARN([$warn_qhull])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_zlib"; then
-  AC_MSG_WARN([$warn_zlib])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_ghostscript"; then
-  AC_MSG_WARN([$warn_ghostscript])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_texi2dvi"; then
-  AC_MSG_WARN([$warn_texi2dvi])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_texi2pdf"; then
-  AC_MSG_WARN([$warn_texi2pdf])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_docs"; then
-  AC_MSG_WARN([$warn_docs])
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_64_bit"; then
-  AC_MSG_WARN([$warn_64_bit])
-  warn_msg_printed=true
-fi
-
 if $USE_64_BIT_IDX_T; then
   AC_MSG_WARN([])
   AC_MSG_WARN([You used the EXPERIMENTAL --enable-64 option.])
@@ -2430,37 +2322,6 @@
   warn_msg_printed=true
 fi
 
-native_graphics=true
-if test -n "$warn_opengl"; then
-  AC_MSG_WARN([$warn_opengl])
-  native_graphics=false
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_freetype"; then
-  AC_MSG_WARN([$warn_freetype])
-  native_graphics=false
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_fontconfig"; then
-  AC_MSG_WARN([$warn_fontconfig])
-  native_graphics=false
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_fltk_config"; then
-  AC_MSG_WARN([$warn_fltk_config])
-  native_graphics=false
-  warn_msg_printed=true
-fi
-
-if test -n "$warn_fltk_opengl"; then
-  AC_MSG_WARN([$warn_fltk_opengl])
-  native_graphics=false
-  warn_msg_printed=true
-fi
-
 if $native_graphics; then
   true;
 else
@@ -2516,8 +2377,9 @@
 
 if $warn_msg_printed; then
   AC_MSG_NOTICE([])
-  AC_MSG_NOTICE([NOTE: libraries may be skipped if a library is not found OR])
-  AC_MSG_NOTICE([NOTE: if the library on your system is missing required features.])
+  AC_MSG_NOTICE([NOTE: Libraries or auxiliary programs may be skipped if they are])
+  AC_MSG_NOTICE([NOTE: not found OR if they are missing required features on your])
+  AC_MSG_NOTICE([NOTE: system. ])
 fi
 
 ### End of configure.
--- a/doc/faq/OctaveFAQ.texi
+++ b/doc/faq/OctaveFAQ.texi
@@ -454,7 +454,7 @@
 @group
 octave:1> [3 1 4 1 5 9](3)
 ans = 4
-octave:2> cos([0 pi pi/4 7])(3)
+octave:2> cos ([0 pi pi/4 7])(3)
 ans = 0.70711
 @end group
 @end example
@@ -871,7 +871,7 @@
 @example
 @group
 function y = foo (x)
-  y = bar(x)
+  y = bar (x)
   function y = bar (x)
     y = @dots{};
   end
@@ -884,7 +884,7 @@
 @example
 @group
 function y = foo (x)
-   y = bar(x)
+   y = bar (x)
 end
 function y = bar (x)
    y = @dots{};
@@ -1065,7 +1065,7 @@
 
 @example
 @group
-  do_braindead_shortcircuit_evaluation(1)
+  do_braindead_shortcircuit_evaluation (1)
 @end group
 @end example
 
@@ -1102,7 +1102,7 @@
 logically true).
 
 Finally, note the inconsistence of thinking of the condition of an if
-statement as being equivalent to @code{all(X(:))} when @var{X} is a
+statement as being equivalent to @code{all (X(:))} when @var{X} is a
 matrix.  This is true for all cases EXCEPT empty matrices:
 
 @example
@@ -1147,7 +1147,7 @@
 @example
 @group
 function x = mldivide (A, b)
-  [Q, R, E] = qr(A);
+  [Q, R, E] = qr (A);
   x = [A \ b, E(:, 1:m) * (R(:, 1:m) \ (Q' * b))]
 end
 @end group
@@ -1161,14 +1161,14 @@
 A numerical question arises: how big can the null space component
 become, relative to the minimum-norm solution? Can it be nicely bounded,
 or can it be arbitrarily big? Consider this example:
-
+OctaveFAQ.texi
 @example
 @group
 m = 10;
 n = 10000;
-A = ones(m, n) + 1e-6 * randn(m,n);
-b = ones(m, 1) + 1e-6 * randn(m,1);
-norm(A \ b)
+A = ones (m, n) + 1e-6 * randn (m,n);
+b = ones (m, 1) + 1e-6 * randn (m,1);
+norm (A \ b)
 @end group
 @end example
 
@@ -1180,14 +1180,14 @@
 @group
 m = 5;
 n = 100;
-j = floor(m * rand(1, n)) + 1;
-b = ones(m, 1);
-A = zeros(m, n);
-A(sub2ind(size(A),j,1:n)) = 1;
+j = floor (m * rand (1, n)) + 1;
+b = ones (m, 1);
+A = zeros (m, n);
+A(sub2ind (size (A),j,1:n)) = 1;
 x = A \ b;
-[dummy,p] = sort(rand(1,n));
-y = A(:,p)\b;
-norm(x(p)-y)
+[dummy,p] = sort (rand (1,n));
+y = A(:,p) \ b;
+norm (x(p)-y)
 @end group
 @end example
 
@@ -1282,10 +1282,10 @@
 gives no safe way of temporarily changing global variables.
 
 @item
-Indexing can be applied to all objects in Octave and not just
+Indexing can be applied to all objects in Octave and not just a
 variable. Therefore @code{sin(x)(1:10);} for example is perfectly valid
 in Octave but not @sc{Matlab}. To do the same in @sc{Matlab} you must do
-@code{y = sin(x); y = y([1:10]);}
+@code{y = sin (x); y = y([1:10]);}
 
 @item
 Octave has the operators "++", "--", "-=", "+=", "*=", etc.  As
--- a/doc/interpreter/Makefile.am
+++ b/doc/interpreter/Makefile.am
@@ -179,23 +179,17 @@
 	@$(GREP) '#define HAVE_UMFPACK 1' $(top_builddir)/config.h > /dev/null || { echo "Documentation creation requires missing UMFPACK library.  Cannot package distribution!" ; exit 1; }
 	@$(GREP) '#define HAVE_QHULL 1' $(top_builddir)/config.h > /dev/null || { echo "Documentation creation requires missing QHULL library.  Cannot package distribution!" ; exit 1; }
 
-octetc_DATA = doc-cache
+octetc_DATA = doc-cache macros.texi
 
 DOCSTRING_FILES = $(shell $(srcdir)/find-docstring-files.sh "$(top_srcdir)")
 
 doc-cache: $(DOCSTRING_FILES) mk_doc_cache.m
-	$(top_builddir)/run-octave -f -q -H $(srcdir)/mk_doc_cache.m doc-cache $(DOCSTRING_FILES) || { rm -f doc-cache; exit 1; }
-
-## Program compiled only to help build documentation.  No need to install
-noinst_PROGRAMS = munge-texi
-
-munge_texi_SOURCES = munge-texi.cc
+	$(top_builddir)/run-octave -f -q -H $(srcdir)/mk_doc_cache.m doc-cache $(srcdir)/macros.texi $(DOCSTRING_FILES) || { rm -f doc-cache; exit 1; }
 
 $(MUNGED_TEXI_SRC): $(DOCSTRING_FILES) $(munge_texi_SOURCES)
 
-%.texi: %.txi
-	@$(MAKE) $(AM_MAKEFLAGS) munge-texi$(BUILD_EXEEXT)
-	./munge-texi $(top_srcdir) $(DOCSTRING_FILES) < $< > $@-t
+%.texi: %.txi munge-texi.pl
+	$(PERL) $(srcdir)/munge-texi.pl $(top_srcdir) $(DOCSTRING_FILES) < $< > $@-t
 	mv $@-t $@
 
 contributors.texi: contributors.in
@@ -204,6 +198,10 @@
 
 ../../AUTHORS: preface.texi contributors.texi
 	rm -f AUTHORS
+	if [ "x$(srcdir)" != "x." ] && [ -f $(srcdir)/contributors.texi ] && [ ! -f contributors.texi ]; then \
+		cp $(srcdir)/contributors.texi contributors.texi; \
+		touch -r $(srcdir)/contributors.texi contributors.texi; \
+	fi
 	-$(MAKEINFO) -D AUTHORSONLY \
 	  --no-validate --no-headers --no-split --output AUTHORS $<
 	mv AUTHORS ../../AUTHORS
@@ -251,8 +249,10 @@
   images \
   images.awk \
   images.mk \
+  macros.texi \
   mk_doc_cache.m \
   mkcontrib.awk \
+  munge-texi.pl \
   octave.dvi \
   octave.html \
   octave.pdf \
--- a/doc/interpreter/arith.txi
+++ b/doc/interpreter/arith.txi
@@ -255,6 +255,8 @@
 
 @DOCSTRING(betainc)
 
+@DOCSTRING(betaincinv)
+
 @DOCSTRING(betaln)
 
 @DOCSTRING(bincoeff)
@@ -271,6 +273,8 @@
 
 @DOCSTRING(erfinv)
 
+@DOCSTRING(erfcinv)
+
 @DOCSTRING(gamma)
 
 @DOCSTRING(gammainc)
--- a/doc/interpreter/basics.txi
+++ b/doc/interpreter/basics.txi
@@ -389,6 +389,8 @@
 
 @DOCSTRING(makeinfo_program)
 
+@DOCSTRING(texi_macros_file)
+
 @DOCSTRING(doc_cache_file)
 
 @DOCSTRING(suppress_verbose_help_message)
@@ -1021,10 +1023,10 @@
 @group
 function countdown
   # Count down for main rocket engines 
-  disp(3);
-  disp(2);
-  disp(1);
-  disp("Blast Off!");  # Rocket leaves pad
+  disp (3);
+  disp (2);
+  disp (1);
+  disp ("Blast Off!");  # Rocket leaves pad
 endfunction
 @end group
 @end example
@@ -1044,19 +1046,19 @@
 @group
 function quick_countdown
   # Count down for main rocket engines 
-  disp(3);
+  disp (3);
  #@{
-  disp(2);
-  disp(1);
+  disp (2);
+  disp (1);
  #@}
-  disp("Blast Off!");  # Rocket leaves pad
+  disp ("Blast Off!");  # Rocket leaves pad
 endfunction
 @end group
 @end example
 
 @noindent
 will produce a very quick countdown from '3' to 'Blast Off' as the
-lines "@code{disp(2);}" and "@code{disp(1);}" won't be executed.
+lines "@code{disp (2);}" and "@code{disp (1);}" won't be executed.
 
 The block comment markers must appear alone as the only characters on a line
 (excepting whitespace) in order to be parsed correctly.
--- a/doc/interpreter/container.txi
+++ b/doc/interpreter/container.txi
@@ -308,7 +308,7 @@
 
 @example
 @group
-[x.a] = deal("new string1", "new string2");
+[x.a] = deal ("new string1", "new string2");
  x(1).a
      @result{} ans = new string1
  x(2).a
@@ -322,7 +322,7 @@
 @example
 @group
 x(3:4) = x(1:2);
-[x([1,3]).a] = deal("other string1", "other string2");
+[x([1,3]).a] = deal ("other string1", "other string2");
 x.a
      @result{}
         ans = other string1
@@ -337,7 +337,7 @@
 
 @example
 @group
-size(x)
+size (x)
      @result{} ans =
 
           1   4
@@ -605,10 +605,10 @@
 
 @example
 @group
-iscell(c)
+iscell (c)
      @result{} ans = 1
 
-iscell(3)
+iscell (3)
      @result{} ans = 0
 
 @end group
@@ -631,7 +631,7 @@
 
 @example
 @group
-c = cell(2,2)
+c = cell (2,2)
      @result{} c =
          
          @{
@@ -652,9 +652,9 @@
 
 @example
 @group
-c1 = cell(3, 4, 5);
-c2 = cell( [3, 4, 5] );
-size(c1)
+c1 = cell (3, 4, 5);
+c2 = cell ( [3, 4, 5] );
+size (c1)
      @result{} ans =
          3   4   5
 @end group
@@ -690,14 +690,14 @@
 
 @example
 @group
-c = @{"1", "2", "3"; "a", "b", "c"; "4", "5", "6"@};
+c = @{"1", "2", "3"; "x", "y", "z"; "4", "5", "6"@};
 c@{2,3@}
-     @result{} ans = c
+     @result{} ans = z
 
 c(2,3)
      @result{} ans = 
         @{
-          [1,1] = c
+          [1,1] = z
         @}
 @end group
 @end example
@@ -766,7 +766,7 @@
 
 @example
 @group
-[c@{[1,2], :@}] = deal(c@{[2, 1], :@})
+[c@{[1,2], :@}] = deal (c@{[2, 1], :@})
      @result{} = 
         @{
           [1,1] =  1
--- a/doc/interpreter/contrib.txi
+++ b/doc/interpreter/contrib.txi
@@ -66,28 +66,35 @@
 @itemize @bullet
 @item
 Check out a copy of the Octave sources:
+
 @example
 hg clone http://hg.savannah.gnu.org/hgweb/octave
 @end example
 
 @item
 Change to the top-level directory of the newly checked out sources:
+
 @example
 cd octave
 @end example
 
 @item
 Generate the necessary configuration files:
+
 @example
 ./autogen.sh
 @end example
 
 @item
 Create a build directory and change to it:
+
 @example
+@group
 mkdir build
 cd build
+@end group
 @end example
+
 By using a separate build directory, you will keep the source directory
 clean and it will be easy to completely remove all files generated by
 the build.  You can also have parallel build trees for different
@@ -98,15 +105,18 @@
 
 @item
 Run Octave's configure script from the build directory:
+
 @example
 ../configure
 @end example
 
 @item
 Run make in the build directory:
+
 @example
 make
 @end example
+
 @end itemize
 
 Once the build is finished, you will see a message like the following:
@@ -321,7 +331,7 @@
 @example
 @group
 if (isvector (a))
-  s = sum(a);
+  s = sum (a);
 endif
 @end group
 @end example
--- a/doc/interpreter/contributors.in
+++ b/doc/interpreter/contributors.in
@@ -20,6 +20,7 @@
 Richard Bovey
 John Bradshaw
 Marcus Brinkmann
+Max Brister
 Remy Bruno
 Ansgar Burchard
 Marco Caliari
@@ -101,6 +102,7 @@
 Kurt Hornik
 Christopher Hulbert
 Cyril Humbert
+John Hunt
 Teemu Ikonen
 Alan W. Irwin
 Geoff Jacobsen
@@ -152,9 +154,11 @@
 Hoxide Ma
 James Macnicol
 Jens-Uwe Mager
+Colin Macdonald
 Rob Mahurin
 Ricardo Marranita
 Orestes Mas
+Axel Mathéi
 Makoto Matsumoto
 Tatsuro Matsuoka
 Laurent Mazet
@@ -164,11 +168,13 @@
 Júlio Hoffimann Mendes
 Thorsten Meyer
 Petr Mikulik
+Mike Miller
 Stefan Monnier
 Antoine Moreau
 Kai P. Mueller
 Hannes Müller
 Victor Munoz
+Iain Murray
 Carmen Navarrete
 Todd Neal
 Philip Nienhuis
@@ -213,6 +219,7 @@
 Petter Risholm
 Matthew W. Roberts
 Andrew Ross
+Fabio Rossi
 Mark van Rossum
 Joe Rothweiler
 Kevin Ruland
@@ -266,6 +273,7 @@
 Karsten Trulsen
 Frederick Umminger
 Utkarsh Upadhyay
+Daniel Wagenaar
 Stefan van der Walt
 Peter Van Wieren
 James R. Van Zandt
--- a/doc/interpreter/diagperm.txi
+++ b/doc/interpreter/diagperm.txi
@@ -23,7 +23,7 @@
 * Basic Usage::          Creation and Manipulation of Diagonal and Permutation Matrices
 * Matrix Algebra::       Linear Algebra with Diagonal and Permutation Matrices
 * Function Support::     Functions That Are Aware of These Matrices
-* Example Codes::        Some Examples of Usage
+* Example Code::         Some Examples of Usage
 * Zeros Treatment::      The Differences in Treatment of Zero Elements
 @end menu
 
@@ -93,7 +93,7 @@
    0   0   3   0
    0   0   0   4
 
-  diag(1:3,5,3)
+  diag (1:3,5,3)
 
 @result{}
 Diagonal Matrix
@@ -412,7 +412,7 @@
 The @dfn{find} function will also work efficiently with a permutation matrix,
 making it possible to conveniently obtain the permutation indices.
 
-@node Example Codes
+@node Example Code
 @section Some Examples of Usage
 
 The following can be used to solve a linear system @code{A*x = b}
@@ -426,12 +426,23 @@
 @end example
 
 @noindent
-This is how you normalize columns of a matrix @var{X} to unit norm:
+This is one way to normalize columns of a matrix @var{X} to unit norm:
 
 @example
 @group
   s = norm (X, "columns");
-  X = diag (s) \ X;
+  X /= diag (s);
+@end group
+@end example
+
+@noindent
+The same can also be accomplished with broadcasting
+(@pxref{Broadcasting}):
+
+@example
+@group
+  s = norm (X, "columns");
+  X ./= s;
 @end group
 @end example
 
@@ -445,7 +456,7 @@
 @end example
 
 @noindent
-Finally, here's how you solve a linear system @code{A*x = b} 
+Finally, here's how you solve a linear system @code{A*x = b}
 with Tikhonov regularization (ridge regression) using SVD (a skeleton only):
 
 @example
@@ -500,6 +511,7 @@
 This behavior not only facilitates the most straightforward and efficient
 implementation of algorithms, but also preserves certain useful invariants,
 like:
+
 @itemize
 @item scalar * diagonal matrix is a diagonal matrix
 
@@ -542,13 +554,13 @@
 
 @example
 @group
-diag(1:3) * [NaN; 1; 1]
+diag (1:3) * [NaN; 1; 1]
 @result{}
    NaN
      2
      3
 
-sparse(1:3,1:3,1:3) * [NaN; 1; 1]
+sparse (1:3,1:3,1:3) * [NaN; 1; 1]
 @result{}
    NaN
      2
--- a/doc/interpreter/diffeq.txi
+++ b/doc/interpreter/diffeq.txi
@@ -100,8 +100,8 @@
 
 @example
 @group
-t = [0, logspace (-1, log10(303), 150), \
-        logspace (log10(304), log10(500), 150)];
+t = [0, logspace(-1, log10(303), 150), \
+        logspace(log10(304), log10(500), 150)];
 @end group
 @end example
 
--- a/doc/interpreter/doccheck/aspell-octave.en.pws
+++ b/doc/interpreter/doccheck/aspell-octave.en.pws
@@ -66,6 +66,7 @@
 binopdf
 binornd
 Biomathematics
+bitmapped
 bitmax
 bitwise
 bivariate
@@ -120,6 +121,7 @@
 chol
 Cholesky
 cholmod
+chrominance
 cindex
 circ
 circshift
@@ -138,6 +140,8 @@
 collectoutput
 colorbar
 colormap
+colormaps
+ColorOrder
 colperm
 Comint
 Commandline
@@ -336,6 +340,7 @@
 gesvd
 gfortan
 Ghostscript
+Ghostscript's
 gif
 GIF
 glibc
@@ -356,6 +361,7 @@
 gplot
 grabdemo
 GradObj
+GraphicsAlphaBits
 GraphicsMagick
 Graymap
 grayscale
@@ -531,6 +537,7 @@
 Mahalanobis
 makefile
 makefiles
+makeinfo
 Mandriva
 MANOVA
 manova
@@ -555,6 +562,7 @@
 metafiles
 Metafont
 mex
+mget
 Michelsen
 Microsystems
 MinGW
@@ -565,6 +573,7 @@
 MIP
 miscompiled
 Misra
+mkdir
 mkoctfile
 mldivide
 mmd
@@ -578,6 +587,7 @@
 Montanet
 mpoles
 mpower
+mput
 mrdivide
 MSYS
 mtimes
@@ -771,6 +781,7 @@
 Rightarrow
 rightarrow
 rline
+rmdir
 RMS
 rnd
 roffset
@@ -824,6 +835,7 @@
 Spearman's
 speye
 spfun
+splinefit
 spmatrix
 spones
 spparms
@@ -854,6 +866,8 @@
 stringanchors
 strncmp
 strncmpi
+strread
+strread's
 struct
 structs
 subarrays
@@ -910,6 +924,7 @@
 tex
 texinfo
 Texinfo
+TextAlphaBits
 textscan
 th
 ths
@@ -976,6 +991,7 @@
 unnormalized
 unpadded
 unpivoted
+unregister
 unshare
 unsymmetric
 untabified
@@ -1033,6 +1049,7 @@
 wp
 wspace
 xb
+xc
 xcorr
 xdigit
 xerrorbar
@@ -1054,6 +1071,7 @@
 xyerrorbar
 xyerrorbars
 xyz
+yc
 ydata
 yerrorbar
 yerrorbars
--- a/doc/interpreter/dynamic.txi
+++ b/doc/interpreter/dynamic.txi
@@ -551,7 +551,7 @@
 should use @code{numel} rather than @code{nelem}.  Note that for very
 large matrices, where the product of the two dimensions is larger than
 the representation of an unsigned int, then @code{numel} can overflow.
-An example is @code{speye(1e6)} which will create a matrix with a million
+An example is @code{speye (1e6)} which will create a matrix with a million
 rows and columns, but only a million non-zero elements.  Therefore the
 number of rows by the number of columns in this case is more than two
 hundred times the maximum value that can be represented by an unsigned int.
@@ -901,9 +901,9 @@
 @group
 funcdemo (@@sin,1)
 @result{} 0.84147
-funcdemo (@@(x) sin(x), 1)
+funcdemo (@@(x) sin (x), 1)
 @result{} 0.84147
-funcdemo (inline ("sin(x)"), 1)
+funcdemo (inline ("sin (x)"), 1)
 @result{} 0.84147
 funcdemo ("sin",1)
 @result{} 0.84147
@@ -1008,7 +1008,7 @@
 @result{}
   b = 1.00000   0.50000   0.33333
   s = There are   3 values in the input vector
-[b, s] = fortdemo(0:3)
+[b, s] = fortdemo (0:3)
 error: fortsub:divide by zero
 error: exception encountered in Fortran subroutine fortsub_
 error: fortdemo: error in Fortran
@@ -1086,7 +1086,7 @@
 for (octave_idx_type i = 0; i < a.nelem (); i++)
   @{
     OCTAVE_QUIT;
-    b.elem(i) = 2. * a.elem(i);
+    b.elem (i) = 2. * a.elem (i);
   @}
 @end group
 @end example
@@ -1195,9 +1195,9 @@
 @group
 /*
 
-%!error (sin())
-%!error (sin(1,1))
-%!assert (sin([1,2]),[sin(1),sin(2)])
+%!error (sin ())
+%!error (sin (1,1))
+%!assert (sin ([1,2]),[sin(1),sin(2)])
 
 */
 @end group
@@ -1279,7 +1279,7 @@
 
 @example
 @group
-firstmexdemo()
+firstmexdemo ()
 @result{} 1.2346
 @end group
 @end example
@@ -1324,10 +1324,10 @@
 
 @example
 @group
-myfunc()
+myfunc ()
 @result{} You called function: myfunc
     This is the principal function
-myfunc2()
+myfunc2 ()
 @result{} You called function: myfunc2
 @end group
 @end example
@@ -1371,7 +1371,7 @@
 mwSize *dims;
 UINT32_T *pr;
 
-dims = (mwSize *) mxMalloc (2 * sizeof(mwSize));
+dims = (mwSize *) mxMalloc (2 * sizeof (mwSize));
 dims[0] = 2;
 dims[1] = 2;
 m = mxCreateNumericArray (2, dims, mxUINT32_CLASS, mxREAL);
@@ -1403,8 +1403,8 @@
 
 @example
 @group
-b = randn(4,1) + 1i * randn(4,1);
-all(b.^2 == mypow2(b))
+b = randn (4,1) + 1i * randn (4,1);
+all (b.^2 == mypow2 (b))
 @result{} 1
 @end group
 @end example
@@ -1434,7 +1434,7 @@
 
 @example
 @group
-mystring(["First String"; "Second String"])
+mystring (["First String"; "Second String"])
 @result{} s1 = Second String
         First String
 @end group
@@ -1549,7 +1549,7 @@
 @example
 a(1).f1 = "f11"; a(1).f2 = "f12"; 
 a(2).f1 = "f21"; a(2).f2 = "f22";
-b = mystruct(a)
+b = mystruct (a)
 @result{} field f1(0) = f11
     field f1(1) = f21
     field f2(0) = f12
@@ -1651,8 +1651,8 @@
 
 @example
 @group
-myfeval("sin", 1)
-a = myfeval("sin", 1)
+myfeval ("sin", 1)
+a = myfeval ("sin", 1)
 @result{} Hello, World!
     I have 2 inputs and 1 outputs
     I'm going to call the interpreter function sin
--- a/doc/interpreter/emacs.txi
+++ b/doc/interpreter/emacs.txi
@@ -329,6 +329,7 @@
 @end table
 
 If Font Lock mode is enabled, Octave mode will display
+
 @itemize @bullet
 @item
 strings in @code{font-lock-string-face}
@@ -436,6 +437,7 @@
 
 The effect of the commands which send code to the Octave process can be
 customized by the following variables.
+
 @table @code
 @item octave-send-echo-input
 Non-@code{nil} means echo input sent to the inferior Octave process.
--- a/doc/interpreter/errors.txi
+++ b/doc/interpreter/errors.txi
@@ -63,7 +63,7 @@
 @group
 function f (arg1)
   if (nargin == 0)
-    error("not enough input arguments");
+    error ("not enough input arguments");
   endif
 endfunction
 @end group
--- a/doc/interpreter/eval.txi
+++ b/doc/interpreter/eval.txi
@@ -127,8 +127,8 @@
 @group
 function save (file, name1, name2)
   f = open_save_file (file);
-  save_var(f, name1, evalin ("caller", name1));
-  save_var(f, name2, evalin ("caller", name2));
+  save_var (f, name1, evalin ("caller", name1));
+  save_var (f, name2, evalin ("caller", name2));
 endfunction
 @end group
 @end example
--- a/doc/interpreter/expr.txi
+++ b/doc/interpreter/expr.txi
@@ -258,7 +258,7 @@
 $a_i = \sqrt{i}$.
 @end tex
 @ifnottex
-a(i) = sqrt(i).
+a(i) = sqrt (i).
 @end ifnottex
 
 @example
@@ -772,8 +772,8 @@
 
 @example
 @group
-  abs(@var{z1}) < abs(@var{z2}) 
-  || (abs(@var{z1}) == abs(@var{z2}) && arg(@var{z1}) < arg(@var{z2}))
+  abs (@var{z1}) < abs (@var{z2}) 
+  || (abs (@var{z1}) == abs (@var{z2}) && arg (@var{z1}) < arg (@var{z2}))
 @end group
 @end example
 
--- a/doc/interpreter/func.txi
+++ b/doc/interpreter/func.txi
@@ -29,6 +29,7 @@
 like built-in functions.
 
 @menu
+* Introduction to Function and Script Files::
 * Defining Functions::          
 * Multiple Return Values::      
 * Variable-length Argument Lists::  
@@ -43,6 +44,39 @@
 * Organization of Functions::   
 @end menu
 
+@node Introduction to Function and Script Files
+@section Introduction to Function and Script Files
+
+There are seven different things covered in this section.
+@enumerate
+@item
+Typing in a function at the command prompt.
+
+@item
+Storing a group of commands in a file --- called a script file.
+
+@item
+Storing a function in a file---called a function file.
+
+@item
+Subfunctions in function files.
+
+@item
+Multiple functions in one script file.
+
+@item
+Private functions.
+
+@item
+Nested functions.
+@end enumerate
+
+Both function files and script files end with an extension of .m, for
+@sc{matlab} compatibility.  If you want more than one independent
+functions in a file, it must be a script file (@pxref{Script Files}),
+and to use these functions you must execute the script file before you
+can use the functions that are in the script file.
+
 @node Defining Functions
 @section Defining Functions
 @cindex @code{function} statement
@@ -717,6 +751,7 @@
 * Manipulating the Load Path::
 * Subfunctions::
 * Private Functions::
+* Nested Functions::
 * Overloading and Autoloading::
 * Function Locking::
 * Function Precedence::
@@ -737,7 +772,7 @@
 code adds @samp{~/Octave} to the load path.
 
 @example
-addpath("~/Octave")
+addpath ("~/Octave")
 @end example
 
 @noindent
@@ -825,6 +860,157 @@
 then @code{func2} is only available for use of the functions, like 
 @code{func1}, that are found in @code{<directory>}.
 
+@node Nested Functions
+@subsection Nested Functions
+
+Nested functions are similar to subfunctions in that only the main function is
+visible outside the file.  However, they also allow for child functions to
+access the local variables in their parent function.  This shared access mimics
+using a global variable to share information --- but a global variable which is
+not visible to the rest of Octave.  As a programming strategy, sharing data
+this way can create code which is difficult to maintain.  It is recommended to
+use subfunctions in place of nested functions when possible.
+
+As a simple example, consider a parent function @code{foo}, that calls a nested
+child function @code{bar}, with a shared variable @var{x}.
+
+@example
+@group
+function y = foo ()
+  x = 10;
+  bar ();
+  y = x;
+
+  function bar ()
+    x = 20;
+  endfunction
+endfunction
+
+foo ()
+ @result{} 20
+@end group
+@end example
+
+@noindent
+Notice that there is no special syntax for sharing @var{x}.  This can lead to
+problems with accidental variable sharing between a parent function and its
+child.  While normally variables are inherited, child function parameters and
+return values are local to the child function.
+
+Now consider the function @code{foobar} that uses variables @var{x} and
+@var{y}.  @code{foobar} calls a nested function @code{foo} which takes
+@var{x} as a parameter and returns @var{y}.  @code{foo} then calls @code{bat}
+which does some computation.
+
+@example
+@group
+function z = foobar ()
+  x = 0;
+  y = 0;
+  z = foo (5);
+  z += x + y;
+
+  function y = foo (x)
+    y = x + bat ();
+
+    function z = bat ()
+      z = x;
+    endfunction
+  endfunction
+endfunction
+
+foobar ()
+    @result{} 10
+@end group
+@end example
+
+@noindent
+It is important to note that the @var{x} and @var{y} in @code{foobar} remain
+zero, as in @code{foo} they are a return value and parameter respectively.  The
+@var{x} in @code{bat} refers to the @var{x} in @code{foo}.
+
+Variable inheritance leads to a problem for @code{eval} and scripts.  If a
+new variable is created in a parent function, it is not clear what should happen
+in nested child functions.  For example, consider a parent function @code{foo}
+with a nested child function @code{bar}:
+
+@example
+@group
+function y = foo (to_eval)
+  bar ();
+  eval (to_eval);
+
+  function bar ()
+    eval ("x = 100;");
+    eval ("y = x;");
+  endfunction
+endfunction
+
+foo ("x = 5;")
+    @result{} error: can not add variable "x" to a static workspace
+
+foo ("y = 10;")
+    @result{} 10
+
+foo ("")
+    @result{} 100
+@end group
+@end example
+
+@noindent
+The parent function @code{foo} is unable to create a new variable
+@var{x}, but the child function @code{bar} was successful.  Furthermore, even
+in an @code{eval} statement @var{y} in @code{bar} is the same @var{y} as in its
+parent function @code{foo}.  The use of @code{eval} in conjunction with nested
+functions is best avoided.
+
+As with subfunctions, only the first nested function in a file may be called
+from the outside.  Inside a function the rules are more complicated.  In
+general a nested function may call:
+
+@enumerate 0
+@item
+Globally visible functions
+
+@item
+Any function that the nested function's parent can call
+
+@item
+Sibling functions (functions that have the same parents)
+
+@item
+Direct children
+
+@end enumerate
+
+As a complex example consider a parent function @code{ex_top} with two
+child functions, @code{ex_a} and @code{ex_b}.  In addition, @code{ex_a} has two
+more child functions, @code{ex_aa} and @code{ex_ab}.  For example:
+
+@example
+function ex_top ()
+  ## Can call: ex_top, ex_a, and ex_b
+  ## Can NOT call: ex_aa and ex_ab
+
+  function ex_a ()
+    ## Call call everything
+
+    function ex_aa ()
+      ## Can call everything
+    endfunction
+
+    function ex_ab ()
+      ## Can call everything
+    endfunction
+  endfunction
+
+  function ex_b ()
+    ## Can call: ex_top, ex_a, and ex_b
+    ## Can NOT call: ex_aa and ex_ab
+  endfunction
+endfunction
+@end example
+
 @node Overloading and Autoloading
 @subsection Overloading and Autoloading
 
@@ -891,7 +1077,7 @@
 
 @example
 @group
-function count_calls()
+function count_calls ()
   persistent calls = 0;
   printf ("'count_calls' has been called %d times\n",
           ++calls);
@@ -1214,7 +1400,7 @@
 function @math{f(x) = x^2 + 2}.
 
 @example
-f = inline("x^2 + 2");
+f = inline ("x^2 + 2");
 @end example
 
 @noindent
@@ -1244,7 +1430,7 @@
 is equivalent to 
 
 @example
-my_command("hello", "world")
+my_command ("hello", "world")
 @end example
 
 @noindent
--- a/doc/interpreter/geometry.txi
+++ b/doc/interpreter/geometry.txi
@@ -72,7 +72,7 @@
 X = [ x(T(:,1)); x(T(:,2)); x(T(:,3)); x(T(:,1)) ];
 Y = [ y(T(:,1)); y(T(:,2)); y(T(:,3)); y(T(:,1)) ];
 axis ([0, 1, 0, 1]);
-plot(X, Y, "b", x, y, "r*");
+plot (X, Y, "b", x, y, "r*");
 @end group
 @end example
 
@@ -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
@@ -169,7 +172,7 @@
 @example
 @group
 @var{p} - @var{t}(end, :) = @var{beta}(1:end-1) * (@var{t}(1:end-1, :)
-      - ones(@var{N}, 1) * @var{t}(end, :)
+      - ones (@var{N}, 1) * @var{t}(end, :)
 @end group
 @end example
 
@@ -179,8 +182,8 @@
 @example
 @group
 @var{beta}(1:end-1) = (@var{p} - @var{t}(end, :)) / (@var{t}(1:end-1, :)
-      - ones(@var{N}, 1) * @var{t}(end, :))
-@var{beta}(end) = sum(@var{beta}(1:end-1))
+      - ones (@var{N}, 1) * @var{t}(end, :))
+@var{beta}(end) = sum (@var{beta}(1:end-1))
 @end group
 @end example
 
@@ -295,9 +298,9 @@
 
 @example
 @group
-rand("state",9);
-x = rand(10,1);
-y = rand(10,1);
+rand ("state",9);
+x = rand (10,1);
+y = rand (10,1);
 tri = delaunay (x, y);
 [vx, vy] = voronoi (x, y, tri);
 triplot (tri, x, y, "b");
@@ -333,7 +336,7 @@
 x = rand (10, 1);
 y = rand (10, 1);
 [c, f] = voronoin ([x, y]);
-af = zeros (size(f));
+af = zeros (size (f));
 for i = 1 : length (f)
   af(i) = polyarea (c (f @{i, :@}, 1), c (f @{i, :@}, 2));
 endfor
@@ -358,7 +361,7 @@
 vx = cos (pi * [-1 : 0.1: 1]);
 vy = sin (pi * [-1 : 0.1 : 1]);
 in = inpolygon (x, y, vx, vy);
-plot(vx, vy, x(in), y(in), "r+", x(!in), y(!in), "bo");
+plot (vx, vy, x(in), y(in), "r+", x(!in), y(!in), "bo");
 axis ([-2, 2, -2, 2]);
 @end group
 @end example
@@ -431,12 +434,12 @@
 
 @example
 @group
-rand("state",1);
-x=2*rand(1000,1)-1;
-y=2*rand(size(x))-1;
-z=sin(2*(x.^2+y.^2));
-[xx,yy]=meshgrid(linspace(-1,1,32));
-griddata(x,y,z,xx,yy);
+rand ("state", 1);
+x = 2*rand (1000,1) - 1;
+y = 2*rand (size (x)) - 1;
+z = sin (2*(x.^2+y.^2));
+[xx,yy] = meshgrid (linspace (-1,1,32));
+griddata (x,y,z,xx,yy);
 @end group
 @end example
 
--- a/doc/interpreter/grammar.txi
+++ b/doc/interpreter/grammar.txi
@@ -46,12 +46,12 @@
 @item @code{endif} @tab @code{endmethods} @tab @code{endparfor}
 @item @code{endproperties} @tab @code{endswitch} @tab @code{endwhile}
 @item @code{enumeration} @tab @code{events} @tab @code{for}
-@item @code{function} @tab @code{get} @tab @code{global}
-@item @code{if} @tab @code{methods} @tab @code{otherwise}
-@item @code{parfor} @tab @code{persistent} @tab @code{properties}
-@item @code{return} @tab @code{set} @tab @code{static}
-@item @code{switch} @tab @code{try} @tab @code{until}
-@item @code{unwind_protect} @tab @code{unwind_protect_cleanup} @tab @code{while}
+@item @code{function} @tab @code{global} @tab @code{if}
+@item @code{methods} @tab @code{otherwise} @tab @code{parfor}
+@item @code{persistent} @tab @code{properties} @tab @code{return}
+@item @code{static} @tab @code{switch} @tab @code{try}
+@item @code{until} @tab @code{unwind_protect} @tab @code{unwind_protect_cleanup}
+@item @code{while}
 @end multitable
 
 The function @code{iskeyword} can be used to quickly check whether an
--- a/doc/interpreter/image.txi
+++ b/doc/interpreter/image.txi
@@ -127,10 +127,14 @@
 
 @DOCSTRING(colormap)
 
+@DOCSTRING(rgbplot)
+
 @DOCSTRING(autumn)
 
 @DOCSTRING(bone)
 
+@DOCSTRING(colorcube)
+
 @DOCSTRING(cool)
 
 @DOCSTRING(copper)
@@ -145,6 +149,8 @@
 
 @DOCSTRING(jet)
 
+@DOCSTRING(lines)
+
 @DOCSTRING(ocean)
 
 @DOCSTRING(pink)
@@ -166,9 +172,9 @@
 An additional colormap is @code{gmap40}.  This code map contains only
 colors with integer values of the red, green and blue components.  This
 is a workaround for a limitation of gnuplot 4.0, that does not allow the color
-of line or patch objects to be set, and so @code{gmap40} is useful for gnuplot
-4.0 users, and in particular in conjunction with the @var{bar},
-@var{barh} or @var{contour} functions.
+of line or patch objects to be set.  @code{gmap40} is chiefly useful to gnuplot
+4.0 users, and particularly in conjunction with the @var{bar}, @var{surf},
+and @var{contour} functions.
 
 @DOCSTRING(gmap40)
 
--- a/doc/interpreter/images
+++ b/doc/interpreter/images
@@ -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
+++ b/doc/interpreter/install.txi
@@ -65,16 +65,16 @@
 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,
+automatically.  The commands for doing this vary by system.  Similarly,
 the names of pre-compiled packages vary by system and do not always
 match exactly the names listed in @ref{Build Tools} and @ref{External
 Packages}.
@@ -182,8 +182,10 @@
 (@url{http://www.netlib.org/blas}).  Accelerated BLAS libraries such as
 ATLAS (@url{http://math-atlas.sourceforge.net}) are recommeded for
 better performance.
+
 @item LAPACK
 Linear Algebra Package (@url{http://www.netlib.org/lapack}).
+
 @item PCRE
 The Perl Compatible Regular Expression library (http://www.pcre.org).
 @end table
@@ -196,7 +198,7 @@
 @end table
 
 If you wish to build Octave without GNU readline installed, you must use
-the @code{--disable-readline} option when running the configure script.
+the @option{--disable-readline} option when running the configure script.
 
 The following external software packages are optional but recommended:
 
@@ -249,7 +251,7 @@
 @code{load} and @code{save} commands to read and write HDF data files.
 
 @item OpenGL
-API for portable 2D and 3D graphics (@url{http://www.opengl.org}).  An
+API for portable 2-D and 3-D graphics (@url{http://www.opengl.org}).  An
 OpenGL implementation is required to provide Octave's OpenGL-based
 graphics functions.  Octave's OpenGL-based graphics functions usually
 outperform the gnuplot-based graphics functions because plot data can be
@@ -277,7 +279,7 @@
 @item zlib
 Data compression library (@url{http://zlib.net}).  The zlib library is
 required for Octave's @code{load} and @code{save} commands to handle
-compressed data, including @sc{Matlab} v5 MAT files.
+compressed data, including @sc{matlab} v5 MAT files.
 @end table
 
 @node Running Configure and Make
--- a/doc/interpreter/interp.txi
+++ b/doc/interpreter/interp.txi
@@ -50,17 +50,17 @@
 dt = 1;
 ti =-2:0.025:2;
 dti = 0.025;
-y = sign(t);
-ys = interp1(t,y,ti,'spline');
-yp = interp1(t,y,ti,'pchip');
-ddys = diff(diff(ys)./dti)./dti;
-ddyp = diff(diff(yp)./dti)./dti;
-figure(1);
-plot (ti, ys,'r-', ti, yp,'g-');
-legend('spline','pchip',4);
-figure(2);
-plot (ti, ddys,'r+', ti, ddyp,'g*');
-legend('spline','pchip');
+y = sign (t);
+ys = interp1 (t,y,ti,'spline');
+yp = interp1 (t,y,ti,'pchip');
+ddys = diff (diff (ys)./dti) ./ dti;
+ddyp = diff (diff (yp)./dti) ./ dti;
+figure (1);
+plot (ti,ys,'r-', ti,yp,'g-');
+legend ('spline', 'pchip', 4);
+figure (2);
+plot (ti,ddys,'r+', ti,ddyp,'g*');
+legend ('spline', 'pchip');
 @end group
 @end example
 
@@ -107,9 +107,9 @@
 ti = t(1) + [0 : k-1]*dt*n/k;
 y = sin (4*t + 0.3) .* cos (3*t - 0.1);
 yp = sin (4*ti + 0.3) .* cos (3*ti - 0.1);
-plot (ti, yp, 'g', ti, interp1(t, y, ti, 'spline'), 'b', ...
+plot (ti, yp, 'g', ti, interp1 (t, y, ti, 'spline'), 'b', ...
       ti, interpft (y, k), 'c', t, y, 'r+');
-legend ('sin(4t+0.3)cos(3t-0.1','spline','interpft','data');
+legend ('sin(4t+0.3)cos(3t-0.1', 'spline', 'interpft', 'data');
 @end group
 @end example
 
@@ -164,9 +164,9 @@
 v = f (xx,yy,zz);
 xi = yi = zi = -1:0.1:1;
 [xxi, yyi, zzi] = meshgrid (xi, yi, zi);
-vi = interp3(x, y, z, v, xxi, yyi, zzi, 'spline');
+vi = interp3 (x, y, z, v, xxi, yyi, zzi, 'spline');
 [xxi, yyi, zzi] = ndgrid (xi, yi, zi);
-vi2 = interpn(x, y, z, v, xxi, yyi, zzi, 'spline');
+vi2 = interpn (x, y, z, v, xxi, yyi, zzi, 'spline');
 mesh (zi, yi, squeeze (vi2(1,:,:)));
 @end group
 @end example
--- a/doc/interpreter/intro.txi
+++ b/doc/interpreter/intro.txi
@@ -104,7 +104,7 @@
 tolerance of the calculation. 
 
 @example
-octave:1> exp(i*pi)
+octave:1> exp (i*pi)
 @end example
 
 @subsection Creating a Matrix
new file mode 100644
--- /dev/null
+++ b/doc/interpreter/macros.texi
@@ -0,0 +1,65 @@
+@c Copyright (C) 2012 John W. Eaton
+@c
+@c This file is part of Octave.
+@c
+@c Octave is free software; you can redistribute it and/or modify it
+@c under the terms of the GNU General Public License as published by the
+@c Free Software Foundation; either version 3 of the License, or (at
+@c your option) any later version.
+@c 
+@c Octave is distributed in the hope that it will be useful, but WITHOUT
+@c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+@c FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+@c for more details.
+@c 
+@c You should have received a copy of the GNU General Public License
+@c along with Octave; see the file COPYING.  If not, see
+@c <http://www.gnu.org/licenses/>.
+
+@c FIXME -- someday, we might replace this with @backslashchar, which
+@c has been added to Texinfo.
+
+@macro xbackslashchar
+\\
+@end macro
+
+@c The following macro is used for the on-line help system, but we don't
+@c want lots of `See also: foo, bar, and baz' strings cluttering the
+@c printed manual (that information should be in the supporting text for
+@c each group of functions and variables).
+
+@macro seealso {args}
+@iftex
+@vskip 2pt
+@end iftex
+@ifnottex
+@c Texinfo @sp should work but in practice produces ugly results for HTML.
+@c A simple blank line produces the correct behavior. 
+@c @sp 1
+
+@end ifnottex
+@noindent
+@strong{See also:} \args\.
+@end macro
+
+@c The following macro marks words that aspell should ignore during
+@c spellchecking.  Within Texinfo it has no effect as it merely replaces
+@c the macro call with the argument itself.
+
+@macro nospell {arg}
+\arg\
+@end macro
+
+@c The following macro works around a situation where the Info/plain text
+@c expansion of the @code{XXX} macro is `XXX'.  The use of the apostrophe
+@c can be confusing if the code segment itself ends with a transpose operator.
+@ifinfo
+@macro xcode{arg}
+\arg\
+@end macro
+@end ifinfo
+@ifnotinfo
+@macro xcode{arg}
+@code{\arg\}
+@end macro
+@end ifnotinfo
--- a/doc/interpreter/mk_doc_cache.m
+++ b/doc/interpreter/mk_doc_cache.m
@@ -38,17 +38,20 @@
     error ("unable to open %s for reading", file);
   else
     tmp = fread (fid, Inf, "*char")';
-    ## Strip off header lines
-    [~, text{i}] = strtok (tmp, doc_delim);
+    if (isempty (strfind (tmp, doc_delim)))
+      ## No delimiter, copy verbatim (this is the case for the file
+      ## containing macro definitions, for example).
+      text{i} = tmp;
+    else
+      ## Strip off header lines
+      [~, text{i}] = strtok (tmp, doc_delim);
+    endif
   endif
 endfor
 text = [text{:}, doc_delim];
 
-## Modify Octave-specific macros before passing to makeinfo
+## Strip Texinfo markers and docstring separators.
 text = regexprep (text, "-\\*- texinfo -\\*-[ \t]*[\r\n]*", "");
-text = regexprep (text, '@seealso *\{([^}]*)\}', "See also: $1.");
-text = regexprep (text, '@nospell *\{([^}]*)\}', "$1");
-text = regexprep (text, '@xcode *\{([^}]*)\}', "$1");
 text = strrep (text, '@', "@@");
 
 ## Write data to temporary file for input to makeinfo
deleted file mode 100644
--- a/doc/interpreter/munge-texi.cc
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
-
-Copyright (C) 1999-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/>.
-
-*/
-
-#include <cctype>
-#include <iostream>
-#include <fstream>
-#include <string>
-#include <map>
-
-#include <cstdlib>
-#include <cstring>
-
-static std::string top_srcdir;
-
-static const char doc_delim = '';
-
-static std::map<std::string, std::string> help_text;
-
-static void
-fatal (const std::string& msg)
-{
-  std::cerr << msg << "\n";
-  exit (1);
-}
-
-static void
-usage (void)
-{
-  std::cerr << "usage: munge-texi TOP-SRCDIR DOCSTRING-FILE < file\n";
-  exit (1);
-}
-
-static std::string
-extract_symbol_name (std::istream& is)
-{
-  std::string symbol_name;
-
-  int c;
-  while ((c = is.get ()) != EOF && c != '\n')
-    symbol_name += static_cast<char> (c);
-
-  return symbol_name;
-}
-
-static std::string
-extract_docstring (std::istream& is)
-{
-  std::string doc;
-
-  int c;
-  while ((c = is.get ()) != EOF && c != doc_delim)
-    {
-      // Expand @seealso commands to Texinfo references.
-      if (c == '@')
-        {
-          char buf[16];
-          int i = 0;
-          buf[i++] = static_cast<char> (c);
-
-          if ((   buf[i++] = static_cast<char> (is.get ())) == 's'
-              && (buf[i++] = static_cast<char> (is.get ())) == 'e'
-              && (buf[i++] = static_cast<char> (is.get ())) == 'e'
-              && (buf[i++] = static_cast<char> (is.get ())) == 'a'
-              && (buf[i++] = static_cast<char> (is.get ())) == 'l'
-              && (buf[i++] = static_cast<char> (is.get ())) == 's'
-              && (buf[i++] = static_cast<char> (is.get ())) == 'o'
-              && (buf[i++] = static_cast<char> (is.get ())) == '{')
-            {
-              doc += "@seealso{";
-
-              bool first = true;
-
-              // process @seealso parameters
-              while ((c = is.get ()) != EOF
-                     && c != doc_delim
-                     && c != '}')
-                {
-                  // ignore whitespace and delimiters
-                  while (   c == ' '
-                         || c == '\t'
-                         || c == '\r'
-                         || c == '\n'
-                         || c == ',')
-                    {
-                      c = is.get ();
-                    }
-
-                  // test for end of @seealso
-                  if (c == '}')
-                    break;
-
-                  // get function name
-                  std::string function_name;
-                  do
-                    function_name += static_cast<char> (c);
-                  while ((c = is.get ()) != EOF
-                          && c != doc_delim
-                          && c != ' '
-                          && c != '\t'
-                          && c != '\r'
-                          && c != '\n'
-                          && c != ','
-                          && c != '}');
-                  if (first)
-                    first = false;
-                  else
-                    doc += ", ";
-
-                  if (function_name[0] == '@')
-                    function_name = "@" + function_name;
-
-                  doc += "@ref{doc-" + function_name + ",,"
-                    + function_name + "}";
-
-                  // test for end of @seealso
-                  if (c == '}')
-                    break;
-                }
-              if (c == '}')
-                doc += static_cast<char> (c);
-            }
-          else
-            {
-              for (int j = 0; j < i; j++)
-                doc += buf[j];
-            }
-        }
-      else
-        doc += static_cast<char> (c);
-    }
-  return doc;
-}
-
-static void
-skip_comments (std::ifstream& is)
-{
-  int c;
-
-  bool in_comment = false;
-
-  while ((c = is.get ()) != EOF)
-    {
-      if (c == '#')
-        in_comment = true;
-      else if (c == '\n')
-        in_comment = false;
-      else if (! (in_comment || ::isspace (c)))
-        {
-          is.putback (c);
-          break;
-        }
-    }
-}
-
-static void
-process_doc_file (const std::string& fname)
-{
-  std::ifstream infile (fname.c_str ());
-
-  if (infile)
-    {
-      skip_comments (infile);
-
-      if (infile.get () != doc_delim)
-        fatal ("invalid doc file format");
-
-      std::string symbol_name;
-
-      do
-        {
-          symbol_name = extract_symbol_name (infile);
-
-          if (! symbol_name.empty ())
-            {
-              std::string doc_string = extract_docstring (infile);
-
-              if (help_text.find (symbol_name) != help_text.end ())
-                std::cerr << "ignoring duplicate entry for "
-                          << symbol_name << "\n";
-              else
-                help_text[symbol_name] = doc_string;
-            }
-        }
-      while (! symbol_name.empty ());
-    }
-  else
-    fatal ("unable to open docfile");
-}
-
-static bool
-recover_from_macro (std::ostream& os, char *buf, int i)
-{
-  bool bol = false;
-
-  buf[i] = '\0';
-  os << buf;
-
-  if (buf[i - 1] == '\n')
-    bol = true;
-
-  return bol;
-}
-
-static void
-process_example_file (const std::string& file_name, std::ostream& os)
-{
-  std::ifstream infile (file_name.c_str ());
-
-  if (infile)
-    {
-      os << "@verbatim\n";
-
-      int c;
-      int clast = 0;
-
-      while ((c = infile.get ()) != EOF)
-        {
-          os << static_cast<char> (c);
-          clast = c;
-        }
-
-      if (clast != '\n')
-        os << "\n";
-
-      os << "@end verbatim\n";
-    }
-  else
-    fatal ("unable to open example file " + file_name);
-}
-
-static void
-process_texi_input_file (std::istream& is, std::ostream& os)
-{
-  os << "@c DO NOT EDIT!  Generated automatically by munge-texi.\n\n";
-
-  bool bol = true;
-
-  int c;
-  while ((c = is.get ()) != EOF)
-    {
-      if (bol)
-        {
-          if (c == '@')
-            {
-              char buf[16];
-              int i = 0;
-              buf[i++] = static_cast<char> (c);
-
-              buf[i++] = c = static_cast<char> (is.get ());
-
-              if (c == 'D')
-                {
-                  std::string symbol_name;
-
-                  if (   (buf[i++] = static_cast<char> (is.get ())) == 'O'
-                      && (buf[i++] = static_cast<char> (is.get ())) == 'C'
-                      && (buf[i++] = static_cast<char> (is.get ())) == 'S'
-                      && (buf[i++] = static_cast<char> (is.get ())) == 'T'
-                      && (buf[i++] = static_cast<char> (is.get ())) == 'R'
-                      && (buf[i++] = static_cast<char> (is.get ())) == 'I'
-                      && (buf[i++] = static_cast<char> (is.get ())) == 'N'
-                      && (buf[i++] = static_cast<char> (is.get ())) == 'G'
-                      && (buf[i++] = static_cast<char> (is.get ())) == '(')
-                    {
-                      while ((c = is.get ()) != EOF && c != ')')
-                        symbol_name += static_cast<char> (c);
-
-                      if (is.eof ())
-                        fatal ("end of file while reading @DOCSTRING command");
-                      else
-                        {
-                          std::string doc_string = help_text[symbol_name];
-
-                          size_t len = doc_string.length ();
-
-                          int j = 0;
-
-                          // If there is a leading comment with the file
-                          // name, copy it to the output.
-                          if (len > 1
-                              && doc_string[j] == '@'
-                              && doc_string[j+1] == 'c')
-                            {
-                              j = 2;
-                              while (doc_string[j++] != '\n')
-                                /* find eol */;
-
-                              os << doc_string.substr (0, j);
-                            }
-
-                          while (doc_string[j] == ' ')
-                            j++;
-
-                          if (doc_string.substr (j, 15) == "-*- texinfo -*-")
-                            {
-                              j += 15;
-
-                              while (isspace (doc_string[j]))
-                                j++;
-
-                              // Make `see also' references in functions
-                              // possible using @anchor{TAG} (new with
-                              // Texinfo 4.0).
-
-                              if (symbol_name[0] == '@')
-                                symbol_name = "@" + symbol_name;
-
-                              os << "@anchor{doc-" << symbol_name << "}\n";
-
-                              os << doc_string.substr (j);
-                            }
-                          else
-                            os << doc_string;
-                        }
-                    }
-                  else
-                    bol = recover_from_macro (os, buf, i);
-                }
-              else if (c == 'E')
-                {
-                  std::string file_name;
-
-                  if (   (buf[i++] = static_cast<char> (is.get ())) == 'X'
-                      && (buf[i++] = static_cast<char> (is.get ())) == 'A'
-                      && (buf[i++] = static_cast<char> (is.get ())) == 'M'
-                      && (buf[i++] = static_cast<char> (is.get ())) == 'P'
-                      && (buf[i++] = static_cast<char> (is.get ())) == 'L'
-                      && (buf[i++] = static_cast<char> (is.get ())) == 'E'
-                      && (buf[i++] = static_cast<char> (is.get ())) == 'F'
-                      && (buf[i++] = static_cast<char> (is.get ())) == 'I'
-                      && (buf[i++] = static_cast<char> (is.get ())) == 'L'
-                      && (buf[i++] = static_cast<char> (is.get ())) == 'E'
-                      && (buf[i++] = static_cast<char> (is.get ())) == '(')
-                    {
-                      while ((c = is.get ()) != EOF && c != ')')
-                        file_name += static_cast<char> (c);
-
-                      file_name = top_srcdir + "/examples/" + file_name;
-
-                      process_example_file (file_name, os);
-                    }
-                  else
-                    bol = recover_from_macro (os, buf, i);
-                }
-              else
-                bol = recover_from_macro (os, buf, i);
-            }
-          else
-            os.put (static_cast<char> (c));
-        }
-      else
-        {
-          if (c == '\n')
-            bol = true;
-
-          os.put (static_cast<char> (c));
-        }
-    }
-}
-
-int
-main (int argc, char **argv)
-{
-  int retval = 0;
-
-  if (argc > 1)
-    {
-      top_srcdir = *++argv;
-
-      while (*++argv)
-        process_doc_file (*argv);
-
-      process_texi_input_file (std::cin, std::cout);
-    }
-  else
-    {
-      usage ();
-
-      retval = 1;
-    }
-
-  return retval;
-
-}
new file mode 100755
--- /dev/null
+++ b/doc/interpreter/munge-texi.pl
@@ -0,0 +1,124 @@
+#!/usr/bin/perl -w
+
+# Validate program call
+die "usage: munge-texi TOP-SRCDIR DOCSTRING-FILE < file" if (@ARGV < 2);
+
+$top_srcdir = shift (@ARGV);
+
+# Constant patterns
+$doc_delim = qr/^\c_/;
+$tex_delim = qr/\Q-*- texinfo -*-\E/;
+$comment_line = qr/^\s*(?:$|#)/;
+# Pre-declare hash size for efficiency
+keys(%help_text) = 1800;
+
+################################################################################
+# Load DOCSTRINGS into memory while expanding @seealso references
+foreach $DOCSTRING_file (@ARGV)
+{
+  open (DOCFH, $DOCSTRING_file) or die "Unable to open $DOCSTRING_file\n";
+
+  # Skip comments
+  while (defined ($_ = <DOCFH>) and /$comment_line/o) {;}
+
+  # Validate DOCSTRING file format
+  die "invalid doc file format\n" if (! /$doc_delim/o);
+  
+  do 
+  {
+    chomp;
+    $symbol = substr ($_,1);
+    $docstring = extract_docstring ();
+    if ($help_text{$symbol})
+    {
+      warn "ignoring duplicate entry for $symbol\n";
+    }
+    else
+    {
+      $help_text{$symbol} = $docstring;
+    }
+
+  } while (! eof);
+
+}
+
+################################################################################
+# Process .txi to .texi by expanding @DOCSTRING, @EXAMPLEFILE macros
+
+# Add warning header
+print '@c DO NOT EDIT!  Generated automatically by munge-texi.',"\n\n";
+
+TXI_LINE: while (<STDIN>)
+{
+  if (/^\s*\@DOCSTRING\((\S+)\)/)
+  {
+    $func = $1;
+    $docstring = $help_text{$func};
+    if (! $docstring)
+    {
+      warn "no docstring entry for $func\n";
+      next TXI_LINE;
+    }
+
+    $func =~ s/^@/@@/;   # Texinfo uses @@ to produce '@'
+    $docstring =~ s/^$tex_delim$/\@anchor{doc-$func}/m;
+    print $docstring,"\n";
+
+    next TXI_LINE;
+  }
+  if (/^\s*\@EXAMPLEFILE\((\S+)\)/)
+  {
+    $fname = "$top_srcdir/examples/$1";
+    print '@verbatim',"\n";
+    open (EXAMPFH, $fname) or die "unable to open example file $fname\n";
+    while (<EXAMPFH>) 
+    { 
+      print $_;
+      print "\n" if (eof and substr ($_, -1) ne "\n");
+    }
+    close (EXAMPFH);
+    print '@end verbatim',"\n\n";
+
+    next TXI_LINE;
+  }
+
+  # pass ordinary lines straight through to output
+  print $_;
+}
+
+
+################################################################################
+# Subroutines 
+################################################################################
+sub extract_docstring
+{
+  my ($docstring, $arg_list, $func_list, $repl, $rest_of_line);
+  
+  while (defined ($_ = <DOCFH>) and ! /$doc_delim/o)
+  {
+    # expand any @seealso references
+    if (m'^@seealso{')
+    {
+      # Join multiple lines until full macro body found
+      while (! /}/m) { $_ .= <DOCFH>; }
+
+      ($arg_list, $rest_of_line) = m'^@seealso{(.*)}(.*)?'s;
+     
+      $func_list = $arg_list;
+      $func_list =~ s/\s+//gs;
+      $repl = "";
+      foreach $func (split (/,/, $func_list))
+      {
+        $func =~ s/^@/@@/;   # Texinfo uses @@ to produce '@'
+        $repl .= "\@ref{doc-$func,,$func}, ";
+      }
+      substr($repl,-2) = "";   # Remove last ', ' 
+      $_ = "\@seealso{$repl}$rest_of_line";
+    }
+
+    $docstring .= $_;
+  }
+
+  return $docstring;
+}
+
--- a/doc/interpreter/numbers.txi
+++ b/doc/interpreter/numbers.txi
@@ -570,7 +570,7 @@
 When doing integer division Octave will round the result to the nearest
 integer.  This is different from most programming languages, where the
 result is often floored to the nearest integer.  So, the result of
-@code{int32(5) ./ int32(8)} is @code{1}.
+@code{int32 (5) ./ int32 (8)} is @code{1}.
 
 @DOCSTRING(idivide)
 
@@ -773,9 +773,9 @@
 @example
 @group
 x = ones (2, 2);
-x (1, 1) = single (2)
-    @result{} x = 2   1
-           1   1
+x(1, 1) = single (2)
+   @result{} x = 2   1
+          1   1
 @end group
 @end example
 
--- a/doc/interpreter/octave.texi
+++ b/doc/interpreter/octave.texi
@@ -19,46 +19,7 @@
 \input texinfo
 @setfilename octave.info
 
-@c The following macro is used for the on-line help system, but we don't
-@c want lots of `See also: foo, bar, and baz' strings cluttering the
-@c printed manual (that information should be in the supporting text for
-@c each group of functions and variables).
-
-@macro seealso {args}
-@iftex
-@vskip 2pt
-@end iftex
-@ifnottex
-@c Texinfo @sp should work but in practice produces ugly results for HTML.
-@c A simple blank line produces the correct behavior. 
-@c @sp 1
-
-@end ifnottex
-@noindent
-@strong{See also:} \args\.
-@end macro
-
-@c The following macro marks words that aspell should ignore during
-@c spellchecking.  Within Texinfo it has no effect as it merely replaces
-@c the macro call with the argument itself.
-
-@macro nospell {arg}
-\arg\
-@end macro
-
-@c The following macro works around a situation where the Info/plain text
-@c expansion of the @code{XXX} macro is `XXX'.  The use of the apostrophe
-@c can be confusing if the code segment itself ends with a transpose operator.
-@ifinfo
-@macro xcode{arg}
-\arg\
-@end macro
-@end ifinfo
-@ifnotinfo
-@macro xcode{arg}
-@code{\arg\}
-@end macro
-@end ifnotinfo
+@include macros.texi
 
 @ifinfo
 @format
@@ -644,7 +605,7 @@
 * Basic Usage::          Creation and Manipulation of Diagonal and Permutation Matrices
 * Matrix Algebra::       Linear Algebra with Diagonal and Permutation Matrices
 * Function Support::     Functions That Are Aware of These Matrices
-* Example Codes::        Some Examples of Usage
+* Example Code::         Some Examples of Usage
 * Zeros Treatment::      The Differences in Treatment of Zero Elements
 
 Basic Usage
@@ -890,7 +851,7 @@
 
 Build Dependencies
 
-* Obtaining the Depencies Automatically::
+* Obtaining the Dependencies Automatically::
 * Build Tools::
 * External Packages::
 
--- a/doc/interpreter/oop.txi
+++ b/doc/interpreter/oop.txi
@@ -184,7 +184,7 @@
 
 @noindent
 Note that in the display method, it makes sense to start the method
-with the line @code{fprintf("%s =", inputname(1))} to be consistent
+with the line @code{fprintf ("%s =", inputname (1))} to be consistent
 with the rest of Octave and print the variable name to be displayed
 when displaying the class. 
 
@@ -317,7 +317,7 @@
 
 @example
 @group
-p = polynomial([1,2,3,4]);
+p = polynomial ([1,2,3,4]);
 p(end-1)
   @result{} 3
 @end group
@@ -354,7 +354,7 @@
 @group
   function x = subsasgn (x, ss, val)
     @dots{}
-    x.myfield(ss.subs@{1@}) = val;
+    x.myfield (ss.subs@{1@}) = val;
   endfunction
 @end group
 @end example
@@ -726,15 +726,15 @@
 
 @example
 @group
-octave:1> f=FIRfilter(polynomial([1 1 1]/3))
+octave:1> f = FIRfilter (polynomial ([1 1 1]/3))
 f.polynomial = 0.333333 + 0.333333 * X + 0.333333 * X ^ 2
-octave:2> class(f)
+octave:2> class (f)
 ans = FIRfilter
-octave:3> isa(f,"FIRfilter")
+octave:3> isa (f,"FIRfilter")
 ans =  1
-octave:4> isa(f,"polynomial")
+octave:4> isa (f,"polynomial")
 ans =  1
-octave:5> struct(f)
+octave:5> struct (f)
 ans = 
 @{
 polynomial = 0.333333 + 0.333333 * X + 0.333333 * X ^ 2
@@ -759,9 +759,9 @@
 
 @example
 @group
-octave:2> f=FIRfilter(polynomial([1 1 1]/3));
-octave:3> x=ones(5,1);
-octave:4> y=f(x)
+octave:2> f = FIRfilter (polynomial ([1 1 1]/3));
+octave:3> x = ones (5,1);
+octave:4> y = f(x)
 y =
 
    0.33333
@@ -776,7 +776,7 @@
 
 @example
 @group
-octave:1> f=FIRfilter(polynomial([1 1 1]/3));
+octave:1> f = FIRfilter (polynomial ([1 1 1]/3));
 octave:2> f.polynomial
 ans = 0.333333 + 0.333333 * X + 0.333333 * X ^ 2
 @end group
@@ -796,13 +796,12 @@
 
 @example
 @group
-octave:6> f=FIRfilter();
-octave:7> f.polynomial = polynomial([1 2 3]);
+octave:6> f = FIRfilter ();
+octave:7> f.polynomial = polynomial ([1 2 3]);
 f.polynomial = 1 + 2 * X + 3 * X ^ 2
 @end group
 @end example
 
-
 Defining the FIRfilter class as a child of the polynomial class
 implies that and FIRfilter object may be used any place that a
 polynomial may be used.  This is not a normal use of a filter, so that
--- a/doc/interpreter/package.txi
+++ b/doc/interpreter/package.txi
@@ -1,4 +1,4 @@
-@c Copyright (C) 2007-2012 S�ren Hauberg
+@c Copyright (C) 2007-2012 Søren Hauberg
 @c
 @c This file is part of Octave.
 @c
@@ -181,7 +181,6 @@
 following be referred to as @code{package} and may contain the
 following files:
 
-@noindent
 @table @code
 @item package/COPYING
 This is a required file containing the license of the package.  No
@@ -260,7 +259,6 @@
 Besides the above mentioned files, a package can also contain on or
 more of the following directories:
 
-@noindent
 @table @code
 @item package/inst
 An optional directory containing any files that are directly installed
@@ -305,7 +303,6 @@
 package, such as its name, author, and version.  This file has a very
 simple format
 
-@noindent
 @itemize
 @item
 Lines starting with @samp{#} are comments.
@@ -340,7 +337,6 @@
 
 The package manager currently recognizes the following keywords
 
-@noindent
 @table @code
 @item Name
 Name of the package.
@@ -441,7 +437,6 @@
 The optional @file{INDEX} file provides a categorical view of the
 functions in the package.  This file has a very simple format
 
-@noindent
 @itemize
 @item Lines beginning with @samp{#} are comments.
 
--- a/doc/interpreter/plot.txi
+++ b/doc/interpreter/plot.txi
@@ -363,6 +363,8 @@
 
 @DOCSTRING(isocolors)
 
+@DOCSTRING(shrinkfaces)
+
 @DOCSTRING(diffuse)
 
 @DOCSTRING(specular)
@@ -809,11 +811,11 @@
 @example
 @group
 x = 0:0.01:3;
-plot(x,erf(x));
+plot (x, erf (x));
 hold on;
-plot(x,x,"r");
-axis([0, 3, 0, 1]);
-text(0.65, 0.6175, strcat('\leftarrow x = @{2/\surd\pi',
+plot (x,x,"r");
+axis ([0, 3, 0, 1]);
+text (0.65, 0.6175, strcat ('\leftarrow x = @{2/\surd\pi',
 ' @{\fontsize@{16@}\int_@{\fontsize@{8@}0@}^@{\fontsize@{8@}x@}@}',
 ' e^@{-t^2@} dt@} = 0.6175'))
 @end group
@@ -834,15 +836,22 @@
 @cindex printing plots
 @cindex saving plots
 
-The @code{print} command allows you to save plots in a variety of
-formats.  For example,
+The @code{print} command allows you to send plots to you printer and
+to save plots in a variety of formats.  For example,
+
+@example
+print -dpsc
+@end example
+
+@noindent
+prints the current figure to a color PostScript printer.  And,
 
 @example
 print -deps foo.eps
 @end example
 
 @noindent
-writes the current figure to an encapsulated PostScript file called
+saves the current figure to an encapsulated PostScript file called
 @file{foo.eps}.
 
 @DOCSTRING(print)
@@ -1145,6 +1154,8 @@
 
 @DOCSTRING(allchild)
 
+@DOCSTRING(findfigs)
+
 @node Graphics Object Properties
 @subsection Graphics Object Properties
 @cindex graphics object properties
@@ -1169,6 +1180,7 @@
 @cindex root figure properties
 
 The @code{root figure} properties are:
+
 @table @code
 @item __modified__  
 --- Values: "on," "off"
@@ -1241,6 +1253,7 @@
 @cindex figure properties
 
 The @code{figure} properties are:
+
 @table @code
 @item __graphics_toolkit__  
 --- The graphics toolkit currently in use.
@@ -1324,6 +1337,7 @@
 respectively.  The functions are called with two input arguments.  The
 first argument holds the handle of the calling figure.  The second
 argument holds the event structure which has the following members:
+
 @table @code
 @item Character
 The ASCII value of the key
@@ -1345,6 +1359,7 @@
 
 @item nextplot
 May be one of
+
 @table @code
 @item "new"
 
@@ -1440,6 +1455,7 @@
 @cindex axes properties
 
 The @code{axes} properties are:
+
 @table @code
 @item __modified__
 
@@ -1569,6 +1585,7 @@
 
 @item nextplot
 May be one of
+
 @table @code
 @item "new"
 
@@ -1785,6 +1802,7 @@
 @cindex line properties
 
 The @code{line} properties are:
+
 @table @code
 @item __modified__
 
@@ -1896,6 +1914,7 @@
 @cindex text properties
 
 The @code{text} properties are:
+
 @table @code
 @item __modified__
 
@@ -2013,6 +2032,7 @@
 @cindex image properties
 
 The @code{image} properties are:
+
 @table @code
 @item __modified__
 
@@ -2089,6 +2109,7 @@
 @cindex patch properties
 
 The @code{patch} properties are:
+
 @table @code
 @item __modified__
 
@@ -2237,6 +2258,7 @@
 @cindex surface properties
 
 The @code{surface} properties are:
+
 @table @code
 @item __modified__
 
@@ -2512,6 +2534,7 @@
 @table @code
 @item linestyle
 May be one of
+
 @table @code
 @item "-"
 Solid line.  [default]
@@ -2540,6 +2563,7 @@
 @cindex marker styles, graphics
 
 Marker styles are specified by the following properties:
+
 @table @code
 @item marker
 A character indicating a plot marker to be place at each data point, or
@@ -2586,7 +2610,7 @@
 @code{set} function.  For example,
 
 @example
-plot (x, "DeleteFcn", @@(s, e) disp("Window Deleted"))
+plot (x, "DeleteFcn", @@(s, e) disp ("Window Deleted"))
 @end example
 
 @noindent
--- a/doc/interpreter/poly.txi
+++ b/doc/interpreter/poly.txi
@@ -54,8 +54,8 @@
 
 @example
 @group
-N = length(c)-1;
-val = dot( x.^(N:-1:0), c );
+N = length (c) - 1;
+val = dot (x.^(N:-1:0), c);
 @end group
 @end example
 
@@ -114,8 +114,8 @@
 @example
 @group
 c = [1, 0, 1];
-integral = polyint(c);
-area = polyval(integral, 3) - polyval(integral, 0)
+integral = polyint (c);
+area = polyval (integral, 3) - polyval (integral, 0)
 @result{} 12
 @end group
 @end example
@@ -132,18 +132,224 @@
 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 demonstrated 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 piecewise 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
+## 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 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 endpoints,
+and a second periodic fit which is hinged at the endpoints.
+
+@example
+## 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 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 endpoints clamped and the second has its endpoints
+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
+## 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 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
@@ -155,10 +361,10 @@
 p = [ 0,  1, 0;
       1, -2, 1;
       0, -1, 1 ];
-pp = mkpp(x, p);
-xi = linspace(-2, 2, 50);
-yi = ppval(pp, xi);
-plot(xi, yi);
+pp = mkpp (x, p);
+xi = linspace (-2, 2, 50);
+yi = ppval (pp, xi);
+plot (xi, yi);
 @end group
 @end example
 
--- a/doc/interpreter/quad.txi
+++ b/doc/interpreter/quad.txi
@@ -338,7 +338,7 @@
 @ifnottex
 the sum over @code{i=1:n} and @code{j=1:n} of @code{q(i)*q(j)*f(r(i),r(j))},
 @end ifnottex
-where @math{q} and @math{r} is as returned by @code{colloc(n)}.  The
+where @math{q} and @math{r} is as returned by @code{colloc (n)}.  The
 generalization to more than two variables is straight forward.  The
 following code computes the studied integral using @math{n=8} points.
 
--- a/doc/interpreter/set.txi
+++ b/doc/interpreter/set.txi
@@ -40,7 +40,7 @@
 @code{y} contains two sets, then
 
 @example
-union(x, y)
+union (x, y)
 @end example
 
 @noindent
--- a/doc/interpreter/sparse.txi
+++ b/doc/interpreter/sparse.txi
@@ -106,7 +106,7 @@
 @example
 @group
   for (j = 0; j < nc; j++)
-    for (i = cidx (j); i < cidx(j+1); i++)
+    for (i = cidx(j); i < cidx(j+1); i++)
        printf ("non-zero element (%i,%i) is %d\n", 
            ridx(i), j, data(i));
 @end group
@@ -212,7 +212,7 @@
 that corresponds to this.  For example,
 
 @example
-s = diag (sparse(randn(1,n)), -1);
+s = diag (sparse (randn (1,n)), -1);
 @end example
 
 @noindent
@@ -348,8 +348,8 @@
 
 @example
 @group
-a = tril (sprandn(1024, 1024, 0.02), -1) ...
-    + speye(1024); 
+a = tril (sprandn (1024, 1024, 0.02), -1) ...
+    + speye (1024); 
 matrix_type (a);
 ans = Lower
 @end group
@@ -363,7 +363,7 @@
 @example
 @group
 a = matrix_type (tril (sprandn (1024, ...
-   1024, 0.02), -1) + speye(1024), 'Lower');
+   1024, 0.02), -1) + speye (1024), "Lower");
 @end group
 @end example
 
@@ -398,10 +398,10 @@
 
 @example
 @group
-A = sparse([2,6,1,3,2,4,3,5,4,6,1,5],
+A = sparse ([2,6,1,3,2,4,3,5,4,6,1,5],
     [1,1,2,2,3,3,4,4,5,5,6,6],1,6,6);
 xy = [0,4,8,6,4,2;5,0,5,7,5,7]';
-gplot(A,xy)
+gplot (A,xy)
 @end group
 @end example
 
@@ -422,8 +422,8 @@
 calculated in linear time without explicitly needing to calculate the
 Cholesky@tie{}factorization by the @code{etree} command.  This command
 returns the elimination tree of the matrix and can be displayed
-graphically by the command @code{treeplot(etree(A))} if @code{A} is
-symmetric or @code{treeplot(etree(A+A'))} otherwise.
+graphically by the command @code{treeplot (etree (A))} if @code{A} is
+symmetric or @code{treeplot (etree (A+A'))} otherwise.
 
 @DOCSTRING(spy)
 
@@ -519,7 +519,7 @@
 
 @example
 @group
-speye(3) + 0
+speye (3) + 0
 @result{}   1  0  0
   0  1  0
   0  0  1
@@ -541,7 +541,7 @@
 one area where it does cause a problem is where a sparse matrix is
 promoted to a full matrix, where subsequent operations would resparsify
 the matrix.  Such cases are rare, but can be artificially created, for
-example @code{(fliplr(speye(3)) + speye(3)) - speye(3)} gives a full
+example @code{(fliplr (speye (3)) + speye (3)) - speye (3)} gives a full
 matrix when it should give a sparse one.  In general, where such cases 
 occur, they impose only a small memory penalty.
 
@@ -551,7 +551,7 @@
 depending on the type of its input arguments.  So 
 
 @example
- a = diag (sparse([1,2,3]), -1);
+ a = diag (sparse ([1,2,3]), -1);
 @end example
 
 @noindent
@@ -655,7 +655,7 @@
 The standard Cholesky@tie{}factorization of this matrix can be
 obtained by the same command that would be used for a full
 matrix.  This can be visualized with the command 
-@code{r = chol(A); spy(r);}.
+@code{r = chol (A); spy (r);}.
 @xref{fig:simplechol}.
 The original matrix had 
 @ifinfo
@@ -682,8 +682,8 @@
 
 The appropriate sparsity preserving permutation of the original
 matrix is given by @dfn{symamd} and the factorization using this
-reordering can be visualized using the command @code{q = symamd(A);
-r = chol(A(q,q)); spy(r)}.  This gives 
+reordering can be visualized using the command @code{q = symamd (A);
+r = chol (A(q,q)); spy (r)}.  This gives 
 @ifinfo
 @ifnothtml
 29
@@ -697,7 +697,7 @@
 The Cholesky@tie{}factorization itself can be used to determine the
 appropriate sparsity preserving reordering of the matrix during the
 factorization, In that case this might be obtained with three return
-arguments as r@code{[r, p, q] = chol(A); spy(r)}.
+arguments as @code{[r, p, q] = chol (A); spy (r)}.
 
 @float Figure,fig:simplechol
 @center @image{spchol,4in}
@@ -712,7 +712,7 @@
 In the case of an asymmetric matrix, the appropriate sparsity
 preserving permutation is @dfn{colamd} and the factorization using
 this reordering can be visualized using the command
-@code{q = colamd(A); [l, u, p] = lu(A(:,q)); spy(l+u)}.
+@code{q = colamd (A); [l, u, p] = lu (A(:,q)); spy (l+u)}.
 
 Finally, Octave implicitly reorders the matrix when using the div (/)
 and ldiv (\) operators, and so no the user does not need to explicitly
@@ -948,23 +948,23 @@
 
 @example
 @group
-   node_y= [1;1.2;1.5;1.8;2]*ones(1,11);
-   node_x= ones(5,1)*[1,1.05,1.1,1.2, ...
+   node_y = [1;1.2;1.5;1.8;2]*ones(1,11);
+   node_x = ones(5,1)*[1,1.05,1.1,1.2, ...
              1.3,1.5,1.7,1.8,1.9,1.95,2];
-   nodes= [node_x(:), node_y(:)];
+   nodes = [node_x(:), node_y(:)];
 
-   [h,w]= size(node_x);
-   elems= [];
-   for idx= 1:w-1
-     widx= (idx-1)*h;
-     elems= [elems; ...
+   [h,w] = size (node_x);
+   elems = [];
+   for idx = 1:w-1
+     widx = (idx-1)*h;
+     elems = [elems; ...
        widx+[(1:h-1);(2:h);h+(1:h-1)]'; ...
        widx+[(2:h);h+(2:h);h+(1:h-1)]' ]; 
    endfor
 
-   E= size(elems,1); # No. of simplices
-   N= size(nodes,1); # No. of vertices
-   D= size(elems,2); # dimensions+1
+   E = size (elems,1); # No. of simplices
+   N = size (nodes,1); # No. of vertices
+   D = size (elems,2); # dimensions+1
 @end group
 @end example
 
@@ -1001,32 +1001,32 @@
 calculated.
 
 @example
-  # Element conductivity
-  conductivity= [1*ones(1,16), ...
+  ## Element conductivity
+  conductivity = [1*ones(1,16), ...
          2*ones(1,48), 1*ones(1,16)];
 
-  # Connectivity matrix
+  ## Connectivity matrix
   C = sparse ((1:D*E), reshape (elems', ...
          D*E, 1), 1, D*E, N);
 
-  # Calculate system matrix
+  ## Calculate system matrix
   Siidx = floor ([0:D*E-1]'/D) * D * ...
          ones(1,D) + ones(D*E,1)*(1:D) ;
-  Sjidx = [1:D*E]'*ones(1,D);
-  Sdata = zeros(D*E,D);
-  dfact = factorial(D-1);
-  for j=1:E
-     a = inv([ones(D,1), ... 
+  Sjidx = [1:D*E]'*ones (1,D);
+  Sdata = zeros (D*E,D);
+  dfact = factorial (D-1);
+  for j = 1:E
+     a = inv ([ones(D,1), ... 
          nodes(elems(j,:), :)]);
      const = conductivity(j) * 2 / ...
-         dfact / abs(det(a));
+         dfact / abs (det (a));
      Sdata(D*(j-1)+(1:D),:) = const * ...
          a(2:D,:)' * a(2:D,:);
   endfor
-  # Element-wise system matrix
-  SE= sparse(Siidx,Sjidx,Sdata);
-  # Global system matrix
-  S= C'* SE *C;
+  ## Element-wise system matrix
+  SE = sparse(Siidx,Sjidx,Sdata);
+  ## Global system matrix
+  S = C'* SE *C;
 @end example
 
 The system matrix acts like the conductivity 
@@ -1047,23 +1047,23 @@
 solve for the voltages at each vertex @code{V}. 
 
 @example
-  # Dirichlet boundary conditions
-  D_nodes=[1:5, 51:55]; 
-  D_value=[10*ones(1,5), 20*ones(1,5)]; 
+  ## Dirichlet boundary conditions
+  D_nodes = [1:5, 51:55]; 
+  D_value = [10*ones(1,5), 20*ones(1,5)]; 
 
-  V= zeros(N,1);
+  V = zeros (N,1);
   V(D_nodes) = D_value;
   idx = 1:N; # vertices without Dirichlet 
              # boundary condns
   idx(D_nodes) = [];
 
-  # Neumann boundary conditions.  Note that
-  # N_value must be normalized by the
-  # boundary length and element conductivity
-  N_nodes=[];
-  N_value=[];
+  ## Neumann boundary conditions.  Note that
+  ## N_value must be normalized by the
+  ## boundary length and element conductivity
+  N_nodes = [];
+  N_value = [];
 
-  Q = zeros(N,1);
+  Q = zeros (N,1);
   Q(N_nodes) = N_value;
 
   V(idx) = S(idx,idx) \ ( Q(idx) - ...
@@ -1082,8 +1082,8 @@
   xelems = reshape (nodes(elemx, 1), 4, E);
   yelems = reshape (nodes(elemx, 2), 4, E);
   velems = reshape (V(elemx), 4, E);
-  plot3 (xelems,yelems,velems,'k'); 
-  print ('grid.eps');
+  plot3 (xelems,yelems,velems,"k"); 
+  print "grid.eps";
 @end group
 @end example
 
new file mode 100644
--- /dev/null
+++ b/doc/interpreter/splineimages.m
@@ -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/stmt.txi
+++ b/doc/interpreter/stmt.txi
@@ -560,11 +560,11 @@
 
 @example
 @group
-disp("Loop over a matrix")
+disp ("Loop over a matrix")
 for i = [1,3;2,4]
   i
 endfor
-disp("Loop over a cell array")
+disp ("Loop over a cell array")
 for i = @{1,"two";"three",4@}
   i
 endfor
@@ -580,7 +580,7 @@
 
 @example
 @group
-a = [1,3;2,4]; c = cat(3, a, 2*a);
+a = [1,3;2,4]; c = cat (3, a, 2*a);
 for i = c
   i
 endfor
@@ -589,8 +589,8 @@
 
 @noindent
 In the above case, the multi-dimensional matrix @var{c} is reshaped to a
-two-dimensional matrix as @code{reshape (c, rows(c),
-prod(size(c)(2:end)))} and then the same behavior as a loop over a two
+two-dimensional matrix as @code{reshape (c, rows (c),
+prod (size (c)(2:end)))} and then the same behavior as a loop over a two
 dimensional matrix is produced.
 
 Although it is possible to rewrite all @code{for} loops as @code{while}
--- a/doc/interpreter/strings.txi
+++ b/doc/interpreter/strings.txi
@@ -187,14 +187,14 @@
 
 @example
 @group
-ischar(collection)
-     @result{} ans = 1
+ischar (collection)
+     @result{} 1
 
-ischar(collection) && isvector(collection)
-     @result{} ans = 0
+ischar (collection) && isvector (collection)
+     @result{} 0
 
-ischar("my string") && isvector("my string")
-     @result{} ans = 1
+ischar ("my string") && isvector ("my string")
+     @result{} 1
 @end group
 @end example
 
@@ -243,9 +243,8 @@
 
 @example
 @group
-char([98, 97, 110, 97, 110, 97])
-     @result{} ans =
-       banana
+char ([98, 97, 110, 97, 110, 97])
+   @result{} banana
 @end group
 @end example
 
@@ -256,16 +255,14 @@
 
 @example
 @group
-char("an apple", "two pears")
-     @result{} ans =
-       an apple
+char ("an apple", "two pears")
+    @result{} an apple
        two pears
 @end group
 
 @group
-strcat("oc", "tave", " is", " good", " for you")
-     @result{} ans =
-       octave is good for you
+strcat ("oc", "tave", " is", " good", " for you")
+     @result{} octave is good for you
 @end group
 @end example
 
@@ -275,18 +272,16 @@
 
 @example
 @group
-char("orange", "green", "", "red")
-     @result{} ans =
-       orange
+char ("orange", "green", "", "red")
+    @result{} orange
        green 
              
        red   
 @end group
 
 @group
-strvcat("orange", "green", "", "red")
-     @result{} ans =
-       orange
+strvcat ("orange", "green", "", "red")
+    @result{} orange
        green 
        red  
 @end group
@@ -299,21 +294,20 @@
 
 @example
 @group
-char(@{"red", "green", "", "blue"@})
-     @result{} ans =
-       red  
-       green
+char (@{"red", "green", "", "blue"@})
+     @result{} red  
+        green
 
-       blue 
+        blue 
 @end group
 
 @group
-strcat(@{"abc"; "ghi"@}, @{"def"; "jkl"@})
-     @result{} ans =
-       @{
-         [1,1] = abcdef
-         [2,1] = ghijkl
-       @}
+strcat (@{"abc"; "ghi"@}, @{"def"; "jkl"@})
+     @result{}
+        @{
+          [1,1] = abcdef
+          [2,1] = ghijkl
+        @}
 @end group
 @end example
 
@@ -323,17 +317,15 @@
 
 @example
 @group
-strcat(["dir1";"directory2"], ["/";"/"], ["file1";"file2"])
-     @result{} ans =
-       dir1/file1      
-       directory2/file2
+strcat (["dir1";"directory2"], ["/";"/"], ["file1";"file2"])
+     @result{} dir1/file1      
+        directory2/file2
 @end group
 @group
 
-cstrcat(["thirteen apples"; "a banana"], [" 5$";" 1$"])
-     @result{} ans =
-       thirteen apples 5$
-       a banana        1$
+cstrcat (["thirteen apples"; "a banana"], [" 5$";" 1$"])
+      @result{} thirteen apples 5$
+         a banana        1$
 @end group
 @end example
 
@@ -467,7 +459,7 @@
 @example
 @group
 hex2dec ("FF")
-     @result{} ans = 255
+      @result{} 255
 @end group
 @end example
 
--- a/doc/interpreter/system.txi
+++ b/doc/interpreter/system.txi
@@ -266,16 +266,34 @@
 @node FTP Objects
 @subsection FTP Objects
 
+Octave supports the FTP protocol through an object-oriented interface.
+Use the function @code{ftp} to create an FTP object which represents the
+connection.  All FTP functions take an FTP object as the first argument.
+
 @DOCSTRING(@ftp/ftp)
 
+@DOCSTRING(@ftp/close)
+
 @DOCSTRING(@ftp/mget)
 
 @DOCSTRING(@ftp/mput)
 
+@DOCSTRING(@ftp/cd)
+
+@DOCSTRING(@ftp/dir)
+
 @DOCSTRING(@ftp/ascii)
 
 @DOCSTRING(@ftp/binary)
 
+@DOCSTRING(@ftp/delete)
+
+@DOCSTRING(@ftp/rename)
+
+@DOCSTRING(@ftp/mkdir)
+
+@DOCSTRING(@ftp/rmdir)
+
 @node URL Manipulation
 @subsection URL Manipulation
 
--- a/doc/interpreter/testfun.txi
+++ b/doc/interpreter/testfun.txi
@@ -72,7 +72,7 @@
 %! get = kron (@var{b}, @var{a});
 %! if (any (size (expect) != size (get)))
 %!   error ("wrong size: expected %d,%d but got %d,%d",
-%!          size(expect), size(get));
+%!          size (expect), size (get));
 %! elseif (any (any (expect != get)))
 %!   error ("didn't get what was expected.");
 %! endif
--- a/doc/interpreter/var.txi
+++ b/doc/interpreter/var.txi
@@ -272,21 +272,21 @@
 
 clear
 for i = 1:2
-  count_calls();
+  count_calls ();
 endfor
 @print{} 'count_calls' has been called 3 times
 @print{} 'count_calls' has been called 4 times
 
 clear all
 for i = 1:2
-  count_calls();
+  count_calls ();
 endfor
 @print{} 'count_calls' has been called 1 times
 @print{} 'count_calls' has been called 2 times
 
 clear count_calls
 for i = 1:2
-  count_calls();
+  count_calls ();
 endfor
 @print{} 'count_calls' has been called 1 times
 @print{} 'count_calls' has been called 2 times
--- a/doc/interpreter/vectorize.txi
+++ b/doc/interpreter/vectorize.txi
@@ -191,6 +191,7 @@
 
 @item
 Repetition
+
 @itemize
 @item
 repmat
@@ -201,6 +202,7 @@
 
 @item
 Vectorized arithmetic
+
 @itemize
 @item
 sum
@@ -232,6 +234,7 @@
 
 @item
 Shape of higher dimensional arrays
+
 @itemize
 @item
 reshape
@@ -342,8 +345,8 @@
 subtraction takes place.
 
 A special case of broadcasting that may be familiar is when all
-dimensions of the array being broadcast are 1, i.e. the array is a
-scalar. Thus for example, operations like @code{x - 42} and @code{max
+dimensions of the array being broadcast are 1, i.e., the array is a
+scalar.  Thus for example, operations like @code{x - 42} and @code{max
 (x, 2)} are basic examples of broadcasting.
 
 For a higher-dimensional example, suppose @code{img} is an RGB image of
@@ -657,7 +660,7 @@
 @group
 n = length (A);
 B = zeros (n, 2);
-for i = 1:length(A)
+for i = 1:length (A)
   ## this will be two columns, the first is the difference and
   ## the second the mean of the two elements used for the diff.
   B(i,:) = [A(i+1)-A(i), (A(i+1) + A(i))/2)];
--- a/doc/refcard/refcard.tex
+++ b/doc/refcard/refcard.tex
@@ -679,7 +679,7 @@
 \sec Paths and Packages;
 path&display the current Octave function path.\cr
 pathdef&display the default path.\cr
-addpath({\it dir})&add a directory to the path.\cr
+addpath ({\it dir})&add a directory to the path.\cr
 EXEC\_PATH&manipulate the Octave executable path.\cr
 pkg list&display installed packages.\cr
 pkg load {\it pack}&Load an installed package.\cr
@@ -688,8 +688,8 @@
 \sec Cells and Structures;
 {\it{var}}.{\it{field}} = ...&set a field of a structure.\cr
 {\it{var}}$\{${\it{idx}}$\}$ = ...&set an element of a cell array.\cr
-cellfun({\it f}, {\it c})&apply a function to elements of cell array.\cr
-fieldnames({\it s})&returns the fields of a structure.\cr
+cellfun ({\it f}, {\it c})&apply a function to elements of cell array.\cr
+fieldnames ({\it s})&returns the fields of a structure.\cr
 \endsec
 
 \widesec Statements;
@@ -803,10 +803,10 @@
   values\cr 
 \endsec
 
-% sin({\it a}) cos({\it a}) tan({\it a})&trigonometric functions\cr
-% asin({\it a}) acos({\it a}) atan({\it a})&inverse trigonometric functions\cr
-% sinh({\it a}) cosh({\it a}) tanh({\it a})&hyperbolic trig functions\cr
-% asinh({\it a}) acosh({\it a}) atanh({\it a})&inverse hyperbolic trig
+% sin ({\it a}) cos({\it a}) tan({\it a})&trigonometric functions\cr
+% asin ({\it a}) acos({\it a}) atan({\it a})&inverse trigonometric functions\cr
+% sinh ({\it a}) cosh({\it a}) tanh({\it a})&hyperbolic trig functions\cr
+% asinh ({\it a}) acosh({\it a}) atanh({\it a})&inverse hyperbolic trig
 % functions\cr\cr 
 
 \sec Linear Algebra;
--- a/etc/HACKING
+++ b/etc/HACKING
@@ -5,7 +5,7 @@
 
 * Working from the repository
 
-These notes are intended to help people working on sources checked-out from
+These notes are intended to help people working on sources cloned from
 the savannah source code repository.
 These requirements do not apply when building from a distribution tarball.
 
@@ -13,7 +13,7 @@
 
 We've opted to keep only the highest-level sources in the repository.
 This eases our maintenance burden, (fewer merges, etc.), but imposes
-more requirements on anyone wishing to build from the just-checked-out
+more requirements on anyone wishing to build from the just-cloned
 sources.  For example, you have to use the latest stable versions of
 the maintainer tools we depend upon, including:
 
@@ -35,15 +35,15 @@
 Later, after synchronizing from the repository, a plain `make' should
 be sufficient.
 
-** First checkout
+** First clone
 
-Obviously, if you are reading these notes, you did manage to check out
+If you are reading these notes, you may have already managed to clone
 this package from the repository.  For the record, you will find all the
 relevant information on downloading sources at:
 
   http://www.gnu.org/software/octave/download.html
 
-After checking out Octave, you will need to run the autogen.sh script:
+After cloning Octave, you will need to run the autogen.sh script:
 
   $ ./autogen.sh
 
@@ -51,8 +51,7 @@
 fragments and then runs the bootstrap script.  The bootstrap script comes
 from gnulib, but is kept in the Octave source archive.  It should be
 updated from the gnulib sources as necssary.  The bootstrap script takes
-care of checking out a copy of gnulib, running the autotools, and
-generating the configure script.
+care of running the autotools and generating the configure script.
 
 If you have a copy of gnulib in some directory apart from the Octave
 source tree, then pass the name of the directory containing gnulib-tool
@@ -66,12 +65,10 @@
 gnulib-tool script resides).
 
 By using an external gnulib directory, you can share a single gnulib source
-tree among several projects.  Regardless of the location of the gnulib
-sources, the bootstrap script will try to update them if it appears
-that they are checked out using git.  Otherwise, it is your
-responsibility to keep the gnulib sources up to date.  They change
-frequently, so the best way to stay current is probably to use git to
-do the job.
+tree among several projects.  Since 2011, the gnulib sources are a Mercurial
+subrepository, so they will be automatically updated to the
+corresponding Mercurial revision if you update the working directory to
+a past revision not too far in the past.
 
 Additional options besides --gnulib-srcdir can be passed to autogen.sh and
 they will be forwarded without modification to the bootstrap script.
@@ -83,8 +80,8 @@
   $ make
   $ make check
 
-At this point, there should be no difference between your local copy,
-and the master copy:
+At this point, there should be no difference between your working tree
+and the currently visited hg revision:
 
   $ hg diff
 
--- a/etc/OLD-ChangeLogs/ChangeLog
+++ b/etc/OLD-ChangeLogs/ChangeLog
@@ -1882,7 +1882,7 @@
 	(--enable-strict-warning-flags): Rename from --enable-picky-flags.
 	(GXX_STRICT_FLAGS): Remove -Wenum-clash from the list.
 
-2009-03-08  S�ren Hauberg  <hauberg@gmail.com>
+2009-03-08  Søren Hauberg  <hauberg@gmail.com>
 
 	* NEWS: Mention 'histc'.
 
@@ -2652,7 +2652,7 @@
 	* aclocal.m4 (OCTAVE_PROG_GNUPLOT): Drop check for multiple plot
 	windows.
 
-2007-08-10  S�ren Hauberg  <hauberg@gmail.com>
+2007-08-10  Søren Hauberg  <hauberg@gmail.com>
 
 	* ROADMAP: Update for current sources.
 
@@ -2973,7 +2973,7 @@
 	* Makeconf.in (simple-move-if-change-rule,
 	(builddir-move-if-change-rule): New macros.
 
-2006-11-11  S�ren Hauberg  <hauberg@gmail.com>
+2006-11-11  Søren Hauberg  <hauberg@gmail.com>
 
 	* examples/Makefile.in (uninstall): Add missing semicolon.
 
@@ -3183,7 +3183,7 @@
 2006-09-27  John W. Eaton  <jwe@octave.org>
 
 	* mkoctfile.in [--mex]: Include -I. in incflags.
-	From S�ren Hauberg <hauberg@gmail.com>.
+	From Søren Hauberg <hauberg@gmail.com>.
 
 2006-09-26  John W. Eaton  <jwe@octave.org>
 
@@ -3565,7 +3565,7 @@
 	* configure.in: Use it.
 	* Makeconf.in: Substitute DESKTOP_FILE_INSTALL.
 
-	* octave.desktop.in: New file.  From S�ren Hauberg <hauberg@gmail.com>.
+	* octave.desktop.in: New file.  From Søren Hauberg <hauberg@gmail.com>.
 	* examples/Makefile.in (SOURCES): Add it to the list.
 	(octave.desktop): New target.
 	(all): Depend on octave.desktop.
--- a/etc/OLD-ChangeLogs/doc-ChangeLog
+++ b/etc/OLD-ChangeLogs/doc-ChangeLog
@@ -1311,11 +1311,11 @@
 	* interpreter/oop.txi: Update docs of polynomial class, mention
 	chained indexing.
 
-2009-05-27  S�ren Hauberg  <hauberg@gmail.com>
+2009-05-27  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/errors.txi: fix 'print_usage' output.
 
-2009-05-27  S�ren Hauberg  <hauberg@gmail.com>
+2009-05-27  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/bugs.txi: fix call to 'page_screen_output'.
 
@@ -1456,7 +1456,7 @@
 	* interpreter/Makefile.in (DISTFILES): Use doc-cache instead of
 	DOC for doc cache file.
 
-2009-03-08  S�ren Hauberg  <hauberg@gmail.com>
+2009-03-08  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/stats.txi (Basic Statistical Functions):
 	Add the 'histc' function.
@@ -1542,11 +1542,11 @@
 	(DISTFILES): Add DOC nad mk_doc_cache.m to the list.
 	* mk_doc_cache.m: New file.
 
-2009-02-01  S�ren Hauberg  <hauberg@gmail.com>
+2009-02-01  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/nonlin.txi: Remove reference to 'fsolve_options'.
 
-2009-02-01  S�ren Hauberg  <hauberg@gmail.com>
+2009-02-01  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/system.txi: Remove reference to 'eomdate'.
 
@@ -1562,7 +1562,7 @@
 	* vr-idx.txi: Delete.
 	* interpreter/Makefile.in (SUB_SOURCE): Remove it from the list.
 
-2009-01-22  S�ren Hauberg  <hauberg@gmail.com>
+2009-01-22  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/func.txi: Put varargin and varargout in concept index.
 	* interpreter/var.txi: Put ans in concept index.
@@ -1684,12 +1684,12 @@
 	* interpreter/contrib.txi: correction of the mercurial example
 	* interpreter/container.txi: minor correction of the text
 
-2008-09-25  S�ren Hauberg  <hauberg@gmail.com>
+2008-09-25  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/image.txi: Update for imread and imwrite instead of
 	loadimge and saveimage.
 
-2008-09-24  S�ren Hauberg  <hauberg@gmail.com>
+2008-09-24  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/image.txi: Document imfinfo.
 
@@ -1738,7 +1738,7 @@
 
 	* interpreter/numbers.txi: Document intwarning.
 
-2008-08-06  S�ren Hauberg  <hauberg@gmail.com>
+2008-08-06  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/basics.txi, interpreter/errors.txi,
 	interpreter/expr.txi, interpreter/func.txi,
@@ -1955,7 +1955,7 @@
 
 	* refcard/refcard.tex: Update for 3.0.
 
-2007-10-15  S�ren Hauberg  <hauberg@gmail.com>
+2007-10-15  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/preface.txi, interpreter/basics.txi,
 	interpreter/strings.txi, interpreter/container.txi,
@@ -1987,7 +1987,7 @@
 
 2007-10-06  John W. Eaton  <jwe@octave.org>
 
-	* interpreter/octave.texi: Add David Bateman and S�ren Hauberg as
+	* interpreter/octave.texi: Add David Bateman and Søren Hauberg as
 	authors.
 
 2006-09-28  Henry Mollet  mollet@pacbell.net
@@ -2019,7 +2019,7 @@
 	* interpreter/geometry.txi: Check whether TEXINFO_QHULL is set
 	before including certain figures.
 
-2007-08-31  S�ren Hauberg  <hauberg@gmail.com>
+2007-08-31  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/nonlin.txi: Extended the example.
 
@@ -2102,7 +2102,7 @@
 	* interpreter/interp.txi: Also change figures here.
 	* interpreter/Makefile.in: and here.
 
-2007-06-18  S�ren Hauberg  <hauberg@gmail.com>
+2007-06-18  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/optim.txi: Added some introductory text to each
 	section.
@@ -2148,7 +2148,7 @@
 	chapter. Remove references to Hashing chapter and hashing.texi,
 	and subsections for hashing to system utilities chapter.
 
-2007-06-12  2007-06-10  S�ren Hauberg  <hauberg@gmail.com>
+2007-06-12  2007-06-10  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/diffeq.txi: Note that x-dot is the derivative of x.
 
@@ -2176,7 +2176,7 @@
 	* interpreter/Makefile.in ($(HTML_IMAGES_PNG)): Use cp instead of
 	INSTALL_DATA to copy files to the HTML directory.
 
-2007-05-28  S�ren Hauberg  <hauberg@gmail.com>
+2007-05-28  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/errors.txi: Add new sections and some more detailed
 	descriptions on errors and warnings.
@@ -2184,7 +2184,7 @@
 	interpreter/var.txi: Add references to the new sections in
 	errors.txi.
 
-2007-05-28  S�ren Hauberg  <hauberg@gmail.com>
+2007-05-28  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/io.txi: Rearrange some sections, and add
 	a few examples.
@@ -2218,7 +2218,7 @@
 
 	* interpreter/debug.txi, io.txi, octave.txi: Doc fixes.
 
-2007-05-21  S�ren Hauberg  <hauberg@gmail.com>
+2007-05-21  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/expr.txi: Describe +=, -=, *=, and /= operators.
 	Add new example.
@@ -2240,7 +2240,7 @@
 	* interpreter/func.txi: Additional documentation for function
 	locking, dispatch and autoloading.
 
-2007-05-16  S�ren Hauberg  <hauberg@gmail.com>
+2007-05-16  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/expr.txi: Improve docs.
 
@@ -2250,7 +2250,7 @@
 	interpreter/intro.txi, interpreter/numbers.txi,
 	interpreter/octave.texi, interpreter/preface.txi: Doc fixes.
 
-2007-04-18  S�ren Hauberg  <hauberg@gmail.com>
+2007-04-18  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/package.texi: Document "*" flag for loaded packages.
 
@@ -2333,7 +2333,7 @@
 
 	* Makefile.in (SUB_SOURCE): Include dynamic.txi in the list.
 
-2007-04-18  S�ren Hauberg  <hauberg@gmail.com>
+2007-04-18  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/package.texi: New file.
 	* octave/texi: @include it, add it to the menus.
@@ -2358,7 +2358,7 @@
 	* interpreter/stream.txi: Delete.
 	* interpreter/Makefile.in (SUB_SOURCE): Remove it from the list.
 
-2007-04-16  S�ren Hauberg  <hauberg@gmail.com>
+2007-04-16  Søren Hauberg  <hauberg@gmail.com>
 
 	* intrepreter/stmt.txi: Improve documentation of switch statement.
 
@@ -2370,15 +2370,15 @@
 
 	* interpreter/image.txi: Update docs.
 
-2007-04-11  S�ren Hauberg  <hauberg@gmail.com>
+2007-04-11  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/container.txi: Document indexing with ().
 
-2007-04-11  S�ren Hauberg  <hauberg@gmail.com>
+2007-04-11  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/container.txi: Improve cell array documentation.
 
-2007-04-09  S�ren Hauberg  <hauberg@gmail.com>
+2007-04-09  Søren Hauberg  <hauberg@gmail.com>
 
 	* interpreter/func.txi: Document varargin, varargout, and default
 	argument values.
--- a/etc/OLD-ChangeLogs/liboctave-ChangeLog
+++ b/etc/OLD-ChangeLogs/liboctave-ChangeLog
@@ -1480,7 +1480,7 @@
 	Remove occurences of ftrunc, fnon_int and fnan eveywhere.
 	* oct-inttypes.cc: Ditto last sentence. Remove warning tests.
 
-2010-03-07  Soren Hauberg  <hauberg@gmail.com>
+2010-03-07  Søren Hauberg  <hauberg@gmail.com>
 
 	* dim-vector.h: New constructor accepting a C array of dimensions.
 
--- a/etc/OLD-ChangeLogs/scripts-ChangeLog
+++ b/etc/OLD-ChangeLogs/scripts-ChangeLog
@@ -1585,7 +1585,7 @@
 
 	* audio/setaudio.m: Re-write docstring.
 
-2010-12-23  Soren Hauberg  <hauberg@gmail.com>
+2010-12-23  Søren Hauberg  <hauberg@gmail.com>
 
 	* signal/detrend.m: Also accept polynomial order as a string
 	("constant" or "linear") for compatibility with Matlab.
@@ -2863,7 +2863,7 @@
 	* general/interpn.m: Convert interpolation vectors of non-equal
 	length to nd-arrays.
 
-2010-07-26  Soren Hauberg  <hauberg@gmail.com>
+2010-07-26  Søren Hauberg  <hauberg@gmail.com>
 
 	* image/image.m: Replace parenthesis with curly bracket in Texinfo.
 
@@ -3065,7 +3065,7 @@
 	* newplot.m: Conditionally initialisation the line style and color
 	based on the __hold_all__ axes property.
 
-2010-07-04  Soren Hauberg  <hauberg@gmail.com>
+2010-07-04  Søren Hauberg  <hauberg@gmail.com>
 
 	* polynomial/deconv.m: ensure that the orientation of the third
 	input to 'filter' matches the orientation of 'y'.
@@ -3733,17 +3733,17 @@
 
 	* plot/refreshdata.m: Don't use cell2mat on cell array of cell arrays.
 
-2010-03-22  Soren Hauberg  <hauberg@gmail.com>
+2010-03-22  Søren Hauberg  <hauberg@gmail.com>
 
 	* image/gmap40.m, image/hot.m, image/hsv2rgb.m, image/image.m,
 	image/image_viewer.m, image/imfinfo.m, image/imread.m, image/imshow.m,
 	image/saveimage: Detabify.
 
-2010-03-21  Soren Hauberg  <hauberg@gmail.com>
+2010-03-21  Søren Hauberg  <hauberg@gmail.com>
 
 	* general/quadv.m: Replace 'quadl' with 'quadv' in help text.
 
-2010-03-20  Soren Hauberg  <hauberg@gmail.com>
+2010-03-20  Søren Hauberg  <hauberg@gmail.com>
 
 	* general/interp2.m: For nearest neighbour interpolation ceil
 	(instead of floor) at the center of the data intervals to be
@@ -3782,12 +3782,12 @@
 
 	* strings/strchr.m: Optimize.
 
-2010-03-05  Soren Hauberg  <hauberg@gmail.com>
+2010-03-05  Søren Hauberg  <hauberg@gmail.com>
 
 	* pkg/pkg.m (write_index): include classes in autogenerated
 	INDEX files.
 
-2010-03-05  Soren Hauberg  <hauberg@gmail.com>
+2010-03-05  Søren Hauberg  <hauberg@gmail.com>
 
 	* plot/fplot.m: Ensure that 'limits' is a 2 or 4 vector, and
 	that 'fn' is a function.
@@ -4738,7 +4738,7 @@
 	* general/tril.m, general/triu.m: Remove sources.
 	* general/Makefile.in: Update.
 
-2009-10-20  Soren Hauberg  <hauberg@gmail.com>
+2009-10-20  Søren Hauberg  <hauberg@gmail.com>
 
 	* general/interp2.m: improved error checking and support for bicubic
 	interpolation when X and Y are meshgrid format.
@@ -4749,7 +4749,7 @@
 	instead of multiple ifs).
 	* polynomial/pchip.m: Employ more optimized formulas (from SLATEC).
 
-2009-10-22  Soren Hauberg  <hauberg@gmail.com>
+2009-10-22  Søren Hauberg  <hauberg@gmail.com>
 
 	* image/autumn.m, image/bone.m, image/cool.m, image/copper.m,
 	image/flag.m, image/gmap40.m, image/gray.m, image/hot.m,
@@ -4757,11 +4757,11 @@
 	image/prism.m, image/rainbow.m, image/spring.m, image/summer.m,
 	image/white.m, image/winter.m: Add demos.
 
-2009-10-20  Soren Hauberg  <hauberg@gmail.com>
+2009-10-20  Søren Hauberg  <hauberg@gmail.com>
 
  	* general/interp2.m: improved error checking and support for bicubic
 
-2009-10-19  Soren Hauberg  <hauberg@gmail.com>
+2009-10-19  Søren Hauberg  <hauberg@gmail.com>
 
 	* io/strread.m, io/textread.m: New functions.
 
@@ -5242,7 +5242,7 @@
 	* plot/__go_draw_axes__.m: Fix rendering of overlaping images and
 	line objects.  Add demos as well.
 
-2009-05-27 S�ren Hauberg  <hauberg@gmail.com>
+2009-05-27 Søren Hauberg  <hauberg@gmail.com>
 
 	* geometry/delaunay.m: Support cellstr's as options.
 
@@ -5250,7 +5250,7 @@
 
 	* plot/imshow.m: Fix handling of indexed images.
 
-2009-05-26 S�ren Hauberg  <hauberg@gmail.com>
+2009-05-26 Søren Hauberg  <hauberg@gmail.com>
 
 	* help/__makeinfo__.m: Support several @seealso's in one text.
 
@@ -5621,7 +5621,7 @@
 	__accumarray_sum__ for the default summation case.
 	* statistics/base/histc.m: Reimplement using lookup & accumarray.
 
-2009-03-08  S�ren Hauberg  <hauberg@gmail.com>
+2009-03-08  Søren Hauberg  <hauberg@gmail.com>
 
 	* statistics/base/histc.m: New function.
 
@@ -5959,12 +5959,12 @@
 
 	* general/sortrows.m: Call __sort_rows_idx__, not __sortrows_idx__.
 
-2009-02-12  Soren Hauberg  <hauberg@gmail.com>
+2009-02-12  Søren Hauberg  <hauberg@gmail.com>
 
 	* help/gen_doc_cache.m: Change API so we only handle one directory per
 	call to this function.
 
-2009-02-12  Soren Hauberg  <hauberg@gmail.com>
+2009-02-12  Søren Hauberg  <hauberg@gmail.com>
 
 	* help/lookfor.m: Adapt to new cache scheme.
 
@@ -6012,7 +6012,7 @@
 
 	* help/which.m: Still print something sensible if type is empty.
 
-2009-02-04  Soren Hauberg  <hauberg@gmail.com>
+2009-02-04  Søren Hauberg  <hauberg@gmail.com>
 	    Thomas Treichl  <Thomas.Treichl@gmx.net>
 
 	* miscellaneous/Makefile.in (SOURCES): Add bzip2.m to the list.
@@ -6107,7 +6107,7 @@
 
 	* plot/__go_draw_axes__.m: Add support for transparent patches.
 
-2009-01-29  S�ren Hauberg  <hauberg@gmail.com>
+2009-01-29  Søren Hauberg  <hauberg@gmail.com>
 
 	* help/help.m, help/print_usage.m, help/get_first_help_sentence.m:
 	print sensible error message when function is found but not documented.
@@ -6160,7 +6160,7 @@
 
 	* polynomial/spline.m: Doc fix.
 
-2009-01-27  S�ren Hauberg  <hauberg@gmail.com>
+2009-01-27  Søren Hauberg  <hauberg@gmail.com>
 
 	* general/gradient.m: Handle computing the gradient of a function
 	handle.
@@ -6206,7 +6206,7 @@
 
 	* sparse/svds.m: svds.m: skip tests if ARPACK is missing.
 
-2009-01-23  S�ren Hauberg  <hauberg@gmail.com>
+2009-01-23  Søren Hauberg  <hauberg@gmail.com>
 
 	* help/type.m: Make 'type X' work, when X is the name of a variable.
 
@@ -6220,7 +6220,7 @@
 	* help/__additional_help_message__.m: Return message instead of
 	displaying it.
 
-2009-01-22  S�ren Hauberg  <hauberg@gmail.com>
+2009-01-22  Søren Hauberg  <hauberg@gmail.com>
 
 	* help: New directory.
 	* configure.in (AC_CONFIG_FILES): Add help/Makefile to the list.
@@ -6311,7 +6311,7 @@
 	* plot/__go_draw_axes__.m (ticklabel_to_cell): New function.
 	Use it to handle non-cell ticklabels.
 
-2009-01-14  S�ren Hauberg  <hauberg@gmail.com>
+2009-01-14  Søren Hauberg  <hauberg@gmail.com>
 
 	* general/diff.m, general/logspace.m, general/nextpow2.m,
 	linear-algebra/commutation_matrix.m,
@@ -6695,7 +6695,7 @@
 	* optimization/qp.m: Convert bounds of the form b <= x <= b and
 	constraints of the form b <= A*x <= b to equality constraints.
 
-2008-10-27  S�ren Hauberg  <hauberg@gmail.com>
+2008-10-27  Søren Hauberg  <hauberg@gmail.com>
 
 	* plot/ellipsoid.m: Check nargin == 6, not nargin == 5.
 
@@ -6972,7 +6972,7 @@
 
 	* image/imfinfo.m: Delete temporary file.
 
-2008-09-25  S�ren Hauberg  <hauberg@gmail.com>
+2008-09-25  Søren Hauberg  <hauberg@gmail.com>
 
 	* image/imread.m, image/imwrite.m: Doc fix.
 
@@ -6980,7 +6980,7 @@
 
 	* plot/fplot.m: Call axis after calling plot.
 
-2008-09-24  S�ren Hauberg  <hauberg@gmail.com>
+2008-09-24  Søren Hauberg  <hauberg@gmail.com>
 
 	* image/imfinfo.m: New function.
 	* image/Makefile.in (SOURCES): Add it to the list.
@@ -7450,7 +7450,7 @@
 	Change caller.  Improve sizing and position of colorbox for subplots.
 	* plot/colorbar.m: New demos.
 
-2008-04-16  S�ren Hauberg  <hauberg@gmail.com>
+2008-04-16  Søren Hauberg  <hauberg@gmail.com>
 
 	* plot/__gnuplot_version__.m: Display error if gnuplot is not found.
 
@@ -7740,7 +7740,7 @@
 	* miscellaneous/info.m: New function.
 	* miscellaneous/Makefile.in (SOURCES): Add it to the list.
 
-2008-03-27  S�ren Hauberg  <hauberg@gmail.com>
+2008-03-27  Søren Hauberg  <hauberg@gmail.com>
 
 	* plot/xlim.m, plot/ylim.m, plot/zlim.m, strings/strtrim.m:
 	Doc fixes.
@@ -7798,7 +7798,7 @@
 
 	* linear-algebra/dmult.m: Handle scaling along arbitrary dimension.
 
-2008-03-26  S�ren Hauberg  <hauberg@gmail.com>
+2008-03-26  Søren Hauberg  <hauberg@gmail.com>
 
 	* polynomial/convn.m: New tests.
 
@@ -7810,7 +7810,7 @@
 	statistics/base/prctile.m: New functions.
 	* statistics/base/Makefile.in (SOURCES): Add them to the list.
 
-2008-03-25  S�ren Hauberg  <hauberg@gmail.com>
+2008-03-25  Søren Hauberg  <hauberg@gmail.com>
 
 	* polynomial/convn.m: New function.
 	* polynomial/Makefile.in (SOURCES): Add it to the list.
@@ -8327,7 +8327,7 @@
 
 	* plot/axis.m: Correctly handle "tight" and "image" options.
 
-2008-01-14  S�ren Hauberg  <hauberg@gmail.com>
+2008-01-14  Søren Hauberg  <hauberg@gmail.com>
 
 	* image/hsv2rgb.m, image/ntsc2rgb.m, image/rgb2hsv.m,
 	image/rgb2ntsc.m: Also accept images as input.
@@ -8388,7 +8388,7 @@
 
 	* general/sub2ind.m, general/ind2sub.m: Doc fix.
 
-2008-01-04  S�ren Hauberg   <hauberg@gmail.com>
+2008-01-04  Søren Hauberg   <hauberg@gmail.com>
 
 	* set/create_set.m, set/union.m: Accept "rows" argument.
 
@@ -8416,7 +8416,7 @@
 
 	Version 3.0.0 released.
 
-2007-12-21  S�ren Hauberg  <hauberg@gmail.com>
+2007-12-21  Søren Hauberg  <hauberg@gmail.com>
 
 	* image/imshow.m: Accept empty value for display_range.
 
@@ -8424,7 +8424,7 @@
 
 	* pkg/pkg.m: Add .lib as architecture-dependent suffix.
 
-2007-12-19  S�ren Hauberg  <hauberg@gmail.com>
+2007-12-19  Søren Hauberg  <hauberg@gmail.com>
 
 	* image/imshow.m: Store uint8 images as doubles.  Handle default
 	display ranges correctly.
@@ -9227,7 +9227,7 @@
 	* plot/print.m: Handle -textspecial and -textnormal flags for fig
 	output.
 
-2007-10-15  S�ren Hauberg  <hauberg@gmail.com>
+2007-10-15  Søren Hauberg  <hauberg@gmail.com>
 
 	* general/rat.m, sparse/pcg.m, sparse/pcr.m, optimization/sqp.m,
 	statistics/models/logistic_regression.m, polynomial/polygcd.m,
@@ -9412,7 +9412,7 @@
 
 	* polynomial/residue.m: New test from test/test_poly.m.
 
-2007-10-06  S�ren Hauberg  <hauberg@gmail.com>
+2007-10-06  Søren Hauberg  <hauberg@gmail.com>
 
 	* image/saveimage.m: Handle saving color images without a colormap.
 	* image/__img_via_file__.m: Add missing semicolon.
@@ -9655,7 +9655,7 @@
 
 	* plot/ancestor.m: New function, adapted from Octave Forge.
 
-2007-08-31  S�ren Hauberg  <hauberg@gmail.com>
+2007-08-31  Søren Hauberg  <hauberg@gmail.com>
 
 	* polynomial/polygcd.m: Better layout of example.
 	* polynomial/compan.m: Remove unnecessary check.
@@ -9889,7 +9889,7 @@
 	* plot/drawnow.m, plot/__go_draw_axes__.m: Use strcmpi instead of
 	strcmp for selected property comparisons.
 
-2007-06-25  S�ren Hauberg  <hauberg@gmail.com>
+2007-06-25  Søren Hauberg  <hauberg@gmail.com>
 
 	* image/imshow.m: Fix check for colormap arguments.
 
@@ -9897,7 +9897,7 @@
 
 	* plot/drawnow.m: Handle GNUTERM=aqua if DISPLAY is not set.
 
-2007-06-25  S�ren Hauberg  <hauberg@gmail.com>
+2007-06-25  Søren Hauberg  <hauberg@gmail.com>
 
 	* statistics/base/median.m: Update help text to mention 'dim'
 	argument, and note that the data should be sorted for the
@@ -9990,19 +9990,19 @@
 	* plot/__go_draw_axes__.m (do_tics, do_tics_1): New functions.
 	(__go_draw_axes__): Call do_tics to handle tic marks.
 
-2007-06-18  S�ren Hauberg  <hauberg@gmail.com>
+2007-06-18  Søren Hauberg  <hauberg@gmail.com>
 
 	* general/interp1.m, general/interp2.m, general/interp3.m,
 	general/interpn.m: Replace, NaN with NA.  Use isna instead of ==
 	to check for NA.
 
-2007-06-18  S�ren Hauberg  <hauberg@gmail.com>
+2007-06-18  Søren Hauberg  <hauberg@gmail.com>
 
 	* optimization/glpk.m: TeXified the help text.
 	* optimization/qp.m: TeXified the help text.
 	* optimization/sqp.m: TeXified the help text.
 
-2007-06-16  S�ren Hauberg  <hauberg@gmail.com>
+2007-06-16  Søren Hauberg  <hauberg@gmail.com>
 
 	* plot/legend.m: Replace 'vargin' with 'varargin'.
 
@@ -10094,7 +10094,7 @@
 
 	* statistics/tests/wilcoxon_test.m: Error if N <= 25.
 
-2007-06-12  S�ren Hauberg  <soren@hauberg.org>
+2007-06-12  Søren Hauberg  <soren@hauberg.org>
 
 	* plot/fplot.m: If function is inline, vectorize it.
 
@@ -10121,7 +10121,7 @@
 	indexes into the installed package list indicating the packages to
 	load and the order to load them in to respect the dependencies.
 
-2007-06-03  S�ren Hauberg  <soren@hauberg.org>
+2007-06-03  Søren Hauberg  <soren@hauberg.org>
 
 	* plot/axes.m: Eliminate redundant else clause.
 
@@ -10233,7 +10233,7 @@
 	* plot/hbar.m: Remove.
 	* plot/barh.m: and move it here.
 
-2007-05-16  S�ren Hauberg  <soren@hauberg.org>
+2007-05-16  Søren Hauberg  <soren@hauberg.org>
 
 	* general/sub2ind.m, general/ind2sub.m: Doc fix.
 
@@ -10264,7 +10264,7 @@
 
 	* pkg/pkg.m: Mark loaded packages with "*".
 
-2007-05-13  S�ren Hauberg  <soren@hauberg.org>
+2007-05-13  Søren Hauberg  <soren@hauberg.org>
 
 	* miscellaneous/single.m: Doc fix.
 	Convert to double instead of returning argument unchanged.
@@ -10349,7 +10349,7 @@
 2007-04-24  John W. Eaton  <jwe@octave.org>
 
 	* io/beep.m: Fix cut and paste error.
-	From S�ren Hauberg  <soren@hauberg.org>.
+	From Søren Hauberg  <soren@hauberg.org>.
 
 2007-04-23  John W. Eaton  <jwe@octave.org>
 
@@ -10400,7 +10400,7 @@
 
 	* gethelp.cc (looks_like_octave_copyright): Use same logic as in
 	looks_like_copyright in src/help.cc.
-	From S�ren Hauberg <soren@hauberg.org>.
+	From Søren Hauberg <soren@hauberg.org>.
 
 	* plot/__go_draw_axes__.m: For log plots, omit zero values too.
 
@@ -10765,7 +10765,7 @@
 
 	* miscellaneous/cast.m: Use feval and strcmp with cell to check
 	arg instead of switch statement.
-	From S�ren Hauberg <soren@hauberg.org>.
+	From Søren Hauberg <soren@hauberg.org>.
 
 2007-03-12  John W. Eaton  <jwe@octave.org>
 
@@ -11438,7 +11438,7 @@
 
 	* polynomial/spline.m: Make DG a column instead of a row vector.
 
-2007-01-18  S�ren Hauberg  <hauberg@gmail.com>
+2007-01-18  Søren Hauberg  <hauberg@gmail.com>
 
 	* pkg/pkg.m (copy_files): Call write_INDEX with correct target
 	file name.
@@ -11460,11 +11460,11 @@
 	elfun/cscd.m, elfun/secd.m, elfun/sind.m, elfun/tand.m:
 	New files.
 
-2007-01-09  S�ren Hauberg  <hauberg@gmail.com>
+2007-01-09  Søren Hauberg  <hauberg@gmail.com>
 
 	* pkg/pkg.m: Allow filenames to contain glob patterns.
 
-2007-01-08  S�ren Hauberg  <hauberg@gmail.com>
+2007-01-08  Søren Hauberg  <hauberg@gmail.com>
 
 	* pkg/pkg.m: Use copyfile instead of calling system.  Use fullfile
 	instead of concatenating with "/".  Use mlock to ensure that
@@ -11474,7 +11474,7 @@
 
 	* miscellaneous/copyfile.m, miscellaneous/movefile.m:
 	Improve handling of file names containing globbing characters.
-	From S�ren Hauberg <hauberg@gmail.com>.
+	From Søren Hauberg <hauberg@gmail.com>.
 
 2007-01-05  John W. Eaton  <jwe@octave.org>
 
@@ -11486,7 +11486,7 @@
 	* sparse/spfun.m: Check for "function_handle" not "function handle".
 	* plot/fplot.m: Likewise.  Use isa instead of strcmp + class.
 
-2006-12-27  S�ren Hauberg  <hauberg@gmail.com>
+2006-12-27  Søren Hauberg  <hauberg@gmail.com>
 
 	* image/imshow.m: Strip NaNs from image.
 
@@ -11501,7 +11501,7 @@
 
 	* startup/inputrc: Include sequences for Windows.
 
-2006-12-06  S�ren Hauberg  <hauberg@gmail.com>
+2006-12-06  Søren Hauberg  <hauberg@gmail.com>
 
 	* pkg/pkg.m (unload_packages): New function.
 	(pkg): Handle unload action.
@@ -11578,7 +11578,7 @@
 	* image/image_viewer.m: Always return old values.  Check arguments.
 	* image/__img_gnuplot__.m: Rename from __img__m.
 
-2006-11-14  S�ren Hauberg  <soren@hauberg.org>
+2006-11-14  Søren Hauberg  <soren@hauberg.org>
 
 	* image/image_viewer.m: New function.
 	* image/__img_via_file__.m: New function.
@@ -11608,7 +11608,7 @@
 	* general/__isequal__.m: Avoid assignment of comma-separated lists
 	when comparing structs.
 
-2006-11-13  S�ren Hauberg  <hauberg@gmail.com>
+2006-11-13  Søren Hauberg  <hauberg@gmail.com>
 
 	* general/bicubic.m, general/cart2pol.m, general/cart2sph.m,
 	plot/contour.m, linear-algebra/cross.m, general/cumtrapz.m,
@@ -11622,11 +11622,11 @@
 
 	* plot/mesh.m: Use size_equal to compare dimensions.
 
-2006-11-13  S�ren Hauberg  <soren@hauberg.org>
+2006-11-13  Søren Hauberg  <soren@hauberg.org>
 
 	* plot/mesh.m: Simplify.  Set hidden3d for the plot.
 
-2006-11-11  S�ren Hauberg  <soren@hauberg.org>
+2006-11-11  Søren Hauberg  <soren@hauberg.org>
 
 	* miscellaneous/copyfile.m: Fix docs to match function.
 
@@ -11674,7 +11674,7 @@
 
 	* startup/main-rcfile: Conditionally set PAGER_FLAGS.
 
-2006-11-06  S�ren Hauberg  <soren@hauberg.org>
+2006-11-06  Søren Hauberg  <soren@hauberg.org>
 
 	* pkg/pkg.m (extract_pkg): No need to pass "dotexceptnewline"
 	option to regexp.
@@ -11720,7 +11720,7 @@
 	Daniel J Sebald <daniel.sebald@ieee.org> by way of
 	Quentin Spencer <qspencer@ieee.org>.
 
-2006-10-25  S�ren Hauberg  <soren@hauberg.org>
+2006-10-25  Søren Hauberg  <soren@hauberg.org>
 
 	* plot/__pltopt__.m: Update symbol marker id numbers for gnuplot 4.
 
@@ -12034,7 +12034,7 @@
 
 	* pkg/pkg.m: Use fullfile to concatenate directory and file names.
 
-2006-10-04  S�ren Hauberg  <soren@hauberg.org>
+2006-10-04  Søren Hauberg  <soren@hauberg.org>
 
 	* pkg/pkg.m: Update docs.  Handle prefix option.
 	Handle dependencies for load option.
@@ -12047,7 +12047,7 @@
 	* plot/__init_plot_vars__.m: New function.
 	* plot/__setup_plot__.m: Use __init_plot_vars__.
 
-2006-10-03  S�ren Hauberg  <soren@hauberg.org>
+2006-10-03  Søren Hauberg  <soren@hauberg.org>
 
 	* pkg/pkg.m: Avoid calling addpath with no args.
 
@@ -12103,7 +12103,7 @@
 
 	* deprecated/chisquare_pdf.m: Typo in documentation.
 
-2006-09-22  S�ren Hauberg  <soren@hauberg.org>
+2006-09-22  Søren Hauberg  <soren@hauberg.org>
 
 	* signal/filter2.m: Correct texinfo doc.
 
@@ -12182,7 +12182,7 @@
 	* image/saveimage.m: Use logical indexing instead of
 	indices computed by calling find on the logical index.
 
-2006-08-24  S�ren Hauberg  <soren@hauberg.org>
+2006-08-24  Søren Hauberg  <soren@hauberg.org>
 
 	* miscellaneous/bincoeff.m, specfun/factorial.m:
 	Use logical indexing instead of indices computed by calling find
@@ -12210,7 +12210,7 @@
 	PKG_ADD directives and append user supplied PKG_ADD.
 	(pkg): Call create_pkgadd after copying files.
 
-2006-08-21  S�ren Hauberg  <soren@hauberg.org>
+2006-08-21  Søren Hauberg  <soren@hauberg.org>
 
 	* pkg/pkg.m: Handle multiple packages in a single file.
 	Insert directory separator between OCTAVE_HOME and rest of package
@@ -12229,7 +12229,7 @@
 
 	* audio/wavread.m: Fix calculation of sample count.
 
-2006-08-14  S�ren Hauberg  <soren@hauberg.org>
+2006-08-14  Søren Hauberg  <soren@hauberg.org>
 
 	* image/imshow.m: New Matlab-compatible version.
 
@@ -12246,7 +12246,7 @@
 	* sparse/spy.m, control/base/bode.m, control/base/__stepimp__.m,
 	signal/freqz_plot.m: Adapt to new automatic_replot definition.
 
-2006-08-14  S�ren Hauberg  <soren@hauberg.org>
+2006-08-14  Søren Hauberg  <soren@hauberg.org>
 
 	* pkg/pkg.m: Don't pass function name to print_usage.
 	Use addpath and rmpath instead of manipulating LOADPATH.
@@ -12377,7 +12377,7 @@
 	* tar.m, untar.m, unzip.m: Adapt to Octave coding style.
 	* tar.m, untar.m: Only tar; don't compress or uncompress.
 
-2006-05-10  S�ren Hauberg  <hauberg@gmail.com>
+2006-05-10  Søren Hauberg  <hauberg@gmail.com>
 
 	* tar.m, untar.m, unzip.m: New files.
 
@@ -12594,7 +12594,7 @@
 2006-03-15  John W. Eaton  <jwe@octave.org>
 
 	* miscellaneous/doc.m: New file.
-	From S�ren Hauberg <soren@hauberg.org>.
+	From Søren Hauberg <soren@hauberg.org>.
 
 2006-03-15  Keith Goodman  <kwgoodman@gmail.com>
 
@@ -13382,7 +13382,7 @@
 	* optimization/glpk.m, optimization/glpkparams.m,
 	optimization/glpktest1, optimization/glpktest2: New files.
 
-2005-03-16  S�ren Hauberg  <soren@hauberg.org>
+2005-03-16  Søren Hauberg  <soren@hauberg.org>
 
 	* strings/split.m: Quick return for empty second arg.
 	Improve warning for multi-line strings.
--- a/etc/OLD-ChangeLogs/src-ChangeLog
+++ b/etc/OLD-ChangeLogs/src-ChangeLog
@@ -3027,7 +3027,7 @@
 	the "eng" argument.
 	(Fformat): Document the new engineering format.
 
-2010-07-04  Soren Hauberg  <hauberg@gmail.com>
+2010-07-04  Søren Hauberg  <hauberg@gmail.com>
 
 	* DLD_FUNCTIONS/__magick_read__.cc: restore locale after
 	GraphicsMagick initialisation.
@@ -4226,7 +4226,7 @@
 	* load-path.cc (in_path_list): New helper function.
 	(add_to_fcn_map): Use it here.
 
-2010-02-18  S�ren Hauberg  <hauberg@gmail.com>
+2010-02-18  Søren Hauberg  <hauberg@gmail.com>
 
 	* DLD-FUNCTIONS/__magick_read__.cc (__magick_finfo__):
 	Handle multiple frames in a single image file.
@@ -7564,7 +7564,7 @@
 	zooming methods.
 	(help_text): Update to reflect new mouse/key bindings.
 
-2009-07-23  Soren Hauberg  <hauberg@gmail.com>
+2009-07-23  Søren Hauberg  <hauberg@gmail.com>
 
 	* graphics.cc (axes::properties::zoom_about_point,
 	axes::properties::translate_view): New functions.
@@ -10246,12 +10246,12 @@
 
 	* DLD-FUNCTIONS/eigs.cc: eigs.cc: skip tests if ARPACK is missing.
 
-2009-01-25  S�ren Hauberg  <hauberg@gmail.com>
+2009-01-25  Søren Hauberg  <hauberg@gmail.com>
 
 	* help.cc (do_get_help_text, raw_help_from_symbol_table): new output to
 	flag the a function is found but not documented.
 
-2009-01-25  S�ren Hauberg  <hauberg@gmail.com>
+2009-01-25  Søren Hauberg  <hauberg@gmail.com>
 
 	* help.cc (raw_help_from_file): No longer search for files called
 	'Contents.m', as this is moved to 'script/help.m'.
@@ -10302,7 +10302,7 @@
 	* do_which (const std::string&):
 	Call do_which (const std::string&, std::string&) to do the work.
 
-2009-01-22  S�ren Hauberg  <hauberg@gmail.com>
+2009-01-22  Søren Hauberg  <hauberg@gmail.com>
 
 	* defun-int.h (print_usage): No longer mark as deprecated.
 	* defun.cc (print_usage): Simply call feval to execute print_usage.m.
@@ -10452,12 +10452,12 @@
 	* ov-struct.cc: Ditto.
 	* pt-decl.h: Ditto.
 
-2009-01-15  S�ren Hauberg  <hauberg@gmail.com>
+2009-01-15  Søren Hauberg  <hauberg@gmail.com>
 
 	* DLD-FUNCTIONS/__magick_read__.cc (encode_uint_image):
 	Initialize bitdepth.
 
-2009-01-14  S�ren Hauberg  <hauberg@gmail.com>
+2009-01-14  Søren Hauberg  <hauberg@gmail.com>
 
 	* DLD-FUNCTIONS/betainc.cc, DLD-FUNCTIONS/chol.cc,
 	DLD-FUNCTIONS/daspk.cc, DLD-FUNCTIONS/dasrt.cc,
@@ -11429,7 +11429,7 @@
 	* symtab.cc (symbol_table::do_find): Don't set evaluated_args and
 	args_evaluated here, prior to call to symbol_table::fcn_info::find.
 
-2008-09-24  S�ren Hauberg  <hauberg@gmail.com>
+2008-09-24  Søren Hauberg  <hauberg@gmail.com>
 
 	* DLD-FUNCTIONS/__magick_read__.cc (magick_to_octave_value): New
 	template function with specializations for various
@@ -11873,7 +11873,7 @@
 	Fix typo in warning identifier.
 	(make_unimplemented_options): Use CamelCase names here.
 
-2008-08-06  S�ren Hauberg  <hauberg@gmail.com>
+2008-08-06  Søren Hauberg  <hauberg@gmail.com>
 
 	* error.cc (Ferror): Update format of error messages in exmple.
 	* parse.y: (Feval): Likewise.
@@ -14465,7 +14465,7 @@
 	* DLD-FUNCTIONS/__convn__.cc (convn): Use traits class and
 	typedefs to allow all types to be deduced from argument types.
 
-2008-03-27  S�ren Hauberg  <hauberg@gmail.com>
+2008-03-27  Søren Hauberg  <hauberg@gmail.com>
 
 	* DLD-FUNCTIONS/__convn__.cc (Fconvn): Allow convolving real data with
 	complex data.
@@ -14515,7 +14515,7 @@
 	DLD-FUNCTIONS/qr.cc, DLD-FUNCTIONS/symrcm.cc, file-io.cc):
 	Texinfo fixes.
 
-2008-03-26  S�ren Hauberg  <hauberg@gmail.com>
+2008-03-26  Søren Hauberg  <hauberg@gmail.com>
 
 	* DLD-FUNCTIONS/__convn__.cc (Fconvn):
 	Call complex_array_value to extract N-d array.
@@ -14525,7 +14525,7 @@
 	* ov-base-sparse.cc (octave_base_sparse<T>::print_raw):
 	Also display percentage of elements that are nonzero.
 
-2008-03-25  S�ren Hauberg  <hauberg@gmail.com>
+2008-03-25  Søren Hauberg  <hauberg@gmail.com>
 
 	* DLD-FUNCTIONS/__convn__.cc: New file.
 	* Makefile.in: Add __convn__.cc
@@ -16805,7 +16805,7 @@
 
 	* DLD-FUNCTIONS/__qp__.cc (qp): Fix check for Wact(j).
 
-2007-10-15  S�ren Hauberg  <hauberg@gmail.com>
+2007-10-15  Søren Hauberg  <hauberg@gmail.com>
 
 	* error.cc (Ferror): Make text fit on pages when using smallbook.
 	* load-save.cc (Fsave_header_format_string): Ditto.
@@ -17533,7 +17533,7 @@
 	(octave_stream_list::do_insert, octave_steam_list::insert):
 	Remove const qualifier of argument.
 
-2007-06-18  S�ren Hauberg  <hauberg@gmail.com>
+2007-06-18  Søren Hauberg  <hauberg@gmail.com>
 
 	* DLD-FUNCTIONS/__lin_interpn__.cc: Replace octave_NaN with octave_NA.
 
@@ -17748,7 +17748,7 @@
 	arguments.
 	(Fdbclar): ditto. Eliminate extraneous debugging messages.
 
-2007-05-21  S�ren Hauberg  <hauberg@gmail.com>
+2007-05-21  Søren Hauberg  <hauberg@gmail.com>
 
 	* load-path.cc (Fpath, Frehash): Replace "LOADPATH" with "load
 	path" in doc strings.
@@ -17769,7 +17769,7 @@
 	(Octave_map::empty): Delete.
 	Change all uses of empty to check nfields () == 0 instead.
 
-2007-05-21  S�ren Hauberg  <soren@hauberg.org>
+2007-05-21  Søren Hauberg  <soren@hauberg.org>
 
 	* help.cc (Fautoload): Doc fix.
 	* variables.cc (Fiscommand): Doc fix.
@@ -17778,7 +17778,7 @@
 
 	* ov-fcn-inline.cc (Fvectorize): Doc fix.
 
-2007-05-16  S�ren Hauberg  <soren@hauberg.org>
+2007-05-16  Søren Hauberg  <soren@hauberg.org>
 
 	* ov.cc (Fsubsref, Fsubsasgn): Doc fix.
 
@@ -17846,14 +17846,14 @@
 
 	* DLD-FUNCTIONS/fft.cc (do_fft): Handle empty matrices.  New tests.
 
-2007-05-14  S�ren Hauberg  <soren@hauberg.org>
+2007-05-14  Søren Hauberg  <soren@hauberg.org>
 
 	* toplev.cc (Fatexit): Simplify example in doc string.
 	* help.cc (Flookfor): Doc fix.
 	* DLD-FUNCTIONS/cellfun.cc (Fcellfun):
 	Reformat to avoid long lines in doc string example.
 
-2007-05-13  S�ren Hauberg  <soren@hauberg.org>
+2007-05-13  Søren Hauberg  <soren@hauberg.org>
 
 	* toplev.cc (Fquit): Doc fix.
 	* help.cc (Fhelp): Doc fix.
@@ -17934,7 +17934,7 @@
 	* ov-usr-fcn.cc (octave_user_function::do_multi_index_op):
 	Only deal with varargout if ret_list->takes_varargs () is true.
 
-2007-04-26  S�ren Hauberg  <soren@hauberg.org>
+2007-04-26  Søren Hauberg  <soren@hauberg.org>
 
 	* DLD-FUNCTIONS/urlwrite.cc: Doc fix.
 
@@ -17963,7 +17963,7 @@
 	(color_property::validate): Use rgba.
 	(color_property::c2rgba): New function.
 
-2007-04-23  S�ren Hauberg  <soren@hauberg.org>
+2007-04-23  Søren Hauberg  <soren@hauberg.org>
 
 	* data.cc (Fsize_equal): Allow more than two arguments.
 
@@ -19366,7 +19366,7 @@
 	New functions.
 	* ov-base-int.h: Provide decls.
 
-2006-09-15  S�ren Hauberg  <soren@hauberg.org>.
+2006-09-15  Søren Hauberg  <soren@hauberg.org>.
 
 	* data.cc (Fsize): If nargout > ndims, fill with 1.
 
@@ -21472,7 +21472,7 @@
 	* help.cc (help_from_info): Simplify.
 	(try_info): Use feval to call doc instead of executing info program.
 	(additional_help_message): Point users to doc instead of help -i.
-	From S�ren Hauberg <soren@hauberg.org>.
+	From Søren Hauberg <soren@hauberg.org>.
 
 	* toplev.cc (Fsystem): Return output if nargout > 1, not 0.
 
@@ -22319,7 +22319,7 @@
 
 2005-07-18  John W. Eaton  <jwe@octave.org>
 
-	* strfns.cc (Fstrcmp): New function from S�ren Hauberg
+	* strfns.cc (Fstrcmp): New function from Søren Hauberg
 	<soren@hauberg.org> and Tom Holroyd <tomh@kurage.nimh.nih.gov>.
 	Adapt to Octave conventions.
 
--- a/etc/OLD-ChangeLogs/test-ChangeLog
+++ b/etc/OLD-ChangeLogs/test-ChangeLog
@@ -285,7 +285,7 @@
 
 	* test_struct.m: Add struct array tests.
 
-2009-01-23  Søren Hauberg  <hauberg@gmail.com>
+2009-01-23  Søren Hauberg  <hauberg@gmail.com>
 
 	* test_prefer.m: Update to match new API of the 'type' function.
 
deleted file mode 100644
--- a/etc/README.devel
+++ /dev/null
@@ -1,82 +0,0 @@
-This directory contains development releases of Octave.
-
-If you want a stable, well-tested version of Octave, you should be
-looking at ftp://ftp.gnu.org/gnu/octave.
-
-Development releases are provided for people who want to help test,
-debug, and improve Octave.  Very little testing is done before making
-the development releases and they may even be made when Octave is in
-an inconsistent state.  It is possible that you will encounter a
-very obvious bug, such as a failure to compile on *any* machine.  It is
-likely that such bugs will be fixed by the next development release,
-so it really isn't necessary to report them unless they persist over
-more than one release.
-
-Please DO report other bugs in the development releases as soon as you
-find them.  Bugs should be reported to the bug tracker at
-'http://bugs.octave.org'.  Please read read the bug reporting
-guidelines (http://www.gnu.org/software/octave/bugs.html) before
-submitting an item.
-
-If you have a fix for a bug, or an enhancement to submit, send your
-patch to maintainers@octave.org or submit it to the patch
-tracker at 'http://savannah.gnu.org/patch/?group=octave'. 
-
-By adhering to the following guidelines you can minimize the work that
-Octave maintainers need to do to apply your patch.  Maintaining Octave
-is a lot of work in the best of circumstances, and we can't keep up
-unless you do your best to help.
-
-   * Send an explanation with your changes of what problem they fix or
-     what improvement they bring about.  For a bug fix, just include a
-     copy of the bug report, and explain why the change fixes the bug.
-
-   * Always include a proper bug report for the problem you think you
-     have fixed.  We need to convince ourselves that the change is
-     right before installing it.  Even if it is right, we might have
-     trouble judging it if we don't have a way to reproduce the problem.
-
-   * Include all the comments that are appropriate to help people
-     reading the source in the future understand why this change was
-     needed.
-
-   * Don't mix together changes made for different reasons.  Send them
-     _individually_.
-
-     If you make two changes for separate reasons, then we might not
-     want to install them both.  We might want to install just one.
-
-   * Use `diff -c' to make your diffs.  Diffs without context are hard
-     for us to install reliably.  More than that, they make it hard for
-     us to study the diffs to decide whether we want to install them.
-     Unified diff format is better than contextless diffs, but not as
-     easy to read as `-c' format.
-
-     If you have GNU diff, use `diff -cp', which shows the name of the
-     function that each change occurs in.
-
-   * Write the change log entries for your changes.
-
-     Read the `ChangeLog' file to see what sorts of information to put
-     in, and to learn the style that we use.  The purpose of the
-     change log is to show people where to find what was changed.  So
-     you need to be specific about what functions you changed; in
-     large functions, it's often helpful to indicate where within the
-     function the change was made.
-
-     On the other hand, once you have shown people where to find the
-     change, you need not explain its purpose.  Thus, if you add a new
-     function, all you need to say about it is that it is new.  If you
-     feel that the purpose needs explaining, it probably does--but the
-     explanation will be much more useful if you put it in comments in
-     the code.
-
-     If you would like your name to appear in the header line for who
-     made the change, send us the header line.
-
-If you would like to be on the very sharpest part of the bleeding
-edge, you can now use Mercurial to access Octave's current development
-sources.  Instructions for checking out a copy are available on the
-web at http://www.gnu.org/software/octave/download.html.
-
-Last updated: Sat Jan 22 21:26:18 PST 2011
deleted file mode 100644
--- a/etc/README.ftp
+++ /dev/null
@@ -1,38 +0,0 @@
-This directory contains the source for Octave, a high-level interactive
-language for solving numerical problems.  See the file README for more general
-information, and the file NEWS for a list of recent changes.
-
-Binary distributions:
---------------------
-
-Octave binaries are not distributed from this site.
-
-Packaged versions of Octave for various GNU/Linux systems are available
-with the major GNU/Linux distributions (Debian, Ubuntu, Red Hat, SUSE, etc.).
-
-Binary distributions of Octave for Mac OS X are available from both Fink
-and MacPorts.
-
-  http://www.finkproject.com
-  http://www.macports.org/
-
-The file README.Windows provides instructions for installing Octave on
-Windows systems.
-
-A note about .gz files:
-----------------------
-
-Files with names ending in `.gz' have been compressed with `gzip'.
-
-Unlike the compress utility, gzip is free of any known software
-patents and tends to compress better anyway.  Gzip can uncompress
-`compress'-compressed files too, so you can install it as "uncompress"
-and use it to handle both types of files.
-
-The gzip program is available in the directory /pub/gnu in shar, tar,
-or gzipped tar format (for those who already have a prior version of
-gzip and want faster data transmission).  It works on virtually every
-unix system, MSDOS, OS/2, and VMS.
-
-
-Last updated: Thu Jan 20 10:14:49 PST 2011
deleted file mode 100644
--- a/etc/README.mirrors
+++ /dev/null
@@ -1,12 +0,0 @@
-If you have trouble transferring Octave from this site, you might try
-one of those listed below.  They mirror the /pub/octave directory on
-ftp.octave.org
-
-FTP:
-
-  site                          directory
-  ----                          ---------
-  ftp.u-aizu.ac.jp              /pub/SciEng/numanal/Octave
-  mirrors.fe.up.pt              /pub/octave
-
-Last updated: Mon Jan 10 21:26:17 PST 2011
deleted file mode 100644
--- a/etc/README.snapshots
+++ /dev/null
@@ -1,161 +0,0 @@
-Octave Snapshots -- general info
-
-Snapshots are an "image" of the main Octave development tree, captured
-at a particular random instant in time.  When you use the snapshots,
-you should be able to maintain a local copy of Octave that is
-reasonably close to the official source tree used by the Octave
-maintainers.
-
-The primary purpose of providing snapshots is to widen the group of
-motivated developers that would like to help test, debug, and enhance
-Octave, by providing you with access to the "latest and greatest"
-source.  This has several advantages, and several disadvantages.
-
-    First the advantages:
-
-    o	Once we have a large base of motivated testers using the
-	snapshots, this should provide good coverage across all
-	currently supported Octave hosts and targets.  If a new bug is
-	introduced in Octave due to fixing another bug or ongoing
-	development, it should become obvious much more quickly and
-	get fixed before the next general net release.  This should
-	help to reduce the chances of Octave being released to the
-	general public with a major bug that went unnoticed during the
-	release cycle testing because they are machine dependent.  We
-	hope to greatly improve Octave's stability and reliability by
-	involving more people and more execution environments in the
-	prerelease testing.
-
-    o	With access to the latest source, any diffs that you send to fix
-	bugs or add new features should be much easier for the Octave
-	maintainers to merge into the official source base (after
-	suitable review of course).  This encourages us to merge your
-	changes quicker, while they are still "fresh".
-
-    o	Once your diffs are merged, you can obtain a new copy of Octave
-	containing your changes almost immediately.  Thus you do not
-	have to maintain local copies of your changes for any longer
-	than it takes to get them merged into the official source
-	base.  This encourages you to send in changes quicker.
-
-    And the disadvantages:
-
-    o	The snapshot you get will be largely untested and of unknown
-	quality.  It may fail to configure or compile.  It may have
-	serious bugs.  You should always keep a copy of the last known
-	working version before updating to the current snapshot, or at
-	least be able to regenerate a working version if the latest
-	snapshot is unusable in your environment for some reason.
-
-	If a production version of Octave has a bug and a snapshot has
-	the fix, and you care about stability, you should put only the
-	fix for that particular problem into your production version.
-	Of course, if you are eager to test Octave, you can use the
-	snapshot versions in your daily work, but users who have not
-	been consulted about whether they feel like testing Octave should
-	generally have something which is at least as bug free as the
-	last released version.
-
-    o	Providing timely response to your questions, bug reports, and
-	submitted patches will require the Octave developers to
-	allocate time from an already thin time budget.  Please try to
-	help us make this time as productive as possible.  See the
-	section below about how to submit changes.
-
-
-How to get the snapshots
-------------------------
-
-The current plan is to provide a full snapshot every week or so.  For
-now, diffs from previous versions will not be available.  The files
-will be available via anonymous ftp from ftp.octave.org, in the
-directory /private/octave in the form of a tar files compressed with
-GNU gzip.  You can ftp gzip from ftp.octave.org in the directory
-/pub/gnu.
-
-Even though the snapshots are available in a public place, we ask that
-recipients not widely publicize the availability of the snapshots.
-The motivation for this request is not to hoard them, but to avoid the
-situation where the general Octave user base naively attempts to use
-the snapshots, has trouble with them, complains publicly, and the
-reputation of Octave declines because of a perception of instability
-or lack of quality control.
-
-
-Octave test suite
------------------
-
-A test suite is distributed as an integral part of the snapshots.
-However, to use it you will need to get a copy of the dejagnu testing
-framework.  Snapshots of dejagnu are available alongside the Octave
-snapshots, using the same naming conventions as the Octave snapshots.
-Once you have installed the dejagnu framework, a simple "make check"
-in the Octave directory should be sufficient to run the tests.
-
-Note that the test suite is still quite limited.  The test framework
-itself might not install on your system if you have an environment
-that is not similar to one that the Octave developers already use.
-The tests themselves only cover a small portion of Octave features,
-and what tests do exist for a feature are not exhaustive.  New tests
-are welcomed.
-
-
-Bug reports
------------
-
-Send bug reports to maintainers@octave.org.
-
-Note that since no testing is done on the snapshots, and snapshots may
-even be made when Octave is in an inconsistent state, it may not be
-unusual for an occasional snapshot to have a very obvious bug, such as
-failure to compile on *any* machine.  It is likely that such bugs will
-be fixed by the next snapshot, so it really isn't necessary to report
-them unless they persist over more than one snapshot.
-
-Missing files should always be reported, since they usually mean there
-is a problem with the snapshot-generating process and we won't know
-about them unless someone tells us.
-
-Bugs which are non-obvious, such as failure to compile on only a
-specific machine, a new machine dependent or obscure bug (particularly
-one not detected by the testsuite), etc. should be reported when you
-discover them, or have a suggested patch to fix them.
-
-
-FORMAT FOR PATCHES
-------------------
-
-If you have a fix for a bug, or an enhancement to submit, send your
-patch to maintainers@octave.org.  Here are some simple guidelines for
-submitting patches:
-
-    o	Use "context diffs" for patches.  A typical command for
-	generating context diffs is "diff -rc octave-old octave-new".
-
-    o	Use the "minimalist approach" for patches.  That is, each patch
-	should address only one particular bug, new feature, etc.  Do
-	not save up many unrelated changes and submit them all in one
-	big patch, since in general, the larger the patch the more
-	difficult it is for us to decide if the patch is either
-	correct or desirable.  And if we find something about the
-	patch that needs to be corrected before it can be installed,
-	we would have to reject the entire patch, which might contain
-	changes which otherwise would be accepted if submitted
-	separately.
-
-    o	Submit a sample ChangeLog entry with your patch.  See the
-	existing Octave ChangeLog for examples of what a ChangeLog
-	entry should look like.  The emacs command ^X4A will create a
-	ChangeLog entry header for you.
-
-
-Thanks,
-
-John W. Eaton
-jwe@octave.org
-
-Wed, 31 Oct 2007 16:31:54 EDT
-
-This file was adapted from a similar document written by Fred Fish and
-used by the GDB developers.
-
--- a/examples/@FIRfilter/display.m
+++ b/examples/@FIRfilter/display.m
@@ -1,6 +1,6 @@
 function display (f)
 
-  display(f.polynomial);
+  display (f.polynomial);
 
 endfunction
 
--- a/examples/@FIRfilter/subsref.m
+++ b/examples/@FIRfilter/subsref.m
@@ -2,7 +2,7 @@
   switch x.type
     case "()"
       n = f.polynomial;
-      out = filter(n.poly, 1, x.subs{1});
+      out = filter (n.poly, 1, x.subs{1});
     case "."
       fld = x.subs;
       if (strcmp (fld, "polynomial"))
--- a/examples/@polynomial/display.m
+++ b/examples/@polynomial/display.m
@@ -1,7 +1,7 @@
 function display (p)
   a = p.poly;
   first = true;
-  fprintf("%s =", inputname(1));
+  fprintf ("%s =", inputname (1));
   for i = 1 : length (a);
     if (a(i) != 0)
       if (first)
@@ -26,7 +26,7 @@
     endif
   endfor
   if (first)
-    fprintf(" 0");
+    fprintf (" 0");
   endif
-  fprintf("\n");
+  fprintf ("\n");
 endfunction
--- a/examples/@polynomial/mtimes.m
+++ b/examples/@polynomial/mtimes.m
@@ -1,3 +1,3 @@
 function y = mtimes (a, b)
-  y = polynomial (conv (double(a),double(b)));
-endfunction
\ No newline at end of file
+  y = polynomial (conv (double (a), double (b)));
+endfunction
--- a/examples/@polynomial/plot.m
+++ b/examples/@polynomial/plot.m
@@ -1,10 +1,10 @@
-function h = plot(p, varargin)
+function h = plot (p, varargin)
   n = 128;
   rmax = max (abs (roots (p.poly)));
   x = [0 : (n - 1)] / (n - 1) * 2.2 * rmax - 1.1 * rmax;
   if (nargout > 0)
-    h = plot(x, p(x), varargin{:});
+    h = plot (x, p(x), varargin{:});
   else
-    plot(x, p(x), varargin{:});
+    plot (x, p(x), varargin{:});
   endif
-endfunction
\ No newline at end of file
+endfunction
--- a/examples/@polynomial/polyval.m
+++ b/examples/@polynomial/polyval.m
@@ -1,7 +1,7 @@
 function [y, dy] = polyval (p, varargin)
   if (nargout == 2)
-    [y, dy] = polyval (fliplr(p.poly), varargin{:});
+    [y, dy] = polyval (fliplr (p.poly), varargin{:});
   else
-    y = polyval (fliplr(p.poly), varargin{:});
+    y = polyval (fliplr (p.poly), varargin{:});
   endif
 endfunction
--- a/examples/embedded.cc
+++ b/examples/embedded.cc
@@ -10,33 +10,24 @@
   argv(0) = "embedded";
   argv(1) = "-q";
 
-  octave_main (2, argv.c_str_vec(), 1);
+  octave_main (2, argv.c_str_vec (), 1);
 
   octave_idx_type n = 2;
-  Matrix a_matrix = Matrix (1, 2);
+  octave_value_list in;
 
-  std::cout << "GCD of [";
-  for (octave_idx_type i = 0; i < n; i++)
-    {
-      a_matrix (i) = 5 * (i + 1);
-      if (i != 0)
-        std::cout << ", " << 5 * (i + 2);
-      else
-        std::cout << 5 * (i + 2);
-    }
-  std::cout << "] is ";
-
-  octave_value_list in = octave_value (a_matrix);
+  for (octave_idx_type i = 0; i < n; i++)  
+    in(i) = octave_value (5 * (i + 1));
+  
   octave_value_list out = feval ("gcd", in, 1);
 
+  
   if (!error_state && out.length () > 0)
-    {
-      a_matrix = out(0).matrix_value ();
-      if (a_matrix.numel () == 1)
-        std::cout << a_matrix(0) << "\n";
-      else
-        std::cout << "invalid\n";
-    }
+    std::cout << "GCD of [" 
+              << in(0).int_value () 
+              << ", " 
+              << in(1).int_value ()
+              << "] is " << out(0).int_value () 
+              << std::endl;
   else
     std::cout << "invalid\n";
 
--- a/examples/fortdemo.cc
+++ b/examples/fortdemo.cc
@@ -12,7 +12,7 @@
 DEFUN_DLD (fortdemo , args , , "Fortran Demo.")
 {
   octave_value_list retval;
-  int nargin = args.length();
+  int nargin = args.length ();
   if (nargin != 1)
     print_usage ();
   else
--- a/examples/funcdemo.cc
+++ b/examples/funcdemo.cc
@@ -3,7 +3,7 @@
 
 DEFUN_DLD (funcdemo, args, nargout, "Function Demo")
 {
-  int nargin = args.length();
+  int nargin = args.length ();
   octave_value_list retval;
 
   if (nargin < 2)
--- a/examples/hello.cc
+++ b/examples/hello.cc
@@ -89,9 +89,9 @@
 
   for (int i = 0; i < nargin; i++)
     {
-      octave_value tmp = args (i);
+      octave_value tmp = args(i);
       tmp.print (octave_stdout);
-      retval (nargin-i-1) = tmp;
+      retval(nargin-i-1) = tmp;
     }
 
   return retval;
--- a/examples/myprop.c
+++ b/examples/myprop.c
@@ -8,7 +8,7 @@
 
   if (nrhs < 2 || nrhs > 3)
     mexErrMsgTxt ("incorrect number of arguments");
-  if (!mxIsDouble(prhs[0]))
+  if (!mxIsDouble (prhs[0]))
     mexErrMsgTxt ("handle expected to be a double scalar");
   if (!mxIsChar (prhs[1]))
     mexErrMsgTxt ("expected property to be a string");
--- a/examples/paramdemo.cc
+++ b/examples/paramdemo.cc
@@ -7,23 +7,23 @@
   octave_value retval;
 
   if (nargin != 1)
-    print_usage();
+    print_usage ();
   else if (nargout != 0)
     error ("paramdemo: function has no output arguments");
   else
     {
-      NDArray m = args(0).array_value();
+      NDArray m = args(0).array_value ();
       double min_val = -10.0;
       double max_val = 10.0;
       octave_stdout << "Properties of input array:\n";
       if (m.any_element_is_negative ())
         octave_stdout << "  includes negative values\n";
-      if (m.any_element_is_inf_or_nan())
+      if (m.any_element_is_inf_or_nan ())
         octave_stdout << "  includes Inf or NaN values\n";
-      if (m.any_element_not_one_or_zero())
+      if (m.any_element_not_one_or_zero ())
         octave_stdout <<
           "  includes other values than 1 and 0\n";
-      if (m.all_elements_are_int_or_inf_or_nan())
+      if (m.all_elements_are_int_or_inf_or_nan ())
         octave_stdout <<
           "  includes only int, Inf or NaN values\n";
       if (m.all_integers (min_val, max_val))
--- a/examples/stringdemo.cc
+++ b/examples/stringdemo.cc
@@ -2,7 +2,7 @@
 
 DEFUN_DLD (stringdemo, args, , "String Demo")
 {
-  int nargin = args.length();
+  int nargin = args.length ();
   octave_value_list retval;
 
   if (nargin != 1)
@@ -18,13 +18,13 @@
           else
             retval(1) = octave_value (ch, true, '\'');
 
-          octave_idx_type nr = ch.rows();
+          octave_idx_type nr = ch.rows ();
           for (octave_idx_type i = 0; i < nr / 2; i++)
             {
               std::string tmp = ch.row_as_string (i);
-              ch.insert (ch.row_as_string(nr-i-1).c_str(),
+              ch.insert (ch.row_as_string (nr-i-1).c_str (),
                          i, 0);
-              ch.insert (tmp.c_str(), nr-i-1, 0);
+              ch.insert (tmp.c_str (), nr-i-1, 0);
             }
           retval(0) = octave_value (ch, true);
         }
--- a/examples/unwinddemo.cc
+++ b/examples/unwinddemo.cc
@@ -9,7 +9,7 @@
 
 DEFUN_DLD (unwinddemo, args, nargout, "Unwind Demo")
 {
-  int nargin = args.length();
+  int nargin = args.length ();
   octave_value retval;
   if (nargin < 2)
     print_usage ();
@@ -22,7 +22,7 @@
         {
           unwind_protect::begin_frame ("Funwinddemo");
           unwind_protect_ptr (current_liboctave_warning_handler);
-          set_liboctave_warning_handler(err_hand);
+          set_liboctave_warning_handler (err_hand);
           retval = octave_value (quotient (a, b));
           unwind_protect::run_frame ("Funwinddemo");
         }
--- a/libcruft/Makefile.am
+++ b/libcruft/Makefile.am
@@ -31,6 +31,8 @@
 
 libcruft_la_SOURCES =
 
+nodist_libcruft_la_SOURCES =
+
 libcruft_la_FFLAGS = $(F77_INTEGER_8_FLAG)
 
 libcruft_la_CPPFLAGS = \
@@ -47,7 +49,7 @@
 # Increment these as needed and according to the rules in the libtool
 # manual:
 libcruft_current = 1
-libcruft_revision = 1
+libcruft_revision = 0
 libcruft_age = 0
 
 libcruft_version_info = $(libcruft_current):$(libcruft_revision):$(libcruft_age)
@@ -98,5 +100,5 @@
 
 EXTRA_DIST += mkf77def.in
 
-DISTCLEANFILES = cruft.def ranlib.def
+DISTCLEANFILES = cruft.def ranlib.def $(nodist_libcruft_la_SOURCES)
 
--- a/libcruft/misc/lo-error.c
+++ b/libcruft/misc/lo-error.c
@@ -111,6 +111,7 @@
 liboctave_fatal_with_id (const char *id, const char *fmt, ...)
 {
   va_list args;
+  (void) id; /*unused*/
   va_start (args, fmt);
   verror ("fatal", fmt, args);
   va_end (args);
@@ -131,6 +132,7 @@
 liboctave_warning_with_id (const char *id, const char *fmt, ...)
 {
   va_list args;
+  (void) id; /*unused*/
   va_start (args, fmt);
   verror ("warning", fmt, args);
   va_end (args);
--- a/libcruft/slatec-fn/atanh.f
+++ b/libcruft/slatec-fn/atanh.f
@@ -57,8 +57,14 @@
       FIRST = .FALSE.
 C
       Y = ABS(X)
-      IF (Y .GE. 1.0) CALL XERMSG ('SLATEC', 'ATANH', 'ABS(X) GE 1', 2,
-     +   2)
+      IF (Y .GE. 1.0) THEN
+         IF (Y .GT. 1.0) THEN 
+            ATANH = (X - X) / (X - X)
+         ELSE
+            ATANH = X / 0.0
+         ENDIF
+         RETURN
+      ENDIF
 C
       IF (1.0-Y .LT. DXREL) CALL XERMSG ('SLATEC', 'ATANH',
      +   'ANSWER LT HALF PRECISION BECAUSE ABS(X) TOO NEAR 1', 1, 1)
--- a/libcruft/slatec-fn/datanh.f
+++ b/libcruft/slatec-fn/datanh.f
@@ -68,8 +68,14 @@
       FIRST = .FALSE.
 C
       Y = ABS(X)
-      IF (Y .GE. 1.D0) CALL XERMSG ('SLATEC', 'DATANH', 'ABS(X) GE 1',
-     +   2, 2)
+      IF (Y .GE. 1.D0) THEN
+         IF (Y .GT. 1.D0) THEN 
+            DATANH = (X - X) / (X - X)
+         ELSE
+            DATANH = X / 0.D0
+         ENDIF
+         RETURN
+      ENDIF
 C
       IF (1.D0-Y .LT. DXREL) CALL XERMSG ('SLATEC', 'DATANH',
      +   'ANSWER LT HALF PRECISION BECAUSE ABS(X) TOO NEAR 1', 1, 1)
--- a/libcruft/slatec-fn/derf.f
+++ b/libcruft/slatec-fn/derf.f
@@ -69,7 +69,7 @@
 C
 C ERF(X) = 1.0 - ERFC(X)  FOR  -1.0 .LE. X .LE. 1.0
 C
-      IF (Y.LE.SQEPS) DERF = 2.0D0*X*X/SQRTPI
+      IF (Y.LE.SQEPS) DERF = 2.0D0*X/SQRTPI
       IF (Y.GT.SQEPS) DERF = X*(1.0D0 + DCSEVL (2.D0*X*X-1.D0,
      1  ERFCS, NTERF))
       RETURN
rename from libcruft/slatec-fn/derfc.f
rename to libcruft/slatec-fn/derfc.in.f
--- a/libcruft/slatec-fn/derfc.f
+++ b/libcruft/slatec-fn/derfc.in.f
@@ -191,6 +191,11 @@
       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
@@ -219,8 +224,7 @@
       IF (X.LT.0.D0) DERFC = 2.0D0 - DERFC
       RETURN
 C
- 40   CALL XERMSG ('SLATEC', 'DERFC', 'X SO BIG ERFC UNDERFLOWS', 1, 1)
-      DERFC = 0.D0
+ 40   DERFC = 0.D0
       RETURN
 C
       END
rename from libcruft/slatec-fn/erfc.f
rename to libcruft/slatec-fn/erfc.in.f
--- a/libcruft/slatec-fn/erfc.f
+++ b/libcruft/slatec-fn/erfc.in.f
@@ -121,6 +121,11 @@
       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
@@ -149,8 +154,7 @@
       IF (X.LT.0.) ERFC = 2.0 - ERFC
       RETURN
 C
- 40   CALL XERMSG ('SLATEC', 'ERFC', 'X SO BIG ERFC UNDERFLOWS', 1, 1)
-      ERFC = 0.
+ 40   ERFC = 0.
       RETURN
 C
       END
--- a/libcruft/slatec-fn/module.mk
+++ b/libcruft/slatec-fn/module.mk
@@ -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-util.cc
+++ b/liboctave/Array-util.cc
@@ -236,7 +236,7 @@
   Array<octave_idx_type> retval (a.dims ());
 
   for (octave_idx_type i = 0; i < a.length (); i++)
-    retval (i) = a(i).elem (0);
+    retval(i) = a(i).elem (0);
 
   return retval;
 }
@@ -247,7 +247,7 @@
   Array<idx_vector> retval (dim_vector (len, 1));
 
   for (octave_idx_type i = 0; i < len; i++)
-      retval (i) = tmp[i];
+      retval(i) = tmp[i];
 
   return retval;
 }
--- a/liboctave/Array.cc
+++ b/liboctave/Array.cc
@@ -884,7 +884,8 @@
 // The default fill value.  Override if you want a different one.
 
 template <class T>
-const T& Array<T>::resize_fill_value ()
+T
+Array<T>::resize_fill_value (void) const
 {
   static T zero = T ();
   return zero;
@@ -1652,24 +1653,24 @@
 %! m9 = reshape (1 : 9*8, 8, 9);
 %! mt9 = [mt8; 65:72];
 
-%!assert(m7', mt7)
-%!assert((1i*m7).', 1i * mt7)
-%!assert((1i*m7)', conj (1i * mt7))
-%!assert(m8', mt8)
-%!assert((1i*m8).', 1i * mt8)
-%!assert((1i*m8)', conj (1i * mt8))
-%!assert(m9', mt9)
-%!assert((1i*m9).', 1i * mt9)
-%!assert((1i*m9)', conj (1i * mt9))
-%!assert([m7, m8; m7, m8]', [mt7, mt7; mt8, mt8])
-%!assert((1i*[m7, m8; m7, m8]).', 1i * [mt7, mt7; mt8, mt8])
-%!assert((1i*[m7, m8; m7, m8])', conj (1i * [mt7, mt7; mt8, mt8]))
-%!assert([m8, m8; m8, m8]', [mt8, mt8; mt8, mt8])
-%!assert((1i*[m8, m8; m8, m8]).', 1i * [mt8, mt8; mt8, mt8])
-%!assert((1i*[m8, m8; m8, m8])', conj (1i * [mt8, mt8; mt8, mt8]))
-%!assert([m9, m8; m9, m8]', [mt9, mt9; mt8, mt8])
-%!assert((1i*[m9, m8; m9, m8]).', 1i * [mt9, mt9; mt8, mt8])
-%!assert((1i*[m9, m8; m9, m8])', conj (1i * [mt9, mt9; mt8, mt8]))
+%!assert (m7', mt7)
+%!assert ((1i*m7).', 1i * mt7)
+%!assert ((1i*m7)', conj (1i * mt7))
+%!assert (m8', mt8)
+%!assert ((1i*m8).', 1i * mt8)
+%!assert ((1i*m8)', conj (1i * mt8))
+%!assert (m9', mt9)
+%!assert ((1i*m9).', 1i * mt9)
+%!assert ((1i*m9)', conj (1i * mt9))
+%!assert ([m7, m8; m7, m8]', [mt7, mt7; mt8, mt8])
+%!assert ((1i*[m7, m8; m7, m8]).', 1i * [mt7, mt7; mt8, mt8])
+%!assert ((1i*[m7, m8; m7, m8])', conj (1i * [mt7, mt7; mt8, mt8]))
+%!assert ([m8, m8; m8, m8]', [mt8, mt8; mt8, mt8])
+%!assert ((1i*[m8, m8; m8, m8]).', 1i * [mt8, mt8; mt8, mt8])
+%!assert ((1i*[m8, m8; m8, m8])', conj (1i * [mt8, mt8; mt8, mt8]))
+%!assert ([m9, m8; m9, m8]', [mt9, mt9; mt8, mt8])
+%!assert ((1i*[m9, m8; m9, m8]).', 1i * [mt9, mt9; mt8, mt8])
+%!assert ((1i*[m9, m8; m9, m8])', conj (1i * [mt9, mt9; mt8, mt8]))
 
 */
 
@@ -2531,6 +2532,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.
@@ -2667,7 +2688,7 @@
 {
   // This guards against accidental implicit instantiations.
   // Array<T> instances should always be explicit and use INSTANTIATE_ARRAY.
-  T::__xXxXx__();
+  T::__xXxXx__ ();
 }
 
 #define INSTANTIATE_ARRAY(T, API) \
--- a/liboctave/Array.h
+++ b/liboctave/Array.h
@@ -327,13 +327,13 @@
   T& xelem (octave_idx_type n) { return slice_data [n]; }
   crefT xelem (octave_idx_type n) const { return slice_data [n]; }
 
-  T& xelem (octave_idx_type i, octave_idx_type j) { return xelem (dim1()*j+i); }
-  crefT xelem (octave_idx_type i, octave_idx_type j) const { return xelem (dim1()*j+i); }
+  T& xelem (octave_idx_type i, octave_idx_type j) { return xelem (dim1 ()*j+i); }
+  crefT xelem (octave_idx_type i, octave_idx_type j) const { return xelem (dim1 ()*j+i); }
 
   T& xelem (octave_idx_type i, octave_idx_type j, octave_idx_type k)
-    { return xelem (i, dim2()*k+j); }
+    { return xelem (i, dim2 ()*k+j); }
   crefT xelem (octave_idx_type i, octave_idx_type j, octave_idx_type k) const
-    { return xelem (i, dim2()*k+j); }
+    { return xelem (i, dim2 ()*k+j); }
 
   T& xelem (const Array<octave_idx_type>& ra_idx)
     { return xelem (compute_index_unchecked (ra_idx)); }
@@ -356,9 +356,9 @@
       return xelem (n);
     }
 
-  T& elem (octave_idx_type i, octave_idx_type j) { return elem (dim1()*j+i); }
+  T& elem (octave_idx_type i, octave_idx_type j) { return elem (dim1 ()*j+i); }
 
-  T& elem (octave_idx_type i, octave_idx_type j, octave_idx_type k) { return elem (i, dim2()*k+j); }
+  T& elem (octave_idx_type i, octave_idx_type j, octave_idx_type k) { return elem (i, dim2 ()*k+j); }
 
   T& elem (const Array<octave_idx_type>& ra_idx)
     { return Array<T>::elem (compute_index_unchecked (ra_idx)); }
@@ -450,46 +450,69 @@
 
   Array<T> index (const Array<idx_vector>& ia) const;
 
-  static const T& resize_fill_value ();
+  virtual T resize_fill_value (void) const;
 
   // Resizing (with fill).
 
-  void resize1 (octave_idx_type n, const T& rfv = resize_fill_value ());
+  void resize1 (octave_idx_type n, const T& rfv);
+  void resize1 (octave_idx_type n) { resize1 (n, resize_fill_value ()); }
 
-  void resize (octave_idx_type n) GCC_ATTR_DEPRECATED
-    { resize1 (n); }
+  void resize (octave_idx_type n) GCC_ATTR_DEPRECATED { resize1 (n); }
 
-  void resize (octave_idx_type nr, octave_idx_type nc,
-               const T& rfv = resize_fill_value ()) GCC_ATTR_DEPRECATED
+  void resize (octave_idx_type nr, octave_idx_type nc, const T& rfv) GCC_ATTR_DEPRECATED
   {
     resize2 (nr, nc, rfv);
   }
 
-  void resize (const dim_vector& dv, const T& rfv = resize_fill_value ());
+  void resize (octave_idx_type nr, octave_idx_type nc) GCC_ATTR_DEPRECATED
+  {
+    resize2 (nr, nc, resize_fill_value ());
+  }
+
+  void resize (const dim_vector& dv, const T& rfv);
+  void resize (const dim_vector& dv) { resize (dv, resize_fill_value ()); }
 
   // Indexing with possible resizing and fill
   // FIXME -- this is really a corner case, that should better be
   // handled directly in liboctinterp.
 
-  Array<T> index (const idx_vector& i, bool resize_ok,
-                  const T& rfv = resize_fill_value ()) const;
+  Array<T> index (const idx_vector& i, bool resize_ok, const T& rfv) const;
+  Array<T> index (const idx_vector& i, bool resize_ok) const
+  {
+    return index (i, resize_ok, resize_fill_value ());
+  }
 
-  Array<T> index (const idx_vector& i, const idx_vector& j,
-                  bool resize_ok, const T& rfv = resize_fill_value ()) const;
+  Array<T> index (const idx_vector& i, const idx_vector& j, bool resize_ok, const T& rfv) const;
+  Array<T> index (const idx_vector& i, const idx_vector& j, bool resize_ok) const
+  {
+    return index (i, j, resize_ok, resize_fill_value ());
+  }
 
-  Array<T> index (const Array<idx_vector>& ia,
-                  bool resize_ok, const T& rfv = resize_fill_value ()) const;
+  Array<T> index (const Array<idx_vector>& ia, bool resize_ok, const T& rfv) const;
+  Array<T> index (const Array<idx_vector>& ia, bool resize_ok) const
+  {
+    return index (ia, resize_ok, resize_fill_value ());
+  }
 
   // Indexed assignment (always with resize & fill).
 
-  void assign (const idx_vector& i, const Array<T>& rhs,
-               const T& rfv = resize_fill_value ());
+  void assign (const idx_vector& i, const Array<T>& rhs, const T& rfv);
+  void assign (const idx_vector& i, const Array<T>& rhs)
+  {
+    assign (i, rhs, resize_fill_value ());
+  }
 
-  void assign (const idx_vector& i, const idx_vector& j, const Array<T>& rhs,
-               const T& rfv = resize_fill_value ());
+  void assign (const idx_vector& i, const idx_vector& j, const Array<T>& rhs, const T& rfv);
+  void assign (const idx_vector& i, const idx_vector& j, const Array<T>& rhs)
+  {
+    assign (i, j, rhs, resize_fill_value ());
+  }
 
-  void assign (const Array<idx_vector>& ia, const Array<T>& rhs,
-               const T& rfv = resize_fill_value ());
+  void assign (const Array<idx_vector>& ia, const Array<T>& rhs, const T& rfv);
+  void assign (const Array<idx_vector>& ia, const Array<T>& rhs)
+  {
+    assign (ia, rhs, resize_fill_value ());
+  }
 
   // Deleting elements.
 
@@ -562,6 +585,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.
@@ -670,8 +695,11 @@
 
 private:
 
-  void resize2 (octave_idx_type nr, octave_idx_type nc,
-                const T& rfv = resize_fill_value ());
+  void resize2 (octave_idx_type nr, octave_idx_type nc, const T& rfv);
+  void resize2 (octave_idx_type nr, octave_idx_type nc)                
+  {
+    resize2 (nr, nc, resize_fill_value ());
+  }
 
   static void instantiation_guard ();
 };
--- a/liboctave/CColVector.cc
+++ b/liboctave/CColVector.cc
@@ -515,7 +515,7 @@
 std::istream&
 operator >> (std::istream& is, ComplexColumnVector& a)
 {
-  octave_idx_type len = a.length();
+  octave_idx_type len = a.length ();
 
   if (len > 0)
     {
--- a/liboctave/CColVector.h
+++ b/liboctave/CColVector.h
@@ -132,8 +132,7 @@
   friend OCTAVE_API std::ostream& operator << (std::ostream& os, const ComplexColumnVector& a);
   friend OCTAVE_API std::istream& operator >> (std::istream& is, ComplexColumnVector& a);
 
-  void resize (octave_idx_type n,
-               const Complex& rfv = Array<Complex>::resize_fill_value ())
+  void resize (octave_idx_type n, const Complex& rfv = Complex (0))
   {
     Array<Complex>::resize (dim_vector (n, 1), rfv);
   }
--- a/liboctave/CDiagMatrix.h
+++ b/liboctave/CDiagMatrix.h
@@ -90,7 +90,7 @@
   ComplexDiagMatrix& fill (const ComplexRowVector& a, octave_idx_type beg);
 
   ComplexDiagMatrix hermitian (void) const { return MDiagArray2<Complex>::hermitian (std::conj); }
-  ComplexDiagMatrix transpose (void) const { return MDiagArray2<Complex>::transpose(); }
+  ComplexDiagMatrix transpose (void) const { return MDiagArray2<Complex>::transpose (); }
   DiagMatrix abs (void) const;
 
   friend OCTAVE_API ComplexDiagMatrix conj (const ComplexDiagMatrix& a);
--- a/liboctave/CMatrix.cc
+++ b/liboctave/CMatrix.cc
@@ -1089,7 +1089,7 @@
       // Calculate the norm of the matrix, for later use.
       double anorm;
       if (calc_cond)
-        anorm  = retval.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+        anorm  = retval.abs ().sum ().row(static_cast<octave_idx_type>(0)).max ();
 
       F77_XFCN (zgetrf, ZGETRF, (nc, nc, tmp_data, nr, pipvt, info));
 
@@ -1127,7 +1127,7 @@
         }
 
       if (info != 0)
-        mattype.mark_as_rectangular();
+        mattype.mark_as_rectangular ();
     }
 
   return retval;
@@ -1153,7 +1153,7 @@
           if (info == 0)
             {
               if (calc_cond)
-                rcon = chol.rcond();
+                rcon = chol.rcond ();
               else
                 rcon = 1.0;
               ret = chol.inverse ();
@@ -1793,8 +1793,8 @@
             {
               octave_idx_type info = 0;
               char job = 'L';
-              anorm = atmp.abs().sum().
-                row(static_cast<octave_idx_type>(0)).max();
+              anorm = atmp.abs ().sum ().
+                row(static_cast<octave_idx_type>(0)).max ();
 
               F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
                                          tmp_data, nr, info
@@ -1833,8 +1833,8 @@
               octave_idx_type *pipvt = ipvt.fortran_vec ();
 
               if(anorm < 0.)
-                anorm = atmp.abs().sum().
-                  row(static_cast<octave_idx_type>(0)).max();
+                anorm = atmp.abs ().sum ().
+                  row(static_cast<octave_idx_type>(0)).max ();
 
               Array<Complex> z (dim_vector (2 * nc, 1));
               Complex *pz = z.fortran_vec ();
@@ -2100,7 +2100,7 @@
           char job = 'L';
           ComplexMatrix atmp = *this;
           Complex *tmp_data = atmp.fortran_vec ();
-          anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+          anorm = atmp.abs ().sum ().row(static_cast<octave_idx_type>(0)).max ();
 
           F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
                                      tmp_data, nr, info
@@ -2156,7 +2156,7 @@
 
                   F77_XFCN (zpotrs, ZPOTRS, (F77_CONST_CHAR_ARG2 (&job, 1),
                                              nr, b_nc, tmp_data, nr,
-                                             result, b.rows(), info
+                                             result, b.rows (), info
                                              F77_CHAR_ARG_LEN (1)));
                 }
               else
@@ -2184,7 +2184,7 @@
 
           // Calculate the norm of the matrix, for later use.
           if (anorm < 0.)
-            anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+            anorm = atmp.abs ().sum ().row(static_cast<octave_idx_type>(0)).max ();
 
           F77_XFCN (zgetrf, ZGETRF, (nr, nr, tmp_data, nr, pipvt, info));
 
@@ -2242,7 +2242,7 @@
                   char job = 'N';
                   F77_XFCN (zgetrs, ZGETRS, (F77_CONST_CHAR_ARG2 (&job, 1),
                                              nr, b_nc, tmp_data, nr,
-                                             pipvt, result, b.rows(), info
+                                             pipvt, result, b.rows (), info
                                              F77_CHAR_ARG_LEN (1)));
                 }
               else
@@ -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
 {
@@ -3702,25 +3719,27 @@
     return ComplexMatrix (m) * a;
 }
 
-/* Simple Dot Product, Matrix-Vector and Matrix-Matrix Unit tests
-%!assert([1+i 2+i 3+i] * [ 4+i ; 5+i ; 6+i], 29+21i, 1e-14)
-%!assert([1+i 2+i ; 3+i 4+i ] * [5+i ; 6+i], [15 + 14i ; 37 + 18i], 1e-14)
-%!assert([1+i 2+i ; 3+i 4+i ] * [5+i 6+i ; 7+i 8+i], [17 + 15i 20 + 17i; 41 + 19i 48 + 21i], 1e-14)
-%!assert([1 i]*[i 0]', -i);
-*/
-
-/* Test some simple identities
+/*
+
+## Simple Dot Product, Matrix-Vector, and Matrix-Matrix Unit tests
+%!assert ([1+i 2+i 3+i] * [ 4+i ; 5+i ; 6+i], 29+21i, 1e-14)
+%!assert ([1+i 2+i ; 3+i 4+i ] * [5+i ; 6+i], [15 + 14i ; 37 + 18i], 1e-14)
+%!assert ([1+i 2+i ; 3+i 4+i ] * [5+i 6+i ; 7+i 8+i], [17 + 15i 20 + 17i; 41 + 19i 48 + 21i], 1e-14)
+%!assert ([1 i]*[i 0]', -i);
+
+## Test some simple identities
 %!shared M, cv, rv
-%! M = randn(10,10)+i*rand(10,10);
-%! cv = randn(10,1)+i*rand(10,1);
-%! rv = randn(1,10)+i*rand(1,10);
-%!assert([M*cv,M*cv],M*[cv,cv],1e-14)
-%!assert([M.'*cv,M.'*cv],M.'*[cv,cv],1e-14)
-%!assert([M'*cv,M'*cv],M'*[cv,cv],1e-14)
-%!assert([rv*M;rv*M],[rv;rv]*M,1e-14)
-%!assert([rv*M.';rv*M.'],[rv;rv]*M.',1e-14)
-%!assert([rv*M';rv*M'],[rv;rv]*M',1e-14)
-%!assert(2*rv*cv,[rv,rv]*[cv;cv],1e-14)
+%! M = randn (10,10) + i*rand (10,10);
+%! cv = randn (10,1) + i*rand (10,1);
+%! rv = randn (1,10) + i*rand (1,10);
+%!assert ([M*cv,M*cv], M*[cv,cv], 1e-14)
+%!assert ([M.'*cv,M.'*cv], M.'*[cv,cv], 1e-14)
+%!assert ([M'*cv,M'*cv], M'*[cv,cv], 1e-14)
+%!assert ([rv*M;rv*M], [rv;rv]*M, 1e-14)
+%!assert ([rv*M.';rv*M.'], [rv;rv]*M.', 1e-14)
+%!assert ([rv*M';rv*M'], [rv;rv]*M', 1e-14)
+%!assert (2*rv*cv, [rv,rv]*[cv;cv], 1e-14)
+
 */
 
 static inline char
--- a/liboctave/CMatrix.h
+++ b/liboctave/CMatrix.h
@@ -152,7 +152,7 @@
   ComplexColumnVector column (octave_idx_type i) const;
 
   void resize (octave_idx_type nr, octave_idx_type nc,
-               const Complex& rfv = resize_fill_value ())
+               const Complex& rfv = Complex (0))
   {
     MArray<Complex>::resize (dim_vector (nr, nc), rfv);
   }
@@ -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;
 
@@ -376,9 +378,6 @@
 
   friend OCTAVE_API std::ostream& operator << (std::ostream& os, const ComplexMatrix& a);
   friend OCTAVE_API std::istream& operator >> (std::istream& is, ComplexMatrix& a);
-
-  static Complex resize_fill_value (void) { return Complex (0.0, 0.0); }
-
 };
 
 extern OCTAVE_API ComplexMatrix conj (const ComplexMatrix& a);
--- a/liboctave/CNDArray.cc
+++ b/liboctave/CNDArray.cc
@@ -119,7 +119,7 @@
 ComplexNDArray
 ComplexNDArray::fourier2d (void) const
 {
-  dim_vector dv = dims();
+  dim_vector dv = dims ();
   if (dv.length () < 2)
     return ComplexNDArray ();
 
@@ -127,7 +127,7 @@
   const Complex *in = fortran_vec ();
   ComplexNDArray retval (dv);
   Complex *out = retval.fortran_vec ();
-  octave_idx_type howmany = numel() / dv(0) / dv(1);
+  octave_idx_type howmany = numel () / dv(0) / dv(1);
   octave_idx_type dist = dv(0) * dv(1);
 
   for (octave_idx_type i=0; i < howmany; i++)
@@ -139,7 +139,7 @@
 ComplexNDArray
 ComplexNDArray::ifourier2d (void) const
 {
-  dim_vector dv = dims();
+  dim_vector dv = dims ();
   if (dv.length () < 2)
     return ComplexNDArray ();
 
@@ -147,7 +147,7 @@
   const Complex *in = fortran_vec ();
   ComplexNDArray retval (dv);
   Complex *out = retval.fortran_vec ();
-  octave_idx_type howmany = numel() / dv(0) / dv(1);
+  octave_idx_type howmany = numel () / dv(0) / dv(1);
   octave_idx_type dist = dv(0) * dv(1);
 
   for (octave_idx_type i=0; i < howmany; i++)
@@ -245,7 +245,7 @@
           F77_FUNC (zfftf, ZFFTF) (npts, tmp, pwsave);
 
           for (octave_idx_type i = 0; i < npts; i++)
-            retval ((i + k*npts)*stride + j*dist) = tmp[i];
+            retval((i + k*npts)*stride + j*dist) = tmp[i];
         }
     }
 
@@ -292,7 +292,7 @@
           F77_FUNC (zfftb, ZFFTB) (npts, tmp, pwsave);
 
           for (octave_idx_type i = 0; i < npts; i++)
-            retval ((i + k*npts)*stride + j*dist) = tmp[i] /
+            retval((i + k*npts)*stride + j*dist) = tmp[i] /
               static_cast<double> (npts);
         }
     }
@@ -333,12 +333,12 @@
               octave_quit ();
 
               for (octave_idx_type l = 0; l < npts; l++)
-                prow[l] = retval ((l + k*npts)*stride + j*dist);
+                prow[l] = retval((l + k*npts)*stride + j*dist);
 
               F77_FUNC (zfftf, ZFFTF) (npts, prow, pwsave);
 
               for (octave_idx_type l = 0; l < npts; l++)
-                retval ((l + k*npts)*stride + j*dist) = prow[l];
+                retval((l + k*npts)*stride + j*dist) = prow[l];
             }
         }
 
@@ -351,7 +351,7 @@
 ComplexNDArray
 ComplexNDArray::ifourier2d (void) const
 {
-  dim_vector dv = dims();
+  dim_vector dv = dims ();
   dim_vector dv2 (dv(0), dv(1));
   int rank = 2;
   ComplexNDArray retval (*this);
@@ -381,12 +381,12 @@
               octave_quit ();
 
               for (octave_idx_type l = 0; l < npts; l++)
-                prow[l] = retval ((l + k*npts)*stride + j*dist);
+                prow[l] = retval((l + k*npts)*stride + j*dist);
 
               F77_FUNC (zfftb, ZFFTB) (npts, prow, pwsave);
 
               for (octave_idx_type l = 0; l < npts; l++)
-                retval ((l + k*npts)*stride + j*dist) = prow[l] /
+                retval((l + k*npts)*stride + j*dist) = prow[l] /
                   static_cast<double> (npts);
             }
         }
@@ -429,12 +429,12 @@
               octave_quit ();
 
               for (octave_idx_type l = 0; l < npts; l++)
-                prow[l] = retval ((l + k*npts)*stride + j*dist);
+                prow[l] = retval((l + k*npts)*stride + j*dist);
 
               F77_FUNC (zfftf, ZFFTF) (npts, prow, pwsave);
 
               for (octave_idx_type l = 0; l < npts; l++)
-                retval ((l + k*npts)*stride + j*dist) = prow[l];
+                retval((l + k*npts)*stride + j*dist) = prow[l];
             }
         }
 
@@ -476,12 +476,12 @@
               octave_quit ();
 
               for (octave_idx_type l = 0; l < npts; l++)
-                prow[l] = retval ((l + k*npts)*stride + j*dist);
+                prow[l] = retval((l + k*npts)*stride + j*dist);
 
               F77_FUNC (zfftb, ZFFTB) (npts, prow, pwsave);
 
               for (octave_idx_type l = 0; l < npts; l++)
-                retval ((l + k*npts)*stride + j*dist) = prow[l] /
+                retval((l + k*npts)*stride + j*dist) = prow[l] /
                   static_cast<double> (npts);
             }
         }
@@ -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
+++ b/liboctave/CNDArray.h
@@ -135,13 +135,13 @@
   friend OCTAVE_API std::ostream& operator << (std::ostream& os, const ComplexNDArray& a);
   friend OCTAVE_API std::istream& operator >> (std::istream& is, ComplexNDArray& a);
 
-  static Complex resize_fill_value (void) { return Complex (0.0, 0.0); }
-
   //  bool all_elements_are_real (void) const;
   //  bool all_integers (double& max_val, double& min_val) const;
 
   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/CRowVector.cc
+++ b/liboctave/CRowVector.cc
@@ -411,7 +411,7 @@
 std::istream&
 operator >> (std::istream& is, ComplexRowVector& a)
 {
-  octave_idx_type len = a.length();
+  octave_idx_type len = a.length ();
 
   if (len > 0)
     {
--- a/liboctave/CRowVector.h
+++ b/liboctave/CRowVector.h
@@ -112,8 +112,7 @@
   friend std::ostream& operator << (std::ostream& os, const ComplexRowVector& a);
   friend std::istream& operator >> (std::istream& is, ComplexRowVector& a);
 
-  void resize (octave_idx_type n,
-               const Complex& rfv = Array<Complex>::resize_fill_value ())
+  void resize (octave_idx_type n, const Complex& rfv = Complex (0))
   {
     Array<Complex>::resize (dim_vector (1, n), rfv);
   }
--- a/liboctave/CSparse.cc
+++ b/liboctave/CSparse.cc
@@ -743,12 +743,12 @@
           typ == MatrixType::Permuted_Diagonal)
         {
           if (typ == MatrixType::Permuted_Diagonal)
-            retval = transpose();
+            retval = transpose ();
           else
             retval = *this;
 
           // Force make_unique to be called
-          Complex *v = retval.data();
+          Complex *v = retval.data ();
 
           if (calccond)
             {
@@ -929,7 +929,7 @@
               OCTAVE_LOCAL_BUFFER (Complex, work, nr);
               OCTAVE_LOCAL_BUFFER (octave_idx_type, rperm, nr);
 
-              octave_idx_type *perm = mattyp.triangular_perm();
+              octave_idx_type *perm = mattyp.triangular_perm ();
               if (typ == MatrixType::Permuted_Upper)
                 {
                   for (octave_idx_type i = 0; i < nr; i++)
@@ -1049,7 +1049,7 @@
   return retval;
 
  inverse_singular:
-  return SparseComplexMatrix();
+  return SparseComplexMatrix ();
 }
 
 SparseComplexMatrix
@@ -1065,26 +1065,26 @@
   if (typ == MatrixType::Diagonal || typ == MatrixType::Permuted_Diagonal)
     ret = dinverse (mattype, info, rcond, true, calc_cond);
   else if (typ == MatrixType::Upper || typ == MatrixType::Permuted_Upper)
-    ret = tinverse (mattype, info, rcond, true, calc_cond).transpose();
+    ret = tinverse (mattype, info, rcond, true, calc_cond).transpose ();
   else if (typ == MatrixType::Lower || typ == MatrixType::Permuted_Lower)
     {
-      MatrixType newtype = mattype.transpose();
-      ret = transpose().tinverse (newtype, info, rcond, true, calc_cond);
+      MatrixType newtype = mattype.transpose ();
+      ret = transpose ().tinverse (newtype, info, rcond, true, calc_cond);
     }
   else
     {
-      if (mattype.is_hermitian())
+      if (mattype.is_hermitian ())
         {
           MatrixType tmp_typ (MatrixType::Upper);
           SparseComplexCHOL fact (*this, info, false);
-          rcond = fact.rcond();
+          rcond = fact.rcond ();
           if (info == 0)
             {
               double rcond2;
-              SparseMatrix Q = fact.Q();
-              SparseComplexMatrix InvL = fact.L().transpose().
+              SparseMatrix Q = fact.Q ();
+              SparseComplexMatrix InvL = fact.L ().transpose ().
                 tinverse(tmp_typ, info, rcond2, true, false);
-              ret = Q * InvL.hermitian() * InvL * Q.transpose();
+              ret = Q * InvL.hermitian () * InvL * Q.transpose ();
             }
           else
             {
@@ -1094,22 +1094,22 @@
             }
         }
 
-      if (!mattype.is_hermitian())
+      if (!mattype.is_hermitian ())
         {
-          octave_idx_type n = rows();
+          octave_idx_type n = rows ();
           ColumnVector Qinit(n);
           for (octave_idx_type i = 0; i < n; i++)
             Qinit(i) = i;
 
           MatrixType tmp_typ (MatrixType::Upper);
           SparseComplexLU fact (*this, Qinit, Matrix (), false, false);
-          rcond = fact.rcond();
+          rcond = fact.rcond ();
           double rcond2;
-          SparseComplexMatrix InvL = fact.L().transpose().
+          SparseComplexMatrix InvL = fact.L ().transpose ().
             tinverse(tmp_typ, info, rcond2, true, false);
-          SparseComplexMatrix InvU = fact.U().
-            tinverse(tmp_typ, info, rcond2, true, false).transpose();
-          ret = fact.Pc().transpose() * InvU * InvL * fact.Pr();
+          SparseComplexMatrix InvU = fact.U ().
+            tinverse(tmp_typ, info, rcond2, true, false).transpose ();
+          ret = fact.Pc ().transpose () * InvU * InvL * fact.Pr ();
         }
     }
 
@@ -1279,13 +1279,13 @@
       if (typ == MatrixType::Diagonal ||
           typ == MatrixType::Permuted_Diagonal)
         {
-          retval.resize (nc, b.cols(), Complex(0.,0.));
+          retval.resize (nc, b.cols (), Complex(0.,0.));
           if (typ == MatrixType::Diagonal)
-            for (octave_idx_type j = 0; j < b.cols(); j++)
+            for (octave_idx_type j = 0; j < b.cols (); j++)
                 for (octave_idx_type i = 0; i < nm; i++)
                   retval(i,j) = b(i,j) / data (i);
           else
-            for (octave_idx_type j = 0; j < b.cols(); j++)
+            for (octave_idx_type j = 0; j < b.cols (); j++)
               for (octave_idx_type k = 0; k < nc; k++)
                 for (octave_idx_type i = cidx(k); i < cidx(k+1); i++)
                   retval(k,j) = b(ridx(i),j) / data (i);
@@ -1347,7 +1347,7 @@
           retval.xcidx(0) = 0;
           octave_idx_type ii = 0;
           if (typ == MatrixType::Diagonal)
-            for (octave_idx_type j = 0; j < b.cols(); j++)
+            for (octave_idx_type j = 0; j < b.cols (); j++)
               {
                 for (octave_idx_type i = b.cidx(j); i < b.cidx(j+1); i++)
                   {
@@ -1359,7 +1359,7 @@
                 retval.xcidx(j+1) = ii;
               }
           else
-            for (octave_idx_type j = 0; j < b.cols(); j++)
+            for (octave_idx_type j = 0; j < b.cols (); j++)
               {
                 for (octave_idx_type l = 0; l < nc; l++)
                   for (octave_idx_type i = cidx(l); i < cidx(l+1); i++)
@@ -1431,13 +1431,13 @@
       if (typ == MatrixType::Diagonal ||
           typ == MatrixType::Permuted_Diagonal)
         {
-          retval.resize (nc, b.cols(), Complex(0.,0.));
+          retval.resize (nc, b.cols (), Complex(0.,0.));
           if (typ == MatrixType::Diagonal)
-            for (octave_idx_type j = 0; j < b.cols(); j++)
+            for (octave_idx_type j = 0; j < b.cols (); j++)
               for (octave_idx_type i = 0; i < nm; i++)
                 retval(i,j) = b(i,j) / data (i);
           else
-            for (octave_idx_type j = 0; j < b.cols(); j++)
+            for (octave_idx_type j = 0; j < b.cols (); j++)
               for (octave_idx_type k = 0; k < nc; k++)
                 for (octave_idx_type i = cidx(k); i < cidx(k+1); i++)
                   retval(k,j) = b(ridx(i),j) / data (i);
@@ -1499,7 +1499,7 @@
           retval.xcidx(0) = 0;
           octave_idx_type ii = 0;
           if (typ == MatrixType::Diagonal)
-            for (octave_idx_type j = 0; j < b.cols(); j++)
+            for (octave_idx_type j = 0; j < b.cols (); j++)
               {
                 for (octave_idx_type i = b.cidx(j); i < b.cidx(j+1); i++)
                   {
@@ -1511,7 +1511,7 @@
                 retval.xcidx(j+1) = ii;
               }
           else
-            for (octave_idx_type j = 0; j < b.cols(); j++)
+            for (octave_idx_type j = 0; j < b.cols (); j++)
               {
                 for (octave_idx_type l = 0; l < nc; l++)
                   for (octave_idx_type i = cidx(l); i < cidx(l+1); i++)
@@ -1639,7 +1639,7 @@
                     }
 
                   for (octave_idx_type i = 0; i < nc; i++)
-                    retval (perm[i], j) = work[i];
+                    retval(perm[i], j) = work[i];
                 }
 
               if (calc_cond)
@@ -2162,7 +2162,7 @@
                     }
 
                   for (octave_idx_type i = 0; i < nc; i++)
-                    retval (perm[i], j) = work[i];
+                    retval(perm[i], j) = work[i];
                 }
 
               if (calc_cond)
@@ -2695,7 +2695,7 @@
                     }
 
                   for (octave_idx_type i = 0; i < nc; i++)
-                    retval (i, j) = work[i];
+                    retval(i, j) = work[i];
                 }
 
               if (calc_cond)
@@ -3259,7 +3259,7 @@
                     }
 
                   for (octave_idx_type i = 0; i < nc; i++)
-                    retval (i, j) = work[i];
+                    retval(i, j) = work[i];
                 }
 
               if (calc_cond)
@@ -3796,12 +3796,12 @@
                   }
             }
 
-          octave_idx_type b_nc = b.cols();
+          octave_idx_type b_nc = b.cols ();
           retval = ComplexMatrix (b);
           Complex *result = retval.fortran_vec ();
 
           F77_XFCN (zptsv, ZPTSV, (nr, b_nc, D, DL, result,
-                                   b.rows(), err));
+                                   b.rows (), err));
 
           if (err != 0)
             {
@@ -3853,12 +3853,12 @@
                   }
             }
 
-          octave_idx_type b_nc = b.cols();
+          octave_idx_type b_nc = b.cols ();
           retval = ComplexMatrix (b);
           Complex *result = retval.fortran_vec ();
 
           F77_XFCN (zgtsv, ZGTSV, (nr, b_nc, DL, D, DU, result,
-                                   b.rows(), err));
+                                   b.rows (), err));
 
           if (err != 0)
             {
@@ -4095,7 +4095,7 @@
             }
 
           octave_idx_type b_nr = b.rows ();
-          octave_idx_type b_nc = b.cols();
+          octave_idx_type b_nc = b.cols ();
           rcond = 1.;
 
           retval = ComplexMatrix (b);
@@ -4152,8 +4152,8 @@
                   }
             }
 
-          octave_idx_type b_nr = b.rows();
-          octave_idx_type b_nc = b.cols();
+          octave_idx_type b_nr = b.rows ();
+          octave_idx_type b_nc = b.cols ();
           rcond = 1.;
 
           retval = ComplexMatrix (b);
@@ -4393,7 +4393,7 @@
           // Calculate the norm of the matrix, for later use.
           double anorm;
           if (calc_cond)
-            anorm = m_band.abs().sum().row(0).max();
+            anorm = m_band.abs ().sum ().row(0).max ();
 
           char job = 'L';
           F77_XFCN (zpbtrf, ZPBTRF, (F77_CONST_CHAR_ARG2 (&job, 1),
@@ -4457,7 +4457,7 @@
                   F77_XFCN (zpbtrs, ZPBTRS,
                             (F77_CONST_CHAR_ARG2 (&job, 1),
                              nr, n_lower, b_nc, tmp_data,
-                             ldm, result, b.rows(), err
+                             ldm, result, b.rows (), err
                              F77_CHAR_ARG_LEN (1)));
 
                   if (err != 0)
@@ -4579,7 +4579,7 @@
                   F77_XFCN (zgbtrs, ZGBTRS,
                             (F77_CONST_CHAR_ARG2 (&job, 1),
                              nr, n_lower, n_upper, b_nc, tmp_data,
-                             ldm, pipvt, result, b.rows(), err
+                             ldm, pipvt, result, b.rows (), err
                              F77_CHAR_ARG_LEN (1)));
                 }
             }
@@ -4642,7 +4642,7 @@
           // Calculate the norm of the matrix, for later use.
           double anorm;
           if (calc_cond)
-            anorm = m_band.abs().sum().row(0).max();
+            anorm = m_band.abs ().sum ().row(0).max ();
 
           char job = 'L';
           F77_XFCN (zpbtrf, ZPBTRF, (F77_CONST_CHAR_ARG2 (&job, 1),
@@ -4960,7 +4960,7 @@
           // Calculate the norm of the matrix, for later use.
           double anorm;
           if (calc_cond)
-            anorm = m_band.abs().sum().row(0).max();
+            anorm = m_band.abs ().sum ().row(0).max ();
 
           char job = 'L';
           F77_XFCN (zpbtrf, ZPBTRF, (F77_CONST_CHAR_ARG2 (&job, 1),
@@ -5206,7 +5206,7 @@
           // Calculate the norm of the matrix, for later use.
           double anorm;
           if (calc_cond)
-            anorm = m_band.abs().sum().row(0).max();
+            anorm = m_band.abs ().sum ().row(0).max ();
 
           char job = 'L';
           F77_XFCN (zpbtrf, ZPBTRF, (F77_CONST_CHAR_ARG2 (&job, 1),
@@ -5655,9 +5655,9 @@
           A->nrow = nr;
           A->ncol = nc;
 
-          A->p = cidx();
-          A->i = ridx();
-          A->nzmax = nnz();
+          A->p = cidx ();
+          A->i = ridx ();
+          A->nzmax = nnz ();
           A->packed = true;
           A->sorted = true;
           A->nz = 0;
@@ -5673,21 +5673,21 @@
           if (nr < 1)
             A->x = &dummy;
           else
-            A->x = data();
+            A->x = data ();
 
           cholmod_dense Bstore;
           cholmod_dense *B = &Bstore;
-          B->nrow = b.rows();
-          B->ncol = b.cols();
+          B->nrow = b.rows ();
+          B->ncol = b.cols ();
           B->d = B->nrow;
           B->nzmax = B->nrow * B->ncol;
           B->dtype = CHOLMOD_DOUBLE;
           B->xtype = CHOLMOD_REAL;
-          if (nc < 1 || b.cols() < 1)
+          if (nc < 1 || b.cols () < 1)
             B->x = &dummy;
           else
             // We won't alter it, honest :-)
-            B->x = const_cast<double *>(b.fortran_vec());
+            B->x = const_cast<double *>(b.fortran_vec ());
 
           cholmod_factor *L;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
@@ -5731,11 +5731,11 @@
               X = CHOLMOD_NAME(solve) (CHOLMOD_A, L, B, cm);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 
-              retval.resize (b.rows (), b.cols());
-              for (octave_idx_type j = 0; j < b.cols(); j++)
-                {
-                  octave_idx_type jr = j * b.rows();
-                  for (octave_idx_type i = 0; i < b.rows(); i++)
+              retval.resize (b.rows (), b.cols ());
+              for (octave_idx_type j = 0; j < b.cols (); j++)
+                {
+                  octave_idx_type jr = j * b.rows ();
+                  for (octave_idx_type i = 0; i < b.rows (); i++)
                     retval.xelem(i,j) = static_cast<Complex *>(X->x)[jr + i];
                 }
 
@@ -5898,9 +5898,9 @@
           A->nrow = nr;
           A->ncol = nc;
 
-          A->p = cidx();
-          A->i = ridx();
-          A->nzmax = nnz();
+          A->p = cidx ();
+          A->i = ridx ();
+          A->nzmax = nnz ();
           A->packed = true;
           A->sorted = true;
           A->nz = 0;
@@ -5916,15 +5916,15 @@
           if (nr < 1)
             A->x = &dummy;
           else
-            A->x = data();
+            A->x = data ();
 
           cholmod_sparse Bstore;
           cholmod_sparse *B = &Bstore;
-          B->nrow = b.rows();
-          B->ncol = b.cols();
-          B->p = b.cidx();
-          B->i = b.ridx();
-          B->nzmax = b.nnz();
+          B->nrow = b.rows ();
+          B->ncol = b.cols ();
+          B->p = b.cidx ();
+          B->i = b.ridx ();
+          B->nzmax = b.nnz ();
           B->packed = true;
           B->sorted = true;
           B->nz = 0;
@@ -5937,10 +5937,10 @@
           B->stype = 0;
           B->xtype = CHOLMOD_REAL;
 
-          if (b.rows() < 1 || b.cols() < 1)
+          if (b.rows () < 1 || b.cols () < 1)
             B->x = &dummy;
           else
-            B->x = b.data();
+            B->x = b.data ();
 
           cholmod_factor *L;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
@@ -6189,9 +6189,9 @@
           A->nrow = nr;
           A->ncol = nc;
 
-          A->p = cidx();
-          A->i = ridx();
-          A->nzmax = nnz();
+          A->p = cidx ();
+          A->i = ridx ();
+          A->nzmax = nnz ();
           A->packed = true;
           A->sorted = true;
           A->nz = 0;
@@ -6207,21 +6207,21 @@
           if (nr < 1)
             A->x = &dummy;
           else
-            A->x = data();
+            A->x = data ();
 
           cholmod_dense Bstore;
           cholmod_dense *B = &Bstore;
-          B->nrow = b.rows();
-          B->ncol = b.cols();
+          B->nrow = b.rows ();
+          B->ncol = b.cols ();
           B->d = B->nrow;
           B->nzmax = B->nrow * B->ncol;
           B->dtype = CHOLMOD_DOUBLE;
           B->xtype = CHOLMOD_COMPLEX;
-          if (nc < 1 || b.cols() < 1)
+          if (nc < 1 || b.cols () < 1)
             B->x = &dummy;
           else
             // We won't alter it, honest :-)
-            B->x = const_cast<Complex *>(b.fortran_vec());
+            B->x = const_cast<Complex *>(b.fortran_vec ());
 
           cholmod_factor *L;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
@@ -6265,11 +6265,11 @@
               X = CHOLMOD_NAME(solve) (CHOLMOD_A, L, B, cm);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 
-              retval.resize (b.rows (), b.cols());
-              for (octave_idx_type j = 0; j < b.cols(); j++)
-                {
-                  octave_idx_type jr = j * b.rows();
-                  for (octave_idx_type i = 0; i < b.rows(); i++)
+              retval.resize (b.rows (), b.cols ());
+              for (octave_idx_type j = 0; j < b.cols (); j++)
+                {
+                  octave_idx_type jr = j * b.rows ();
+                  for (octave_idx_type i = 0; i < b.rows (); i++)
                     retval.xelem(i,j) = static_cast<Complex *>(X->x)[jr + i];
                 }
 
@@ -6411,9 +6411,9 @@
           A->nrow = nr;
           A->ncol = nc;
 
-          A->p = cidx();
-          A->i = ridx();
-          A->nzmax = nnz();
+          A->p = cidx ();
+          A->i = ridx ();
+          A->nzmax = nnz ();
           A->packed = true;
           A->sorted = true;
           A->nz = 0;
@@ -6429,15 +6429,15 @@
           if (nr < 1)
             A->x = &dummy;
           else
-            A->x = data();
+            A->x = data ();
 
           cholmod_sparse Bstore;
           cholmod_sparse *B = &Bstore;
-          B->nrow = b.rows();
-          B->ncol = b.cols();
-          B->p = b.cidx();
-          B->i = b.ridx();
-          B->nzmax = b.nnz();
+          B->nrow = b.rows ();
+          B->ncol = b.cols ();
+          B->p = b.cidx ();
+          B->i = b.ridx ();
+          B->nzmax = b.nnz ();
           B->packed = true;
           B->sorted = true;
           B->nz = 0;
@@ -6450,10 +6450,10 @@
           B->stype = 0;
           B->xtype = CHOLMOD_COMPLEX;
 
-          if (b.rows() < 1 || b.cols() < 1)
+          if (b.rows () < 1 || b.cols () < 1)
             B->x = &dummy;
           else
-            B->x = b.data();
+            B->x = b.data ();
 
           cholmod_factor *L;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
@@ -7348,8 +7348,8 @@
 SparseComplexMatrix
 SparseComplexMatrix::prod (int dim) const
 {
-  if ((rows() == 1 && dim == -1) || dim == 1)
-    return transpose (). prod (0). transpose();
+  if ((rows () == 1 && dim == -1) || dim == 1)
+    return transpose (). prod (0). transpose ();
   else
     {
       SPARSE_REDUCTION_OP (SparseComplexMatrix, Complex, *=,
@@ -7386,7 +7386,7 @@
   octave_idx_type nz = nnz ();
   octave_idx_type nc = cols ();
 
-  SparseMatrix retval (rows(), nc, nz);
+  SparseMatrix retval (rows (), nc, nz);
 
   for (octave_idx_type i = 0; i < nc + 1; i++)
     retval.cidx (i) = cidx (i);
@@ -7665,7 +7665,7 @@
 {
   SparseComplexMatrix r;
 
-  if ((a.rows() == b.rows()) && (a.cols() == b.cols()))
+  if ((a.rows () == b.rows ()) && (a.cols () == b.cols ()))
     {
       octave_idx_type a_nr = a.rows ();
       octave_idx_type a_nc = a.cols ();
@@ -7785,7 +7785,7 @@
 {
   SparseComplexMatrix r;
 
-  if ((a.rows() == b.rows()) && (a.cols() == b.cols()))
+  if ((a.rows () == b.rows ()) && (a.cols () == b.cols ()))
     {
       octave_idx_type a_nr = a.rows ();
       octave_idx_type a_nc = a.cols ();
--- a/liboctave/CmplxGEPBAL.cc
+++ b/liboctave/CmplxGEPBAL.cc
@@ -70,7 +70,7 @@
       return -1;
     }
 
-  if (a.dims() != b.dims ())
+  if (a.dims () != b.dims ())
     {
       gripe_nonconformant ("ComplexGEPBALANCE", n, n, b.rows(), b.cols());
       return -1;
--- a/liboctave/DiagArray2.h
+++ b/liboctave/DiagArray2.h
@@ -127,7 +127,7 @@
   T operator () (octave_idx_type r, octave_idx_type c) const
     {
 #if defined (BOUNDS_CHECKING)
-      checkelem (r, c);
+      return checkelem (r, c);
 #else
       return elem (r, c);
 #endif
@@ -161,8 +161,11 @@
   T dgxelem (octave_idx_type i) const
     { return Array<T>::xelem (i); }
 
-  void resize (octave_idx_type n, octave_idx_type m,
-               const T& rfv = Array<T>::resize_fill_value ());
+  void resize (octave_idx_type n, octave_idx_type m, const T& rfv);
+  void resize (octave_idx_type n, octave_idx_type m)
+  {
+    resize (n, m, Array<T>::resize_fill_value ());
+  }
 
   DiagArray2<T> transpose (void) const;
   DiagArray2<T> hermitian (T (*fcn) (const T&) = 0) const;
--- a/liboctave/EIG.cc
+++ b/liboctave/EIG.cc
@@ -691,7 +691,7 @@
   octave_idx_type n = a.rows ();
   octave_idx_type nb = b.rows ();
 
-  if (n != a.cols () || nb != b.cols())
+  if (n != a.cols () || nb != b.cols ())
     {
       (*current_liboctave_error_handler) ("EIG requires square matrix");
       return -1;
--- a/liboctave/MSparse.cc
+++ b/liboctave/MSparse.cc
@@ -417,7 +417,7 @@
       else
         {
           r = MSparse<T> (b);
-          octave_idx_type b_nnz = b.nnz();
+          octave_idx_type b_nnz = b.nnz ();
 
           for (octave_idx_type i = 0 ; i < b_nnz ; i++)
             {
@@ -434,7 +434,7 @@
       else
         {
           r = MSparse<T> (a);
-          octave_idx_type a_nnz = a.nnz();
+          octave_idx_type a_nnz = a.nnz ();
 
           for (octave_idx_type i = 0 ; i < a_nnz ; i++)
             {
@@ -512,10 +512,10 @@
   if (a_nr == 1 && a_nc == 1)
     {
       T val = a.elem (0,0);
-      T fill = val / T();
-      if (fill == T())
+      T fill = val / T ();
+      if (fill == T ())
         {
-          octave_idx_type b_nnz = b.nnz();
+          octave_idx_type b_nnz = b.nnz ();
           r = MSparse<T> (b);
           for (octave_idx_type i = 0 ; i < b_nnz ; i++)
             r.data (i) = val / r.data(i);
@@ -540,10 +540,10 @@
   else if (b_nr == 1 && b_nc == 1)
     {
       T val = b.elem (0,0);
-      T fill = T() / val;
-      if (fill == T())
+      T fill = T () / val;
+      if (fill == T ())
         {
-          octave_idx_type a_nnz = a.nnz();
+          octave_idx_type a_nnz = a.nnz ();
           r = MSparse<T> (a);
           for (octave_idx_type i = 0 ; i < a_nnz ; i++)
             r.data (i) = r.data(i) / val;
--- a/liboctave/Makefile.am
+++ b/liboctave/Makefile.am
@@ -522,9 +522,9 @@
 
 # Increment these as needed and according to the rules in the libtool
 # manual:
-liboctave_current = 2
-liboctave_revision = 0
-liboctave_age = 1
+liboctave_current = 1
+liboctave_revision = 1
+liboctave_age = 0
 
 liboctave_version_info = $(liboctave_current):$(liboctave_revision):$(liboctave_age)
 
--- a/liboctave/MatrixType.cc
+++ b/liboctave/MatrixType.cc
@@ -40,7 +40,7 @@
 
 MatrixType::MatrixType (void)
   : typ (MatrixType::Unknown),
-    sp_bandden (octave_sparse_params::get_bandden()),
+    sp_bandden (octave_sparse_params::get_bandden ()),
     bandden (0), upper_band (0),
     lower_band (0), dense (false), full (false), nperm (0), perm (0) { }
 
@@ -140,8 +140,8 @@
           std::complex<T> d = a.elem (j,j);
           upper = upper && (d != zero);
           lower = lower && (d != zero);
-          hermitian = hermitian && (d.real() > zero && d.imag() == zero);
-          diag[j] = d.real();
+          hermitian = hermitian && (d.real () > zero && d.imag () == zero);
+          diag[j] = d.real ();
         }
 
       for (octave_idx_type j = 0;
@@ -220,7 +220,7 @@
     (*current_liboctave_warning_handler)
       ("Calculating Sparse Matrix Type");
 
-  sp_bandden = octave_sparse_params::get_bandden();
+  sp_bandden = octave_sparse_params::get_bandden ();
   bool maybe_hermitian = false;
   typ = MatrixType::Full;
 
@@ -541,7 +541,7 @@
     (*current_liboctave_warning_handler)
       ("Calculating Sparse Matrix Type");
 
-  sp_bandden = octave_sparse_params::get_bandden();
+  sp_bandden = octave_sparse_params::get_bandden ();
   bool maybe_hermitian = false;
   typ = MatrixType::Full;
 
@@ -804,8 +804,8 @@
                   if (a.ridx(i) == j)
                     {
                       Complex d = a.data(i);
-                      is_herm = d.real() > 0. && d.imag() == 0.;
-                      diag(j) = d.real();
+                      is_herm = d.real () > 0. && d.imag () == 0.;
+                      diag(j) = d.real ();
                       break;
                     }
                 }
@@ -850,7 +850,7 @@
 }
 MatrixType::MatrixType (const matrix_type t, bool _full)
   : typ (MatrixType::Unknown),
-    sp_bandden (octave_sparse_params::get_bandden()),
+    sp_bandden (octave_sparse_params::get_bandden ()),
     bandden (0), upper_band (0), lower_band (0),
     dense (false), full (_full), nperm (0), perm (0)
 {
@@ -867,7 +867,7 @@
 MatrixType::MatrixType (const matrix_type t, const octave_idx_type np,
                         const octave_idx_type *p, bool _full)
   : typ (MatrixType::Unknown),
-    sp_bandden (octave_sparse_params::get_bandden()),
+    sp_bandden (octave_sparse_params::get_bandden ()),
     bandden (0), upper_band (0), lower_band (0),
     dense (false), full (_full), nperm (0), perm (0)
 {
@@ -887,7 +887,7 @@
 MatrixType::MatrixType (const matrix_type t, const octave_idx_type ku,
                         const octave_idx_type kl, bool _full)
   : typ (MatrixType::Unknown),
-    sp_bandden (octave_sparse_params::get_bandden()),
+    sp_bandden (octave_sparse_params::get_bandden ()),
     bandden (0), upper_band (0), lower_band (0),
     dense (false), full (_full), nperm (0), perm (0)
 {
@@ -944,7 +944,7 @@
 MatrixType::type (bool quiet)
 {
   if (typ != MatrixType::Unknown && (full ||
-      sp_bandden == octave_sparse_params::get_bandden()))
+      sp_bandden == octave_sparse_params::get_bandden ()))
     {
       if (!quiet &&
           octave_sparse_params::get_key ("spumoni") != 0.)
@@ -968,7 +968,7 @@
 MatrixType::type (const SparseMatrix &a)
 {
   if (typ != MatrixType::Unknown && (full ||
-      sp_bandden == octave_sparse_params::get_bandden()))
+      sp_bandden == octave_sparse_params::get_bandden ()))
     {
       if (octave_sparse_params::get_key ("spumoni") != 0.)
         (*current_liboctave_warning_handler)
@@ -1001,7 +1001,7 @@
 MatrixType::type (const SparseComplexMatrix &a)
 {
   if (typ != MatrixType::Unknown && (full ||
-      sp_bandden == octave_sparse_params::get_bandden()))
+      sp_bandden == octave_sparse_params::get_bandden ()))
     {
       if (octave_sparse_params::get_key ("spumoni") != 0.)
         (*current_liboctave_warning_handler)
--- a/liboctave/Sparse-op-defs.h
+++ b/liboctave/Sparse-op-defs.h
@@ -519,7 +519,7 @@
         else \
           { \
             r = R (m2); \
-            octave_idx_type m2_nnz = m2.nnz(); \
+            octave_idx_type m2_nnz = m2.nnz (); \
             \
             for (octave_idx_type i = 0 ; i < m2_nnz ; i++) \
               { \
@@ -536,7 +536,7 @@
         else \
           { \
             r = R (m1); \
-            octave_idx_type m1_nnz = m1.nnz(); \
+            octave_idx_type m1_nnz = m1.nnz (); \
             \
             for (octave_idx_type i = 0 ; i < m1_nnz ; i++) \
               { \
@@ -612,9 +612,9 @@
  \
     if (m1_nr == 1 && m1_nc == 1) \
       { \
-        if ((m1.elem (0,0) OP Complex()) == Complex()) \
+        if ((m1.elem (0,0) OP Complex ()) == Complex ()) \
           { \
-            octave_idx_type m2_nnz = m2.nnz(); \
+            octave_idx_type m2_nnz = m2.nnz (); \
             r = R (m2); \
             for (octave_idx_type i = 0 ; i < m2_nnz ; i++) \
               r.data (i) = m1.elem(0,0) OP r.data(i); \
@@ -638,9 +638,9 @@
       } \
     else if (m2_nr == 1 && m2_nc == 1) \
       { \
-        if ((Complex() OP m1.elem (0,0)) == Complex()) \
+        if ((Complex () OP m1.elem (0,0)) == Complex ()) \
           { \
-            octave_idx_type m1_nnz = m1.nnz(); \
+            octave_idx_type m1_nnz = m1.nnz (); \
             r = R (m1); \
             for (octave_idx_type i = 0 ; i < m1_nnz ; i++) \
               r.data (i) = r.data(i) OP m2.elem(0,0); \
@@ -648,7 +648,7 @@
           } \
         else \
           { \
-            r = R (m1_nr, m1_nc, Complex() OP m2.elem(0,0)); \
+            r = R (m1_nr, m1_nc, Complex () OP m2.elem(0,0)); \
             for (octave_idx_type j = 0 ; j < m1_nc ; j++) \
               { \
                 octave_quit (); \
@@ -1830,8 +1830,8 @@
                         INIT_VAL, MT_RESULT)
 
 #define SPARSE_ALL_OP(DIM) \
-  if ((rows() == 1 && dim == -1) || dim == 1) \
-    return transpose (). all (0). transpose(); \
+  if ((rows () == 1 && dim == -1) || dim == 1) \
+    return transpose (). all (0). transpose (); \
   else \
     { \
       SPARSE_ANY_ALL_OP (DIM, (cidx(j+1) - cidx(j) < nr ? false : true), \
@@ -1850,7 +1850,7 @@
   if (nr == 1 && nc == 1) \
    { \
      RET_EL_TYPE s = m.elem(0,0); \
-     octave_idx_type nz = a.nnz(); \
+     octave_idx_type nz = a.nnz (); \
      RET_TYPE r (a_nr, a_nc, nz); \
      \
      for (octave_idx_type i = 0; i < nz; i++) \
@@ -1871,7 +1871,7 @@
   else if (a_nr == 1 && a_nc == 1) \
    { \
      RET_EL_TYPE s = a.elem(0,0); \
-     octave_idx_type nz = m.nnz(); \
+     octave_idx_type nz = m.nnz (); \
      RET_TYPE r (nr, nc, nz); \
      \
      for (octave_idx_type i = 0; i < nz; i++) \
@@ -1946,7 +1946,7 @@
           octave_idx_type n_per_col = (a_nc > 43000 ? 43000 : \
                                         (a_nc * a_nc) / 43000); \
           octave_idx_type ii = 0; \
-          octave_idx_type *ri = retval.xridx(); \
+          octave_idx_type *ri = retval.xridx (); \
           octave_sort<octave_idx_type> sort; \
           \
           for (octave_idx_type i = 0; i < a_nc ; i++) \
--- a/liboctave/Sparse-perm-op-defs.h
+++ b/liboctave/Sparse-perm-op-defs.h
@@ -49,7 +49,7 @@
           sidx[ii++]=i;
           r.xridx (i) = pcol[a.ridx (i)];
         }
-      sort.sort (r.xridx() + r.xcidx(j), sidx, r.xcidx(j+1) - r.xcidx(j));
+      sort.sort (r.xridx () + r.xcidx(j), sidx, r.xcidx(j+1) - r.xcidx(j));
       for (octave_idx_type i = r.xcidx(j), ii = 0; i < r.xcidx(j+1); i++)
         r.xdata(i) = a.data (sidx[ii++]);
     }
--- a/liboctave/Sparse.cc
+++ b/liboctave/Sparse.cc
@@ -55,7 +55,7 @@
 template <class T>
 Sparse<T>::Sparse (const PermMatrix& a)
   : rep (new typename Sparse<T>::SparseRep (a.rows (), a.cols (), a.rows ())),
-         dimensions (dim_vector (a.rows (), a.cols()))
+         dimensions (dim_vector (a.rows (), a.cols ()))
 {
   octave_idx_type n = a.rows ();
   for (octave_idx_type i = 0; i <= n; i++)
@@ -149,7 +149,7 @@
         {
           octave_idx_type u = c[j];
           for (i = i; i < u; i++)
-            if (d[i] != T())
+            if (d[i] != T ())
               {
                 d[k] = d[i];
                 r[k++] = r[i];
@@ -231,11 +231,11 @@
 Sparse<T>::Sparse (const dim_vector& dv)
   : rep (0), dimensions (dv)
 {
-  if (dv.length() != 2)
+  if (dv.length () != 2)
     (*current_liboctave_error_handler)
       ("Sparse::Sparse (const dim_vector&): dimension mismatch");
   else
-    rep = new typename Sparse<T>::SparseRep (dv(0), dv(1));
+    rep = new typename Sparse<T>::SparseRep (dv(0), dv(1), 0);
 }
 
 template <class T>
@@ -254,7 +254,7 @@
       ("Sparse::Sparse (const Sparse&, const dim_vector&): dimension mismatch");
   else
     {
-      dim_vector old_dims = a.dims();
+      dim_vector old_dims = a.dims ();
       octave_idx_type new_nzmx = a.nnz ();
       octave_idx_type new_nr = dv (0);
       octave_idx_type new_nc = dv (1);
@@ -301,11 +301,10 @@
     (*current_liboctave_error_handler)
       ("sparse: column index %d out of bound %d", r.extent (nc), nc);
 
-  rep = new SparseRep (nr, nc);
+  rep = new typename Sparse<T>::SparseRep (nr, nc, (nzm > 0 ? nzm : 0));
 
   dimensions = dim_vector (nr, nc);
 
-
   octave_idx_type n = a.numel (), rl = r.length (nr), cl = c.length (nc);
   bool a_scalar = n == 1;
   if (a_scalar)
@@ -324,6 +323,7 @@
       if (n == 1 && a(0) != T ())
         {
           change_capacity (nzm > 1 ? nzm : 1);
+          xcidx(0) = 0;
           xridx(0) = r(0);
           xdata(0) = a(0);
           for (octave_idx_type j = 0; j < nc; j++)
@@ -334,7 +334,7 @@
     {
       // This is completely specialized, because the sorts can be simplified.
       T a0 = a(0);
-      if (a0 == T())
+      if (a0 == T ())
         {
           // Do nothing, it's an empty matrix.
         }
@@ -352,6 +352,7 @@
             new_nz += rd[i-1] != rd[i];
           // Allocate result.
           change_capacity (nzm > new_nz ? nzm : new_nz);
+          xcidx (0) = 0;
           xcidx (1) = new_nz;
           octave_idx_type *rri = ridx ();
           T *rrd = data ();
@@ -494,6 +495,7 @@
         new_nz += rd[i-1] != rd[i];
       // Allocate result.
       change_capacity (nzm > new_nz ? nzm : new_nz);
+      xcidx(0) = 0;
       xcidx(1) = new_nz;
       octave_idx_type *rri = ridx ();
       T *rrd = data ();
@@ -813,7 +815,7 @@
       (*current_liboctave_warning_handler)
         ("reshape: sparse reshape to N-d array smashes dims");
 
-      for (octave_idx_type i = 2; i < dims2.length(); i++)
+      for (octave_idx_type i = 2; i < dims2.length (); i++)
         dims2(1) *= dims2(i);
 
       dims2.resize (2);
@@ -1238,16 +1240,31 @@
         gripe_del_index_out_of_range (false, idx_j.extent (nc), nc);
       else if (idx_j.is_cont_range (nc, lb, ub))
         {
-          const Sparse<T> tmp = *this;
-          octave_idx_type lbi = tmp.cidx(lb), ubi = tmp.cidx(ub), new_nz = nz - (ubi - lbi);
-          *this = Sparse<T> (nr, nc - (ub - lb), new_nz);
-          copy_or_memcpy (lbi, tmp.data (), data ());
-          copy_or_memcpy (lbi, tmp.ridx (), ridx ());
-          copy_or_memcpy (nz - ubi, tmp.data () + ubi, xdata () + lbi);
-          copy_or_memcpy (nz - ubi, tmp.ridx () + ubi, xridx () + lbi);
-          copy_or_memcpy (lb, tmp.cidx () + 1, cidx () + 1);
-          mx_inline_sub (nc - ub, xcidx () + lb + 1,
-                         tmp.cidx () + ub + 1, ubi - lbi);
+          if (lb == 0 && ub == nc)
+            {
+              // Delete all rows and columns.
+              *this = Sparse<T> (nr, 0);
+            }
+          else if (nz == 0)
+            {
+              // No elements to preserve; adjust dimensions.
+              *this = Sparse<T> (nr, nc - (ub - lb));
+            }
+          else
+            {
+              const Sparse<T> tmp = *this;
+              octave_idx_type lbi = tmp.cidx(lb), ubi = tmp.cidx(ub),
+                new_nz = nz - (ubi - lbi);
+
+              *this = Sparse<T> (nr, nc - (ub - lb), new_nz);
+              copy_or_memcpy (lbi, tmp.data (), data ());
+              copy_or_memcpy (lbi, tmp.ridx (), ridx ());
+              copy_or_memcpy (nz - ubi, tmp.data () + ubi, xdata () + lbi);
+              copy_or_memcpy (nz - ubi, tmp.ridx () + ubi, xridx () + lbi);
+              copy_or_memcpy (lb, tmp.cidx () + 1, cidx () + 1);
+              mx_inline_sub (nc - ub, xcidx () + lb + 1,
+                             tmp.cidx () + ub + 1, ubi - lbi);
+            }
         }
       else
         *this = index (idx_i, idx_j.complement (nc));
@@ -1260,24 +1277,40 @@
         gripe_del_index_out_of_range (false, idx_i.extent (nr), nr);
       else if (idx_i.is_cont_range (nr, lb, ub))
         {
-          // This is more memory-efficient than the approach below.
-          const Sparse<T> tmpl = index (idx_vector (0, lb), idx_j);
-          const Sparse<T> tmpu = index (idx_vector (ub, nr), idx_j);
-          *this = Sparse<T> (nr - (ub - lb), nc, tmpl.nnz () + tmpu.nnz ());
-          for (octave_idx_type j = 0, k = 0; j < nc; j++)
+          if (lb == 0 && ub == nr)
+            {
+              // Delete all rows and columns.
+              *this = Sparse<T> (0, nc);
+            }
+          else if (nz == 0)
             {
-              for (octave_idx_type i = tmpl.cidx(j); i < tmpl.cidx(j+1); i++)
+              // No elements to preserve; adjust dimensions.
+              *this = Sparse<T> (nr - (ub - lb), nc);
+            }
+          else
+            {
+              // This is more memory-efficient than the approach below.
+              const Sparse<T> tmpl = index (idx_vector (0, lb), idx_j);
+              const Sparse<T> tmpu = index (idx_vector (ub, nr), idx_j);
+              *this = Sparse<T> (nr - (ub - lb), nc,
+                                 tmpl.nnz () + tmpu.nnz ());
+              for (octave_idx_type j = 0, k = 0; j < nc; j++)
                 {
-                  xdata(k) = tmpl.data(i);
-                  xridx(k++) = tmpl.ridx(i);
+                  for (octave_idx_type i = tmpl.cidx(j); i < tmpl.cidx(j+1);
+                       i++)
+                    {
+                      xdata(k) = tmpl.data(i);
+                      xridx(k++) = tmpl.ridx(i);
+                    }
+                  for (octave_idx_type i = tmpu.cidx(j); i < tmpu.cidx(j+1);
+                       i++)
+                    {
+                      xdata(k) = tmpu.data(i);
+                      xridx(k++) = tmpu.ridx(i) + lb;
+                    }
+
+                  xcidx(j+1) = k;
                 }
-              for (octave_idx_type i = tmpu.cidx(j); i < tmpu.cidx(j+1); i++)
-                {
-                  xdata(k) = tmpu.data(i);
-                  xridx(k++) = tmpu.ridx(i) + lb;
-                }
-
-              xcidx(j+1) = k;
             }
         }
       else
@@ -1585,7 +1618,7 @@
 
       // If nr == 1 then the vector indexing will return a column vector!!
       if (nr == 1)
-        retval.transpose();
+        retval.transpose ();
     }
   else if (idx_i.is_scalar ())
     {
@@ -1833,7 +1866,7 @@
                   octave_idx_type iidx = idx(i);
                   octave_idx_type li = lblookup (ri, nz, iidx);
                   if (li != nz && ri[li] == iidx)
-                    xdata(li) = T();
+                    xdata(li) = T ();
                 }
 
               maybe_compress (true);
@@ -2556,7 +2589,7 @@
 Array<T>
 Sparse<T>::array_value () const
 {
-  NoAlias< Array<T> > retval (dims (), T());
+  NoAlias< Array<T> > retval (dims (), T ());
   if (rows () == 1)
     {
       octave_idx_type i = 0;
@@ -2570,7 +2603,7 @@
     {
       for (octave_idx_type j = 0, nc = cols (); j < nc; j++)
         for (octave_idx_type i = cidx(j), iu = cidx(j+1); i < iu; i++)
-          retval (ridx(i), j) = data (i);
+          retval(ridx(i), j) = data (i);
     }
 
   return retval;
@@ -2580,7 +2613,7 @@
  * Tests
  *
 
-%!function x = set_slice(x, dim, slice, arg)
+%!function x = set_slice (x, dim, slice, arg)
 %!  switch dim
 %!    case 11
 %!      x(slice) = 2;
@@ -2589,151 +2622,151 @@
 %!    case 22
 %!      x(:, slice) = 2;
 %!    otherwise
-%!      error("invalid dim, '%d'", dim);
+%!      error ("invalid dim, '%d'", dim);
 %!  endswitch
-%! endfunction
+%!endfunction
 
-%!function x = set_slice2(x, dim, slice)
+%!function x = set_slice2 (x, dim, slice)
 %!  switch dim
 %!    case 11
-%!      x(slice) = 2 * ones (size(slice));
+%!      x(slice) = 2 * ones (size (slice));
 %!    case 21
-%!      x(slice, :) = 2 * ones (length(slice), columns (x));
+%!      x(slice, :) = 2 * ones (length (slice), columns (x));
 %!    case 22
-%!      x(:, slice) = 2 * ones (rows (x), length(slice));
+%!      x(:, slice) = 2 * ones (rows (x), length (slice));
 %!    otherwise
-%!      error("invalid dim, '%d'", dim);
+%!      error ("invalid dim, '%d'", dim);
 %!  endswitch
-%! endfunction
+%!endfunction
 
-%!function test_sparse_slice(size, dim, slice)
-%!  x = ones(size);
-%!  s = set_slice(sparse(x), dim, slice);
-%!  f = set_slice(x, dim, slice);
+%!function test_sparse_slice (size, dim, slice)
+%!  x = ones (size);
+%!  s = set_slice (sparse (x), dim, slice);
+%!  f = set_slice (x, dim, slice);
 %!  assert (nnz(s), nnz(f));
-%!  assert(full(s), f);
-%!  s = set_slice2(sparse(x), dim, slice);
-%!  f = set_slice2(x, dim, slice);
+%!  assert (full(s), f);
+%!  s = set_slice2 (sparse(x), dim, slice);
+%!  f = set_slice2 (x, dim, slice);
 %!  assert (nnz(s), nnz(f));
-%!  assert(full(s), f);
-%! endfunction
+%!  assert (full(s), f);
+%!endfunction
 
 #### 1d indexing
 
 ## size = [2 0]
-%!test test_sparse_slice([2 0], 11, []);
-%!assert(set_slice(sparse(ones([2 0])), 11, 1), sparse([2 0]'));  # sparse different from full
-%!assert(set_slice(sparse(ones([2 0])), 11, 2), sparse([0 2]'));  # sparse different from full
-%!assert(set_slice(sparse(ones([2 0])), 11, 3), sparse([0 0; 2 0]'));  # sparse different from full
-%!assert(set_slice(sparse(ones([2 0])), 11, 4), sparse([0 0; 0 2]'));  # sparse different from full
+%!test test_sparse_slice ([2 0], 11, []);
+%!assert (set_slice (sparse (ones ([2 0])), 11, 1), sparse ([2 0]'))  # sparse different from full
+%!assert (set_slice (sparse (ones ([2 0])), 11, 2), sparse ([0 2]'))  # sparse different from full
+%!assert (set_slice (sparse (ones ([2 0])), 11, 3), sparse ([0 0; 2 0]'))  # sparse different from full
+%!assert (set_slice (sparse (ones ([2 0])), 11, 4), sparse ([0 0; 0 2]'))  # sparse different from full
 
 ## size = [0 2]
-%!test test_sparse_slice([0 2], 11, []);
-%!assert(set_slice(sparse(ones([0 2])), 11, 1), sparse([2 0]));  # sparse different from full
-%!test test_sparse_slice([0 2], 11, 2);
-%!test test_sparse_slice([0 2], 11, 3);
-%!test test_sparse_slice([0 2], 11, 4);
-%!test test_sparse_slice([0 2], 11, [4, 4]);
+%!test test_sparse_slice ([0 2], 11, []);
+%!assert (set_slice (sparse (ones ([0 2])), 11, 1), sparse ([2 0]))  # sparse different from full
+%!test test_sparse_slice ([0 2], 11, 2);
+%!test test_sparse_slice ([0 2], 11, 3);
+%!test test_sparse_slice ([0 2], 11, 4);
+%!test test_sparse_slice ([0 2], 11, [4, 4]);
 
 ## size = [2 1]
-%!test test_sparse_slice([2 1], 11, []);
-%!test test_sparse_slice([2 1], 11, 1);
-%!test test_sparse_slice([2 1], 11, 2);
-%!test test_sparse_slice([2 1], 11, 3);
-%!test test_sparse_slice([2 1], 11, 4);
-%!test test_sparse_slice([2 1], 11, [4, 4]);
+%!test test_sparse_slice ([2 1], 11, []);
+%!test test_sparse_slice ([2 1], 11, 1);
+%!test test_sparse_slice ([2 1], 11, 2);
+%!test test_sparse_slice ([2 1], 11, 3);
+%!test test_sparse_slice ([2 1], 11, 4);
+%!test test_sparse_slice ([2 1], 11, [4, 4]);
 
 ## size = [1 2]
-%!test test_sparse_slice([1 2], 11, []);
-%!test test_sparse_slice([1 2], 11, 1);
-%!test test_sparse_slice([1 2], 11, 2);
-%!test test_sparse_slice([1 2], 11, 3);
-%!test test_sparse_slice([1 2], 11, 4);
-%!test test_sparse_slice([1 2], 11, [4, 4]);
+%!test test_sparse_slice ([1 2], 11, []);
+%!test test_sparse_slice ([1 2], 11, 1);
+%!test test_sparse_slice ([1 2], 11, 2);
+%!test test_sparse_slice ([1 2], 11, 3);
+%!test test_sparse_slice ([1 2], 11, 4);
+%!test test_sparse_slice ([1 2], 11, [4, 4]);
 
 ## size = [2 2]
-%!test test_sparse_slice([2 2], 11, []);
-%!test test_sparse_slice([2 2], 11, 1);
-%!test test_sparse_slice([2 2], 11, 2);
-%!test test_sparse_slice([2 2], 11, 3);
-%!test test_sparse_slice([2 2], 11, 4);
-%!test test_sparse_slice([2 2], 11, [4, 4]);
+%!test test_sparse_slice ([2 2], 11, []);
+%!test test_sparse_slice ([2 2], 11, 1);
+%!test test_sparse_slice ([2 2], 11, 2);
+%!test test_sparse_slice ([2 2], 11, 3);
+%!test test_sparse_slice ([2 2], 11, 4);
+%!test test_sparse_slice ([2 2], 11, [4, 4]);
 # These 2 errors are the same as in the full case
-%!error id=Octave:invalid-resize set_slice(sparse(ones([2 2])), 11, 5);
-%!error id=Octave:invalid-resize set_slice(sparse(ones([2 2])), 11, 6);
+%!error id=Octave:invalid-resize set_slice (sparse (ones ([2 2])), 11, 5)
+%!error id=Octave:invalid-resize set_slice (sparse (ones ([2 2])), 11, 6)
 
 
 #### 2d indexing
 
 ## size = [2 0]
-%!test test_sparse_slice([2 0], 21, []);
-%!test test_sparse_slice([2 0], 21, 1);
-%!test test_sparse_slice([2 0], 21, 2);
-%!test test_sparse_slice([2 0], 21, [2,2]);
-%!assert(set_slice(sparse(ones([2 0])), 21, 3), sparse(3,0));
-%!assert(set_slice(sparse(ones([2 0])), 21, 4), sparse(4,0));
-%!test test_sparse_slice([2 0], 22, []);
-%!test test_sparse_slice([2 0], 22, 1);
-%!test test_sparse_slice([2 0], 22, 2);
-%!test test_sparse_slice([2 0], 22, [2,2]);
-%!assert(set_slice(sparse(ones([2 0])), 22, 3), sparse([0 0 2;0 0 2]));  # sparse different from full
-%!assert(set_slice(sparse(ones([2 0])), 22, 4), sparse([0 0 0 2;0 0 0 2]));  # sparse different from full
+%!test test_sparse_slice ([2 0], 21, []);
+%!test test_sparse_slice ([2 0], 21, 1);
+%!test test_sparse_slice ([2 0], 21, 2);
+%!test test_sparse_slice ([2 0], 21, [2,2]);
+%!assert (set_slice (sparse (ones ([2 0])), 21, 3), sparse (3,0))
+%!assert (set_slice (sparse (ones ([2 0])), 21, 4), sparse (4,0))
+%!test test_sparse_slice ([2 0], 22, []);
+%!test test_sparse_slice ([2 0], 22, 1);
+%!test test_sparse_slice ([2 0], 22, 2);
+%!test test_sparse_slice ([2 0], 22, [2,2]);
+%!assert (set_slice (sparse (ones ([2 0])), 22, 3), sparse ([0 0 2;0 0 2]))  # sparse different from full
+%!assert (set_slice (sparse (ones ([2 0])), 22, 4), sparse ([0 0 0 2;0 0 0 2]))  # sparse different from full
 
 ## size = [0 2]
-%!test test_sparse_slice([0 2], 21, []);
-%!test test_sparse_slice([0 2], 21, 1);
-%!test test_sparse_slice([0 2], 21, 2);
-%!test test_sparse_slice([0 2], 21, [2,2]);
-%!assert(set_slice(sparse(ones([0 2])), 21, 3), sparse([0 0;0 0;2 2]));  # sparse different from full
-%!assert(set_slice(sparse(ones([0 2])), 21, 4), sparse([0 0;0 0;0 0;2 2]));  # sparse different from full
-%!test test_sparse_slice([0 2], 22, []);
-%!test test_sparse_slice([0 2], 22, 1);
-%!test test_sparse_slice([0 2], 22, 2);
-%!test test_sparse_slice([0 2], 22, [2,2]);
-%!assert(set_slice(sparse(ones([0 2])), 22, 3), sparse(0,3));
-%!assert(set_slice(sparse(ones([0 2])), 22, 4), sparse(0,4));
+%!test test_sparse_slice ([0 2], 21, []);
+%!test test_sparse_slice ([0 2], 21, 1);
+%!test test_sparse_slice ([0 2], 21, 2);
+%!test test_sparse_slice ([0 2], 21, [2,2]);
+%!assert (set_slice (sparse (ones ([0 2])), 21, 3), sparse ([0 0;0 0;2 2]))  # sparse different from full
+%!assert (set_slice (sparse (ones ([0 2])), 21, 4), sparse ([0 0;0 0;0 0;2 2]))  # sparse different from full
+%!test test_sparse_slice ([0 2], 22, []);
+%!test test_sparse_slice ([0 2], 22, 1);
+%!test test_sparse_slice ([0 2], 22, 2);
+%!test test_sparse_slice ([0 2], 22, [2,2]);
+%!assert (set_slice (sparse (ones ([0 2])), 22, 3), sparse (0,3))
+%!assert (set_slice (sparse (ones ([0 2])), 22, 4), sparse (0,4))
 
 ## size = [2 1]
-%!test test_sparse_slice([2 1], 21, []);
-%!test test_sparse_slice([2 1], 21, 1);
-%!test test_sparse_slice([2 1], 21, 2);
-%!test test_sparse_slice([2 1], 21, [2,2]);
-%!test test_sparse_slice([2 1], 21, 3);
-%!test test_sparse_slice([2 1], 21, 4);
-%!test test_sparse_slice([2 1], 22, []);
-%!test test_sparse_slice([2 1], 22, 1);
-%!test test_sparse_slice([2 1], 22, 2);
-%!test test_sparse_slice([2 1], 22, [2,2]);
-%!test test_sparse_slice([2 1], 22, 3);
-%!test test_sparse_slice([2 1], 22, 4);
+%!test test_sparse_slice ([2 1], 21, []);
+%!test test_sparse_slice ([2 1], 21, 1);
+%!test test_sparse_slice ([2 1], 21, 2);
+%!test test_sparse_slice ([2 1], 21, [2,2]);
+%!test test_sparse_slice ([2 1], 21, 3);
+%!test test_sparse_slice ([2 1], 21, 4);
+%!test test_sparse_slice ([2 1], 22, []);
+%!test test_sparse_slice ([2 1], 22, 1);
+%!test test_sparse_slice ([2 1], 22, 2);
+%!test test_sparse_slice ([2 1], 22, [2,2]);
+%!test test_sparse_slice ([2 1], 22, 3);
+%!test test_sparse_slice ([2 1], 22, 4);
 
 ## size = [1 2]
-%!test test_sparse_slice([1 2], 21, []);
-%!test test_sparse_slice([1 2], 21, 1);
-%!test test_sparse_slice([1 2], 21, 2);
-%!test test_sparse_slice([1 2], 21, [2,2]);
-%!test test_sparse_slice([1 2], 21, 3);
-%!test test_sparse_slice([1 2], 21, 4);
-%!test test_sparse_slice([1 2], 22, []);
-%!test test_sparse_slice([1 2], 22, 1);
-%!test test_sparse_slice([1 2], 22, 2);
-%!test test_sparse_slice([1 2], 22, [2,2]);
-%!test test_sparse_slice([1 2], 22, 3);
-%!test test_sparse_slice([1 2], 22, 4);
+%!test test_sparse_slice ([1 2], 21, []);
+%!test test_sparse_slice ([1 2], 21, 1);
+%!test test_sparse_slice ([1 2], 21, 2);
+%!test test_sparse_slice ([1 2], 21, [2,2]);
+%!test test_sparse_slice ([1 2], 21, 3);
+%!test test_sparse_slice ([1 2], 21, 4);
+%!test test_sparse_slice ([1 2], 22, []);
+%!test test_sparse_slice ([1 2], 22, 1);
+%!test test_sparse_slice ([1 2], 22, 2);
+%!test test_sparse_slice ([1 2], 22, [2,2]);
+%!test test_sparse_slice ([1 2], 22, 3);
+%!test test_sparse_slice ([1 2], 22, 4);
 
 ## size = [2 2]
-%!test test_sparse_slice([2 2], 21, []);
-%!test test_sparse_slice([2 2], 21, 1);
-%!test test_sparse_slice([2 2], 21, 2);
-%!test test_sparse_slice([2 2], 21, [2,2]);
-%!test test_sparse_slice([2 2], 21, 3);
-%!test test_sparse_slice([2 2], 21, 4);
-%!test test_sparse_slice([2 2], 22, []);
-%!test test_sparse_slice([2 2], 22, 1);
-%!test test_sparse_slice([2 2], 22, 2);
-%!test test_sparse_slice([2 2], 22, [2,2]);
-%!test test_sparse_slice([2 2], 22, 3);
-%!test test_sparse_slice([2 2], 22, 4);
+%!test test_sparse_slice ([2 2], 21, []);
+%!test test_sparse_slice ([2 2], 21, 1);
+%!test test_sparse_slice ([2 2], 21, 2);
+%!test test_sparse_slice ([2 2], 21, [2,2]);
+%!test test_sparse_slice ([2 2], 21, 3);
+%!test test_sparse_slice ([2 2], 21, 4);
+%!test test_sparse_slice ([2 2], 22, []);
+%!test test_sparse_slice ([2 2], 22, 1);
+%!test test_sparse_slice ([2 2], 22, 2);
+%!test test_sparse_slice ([2 2], 22, [2,2]);
+%!test test_sparse_slice ([2 2], 22, 3);
+%!test test_sparse_slice ([2 2], 22, 4);
 
 bug #35570:
 
--- a/liboctave/Sparse.h
+++ b/liboctave/Sparse.h
@@ -71,33 +71,34 @@
     octave_idx_type ncols;
     octave_refcount<int> count;
 
-    SparseRep (void) : d (0), r (0), c (new octave_idx_type [1]), nzmx (0), nrows (0),
-                       ncols (0), count (1) { c[0] = 0; }
+    SparseRep (void)
+      : d (0), r (0), c (new octave_idx_type [1]), nzmx (0), nrows (0),
+      ncols (0), count (1)
+      {
+        c[0] = 0;
+      }
 
-    SparseRep (octave_idx_type n) : d (0), r (0), c (new octave_idx_type [n+1]), nzmx (0), nrows (n),
+    SparseRep (octave_idx_type n)
+      : d (0), r (0), c (new octave_idx_type [n+1]), nzmx (0), nrows (n),
       ncols (n), count (1)
       {
         for (octave_idx_type i = 0; i < n + 1; i++)
           c[i] = 0;
       }
 
-    SparseRep (octave_idx_type nr, octave_idx_type nc) : d (0), r (0), c (new octave_idx_type [nc+1]), nzmx (0),
-      nrows (nr), ncols (nc), count (1)
-      {
-        for (octave_idx_type i = 0; i < nc + 1; i++)
-          c[i] = 0;
-      }
-
-    SparseRep (octave_idx_type nr, octave_idx_type nc, octave_idx_type nz) : d (new T [nz]),
-      r (new octave_idx_type [nz]), c (new octave_idx_type [nc+1]), nzmx (nz), nrows (nr),
+    SparseRep (octave_idx_type nr, octave_idx_type nc, octave_idx_type nz = 0)
+      : d (new T [nz]), r (new octave_idx_type [nz]),
+      c (new octave_idx_type [nc+1]), nzmx (nz), nrows (nr),
       ncols (nc), count (1)
       {
-        for (octave_idx_type i = 0; i < nc + 1; i++)
+        c[nc] = nz;
+        for (octave_idx_type i = 0; i < nc; i++)
           c[i] = 0;
       }
 
     SparseRep (const SparseRep& a)
-      : d (new T [a.nzmx]), r (new octave_idx_type [a.nzmx]), c (new octave_idx_type [a.ncols + 1]),
+      : d (new T [a.nzmx]), r (new octave_idx_type [a.nzmx]),
+      c (new octave_idx_type [a.ncols + 1]),
       nzmx (a.nzmx), nrows (a.nrows), ncols (a.ncols), count (1)
       {
         octave_idx_type nz = a.nnz ();
@@ -144,17 +145,17 @@
   //--------------------------------------------------------------------
 
   void make_unique (void)
-    {
-      if (rep->count > 1)
-        {
-          SparseRep *r = new SparseRep (*rep);
+  {
+    if (rep->count > 1)
+      {
+        SparseRep *r = new SparseRep (*rep);
 
-          if (--rep->count == 0)
-            delete rep;
+        if (--rep->count == 0)
+          delete rep;
 
-          rep = r;
-        }
-    }
+        rep = r;
+      }
+  }
 
 public:
 
@@ -168,18 +169,18 @@
 private:
 
   typename Sparse<T>::SparseRep *nil_rep (void) const
-    {
-      static typename Sparse<T>::SparseRep nr;
-      return &nr;
-    }
+  {
+    static typename Sparse<T>::SparseRep nr;
+    return &nr;
+  }
 
 public:
 
   Sparse (void)
     : rep (nil_rep ()), dimensions (dim_vector(0,0))
-    {
-      rep->count++;
-    }
+  {
+    rep->count++;
+  }
 
   explicit Sparse (octave_idx_type n)
     : rep (new typename Sparse<T>::SparseRep (n)),
@@ -193,7 +194,7 @@
 
   Sparse (const dim_vector& dv, octave_idx_type nz)
     : rep (new typename Sparse<T>::SparseRep (dv(0), dv(1), nz)),
-    dimensions (dv) { }
+      dimensions (dv) { }
 
   Sparse (octave_idx_type nr, octave_idx_type nc, octave_idx_type nz)
     : rep (new typename Sparse<T>::SparseRep (nr, nc, nz)),
@@ -207,20 +208,20 @@
   template <class U>
   Sparse (const Sparse<U>& a)
     : rep (new typename Sparse<T>::SparseRep (a.rep->nrows, a.rep->ncols, a.rep->nzmx)),
-    dimensions (a.dimensions)
-    {
-      octave_idx_type nz = a.nnz ();
-      std::copy (a.rep->d, a.rep->d + nz, rep->d);
-      copy_or_memcpy (nz, a.rep->r, rep->r);
-      copy_or_memcpy (rep->ncols + 1, a.rep->c, rep->c);
-    }
+      dimensions (a.dimensions)
+  {
+    octave_idx_type nz = a.nnz ();
+    std::copy (a.rep->d, a.rep->d + nz, rep->d);
+    copy_or_memcpy (nz, a.rep->r, rep->r);
+    copy_or_memcpy (rep->ncols + 1, a.rep->c, rep->c);
+  }
 
   // No type conversion case.
   Sparse (const Sparse<T>& a)
     : rep (a.rep), dimensions (a.dimensions)
-    {
-      rep->count++;
-    }
+  {
+    rep->count++;
+  }
 
 public:
 
@@ -249,9 +250,9 @@
   // Querying the number of elements (incl. zeros) may overflow the index type,
   // so don't do it unless you really need it.
   octave_idx_type numel (void) const
-    {
-      return dimensions.safe_numel ();
-    }
+  {
+    return dimensions.safe_numel ();
+  }
 
   octave_idx_type nelem (void) const { return capacity (); }
   octave_idx_type length (void) const { return numel (); }
@@ -265,18 +266,19 @@
 
   octave_idx_type get_row_index (octave_idx_type k) { return ridx (k); }
   octave_idx_type get_col_index (octave_idx_type k)
-    {
-      octave_idx_type ret = 0;
-      while (cidx(ret+1) < k)
-        ret++;
-      return ret;
-    }
+  {
+    octave_idx_type ret = 0;
+    while (cidx(ret+1) < k)
+      ret++;
+    return ret;
+  }
 
   size_t byte_size (void) const
-    {
-      return (static_cast<size_t>(cols () + 1) * sizeof (octave_idx_type)
-              + static_cast<size_t> (capacity ()) * (sizeof (T) + sizeof (octave_idx_type)));
-    }
+  {
+    return (static_cast<size_t>(cols () + 1) * sizeof (octave_idx_type)
+            + static_cast<size_t> (capacity ())
+            * (sizeof (T) + sizeof (octave_idx_type)));
+  }
 
   dim_vector dims (void) const { return dimensions; }
 
@@ -296,145 +298,189 @@
   // No checking, even for multiple references, ever.
 
   T& xelem (octave_idx_type n)
-    {
-      octave_idx_type i = n % rows (), j = n / rows();
-      return xelem (i, j);
-    }
+  {
+    octave_idx_type i = n % rows (), j = n / rows ();
+    return xelem (i, j);
+  }
 
   T xelem (octave_idx_type n) const
-    {
-      octave_idx_type i = n % rows (), j = n / rows();
-      return xelem (i, j);
-    }
+  {
+    octave_idx_type i = n % rows (), j = n / rows ();
+    return xelem (i, j);
+  }
 
   T& xelem (octave_idx_type i, octave_idx_type j) { return rep->elem (i, j); }
-  T xelem (octave_idx_type i, octave_idx_type j) const { return rep->celem (i, j); }
+  T xelem (octave_idx_type i, octave_idx_type j) const
+  {
+    return rep->celem (i, j);
+  }
 
   T& xelem (const Array<octave_idx_type>& ra_idx)
-    { return xelem (compute_index (ra_idx)); }
+  { return xelem (compute_index (ra_idx)); }
 
   T xelem (const Array<octave_idx_type>& ra_idx) const
-    { return xelem (compute_index (ra_idx)); }
+  { return xelem (compute_index (ra_idx)); }
 
   // FIXME -- would be nice to fix this so that we don't
   // unnecessarily force a copy, but that is not so easy, and I see no
   // clean way to do it.
 
   T& checkelem (octave_idx_type n)
-    {
-      if (n < 0 || n >= numel ())
-        return range_error ("T& Sparse<T>::checkelem", n);
-      else
-        {
-          make_unique ();
-          return xelem (n);
-        }
-    }
+  {
+    if (n < 0 || n >= numel ())
+      return range_error ("T& Sparse<T>::checkelem", n);
+    else
+      {
+        make_unique ();
+        return xelem (n);
+      }
+  }
 
   T& checkelem (octave_idx_type i, octave_idx_type j)
-    {
-      if (i < 0 || j < 0 || i >= dim1 () || j >= dim2 ())
-        return range_error ("T& Sparse<T>::checkelem", i, j);
-      else
-        {
-          make_unique ();
-          return xelem (i, j);
-        }
-    }
+  {
+    if (i < 0 || j < 0 || i >= dim1 () || j >= dim2 ())
+      return range_error ("T& Sparse<T>::checkelem", i, j);
+    else
+      {
+        make_unique ();
+        return xelem (i, j);
+      }
+  }
 
   T& checkelem (const Array<octave_idx_type>& ra_idx)
-    {
-      octave_idx_type i = compute_index (ra_idx);
+  {
+    octave_idx_type i = compute_index (ra_idx);
 
-      if (i < 0)
-        return range_error ("T& Sparse<T>::checkelem", ra_idx);
-      else
-        return elem (i);
-    }
+    if (i < 0)
+      return range_error ("T& Sparse<T>::checkelem", ra_idx);
+    else
+      return elem (i);
+  }
 
   T& elem (octave_idx_type n)
-    {
-      make_unique ();
-      return xelem (n);
-    }
+  {
+    make_unique ();
+    return xelem (n);
+  }
 
   T& elem (octave_idx_type i, octave_idx_type j)
-    {
-      make_unique ();
-      return xelem (i, j);
-    }
+  {
+    make_unique ();
+    return xelem (i, j);
+  }
 
   T& elem (const Array<octave_idx_type>& ra_idx)
-    { return Sparse<T>::elem (compute_index (ra_idx)); }
+  { return Sparse<T>::elem (compute_index (ra_idx)); }
 
 #if defined (BOUNDS_CHECKING)
-  T& operator () (octave_idx_type n) { return checkelem (n); }
-  T& operator () (octave_idx_type i, octave_idx_type j) { return checkelem (i, j); }
-  T& operator () (const Array<octave_idx_type>& ra_idx) { return checkelem (ra_idx); }
+  T& operator () (octave_idx_type n)
+  {
+    return checkelem (n);
+  }
+
+  T& operator () (octave_idx_type i, octave_idx_type j)
+  {
+    return checkelem (i, j);
+  }
+
+  T& operator () (const Array<octave_idx_type>& ra_idx)
+  {
+    return checkelem (ra_idx);
+  }
+
 #else
-  T& operator () (octave_idx_type n) { return elem (n); }
-  T& operator () (octave_idx_type i, octave_idx_type j) { return elem (i, j); }
-  T& operator () (const Array<octave_idx_type>& ra_idx) { return elem (ra_idx); }
+  T& operator () (octave_idx_type n)
+  {
+    return elem (n);
+  }
+
+  T& operator () (octave_idx_type i, octave_idx_type j)
+  {
+    return elem (i, j);
+  }
+
+  T& operator () (const Array<octave_idx_type>& ra_idx)
+  {
+    return elem (ra_idx);
+  }
+
 #endif
 
   T checkelem (octave_idx_type n) const
-    {
-      if (n < 0 || n >= numel ())
-        return range_error ("T Sparse<T>::checkelem", n);
-      else
-        return xelem (n);
-    }
+  {
+    if (n < 0 || n >= numel ())
+      return range_error ("T Sparse<T>::checkelem", n);
+    else
+      return xelem (n);
+  }
 
   T checkelem (octave_idx_type i, octave_idx_type j) const
-    {
-      if (i < 0 || j < 0 || i >= dim1 () || j >= dim2 ())
-        return range_error ("T Sparse<T>::checkelem", i, j);
-      else
-        return xelem (i, j);
-    }
+  {
+    if (i < 0 || j < 0 || i >= dim1 () || j >= dim2 ())
+      return range_error ("T Sparse<T>::checkelem", i, j);
+    else
+      return xelem (i, j);
+  }
 
   T checkelem (const Array<octave_idx_type>& ra_idx) const
-    {
-      octave_idx_type i = compute_index (ra_idx);
+  {
+    octave_idx_type i = compute_index (ra_idx);
 
-      if (i < 0)
-        return range_error ("T Sparse<T>::checkelem", ra_idx);
-      else
-        return Sparse<T>::elem (i);
-    }
+    if (i < 0)
+      return range_error ("T Sparse<T>::checkelem", ra_idx);
+    else
+      return Sparse<T>::elem (i);
+  }
 
   T elem (octave_idx_type n) const { return xelem (n); }
 
   T elem (octave_idx_type i, octave_idx_type j) const { return xelem (i, j); }
 
   T elem (const Array<octave_idx_type>& ra_idx) const
-    { return Sparse<T>::elem (compute_index (ra_idx)); }
+  { return Sparse<T>::elem (compute_index (ra_idx)); }
 
 #if defined (BOUNDS_CHECKING)
   T operator () (octave_idx_type n) const { return checkelem (n); }
-  T operator () (octave_idx_type i, octave_idx_type j) const { return checkelem (i, j); }
-  T operator () (const Array<octave_idx_type>& ra_idx) const { return checkelem (ra_idx); }
+  T operator () (octave_idx_type i, octave_idx_type j) const
+  {
+    return checkelem (i, j);
+  }
+
+  T operator () (const Array<octave_idx_type>& ra_idx) const
+  {
+    return checkelem (ra_idx);
+  }
+
 #else
   T operator () (octave_idx_type n) const { return elem (n); }
-  T operator () (octave_idx_type i, octave_idx_type j) const { return elem (i, j); }
-  T operator () (const Array<octave_idx_type>& ra_idx) const { return elem (ra_idx); }
+  T operator () (octave_idx_type i, octave_idx_type j) const
+  {
+    return elem (i, j);
+  }
+
+  T operator () (const Array<octave_idx_type>& ra_idx) const
+  {
+    return elem (ra_idx);
+  }
 #endif
 
   Sparse<T> maybe_compress (bool remove_zeros = false)
-    {
-      if (remove_zeros)
-        make_unique (); // Needs to unshare because elements are removed.
+  {
+    if (remove_zeros)
+      make_unique (); // Needs to unshare because elements are removed.
 
-      rep->maybe_compress (remove_zeros);
-      return (*this);
-    }
+    rep->maybe_compress (remove_zeros);
+    return (*this);
+  }
 
   Sparse<T> reshape (const dim_vector& new_dims) const;
 
   Sparse<T> permute (const Array<octave_idx_type>& vec, bool inv = false) const;
 
   Sparse<T> ipermute (const Array<octave_idx_type>& vec) const
-    { return permute (vec, true); }
+  {
+    return permute (vec, true);
+  }
 
   void resize1 (octave_idx_type n);
 
@@ -443,11 +489,11 @@
   void resize (const dim_vector& dv);
 
   void change_capacity (octave_idx_type nz)
-    {
-      if (nz < nnz ())
-        make_unique (); // Unshare now because elements will be truncated.
-      rep->change_length (nz);
-    }
+  {
+    if (nz < nnz ())
+      make_unique (); // Unshare now because elements will be truncated.
+    rep->change_length (nz);
+  }
 
   Sparse<T>& insert (const Sparse<T>& a, octave_idx_type r, octave_idx_type c);
   Sparse<T>& insert (const Sparse<T>& a, const Array<octave_idx_type>& idx);
@@ -468,7 +514,11 @@
   T* data (void) const { return rep->d; }
 
   octave_idx_type* ridx (void) { make_unique (); return rep->r; }
-  octave_idx_type& ridx (octave_idx_type i) { make_unique (); return rep->ridx (i); }
+  octave_idx_type& ridx (octave_idx_type i)
+  {
+    make_unique (); return rep->ridx (i);
+  }
+
   octave_idx_type* xridx (void) { return rep->r; }
   octave_idx_type& xridx (octave_idx_type i) { return rep->ridx (i); }
 
@@ -477,7 +527,11 @@
   octave_idx_type* ridx (void) const { return rep->r; }
 
   octave_idx_type* cidx (void) { make_unique (); return rep->c; }
-  octave_idx_type& cidx (octave_idx_type i) { make_unique (); return rep->cidx (i); }
+  octave_idx_type& cidx (octave_idx_type i)
+  {
+    make_unique (); return rep->cidx (i);
+  }
+
   octave_idx_type* xcidx (void) { return rep->c; }
   octave_idx_type& xcidx (octave_idx_type i) { return rep->cidx (i); }
 
@@ -495,7 +549,8 @@
 
   Sparse<T> index (const idx_vector& i, bool resize_ok = false) const;
 
-  Sparse<T> index (const idx_vector& i, const idx_vector& j, bool resize_ok = false) const;
+  Sparse<T> index (const idx_vector& i, const idx_vector& j,
+                   bool resize_ok = false) const;
 
   void assign (const idx_vector& i, const Sparse<T>& rhs);
 
@@ -507,13 +562,19 @@
   // You should not use them anywhere else.
   void *mex_get_data (void) const { return const_cast<T *> (data ()); }
 
-  octave_idx_type *mex_get_ir (void) const { return const_cast<octave_idx_type *> (ridx ()); }
+  octave_idx_type *mex_get_ir (void) const
+  {
+    return const_cast<octave_idx_type *> (ridx ());
+  }
 
-  octave_idx_type *mex_get_jc (void) const { return const_cast<octave_idx_type *> (cidx ()); }
+  octave_idx_type *mex_get_jc (void) const
+  {
+    return const_cast<octave_idx_type *> (cidx ());
+  }
 
   Sparse<T> sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const;
   Sparse<T> sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0,
-                 sortmode mode = ASCENDING) const;
+                  sortmode mode = ASCENDING) const;
 
   Sparse<T> diag (octave_idx_type k = 0) const;
 
--- a/liboctave/SparseCmplxCHOL.cc
+++ b/liboctave/SparseCmplxCHOL.cc
@@ -52,12 +52,12 @@
       if (typ == MatrixType::Upper)
         {
           rinv = r.inverse(mattype, info, rcond, true, false);
-          retval = rinv.transpose() * rinv;
+          retval = rinv.transpose () * rinv;
         }
       else if (typ == MatrixType::Lower)
         {
-          rinv = r.transpose().inverse(mattype, info, rcond, true, false);
-          retval = rinv.transpose() * rinv;
+          rinv = r.transpose ().inverse(mattype, info, rcond, true, false);
+          retval = rinv.transpose () * rinv;
         }
       else
         (*current_liboctave_error_handler)
--- a/liboctave/SparseCmplxCHOL.h
+++ b/liboctave/SparseCmplxCHOL.h
@@ -61,7 +61,7 @@
       return *this;
     }
 
-  SparseComplexMatrix chol_matrix (void) const { return R(); }
+  SparseComplexMatrix chol_matrix (void) const { return R (); }
 
   SparseComplexMatrix L (void) const
     { return sparse_base_chol<SparseComplexMatrix, Complex,
--- a/liboctave/SparseCmplxLU.cc
+++ b/liboctave/SparseCmplxLU.cc
@@ -57,7 +57,7 @@
   double tmp = octave_sparse_params::get_key ("spumoni");
   if (!xisnan (tmp))
     Control (UMFPACK_PRL) = tmp;
-  if (piv_thres.nelem() == 2)
+  if (piv_thres.nelem () == 2)
     {
       tmp = (piv_thres (0) > 1. ? 1. : piv_thres (0));
       if (!xisnan (tmp))
@@ -223,12 +223,12 @@
 
                   UMFPACK_ZNAME (report_matrix) (nr, n_inner,
                                             Lfact.cidx (), Lfact.ridx (),
-                                            reinterpret_cast<double *> (Lfact.data()),
+                                            reinterpret_cast<double *> (Lfact.data ()),
                                             0, 1, control);
 
                   UMFPACK_ZNAME (report_matrix) (n_inner, nc,
                                             Ufact.cidx (), Ufact.ridx (),
-                                            reinterpret_cast<double *> (Ufact.data()),
+                                            reinterpret_cast<double *> (Ufact.data ()),
                                             0, 1, control);
                   UMFPACK_ZNAME (report_perm) (nr, p, control);
                   UMFPACK_ZNAME (report_perm) (nc, q, control);
@@ -266,7 +266,7 @@
       double tmp = octave_sparse_params::get_key ("spumoni");
       if (!xisnan (tmp))
         Control (UMFPACK_PRL) = tmp;
-      if (piv_thres.nelem() == 2)
+      if (piv_thres.nelem () == 2)
         {
           tmp = (piv_thres (0) > 1. ? 1. : piv_thres (0));
           if (!xisnan (tmp))
@@ -452,13 +452,13 @@
                       UMFPACK_ZNAME (report_matrix) (nr, n_inner,
                                                 Lfact.cidx (),
                                                 Lfact.ridx (),
-                                                reinterpret_cast<double *> (Lfact.data()),
+                                                reinterpret_cast<double *> (Lfact.data ()),
                                                 0, 1, control);
 
                       UMFPACK_ZNAME (report_matrix) (n_inner, nc,
                                                 Ufact.cidx (),
                                                 Ufact.ridx (),
-                                                reinterpret_cast<double *> (Ufact.data()),
+                                                reinterpret_cast<double *> (Ufact.data ()),
                                                 0, 1, control);
                       UMFPACK_ZNAME (report_perm) (nr, p, control);
                       UMFPACK_ZNAME (report_perm) (nc, q, control);
--- a/liboctave/SparseCmplxQR.cc
+++ b/liboctave/SparseCmplxQR.cc
@@ -192,14 +192,14 @@
 SparseComplexQR::SparseComplexQR_rep::C (const ComplexMatrix &b) const
 {
 #ifdef HAVE_CXSPARSE
-  octave_idx_type b_nr = b.rows();
-  octave_idx_type b_nc = b.cols();
+  octave_idx_type b_nr = b.rows ();
+  octave_idx_type b_nc = b.cols ();
   octave_idx_type nc = N->L->n;
   octave_idx_type nr = nrows;
   const cs_complex_t *bvec =
-    reinterpret_cast<const cs_complex_t *>(b.fortran_vec());
+    reinterpret_cast<const cs_complex_t *>(b.fortran_vec ());
   ComplexMatrix ret(b_nr, b_nc);
-  Complex *vec = ret.fortran_vec();
+  Complex *vec = ret.fortran_vec ();
   if (nr < 0 || nc < 0 || nr != b_nr)
     (*current_liboctave_error_handler) ("matrix dimension mismatch");
   else if (nr == 0 || nc == 0 || b_nc == 0)
@@ -245,7 +245,7 @@
   octave_idx_type nc = N->L->n;
   octave_idx_type nr = nrows;
   ComplexMatrix ret(nr, nr);
-  Complex *vec = ret.fortran_vec();
+  Complex *vec = ret.fortran_vec ();
   if (nr < 0 || nc < 0)
     (*current_liboctave_error_handler) ("matrix dimension mismatch");
   else if (nr == 0 || nc == 0)
@@ -294,10 +294,10 @@
 {
   info = -1;
 #ifdef HAVE_CXSPARSE
-  octave_idx_type nr = a.rows();
-  octave_idx_type nc = a.cols();
-  octave_idx_type b_nc = b.cols();
-  octave_idx_type b_nr = b.rows();
+  octave_idx_type nr = a.rows ();
+  octave_idx_type nc = a.cols ();
+  octave_idx_type b_nc = b.cols ();
+  octave_idx_type b_nr = b.rows ();
   ComplexMatrix x;
 
   if (nr < 0 || nc < 0 || nr != b_nr)
@@ -309,41 +309,41 @@
     {
       SparseComplexQR q (a, 2);
       if (! q.ok ())
-        return ComplexMatrix();
+        return ComplexMatrix ();
       x.resize(nc, b_nc);
       cs_complex_t *vec = reinterpret_cast<cs_complex_t *>
-        (x.fortran_vec());
-      OCTAVE_C99_COMPLEX (buf, q.S()->m2);
+        (x.fortran_vec ());
+      OCTAVE_C99_COMPLEX (buf, q.S ()->m2);
       OCTAVE_LOCAL_BUFFER (Complex, Xx, b_nr);
       for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
         {
           octave_quit ();
           for (octave_idx_type j = 0; j < b_nr; j++)
             Xx[j] = b.xelem(j,i);
-          for (octave_idx_type j = nr; j < q.S()->m2; j++)
+          for (octave_idx_type j = nr; j < q.S ()->m2; j++)
             buf[j] = OCTAVE_C99_ZERO;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
           CXSPARSE_ZNAME (_ipvec)
-            (q.S()->pinv, reinterpret_cast<cs_complex_t *>(Xx), buf, nr);
+            (q.S ()->pinv, reinterpret_cast<cs_complex_t *>(Xx), buf, nr);
 #else
           CXSPARSE_ZNAME (_ipvec)
-            (nr, q.S()->Pinv, reinterpret_cast<cs_complex_t *>(Xx), buf);
+            (nr, q.S ()->Pinv, reinterpret_cast<cs_complex_t *>(Xx), buf);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = 0; j < nc; j++)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-              CXSPARSE_ZNAME (_happly) (q.N()->L, j, q.N()->B[j], buf);
+              CXSPARSE_ZNAME (_happly) (q.N ()->L, j, q.N ()->B[j], buf);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-          CXSPARSE_ZNAME (_usolve) (q.N()->U, buf);
+          CXSPARSE_ZNAME (_usolve) (q.N ()->U, buf);
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_ZNAME (_ipvec) (q.S()->q, buf, vec + idx, nc);
+          CXSPARSE_ZNAME (_ipvec) (q.S ()->q, buf, vec + idx, nc);
 #else
-          CXSPARSE_ZNAME (_ipvec) (nc, q.S()->Q, buf, vec + idx);
+          CXSPARSE_ZNAME (_ipvec) (nc, q.S ()->Q, buf, vec + idx);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
         }
@@ -351,24 +351,24 @@
     }
   else
     {
-      SparseComplexMatrix at = a.hermitian();
+      SparseComplexMatrix at = a.hermitian ();
       SparseComplexQR q (at, 2);
       if (! q.ok ())
-        return ComplexMatrix();
+        return ComplexMatrix ();
       x.resize(nc, b_nc);
       cs_complex_t *vec = reinterpret_cast<cs_complex_t *>
-        (x.fortran_vec());
-      volatile octave_idx_type nbuf = (nc > q.S()->m2 ? nc : q.S()->m2);
+        (x.fortran_vec ());
+      volatile octave_idx_type nbuf = (nc > q.S ()->m2 ? nc : q.S ()->m2);
       OCTAVE_C99_COMPLEX (buf, nbuf);
       OCTAVE_LOCAL_BUFFER (Complex, Xx, b_nr);
 #if defined(CS_VER) && (((CS_VER == 2) && (CS_SUBVER >= 2)) || (CS_VER > 2))
       OCTAVE_LOCAL_BUFFER (double, B, nr);
       for (octave_idx_type i = 0; i < nr; i++)
-        B[i] = q.N()->B [i];
+        B[i] = q.N ()->B [i];
 #else
       OCTAVE_LOCAL_BUFFER (Complex, B, nr);
       for (octave_idx_type i = 0; i < nr; i++)
-        B[i] = conj (reinterpret_cast<Complex *>(q.N()->B) [i]);
+        B[i] = conj (reinterpret_cast<Complex *>(q.N ()->B) [i]);
 #endif
       for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
         {
@@ -380,12 +380,12 @@
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
           CXSPARSE_ZNAME (_pvec)
-            (q.S()->q, reinterpret_cast<cs_complex_t *>(Xx), buf, nr);
+            (q.S ()->q, reinterpret_cast<cs_complex_t *>(Xx), buf, nr);
 #else
           CXSPARSE_ZNAME (_pvec)
-            (nr, q.S()->Q, reinterpret_cast<cs_complex_t *>(Xx), buf);
+            (nr, q.S ()->Q, reinterpret_cast<cs_complex_t *>(Xx), buf);
 #endif
-          CXSPARSE_ZNAME (_utsolve) (q.N()->U, buf);
+          CXSPARSE_ZNAME (_utsolve) (q.N ()->U, buf);
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = nr-1; j >= 0; j--)
             {
@@ -393,18 +393,18 @@
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 
 #if defined(CS_VER) && (((CS_VER == 2) && (CS_SUBVER >= 2)) || (CS_VER > 2))
-              CXSPARSE_ZNAME (_happly) (q.N()->L, j, B[j], buf);
+              CXSPARSE_ZNAME (_happly) (q.N ()->L, j, B[j], buf);
 #else
               CXSPARSE_ZNAME (_happly)
-                (q.N()->L, j, reinterpret_cast<cs_complex_t *>(B)[j], buf);
+                (q.N ()->L, j, reinterpret_cast<cs_complex_t *>(B)[j], buf);
 #endif
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_ZNAME (_pvec) (q.S()->pinv, buf, vec + idx, nc);
+          CXSPARSE_ZNAME (_pvec) (q.S ()->pinv, buf, vec + idx, nc);
 #else
-          CXSPARSE_ZNAME (_pvec) (nc, q.S()->Pinv, buf, vec + idx);
+          CXSPARSE_ZNAME (_pvec) (nc, q.S ()->Pinv, buf, vec + idx);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
         }
@@ -422,10 +422,10 @@
 {
   info = -1;
 #ifdef HAVE_CXSPARSE
-  octave_idx_type nr = a.rows();
-  octave_idx_type nc = a.cols();
-  octave_idx_type b_nc = b.cols();
-  octave_idx_type b_nr = b.rows();
+  octave_idx_type nr = a.rows ();
+  octave_idx_type nc = a.cols ();
+  octave_idx_type b_nc = b.cols ();
+  octave_idx_type b_nr = b.rows ();
   SparseComplexMatrix x;
   volatile octave_idx_type ii, x_nz;
 
@@ -438,44 +438,44 @@
     {
       SparseComplexQR q (a, 2);
       if (! q.ok ())
-        return SparseComplexMatrix();
-      x = SparseComplexMatrix (nc, b_nc, b.nnz());
+        return SparseComplexMatrix ();
+      x = SparseComplexMatrix (nc, b_nc, b.nnz ());
       x.xcidx(0) = 0;
-      x_nz = b.nnz();
+      x_nz = b.nnz ();
       ii = 0;
       OCTAVE_LOCAL_BUFFER (Complex, Xx, (b_nr > nc ? b_nr : nc));
-      OCTAVE_C99_COMPLEX (buf, q.S()->m2);
+      OCTAVE_C99_COMPLEX (buf, q.S ()->m2);
       for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
         {
           octave_quit ();
           for (octave_idx_type j = 0; j < b_nr; j++)
             Xx[j] = b.xelem(j,i);
-          for (octave_idx_type j = nr; j < q.S()->m2; j++)
+          for (octave_idx_type j = nr; j < q.S ()->m2; j++)
             buf[j] = OCTAVE_C99_ZERO;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
           CXSPARSE_ZNAME (_ipvec)
-            (q.S()->pinv, reinterpret_cast<cs_complex_t *>(Xx), buf, nr);
+            (q.S ()->pinv, reinterpret_cast<cs_complex_t *>(Xx), buf, nr);
 #else
           CXSPARSE_ZNAME (_ipvec)
-            (nr, q.S()->Pinv, reinterpret_cast<cs_complex_t *>(Xx), buf);
+            (nr, q.S ()->Pinv, reinterpret_cast<cs_complex_t *>(Xx), buf);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = 0; j < nc; j++)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-              CXSPARSE_ZNAME (_happly) (q.N()->L, j, q.N()->B[j], buf);
+              CXSPARSE_ZNAME (_happly) (q.N ()->L, j, q.N ()->B[j], buf);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-          CXSPARSE_ZNAME (_usolve) (q.N()->U, buf);
+          CXSPARSE_ZNAME (_usolve) (q.N ()->U, buf);
 #if defined(CS_VER) && (CS_VER >= 2)
           CXSPARSE_ZNAME (_ipvec)
-            (q.S()->q, buf, reinterpret_cast<cs_complex_t *>(Xx), nc);
+            (q.S ()->q, buf, reinterpret_cast<cs_complex_t *>(Xx), nc);
 #else
           CXSPARSE_ZNAME (_ipvec)
-            (nc, q.S()->Q, buf, reinterpret_cast<cs_complex_t *>(Xx));
+            (nc, q.S ()->Q, buf, reinterpret_cast<cs_complex_t *>(Xx));
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 
@@ -502,26 +502,26 @@
     }
   else
     {
-      SparseComplexMatrix at = a.hermitian();
+      SparseComplexMatrix at = a.hermitian ();
       SparseComplexQR q (at, 2);
       if (! q.ok ())
-        return SparseComplexMatrix();
-      x = SparseComplexMatrix (nc, b_nc, b.nnz());
+        return SparseComplexMatrix ();
+      x = SparseComplexMatrix (nc, b_nc, b.nnz ());
       x.xcidx(0) = 0;
-      x_nz = b.nnz();
+      x_nz = b.nnz ();
       ii = 0;
-      volatile octave_idx_type nbuf = (nc > q.S()->m2 ? nc : q.S()->m2);
+      volatile octave_idx_type nbuf = (nc > q.S ()->m2 ? nc : q.S ()->m2);
       OCTAVE_LOCAL_BUFFER (Complex, Xx, (b_nr > nc ? b_nr : nc));
       OCTAVE_C99_COMPLEX (buf, nbuf);
 
 #if defined(CS_VER) && (((CS_VER == 2) && (CS_SUBVER >= 2)) || (CS_VER > 2))
       OCTAVE_LOCAL_BUFFER (double, B, nr);
       for (octave_idx_type i = 0; i < nr; i++)
-        B[i] = q.N()->B [i];
+        B[i] = q.N ()->B [i];
 #else
       OCTAVE_LOCAL_BUFFER (Complex, B, nr);
       for (octave_idx_type i = 0; i < nr; i++)
-        B[i] = conj (reinterpret_cast<Complex *>(q.N()->B) [i]);
+        B[i] = conj (reinterpret_cast<Complex *>(q.N ()->B) [i]);
 #endif
       for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
         {
@@ -533,32 +533,32 @@
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
           CXSPARSE_ZNAME (_pvec)
-            (q.S()->q, reinterpret_cast<cs_complex_t *>(Xx), buf, nr);
+            (q.S ()->q, reinterpret_cast<cs_complex_t *>(Xx), buf, nr);
 #else
           CXSPARSE_ZNAME (_pvec)
-            (nr, q.S()->Q, reinterpret_cast<cs_complex_t *>(Xx), buf);
+            (nr, q.S ()->Q, reinterpret_cast<cs_complex_t *>(Xx), buf);
 #endif
-          CXSPARSE_ZNAME (_utsolve) (q.N()->U, buf);
+          CXSPARSE_ZNAME (_utsolve) (q.N ()->U, buf);
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = nr-1; j >= 0; j--)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (((CS_VER == 2) && (CS_SUBVER >= 2)) || (CS_VER > 2))
-              CXSPARSE_ZNAME (_happly) (q.N()->L, j, B[j], buf);
+              CXSPARSE_ZNAME (_happly) (q.N ()->L, j, B[j], buf);
 #else
               CXSPARSE_ZNAME (_happly)
-                (q.N()->L, j, reinterpret_cast<cs_complex_t *>(B)[j], buf);
+                (q.N ()->L, j, reinterpret_cast<cs_complex_t *>(B)[j], buf);
 #endif
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
           CXSPARSE_ZNAME (_pvec)
-            (q.S()->pinv, buf, reinterpret_cast<cs_complex_t *>(Xx), nc);
+            (q.S ()->pinv, buf, reinterpret_cast<cs_complex_t *>(Xx), nc);
 #else
           CXSPARSE_ZNAME (_pvec)
-            (nc, q.S()->Pinv, buf, reinterpret_cast<cs_complex_t *>(Xx));
+            (nc, q.S ()->Pinv, buf, reinterpret_cast<cs_complex_t *>(Xx));
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 
@@ -596,12 +596,12 @@
 {
   info = -1;
 #ifdef HAVE_CXSPARSE
-  octave_idx_type nr = a.rows();
-  octave_idx_type nc = a.cols();
-  octave_idx_type b_nc = b.cols();
-  octave_idx_type b_nr = b.rows();
+  octave_idx_type nr = a.rows ();
+  octave_idx_type nc = a.cols ();
+  octave_idx_type b_nc = b.cols ();
+  octave_idx_type b_nr = b.rows ();
   const cs_complex_t *bvec =
-    reinterpret_cast<const cs_complex_t *>(b.fortran_vec());
+    reinterpret_cast<const cs_complex_t *>(b.fortran_vec ());
   ComplexMatrix x;
 
   if (nr < 0 || nc < 0 || nr != b_nr)
@@ -613,37 +613,37 @@
     {
       SparseComplexQR q (a, 2);
       if (! q.ok ())
-        return ComplexMatrix();
+        return ComplexMatrix ();
       x.resize(nc, b_nc);
       cs_complex_t *vec = reinterpret_cast<cs_complex_t *>
-        (x.fortran_vec());
-      OCTAVE_C99_COMPLEX (buf, q.S()->m2);
+        (x.fortran_vec ());
+      OCTAVE_C99_COMPLEX (buf, q.S ()->m2);
       for (volatile octave_idx_type i = 0, idx = 0, bidx = 0; i < b_nc;
            i++, idx+=nc, bidx+=b_nr)
         {
           octave_quit ();
-          for (octave_idx_type j = nr; j < q.S()->m2; j++)
+          for (octave_idx_type j = nr; j < q.S ()->m2; j++)
             buf[j] = OCTAVE_C99_ZERO;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_ZNAME (_ipvec) (q.S()->pinv, bvec + bidx, buf, nr);
+          CXSPARSE_ZNAME (_ipvec) (q.S ()->pinv, bvec + bidx, buf, nr);
 #else
-          CXSPARSE_ZNAME (_ipvec) (nr, q.S()->Pinv, bvec + bidx, buf);
+          CXSPARSE_ZNAME (_ipvec) (nr, q.S ()->Pinv, bvec + bidx, buf);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = 0; j < nc; j++)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-              CXSPARSE_ZNAME (_happly) (q.N()->L, j, q.N()->B[j], buf);
+              CXSPARSE_ZNAME (_happly) (q.N ()->L, j, q.N ()->B[j], buf);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-          CXSPARSE_ZNAME (_usolve) (q.N()->U, buf);
+          CXSPARSE_ZNAME (_usolve) (q.N ()->U, buf);
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_ZNAME (_ipvec) (q.S()->q, buf, vec + idx, nc);
+          CXSPARSE_ZNAME (_ipvec) (q.S ()->q, buf, vec + idx, nc);
 #else
-          CXSPARSE_ZNAME (_ipvec) (nc, q.S()->Q, buf, vec + idx);
+          CXSPARSE_ZNAME (_ipvec) (nc, q.S ()->Q, buf, vec + idx);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
         }
@@ -651,23 +651,23 @@
     }
   else
     {
-      SparseComplexMatrix at = a.hermitian();
+      SparseComplexMatrix at = a.hermitian ();
       SparseComplexQR q (at, 2);
       if (! q.ok ())
-        return ComplexMatrix();
+        return ComplexMatrix ();
       x.resize(nc, b_nc);
       cs_complex_t *vec = reinterpret_cast<cs_complex_t *>
-        (x.fortran_vec());
-      volatile octave_idx_type nbuf = (nc > q.S()->m2 ? nc : q.S()->m2);
+        (x.fortran_vec ());
+      volatile octave_idx_type nbuf = (nc > q.S ()->m2 ? nc : q.S ()->m2);
       OCTAVE_C99_COMPLEX (buf, nbuf);
 #if defined(CS_VER) && (((CS_VER == 2) && (CS_SUBVER >= 2)) || (CS_VER > 2))
       OCTAVE_LOCAL_BUFFER (double, B, nr);
       for (octave_idx_type i = 0; i < nr; i++)
-        B[i] = q.N()->B [i];
+        B[i] = q.N ()->B [i];
 #else
       OCTAVE_LOCAL_BUFFER (Complex, B, nr);
       for (octave_idx_type i = 0; i < nr; i++)
-        B[i] = conj (reinterpret_cast<Complex *>(q.N()->B) [i]);
+        B[i] = conj (reinterpret_cast<Complex *>(q.N ()->B) [i]);
 #endif
       for (volatile octave_idx_type i = 0, idx = 0, bidx = 0; i < b_nc;
            i++, idx+=nc, bidx+=b_nr)
@@ -677,29 +677,29 @@
             buf[j] = OCTAVE_C99_ZERO;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_ZNAME (_pvec) (q.S()->q, bvec + bidx, buf, nr);
+          CXSPARSE_ZNAME (_pvec) (q.S ()->q, bvec + bidx, buf, nr);
 #else
-          CXSPARSE_ZNAME (_pvec) (nr, q.S()->Q, bvec + bidx, buf);
+          CXSPARSE_ZNAME (_pvec) (nr, q.S ()->Q, bvec + bidx, buf);
 #endif
-          CXSPARSE_ZNAME (_utsolve) (q.N()->U, buf);
+          CXSPARSE_ZNAME (_utsolve) (q.N ()->U, buf);
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = nr-1; j >= 0; j--)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (((CS_VER == 2) && (CS_SUBVER >= 2)) || (CS_VER > 2))
-              CXSPARSE_ZNAME (_happly) (q.N()->L, j, B[j], buf);
+              CXSPARSE_ZNAME (_happly) (q.N ()->L, j, B[j], buf);
 #else
               CXSPARSE_ZNAME (_happly)
-                (q.N()->L, j, reinterpret_cast<cs_complex_t *>(B)[j], buf);
+                (q.N ()->L, j, reinterpret_cast<cs_complex_t *>(B)[j], buf);
 #endif
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_ZNAME (_pvec) (q.S()->pinv, buf, vec + idx, nc);
+          CXSPARSE_ZNAME (_pvec) (q.S ()->pinv, buf, vec + idx, nc);
 #else
-          CXSPARSE_ZNAME (_pvec) (nc, q.S()->Pinv, buf, vec + idx);
+          CXSPARSE_ZNAME (_pvec) (nc, q.S ()->Pinv, buf, vec + idx);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
         }
@@ -717,10 +717,10 @@
 {
   info = -1;
 #ifdef HAVE_CXSPARSE
-  octave_idx_type nr = a.rows();
-  octave_idx_type nc = a.cols();
-  octave_idx_type b_nc = b.cols();
-  octave_idx_type b_nr = b.rows();
+  octave_idx_type nr = a.rows ();
+  octave_idx_type nc = a.cols ();
+  octave_idx_type b_nc = b.cols ();
+  octave_idx_type b_nr = b.rows ();
   SparseComplexMatrix x;
   volatile octave_idx_type ii, x_nz;
 
@@ -733,44 +733,44 @@
     {
       SparseComplexQR q (a, 2);
       if (! q.ok ())
-        return SparseComplexMatrix();
-      x = SparseComplexMatrix (nc, b_nc, b.nnz());
+        return SparseComplexMatrix ();
+      x = SparseComplexMatrix (nc, b_nc, b.nnz ());
       x.xcidx(0) = 0;
-      x_nz = b.nnz();
+      x_nz = b.nnz ();
       ii = 0;
       OCTAVE_LOCAL_BUFFER (Complex, Xx, (b_nr > nc ? b_nr : nc));
-      OCTAVE_C99_COMPLEX (buf, q.S()->m2);
+      OCTAVE_C99_COMPLEX (buf, q.S ()->m2);
       for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
         {
           octave_quit ();
           for (octave_idx_type j = 0; j < b_nr; j++)
             Xx[j] = b.xelem(j,i);
-          for (octave_idx_type j = nr; j < q.S()->m2; j++)
+          for (octave_idx_type j = nr; j < q.S ()->m2; j++)
             buf[j] = OCTAVE_C99_ZERO;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
           CXSPARSE_ZNAME (_ipvec)
-            (q.S()->pinv, reinterpret_cast<cs_complex_t *>(Xx), buf, nr);
+            (q.S ()->pinv, reinterpret_cast<cs_complex_t *>(Xx), buf, nr);
 #else
           CXSPARSE_ZNAME (_ipvec)
-            (nr, q.S()->Pinv, reinterpret_cast<cs_complex_t *>(Xx), buf);
+            (nr, q.S ()->Pinv, reinterpret_cast<cs_complex_t *>(Xx), buf);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = 0; j < nc; j++)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-              CXSPARSE_ZNAME (_happly) (q.N()->L, j, q.N()->B[j], buf);
+              CXSPARSE_ZNAME (_happly) (q.N ()->L, j, q.N ()->B[j], buf);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-          CXSPARSE_ZNAME (_usolve) (q.N()->U, buf);
+          CXSPARSE_ZNAME (_usolve) (q.N ()->U, buf);
 #if defined(CS_VER) && (CS_VER >= 2)
           CXSPARSE_ZNAME (_ipvec)
-            (q.S()->q, buf, reinterpret_cast<cs_complex_t *>(Xx), nc);
+            (q.S ()->q, buf, reinterpret_cast<cs_complex_t *>(Xx), nc);
 #else
           CXSPARSE_ZNAME (_ipvec)
-            (nc, q.S()->Q, buf, reinterpret_cast<cs_complex_t *>(Xx));
+            (nc, q.S ()->Q, buf, reinterpret_cast<cs_complex_t *>(Xx));
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 
@@ -797,25 +797,25 @@
     }
   else
     {
-      SparseComplexMatrix at = a.hermitian();
+      SparseComplexMatrix at = a.hermitian ();
       SparseComplexQR q (at, 2);
       if (! q.ok ())
-        return SparseComplexMatrix();
-      x = SparseComplexMatrix (nc, b_nc, b.nnz());
+        return SparseComplexMatrix ();
+      x = SparseComplexMatrix (nc, b_nc, b.nnz ());
       x.xcidx(0) = 0;
-      x_nz = b.nnz();
+      x_nz = b.nnz ();
       ii = 0;
-      volatile octave_idx_type nbuf = (nc > q.S()->m2 ? nc : q.S()->m2);
+      volatile octave_idx_type nbuf = (nc > q.S ()->m2 ? nc : q.S ()->m2);
       OCTAVE_LOCAL_BUFFER (Complex, Xx, (b_nr > nc ? b_nr : nc));
       OCTAVE_C99_COMPLEX (buf, nbuf);
 #if defined(CS_VER) && (((CS_VER == 2) && (CS_SUBVER >= 2)) || (CS_VER > 2))
       OCTAVE_LOCAL_BUFFER (double, B, nr);
       for (octave_idx_type i = 0; i < nr; i++)
-        B[i] = q.N()->B [i];
+        B[i] = q.N ()->B [i];
 #else
       OCTAVE_LOCAL_BUFFER (Complex, B, nr);
       for (octave_idx_type i = 0; i < nr; i++)
-        B[i] = conj (reinterpret_cast<Complex *>(q.N()->B) [i]);
+        B[i] = conj (reinterpret_cast<Complex *>(q.N ()->B) [i]);
 #endif
       for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
         {
@@ -827,32 +827,32 @@
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
           CXSPARSE_ZNAME (_pvec)
-            (q.S()->q, reinterpret_cast<cs_complex_t *>(Xx), buf, nr);
+            (q.S ()->q, reinterpret_cast<cs_complex_t *>(Xx), buf, nr);
 #else
           CXSPARSE_ZNAME (_pvec)
-            (nr, q.S()->Q, reinterpret_cast<cs_complex_t *>(Xx), buf);
+            (nr, q.S ()->Q, reinterpret_cast<cs_complex_t *>(Xx), buf);
 #endif
-          CXSPARSE_ZNAME (_utsolve) (q.N()->U, buf);
+          CXSPARSE_ZNAME (_utsolve) (q.N ()->U, buf);
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = nr-1; j >= 0; j--)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (((CS_VER == 2) && (CS_SUBVER >= 2)) || (CS_VER > 2))
-              CXSPARSE_ZNAME (_happly) (q.N()->L, j, B[j], buf);
+              CXSPARSE_ZNAME (_happly) (q.N ()->L, j, B[j], buf);
 #else
               CXSPARSE_ZNAME (_happly)
-                (q.N()->L, j, reinterpret_cast<cs_complex_t *>(B)[j], buf);
+                (q.N ()->L, j, reinterpret_cast<cs_complex_t *>(B)[j], buf);
 #endif
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
           CXSPARSE_ZNAME (_pvec)
-            (q.S()->pinv, buf, reinterpret_cast<cs_complex_t *>(Xx), nc);
+            (q.S ()->pinv, buf, reinterpret_cast<cs_complex_t *>(Xx), nc);
 #else
           CXSPARSE_ZNAME (_pvec)
-            (nc, q.S()->Pinv, buf, reinterpret_cast<cs_complex_t *>(Xx));
+            (nc, q.S ()->Pinv, buf, reinterpret_cast<cs_complex_t *>(Xx));
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 
--- a/liboctave/SparseCmplxQR.h
+++ b/liboctave/SparseCmplxQR.h
@@ -87,7 +87,7 @@
 
 public:
   SparseComplexQR (void) :
-    rep (new SparseComplexQR_rep (SparseComplexMatrix(), 0)) { }
+    rep (new SparseComplexQR_rep (SparseComplexMatrix (), 0)) { }
 
   SparseComplexQR (const SparseComplexMatrix& a, int order = 0) :
     rep (new SparseComplexQR_rep (a, order)) { }
@@ -113,20 +113,20 @@
       return *this;
     }
 
-  bool ok (void) const { return rep->ok(); }
+  bool ok (void) const { return rep->ok (); }
 
-  SparseComplexMatrix V (void) const { return rep->V(); }
+  SparseComplexMatrix V (void) const { return rep->V (); }
 
-  ColumnVector Pinv (void) const { return rep->P(); }
+  ColumnVector Pinv (void) const { return rep->P (); }
 
-  ColumnVector P (void) const { return rep->P(); }
+  ColumnVector P (void) const { return rep->P (); }
 
   SparseComplexMatrix R (const bool econ = false) const
     { return rep->R(econ); }
 
   ComplexMatrix C (const ComplexMatrix &b) const { return rep->C(b); }
 
-  ComplexMatrix Q (void) const { return rep->Q(); }
+  ComplexMatrix Q (void) const { return rep->Q (); }
 
   friend ComplexMatrix qrsolve (const SparseComplexMatrix &a, const Matrix &b,
                                 octave_idx_type &info);
--- a/liboctave/SparseQR.cc
+++ b/liboctave/SparseQR.cc
@@ -174,13 +174,13 @@
 SparseQR::SparseQR_rep::C (const Matrix &b) const
 {
 #ifdef HAVE_CXSPARSE
-  octave_idx_type b_nr = b.rows();
-  octave_idx_type b_nc = b.cols();
+  octave_idx_type b_nr = b.rows ();
+  octave_idx_type b_nc = b.cols ();
   octave_idx_type nc = N->L->n;
   octave_idx_type nr = nrows;
-  const double *bvec = b.fortran_vec();
+  const double *bvec = b.fortran_vec ();
   Matrix ret (b_nr, b_nc);
-  double *vec = ret.fortran_vec();
+  double *vec = ret.fortran_vec ();
   if (nr < 0 || nc < 0 || nr != b_nr)
     (*current_liboctave_error_handler) ("matrix dimension mismatch");
   else if (nr == 0 || nc == 0 || b_nc == 0)
@@ -226,7 +226,7 @@
   octave_idx_type nc = N->L->n;
   octave_idx_type nr = nrows;
   Matrix ret (nr, nr);
-  double *vec = ret.fortran_vec();
+  double *vec = ret.fortran_vec ();
   if (nr < 0 || nc < 0)
     (*current_liboctave_error_handler) ("matrix dimension mismatch");
   else if (nr == 0 || nc == 0)
@@ -275,11 +275,11 @@
 {
   info = -1;
 #ifdef HAVE_CXSPARSE
-  octave_idx_type nr = a.rows();
-  octave_idx_type nc = a.cols();
-  octave_idx_type b_nc = b.cols();
-  octave_idx_type b_nr = b.rows();
-  const double *bvec = b.fortran_vec();
+  octave_idx_type nr = a.rows ();
+  octave_idx_type nc = a.cols ();
+  octave_idx_type b_nc = b.cols ();
+  octave_idx_type b_nr = b.rows ();
+  const double *bvec = b.fortran_vec ();
   Matrix x;
 
   if (nr < 0 || nc < 0 || nr != b_nr)
@@ -291,36 +291,36 @@
     {
       SparseQR q (a, 3);
       if (! q.ok ())
-        return Matrix();
+        return Matrix ();
       x.resize(nc, b_nc);
-      double *vec = x.fortran_vec();
-      OCTAVE_LOCAL_BUFFER (double, buf, q.S()->m2);
+      double *vec = x.fortran_vec ();
+      OCTAVE_LOCAL_BUFFER (double, buf, q.S ()->m2);
       for (volatile octave_idx_type i = 0, idx = 0, bidx = 0; i < b_nc;
            i++, idx+=nc, bidx+=b_nr)
         {
           octave_quit ();
-          for (octave_idx_type j = nr; j < q.S()->m2; j++)
+          for (octave_idx_type j = nr; j < q.S ()->m2; j++)
             buf[j] = 0.;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_ipvec) (q.S()->pinv, bvec + bidx, buf, nr);
+          CXSPARSE_DNAME (_ipvec) (q.S ()->pinv, bvec + bidx, buf, nr);
 #else
-          CXSPARSE_DNAME (_ipvec) (nr, q.S()->Pinv, bvec + bidx, buf);
+          CXSPARSE_DNAME (_ipvec) (nr, q.S ()->Pinv, bvec + bidx, buf);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = 0; j < nc; j++)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-              CXSPARSE_DNAME (_happly) (q.N()->L, j, q.N()->B[j], buf);
+              CXSPARSE_DNAME (_happly) (q.N ()->L, j, q.N ()->B[j], buf);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-          CXSPARSE_DNAME (_usolve) (q.N()->U, buf);
+          CXSPARSE_DNAME (_usolve) (q.N ()->U, buf);
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_ipvec) (q.S()->q, buf, vec + idx, nc);
+          CXSPARSE_DNAME (_ipvec) (q.S ()->q, buf, vec + idx, nc);
 #else
-          CXSPARSE_DNAME (_ipvec) (nc, q.S()->Q, buf, vec + idx);
+          CXSPARSE_DNAME (_ipvec) (nc, q.S ()->Q, buf, vec + idx);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
         }
@@ -328,13 +328,13 @@
     }
   else
     {
-      SparseMatrix at = a.hermitian();
+      SparseMatrix at = a.hermitian ();
       SparseQR q (at, 3);
       if (! q.ok ())
-        return Matrix();
+        return Matrix ();
       x.resize(nc, b_nc);
-      double *vec = x.fortran_vec();
-      volatile octave_idx_type nbuf = (nc > q.S()->m2 ? nc : q.S()->m2);
+      double *vec = x.fortran_vec ();
+      volatile octave_idx_type nbuf = (nc > q.S ()->m2 ? nc : q.S ()->m2);
       OCTAVE_LOCAL_BUFFER (double, buf, nbuf);
       for (volatile octave_idx_type i = 0, idx = 0, bidx = 0; i < b_nc;
            i++, idx+=nc, bidx+=b_nr)
@@ -344,24 +344,24 @@
             buf[j] = 0.;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_pvec) (q.S()->q, bvec + bidx, buf, nr);
+          CXSPARSE_DNAME (_pvec) (q.S ()->q, bvec + bidx, buf, nr);
 #else
-          CXSPARSE_DNAME (_pvec) (nr, q.S()->Q, bvec + bidx, buf);
+          CXSPARSE_DNAME (_pvec) (nr, q.S ()->Q, bvec + bidx, buf);
 #endif
-          CXSPARSE_DNAME (_utsolve) (q.N()->U, buf);
+          CXSPARSE_DNAME (_utsolve) (q.N ()->U, buf);
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = nr-1; j >= 0; j--)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-              CXSPARSE_DNAME (_happly) (q.N()->L, j, q.N()->B[j], buf);
+              CXSPARSE_DNAME (_happly) (q.N ()->L, j, q.N ()->B[j], buf);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_pvec) (q.S()->pinv, buf, vec + idx, nc);
+          CXSPARSE_DNAME (_pvec) (q.S ()->pinv, buf, vec + idx, nc);
 #else
-          CXSPARSE_DNAME (_pvec) (nc, q.S()->Pinv, buf, vec + idx);
+          CXSPARSE_DNAME (_pvec) (nc, q.S ()->Pinv, buf, vec + idx);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
         }
@@ -379,10 +379,10 @@
 {
   info = -1;
 #ifdef HAVE_CXSPARSE
-  octave_idx_type nr = a.rows();
-  octave_idx_type nc = a.cols();
-  octave_idx_type b_nr = b.rows();
-  octave_idx_type b_nc = b.cols();
+  octave_idx_type nr = a.rows ();
+  octave_idx_type nc = a.cols ();
+  octave_idx_type b_nr = b.rows ();
+  octave_idx_type b_nc = b.cols ();
   SparseMatrix x;
   volatile octave_idx_type ii, x_nz;
 
@@ -395,40 +395,40 @@
     {
       SparseQR q (a, 3);
       if (! q.ok ())
-        return SparseMatrix();
-      x = SparseMatrix (nc, b_nc, b.nnz());
+        return SparseMatrix ();
+      x = SparseMatrix (nc, b_nc, b.nnz ());
       x.xcidx(0) = 0;
-      x_nz = b.nnz();
+      x_nz = b.nnz ();
       ii = 0;
       OCTAVE_LOCAL_BUFFER (double, Xx, (b_nr > nc ? b_nr : nc));
-      OCTAVE_LOCAL_BUFFER (double, buf, q.S()->m2);
+      OCTAVE_LOCAL_BUFFER (double, buf, q.S ()->m2);
       for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
         {
           octave_quit ();
           for (octave_idx_type j = 0; j < b_nr; j++)
             Xx[j] = b.xelem(j,i);
-          for (octave_idx_type j = nr; j < q.S()->m2; j++)
+          for (octave_idx_type j = nr; j < q.S ()->m2; j++)
             buf[j] = 0.;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_ipvec) (q.S()->pinv, Xx, buf, nr);
+          CXSPARSE_DNAME (_ipvec) (q.S ()->pinv, Xx, buf, nr);
 #else
-          CXSPARSE_DNAME (_ipvec) (nr, q.S()->Pinv, Xx, buf);
+          CXSPARSE_DNAME (_ipvec) (nr, q.S ()->Pinv, Xx, buf);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = 0; j < nc; j++)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-              CXSPARSE_DNAME (_happly) (q.N()->L, j, q.N()->B[j], buf);
+              CXSPARSE_DNAME (_happly) (q.N ()->L, j, q.N ()->B[j], buf);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-          CXSPARSE_DNAME (_usolve) (q.N()->U, buf);
+          CXSPARSE_DNAME (_usolve) (q.N ()->U, buf);
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_ipvec) (q.S()->q, buf, Xx, nc);
+          CXSPARSE_DNAME (_ipvec) (q.S ()->q, buf, Xx, nc);
 #else
-          CXSPARSE_DNAME (_ipvec) (nc, q.S()->Q, buf, Xx);
+          CXSPARSE_DNAME (_ipvec) (nc, q.S ()->Q, buf, Xx);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 
@@ -455,15 +455,15 @@
     }
   else
     {
-      SparseMatrix at = a.hermitian();
+      SparseMatrix at = a.hermitian ();
       SparseQR q (at, 3);
       if (! q.ok ())
-        return SparseMatrix();
-      x = SparseMatrix (nc, b_nc, b.nnz());
+        return SparseMatrix ();
+      x = SparseMatrix (nc, b_nc, b.nnz ());
       x.xcidx(0) = 0;
-      x_nz = b.nnz();
+      x_nz = b.nnz ();
       ii = 0;
-      volatile octave_idx_type nbuf = (nc > q.S()->m2 ? nc : q.S()->m2);
+      volatile octave_idx_type nbuf = (nc > q.S ()->m2 ? nc : q.S ()->m2);
       OCTAVE_LOCAL_BUFFER (double, Xx, (b_nr > nc ? b_nr : nc));
       OCTAVE_LOCAL_BUFFER (double, buf, nbuf);
       for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
@@ -475,24 +475,24 @@
             buf[j] = 0.;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_pvec) (q.S()->q, Xx, buf, nr);
+          CXSPARSE_DNAME (_pvec) (q.S ()->q, Xx, buf, nr);
 #else
-          CXSPARSE_DNAME (_pvec) (nr, q.S()->Q, Xx, buf);
+          CXSPARSE_DNAME (_pvec) (nr, q.S ()->Q, Xx, buf);
 #endif
-          CXSPARSE_DNAME (_utsolve) (q.N()->U, buf);
+          CXSPARSE_DNAME (_utsolve) (q.N ()->U, buf);
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = nr-1; j >= 0; j--)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-              CXSPARSE_DNAME (_happly) (q.N()->L, j, q.N()->B[j], buf);
+              CXSPARSE_DNAME (_happly) (q.N ()->L, j, q.N ()->B[j], buf);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_pvec) (q.S()->pinv, buf, Xx, nc);
+          CXSPARSE_DNAME (_pvec) (q.S ()->pinv, buf, Xx, nc);
 #else
-          CXSPARSE_DNAME (_pvec) (nc, q.S()->Pinv, buf, Xx);
+          CXSPARSE_DNAME (_pvec) (nc, q.S ()->Pinv, buf, Xx);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 
@@ -530,10 +530,10 @@
 {
   info = -1;
 #ifdef HAVE_CXSPARSE
-  octave_idx_type nr = a.rows();
-  octave_idx_type nc = a.cols();
-  octave_idx_type b_nc = b.cols();
-  octave_idx_type b_nr = b.rows();
+  octave_idx_type nr = a.rows ();
+  octave_idx_type nc = a.cols ();
+  octave_idx_type b_nc = b.cols ();
+  octave_idx_type b_nr = b.rows ();
   ComplexMatrix x;
 
   if (nr < 0 || nc < 0 || nr != b_nr)
@@ -545,12 +545,12 @@
     {
       SparseQR q (a, 3);
       if (! q.ok ())
-        return ComplexMatrix();
+        return ComplexMatrix ();
       x.resize(nc, b_nc);
-      Complex *vec = x.fortran_vec();
+      Complex *vec = x.fortran_vec ();
       OCTAVE_LOCAL_BUFFER (double, Xx, (b_nr > nc ? b_nr : nc));
       OCTAVE_LOCAL_BUFFER (double, Xz, (b_nr > nc ? b_nr : nc));
-      OCTAVE_LOCAL_BUFFER (double, buf, q.S()->m2);
+      OCTAVE_LOCAL_BUFFER (double, buf, q.S ()->m2);
       for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
         {
           octave_quit ();
@@ -560,50 +560,50 @@
               Xx[j] = std::real (c);
               Xz[j] = std::imag (c);
             }
-          for (octave_idx_type j = nr; j < q.S()->m2; j++)
+          for (octave_idx_type j = nr; j < q.S ()->m2; j++)
             buf[j] = 0.;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_ipvec) (q.S()->pinv, Xx, buf, nr);
+          CXSPARSE_DNAME (_ipvec) (q.S ()->pinv, Xx, buf, nr);
 #else
-          CXSPARSE_DNAME (_ipvec) (nr, q.S()->Pinv, Xx, buf);
+          CXSPARSE_DNAME (_ipvec) (nr, q.S ()->Pinv, Xx, buf);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = 0; j < nc; j++)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-              CXSPARSE_DNAME (_happly) (q.N()->L, j, q.N()->B[j], buf);
+              CXSPARSE_DNAME (_happly) (q.N ()->L, j, q.N ()->B[j], buf);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-          CXSPARSE_DNAME (_usolve) (q.N()->U, buf);
+          CXSPARSE_DNAME (_usolve) (q.N ()->U, buf);
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_ipvec) (q.S()->q, buf, Xx, nc);
+          CXSPARSE_DNAME (_ipvec) (q.S ()->q, buf, Xx, nc);
 #else
-          CXSPARSE_DNAME (_ipvec) (nc, q.S()->Q, buf, Xx);
+          CXSPARSE_DNAME (_ipvec) (nc, q.S ()->Q, buf, Xx);
 #endif
-          for (octave_idx_type j = nr; j < q.S()->m2; j++)
+          for (octave_idx_type j = nr; j < q.S ()->m2; j++)
             buf[j] = 0.;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_ipvec) (q.S()->pinv, Xz, buf, nr);
+          CXSPARSE_DNAME (_ipvec) (q.S ()->pinv, Xz, buf, nr);
 #else
-          CXSPARSE_DNAME (_ipvec) (nr, q.S()->Pinv, Xz, buf);
+          CXSPARSE_DNAME (_ipvec) (nr, q.S ()->Pinv, Xz, buf);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = 0; j < nc; j++)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-              CXSPARSE_DNAME (_happly) (q.N()->L, j, q.N()->B[j], buf);
+              CXSPARSE_DNAME (_happly) (q.N ()->L, j, q.N ()->B[j], buf);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-          CXSPARSE_DNAME (_usolve) (q.N()->U, buf);
+          CXSPARSE_DNAME (_usolve) (q.N ()->U, buf);
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_ipvec) (q.S()->q, buf, Xz, nc);
+          CXSPARSE_DNAME (_ipvec) (q.S ()->q, buf, Xz, nc);
 #else
-          CXSPARSE_DNAME (_ipvec) (nc, q.S()->Q, buf, Xz);
+          CXSPARSE_DNAME (_ipvec) (nc, q.S ()->Q, buf, Xz);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (octave_idx_type j = 0; j < nc; j++)
@@ -613,13 +613,13 @@
     }
   else
     {
-      SparseMatrix at = a.hermitian();
+      SparseMatrix at = a.hermitian ();
       SparseQR q (at, 3);
       if (! q.ok ())
-        return ComplexMatrix();
+        return ComplexMatrix ();
       x.resize(nc, b_nc);
-      Complex *vec = x.fortran_vec();
-      volatile octave_idx_type nbuf = (nc > q.S()->m2 ? nc : q.S()->m2);
+      Complex *vec = x.fortran_vec ();
+      volatile octave_idx_type nbuf = (nc > q.S ()->m2 ? nc : q.S ()->m2);
       OCTAVE_LOCAL_BUFFER (double, Xx, (b_nr > nc ? b_nr : nc));
       OCTAVE_LOCAL_BUFFER (double, Xz, (b_nr > nc ? b_nr : nc));
       OCTAVE_LOCAL_BUFFER (double, buf, nbuf);
@@ -636,48 +636,48 @@
             buf[j] = 0.;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_pvec) (q.S()->q, Xx, buf, nr);
+          CXSPARSE_DNAME (_pvec) (q.S ()->q, Xx, buf, nr);
 #else
-          CXSPARSE_DNAME (_pvec) (nr, q.S()->Q, Xx, buf);
+          CXSPARSE_DNAME (_pvec) (nr, q.S ()->Q, Xx, buf);
 #endif
-          CXSPARSE_DNAME (_utsolve) (q.N()->U, buf);
+          CXSPARSE_DNAME (_utsolve) (q.N ()->U, buf);
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = nr-1; j >= 0; j--)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-              CXSPARSE_DNAME (_happly) (q.N()->L, j, q.N()->B[j], buf);
+              CXSPARSE_DNAME (_happly) (q.N ()->L, j, q.N ()->B[j], buf);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_pvec) (q.S()->pinv, buf, Xx, nc);
+          CXSPARSE_DNAME (_pvec) (q.S ()->pinv, buf, Xx, nc);
 #else
-          CXSPARSE_DNAME (_pvec) (nc, q.S()->Pinv, buf, Xx);
+          CXSPARSE_DNAME (_pvec) (nc, q.S ()->Pinv, buf, Xx);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (octave_idx_type j = nr; j < nbuf; j++)
             buf[j] = 0.;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_pvec) (q.S()->q, Xz, buf, nr);
+          CXSPARSE_DNAME (_pvec) (q.S ()->q, Xz, buf, nr);
 #else
-          CXSPARSE_DNAME (_pvec) (nr, q.S()->Q, Xz, buf);
+          CXSPARSE_DNAME (_pvec) (nr, q.S ()->Q, Xz, buf);
 #endif
-          CXSPARSE_DNAME (_utsolve) (q.N()->U, buf);
+          CXSPARSE_DNAME (_utsolve) (q.N ()->U, buf);
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = nr-1; j >= 0; j--)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-              CXSPARSE_DNAME (_happly) (q.N()->L, j, q.N()->B[j], buf);
+              CXSPARSE_DNAME (_happly) (q.N ()->L, j, q.N ()->B[j], buf);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_pvec) (q.S()->pinv, buf, Xz, nc);
+          CXSPARSE_DNAME (_pvec) (q.S ()->pinv, buf, Xz, nc);
 #else
-          CXSPARSE_DNAME (_pvec) (nc, q.S()->Pinv, buf, Xz);
+          CXSPARSE_DNAME (_pvec) (nc, q.S ()->Pinv, buf, Xz);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (octave_idx_type j = 0; j < nc; j++)
@@ -697,10 +697,10 @@
 {
   info = -1;
 #ifdef HAVE_CXSPARSE
-  octave_idx_type nr = a.rows();
-  octave_idx_type nc = a.cols();
-  octave_idx_type b_nr = b.rows();
-  octave_idx_type b_nc = b.cols();
+  octave_idx_type nr = a.rows ();
+  octave_idx_type nc = a.cols ();
+  octave_idx_type b_nr = b.rows ();
+  octave_idx_type b_nc = b.cols ();
   SparseComplexMatrix x;
   volatile octave_idx_type ii, x_nz;
 
@@ -713,14 +713,14 @@
     {
       SparseQR q (a, 3);
       if (! q.ok ())
-        return SparseComplexMatrix();
-      x = SparseComplexMatrix (nc, b_nc, b.nnz());
+        return SparseComplexMatrix ();
+      x = SparseComplexMatrix (nc, b_nc, b.nnz ());
       x.xcidx(0) = 0;
-      x_nz = b.nnz();
+      x_nz = b.nnz ();
       ii = 0;
       OCTAVE_LOCAL_BUFFER (double, Xx, (b_nr > nc ? b_nr : nc));
       OCTAVE_LOCAL_BUFFER (double, Xz, (b_nr > nc ? b_nr : nc));
-      OCTAVE_LOCAL_BUFFER (double, buf, q.S()->m2);
+      OCTAVE_LOCAL_BUFFER (double, buf, q.S ()->m2);
       for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
         {
           octave_quit ();
@@ -730,52 +730,52 @@
               Xx[j] = std::real (c);
               Xz[j] = std::imag (c);
             }
-          for (octave_idx_type j = nr; j < q.S()->m2; j++)
+          for (octave_idx_type j = nr; j < q.S ()->m2; j++)
             buf[j] = 0.;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_ipvec) (q.S()->pinv, Xx, buf, nr);
+          CXSPARSE_DNAME (_ipvec) (q.S ()->pinv, Xx, buf, nr);
 #else
-          CXSPARSE_DNAME (_ipvec) (nr, q.S()->Pinv, Xx, buf);
+          CXSPARSE_DNAME (_ipvec) (nr, q.S ()->Pinv, Xx, buf);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = 0; j < nc; j++)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-              CXSPARSE_DNAME (_happly) (q.N()->L, j, q.N()->B[j], buf);
+              CXSPARSE_DNAME (_happly) (q.N ()->L, j, q.N ()->B[j], buf);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-          CXSPARSE_DNAME (_usolve) (q.N()->U, buf);
+          CXSPARSE_DNAME (_usolve) (q.N ()->U, buf);
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_ipvec) (q.S()->q, buf, Xx, nc);
+          CXSPARSE_DNAME (_ipvec) (q.S ()->q, buf, Xx, nc);
 #else
-          CXSPARSE_DNAME (_ipvec) (nc, q.S()->Q, buf, Xx);
+          CXSPARSE_DNAME (_ipvec) (nc, q.S ()->Q, buf, Xx);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-          for (octave_idx_type j = nr; j < q.S()->m2; j++)
+          for (octave_idx_type j = nr; j < q.S ()->m2; j++)
             buf[j] = 0.;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_ipvec) (q.S()->pinv, Xz, buf, nr);
+          CXSPARSE_DNAME (_ipvec) (q.S ()->pinv, Xz, buf, nr);
 #else
-          CXSPARSE_DNAME (_ipvec) (nr, q.S()->Pinv, Xz, buf);
+          CXSPARSE_DNAME (_ipvec) (nr, q.S ()->Pinv, Xz, buf);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = 0; j < nc; j++)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-              CXSPARSE_DNAME (_happly) (q.N()->L, j, q.N()->B[j], buf);
+              CXSPARSE_DNAME (_happly) (q.N ()->L, j, q.N ()->B[j], buf);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-          CXSPARSE_DNAME (_usolve) (q.N()->U, buf);
+          CXSPARSE_DNAME (_usolve) (q.N ()->U, buf);
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_ipvec) (q.S()->q, buf, Xz, nc);
+          CXSPARSE_DNAME (_ipvec) (q.S ()->q, buf, Xz, nc);
 #else
-          CXSPARSE_DNAME (_ipvec) (nc, q.S()->Q, buf, Xz);
+          CXSPARSE_DNAME (_ipvec) (nc, q.S ()->Q, buf, Xz);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 
@@ -802,15 +802,15 @@
     }
   else
     {
-      SparseMatrix at = a.hermitian();
+      SparseMatrix at = a.hermitian ();
       SparseQR q (at, 3);
       if (! q.ok ())
-        return SparseComplexMatrix();
-      x = SparseComplexMatrix (nc, b_nc, b.nnz());
+        return SparseComplexMatrix ();
+      x = SparseComplexMatrix (nc, b_nc, b.nnz ());
       x.xcidx(0) = 0;
-      x_nz = b.nnz();
+      x_nz = b.nnz ();
       ii = 0;
-      volatile octave_idx_type nbuf = (nc > q.S()->m2 ? nc : q.S()->m2);
+      volatile octave_idx_type nbuf = (nc > q.S ()->m2 ? nc : q.S ()->m2);
       OCTAVE_LOCAL_BUFFER (double, Xx, (b_nr > nc ? b_nr : nc));
       OCTAVE_LOCAL_BUFFER (double, Xz, (b_nr > nc ? b_nr : nc));
       OCTAVE_LOCAL_BUFFER (double, buf, nbuf);
@@ -827,48 +827,48 @@
             buf[j] = 0.;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_pvec) (q.S()->q, Xx, buf, nr);
+          CXSPARSE_DNAME (_pvec) (q.S ()->q, Xx, buf, nr);
 #else
-          CXSPARSE_DNAME (_pvec) (nr, q.S()->Q, Xx, buf);
+          CXSPARSE_DNAME (_pvec) (nr, q.S ()->Q, Xx, buf);
 #endif
-          CXSPARSE_DNAME (_utsolve) (q.N()->U, buf);
+          CXSPARSE_DNAME (_utsolve) (q.N ()->U, buf);
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = nr-1; j >= 0; j--)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-              CXSPARSE_DNAME (_happly) (q.N()->L, j, q.N()->B[j], buf);
+              CXSPARSE_DNAME (_happly) (q.N ()->L, j, q.N ()->B[j], buf);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_pvec) (q.S()->pinv, buf, Xx, nc);
+          CXSPARSE_DNAME (_pvec) (q.S ()->pinv, buf, Xx, nc);
 #else
-          CXSPARSE_DNAME (_pvec) (nc, q.S()->Pinv, buf, Xx);
+          CXSPARSE_DNAME (_pvec) (nc, q.S ()->Pinv, buf, Xx);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (octave_idx_type j = nr; j < nbuf; j++)
             buf[j] = 0.;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_pvec) (q.S()->q, Xz, buf, nr);
+          CXSPARSE_DNAME (_pvec) (q.S ()->q, Xz, buf, nr);
 #else
-          CXSPARSE_DNAME (_pvec) (nr, q.S()->Q, Xz, buf);
+          CXSPARSE_DNAME (_pvec) (nr, q.S ()->Q, Xz, buf);
 #endif
-          CXSPARSE_DNAME (_utsolve) (q.N()->U, buf);
+          CXSPARSE_DNAME (_utsolve) (q.N ()->U, buf);
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
           for (volatile octave_idx_type j = nr-1; j >= 0; j--)
             {
               octave_quit ();
               BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
-              CXSPARSE_DNAME (_happly) (q.N()->L, j, q.N()->B[j], buf);
+              CXSPARSE_DNAME (_happly) (q.N ()->L, j, q.N ()->B[j], buf);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
             }
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 #if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_DNAME (_pvec) (q.S()->pinv, buf, Xz, nc);
+          CXSPARSE_DNAME (_pvec) (q.S ()->pinv, buf, Xz, nc);
 #else
-          CXSPARSE_DNAME (_pvec) (nc, q.S()->Pinv, buf, Xz);
+          CXSPARSE_DNAME (_pvec) (nc, q.S ()->Pinv, buf, Xz);
 #endif
           END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 
--- a/liboctave/SparseQR.h
+++ b/liboctave/SparseQR.h
@@ -89,7 +89,7 @@
 
 public:
 
-  SparseQR (void) : rep (new SparseQR_rep (SparseMatrix(), 0)) { }
+  SparseQR (void) : rep (new SparseQR_rep (SparseMatrix (), 0)) { }
 
   SparseQR (const SparseMatrix& a, int order = 0) :
     rep (new SparseQR_rep (a, order)) { }
@@ -115,19 +115,19 @@
       return *this;
     }
 
-  bool ok (void) const { return rep->ok(); }
+  bool ok (void) const { return rep->ok (); }
 
-  SparseMatrix V (void) const { return rep->V(); }
+  SparseMatrix V (void) const { return rep->V (); }
 
-  ColumnVector Pinv (void) const { return rep->P(); }
+  ColumnVector Pinv (void) const { return rep->P (); }
 
-  ColumnVector P (void) const { return rep->P(); }
+  ColumnVector P (void) const { return rep->P (); }
 
   SparseMatrix R (const bool econ = false) const { return rep->R(econ); }
 
   Matrix C (const Matrix &b) const { return rep->C(b); }
 
-  Matrix Q (void) const { return rep->Q(); }
+  Matrix Q (void) const { return rep->Q (); }
 
   friend Matrix qrsolve (const SparseMatrix &a, const Matrix &b,
                          octave_idx_type &info);
--- a/liboctave/SparsedbleCHOL.cc
+++ b/liboctave/SparsedbleCHOL.cc
@@ -52,12 +52,12 @@
       if (typ == MatrixType::Upper)
         {
           rinv = r.inverse(mattype, info, rcond, true, false);
-          retval = rinv.transpose() * rinv;
+          retval = rinv.transpose () * rinv;
         }
       else if (typ == MatrixType::Lower)
         {
-          rinv = r.transpose().inverse(mattype, info, rcond, true, false);
-          retval = rinv.transpose() * rinv;
+          rinv = r.transpose ().inverse(mattype, info, rcond, true, false);
+          retval = rinv.transpose () * rinv;
         }
       else
         (*current_liboctave_error_handler)
--- a/liboctave/SparsedbleCHOL.h
+++ b/liboctave/SparsedbleCHOL.h
@@ -55,7 +55,7 @@
       return *this;
     }
 
-  SparseMatrix chol_matrix (void) const { return R(); }
+  SparseMatrix chol_matrix (void) const { return R (); }
 
   SparseMatrix L (void) const
   { return sparse_base_chol<SparseMatrix, double, SparseMatrix>:: L (); }
--- a/liboctave/SparsedbleLU.cc
+++ b/liboctave/SparsedbleLU.cc
@@ -57,7 +57,7 @@
   if (!xisnan (tmp))
     Control (UMFPACK_PRL) = tmp;
 
-  if (piv_thres.nelem() == 2)
+  if (piv_thres.nelem () == 2)
     {
       tmp = (piv_thres (0) > 1. ? 1. : piv_thres (0));
       if (!xisnan (tmp))
@@ -253,7 +253,7 @@
       if (!xisnan (tmp))
         Control (UMFPACK_PRL) = tmp;
 
-      if (piv_thres.nelem() == 2)
+      if (piv_thres.nelem () == 2)
         {
           tmp = (piv_thres (0) > 1. ? 1. : piv_thres (0));
           if (!xisnan (tmp))
--- a/liboctave/SparsedbleLU.h
+++ b/liboctave/SparsedbleLU.h
@@ -36,11 +36,11 @@
   SparseLU (void)
     : sparse_base_lu <SparseMatrix, double, SparseMatrix, double> () { }
 
-  SparseLU (const SparseMatrix& a, const Matrix& piv_thres = Matrix(),
+  SparseLU (const SparseMatrix& a, const Matrix& piv_thres = Matrix (),
             bool scale = false);
 
   SparseLU (const SparseMatrix& a, const ColumnVector& Qinit,
-            const Matrix& piv_thres = Matrix(), bool scale = false,
+            const Matrix& piv_thres = Matrix (), bool scale = false,
             bool FixedQ = false, double droptol = -1.,
             bool milu = false, bool udiag = false);
 
--- a/liboctave/base-lu.cc
+++ b/liboctave/base-lu.cc
@@ -111,7 +111,7 @@
 base_lu <lu_type> :: Y (void) const
 {
   if (! packed ())
-    (*current_liboctave_error_handler) ("lu: Y() not implemented for unpacked form");
+    (*current_liboctave_error_handler) ("lu: Y () not implemented for unpacked form");
   return a_fact;
 }
 
@@ -128,7 +128,7 @@
       for (octave_idx_type i = 0; i < a_nr; i++)
         pvt.xelem (i) = i;
 
-      for (octave_idx_type i = 0; i < ipvt.length(); i++)
+      for (octave_idx_type i = 0; i < ipvt.length (); i++)
         {
           octave_idx_type k = ipvt.xelem (i);
 
--- a/liboctave/boolMatrix.h
+++ b/liboctave/boolMatrix.h
@@ -84,14 +84,10 @@
   friend std::istream& operator >> (std::istream& is, Matrix& a);
 #endif
 
-  void resize (octave_idx_type nr, octave_idx_type nc,
-               bool rfv = resize_fill_value ())
+  void resize (octave_idx_type nr, octave_idx_type nc, bool rfv = false)
   {
     Array<bool>::resize (dim_vector (nr, nc), rfv);
   }
-
-  static bool resize_fill_value (void) { return false; }
-
 };
 
 MM_BOOL_OP_DECLS (boolMatrix, boolMatrix, OCTAVE_API)
--- a/liboctave/boolNDArray.cc
+++ b/liboctave/boolNDArray.cc
@@ -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
+++ b/liboctave/boolNDArray.h
@@ -96,13 +96,12 @@
   // friend std::ostream& operator << (std::ostream& os, const NDArray& a);
   // friend std::istream& operator >> (std::istream& is, NDArray& a);
 
-  static bool resize_fill_value (void) { return false; }
-
   //  bool all_elements_are_real (void) const;
   //  bool all_integers (double& max_val, double& min_val) const;
 
   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/caseless-str.h
+++ b/liboctave/caseless-str.h
@@ -23,6 +23,7 @@
 #if !defined (octave_caseless_str_h)
 #define octave_caseless_str_h 1
 
+#include <cctype>
 #include <string>
 
 class caseless_str : public std::string
--- a/liboctave/chMatrix.h
+++ b/liboctave/chMatrix.h
@@ -86,8 +86,7 @@
 
   charMatrix extract (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const;
 
-  void resize (octave_idx_type nr, octave_idx_type nc,
-               char rfv = resize_fill_value ())
+  void resize (octave_idx_type nr, octave_idx_type nc, char rfv = 0)
   {
     Array<char>::resize (dim_vector (nr, nc), rfv);
   }
@@ -103,9 +102,6 @@
   friend std::ostream& operator << (std::ostream& os, const Matrix& a);
   friend std::istream& operator >> (std::istream& is, Matrix& a);
 #endif
-
-  static char resize_fill_value (void) { return '\0'; }
-
 };
 
 MS_CMP_OP_DECLS (charMatrix, char, OCTAVE_API)
--- a/liboctave/chNDArray.cc
+++ b/liboctave/chNDArray.cc
@@ -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
+++ b/liboctave/chNDArray.h
@@ -92,10 +92,9 @@
   // friend std::ostream& operator << (std::ostream& os, const charNDArray& a);
   // friend std::istream& operator >> (std::istream& is, charNDArray& a);
 
-  static char resize_fill_value (void) { return '\0'; }
-
   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/cmd-hist.cc
+++ b/liboctave/cmd-hist.cc
@@ -165,7 +165,7 @@
 
   if (history_control & HC_IGNDUPS)
     {
-      if (retval.length() > 0)
+      if (retval.length () > 0)
         retval.append (":");
 
       retval.append ("ignoredups");
@@ -173,7 +173,7 @@
 
   if (history_control & HC_ERASEDUPS)
     {
-      if (retval.length() > 0)
+      if (retval.length () > 0)
         retval.append (":");
 
       retval.append ("erasedups");
--- a/liboctave/dColVector.cc
+++ b/liboctave/dColVector.cc
@@ -143,7 +143,7 @@
 RowVector
 ColumnVector::transpose (void) const
 {
-  return MArray<double>::transpose();
+  return MArray<double>::transpose ();
 }
 
 ColumnVector
@@ -308,7 +308,7 @@
 std::istream&
 operator >> (std::istream& is, ColumnVector& a)
 {
-  octave_idx_type len = a.length();
+  octave_idx_type len = a.length ();
 
   if (len > 0)
     {
--- a/liboctave/dColVector.h
+++ b/liboctave/dColVector.h
@@ -99,8 +99,7 @@
   friend OCTAVE_API std::ostream& operator << (std::ostream& os, const ColumnVector& a);
   friend OCTAVE_API std::istream& operator >> (std::istream& is, ColumnVector& a);
 
-  void resize (octave_idx_type n,
-               const double& rfv = Array<double>::resize_fill_value ())
+  void resize (octave_idx_type n, const double& rfv = 0)
   {
     Array<double>::resize (dim_vector (n, 1), rfv);
   }
--- a/liboctave/dDiagMatrix.h
+++ b/liboctave/dDiagMatrix.h
@@ -74,7 +74,7 @@
   DiagMatrix& fill (const ColumnVector& a, octave_idx_type beg);
   DiagMatrix& fill (const RowVector& a, octave_idx_type beg);
 
-  DiagMatrix transpose (void) const { return MDiagArray2<double>::transpose(); }
+  DiagMatrix transpose (void) const { return MDiagArray2<double>::transpose (); }
   DiagMatrix abs (void) const;
 
   friend OCTAVE_API DiagMatrix real (const ComplexDiagMatrix& a);
--- a/liboctave/dMatrix.cc
+++ b/liboctave/dMatrix.cc
@@ -763,7 +763,7 @@
       // Calculate the norm of the matrix, for later use.
       double anorm = 0;
       if (calc_cond)
-        anorm = retval.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+        anorm = retval.abs ().sum ().row(static_cast<octave_idx_type>(0)).max ();
 
       F77_XFCN (dgetrf, DGETRF, (nc, nc, tmp_data, nr, pipvt, info));
 
@@ -802,7 +802,7 @@
         }
 
       if (info != 0)
-        mattype.mark_as_rectangular();
+        mattype.mark_as_rectangular ();
     }
 
   return retval;
@@ -1461,8 +1461,8 @@
             {
               octave_idx_type info = 0;
               char job = 'L';
-              anorm = atmp.abs().sum().
-                row(static_cast<octave_idx_type>(0)).max();
+              anorm = atmp.abs ().sum ().
+                row(static_cast<octave_idx_type>(0)).max ();
 
               F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
                                          tmp_data, nr, info
@@ -1499,8 +1499,8 @@
               octave_idx_type *pipvt = ipvt.fortran_vec ();
 
               if(anorm < 0.)
-                anorm = atmp.abs().sum().
-                  row(static_cast<octave_idx_type>(0)).max();
+                anorm = atmp.abs ().sum ().
+                  row(static_cast<octave_idx_type>(0)).max ();
 
               Array<double> z (dim_vector (4 * nc, 1));
               double *pz = z.fortran_vec ();
@@ -1762,7 +1762,7 @@
           char job = 'L';
           Matrix atmp = *this;
           double *tmp_data = atmp.fortran_vec ();
-          anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+          anorm = atmp.abs ().sum ().row(static_cast<octave_idx_type>(0)).max ();
 
           F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
                                      tmp_data, nr, info
@@ -1818,7 +1818,7 @@
 
                   F77_XFCN (dpotrs, DPOTRS, (F77_CONST_CHAR_ARG2 (&job, 1),
                                              nr, b_nc, tmp_data, nr,
-                                             result, b.rows(), info
+                                             result, b.rows (), info
                                              F77_CHAR_ARG_LEN (1)));
                 }
               else
@@ -1839,7 +1839,7 @@
           Matrix atmp = *this;
           double *tmp_data = atmp.fortran_vec ();
           if(anorm < 0.)
-            anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+            anorm = atmp.abs ().sum ().row(static_cast<octave_idx_type>(0)).max ();
 
           Array<double> z (dim_vector (4 * nc, 1));
           double *pz = z.fortran_vec ();
@@ -1902,7 +1902,7 @@
                   char job = 'N';
                   F77_XFCN (dgetrs, DGETRS, (F77_CONST_CHAR_ARG2 (&job, 1),
                                              nr, b_nc, tmp_data, nr,
-                                             pipvt, result, b.rows(), info
+                                             pipvt, result, b.rows (), info
                                              F77_CHAR_ARG_LEN (1)));
                 }
               else
@@ -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
 {
@@ -3113,26 +3130,28 @@
 
 // matrix by matrix -> matrix operations
 
-/* Simple Dot Product, Matrix-Vector and Matrix-Matrix Unit tests
-%!assert([1 2 3] * [ 4 ; 5 ; 6], 32, 1e-14)
-%!assert([1 2 ; 3 4 ] * [5 ; 6], [17 ; 39 ], 1e-14)
-%!assert([1 2 ; 3 4 ] * [5 6 ; 7 8], [19 22; 43 50], 1e-14)
-*/
-
-/* Test some simple identities
+/*
+
+## Simple Dot Product, Matrix-Vector and Matrix-Matrix Unit tests
+%!assert ([1 2 3] * [ 4 ; 5 ; 6], 32, 1e-14)
+%!assert ([1 2 ; 3 4 ] * [5 ; 6], [17 ; 39 ], 1e-14)
+%!assert ([1 2 ; 3 4 ] * [5 6 ; 7 8], [19 22; 43 50], 1e-14)
+
+## Test some simple identities
 %!shared M, cv, rv, Mt, rvt
-%! M = randn(10,10)+100*eye(10,10);
+%! M = randn (10,10) + 100*eye (10,10);
 %! Mt = M';
-%! cv = randn(10,1);
-%! rv = randn(1,10);
+%! cv = randn (10,1);
+%! rv = randn (1,10);
 %! rvt = rv';
-%!assert([M*cv,M*cv],M*[cv,cv],1e-13)
-%!assert([M'*cv,M'*cv],M'*[cv,cv],1e-13)
-%!assert([rv*M;rv*M],[rv;rv]*M,1e-13)
-%!assert([rv*M';rv*M'],[rv;rv]*M',1e-13)
-%!assert(2*rv*cv,[rv,rv]*[cv;cv],1e-13)
-%!assert(M'\cv,Mt\cv,1e-14)
-%!assert(M'\rv',Mt\rvt,1e-14)
+%!assert ([M*cv,M*cv], M*[cv,cv], 1e-13)
+%!assert ([M'*cv,M'*cv], M'*[cv,cv], 1e-13)
+%!assert ([rv*M;rv*M], [rv;rv]*M, 1e-13)
+%!assert ([rv*M';rv*M'], [rv;rv]*M', 1e-13)
+%!assert (2*rv*cv, [rv,rv]*[cv;cv], 1e-13)
+%!assert (M'\cv, Mt\cv, 1e-14)
+%!assert (M'\rv', Mt\rvt, 1e-14)
+
 */
 
 static inline char
--- a/liboctave/dMatrix.h
+++ b/liboctave/dMatrix.h
@@ -125,8 +125,7 @@
 
   ColumnVector column (octave_idx_type i) const;
 
-  void resize (octave_idx_type nr, octave_idx_type nc,
-               double rfv = resize_fill_value ())
+  void resize (octave_idx_type nr, octave_idx_type nc, double rfv = 0)
   {
     MArray<double>::resize (dim_vector (nr, nc), rfv);
   }
@@ -316,6 +315,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;
 
@@ -332,8 +333,6 @@
 
   friend OCTAVE_API std::ostream& operator << (std::ostream& os, const Matrix& a);
   friend OCTAVE_API std::istream& operator >> (std::istream& is, Matrix& a);
-
-  static double resize_fill_value (void) { return 0; }
 };
 
 // Publish externally used friend functions.
--- a/liboctave/dNDArray.cc
+++ b/liboctave/dNDArray.cc
@@ -160,7 +160,7 @@
 ComplexNDArray
 NDArray::fourier2d (void) const
 {
-  dim_vector dv = dims();
+  dim_vector dv = dims ();
   if (dv.length () < 2)
     return ComplexNDArray ();
 
@@ -168,7 +168,7 @@
   const double *in = fortran_vec ();
   ComplexNDArray retval (dv);
   Complex *out = retval.fortran_vec ();
-  octave_idx_type howmany = numel() / dv(0) / dv(1);
+  octave_idx_type howmany = numel () / dv(0) / dv(1);
   octave_idx_type dist = dv(0) * dv(1);
 
   for (octave_idx_type i=0; i < howmany; i++)
@@ -180,14 +180,14 @@
 ComplexNDArray
 NDArray::ifourier2d (void) const
 {
-  dim_vector dv = dims();
+  dim_vector dv = dims ();
   if (dv.length () < 2)
     return ComplexNDArray ();
 
   dim_vector dv2(dv(0), dv(1));
   ComplexNDArray retval (*this);
   Complex *out = retval.fortran_vec ();
-  octave_idx_type howmany = numel() / dv(0) / dv(1);
+  octave_idx_type howmany = numel () / dv(0) / dv(1);
   octave_idx_type dist = dv(0) * dv(1);
 
   for (octave_idx_type i=0; i < howmany; i++)
@@ -286,7 +286,7 @@
           F77_FUNC (zfftf, ZFFTF) (npts, tmp, pwsave);
 
           for (octave_idx_type i = 0; i < npts; i++)
-            retval ((i + k*npts)*stride + j*dist) = tmp[i];
+            retval((i + k*npts)*stride + j*dist) = tmp[i];
         }
     }
 
@@ -333,7 +333,7 @@
           F77_FUNC (zfftb, ZFFTB) (npts, tmp, pwsave);
 
           for (octave_idx_type i = 0; i < npts; i++)
-            retval ((i + k*npts)*stride + j*dist) = tmp[i] /
+            retval((i + k*npts)*stride + j*dist) = tmp[i] /
               static_cast<double> (npts);
         }
     }
@@ -344,7 +344,7 @@
 ComplexNDArray
 NDArray::fourier2d (void) const
 {
-  dim_vector dv = dims();
+  dim_vector dv = dims ();
   dim_vector dv2 (dv(0), dv(1));
   int rank = 2;
   ComplexNDArray retval (*this);
@@ -374,12 +374,12 @@
               octave_quit ();
 
               for (octave_idx_type l = 0; l < npts; l++)
-                prow[l] = retval ((l + k*npts)*stride + j*dist);
+                prow[l] = retval((l + k*npts)*stride + j*dist);
 
               F77_FUNC (zfftf, ZFFTF) (npts, prow, pwsave);
 
               for (octave_idx_type l = 0; l < npts; l++)
-                retval ((l + k*npts)*stride + j*dist) = prow[l];
+                retval((l + k*npts)*stride + j*dist) = prow[l];
             }
         }
 
@@ -392,7 +392,7 @@
 ComplexNDArray
 NDArray::ifourier2d (void) const
 {
-  dim_vector dv = dims();
+  dim_vector dv = dims ();
   dim_vector dv2 (dv(0), dv(1));
   int rank = 2;
   ComplexNDArray retval (*this);
@@ -422,12 +422,12 @@
               octave_quit ();
 
               for (octave_idx_type l = 0; l < npts; l++)
-                prow[l] = retval ((l + k*npts)*stride + j*dist);
+                prow[l] = retval((l + k*npts)*stride + j*dist);
 
               F77_FUNC (zfftb, ZFFTB) (npts, prow, pwsave);
 
               for (octave_idx_type l = 0; l < npts; l++)
-                retval ((l + k*npts)*stride + j*dist) = prow[l] /
+                retval((l + k*npts)*stride + j*dist) = prow[l] /
                   static_cast<double> (npts);
             }
         }
@@ -470,12 +470,12 @@
               octave_quit ();
 
               for (octave_idx_type l = 0; l < npts; l++)
-                prow[l] = retval ((l + k*npts)*stride + j*dist);
+                prow[l] = retval((l + k*npts)*stride + j*dist);
 
               F77_FUNC (zfftf, ZFFTF) (npts, prow, pwsave);
 
               for (octave_idx_type l = 0; l < npts; l++)
-                retval ((l + k*npts)*stride + j*dist) = prow[l];
+                retval((l + k*npts)*stride + j*dist) = prow[l];
             }
         }
 
@@ -517,12 +517,12 @@
               octave_quit ();
 
               for (octave_idx_type l = 0; l < npts; l++)
-                prow[l] = retval ((l + k*npts)*stride + j*dist);
+                prow[l] = retval((l + k*npts)*stride + j*dist);
 
               F77_FUNC (zfftb, ZFFTB) (npts, prow, pwsave);
 
               for (octave_idx_type l = 0; l < npts; l++)
-                retval ((l + k*npts)*stride + j*dist) = prow[l] /
+                retval((l + k*npts)*stride + j*dist) = prow[l] /
                   static_cast<double> (npts);
             }
         }
@@ -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
+++ b/liboctave/dNDArray.h
@@ -150,9 +150,9 @@
   friend OCTAVE_API std::ostream& operator << (std::ostream& os, const NDArray& a);
   friend OCTAVE_API std::istream& operator >> (std::istream& is, NDArray& a);
 
-  static double resize_fill_value (void) { return 0; }
+  NDArray diag (octave_idx_type k = 0) const;
 
-  NDArray diag (octave_idx_type k = 0) const;
+  NDArray diag (octave_idx_type m, octave_idx_type n) const;
 
   NDArray& changesign (void)
     {
--- a/liboctave/dRowVector.cc
+++ b/liboctave/dRowVector.cc
@@ -146,7 +146,7 @@
 ColumnVector
 RowVector::transpose (void) const
 {
-  return MArray<double>::transpose();
+  return MArray<double>::transpose ();
 }
 
 RowVector
@@ -271,7 +271,7 @@
 std::istream&
 operator >> (std::istream& is, RowVector& a)
 {
-  octave_idx_type len = a.length();
+  octave_idx_type len = a.length ();
 
   if (len > 0)
     {
--- a/liboctave/dRowVector.h
+++ b/liboctave/dRowVector.h
@@ -92,8 +92,7 @@
   friend OCTAVE_API std::ostream& operator << (std::ostream& os, const RowVector& a);
   friend OCTAVE_API std::istream& operator >> (std::istream& is, RowVector& a);
 
-  void resize (octave_idx_type n,
-               const double& rfv = Array<double>::resize_fill_value ())
+  void resize (octave_idx_type n, const double& rfv = 0)
   {
     Array<double>::resize (dim_vector (1, n), rfv);
   }
--- a/liboctave/dSparse.cc
+++ b/liboctave/dSparse.cc
@@ -719,7 +719,7 @@
 {
   SparseMatrix r;
 
-  if ((x.rows() == y.rows()) && (x.cols() == y.cols()))
+  if ((x.rows () == y.rows ()) && (x.cols () == y.cols ()))
     {
       octave_idx_type x_nr = x.rows ();
       octave_idx_type x_nc = x.cols ();
@@ -837,12 +837,12 @@
           typ == MatrixType::Permuted_Diagonal)
         {
           if (typ == MatrixType::Permuted_Diagonal)
-            retval = transpose();
+            retval = transpose ();
           else
             retval = *this;
 
           // Force make_unique to be called
-          double *v = retval.data();
+          double *v = retval.data ();
 
           if (calccond)
             {
@@ -1022,7 +1022,7 @@
               OCTAVE_LOCAL_BUFFER (double, work, nr);
               OCTAVE_LOCAL_BUFFER (octave_idx_type, rperm, nr);
 
-              octave_idx_type *perm = mattyp.triangular_perm();
+              octave_idx_type *perm = mattyp.triangular_perm ();
               if (typ == MatrixType::Permuted_Upper)
                 {
                   for (octave_idx_type i = 0; i < nr; i++)
@@ -1142,7 +1142,7 @@
   return retval;
 
  inverse_singular:
-  return SparseMatrix();
+  return SparseMatrix ();
 }
 
 SparseMatrix
@@ -1158,26 +1158,26 @@
   if (typ == MatrixType::Diagonal || typ == MatrixType::Permuted_Diagonal)
     ret = dinverse (mattype, info, rcond, true, calc_cond);
   else if (typ == MatrixType::Upper || typ == MatrixType::Permuted_Upper)
-    ret = tinverse (mattype, info, rcond, true, calc_cond).transpose();
+    ret = tinverse (mattype, info, rcond, true, calc_cond).transpose ();
   else if (typ == MatrixType::Lower || typ == MatrixType::Permuted_Lower)
     {
-      MatrixType newtype = mattype.transpose();
-      ret = transpose().tinverse (newtype, info, rcond, true, calc_cond);
+      MatrixType newtype = mattype.transpose ();
+      ret = transpose ().tinverse (newtype, info, rcond, true, calc_cond);
     }
   else
     {
-      if (mattype.is_hermitian())
+      if (mattype.is_hermitian ())
         {
           MatrixType tmp_typ (MatrixType::Upper);
           SparseCHOL fact (*this, info, false);
-          rcond = fact.rcond();
+          rcond = fact.rcond ();
           if (info == 0)
             {
               double rcond2;
-              SparseMatrix Q = fact.Q();
-              SparseMatrix InvL = fact.L().transpose().tinverse(tmp_typ,
+              SparseMatrix Q = fact.Q ();
+              SparseMatrix InvL = fact.L ().transpose ().tinverse(tmp_typ,
                                            info, rcond2, true, false);
-              ret = Q * InvL.transpose() * InvL * Q.transpose();
+              ret = Q * InvL.transpose () * InvL * Q.transpose ();
             }
           else
             {
@@ -1187,22 +1187,22 @@
             }
         }
 
-      if (!mattype.is_hermitian())
+      if (!mattype.is_hermitian ())
         {
-          octave_idx_type n = rows();
+          octave_idx_type n = rows ();
           ColumnVector Qinit(n);
           for (octave_idx_type i = 0; i < n; i++)
             Qinit(i) = i;
 
           MatrixType tmp_typ (MatrixType::Upper);
-          SparseLU fact (*this, Qinit, Matrix(), false, false);
-          rcond = fact.rcond();
+          SparseLU fact (*this, Qinit, Matrix (), false, false);
+          rcond = fact.rcond ();
           double rcond2;
-          SparseMatrix InvL = fact.L().transpose().tinverse(tmp_typ,
+          SparseMatrix InvL = fact.L ().transpose ().tinverse(tmp_typ,
                                            info, rcond2, true, false);
-          SparseMatrix InvU = fact.U().tinverse(tmp_typ, info, rcond2,
-                                           true, false).transpose();
-          ret = fact.Pc().transpose() * InvU * InvL * fact.Pr();
+          SparseMatrix InvU = fact.U ().tinverse(tmp_typ, info, rcond2,
+                                           true, false).transpose ();
+          ret = fact.Pc ().transpose () * InvU * InvL * fact.Pr ();
         }
     }
 
@@ -1366,13 +1366,13 @@
       if (typ == MatrixType::Diagonal ||
           typ == MatrixType::Permuted_Diagonal)
         {
-          retval.resize (nc, b.cols(), 0.);
+          retval.resize (nc, b.cols (), 0.);
           if (typ == MatrixType::Diagonal)
-            for (octave_idx_type j = 0; j < b.cols(); j++)
+            for (octave_idx_type j = 0; j < b.cols (); j++)
               for (octave_idx_type i = 0; i < nm; i++)
                 retval(i,j) = b(i,j) / data (i);
           else
-            for (octave_idx_type j = 0; j < b.cols(); j++)
+            for (octave_idx_type j = 0; j < b.cols (); j++)
               for (octave_idx_type k = 0; k < nc; k++)
                 for (octave_idx_type i = cidx(k); i < cidx(k+1); i++)
                   retval(k,j) = b(ridx(i),j) / data (i);
@@ -1516,13 +1516,13 @@
       if (typ == MatrixType::Diagonal ||
           typ == MatrixType::Permuted_Diagonal)
         {
-          retval.resize (nc, b.cols(), 0);
+          retval.resize (nc, b.cols (), 0);
           if (typ == MatrixType::Diagonal)
-            for (octave_idx_type j = 0; j < b.cols(); j++)
+            for (octave_idx_type j = 0; j < b.cols (); j++)
                 for (octave_idx_type i = 0; i < nm; i++)
                   retval(i,j) = b(i,j) / data (i);
           else
-            for (octave_idx_type j = 0; j < b.cols(); j++)
+            for (octave_idx_type j = 0; j < b.cols (); j++)
               for (octave_idx_type k = 0; k < nc; k++)
                 for (octave_idx_type i = cidx(k); i < cidx(k+1); i++)
                   retval(k,j) = b(ridx(i),j) / data (i);
@@ -1583,7 +1583,7 @@
           retval.xcidx(0) = 0;
           octave_idx_type ii = 0;
           if (typ == MatrixType::Diagonal)
-            for (octave_idx_type j = 0; j < b.cols(); j++)
+            for (octave_idx_type j = 0; j < b.cols (); j++)
               {
                 for (octave_idx_type i = b.cidx(j); i < b.cidx(j+1); i++)
                   {
@@ -1595,7 +1595,7 @@
                 retval.xcidx(j+1) = ii;
               }
           else
-            for (octave_idx_type j = 0; j < b.cols(); j++)
+            for (octave_idx_type j = 0; j < b.cols (); j++)
               {
                 for (octave_idx_type l = 0; l < nc; l++)
                   for (octave_idx_type i = cidx(l); i < cidx(l+1); i++)
@@ -2783,7 +2783,7 @@
                     }
 
                   for (octave_idx_type i = 0; i < nc; i++)
-                    retval (i, j) = work[i];
+                    retval(i, j) = work[i];
                 }
 
               if (calc_cond)
@@ -3349,7 +3349,7 @@
                     }
 
                   for (octave_idx_type i = 0; i < nc; i++)
-                    retval (i, j) = cwork[i];
+                    retval(i, j) = cwork[i];
                 }
 
               if (calc_cond)
@@ -3889,12 +3889,12 @@
                   }
             }
 
-          octave_idx_type b_nc = b.cols();
+          octave_idx_type b_nc = b.cols ();
           retval = b;
           double *result = retval.fortran_vec ();
 
           F77_XFCN (dptsv, DPTSV, (nr, b_nc, D, DL, result,
-                                   b.rows(), err));
+                                   b.rows (), err));
 
           if (err != 0)
             {
@@ -3946,12 +3946,12 @@
                   }
             }
 
-          octave_idx_type b_nc = b.cols();
+          octave_idx_type b_nc = b.cols ();
           retval = b;
           double *result = retval.fortran_vec ();
 
           F77_XFCN (dgtsv, DGTSV, (nr, b_nc, DL, D, DU, result,
-                                   b.rows(), err));
+                                   b.rows (), err));
 
           if (err != 0)
             {
@@ -4188,7 +4188,7 @@
             }
 
           octave_idx_type b_nr = b.rows ();
-          octave_idx_type b_nc = b.cols();
+          octave_idx_type b_nc = b.cols ();
           rcond = 1.;
 
           retval = b;
@@ -4245,8 +4245,8 @@
                   }
             }
 
-          octave_idx_type b_nr = b.rows();
-          octave_idx_type b_nc = b.cols();
+          octave_idx_type b_nr = b.rows ();
+          octave_idx_type b_nc = b.cols ();
           rcond = 1.;
 
           retval = b;
@@ -4506,7 +4506,7 @@
           // Calculate the norm of the matrix, for later use.
           double anorm;
           if (calc_cond)
-            anorm = m_band.abs().sum().row(0).max();
+            anorm = m_band.abs ().sum ().row(0).max ();
 
           char job = 'L';
           F77_XFCN (dpbtrf, DPBTRF, (F77_CONST_CHAR_ARG2 (&job, 1),
@@ -4570,7 +4570,7 @@
                   F77_XFCN (dpbtrs, DPBTRS,
                             (F77_CONST_CHAR_ARG2 (&job, 1),
                              nr, n_lower, b_nc, tmp_data,
-                             ldm, result, b.rows(), err
+                             ldm, result, b.rows (), err
                              F77_CHAR_ARG_LEN (1)));
 
                   if (err != 0)
@@ -4693,7 +4693,7 @@
                   F77_XFCN (dgbtrs, DGBTRS,
                             (F77_CONST_CHAR_ARG2 (&job, 1),
                              nr, n_lower, n_upper, b_nc, tmp_data,
-                             ldm, pipvt, result, b.rows(), err
+                             ldm, pipvt, result, b.rows (), err
                              F77_CHAR_ARG_LEN (1)));
                 }
             }
@@ -4756,7 +4756,7 @@
           // Calculate the norm of the matrix, for later use.
           double anorm;
           if (calc_cond)
-            anorm = m_band.abs().sum().row(0).max();
+            anorm = m_band.abs ().sum ().row(0).max ();
 
           char job = 'L';
           F77_XFCN (dpbtrf, DPBTRF, (F77_CONST_CHAR_ARG2 (&job, 1),
@@ -5074,7 +5074,7 @@
           // Calculate the norm of the matrix, for later use.
           double anorm;
           if (calc_cond)
-            anorm = m_band.abs().sum().row(0).max();
+            anorm = m_band.abs ().sum ().row(0).max ();
 
           char job = 'L';
           F77_XFCN (dpbtrf, DPBTRF, (F77_CONST_CHAR_ARG2 (&job, 1),
@@ -5164,7 +5164,7 @@
                       F77_XFCN (dpbtrs, DPBTRS,
                                 (F77_CONST_CHAR_ARG2 (&job, 1),
                                  nr, n_lower, 1, tmp_data,
-                                 ldm, Bz, b.rows(), err
+                                 ldm, Bz, b.rows (), err
                                  F77_CHAR_ARG_LEN (1)));
 
                       if (err != 0)
@@ -5176,7 +5176,7 @@
                         }
 
                       for (octave_idx_type i = 0; i < b_nr; i++)
-                        retval (i, j) = Complex (Bx[i], Bz[i]);
+                        retval(i, j) = Complex (Bx[i], Bz[i]);
                     }
                 }
             }
@@ -5310,7 +5310,7 @@
                                  F77_CHAR_ARG_LEN (1)));
 
                       for (octave_idx_type i = 0; i < nr; i++)
-                        retval (i, j) = Complex (Bx[i], Bz[i]);
+                        retval(i, j) = Complex (Bx[i], Bz[i]);
                     }
                 }
             }
@@ -5373,7 +5373,7 @@
           // Calculate the norm of the matrix, for later use.
           double anorm;
           if (calc_cond)
-            anorm = m_band.abs().sum().row(0).max();
+            anorm = m_band.abs ().sum ().row(0).max ();
 
           char job = 'L';
           F77_XFCN (dpbtrf, DPBTRF, (F77_CONST_CHAR_ARG2 (&job, 1),
@@ -5853,9 +5853,9 @@
           A->nrow = nr;
           A->ncol = nc;
 
-          A->p = cidx();
-          A->i = ridx();
-          A->nzmax = nnz();
+          A->p = cidx ();
+          A->i = ridx ();
+          A->nzmax = nnz ();
           A->packed = true;
           A->sorted = true;
           A->nz = 0;
@@ -5871,21 +5871,21 @@
           if (nr < 1)
             A->x = &dummy;
           else
-            A->x = data();
+            A->x = data ();
 
           cholmod_dense Bstore;
           cholmod_dense *B = &Bstore;
-          B->nrow = b.rows();
-          B->ncol = b.cols();
+          B->nrow = b.rows ();
+          B->ncol = b.cols ();
           B->d = B->nrow;
           B->nzmax = B->nrow * B->ncol;
           B->dtype = CHOLMOD_DOUBLE;
           B->xtype = CHOLMOD_REAL;
-          if (nc < 1 || b.cols() < 1)
+          if (nc < 1 || b.cols () < 1)
             B->x = &dummy;
           else
             // We won't alter it, honest :-)
-            B->x = const_cast<double *>(b.fortran_vec());
+            B->x = const_cast<double *>(b.fortran_vec ());
 
           cholmod_factor *L;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
@@ -5930,11 +5930,11 @@
               X = CHOLMOD_NAME(solve) (CHOLMOD_A, L, B, cm);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 
-              retval.resize (b.rows (), b.cols());
-              for (octave_idx_type j = 0; j < b.cols(); j++)
-                {
-                  octave_idx_type jr = j * b.rows();
-                  for (octave_idx_type i = 0; i < b.rows(); i++)
+              retval.resize (b.rows (), b.cols ());
+              for (octave_idx_type j = 0; j < b.cols (); j++)
+                {
+                  octave_idx_type jr = j * b.rows ();
+                  for (octave_idx_type i = 0; i < b.rows (); i++)
                     retval.xelem(i,j) = static_cast<double *>(X->x)[jr + i];
                 }
 
@@ -5965,7 +5965,7 @@
           if (err == 0)
             {
               const double *Bx = b.fortran_vec ();
-              retval.resize (b.rows (), b.cols());
+              retval.resize (b.rows (), b.cols ());
               double *result = retval.fortran_vec ();
               octave_idx_type b_nr = b.rows ();
               octave_idx_type b_nc = b.cols ();
@@ -6069,9 +6069,9 @@
           A->nrow = nr;
           A->ncol = nc;
 
-          A->p = cidx();
-          A->i = ridx();
-          A->nzmax = nnz();
+          A->p = cidx ();
+          A->i = ridx ();
+          A->nzmax = nnz ();
           A->packed = true;
           A->sorted = true;
           A->nz = 0;
@@ -6087,15 +6087,15 @@
           if (nr < 1)
             A->x = &dummy;
           else
-            A->x = data();
+            A->x = data ();
 
           cholmod_sparse Bstore;
           cholmod_sparse *B = &Bstore;
-          B->nrow = b.rows();
-          B->ncol = b.cols();
-          B->p = b.cidx();
-          B->i = b.ridx();
-          B->nzmax = b.nnz();
+          B->nrow = b.rows ();
+          B->ncol = b.cols ();
+          B->p = b.cidx ();
+          B->i = b.ridx ();
+          B->nzmax = b.nnz ();
           B->packed = true;
           B->sorted = true;
           B->nz = 0;
@@ -6108,10 +6108,10 @@
           B->stype = 0;
           B->xtype = CHOLMOD_REAL;
 
-          if (b.rows() < 1 || b.cols() < 1)
+          if (b.rows () < 1 || b.cols () < 1)
             B->x = &dummy;
           else
-            B->x = b.data();
+            B->x = b.data ();
 
           cholmod_factor *L;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
@@ -6331,9 +6331,9 @@
           A->nrow = nr;
           A->ncol = nc;
 
-          A->p = cidx();
-          A->i = ridx();
-          A->nzmax = nnz();
+          A->p = cidx ();
+          A->i = ridx ();
+          A->nzmax = nnz ();
           A->packed = true;
           A->sorted = true;
           A->nz = 0;
@@ -6349,21 +6349,21 @@
           if (nr < 1)
             A->x = &dummy;
           else
-            A->x = data();
+            A->x = data ();
 
           cholmod_dense Bstore;
           cholmod_dense *B = &Bstore;
-          B->nrow = b.rows();
-          B->ncol = b.cols();
+          B->nrow = b.rows ();
+          B->ncol = b.cols ();
           B->d = B->nrow;
           B->nzmax = B->nrow * B->ncol;
           B->dtype = CHOLMOD_DOUBLE;
           B->xtype = CHOLMOD_COMPLEX;
-          if (nc < 1 || b.cols() < 1)
+          if (nc < 1 || b.cols () < 1)
             B->x = &dummy;
           else
             // We won't alter it, honest :-)
-            B->x = const_cast<Complex *>(b.fortran_vec());
+            B->x = const_cast<Complex *>(b.fortran_vec ());
 
           cholmod_factor *L;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
@@ -6407,11 +6407,11 @@
               X = CHOLMOD_NAME(solve) (CHOLMOD_A, L, B, cm);
               END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
 
-              retval.resize (b.rows (), b.cols());
-              for (octave_idx_type j = 0; j < b.cols(); j++)
-                {
-                  octave_idx_type jr = j * b.rows();
-                  for (octave_idx_type i = 0; i < b.rows(); i++)
+              retval.resize (b.rows (), b.cols ());
+              for (octave_idx_type j = 0; j < b.cols (); j++)
+                {
+                  octave_idx_type jr = j * b.rows ();
+                  for (octave_idx_type i = 0; i < b.rows (); i++)
                     retval.xelem(i,j) = static_cast<Complex *>(X->x)[jr + i];
                 }
 
@@ -6487,7 +6487,7 @@
                     }
 
                   for (octave_idx_type i = 0; i < b_nr; i++)
-                    retval (i, j) = Complex (Xx[i], Xz[i]);
+                    retval(i, j) = Complex (Xx[i], Xz[i]);
                 }
 
               UMFPACK_DNAME (report_info) (control, info);
@@ -6565,9 +6565,9 @@
           A->nrow = nr;
           A->ncol = nc;
 
-          A->p = cidx();
-          A->i = ridx();
-          A->nzmax = nnz();
+          A->p = cidx ();
+          A->i = ridx ();
+          A->nzmax = nnz ();
           A->packed = true;
           A->sorted = true;
           A->nz = 0;
@@ -6583,15 +6583,15 @@
           if (nr < 1)
             A->x = &dummy;
           else
-            A->x = data();
+            A->x = data ();
 
           cholmod_sparse Bstore;
           cholmod_sparse *B = &Bstore;
-          B->nrow = b.rows();
-          B->ncol = b.cols();
-          B->p = b.cidx();
-          B->i = b.ridx();
-          B->nzmax = b.nnz();
+          B->nrow = b.rows ();
+          B->ncol = b.cols ();
+          B->p = b.cidx ();
+          B->i = b.ridx ();
+          B->nzmax = b.nnz ();
           B->packed = true;
           B->sorted = true;
           B->nz = 0;
@@ -6604,10 +6604,10 @@
           B->stype = 0;
           B->xtype = CHOLMOD_COMPLEX;
 
-          if (b.rows() < 1 || b.cols() < 1)
+          if (b.rows () < 1 || b.cols () < 1)
             B->x = &dummy;
           else
-            B->x = b.data();
+            B->x = b.data ();
 
           cholmod_factor *L;
           BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;
@@ -7495,8 +7495,8 @@
 SparseMatrix
 SparseMatrix::prod (int dim) const
 {
-  if ((rows() == 1 && dim == -1) || dim == 1)
-    return transpose (). prod (0). transpose();
+  if ((rows () == 1 && dim == -1) || dim == 1)
+    return transpose (). prod (0). transpose ();
   else
     {
       SPARSE_REDUCTION_OP (SparseMatrix, double, *=,
@@ -7765,7 +7765,7 @@
 {
   SparseMatrix r;
 
-  if ((a.rows() == b.rows()) && (a.cols() == b.cols()))
+  if ((a.rows () == b.rows ()) && (a.cols () == b.cols ()))
     {
       octave_idx_type a_nr = a.rows ();
       octave_idx_type a_nc = a.cols ();
@@ -7915,7 +7915,7 @@
 {
   SparseMatrix r;
 
-  if ((a.rows() == b.rows()) && (a.cols() == b.cols()))
+  if ((a.rows () == b.rows ()) && (a.cols () == b.cols ()))
     {
       octave_idx_type a_nr = a.rows ();
       octave_idx_type a_nc = a.cols ();
--- a/liboctave/dbleCHOL.cc
+++ b/liboctave/dbleCHOL.cc
@@ -157,7 +157,7 @@
       octave_idx_type info = 0;
 
       Matrix tmp = r;
-      double *v = tmp.fortran_vec();
+      double *v = tmp.fortran_vec ();
 
       if (info == 0)
         {
--- a/liboctave/dbleGEPBAL.cc
+++ b/liboctave/dbleGEPBAL.cc
@@ -70,7 +70,7 @@
       return -1;
     }
 
-  if (a.dims() != b.dims ())
+  if (a.dims () != b.dims ())
     {
       gripe_nonconformant ("GEPBALANCE", n, n, b.rows(), b.cols());
       return -1;
--- a/liboctave/dim-vector.cc
+++ b/liboctave/dim-vector.cc
@@ -45,7 +45,7 @@
   make_unique ();
 
   int j = 0;
-  int l = ndims();
+  int l = ndims ();
 
   for (int i = 0; i < l; i++)
     {
--- a/liboctave/dim-vector.h
+++ b/liboctave/dim-vector.h
@@ -129,10 +129,10 @@
   {
     if (count () > 1)
       {
-	octave_idx_type *new_rep = clonerep ();
+        octave_idx_type *new_rep = clonerep ();
 
-	if (OCTREFCOUNT_ATOMIC_DECREMENT(&(count())) == 0)
-	  freerep ();
+        if (OCTREFCOUNT_ATOMIC_DECREMENT(&(count())) == 0)
+          freerep ();
 
         rep = new_rep;
       }
--- a/liboctave/eigs-base.cc
+++ b/liboctave/eigs-base.cc
@@ -226,14 +226,14 @@
 static M
 ltsolve (const SM& L, const ColumnVector& Q, const M& m)
 {
-  octave_idx_type n = L.cols();
-  octave_idx_type b_nc = m.cols();
+  octave_idx_type n = L.cols ();
+  octave_idx_type b_nc = m.cols ();
   octave_idx_type err = 0;
   double rcond;
   MatrixType ltyp (MatrixType::Lower);
   M tmp = L.solve (ltyp, m, err, rcond, 0);
   M retval;
-  const double* qv = Q.fortran_vec();
+  const double* qv = Q.fortran_vec ();
 
   if (!err)
     {
@@ -253,14 +253,14 @@
 static M
 utsolve (const SM& U, const ColumnVector& Q, const M& m)
 {
-  octave_idx_type n = U.cols();
-  octave_idx_type b_nc = m.cols();
+  octave_idx_type n = U.cols ();
+  octave_idx_type b_nc = m.cols ();
   octave_idx_type err = 0;
   double rcond;
   MatrixType utyp (MatrixType::Upper);
 
   M retval (n, b_nc);
-  const double* qv = Q.fortran_vec();
+  const double* qv = Q.fortran_vec ();
   for (octave_idx_type j = 0; j < b_nc; j++)
     {
       for (octave_idx_type i = 0; i < n; i++)
@@ -347,14 +347,14 @@
 {
   octave_idx_type info;
   CHOL fact (b, info);
-  octave_idx_type n = b.cols();
+  octave_idx_type n = b.cols ();
 
   if (info != 0)
     return false;
   else
     {
       bt = fact.chol_matrix ();
-      b =  bt.transpose();
+      b =  bt.transpose ();
       permB = ColumnVector(n);
       for (octave_idx_type i = 0; i < n; i++)
         permB(i) = i;
@@ -368,13 +368,13 @@
   octave_idx_type info;
   SparseCHOL fact (b, info, false);
 
-  if (fact.P() != 0)
+  if (fact.P () != 0)
     return false;
   else
     {
-      b = fact.L();
-      bt = b.transpose();
-      permB = fact.perm() - 1.0;
+      b = fact.L ();
+      bt = b.transpose ();
+      permB = fact.perm () - 1.0;
       return true;
     }
 }
@@ -384,14 +384,14 @@
 {
   octave_idx_type info;
   ComplexCHOL fact (b, info);
-  octave_idx_type n = b.cols();
+  octave_idx_type n = b.cols ();
 
   if (info != 0)
     return false;
   else
     {
       bt = fact.chol_matrix ();
-      b =  bt.hermitian();
+      b =  bt.hermitian ();
       permB = ColumnVector(n);
       for (octave_idx_type i = 0; i < n; i++)
         permB(i) = i;
@@ -406,13 +406,13 @@
   octave_idx_type info;
   SparseComplexCHOL fact (b, info, false);
 
-  if (fact.P() != 0)
+  if (fact.P () != 0)
     return false;
   else
     {
-      b = fact.L();
-      bt = b.hermitian();
-      permB = fact.perm() - 1.0;
+      b = fact.L ();
+      bt = b.hermitian ();
+      permB = fact.perm () - 1.0;
       return true;
     }
 }
@@ -424,7 +424,7 @@
                 octave_idx_type *Q)
 {
   bool have_b = ! b.is_empty ();
-  octave_idx_type n = m.rows();
+  octave_idx_type n = m.rows ();
 
   // Caclulate LU decomposition of 'A - sigma * B'
   SparseMatrix AminusSigmaB (m);
@@ -433,7 +433,7 @@
     {
       if (cholB)
         {
-          if (permB.length())
+          if (permB.length ())
             {
               SparseMatrix tmp(n,n,n);
               for (octave_idx_type i = 0; i < n; i++)
@@ -446,11 +446,11 @@
               tmp.xcidx(n) = n;
 
               AminusSigmaB = AminusSigmaB - sigma * tmp *
-                b.transpose() * b * tmp.transpose();
+                b.transpose () * b * tmp.transpose ();
             }
           else
             AminusSigmaB = AminusSigmaB - sigma *
-              b.transpose() * b;
+              b.transpose () * b;
         }
       else
         AminusSigmaB = AminusSigmaB - sigma * b;
@@ -522,7 +522,7 @@
                 octave_idx_type *Q)
 {
   bool have_b = ! b.is_empty ();
-  octave_idx_type n = m.cols();
+  octave_idx_type n = m.cols ();
 
   // Caclulate LU decomposition of 'A - sigma * B'
   Matrix AminusSigmaB (m);
@@ -531,16 +531,16 @@
     {
       if (cholB)
         {
-          Matrix tmp = sigma * b.transpose() * b;
-          const double *pB = permB.fortran_vec();
-          double *p = AminusSigmaB.fortran_vec();
-
-          if (permB.length())
+          Matrix tmp = sigma * b.transpose () * b;
+          const double *pB = permB.fortran_vec ();
+          double *p = AminusSigmaB.fortran_vec ();
+
+          if (permB.length ())
             {
               for (octave_idx_type j = 0;
-                   j < b.cols(); j++)
+                   j < b.cols (); j++)
                 for (octave_idx_type i = 0;
-                     i < b.rows(); i++)
+                     i < b.rows (); i++)
                   *p++ -=  tmp.xelem (static_cast<octave_idx_type>(pB[i]),
                                       static_cast<octave_idx_type>(pB[j]));
             }
@@ -552,7 +552,7 @@
     }
   else
     {
-      double *p = AminusSigmaB.fortran_vec();
+      double *p = AminusSigmaB.fortran_vec ();
 
       for (octave_idx_type i = 0; i < n; i++)
         p[i*(n+1)] -= sigma;
@@ -560,7 +560,7 @@
 
   LU fact (AminusSigmaB);
 
-  L = fact.P().transpose() * fact.L ();
+  L = fact.P ().transpose () * fact.L ();
   U = fact.U ();
   for (octave_idx_type j = 0; j < n; j++)
     P[j] = Q[j] = j;
@@ -599,7 +599,7 @@
                 octave_idx_type *P, octave_idx_type *Q)
 {
   bool have_b = ! b.is_empty ();
-  octave_idx_type n = m.rows();
+  octave_idx_type n = m.rows ();
 
   // Caclulate LU decomposition of 'A - sigma * B'
   SparseComplexMatrix AminusSigmaB (m);
@@ -608,7 +608,7 @@
     {
       if (cholB)
         {
-          if (permB.length())
+          if (permB.length ())
             {
               SparseMatrix tmp(n,n,n);
               for (octave_idx_type i = 0; i < n; i++)
@@ -620,11 +620,11 @@
                 }
               tmp.xcidx(n) = n;
 
-              AminusSigmaB = AminusSigmaB - tmp * b.hermitian() * b *
-                tmp.transpose() * sigma;
+              AminusSigmaB = AminusSigmaB - tmp * b.hermitian () * b *
+                tmp.transpose () * sigma;
             }
           else
-            AminusSigmaB = AminusSigmaB - sigma * b.hermitian() * b;
+            AminusSigmaB = AminusSigmaB - sigma * b.hermitian () * b;
         }
       else
         AminusSigmaB = AminusSigmaB - sigma * b;
@@ -696,7 +696,7 @@
                 octave_idx_type *Q)
 {
   bool have_b = ! b.is_empty ();
-  octave_idx_type n = m.cols();
+  octave_idx_type n = m.cols ();
 
   // Caclulate LU decomposition of 'A - sigma * B'
   ComplexMatrix AminusSigmaB (m);
@@ -705,16 +705,16 @@
     {
       if (cholB)
         {
-          ComplexMatrix tmp = sigma * b.hermitian() * b;
-          const double *pB = permB.fortran_vec();
-          Complex *p = AminusSigmaB.fortran_vec();
-
-          if (permB.length())
+          ComplexMatrix tmp = sigma * b.hermitian () * b;
+          const double *pB = permB.fortran_vec ();
+          Complex *p = AminusSigmaB.fortran_vec ();
+
+          if (permB.length ())
             {
               for (octave_idx_type j = 0;
-                   j < b.cols(); j++)
+                   j < b.cols (); j++)
                 for (octave_idx_type i = 0;
-                     i < b.rows(); i++)
+                     i < b.rows (); i++)
                   *p++ -=  tmp.xelem (static_cast<octave_idx_type>(pB[i]),
                                       static_cast<octave_idx_type>(pB[j]));
             }
@@ -726,7 +726,7 @@
     }
   else
     {
-      Complex *p = AminusSigmaB.fortran_vec();
+      Complex *p = AminusSigmaB.fortran_vec ();
 
       for (octave_idx_type i = 0; i < n; i++)
         p[i*(n+1)] -= sigma;
@@ -734,7 +734,7 @@
 
   ComplexLU fact (AminusSigmaB);
 
-  L = fact.P().transpose() * fact.L ();
+  L = fact.P ().transpose () * fact.L ();
   U = fact.U ();
   for (octave_idx_type j = 0; j < n; j++)
     P[j] = Q[j] = j;
@@ -779,27 +779,27 @@
   M b(_b);
   octave_idx_type n = m.cols ();
   octave_idx_type mode = 1;
-  bool have_b = ! b.is_empty();
+  bool have_b = ! b.is_empty ();
   bool note3 = false;
   char bmat = 'I';
   double sigma = 0.;
   M bt;
 
-  if (m.rows() != m.cols())
+  if (m.rows () != m.cols ())
     {
       (*current_liboctave_error_handler) ("eigs: A must be square");
       return -1;
     }
-  if (have_b && (m.rows() != b.rows() || m.rows() != b.cols()))
+  if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
     {
       (*current_liboctave_error_handler)
         ("eigs: B must be square and the same size as A");
       return -1;
     }
 
-  if (resid.is_empty())
+  if (resid.is_empty ())
     {
-      std::string rand_dist = octave_rand::distribution();
+      std::string rand_dist = octave_rand::distribution ();
       octave_rand::distribution("uniform");
       resid = ColumnVector (octave_rand::vector(n));
       octave_rand::distribution(rand_dist);
@@ -838,10 +838,10 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.length() != 0)
+  if (have_b && cholB && permB.length () != 0)
     {
       // Check the we really have a permutation vector
-      if (permB.length() != n)
+      if (permB.length () != n)
         {
           (*current_liboctave_error_handler)
             ("eigs: permB vector invalid");
@@ -888,8 +888,8 @@
       if (cholB)
         {
           bt = b;
-          b = b.transpose();
-          if (permB.length() == 0)
+          b = b.transpose ();
+          if (permB.length () == 0)
             {
               permB = ColumnVector(n);
               for (octave_idx_type i = 0; i < n; i++)
@@ -939,7 +939,7 @@
     {
       F77_FUNC (dsaupd, DSAUPD)
         (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
-         F77_CONST_CHAR_ARG2 ((typ.c_str()), 2),
+         F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
          k, tol, presid, p, v, n, iparam,
          ipntr, workd, workl, lwork, info
          F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
@@ -1100,15 +1100,15 @@
   M b(_b);
   octave_idx_type n = m.cols ();
   octave_idx_type mode = 3;
-  bool have_b = ! b.is_empty();
+  bool have_b = ! b.is_empty ();
   std::string typ = "LM";
 
-  if (m.rows() != m.cols())
+  if (m.rows () != m.cols ())
     {
       (*current_liboctave_error_handler) ("eigs: A must be square");
       return -1;
     }
-  if (have_b && (m.rows() != b.rows() || m.rows() != b.cols()))
+  if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
     {
       (*current_liboctave_error_handler)
         ("eigs: B must be square and the same size as A");
@@ -1121,9 +1121,9 @@
   //                                _b, permB, resid, os, tol, rvec, cholB,
   //                                disp, maxit);
 
-  if (resid.is_empty())
+  if (resid.is_empty ())
     {
-      std::string rand_dist = octave_rand::distribution();
+      std::string rand_dist = octave_rand::distribution ();
       octave_rand::distribution("uniform");
       resid = ColumnVector (octave_rand::vector(n));
       octave_rand::distribution(rand_dist);
@@ -1162,10 +1162,10 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.length() != 0)
+  if (have_b && cholB && permB.length () != 0)
     {
       // Check the we really have a permutation vector
-      if (permB.length() != n)
+      if (permB.length () != n)
         {
           (*current_liboctave_error_handler) ("eigs: permB vector invalid");
           return -1;
@@ -1215,8 +1215,8 @@
   int iter = 0;
   M L, U;
 
-  OCTAVE_LOCAL_BUFFER (octave_idx_type, P, (have_b ? b.rows() : m.rows()));
-  OCTAVE_LOCAL_BUFFER (octave_idx_type, Q, (have_b ? b.cols() : m.cols()));
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, P, (have_b ? b.rows () : m.rows ()));
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, Q, (have_b ? b.cols () : m.cols ()));
 
   if (! LuAminusSigmaB(m, b, cholB, permB, sigma, L, U, P, Q))
     return -1;
@@ -1232,7 +1232,7 @@
     {
       F77_FUNC (dsaupd, DSAUPD)
         (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
-         F77_CONST_CHAR_ARG2 ((typ.c_str()), 2),
+         F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
          k, tol, presid, p, v, n, iparam,
          ipntr, workd, workl, lwork, info
          F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
@@ -1430,9 +1430,9 @@
   octave_idx_type mode = 1;
   int err = 0;
 
-  if (resid.is_empty())
+  if (resid.is_empty ())
     {
-      std::string rand_dist = octave_rand::distribution();
+      std::string rand_dist = octave_rand::distribution ();
       octave_rand::distribution("uniform");
       resid = ColumnVector (octave_rand::vector(n));
       octave_rand::distribution(rand_dist);
@@ -1533,7 +1533,7 @@
     {
       F77_FUNC (dsaupd, DSAUPD)
         (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
-         F77_CONST_CHAR_ARG2 ((typ.c_str()), 2),
+         F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
          k, tol, presid, p, v, n, iparam,
          ipntr, workd, workl, lwork, info
          F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
@@ -1692,28 +1692,28 @@
   M b(_b);
   octave_idx_type n = m.cols ();
   octave_idx_type mode = 1;
-  bool have_b = ! b.is_empty();
+  bool have_b = ! b.is_empty ();
   bool note3 = false;
   char bmat = 'I';
   double sigmar = 0.;
   double sigmai = 0.;
   M bt;
 
-  if (m.rows() != m.cols())
+  if (m.rows () != m.cols ())
     {
       (*current_liboctave_error_handler) ("eigs: A must be square");
       return -1;
     }
-  if (have_b && (m.rows() != b.rows() || m.rows() != b.cols()))
+  if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
     {
       (*current_liboctave_error_handler)
         ("eigs: B must be square and the same size as A");
       return -1;
     }
 
-  if (resid.is_empty())
+  if (resid.is_empty ())
     {
-      std::string rand_dist = octave_rand::distribution();
+      std::string rand_dist = octave_rand::distribution ();
       octave_rand::distribution("uniform");
       resid = ColumnVector (octave_rand::vector(n));
       octave_rand::distribution(rand_dist);
@@ -1752,10 +1752,10 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.length() != 0)
+  if (have_b && cholB && permB.length () != 0)
     {
       // Check the we really have a permutation vector
-      if (permB.length() != n)
+      if (permB.length () != n)
         {
           (*current_liboctave_error_handler)
             ("eigs: permB vector invalid");
@@ -1802,8 +1802,8 @@
       if (cholB)
         {
           bt = b;
-          b = b.transpose();
-          if (permB.length() == 0)
+          b = b.transpose ();
+          if (permB.length () == 0)
             {
               permB = ColumnVector(n);
               for (octave_idx_type i = 0; i < n; i++)
@@ -1853,7 +1853,7 @@
     {
       F77_FUNC (dnaupd, DNAUPD)
         (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
-         F77_CONST_CHAR_ARG2 ((typ.c_str()), 2),
+         F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
          k, tol, presid, p, v, n, iparam,
          ipntr, workd, workl, lwork, info
          F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
@@ -2062,16 +2062,16 @@
   M b(_b);
   octave_idx_type n = m.cols ();
   octave_idx_type mode = 3;
-  bool have_b = ! b.is_empty();
+  bool have_b = ! b.is_empty ();
   std::string typ = "LM";
   double sigmai = 0.;
 
-  if (m.rows() != m.cols())
+  if (m.rows () != m.cols ())
     {
       (*current_liboctave_error_handler) ("eigs: A must be square");
       return -1;
     }
-  if (have_b && (m.rows() != b.rows() || m.rows() != b.cols()))
+  if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
     {
       (*current_liboctave_error_handler)
         ("eigs: B must be square and the same size as A");
@@ -2084,9 +2084,9 @@
   //                                   _b, permB, resid, os, tol, rvec, cholB,
   //                                   disp, maxit);
 
-  if (resid.is_empty())
+  if (resid.is_empty ())
     {
-      std::string rand_dist = octave_rand::distribution();
+      std::string rand_dist = octave_rand::distribution ();
       octave_rand::distribution("uniform");
       resid = ColumnVector (octave_rand::vector(n));
       octave_rand::distribution(rand_dist);
@@ -2125,10 +2125,10 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.length() != 0)
+  if (have_b && cholB && permB.length () != 0)
     {
       // Check that we really have a permutation vector
-      if (permB.length() != n)
+      if (permB.length () != n)
         {
           (*current_liboctave_error_handler) ("eigs: permB vector invalid");
           return -1;
@@ -2178,8 +2178,8 @@
   int iter = 0;
   M L, U;
 
-  OCTAVE_LOCAL_BUFFER (octave_idx_type, P, (have_b ? b.rows() : m.rows()));
-  OCTAVE_LOCAL_BUFFER (octave_idx_type, Q, (have_b ? b.cols() : m.cols()));
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, P, (have_b ? b.rows () : m.rows ()));
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, Q, (have_b ? b.cols () : m.cols ()));
 
   if (! LuAminusSigmaB(m, b, cholB, permB, sigmar, L, U, P, Q))
     return -1;
@@ -2195,7 +2195,7 @@
     {
       F77_FUNC (dnaupd, DNAUPD)
         (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
-         F77_CONST_CHAR_ARG2 ((typ.c_str()), 2),
+         F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
          k, tol, presid, p, v, n, iparam,
          ipntr, workd, workl, lwork, info
          F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
@@ -2447,9 +2447,9 @@
   octave_idx_type mode = 1;
   int err = 0;
 
-  if (resid.is_empty())
+  if (resid.is_empty ())
     {
-      std::string rand_dist = octave_rand::distribution();
+      std::string rand_dist = octave_rand::distribution ();
       octave_rand::distribution("uniform");
       resid = ColumnVector (octave_rand::vector(n));
       octave_rand::distribution(rand_dist);
@@ -2551,7 +2551,7 @@
     {
       F77_FUNC (dnaupd, DNAUPD)
         (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
-         F77_CONST_CHAR_ARG2 ((typ.c_str()), 2),
+         F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
          k, tol, presid, p, v, n, iparam,
          ipntr, workd, workl, lwork, info
          F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
@@ -2757,27 +2757,27 @@
   M b(_b);
   octave_idx_type n = m.cols ();
   octave_idx_type mode = 1;
-  bool have_b = ! b.is_empty();
+  bool have_b = ! b.is_empty ();
   bool note3 = false;
   char bmat = 'I';
   Complex sigma = 0.;
   M bt;
 
-  if (m.rows() != m.cols())
+  if (m.rows () != m.cols ())
     {
       (*current_liboctave_error_handler) ("eigs: A must be square");
       return -1;
     }
-  if (have_b && (m.rows() != b.rows() || m.rows() != b.cols()))
+  if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
     {
       (*current_liboctave_error_handler)
         ("eigs: B must be square and the same size as A");
       return -1;
     }
 
-  if (cresid.is_empty())
+  if (cresid.is_empty ())
     {
-      std::string rand_dist = octave_rand::distribution();
+      std::string rand_dist = octave_rand::distribution ();
       octave_rand::distribution("uniform");
       Array<double> rr (octave_rand::vector(n));
       Array<double> ri (octave_rand::vector(n));
@@ -2820,10 +2820,10 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.length() != 0)
+  if (have_b && cholB && permB.length () != 0)
     {
       // Check the we really have a permutation vector
-      if (permB.length() != n)
+      if (permB.length () != n)
         {
           (*current_liboctave_error_handler)
             ("eigs: permB vector invalid");
@@ -2870,8 +2870,8 @@
       if (cholB)
         {
           bt = b;
-          b = b.hermitian();
-          if (permB.length() == 0)
+          b = b.hermitian ();
+          if (permB.length () == 0)
             {
               permB = ColumnVector(n);
               for (octave_idx_type i = 0; i < n; i++)
@@ -2922,7 +2922,7 @@
     {
       F77_FUNC (znaupd, ZNAUPD)
         (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
-         F77_CONST_CHAR_ARG2 ((typ.c_str()), 2),
+         F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
          k, tol, presid, p, v, n, iparam,
          ipntr, workd, workl, lwork, rwork, info
          F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
@@ -3079,15 +3079,15 @@
   M b(_b);
   octave_idx_type n = m.cols ();
   octave_idx_type mode = 3;
-  bool have_b = ! b.is_empty();
+  bool have_b = ! b.is_empty ();
   std::string typ = "LM";
 
-  if (m.rows() != m.cols())
+  if (m.rows () != m.cols ())
     {
       (*current_liboctave_error_handler) ("eigs: A must be square");
       return -1;
     }
-  if (have_b && (m.rows() != b.rows() || m.rows() != b.cols()))
+  if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
     {
       (*current_liboctave_error_handler)
         ("eigs: B must be square and the same size as A");
@@ -3100,9 +3100,9 @@
   //                                      eig_val, _b, permB, cresid, os, tol,
   //                                      rvec, cholB, disp, maxit);
 
-  if (cresid.is_empty())
+  if (cresid.is_empty ())
     {
-      std::string rand_dist = octave_rand::distribution();
+      std::string rand_dist = octave_rand::distribution ();
       octave_rand::distribution("uniform");
       Array<double> rr (octave_rand::vector(n));
       Array<double> ri (octave_rand::vector(n));
@@ -3145,10 +3145,10 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.length() != 0)
+  if (have_b && cholB && permB.length () != 0)
     {
       // Check that we really have a permutation vector
-      if (permB.length() != n)
+      if (permB.length () != n)
         {
           (*current_liboctave_error_handler) ("eigs: permB vector invalid");
           return -1;
@@ -3198,8 +3198,8 @@
   int iter = 0;
   M L, U;
 
-  OCTAVE_LOCAL_BUFFER (octave_idx_type, P, (have_b ? b.rows() : m.rows()));
-  OCTAVE_LOCAL_BUFFER (octave_idx_type, Q, (have_b ? b.cols() : m.cols()));
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, P, (have_b ? b.rows () : m.rows ()));
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, Q, (have_b ? b.cols () : m.cols ()));
 
   if (! LuAminusSigmaB(m, b, cholB, permB, sigma, L, U, P, Q))
     return -1;
@@ -3216,7 +3216,7 @@
     {
       F77_FUNC (znaupd, ZNAUPD)
         (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
-         F77_CONST_CHAR_ARG2 ((typ.c_str()), 2),
+         F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
          k, tol, presid, p, v, n, iparam,
          ipntr, workd, workl, lwork, rwork, info
          F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
@@ -3417,9 +3417,9 @@
   octave_idx_type mode = 1;
   int err = 0;
 
-  if (cresid.is_empty())
+  if (cresid.is_empty ())
     {
-      std::string rand_dist = octave_rand::distribution();
+      std::string rand_dist = octave_rand::distribution ();
       octave_rand::distribution("uniform");
       Array<double> rr (octave_rand::vector(n));
       Array<double> ri (octave_rand::vector(n));
@@ -3525,7 +3525,7 @@
     {
       F77_FUNC (znaupd, ZNAUPD)
         (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
-         F77_CONST_CHAR_ARG2 ((typ.c_str()), 2),
+         F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
          k, tol, presid, p, v, n, iparam,
          ipntr, workd, workl, lwork, rwork, info
          F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
@@ -3833,43 +3833,43 @@
 #endif
 
 #ifndef _MSC_VER
-template static octave_idx_type
+template octave_idx_type
 lusolve (const SparseMatrix&, const SparseMatrix&, Matrix&);
 
-template static octave_idx_type
+template octave_idx_type
 lusolve (const SparseComplexMatrix&, const SparseComplexMatrix&,
          ComplexMatrix&);
 
-template static octave_idx_type
+template octave_idx_type
 lusolve (const Matrix&, const Matrix&, Matrix&);
 
-template static octave_idx_type
+template octave_idx_type
 lusolve (const ComplexMatrix&, const ComplexMatrix&, ComplexMatrix&);
 
-template static ComplexMatrix
+template ComplexMatrix
 ltsolve (const SparseComplexMatrix&, const ColumnVector&,
          const ComplexMatrix&);
 
-template static Matrix
+template Matrix
 ltsolve (const SparseMatrix&, const ColumnVector&, const Matrix&);
 
-template static ComplexMatrix
+template ComplexMatrix
 ltsolve (const ComplexMatrix&, const ColumnVector&, const ComplexMatrix&);
 
-template static Matrix
+template Matrix
 ltsolve (const Matrix&, const ColumnVector&, const Matrix&);
 
-template static ComplexMatrix
+template ComplexMatrix
 utsolve (const SparseComplexMatrix&, const ColumnVector&,
          const ComplexMatrix&);
 
-template static Matrix
+template Matrix
 utsolve (const SparseMatrix&, const ColumnVector&, const Matrix&);
 
-template static ComplexMatrix
+template ComplexMatrix
 utsolve (const ComplexMatrix&, const ColumnVector&, const ComplexMatrix&);
 
-template static Matrix
+template Matrix
 utsolve (const Matrix&, const ColumnVector&, const Matrix&);
 #endif
 
--- a/liboctave/f2c-main.c
+++ b/liboctave/f2c-main.c
@@ -31,5 +31,5 @@
 #  ifdef __cplusplus
 extern "C"
 #  endif
-int F77_DUMMY_MAIN() { assert(0); return 1; }
+int F77_DUMMY_MAIN () { assert(0); return 1; }
 #endif
--- a/liboctave/fCColVector.cc
+++ b/liboctave/fCColVector.cc
@@ -514,7 +514,7 @@
 std::istream&
 operator >> (std::istream& is, FloatComplexColumnVector& a)
 {
-  octave_idx_type len = a.length();
+  octave_idx_type len = a.length ();
 
   if (len > 0)
     {
--- a/liboctave/fCColVector.h
+++ b/liboctave/fCColVector.h
@@ -134,8 +134,7 @@
   friend OCTAVE_API std::ostream& operator << (std::ostream& os, const FloatComplexColumnVector& a);
   friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatComplexColumnVector& a);
 
-  void resize (octave_idx_type n,
-               const FloatComplex& rfv = Array<FloatComplex>::resize_fill_value ())
+  void resize (octave_idx_type n, const FloatComplex& rfv = FloatComplex (0))
   {
     Array<FloatComplex>::resize (dim_vector (n, 1), rfv);
   }
--- a/liboctave/fCDiagMatrix.h
+++ b/liboctave/fCDiagMatrix.h
@@ -90,7 +90,7 @@
   FloatComplexDiagMatrix& fill (const FloatComplexRowVector& a, octave_idx_type beg);
 
   FloatComplexDiagMatrix hermitian (void) const { return MDiagArray2<FloatComplex>::hermitian (std::conj); }
-  FloatComplexDiagMatrix transpose (void) const { return MDiagArray2<FloatComplex>::transpose(); }
+  FloatComplexDiagMatrix transpose (void) const { return MDiagArray2<FloatComplex>::transpose (); }
   FloatDiagMatrix abs (void) const;
 
   friend OCTAVE_API FloatComplexDiagMatrix conj (const FloatComplexDiagMatrix& a);
--- a/liboctave/fCMatrix.cc
+++ b/liboctave/fCMatrix.cc
@@ -1091,7 +1091,7 @@
       // Calculate the norm of the matrix, for later use.
       float anorm;
       if (calc_cond)
-        anorm  = retval.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+        anorm  = retval.abs ().sum ().row(static_cast<octave_idx_type>(0)).max ();
 
       F77_XFCN (cgetrf, CGETRF, (nc, nc, tmp_data, nr, pipvt, info));
 
@@ -1129,7 +1129,7 @@
         }
 
       if (info != 0)
-        mattype.mark_as_rectangular();
+        mattype.mark_as_rectangular ();
     }
 
   return retval;
@@ -1155,7 +1155,7 @@
           if (info == 0)
             {
               if (calc_cond)
-                rcon = chol.rcond();
+                rcon = chol.rcond ();
               else
                 rcon = 1.0;
               ret = chol.inverse ();
@@ -1789,8 +1789,8 @@
             {
               octave_idx_type info = 0;
               char job = 'L';
-              anorm = atmp.abs().sum().
-                row(static_cast<octave_idx_type>(0)).max();
+              anorm = atmp.abs ().sum ().
+                row(static_cast<octave_idx_type>(0)).max ();
 
               F77_XFCN (cpotrf, CPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
                                          tmp_data, nr, info
@@ -1829,8 +1829,8 @@
               octave_idx_type *pipvt = ipvt.fortran_vec ();
 
               if(anorm < 0.)
-                anorm = atmp.abs().sum().
-                  row(static_cast<octave_idx_type>(0)).max();
+                anorm = atmp.abs ().sum ().
+                  row(static_cast<octave_idx_type>(0)).max ();
 
               Array<FloatComplex> z (dim_vector (2 * nc, 1));
               FloatComplex *pz = z.fortran_vec ();
@@ -2096,7 +2096,7 @@
           char job = 'L';
           FloatComplexMatrix atmp = *this;
           FloatComplex *tmp_data = atmp.fortran_vec ();
-          anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+          anorm = atmp.abs ().sum ().row(static_cast<octave_idx_type>(0)).max ();
 
           F77_XFCN (cpotrf, CPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
                                      tmp_data, nr, info
@@ -2152,7 +2152,7 @@
 
                   F77_XFCN (cpotrs, CPOTRS, (F77_CONST_CHAR_ARG2 (&job, 1),
                                              nr, b_nc, tmp_data, nr,
-                                             result, b.rows(), info
+                                             result, b.rows (), info
                                              F77_CHAR_ARG_LEN (1)));
                 }
               else
@@ -2180,7 +2180,7 @@
 
           // Calculate the norm of the matrix, for later use.
           if (anorm < 0.)
-            anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+            anorm = atmp.abs ().sum ().row(static_cast<octave_idx_type>(0)).max ();
 
           F77_XFCN (cgetrf, CGETRF, (nr, nr, tmp_data, nr, pipvt, info));
 
@@ -2238,7 +2238,7 @@
                   char job = 'N';
                   F77_XFCN (cgetrs, CGETRS, (F77_CONST_CHAR_ARG2 (&job, 1),
                                              nr, b_nc, tmp_data, nr,
-                                             pipvt, result, b.rows(), info
+                                             pipvt, result, b.rows (), info
                                              F77_CHAR_ARG_LEN (1)));
                 }
               else
@@ -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
 {
@@ -3698,25 +3715,27 @@
     return m * FloatComplexMatrix (a);
 }
 
-/* Simple Dot Product, Matrix-Vector and Matrix-Matrix Unit tests
-%!assert(single([1+i 2+i 3+i]) * single([ 4+i ; 5+i ; 6+i]), single(29+21i), 5e-7)
-%!assert(single([1+i 2+i ; 3+i 4+i ]) * single([5+i ; 6+i]), single([15 + 14i ; 37 + 18i]), 5e-7)
-%!assert(single([1+i 2+i ; 3+i 4+i ]) * single([5+i 6+i ; 7+i 8+i]), single([17 + 15i 20 + 17i; 41 + 19i 48 + 21i]), 5e-7)
-%!assert(single([1 i])*single([i 0])', single(-i));
-*/
-
-/* Test some simple identities
+/*
+
+## Simple Dot Product, Matrix-Vector, and Matrix-Matrix Unit tests
+%!assert (single ([1+i 2+i 3+i]) * single ([ 4+i ; 5+i ; 6+i]), single (29+21i), 5e-7)
+%!assert (single ([1+i 2+i ; 3+i 4+i]) * single ([5+i ; 6+i]), single ([15 + 14i ; 37 + 18i]), 5e-7)
+%!assert (single ([1+i 2+i ; 3+i 4+i ]) * single ([5+i 6+i ; 7+i 8+i]), single ([17 + 15i 20 + 17i; 41 + 19i 48 + 21i]), 5e-7)
+%!assert (single ([1 i])*single ([i 0])', single (-i))
+
+## Test some simple identities
 %!shared M, cv, rv
-%! M = single(randn(10,10))+i*single(rand(10,10));
-%! cv = single(randn(10,1))+i*single(rand(10,1));
-%! rv = single(randn(1,10))+i*single(rand(1,10));
-%!assert([M*cv,M*cv],M*[cv,cv],5e-6)
-%!assert([M.'*cv,M.'*cv],M.'*[cv,cv],5e-6)
-%!assert([M'*cv,M'*cv],M'*[cv,cv],5e-6)
-%!assert([rv*M;rv*M],[rv;rv]*M,5e-6)
-%!assert([rv*M.';rv*M.'],[rv;rv]*M.',5e-6)
-%!assert([rv*M';rv*M'],[rv;rv]*M',5e-6)
-%!assert(2*rv*cv,[rv,rv]*[cv;cv],5e-6)
+%! M = single (randn (10,10))+ i*single (rand (10,10));
+%! cv = single (randn (10,1))+ i*single (rand (10,1));
+%! rv = single (randn (1,10))+ i*single (rand (1,10));
+%!assert ([M*cv,M*cv], M*[cv,cv], 5e-6)
+%!assert ([M.'*cv,M.'*cv], M.'*[cv,cv], 5e-6)
+%!assert ([M'*cv,M'*cv], M'*[cv,cv], 5e-6)
+%!assert ([rv*M;rv*M], [rv;rv]*M, 5e-6)
+%!assert ([rv*M.';rv*M.'], [rv;rv]*M.', 5e-6)
+%!assert ([rv*M';rv*M'], [rv;rv]*M', 5e-6)
+%!assert (2*rv*cv, [rv,rv]*[cv;cv], 5e-6)
+
 */
 
 static char
--- a/liboctave/fCMatrix.h
+++ b/liboctave/fCMatrix.h
@@ -157,7 +157,7 @@
   FloatComplexColumnVector column (octave_idx_type i) const;
 
   void resize (octave_idx_type nr, octave_idx_type nc,
-               const FloatComplex& rfv = resize_fill_value ())
+               const FloatComplex& rfv = FloatComplex (0))
   {
     MArray<FloatComplex>::resize (dim_vector (nr, nc), rfv);
   }
@@ -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;
 
@@ -381,9 +383,6 @@
 
   friend OCTAVE_API std::ostream& operator << (std::ostream& os, const FloatComplexMatrix& a);
   friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatComplexMatrix& a);
-
-  static FloatComplex resize_fill_value (void) { return FloatComplex (0.0, 0.0); }
-
 };
 
 extern OCTAVE_API FloatComplexMatrix conj (const FloatComplexMatrix& a);
--- a/liboctave/fCNDArray.cc
+++ b/liboctave/fCNDArray.cc
@@ -119,7 +119,7 @@
 FloatComplexNDArray
 FloatComplexNDArray::fourier2d (void) const
 {
-  dim_vector dv = dims();
+  dim_vector dv = dims ();
   if (dv.length () < 2)
     return FloatComplexNDArray ();
 
@@ -127,7 +127,7 @@
   const FloatComplex *in = fortran_vec ();
   FloatComplexNDArray retval (dv);
   FloatComplex *out = retval.fortran_vec ();
-  octave_idx_type howmany = numel() / dv(0) / dv(1);
+  octave_idx_type howmany = numel () / dv(0) / dv(1);
   octave_idx_type dist = dv(0) * dv(1);
 
   for (octave_idx_type i=0; i < howmany; i++)
@@ -139,7 +139,7 @@
 FloatComplexNDArray
 FloatComplexNDArray::ifourier2d (void) const
 {
-  dim_vector dv = dims();
+  dim_vector dv = dims ();
   if (dv.length () < 2)
     return FloatComplexNDArray ();
 
@@ -147,7 +147,7 @@
   const FloatComplex *in = fortran_vec ();
   FloatComplexNDArray retval (dv);
   FloatComplex *out = retval.fortran_vec ();
-  octave_idx_type howmany = numel() / dv(0) / dv(1);
+  octave_idx_type howmany = numel () / dv(0) / dv(1);
   octave_idx_type dist = dv(0) * dv(1);
 
   for (octave_idx_type i=0; i < howmany; i++)
@@ -242,7 +242,7 @@
           F77_FUNC (cfftf, CFFTF) (npts, tmp, pwsave);
 
           for (octave_idx_type i = 0; i < npts; i++)
-            retval ((i + k*npts)*stride + j*dist) = tmp[i];
+            retval((i + k*npts)*stride + j*dist) = tmp[i];
         }
     }
 
@@ -289,7 +289,7 @@
           F77_FUNC (cfftb, CFFTB) (npts, tmp, pwsave);
 
           for (octave_idx_type i = 0; i < npts; i++)
-            retval ((i + k*npts)*stride + j*dist) = tmp[i] /
+            retval((i + k*npts)*stride + j*dist) = tmp[i] /
               static_cast<float> (npts);
         }
     }
@@ -330,12 +330,12 @@
               octave_quit ();
 
               for (octave_idx_type l = 0; l < npts; l++)
-                prow[l] = retval ((l + k*npts)*stride + j*dist);
+                prow[l] = retval((l + k*npts)*stride + j*dist);
 
               F77_FUNC (cfftf, CFFTF) (npts, prow, pwsave);
 
               for (octave_idx_type l = 0; l < npts; l++)
-                retval ((l + k*npts)*stride + j*dist) = prow[l];
+                retval((l + k*npts)*stride + j*dist) = prow[l];
             }
         }
 
@@ -348,7 +348,7 @@
 FloatComplexNDArray
 FloatComplexNDArray::ifourier2d (void) const
 {
-  dim_vector dv = dims();
+  dim_vector dv = dims ();
   dim_vector dv2 (dv(0), dv(1));
   int rank = 2;
   FloatComplexNDArray retval (*this);
@@ -378,12 +378,12 @@
               octave_quit ();
 
               for (octave_idx_type l = 0; l < npts; l++)
-                prow[l] = retval ((l + k*npts)*stride + j*dist);
+                prow[l] = retval((l + k*npts)*stride + j*dist);
 
               F77_FUNC (cfftb, CFFTB) (npts, prow, pwsave);
 
               for (octave_idx_type l = 0; l < npts; l++)
-                retval ((l + k*npts)*stride + j*dist) = prow[l] /
+                retval((l + k*npts)*stride + j*dist) = prow[l] /
                   static_cast<float> (npts);
             }
         }
@@ -426,12 +426,12 @@
               octave_quit ();
 
               for (octave_idx_type l = 0; l < npts; l++)
-                prow[l] = retval ((l + k*npts)*stride + j*dist);
+                prow[l] = retval((l + k*npts)*stride + j*dist);
 
               F77_FUNC (cfftf, CFFTF) (npts, prow, pwsave);
 
               for (octave_idx_type l = 0; l < npts; l++)
-                retval ((l + k*npts)*stride + j*dist) = prow[l];
+                retval((l + k*npts)*stride + j*dist) = prow[l];
             }
         }
 
@@ -473,12 +473,12 @@
               octave_quit ();
 
               for (octave_idx_type l = 0; l < npts; l++)
-                prow[l] = retval ((l + k*npts)*stride + j*dist);
+                prow[l] = retval((l + k*npts)*stride + j*dist);
 
               F77_FUNC (cfftb, CFFTB) (npts, prow, pwsave);
 
               for (octave_idx_type l = 0; l < npts; l++)
-                retval ((l + k*npts)*stride + j*dist) = prow[l] /
+                retval((l + k*npts)*stride + j*dist) = prow[l] /
                   static_cast<float> (npts);
             }
         }
@@ -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
+++ b/liboctave/fCNDArray.h
@@ -135,13 +135,13 @@
   friend OCTAVE_API std::ostream& operator << (std::ostream& os, const FloatComplexNDArray& a);
   friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatComplexNDArray& a);
 
-  static FloatComplex resize_fill_value (void) { return FloatComplex (0.0, 0.0); }
-
   //  bool all_elements_are_real (void) const;
   //  bool all_integers (float& max_val, float& min_val) const;
 
   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/fCRowVector.cc
+++ b/liboctave/fCRowVector.cc
@@ -411,7 +411,7 @@
 std::istream&
 operator >> (std::istream& is, FloatComplexRowVector& a)
 {
-  octave_idx_type len = a.length();
+  octave_idx_type len = a.length ();
 
   if (len > 0)
     {
--- a/liboctave/fCRowVector.h
+++ b/liboctave/fCRowVector.h
@@ -116,8 +116,7 @@
   friend std::ostream& operator << (std::ostream& os, const FloatComplexRowVector& a);
   friend std::istream& operator >> (std::istream& is, FloatComplexRowVector& a);
 
-  void resize (octave_idx_type n,
-               const FloatComplex& rfv = Array<FloatComplex>::resize_fill_value ())
+  void resize (octave_idx_type n, const FloatComplex& rfv = FloatComplex (0))
   {
     Array<FloatComplex>::resize (dim_vector (1, n), rfv);
   }
--- a/liboctave/fCmplxGEPBAL.cc
+++ b/liboctave/fCmplxGEPBAL.cc
@@ -69,7 +69,7 @@
       return -1;
     }
 
-  if (a.dims() != b.dims ())
+  if (a.dims () != b.dims ())
     {
       gripe_nonconformant ("FloatComplexGEPBALANCE", n, n, b.rows(), b.cols());
       return -1;
--- a/liboctave/fColVector.cc
+++ b/liboctave/fColVector.cc
@@ -142,7 +142,7 @@
 FloatRowVector
 FloatColumnVector::transpose (void) const
 {
-  return MArray<float>::transpose();
+  return MArray<float>::transpose ();
 }
 
 FloatColumnVector
@@ -307,7 +307,7 @@
 std::istream&
 operator >> (std::istream& is, FloatColumnVector& a)
 {
-  octave_idx_type len = a.length();
+  octave_idx_type len = a.length ();
 
   if (len > 0)
     {
--- a/liboctave/fColVector.h
+++ b/liboctave/fColVector.h
@@ -102,8 +102,7 @@
   friend OCTAVE_API std::ostream& operator << (std::ostream& os, const FloatColumnVector& a);
   friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatColumnVector& a);
 
-  void resize (octave_idx_type n,
-               const float& rfv = Array<float>::resize_fill_value ())
+  void resize (octave_idx_type n, const float& rfv = 0)
   {
     Array<float>::resize (dim_vector (n, 1), rfv);
   }
--- a/liboctave/fDiagMatrix.h
+++ b/liboctave/fDiagMatrix.h
@@ -74,7 +74,7 @@
   FloatDiagMatrix& fill (const FloatColumnVector& a, octave_idx_type beg);
   FloatDiagMatrix& fill (const FloatRowVector& a, octave_idx_type beg);
 
-  FloatDiagMatrix transpose (void) const { return MDiagArray2<float>::transpose(); }
+  FloatDiagMatrix transpose (void) const { return MDiagArray2<float>::transpose (); }
   FloatDiagMatrix abs (void) const;
 
   friend OCTAVE_API FloatDiagMatrix real (const FloatComplexDiagMatrix& a);
--- a/liboctave/fEIG.cc
+++ b/liboctave/fEIG.cc
@@ -686,7 +686,7 @@
   octave_idx_type n = a.rows ();
   octave_idx_type nb = b.rows ();
 
-  if (n != a.cols () || nb != b.cols())
+  if (n != a.cols () || nb != b.cols ())
     {
       (*current_liboctave_error_handler) ("EIG requires square matrix");
       return -1;
--- a/liboctave/fMatrix.cc
+++ b/liboctave/fMatrix.cc
@@ -763,7 +763,7 @@
       // Calculate the norm of the matrix, for later use.
       float anorm = 0;
       if (calc_cond)
-        anorm = retval.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+        anorm = retval.abs ().sum ().row(static_cast<octave_idx_type>(0)).max ();
 
       F77_XFCN (sgetrf, SGETRF, (nc, nc, tmp_data, nr, pipvt, info));
 
@@ -802,7 +802,7 @@
         }
 
       if (info != 0)
-        mattype.mark_as_rectangular();
+        mattype.mark_as_rectangular ();
     }
 
   return retval;
@@ -1461,8 +1461,8 @@
             {
               octave_idx_type info = 0;
               char job = 'L';
-              anorm = atmp.abs().sum().
-                row(static_cast<octave_idx_type>(0)).max();
+              anorm = atmp.abs ().sum ().
+                row(static_cast<octave_idx_type>(0)).max ();
 
               F77_XFCN (spotrf, SPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
                                          tmp_data, nr, info
@@ -1499,8 +1499,8 @@
               octave_idx_type *pipvt = ipvt.fortran_vec ();
 
               if(anorm < 0.)
-                anorm = atmp.abs().sum().
-                  row(static_cast<octave_idx_type>(0)).max();
+                anorm = atmp.abs ().sum ().
+                  row(static_cast<octave_idx_type>(0)).max ();
 
               Array<float> z (dim_vector (4 * nc, 1));
               float *pz = z.fortran_vec ();
@@ -1762,7 +1762,7 @@
           char job = 'L';
           FloatMatrix atmp = *this;
           float *tmp_data = atmp.fortran_vec ();
-          anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+          anorm = atmp.abs ().sum ().row(static_cast<octave_idx_type>(0)).max ();
 
           F77_XFCN (spotrf, SPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
                                      tmp_data, nr, info
@@ -1818,7 +1818,7 @@
 
                   F77_XFCN (spotrs, SPOTRS, (F77_CONST_CHAR_ARG2 (&job, 1),
                                              nr, b_nc, tmp_data, nr,
-                                             result, b.rows(), info
+                                             result, b.rows (), info
                                              F77_CHAR_ARG_LEN (1)));
                 }
               else
@@ -1839,7 +1839,7 @@
           FloatMatrix atmp = *this;
           float *tmp_data = atmp.fortran_vec ();
           if(anorm < 0.)
-            anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max();
+            anorm = atmp.abs ().sum ().row(static_cast<octave_idx_type>(0)).max ();
 
           Array<float> z (dim_vector (4 * nc, 1));
           float *pz = z.fortran_vec ();
@@ -1902,7 +1902,7 @@
                   char job = 'N';
                   F77_XFCN (sgetrs, SGETRS, (F77_CONST_CHAR_ARG2 (&job, 1),
                                              nr, b_nc, tmp_data, nr,
-                                             pipvt, result, b.rows(), info
+                                             pipvt, result, b.rows (), info
                                              F77_CHAR_ARG_LEN (1)));
                 }
               else
@@ -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
 {
@@ -3113,22 +3130,23 @@
 
 // matrix by matrix -> matrix operations
 
-/* Simple Dot Product, Matrix-Vector and Matrix-Matrix Unit tests
-%!assert(single([1 2 3]) * single([ 4 ; 5 ; 6]), single(32), 5e-7)
-%!assert(single([1 2 ; 3 4 ]) * single([5 ; 6]), single([17 ; 39 ]), 5e-7)
-%!assert(single([1 2 ; 3 4 ]) * single([5 6 ; 7 8]), single([19 22; 43 50]), 5e-7)
-*/
-
-/* Test some simple identities
+/*
+## Simple Dot Product, Matrix-Vector, and Matrix-Matrix Unit tests
+%!assert (single ([1 2 3]) * single ([ 4 ; 5 ; 6]), single (32), 5e-7)
+%!assert (single ([1 2 ; 3 4]) * single ([5 ; 6]), single ([17 ; 39]), 5e-7)
+%!assert (single ([1 2 ; 3 4]) * single ([5 6 ; 7 8]), single ([19 22; 43 50]), 5e-7)
+
+## Test some simple identities
 %!shared M, cv, rv
-%! M = single(randn(10,10));
-%! cv = single(randn(10,1));
-%! rv = single(randn(1,10));
-%!assert([M*cv,M*cv],M*[cv,cv],5e-6)
-%!assert([M'*cv,M'*cv],M'*[cv,cv],5e-6)
-%!assert([rv*M;rv*M],[rv;rv]*M,5e-6)
-%!assert([rv*M';rv*M'],[rv;rv]*M',5e-6)
-%!assert(2*rv*cv,[rv,rv]*[cv;cv],5e-6)
+%! M = single (randn (10,10));
+%! cv = single (randn (10,1));
+%! rv = single (randn (1,10));
+%!assert ([M*cv,M*cv], M*[cv,cv], 5e-6)
+%!assert ([M'*cv,M'*cv], M'*[cv,cv], 5e-6)
+%!assert ([rv*M;rv*M], [rv;rv]*M, 5e-6)
+%!assert ([rv*M';rv*M'], [rv;rv]*M', 5e-6)
+%!assert (2*rv*cv, [rv,rv]*[cv;cv], 5e-6)
+
 */
 
 static char
--- a/liboctave/fMatrix.h
+++ b/liboctave/fMatrix.h
@@ -126,8 +126,7 @@
 
   FloatColumnVector column (octave_idx_type i) const;
 
-  void resize (octave_idx_type nr, octave_idx_type nc,
-               float rfv = resize_fill_value ())
+  void resize (octave_idx_type nr, octave_idx_type nc, float rfv = 0)
   {
     MArray<float>::resize (dim_vector (nr, nc), rfv);
   }
@@ -316,6 +315,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;
 
@@ -332,9 +333,6 @@
 
   friend OCTAVE_API std::ostream& operator << (std::ostream& os, const FloatMatrix& a);
   friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatMatrix& a);
-
-  static float resize_fill_value (void) { return 0; }
-
 };
 
 // Publish externally used friend functions.
--- a/liboctave/fNDArray.cc
+++ b/liboctave/fNDArray.cc
@@ -118,7 +118,7 @@
 FloatComplexNDArray
 FloatNDArray::fourier2d (void) const
 {
-  dim_vector dv = dims();
+  dim_vector dv = dims ();
   if (dv.length () < 2)
     return FloatComplexNDArray ();
 
@@ -126,7 +126,7 @@
   const float *in = fortran_vec ();
   FloatComplexNDArray retval (dv);
   FloatComplex *out = retval.fortran_vec ();
-  octave_idx_type howmany = numel() / dv(0) / dv(1);
+  octave_idx_type howmany = numel () / dv(0) / dv(1);
   octave_idx_type dist = dv(0) * dv(1);
 
   for (octave_idx_type i=0; i < howmany; i++)
@@ -138,14 +138,14 @@
 FloatComplexNDArray
 FloatNDArray::ifourier2d (void) const
 {
-  dim_vector dv = dims();
+  dim_vector dv = dims ();
   if (dv.length () < 2)
     return FloatComplexNDArray ();
 
   dim_vector dv2(dv(0), dv(1));
   FloatComplexNDArray retval (*this);
   FloatComplex *out = retval.fortran_vec ();
-  octave_idx_type howmany = numel() / dv(0) / dv(1);
+  octave_idx_type howmany = numel () / dv(0) / dv(1);
   octave_idx_type dist = dv(0) * dv(1);
 
   for (octave_idx_type i=0; i < howmany; i++)
@@ -246,7 +246,7 @@
           F77_FUNC (cfftf, CFFTF) (npts, tmp, pwsave);
 
           for (octave_idx_type i = 0; i < npts; i++)
-            retval ((i + k*npts)*stride + j*dist) = tmp[i];
+            retval((i + k*npts)*stride + j*dist) = tmp[i];
         }
     }
 
@@ -293,7 +293,7 @@
           F77_FUNC (cfftb, CFFTB) (npts, tmp, pwsave);
 
           for (octave_idx_type i = 0; i < npts; i++)
-            retval ((i + k*npts)*stride + j*dist) = tmp[i] /
+            retval((i + k*npts)*stride + j*dist) = tmp[i] /
               static_cast<float> (npts);
         }
     }
@@ -304,7 +304,7 @@
 FloatComplexNDArray
 FloatNDArray::fourier2d (void) const
 {
-  dim_vector dv = dims();
+  dim_vector dv = dims ();
   dim_vector dv2 (dv(0), dv(1));
   int rank = 2;
   FloatComplexNDArray retval (*this);
@@ -334,12 +334,12 @@
               octave_quit ();
 
               for (octave_idx_type l = 0; l < npts; l++)
-                prow[l] = retval ((l + k*npts)*stride + j*dist);
+                prow[l] = retval((l + k*npts)*stride + j*dist);
 
               F77_FUNC (cfftf, CFFTF) (npts, prow, pwsave);
 
               for (octave_idx_type l = 0; l < npts; l++)
-                retval ((l + k*npts)*stride + j*dist) = prow[l];
+                retval((l + k*npts)*stride + j*dist) = prow[l];
             }
         }
 
@@ -352,7 +352,7 @@
 FloatComplexNDArray
 FloatNDArray::ifourier2d (void) const
 {
-  dim_vector dv = dims();
+  dim_vector dv = dims ();
   dim_vector dv2 (dv(0), dv(1));
   int rank = 2;
   FloatComplexNDArray retval (*this);
@@ -382,12 +382,12 @@
               octave_quit ();
 
               for (octave_idx_type l = 0; l < npts; l++)
-                prow[l] = retval ((l + k*npts)*stride + j*dist);
+                prow[l] = retval((l + k*npts)*stride + j*dist);
 
               F77_FUNC (cfftb, CFFTB) (npts, prow, pwsave);
 
               for (octave_idx_type l = 0; l < npts; l++)
-                retval ((l + k*npts)*stride + j*dist) = prow[l] /
+                retval((l + k*npts)*stride + j*dist) = prow[l] /
                   static_cast<float> (npts);
             }
         }
@@ -430,12 +430,12 @@
               octave_quit ();
 
               for (octave_idx_type l = 0; l < npts; l++)
-                prow[l] = retval ((l + k*npts)*stride + j*dist);
+                prow[l] = retval((l + k*npts)*stride + j*dist);
 
               F77_FUNC (cfftf, CFFTF) (npts, prow, pwsave);
 
               for (octave_idx_type l = 0; l < npts; l++)
-                retval ((l + k*npts)*stride + j*dist) = prow[l];
+                retval((l + k*npts)*stride + j*dist) = prow[l];
             }
         }
 
@@ -477,12 +477,12 @@
               octave_quit ();
 
               for (octave_idx_type l = 0; l < npts; l++)
-                prow[l] = retval ((l + k*npts)*stride + j*dist);
+                prow[l] = retval((l + k*npts)*stride + j*dist);
 
               F77_FUNC (cfftb, CFFTB) (npts, prow, pwsave);
 
               for (octave_idx_type l = 0; l < npts; l++)
-                retval ((l + k*npts)*stride + j*dist) = prow[l] /
+                retval((l + k*npts)*stride + j*dist) = prow[l] /
                   static_cast<float> (npts);
             }
         }
@@ -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
+++ b/liboctave/fNDArray.h
@@ -147,9 +147,9 @@
   friend OCTAVE_API std::ostream& operator << (std::ostream& os, const FloatNDArray& a);
   friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatNDArray& a);
 
-  static float resize_fill_value (void) { return 0; }
+  FloatNDArray diag (octave_idx_type k = 0) const;
 
-  FloatNDArray diag (octave_idx_type k = 0) const;
+  FloatNDArray diag (octave_idx_type m, octave_idx_type n) const;
 
   FloatNDArray& changesign (void)
     {
--- a/liboctave/fRowVector.cc
+++ b/liboctave/fRowVector.cc
@@ -146,7 +146,7 @@
 FloatColumnVector
 FloatRowVector::transpose (void) const
 {
-  return MArray<float>::transpose();
+  return MArray<float>::transpose ();
 }
 
 FloatRowVector
@@ -271,7 +271,7 @@
 std::istream&
 operator >> (std::istream& is, FloatRowVector& a)
 {
-  octave_idx_type len = a.length();
+  octave_idx_type len = a.length ();
 
   if (len > 0)
     {
--- a/liboctave/fRowVector.h
+++ b/liboctave/fRowVector.h
@@ -93,8 +93,7 @@
   friend OCTAVE_API std::ostream& operator << (std::ostream& os, const FloatRowVector& a);
   friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatRowVector& a);
 
-  void resize (octave_idx_type n,
-               const float& rfv = Array<float>::resize_fill_value ())
+  void resize (octave_idx_type n, const float& rfv = 0)
   {
     Array<float>::resize (dim_vector (1, n), rfv);
   }
--- a/liboctave/file-ops.cc
+++ b/liboctave/file-ops.cc
@@ -356,7 +356,7 @@
 {
   return dir.empty ()
     ? file
-    : (is_dir_sep (dir[dir.length()-1])
+    : (is_dir_sep (dir[dir.length ()-1])
        ? dir + file
        : dir + dir_sep_char () + file);
 }
--- a/liboctave/file-stat.cc
+++ b/liboctave/file-stat.cc
@@ -189,7 +189,7 @@
       // Remove trailing slash.
       if (file_ops::is_dir_sep (full_file_name[full_file_name.length () - 1])
           && full_file_name.length () != 1
-          && ! (full_file_name.length() == 3 && full_file_name[1] == ':'))
+          && ! (full_file_name.length () == 3 && full_file_name[1] == ':'))
         full_file_name.resize (full_file_name.length () - 1);
 #endif
 
--- a/liboctave/floatCHOL.cc
+++ b/liboctave/floatCHOL.cc
@@ -157,7 +157,7 @@
       octave_idx_type info = 0;
 
       FloatMatrix tmp = r;
-      float *v = tmp.fortran_vec();
+      float *v = tmp.fortran_vec ();
 
       if (info == 0)
         {
--- a/liboctave/floatGEPBAL.cc
+++ b/liboctave/floatGEPBAL.cc
@@ -70,7 +70,7 @@
       return -1;
     }
 
-  if (a.dims() != b.dims ())
+  if (a.dims () != b.dims ())
     {
       gripe_nonconformant ("FloatGEPBALANCE", n, n, b.rows(), b.cols());
       return -1;
--- a/liboctave/idx-vector.h
+++ b/liboctave/idx-vector.h
@@ -604,7 +604,7 @@
     { return orig_dimensions () (1); }
 
   int orig_empty (void) const
-    { return (! is_colon () && orig_dimensions().any_zero ()); }
+    { return (! is_colon () && orig_dimensions ().any_zero ()); }
 
   // i/o
 
--- a/liboctave/intNDArray.cc
+++ b/liboctave/intNDArray.cc
@@ -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
+++ b/liboctave/intNDArray.h
@@ -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 ();
@@ -113,9 +115,6 @@
 
   static octave_idx_type compute_index (Array<octave_idx_type>& ra_idx,
                             const dim_vector& dimensions);
-
-  static T resize_fill_value (void) { return 0; }
-
 };
 
 // i/o
--- a/liboctave/lo-ieee.h
+++ b/liboctave/lo-ieee.h
@@ -118,4 +118,26 @@
 #define lo_ieee_signbit(x) (sizeof (x) == sizeof (float) ? \
                           __lo_ieee_float_signbit (x) : __lo_ieee_signbit (x))
 
+#ifdef __cplusplus
+
+template <typename T>
+struct octave_numeric_limits
+{
+  static T NA (void) { return static_cast<T> (0); }
+};
+
+template <>
+struct octave_numeric_limits<double>
+{
+  static double NA (void) { return octave_NA; }
+};
+
+template <>
+struct octave_numeric_limits<float>
+{
+  static float NA (void) { return octave_Float_NA; }
+};
+
 #endif
+
+#endif
--- a/liboctave/lo-specfun.cc
+++ b/liboctave/lo-specfun.cc
@@ -460,7 +460,7 @@
 
   if (std:: abs (x) < 1)
     {
-      double im = x.imag();
+      double im = x.imag ();
       double u = expm1 (x.real ());
       double v = sin (im/2);
       v = -2*v*v;
@@ -515,7 +515,7 @@
 
   if (std:: abs (x) < 1)
     {
-      float im = x.imag();
+      float im = x.imag ();
       float u = expm1 (x.real ());
       float v = sin (im/2);
       v = -2*v*v;
@@ -556,7 +556,7 @@
 {
   Complex retval;
 
-  double r = x.real (), i = x.imag();
+  double r = x.real (), i = x.imag ();
 
   if (fabs (r) < 0.5 && fabs (i) < 0.5)
     {
@@ -615,7 +615,7 @@
 {
   FloatComplex retval;
 
-  float r = x.real (), i = x.imag();
+  float r = x.real (), i = x.imag ();
 
   if (fabs (r) < 0.5 && fabs (i) < 0.5)
     {
@@ -873,7 +873,7 @@
           if (kode == 2)
             {
               // Compensate for different scaling factor of besk.
-              tmp2 *= exp(-z - std::abs(z.real()));
+              tmp2 *= exp(-z - std::abs(z.real ()));
             }
 
           tmp += tmp2;
@@ -1483,7 +1483,7 @@
           if (kode == 2)
             {
               // Compensate for different scaling factor of besk.
-              tmp2 *= exp(-z - std::abs(z.real()));
+              tmp2 *= exp(-z - std::abs(z.real ()));
             }
 
           tmp += tmp2;
@@ -1986,7 +1986,7 @@
   ierr.resize (dv);
 
   for (octave_idx_type i = 0; i < nel; i++)
-    retval (i) = airy (z(i), deriv, scaled, ierr(i));
+    retval(i) = airy (z(i), deriv, scaled, ierr(i));
 
   return retval;
 }
@@ -2001,7 +2001,7 @@
   ierr.resize (dv);
 
   for (octave_idx_type i = 0; i < nel; i++)
-    retval (i) = biry (z(i), deriv, scaled, ierr(i));
+    retval(i) = biry (z(i), deriv, scaled, ierr(i));
 
   return retval;
 }
@@ -2116,7 +2116,7 @@
   ierr.resize (dv);
 
   for (octave_idx_type i = 0; i < nel; i++)
-    retval (i) = airy (z(i), deriv, scaled, ierr(i));
+    retval(i) = airy (z(i), deriv, scaled, ierr(i));
 
   return retval;
 }
@@ -2131,7 +2131,7 @@
   ierr.resize (dv);
 
   for (octave_idx_type i = 0; i < nel; i++)
-    retval (i) = biry (z(i), deriv, scaled, ierr(i));
+    retval(i) = biry (z(i), deriv, scaled, ierr(i));
 
   return retval;
 }
@@ -2158,6 +2158,28 @@
    d1_str.c_str (), d2_str.c_str (), d3_str.c_str ());
 }
 
+static void
+gripe_betaincinv_nonconformant (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2, octave_idx_type r3,
+                                octave_idx_type c3)
+{
+  (*current_liboctave_error_handler)
+   ("betaincinv: nonconformant arguments (x is %dx%d, a is %dx%d, b is %dx%d)",
+     r1, c1, r2, c2, r3, c3);
+}
+
+static void
+gripe_betaincinv_nonconformant (const dim_vector& d1, const dim_vector& d2,
+                                const dim_vector& d3)
+{
+  std::string d1_str = d1.str ();
+  std::string d2_str = d2.str ();
+  std::string d3_str = d3.str ();
+
+  (*current_liboctave_error_handler)
+  ("betaincinv: nonconformant arguments (x is %s, a is %s, b is %s)",
+   d1_str.c_str (), d2_str.c_str (), d3_str.c_str ());
+}
+
 double
 betainc (double x, double a, double b)
 {
@@ -2166,93 +2188,42 @@
   return retval;
 }
 
-Matrix
-betainc (double x, double a, const Matrix& b)
+Array<double>
+betainc (double x, double a, const Array<double>& b)
 {
-  octave_idx_type nr = b.rows ();
-  octave_idx_type nc = b.cols ();
-
-  Matrix retval (nr, nc);
-
-  for (octave_idx_type j = 0; j < nc; j++)
-    for (octave_idx_type i = 0; i < nr; i++)
-      retval(i,j) = betainc (x, a, b(i,j));
-
-  return retval;
-}
-
-Matrix
-betainc (double x, const Matrix& a, double b)
-{
-  octave_idx_type nr = a.rows ();
-  octave_idx_type nc = a.cols ();
-
-  Matrix retval (nr, nc);
-
-  for (octave_idx_type j = 0; j < nc; j++)
-    for (octave_idx_type i = 0; i < nr; i++)
-      retval(i,j) = betainc (x, a(i,j), b);
+  dim_vector dv = b.dims ();
+  octave_idx_type nel = dv.numel ();
+
+  Array<double> retval (dv);
+
+  double *pretval = retval.fortran_vec ();
+
+  for (octave_idx_type i = 0; i < nel; i++)
+    *pretval++ = betainc (x, a, b(i));
 
   return retval;
 }
 
-Matrix
-betainc (double x, const Matrix& a, const Matrix& b)
+Array<double>
+betainc (double x, const Array<double>& a, double b)
 {
-  Matrix retval;
-
-  octave_idx_type a_nr = a.rows ();
-  octave_idx_type a_nc = a.cols ();
-
-  octave_idx_type b_nr = b.rows ();
-  octave_idx_type b_nc = b.cols ();
-
-  if (a_nr == b_nr && a_nc == b_nc)
-    {
-      retval.resize (a_nr, a_nc);
-
-      for (octave_idx_type j = 0; j < a_nc; j++)
-        for (octave_idx_type i = 0; i < a_nr; i++)
-          retval(i,j) = betainc (x, a(i,j), b(i,j));
-    }
-  else
-    gripe_betainc_nonconformant (1, 1, a_nr, a_nc, b_nr, b_nc);
+  dim_vector dv = a.dims ();
+  octave_idx_type nel = dv.numel ();
+
+  Array<double> retval (dv);
+
+  double *pretval = retval.fortran_vec ();
+
+  for (octave_idx_type i = 0; i < nel; i++)
+    *pretval++ = betainc (x, a(i), b);
 
   return retval;
 }
 
-NDArray
-betainc (double x, double a, const NDArray& b)
+Array<double>
+betainc (double x, const Array<double>& a, const Array<double>& b)
 {
-  dim_vector dv = b.dims ();
-  octave_idx_type nel = dv.numel ();
-
-  NDArray retval (dv);
-
-  for (octave_idx_type i = 0; i < nel; i++)
-    retval (i) = betainc (x, a, b(i));
-
-  return retval;
-}
-
-NDArray
-betainc (double x, const NDArray& a, double b)
-{
-  dim_vector dv = a.dims ();
-  octave_idx_type nel = dv.numel ();
-
-  NDArray retval (dv);
-
-  for (octave_idx_type i = 0; i < nel; i++)
-    retval (i) = betainc (x, a(i), b);
-
-  return retval;
-}
-
-NDArray
-betainc (double x, const NDArray& a, const NDArray& b)
-{
-  NDArray retval;
+  Array<double> retval;
   dim_vector dv = a.dims ();
 
   if (dv == b.dims ())
@@ -2261,8 +2232,10 @@
 
       retval.resize (dv);
 
+      double *pretval = retval.fortran_vec ();
+
       for (octave_idx_type i = 0; i < nel; i++)
-        retval (i) = betainc (x, a(i), b(i));
+        *pretval++ = betainc (x, a(i), b(i));
     }
   else
     gripe_betainc_nonconformant (dim_vector (0, 0), dv, b.dims ());
@@ -2270,118 +2243,26 @@
   return retval;
 }
 
-
-Matrix
-betainc (const Matrix& x, double a, double b)
-{
-  octave_idx_type nr = x.rows ();
-  octave_idx_type nc = x.cols ();
-
-  Matrix retval (nr, nc);
-
-  for (octave_idx_type j = 0; j < nc; j++)
-    for (octave_idx_type i = 0; i < nr; i++)
-      retval(i,j) = betainc (x(i,j), a, b);
-
-  return retval;
-}
-
-Matrix
-betainc (const Matrix& x, double a, const Matrix& b)
+Array<double>
+betainc (const Array<double>& x, double a, double b)
 {
-  Matrix retval;
-
-  octave_idx_type nr = x.rows ();
-  octave_idx_type nc = x.cols ();
-
-  octave_idx_type b_nr = b.rows ();
-  octave_idx_type b_nc = b.cols ();
-
-  if (nr == b_nr && nc == b_nc)
-    {
-      retval.resize (nr, nc);
-
-      for (octave_idx_type j = 0; j < nc; j++)
-        for (octave_idx_type i = 0; i < nr; i++)
-          retval(i,j) = betainc (x(i,j), a, b(i,j));
-    }
-  else
-    gripe_betainc_nonconformant (nr, nc, 1, 1, b_nr, b_nc);
+  dim_vector dv = x.dims ();
+  octave_idx_type nel = dv.numel ();
+
+  Array<double> retval (dv);
+
+  double *pretval = retval.fortran_vec ();
+
+  for (octave_idx_type i = 0; i < nel; i++)
+    *pretval++ = betainc (x(i), a, b);
 
   return retval;
 }
 
-Matrix
-betainc (const Matrix& x, const Matrix& a, double b)
-{
-  Matrix retval;
-
-  octave_idx_type nr = x.rows ();
-  octave_idx_type nc = x.cols ();
-
-  octave_idx_type a_nr = a.rows ();
-  octave_idx_type a_nc = a.cols ();
-
-  if (nr == a_nr && nc == a_nc)
-    {
-      retval.resize (nr, nc);
-
-      for (octave_idx_type j = 0; j < nc; j++)
-        for (octave_idx_type i = 0; i < nr; i++)
-          retval(i,j) = betainc (x(i,j), a(i,j), b);
-    }
-  else
-    gripe_betainc_nonconformant (nr, nc, a_nr, a_nc, 1, 1);
-
-  return retval;
-}
-
-Matrix
-betainc (const Matrix& x, const Matrix& a, const Matrix& b)
+Array<double>
+betainc (const Array<double>& x, double a, const Array<double>& b)
 {
-  Matrix retval;
-
-  octave_idx_type nr = x.rows ();
-  octave_idx_type nc = x.cols ();
-
-  octave_idx_type a_nr = a.rows ();
-  octave_idx_type a_nc = a.cols ();
-
-  octave_idx_type b_nr = b.rows ();
-  octave_idx_type b_nc = b.cols ();
-
-  if (nr == a_nr && nr == b_nr && nc == a_nc && nc == b_nc)
-    {
-      retval.resize (nr, nc);
-
-      for (octave_idx_type j = 0; j < nc; j++)
-        for (octave_idx_type i = 0; i < nr; i++)
-          retval(i,j) = betainc (x(i,j), a(i,j), b(i,j));
-    }
-  else
-    gripe_betainc_nonconformant (nr, nc, a_nr, a_nc, b_nr, b_nc);
-
-  return retval;
-}
-
-NDArray
-betainc (const NDArray& x, double a, double b)
-{
-  dim_vector dv = x.dims ();
-  octave_idx_type nel = dv.numel ();
-
-  NDArray retval (dv);
-
-  for (octave_idx_type i = 0; i < nel; i++)
-    retval (i) = betainc (x(i), a, b);
-
-  return retval;
-}
-
-NDArray
-betainc (const NDArray& x, double a, const NDArray& b)
-{
-  NDArray retval;
+  Array<double> retval;
   dim_vector dv = x.dims ();
 
   if (dv == b.dims ())
@@ -2390,8 +2271,10 @@
 
       retval.resize (dv);
 
+      double *pretval = retval.fortran_vec ();
+
       for (octave_idx_type i = 0; i < nel; i++)
-        retval (i) = betainc (x(i), a, b(i));
+        *pretval++ = betainc (x(i), a, b(i));
     }
   else
     gripe_betainc_nonconformant (dv, dim_vector (0, 0), b.dims ());
@@ -2399,10 +2282,10 @@
   return retval;
 }
 
-NDArray
-betainc (const NDArray& x, const NDArray& a, double b)
+Array<double>
+betainc (const Array<double>& x, const Array<double>& a, double b)
 {
-  NDArray retval;
+  Array<double> retval;
   dim_vector dv = x.dims ();
 
   if (dv == a.dims ())
@@ -2411,8 +2294,10 @@
 
       retval.resize (dv);
 
+      double *pretval = retval.fortran_vec ();
+
       for (octave_idx_type i = 0; i < nel; i++)
-        retval (i) = betainc (x(i), a(i), b);
+        *pretval++ = betainc (x(i), a(i), b);
     }
   else
     gripe_betainc_nonconformant (dv, a.dims (), dim_vector (0, 0));
@@ -2420,10 +2305,10 @@
   return retval;
 }
 
-NDArray
-betainc (const NDArray& x, const NDArray& a, const NDArray& b)
+Array<double>
+betainc (const Array<double>& x, const Array<double>& a, const Array<double>& b)
 {
-  NDArray retval;
+  Array<double> retval;
   dim_vector dv = x.dims ();
 
   if (dv == a.dims () && dv == b.dims ())
@@ -2432,8 +2317,10 @@
 
       retval.resize (dv);
 
+      double *pretval = retval.fortran_vec ();
+
       for (octave_idx_type i = 0; i < nel; i++)
-        retval (i) = betainc (x(i), a(i), b(i));
+        *pretval++ = betainc (x(i), a(i), b(i));
     }
   else
     gripe_betainc_nonconformant (dv, a.dims (), b.dims ());
@@ -2449,93 +2336,42 @@
   return retval;
 }
 
-FloatMatrix
-betainc (float x, float a, const FloatMatrix& b)
+Array<float>
+betainc (float x, float a, const Array<float>& b)
 {
-  octave_idx_type nr = b.rows ();
-  octave_idx_type nc = b.cols ();
-
-  FloatMatrix retval (nr, nc);
-
-  for (octave_idx_type j = 0; j < nc; j++)
-    for (octave_idx_type i = 0; i < nr; i++)
-      retval(i,j) = betainc (x, a, b(i,j));
-
-  return retval;
-}
-
-FloatMatrix
-betainc (float x, const FloatMatrix& a, float b)
-{
-  octave_idx_type nr = a.rows ();
-  octave_idx_type nc = a.cols ();
-
-  FloatMatrix retval (nr, nc);
-
-  for (octave_idx_type j = 0; j < nc; j++)
-    for (octave_idx_type i = 0; i < nr; i++)
-      retval(i,j) = betainc (x, a(i,j), b);
+  dim_vector dv = b.dims ();
+  octave_idx_type nel = dv.numel ();
+
+  Array<float> retval (dv);
+
+  float *pretval = retval.fortran_vec ();
+
+  for (octave_idx_type i = 0; i < nel; i++)
+    *pretval++ = betainc (x, a, b(i));
 
   return retval;
 }
 
-FloatMatrix
-betainc (float x, const FloatMatrix& a, const FloatMatrix& b)
+Array<float>
+betainc (float x, const Array<float>& a, float b)
 {
-  FloatMatrix retval;
-
-  octave_idx_type a_nr = a.rows ();
-  octave_idx_type a_nc = a.cols ();
-
-  octave_idx_type b_nr = b.rows ();
-  octave_idx_type b_nc = b.cols ();
-
-  if (a_nr == b_nr && a_nc == b_nc)
-    {
-      retval.resize (a_nr, a_nc);
-
-      for (octave_idx_type j = 0; j < a_nc; j++)
-        for (octave_idx_type i = 0; i < a_nr; i++)
-          retval(i,j) = betainc (x, a(i,j), b(i,j));
-    }
-  else
-    gripe_betainc_nonconformant (1, 1, a_nr, a_nc, b_nr, b_nc);
+  dim_vector dv = a.dims ();
+  octave_idx_type nel = dv.numel ();
+
+  Array<float> retval (dv);
+
+  float *pretval = retval.fortran_vec ();
+
+  for (octave_idx_type i = 0; i < nel; i++)
+    *pretval++ = betainc (x, a(i), b);
 
   return retval;
 }
 
-FloatNDArray
-betainc (float x, float a, const FloatNDArray& b)
+Array<float>
+betainc (float x, const Array<float>& a, const Array<float>& b)
 {
-  dim_vector dv = b.dims ();
-  octave_idx_type nel = dv.numel ();
-
-  FloatNDArray retval (dv);
-
-  for (octave_idx_type i = 0; i < nel; i++)
-    retval (i) = betainc (x, a, b(i));
-
-  return retval;
-}
-
-FloatNDArray
-betainc (float x, const FloatNDArray& a, float b)
-{
-  dim_vector dv = a.dims ();
-  octave_idx_type nel = dv.numel ();
-
-  FloatNDArray retval (dv);
-
-  for (octave_idx_type i = 0; i < nel; i++)
-    retval (i) = betainc (x, a(i), b);
-
-  return retval;
-}
-
-FloatNDArray
-betainc (float x, const FloatNDArray& a, const FloatNDArray& b)
-{
-  FloatNDArray retval;
+  Array<float> retval;
   dim_vector dv = a.dims ();
 
   if (dv == b.dims ())
@@ -2544,8 +2380,10 @@
 
       retval.resize (dv);
 
+      float *pretval = retval.fortran_vec ();
+
       for (octave_idx_type i = 0; i < nel; i++)
-        retval (i) = betainc (x, a(i), b(i));
+        *pretval++ = betainc (x, a(i), b(i));
     }
   else
     gripe_betainc_nonconformant (dim_vector (0, 0), dv, b.dims ());
@@ -2553,118 +2391,26 @@
   return retval;
 }
 
-
-FloatMatrix
-betainc (const FloatMatrix& x, float a, float b)
-{
-  octave_idx_type nr = x.rows ();
-  octave_idx_type nc = x.cols ();
-
-  FloatMatrix retval (nr, nc);
-
-  for (octave_idx_type j = 0; j < nc; j++)
-    for (octave_idx_type i = 0; i < nr; i++)
-      retval(i,j) = betainc (x(i,j), a, b);
-
-  return retval;
-}
-
-FloatMatrix
-betainc (const FloatMatrix& x, float a, const FloatMatrix& b)
+Array<float>
+betainc (const Array<float>& x, float a, float b)
 {
-  FloatMatrix retval;
-
-  octave_idx_type nr = x.rows ();
-  octave_idx_type nc = x.cols ();
-
-  octave_idx_type b_nr = b.rows ();
-  octave_idx_type b_nc = b.cols ();
-
-  if (nr == b_nr && nc == b_nc)
-    {
-      retval.resize (nr, nc);
-
-      for (octave_idx_type j = 0; j < nc; j++)
-        for (octave_idx_type i = 0; i < nr; i++)
-          retval(i,j) = betainc (x(i,j), a, b(i,j));
-    }
-  else
-    gripe_betainc_nonconformant (nr, nc, 1, 1, b_nr, b_nc);
+  dim_vector dv = x.dims ();
+  octave_idx_type nel = dv.numel ();
+
+  Array<float> retval (dv);
+
+  float *pretval = retval.fortran_vec ();
+
+  for (octave_idx_type i = 0; i < nel; i++)
+    *pretval++ = betainc (x(i), a, b);
 
   return retval;
 }
 
-FloatMatrix
-betainc (const FloatMatrix& x, const FloatMatrix& a, float b)
-{
-  FloatMatrix retval;
-
-  octave_idx_type nr = x.rows ();
-  octave_idx_type nc = x.cols ();
-
-  octave_idx_type a_nr = a.rows ();
-  octave_idx_type a_nc = a.cols ();
-
-  if (nr == a_nr && nc == a_nc)
-    {
-      retval.resize (nr, nc);
-
-      for (octave_idx_type j = 0; j < nc; j++)
-        for (octave_idx_type i = 0; i < nr; i++)
-          retval(i,j) = betainc (x(i,j), a(i,j), b);
-    }
-  else
-    gripe_betainc_nonconformant (nr, nc, a_nr, a_nc, 1, 1);
-
-  return retval;
-}
-
-FloatMatrix
-betainc (const FloatMatrix& x, const FloatMatrix& a, const FloatMatrix& b)
+Array<float>
+betainc (const Array<float>& x, float a, const Array<float>& b)
 {
-  FloatMatrix retval;
-
-  octave_idx_type nr = x.rows ();
-  octave_idx_type nc = x.cols ();
-
-  octave_idx_type a_nr = a.rows ();
-  octave_idx_type a_nc = a.cols ();
-
-  octave_idx_type b_nr = b.rows ();
-  octave_idx_type b_nc = b.cols ();
-
-  if (nr == a_nr && nr == b_nr && nc == a_nc && nc == b_nc)
-    {
-      retval.resize (nr, nc);
-
-      for (octave_idx_type j = 0; j < nc; j++)
-        for (octave_idx_type i = 0; i < nr; i++)
-          retval(i,j) = betainc (x(i,j), a(i,j), b(i,j));
-    }
-  else
-    gripe_betainc_nonconformant (nr, nc, a_nr, a_nc, b_nr, b_nc);
-
-  return retval;
-}
-
-FloatNDArray
-betainc (const FloatNDArray& x, float a, float b)
-{
-  dim_vector dv = x.dims ();
-  octave_idx_type nel = dv.numel ();
-
-  FloatNDArray retval (dv);
-
-  for (octave_idx_type i = 0; i < nel; i++)
-    retval (i) = betainc (x(i), a, b);
-
-  return retval;
-}
-
-FloatNDArray
-betainc (const FloatNDArray& x, float a, const FloatNDArray& b)
-{
-  FloatNDArray retval;
+  Array<float> retval;
   dim_vector dv = x.dims ();
 
   if (dv == b.dims ())
@@ -2673,8 +2419,10 @@
 
       retval.resize (dv);
 
+      float *pretval = retval.fortran_vec ();
+
       for (octave_idx_type i = 0; i < nel; i++)
-        retval (i) = betainc (x(i), a, b(i));
+        *pretval++ = betainc (x(i), a, b(i));
     }
   else
     gripe_betainc_nonconformant (dv, dim_vector (0, 0), b.dims ());
@@ -2682,10 +2430,10 @@
   return retval;
 }
 
-FloatNDArray
-betainc (const FloatNDArray& x, const FloatNDArray& a, float b)
+Array<float>
+betainc (const Array<float>& x, const Array<float>& a, float b)
 {
-  FloatNDArray retval;
+  Array<float> retval;
   dim_vector dv = x.dims ();
 
   if (dv == a.dims ())
@@ -2694,8 +2442,10 @@
 
       retval.resize (dv);
 
+      float *pretval = retval.fortran_vec ();
+
       for (octave_idx_type i = 0; i < nel; i++)
-        retval (i) = betainc (x(i), a(i), b);
+        *pretval++ = betainc (x(i), a(i), b);
     }
   else
     gripe_betainc_nonconformant (dv, a.dims (), dim_vector (0, 0));
@@ -2703,10 +2453,10 @@
   return retval;
 }
 
-FloatNDArray
-betainc (const FloatNDArray& x, const FloatNDArray& a, const FloatNDArray& b)
+Array<float>
+betainc (const Array<float>& x, const Array<float>& a, const Array<float>& b)
 {
-  FloatNDArray retval;
+  Array<float> retval;
   dim_vector dv = x.dims ();
 
   if (dv == a.dims () && dv == b.dims ())
@@ -2715,8 +2465,10 @@
 
       retval.resize (dv);
 
+      float *pretval = retval.fortran_vec ();
+
       for (octave_idx_type i = 0; i < nel; i++)
-        retval (i) = betainc (x(i), a(i), b(i));
+        *pretval++ = betainc (x(i), a(i), b(i));
     }
   else
     gripe_betainc_nonconformant (dv, a.dims (), b.dims ());
@@ -3128,7 +2880,7 @@
 
       (*current_liboctave_error_handler)
         ("gammainc: nonconformant arguments (arg 1 is %s, arg 2 is %s)",
-         x_str.c_str (), a_str. c_str ());
+         x_str.c_str (), a_str.c_str ());
     }
 
  done:
@@ -3152,7 +2904,7 @@
 // This algorithm is due to P. J. Acklam.
 // See http://home.online.no/~pjacklam/notes/invnorm/
 // The rational approximation has relative accuracy 1.15e-9 in the whole region.
-// For doubles, it is refined by a single step of Higham's 3rd order method.
+// For doubles, it is refined by a single step of Halley's 3rd order method.
 // For single precision, the accuracy is already OK, so we skip it to get
 // faster evaluation.
 
@@ -3175,7 +2927,7 @@
     {  7.784695709041462e-03,  3.224671290700398e-01,
        2.445134137142996e+00,  3.754408661907416e+00 };
 
-  static const double spi2 =  8.862269254527579e-01; // sqrt(pi)/2.
+  static const double spi2 = 8.862269254527579e-01; // sqrt(pi)/2.
   static const double pbreak = 0.95150;
   double ax = fabs (x), y;
 
@@ -3204,7 +2956,7 @@
   if (refine)
     {
       // One iteration of Halley's method gives full precision.
-      double u = (erf(y) - x) * spi2 * exp (y*y);
+      double u = (erf (y) - x) * spi2 * exp (y*y);
       y -= u / (1 + y*u);
     }
 
@@ -3221,6 +2973,80 @@
   return do_erfinv (x, false);
 }
 
+// The algorthim for erfcinv is an adaptation of the erfinv algorithm above
+// from P. J. Acklam.  It has been modified to run over the different input
+// domain of erfcinv.  See the notes for erfinv for an explanation.
+
+static double do_erfcinv (double x, bool refine)
+{
+  // Coefficients of rational approximation.
+  static const double a[] =
+    { -2.806989788730439e+01,  1.562324844726888e+02,
+      -1.951109208597547e+02,  9.783370457507161e+01,
+      -2.168328665628878e+01,  1.772453852905383e+00 };
+  static const double b[] =
+    { -5.447609879822406e+01,  1.615858368580409e+02,
+      -1.556989798598866e+02,  6.680131188771972e+01,
+      -1.328068155288572e+01 };
+  static const double c[] =
+    { -5.504751339936943e-03, -2.279687217114118e-01,
+      -1.697592457770869e+00, -1.802933168781950e+00,
+       3.093354679843505e+00,  2.077595676404383e+00 };
+  static const double d[] =
+    {  7.784695709041462e-03,  3.224671290700398e-01,
+       2.445134137142996e+00,  3.754408661907416e+00 };
+
+  static const double spi2 = 8.862269254527579e-01; // sqrt(pi)/2.
+  static const double pbreak_lo = 0.04850;  // 1-pbreak
+  static const double pbreak_hi = 1.95150;  // 1+pbreak
+  double y;
+
+  // Select case.
+  if (x >= pbreak_lo && x <= pbreak_hi)
+    {
+      // Middle region.
+      const double q = 0.5*(1-x), r = q*q;
+      const double yn = (((((a[0]*r + a[1])*r + a[2])*r + a[3])*r + a[4])*r + a[5])*q;
+      const double yd = ((((b[0]*r + b[1])*r + b[2])*r + b[3])*r + b[4])*r + 1.0;
+      y = yn / yd;
+    }
+  else if (x > 0.0 && x < 2.0)
+    {
+      // Tail region.
+      const double q = x < 1 ? sqrt (-2*log (0.5*x)) : sqrt (-2*log (0.5*(2-x)));
+      const double yn = ((((c[0]*q + c[1])*q + c[2])*q + c[3])*q + c[4])*q + c[5];
+      const double yd = (((d[0]*q + d[1])*q + d[2])*q + d[3])*q + 1.0;
+      y = yn / yd;
+      if (x < pbreak_lo)
+        y = -y;
+    }
+  else if (x == 0.0)
+    return octave_Inf;
+  else if (x == 2.0)
+    return -octave_Inf;
+  else
+    return octave_NaN;
+
+  if (refine)
+    {
+      // One iteration of Halley's method gives full precision.
+      double u = (erf (y) - (1-x)) * spi2 * exp (y*y);
+      y -= u / (1 + y*u);
+    }
+
+  return y;
+}
+
+double erfcinv (double x)
+{
+  return do_erfcinv (x, true);
+}
+
+float erfcinv (float x)
+{
+  return do_erfcinv (x, false);
+}
+
 // Implementation based on the Fortran code by W.J.Cody
 // see http://www.netlib.org/specfun/erf.
 // Templatized and simplified workflow.
@@ -3320,3 +3146,468 @@
 {
   return erfcx_impl (x);
 }
+
+//
+//  Incomplete Beta function ratio
+//
+//  Algorithm based on the one by John Burkardt.
+//  See http://people.sc.fsu.edu/~jburkardt/cpp_src/asa109/asa109.html
+//
+//  The original code is distributed under the GNU LGPL v3 license.
+//
+//  Reference:
+//
+//    KL Majumder, GP Bhattacharjee,
+//    Algorithm AS 63:
+//    The incomplete Beta Integral,
+//    Applied Statistics,
+//    Volume 22, Number 3, 1973, pages 409-411.
+//
+double
+betain (double x, double p, double q, double beta, bool& err)
+{
+  double acu = 0.1E-14, ai, cx;
+  bool indx;
+  int ns;
+  double pp, psq, qq, rx, temp, term, value, xx;
+
+  value = x;
+  err = false;
+
+  //  Check the input arguments.
+
+  if ((p <= 0.0 || q <= 0.0) || (x < 0.0 || 1.0 < x))
+    {
+      err = true;
+      return value;
+    }
+
+  //  Special cases.
+
+  if (x == 0.0 || x == 1.0)
+    {
+      return value;
+    }
+
+  //  Change tail if necessary and determine S.
+
+  psq = p + q;
+  cx = 1.0 - x;
+
+  if (p < psq * x)
+    {
+      xx = cx;
+      cx = x;
+      pp = q;
+      qq = p;
+      indx = true;
+    }
+  else
+    {
+      xx = x;
+      pp = p;
+      qq = q;
+      indx = false;
+    }
+
+  term = 1.0;
+  ai = 1.0;
+  value = 1.0;
+  ns = (int) (qq + cx * psq);
+
+  //  Use the Soper reduction formula.
+
+  rx = xx / cx;
+  temp = qq - ai;
+  if (ns == 0)
+    {
+      rx = xx;
+    }
+
+  for ( ; ; )
+    {
+      term = term * temp * rx / (pp + ai);
+      value = value + term;
+      temp = fabs (term);
+
+      if (temp <= acu && temp <= acu * value)
+        {
+          value = value * exp (pp * log (xx)
+          + (qq - 1.0) * log (cx) - beta) / pp;
+
+          if (indx)
+            {
+              value = 1.0 - value;
+            }
+          break;
+        }
+
+      ai = ai + 1.0;
+      ns = ns - 1;
+
+      if (0 <= ns)
+        {
+          temp = qq - ai;
+          if (ns == 0)
+            {
+              rx = xx;
+            }
+        }
+      else
+        {
+          temp = psq;
+          psq = psq + 1.0;
+        }
+    }
+
+  return value;
+}
+
+//
+//  Inverse of the incomplete Beta function
+//
+//  Algorithm based on the one by John Burkardt.
+//  See http://people.sc.fsu.edu/~jburkardt/cpp_src/asa109/asa109.html
+//
+//  The original code is distributed under the GNU LGPL v3 license.
+//
+//  Reference:
+//
+//    GW Cran, KJ Martin, GE Thomas,
+//    Remark AS R19 and Algorithm AS 109:
+//    A Remark on Algorithms AS 63: The Incomplete Beta Integral
+//    and AS 64: Inverse of the Incomplete Beta Integeral,
+//    Applied Statistics,
+//    Volume 26, Number 1, 1977, pages 111-114.
+//
+double
+betaincinv (double y, double p, double q) {
+  double a, acu, adj, fpu, g, h;
+  int iex;
+  bool indx;
+  double pp, prev, qq, r, s, sae = -37.0, sq, t, tx, value, w, xin, ycur, yprev;
+
+  double beta = xlgamma (p) + xlgamma (q) - xlgamma (p + q);
+  bool err = false;
+  fpu = pow (10.0, sae);
+  value = y;
+
+  //  Test for admissibility of parameters.
+
+  if (p <= 0.0 || q <= 0.0)
+    {
+      (*current_liboctave_error_handler)
+        ("betaincinv: wrong parameters");
+    }
+
+  if (y < 0.0 || 1.0 < y)
+    {
+      (*current_liboctave_error_handler)
+        ("betaincinv: wrong parameter Y");
+    }
+
+  if (y == 0.0 || y == 1.0)
+    {
+      return value;
+    }
+
+  //  Change tail if necessary.
+
+  if (0.5 < y)
+    {
+      a = 1.0 - y;
+      pp = q;
+      qq = p;
+      indx = true;
+    }
+  else
+    {
+      a = y;
+      pp = p;
+      qq = q;
+      indx = false;
+    }
+
+  //  Calculate the initial approximation.
+
+  r = sqrt (- log (a * a));
+
+  ycur = r - (2.30753 + 0.27061 * r) / (1.0 + (0.99229 + 0.04481 * r) * r);
+
+  if (1.0 < pp && 1.0 < qq)
+    {
+      r = (ycur * ycur - 3.0) / 6.0;
+      s = 1.0 / (pp + pp - 1.0);
+      t = 1.0 / (qq + qq - 1.0);
+      h = 2.0 / (s + t);
+      w = ycur * sqrt (h + r) / h - (t - s) * (r + 5.0 / 6.0 - 2.0 / (3.0 * h));
+      value = pp / (pp + qq * exp (w + w));
+    }
+  else
+    {
+      r = qq + qq;
+      t = 1.0 / (9.0 * qq);
+      t = r * pow (1.0 - t + ycur * sqrt (t), 3);
+
+      if (t <= 0.0)
+        {
+          value = 1.0 - exp ((log ((1.0 - a) * qq) + beta) / qq);
+        }
+      else
+        {
+          t = (4.0 * pp + r - 2.0) / t;
+
+          if (t <= 1.0)
+            {
+              value = exp ((log (a * pp) + beta) / pp);
+            }
+          else
+            {
+              value = 1.0 - 2.0 / (t + 1.0);
+            }
+        }
+    }
+
+  //  Solve for X by a modified Newton-Raphson method,
+  //  using the function BETAIN.
+
+  r = 1.0 - pp;
+  t = 1.0 - qq;
+  yprev = 0.0;
+  sq = 1.0;
+  prev = 1.0;
+
+  if (value < 0.0001)
+    {
+      value = 0.0001;
+    }
+
+  if (0.9999 < value)
+    {
+      value = 0.9999;
+    }
+
+  iex = std::max (- 5.0 / pp / pp - 1.0 / pow (a, 0.2) - 13.0, sae);
+
+  acu = pow (10.0, iex);
+
+  for ( ; ; )
+    {
+      ycur = betain (value, pp, qq, beta, err);
+
+      if (err)
+        {
+          return value;
+        }
+
+      xin = value;
+      ycur = (ycur - a) * exp (beta + r * log (xin) + t * log (1.0 - xin));
+
+      if (ycur * yprev <= 0.0)
+        {
+          prev = std::max (sq, fpu);
+        }
+
+      g = 1.0;
+
+      for ( ; ; )
+        {
+          for ( ; ; )
+            {
+              adj = g * ycur;
+              sq = adj * adj;
+
+              if (sq < prev)
+                {
+                  tx = value - adj;
+
+                  if (0.0 <= tx && tx <= 1.0)
+                    {
+                      break;
+                    }
+                }
+              g = g / 3.0;
+            }
+
+          if (prev <= acu)
+            {
+              if (indx)
+                {
+                  value = 1.0 - value;
+                }
+              return value;
+            }
+
+          if (ycur * ycur <= acu)
+            {
+              if (indx)
+                {
+                  value = 1.0 - value;
+                }
+              return value;
+            }
+
+          if (tx != 0.0 && tx != 1.0)
+            {
+              break;
+            }
+
+          g = g / 3.0;
+        }
+
+      if (tx == value)
+        {
+          break;
+        }
+
+      value = tx;
+      yprev = ycur;
+    }
+
+  if (indx)
+    {
+      value = 1.0 - value;
+    }
+
+  return value;
+}
+
+Array<double>
+betaincinv (double x, double a, const Array<double>& b)
+{
+  dim_vector dv = b.dims ();
+  octave_idx_type nel = dv.numel ();
+
+  Array<double> retval (dv);
+
+  double *pretval = retval.fortran_vec ();
+
+  for (octave_idx_type i = 0; i < nel; i++)
+    *pretval++ = betaincinv (x, a, b(i));
+
+  return retval;
+}
+
+Array<double>
+betaincinv (double x, const Array<double>& a, double b)
+{
+  dim_vector dv = a.dims ();
+  octave_idx_type nel = dv.numel ();
+
+  Array<double> retval (dv);
+
+  double *pretval = retval.fortran_vec ();
+
+  for (octave_idx_type i = 0; i < nel; i++)
+    *pretval++ = betaincinv (x, a(i), b);
+
+  return retval;
+}
+
+Array<double>
+betaincinv (double x, const Array<double>& a, const Array<double>& b)
+{
+  Array<double> retval;
+  dim_vector dv = a.dims ();
+
+  if (dv == b.dims ())
+    {
+      octave_idx_type nel = dv.numel ();
+
+      retval.resize (dv);
+
+      double *pretval = retval.fortran_vec ();
+
+      for (octave_idx_type i = 0; i < nel; i++)
+        *pretval++ = betaincinv (x, a(i), b(i));
+    }
+  else
+    gripe_betaincinv_nonconformant (dim_vector (0, 0), dv, b.dims ());
+
+  return retval;
+}
+
+Array<double>
+betaincinv (const Array<double>& x, double a, double b)
+{
+  dim_vector dv = x.dims ();
+  octave_idx_type nel = dv.numel ();
+
+  Array<double> retval (dv);
+
+  double *pretval = retval.fortran_vec ();
+
+  for (octave_idx_type i = 0; i < nel; i++)
+    *pretval++ = betaincinv (x(i), a, b);
+
+  return retval;
+}
+
+Array<double>
+betaincinv (const Array<double>& x, double a, const Array<double>& b)
+{
+  Array<double> retval;
+  dim_vector dv = x.dims ();
+
+  if (dv == b.dims ())
+    {
+      octave_idx_type nel = dv.numel ();
+
+      retval.resize (dv);
+
+      double *pretval = retval.fortran_vec ();
+
+      for (octave_idx_type i = 0; i < nel; i++)
+        *pretval++ = betaincinv (x(i), a, b(i));
+    }
+  else
+    gripe_betaincinv_nonconformant (dv, dim_vector (0, 0), b.dims ());
+
+  return retval;
+}
+
+Array<double>
+betaincinv (const Array<double>& x, const Array<double>& a, double b)
+{
+  Array<double> retval;
+  dim_vector dv = x.dims ();
+
+  if (dv == a.dims ())
+    {
+      octave_idx_type nel = dv.numel ();
+
+      retval.resize (dv);
+
+      double *pretval = retval.fortran_vec ();
+
+      for (octave_idx_type i = 0; i < nel; i++)
+        *pretval++ = betaincinv (x(i), a(i), b);
+    }
+  else
+    gripe_betaincinv_nonconformant (dv, a.dims (), dim_vector (0, 0));
+
+  return retval;
+}
+
+Array<double>
+betaincinv (const Array<double>& x, const Array<double>& a, const Array<double>& b)
+{
+  Array<double> retval;
+  dim_vector dv = x.dims ();
+
+  if (dv == a.dims () && dv == b.dims ())
+    {
+      octave_idx_type nel = dv.numel ();
+
+      retval.resize (dv);
+
+      double *pretval = retval.fortran_vec ();
+
+      for (octave_idx_type i = 0; i < nel; i++)
+        *pretval++ = betaincinv (x(i), a(i), b(i));
+    }
+  else
+    gripe_betaincinv_nonconformant (dv, a.dims (), b.dims ());
+
+  return retval;
+}
--- a/liboctave/lo-specfun.h
+++ b/liboctave/lo-specfun.h
@@ -520,42 +520,24 @@
 biry (const FloatComplexNDArray& z, bool deriv, bool scaled, Array<octave_idx_type>& ierr);
 
 extern OCTAVE_API double betainc (double x, double a, double b);
-extern OCTAVE_API Matrix betainc (double x, double a, const Matrix& b);
-extern OCTAVE_API Matrix betainc (double x, const Matrix& a, double b);
-extern OCTAVE_API Matrix betainc (double x, const Matrix& a, const Matrix& b);
-
-extern OCTAVE_API NDArray betainc (double x, double a, const NDArray& b);
-extern OCTAVE_API NDArray betainc (double x, const NDArray& a, double b);
-extern OCTAVE_API NDArray betainc (double x, const NDArray& a, const NDArray& b);
-
-extern OCTAVE_API Matrix betainc (const Matrix& x, double a, double b);
-extern OCTAVE_API Matrix betainc (const Matrix& x, double a, const Matrix& b);
-extern OCTAVE_API Matrix betainc (const Matrix& x, const Matrix& a, double b);
-extern OCTAVE_API Matrix betainc (const Matrix& x, const Matrix& a, const Matrix& b);
-
-extern OCTAVE_API NDArray betainc (const NDArray& x, double a, double b);
-extern OCTAVE_API NDArray betainc (const NDArray& x, double a, const NDArray& b);
-extern OCTAVE_API NDArray betainc (const NDArray& x, const NDArray& a, double b);
-extern OCTAVE_API NDArray betainc (const NDArray& x, const NDArray& a, const NDArray& b);
+extern OCTAVE_API Array<double> betainc (double x, double a, const Array<double>& b);
+extern OCTAVE_API Array<double> betainc (double x, const Array<double>& a, double b);
+extern OCTAVE_API Array<double> betainc (double x, const Array<double>& a, const Array<double>& b);
+extern OCTAVE_API Array<double> betainc (const Array<double>& x, double a, double b);
+extern OCTAVE_API Array<double> betainc (const Array<double>& x, double a, double b);
+extern OCTAVE_API Array<double> betainc (const Array<double>& x, double a, const Array<double>& b);
+extern OCTAVE_API Array<double> betainc (const Array<double>& x, const Array<double>& a, double b);
+extern OCTAVE_API Array<double> betainc (const Array<double>& x, const Array<double>& a, const Array<double>& b);
 
 extern OCTAVE_API float betainc (float x, float a, float b);
-extern OCTAVE_API FloatMatrix betainc (float x, float a, const FloatMatrix& b);
-extern OCTAVE_API FloatMatrix betainc (float x, const FloatMatrix& a, float b);
-extern OCTAVE_API FloatMatrix betainc (float x, const FloatMatrix& a, const FloatMatrix& b);
-
-extern OCTAVE_API FloatNDArray betainc (float x, float a, const FloatNDArray& b);
-extern OCTAVE_API FloatNDArray betainc (float x, const FloatNDArray& a, float b);
-extern OCTAVE_API FloatNDArray betainc (float x, const FloatNDArray& a, const FloatNDArray& b);
-
-extern OCTAVE_API FloatMatrix betainc (const FloatMatrix& x, float a, float b);
-extern OCTAVE_API FloatMatrix betainc (const FloatMatrix& x, float a, const FloatMatrix& b);
-extern OCTAVE_API FloatMatrix betainc (const FloatMatrix& x, const FloatMatrix& a, float b);
-extern OCTAVE_API FloatMatrix betainc (const FloatMatrix& x, const FloatMatrix& a, const FloatMatrix& b);
-
-extern OCTAVE_API FloatNDArray betainc (const FloatNDArray& x, float a, float b);
-extern OCTAVE_API FloatNDArray betainc (const FloatNDArray& x, float a, const FloatNDArray& b);
-extern OCTAVE_API FloatNDArray betainc (const FloatNDArray& x, const FloatNDArray& a, float b);
-extern OCTAVE_API FloatNDArray betainc (const FloatNDArray& x, const FloatNDArray& a, const FloatNDArray& b);
+extern OCTAVE_API Array<float> betainc (float x, float a, const Array<float>& b);
+extern OCTAVE_API Array<float> betainc (float x, const Array<float>& a, float b);
+extern OCTAVE_API Array<float> betainc (float x, const Array<float>& a, const Array<float>& b);
+extern OCTAVE_API Array<float> betainc (const Array<float>& x, float a, float b);
+extern OCTAVE_API Array<float> betainc (const Array<float>& x, float a, float b);
+extern OCTAVE_API Array<float> betainc (const Array<float>& x, float a, const Array<float>& b);
+extern OCTAVE_API Array<float> betainc (const Array<float>& x, const Array<float>& a, float b);
+extern OCTAVE_API Array<float> betainc (const Array<float>& x, const Array<float>& a, const Array<float>& b);
 
 extern OCTAVE_API double gammainc (double x, double a, bool& err);
 extern OCTAVE_API Matrix gammainc (double x, const Matrix& a);
@@ -593,7 +575,20 @@
 extern OCTAVE_API double erfinv (double x);
 extern OCTAVE_API float erfinv (float x);
 
+extern OCTAVE_API double erfcinv (double x);
+extern OCTAVE_API float erfcinv (float x);
+
 extern OCTAVE_API double erfcx (double x);
 extern OCTAVE_API float erfcx (float x);
 
+extern OCTAVE_API double betaincinv (double x, double a, double b);
+extern OCTAVE_API Array<double> betaincinv (double x, double a, const Array<double>& b);
+extern OCTAVE_API Array<double> betaincinv (double x, const Array<double>& a, double b);
+extern OCTAVE_API Array<double> betaincinv (double x, const Array<double>& a, const Array<double>& b);
+extern OCTAVE_API Array<double> betaincinv (const Array<double>& x, double a, double b);
+extern OCTAVE_API Array<double> betaincinv (const Array<double>& x, double a, double b);
+extern OCTAVE_API Array<double> betaincinv (const Array<double>& x, double a, const Array<double>& b);
+extern OCTAVE_API Array<double> betaincinv (const Array<double>& x, const Array<double>& a, double b);
+extern OCTAVE_API Array<double> betaincinv (const Array<double>& x, const Array<double>& a, const Array<double>& b);
+
 #endif
--- a/liboctave/lo-sysdep.cc
+++ b/liboctave/lo-sysdep.cc
@@ -73,7 +73,7 @@
   std::string path = file_ops::tilde_expand (path_arg);
 
 #if defined (__WIN32__) && ! defined (__CYGWIN__)
-  if (path.length() == 2 && path[1] == ':')
+  if (path.length () == 2 && path[1] == ':')
     path += "\\";
 #endif
 
@@ -90,7 +90,7 @@
   PROCESS_INFORMATION pi;
   STARTUPINFO si;
   std::string command = "\"" + cmd + "\"";
-  HANDLE hProcess = GetCurrentProcess(), childRead, childWrite, parentRead, parentWrite;
+  HANDLE hProcess = GetCurrentProcess (), childRead, childWrite, parentRead, parentWrite;
   DWORD pipeMode;
 
   ZeroMemory (&pi, sizeof (pi));
@@ -121,7 +121,7 @@
   si.hStdOutput = childWrite;
 
   // Ignore first arg as it is the command
-  for (int k=1; k<args.length(); k++)
+  for (int k=1; k<args.length (); k++)
     command += " \"" + args[k] + "\"";
   OCTAVE_LOCAL_BUFFER (char, c_command, command.length () + 1);
   strcpy (c_command, command.c_str ());
--- a/liboctave/lo-utils.cc
+++ b/liboctave/lo-utils.cc
@@ -198,10 +198,11 @@
 // Note that the caller is responsible for repositioning the stream on
 // failure.
 
-static inline double
+template <typename T>
+T
 read_inf_nan_na (std::istream& is, char c0)
 {
-  double d = 0.0;
+  T val = 0.0;
 
   switch (c0)
     {
@@ -212,7 +213,7 @@
           {
             char c2 = is.get ();
             if (c2 == 'f' || c2 == 'F')
-              d = octave_Inf;
+              val = std::numeric_limits<T>::infinity ();
             else
               is.setstate (std::ios::failbit);
           }
@@ -228,9 +229,9 @@
           {
             char c2 = is.get ();
             if (c2 == 'n' || c2 == 'N')
-              d = octave_NaN;
+              val = std::numeric_limits<T>::quiet_NaN ();
             else
-              d = octave_NA;
+              val = octave_numeric_limits<T>::NA ();
           }
         else
           is.setstate (std::ios::failbit);
@@ -241,16 +242,16 @@
       abort ();
     }
 
-  return d;
+  return val;
 }
 
 // Read a double value.  Discard any sign on NaN and NA.
 
-template <>
+template <typename T>
 double
-octave_read_value (std::istream& is)
+octave_read_fp_value (std::istream& is)
 {
-  double d = 0.0;
+  T val = 0.0;
 
   // FIXME -- resetting stream position is likely to fail unless we are
   // reading from a file.
@@ -274,26 +275,26 @@
         char c2 = 0;
         c2 = is.get ();
         if (c2 == 'i' || c2 == 'I' || c2 == 'n' || c2 == 'N')
-          d = read_inf_nan_na (is, c2);
+          val = read_inf_nan_na<T> (is, c2);
         else
           {
             is.putback (c2);
-            is >> d;
+            is >> val;
           }
 
         if (neg && ! is.fail ())
-          d = -d;
+          val = -val;
       }
       break;
 
     case 'i': case 'I':
     case 'n': case 'N':
-      d = read_inf_nan_na (is, c1);
+      val = read_inf_nan_na<T> (is, c1);
       break;
 
     default:
       is.putback (c1);
-      is >> d;
+      is >> val;
       break;
     }
 
@@ -305,16 +306,16 @@
       is.setstate (status);
     }
 
-  return d;
+  return val;
 }
 
-template <>
-Complex
-octave_read_value (std::istream& is)
+template <typename T>
+std::complex<T>
+octave_read_cx_fp_value (std::istream& is)
 {
-  double re = 0.0, im = 0.0;
+  T re = 0.0, im = 0.0;
 
-  Complex cx = 0.0;
+  std::complex<T> cx = 0.0;
 
   char ch = ' ';
 
@@ -323,16 +324,16 @@
 
   if (ch == '(')
     {
-      re = octave_read_value<double> (is);
+      re = octave_read_value<T> (is);
       ch = is.get ();
 
       if (ch == ',')
         {
-          im = octave_read_value<double> (is);
+          im = octave_read_value<T> (is);
           ch = is.get ();
 
           if (ch == ')')
-            cx = Complex (re, im);
+            cx = std::complex<T> (re, im);
           else
             is.setstate (std::ios::failbit);
         }
@@ -348,163 +349,26 @@
     }
 
   return cx;
-
 }
 
-// Note that the caller is responsible for repositioning the stream on
-// failure.
-
-static inline float
-read_float_inf_nan_na (std::istream& is, char c0, char sign = '+')
+template <> OCTAVE_API double octave_read_value (std::istream& is)
 {
-  float d = 0.0;
-
-  switch (c0)
-    {
-    case 'i': case 'I':
-      {
-        char c1 = is.get ();
-        if (c1 == 'n' || c1 == 'N')
-          {
-            char c2 = is.get ();
-            if (c2 == 'f' || c2 == 'F')
-              d = octave_Float_Inf;
-            else
-              is.setstate (std::ios::failbit);
-          }
-        else
-          is.setstate (std::ios::failbit);
-      }
-      break;
-
-    case 'n': case 'N':
-      {
-        char c1 = is.get ();
-        if (c1 == 'a' || c1 == 'A')
-          {
-            char c2 = is.get ();
-            if (c2 == 'n' || c2 == 'N')
-              d = octave_Float_NaN;
-            else
-              d = octave_Float_NA;
-          }
-        else
-          is.setstate (std::ios::failbit);
-      }
-      break;
-
-    default:
-      abort ();
-    }
-
-  return d;
+  return octave_read_fp_value<double> (is);
 }
 
-// Read a float value.  Discard any sign on NaN and NA.
-
-template <>
-float
-octave_read_value (std::istream& is)
+template <> OCTAVE_API Complex octave_read_value (std::istream& is)
 {
-  float d = 0.0;
-
-  // FIXME -- resetting stream position is likely to fail unless we are
-  // reading from a file.
-  std::ios::streampos pos = is.tellg ();
-
-  char c1 = ' ';
-
-  while (isspace (c1))
-    c1 = is.get ();
-
-  bool neg = false;
-
-  switch (c1)
-    {
-    case '-':
-      neg = true;
-      // fall through...
-
-    case '+':
-      {
-        char c2 = 0;
-        c2 = is.get ();
-        if (c2 == 'i' || c2 == 'I' || c2 == 'n' || c2 == 'N')
-          d = read_float_inf_nan_na (is, c2);
-        else
-          {
-            is.putback (c2);
-            is >> d;
-          }
-
-        if (neg && ! is.fail ())
-          d = -d;
-      }
-      break;
-
-    case 'i': case 'I':
-    case 'n': case 'N':
-      d = read_float_inf_nan_na (is, c1);
-      break;
-
-    default:
-      is.putback (c1);
-      is >> d;
-      break;
-    }
-
-  std::ios::iostate status = is.rdstate ();
-  if (status & std::ios::failbit)
-    {
-      is.clear ();
-      is.seekg (pos);
-      is.setstate (status);
-    }
-
-  return d;
+  return octave_read_cx_fp_value<double> (is);
 }
 
-template <>
-FloatComplex
-octave_read_value (std::istream& is)
+template <> OCTAVE_API float octave_read_value (std::istream& is)
 {
-  float re = 0.0, im = 0.0;
-
-  FloatComplex cx = 0.0;
-
-  char ch = ' ';
-
-  while (isspace (ch))
-    ch = is.get ();
-
-  if (ch == '(')
-    {
-      re = octave_read_value<float> (is);
-      ch = is.get ();
+  return octave_read_fp_value<float> (is);
+}
 
-      if (ch == ',')
-        {
-          im = octave_read_value<float> (is);
-          ch = is.get ();
-
-          if (ch == ')')
-            cx = FloatComplex (re, im);
-          else
-            is.setstate (std::ios::failbit);
-        }
-      else if (ch == ')')
-        cx = re;
-      else
-        is.setstate (std::ios::failbit);
-    }
-  else
-    {
-      is.putback (ch);
-      cx = octave_read_value<float> (is);
-    }
-
-  return cx;
-
+template <> OCTAVE_API FloatComplex octave_read_value (std::istream& is)
+{
+  return octave_read_cx_fp_value<float> (is);
 }
 
 void
--- a/liboctave/mach-info.cc
+++ b/liboctave/mach-info.cc
@@ -237,19 +237,19 @@
   switch (flt_fmt)
     {
     case flt_fmt_ieee_big_endian:
-      retval = "ieee_big_endian";
+      retval = "ieee-be";
       break;
 
     case flt_fmt_ieee_little_endian:
-      retval = "ieee_little_endian";
+      retval = "ieee-le";
       break;
 
     case flt_fmt_vax_d:
-      retval = "vax_d_float";
+      retval = "vaxd";
       break;
 
     case flt_fmt_vax_g:
-      retval = "vax_g_float";
+      retval = "vaxg";
       break;
 
     case flt_fmt_cray:
--- a/liboctave/mx-inlines.cc
+++ b/liboctave/mx-inlines.cc
@@ -62,7 +62,7 @@
 #define DEFMXUNBOOLOP(F, OP) \
 template <class X> \
 inline void F (size_t n, bool *r, const X *x) throw () \
-{ const X zero = X(); for (size_t i = 0; i < n; i++) r[i] = x[i] OP zero; }
+{ const X zero = X (); for (size_t i = 0; i < n; i++) r[i] = x[i] OP zero; }
 
 DEFMXUNBOOLOP (mx_inline_iszero, ==)
 DEFMXUNBOOLOP (mx_inline_notzero, !=)
--- a/liboctave/oct-binmap.h
+++ b/liboctave/oct-binmap.h
@@ -265,7 +265,7 @@
   R yzero = R ();
 
   U fz = fcn (xzero, yzero);
-  if (fz == U())
+  if (fz == U ())
     {
       // Sparsity-preserving function. Do it efficiently.
       octave_idx_type nr = xs.rows (), nc = xs.cols ();
--- a/liboctave/oct-convn.cc
+++ b/liboctave/oct-convn.cc
@@ -125,7 +125,7 @@
                              static_cast<octave_idx_type> (0));
     }
 
-  MArray<T> c (cdims, T());
+  MArray<T> c (cdims, T ());
 
   convolve_nd<T, R> (a.fortran_vec (), adims, adims.cumulative (),
                      b.fortran_vec (), bdims, bdims.cumulative (),
--- a/liboctave/oct-inttypes.cc
+++ b/liboctave/oct-inttypes.cc
@@ -630,24 +630,23 @@
 INSTANTIATE_INTTYPE (uint64_t);
 
 
-// Tests follow.
-
 /*
 
-%!assert(intmax("int64")/intmin("int64"),int64(-1))
-%!assert(intmin("int64")/int64(-1),intmax("int64"))
-%!assert(int64(2**63),intmax("int64"))
-%!assert(uint64(2**64),intmax("uint64"))
+%!assert (intmax ("int64") / intmin ("int64"), int64 (-1))
+%!assert (intmin ("int64") / int64 (-1), intmax ("int64"))
+%!assert (int64 (2**63), intmax ("int64"))
+%!assert (uint64 (2**64), intmax ("uint64"))
 %!test
-%! a = 1.9*2^61; b = uint64(a); b++; assert(b > a)
+%! a = 1.9*2^61; b = uint64 (a); b++; assert (b > a);
 %!test
-%! a = -1.9*2^61; b = int64(a); b++; assert(b > a)
+%! a = -1.9*2^61; b = int64 (a); b++; assert (b > a);
 %!test
-%! a = int64(-2**60) + 2; assert(1.25*a == (5*a)/4)
+%! a = int64 (-2**60) + 2; assert (1.25*a == (5*a)/4);
 %!test
-%! a = uint64(2**61) + 2; assert(1.25*a == (5*a)/4)
-%!assert(int32(2**31+0.5),intmax('int32'))
-%!assert(int32(-2**31-0.5),intmin('int32'))
-%!assert((int64(2**62)+1)**1, int64(2**62)+1)
-%!assert((int64(2**30)+1)**2, int64(2**60+2**31) + 1)
+%! a = uint64 (2**61) + 2; assert (1.25*a == (5*a)/4);
+%!assert (int32 (2**31+0.5), intmax ("int32"))
+%!assert (int32 (-2**31-0.5), intmin ("int32"))
+%!assert ((int64 (2**62)+1)**1, int64 (2**62)+1)
+%!assert ((int64 (2**30)+1)**2, int64 (2**60+2**31) + 1)
+
 */
--- a/liboctave/oct-md5.cc
+++ b/liboctave/oct-md5.cc
@@ -79,7 +79,7 @@
     }
   else
     (*current_liboctave_error_handler) ("unable to open file `%s' for reading",
-                                        file.c_str());
+                                        file.c_str ());
 
   return retval;
 }
--- a/liboctave/oct-mem.h
+++ b/liboctave/oct-mem.h
@@ -92,7 +92,7 @@
 
 template <class T>
 inline bool helper_is_zero_mem (const octave_int<T>& value)
-{ return value.value () == T(); }
+{ return value.value () == T (); }
 
 #define DEFINE_POD_FILL(T) \
 inline void fill_or_memset (size_t n, const T& value, T *dest) \
--- a/liboctave/oct-norm.cc
+++ b/liboctave/oct-norm.cc
@@ -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/oct-rand.cc
+++ b/liboctave/oct-rand.cc
@@ -419,34 +419,86 @@
   return retval;
 }
 
-Matrix
-octave_rand::do_matrix (octave_idx_type n, octave_idx_type m, double a)
+float
+octave_rand::do_float_scalar (float a)
 {
-  Matrix retval;
+  float retval = 0.0;
+
+  if (use_old_generators)
+    {
+      double da = a;
+      double dretval;
+      switch (current_distribution)
+        {
+        case uniform_dist:
+          F77_FUNC (dgenunf, DGENUNF) (0.0, 1.0, dretval);
+          break;
+
+        case normal_dist:
+          F77_FUNC (dgennor, DGENNOR) (0.0, 1.0, dretval);
+          break;
+
+        case expon_dist:
+          F77_FUNC (dgenexp, DGENEXP) (1.0, dretval);
+          break;
 
-  if (n >= 0 && m >= 0)
-    {
-      retval.clear (n, m);
+        case poisson_dist:
+          if (da < 0.0 || xisnan(da) || xisinf(da))
+            dretval = octave_NaN;
+          else
+            {
+              // workaround bug in ignpoi, by calling with different Mu
+              F77_FUNC (dignpoi, DIGNPOI) (da + 1, dretval);
+              F77_FUNC (dignpoi, DIGNPOI) (da, dretval);
+            }
+          break;
 
-      if (n > 0 && m > 0)
-        fill (retval.capacity(), retval.fortran_vec(), a);
+        case gamma_dist:
+          if (da <= 0.0 || xisnan(da) || xisinf(da))
+            retval = octave_NaN;
+          else
+            F77_FUNC (dgengam, DGENGAM) (1.0, da, dretval);
+          break;
+
+        default:
+          (*current_liboctave_error_handler)
+            ("rand: invalid distribution ID = %d", current_distribution);
+          break;
+        }
+      retval = dretval;
     }
   else
-    (*current_liboctave_error_handler) ("rand: invalid negative argument");
+    {
+      switch (current_distribution)
+        {
+        case uniform_dist:
+          retval = oct_float_randu ();
+          break;
 
-  return retval;
-}
+        case normal_dist:
+          retval = oct_float_randn ();
+          break;
+
+        case expon_dist:
+          retval = oct_float_rande ();
+          break;
 
-NDArray
-octave_rand::do_nd_array (const dim_vector& dims, double a)
-{
-  NDArray retval;
+        case poisson_dist:
+          // Keep poisson distribution in double precision for accuracy
+          retval = oct_randp (a);
+          break;
 
-  if (! dims.all_zero ())
-    {
-      retval.clear (dims);
+        case gamma_dist:
+          retval = oct_float_randg (a);
+          break;
 
-      fill (retval.capacity(), retval.fortran_vec(), a);
+        default:
+          (*current_liboctave_error_handler)
+            ("rand: invalid distribution ID = %d", current_distribution);
+          break;
+        }
+
+      save_state ();
     }
 
   return retval;
@@ -469,6 +521,53 @@
   return retval;
 }
 
+Array<float>
+octave_rand::do_float_vector (octave_idx_type n, float a)
+{
+  Array<float> retval;
+
+  if (n > 0)
+    {
+      retval.clear (n, 1);
+
+      fill (retval.capacity (), retval.fortran_vec (), a);
+    }
+  else if (n < 0)
+    (*current_liboctave_error_handler) ("rand: invalid negative argument");
+
+  return retval;
+}
+
+NDArray
+octave_rand::do_nd_array (const dim_vector& dims, double a)
+{
+  NDArray retval;
+
+  if (! dims.all_zero ())
+    {
+      retval.clear (dims);
+
+      fill (retval.capacity (), retval.fortran_vec (), a);
+    }
+
+  return retval;
+}
+
+FloatNDArray
+octave_rand::do_float_nd_array (const dim_vector& dims, float a)
+{
+  FloatNDArray retval;
+
+  if (! dims.all_zero ())
+    {
+      retval.clear (dims);
+
+      fill (retval.capacity (), retval.fortran_vec (), a);
+    }
+
+  return retval;
+}
+
 // Make the random number generator give us a different sequence every
 // time we start octave unless we specifically set the seed.  The
 // technique used below will cycle monthly, but it it does seem to
@@ -481,11 +580,11 @@
   int stored_distribution = current_distribution;
   F77_FUNC (setcgn, SETCGN) (uniform_dist);
 
-  int hour = tm.hour() + 1;
-  int minute = tm.min() + 1;
-  int second = tm.sec() + 1;
+  int hour = tm.hour () + 1;
+  int minute = tm.min () + 1;
+  int second = tm.sec () + 1;
 
-  int32_t s0 = tm.mday() * hour * minute * second;
+  int32_t s0 = tm.mday () * hour * minute * second;
   int32_t s1 = hour * minute * second;
 
   s0 = force_to_fit_range (s0, 1, 2147483563);
@@ -693,3 +792,94 @@
 
   return;
 }
+
+void
+octave_rand::fill (octave_idx_type len, float *v, float a)
+{
+  if (len < 1)
+    return;
+
+  switch (current_distribution)
+    {
+    case uniform_dist:
+      if (use_old_generators)
+        {
+#define RAND_FUNC(x) F77_FUNC (dgenunf, DGENUNF) (0.0, 1.0, x)
+          MAKE_RAND (len);
+#undef RAND_FUNC
+        }
+      else
+        oct_fill_float_randu (len, v);
+      break;
+
+    case normal_dist:
+      if (use_old_generators)
+        {
+#define RAND_FUNC(x) F77_FUNC (dgennor, DGENNOR) (0.0, 1.0, x)
+          MAKE_RAND (len);
+#undef RAND_FUNC
+        }
+      else
+        oct_fill_float_randn (len, v);
+      break;
+
+    case expon_dist:
+      if (use_old_generators)
+        {
+#define RAND_FUNC(x) F77_FUNC (dgenexp, DGENEXP) (1.0, x)
+          MAKE_RAND (len);
+#undef RAND_FUNC
+        }
+      else
+        oct_fill_float_rande (len, v);
+      break;
+
+    case poisson_dist:
+      if (use_old_generators)
+        {
+          double da = a;
+          if (da < 0.0 || xisnan(da) || xisinf(da))
+#define RAND_FUNC(x) x = octave_NaN;
+            MAKE_RAND (len);
+#undef RAND_FUNC
+          else
+            {
+              // workaround bug in ignpoi, by calling with different Mu
+              double tmp;
+              F77_FUNC (dignpoi, DIGNPOI) (da + 1, tmp);
+#define RAND_FUNC(x) F77_FUNC (dignpoi, DIGNPOI) (da, x)
+                MAKE_RAND (len);
+#undef RAND_FUNC
+            }
+        }
+      else
+        oct_fill_float_randp (a, len, v);
+      break;
+
+    case gamma_dist:
+      if (use_old_generators)
+        {
+          double da = a;
+          if (da <= 0.0 || xisnan(da) || xisinf(da))
+#define RAND_FUNC(x) x = octave_NaN;
+            MAKE_RAND (len);
+#undef RAND_FUNC
+          else
+#define RAND_FUNC(x) F77_FUNC (dgengam, DGENGAM) (1.0, da, x)
+            MAKE_RAND (len);
+#undef RAND_FUNC
+        }
+      else
+        oct_fill_float_randg (a, len, v);
+      break;
+
+    default:
+      (*current_liboctave_error_handler)
+        ("rand: invalid distribution ID = %d", current_distribution);
+      break;
+    }
+
+  save_state ();
+
+  return;
+}
--- a/liboctave/oct-rand.h
+++ b/liboctave/oct-rand.h
@@ -27,8 +27,8 @@
 #include <string>
 
 #include "dColVector.h"
-#include "dMatrix.h"
 #include "dNDArray.h"
+#include "fNDArray.h"
 #include "lo-ieee.h"
 
 class
@@ -136,13 +136,24 @@
     return instance_ok () ? instance->do_scalar (a) : octave_NaN;
   }
 
-  // Return a matrix of numbers from the sequence, filled in column
-  // major order.
-  static Matrix matrix (octave_idx_type r, octave_idx_type c, double a = 1.0)
+  // Return the next number from the sequence.
+  static float float_scalar (float a = 1.0)
   {
-    return instance_ok () ? instance->do_matrix (r, c, a) : Matrix ();
+    return instance_ok () ? instance->do_float_scalar (a) : octave_Float_NaN;
   }
 
+  // Return an array of numbers from the sequence.
+  static Array<double> vector (octave_idx_type n, double a = 1.0)
+   {
+     return instance_ok () ? instance->do_vector (n, a) : Array<double> ();
+   }
+
+  // Return an array of numbers from the sequence.
+  static Array<float> float_vector (octave_idx_type n, float a = 1.0)
+   {
+     return instance_ok () ? instance->do_float_vector (n, a) : Array<float> ();
+   }
+
   // Return an N-dimensional array of numbers from the sequence,
   // filled in column major order.
   static NDArray nd_array (const dim_vector& dims, double a = 1.0)
@@ -150,10 +161,12 @@
     return instance_ok () ? instance->do_nd_array (dims, a) : NDArray ();
   }
 
-  // Return an array of numbers from the sequence.
-  static Array<double> vector (octave_idx_type n, double a = 1.0)
+
+  // Return an N-dimensional array of numbers from the sequence,
+  // filled in column major order.
+  static FloatNDArray float_nd_array (const dim_vector& dims, float a = 1.0)
   {
-    return instance_ok () ? instance->do_vector (n, a) : Array<double> ();
+    return instance_ok () ? instance->do_float_nd_array (dims, a) : FloatNDArray ();
   }
 
 private:
@@ -220,16 +233,22 @@
   // Return the next number from the sequence.
   double do_scalar (double a = 1.);
 
-  // Return a matrix of numbers from the sequence, filled in column
-  // major order.
-  Matrix do_matrix (octave_idx_type r, octave_idx_type c, double a = 1.);
+  // Return the next number from the sequence.
+  float do_float_scalar (float a = 1.);
+
+  // Return an array of numbers from the sequence.
+  Array<double> do_vector (octave_idx_type n, double a = 1.);
+
+  // Return an array of numbers from the sequence.
+  Array<float> do_float_vector (octave_idx_type n, float a = 1.);
 
   // Return an N-dimensional array of numbers from the sequence,
   // filled in column major order.
   NDArray do_nd_array (const dim_vector& dims, double a = 1.);
 
-  // Return an array of numbers from the sequence.
-  Array<double> do_vector (octave_idx_type n, double a = 1.);
+  // Return an N-dimensional array of numbers from the sequence,
+  // filled in column major order.
+  FloatNDArray do_float_nd_array (const dim_vector& dims, float a = 1.);
 
   // Some helper functions.
 
@@ -248,6 +267,8 @@
   void switch_to_generator (int dist);
 
   void fill (octave_idx_type len, double *v, double a);
+
+  void fill (octave_idx_type len, float *v, float a);
 };
 
 #endif
--- a/liboctave/oct-syscalls.cc
+++ b/liboctave/oct-syscalls.cc
@@ -356,7 +356,7 @@
               else
                 child_msg = "popen2 (child): file handle duplication failed -- " + child_msg;
 
-              (*current_liboctave_error_handler)(child_msg.c_str());
+              (*current_liboctave_error_handler)(child_msg.c_str ());
 
               exit(0);
             }
--- a/liboctave/randgamma.c
+++ b/liboctave/randgamma.c
@@ -58,7 +58,7 @@
 chisq(df) for df>0
   r = 2*randg(df/2)
 t(df) for 0<df<inf (use randn if df is infinite)
-  r = randn() / sqrt(2*randg(df/2)/df)
+  r = randn () / sqrt(2*randg(df/2)/df)
 F(n1,n2) for 0<n1, 0<n2
   r1 = 2*randg(n1/2)/n1 or 1 if n1 is infinite
   r2 = 2*randg(n2/2)/n2 or 1 if n2 is infinite
@@ -141,3 +141,59 @@
   oct_fill_randg(a,1,&ret);
   return ret;
 }
+
+#undef NAN
+#undef RUNI
+#undef RNOR
+#undef REXP
+#define NAN octave_Float_NaN
+#define RUNI oct_float_randu()
+#define RNOR oct_float_randn()
+#define REXP oct_float_rande()
+
+void
+oct_fill_float_randg (float a, octave_idx_type n, float *r)
+{
+  octave_idx_type i;
+  /* If a < 1, start by generating gamma(1+a) */
+  const float d =  (a < 1. ? 1.+a : a) - 1./3.;
+  const float c = 1./sqrt(9.*d);
+
+  /* Handle invalid cases */
+  if (a <= 0 || INFINITE(a))
+    {
+      for (i=0; i < n; i++)
+        r[i] = NAN;
+      return;
+    }
+
+  for (i=0; i < n; i++)
+    {
+      float x, xsq, v, u;
+    frestart:
+      x = RNOR;
+      v = (1+c*x);
+      v *= v*v;
+      if (v <= 0)
+        goto frestart; /* rare, so don't bother moving up */
+      u = RUNI;
+      xsq = x*x;
+      if (u >= 1.-0.0331*xsq*xsq && log(u) >= 0.5*xsq + d*(1-v+log(v)))
+        goto frestart;
+      r[i] = d*v;
+    }
+  if (a < 1)
+    { /* Use gamma(a) = gamma(1+a)*U^(1/a) */
+      /* Given REXP = -log(U) then U^(1/a) = exp(-REXP/a) */
+      for (i = 0; i < n; i++)
+        r[i] *= exp(-REXP/a);
+    }
+}
+
+float
+oct_float_randg (float a)
+{
+  float ret;
+  oct_fill_float_randg(a,1,&ret);
+  return ret;
+}
--- a/liboctave/randgamma.h
+++ b/liboctave/randgamma.h
@@ -32,6 +32,9 @@
 extern OCTAVE_API double oct_randg (double a);
 extern OCTAVE_API void oct_fill_randg (double a, octave_idx_type n, double *p);
 
+extern OCTAVE_API float oct_float_randg (float a);
+extern OCTAVE_API void oct_fill_float_randg (float a, octave_idx_type n, float *p);
+
 #ifdef  __cplusplus
 }
 #endif
--- a/liboctave/randmtzig.c
+++ b/liboctave/randmtzig.c
@@ -64,10 +64,6 @@
    http://www.math.keio.ac.jp/matumoto/emt.html
    email: matumoto@math.keio.ac.jp
 
-   * 2006-04-01 David Bateman
-   * * convert for use in octave, declaring static functions only used
-   *   here and adding oct_ to functions visible externally
-   * * inverse sense of ALLBITS
    * 2004-01-19 Paul Kienzle
    * * comment out main
    * add init_by_entropy, get_state, set_state
@@ -87,6 +83,15 @@
    *
    * 2005-02-23 Paul Kienzle
    * * fix -DHAVE_X86_32 flag and add -DUSE_X86_32=0|1 for explicit control
+   *
+   * 2006-04-01 David Bateman
+   * * convert for use in octave, declaring static functions only used
+   *   here and adding oct_ to functions visible externally
+   * * inverse sense of ALLBITS
+   *
+   * 2012-05-18 David Bateman
+   * * Remove randu64 and ALLBIT option
+   * * Add the single precision generators
    */
 
 /*
@@ -96,9 +101,6 @@
    available.  This is not necessary if your architecture has
    /dev/urandom defined.
 
-   Compile with -DALLBITS to disable 53-bit random numbers. This is about
-   50% slower than using 32-bit random numbers.
-
    Uses implicit -Di386 or explicit -DHAVE_X86_32 to determine if CPU=x86.
    You can force X86 behaviour with -DUSE_X86_32=1, or suppress it with
    -DUSE_X86_32=0. You should also consider -march=i686 or similar for
@@ -126,21 +128,28 @@
    static uint32_t randi32(void)   returns 32-bit unsigned int
    static uint64_t randi53(void)   returns 53-bit unsigned int
    static uint64_t randi54(void)   returns 54-bit unsigned int
-   static uint64_t randi64(void)   returns 64-bit unsigned int
-   static double randu32(void)     returns 32-bit uniform in (0,1)
+   static float randu32(void)     returns 32-bit uniform in (0,1)
    static double randu53(void)     returns 53-bit uniform in (0,1)
 
    double oct_randu(void)       returns M-bit uniform in (0,1)
    double oct_randn(void)       returns M-bit standard normal
    double oct_rande(void)       returns N-bit standard exponential
 
+   float oct_float_randu(void)       returns M-bit uniform in (0,1)
+   float oct_float_randn(void)       returns M-bit standard normal
+   float oct_float_rande(void)       returns N-bit standard exponential
+
    === Array generators ===
    void oct_fill_randi32(octave_idx_type, uint32_t [])
    void oct_fill_randi64(octave_idx_type, uint64_t [])
+
    void oct_fill_randu(octave_idx_type, double [])
    void oct_fill_randn(octave_idx_type, double [])
    void oct_fill_rande(octave_idx_type, double [])
 
+   void oct_fill_float_randu(octave_idx_type, float [])
+   void oct_fill_float_randn(octave_idx_type, float [])
+   void oct_fill_float_rande(octave_idx_type, float [])
 */
 
 #if defined (HAVE_CONFIG_H)
@@ -180,6 +189,7 @@
 static int left = 1;
 static int initf = 0;
 static int initt = 1;
+static int inittf = 1;
 
 /* initializes state[MT_N] with a seed */
 void
@@ -267,7 +277,7 @@
     if (n < MT_N)
       entropy[n++] = time(NULL); /* Current time in seconds */
     if (n < MT_N)
-      entropy[n++] = clock();    /* CPU time used (usec) */
+      entropy[n++] = clock ();    /* CPU time used (usec) */
 #ifdef HAVE_GETTIMEOFDAY
     if (n < MT_N)
       {
@@ -310,7 +320,7 @@
   /* if (initf==0) init_by_int(5489UL); */
   /* Or better yet, a random seed! */
   if (initf == 0)
-    oct_init_by_entropy();
+    oct_init_by_entropy ();
 
   left = MT_N;
   next = state;
@@ -331,7 +341,7 @@
   register uint32_t y;
 
   if (--left == 0)
-    next_state();
+    next_state ();
   y = *next++;
 
   /* Tempering */
@@ -349,8 +359,8 @@
 static uint64_t
 randi53 (void)
 {
-  const uint32_t lo = randi32();
-  const uint32_t hi = randi32()&0x1FFFFF;
+  const uint32_t lo = randi32 ();
+  const uint32_t hi = randi32 ()&0x1FFFFF;
 #if HAVE_X86_32
   uint64_t u;
   uint32_t *p = (uint32_t *)&u;
@@ -365,8 +375,8 @@
 static uint64_t
 randi54 (void)
 {
-  const uint32_t lo = randi32();
-  const uint32_t hi = randi32()&0x3FFFFF;
+  const uint32_t lo = randi32 ();
+  const uint32_t hi = randi32 ()&0x3FFFFF;
 #if HAVE_X86_32
   uint64_t u;
   uint32_t *p = (uint32_t *)&u;
@@ -378,71 +388,38 @@
 #endif
 }
 
-#if 0
-// FIXME -- this doesn't seem to be used anywhere; should it be removed?
-static uint64_t
-randi64 (void)
-{
-  const uint32_t lo = randi32();
-  const uint32_t hi = randi32();
-#if HAVE_X86_32
-  uint64_t u;
-  uint32_t *p = (uint32_t *)&u;
-  p[0] = lo;
-  p[1] = hi;
-  return u;
-#else
-  return (((uint64_t)hi<<32)|lo);
-#endif
-}
-#endif
-
-#ifdef ALLBITS
 /* generates a random number on (0,1)-real-interval */
-static double
+static float
 randu32 (void)
 {
-  return ((double)randi32() + 0.5) * (1.0/4294967296.0);
+  return ((float)randi32 () + 0.5) * (1.0/4294967296.0);
   /* divided by 2^32 */
 }
-#else
+
 /* generates a random number on (0,1) with 53-bit resolution */
 static double
 randu53 (void)
 {
-  const uint32_t a=randi32()>>5;
-  const uint32_t b=randi32()>>6;
+  const uint32_t a=randi32 ()>>5;
+  const uint32_t b=randi32 ()>>6;
   return (a*67108864.0+b+0.4) * (1.0/9007199254740992.0);
 }
-#endif
 
 /* Determine mantissa for uniform doubles */
 double
 oct_randu (void)
 {
-#ifdef ALLBITS
+  return randu53 ();
+}
+
+/* Determine mantissa for uniform floats */
+float
+oct_float_randu (void)
+{
   return randu32 ();
-#else
-  return randu53 ();
-#endif
 }
 
 /* ===== Ziggurat normal and exponential generators ===== */
-#ifdef ALLBITS
-# define ZIGINT uint32_t
-# define EMANTISSA 4294967296.0 /* 32 bit mantissa */
-# define ERANDI randi32() /* 32 bits for mantissa */
-# define NMANTISSA 2147483648.0 /* 31 bit mantissa */
-# define NRANDI randi32() /* 31 bits for mantissa + 1 bit sign */
-# define RANDU randu32()
-#else
-# define ZIGINT uint64_t
-# define EMANTISSA 9007199254740992.0  /* 53 bit mantissa */
-# define ERANDI randi53() /* 53 bits for mantissa */
-# define NMANTISSA EMANTISSA
-# define NRANDI randi54() /* 53 bits for mantissa + 1 bit sign */
-# define RANDU randu53()
-#endif
 
 #define ZIGGURAT_TABLE_SIZE 256
 
@@ -454,6 +431,13 @@
 #define ZIGGURAT_EXP_INV_R 0.129918765548341586
 #define EXP_SECTION_AREA 0.0039496598225815571993
 
+#define ZIGINT uint64_t
+#define EMANTISSA 9007199254740992.0  /* 53 bit mantissa */
+#define ERANDI randi53() /* 53 bits for mantissa */
+#define NMANTISSA EMANTISSA
+#define NRANDI randi54() /* 53 bits for mantissa + 1 bit sign */
+#define RANDU randu53()
+
 static ZIGINT ki[ZIGGURAT_TABLE_SIZE];
 static double wi[ZIGGURAT_TABLE_SIZE], fi[ZIGGURAT_TABLE_SIZE];
 static ZIGINT ke[ZIGGURAT_TABLE_SIZE];
@@ -580,7 +564,7 @@
 oct_randn (void)
 {
   if (initt)
-    create_ziggurat_tables();
+    create_ziggurat_tables ();
 
   while (1)
     {
@@ -592,7 +576,6 @@
        * Of course, different compilers and operating systems may
        * have something to do with this.
        */
-#if !defined(ALLBITS)
 # if HAVE_X86_32
       /* 53-bit mantissa, 1-bit sign, x86 32-bit architecture */
       double x;
@@ -600,9 +583,9 @@
       register uint32_t lo, hi;
       int64_t rabs;
       uint32_t *p = (uint32_t *)&rabs;
-      lo = randi32();
+      lo = randi32 ();
       idx = lo&0xFF;
-      hi = randi32();
+      hi = randi32 ();
       si = hi&UMASK;
       p[0] = lo;
       p[1] = hi&0x1FFFFF;
@@ -615,14 +598,6 @@
       const double x = ( r&1 ? -rabs : rabs) * wi[idx];
 # endif /* !HAVE_X86_32 */
       if (rabs < (int64_t)ki[idx])
-#else /* ALLBITS */
-      /* 32-bit mantissa */
-      const uint32_t r = randi32();
-      const uint32_t rabs = r&LMASK;
-      const int idx = (int)(r&0xFF);
-      const double x = ((int32_t)r) * wi[idx];
-      if (rabs < ki[idx])
-#endif /* ALLBITS */
         return x;        /* 99.3% of the time we return here 1st try */
       else if (idx == 0)
         {
@@ -654,7 +629,7 @@
 oct_rande (void)
 {
   if (initt)
-    create_ziggurat_tables();
+    create_ziggurat_tables ();
 
   while (1)
     {
@@ -677,13 +652,180 @@
     }
 }
 
+#undef ZIGINT
+#undef EMANTISSA
+#undef ERANDI
+#undef NMANTISSA
+#undef NRANDI
+#undef RANDU
+
+#define ZIGINT uint32_t
+#define EMANTISSA 4294967296.0 /* 32 bit mantissa */
+#define ERANDI randi32() /* 32 bits for mantissa */
+#define NMANTISSA 2147483648.0 /* 31 bit mantissa */
+#define NRANDI randi32() /* 31 bits for mantissa + 1 bit sign */
+#define RANDU randu32()
+
+static ZIGINT fki[ZIGGURAT_TABLE_SIZE];
+static float fwi[ZIGGURAT_TABLE_SIZE], ffi[ZIGGURAT_TABLE_SIZE];
+static ZIGINT fke[ZIGGURAT_TABLE_SIZE];
+static float fwe[ZIGGURAT_TABLE_SIZE], ffe[ZIGGURAT_TABLE_SIZE];
+
+
+static void
+create_ziggurat_float_tables (void)
+{
+  int i;
+  float x, x1;
+
+  /* Ziggurat tables for the normal distribution */
+  x1 = ZIGGURAT_NOR_R;
+  fwi[255] = x1 / NMANTISSA;
+  ffi[255] = exp (-0.5 * x1 * x1);
+
+  /* Index zero is special for tail strip, where Marsaglia and Tsang
+   * defines this as
+   * k_0 = 2^31 * r * f(r) / v, w_0 = 0.5^31 * v / f(r), f_0 = 1,
+   * where v is the area of each strip of the ziggurat.
+   */
+  fki[0] = (ZIGINT) (x1 * ffi[255] / NOR_SECTION_AREA * NMANTISSA);
+  fwi[0] = NOR_SECTION_AREA / ffi[255] / NMANTISSA;
+  ffi[0] = 1.;
+
+  for (i = 254; i > 0; i--)
+    {
+      /* New x is given by x = f^{-1}(v/x_{i+1} + f(x_{i+1})), thus
+       * need inverse operator of y = exp(-0.5*x*x) -> x = sqrt(-2*ln(y))
+       */
+      x = sqrt(-2. * log(NOR_SECTION_AREA / x1 + ffi[i+1]));
+      fki[i+1] = (ZIGINT)(x / x1 * NMANTISSA);
+      fwi[i] = x / NMANTISSA;
+      ffi[i] = exp (-0.5 * x * x);
+      x1 = x;
+    }
+
+  fki[1] = 0;
+
+  /* Zigurrat tables for the exponential distribution */
+  x1 = ZIGGURAT_EXP_R;
+  fwe[255] = x1 / EMANTISSA;
+  ffe[255] = exp (-x1);
+
+  /* Index zero is special for tail strip, where Marsaglia and Tsang
+   * defines this as
+   * k_0 = 2^32 * r * f(r) / v, w_0 = 0.5^32 * v / f(r), f_0 = 1,
+   * where v is the area of each strip of the ziggurat.
+   */
+  fke[0] = (ZIGINT) (x1 * ffe[255] / EXP_SECTION_AREA * EMANTISSA);
+  fwe[0] = EXP_SECTION_AREA / ffe[255] / EMANTISSA;
+  ffe[0] = 1.;
+
+  for (i = 254; i > 0; i--)
+    {
+      /* New x is given by x = f^{-1}(v/x_{i+1} + f(x_{i+1})), thus
+       * need inverse operator of y = exp(-x) -> x = -ln(y)
+       */
+      x = - log(EXP_SECTION_AREA / x1 + ffe[i+1]);
+      fke[i+1] = (ZIGINT)(x / x1 * EMANTISSA);
+      fwe[i] = x / EMANTISSA;
+      ffe[i] = exp (-x);
+      x1 = x;
+    }
+  fke[1] = 0;
+
+  inittf = 0;
+}
+
+/*
+ * Here is the guts of the algorithm. As Marsaglia and Tsang state the
+ * algorithm in their paper
+ *
+ * 1) Calculate a random signed integer j and let i be the index
+ *     provided by the rightmost 8-bits of j
+ * 2) Set x = j * w_i. If j < k_i return x
+ * 3) If i = 0, then return x from the tail
+ * 4) If [f(x_{i-1}) - f(x_i)] * U < f(x) - f(x_i), return x
+ * 5) goto step 1
+ *
+ * Where f is the functional form of the distribution, which for a normal
+ * distribution is exp(-0.5*x*x)
+ */
+
+float
+oct_float_randn (void)
+{
+  if (inittf)
+    create_ziggurat_float_tables ();
+
+  while (1)
+    {
+      /* 32-bit mantissa */
+      const uint32_t r = randi32 ();
+      const uint32_t rabs = r&LMASK;
+      const int idx = (int)(r&0xFF);
+      const float x = ((int32_t)r) * fwi[idx];
+      if (rabs < fki[idx])
+        return x;        /* 99.3% of the time we return here 1st try */
+      else if (idx == 0)
+        {
+          /* As stated in Marsaglia and Tsang
+           *
+           * For the normal tail, the method of Marsaglia[5] provides:
+           * generate x = -ln(U_1)/r, y = -ln(U_2), until y+y > x*x,
+           * then return r+x. Except that r+x is always in the positive
+           * tail!!!! Any thing random might be used to determine the
+           * sign, but as we already have r we might as well use it
+           *
+           * [PAK] but not the bottom 8 bits, since they are all 0 here!
+           */
+          float xx, yy;
+          do
+            {
+              xx = - ZIGGURAT_NOR_INV_R * log (RANDU);
+              yy = - log (RANDU);
+            }
+          while ( yy+yy <= xx*xx);
+          return (rabs&0x100 ? -ZIGGURAT_NOR_R-xx : ZIGGURAT_NOR_R+xx);
+        }
+      else if ((ffi[idx-1] - ffi[idx]) * RANDU + ffi[idx] < exp(-0.5*x*x))
+        return x;
+    }
+}
+
+float
+oct_float_rande (void)
+{
+  if (inittf)
+    create_ziggurat_float_tables ();
+
+  while (1)
+    {
+      ZIGINT ri = ERANDI;
+      const int idx = (int)(ri & 0xFF);
+      const float x = ri * fwe[idx];
+      if (ri < fke[idx])
+        return x;               // 98.9% of the time we return here 1st try
+      else if (idx == 0)
+        {
+          /* As stated in Marsaglia and Tsang
+           *
+           * For the exponential tail, the method of Marsaglia[5] provides:
+           * x = r - ln(U);
+           */
+          return ZIGGURAT_EXP_R - log(RANDU);
+        }
+      else if ((ffe[idx-1] - ffe[idx]) * RANDU + ffe[idx] < exp(-x))
+        return x;
+    }
+}
+
 /* Array generators */
 void
 oct_fill_randu (octave_idx_type n, double *p)
 {
   octave_idx_type i;
   for (i = 0; i < n; i++)
-    p[i] = oct_randu();
+    p[i] = oct_randu ();
 }
 
 void
@@ -691,7 +833,7 @@
 {
   octave_idx_type i;
   for (i = 0; i < n; i++)
-    p[i] = oct_randn();
+    p[i] = oct_randn ();
 }
 
 void
@@ -699,5 +841,29 @@
 {
   octave_idx_type i;
   for (i = 0; i < n; i++)
-    p[i] = oct_rande();
+    p[i] = oct_rande ();
+}
+
+void
+oct_fill_float_randu (octave_idx_type n, float *p)
+{
+  octave_idx_type i;
+  for (i = 0; i < n; i++)
+    p[i] = oct_float_randu ();
 }
+
+void
+oct_fill_float_randn (octave_idx_type n, float *p)
+{
+  octave_idx_type i;
+  for (i = 0; i < n; i++)
+    p[i] = oct_float_randn ();
+}
+
+void
+oct_fill_float_rande (octave_idx_type n, float *p)
+{
+  octave_idx_type i;
+  for (i = 0; i < n; i++)
+    p[i] = oct_float_rande ();
+}
--- a/liboctave/randmtzig.h
+++ b/liboctave/randmtzig.h
@@ -82,11 +82,19 @@
 extern OCTAVE_API double oct_randn (void);
 extern OCTAVE_API double oct_rande (void);
 
+extern OCTAVE_API float oct_float_randu (void);
+extern OCTAVE_API float oct_float_randn (void);
+extern OCTAVE_API float oct_float_rande (void);
+
 /* === Array generators === */
 extern OCTAVE_API void oct_fill_randu (octave_idx_type n, double *p);
 extern OCTAVE_API void oct_fill_randn (octave_idx_type n, double *p);
 extern OCTAVE_API void oct_fill_rande (octave_idx_type n, double *p);
 
+extern OCTAVE_API void oct_fill_float_randu (octave_idx_type n, float *p);
+extern OCTAVE_API void oct_fill_float_randn (octave_idx_type n, float *p);
+extern OCTAVE_API void oct_fill_float_rande (octave_idx_type n, float *p);
+
 #ifdef  __cplusplus
 }
 #endif
--- a/liboctave/randpoisson.c
+++ b/liboctave/randpoisson.c
@@ -368,6 +368,46 @@
   }
 }
 
+static void
+poisson_cdf_lookup_float(double lambda, float *p, size_t n)
+{
+  double t[TABLESIZE];
+
+  /* Precompute the table for the u up to and including 0.458.
+   * We will almost certainly need it. */
+  int intlambda = (int)floor(lambda);
+  double P;
+  int tableidx;
+  size_t i = n;
+
+  t[0] = P = exp(-lambda);
+  for (tableidx = 1; tableidx <= intlambda; tableidx++) {
+    P = P*lambda/(double)tableidx;
+    t[tableidx] = t[tableidx-1] + P;
+  }
+
+  while (i-- > 0) {
+    double u = RUNI;
+    int k = (u > 0.458 ? intlambda : 0);
+  nextk:
+    if ( u <= t[k] ) {
+      p[i] = (float) k;
+      continue;
+    }
+    if (++k < tableidx) goto nextk;
+
+    while (tableidx < TABLESIZE) {
+      P = P*lambda/(double)tableidx;
+      t[tableidx] = t[tableidx-1] + P;
+      if (t[tableidx] == t[tableidx-1]) t[tableidx] = 1.0;
+      tableidx++;
+      if (u <= t[tableidx-1]) break;
+    }
+
+    p[i] = (float)(tableidx-1);
+  }
+}
+
 /* From Press, et al., Numerical Recipes */
 static void
 poisson_rejection (double lambda, double *p, size_t n)
@@ -392,6 +432,30 @@
     }
 }
 
+/* From Press, et al., Numerical Recipes */
+static void
+poisson_rejection_float (double lambda, float *p, size_t n)
+{
+  double sq = sqrt(2.0*lambda);
+  double alxm = log(lambda);
+  double g = lambda*alxm - LGAMMA(lambda+1.0);
+  size_t i;
+
+  for (i = 0; i < n; i++)
+    {
+      double y, em, t;
+      do {
+        do {
+          y = tan(M_PI*RUNI);
+          em = sq * y + lambda;
+        } while (em < 0.0);
+        em = floor(em);
+        t = 0.9*(1.0+y*y)*exp(em*alxm-flogfak(em)-g);
+      } while (RUNI > t);
+      p[i] = em;
+    }
+}
+
 /* The cutoff of L <= 1e8 in the following two functions before using
  * the normal approximation is based on:
  *   > L=1e8; x=floor(linspace(0,2*L,1000));
@@ -463,3 +527,68 @@
   }
   return ret;
 }
+
+/* Generate a set of poisson numbers with the same distribution */
+void
+oct_fill_float_randp (float FL, octave_idx_type n, float *p)
+{
+  double L = FL;
+  octave_idx_type i;
+  if (L < 0.0 || INFINITE(L))
+    {
+      for (i=0; i<n; i++)
+        p[i] = NAN;
+    }
+  else if (L <= 10.0)
+    {
+      poisson_cdf_lookup_float(L, p, n);
+    }
+  else if (L <= 1e8)
+    {
+      for (i=0; i<n; i++)
+        p[i] = pprsc(L);
+    }
+  else
+    {
+      /* normal approximation: from Phys. Rev. D (1994) v50 p1284 */
+      const double sqrtL = sqrt(L);
+      for (i = 0; i < n; i++)
+        {
+          p[i] = floor(RNOR*sqrtL + L + 0.5);
+          if (p[i] < 0.0)
+            p[i] = 0.0; /* will probably never happen */
+        }
+    }
+}
+
+/* Generate one poisson variate */
+float
+oct_float_randp (float FL)
+{
+  double L = FL;
+  float ret;
+  if (L < 0.0) ret = NAN;
+  else if (L <= 12.0) {
+    /* From Press, et al. Numerical recipes */
+    double g = exp(-L);
+    int em = -1;
+    double t = 1.0;
+    do {
+      ++em;
+      t *= RUNI;
+    } while (t > g);
+    ret = em;
+  } else if (L <= 1e8) {
+    /* numerical recipes */
+    poisson_rejection_float(L, &ret, 1);
+  } else if (INFINITE(L)) {
+    /* FIXME R uses NaN, but the normal approx. suggests that as
+     * limit should be inf. Which is correct? */
+    ret = NAN;
+  } else {
+    /* normal approximation: from Phys. Rev. D (1994) v50 p1284 */
+    ret = floor(RNOR*sqrt(L) + L + 0.5);
+    if (ret < 0.0) ret = 0.0; /* will probably never happen */
+  }
+  return ret;
+}
--- a/liboctave/randpoisson.h
+++ b/liboctave/randpoisson.h
@@ -32,6 +32,9 @@
 extern OCTAVE_API double oct_randp (double L);
 extern OCTAVE_API void oct_fill_randp (double L, octave_idx_type n, double *p);
 
+extern OCTAVE_API float oct_float_randp (float L);
+extern OCTAVE_API void oct_fill_float_randp (float L, octave_idx_type n, float *p);
+
 #ifdef  __cplusplus
 }
 #endif
--- a/liboctave/regexp.cc
+++ b/liboctave/regexp.cc
@@ -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;
@@ -333,8 +333,7 @@
             {
               if (ovector[2*i] >= 0 && ovector[2*i+1] > 0
                   && (i == 1 || ovector[2*i] != ovector[2*i-2]
-                      || ovector[2*i-1] != ovector[2*i+1])
-                  && ovector[2*i] >= 0 && ovector[2*i+1] > 0)
+                      || ovector[2*i-1] != ovector[2*i+1]))
                 {
                   token_extents(pos_match,0) = double (ovector[2*i]+1);
                   token_extents(pos_match++,1) = double (ovector[2*i+1]);
@@ -401,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
+++ b/liboctave/regexp.h
@@ -33,7 +33,9 @@
 #include "base-list.h"
 #include "str-vec.h"
 
-class regexp
+class
+OCTAVE_API
+regexp
 {
 public:
 
@@ -87,17 +89,19 @@
   std::string replace (const std::string& buffer,
                        const std::string& replacement);
 
-  struct opts
+  class opts
   {
   public:
 
     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)
@@ -109,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;
@@ -121,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; }
@@ -135,6 +142,7 @@
 
     bool x_case_insensitive;
     bool x_dotexceptnewline;
+    bool x_emptymatch;
     bool x_freespacing;
     bool x_lineanchors;
     bool x_once;
--- a/liboctave/sparse-base-chol.cc
+++ b/liboctave/sparse-base-chol.cc
@@ -129,9 +129,9 @@
   ac->nrow = a_nr;
   ac->ncol = a_nc;
 
-  ac->p = a.cidx();
-  ac->i = a.ridx();
-  ac->nzmax = a.nnz();
+  ac->p = a.cidx ();
+  ac->i = a.ridx ();
+  ac->nzmax = a.nnz ();
   ac->packed = true;
   ac->sorted = true;
   ac->nz = 0;
@@ -151,7 +151,7 @@
   if (a_nr < 1)
     ac->x = &dummy;
   else
-    ac->x = a.data();
+    ac->x = a.data ();
 
   // use natural ordering if no q output parameter
   if (natural)
@@ -224,7 +224,7 @@
 sparse_base_chol<chol_type, chol_elt, p_type>::L (void) const
 {
 #ifdef HAVE_CHOLMOD
-  cholmod_sparse *m = rep->L();
+  cholmod_sparse *m = rep->L ();
   octave_idx_type nc = m->ncol;
   octave_idx_type nnz = m->nzmax;
   chol_type ret (m->nrow, nc, nnz);
@@ -237,7 +237,7 @@
     }
   return ret;
 #else
-  return chol_type();
+  return chol_type ();
 #endif
 }
 
@@ -260,7 +260,7 @@
 
   return p;
 #else
-  return p_type();
+  return p_type ();
 #endif
 }
 
@@ -270,19 +270,19 @@
 {
   chol_type retval;
 #ifdef HAVE_CHOLMOD
-  cholmod_sparse *m = rep->L();
+  cholmod_sparse *m = rep->L ();
   octave_idx_type n = m->ncol;
-  ColumnVector perms = rep->perm();
+  ColumnVector perms = rep->perm ();
   chol_type ret;
   double rcond2;
   octave_idx_type info;
   MatrixType mattype (MatrixType::Upper);
-  chol_type linv = L().hermitian().inverse(mattype, info, rcond2, 1, 0);
+  chol_type linv = L ().hermitian ().inverse(mattype, info, rcond2, 1, 0);
 
-  if (perms.length() == n)
+  if (perms.length () == n)
     {
-      p_type Qc = Q();
-      retval = Qc * linv * linv.hermitian() * Qc.transpose();
+      p_type Qc = Q ();
+      retval = Qc * linv * linv.hermitian () * Qc.transpose ();
     }
   else
     retval = linv * linv.hermitian ();
--- a/liboctave/sparse-base-chol.h
+++ b/liboctave/sparse-base-chol.h
@@ -198,18 +198,18 @@
 
   chol_type L (void) const;
 
-  chol_type R (void) const { return L().hermitian (); }
+  chol_type R (void) const { return L ().hermitian (); }
 
-  octave_idx_type P (void) const { return rep->P(); }
+  octave_idx_type P (void) const { return rep->P (); }
 
-  ColumnVector perm (void) const { return rep->perm(); }
+  ColumnVector perm (void) const { return rep->perm (); }
 
-  p_type Q (void) const { return rep->Q(); }
+  p_type Q (void) const { return rep->Q (); }
 
   bool is_positive_definite (void) const
-    { return rep->is_positive_definite(); }
+    { return rep->is_positive_definite (); }
 
-  double rcond (void) const { return rep->rcond(); }
+  double rcond (void) const { return rep->rcond (); }
 
   chol_type inverse (void) const;
 };
--- a/liboctave/sparse-base-lu.cc
+++ b/liboctave/sparse-base-lu.cc
@@ -35,7 +35,7 @@
   octave_idx_type nc = Ufact.rows ();
   octave_idx_type rcmin = (nr > nc ? nr : nc);
 
-  lu_type Yout (nr, nc, Lfact.nnz() + Ufact.nnz());
+  lu_type Yout (nr, nc, Lfact.nnz () + Ufact.nnz ());
   octave_idx_type ii = 0;
   Yout.xcidx(0) = 0;
 
--- a/liboctave/sparse-dmsolve.cc
+++ b/liboctave/sparse-dmsolve.cc
@@ -73,7 +73,7 @@
     {
       OCTAVE_LOCAL_BUFFER (T, X, rend - rst);
       octave_sort<octave_idx_type> sort;
-      octave_idx_type *ri = B.xridx();
+      octave_idx_type *ri = B.xridx ();
       nz = 0;
       for (octave_idx_type j = cst ; j < cend ; j++)
         {
@@ -158,11 +158,11 @@
 dmsolve_insert (MArray<T> &a, const MArray<T> &b, const octave_idx_type *Q,
                octave_idx_type r, octave_idx_type c)
 {
-  T *ax = a.fortran_vec();
-  const T *bx = b.fortran_vec();
-  octave_idx_type anr = a.rows();
-  octave_idx_type nr = b.rows();
-  octave_idx_type nc = b.cols();
+  T *ax = a.fortran_vec ();
+  const T *bx = b.fortran_vec ();
+  octave_idx_type anr = a.rows ();
+  octave_idx_type nr = b.rows ();
+  octave_idx_type nc = b.cols ();
   for (octave_idx_type j = 0; j < nc; j++)
     {
       octave_idx_type aoff = (c + j) * anr;
@@ -214,7 +214,7 @@
   octave_sort<octave_idx_type> sort;
   MSparse<T> tmp (a);
   a = MSparse<T> (nr, nc, nel);
-  octave_idx_type *ri = a.xridx();
+  octave_idx_type *ri = a.xridx ();
 
   for (octave_idx_type i = 0; i < tmp.cidx(c); i++)
     {
@@ -278,9 +278,9 @@
 {
   octave_idx_type b_nr = b.rows ();
   octave_idx_type b_nc = b.cols ();
-  const T *Bx = b.fortran_vec();
+  const T *Bx = b.fortran_vec ();
   a.resize (dim_vector (b_nr, b_nc));
-  RT *Btx = a.fortran_vec();
+  RT *Btx = a.fortran_vec ();
   for (octave_idx_type j = 0; j < b_nc; j++)
     {
       octave_idx_type off = j * b_nr;
@@ -316,7 +316,7 @@
   octave_idx_type nz = 0;
   a = MSparse<RT> (b_nr, b_nc, b_nz);
   octave_sort<octave_idx_type> sort;
-  octave_idx_type *ri = a.xridx();
+  octave_idx_type *ri = a.xridx ();
   OCTAVE_LOCAL_BUFFER (RT, X, b_nr);
   a.xcidx(0) = 0;
   for (octave_idx_type j = 0; j < b_nc; j++)
@@ -411,7 +411,7 @@
         {
           ST m = dmsolve_extract (a, pinv, q, dm->rr [2], nr, dm->cc [3], nc,
                                   nnz_remaining, true);
-          nnz_remaining -= m.nnz();
+          nnz_remaining -= m.nnz ();
           RT mtmp =
             qrsolve (m, dmsolve_extract (btmp, 0, 0, dm->rr[2], b_nr, 0,
                                          b_nc), info);
@@ -420,7 +420,7 @@
             {
               m = dmsolve_extract (a, pinv, q, 0, dm->rr [2],
                                    dm->cc [3], nc, nnz_remaining, true);
-              nnz_remaining -= m.nnz();
+              nnz_remaining -= m.nnz ();
               RT ctmp = dmsolve_extract (btmp, 0, 0, 0,
                                          dm->rr[2], 0, b_nc);
               btmp.insert (ctmp - m * mtmp, 0, 0);
@@ -433,7 +433,7 @@
         {
           ST m = dmsolve_extract (a, pinv, q, dm->rr [1], dm->rr [2],
                                   dm->cc [2], dm->cc [3], nnz_remaining, false);
-          nnz_remaining -= m.nnz();
+          nnz_remaining -= m.nnz ();
           RT btmp2 = dmsolve_extract (btmp, 0, 0, dm->rr [1], dm->rr [2],
                                       0, b_nc);
           double rcond = 0.0;
@@ -451,7 +451,7 @@
             {
               m = dmsolve_extract (a, pinv, q, 0, dm->rr [1], dm->cc [2],
                                    dm->cc [3], nnz_remaining, true);
-              nnz_remaining -= m.nnz();
+              nnz_remaining -= m.nnz ();
               RT ctmp = dmsolve_extract (btmp, 0, 0, 0,
                                          dm->rr[1], 0, b_nc);
               btmp.insert (ctmp - m * mtmp, 0, 0);
--- a/liboctave/str-vec.cc
+++ b/liboctave/str-vec.cc
@@ -212,7 +212,8 @@
 // Format a list in neat columns.
 
 std::ostream&
-string_vector::list_in_columns (std::ostream& os, int width) const
+string_vector::list_in_columns (std::ostream& os, int width,
+                                const std::string& prefix) const
 {
   // Compute the maximum name length.
 
@@ -241,7 +242,8 @@
   // Calculate the maximum number of columns that will fit.
 
   octave_idx_type line_length
-    = (width <= 0) ? command_editor::terminal_cols () : width;
+    = ((width <= 0 ? command_editor::terminal_cols () : width)
+       - prefix.length ());
 
   octave_idx_type nc = line_length / max_name_length;
   if (nc == 0)
@@ -264,6 +266,8 @@
 
       // Print the next row.
 
+      os << prefix;
+
       while (1)
         {
           std::string nm = elem (count);
--- a/liboctave/str-vec.h
+++ b/liboctave/str-vec.h
@@ -88,7 +88,7 @@
     return longest;
   }
 
-  void resize (octave_idx_type n, const std::string& rfv = resize_fill_value ())
+  void resize (octave_idx_type n, const std::string& rfv = std::string ())
   {
     Array<std::string>::resize (dim_vector (n, 1), rfv);
   }
@@ -111,7 +111,9 @@
 
   static void delete_c_str_vec (const char * const*);
 
-  std::ostream& list_in_columns (std::ostream&, int width = 0) const;
+  std::ostream&
+  list_in_columns (std::ostream&, int width = 0,
+                   const std::string& prefix = std::string ()) const;
 };
 
 #endif
--- a/liboctave/tempname.c
+++ b/liboctave/tempname.c
@@ -107,7 +107,7 @@
   size_t *idx;
   static char buf[FILENAME_MAX];
   static pid_t oldpid = (pid_t) 0;
-  pid_t pid = getpid();
+  pid_t pid = getpid ();
   register size_t len, plen, dlen;
 
   if (dir_search)
--- a/m4/acinclude.m4
+++ b/m4/acinclude.m4
@@ -105,6 +105,27 @@
 AC_LANG_POP(C++)
 ])
 dnl
+dnl See if the C++ library has the bit_and, bit_or and bit_xor
+dnl templates defined.
+dnl
+AC_DEFUN([OCTAVE_CXX_BITWISE_OP_TEMPLATES],
+[AC_CACHE_CHECK([whether bit_and, bit_or and bit_xor are defined in the c++ library],
+octave_cv_cxx_bitwise_op_templates,
+[AC_LANG_PUSH(C++)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <functional>]],
+[[int x = 0;
+int y = 1;
+int z1 = std::bit_and<int>() (x, y);
+int z2 = std::bit_or<int>() (x, y);
+int z3 = std::bit_xor<int>() (x, y);]])],
+octave_cv_cxx_bitwise_op_templates=yes, octave_cv_cxx_bitwise_op_templates=no)])
+if test $octave_cv_cxx_bitwise_op_templates = yes; then
+AC_DEFINE(HAVE_CXX_BITWISE_OP_TEMPLATES,1,[Define if C++ library has templated bitwise operators])
+fi
+AC_LANG_POP(C++)
+])
+
+dnl
 dnl See if the C++ library has functions to set real and imaginary
 dnl parts of complex numbers independently.
 dnl
@@ -137,6 +158,25 @@
 AC_LANG_POP(C++)
 ])
 dnl
+dnl See if the Carbon Framework defines CGDisplayBitsPerPixel.
+dnl
+AC_DEFUN([OCTAVE_CARBON_CGDISPLAYBITSPERPIXEL],
+[AC_CACHE_CHECK([whether CGDisplayBitsPerPixel is defined in the Carbon Framework],
+octave_cv_carbon_cgdisplaybitsperpixel,
+[AC_LANG_PUSH(C++)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <Carbon/Carbon.h>
+]], [[
+CGDirectDisplayID display = CGMainDisplayID ();
+size_t depth = CGDisplayBitsPerPixel (display);
+]])],
+octave_cv_carbon_cgdisplaybitsperpixel=yes, octave_cv_carbon_cgdisplaybitsperpixel=no)])
+if test $octave_cv_carbon_cgdisplaybitsperpixel = yes; then
+AC_DEFINE(HAVE_CARBON_CGDISPLAYBITSPERPIXEL,1,[Define if Carbon Framework has CGDisplayBitsPerPixel])
+fi
+AC_LANG_POP(C++)
+])
+dnl
 dnl The following test is from Karl Berry's Kpathseach library.  I'm
 dnl including it here in case we someday want to make the use of
 dnl kpathsea optional.
@@ -329,6 +369,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], [
@@ -384,6 +446,25 @@
 ])
 dnl
 dnl
+dnl Adds warnings to final summary
+dnl
+AC_DEFUN([OCTAVE_CONFIGURE_WARNING], [
+  AC_MSG_WARN([$][$1])
+  m4_set_add([summary_warning_list], [$1])
+])
+dnl
+dnl
+dnl Prints final summary
+dnl
+AC_DEFUN([OCTAVE_CONFIGURE_WARNING_SUMMARY], [
+  m4_set_foreach([summary_warning_list], [elt], [
+    if test -n "[$]elt"; then
+      AC_MSG_WARN([$]elt)
+      warn_msg_printed=true
+    fi])
+])
+dnl
+dnl
 dnl
 dnl OCTAVE_CHECK_LIBRARY(LIBRARY, DOC-NAME, WARN-MSG, HEADER, FUNC,
 dnl                      LANG, DOC-STRING, EXTRA-CHECK)
@@ -424,6 +505,8 @@
 
   [TEXINFO_]m4_toupper([$1])=
   warn_$1="$3"
+  m4_set_add([summary_warning_list], [warn_$1])
+
   if test -n "$m4_toupper([$1])_LIBS"; then
     octave_check_library_save_CPPFLAGS="$CPPFLAGS"
     CPPFLAGS="$m4_toupper([$1])_CPPFLAGS $CPPFLAGS"
@@ -478,9 +561,13 @@
       LEXLIB=
     ;;
     *)
-      LEX='$(top_srcdir)/missing flex'
-      warn_flex="I didn't find flex, but it's only a problem if you need to reconstruct lex.cc"
-      AC_MSG_WARN([$warn_flex])
+      LEX='$(top_srcdir)/build-aux/missing flex'
+      warn_flex="
+
+I didn't find flex, but it's only a problem if you need to reconstruct
+lex.cc, which is the case if you're building from VCS sources.
+"
+      OCTAVE_CONFIGURE_WARNING([warn_flex])
     ;;
   esac
   AC_SUBST(LFLAGS)
@@ -494,9 +581,15 @@
     bison*)
     ;;
     *)
-      YACC='$(top_srcdir)/missing bison'
-      warn_bison="I didn't find bison, but it's only a problem if you need to reconstruct parse.cc"
-      AC_MSG_WARN([$warn_bison])
+      YACC='$(top_srcdir)/build-aux/missing bison'
+      warn_bison="
+
+I didn't find bison, but it's only a problem if you need to
+reconstruct parse.cc, which is the case if you're building from VCS
+sources.
+
+"
+      OCTAVE_CONFIGURE_WARNING([warn_bison])
     ;;
   esac
 ])
@@ -519,7 +612,7 @@
   AC_CHECK_PROGS(DEFAULT_PAGER, $octave_possible_pagers, [])
   if test -z "$DEFAULT_PAGER"; then
     warn_less="I couldn't find \`less', \`more', \`page', or \`pg'"
-    AC_MSG_WARN([$warn_less])
+    OCTAVE_CONFIGURE_WARNING([warn_less])
   fi
 fi
 ])
@@ -538,10 +631,14 @@
     warn_gnuplot=yes
 
     GNUPLOT="$gp_default"
+    warn_gnuplot = "
 
-    AC_MSG_WARN([gnuplot not found.  It isn't necessary to have gnuplot])
-    AC_MSG_WARN([installed, but without native graphics or gnuplot])
-	 AC_MSG_WARN([you won't be able to use any of Octave's plotting commands.])
+gnuplot not found. It isn't necessary to have gnuplot installed, but
+without native graphics or gnuplot you won't be able to use any of
+Octave's plotting commands.
+
+"
+    OCTAVE_CONFIGURE_WARNING([warn_gnuplot])
   fi
 fi
 AC_SUBST(GNUPLOT)
@@ -553,9 +650,13 @@
 AC_DEFUN([OCTAVE_PROG_GPERF], [
   AC_CHECK_PROG(GPERF, gperf, gperf, [])
   if test -z "$GPERF"; then
-    GPERF='$(top_srcdir)/missing gperf'
-    warn_gperf="I didn't find gperf, but it's only a problem if you need to reconstruct oct-gperf.h"
-    AC_MSG_WARN([$warn_gperf])
+    GPERF='$(top_srcdir)/build-aux/missing gperf'
+    warn_gperf="
+
+I didn't find gperf, but it's only a problem if you need to
+reconstruct oct-gperf.h 
+"
+    OCTAVE_CONFIGURE_WARNING([warn_gperf])
   fi
   AC_SUBST(GPERF)
 ])
@@ -574,9 +675,15 @@
   esac
   AC_CHECK_PROGS(GHOSTSCRIPT, [$gs_names])
   if test -z "$GHOSTSCRIPT"; then
-    GHOSTSCRIPT='$(top_srcdir)/missing gs'
-    warn_ghostscript="I didn't find ghostscript, so reconstructing figures for the manual will fail, and saving graphics in some output formats will fail when using Octave"
-    AC_MSG_WARN([$warn_ghostscript])
+    GHOSTSCRIPT='$(top_srcdir)/build-aux/missing gs'
+    warn_ghostscript="
+
+I didn't find ghostscript, so reconstructing figures for the manual
+will fail, and saving graphics in some output formats will fail when
+using Octave
+"
+
+    OCTAVE_CONFIGURE_WARNING([warn_ghostscript])
   fi
   AC_SUBST(GHOSTSCRIPT)
 ])
@@ -587,9 +694,13 @@
 AC_DEFUN([OCTAVE_PROG_TEXI2DVI], [
   AC_CHECK_PROG(TEXI2DVI, texi2dvi, texi2dvi, [])
   if test -z "$TEXI2DVI"; then
-    TEXI2DVI='$(top_srcdir)/missing texi2dvi'
-    warn_texi2dvi="I didn't find texi2dvi, but it's only a problem if you need to reconstruct the DVI version of the manual"
-    AC_MSG_WARN([$warn_texi2dvi])
+    TEXI2DVI='$(top_srcdir)/build-aux/missing texi2dvi'
+    warn_texi2dvi="
+
+I didn't find texi2dvi, but it's only a problem if you need to
+reconstruct the DVI version of the manual
+"
+    OCTAVE_CONFIGURE_WARNING([warn_texi2dvi])
   fi
   AC_SUBST(TEXI2DVI)
 ])
@@ -610,9 +721,13 @@
     missing=false;
   fi
   if $missing; then
-    TEXI2PDF='$(top_srcdir)/missing texi2pdf'
-    warn_texi2pdf="I didn't find texi2pdf, but it's only a problem if you need to reconstruct the PDF version of the manual"
-    AC_MSG_WARN([$warn_texi2pdf])
+    TEXI2PDF='$(top_srcdir)/build-aux/missing texi2pdf'
+    warn_texi2pdf="
+
+I didn't find texi2pdf, but it's only a problem if you need to
+reconstruct the PDF version of the manual
+"
+    OCTAVE_CONFIGURE_WARNING([warn_texi2pdf])
   fi
   AC_SUBST(TEXI2PDF)
 ])
@@ -1458,31 +1573,33 @@
    else
      AC_MSG_RESULT([no])
      if test "$FT2_CONFIG" = "no" ; then
-       AC_MSG_WARN([
+     warn_ft2_config = "
 
-  The freetype-config script installed by FreeType 2 could not be found.
-  If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in
-  your path, or set the FT2_CONFIG environment variable to the
-  full path to freetype-config.
-       ])
+The freetype-config script installed by FreeType 2 could not be found.
+If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in your
+path, or set the FT2_CONFIG environment variable to the full path to
+freetype-config.
+"
+       OCTAVE_CONFIGURE_WARNING([warn_ft2_config])
      else
        if test x$ft_config_is_lt = xyes ; then
-         AC_MSG_WARN([
+       warn_ft2_too_old="
 
-  Your installed version of the FreeType 2 library is too old.
-  If you have different versions of FreeType 2, make sure that
-  correct values for --with-ft-prefix or --with-ft-exec-prefix
-  are used, or set the FT2_CONFIG environment variable to the
-  full path to freetype-config.
-         ])
+Your installed version of the FreeType 2 library is too old. If you
+have different versions of FreeType 2, make sure that correct values
+for --with-ft-prefix or --with-ft-exec-prefix are used, or set the
+FT2_CONFIG environment variable to the full path to freetype-config.
+"
+         OCTAVE_CONFIGURE_WARNING([warn_ft2_too_old])
        else
-         AC_MSG_WARN([
+         warn_ft2_failed="
 
-  The FreeType test program failed to run.  If your system uses
-  shared libraries and they are installed outside the normal
-  system library path, make sure the variable LD_LIBRARY_PATH
-  (or whatever is appropiate for your system) is correctly set.
-         ])
+The FreeType test program failed to run. If your system uses shared
+libraries and they are installed outside the normal system library
+path, make sure the variable LD_LIBRARY_PATH (or whatever is
+appropiate for your system) is correctly set.
+"
+         OCTAVE_CONFIGURE_WARNING([warn_ft2_failed])
        fi
      fi
 
--- a/run-octave.in
+++ b/run-octave.in
@@ -45,6 +45,7 @@
 LOADPATH="$d1_path:$d2_path:$d3_path"
 IMAGEPATH="$top_srcdir/scripts/image"
 DOCFILE="$builddir/doc/interpreter/doc-cache"
+TEXIMACROSFILE="$top_srcdir/doc/interpreter/macros.texi"
 INFOFILE="$top_srcdir/doc/interpreter/octave.info"
 
 ## Checking for string equality below with prepended x's in order to
@@ -70,4 +71,4 @@
   exec $builddir/libtool --mode=execute $driver \
     "$builddir/src/octave" --no-init-path --path="$LOADPATH" \
     --image-path="$IMAGEPATH" --doc-cache-file="$DOCFILE" \
-    --info-file="$INFOFILE" "$@"
+    --texi-macros-file="$TEXIMACROSFILE" --info-file="$INFOFILE" "$@"
--- a/scripts/@ftp/ascii.m
+++ b/scripts/@ftp/ascii.m
@@ -18,7 +18,11 @@
 
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} ascii (@var{f})
-## Put the FTP connection @var{f} into ascii mode.
+## Set the FTP connection @var{f} to use ASCII mode for transfers.
+## ASCII mode is only appropriate for text files as it will convert
+## the remote host's newline representation to the local host's newline
+## representation.
+##
 ## @var{f} is an FTP object returned by the @code{ftp} function.
 ## @end deftypefn
 
--- a/scripts/@ftp/binary.m
+++ b/scripts/@ftp/binary.m
@@ -18,7 +18,10 @@
 
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} binary (@var{f})
-## Put the FTP connection @var{f} into binary mode.
+## Set the FTP connection @var{f} to use binary mode for transfers.
+## In binary mode there is no conversion of newlines from the remote
+## representation to the local representation.
+##
 ## @var{f} is an FTP object returned by the @code{ftp} function.
 ## @end deftypefn
 
--- a/scripts/@ftp/cd.m
+++ b/scripts/@ftp/cd.m
@@ -19,6 +19,7 @@
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} cd (@var{f}, @var{path})
 ## Set the remote directory to @var{path} on the FTP connection @var{f}.
+##
 ## @var{f} is an FTP object returned by the @code{ftp} function.
 ## @end deftypefn
 
--- a/scripts/@ftp/close.m
+++ b/scripts/@ftp/close.m
@@ -18,7 +18,8 @@
 
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} close (@var{f})
-## Close the FTP connection represented by the given FTP object @var{f}.
+## Close the FTP connection represented by the FTP object @var{f}.
+##
 ## @var{f} is an FTP object returned by the @code{ftp} function.
 ## @end deftypefn
 
--- a/scripts/@ftp/delete.m
+++ b/scripts/@ftp/delete.m
@@ -18,7 +18,8 @@
 
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} delete (@var{f}, @var{file})
-## Delete the remote file @var{file}, over the FTP connection @var{f}.
+## Delete the remote file @var{file} over the FTP connection @var{f}.
+##
 ## @var{f} is an FTP object returned by the @code{ftp} function.
 ## @end deftypefn
 
--- a/scripts/@ftp/dir.m
+++ b/scripts/@ftp/dir.m
@@ -19,7 +19,9 @@
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {@var{lst} =} dir (@var{f})
 ## List the current directory in verbose form for the FTP connection
-## @var{f}.  @var{f} is an FTP object returned by the @code{ftp} function.
+## @var{f}.
+##
+## @var{f} is an FTP object returned by the @code{ftp} function.
 ## @end deftypefn
 
 function lst = dir (f)
--- a/scripts/@ftp/ftp.m
+++ b/scripts/@ftp/ftp.m
@@ -23,23 +23,38 @@
 ## If @var{username} and @var{password} are not specified, user "anonymous"
 ## with no password is used.  The returned FTP object @var{f} represents the
 ## established FTP connection.
+##
+## The list of actions for an FTP object are shown below.  All functions
+## require an FTP object as the first argument.
+##
+## @multitable @columnfractions 0.15 0.8
+## @headitem Method @tab Description
+## @item ascii @tab Set transfer type to ascii
+## @item binary @tab Set transfer type to binary
+## @item cd @tab Change remote working directory 
+## @item close @tab Close FTP connection
+## @item delete @tab Delete remote file 
+## @item dir @tab List remote directory contents 
+## @item mget @tab Download remote files
+## @item mkdir @tab Create remote directory
+## @item mput @tab Upload local files
+## @item rename @tab Rename remote file or directory
+## @item rmdir @tab Remove remote directory
+## @end multitable
+## 
 ## @end deftypefn
 
-function obj = ftp (host, username = "anonymous", password = "")
-  if (nargin == 0)
-    p.host = "";
-    p.username = username;
-    p.password = password;
-    p.curlhandle = tmpnam ("ftp-");
-    obj = class (p, "ftp");
-  elseif (nargin == 1 && strcmp (class (host), "ftp"))
-    obj = host;
+function obj = ftp (host = "", username = "anonymous", password = "")
+  if (nargin == 1 && isa (host, "ftp"))
+    obj = host;   # Copy constructor
   else
     p.host = host;
     p.username = username;
     p.password = password;
     p.curlhandle = tmpnam ("ftp-");
-    __ftp__ (p.curlhandle, host, username, password);
+    if (nargin > 0)
+      __ftp__ (p.curlhandle, host, username, password);
+    endif
     obj = class (p, "ftp");
   endif
 endfunction
--- a/scripts/@ftp/loadobj.m
+++ b/scripts/@ftp/loadobj.m
@@ -30,7 +30,7 @@
     b = rmfield (b, "dir");
   elseif (isfield (b, "remotePwd"))
     ## FIXME: Can we read matlab java stringBuffer objects?
-    warning ("can not change remote directory in loqded FTP object");
+    warning ("can not change remote directory in loaded FTP object");
     b = rmfield (b, "remotePwd");
   endif
 endfunction
--- a/scripts/@ftp/mget.m
+++ b/scripts/@ftp/mget.m
@@ -19,7 +19,7 @@
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {} mget (@var{f}, @var{file})
 ## @deftypefnx {Function File} {} mget (@var{f}, @var{dir})
-## @deftypefnx {Function File} {} mget (@dots{}, @var{target})
+## @deftypefnx {Function File} {} mget (@var{f}, @var{remote_name}, @var{target})
 ## Download a remote file @var{file} or directory @var{dir} to the local
 ## directory on the FTP connection @var{f}.  @var{f} is an FTP object
 ## returned by the @code{ftp} function.
@@ -28,8 +28,8 @@
 ## files or directories on the remote server that match will be downloaded.
 ##
 ## If a third argument @var{target} is given, then a single file or
-## directory will be downloaded with the name @var{target} to the local
-## directory.
+## directory will be downloaded to the local directory and the local name
+## will be changed to @var{target}.
 ## @end deftypefn
 
 function mget (f, file)
--- a/scripts/@ftp/mkdir.m
+++ b/scripts/@ftp/mkdir.m
@@ -19,6 +19,7 @@
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} mkdir (@var{f}, @var{path})
 ## Create the remote directory @var{path}, over the FTP connection @var{f}.
+##
 ## @var{f} is an FTP object returned by the @code{ftp} function.
 ## @end deftypefn
 
--- a/scripts/@ftp/mput.m
+++ b/scripts/@ftp/mput.m
@@ -22,7 +22,7 @@
 ## the FTP connection @var{f}.  @var{f} is an FTP object returned by the
 ## ftp function.
 ##
-## The argument @var{file} is passed by the @dfn{glob} function and any
+## The argument @var{file} is passed through the @code{glob} function and any
 ## files that match the wildcards in @var{file} will be uploaded.
 ## @end deftypefn
 
--- a/scripts/@ftp/rename.m
+++ b/scripts/@ftp/rename.m
@@ -19,8 +19,9 @@
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} rename (@var{f}, @var{oldname}, @var{newname})
 ## Rename or move the remote file or directory @var{oldname} to @var{newname},
-##  over the FTP connection @var{f}.  @var{f} is an FTP object returned by the
-## ftp function.
+## over the FTP connection @var{f}.
+##
+## @var{f} is an FTP object returned by the ftp function.
 ## @end deftypefn
 
 function rename (f, oldname, newname)
--- a/scripts/@ftp/rmdir.m
+++ b/scripts/@ftp/rmdir.m
@@ -19,6 +19,7 @@
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} rmdir (@var{f}, @var{path})
 ## Remove the remote directory @var{path}, over the FTP connection @var{f}.
+##
 ## @var{f} is an FTP object returned by the @code{ftp} function.
 ## @end deftypefn
 
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -74,7 +74,11 @@
 
 FCN_FILES_IN = $(GEN_FCN_FILES:.m=.in)
 
+if AMCOND_BUILD_DOCS
 all-local: $(GEN_FCN_FILES) $(PKG_ADD_FILES) .DOCSTRINGS
+else
+all-local: $(GEN_FCN_FILES) $(PKG_ADD_FILES)
+endif
 
 octave_dirstamp = $(am__leading_dot)dirstamp
 
@@ -320,22 +324,20 @@
 	$(MKDIR_P) time
 	: > time/$(octave_dirstamp)
 
-## Program compiled only to help build documentation.  No installation needed.
-noinst_PROGRAMS = gethelp
+if AMCOND_BUILD_DOCS
 
-gethelp_SOURCES = gethelp.cc
-
-.DOCSTRINGS: $(FCN_FILES) $(GEN_FCN_FILES) mkdoc $(gethelp_SOURCES) Makefile
-	@$(MAKE) $(AM_MAKEFLAGS) gethelp$(BUILD_EXEEXT)
+.DOCSTRINGS: $(FCN_FILES) $(GEN_FCN_FILES) mkdoc.pl Makefile
 	if [ "x$(srcdir)" != "x." ] && [ -f $(srcdir)/DOCSTRINGS ] && [ ! -f DOCSTRINGS ]; then \
 		cp $(srcdir)/DOCSTRINGS DOCSTRINGS; \
 		touch -r $(srcdir)/DOCSTRINGS DOCSTRINGS; \
 	fi
 	@echo "creating .DOCSTRINGS from .m script files"
-	@$(srcdir)/mkdoc "$(srcdir)" $(FCN_FILES) -- $(GEN_FCN_FILES) > $@
+	@$(PERL) $(srcdir)/mkdoc.pl "$(srcdir)" $(FCN_FILES) -- $(GEN_FCN_FILES) > $@
 	$(top_srcdir)/build-aux/move-if-change $@ DOCSTRINGS
 	touch $@
 
+endif
+
 $(GEN_FCN_FILES) : %.m : %.in Makefile
 	@$(do_subst_config_vals)
 
@@ -421,7 +423,7 @@
   $(FCN_FILES_IN) \
   $(GEN_FCN_FILES) \
   DOCSTRINGS \
-  mkdoc \
+  mkdoc.pl \
   mk-pkg-add
 
 DISTCLEANFILES = \
--- a/scripts/audio/lin2mu.m
+++ b/scripts/audio/lin2mu.m
@@ -62,7 +62,7 @@
   endif
 
   ## Determine sign of x, set sign(0) = 1.
-  sig = sign(x) + (x == 0);
+  sig = sign (x) + (x == 0);
 
   ## Take absolute value of x, but force it to be smaller than 32636;
   ## add bias.
--- a/scripts/audio/loadaudio.m
+++ b/scripts/audio/loadaudio.m
@@ -63,7 +63,7 @@
       [X, c] = fread (num, inf, "short");
     endif
   elseif (strcmp (ext, "mu") || strcmp (ext, "au")
-          || strcmp (ext, "snd") || strcmp(ext, "ul"))
+          || strcmp (ext, "snd") || strcmp (ext, "ul"))
     [Y, c] = fread (num, inf, "uchar");
     ## remove file header
     m = find (Y(1:64) == 0, 1, "last");
--- a/scripts/audio/mu2lin.m
+++ b/scripts/audio/mu2lin.m
@@ -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/audio/wavread.m
+++ b/scripts/audio/wavread.m
@@ -87,7 +87,7 @@
     ## Find format chunk inside the RIFF chunk.
     fseek (fid, riff_pos, "bof");
     fmt_size = find_chunk (fid, "fmt ", riff_size);
-    fmt_pos = ftell(fid);
+    fmt_pos = ftell (fid);
     if (fmt_size == -1)
       error ("wavread: file contains no format chunk");
     endif
@@ -196,7 +196,7 @@
   endif
 
   if (bits_per_sample == 24)
-    yi = reshape (yi, 3, rows(yi)/3)';
+    yi = reshape (yi, 3, rows (yi) / 3)';
     yi(yi(:,3) >= 128, 3) -= 256;
     yi = yi * [1; 256; 65536];
   endif
@@ -244,6 +244,7 @@
   endif
 endfunction
 
-## Mark file as being tested.  Tests for wavread/wavwrite pair are in
-## wavwrite.m
-%!assert(1)
+
+## Mark file as tested.  Tests for wavread/wavwrite pair are in wavwrite.m.
+%!assert (1)
+
deleted file mode 100644
--- a/scripts/deprecated/autocor.m
+++ /dev/null
@@ -1,59 +0,0 @@
-## Copyright (C) 1995-2012 Friedrich Leisch
-##
-## 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} {} autocor (@var{x}, @var{h})
-## Return the autocorrelations from lag 0 to @var{h} of vector @var{x}.
-## If @var{h} is omitted, all autocorrelations are computed.
-## If @var{x} is a matrix, the autocorrelations of each column are
-## computed.
-## The particular algorithm used is from the field of statistics and
-## differs from the definition used in signal processing.
-## @end deftypefn
-
-## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at>
-## Description: Compute autocorrelations
-
-## Deprecated in version 3.4
-
-function retval = autocor (X, h)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "autocor is obsolete and will be removed from a future version of Octave; See the Octave-Forge signal package and the function xcor for a replacement");
-  endif
-
-
-  if (nargin == 1)
-    retval = autocov (X);
-  elseif (nargin == 2)
-    retval = autocov (X, h);
-  else
-    print_usage ();
-  endif
-
-  if (min (retval (1,:)) != 0)
-    retval = retval ./ (ones (rows (retval), 1) * retval(1,:));
-  endif
-
-endfunction
-
-
-
deleted file mode 100644
--- a/scripts/deprecated/autocov.m
+++ /dev/null
@@ -1,62 +0,0 @@
-## Copyright (C) 1995-2012 Friedrich Leisch
-##
-## 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} {} autocov (@var{x}, @var{h})
-## Return the autocovariances from lag 0 to @var{h} of vector @var{x}.
-## If @var{h} is omitted, all autocovariances are computed.
-## If @var{x} is a matrix, the autocovariances of each column are
-## computed.
-## The particular algorithm used is from the field of statistics and
-## differs from the definition used in signal processing.
-## @end deftypefn
-
-## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at>
-## Description: Compute autocovariances
-
-## Deprecated in version 3.4
-
-function retval = autocov (X, h)
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "autocov is obsolete and will be removed from a future version of Octave; See the Octave-Forge signal package and the function xcov for a replacement");
-  endif
-
-  [n, c] = size (X);
-
-  if (isvector (X))
-    n = length (X);
-    c = 1;
-    X = reshape (X, n, 1);
-  endif
-
-  X = center (X);
-
-  if (nargin == 1)
-    h = n - 1;
-  endif
-
-  retval = zeros (h + 1, c);
-
-  for i = 0 : h
-    retval(i+1, :) = diag (X(i+1:n, :).' * conj (X(1:n-i, :))).' / n;
-  endfor
-
-endfunction
deleted file mode 100644
--- a/scripts/deprecated/betai.m
+++ /dev/null
@@ -1,47 +0,0 @@
-## Copyright (C) 1994-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/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {} betai (@var{a}, @var{b}, @var{x})
-## This function is provided for compatibility with older versions of
-## Octave.  New programs should use betainc instead.
-##
-## @code{betai (@var{a}, @var{b}, @var{x})} is the same as
-## @code{betainc (@var{x}, @var{a}, @var{b})}.
-## @end deftypefn
-
-## Author: jwe
-## Created: 30 Jan 1998
-
-## Deprecated in version 3.4
-
-function retval = betai (a, b, x)
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "betai is obsolete and will be removed from a future version of Octave; please use betainc instead");
-  endif
-
-  if (nargin == 3)
-    retval = betainc (x, a, b);
-  else
-    print_usage ();
-  endif
-
-endfunction
deleted file mode 100644
--- a/scripts/deprecated/cellidx.m
+++ /dev/null
@@ -1,108 +0,0 @@
-## Copyright (C) 2000-2012 Auburn University.  All rights reserved.
-##
-## This file is part of Octave.
-##
-## Octave program 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 program 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{idxvec}, @var{errmsg}] =} cellidx (@var{listvar}, @var{strlist})
-## Return indices of string entries in @var{listvar} that match strings
-## in @var{strlist}.
-##
-## Both @var{listvar} and @var{strlist} may be passed as strings or
-## string matrices.  If they are passed as string matrices, each entry
-## is processed by @code{deblank} prior to searching for the entries.
-##
-## The first output is the vector of indices in @var{listvar}.
-##
-## If @var{strlist} contains a string not in @var{listvar}, then
-## an error message is returned in @var{errmsg}.  If only one output
-## argument is requested, then @var{cellidx} prints @var{errmsg} to the
-## screen and exits with an error.
-## @end deftypefn
-
-## deprecated in version 3.4
-
-function [idxvec,errmsg]  = cellidx (listvar, strlist)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "cellidx is obsolete and will be removed from a future version of Octave; use ismember instead");
-  endif
-
-  if (nargin != 2)
-    print_usage ();
-  endif
-
-  if (ischar (strlist))
-    tmp = strlist;
-    strlist = {};
-    for kk = 1:rows(tmp)
-      strlist{kk} = deblank (tmp(kk,:));
-    endfor
-  endif
-
-  if (ischar (listvar))
-    tmp = listvar;
-    listvar = {};
-    for kk = 1:rows(tmp)
-      listvar{kk} = deblank (tmp(kk,:));
-    endfor
-  endif
-
-  ## initialize size of idxvec (for premature return)
-  idxvec = zeros (length(strlist), 1);
-
-  errmsg = "";
-  if (! iscellstr (listvar))
-    errmsg = "listvar must be a list of strings";
-  elseif (! iscellstr (strlist))
-    errmsg = "strlist must be a list of strings";
-  endif
-
-  if (length (errmsg))
-    if (nargout < 2)
-      error (errmsg);
-    else
-      return;
-    endif
-  endif
-
-  nsigs = length(listvar);
-  for idx = 1:length(strlist)
-    signame = strlist{idx};
-    for jdx = 1:nsigs
-      if (strcmp (signame, listvar{jdx}))
-        if (idxvec(idx) != 0)
-          warning ("Duplicate signal name %s (%d,%d)\n",
-                   listvar{jdx}, jdx, idxvec(idx));
-        else
-          idxvec(idx) = jdx;
-        endif
-      endif
-    endfor
-    if (idxvec(idx) == 0)
-      errmsg = sprintf ("Did not find %s", signame);
-      if (nargout == 1)
-        error (errmsg);
-      else
-        break;
-      endif
-    endif
-  endfor
-
-endfunction
deleted file mode 100644
--- a/scripts/deprecated/clg.m
+++ /dev/null
@@ -1,40 +0,0 @@
-## 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/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {} clg ()
-## This function has been deprecated.  Use clf instead.
-## @end deftypefn
-
-## Author: jwe
-
-## Deprecated in version 3.0
-## Matlab still has this function, so don't remove just yet.
-
-function clg ()
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "clg is obsolete and will be removed from a future version of Octave, please use clf instead");
-  endif
-
-  clf ();
-
-endfunction
deleted file mode 100644
--- a/scripts/deprecated/cquad.m
+++ /dev/null
@@ -1,39 +0,0 @@
-## Copyright (C) 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/>.
-
-## -*- texinfo -*-
-## @deftypefn  {Function File} {[@var{int}, @var{err}, @var{nr_points}] =} cquad (@var{f}, @var{a}, @var{b}, @var{tol})
-## @deftypefnx {Function File} {[@var{int}, @var{err}, @var{nr_points}] =} cquad (@var{f}, @var{a}, @var{b}, @var{tol}, @var{sing})
-## This function is an alias for compatibility with older versions of
-## Octave.  New programs should use @code{quadcc} instead.
-## @seealso{quadcc}
-## @end deftypefn
-
-## Deprecated in version 3.4
-
-function retval = cquad (varargin)
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "cquad has been renamed to quadcc and this alias will be removed from a future version of Octave; please use quadcc instead");
-  endif
-
-  retval = quadcc (varargin{:});
-
-endfunction
--- a/scripts/deprecated/cut.m
+++ b/scripts/deprecated/cut.m
@@ -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)));
deleted file mode 100644
--- a/scripts/deprecated/dispatch.m
+++ /dev/null
@@ -1,103 +0,0 @@
-## Copyright (C) 2010-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/>.
-
-## -*- texinfo -*-
-## @deftypefn {Loadable Function} {} dispatch (@var{f}, @var{r}, @var{type})
-##
-## Replace the function @var{f} with a dispatch so that function @var{r}
-## is called when @var{f} is called with the first argument of the named
-## @var{type}.  If the type is @var{any} then call @var{r} if no other type
-## matches.  The original function @var{f} is accessible using
-## @code{builtin (@var{f}, @dots{})}.
-##
-## If @var{r} is omitted, clear dispatch function associated with @var{type}.
-##
-## If both @var{r} and @var{type} are omitted, list dispatch functions
-## for @var{f}.
-## @seealso{builtin}
-## @end deftypefn
-
-## Deprecated in version 3.4
-
-function varargout = dispatch (varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "dispatch is obsolete and will be removed from a future version of Octave; please use classes instead");
-  endif
-
-  varargout = cell (nargout, 1);
-  [ varargout{:} ] = __dispatch__ (varargin{:});
-
-endfunction
-
-
-%!test # builtin function replacement
-%! dispatch('sin','length','string')
-%! assert(sin("abc"),3)
-%! assert(sin(0),0,10*eps);
-
-%!test # 'any' function
-%! dispatch('sin','exp','any')
-%! assert(sin(0),1,eps);
-%! assert(sin("abc"),3);
-
-%!test # 'builtin' function
-%! assert(builtin('sin',0),0,eps);
-%! builtin('eval','x=1;');
-%! assert(x,1);
-
-%!test # clear function mapping
-%! dispatch('sin','string')
-%! dispatch('sin','any')
-%! assert(sin(0),0,10*eps);
-
-%!test # oct-file replacement
-%! dispatch('fft','length','string')
-%! assert(fft([1,1]),[2,0]);
-%! assert(fft("abc"),3)
-%! dispatch('fft','string');
-
-%!test # m-file replacement
-%! dispatch('hamming','length','string')
-%! assert(hamming(1),1)
-%! assert(hamming("abc"),3)
-%! dispatch('hamming','string')
-
-%!test # override preloaded builtin
-%! evalin('base','cos(1);');
-%! dispatch('cos','length','string')
-%! evalin('base','assert(cos("abc"),3)');
-%! evalin('base','assert(cos(0),1,eps)');
-%! dispatch('cos','string')
-
-%!test # override pre-loaded oct-file
-%! evalin('base','qr(1);');
-%! dispatch('qr','length','string')
-%! evalin('base','assert(qr("abc"),3)');
-%! evalin('base','assert(qr(1),1)');
-%! dispatch('qr','string');
-
-%!test # override pre-loaded m-file
-%! evalin('base','hanning(1);');
-%! dispatch('hanning','length','string')
-%! evalin('base','assert(hanning("abc"),3)');
-%! evalin('base','assert(hanning(1),1)');
-%! dispatch('hanning','string');
deleted file mode 100644
--- a/scripts/deprecated/fstat.m
+++ /dev/null
@@ -1,35 +0,0 @@
-## Copyright (C) 2010-2012 VZLU Prague
-##
-## 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{info}, @var{err}, @var{msg}] =} fstat (fid)
-## This function has been deprecated.  Use stat instead.
-## @end deftypefn
-
-## Deprecated in version 3.4
-
-function [info, err, msg] = fstat (fid)
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "fstat is obsolete and will be removed from a future version of Octave, please use stat instead");
-  endif
-
-  [info, err, msg] = stat (fid);
-endfunction
deleted file mode 100644
--- a/scripts/deprecated/gammai.m
+++ /dev/null
@@ -1,47 +0,0 @@
-## Copyright (C) 1994-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/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {} gammai (@var{a}, @var{x})
-## This function is provided for compatibility with older versions of
-## Octave.  New programs should use @code{gammainc} instead.
-##
-## @code{gammai (@var{a}, @var{x})} is the same as
-## @code{gammainc (@var{x}, @var{a})}.
-## @end deftypefn
-
-## Author: jwe
-## Created: 30 Jan 1998
-
-## Deprecated in version 3.4
-
-function retval = gammai (a, x)
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "gammai is obsolete and will be removed from a future version of Octave; please use gammainc instead");
-  endif
-
-  if (nargin == 2)
-    retval = gammainc (x, a);
-  else
-    print_usage ();
-  endif
-
-endfunction
deleted file mode 100644
--- a/scripts/deprecated/glpkmex.m
+++ /dev/null
@@ -1,117 +0,0 @@
-## Copyright (C) 2005-2012 Nicolo' Giorgetti
-##
-## 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{xopt}, @var{fmin}, @var{status}, @var{extra}] =} glpkmex (@var{sense}, @var{c}, @var{A}, @var{b}, @var{ctype}, @var{lb}, @var{ub}, @var{vartype}, @var{param}, @var{lpsolver}, @var{save_pb})
-## This function is provided for compatibility with the old @sc{matlab}
-## interface to the GNU @sc{glpk} library.  For Octave code, you should use
-## the @code{glpk} function instead.
-## @seealso{glpk}
-## @end deftypefn
-
-function [xopt, fopt, status, extra] = glpkmex (varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "glpkmex is obsolete and will be removed from a future version of Octave; please use glpk instead");
-  endif
-
-  ## If there is no input output the version and syntax
-  if (nargin < 4 || nargin > 11)
-    print_usage ();
-    return;
-  endif
-
-  ## reorder args:
-  ##
-  ##     glpkmex    glpk
-  ##
-  ##  1   sense      c
-  ##  2   c          a
-  ##  3   a          b
-  ##  4   b          lb
-  ##  5   ctype      ub
-  ##  6   lb         ctype
-  ##  7   ub         vartype
-  ##  8   vartype    sense
-  ##  9   param      param
-  ## 10   lpsolver
-  ## 11   savepb
-
-  sense = varargin{1};
-  c = varargin{2};
-  a = varargin{3};
-  b = varargin{4};
-
-  nx = length  (c);
-
-  if (nargin > 4)
-    ctype = varargin{5};
-  else
-    ctype = repmat ("U", nx, 1);
-  endif
-
-  if (nargin > 5)
-    lb = varargin{6};
-  else
-    lb = repmat (-Inf, nx, 1);
-  endif
-
-  if (nargin > 6)
-    ub = varargin{7};
-  else
-    ub = repmat (Inf, nx, 1);
-  endif
-
-  if (nargin > 7)
-    vartype = varargin{8};
-  else
-    vartype = repmat ("C", nx, 1);
-  endif
-
-  if (nargin > 8)
-    param = varargin{9};
-  else
-    param = struct ();
-  endif
-
-  if (nargin > 9 && ! isfield (param, "lpsolver"))
-    param.lpsolver = varargin{10};
-  endif
-
-  if (nargin > 10 && ! isfield (param, "save"))
-    param.save = varargin{11};
-  endif
-
-  if (nargout == 0)
-    glpk (c, a, b, lb, ub, ctype, vartype, sense, param);
-  elseif (nargout == 1)
-    xopt = glpk (c, a, b, lb, ub, ctype, vartype, sense, param);
-  elseif (nargout == 2)
-    [xopt, fopt] = glpk (c, a, b, lb, ub, ctype, vartype, sense, param);
-  elseif (nargout == 3)
-    [xopt, fopt, status] = ...
-      glpk (c, a, b, lb, ub, ctype, vartype, sense, param);
-  else
-    [xopt, fopt, status, extra] = ...
-      glpk (c, a, b, lb, ub, ctype, vartype, sense, param);
-  endif
-
-endfunction
deleted file mode 100644
--- a/scripts/deprecated/intwarning.m
+++ /dev/null
@@ -1,133 +0,0 @@
-## Copyright (C) 2008-2012 David Bateman
-##
-## 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} {} intwarning (@var{action})
-## @deftypefnx {Function File} {} intwarning (@var{s})
-## @deftypefnx {Function File} {@var{s} =} intwarning (@dots{})
-## Control the state of the warning for integer conversions and math
-## operations.
-##
-## @table @asis
-## @item "query"
-## With an output argument, return the current state of the integer
-## conversion and math warnings.  With no output arguments, print the
-## current state.
-## @c Set example in small font to prevent overfull line
-##
-## @smallexample
-## @group
-## intwarning ("query")
-## The state of warning "Octave:int-convert-nan" is "off"
-## The state of warning "Octave:int-convert-non-int-val" is "off"
-## The state of warning "Octave:int-convert-overflow" is "off"
-## The state of warning "Octave:int-math-overflow" is "off"
-## @end group
-## @end smallexample
-##
-## @item "on"
-## @itemx "off"
-## Turn integer conversion and math warnings on (or off).  If there is
-## no output argument, then nothing is printed.  Otherwise the original
-## state of the state of the integer conversion and math warnings is
-## returned in a structure array.
-## @end table
-##
-## The original state of the integer warnings can be restored by passing
-## the structure array returned by @code{intwarning} to a later call to
-## @code{intwarning}.  For example:
-##
-## @example
-## @group
-## s = intwarning ("off");
-## @dots{}
-## intwarning (s);
-## @end group
-## @end example
-## @seealso{warning}
-## @end deftypefn
-
-## Deprecated in v. 3.4
-
-function y = intwarning (x)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "intwarning is obsolete and will be removed from a future version of Octave; integer math no longer produces warnings -- supply your own checks if you need those");
-  endif
-
-  return;
-
-  if (nargin != 1)
-    print_usage ();
-  else
-    if (nargout > 0)
-      y = warning("query", "Octave:int-convert-nan");
-      y = [y; warning("query", "Octave:int-convert-non-int-val")];
-      y = [y; warning("query", "Octave:int-convert-overflow")];
-      y = [y; warning("query", "Octave:int-math-overflow")];
-    endif
-    if (ischar (x))
-      if (strcmpi (x, "query"))
-        if (nargout == 0)
-          __print_int_warn_state__ ("Octave:int-convert-nan");
-          __print_int_warn_state__ ("Octave:int-convert-non-int-val");
-          __print_int_warn_state__ ("Octave:int-convert-overflow");
-          __print_int_warn_state__ ("Octave:int-math-overflow");
-          printf("\n");
-        endif
-      elseif (strcmpi (x, "on"))
-        warning ("on", "Octave:int-convert-nan");
-        warning ("on", "Octave:int-convert-non-int-val");
-        warning ("on", "Octave:int-convert-overflow");
-        warning ("on", "Octave:int-math-overflow");
-      elseif (strcmpi (x, "off"))
-        warning ("off", "Octave:int-convert-nan");
-        warning ("off", "Octave:int-convert-non-int-val");
-        warning ("off", "Octave:int-convert-overflow");
-        warning ("off", "Octave:int-math-overflow");
-      else
-        error ("intwarning: unrecognized argument");
-      endif
-    elseif (isstruct(x))
-      for fld = fieldnames (x)
-        if (strcmp ("Octave:int-convert-nan")
-            || strcmp ("Octave:int-convert-non-int-val")
-            || strcmp ("Octave:int-convert-overflow")
-            || strcmp ("Octave:int-cmath-overflow"))
-          s = getfield (x, fld);
-          if (! ischar (s) || !(strcmpi("s","on") || strcmpi("s","off")))
-            error ("intwarning: unexpected warning state");
-          endif
-          warning (s, fld);
-        else
-          error ("intwarning: unrecognized integer warning %s", fld);
-        endif
-      endfor
-    else
-      error ("intwarning: unexpected input");
-    endif
-  endif
-endfunction
-
-function __print_int_warn_state__ (s)
-  fprintf ("The state of warning \"%s\" is \"%s\"\n",
-           s, warning ("query", s).state);
-endfunction
deleted file mode 100644
--- a/scripts/deprecated/is_duplicate_entry.m
+++ /dev/null
@@ -1,53 +0,0 @@
-## Copyright (C) 1996-2012 A. S. Hodel
-##
-## 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} {} is_duplicate_entry (@var{x})
-## Return non-zero if any entries in @var{x} are duplicates of one
-## another.
-## @seealso{unique}
-## @end deftypefn
-
-## Author: A. S. Hodel <scotte@eng.auburn.edu>
-
-function retval = is_duplicate_entry (x)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "is_duplicate_entry is obsolete and will be removed from a future version of Octave; see the function unique for equivalent functionality");
-  endif
-
-
-  if (nargin == 1)
-    if (ismatrix (x))
-      lx = numel (x);
-      lx1 = lx-1;
-      x = sort (reshape (x, 1, lx));
-      dx = x(1:lx1) - x(2:lx);
-      retval = sum (dx == 0);
-    else
-      error ("is_duplicate_entry: expecting matrix argument");
-    endif
-  else
-    print_usage ();
-  endif
-
-endfunction
-
deleted file mode 100644
--- a/scripts/deprecated/is_global.m
+++ /dev/null
@@ -1,37 +0,0 @@
-## Copyright (C) 1994-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/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {} is_global (@var{name})
-## This function is provided for compatibility with older versions of
-## Octave.  New programs should use isglobal instead.
-## @end deftypefn
-
-## Deprecated in version 3.4
-
-function retval = is_global (name)
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "is_global is obsolete and will be removed from a future version of Octave; please use isglobal instead");
-  endif
-
-  retval = isglobal(name);
-
-endfunction
deleted file mode 100644
--- a/scripts/deprecated/krylovb.m
+++ /dev/null
@@ -1,46 +0,0 @@
-## Copyright (C) 1993-2012 A. Scottedward Hodel
-##
-## 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{u}, @var{ucols}] =} krylovb (@var{A}, @var{V}, @var{k}, @var{eps1}, @var{pflg})
-## See @code{krylov}.
-## @end deftypefn
-
-## Deprecated in version 3.4
-
-function [Uret, Ucols] = krylovb (A, V, k, eps1, pflg)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "krylovb is obsolete and will be removed from a future version of Octave; please use [Uret, ~, Ucols] = krylov (...) instead");
-  endif
-
-  switch (nargin)
-    case (3)
-      [Uret, H, Ucols] = krylov (A, V, k);
-    case (4)
-      [Uret, H, Ucols] = krylov (A, V, k, eps1);
-    case (5)
-      [Uret, H, Ucols] = krylov (A, V, k, eps1, pflg);
-    otherwise
-      print_usage ();
-  endswitch
-
-endfunction
--- a/scripts/deprecated/module.mk
+++ b/scripts/deprecated/module.mk
@@ -2,39 +2,16 @@
 
 deprecated_FCN_FILES = \
   deprecated/__error_text__.m \
-  deprecated/autocor.m \
-  deprecated/autocov.m \
-  deprecated/betai.m \
-  deprecated/cellidx.m \
-  deprecated/clg.m \
   deprecated/cor.m \
   deprecated/corrcoef.m \
-  deprecated/cquad.m \
   deprecated/cut.m \
-  deprecated/dispatch.m \
   deprecated/error_text.m \
-  deprecated/fstat.m \
-  deprecated/gammai.m \
-  deprecated/glpkmex.m \
-  deprecated/intwarning.m \
-  deprecated/is_duplicate_entry.m \
-  deprecated/is_global.m \
   deprecated/isstr.m \
-  deprecated/krylovb.m \
-  deprecated/perror.m \
   deprecated/polyderiv.m \
-  deprecated/replot.m \
-  deprecated/saveimage.m \
   deprecated/setstr.m \
   deprecated/shell_cmd.m \
-  deprecated/strerror.m \
   deprecated/studentize.m \
-  deprecated/sylvester_matrix.m \
-  deprecated/values.m \
-  deprecated/weibcdf.m \
-  deprecated/weibinv.m \
-  deprecated/weibpdf.m \
-  deprecated/weibrnd.m
+  deprecated/sylvester_matrix.m
 
 FCN_FILES += $(deprecated_FCN_FILES)
 
deleted file mode 100644
--- a/scripts/deprecated/perror.m
+++ /dev/null
@@ -1,45 +0,0 @@
-## 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/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {} perror (@var{funcname}, @var{num})
-## Print the error message for function @var{funcname} corresponding to the
-## error number @var{num}.  This function is intended to be used to print
-## useful error messages for those functions that return numeric error
-## codes.
-## @seealso{strerror}
-## @end deftypefn
-
-## Author: jwe
-
-function perror (funcname, num)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "perror is obsolete and will be removed from a future version of Octave.");
-  endif
-
-  if (nargin != 2)
-    print_usage ();
-  else
-    printf (strerror (funcname, num));
-  endif
-
-endfunction
deleted file mode 100644
--- a/scripts/deprecated/replot.m
+++ /dev/null
@@ -1,43 +0,0 @@
-## 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/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {} replot ()
-## Refresh the plot window.
-## @end deftypefn
-
-## Author: jwe
-
-## Deprecated in version 3.4
-
-function replot ()
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "replot is obsolete and will be removed from a future version of Octave; please use refresh instead");
-  endif
-
-  if (nargin == 0)
-    drawnow ();
-  else
-    print_usage ();
-  endif
-
-endfunction
deleted file mode 100644
--- a/scripts/deprecated/saveimage.m
+++ /dev/null
@@ -1,314 +0,0 @@
-## Copyright (C) 1994-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/>.
-
-## -*- texinfo -*-
-## @deftypefn  {Function File} {} saveimage (@var{fname}, @var{img}, @var{fmt})
-## @deftypefnx {Function File} {} saveimage (@var{fname}, @var{img}, @var{fmt}, @var{map})
-## Save the matrix @var{img} to file @var{fname} in image format @var{fmt}.
-## Valid values for @var{fmt} are
-##
-## @table @asis
-## @item "img"
-## Octave's image format.  The current colormap is also saved in the file.
-##
-## @item "ppm"
-## Portable pixmap format.
-##
-## @item "ps"
-## PostScript format.
-## @end table
-##
-## If the fourth argument is supplied, the specified colormap will also be
-## saved along with the image.
-##
-## Note: if the colormap contains only two entries and these entries are
-## black and white, the bitmap ppm and PostScript formats are used.  If the
-## image is a gray scale image (the entries within each row of the colormap
-## are equal) the gray scale ppm and PostScript image formats are used,
-## otherwise the full color formats are used.
-## @seealso{imread, save, load, colormap}
-## @end deftypefn
-
-## The conversion to PostScript is based on pbmtolps.c, which was
-## written by
-##
-##   George Phillips <phillips@cs.ubc.ca>
-##   Department of Computer Science
-##   University of British Columbia
-##
-## and is part of the portable bitmap utilities,
-
-## Author: Tony Richardson <arichard@stark.cc.oh.us>
-## Created: July 1994
-## Adapted-By: jwe
-
-## Rewritten by jwe to avoid using octoppm and pbm routines so that
-## people who don't have the pbm stuff installed can still use this
-## function.
-##
-## The conversion to PostScript is based on pnmtops.c, which is part of
-## the portable bitmap utilties and bears this copyright notice:
-##
-## Copyright (C) 1989 by Jef Poskanzer.
-##
-## Permission to use, copy, modify, and distribute this software and its
-## documentation for any purpose and without fee is hereby granted, provided
-## that the above copyright notice appear in all copies and that both that
-## copyright notice and this permission notice appear in supporting
-## documentation.  This software is provided "as is" without express or
-## implied warranty.
-
-function saveimage (fname, img, fmt, map)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "saveimage is obsolete and will be removed from a future version of Octave; please use imwrite instead");
-  endif
-
-  if (nargin < 2 || nargin > 4)
-    print_usage ();
-  endif
-
-  if (nargin < 4)
-    if (size(img, 3) == 3)
-      [img, map] = rgb2ind(img);
-    else
-      map = colormap ();
-    endif
-  endif
-
-  [map_nr, map_nc] = size (map);
-
-  if (map_nc != 3)
-    error ("saveimage: MAP must be an N x 3 matrix");
-  endif
-
-  if (nargin < 3)
-    fmt = "img";
-  elseif (! ischar (fmt))
-    error ("saveimage: FMT specification must be a string");
-  elseif (! (strcmp (fmt, "img")
-             || strcmp (fmt, "ppm")
-             || strcmp (fmt, "ps")))
-    error ("saveimage: unsupported image format specification");
-  endif
-
-  if (! ismatrix (img))
-    warning ("IMG variable is not a matrix");
-  endif
-
-  if (! ischar (fname))
-    error ("saveimage: FNAME must be a string");
-  endif
-
-  ## If we just want Octave image format, save and return.
-
-  if (strcmp (fmt, "img"))
-    save ("-text", fname, "map", "img");
-    return;
-  endif
-
-  ## Convert to another format if requested.
-
-  grey = all (map(:,1) == map(:,2) && map(:,1) == map (:,3));
-
-  pbm = pgm = ppm = 0;
-
-  map_sz = map_nr * map_nc;
-
-  map = reshape (map, map_sz, 1);
-
-  map (map > 1) = 1;
-  map (map < 0) = 0;
-
-  map = round (255 * map);
-
-  bw = (map_nr == 2
-        && ((map(1,1) == 0 && map(2,1) == 255)
-            || (map(1,1) == 255 && map(2,1) == 0)));
-
-  img = round (img');
-  [img_nr, img_nc] = size (img);
-
-  img_sz = img_nr * img_nc;
-  img = reshape (img, img_sz, 1);
-
-  img (img > map_nr) = map_nr;
-  img (img <= 0) = 1;
-
-  if (strcmp (fmt, "ppm"))
-
-    ## Would be nice to make this consistent with the line used by the
-    ## load/save functions, but we need a good way to get username and
-    ## hostname information.
-
-    time_string = ctime (time ());
-    time_string = time_string (1:length (time_string)-1);
-    tagline = sprintf ("# Created by Octave %s, %s",
-                       OCTAVE_VERSION, time_string);
-
-    if (grey && bw)
-
-      if (map(1) != 0)
-        map = [0; 1];
-      else
-        map = [1; 0];
-      endif
-
-      n_long = rem (img_nc, 8);
-      tmp = zeros (ceil (img_nc/8), img_nr);
-
-      k = ceil (img_nr/8);
-      tmp = zeros (k, img_nc);
-
-      ## Append columns with zeros to original image so that
-      ## mod (cols, 8) = 0.
-
-      bwimg = postpad (reshape (map(img), img_nr, img_nc), k * 8, 0);
-
-      b = kron (pow2 (7:-1:0)', ones (1, img_nc));
-
-      for i = 1:k
-        tmp(i,:) = sum (bwimg(8*(i-1)+1:8*i,:) .* b);
-      endfor
-
-      fid = fopen (fname, "wb");
-      fprintf (fid, "P4\n%s\n%d %d\n", tagline, img_nr, img_nc);
-      fwrite (fid, tmp, "uchar");
-      fprintf (fid, "\n");
-      fclose (fid);
-
-    elseif (grey)
-
-      fid = fopen (fname, "wb");
-      fprintf (fid, "P5\n%s\n%d %d\n255\n", tagline, img_nr, img_nc);
-      fwrite (fid, map(img), "uchar");
-      fprintf (fid, "\n");
-      fclose (fid);
-
-    else
-
-      img_idx = ((1:3:3*img_sz)+2)';
-      map_idx = ((2*map_nr+1):map_sz)';
-
-      tmap = map(map_idx);
-      tmp(img_idx--) = tmap(img);
-
-      map_idx = map_idx - map_nr;
-      tmap = map(map_idx);
-      tmp(img_idx--) = tmap(img);
-
-      map_idx = map_idx - map_nr;
-      tmap = map(map_idx);
-      tmp(img_idx--) = tmap(img);
-
-      fid = fopen (fname, "wb");
-      fprintf (fid, "P6\n%s\n%d %d\n255\n", tagline, img_nr, img_nc);
-      fwrite (fid, tmp, "uchar");
-      fprintf (fid, "\n");
-      fclose (fid);
-
-    endif
-
-  elseif (strcmp (fmt, "ps") == 1)
-
-    if (! grey)
-      error ("saveimage: must have a greyscale colormap for conversion to PostScript");
-    endif
-
-    bps = 8;
-    dpi = 300;
-    pagewid = 612;
-    pagehgt = 762;
-    MARGIN = 0.95;
-    devpix = dpi / 72.0 + 0.5;
-    pixfac = 72.0 / dpi * devpix;
-
-    ## Compute padding to round cols * bps up to the nearest multiple of 8
-    ## (nr and nc are switched because we transposed the image above).
-
-    padright = (((img_nr * bps + 7) / 8) * 8 - img_nr * bps) / bps;
-
-    scols = img_nr * pixfac;
-    srows = img_nc * pixfac;
-    scale = 1;
-
-    if (scols > pagewid * MARGIN || srows > pagehgt * MARGIN)
-      if (scols > pagewid * MARGIN)
-        scale = scale * (pagewid / scols * MARGIN);
-        scols = scale * img_nr * pixfac;
-        srows = scale * img_nc * pixfac;
-      endif
-      if (srows > pagehgt * MARGIN)
-        scale = scale * (pagehgt / srows * MARGIN);
-        scols = scale * img_nr * pixfac;
-        srows = scale * img_nc * pixfac;
-      endif
-      warning ("image too large for page, rescaling to %g", scale);
-    endif
-
-    llx = (pagewid - scols) / 2;
-    lly = (pagehgt - srows) / 2;
-    urx = llx + fix (scols + 0.5);
-    ury = lly + fix (srows + 0.5);
-
-    fid = fopen (fname, "wb");
-
-    fprintf (fid, "%%!PS-Adobe-2.0 EPSF-2.0\n");
-    fprintf (fid, "%%%%Creator: Octave %s (saveimage.m)\n", OCTAVE_VERSION);
-    fprintf (fid, "%%%%Title: %s\n", fname);
-    fprintf (fid, "%%%%Pages: 1\n");
-    fprintf (fid, "%%%%BoundingBox: %d %d %d %d\n",
-             fix (llx), fix (lly), fix (urx), fix (ury));
-    fprintf (fid, "%%%%EndComments\n");
-    fprintf (fid, "/readstring {\n");
-    fprintf (fid, "  currentfile exch readhexstring pop\n");
-    fprintf (fid, "} bind def\n");
-    fprintf (fid, "/picstr %d string def\n",
-             fix ((img_nr + padright) * bps / 8));
-    fprintf (fid, "%%%%EndProlog\n");
-    fprintf (fid, "%%%%Page: 1 1\n");
-    fprintf (fid, "gsave\n");
-    fprintf (fid, "%g %g translate\n", llx, lly);
-    fprintf (fid, "%g %g scale\n", scols, srows);
-    fprintf (fid, "%d %d %d\n", img_nr, img_nc, bps);
-    fprintf (fid, "[ %d 0 0 -%d 0 %d ]\n", img_nr, img_nc, img_nc);
-    fprintf (fid, "{ picstr readstring }\n");
-    fprintf (fid, "image\n");
-
-    img = map(img);
-
-    fmt = "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n";
-    fprintf (fid, fmt, img);
-
-    if (rem (img_sz, 30) != 0)
-      fprintf (fid, "\n");
-    endif
-
-    fprintf (fid, "grestore\n");
-    fprintf (fid, "showpage\n");
-    fprintf (fid, "%%%%Trailer\n");
-    fclose (fid);
-
-  else
-    error ("saveimage: what happened to the image type?");
-  endif
-
-endfunction
deleted file mode 100644
--- a/scripts/deprecated/strerror.m
+++ /dev/null
@@ -1,72 +0,0 @@
-## Copyright (C) 1995-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/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {} strerror (@var{name}, @var{num})
-## Return the text of an error message for function @var{name}
-## corresponding to the error number @var{num}.  This function is intended
-## to be used to print useful error messages for those functions that
-## return numeric error codes.
-## @end deftypefn
-
-## Author: jwe
-
-function msg = strerror (name, num)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "strerror is obsolete and will be removed from a future version of Octave.");
-  endif
-
-  if (nargin != 2)
-    print_usage ();
-  endif
-
-  if (! ischar (name))
-    error ("strerror: first argument must be a string");
-  endif
-
-  if (! isscalar (num))
-    error ("strerror: second argument must be a scalar");
-  endif
-
-  if (strcmp (name, "fsolve"))
-
-    if (num == -2)
-      msg = "input error\n";
-    elseif (num == -1)
-      msg = "error encountered in user-supplied function\n";
-    elseif (num == 1)
-      msg = "solution converged to requested tolerance\n";
-    elseif (num == 3)
-      msg = "iteration is not making good progress\n";
-    elseif (num == 4)
-      msg = "iteration limit exceeded\n";
-    else
-      error ("strerror: unrecognized error code for fsolve");
-    endif
-
-  else
-
-    error ("strerror: unrecognized function NAME");
-
-  endif
-
-endfunction
deleted file mode 100644
--- a/scripts/deprecated/values.m
+++ /dev/null
@@ -1,61 +0,0 @@
-## Copyright (C) 1995-2012 Kurt Hornik
-##
-## 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} {} values (@var{x})
-## Return the different values in a column vector, arranged in ascending
-## order.
-##
-## As an example, @code{values([1, 2, 3, 1])} returns the vector
-## @code{[1, 2, 3]}.
-## @end deftypefn
-
-## Author: KH <Kurt.Hornik@wu-wien.ac.at>
-## Description: Extract unique elements
-
-## Deprecated in version 3.4
-
-function v = values (x)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "values is obsolete and will be removed from a future version of Octave; please use unique instead");
-  endif
-
-  if (nargin != 1)
-    print_usage ();
-  endif
-
-  if (! (isvector (x)))
-    error ("values: X must be a vector");
-  endif
-
-  i = any (isnan (x));
-  ## HACK!
-  x = x(find(!isnan (x)));
-  n = length (x);
-  x = reshape (x, n, 1);
-  s = sort (x);
-  v = s([1; (find (s(2:n) > s(1:n-1)) + 1)]);
-  if (i)
-    v = [v; NaN];
-  endif
-
-endfunction
deleted file mode 100644
--- a/scripts/deprecated/weibcdf.m
+++ /dev/null
@@ -1,47 +0,0 @@
-## 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/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {} weibcdf (@var{x}, @var{scale}, @var{shape})
-## Compute the cumulative distribution function (CDF) at @var{x} of the
-## Weibull distribution with shape parameter @var{scale} and scale
-## parameter @var{shape}, which is
-##
-## @example
-## 1 - exp(-(x/shape)^scale)
-## @end example
-##
-## @noindent
-## for @var{x} @geq{} 0.
-## @end deftypefn
-
-## Deprecated in version 3.0
-## Matlab still has this function, so don't remove just yet.
-
-function cdf = weibcdf (varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "weibcdf is obsolete and will be removed from a future version of Octave; please use wblcdf instead");
-  endif
-
-  cdf = wblcdf (varargin{:});
-
-endfunction
deleted file mode 100644
--- a/scripts/deprecated/weibinv.m
+++ /dev/null
@@ -1,40 +0,0 @@
-## 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/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {} weibinv (@var{x}, @var{scale}, @var{shape})
-## Compute the quantile (the inverse of the CDF) at @var{x} of the
-## Weibull distribution with shape parameter @var{scale} and scale
-## parameter @var{shape}.
-## @end deftypefn
-
-## Deprecated in version 3.0
-## Matlab still has this function, so don't remove just yet.
-
-function inv = weibinv (varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "weibinv is obsolete and will be removed from a future version of Octave; please use wblinv instead");
-  endif
-
-  inv = wblinv (varargin{:});
-
-endfunction
deleted file mode 100644
--- a/scripts/deprecated/weibpdf.m
+++ /dev/null
@@ -1,47 +0,0 @@
-## 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/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {} weibpdf (@var{x}, @var{scale}, @var{shape})
-## Compute the probability density function (PDF) at @var{x} of the
-## Weibull distribution with shape parameter @var{scale} and scale
-## parameter @var{shape} which is given by
-##
-## @example
-##    scale * shape^(-scale) * x^(scale-1) * exp(-(x/shape)^scale)
-## @end example
-##
-## @noindent
-## for @var{x} > 0.
-## @end deftypefn
-
-## Deprecated in version 3.0
-## Matlab still has this function, so don't remove just yet.
-
-function pdf = weibpdf (varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "weibpdf is obsolete and will be removed from a future version of Octave; please use wblpdf instead");
-  endif
-
-  pdf = wblpdf (varargin{:});
-
-endfunction
deleted file mode 100644
--- a/scripts/deprecated/weibrnd.m
+++ /dev/null
@@ -1,46 +0,0 @@
-## 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/>.
-
-## -*- texinfo -*-
-## @deftypefn  {Function File} {} weibrnd (@var{scale}, @var{shape}, @var{r}, @var{c})
-## @deftypefnx {Function File} {} weibrnd (@var{scale}, @var{shape}, @var{sz})
-## Return an @var{r} by @var{c} matrix of random samples from the
-## Weibull distribution with parameters @var{scale} and @var{shape}
-## which must be scalar or of size @var{r} by @var{c}.  Or if @var{sz}
-## is a vector return a matrix of size @var{sz}.
-##
-## If @var{r} and @var{c} are omitted, the size of the result matrix is
-## the common size of @var{alpha} and @var{sigma}.
-## @end deftypefn
-
-## Deprecated in version 3.0
-## Matlab still has this function, so don't remove just yet.
-
-function rnd = weibrnd (varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "weibrnd is obsolete and will be removed from a future version of Octave; please use wblrnd instead");
-  endif
-
-  rnd = wblrnd (varargin{:});
-
-endfunction
-
--- a/scripts/elfun/acosd.m
+++ b/scripts/elfun/acosd.m
@@ -25,12 +25,18 @@
 ## Author: David Bateman <dbateman@free.fr>
 
 function y = acosd (x)
+
   if (nargin != 1)
     print_usage ();
   endif
-  y = acos(x) .* 180 ./ pi;
+
+  y = acos (x) .* 180 ./ pi;
+
 endfunction
 
-%!error(acosd())
-%!error(acosd(1,2))
-%!assert(acosd(0:0.1:1),180/pi*acos(0:0.1:1),-10*eps)
+
+%!assert (acosd (0:0.1:1), 180/pi * acos (0:0.1:1), -10*eps)
+
+%!error acosd ()
+%!error acosd (1, 2)
+
--- a/scripts/elfun/acot.m
+++ b/scripts/elfun/acot.m
@@ -30,18 +30,18 @@
     print_usage ();
   endif
 
-  y = atan (1./x);
+  y = atan (1 ./ x);
 
 endfunction
 
+
 %!test
 %! rt2 = sqrt (2);
 %! rt3 = sqrt (3);
 %! x = [rt3, 1, rt3/3, 0, -rt3/3, -1, -rt3];
 %! v = [pi/6, pi/4, pi/3, pi/2, -pi/3, -pi/4, -pi/6];
-%! assert(all (abs (acot (x) - v) < sqrt (eps)));
+%! assert (acot (x), v, sqrt (eps));
 
-%!error acot ();
+%!error acot ()
+%!error acot (1, 2)
 
-%!error acot (1, 2);
-
--- a/scripts/elfun/acotd.m
+++ b/scripts/elfun/acotd.m
@@ -25,12 +25,18 @@
 ## Author: David Bateman <dbateman@free.fr>
 
 function y = acotd (x)
+
   if (nargin != 1)
     print_usage ();
   endif
+
   y = atand (1 ./ x);
+
 endfunction
 
-%!error(acotd())
-%!error(acotd(1,2))
-%!assert(acotd(0:10:90),180./pi.*acot(0:10:90),-10*eps)
+
+%!assert (acotd (0:10:90), 180/pi * acot (0:10:90), -10*eps)
+
+%!error acotd ()
+%!error acotd (1, 2)
+
--- a/scripts/elfun/acoth.m
+++ b/scripts/elfun/acoth.m
@@ -34,14 +34,14 @@
 
 endfunction
 
+
 %!test
 %! rt2 = sqrt (2);
 %! rt3 = sqrt (3);
 %! v = -i*[pi/6, pi/4, pi/3, -pi/3, -pi/4, -pi/6];
 %! x = i*[rt3, 1, rt3/3, -rt3/3, -1, -rt3];
-%! assert(all (abs (acoth (x) - v) < sqrt (eps)));
+%! assert (acoth (x), v, sqrt (eps));
 
-%!error acoth ();
+%!error acoth ()
+%!error acoth (1, 2)
 
-%!error acoth (1, 2);
-
--- a/scripts/elfun/acsc.m
+++ b/scripts/elfun/acsc.m
@@ -34,14 +34,14 @@
 
 endfunction
 
+
 %!test
 %! rt2 = sqrt (2);
 %! rt3 = sqrt (3);
 %! v = [pi/6, pi/4, pi/3, pi/2, pi/3, pi/4, pi/6];
 %! x = [2, rt2, 2*rt3/3, 1, 2*rt3/3, rt2, 2];
-%! assert(all (abs (acsc (x) - v) < sqrt (eps)));
+%! assert (acsc (x), v, sqrt (eps));
 
-%!error acsc ();
+%!error acsc ()
+%!error acsc (1, 2)
 
-%!error acsc (1, 2);
-
--- a/scripts/elfun/acscd.m
+++ b/scripts/elfun/acscd.m
@@ -25,12 +25,18 @@
 ## Author: David Bateman <dbateman@free.fr>
 
 function y = acscd (x)
+
   if (nargin != 1)
     print_usage ();
   endif
-  y = acsc(x) .* 180 ./ pi;
+
+  y = acsc (x) .* 180 ./ pi;
+
 endfunction
 
-%!error(acscd())
-%!error(acscd(1,2))
-%!assert(acscd(0:10:90),180/pi*acsc(0:10:90),-10*eps)
+
+%!assert (acscd (0:10:90), 180/pi * acsc (0:10:90), -10*eps)
+
+%!error acscd ()
+%!error acscd (1, 2)
+
--- a/scripts/elfun/acsch.m
+++ b/scripts/elfun/acsch.m
@@ -34,12 +34,12 @@
 
 endfunction
 
+
 %!test
 %! v = [pi/2*i, -pi/2*i];
 %! x = [-i, i];
-%! assert(all (abs (acsch (x) - v) < sqrt (eps)));
+%! assert (acsch (x), v, sqrt (eps));
 
-%!error acsch ();
+%!error acsch ()
+%!error acsch (1, 2)
 
-%!error acsch (1, 2);
-
--- a/scripts/elfun/asec.m
+++ b/scripts/elfun/asec.m
@@ -34,13 +34,14 @@
 
 endfunction
 
+
 %!test
 %! rt2 = sqrt (2);
 %! rt3 = sqrt (3);
 %! v = [0, pi/6, pi/4, pi/3, 2*pi/3, 3*pi/4, 5*pi/6, pi];
 %! x = [1, 2*rt3/3, rt2, 2, -2, -rt2, -2*rt3/3, -1];
-%! assert(all (abs (asec (x) - v) < sqrt (eps)));
+%! assert (asec (x), v, sqrt (eps));
 
-%!error asec ();
+%!error asec ()
+%!error asec (1, 2)
 
-%!error asec (1, 2);
--- a/scripts/elfun/asecd.m
+++ b/scripts/elfun/asecd.m
@@ -25,12 +25,18 @@
 ## Author: David Bateman <dbateman@free.fr>
 
 function y = asecd (x)
+
   if (nargin != 1)
     print_usage ();
   endif
+
   y = asec (x) .* 180 ./ pi;
-endfunction;
+
+endfunction
+
 
-%!error(asecd())
-%!error(asecd(1,2))
-%!assert(asecd(0:10:90),180./pi.*asec(0:10:90),-10*eps)
+%!assert (asecd (0:10:90), 180/pi * asec (0:10:90), -10*eps)
+
+%!error asecd ()
+%!error asecd (1, 2)
+
--- a/scripts/elfun/asech.m
+++ b/scripts/elfun/asech.m
@@ -34,12 +34,12 @@
 
 endfunction
 
+
 %!test
 %! v = [0, pi*i];
 %! x = [1, -1];
-%! assert(all (abs (asech (x) - v) < sqrt (eps)));
+%! assert (asech (x), v, sqrt (eps));
 
-%!error asech ();
+%!error asech ()
+%!error asech (1, 2)
 
-%!error asech (1, 2);
-
--- a/scripts/elfun/asind.m
+++ b/scripts/elfun/asind.m
@@ -25,12 +25,18 @@
 ## Author: David Bateman <dbateman@free.fr>
 
 function y = asind (x)
+
   if (nargin != 1)
     print_usage ();
   endif
-  y = asin(x) .* 180 ./ pi;
+
+  y = asin (x) .* 180 ./ pi;
+
 endfunction
 
-%!error(asind())
-%!error(asind(1,2))
-%!assert(asind(0:0.1:1),180/pi*asin(0:0.1:1),-10*eps)
+
+%!assert (asind (0:0.1:1), 180/pi * asin (0:0.1:1), -10*eps)
+
+%!error asind ()
+%!error asind (1, 2)
+
--- a/scripts/elfun/atand.m
+++ b/scripts/elfun/atand.m
@@ -25,12 +25,18 @@
 ## Author: David Bateman <dbateman@free.fr>
 
 function y = atand (x)
+
   if (nargin != 1)
     print_usage ();
   endif
+
   y = 180 ./ pi .* atan (x);
+
 endfunction
 
-%!error(atand())
-%!error(atand(1,2))
-%!assert(atand(0:10:90),180./pi.*atan(0:10:90),-10*eps)
+
+%!assert (atand (0:10:90), 180/pi * atan (0:10:90), -10*eps)
+
+%!error atand ()
+%!error atand (1, 2)
+
--- a/scripts/elfun/cosd.m
+++ b/scripts/elfun/cosd.m
@@ -26,17 +26,23 @@
 ## Author: David Bateman <dbateman@free.fr>
 
 function y = cosd (x)
+
   if (nargin != 1)
     print_usage ();
   endif
+
   I = x / 180;
   y = cos (I .* pi);
   I = I + 0.5;
   y(I == fix (I) & finite (I)) = 0;
+
 endfunction
 
-%!error(cosd())
-%!error(cosd(1,2))
-%!assert(cosd(0:10:80),cos(pi*[0:10:80]/180),-10*eps)
-%!assert(cosd([0,180,360]) != 0)
-%!assert(cosd([90,270]) == 0)
+
+%!assert (cosd (0:10:80), cos (pi*[0:10:80]/180), -10*eps)
+%!assert (cosd ([0, 180, 360]) != 0)
+%!assert (cosd ([90, 270]) == 0)
+
+%!error cosd ()
+%!error cosd (1, 2)
+
--- a/scripts/elfun/cot.m
+++ b/scripts/elfun/cot.m
@@ -30,18 +30,18 @@
     print_usage ();
   endif
 
-  y = 1 ./ tan(x);
+  y = 1 ./ tan (x);
 
 endfunction
 
+
 %!test
 %! rt2 = sqrt (2);
 %! rt3 = sqrt (3);
 %! x = [pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6];
 %! v = [rt3, 1, rt3/3, 0, -rt3/3, -1, -rt3];
-%! assert(all (abs (cot (x) - v) < sqrt (eps)));
+%! assert (cot (x), v, sqrt (eps));
 
-%!error cot ();
+%!error cot ()
+%!error cot (1, 2)
 
-%!error cot (1, 2);
-
--- a/scripts/elfun/cotd.m
+++ b/scripts/elfun/cotd.m
@@ -25,14 +25,20 @@
 ## Author: David Bateman <dbateman@free.fr>
 
 function y = cotd (x)
+
   if (nargin != 1)
     print_usage ();
   endif
+
   y = 1 ./ tand (x);
+
 endfunction
 
-%!error(cotd())
-%!error(cotd(1,2))
-%!assert(cotd(10:10:80),cot(pi*[10:10:80]/180),-10*eps)
-%!assert(cotd([0,180,360]) == Inf)
-%!assert(cotd([90,270]) == 0)
+
+%!assert (cotd (10:10:80), cot (pi*[10:10:80]/180), -10*eps)
+%!assert (cotd ([0, 180, 360]) == Inf)
+%!assert (cotd ([90, 270]) == 0)
+
+%!error cotd ()
+%!error cotd (1, 2)
+
--- a/scripts/elfun/coth.m
+++ b/scripts/elfun/coth.m
@@ -34,12 +34,12 @@
 
 endfunction
 
+
 %!test
 %! x = [pi/2*i, 3*pi/2*i];
 %! v = [0, 0];
-%! assert(all (abs (coth (x) - v) < sqrt (eps)));
+%! assert (coth (x), v, sqrt (eps));
 
-%!error coth ();
+%!error coth ()
+%!error coth (1, 2)
 
-%!error coth (1, 2);
-
--- a/scripts/elfun/csc.m
+++ b/scripts/elfun/csc.m
@@ -30,18 +30,18 @@
     print_usage ();
   endif
 
-  y = 1 ./ sin(x);
+  y = 1 ./ sin (x);
 
 endfunction
 
+
 %!test
 %! rt2 = sqrt (2);
 %! rt3 = sqrt (3);
 %! x = [pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6];
 %! v = [2, rt2, 2*rt3/3, 1, 2*rt3/3, rt2, 2];
-%! assert(all (abs (csc (x) - v) < sqrt (eps)));
+%! assert (csc (x), v, sqrt (eps));
 
-%!error csc ();
+%!error csc ()
+%!error csc (1, 2)
 
-%!error csc (1, 2);
-
--- a/scripts/elfun/cscd.m
+++ b/scripts/elfun/cscd.m
@@ -25,15 +25,20 @@
 ## Author: David Bateman <dbateman@free.fr>
 
 function y = cscd (x)
+
   if (nargin != 1)
     print_usage ();
   endif
+
   y = 1 ./ sind (x);
+
 endfunction
 
-%!error(cscd())
-%!error(cscd(1,2))
-%!assert(cscd(10:10:90),csc(pi*[10:10:90]/180),-10*eps)
-%!assert(cscd([0,180,360]) == Inf)
-%!assert(cscd([90,270]) != Inf)
 
+%!assert (cscd (10:10:90), csc (pi*[10:10:90]/180), -10*eps)
+%!assert (cscd ([0, 180, 360]) == Inf)
+%!assert (cscd ([90, 270]) != Inf)
+
+%!error cscd ()
+%!error cscd (1, 2)
+
--- a/scripts/elfun/csch.m
+++ b/scripts/elfun/csch.m
@@ -30,16 +30,16 @@
     print_usage ();
   endif
 
-  y = 1 ./ sinh(x);
+  y = 1 ./ sinh (x);
 
 endfunction
 
+
 %!test
 %! x = [pi/2*i, 3*pi/2*i];
 %! v = [-i, i];
-%! assert(all (abs (csch (x) - v) < sqrt (eps)));
+%! assert (csch (x), v, sqrt (eps));
 
-%!error csch ();
+%!error csch ()
+%!error csch (1, 2)
 
-%!error csch (1, 2);
-
--- a/scripts/elfun/sec.m
+++ b/scripts/elfun/sec.m
@@ -30,18 +30,18 @@
     print_usage ();
   endif
 
-  y = 1 ./ cos(x);
+  y = 1 ./ cos (x);
 
 endfunction
 
+
 %!test
 %! rt2 = sqrt (2);
 %! rt3 = sqrt (3);
 %! x = [0, pi/6, pi/4, pi/3, 2*pi/3, 3*pi/4, 5*pi/6, pi];
 %! v = [1, 2*rt3/3, rt2, 2, -2, -rt2, -2*rt3/3, -1];
-%! assert(all (abs (sec (x) - v) < sqrt (eps)));
+%! assert (sec (x), v, sqrt (eps));
 
-%!error sec ();
+%!error sec ()
+%!error sec (1, 2)
 
-%!error sec (1, 2);
-
--- a/scripts/elfun/secd.m
+++ b/scripts/elfun/secd.m
@@ -25,14 +25,20 @@
 ## Author: David Bateman <dbateman@free.fr>
 
 function y = secd (x)
+
   if (nargin != 1)
     print_usage ();
   endif
+
   y = 1 ./ cosd (x);
+
 endfunction
 
-%!error(secd())
-%!error(secd(1,2))
-%!assert(secd(0:10:80),sec(pi*[0:10:80]/180),-10*eps)
-%!assert(secd([0,180,360]) != Inf)
-%!assert(secd([90,270]) == Inf)
+
+%!assert (secd (0:10:80), sec (pi*[0:10:80]/180), -10*eps)
+%!assert (secd ([0, 180, 360]) != Inf)
+%!assert (secd ([90, 270]) == Inf)
+
+%!error secd ()
+%!error secd (1, 2)
+
--- a/scripts/elfun/sech.m
+++ b/scripts/elfun/sech.m
@@ -30,16 +30,16 @@
     print_usage ();
   endif
 
-  y = 1 ./ cosh(x);
+  y = 1 ./ cosh (x);
 
 endfunction
 
+
 %!test
 %! x = [0, pi*i];
 %! v = [1, -1];
-%! assert(all (abs (sech (x) - v) < sqrt (eps)));
+%! assert (sech (x), v, sqrt (eps));
 
-%!error sech ();
+%!error sech ()
+%!error sech (1, 2)
 
-%!error sech (1, 2);
-
--- a/scripts/elfun/sind.m
+++ b/scripts/elfun/sind.m
@@ -26,16 +26,22 @@
 ## Author: David Bateman <dbateman@free.fr>
 
 function y = sind (x)
+
   if (nargin != 1)
     print_usage ();
   endif
+
   I = x / 180;
   y = sin (I .* pi);
   y(I == fix (I) & finite (I)) = 0;
+
 endfunction
 
-%!error(sind())
-%!error(sind(1,2))
-%!assert(sind(10:10:90),sin(pi*[10:10:90]/180),-10*eps)
-%!assert(sind([0,180,360]) == 0)
-%!assert(sind([90,270]) != 0)
+
+%!assert (sind (10:10:90), sin (pi*[10:10:90]/180), -10*eps)
+%!assert (sind ([0, 180, 360]) == 0)
+%!assert (sind ([90, 270]) != 0)
+
+%!error sind ()
+%!error sind (1, 2)
+
--- a/scripts/elfun/tand.m
+++ b/scripts/elfun/tand.m
@@ -27,18 +27,24 @@
 ## Author: David Bateman <dbateman@free.fr>
 
 function y = tand (x)
+
   if (nargin != 1)
     print_usage ();
   endif
+
   I0 = x / 180;
   I90 = (x-90) / 180;
   y = tan (I0 .* pi);
   y(I0 == fix (I0) & finite (I0)) = 0;
   y(I90 == fix (I90) & finite (I90)) = Inf;
-endfunction;
+
+endfunction
+
 
-%!error(tand())
-%!error(tand(1,2))
-%!assert(tand(10:10:80),tan(pi*[10:10:80]/180),-10*eps)
-%!assert(tand([0,180,360]) == 0)
-%!assert(tand([90,270]) == Inf)
+%!assert (tand (10:10:80), tan (pi*[10:10:80]/180), -10*eps)
+%!assert (tand ([0, 180, 360]) == 0)
+%!assert (tand ([90, 270]) == Inf)
+
+%!error tand ()
+%!error tand (1, 2)
+
--- a/scripts/general/accumarray.m
+++ b/scripts/general/accumarray.m
@@ -92,7 +92,7 @@
 ## @end example
 ##
 ## The sparse option can be used as an alternative to the @code{sparse}
-## constructor (@pxref{doc-sparse}). Thus
+## constructor (@pxref{doc-sparse}).  Thus
 ##
 ## @example
 ## sparse (@var{i}, @var{j}, @var{sv})
@@ -106,7 +106,7 @@
 ## @end example
 ##
 ## @noindent
-## For repeated indices, @code{sparse} adds the corresponding value. To
+## For repeated indices, @code{sparse} adds the corresponding value.  To
 ## take the minimum instead, use @code{min} as an accumulator function:
 ##
 ## @example
@@ -368,24 +368,23 @@
   endif
 endfunction
 
-%!error (accumarray (1:5))
-%!error (accumarray ([1,2,3],1:2))
+
 %!assert (accumarray ([1;2;4;2;4],101:105), [101;206;0;208])
-%!assert (accumarray ([1,1,1;2,1,2;2,3,2;2,1,2;2,3,2],101:105),cat(3, [101,0,0;0,0,0],[0,0,0;206,0,208]))
-%!assert (accumarray ([1,1,1;2,1,2;2,3,2;2,1,2;2,3,2],101:105,[],@(x)sin(sum(x))),sin(cat(3, [101,0,0;0,0,0],[0,0,0;206,0,208])))
-%!assert (accumarray ({[1 3 3 2 3 1 2 2 3 3 1 2],[3 4 2 1 4 3 4 2 2 4 3 4],[1 1 2 2 1 1 2 1 1 1 2 2]},101:112),cat(3,[0,0,207,0;0,108,0,0;0,109,0,317],[0,0,111,0;104,0,0,219;0,103,0,0]))
-%!assert (accumarray ([1,1;2,1;2,3;2,1;2,3],101:105,[2,4],@max,NaN),[101,NaN,NaN,NaN;104,NaN,105,NaN])
+%!assert (accumarray ([1,1,1;2,1,2;2,3,2;2,1,2;2,3,2],101:105), cat (3, [101,0,0;0,0,0],[0,0,0;206,0,208]))
+%!assert (accumarray ([1,1,1;2,1,2;2,3,2;2,1,2;2,3,2],101:105,[],@(x)sin(sum(x))), sin (cat (3, [101,0,0;0,0,0],[0,0,0;206,0,208])))
+%!assert (accumarray ({[1 3 3 2 3 1 2 2 3 3 1 2],[3 4 2 1 4 3 4 2 2 4 3 4],[1 1 2 2 1 1 2 1 1 1 2 2]},101:112), cat (3, [0,0,207,0;0,108,0,0;0,109,0,317], [0,0,111,0;104,0,0,219;0,103,0,0]))
+%!assert (accumarray ([1,1;2,1;2,3;2,1;2,3],101:105,[2,4],@max,NaN), [101,NaN,NaN,NaN;104,NaN,105,NaN])
 %!assert (accumarray ([1 1; 2 1; 2 3; 2 1; 2 3],101:105, [], @prod), [101, 0, 0; 10608, 0, 10815])
-%!assert (accumarray ([1 1; 2 1; 2 3; 2 1; 2 3],101:105,[2 4],@prod,0,true),sparse([1,2,2],[1,1,3],[101,10608,10815],2,4))
+%!assert (accumarray ([1 1; 2 1; 2 3; 2 1; 2 3],101:105,[2 4],@prod,0,true), sparse ([1,2,2],[1,1,3],[101,10608,10815],2,4))
 %!assert (accumarray ([1 1; 2 1; 2 3; 2 1; 2 3],1,[2,4]), [1,0,0,0;2,0,2,0])
-%!assert (accumarray ([1 1; 2 1; 2 3; 2 1; 2 3],101:105,[2,4],@(x)length(x)>1),[false,false,false,false;true,false,true,false])
+%!assert (accumarray ([1 1; 2 1; 2 3; 2 1; 2 3],101:105,[2,4],@(x)length(x)>1), [false,false,false,false;true,false,true,false])
 %!assert (accumarray ([1; 2], [3; 4], [2, 1], @min, [], 0), [3; 4])
 %!assert (accumarray ([1; 2], [3; 4], [2, 1], @min, [], 1), sparse ([3; 4]))
 %!assert (accumarray ([1; 2], [3; 4], [1, 2], @min, [], 0), [3, 4])
 %!assert (accumarray ([1; 2], [3; 4], [1, 2], @min, [], 1), sparse ([3, 4]))
 %!test
-%! A = accumarray ([1 1; 2 1; 2 3; 2 1; 2 3],101:105,[2,4],@(x){x});
-%! assert (A{2},[102;104])
+%! A = accumarray ([1 1; 2 1; 2 3; 2 1; 2 3], 101:105, [2,4], @(x){x});
+%! assert (A{2},[102;104]);
 %!test
 %! subs = ceil (rand (2000, 3)*10);
 %! vals = rand (2000, 1);
@@ -405,4 +404,6 @@
 %! vals = rand (2000, 1);
 %! assert (accumarray (subsc, vals, [], @max), accumarray (subs, vals, [], @max));
 
+%!error (accumarray (1:5))
+%!error (accumarray ([1,2,3],1:2))
 
--- a/scripts/general/accumdim.m
+++ b/scripts/general/accumdim.m
@@ -83,7 +83,8 @@
   sz = size (vals);
 
   if (nargin < 3)
-    [~, dim] = max (sz != 1); # first non-singleton dim
+    ## Find the first non-singleton dimension.
+    (dim = find (sz > 1, 1)) || (dim = 1);
   elseif (! isindex (dim))
     error ("accumdim: DIM must be a valid dimension");
   elseif (dim > length (sz))
@@ -147,6 +148,7 @@
 
 endfunction
 
+
 %%test accumdim vs. accumarray
 
 %!shared a
@@ -156,3 +158,4 @@
 %!assert (accumdim ([2;3;2;2;2], a, 2, 4)(4,:,2), accumarray ([2;3;2;2;2], a(4,:,2), [1,4]))
 %!assert (accumdim ([2;3;2;1;2], a, 3, 3, @min)(1,5,:), accumarray ([2;3;2;1;2], a(1,5,:), [1,1,3], @min))
 %!assert (accumdim ([1;3;2;2;1], a, 2, 3, @median)(4,:,5), accumarray ([1;3;2;2;1], a(4,:,5), [1,3], @median))
+
--- a/scripts/general/bicubic.m
+++ b/scripts/general/bicubic.m
@@ -38,7 +38,7 @@
     print_usage ();
   endif
 
-  if (nargin == 7 && isscalar(spline_alpha))
+  if (nargin == 7 && isscalar (spline_alpha))
     a = spline_alpha;
   else
     a = 0.5;
@@ -50,9 +50,9 @@
 
   if (isa (x, "single") || isa (y, "single") || isa (z, "single")
       || isa (xi, "single") || isa (yi, "single"))
-    myeps = eps("single");
+    myeps = eps ("single");
   else
-    myeps = eps;
+    myeps = eps ();
   endif
 
   if (nargin <= 2)
@@ -65,8 +65,8 @@
     z = x;
     x = [];
     [rz, cz] = size (z);
-    s = linspace (1, cz, (cz-1)*pow2(n)+1);
-    t = linspace (1, rz, (rz-1)*pow2(n)+1);
+    s = linspace (1, cz, (cz-1) * pow2 (n) + 1);
+    t = linspace (1, rz, (rz-1) * pow2 (n) + 1);
   elseif (nargin == 3)
     if (! isvector (x) || ! isvector (y))
       error ("bicubic: XI and YI must be vector");
@@ -88,6 +88,23 @@
       error ("bicubic: X, Y and Z must be equal size matrices of same size");
     endif
 
+    if (all (diff (x) < 0))
+      flipx = true;
+      x = fliplr (x);
+    elseif (all (diff (x) > 0))
+      flipx = false;
+    else
+      error ("bicubic:nonmonotonic", "bicubic: X values must be monotonic")
+    endif
+    if (all (diff (y) < 0))
+      flipy = true;
+      y = flipud (y);
+    elseif (all (diff (y) > 0))
+      flipy = false;
+    else
+      error ("bicubic:nonmonotonic", "bicubic: Y values must be monotonic")
+    endif
+
     ## Mark values outside the lookup table.
     xfirst_ind = find (xi < x(1));
     xlast_ind  = find (xi > x(cz));
@@ -99,9 +116,8 @@
     yi(yfirst_ind) = y(1);
     yi(ylast_ind) = y(rz);
 
-
     x = reshape (x, 1, cz);
-    x(cz) *= 1 + sign (x(cz))*myeps;
+    x(cz) *= 1 + sign (x(cz)) * myeps;
     if (x(cz) == 0)
       x(cz) = myeps;
     endif;
@@ -111,7 +127,7 @@
     xidx = o(find (i > cz));
 
     y = reshape (y, rz, 1);
-    y(rz) *= 1 + sign (y(rz))*myeps;
+    y(rz) *= 1 + sign (y(rz)) * myeps;
     if (y(rz) == 0)
       y(rz) = myeps;
     endif;
@@ -121,8 +137,15 @@
     yidx = o([find(i > rz)]);
 
     ## Set s and t used follow codes.
-    s = xidx + ((xi .- x(xidx))./(x(xidx+1) .- x(xidx)));
-    t = yidx + ((yi - y(yidx))./(y(yidx+1) - y(yidx)));
+    s = xidx + ((xi .- x(xidx)) ./ (x(xidx+1) .- x(xidx)));
+    t = yidx + ((yi  - y(yidx)) ./ (y(yidx+1)  - y(yidx)));
+
+    if (flipx)
+      s = fliplr (s);
+    endif
+    if (flipy)
+      t = flipud (t);
+    endif
   else
     print_usage ();
   endif
@@ -199,10 +222,26 @@
 endfunction
 
 %!demo
-%! A=[13,-1,12;5,4,3;1,6,2];
-%! x=[0,1,4]+10; y=[-10,-9,-8];
-%! xi=linspace(min(x),max(x),17);
-%! yi=linspace(min(y),max(y),26)';
-%! mesh(xi,yi,bicubic(x,y,A,xi,yi));
-%! [x,y] = meshgrid(x,y);
-%! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
+%! clf;
+%! colormap ("default");
+%! A = [13,-1,12;5,4,3;1,6,2];
+%! x = [0,1,4]+10;
+%! y = [-10,-9,-8];
+%! xi = linspace (min (x), max (x), 17);
+%! yi = linspace (min (y), max (y), 26)';
+%! mesh (xi, yi, bicubic (x,y,A,xi,yi));
+%! [x,y] = meshgrid (x,y);
+%! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off;
+
+%!test
+%! x = linspace (1, -1, 10);
+%! [xx, yy] = meshgrid (x);
+%! z = cos (6 * xx) + sin (6 * yy);
+%! x = linspace (1, -1, 30);
+%! [xx2, yy2] = meshgrid (x);
+%! z1 = interp2 (xx, yy, z, xx2, yy2, "cubic");
+%! z2 = interp2 (fliplr (xx), flipud (yy), fliplr (flipud(z)),
+%!               fliplr (xx2), flipud (yy2), "cubic");
+%! z2 = fliplr (flipud (z2));
+%! assert (z1, z2, 100 * eps ())
+
--- a/scripts/general/bitcmp.m
+++ b/scripts/general/bitcmp.m
@@ -86,38 +86,38 @@
 
 
 %!test
-%! Amax=53;
+%! Amax = 53;
 %! Bmax = bitmax;
-%! A = bitshift(Bmax,-2);
-%! assert(bitcmp(A,Amax),bitor(bitshift(1,Amax-1),bitshift(1,Amax-2)));
-%! assert(bitcmp(A,Amax-1),bitshift(1,Amax-2));
-%! assert(bitcmp(A,Amax-2),0);
+%! A = bitshift (Bmax,-2);
+%! assert (bitcmp (A,Amax),bitor (bitshift (1,Amax-1), bitshift (1,Amax-2)));
+%! assert (bitcmp (A,Amax-1), bitshift (1,Amax-2));
+%! assert (bitcmp (A,Amax-2), 0);
 %!test
-%! Amax=8;
-%! Bmax = intmax('uint8');
-%! A = bitshift(Bmax,-2);
-%! assert(bitcmp(A,Amax),bitor(bitshift(uint8(1),Amax-1),bitshift(uint8(1),Amax-2)));
-%! assert(bitcmp(A,Amax-1),bitshift(uint8(1),Amax-2));
-%! assert(bitcmp(A,Amax-2),uint8(0));
+%! Amax = 8;
+%! Bmax = intmax ("uint8");
+%! A = bitshift (Bmax,-2);
+%! assert (bitcmp (A,Amax),bitor (bitshift (uint8 (1),Amax-1), bitshift (uint8 (1),Amax-2)));
+%! assert (bitcmp (A,Amax-1), bitshift (uint8 (1),Amax-2));
+%! assert (bitcmp (A,Amax-2), uint8 (0));
 %!test
-%! Amax=16;
-%! Bmax = intmax('uint16');
-%! A = bitshift(Bmax,-2);
-%! assert(bitcmp(A,Amax),bitor(bitshift(uint16(1),Amax-1),bitshift(uint16(1),Amax-2)));
-%! assert(bitcmp(A,Amax-1),bitshift(uint16(1),Amax-2));
-%! assert(bitcmp(A,Amax-2),uint16(0));
+%! Amax = 16;
+%! Bmax = intmax ("uint16");
+%! A = bitshift (Bmax,-2);
+%! assert (bitcmp (A,Amax),bitor (bitshift (uint16 (1),Amax-1), bitshift (uint16 (1),Amax-2)));
+%! assert (bitcmp (A,Amax-1), bitshift (uint16 (1),Amax-2));
+%! assert (bitcmp (A,Amax-2), uint16 (0));
 %!test
-%! Amax=32;
-%! Bmax = intmax('uint32');
-%! A = bitshift(Bmax,-2);
-%! assert(bitcmp(A,Amax),bitor(bitshift(uint32(1),Amax-1),bitshift(uint32(1),Amax-2)));
-%! assert(bitcmp(A,Amax-1),bitshift(uint32(1),Amax-2));
-%! assert(bitcmp(A,Amax-2),uint32(0));
+%! Amax = 32;
+%! Bmax = intmax ("uint32");
+%! A = bitshift (Bmax,-2);
+%! assert (bitcmp (A,Amax),bitor (bitshift (uint32 (1),Amax-1), bitshift (uint32 (1),Amax-2)));
+%! assert (bitcmp (A,Amax-1), bitshift (uint32 (1),Amax-2));
+%! assert (bitcmp (A,Amax-2), uint32 (0));
 %!test
-%! Amax=64;
-%! Bmax = intmax('uint64');
-%! A = bitshift(Bmax,-2);
-%! assert(bitcmp(A,Amax),bitor(bitshift(uint64(1),Amax-1),bitshift(uint64(1),Amax-2)));
-%! assert(bitcmp(A,Amax-1),bitshift(uint64(1),Amax-2));
-%! assert(bitcmp(A,Amax-2),uint64(0));
+%! Amax = 64;
+%! Bmax = intmax ("uint64");
+%! A = bitshift (Bmax,-2);
+%! assert (bitcmp (A,Amax),bitor (bitshift (uint64 (1),Amax-1), bitshift (uint64 (1),Amax-2)));
+%! assert (bitcmp (A,Amax-1), bitshift (uint64 (1),Amax-2));
+%! assert (bitcmp (A,Amax-2), uint64 (0));
 
--- a/scripts/general/bitget.m
+++ b/scripts/general/bitget.m
@@ -80,8 +80,6 @@
 
 endfunction
 
-%!error bitget (1);
-%!error bitget (1, 2, 3);
 
 %!test
 %! assert (bitget ([4, 14], [3, 3]), logical ([1, 1]));
@@ -93,17 +91,21 @@
 %!   endfor
 %! endfor
 
-%!error bitget (0, 0);
-%!error bitget (0, 55);
+%!error bitget (0, 0)
+%!error bitget (0, 55)
 
-%!error bitget (int8 (0), 9);
-%!error bitget (uint8 (0), 9);
+%!error bitget (int8 (0), 9)
+%!error bitget (uint8 (0), 9)
+
+%!error bitget (int16 (0), 17)
+%!error bitget (uint16 (0), 17)
 
-%!error bitget (int16 (0), 17);
-%!error bitget (uint16 (0), 17);
+%!error bitget (int32 (0), 33)
+%!error bitget (uint32 (0), 33)
 
-%!error bitget (int32 (0), 33);
-%!error bitget (uint32 (0), 33);
+%!error bitget (int64 (0), 65)
+%!error bitget (uint64 (0), 65)
 
-%!error bitget (int64 (0), 65);
-%!error bitget (uint64 (0), 65);
+%!error bitget (1)
+%!error bitget (1, 2, 3)
+
--- a/scripts/general/bitset.m
+++ b/scripts/general/bitset.m
@@ -1,4 +1,5 @@
 ## Copyright (C) 2004-2012 David Bateman
+## Copyright (C) 2012 Jordi Gutiérrez Hermoso
 ##
 ## This file is part of Octave.
 ##
@@ -21,7 +22,8 @@
 ## @deftypefnx {Function File} {@var{C} =} bitset (@var{A}, @var{n}, @var{val})
 ## Set or reset bit(s) @var{n} of unsigned integers in @var{A}.
 ## @var{val} = 0 resets and @var{val} = 1 sets the bits.
-## The lowest significant bit is: @var{n} = 1
+## The lowest significant bit is: @var{n} = 1.  All variables must be the
+## same size or scalars.
 ##
 ## @example
 ## @group
@@ -32,69 +34,60 @@
 ## @seealso{bitand, bitor, bitxor, bitget, bitcmp, bitshift, bitmax}
 ## @end deftypefn
 
-## Liberally based on the version by Kai Habel from octave-forge
-
 function C = bitset (A, n, val)
 
   if (nargin < 2 || nargin > 3)
     print_usage ();
   endif
 
+  if (any (A(:) < 0))
+    error ("bitset: A must be >= 0");
+  endif
+
+  sz = size (A);
+
   if (nargin == 2)
-    val = 1;
+    val = true (sz);
   endif
 
-  if (isa (A, "double"))
-    Bmax = bitmax;
-    Amax = log2 (Bmax) + 1;
-    _conv = @double;
+  cl = class (A);
+
+  if (isfloat (A) && isreal (A))
+    Bmax = bitmax (cl);
+    Amax = log2 (Bmax);
+  elseif (isinteger (A))
+    Bmax = intmax (cl);
+    Amax = round (log2 (Bmax));
   else
-    if (isa (A, "uint8"))
-      Amax = 8;
-      _conv = @uint8;
-    elseif (isa (A, "uint16"))
-      Amax = 16;
-      _conv = @uint16;
-    elseif (isa (A, "uint32"))
-      Amax = 32;
-      _conv = @uint32;
-    elseif (isa (A, "uint64"))
-      Amax = 64;
-      _conv = @uint64;
-    elseif (isa (A, "int8"))
-      Amax = 8;
-      _conv = @int8;
-    elseif (isa (A, "int16"))
-      Amax = 16;
-      _conv = @int16;
-    elseif (isa (A, "int32"))
-      Amax = 32;
-      _conv = @int32;
-    elseif (isa (A, "int64"))
-      Amax = 64;
-      _conv = @int64;
-    else
-      error ("bitset: invalid class %s", class (A));
-    endif
-    Bmax = intmax (class (A));
+    error ("bitset: invalid class %s", cl);
   endif
 
-  m = double (n(:));
-  if (any (m < 1) || any (m > Amax))
+  if (any ((n < 1)(:)) || any ((n > Amax)(:)))
     error ("bitset: N must be in the range [1,%d]", Amax);
   endif
 
-  mask = bitshift (_conv (1), uint8 (n) - uint8 (1));
-  C = bitxor (A, bitand (A, mask));
+  mask = bitshift (cast (1, cl), uint8 (n) - uint8 (1));
+
+  on = logical (val);
+  off = !on;
 
-  if (val)
-    C = bitor (A, mask);
+  if (isscalar (mask))
+    onmask = mask;
+    offmask = mask;
+  else
+    if (! size_equal (A, n))
+      error ("bitset: N must be scalar or the same size as A");
+    endif
+    onmask = mask(on);
+    offmask = mask(off);
   endif
 
+  C = zeros (sz, cl);
+  C(on) = bitor (A(on), onmask);
+  C(off) = bitand (A(off), bitcmp (offmask));
+
 endfunction
 
-%!error bitset (1);
-%!error bitset (1, 2, 3, 4);
 
 %!test
 %! assert (bitset ([0, 10], [3, 3]), [4, 14]);
@@ -106,17 +99,24 @@
 %!   endfor
 %! endfor
 
-%!error bitset (0, 0);
-%!error bitset (0, 55);
-
-%!error bitset (int8 (0), 9);
-%!error bitset (uint8 (0), 9);
+## Bug #36458
+%!assert (bitset (uint8 ([1, 2;3 4]), 1, [0 1; 0 1]), uint8 ([0, 3; 2 5]))
 
-%!error bitset (int16 (0), 17);
-%!error bitset (uint16 (0), 17);
+%!error bitset (1)
+%!error bitset (1, 2, 3, 4)
+%!error <A must be .= 0> bitset (-1, 2)
+%!error <invalid class char> bitset ("1", 2)
+%!error <N must be in the range \[1,53\]> bitset (0, 0)
+%!error <N must be in the range \[1,53\]> bitset (0, 55)
+%!error <N must be in the range \[1,8\]> bitset (uint8 (0), 0)
+%!error <N must be in the range \[1,8\]> bitset (uint8 (0), 9)
+%!error <N must be in the range \[1,7\]> bitset (int8 (0), 9)
+%!error <N must be in the range \[1,15\]> bitset (int16 (0), 17)
+%!error <N must be in the range \[1,16\]> bitset (uint16 (0), 17)
+%!error <N must be in the range \[1,31\]> bitset (int32 (0), 33)
+%!error <N must be in the range \[1,32\]> bitset (uint32 (0), 33)
+%!error <N must be in the range \[1,63\]> bitset (int64 (0), 65)
+%!error <N must be in the range \[1,64\]> bitset (uint64 (0), 65)
+%!error <N must be scalar or the same size as A> bitset (uint8 (1), [1 3])
+%!error <N must be scalar or the same size as A> bitset (uint8 (1:3), [1 3])
 
-%!error bitset (int32 (0), 33);
-%!error bitset (uint32 (0), 33);
-
-%!error bitset (int64 (0), 65);
-%!error bitset (uint64 (0), 65);
--- a/scripts/general/blkdiag.m
+++ b/scripts/general/blkdiag.m
@@ -63,19 +63,21 @@
 
 endfunction
 
+
 ## regular tests
-%!assert(blkdiag(1,ones(2),1),[1,0,0,0;0,1,1,0;0,1,1,0;0,0,0,1])
-%!assert(blkdiag([1,2],[3,4],[5,6]),[1,2,0,0,0,0;0,0,3,4,0,0;0,0,0,0,5,6])
-%!assert(blkdiag([1,2],[3;4],[5,6]),[1,2,0,0,0;0,0,3,0,0;0,0,4,0,0;0,0,0,5,6])
-%!assert(blkdiag([1,2;3,4],[5,6,7]),[1,2,0,0,0;3,4,0,0,0;0,0,5,6,7])
+%!assert (blkdiag (1,ones (2),1), [1,0,0,0;0,1,1,0;0,1,1,0;0,0,0,1])
+%!assert (blkdiag ([1,2],[3,4],[5,6]), [1,2,0,0,0,0;0,0,3,4,0,0;0,0,0,0,5,6])
+%!assert (blkdiag ([1,2],[3;4],[5,6]), [1,2,0,0,0;0,0,3,0,0;0,0,4,0,0;0,0,0,5,6])
+%!assert (blkdiag ([1,2;3,4],[5,6,7]), [1,2,0,0,0;3,4,0,0,0;0,0,5,6,7])
 ## tests involving empty matrices
-%!assert(blkdiag([],[],[]),[])
-%!assert(blkdiag([],[1,2;3,4],[],5,[]),[1,2,0;3,4,0;0,0,5])
-%!assert(blkdiag(zeros(1,0,1),[1,2,3],1,0,5,zeros(0,1,1)),[0,0,0,0,0,0,0;1,2,3,0,0,0,0;0,0,0,1,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,5,0]);
+%!assert (blkdiag ([],[],[]), [])
+%!assert (blkdiag ([],[1,2;3,4],[],5,[]), [1,2,0;3,4,0;0,0,5])
+%!assert (blkdiag (zeros (1,0,1),[1,2,3],1,0,5,zeros (0,1,1)), [0,0,0,0,0,0,0;1,2,3,0,0,0,0;0,0,0,1,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,5,0]);
 ## tests involving sparse matrices
-%!assert (blkdiag (sparse([1,2;3,4]),[5,6;7,8]), sparse([1,2,0,0;3,4,0,0;0,0,5,6;0,0,7,8]))
-%!assert (blkdiag (sparse([1,2;3,4]),[5,6]), sparse([1,2,0,0;3,4,0,0;0,0,5,6]))
+%!assert (blkdiag (sparse ([1,2;3,4]),[5,6;7,8]), sparse ([1,2,0,0;3,4,0,0;0,0,5,6;0,0,7,8]))
+%!assert (blkdiag (sparse ([1,2;3,4]),[5,6]), sparse ([1,2,0,0;3,4,0,0;0,0,5,6]))
 # sanity checks
 %!test
 %! A = rand (round (rand (1, 2) * 10));
 %! assert (blkdiag (A), A);
+
--- a/scripts/general/cart2pol.m
+++ b/scripts/general/cart2pol.m
@@ -81,6 +81,7 @@
 
 endfunction
 
+
 %!test
 %! x = [0, 1, 2];
 %! y = 0;
@@ -92,16 +93,16 @@
 %! x = [0, 1, 2];
 %! y = [0, 1, 2];
 %! [t, r] = cart2pol (x, y);
-%! assert (t, [0, pi/4, pi/4], sqrt(eps));
-%! assert (r, sqrt(2)*[0, 1, 2], sqrt(eps));
+%! assert (t, [0, pi/4, pi/4], sqrt (eps));
+%! assert (r, sqrt (2)*[0, 1, 2], sqrt (eps));
 
 %!test
 %! x = [0, 1, 2];
 %! y = [0, 1, 2];
 %! z = [0, 1, 2];
 %! [t, r, z2] = cart2pol (x, y, z);
-%! assert (t, [0, pi/4, pi/4], sqrt(eps));
-%! assert (r, sqrt(2)*[0, 1, 2], sqrt(eps));
+%! assert (t, [0, pi/4, pi/4], sqrt (eps));
+%! assert (r, sqrt (2)*[0, 1, 2], sqrt (eps));
 %! assert (z, z2);
 
 %!test
@@ -134,10 +135,10 @@
 %!test
 %! C = [0, 0; 1, 1; 2, 2];
 %! P = [0, 0; pi/4, sqrt(2); pi/4, 2*sqrt(2)];
-%! assert (cart2pol (C), P, sqrt(eps));
+%! assert (cart2pol (C), P, sqrt (eps));
 
 %!test
 %! C = [0, 0, 0; 1, 1, 1; 2, 2, 2];
 %! P = [0, 0, 0; pi/4, sqrt(2), 1; pi/4, 2*sqrt(2), 2];
-%! assert (cart2pol (C), P, sqrt(eps));
+%! assert (cart2pol (C), P, sqrt (eps));
 
--- a/scripts/general/cart2sph.m
+++ b/scripts/general/cart2sph.m
@@ -71,14 +71,15 @@
 
 endfunction
 
+
 %!test
 %! x = [0, 1, 2];
 %! y = [0, 1, 2];
 %! z = [0, 1, 2];
 %! [t, p, r] = cart2sph (x, y, z);
 %! assert (t, [0, pi/4, pi/4], eps);
-%! assert (p, [0, 1, 1]*atan(sqrt(0.5)), eps);
-%! assert (r, [0, 1, 2]*sqrt(3), eps);
+%! assert (p, [0, 1, 1]*atan (sqrt (0.5)), eps);
+%! assert (r, [0, 1, 2]*sqrt (3), eps);
 
 %!test
 %! x = 0;
@@ -87,7 +88,7 @@
 %! [t, p, r] = cart2sph (x, y, z);
 %! assert (t, [0, 1, 1] * pi/2, eps);
 %! assert (p, [0, 1, 1] * pi/4, eps);
-%! assert (r, [0, 1, 2] * sqrt(2), eps);
+%! assert (r, [0, 1, 2] * sqrt (2), eps);
 
 %!test
 %! x = [0, 1, 2];
@@ -96,7 +97,7 @@
 %! [t, p, r] = cart2sph (x, y, z);
 %! assert (t, [0, 0, 0]);
 %! assert (p, [0, 1, 1] * pi/4);
-%! assert (r, [0, 1, 2] * sqrt(2));
+%! assert (r, [0, 1, 2] * sqrt (2));
 
 %!test
 %! x = [0, 1, 2];
@@ -105,9 +106,10 @@
 %! [t, p, r] = cart2sph (x, y, z);
 %! assert (t, [0, 1, 1] * pi/4);
 %! assert (p, [0, 0, 0]);
-%! assert (r, [0, 1, 2] * sqrt(2));
+%! assert (r, [0, 1, 2] * sqrt (2));
 
 %!test
 %! C = [0, 0, 0; 1, 0, 1; 2, 0, 2];
 %! S = [0, 0, 0; 0, pi/4, sqrt(2); 0, pi/4, 2*sqrt(2)];
-%! assert (cart2sph(C), S, eps);
+%! assert (cart2sph (C), S, eps);
+
--- a/scripts/general/cell2mat.m
+++ b/scripts/general/cell2mat.m
@@ -78,27 +78,28 @@
 
 endfunction
 
-## Tests
-%!shared C, D, E, F
+
+%!demo
+%! C = {[1], [2 3 4]; [5; 9], [6 7 8; 10 11 12]};
+%! cell2mat (C)
+
+%!assert (cell2mat ({}), []);
+%!test
 %! C = {[1], [2 3 4]; [5; 9], [6 7 8; 10 11 12]};
 %! D = C; D(:,:,2) = C;
 %! E = [1 2 3 4; 5 6 7 8; 9 10 11 12];
 %! F = E; F(:,:,2) = E;
-%!assert (cell2mat (C), E);
-%!assert (cell2mat (D), F);
+%! assert (cell2mat (C), E);
+%! assert (cell2mat (D), F);
 %!test
 %! m = rand (10) + i * rand (10);
 %! c = mat2cell (m, [1 2 3 4], [4 3 2 1]);
-%! assert (cell2mat (c), m)
+%! assert (cell2mat (c), m);
 %!test
 %! m = int8 (256*rand (4, 5, 6, 7, 8));
 %! c = mat2cell (m, [1 2 1], [1 2 2], [3 1 1 1], [4 1 2], [3 1 4]);
-%! assert (cell2mat (c), m)
+%! assert (cell2mat (c), m);
 %!test
 %! m = {1, 2, 3};
 %! assert (cell2mat (mat2cell (m, 1, [1 1 1])), m);
-%!assert (cell2mat ({}), []);
-## Demos
-%!demo
-%! C = {[1], [2 3 4]; [5; 9], [6 7 8; 10 11 12]};
-%! cell2mat (C)
+
--- a/scripts/general/celldisp.m
+++ b/scripts/general/celldisp.m
@@ -71,17 +71,19 @@
   if (sum (dv != 1) > 1)
     c = cell (size (dv));
     [c{:}] = ind2sub (dv, i);
-    s = sprintf("%i,", c{:});
+    s = sprintf ("%i,", c{:});
     s(end) = [];
   else
-    s = sprintf("%i", i);
+    s = sprintf ("%i", i);
   endif
 endfunction
 
+
 %!demo
 %! c = {1, 2, {31, 32}};
-%! celldisp(c, "b")
+%! celldisp (c, "b")
 
-%!error celldisp ();
-%!error celldisp ({}, "name", 1);
-%!error celldisp (1);
+%!error celldisp ()
+%!error celldisp ({}, "name", 1)
+%!error celldisp (1)
+
--- a/scripts/general/chop.m
+++ b/scripts/general/chop.m
@@ -78,3 +78,4 @@
 %!assert (chop (-e, 4, 7), -2.716)
 %!assert (chop (hilb (3), 3), [1,.5,.333;.5,.333,.25;.333,.25,.2])
 %!assert (chop (hilb (3), 2, 7), [.7,.49,.35;.49,.35,.28;.35,.28,.21], 2*eps)
+
--- a/scripts/general/circshift.m
+++ b/scripts/general/circshift.m
@@ -98,7 +98,7 @@
 %!error circshift ()
 %!error circshift (1)
 %!error circshift (1,2,3)
-%!error circshift (1, ones(2,2))
+%!error circshift (1, ones (2,2))
 %!error circshift (1, [1 2 3])
 %!error circshift (1, 1.5)
 
--- a/scripts/general/colon.m
+++ b/scripts/general/colon.m
@@ -35,10 +35,11 @@
 
 function r = colon (varargin)
   if (nargin != 0)
-    error ("colon: not defined for class \"%s\"", class(varargin{1}));
+    error ('colon: not defined for class "%s"', class (varargin{1}));
   endif
 endfunction
 
+
 %!error colon (1)
 
 ## FIXME -- what does colon () mean since it doesn't set a return value?
--- a/scripts/general/common_size.m
+++ b/scripts/general/common_size.m
@@ -79,7 +79,6 @@
   endif
 endfunction
 
-%!error common_size ();
 
 %!test
 %! m = [1,2;3,4];
@@ -88,3 +87,6 @@
 %! assert (a, m);
 %! assert (b, [3,3;3,3]);
 %! assert (c, [5,5;5,5]);
+
+%!error common_size ()
+
--- a/scripts/general/cplxpair.m
+++ b/scripts/general/cplxpair.m
@@ -44,15 +44,15 @@
 ## @end deftypefn
 
 ## FIXME: subsort returned pairs by imaginary magnitude
-## FIXME: Why doesn't exp(2i*pi*[0:4]'/5) produce exact conjugates. Does
-## FIXME:    it in Matlab?  The reason is that complex pairs are supposed
-## FIXME:    to be exact conjugates, and not rely on a tolerance test.
+## FIXME: Why doesn't exp (2i*pi*[0:4]'/5) produce exact conjugates.  Does
+## FIXME: it in Matlab?  The reason is that complex pairs are supposed
+## FIXME: to be exact conjugates, and not rely on a tolerance test.
 
 ## 2006-05-12 David Bateman - Modified for NDArrays
 
 function y = cplxpair (z, tol, dim)
 
-  if nargin < 1 || nargin > 3
+  if (nargin < 1 || nargin > 3)
     print_usage ();
   endif
 
@@ -82,7 +82,7 @@
       dim = 1;
     endif
   else
-    dim = floor(dim);
+    dim = floor (dim);
     if (dim < 1 || dim > nd)
       error ("cplxpair: invalid dimension along which to sort");
     endif
@@ -105,7 +105,7 @@
   if (isa (z, "single"))
     cls = "single";
   endif
-  [idxi, idxj] = find (abs (imag (z)) ./ (abs (z) + realmin(cls)) < tol);
+  [idxi, idxj] = find (abs (imag (z)) ./ (abs (z) + realmin (cls)) < tol);
   q = sparse (idxi, idxj, 1, n, m);
   nr = sum (q, 1);
   [q, idx] = sort (q, 1);
@@ -139,26 +139,28 @@
 
 endfunction
 
+
 %!demo
 %! [ cplxpair(exp(2i*pi*[0:4]'/5)), exp(2i*pi*[3; 2; 4; 1; 0]/5) ]
 
-%!assert (isempty(cplxpair([])));
-%!assert (cplxpair(1), 1)
-%!assert (cplxpair([1+1i, 1-1i]), [1-1i, 1+1i])
-%!assert (cplxpair([1+1i, 1+1i, 1, 1-1i, 1-1i, 2]), \
-%!        [1-1i, 1+1i, 1-1i, 1+1i, 1, 2])
-%!assert (cplxpair([1+1i; 1+1i; 1; 1-1i; 1-1i; 2]), \
-%!        [1-1i; 1+1i; 1-1i; 1+1i; 1; 2])
-%!assert (cplxpair([0, 1, 2]), [0, 1, 2]);
+%!assert (isempty (cplxpair ([])))
+%!assert (cplxpair (1), 1)
+%!assert (cplxpair ([1+1i, 1-1i]), [1-1i, 1+1i])
+%!assert (cplxpair ([1+1i, 1+1i, 1, 1-1i, 1-1i, 2]), ...
+%!                  [1-1i, 1+1i, 1-1i, 1+1i, 1, 2])
+%!assert (cplxpair ([1+1i; 1+1i; 1; 1-1i; 1-1i; 2]), ...
+%!                  [1-1i; 1+1i; 1-1i; 1+1i; 1; 2])
+%!assert (cplxpair ([0, 1, 2]), [0, 1, 2])
 
 %!shared z
-%! z=exp(2i*pi*[4; 3; 5; 2; 6; 1; 0]/7);
-%!assert (cplxpair(z(randperm(7))), z);
-%!assert (cplxpair(z(randperm(7))), z);
-%!assert (cplxpair(z(randperm(7))), z);
-%!assert (cplxpair([z(randperm(7)),z(randperm(7))]),[z,z])
-%!assert (cplxpair([z(randperm(7)),z(randperm(7))],[],1),[z,z])
-%!assert (cplxpair([z(randperm(7)).';z(randperm(7)).'],[],2),[z.';z.'])
+%! z = exp (2i*pi*[4; 3; 5; 2; 6; 1; 0]/7);
+%!assert (cplxpair (z(randperm (7))), z)
+%!assert (cplxpair (z(randperm (7))), z)
+%!assert (cplxpair (z(randperm (7))), z)
+%!assert (cplxpair ([z(randperm(7)),z(randperm(7))]), [z,z])
+%!assert (cplxpair ([z(randperm(7)),z(randperm(7))],[],1), [z,z])
+%!assert (cplxpair ([z(randperm(7)).';z(randperm(7)).'],[],2), [z.';z.'])
 
 %!## tolerance test
-%!assert (cplxpair([1i, -1i, 1+(1i*eps)],2*eps), [-1i, 1i, 1+(1i*eps)]);
+%!assert (cplxpair ([1i, -1i, 1+(1i*eps)],2*eps), [-1i, 1i, 1+(1i*eps)])
+ 
--- a/scripts/general/cumtrapz.m
+++ b/scripts/general/cumtrapz.m
@@ -117,18 +117,18 @@
 %! x1 = [0,0,0;2,2,2];
 %! x2 = [0,2,4;0,2,4];
 %! y = [1,2,3;4,5,6];
-%!assert (cumtrapz(y), [0,0,0;2.5,3.5,4.5])
-%!assert (cumtrapz(x1,y), [0,0,0;5,7,9])
-%!assert (cumtrapz(y,1), [0,0,0;2.5,3.5,4.5])
-%!assert (cumtrapz(x1,y,1), [0,0,0;5,7,9])
-%!assert (cumtrapz(y,2), [0,1.5,4;0,4.5,10])
-%!assert (cumtrapz(x2,y,2), [0,3,8;0,9,20])
+%!assert (cumtrapz (y), [0,0,0;2.5,3.5,4.5])
+%!assert (cumtrapz (x1,y), [0,0,0;5,7,9])
+%!assert (cumtrapz (y,1), [0,0,0;2.5,3.5,4.5])
+%!assert (cumtrapz (x1,y,1), [0,0,0;5,7,9])
+%!assert (cumtrapz (y,2), [0,1.5,4;0,4.5,10])
+%!assert (cumtrapz (x2,y,2), [0,3,8;0,9,20])
 %% Test ND-array implementation
 %!shared x1,x2,y
 %! x1 = 1:3;
 %! x2 = reshape ([0,2,4;0,2,4], [1 2 3]);
 %! y = reshape ([1,2,3;4,5,6], [1 2 3]);
-%!assert (cumtrapz(y,3), reshape([0,1.5,4;0,4.5,10],[1 2 3]))
-%!assert (cumtrapz(x1,y,3), reshape([0,1.5,4;0,4.5,10],[1 2 3]))
-%!assert (cumtrapz(x2,y,3), reshape([0,3,8;0,9,20],[1 2 3]))
+%!assert (cumtrapz (y,3), reshape ([0,1.5,4;0,4.5,10],[1 2 3]))
+%!assert (cumtrapz (x1,y,3), reshape ([0,1.5,4;0,4.5,10],[1 2 3]))
+%!assert (cumtrapz (x2,y,3), reshape ([0,3,8;0,9,20],[1 2 3]))
 
--- a/scripts/general/curl.m
+++ b/scripts/general/curl.m
@@ -71,7 +71,7 @@
     dy = varargin{2}(:,1,1)(:);
     dz = varargin{3}(1,1,:)(:);
   else
-    print_usage();
+    print_usage ();
   endif
 
   if ((nargin == 4) || (nargin == 2))
@@ -129,14 +129,16 @@
 
 endfunction
 
+
 %!test
-%! [X,Y]=meshgrid(-20:20,-22:22);
-%! av = curl(2*(X-Y),Y);
-%! assert(all(av(:)==1));
-%! [cz,av] = curl(2*(X-Y),Y);
-%! assert(all(cz(:)==2));
-%! assert(all(av(:)==1));
-%! [cz,av] = curl(X/2,Y/2,2*(X-Y),Y);
-%! assert(all(cz(:)==4));
-%! assert(all(av(:)==2));
-%! assert(size_equal(X,Y,cz,av));
+%! [X,Y] = meshgrid (-20:20,-22:22);
+%! av = curl (2*(X-Y), Y);
+%! assert (all (av(:) == 1));
+%! [cz,av] = curl (2*(X-Y), Y);
+%! assert (all (cz(:) == 2));
+%! assert (all (av(:) == 1));
+%! [cz,av] = curl (X/2, Y/2, 2*(X-Y), Y);
+%! assert (all (cz(:) == 4));
+%! assert (all (av(:) == 2));
+%! assert (size_equal (X,Y,cz,av));
+
--- a/scripts/general/dblquad.m
+++ b/scripts/general/dblquad.m
@@ -67,16 +67,17 @@
 endfunction
 
 function q = __dblquad_inner__ (y, f, xa, xb, tol, quadf, varargin)
-  q = zeros (size(y));
+  q = zeros (size (y));
   for i = 1 : length (y)
     q(i) = feval (quadf, @(x) f(x, y(i), varargin{:}), xa, xb, tol);
   endfor
 endfunction
 
+
 %% Nasty integrand to show quadcc off
-%!assert (dblquad (@(x,y) 1 ./ (x+y), 0, 1, 0, 1), 2*log(2), 1e-6)
+%!assert (dblquad (@(x,y) 1 ./ (x+y), 0, 1, 0, 1), 2*log (2), 1e-6)
 
-%!assert (dblquad (@(x,y) exp(-x.^2 - y.^2) , -1, 1, -1, 1, 1e-6, @quadgk), pi * erf(1).^2, 1e-6)
-%!assert (dblquad (@(x,y) exp(-x.^2 - y.^2) , -1, 1, -1, 1, 1e-6, @quadl), pi * erf(1).^2, 1e-6)
-%!assert (dblquad (@(x,y) exp(-x.^2 - y.^2) , -1, 1, -1, 1, 1e-6, @quadv), pi * erf(1).^2, 1e-6)
+%!assert (dblquad (@(x,y) exp (-x.^2 - y.^2) , -1, 1, -1, 1, 1e-6, @quadgk), pi * erf (1).^2, 1e-6)
+%!assert (dblquad (@(x,y) exp (-x.^2 - y.^2) , -1, 1, -1, 1, 1e-6, @quadl), pi * erf (1).^2, 1e-6)
+%!assert (dblquad (@(x,y) exp (-x.^2 - y.^2) , -1, 1, -1, 1, 1e-6, @quadv), pi * erf (1).^2, 1e-6)
 
--- a/scripts/general/deal.m
+++ b/scripts/general/deal.m
@@ -73,11 +73,13 @@
 
 endfunction
 
+
 %!test
-%! [a,b]=deal(1,2);
-%! assert(a,1);
-%! assert(b,2);
+%! [a,b] = deal (1,2);
+%! assert (a, 1);
+%! assert (b, 2);
 %!test
-%! [a,b]=deal(1);
-%! assert(a,1);
-%! assert(b,1);
+%! [a,b] = deal (1);
+%! assert (a, 1);
+%! assert (b, 1);
+
--- a/scripts/general/divergence.m
+++ b/scripts/general/divergence.m
@@ -69,7 +69,7 @@
     dy = varargin{2}(:,1,1)(:);
     dz = varargin{3}(1,1,:)(:);
   else
-    print_usage();
+    print_usage ();
   endif
 
   if ((nargin == 4) || (nargin == 2))
@@ -81,8 +81,8 @@
       error ("divergence: size of dx and dy must match the respective dimension of X and Y");
     endif
 
-    retval = gradient(varargin{fidx}, dx, dy);
-    retval += gradient(varargin{fidx + 1}.', dy, dx).';
+    retval = gradient (varargin{fidx}, dx, dy);
+    retval += gradient (varargin{fidx + 1}.', dy, dx).';
 
   elseif ((nargin == 6) || (nargin == 3))
     if (!size_equal (varargin{fidx},varargin{fidx + 1},varargin{fidx + 2}))
@@ -105,8 +105,10 @@
 
 endfunction
 
+
 %!test
-%! [X,Y]=meshgrid(-20:20,-22:22);
-%! div = divergence(X-Y,Y);
-%! assert(all(div(:)==2));
-%! assert(size_equal(X,Y,div));
+%! [X,Y] = meshgrid (-20:20,-22:22);
+%! div = divergence (X-Y,Y);
+%! assert (all (div(:) == 2));
+%! assert (size_equal (X,Y,div));
+
--- a/scripts/general/flipdim.m
+++ b/scripts/general/flipdim.m
@@ -57,11 +57,13 @@
 
 endfunction
 
-%!error flipdim ();
-%!error flipdim (1, 2, 3);
 
-%!assert (flipdim ([1,2;3,4]), flipdim ([1,2 ; 3,4], 1));
-%!assert (flipdim ([1,2;3,4], 2), [2,1;4,3]);
-%!assert (flipdim ([1,2;3,4], 3), [1,2;3,4]);
+%!assert (flipdim ([1,2;3,4]), flipdim ([1,2 ; 3,4], 1))
+%!assert (flipdim ([1,2;3,4], 2), [2,1;4,3])
+%!assert (flipdim ([1,2;3,4], 3), [1,2;3,4])
 
 ## FIXME -- we need tests for multidimensional arrays.
+
+%!error flipdim ()
+%!error flipdim (1, 2, 3)
+
--- a/scripts/general/fliplr.m
+++ b/scripts/general/fliplr.m
@@ -52,11 +52,11 @@
 
 endfunction
 
-%!assert((fliplr ([1, 2; 3, 4]) == [2, 1; 4, 3]
-%! && fliplr ([1, 2; 3, 4; 5, 6]) == [2, 1; 4, 3; 6, 5]
-%! && fliplr ([1, 2, 3; 4, 5, 6]) == [3, 2, 1; 6, 5, 4]));
 
-%!error fliplr();
+%!assert (fliplr ([1, 2; 3, 4]), [2, 1; 4, 3])
+%!assert (fliplr ([1, 2; 3, 4; 5, 6]), [2, 1; 4, 3; 6, 5])
+%!assert (fliplr ([1, 2, 3; 4, 5, 6]), [3, 2, 1; 6, 5, 4])
 
-%!error fliplr (1, 2);
+%!error fliplr()
+%!error fliplr (1, 2)
 
--- a/scripts/general/flipud.m
+++ b/scripts/general/flipud.m
@@ -52,11 +52,11 @@
 
 endfunction
 
-%!assert((flipud ([1, 2; 3, 4]) == [3, 4; 1, 2]
-%! && flipud ([1, 2; 3, 4; 5, 6]) == [5, 6; 3, 4; 1, 2]
-%! && flipud ([1, 2, 3; 4, 5, 6]) == [4, 5, 6; 1, 2, 3]));
 
-%!error flipud ();
+%!assert (flipud ([1, 2; 3, 4]), [3, 4; 1, 2])
+%!assert (flipud ([1, 2; 3, 4; 5, 6]), [5, 6; 3, 4; 1, 2])
+%!assert (flipud ([1, 2, 3; 4, 5, 6]), [4, 5, 6; 1, 2, 3])
 
-%!error flipud (1, 2);
+%!error flipud ()
+%!error flipud (1, 2)
 
--- a/scripts/general/genvarname.m
+++ b/scripts/general/genvarname.m
@@ -158,45 +158,45 @@
     endif
     varname(i) = str(i);
     idx = 0;
-    while excluded
+    while (excluded)
       idx++;
-      varname{i} = sprintf("%s%d", str{i}, idx);
+      varname{i} = sprintf ("%s%d", str{i}, idx);
       excluded = any (strcmp (varname{i}, exclusions));
     endwhile
     exclusions(end+1) = varname(i);
   endfor
 
-  if strinput
+  if (strinput)
     varname = varname{1};
   endif
 
 endfunction
 
-## Tests
+
 ## a single argument
-%!assert(genvarname("a"), "a")
+%!assert (genvarname ("a"), "a")
 ## a single argument with a non-conflicting exception
-%!assert(genvarname("a", "b"), "a")
+%!assert (genvarname ("a", "b"), "a")
 ## a single argument with a conflicting exception
-%!assert(genvarname("a", "a"), "a1")
+%!assert (genvarname ("a", "a"), "a1")
 ## a single argument as a cell
-%!assert(genvarname({"a"}), {"a"})
-%!assert(genvarname({"a"}, "b"), {"a"})
-%!assert(genvarname({"a"}, {"b"}), {"a"})
-%!assert(genvarname({"a"}, "a"), {"a1"})
-%!assert(genvarname({"a"}, {"a"}), {"a1"})
+%!assert (genvarname ({"a"}), {"a"})
+%!assert (genvarname ({"a"}, "b"), {"a"})
+%!assert (genvarname ({"a"}, {"b"}), {"a"})
+%!assert (genvarname ({"a"}, "a"), {"a1"})
+%!assert (genvarname ({"a"}, {"a"}), {"a1"})
 ## Test different arguments
 ## orientation
-%!assert(genvarname({"a" "b"}), {"a" "b"})
-%!assert(genvarname({"a";"b"}), {"a";"b"})
-%!assert(genvarname({"a" "a"}), {"a" "a1"})
-%!assert(genvarname({"a" "b";"c" "d"}), {"a" "b";"c" "d"})
-%!assert(genvarname({"a" "a" "a";"a" "a" "a"}), {"a" "a2" "a4";"a1" "a3" "a5"})
+%!assert (genvarname ({"a" "b"}), {"a" "b"})
+%!assert (genvarname ({"a";"b"}), {"a";"b"})
+%!assert (genvarname ({"a" "a"}), {"a" "a1"})
+%!assert (genvarname ({"a" "b";"c" "d"}), {"a" "b";"c" "d"})
+%!assert (genvarname ({"a" "a" "a";"a" "a" "a"}), {"a" "a2" "a4";"a1" "a3" "a5"})
 ## more than one repetition
-%!assert(genvarname({"a" "a" "a"}), {"a" "a1" "a2"})
-%!assert(genvarname({"a" "a" "a"}, {"a" "a1" "a2"}), {"a3" "a4" "a5"})
+%!assert (genvarname ({"a" "a" "a"}), {"a" "a1" "a2"})
+%!assert (genvarname ({"a" "a" "a"}, {"a" "a1" "a2"}), {"a3" "a4" "a5"})
 ## more than one repetition not in order
-%!assert(genvarname({"a" "b" "a" "b" "a"}), {"a" "b" "a1" "b1" "a2"})
+%!assert (genvarname ({"a" "b" "a" "b" "a"}), {"a" "b" "a1" "b1" "a2"})
 ## Variable name munging
 %!assert (genvarname ("__x__"), "_x_")
 %!assert (genvarname ("123456789"), "_123456789")
@@ -206,3 +206,4 @@
 %!assert (genvarname ({"", "", ""}), {"x", "x1", "x2"})
 %!assert (genvarname ("if"), "_if")
 %!assert (genvarname ({"if", "if", "if"}), {"_if", "_if1", "_if2"})
+
--- a/scripts/general/gradient.m
+++ b/scripts/general/gradient.m
@@ -70,12 +70,12 @@
     print_usage ();
   endif
 
-  nargout_with_ans = max(1,nargout);
+  nargout_with_ans = max (1,nargout);
   if (ismatrix (m))
     [varargout{1:nargout_with_ans}] = matrix_gradient (m, varargin{:});
   elseif (isa (m, "function_handle"))
     [varargout{1:nargout_with_ans}] = handle_gradient (m, varargin{:});
-  elseif (ischar(m))
+  elseif (ischar (m))
     [varargout{1:nargout_with_ans}] = handle_gradient (str2func (m), varargin{:});
   else
     error ("gradient: first input must be an array or a function");
@@ -87,13 +87,13 @@
   transposed = false;
   if (isvector (m))
     ## make a row vector.
-    transposed = (size (m, 2) == 1);
+    transposed = (columns (m) == 1);
     m = m(:).';
   endif
 
   nd = ndims (m);
   sz = size (m);
-  if (length(sz) > 1)
+  if (length (sz) > 1)
     tmp = sz(1); sz(1) = sz(2); sz(2) = tmp;
   endif
 
@@ -220,6 +220,7 @@
   endfor
 endfunction
 
+
 %!test
 %! data = [1, 2, 4, 2];
 %! dx = gradient (data);
@@ -228,63 +229,63 @@
 %! assert (dx, [1, 3/2, 0, -2]);
 %! assert (dx2, [4, 6, 0, -8]);
 %! assert (dx3, [4, 4, 0, -1]);
-%! assert (size_equal(data, dx));
+%! assert (size_equal (data, dx));
 
 %!test
 %! [Y,X,Z,U] = ndgrid (2:2:8,1:5,4:4:12,3:5:30);
 %! [dX,dY,dZ,dU] = gradient (X);
-%! assert (all(dX(:)==1));
-%! assert (all(dY(:)==0));
-%! assert (all(dZ(:)==0));
-%! assert (all(dU(:)==0));
+%! assert (all (dX(:) == 1));
+%! assert (all (dY(:) == 0));
+%! assert (all (dZ(:) == 0));
+%! assert (all (dU(:) == 0));
 %! [dX,dY,dZ,dU] = gradient (Y);
-%! assert (all(dX(:)==0));
-%! assert (all(dY(:)==2));
-%! assert (all(dZ(:)==0));
-%! assert (all(dU(:)==0));
+%! assert (all (dX(:) == 0));
+%! assert (all (dY(:) == 2));
+%! assert (all (dZ(:) == 0));
+%! assert (all (dU(:) == 0));
 %! [dX,dY,dZ,dU] = gradient (Z);
-%! assert (all(dX(:)==0));
-%! assert (all(dY(:)==0));
-%! assert (all(dZ(:)==4));
-%! assert (all(dU(:)==0));
+%! assert (all (dX(:) == 0));
+%! assert (all (dY(:) == 0));
+%! assert (all (dZ(:) == 4));
+%! assert (all (dU(:) == 0));
 %! [dX,dY,dZ,dU] = gradient (U);
-%! assert (all(dX(:)==0));
-%! assert (all(dY(:)==0));
-%! assert (all(dZ(:)==0));
-%! assert (all(dU(:)==5));
-%! assert (size_equal(dX, dY, dZ, dU, X, Y, Z, U));
+%! assert (all (dX(:) == 0));
+%! assert (all (dY(:) == 0));
+%! assert (all (dZ(:) == 0));
+%! assert (all (dU(:) == 5));
+%! assert (size_equal (dX, dY, dZ, dU, X, Y, Z, U));
 %! [dX,dY,dZ,dU] = gradient (U, 5.0);
-%! assert (all(dU(:)==1));
+%! assert (all (dU(:) == 1));
 %! [dX,dY,dZ,dU] = gradient (U, 1.0, 2.0, 3.0, 2.5);
-%! assert (all(dU(:)==2));
+%! assert (all (dU(:) == 2));
 
 %!test
 %! [Y,X,Z,U] = ndgrid (2:2:8,1:5,4:4:12,3:5:30);
 %! [dX,dY,dZ,dU] = gradient (X+j*X);
-%! assert (all(dX(:)==1+1j));
-%! assert (all(dY(:)==0));
-%! assert (all(dZ(:)==0));
-%! assert (all(dU(:)==0));
+%! assert (all (dX(:) == 1+1j));
+%! assert (all (dY(:) == 0));
+%! assert (all (dZ(:) == 0));
+%! assert (all (dU(:) == 0));
 %! [dX,dY,dZ,dU] = gradient (Y-j*Y);
-%! assert (all(dX(:)==0));
-%! assert (all(dY(:)==2-j*2));
-%! assert (all(dZ(:)==0));
-%! assert (all(dU(:)==0));
+%! assert (all (dX(:) == 0));
+%! assert (all (dY(:) == 2-j*2));
+%! assert (all (dZ(:) == 0));
+%! assert (all (dU(:) == 0));
 %! [dX,dY,dZ,dU] = gradient (Z+j*1);
-%! assert (all(dX(:)==0));
-%! assert (all(dY(:)==0));
-%! assert (all(dZ(:)==4));
-%! assert (all(dU(:)==0));
+%! assert (all (dX(:) == 0));
+%! assert (all (dY(:) == 0));
+%! assert (all (dZ(:) == 4));
+%! assert (all (dU(:) == 0));
 %! [dX,dY,dZ,dU] = gradient (U-j*1);
-%! assert (all(dX(:)==0));
-%! assert (all(dY(:)==0));
-%! assert (all(dZ(:)==0));
-%! assert (all(dU(:)==5));
-%! assert (size_equal(dX, dY, dZ, dU, X, Y, Z, U));
+%! assert (all (dX(:) == 0));
+%! assert (all (dY(:) == 0));
+%! assert (all (dZ(:) == 0));
+%! assert (all (dU(:) == 5));
+%! assert (size_equal (dX, dY, dZ, dU, X, Y, Z, U));
 %! [dX,dY,dZ,dU] = gradient (U, 5.0);
-%! assert (all(dU(:)==1));
+%! assert (all (dU(:) == 1));
 %! [dX,dY,dZ,dU] = gradient (U, 1.0, 2.0, 3.0, 2.5);
-%! assert (all(dU(:)==2));
+%! assert (all (dU(:) == 2));
 
 %!test
 %! x = 0:10;
--- a/scripts/general/idivide.m
+++ b/scripts/general/idivide.m
@@ -100,25 +100,27 @@
   endif
 endfunction
 
+
 %!shared a, af, b, bf
-%! a = int8(3);
+%! a = int8 (3);
 %! af = 3;
-%! b = int8([-4, 4]);
+%! b = int8 ([-4, 4]);
 %! bf = [-4, 4];
 
 %!assert (idivide (a, b), int8 ([0, 0]))
-%!assert (idivide (a, b, "floor"), int8([-1, 0]))
+%!assert (idivide (a, b, "floor"), int8 ([-1, 0]))
 %!assert (idivide (a, b, "ceil"), int8 ([0, 1]))
 %!assert (idivide (a, b, "round"), int8 ([-1, 1]))
 
 %!assert (idivide (af, b), int8 ([0, 0]))
-%!assert (idivide (af, b, "floor"), int8([-1, 0]))
+%!assert (idivide (af, b, "floor"), int8 ([-1, 0]))
 %!assert (idivide (af, b, "ceil"), int8 ([0, 1]))
 %!assert (idivide (af, b, "round"), int8 ([-1, 1]))
 
 %!assert (idivide (a, bf), int8 ([0, 0]))
-%!assert (idivide (a, bf, "floor"), int8([-1, 0]))
+%!assert (idivide (a, bf, "floor"), int8 ([-1, 0]))
 %!assert (idivide (a, bf, "ceil"), int8 ([0, 1]))
 %!assert (idivide (a, bf, "round"), int8 ([-1, 1]))
 
-%!error (idivide (uint8(1), int8(1)))
+%!error (idivide (uint8 (1), int8 (1)))
+
--- a/scripts/general/int2str.m
+++ b/scripts/general/int2str.m
@@ -32,7 +32,7 @@
 ##         4  5  6
 ##
 ## whos s
-##      @result{} s =
+##      @result{}
 ##       Attr Name        Size                     Bytes  Class
 ##       ==== ====        ====                     =====  =====
 ##            s           2x7                         14  char
@@ -57,8 +57,8 @@
     return;
   endif
 
-  n = round (real(n));
-  sz = size(n);
+  n = round (real (n));
+  sz = size (n);
   nd = ndims (n);
   nc = columns (n);
   if (nc > 1)
@@ -113,10 +113,12 @@
 
 endfunction
 
-%!assert (strcmp (int2str (-123), "-123") && strcmp (int2str (1.2), "1"));
-%!assert (all (int2str ([1, 2, 3; 4, 5, 6]) == ["1  2  3";"4  5  6"]));
-%!assert (int2str([]), "");
 
-%!error int2str ();
-%!error int2str (1, 2);
+%!assert (int2str (-123), "-123")
+%!assert (int2str (1.2), "1")
+%!assert (int2str ([1, 2, 3; 4, 5, 6]), ["1  2  3";"4  5  6"])
+%!assert (int2str ([]), "")
 
+%!error int2str ()
+%!error int2str (1, 2)
+
--- a/scripts/general/interp1.m
+++ b/scripts/general/interp1.m
@@ -22,7 +22,7 @@
 ## @deftypefnx {Function File} {@var{yi} =} interp1 (@var{y}, @var{xi})
 ## @deftypefnx {Function File} {@var{yi} =} interp1 (@dots{}, @var{method})
 ## @deftypefnx {Function File} {@var{yi} =} interp1 (@dots{}, @var{extrap})
-## @deftypefnx {Function File} {@var{pp} =} interp1 (@dots{}, 'pp')
+## @deftypefnx {Function File} {@var{pp} =} interp1 (@dots{}, "pp")
 ##
 ## One-dimensional interpolation.  Interpolate @var{y}, defined at the
 ## points @var{x}, at the points @var{xi}.  The sample points @var{x}
@@ -33,19 +33,19 @@
 ## Method is one of:
 ##
 ## @table @asis
-## @item 'nearest'
+## @item "nearest"
 ## Return the nearest neighbor.
 ##
-## @item 'linear'
+## @item "linear"
 ## Linear interpolation from nearest neighbors
 ##
-## @item 'pchip'
+## @item "pchip"
 ## Piecewise cubic Hermite interpolating polynomial
 ##
-## @item 'cubic'
+## @item "cubic"
 ## Cubic interpolation (same as @code{pchip})
 ##
-## @item 'spline'
+## @item "spline"
 ## Cubic spline interpolation---smooth first and second derivatives
 ## throughout the curve
 ## @end table
@@ -53,18 +53,18 @@
 ## Appending '*' to the start of the above method forces @code{interp1}
 ## to assume that @var{x} is uniformly spaced, and only @code{@var{x}
 ## (1)} and @code{@var{x} (2)} are referenced.  This is usually faster,
-## and is never slower.  The default method is 'linear'.
+## and is never slower.  The default method is "linear".
 ##
-## If @var{extrap} is the string 'extrap', then extrapolate values beyond
+## If @var{extrap} is the string "extrap", then extrapolate values beyond
 ## the endpoints.  If @var{extrap} is a number, replace values beyond the
 ## endpoints with that number.  If @var{extrap} is missing, assume NA.
 ##
-## If the string argument 'pp' is specified, then @var{xi} should not be
+## If the string argument "pp" is specified, then @var{xi} should not be
 ## supplied and @code{interp1} returns the piecewise polynomial that
 ## can later be used with @code{ppval} to evaluate the interpolation.
 ## There is an equivalence, such that @code{ppval (interp1 (@var{x},
-## @var{y}, @var{method}, 'pp'), @var{xi}) == interp1 (@var{x}, @var{y},
-## @var{xi}, @var{method}, 'extrap')}.
+## @var{y}, @var{method}, "pp"), @var{xi}) == interp1 (@var{x}, @var{y},
+## @var{xi}, @var{method}, "extrap")}.
 ##
 ## Duplicate points in @var{x} specify a discontinuous interpolant.  There
 ## should be at most 2 consecutive points with the same value.
@@ -141,7 +141,7 @@
   if (isempty (xi) && firstnumeric && ! ispp)
     xi = y;
     y = x;
-    x = 1:numel(y);
+    x = 1:numel (y);
   endif
 
   ## reshape matrices for convenience
@@ -204,7 +204,7 @@
     if (ispp)
       yi = pp;
     else
-      yi = ppval(pp, reshape (xi, szx));
+      yi = ppval (pp, reshape (xi, szx));
     endif
   case "linear"
     dy = diff (y);
@@ -225,7 +225,7 @@
     if (ispp)
       yi = pp;
     else
-      yi = ppval(pp, reshape (xi, szx));
+      yi = ppval (pp, reshape (xi, szx));
     endif
 
   case "*linear"
@@ -237,7 +237,7 @@
     if (ispp)
       yi = pp;
     else
-      yi = ppval(pp, reshape (xi, szx));
+      yi = ppval (pp, reshape (xi, szx));
     endif
 
   case {"pchip", "*pchip", "cubic", "*cubic"}
@@ -248,21 +248,29 @@
     if (ispp)
       y = shiftdim (reshape (y, szy), 1);
       yi = pchip (x, y);
+      yi.orient = "first";
     else
       y = shiftdim (y, 1);
       yi = pchip (x, y, reshape (xi, szx));
+      if (! isvector (y))
+        yi = shiftdim (yi, 1);
+      endif
     endif
   case {"spline", "*spline"}
     if (nx == 2 || starmethod)
-      x = linspace(x(1), x(nx), ny);
+      x = linspace (x(1), x(nx), ny);
     endif
 
     if (ispp)
       y = shiftdim (reshape (y, szy), 1);
       yi = spline (x, y);
+      yi.orient = "first";
     else
       y = shiftdim (y, 1);
       yi = spline (x, y, reshape (xi, szx));
+      if (! isvector (y))
+        yi = shiftdim (yi, 1);
+      endif
     endif
   otherwise
     error ("interp1: invalid method '%s'", method);
@@ -280,68 +288,63 @@
         yi(outliers) = extrap;
         yi = reshape (yi, szx);
       elseif (!isvector (yi))
-        if (strcmp (method, "pchip") || strcmp (method, "*pchip")
-          ||strcmp (method, "cubic") || strcmp (method, "*cubic")
-          ||strcmp (method, "spline") || strcmp (method, "*spline"))
-          yi(:, outliers) = extrap;
-          yi = shiftdim(yi, 1);
-        else
-          yi(outliers, :) = extrap;
-        endif
+        yi(outliers, :) = extrap;
       else
         yi(outliers.') = extrap;
       endif
     endif
-  else
-    yi.orient = "first";
   endif
 
 endfunction
 
+
 %!demo
-%! xf=0:0.05:10; yf = sin(2*pi*xf/5);
-%! xp=0:10;      yp = sin(2*pi*xp/5);
-%! lin=interp1(xp,yp,xf,"linear");
-%! spl=interp1(xp,yp,xf,"spline");
-%! cub=interp1(xp,yp,xf,"pchip");
-%! near=interp1(xp,yp,xf,"nearest");
-%! plot(xf,yf,"r",xf,near,"g",xf,lin,"b",xf,cub,"c",xf,spl,"m",xp,yp,"r*");
-%! legend ("original","nearest","linear","pchip","spline")
+%! clf;
+%! xf = 0:0.05:10;  yf = sin (2*pi*xf/5);
+%! xp = 0:10;       yp = sin (2*pi*xp/5);
+%! lin = interp1 (xp,yp,xf, "linear");
+%! spl = interp1 (xp,yp,xf, "spline");
+%! cub = interp1 (xp,yp,xf, "pchip");
+%! near= interp1 (xp,yp,xf, "nearest");
+%! plot (xf,yf,"r",xf,near,"g",xf,lin,"b",xf,cub,"c",xf,spl,"m",xp,yp,"r*");
+%! legend ("original", "nearest", "linear", "pchip", "spline");
 %! %--------------------------------------------------------
 %! % confirm that interpolated function matches the original
 
 %!demo
-%! xf=0:0.05:10; yf = sin(2*pi*xf/5);
-%! xp=0:10;      yp = sin(2*pi*xp/5);
-%! lin=interp1(xp,yp,xf,"*linear");
-%! spl=interp1(xp,yp,xf,"*spline");
-%! cub=interp1(xp,yp,xf,"*cubic");
-%! near=interp1(xp,yp,xf,"*nearest");
-%! plot(xf,yf,"r",xf,near,"g",xf,lin,"b",xf,cub,"c",xf,spl,"m",xp,yp,"r*");
-%! legend ("*original","*nearest","*linear","*cubic","*spline")
+%! clf;
+%! xf = 0:0.05:10;  yf = sin (2*pi*xf/5);
+%! xp = 0:10;       yp = sin (2*pi*xp/5);
+%! lin = interp1 (xp,yp,xf, "*linear");
+%! spl = interp1 (xp,yp,xf, "*spline");
+%! cub = interp1 (xp,yp,xf, "*cubic");
+%! near= interp1 (xp,yp,xf, "*nearest");
+%! plot (xf,yf,"r",xf,near,"g",xf,lin,"b",xf,cub,"c",xf,spl,"m",xp,yp,"r*");
+%! legend ("*original", "*nearest", "*linear", "*cubic", "*spline");
 %! %--------------------------------------------------------
 %! % confirm that interpolated function matches the original
 
 %!demo
+%! clf;
 %! t = 0 : 0.3 : pi; dt = t(2)-t(1);
 %! n = length (t); k = 100; dti = dt*n/k;
 %! ti = t(1) + [0 : k-1]*dti;
 %! y = sin (4*t + 0.3) .* cos (3*t - 0.1);
-%! ddyc = diff(diff(interp1(t,y,ti,'cubic'))./dti)./dti;
-%! ddys = diff(diff(interp1(t,y,ti,'spline'))./dti)./dti;
-%! ddyp = diff(diff(interp1(t,y,ti,'pchip'))./dti)./dti;
-%! plot (ti(2:end-1), ddyc,'g+',ti(2:end-1),ddys,'b*', ...
-%!       ti(2:end-1),ddyp,'c^');
-%! legend('cubic','spline','pchip');
-%! title("Second derivative of interpolated 'sin (4*t + 0.3) .* cos (3*t - 0.1)'");
+%! ddyc = diff (diff (interp1 (t,y,ti, "cubic")) ./dti)./dti;
+%! ddys = diff (diff (interp1 (t,y,ti, "spline"))./dti)./dti;
+%! ddyp = diff (diff (interp1 (t,y,ti, "pchip")) ./dti)./dti;
+%! plot (ti(2:end-1),ddyc,'g+', ti(2:end-1),ddys,'b*', ti(2:end-1),ddyp,'c^');
+%! legend ("cubic", "spline", "pchip");
+%! title ("Second derivative of interpolated 'sin (4*t + 0.3) .* cos (3*t - 0.1)'");
 
 %!demo
-%! xf=0:0.05:10; yf = sin(2*pi*xf/5) - (xf >= 5);
-%! xp=[0:.5:4.5,4.99,5:.5:10];      yp = sin(2*pi*xp/5) - (xp >= 5);
-%! lin=interp1(xp,yp,xf,"linear");
-%! near=interp1(xp,yp,xf,"nearest");
-%! plot(xf,yf,"r",xf,near,"g",xf,lin,"b",xp,yp,"r*");
-%! legend ("original","nearest","linear")
+%! clf;
+%! xf = 0:0.05:10;                yf = sin (2*pi*xf/5) - (xf >= 5);
+%! xp = [0:.5:4.5,4.99,5:.5:10];  yp = sin (2*pi*xp/5) - (xp >= 5);
+%! lin = interp1 (xp,yp,xf, "linear");
+%! near= interp1 (xp,yp,xf, "nearest");
+%! plot (xf,yf,"r", xf,near,"g", xf,lin,"b", xp,yp,"r*");
+%! legend ("original", "nearest", "linear");
 %! %--------------------------------------------------------
 %! % confirm that interpolated function matches the original
 
@@ -349,218 +352,224 @@
 
 ## For each type of interpolated test, confirm that the interpolated
 ## value at the knots match the values at the knots.  Points away
-## from the knots are requested, but only 'nearest' and 'linear'
+## from the knots are requested, but only "nearest" and "linear"
 ## confirm they are the correct values.
 
 %!shared xp, yp, xi, style
-%! xp=0:2:10;      yp = sin(2*pi*xp/5);
+%! xp = 0:2:10;
+%! yp = sin (2*pi*xp/5);
 %! xi = [-1, 0, 2.2, 4, 6.6, 10, 11];
 
-
 ## The following BLOCK/ENDBLOCK section is repeated for each style
 ##    nearest, linear, cubic, spline, pchip
 ## The test for ppval of cubic has looser tolerance, but otherwise
 ## the tests are identical.
 ## Note that the block checks style and *style; if you add more tests
-## before to add them to both sections of each block.  One test,
+## be sure to add them to both sections of each block.  One test,
 ## style vs. *style, occurs only in the first section.
 ## There is an ENDBLOCKTEST after the final block
+
 %!test style = "nearest";
 ## BLOCK
-%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]);
-%!assert (interp1(xp,yp,xp,style), yp, 100*eps);
-%!assert (interp1(xp,yp,xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp,style), yp, 100*eps);
-%!assert (isempty(interp1(xp',yp',[],style)));
-%!assert (isempty(interp1(xp,yp,[],style)));
-%!assert (interp1(xp,[yp',yp'],xi(:),style),...
-%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]);
-%!assert (interp1(xp,yp,xi,style),...
-%!        interp1(fliplr(xp),fliplr(yp),xi,style),100*eps);
-%!assert (ppval(interp1(xp,yp,style,"pp"),xi),
-%!        interp1(xp,yp,xi,style,"extrap"),10*eps);
-%!error interp1(1,1,1, style);
-%!assert (interp1(xp,[yp',yp'],xi,style),
-%!        interp1(xp,[yp',yp'],xi,["*",style]),100*eps);
-%!test style=['*',style];
-%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]);
-%!assert (interp1(xp,yp,xp,style), yp, 100*eps);
-%!assert (interp1(xp,yp,xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp,style), yp, 100*eps);
-%!assert (isempty(interp1(xp',yp',[],style)));
-%!assert (isempty(interp1(xp,yp,[],style)));
-%!assert (interp1(xp,[yp',yp'],xi(:),style),...
-%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]);
-%!assert (interp1(xp,yp,xi,style),...
-%!        interp1(fliplr(xp),fliplr(yp),xi,style),100*eps);
-%!assert (ppval(interp1(xp,yp,style,"pp"),xi),
-%!        interp1(xp,yp,xi,style,"extrap"),10*eps);
-%!error interp1(1,1,1, style);
+%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
+%!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
+%!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
+%!assert (isempty (interp1 (xp',yp',[],style)))
+%!assert (isempty (interp1 (xp,yp,[],style)))
+%!assert (interp1 (xp,[yp',yp'],xi(:),style),...
+%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
+%!assert (interp1 (xp,yp,xi,style),...
+%!        interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
+%!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
+%!        interp1 (xp,yp,xi,style,"extrap"),10*eps)
+%!error interp1 (1,1,1, style)
+%!assert (interp1 (xp,[yp',yp'],xi,style),
+%!        interp1 (xp,[yp',yp'],xi,["*",style]),100*eps)
+%!test style = ["*",style];
+%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
+%!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
+%!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
+%!assert (isempty (interp1 (xp',yp',[],style)))
+%!assert (isempty (interp1 (xp,yp,[],style)))
+%!assert (interp1 (xp,[yp',yp'],xi(:),style),...
+%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
+%!assert (interp1 (xp,yp,xi,style),...
+%!        interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
+%!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
+%!        interp1 (xp,yp,xi,style,"extrap"),10*eps)
+%!error interp1 (1,1,1, style)
 ## ENDBLOCK
-%!test style='linear';
+
+%!test style = "linear";
 ## BLOCK
-%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]);
-%!assert (interp1(xp,yp,xp,style), yp, 100*eps);
-%!assert (interp1(xp,yp,xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp,style), yp, 100*eps);
-%!assert (isempty(interp1(xp',yp',[],style)));
-%!assert (isempty(interp1(xp,yp,[],style)));
-%!assert (interp1(xp,[yp',yp'],xi(:),style),...
-%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]);
-%!assert (interp1(xp,yp,xi,style),...
-%!        interp1(fliplr(xp),fliplr(yp),xi,style),100*eps);
-%!assert (ppval(interp1(xp,yp,style,"pp"),xi),
-%!        interp1(xp,yp,xi,style,"extrap"),10*eps);
-%!error interp1(1,1,1, style);
-%!assert (interp1(xp,[yp',yp'],xi,style),
-%!        interp1(xp,[yp',yp'],xi,["*",style]),100*eps);
-%!test style=['*',style];
-%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]);
-%!assert (interp1(xp,yp,xp,style), yp, 100*eps);
-%!assert (interp1(xp,yp,xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp,style), yp, 100*eps);
-%!assert (isempty(interp1(xp',yp',[],style)));
-%!assert (isempty(interp1(xp,yp,[],style)));
-%!assert (interp1(xp,[yp',yp'],xi(:),style),...
-%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]);
-%!assert (interp1(xp,yp,xi,style),...
-%!        interp1(fliplr(xp),fliplr(yp),xi,style),100*eps);
-%!assert (ppval(interp1(xp,yp,style,"pp"),xi),
-%!        interp1(xp,yp,xi,style,"extrap"),10*eps);
-%!error interp1(1,1,1, style);
+%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
+%!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
+%!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
+%!assert (isempty (interp1 (xp',yp',[],style)))
+%!assert (isempty (interp1 (xp,yp,[],style)))
+%!assert (interp1 (xp,[yp',yp'],xi(:),style),...
+%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
+%!assert (interp1 (xp,yp,xi,style),...
+%!        interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
+%!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
+%!        interp1 (xp,yp,xi,style,"extrap"),10*eps)
+%!error interp1 (1,1,1, style)
+%!assert (interp1 (xp,[yp',yp'],xi,style),
+%!        interp1 (xp,[yp',yp'],xi,["*",style]),100*eps)
+%!test style = ['*',style];
+%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
+%!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
+%!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
+%!assert (isempty (interp1 (xp',yp',[],style)))
+%!assert (isempty (interp1 (xp,yp,[],style)))
+%!assert (interp1 (xp,[yp',yp'],xi(:),style),...
+%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
+%!assert (interp1 (xp,yp,xi,style),...
+%!        interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
+%!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
+%!        interp1 (xp,yp,xi,style,"extrap"),10*eps)
+%!error interp1 (1,1,1, style)
 ## ENDBLOCK
-%!test style='cubic';
+
+%!test style = "cubic";
 ## BLOCK
-%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]);
-%!assert (interp1(xp,yp,xp,style), yp, 100*eps);
-%!assert (interp1(xp,yp,xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp,style), yp, 100*eps);
-%!assert (isempty(interp1(xp',yp',[],style)));
-%!assert (isempty(interp1(xp,yp,[],style)));
-%!assert (interp1(xp,[yp',yp'],xi(:),style),...
-%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]);
-%!assert (interp1(xp,yp,xi,style),...
-%!        interp1(fliplr(xp),fliplr(yp),xi,style),100*eps);
-%!assert (ppval(interp1(xp,yp,style,"pp"),xi),
-%!        interp1(xp,yp,xi,style,"extrap"),100*eps);
-%!error interp1(1,1,1, style);
-%!assert (interp1(xp,[yp',yp'],xi,style),
-%!        interp1(xp,[yp',yp'],xi,["*",style]),100*eps);
-%!test style=['*',style];
-%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]);
-%!assert (interp1(xp,yp,xp,style), yp, 100*eps);
-%!assert (interp1(xp,yp,xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp,style), yp, 100*eps);
-%!assert (isempty(interp1(xp',yp',[],style)));
-%!assert (isempty(interp1(xp,yp,[],style)));
-%!assert (interp1(xp,[yp',yp'],xi(:),style),...
-%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]);
-%!assert (interp1(xp,yp,xi,style),...
-%!        interp1(fliplr(xp),fliplr(yp),xi,style),100*eps);
-%!assert (ppval(interp1(xp,yp,style,"pp"),xi),
-%!        interp1(xp,yp,xi,style,"extrap"),100*eps);
-%!error interp1(1,1,1, style);
+%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
+%!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
+%!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
+%!assert (isempty (interp1 (xp',yp',[],style)))
+%!assert (isempty (interp1 (xp,yp,[],style)))
+%!assert (interp1 (xp,[yp',yp'],xi(:),style),...
+%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
+%!assert (interp1 (xp,yp,xi,style),...
+%!        interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
+%!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
+%!        interp1 (xp,yp,xi,style,"extrap"),100*eps)
+%!error interp1 (1,1,1, style)
+%!assert (interp1 (xp,[yp',yp'],xi,style),
+%!        interp1 (xp,[yp',yp'],xi,["*",style]),100*eps)
+%!test style = ["*",style];
+%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
+%!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
+%!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
+%!assert (isempty (interp1 (xp',yp',[],style)))
+%!assert (isempty (interp1 (xp,yp,[],style)))
+%!assert (interp1 (xp,[yp',yp'],xi(:),style),...
+%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
+%!assert (interp1 (xp,yp,xi,style),...
+%!        interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
+%!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
+%!        interp1 (xp,yp,xi,style,"extrap"),100*eps)
+%!error interp1 (1,1,1, style)
 ## ENDBLOCK
-%!test style='pchip';
+
+%!test style = "pchip";
 ## BLOCK
-%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]);
-%!assert (interp1(xp,yp,xp,style), yp, 100*eps);
-%!assert (interp1(xp,yp,xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp,style), yp, 100*eps);
-%!assert (isempty(interp1(xp',yp',[],style)));
-%!assert (isempty(interp1(xp,yp,[],style)));
-%!assert (interp1(xp,[yp',yp'],xi(:),style),...
-%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]);
-%!assert (interp1(xp,yp,xi,style),...
-%!        interp1(fliplr(xp),fliplr(yp),xi,style),100*eps);
-%!assert (ppval(interp1(xp,yp,style,"pp"),xi),
-%!        interp1(xp,yp,xi,style,"extrap"),10*eps);
-%!error interp1(1,1,1, style);
-%!assert (interp1(xp,[yp',yp'],xi,style),
-%!        interp1(xp,[yp',yp'],xi,["*",style]),100*eps);
-%!test style=['*',style];
-%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]);
-%!assert (interp1(xp,yp,xp,style), yp, 100*eps);
-%!assert (interp1(xp,yp,xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp,style), yp, 100*eps);
-%!assert (isempty(interp1(xp',yp',[],style)));
-%!assert (isempty(interp1(xp,yp,[],style)));
-%!assert (interp1(xp,[yp',yp'],xi(:),style),...
-%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]);
-%!assert (interp1(xp,yp,xi,style),...
-%!        interp1(fliplr(xp),fliplr(yp),xi,style),100*eps);
-%!assert (ppval(interp1(xp,yp,style,"pp"),xi),
-%!        interp1(xp,yp,xi,style,"extrap"),10*eps);
-%!error interp1(1,1,1, style);
+%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
+%!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
+%!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
+%!assert (isempty (interp1 (xp',yp',[],style)))
+%!assert (isempty (interp1 (xp,yp,[],style)))
+%!assert (interp1 (xp,[yp',yp'],xi(:),style),...
+%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
+%!assert (interp1 (xp,yp,xi,style),...
+%!        interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
+%!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
+%!        interp1 (xp,yp,xi,style,"extrap"),10*eps)
+%!error interp1 (1,1,1, style)
+%!assert (interp1 (xp,[yp',yp'],xi,style),
+%!        interp1 (xp,[yp',yp'],xi,["*",style]),100*eps)
+%!test style = ["*",style];
+%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
+%!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
+%!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
+%!assert (isempty (interp1 (xp',yp',[],style)))
+%!assert (isempty (interp1 (xp,yp,[],style)))
+%!assert (interp1 (xp,[yp',yp'],xi(:),style),...
+%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
+%!assert (interp1 (xp,yp,xi,style),...
+%!        interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
+%!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
+%!        interp1 (xp,yp,xi,style,"extrap"),10*eps)
+%!error interp1 (1,1,1, style)
 ## ENDBLOCK
-%!test style='spline';
+
+%!test style = "spline";
 ## BLOCK
-%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]);
-%!assert (interp1(xp,yp,xp,style), yp, 100*eps);
-%!assert (interp1(xp,yp,xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp,style), yp, 100*eps);
-%!assert (isempty(interp1(xp',yp',[],style)));
-%!assert (isempty(interp1(xp,yp,[],style)));
-%!assert (interp1(xp,[yp',yp'],xi(:),style),...
-%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]);
-%!assert (interp1(xp,yp,xi,style),...
-%!        interp1(fliplr(xp),fliplr(yp),xi,style),100*eps);
-%!assert (ppval(interp1(xp,yp,style,"pp"),xi),
-%!        interp1(xp,yp,xi,style,"extrap"),10*eps);
-%!error interp1(1,1,1, style);
-%!assert (interp1(xp,[yp',yp'],xi,style),
-%!        interp1(xp,[yp',yp'],xi,["*",style]),100*eps);
-%!test style=['*',style];
-%!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA]);
-%!assert (interp1(xp,yp,xp,style), yp, 100*eps);
-%!assert (interp1(xp,yp,xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp',style), yp', 100*eps);
-%!assert (interp1(xp',yp',xp,style), yp, 100*eps);
-%!assert (isempty(interp1(xp',yp',[],style)));
-%!assert (isempty(interp1(xp,yp,[],style)));
-%!assert (interp1(xp,[yp',yp'],xi(:),style),...
-%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]);
-%!assert (interp1(xp,yp,xi,style),...
-%!        interp1(fliplr(xp),fliplr(yp),xi,style),100*eps);
-%!assert (ppval(interp1(xp,yp,style,"pp"),xi),
-%!        interp1(xp,yp,xi,style,"extrap"),10*eps);
-%!error interp1(1,1,1, style);
+%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
+%!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
+%!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
+%!assert (isempty (interp1 (xp',yp',[],style)))
+%!assert (isempty (interp1 (xp,yp,[],style)))
+%!assert (interp1 (xp,[yp',yp'],xi(:),style),...
+%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
+%!assert (interp1 (xp,yp,xi,style),...
+%!        interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
+%!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
+%!        interp1 (xp,yp,xi,style,"extrap"),10*eps)
+%!error interp1 (1,1,1, style)
+%!assert (interp1 (xp,[yp',yp'],xi,style),
+%!        interp1 (xp,[yp',yp'],xi,["*",style]),100*eps)
+%!test style = ["*",style];
+%!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
+%!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
+%!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
+%!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
+%!assert (isempty (interp1 (xp',yp',[],style)))
+%!assert (isempty (interp1 (xp,yp,[],style)))
+%!assert (interp1 (xp,[yp',yp'],xi(:),style),...
+%!        [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
+%!assert (interp1 (xp,yp,xi,style),...
+%!        interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
+%!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
+%!        interp1 (xp,yp,xi,style,"extrap"),10*eps)
+%!error interp1 (1,1,1, style)
 ## ENDBLOCK
 ## ENDBLOCKTEST
 
 %!# test linear extrapolation
-%!assert (interp1([1:5],[3:2:11],[0,6],"linear","extrap"), [1, 13], eps);
-%!assert (interp1(xp, yp, [-1, max(xp)+1],"linear",5), [5, 5]);
-
-%!error interp1
-%!error interp1(1:2,1:2,1,"bogus")
+%!assert (interp1 ([1:5],[3:2:11],[0,6],"linear","extrap"), [1, 13], eps)
+%!assert (interp1 (xp, yp, [-1, max(xp)+1],"linear",5), [5, 5])
 
-%!assert (interp1(1:2,1:2,1.4,"nearest"),1);
-%!error interp1(1,1,1, "linear");
-%!assert (interp1(1:2,1:2,1.4,"linear"),1.4);
-%!assert (interp1(1:4,1:4,1.4,"cubic"),1.4);
-%!assert (interp1(1:2,1:2,1.1, "spline"), 1.1);
-%!assert (interp1(1:3,1:3,1.4,"spline"),1.4);
+%!assert (interp1 (1:2,1:2,1.4,"nearest"), 1)
+%!assert (interp1 (1:2,1:2,1.4,"linear"), 1.4)
+%!assert (interp1 (1:4,1:4,1.4,"cubic"), 1.4)
+%!assert (interp1 (1:2,1:2,1.1, "spline"), 1.1)
+%!assert (interp1 (1:3,1:3,1.4,"spline"), 1.4)
 
-%!error interp1(1,1,1, "*nearest");
-%!assert (interp1(1:2:4,1:2:4,1.4,"*nearest"),1);
-%!error interp1(1,1,1, "*linear");
-%!assert (interp1(1:2:4,1:2:4,[0,1,1.4,3,4],"*linear"),[NA,1,1.4,3,NA]);
-%!assert (interp1(1:2:8,1:2:8,1.4,"*cubic"),1.4);
-%!assert (interp1(1:2,1:2,1.3, "*spline"), 1.3);
-%!assert (interp1(1:2:6,1:2:6,1.4,"*spline"),1.4);
+%!assert (interp1 (1:2:4,1:2:4,1.4,"*nearest"), 1)
+%!assert (interp1 (1:2:4,1:2:4,[0,1,1.4,3,4],"*linear"), [NA,1,1.4,3,NA])
+%!assert (interp1 (1:2:8,1:2:8,1.4,"*cubic"), 1.4)
+%!assert (interp1 (1:2,1:2,1.3, "*spline"), 1.3)
+%!assert (interp1 (1:2:6,1:2:6,1.4,"*spline"), 1.4)
 
-%!assert (interp1([3,2,1],[3,2,2],2.5),2.5)
+%!assert (interp1 ([3,2,1],[3,2,2],2.5), 2.5)
 
 %!assert (interp1 ([1,2,2,3,4],[0,1,4,2,1],[-1,1.5,2,2.5,3.5], "linear", "extrap"), [-2,0.5,4,3,1.5])
 %!assert (interp1 ([4,4,3,2,0],[0,1,4,2,1],[1.5,4,4.5], "linear"), [1.75,1,NA])
 %!assert (interp1 (0:4, 2.5), 1.5)
+
+%!error interp1 ()
+%!error interp1 (1,1,1, "linear")
+%!error interp1 (1,1,1, "*nearest")
+%!error interp1 (1,1,1, "*linear")
+%!error interp1 (1:2,1:2,1, "bogus")
+
--- a/scripts/general/interp1q.m
+++ b/scripts/general/interp1q.m
@@ -37,7 +37,7 @@
 
 function yi = interp1q (x, y, xi)
   x = x(:);
-  nx = size (x, 1);
+  nx = rows (x);
   szy = size (y);
   y = y(:,:);
   [ny, nc] = size (y);
@@ -57,14 +57,16 @@
   endif
 endfunction
 
+
 %!shared xp, yp, xi, yi
-%! xp=[0:2:10].';      yp = sin(2*pi*xp/5);
+%! xp = [0:2:10].';   yp = sin (2*pi*xp/5);
 %! xi = [-1; 0; 2.2; 4; 6.6; 10; 11];
 %! yi = interp1 (xp,yp,xi);
-%!assert (interp1q(xp, yp, [min(xp)-1; max(xp)+1]), [NA; NA]);
-%!assert (interp1q(xp,yp,xp), yp, 100*eps);
-%!assert (isempty(interp1q(xp,yp,[])));
-%!assert (interp1q(xp,yp,xi), yi);
-%!assert (interp1q(xp,[yp,yp],xi), [yi, yi]);
-%!assert (interp1q(xp,yp,[xi,xi]), [yi, yi]);
-%!assert (interp1q(xp,[yp,yp],[xi,xi]), cat (3, [yi, yi], [yi, yi]));
+%!assert (interp1q (xp,yp, [min(xp)-1; max(xp)+1]), [NA; NA]);
+%!assert (interp1q (xp,yp,xp), yp, 100*eps);
+%!assert (isempty (interp1q (xp,yp,[])));
+%!assert (interp1q (xp,yp,xi), yi);
+%!assert (interp1q (xp,[yp,yp],xi), [yi, yi]);
+%!assert (interp1q (xp,yp,[xi,xi]), [yi, yi]);
+%!assert (interp1q (xp,[yp,yp],[xi,xi]), cat (3, [yi, yi], [yi, yi]));
+
--- a/scripts/general/interp2.m
+++ b/scripts/general/interp2.m
@@ -36,8 +36,8 @@
 ## matrices @var{xi}, @var{yi}.
 ##
 ## If the last argument is a string, the interpolation method can
-## be specified.  The method can be 'linear', 'nearest' or 'cubic'.
-## If it is omitted 'linear' interpolation is assumed.
+## be specified.  The method can be "linear", "nearest" or "cubic".
+## If it is omitted "linear" interpolation is assumed.
 ##
 ## @item interp2 (@var{z}, @var{xi}, @var{yi})
 ## Assumes @code{@var{x} = 1:rows (@var{z})} and @code{@var{y} =
@@ -52,19 +52,19 @@
 ## interpolation.  It can take one of the following values
 ##
 ## @table @asis
-## @item 'nearest'
+## @item "nearest"
 ## Return the nearest neighbor.
 ##
-## @item 'linear'
+## @item "linear"
 ## Linear interpolation from nearest neighbors.
 ##
-## @item 'pchip'
+## @item "pchip"
 ## Piecewise cubic Hermite interpolating polynomial.
 ##
-## @item 'cubic'
+## @item "cubic"
 ## Cubic interpolation from four nearest neighbors.
 ##
-## @item 'spline'
+## @item "spline"
 ## Cubic spline interpolation---smooth first and second derivatives
 ## throughout the curve.
 ## @end table
@@ -377,7 +377,7 @@
         AX_2 = bc ((XI - K - 2));
 
         ## Perform interpolation
-        sz = size(Z);
+        sz = size (Z);
         ZI = AY_2 .* AX_2 .* Z (sym_sub2ind (sz, L+2, K+2)) ...
            + AY_2 .* AX_1 .* Z (sym_sub2ind (sz, L+2, K+1)) ...
            + AY_2 .* AX0  .* Z (sym_sub2ind (sz, L+2, K))   ...
@@ -420,9 +420,9 @@
 endfunction
 
 ## Compute the bicubic interpolation coefficients
-function o = bc(x)
-  x = abs(x);
-  o = zeros(size(x));
+function o = bc (x)
+  x = abs (x);
+  o = zeros (size (x));
   idx1 = (x < 1);
   idx2 = !idx1 & (x < 2);
   o(idx1) = 1 - 2.*x(idx1).^2 + x(idx1).^3;
@@ -430,7 +430,7 @@
 endfunction
 
 ## This version of sub2ind behaves as if the data was symmetrically padded
-function ind = sym_sub2ind(sz, Y, X)
+function ind = sym_sub2ind (sz, Y, X)
   Y (Y < 1) = 1 - Y (Y < 1);
   while (any (Y (:) > 2 * sz (1)))
     Y (Y > 2 * sz (1)) = round (Y (Y > 2 * sz (1)) / 2);
@@ -441,170 +441,191 @@
     X (X > 2 * sz (2)) = round (X (X > 2 * sz (2)) / 2);
   endwhile
   X (X > sz (2)) = 1 + 2 * sz (2) - X (X > sz (2));
-  ind = sub2ind(sz, Y, X);
+  ind = sub2ind (sz, Y, X);
 endfunction
 
 
 %!demo
-%! A=[13,-1,12;5,4,3;1,6,2];
-%! x=[0,1,4]; y=[10,11,12];
-%! xi=linspace(min(x),max(x),17);
-%! yi=linspace(min(y),max(y),26)';
-%! mesh(xi,yi,interp2(x,y,A,xi,yi,'linear'));
-%! [x,y] = meshgrid(x,y);
-%! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
+%! clf;
+%! colormap ("default");
+%! A = [13,-1,12;5,4,3;1,6,2];
+%! x = [0,1,4];  y = [10,11,12];
+%! xi = linspace (min (x), max (x), 17);
+%! yi = linspace (min (y), max (y), 26)';
+%! mesh (xi,yi,interp2 (x,y,A,xi,yi, "linear"));
+%! [x,y] = meshgrid (x,y);
+%! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off;
 
 %!demo
-%! [x,y,A] = peaks(10);
-%! x = x(1,:)'; y = y(:,1);
-%! xi=linspace(min(x),max(x),41);
-%! yi=linspace(min(y),max(y),41)';
-%! mesh(xi,yi,interp2(x,y,A,xi,yi,'linear'));
-%! [x,y] = meshgrid(x,y);
-%! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
+%! clf;
+%! colormap ("default");
+%! [x,y,A] = peaks (10);
+%! x = x(1,:)';  y = y(:,1);
+%! xi = linspace (min (x), max (x), 41);
+%! yi = linspace (min (y), max (y), 41)';
+%! mesh (xi,yi,interp2 (x,y,A,xi,yi, "linear"));
+%! [x,y] = meshgrid (x,y);
+%! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off;
 
 %!demo
-%! A=[13,-1,12;5,4,3;1,6,2];
-%! x=[0,1,4]; y=[10,11,12];
-%! xi=linspace(min(x),max(x),17);
-%! yi=linspace(min(y),max(y),26)';
-%! mesh(xi,yi,interp2(x,y,A,xi,yi,'nearest'));
-%! [x,y] = meshgrid(x,y);
-%! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
+%! clf;
+%! colormap ("default");
+%! A = [13,-1,12;5,4,3;1,6,2];
+%! x = [0,1,4];  y = [10,11,12];
+%! xi = linspace (min (x), max (x), 17);
+%! yi = linspace (min (y), max (y), 26)';
+%! mesh (xi,yi,interp2 (x,y,A,xi,yi, "nearest"));
+%! [x,y] = meshgrid (x,y);
+%! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off;
 
 %!demo
-%! [x,y,A] = peaks(10);
-%! x = x(1,:)'; y = y(:,1);
-%! xi=linspace(min(x),max(x),41);
-%! yi=linspace(min(y),max(y),41)';
-%! mesh(xi,yi,interp2(x,y,A,xi,yi,'nearest'));
-%! [x,y] = meshgrid(x,y);
-%! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
+%! clf;
+%! colormap ("default");
+%! [x,y,A] = peaks (10);
+%! x = x(1,:)';  y = y(:,1);
+%! xi = linspace (min (x), max (x), 41);
+%! yi = linspace (min (y), max (y), 41)';
+%! mesh (xi,yi,interp2 (x,y,A,xi,yi, "nearest"));
+%! [x,y] = meshgrid (x,y);
+%! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off;
 
 %!demo
-%! A=[13,-1,12;5,4,3;1,6,2];
-%! x=[0,1,2]; y=[10,11,12];
-%! xi=linspace(min(x),max(x),17);
-%! yi=linspace(min(y),max(y),26)';
-%! mesh(xi,yi,interp2(x,y,A,xi,yi,'pchip'));
-%! [x,y] = meshgrid(x,y);
-%! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
+%! clf;
+%! colormap ("default");
+%! A = [13,-1,12;5,4,3;1,6,2];
+%! x = [0,1,2];  y = [10,11,12];
+%! xi = linspace (min (x), max (x), 17);
+%! yi = linspace (min (y), max (y), 26)';
+%! mesh (xi,yi,interp2 (x,y,A,xi,yi, "pchip"));
+%! [x,y] = meshgrid (x,y);
+%! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off;
 
 %!demo
-%! [x,y,A] = peaks(10);
-%! x = x(1,:)'; y = y(:,1);
-%! xi=linspace(min(x),max(x),41);
-%! yi=linspace(min(y),max(y),41)';
-%! mesh(xi,yi,interp2(x,y,A,xi,yi,'pchip'));
-%! [x,y] = meshgrid(x,y);
-%! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
+%! clf;
+%! colormap ("default");
+%! [x,y,A] = peaks (10);
+%! x = x(1,:)';  y = y(:,1);
+%! xi = linspace (min (x), max (x), 41);
+%! yi = linspace (min (y), max (y), 41)';
+%! mesh (xi,yi,interp2 (x,y,A,xi,yi, "pchip"));
+%! [x,y] = meshgrid (x,y);
+%! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off;
 
 %!demo
-%! A=[13,-1,12;5,4,3;1,6,2];
-%! x=[0,1,2]; y=[10,11,12];
-%! xi=linspace(min(x),max(x),17);
-%! yi=linspace(min(y),max(y),26)';
-%! mesh(xi,yi,interp2(x,y,A,xi,yi,'cubic'));
-%! [x,y] = meshgrid(x,y);
-%! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
+%! clf;
+%! colormap ("default");
+%! A = [13,-1,12;5,4,3;1,6,2];
+%! x = [0,1,2];  y = [10,11,12];
+%! xi = linspace (min (x), max (x), 17);
+%! yi = linspace (min (y), max (y), 26)';
+%! mesh (xi,yi,interp2 (x,y,A,xi,yi, "cubic"));
+%! [x,y] = meshgrid (x,y);
+%! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off;
 
 %!demo
-%! [x,y,A] = peaks(10);
-%! x = x(1,:)'; y = y(:,1);
-%! xi=linspace(min(x),max(x),41);
-%! yi=linspace(min(y),max(y),41)';
-%! mesh(xi,yi,interp2(x,y,A,xi,yi,'cubic'));
-%! [x,y] = meshgrid(x,y);
-%! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
+%! clf;
+%! colormap ("default");
+%! [x,y,A] = peaks (10);
+%! x = x(1,:)';  y = y(:,1);
+%! xi = linspace (min (x), max (x), 41);
+%! yi = linspace (min (y), max (y), 41)';
+%! mesh (xi,yi,interp2 (x,y,A,xi,yi, "cubic"));
+%! [x,y] = meshgrid (x,y);
+%! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off;
 
 %!demo
-%! A=[13,-1,12;5,4,3;1,6,2];
-%! x=[0,1,2]; y=[10,11,12];
-%! xi=linspace(min(x),max(x),17);
-%! yi=linspace(min(y),max(y),26)';
-%! mesh(xi,yi,interp2(x,y,A,xi,yi,'spline'));
-%! [x,y] = meshgrid(x,y);
-%! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
+%! clf;
+%! colormap ("default");
+%! A = [13,-1,12;5,4,3;1,6,2];
+%! x = [0,1,2];  y = [10,11,12];
+%! xi = linspace (min (x), max (x), 17);
+%! yi = linspace (min (y), max (y), 26)';
+%! mesh (xi,yi,interp2 (x,y,A,xi,yi, "spline"));
+%! [x,y] = meshgrid (x,y);
+%! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off;
 
 %!demo
-%! [x,y,A] = peaks(10);
-%! x = x(1,:)'; y = y(:,1);
-%! xi=linspace(min(x),max(x),41);
-%! yi=linspace(min(y),max(y),41)';
-%! mesh(xi,yi,interp2(x,y,A,xi,yi,'spline'));
-%! [x,y] = meshgrid(x,y);
-%! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
+%! clf;
+%! colormap ("default");
+%! [x,y,A] = peaks (10);
+%! x = x(1,:)';  y = y(:,1);
+%! xi = linspace (min (x), max (x), 41);
+%! yi = linspace (min (y), max (y), 41)';
+%! mesh (xi,yi,interp2 (x,y,A,xi,yi, "spline"));
+%! [x,y] = meshgrid (x,y);
+%! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off;
 
 %!test % simple test
-%!  x = [1,2,3];
-%!  y = [4,5,6,7];
-%!  [X, Y] = meshgrid(x,y);
-%!  Orig = X.^2 + Y.^3;
-%!  xi = [1.2,2, 1.5];
-%!  yi = [6.2, 4.0, 5.0]';
+%! x = [1,2,3];
+%! y = [4,5,6,7];
+%! [X, Y] = meshgrid (x, y);
+%! Orig = X.^2 + Y.^3;
+%! xi = [1.2,2, 1.5];
+%! yi = [6.2, 4.0, 5.0]';
 %!
-%!  Expected = ...
-%!    [243,   245.4,  243.9;
-%!      65.6,  68,     66.5;
-%!     126.6, 129,    127.5];
-%!  Result = interp2(x,y,Orig, xi, yi);
+%! Expected = ...
+%!   [243,   245.4,  243.9;
+%!     65.6,  68,     66.5;
+%!    126.6, 129,    127.5];
+%! Result = interp2 (x,y,Orig, xi, yi);
 %!
-%!  assert(Result, Expected, 1000*eps);
+%! assert (Result, Expected, 1000*eps);
 
 %!test % 2^n form
-%!  x = [1,2,3];
-%!  y = [4,5,6,7];
-%!  [X, Y] = meshgrid(x,y);
-%!  Orig = X.^2 + Y.^3;
-%!  xi = [1:0.25:3]; yi = [4:0.25:7]';
-%!  Expected = interp2(x,y,Orig, xi, yi);
-%!  Result = interp2(Orig,2);
+%! x = [1,2,3];
+%! y = [4,5,6,7];
+%! [X, Y] = meshgrid (x, y);
+%! Orig = X.^2 + Y.^3;
+%! xi = [1:0.25:3];  yi = [4:0.25:7]';
+%! Expected = interp2 (x,y,Orig, xi, yi);
+%! Result = interp2 (Orig, 2);
 %!
-%!  assert(Result, Expected, 10*eps);
+%! assert (Result, Expected, 10*eps);
 
 %!test % matrix slice
-%!  A = eye(4);
-%!  assert(interp2(A,[1:4],[1:4]),[1,1,1,1]);
+%! A = eye (4);
+%! assert (interp2 (A,[1:4],[1:4]), [1,1,1,1]);
 
 %!test % non-gridded XI,YI
-%!  A = eye(4);
-%!  assert(interp2(A,[1,2;3,4],[1,3;2,4]),[1,0;0,1]);
+%! A = eye (4);
+%! assert (interp2 (A,[1,2;3,4],[1,3;2,4]), [1,0;0,1]);
 
 %!test % for values outside of boundaries
-%!  x = [1,2,3];
-%!  y = [4,5,6,7];
-%!  [X, Y] = meshgrid(x,y);
-%!  Orig = X.^2 + Y.^3;
-%!  xi = [0,4];
-%!  yi = [3,8]';
-%!  assert(interp2(x,y,Orig, xi, yi),[NA,NA;NA,NA]);
-%!  assert(interp2(x,y,Orig, xi, yi,'linear', 0),[0,0;0,0]);
+%! x = [1,2,3];
+%! y = [4,5,6,7];
+%! [X, Y] = meshgrid (x,y);
+%! Orig = X.^2 + Y.^3;
+%! xi = [0,4];
+%! yi = [3,8]';
+%! assert (interp2 (x,y,Orig, xi, yi), [NA,NA;NA,NA]);
+%! assert (interp2 (x,y,Orig, xi, yi,"linear", 0), [0,0;0,0]);
 
 %!test % for values at boundaries
-%!  A=[1,2;3,4];
-%!  x=[0,1];
-%!  y=[2,3]';
-%!  assert(interp2(x,y,A,x,y,'linear'), A);
-%!  assert(interp2(x,y,A,x,y,'nearest'), A);
+%! A=[1,2;3,4];
+%! x=[0,1];
+%! y=[2,3]';
+%! assert (interp2 (x,y,A,x,y,"linear"), A);
+%! assert (interp2 (x,y,A,x,y,"nearest"), A);
 
 %!test % for Matlab-compatible rounding for 'nearest'
 %! X = meshgrid (1:4);
-%! assert (interp2 (X, 2.5, 2.5, 'nearest'), 3);
+%! assert (interp2 (X, 2.5, 2.5, "nearest"), 3);
 
 %!shared z, zout, tol
-%!  z = [1 3 5; 3 5 7; 5 7 9];
-%!  zout = [1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8; 5 6 7 8 9];
-%!  tol = 2 * eps;
-%!assert (interp2 (z), zout, tol);
-%!assert (interp2 (z, "linear"), zout, tol);
-%!assert (interp2 (z, "pchip"), zout, tol);
-%!assert (interp2 (z, "cubic"), zout, 10 * tol);
-%!assert (interp2 (z, "spline"), zout, tol);
+%! z = [1 3 5; 3 5 7; 5 7 9];
+%! zout = [1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8; 5 6 7 8 9];
+%! tol = 2 * eps;
+%!assert (interp2 (z), zout, tol)
+%!assert (interp2 (z, "linear"), zout, tol)
+%!assert (interp2 (z, "pchip"), zout, tol)
+%!assert (interp2 (z, "cubic"), zout, 10 * tol)
+%!assert (interp2 (z, "spline"), zout, tol)
 %!assert (interp2 (z, [2 3 1], [2 2 2]', "linear"), repmat ([5, 7, 3], [3, 1]), tol) 
 %!assert (interp2 (z, [2 3 1], [2 2 2]', "pchip"), repmat ([5, 7, 3], [3, 1]), tol) 
 %!assert (interp2 (z, [2 3 1], [2 2 2]', "cubic"), repmat ([5, 7, 3], [3, 1]), 10 * tol) 
 %!assert (interp2 (z, [2 3 1], [2 2 2]', "spline"), repmat ([5, 7, 3], [3, 1]), tol) 
-%!assert (interp2 (z, [2 3 1], [2 2 2], "linear"), [5 7 3], tol);
-%!assert (interp2 (z, [2 3 1], [2 2 2], "pchip"), [5 7 3], tol);
-%!assert (interp2 (z, [2 3 1], [2 2 2], "cubic"), [5 7 3], 10 * tol);
-%!assert (interp2 (z, [2 3 1], [2 2 2], "spline"), [5 7 3], tol);
+%!assert (interp2 (z, [2 3 1], [2 2 2], "linear"), [5 7 3], tol)
+%!assert (interp2 (z, [2 3 1], [2 2 2], "pchip"), [5 7 3], tol)
+%!assert (interp2 (z, [2 3 1], [2 2 2], "cubic"), [5 7 3], 10 * tol)
+%!assert (interp2 (z, [2 3 1], [2 2 2], "spline"), [5 7 3], tol)
+
--- a/scripts/general/interp3.m
+++ b/scripts/general/interp3.m
@@ -28,7 +28,7 @@
 ## array @var{v} represents a value at a location given by the parameters
 ## @var{x}, @var{y}, and @var{z}.  The parameters @var{x}, @var{x}, and
 ## @var{z} are either 3-dimensional arrays of the same size as the array
-## @var{v} in the 'meshgrid' format or vectors.  The parameters @var{xi}, etc.
+## @var{v} in the "meshgrid" format or vectors.  The parameters @var{xi}, etc.
 ## respect a similar format to @var{x}, etc., and they represent the points
 ## at which the array @var{vi} is interpolated.
 ##
@@ -42,23 +42,23 @@
 ## Method is one of:
 ##
 ## @table @asis
-## @item 'nearest'
+## @item "nearest"
 ## Return the nearest neighbor.
 ##
-## @item 'linear'
+## @item "linear"
 ## Linear interpolation from nearest neighbors.
 ##
-## @item 'cubic'
+## @item "cubic"
 ## Cubic interpolation from four nearest neighbors (not implemented yet).
 ##
-## @item 'spline'
+## @item "spline"
 ## Cubic spline interpolation---smooth first and second derivatives
 ## throughout the curve.
 ## @end table
 ##
-## The default method is 'linear'.
+## The default method is "linear".
 ##
-## If @var{extrap} is the string 'extrap', then extrapolate values beyond
+## If @var{extrap} is the string "extrap", then extrapolate values beyond
 ## the endpoints.  If @var{extrap} is a number, replace values beyond the
 ## endpoints with that number.  If @var{extrap} is missing, assume NA.
 ## @seealso{interp1, interp2, spline, meshgrid}
@@ -135,6 +135,7 @@
   endif
 endfunction
 
+
 %!test
 %! x = y = z = -1:1;
 %! f = @(x,y,z) x.^2 - y - z.^2;
@@ -142,9 +143,9 @@
 %! v = f (xx,yy,zz);
 %! xi = yi = zi = -1:0.5:1;
 %! [xxi, yyi, zzi] = meshgrid (xi, yi, zi);
-%! vi = interp3(x, y, z, v, xxi, yyi, zzi);
+%! vi = interp3 (x, y, z, v, xxi, yyi, zzi);
 %! [xxi, yyi, zzi] = ndgrid (xi, yi, zi);
-%! vi2 = interpn(x, y, z, v, xxi, yyi, zzi);
+%! vi2 = interpn (x, y, z, v, xxi, yyi, zzi);
 %! assert (vi, vi2);
 
 %!shared z, zout, tol
@@ -164,3 +165,4 @@
 %!assert (interp3 (z), zout, tol)
 %!assert (interp3 (z, "linear"), zout, tol)
 %!assert (interp3 (z, "spline"), zout, tol)
+
--- a/scripts/general/interpft.m
+++ b/scripts/general/interpft.m
@@ -92,25 +92,28 @@
 
 
 %!demo
-%! t = 0 : 0.3 : pi; dt = t(2)-t(1);
-%! n = length (t); k = 100;
+%! clf;
+%! t = 0 : 0.3 : pi;  dt = t(2)-t(1);
+%! n = length (t);  k = 100;
 %! ti = t(1) + [0 : k-1]*dt*n/k;
 %! y = sin (4*t + 0.3) .* cos (3*t - 0.1);
 %! yp = sin (4*ti + 0.3) .* cos (3*ti - 0.1);
-%! plot (ti, yp, 'g', ti, interp1(t, y, ti, 'spline'), 'b', ...
-%!       ti, interpft (y, k), 'c', t, y, 'r+');
-%! legend ('sin(4t+0.3)cos(3t-0.1','spline','interpft','data');
+%! plot (ti, yp, 'g', ti, interp1(t, y, ti, "spline"), 'b', ...
+%!       ti, interpft (y, k), 'c', t, y, "r+");
+%! legend ("sin(4t+0.3)cos(3t-0.1)", "spline", "interpft", "data");
 
 %!shared n,y
-%! x = [0:10]'; y = sin(x); n = length (x);
-%!assert (interpft(y, n), y, 20*eps);
-%!assert (interpft(y', n), y', 20*eps);
-%!assert (interpft([y,y],n), [y,y], 20*eps);
+%! x = [0:10]';  y = sin(x);  n = length (x);
+%!assert (interpft (y, n), y, 20*eps);
+%!assert (interpft (y', n), y', 20*eps);
+%!assert (interpft ([y,y],n), [y,y], 20*eps);
 
 %% Test input validation
 %!error interpft ()
 %!error interpft (1)
 %!error interpft (1,2,3)
-%!error (interpft(1,[n,n]))
-%!error (interpft(1,2,0))
-%!error (interpft(1,2,3))
+%!error <N must be a scalar integer> interpft (1,[2,2])
+%!error <N must be a scalar integer> interpft (1,2.1)
+%!error <invalid dimension DIM> interpft (1,2,0)
+%!error <invalid dimension DIM> interpft (1,2,3)
+
--- a/scripts/general/interpn.m
+++ b/scripts/general/interpn.m
@@ -29,7 +29,7 @@
 ## at a location given by the parameters @var{x1}, @var{x2}, @dots{}, @var{xn}.
 ## The parameters @var{x1}, @var{x2}, @dots{}, @var{xn} are either
 ## @var{n}-dimensional arrays of the same size as the array @var{v} in
-## the 'ndgrid' format or vectors.  The parameters @var{y1}, etc. respect a
+## the "ndgrid" format or vectors.  The parameters @var{y1}, etc. respect a
 ## similar format to @var{x1}, etc., and they represent the points at which
 ## the array @var{vi} is interpolated.
 ##
@@ -42,21 +42,21 @@
 ## Method is one of:
 ##
 ## @table @asis
-## @item 'nearest'
+## @item "nearest"
 ## Return the nearest neighbor.
 ##
-## @item 'linear'
+## @item "linear"
 ## Linear interpolation from nearest neighbors.
 ##
-## @item 'cubic'
+## @item "cubic"
 ## Cubic interpolation from four nearest neighbors (not implemented yet).
 ##
-## @item 'spline'
+## @item "spline"
 ## Cubic spline interpolation---smooth first and second derivatives
 ## throughout the curve.
 ## @end table
 ##
-## The default method is 'linear'.
+## The default method is "linear".
 ##
 ## If @var{extrapval} is the scalar value, use it to replace the values
 ## beyond the endpoints with that number.  If @var{extrapval} is missing,
@@ -198,8 +198,8 @@
         q(:) = i;
         idx {i} = q;
       endfor
-      vi = vi (cellfun (@(x) sub2ind (size(vi), x{:}), idx));
-      vi = reshape (vi, size(y{1}));
+      vi = vi (cellfun (@(x) sub2ind (size (vi), x{:}), idx));
+      vi = reshape (vi, size (y{1}));
     endif
   elseif (strcmp (method, "cubic"))
     error ("interpn: cubic interpolation not yet implemented");
@@ -209,93 +209,98 @@
 
 endfunction
 
+
 %!demo
-%! A=[13,-1,12;5,4,3;1,6,2];
-%! x=[0,1,4]; y=[10,11,12];
-%! xi=linspace(min(x),max(x),17);
-%! yi=linspace(min(y),max(y),26)';
-%! mesh(xi,yi,interpn(x,y,A.',xi,yi,"linear").');
-%! [x,y] = meshgrid(x,y);
-%! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
+%! clf;
+%! colormap ("default");
+%! A = [13,-1,12;5,4,3;1,6,2];
+%! x = [0,1,4];  y = [10,11,12];
+%! xi = linspace (min (x), max (x), 17);
+%! yi = linspace (min (y), max (y), 26)';
+%! mesh (xi, yi, interpn (x,y,A.',xi,yi, "linear").');
+%! [x,y] = meshgrid (x,y);
+%! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off;
 
 %!demo
-%! A=[13,-1,12;5,4,3;1,6,2];
-%! x=[0,1,4]; y=[10,11,12];
-%! xi=linspace(min(x),max(x),17);
-%! yi=linspace(min(y),max(y),26)';
-%! mesh(xi,yi,interpn(x,y,A.',xi,yi,"nearest").');
-%! [x,y] = meshgrid(x,y);
-%! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
+%! clf;
+%! colormap ("default");
+%! A = [13,-1,12;5,4,3;1,6,2];
+%! x = [0,1,4];  y = [10,11,12];
+%! xi = linspace (min (x), max (x), 17);
+%! yi = linspace (min (y), max (y), 26)';
+%! mesh (xi, yi, interpn (x,y,A.',xi,yi, "nearest").');
+%! [x,y] = meshgrid (x,y);
+%! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off;
 
-%!#demo
-%! A=[13,-1,12;5,4,3;1,6,2];
-%! x=[0,1,2]; y=[10,11,12];
-%! xi=linspace(min(x),max(x),17);
-%! yi=linspace(min(y),max(y),26)';
-%! mesh(xi,yi,interpn(x,y,A.',xi,yi,"cubic").');
-%! [x,y] = meshgrid(x,y);
-%! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
+%!#demo  # FIXME: Uncomment when support for "cubic" has been added
+%! clf;
+%! colormap ("default");
+%! A = [13,-1,12;5,4,3;1,6,2];
+%! x = [0,1,2];  y = [10,11,12];
+%! xi = linspace (min (x), max (x), 17);
+%! yi = linspace (min (y), max (y), 26)';
+%! mesh (xi, yi, interpn (x,y,A.',xi,yi, "cubic").');
+%! [x,y] = meshgrid (x,y);
+%! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off;
 
 %!demo
-%! A=[13,-1,12;5,4,3;1,6,2];
-%! x=[0,1,2]; y=[10,11,12];
-%! xi=linspace(min(x),max(x),17);
-%! yi=linspace(min(y),max(y),26)';
-%! mesh(xi,yi,interpn(x,y,A.',xi,yi,"spline").');
-%! [x,y] = meshgrid(x,y);
-%! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
-
+%! clf;
+%! colormap ("default");
+%! A = [13,-1,12;5,4,3;1,6,2];
+%! x = [0,1,2];  y = [10,11,12];
+%! xi = linspace (min (x), max (x), 17);
+%! yi = linspace (min (y), max (y), 26)';
+%! mesh (xi, yi, interpn (x,y,A.',xi,yi, "spline").');
+%! [x,y] = meshgrid (x,y);
+%! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off;
 
 %!demo
+%! clf;
+%! colormap ("default");
 %! x = y = z = -1:1;
 %! f = @(x,y,z) x.^2 - y - z.^2;
 %! [xx, yy, zz] = meshgrid (x, y, z);
 %! v = f (xx,yy,zz);
 %! xi = yi = zi = -1:0.1:1;
 %! [xxi, yyi, zzi] = ndgrid (xi, yi, zi);
-%! vi = interpn(x, y, z, v, xxi, yyi, zzi, 'spline');
+%! vi = interpn (x, y, z, v, xxi, yyi, zzi, "spline");
 %! mesh (yi, zi, squeeze (vi(1,:,:)));
 
-
 %!test
-%! [x,y,z] = ndgrid(0:2);
-%! f = x+y+z;
-%! assert (interpn(x,y,z,f,[.5 1.5],[.5 1.5],[.5 1.5]), [1.5, 4.5])
-%! assert (interpn(x,y,z,f,[.51 1.51],[.51 1.51],[.51 1.51],'nearest'), [3, 6])
-%! assert (interpn(x,y,z,f,[.5 1.5],[.5 1.5],[.5 1.5],'spline'), [1.5, 4.5])
-%! assert (interpn(x,y,z,f,x,y,z), f)
-%! assert (interpn(x,y,z,f,x,y,z,'nearest'), f)
-%! assert (interpn(x,y,z,f,x,y,z,'spline'), f)
+%! [x,y,z] = ndgrid (0:2);
+%! f = x + y + z;
+%! assert (interpn (x,y,z,f,[.5 1.5],[.5 1.5],[.5 1.5]), [1.5, 4.5]);
+%! assert (interpn (x,y,z,f,[.51 1.51],[.51 1.51],[.51 1.51],"nearest"), [3, 6]);
+%! assert (interpn (x,y,z,f,[.5 1.5],[.5 1.5],[.5 1.5],"spline"), [1.5, 4.5]);
+%! assert (interpn (x,y,z,f,x,y,z), f);
+%! assert (interpn (x,y,z,f,x,y,z,"nearest"), f);
+%! assert (interpn (x,y,z,f,x,y,z,"spline"), f);
 
 %!test
 %! [x, y, z] = ndgrid (0:2, 1:4, 2:6);
 %! f = x + y + z;
-%! xi = [0.5 1.0 1.5];
-%! yi = [1.5 2.0 2.5 3.5];
-%! zi = [2.5 3.5 4.0 5.0 5.5];
+%! xi = [0.5 1.0 1.5];  yi = [1.5 2.0 2.5 3.5];  zi = [2.5 3.5 4.0 5.0 5.5];
 %! fi = interpn (x, y, z, f, xi, yi, zi);
 %! [xi, yi, zi] = ndgrid (xi, yi, zi);
-%! assert (fi, xi + yi + zi)
+%! assert (fi, xi + yi + zi);
 
 %!test
-%! xi = 0:2;
-%! yi = 1:4;
-%! zi = 2:6;
+%! xi = 0:2;  yi = 1:4;  zi = 2:6;
 %! [x, y, z] = ndgrid (xi, yi, zi);
 %! f = x + y + z;
 %! fi = interpn (x, y, z, f, xi, yi, zi, "nearest");
-%! assert (fi, x + y + z)
+%! assert (fi, x + y + z);
 
 %!test
-%! [x,y,z] = ndgrid(0:2);
-%! f = x.^2+y.^2+z.^2;
-%! assert (interpn(x,y,-z,f,1.5,1.5,-1.5), 7.5)
+%! [x,y,z] = ndgrid (0:2);
+%! f = x.^2 + y.^2 + z.^2;
+%! assert (interpn (x,y,-z,f,1.5,1.5,-1.5), 7.5);
 
-%!test % for Matlab-compatible rounding for 'nearest'
-%! X = meshgrid (1:4);
-%! assert (interpn (X, 2.5, 2.5, 'nearest'), 3);
+%!test  # for Matlab-compatible rounding for "nearest"
+%! x = meshgrid (1:4);
+%! assert (interpn (x, 2.5, 2.5, "nearest"), 3);
 
-%!shared z, zout, tol
+%!test
 %! z = zeros (3, 3, 3);
 %! zout = zeros (5, 5, 5);
 %! z(:,:,1) = [1 3 5; 3 5 7; 5 7 9];
@@ -303,12 +308,13 @@
 %! z(:,:,3) = z(:,:,2) + 2;
 %! for n = 1:5
 %!   zout(:,:,n) = [1 2 3 4 5;
-%!                  2 3 4 5 6; 
+%!                  2 3 4 5 6;
 %!                  3 4 5 6 7;
 %!                  4 5 6 7 8;
 %!                  5 6 7 8 9] + (n-1);
-%! end
-%! tol = 10 * eps;
-%!assert (interpn (z), zout, tol)
-%!assert (interpn (z, "linear"), zout, tol)
-%!assert (interpn (z, "spline"), zout, tol)
+%! endfor
+%! tol = 10*eps;
+%! assert (interpn (z), zout, tol);
+%! assert (interpn (z, "linear"), zout, tol);
+%! assert (interpn (z, "spline"), zout, tol);
+
--- a/scripts/general/isa.m
+++ b/scripts/general/isa.m
@@ -51,6 +51,7 @@
 
 endfunction
 
+
 %!assert (isa ("char", "float"), false)
 %!assert (isa (logical (1), "float"), false)
 %!assert (isa (double (13), "float"), true)
@@ -76,20 +77,20 @@
 %!assert (isa (uint32 (13), "numeric"), true)
 %!assert (isa (uint64 (13), "numeric"), true)
 
-%!assert (isa (double (13), "double"));
-%!assert (isa (single (13), "single"));
-%!assert (isa (int8 (13), "int8"));
-%!assert (isa (int16 (13), "int16"));
-%!assert (isa (int32 (13), "int32"));
-%!assert (isa (int64 (13), "int64"));
-%!assert (isa (uint8 (13), "uint8"));
-%!assert (isa (uint16 (13), "uint16"));
-%!assert (isa (uint32 (13), "uint32"));
-%!assert (isa (uint64 (13), "uint64"));
-%!assert (isa ("string", "char"));
-%!assert (isa (true, "logical"));
-%!assert (isa (false, "logical"));
-%!assert (isa ({1, 2}, "cell"));
+%!assert (isa (double (13), "double"))
+%!assert (isa (single (13), "single"))
+%!assert (isa (int8 (13), "int8"))
+%!assert (isa (int16 (13), "int16"))
+%!assert (isa (int32 (13), "int32"))
+%!assert (isa (int64 (13), "int64"))
+%!assert (isa (uint8 (13), "uint8"))
+%!assert (isa (uint16 (13), "uint16"))
+%!assert (isa (uint32 (13), "uint32"))
+%!assert (isa (uint64 (13), "uint64"))
+%!assert (isa ("string", "char"))
+%!assert (isa (true, "logical"))
+%!assert (isa (false, "logical"))
+%!assert (isa ({1, 2}, "cell"))
 %!test
 %! a.b = 1;
 %! assert (isa (a, "struct"));
--- a/scripts/general/isdir.m
+++ b/scripts/general/isdir.m
@@ -32,8 +32,9 @@
 
 endfunction
 
-%!error isdir ();
-%!error isdir (1, 2);
+%!assert (isdir (pwd ()))
+%!assert (! isdir ("this is highly unlikely to be a directory name"))
 
-%!assert (isdir (pwd ()));
-%!assert (! isdir ("this is highly unlikely to be a directory name"));
+%!error isdir ()
+%!error isdir (1, 2)
+
--- a/scripts/general/isequal.m
+++ b/scripts/general/isequal.m
@@ -32,12 +32,13 @@
 
 endfunction
 
+
 ## test size and shape
-%!assert(isequal([1,2,3,4],[1,2,3,4]), true)
-%!assert(isequal([1;2;3;4],[1;2;3;4]), true)
-%!assert(isequal([1,2,3,4],[1;2;3;4]), false)
-%!assert(isequal([1,2,3,4],[1,2;3,4]), false)
-%!assert(isequal([1,2,3,4],[1,3;2,4]), false)
+%!assert (isequal ([1,2,3,4],[1,2,3,4]), true)
+%!assert (isequal ([1;2;3;4],[1;2;3;4]), true)
+%!assert (isequal ([1,2,3,4],[1;2;3;4]), false)
+%!assert (isequal ([1,2,3,4],[1,2;3,4]), false)
+%!assert (isequal ([1,2,3,4],[1,3;2,4]), false)
 
 %!test
 %! A = 1:8;
@@ -55,20 +56,21 @@
 %! assert (isequal (A, B), false);
 
 ## test for equality
-%!assert(isequal([1,2,3,4],[1,2,3,4]), true)
-%!assert(isequal(['a','b','c','d'],['a','b','c','d']), true)
+%!assert (isequal ([1,2,3,4],[1,2,3,4]), true)
+%!assert (isequal (['a','b','c','d'],['a','b','c','d']), true)
 ## Test multi-line strings
-%!assert(isequal(["test";"strings"],["test";"strings"],["test";"strings"]), true)
+%!assert (isequal (["test";"strings"],["test";"strings"],["test";"strings"]), true)
 ## test for inequality
-%!assert(isequal([1,2,3,4],[1;2;3;4]),false)
-%!assert(isequal({1,2,3,4},[1,2,3,4]),false)
-%!assert(isequal([1,2,3,4],{1,2,3,4}),false)
-%!assert(isequal([1,2,NaN,4],[1,2,NaN,4]),false)
-%!assert(isequal(['a','b','c','d'],['a';'b';'c';'d']),false)
-%!assert(isequal({'a','b','c','d'},{'a';'b';'c';'d'}),false)
+%!assert (isequal ([1,2,3,4],[1;2;3;4]), false)
+%!assert (isequal ({1,2,3,4},[1,2,3,4]), false)
+%!assert (isequal ([1,2,3,4],{1,2,3,4}), false)
+%!assert (isequal ([1,2,NaN,4],[1,2,NaN,4]), false)
+%!assert (isequal (['a','b','c','d'],['a';'b';'c';'d']), false)
+%!assert (isequal ({'a','b','c','d'},{'a';'b';'c';'d'}), false)
 ## test for equality (struct)
-%!assert(isequal(struct('a',1,'b',2),struct('a',1,'b',2)),true)
-%!assert(isequal(struct('a',1,'b',2),struct('a',1,'b',2),struct('a',1,'b',2)),true)
-%!assert(isequal(struct('a','abc','b',2),struct('a','abc','b',2)),true)
+%!assert (isequal (struct ('a',1,'b',2),struct ('a',1,'b',2)), true)
+%!assert (isequal (struct ('a',1,'b',2),struct ('a',1,'b',2),struct ('a',1,'b',2)), true)
+%!assert (isequal (struct ('a',"abc",'b',2),struct ('a',"abc",'b',2)), true)
 ## test for inequality (struct)
-%!assert(isequal(struct('a',NaN,'b',2),struct('a',NaN,'b',2),struct('a',NaN,'b',2)),false)
+%!assert (isequal (struct ('a',NaN,'b',2),struct ('a',NaN,'b',2),struct ('a',NaN,'b',2)), false)
+
--- a/scripts/general/isequalwithequalnans.m
+++ b/scripts/general/isequalwithequalnans.m
@@ -33,12 +33,14 @@
 
 endfunction
 
+
 ## test for equality
-%!assert(isequalwithequalnans({1,2,NaN,4},{1,2,NaN,4}), true)
-%!assert(isequalwithequalnans([1,2,NaN,4],[1,2,NaN,4]), true)
+%!assert (isequalwithequalnans ({1,2,NaN,4},{1,2,NaN,4}), true)
+%!assert (isequalwithequalnans ([1,2,NaN,4],[1,2,NaN,4]), true)
 ## test for inequality
-%!assert(isequalwithequalnans([1,2,NaN,4],[1,NaN,3,4]),false)
-%!assert(isequalwithequalnans([1,2,NaN,4],[1,2,3,4]),false)
+%!assert (isequalwithequalnans ([1,2,NaN,4],[1,NaN,3,4]), false)
+%!assert (isequalwithequalnans ([1,2,NaN,4],[1,2,3,4]), false)
 ## test for equality (struct)
-%!assert(isequalwithequalnans(struct('a',NaN,'b',2),struct('a',NaN,'b',2),struct('a',NaN,'b',2)),true)
-%!assert(isequalwithequalnans(1,2,1), false)
+%!assert (isequalwithequalnans (struct ('a',NaN,'b',2),struct ('a',NaN,'b',2),struct ('a',NaN,'b',2)), true)
+%!assert (isequalwithequalnans (1,2,1), false)
+
--- a/scripts/general/issquare.m
+++ b/scripts/general/issquare.m
@@ -41,22 +41,23 @@
 
 endfunction
 
-%!assert(issquare ([]));
-%!assert(issquare (1));
-%!assert(!(issquare ([1, 2])));
-%!assert(issquare ([1, 2; 3, 4]));
-%!assert(!(issquare ([1, 2; 3, 4; 5, 6])));
-%!assert(!(issquare (ones (3,3,3))));
-%!assert(issquare ("t"));
-%!assert(!(issquare ("test")));
-%!assert(issquare (["test"; "ing"; "1"; "2"]));
+
+%!assert (issquare ([]))
+%!assert (issquare (1))
+%!assert (! issquare ([1, 2]))
+%!assert (issquare ([1, 2; 3, 4]))
+%!assert (! issquare ([1, 2; 3, 4; 5, 6]))
+%!assert (! issquare (ones (3,3,3)))
+%!assert (issquare ("t"))
+%!assert (! issquare ("test"))
+%!assert (issquare (["test"; "ing"; "1"; "2"]))
 %!test
 %! s.a = 1;
-%! assert(issquare (s));
-%!assert(issquare ({1, 2; 3, 4}));
-%!assert(sparse (([1, 2; 3, 4])));
+%! assert (issquare (s));
+%!assert (issquare ({1, 2; 3, 4}))
+%!assert (sparse (([1, 2; 3, 4])))
 
 %% Test input validation
-%!error issquare ();
-%!error issquare ([1, 2; 3, 4], 2);
+%!error issquare ()
+%!error issquare ([1, 2; 3, 4], 2)
 
--- a/scripts/general/loadobj.m
+++ b/scripts/general/loadobj.m
@@ -37,5 +37,5 @@
 ## @end deftypefn
 
 function b = loadobj (a)
-  error ("loadobj: not defined for class \"%s\"", class(a));
+  error ('loadobj: not defined for class "%s"', class (a));
 endfunction
--- a/scripts/general/logspace.m
+++ b/scripts/general/logspace.m
@@ -91,9 +91,9 @@
 %! assert (size (x4) == [1, 10] && x4(1) == 10 && abs (x4(10) - pi) < sqrt (eps));
 
 %% Test input validation
-%!error logspace ();
-%!error logspace (1, 2, 3, 4);
-%!error logspace ([1, 2; 3, 4], 5, 6);
-%!error logspace (1, [1, 2; 3, 4], 6);
-%!error logspace (1, 2, [1, 2; 3, 4]);
+%!error logspace ()
+%!error logspace (1, 2, 3, 4)
+%!error logspace ([1, 2; 3, 4], 5, 6)
+%!error logspace (1, [1, 2; 3, 4], 6)
+%!error logspace (1, 2, [1, 2; 3, 4])
 
--- a/scripts/general/nargchk.m
+++ b/scripts/general/nargchk.m
@@ -63,18 +63,19 @@
 
 ## Tests
 %!shared stnul, stmin, stmax
-%!  stnul = resize (struct ("message", "", "identifier", ""), 0, 1);
-%!  stmin = struct ("message", "not enough input arguments",
-%!                  "identifier", "Octave:nargchk:not-enough-inputs");
-%!  stmax = struct ("message", "too many input arguments",
-%!                  "identifier", "Octave:nargchk:too-many-inputs");
+%! stnul = resize (struct ("message", "", "identifier", ""), 0, 1);
+%! stmin = struct ("message", "not enough input arguments",
+%!                 "identifier", "Octave:nargchk:not-enough-inputs");
+%! stmax = struct ("message", "too many input arguments",
+%!                 "identifier", "Octave:nargchk:too-many-inputs");
 %!assert (nargchk (0, 1, 0), "")
 %!assert (nargchk (0, 1, 1), "")
 %!assert (nargchk (1, 1, 0), "not enough input arguments")
 %!assert (nargchk (0, 1, 2), "too many input arguments")
 %!assert (nargchk (0, 1, 2, "string"), "too many input arguments")
 ## Struct outputs
-%!assert (isequal (nargchk (0, 1, 0, "struct"), stnul))
-%!assert (isequal (nargchk (0, 1, 1, "struct"), stnul))
+%!assert (nargchk (0, 1, 0, "struct"), stnul)
+%!assert (nargchk (0, 1, 1, "struct"), stnul)
 %!assert (nargchk (1, 1, 0, "struct"), stmin)
 %!assert (nargchk (0, 1, 2, "struct"), stmax)
+
--- a/scripts/general/narginchk.m
+++ b/scripts/general/narginchk.m
@@ -55,6 +55,7 @@
 
 endfunction
 
+
 %!function f (nargs, varargin)
 %! narginchk (nargs(1), nargs(2));
 %!endfunction
@@ -64,6 +65,6 @@
 
 %!test
 %! f([1,1])
-
 %!test
 %! f([1,5], 2, 3, 4, 5)
+
--- a/scripts/general/nargoutchk.m
+++ b/scripts/general/nargoutchk.m
@@ -104,21 +104,21 @@
 
 endfunction
 
-## Tests
+
 %!shared stnul, stmin, stmax
-%!  stnul = resize (struct ("message", "", "identifier", ""), 0, 1);
-%!  stmin = struct ("message", "not enough output arguments",
-%!                  "identifier", "Octave:nargoutchk:not-enough-outputs");
-%!  stmax = struct ("message", "too many output arguments",
-%!                  "identifier", "Octave:nargoutchk:too-many-outputs");
+%! stnul = resize (struct ("message", "", "identifier", ""), 0, 1);
+%! stmin = struct ("message", "not enough output arguments",
+%!                 "identifier", "Octave:nargoutchk:not-enough-outputs");
+%! stmax = struct ("message", "too many output arguments",
+%!                 "identifier", "Octave:nargoutchk:too-many-outputs");
 %!assert (nargoutchk (0, 1, 0), "")
 %!assert (nargoutchk (0, 1, 1), "")
 %!assert (nargoutchk (1, 1, 0), "not enough output arguments")
 %!assert (nargoutchk (0, 1, 2), "too many output arguments")
 %!assert (nargoutchk (0, 1, 2, "string"), "too many output arguments")
 ## Struct outputs
-%!assert (isequal (nargoutchk (0, 1, 0, "struct"), stnul))
-%!assert (isequal (nargoutchk (0, 1, 1, "struct"), stnul))
+%!assert (nargoutchk (0, 1, 0, "struct"), stnul)
+%!assert (nargoutchk (0, 1, 1, "struct"), stnul)
 %!assert (nargoutchk (1, 1, 0, "struct"), stmin)
 %!assert (nargoutchk (0, 1, 2, "struct"), stmax)
 
--- a/scripts/general/nextpow2.m
+++ b/scripts/general/nextpow2.m
@@ -56,13 +56,15 @@
 
 endfunction
 
-%!error nexpow2 ();
-%!error nexpow2 (1, 2);
 
-%!assert (nextpow2 (16), 4);
-%!assert (nextpow2 (17), 5);
-%!assert (nextpow2 (31), 5);
-%!assert (nextpow2 (-16), 4);
-%!assert (nextpow2 (-17), 5);
-%!assert (nextpow2 (-31), 5);
-%!assert (nextpow2 (1:17), 5);
+%!assert (nextpow2 (16), 4)
+%!assert (nextpow2 (17), 5)
+%!assert (nextpow2 (31), 5)
+%!assert (nextpow2 (-16), 4)
+%!assert (nextpow2 (-17), 5)
+%!assert (nextpow2 (-31), 5)
+%!assert (nextpow2 (1:17), 5)
+
+%!error nexpow2 ()
+%!error nexpow2 (1, 2)
+
--- a/scripts/general/nthargout.m
+++ b/scripts/general/nthargout.m
@@ -34,7 +34,7 @@
 ## @example
 ## @group
 ## @var{m} = magic (5);
-## cell2mat (nthargout ([1, 2], @@ind2sub, size(@var{m}),
+## cell2mat (nthargout ([1, 2], @@ind2sub, size (@var{m}),
 ##                      nthargout (2, @@max, @var{m}(:))))
 ## @result{} 5   3
 ## @end group
@@ -45,7 +45,7 @@
 ##
 ## @example
 ## @group
-## @var{m} = magic(5);
+## @var{m} = magic (5);
 ## [~, idx] = max (@var{M}(:));
 ## [i, j] = ind2sub (size (@var{m}), idx);
 ## [i, j]
@@ -107,7 +107,9 @@
 
 endfunction
 
+
 %!shared m
 %! m = magic (5);
-%!assert (nthargout ([1, 2], @ind2sub, size(m), nthargout (2, @max, m(:))), {5,3}) 
+%!assert (nthargout ([1,2], @ind2sub, size (m), nthargout (2, @max, m(:))), {5,3})
 %!assert (nthargout (3, @find, m(m>20)), [23, 24, 25, 21, 22]')
+
--- a/scripts/general/num2str.m
+++ b/scripts/general/num2str.m
@@ -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,67 +148,40 @@
     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
 
-%!assert ((strcmp (num2str (123), "123") && strcmp (num2str (1.23), "1.23")));
-%!assert (num2str (123.456, 4), "123.5");
-%!assert (all (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");
-%!error num2str ();
-%!error num2str (1, 2, 3);
+
+%!assert (num2str (123), "123")
+%!assert (num2str (1.23), "1.23")
+%!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/general/pol2cart.m
+++ b/scripts/general/pol2cart.m
@@ -80,27 +80,28 @@
 
 endfunction
 
+
 %!test
 %! t = [0, 0.5, 1] * pi;
 %! r = 1;
 %! [x, y] = pol2cart (t, r);
-%! assert (x, [1, 0, -1], sqrt(eps));
-%! assert (y, [0, 1,  0], sqrt(eps));
+%! assert (x, [1, 0, -1], sqrt (eps));
+%! assert (y, [0, 1,  0], sqrt (eps));
 
 %!test
 %! t = [0, 1, 1] * pi/4;
-%! r = sqrt(2) * [0, 1, 2];
+%! r = sqrt (2) * [0, 1, 2];
 %! [x, y] = pol2cart (t, r);
-%! assert (x, [0, 1, 2], sqrt(eps));
-%! assert (y, [0, 1, 2], sqrt(eps));
+%! assert (x, [0, 1, 2], sqrt (eps));
+%! assert (y, [0, 1, 2], sqrt (eps));
 
 %!test
 %! t = [0, 1, 1] * pi/4;
-%! r = sqrt(2) * [0, 1, 2];
+%! r = sqrt (2) * [0, 1, 2];
 %! z = [0, 1, 2];
 %! [x, y, z2] = pol2cart (t, r, z);
-%! assert (x, [0, 1, 2], sqrt(eps));
-%! assert (y, [0, 1, 2], sqrt(eps));
+%! assert (x, [0, 1, 2], sqrt (eps));
+%! assert (y, [0, 1, 2], sqrt (eps));
 %! assert (z, z2);
 
 %!test
@@ -108,8 +109,8 @@
 %! r = [0, 1, 2];
 %! z = [0, 1, 2];
 %! [x, y, z2] = pol2cart (t, r, z);
-%! assert (x, [0, 1, 2], sqrt(eps));
-%! assert (y, [0, 0, 0], sqrt(eps));
+%! assert (x, [0, 1, 2], sqrt (eps));
+%! assert (y, [0, 0, 0], sqrt (eps));
 %! assert (z, z2);
 
 %!test
@@ -117,8 +118,8 @@
 %! r = 1;
 %! z = [0, 1, 2];
 %! [x, y, z2] = pol2cart (t, r, z);
-%! assert (x, [1, 1, 1] / sqrt(2), eps);
-%! assert (y, [1, 1, 1] / sqrt(2), eps);
+%! assert (x, [1, 1, 1] / sqrt (2), eps);
+%! assert (y, [1, 1, 1] / sqrt (2), eps);
 %! assert (z, z2);
 
 %!test
@@ -127,16 +128,16 @@
 %! z = 1;
 %! [x, y, z2] = pol2cart (t, r, z);
 %! assert (x, [1, 2, 3], eps);
-%! assert (y, [0, 0, 0] / sqrt(2), eps);
+%! assert (y, [0, 0, 0] / sqrt (2), eps);
 %! assert (z, z2);
 
 %!test
 %! P = [0, 0; pi/4, sqrt(2); pi/4, 2*sqrt(2)];
 %! C = [0, 0; 1, 1; 2, 2];
-%! assert (pol2cart(P), C, sqrt(eps));
+%! assert (pol2cart (P), C, sqrt (eps));
 
 %!test
 %! P = [0, 0, 0; pi/4, sqrt(2), 1; pi/4, 2*sqrt(2), 2];
 %! C = [0, 0, 0; 1, 1, 1; 2, 2, 2];
-%! assert (pol2cart(P), C, sqrt(eps));
+%! assert (pol2cart (P), C, sqrt (eps));
 
--- a/scripts/general/polyarea.m
+++ b/scripts/general/polyarea.m
@@ -61,10 +61,12 @@
   endif
 endfunction
 
+
 %!shared x, y
 %! x = [1;1;3;3;1];
 %! y = [1;3;3;1;1];
-%!assert (polyarea(x,y), 4, eps)
-%!assert (polyarea([x,x],[y,y]), [4,4], eps)
-%!assert (polyarea([x,x],[y,y],1), [4,4], eps)
-%!assert (polyarea([x,x]',[y,y]',2), [4;4], eps)
+%!assert (polyarea (x,y), 4, eps)
+%!assert (polyarea ([x,x],[y,y]), [4,4], eps)
+%!assert (polyarea ([x,x],[y,y],1), [4,4], eps)
+%!assert (polyarea ([x,x]',[y,y]',2), [4;4], eps)
+
--- a/scripts/general/postpad.m
+++ b/scripts/general/postpad.m
@@ -83,15 +83,15 @@
 
 endfunction
 
-%!error postpad ();
-%!error postpad (1);
-%!error postpad (1,2,3,4,5);
-%!error postpad ([1,2], 2, 2,3);
 
-%!assert (postpad ([1,2], 4), [1,2,0,0]);
-%!assert (postpad ([1;2], 4), [1;2;0;0]);
+%!assert (postpad ([1,2], 4), [1,2,0,0])
+%!assert (postpad ([1;2], 4), [1;2;0;0])
+%!assert (postpad ([1,2], 4, 2), [1,2,2,2])
+%!assert (postpad ([1;2], 4, 2), [1;2;2;2])
+%!assert (postpad ([1,2], 2, 2, 1), [1,2;2,2])
 
-%!assert (postpad ([1,2], 4, 2), [1,2,2,2]);
-%!assert (postpad ([1;2], 4, 2), [1;2;2;2]);
+%!error postpad ()
+%!error postpad (1)
+%!error postpad (1,2,3,4,5)
+%!error postpad ([1,2], 2, 2,3)
 
-%!assert (postpad ([1,2], 2, 2, 1), [1,2;2,2]);
--- a/scripts/general/prepad.m
+++ b/scripts/general/prepad.m
@@ -46,7 +46,7 @@
     c = 0;
   else
     if (! isscalar (c))
-      error ("prepad: third argument must be empty or a scalar");
+      error ("prepad: pad value C must be empty or a scalar");
     endif
   endif
 
@@ -63,7 +63,7 @@
   endif
 
   if (! isscalar (l) || l < 0)
-    error ("prepad: second argument must be a positive scaler");
+    error ("prepad: length L must be a positive scalar");
   endif
 
   if (dim > nd)
@@ -83,17 +83,24 @@
 
 endfunction
 
-%!error prepad ();
-%!error prepad (1);
-%!error prepad (1,2,3,4,5);
-%!error prepad ([1,2], 2, 2,3);
+
+%!assert (prepad ([1,2], 4), [0,0,1,2])
+%!assert (prepad ([1;2], 4), [0;0;1;2])
 
-%!assert (prepad ([1,2], 4), [0,0,1,2]);
-%!assert (prepad ([1;2], 4), [0;0;1;2]);
+%!assert (prepad ([1,2], 4, 2), [2,2,1,2])
+%!assert (prepad ([1;2], 4, 2), [2;2;1;2])
 
-%!assert (prepad ([1,2], 4, 2), [2,2,1,2]);
-%!assert (prepad ([1;2], 4, 2), [2;2;1;2]);
-
-%!assert (prepad ([1,2], 2, 2, 1), [2,2;1,2]);
+%!assert (prepad ([1,2], 2, 2, 1), [2,2;1,2])
 
 ## FIXME -- we need tests for multidimensional arrays.
+
+%!error prepad ()
+%!error prepad (1)
+%!error prepad (1,2,3,4,5)
+%!error <C must be empty or a scalar> prepad ([1,2], 2, ones (2))
+%!error <DIM must be an integer> prepad ([1,2], 2, 2, ones (3))
+%!error <DIM must be an integer> prepad ([1,2], 2, 2, 1.1)
+%!error <DIM must be an integer> prepad ([1,2], 2, 2, 3)
+%!error <L must be a positive scalar> prepad ([1,2], ones (2))
+%!error <L must be a positive scalar> prepad ([1,2], -1)
+
--- a/scripts/general/private/__isequal__.m
+++ b/scripts/general/private/__isequal__.m
@@ -58,7 +58,7 @@
 
   ## All arguments must either be of the same class or they must be
   ## numeric values.
-  t = (all (strcmp (class(x),
+  t = (all (strcmp (class (x),
                     cellfun ("class", varargin, "uniformoutput", false)))
        || ((isnumeric (x) || islogical (x))
            && all (cellfun ("isnumeric", varargin)
--- a/scripts/general/private/__splinen__.m
+++ b/scripts/general/private/__splinen__.m
@@ -31,18 +31,18 @@
   endif
   ## ND isvector function.
   isvec = @(x) numel (x) == length (x);
-  if (!iscell (x) || length(x) < ndims(y) || any (! cellfun (isvec, x))
-      || !iscell (xi) || length(xi) < ndims(y) || any (! cellfun (isvec, xi)))
+  if (!iscell (x) || length (x) < ndims (y) || any (! cellfun (isvec, x))
+      || !iscell (xi) || length (xi) < ndims (y) || any (! cellfun (isvec, xi)))
     error ("__splinen__: %s: non gridded data or dimensions inconsistent", f);
   endif
   yi = y;
-  for i = length(x):-1:1
+  for i = length (x):-1:1
     yi = permute (spline (x{i}, yi, xi{i}(:)), [length(x),1:length(x)-1]);
   endfor
 
   [xi{:}] = ndgrid (cellfun (@(x) x(:), xi, "uniformoutput", false){:});
-  idx = zeros (size(xi{1}));
-  for i = 1 : length(x)
+  idx = zeros (size (xi{1}));
+  for i = 1 : length (x)
     idx |= xi{i} < min (x{i}(:)) | xi{i} > max (x{i}(:));
   endfor
   yi(idx) = extrapval;
--- a/scripts/general/profexplore.m
+++ b/scripts/general/profexplore.m
@@ -21,7 +21,7 @@
 ## Interactively explore hierarchical profiler output.
 ##
 ## Assuming @var{data} is the structure with profile data returned by
-## @code{profile ('info')}, this command opens an interactive prompt
+## @code{profile ("info")}, this command opens an interactive prompt
 ## that can be used to explore the call-tree.  Type @kbd{help} to get a list
 ## of possible commands.
 ## @seealso{profile, profshow}
@@ -32,7 +32,7 @@
 
 function profexplore (data)
 
-  if (nargin ~= 1)
+  if (nargin != 1)
     print_usage ();
   endif
 
@@ -45,7 +45,7 @@
 endfunction
 
 ## This is the worker function.  tree is the current subtree we want to
-## display / explore.  parents is a string containing the already 'rendered'
+## display / explore.  parents is a string containing the already "rendered"
 ## data for the parents which is displayed on top of the list of current
 ## children.  prefix is the prefix to add to each line rendered; this
 ## is just a string of spaces to get indentation right.
@@ -87,7 +87,7 @@
       printf ("help   Display this help message.\n");
       printf ("up [N] Go up N levels, where N is an integer.  Default is 1.\n");
       printf ("N      Go down a level into option N.\n");
-    elseif (~isnan (option))
+    elseif (! isnan (option))
       if (option < 1 || option > length (tree))
         printf ("The chosen option is out of range!\n");
       else
@@ -115,7 +115,7 @@
 
       if (length (cmd) > 3 && cmd(3) == ' ')
         opt = fix (str2double (substr (cmd, 3)));
-        if (~isnan (opt) && opt > 0)
+        if (! isnan (opt) && opt > 0)
           rv = opt;
           return;
         endif
--- a/scripts/general/profile.m
+++ b/scripts/general/profile.m
@@ -21,8 +21,8 @@
 ## @deftypefnx {Command} {} profile off
 ## @deftypefnx {Command} {} profile resume
 ## @deftypefnx {Command} {} profile clear
-## @deftypefnx {Function File} {@var{S} =} profile ('status')
-## @deftypefnx {Function File} {@var{T} =} profile ('info')
+## @deftypefnx {Function File} {@var{S} =} profile ("status")
+## @deftypefnx {Function File} {@var{T} =} profile ("info")
 ## Control the built-in profiler.
 ##
 ## @table @code
@@ -32,7 +32,7 @@
 ##
 ## @item profile off
 ## Stop profiling.  The collected data can later be retrieved and examined
-## with calls like @code{S = profile ('info')}.
+## with calls like @code{S = profile ("info")}.
 ##
 ## @item profile clear
 ## Clear all collected profiler data.
@@ -41,12 +41,12 @@
 ## Restart profiling without cleaning up the old data and instead
 ## all newly collected statistics are added to the already existing ones.
 ##
-## @item @var{S} = profile ('status')
+## @item @var{S} = profile ("status")
 ## Return a structure filled with certain information about the current status
 ## of the profiler.  At the moment, the only field is @code{ProfilerStatus}
-## which is either 'on' or 'off'.
+## which is either "on" or "off".
 ##
-## @item @var{T} = profile ('info')
+## @item @var{T} = profile ("info")
 ## Return the collected profiling statistics in the structure @var{T}.
 ## The flat profile is returned in the field @code{FunctionTable} which is an
 ## array of structures, each entry corresponding to a function which was called
@@ -69,31 +69,31 @@
   endif
 
   switch (option)
-    case 'on'
+    case "on"
       __profiler_reset__ ();
       __profiler_enable__ (true);
 
-    case 'off'
+    case "off"
       __profiler_enable__ (false);
 
-    case 'clear'
+    case "clear"
       __profiler_reset__ ();
 
-    case 'resume'
+    case "resume"
       __profiler_enable__ (true);
 
-    case 'status'
+    case "status"
       enabled = __profiler_enable__ ();
       if (enabled)
-        enabled = 'on';
+        enabled = "on";
       else
-        enabled = 'off';
+        enabled = "off";
       endif
-      retval = struct ('ProfilerStatus', enabled);
+      retval = struct ("ProfilerStatus", enabled);
 
-    case 'info'
+    case "info"
       [flat, tree] = __profiler_data__ ();
-      retval = struct ('FunctionTable', flat, 'Hierarchical', tree);
+      retval = struct ("FunctionTable", flat, "Hierarchical", tree);
 
     otherwise
       warning ("profile: Unrecognized option '%s'", option);
@@ -105,47 +105,50 @@
 
 
 %!demo
-%! profile ('on');
+%! profile on;
 %! A = rand (100);
 %! B = expm (A);
-%! profile ('off');
-%! profile ('resume');
+%! profile off;
+%! profile resume;
 %! C = sqrtm (A);
-%! profile ('off');
-%! T = profile ('info');
+%! profile off;
+%! T = profile ("info");
 %! profshow (T);
 
-%!error profile ();
-%!error profile ('on', 2);
-
 %!test
 %! on_struct.ProfilerStatus = "on";
 %! off_struct.ProfilerStatus = "off";
-%! profile ('on');
+%! profile ("on");
 %! result = logm (rand (200) + 10 * eye (200));
-%! assert (profile ('status'), on_struct);
-%! profile ('off');
-%! assert (profile ('status'), off_struct);
-%! profile ('resume');
+%! assert (profile ("status"), on_struct);
+%! profile ("off");
+%! assert (profile ("status"), off_struct);
+%! profile ("resume");
 %! result = logm (rand (200) + 10 * eye (200));
-%! profile ('off');
-%! assert (profile ('status'), off_struct);
-%! info = profile ('info');
+%! profile ("off");
+%! assert (profile ("status"), off_struct);
+%! info = profile ("info");
 %! assert (isstruct (info));
 %! assert (size (info), [1, 1]);
-%! assert (fieldnames (info), {'FunctionTable'; 'Hierarchical'});
+%! assert (fieldnames (info), {"FunctionTable"; "Hierarchical"});
 %! ftbl = info.FunctionTable;
-%! assert (fieldnames (ftbl), {'FunctionName'; 'TotalTime'; 'NumCalls'; 'IsRecursive'; 'Parents'; 'Children'});
+%! assert (fieldnames (ftbl), {"FunctionName"; "TotalTime"; "NumCalls"; "IsRecursive"; "Parents"; "Children"});
 %! hier = info.Hierarchical;
-%! assert (fieldnames (hier), {'Index'; 'SelfTime'; 'TotalTime'; 'NumCalls'; 'Children'});
-%! profile ('clear');
-%! info = profile ('info');
+%! assert (fieldnames (hier), {"Index"; "SelfTime"; "TotalTime"; "NumCalls"; "Children"});
+%! profile ("clear");
+%! info = profile ("info");
 %! assert (isstruct (info));
 %! assert (size (info), [1, 1]);
-%! assert (fieldnames (info), {'FunctionTable'; 'Hierarchical'});
+%! assert (fieldnames (info), {"FunctionTable"; "Hierarchical"});
 %! ftbl = info.FunctionTable;
 %! assert (size (ftbl), [0, 1]);
-%! assert (fieldnames (ftbl), {'FunctionName'; 'TotalTime'; 'NumCalls'; 'IsRecursive'; 'Parents'; 'Children'});
+%! assert (fieldnames (ftbl), {"FunctionName"; "TotalTime"; "NumCalls"; "IsRecursive"; "Parents"; "Children"});
 %! hier = info.Hierarchical;
 %! assert (size (hier), [0, 1]);
-%! assert (fieldnames (hier), {'Index'; 'SelfTime'; 'NumCalls'; 'Children'});
+%! assert (fieldnames (hier), {"Index"; "SelfTime"; "NumCalls"; "Children"});
+
+%% Test input validation
+%!error profile ()
+%!error profile ("on", 2)
+%!error profile ("INVALID_OPTION")
+
--- a/scripts/general/profshow.m
+++ b/scripts/general/profshow.m
@@ -22,7 +22,7 @@
 ## Show flat profiler results.
 ##
 ## This command prints out profiler data as a flat profile.  @var{data} is the
-## structure returned by @code{profile ('info')}.  If @var{n} is given, it
+## structure returned by @code{profile ("info")}.  If @var{n} is given, it
 ## specifies the number of functions to show in the profile; functions are
 ## sorted in descending order by total time spent in them.  If there are more
 ## than @var{n} included in the profile, those will not be shown.  @var{n}
@@ -81,20 +81,24 @@
 
 endfunction
 
+
 %!demo
-%! profile ("on");
+%! profile on;
 %! A = rand (100);
 %! B = expm (A);
-%! profile ("off");
+%! profile off;
 %! T = profile ("info");
 %! profshow (T, 10);
 
 %!demo
-%! profile ("on");
+%! profile on;
 %! expm (rand (500) + eye (500));
-%! profile ("off");
+%! profile off;
 %! profshow (profile ("info"), 5);
 
-%!error profshow ();
-%!error profshow (1, 2, 3);
-%!error profshow (struct (), 1.2);
+%!error profshow ()
+%!error profshow (1, 2, 3)
+%!error <N must be a positive integer> profshow (struct (), ones (2))
+%!error <N must be a positive integer> profshow (struct (), 1+i)
+%!error <N must be a positive integer> profshow (struct (), -1)
+
--- a/scripts/general/quadgk.m
+++ b/scripts/general/quadgk.m
@@ -78,7 +78,7 @@
 ## unacceptable error are subdivided and re-evaluated.  If the number of
 ## subintervals exceeds 650 subintervals at any point then a poor
 ## convergence is signaled and the current estimate of the integral is
-## returned.  The property 'MaxIntervalCount' can be used to alter the
+## returned.  The property "MaxIntervalCount" can be used to alter the
 ## number of subintervals that can exist before exiting.
 ##
 ## @item WayPoints
@@ -162,7 +162,7 @@
               abstol = varargin{idx++};
             elseif (strcmpi (str, "waypoints"))
               waypoints = varargin{idx++} (:);
-              if (isreal(waypoints))
+              if (isreal (waypoints))
                 waypoints (waypoints < a | waypoints > b) = [];
               endif
             elseif (strcmpi (str, "maxintervalcount"))
@@ -190,13 +190,13 @@
     ## Use variable subsitution to weaken endpoint singularities and to
     ## perform integration with endpoints at infinity. No transform for
     ## contour integrals
-    if (iscomplex (a) || iscomplex (b) || iscomplex(waypoints))
+    if (iscomplex (a) || iscomplex (b) || iscomplex (waypoints))
       ## contour integral, no transform
       subs = [a; waypoints; b];
       h = sum (abs (diff (subs)));
       h0 = h;
       trans = @(t) t;
-    elseif (isinf (a) && isinf(b))
+    elseif (isinf (a) && isinf (b))
       ## Standard Infinite to finite integral transformation.
       ##   \int_{-\infinity_^\infinity f(x) dx = \int_-1^1 f (g(t)) g'(t) dt
       ## where
@@ -205,7 +205,7 @@
       ## waypoint transform is then
       ##   t =  (2 * g(t)) ./ (1 + sqrt(1 + 4 * g(t) .^ 2))
       if (!isempty (waypoints))
-        trans = @(x) (2 * x) ./ (1 + sqrt(1 + 4 * x .^ 2));
+        trans = @(x) (2 * x) ./ (1 + sqrt (1 + 4 * x .^ 2));
         subs = [-1; trans(waypoints); 1];
       else
         subs = linspace (-1, 1, 11)';
@@ -240,7 +240,7 @@
       h0 = b - a;
       trans = @(t) b - (t ./ (1 + t)).^2;
       f = @(s) - 2 * s .* f (b -  (s ./ (1 + s)) .^ 2) ./ ((1 + s) .^ 3);
-    elseif (isinf(b))
+    elseif (isinf (b))
       ## Formula defined in Shampine paper as two separate steps. One to
       ## weaken singularity at finite end, then a second to transform to
       ## a finite interval. The singularity weakening transform is
@@ -281,7 +281,7 @@
         trans = @__quadgk_finite_waypoint__;
         subs = [-1; trans(waypoints, a, b); 1];
       else
-        subs = linspace(-1, 1, 11)';
+        subs = linspace (-1, 1, 11)';
       endif
       h = 2;
       h0 = b - a;
@@ -343,7 +343,7 @@
         endif
 
         ## Accept the subintervals that meet the convergence criteria
-        idx = find (abs (q_errs) < tol .* abs(diff (subs, [], 2)) ./ h);
+        idx = find (abs (q_errs) < tol .* abs (diff (subs, [], 2)) ./ h);
         if (first)
           q = sum (q_subs (idx));
           err = sum (q_errs(idx));
@@ -362,7 +362,7 @@
         endif
 
         if (trace)
-          disp([rows(subs), err, q0]);
+          disp ([rows(subs), err, q0]);
         endif
 
         ## Split remaining subintervals in two
@@ -382,7 +382,7 @@
         [q_subs, q_errs] = __quadgk_eval__ (f, subs);
       endwhile
 
-      if (err > max (abstol, reltol * abs(q)))
+      if (err > max (abstol, reltol * abs (q)))
         warning ("quadgk: Error tolerance not met. Estimated error %g", err);
       endif
     unwind_protect_cleanup
@@ -425,7 +425,7 @@
   halfwidth = diff (subs, [], 2) ./ 2;
   center = sum (subs, 2) ./ 2;;
   x = bsxfun (@plus, halfwidth * abscissa, center);
-  y = reshape (f (x(:)), size(x));
+  y = reshape (f (x(:)), size (x));
 
   ## This is faster than using bsxfun as the * operator can use a
   ## single BLAS call, rather than rows(sub) calls to the @times
@@ -436,26 +436,28 @@
 
 function t = __quadgk_finite_waypoint__ (x, a, b)
   c = (-4 .* x + 2.* (b + a)) ./ (b - a);
-  k = ((sqrt(c .^ 2 - 4) + c) ./ 2) .^ (1/3);
+  k = ((sqrt (c .^ 2 - 4) + c) ./ 2) .^ (1/3);
   t = real ((sqrt(3) .* 1i * (1 - k .^ 2) - (1 + k .^ 2)) ./ 2 ./ k);
 endfunction
 
+
+%!assert (quadgk (@sin,-pi,pi), 0, 1e-6)
+%!assert (quadgk (inline ("sin"),-pi,pi), 0, 1e-6)
+%!assert (quadgk ("sin",-pi,pi), 0, 1e-6)
+%!assert (quadgk (@sin,-pi,pi, "waypoints", 0, "MaxIntervalCount", 100, "reltol", 1e-3, "abstol", 1e-6, "trace", false), 0, 1e-6)
+%!assert (quadgk (@sin,-pi,pi, 1e-6,false), 0, 1e-6)
+
+%!assert (quadgk (@sin,-pi,0), -2, 1e-6)
+%!assert (quadgk (@sin,0,pi), 2, 1e-6)
+%!assert (quadgk (@(x) 1./sqrt (x),0,1), 2, 1e-6)
+%!assert (quadgk (@(x) abs (1 - x.^2),0,2, "Waypoints", 1), 2, 1e-6)
+%!assert (quadgk (@(x) 1./(sqrt (x) .* (x+1)),0,Inf), pi, 1e-6)
+%!assert (quadgk (@(z) log (z),1+1i,1+1i, "WayPoints", [1-1i, -1,-1i, -1+1i]), -pi * 1i, 1e-6)
+
+%!assert (quadgk (@(x) exp (-x .^ 2),-Inf,Inf), sqrt (pi), 1e-6)
+%!assert (quadgk (@(x) exp (-x .^ 2),-Inf,0), sqrt (pi)/2, 1e-6)
+
 %error (quadgk (@sin))
 %error (quadgk (@sin, -pi))
-%error (quadgk (@sin, -pi, pi, 'DummyArg'))
-
-%!assert (quadgk(@sin,-pi,pi), 0, 1e-6)
-%!assert (quadgk(inline('sin'),-pi,pi), 0, 1e-6)
-%!assert (quadgk('sin',-pi,pi), 0, 1e-6)
-%!assert (quadgk(@sin,-pi,pi,'waypoints', 0, 'MaxIntervalCount', 100, 'reltol', 1e-3, 'abstol', 1e-6, 'trace', false), 0, 1e-6)
-%!assert (quadgk(@sin,-pi,pi,1e-6,false), 0, 1e-6)
+%error (quadgk (@sin, -pi, pi, "DummyArg"))
 
-%!assert (quadgk(@sin,-pi,0), -2, 1e-6)
-%!assert (quadgk(@sin,0,pi), 2, 1e-6)
-%!assert (quadgk(@(x) 1./sqrt(x), 0, 1), 2, 1e-6)
-%!assert (quadgk (@(x) abs (1 - x.^2), 0, 2, 'Waypoints', 1), 2, 1e-6)
-%!assert (quadgk(@(x) 1./(sqrt(x).*(x+1)), 0, Inf), pi, 1e-6)
-%!assert (quadgk (@(z) log (z), 1+1i, 1+1i, 'WayPoints', [1-1i, -1,-1i, -1+1i]), -pi * 1i, 1e-6)
-
-%!assert (quadgk (@(x) exp(-x .^ 2), -Inf, Inf), sqrt(pi), 1e-6)
-%!assert (quadgk (@(x) exp(-x .^ 2), -Inf, 0), sqrt(pi)/2, 1e-6)
--- a/scripts/general/quadl.m
+++ b/scripts/general/quadl.m
@@ -136,7 +136,7 @@
   if (R > 0 && R < 1)
     tol = tol/R;
   endif
-  is = s * abs(is) * tol/myeps;
+  is = s * abs (is) * tol/myeps;
   if (is == 0)
     is = b-a;
   endif
@@ -162,7 +162,7 @@
   h = (b-a)/2;
   m = (a+b)/2;
   alpha = sqrt (2/3);
-  beta = 1 / sqrt(5);
+  beta = 1 / sqrt (5);
   mll = m-alpha*h;
   ml  = m-beta*h;
   mr  = m+beta*h;
--- a/scripts/general/quadv.m
+++ b/scripts/general/quadv.m
@@ -148,14 +148,16 @@
   endif
 endfunction
 
+
 %!assert (quadv (@sin, 0, 2 * pi), 0, 1e-5)
 %!assert (quadv (@sin, 0, pi), 2, 1e-5)
 
 %% Handles weak singularities at the edge
-%!assert (quadv (@(x) 1 ./ sqrt(x), 0, 1), 2, 1e-5)
+%!assert (quadv (@(x) 1 ./ sqrt (x), 0, 1), 2, 1e-5)
 
 %% Handles vector-valued functions
 %!assert (quadv (@(x) [(sin (x)), (sin (2 * x))], 0, pi), [2, 0], 1e-5)
 
 %% Handles matrix-valued functions
 %!assert (quadv (@(x) [ x, x, x; x, 1./sqrt(x), x; x, x, x ], 0, 1 ), [0.5, 0.5, 0.5; 0.5, 2, 0.5; 0.5, 0.5, 0.5], 1e-5)
+
--- a/scripts/general/randi.m
+++ b/scripts/general/randi.m
@@ -57,7 +57,7 @@
 function ri = randi (bounds, varargin)
 
   if (nargin < 1)
-    print_usage();
+    print_usage ();
   endif
 
   if (! (isnumeric (bounds) && isreal (bounds)))
@@ -113,29 +113,29 @@
 
 %!test
 %! ri = randi (10, 1000, 1);
-%! assert(isequal(ri, fix (ri)));
-%! assert(min(ri) == 1);
-%! assert(max(ri) == 10);
-%! assert(rows(ri) == 1000);
-%! assert(columns(ri) == 1);
-%! assert(strcmp (class (ri), "double"));
+%! assert (ri, fix (ri));
+%! assert (min (ri), 1);
+%! assert (max (ri), 10);
+%! assert (rows (ri), 1000);
+%! assert (columns (ri), 1);
+%! assert (class (ri), "double");
 %!test
 %! ri = randi ([-5, 10], 1000, 1, "int8");
-%! assert(isequal(ri, fix (ri)));
-%! assert(min(ri) == -5);
-%! assert(max(ri) == 10);
-%! assert(strcmp (class (ri), "int8"));
+%! assert (ri, fix (ri));
+%! assert (min (ri), int8 (-5));
+%! assert (max (ri), int8 (10));
+%! assert (class (ri), "int8");
 %!
-%!assert(size (randi(10, 3,1,2)) == [3, 1, 2])
+%!assert (size (randi (10, 3,1,2)), [3, 1, 2])
 
 %% Test input validation
-%!error(randi())
-%!error(randi("test"))
-%!error(randi(10+2i))
-%!error(randi(0))
-%!error(randi([10, 1]))
-%!error(randi(256, "uint8"))
-%!error(randi(2^25, "single"))
-%!error(randi(bitmax() + 1))
-%!error(randi([-1, bitmax()]))
+%!error (randi ())
+%!error (randi ("test"))
+%!error (randi (10+2i))
+%!error (randi (0))
+%!error (randi ([10, 1]))
+%!error (randi (256, "uint8"))
+%!error (randi (2^25, "single"))
+%!error (randi (bitmax () + 1))
+%!error (randi ([-1, bitmax()]))
 
--- a/scripts/general/rat.m
+++ b/scripts/general/rat.m
@@ -36,7 +36,7 @@
 ## @seealso{rats}
 ## @end deftypefn
 
-function [n,d] = rat(x,tol)
+function [n,d] = rat (x,tol)
 
   if (nargin != [1,2] || nargout > 2)
     print_usage ();
@@ -49,27 +49,27 @@
 
   ## default norm
   if (nargin < 2)
-    tol = 1e-6 * norm(y,1);
+    tol = 1e-6 * norm (y,1);
   endif
 
   ## First step in the approximation is the integer portion
 
   ## First element in the continued fraction.
-  n = round(y);
-  d = ones(size(y));
+  n = round (y);
+  d = ones (size (y));
   frac = y-n;
-  lastn = ones(size(y));
-  lastd = zeros(size(y));
+  lastn = ones (size (y));
+  lastd = zeros (size (y));
 
-  nd = ndims(y);
+  nd = ndims (y);
   nsz = numel (y);
-  steps = zeros([nsz, 0]);
+  steps = zeros ([nsz, 0]);
 
   ## Grab new factors until all continued fractions converge.
   while (1)
     ## Determine which fractions have not yet converged.
-    idx = find(abs (y-n./d) >= tol);
-    if (isempty(idx))
+    idx = find (abs (y-n./d) >= tol);
+    if (isempty (idx))
       if (isempty (steps))
         steps = NaN (nsz, 1);
       endif
@@ -79,7 +79,7 @@
     ## Grab the next step in the continued fraction.
     flip = 1./frac(idx);
     ## Next element in the continued fraction.
-    step = round(flip);
+    step = round (flip);
 
     if (nargout < 2)
       tsteps = NaN (nsz, 1);
@@ -100,23 +100,23 @@
 
   if (nargout == 2)
     ## Move the minus sign to the top.
-    n = n.*sign(d);
-    d = abs(d);
+    n = n .* sign (d);
+    d = abs (d);
 
     ## Return the same shape as you receive.
-    n = reshape(n, size(x));
-    d = reshape(d, size(x));
+    n = reshape (n, size (x));
+    d = reshape (d, size (x));
 
     ## Use 1/0 for Inf.
-    n(isinf(x)) = sign(x(isinf(x)));
-    d(isinf(x)) = 0;
+    n(isinf (x)) = sign (x(isinf (x)));
+    d(isinf (x)) = 0;
 
     ## Reshape the output.
     n = reshape (n, size (x));
     d = reshape (d, size (x));
   else
     n = "";
-    nsteps = size(steps, 2);
+    nsteps = columns (steps);
     for i = 1: nsz
       s = [int2str(y(i))," "];
       j = 1;
@@ -151,10 +151,12 @@
 
 endfunction
 
-%!error rat ();
-%!error rat (1, 2, 3);
 
 %!test
 %! [n, d] = rat ([0.5, 0.3, 1/3]);
 %! assert (n, [1, 3, 1]);
 %! assert (d, [2, 10, 3]);
+
+%!error rat ();
+%!error rat (1, 2, 3);
+
--- a/scripts/general/repmat.m
+++ b/scripts/general/repmat.m
@@ -20,12 +20,13 @@
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {} repmat (@var{A}, @var{m})
 ## @deftypefnx {Function File} {} repmat (@var{A}, @var{m}, @var{n})
-## @deftypefnx {Function File} {} repmat (@var{A}, @var{m}, @var{n}, @var{p}, @dots{})
 ## @deftypefnx {Function File} {} repmat (@var{A}, [@var{m} @var{n}])
 ## @deftypefnx {Function File} {} repmat (@var{A}, [@var{m} @var{n} @var{p} @dots{}])
 ## Form a block matrix of size @var{m} by @var{n}, with a copy of matrix
 ## @var{A} as each element.  If @var{n} is not specified, form an
-## @var{m} by @var{m} block matrix.
+## @var{m} by @var{m} block matrix.  For copying along more than two
+## dimensions, specify the number of times to copy across each dimension
+## @var{m}, @var{n}, @var{p}, @dots{}, in a vector in the second argument.
 ## @seealso{repelems}
 ## @end deftypefn
 
@@ -100,63 +101,64 @@
 
 endfunction
 
+
 # Test various methods of providing size parameters
 %!shared x
 %! x = [1 2;3 4];
-%!assert(repmat(x, [1 1]), repmat(x, 1));
-%!assert(repmat(x, [3 3]), repmat(x, 3));
-%!assert(repmat(x, [1 1]), repmat(x, 1, 1));
-%!assert(repmat(x, [1 3]), repmat(x, 1, 3));
-%!assert(repmat(x, [3 1]), repmat(x, 3, 1));
-%!assert(repmat(x, [3 3]), repmat(x, 3, 3));
+%!assert (repmat (x, [1 1]), repmat (x, 1))
+%!assert (repmat (x, [3 3]), repmat (x, 3))
+%!assert (repmat (x, [1 1]), repmat (x, 1, 1))
+%!assert (repmat (x, [1 3]), repmat (x, 1, 3))
+%!assert (repmat (x, [3 1]), repmat (x, 3, 1))
+%!assert (repmat (x, [3 3]), repmat (x, 3, 3))
 
 # Tests for numel==1 case:
 %!shared x, r
 %! x = [ 65 ];
-%! r = kron(ones(2,2), x);
-%!assert(r, repmat(x, [2 2]));
-%!assert(char(r), repmat(char(x), [2 2]));
-%!assert(int8(r), repmat(int8(x), [2 2]));
+%! r = kron (ones (2,2), x);
+%!assert (r, repmat (x, [2 2]))
+%!assert (char (r), repmat (char (x), [2 2]))
+%!assert (int8 (r), repmat (int8 (x), [2 2]))
 
 # Tests for ndims==2 case:
 %!shared x, r
 %! x = [ 65 66 67 ];
-%! r = kron(ones(2,2), x);
-%!assert(r, repmat(x, [2 2]));
-%!assert(char(r), repmat(char(x), [2 2]));
-%!assert(int8(r), repmat(int8(x), [2 2]));
+%! r = kron (ones (2,2), x);
+%!assert (r, repmat (x, [2 2]))
+%!assert (char (r), repmat (char (x), [2 2]))
+%!assert (int8 (r), repmat (int8 (x), [2 2]))
 
 # Tests for dim>2 case:
 %!shared x, r
 %! x = [ 65 66 67 ];
-%! r = kron(ones(2,2), x);
+%! r = kron (ones (2,2), x);
 %! r(:,:,2) = r(:,:,1);
-%!assert(r, repmat(x, [2 2 2]));
-%!assert(char(r), repmat(char(x), [2 2 2]));
-%!assert(int8(r), repmat(int8(x), [2 2 2]));
+%!assert (r, repmat (x, [2 2 2]))
+%!assert (char (r), repmat (char (x), [2 2 2]))
+%!assert (int8 (r), repmat (int8 (x), [2 2 2]))
 
 # Test that sparsity is kept
-%!assert(sparse(4,4), repmat(sparse(2,2),[2 2]));
+%!assert (sparse (4,4), repmat (sparse (2,2),[2 2]))
 
+%!assert (size (repmat (".", -1, 1)), [0, 1])
+%!assert (size (repmat (".", 1, -1)), [1, 0])
 
-%!assert (size (repmat (".", -1, 1)), [0, 1]);
-%!assert (size (repmat (".", 1, -1)), [1, 0]);
-%!error (size (repmat (".", -1, -1)));
-
-%!assert (size (repmat (1, [1, 0])), [1, 0]);
-%!assert (size (repmat (1, [5, 0])), [5, 0]);
-%!assert (size (repmat (1, [0, 1])), [0, 1]);
-%!assert (size (repmat (1, [0, 5])), [0, 5]);
+%!assert (size (repmat (1, [1, 0])), [1, 0])
+%!assert (size (repmat (1, [5, 0])), [5, 0])
+%!assert (size (repmat (1, [0, 1])), [0, 1])
+%!assert (size (repmat (1, [0, 5])), [0, 5])
 
 %!shared x
 %! x = struct ("a", [], "b", []);
-%!assert (size (repmat (x, [1, 0])), [1, 0]);
-%!assert (size (repmat (x, [5, 0])), [5, 0]);
-%!assert (size (repmat (x, [0, 1])), [0, 1]);
-%!assert (size (repmat (x, [0, 5])), [0, 5]);
+%!assert (size (repmat (x, [1, 0])), [1, 0])
+%!assert (size (repmat (x, [5, 0])), [5, 0])
+%!assert (size (repmat (x, [0, 1])), [0, 1])
+%!assert (size (repmat (x, [0, 5])), [0, 5])
 
-%!assert (size (repmat ({1}, [1, 0])), [1, 0]);
-%!assert (size (repmat ({1}, [5, 0])), [5, 0]);
-%!assert (size (repmat ({1}, [0, 1])), [0, 1]);
-%!assert (size (repmat ({1}, [0, 5])), [0, 5]);
+%!assert (size (repmat ({1}, [1, 0])), [1, 0])
+%!assert (size (repmat ({1}, [5, 0])), [5, 0])
+%!assert (size (repmat ({1}, [0, 1])), [0, 1])
+%!assert (size (repmat ({1}, [0, 5])), [0, 5])
 
+%!error (size (repmat (".", -1, -1)))
+
--- a/scripts/general/rot90.m
+++ b/scripts/general/rot90.m
@@ -87,16 +87,17 @@
 %! x3 = [4, 3; 2, 1];
 %! x4 = [3, 1; 4, 2];
 %!
-%! assert(rot90 (x1), x2);
-%! assert(rot90 (x1, 2), x3);
-%! assert(rot90 (x1, 3), x4);
-%! assert(rot90 (x1, 4), x1);
-%! assert(rot90 (x1, 5), x2);
-%! assert(rot90 (x1, -1), x4);
+%! assert (rot90 (x1), x2);
+%! assert (rot90 (x1, 2), x3);
+%! assert (rot90 (x1, 3), x4);
+%! assert (rot90 (x1, 4), x1);
+%! assert (rot90 (x1, 5), x2);
+%! assert (rot90 (x1, -1), x4);
 
 %% Test input validation
-%!error rot90 ();
-%!error rot90 (1, 2, 3);
-%!error rot90 (1, ones(2));
-%!error rot90 (1, 1.5);
-%!error rot90 (1, 1+i);
+%!error rot90 ()
+%!error rot90 (1, 2, 3)
+%!error rot90 (1, ones (2))
+%!error rot90 (1, 1.5)
+%!error rot90 (1, 1+i)
+
--- a/scripts/general/rotdim.m
+++ b/scripts/general/rotdim.m
@@ -60,8 +60,8 @@
     print_usage ();
   endif
 
-  if (nargin > 1 && ! isempty(n))
-    if (!isscalar (n) || !isreal(n) || fix (n) != n)
+  if (nargin > 1 && ! isempty (n))
+    if (!isscalar (n) || !isreal (n) || fix (n) != n)
       error ("rotdim: N must be a scalar integer");
     endif
   else
@@ -124,35 +124,37 @@
 
 endfunction
 
-%!error rotdim ();
-%!error rotdim (1, 2, 3, 4);
 
 %!shared r, rr
-%! r = [1,2,3]; rr = [3,2,1];
-%!assert (rotdim (r, 0), r);
-%!assert (rotdim (r, 1), rr');
-%!assert (rotdim (r, 2), rr);
-%!assert (rotdim (r, 3), r');
-%!assert (rotdim (r, 3), rotdim (r, -1));
-%!assert (rotdim (r, 1), rotdim (r));
+%! r = [1,2,3];  rr = [3,2,1];
+%!assert (rotdim (r, 0), r)
+%!assert (rotdim (r, 1), rr')
+%!assert (rotdim (r, 2), rr)
+%!assert (rotdim (r, 3), r')
+%!assert (rotdim (r, 3), rotdim (r, -1))
+%!assert (rotdim (r, 1), rotdim (r))
 
 %!shared c, cr
-%! c = [1;2;3]; cr = [3;2;1];
-%!assert (rotdim (c, 0), c);
-%!assert (rotdim (c, 1), c');
-%!assert (rotdim (c, 2), cr);
-%!assert (rotdim (c, 3), cr');
-%!assert (rotdim (c, 3), rotdim (c, -1));
-%!assert (rotdim (c, 1), rotdim (c));
+%! c = [1;2;3];  cr = [3;2;1];
+%!assert (rotdim (c, 0), c)
+%!assert (rotdim (c, 1), c')
+%!assert (rotdim (c, 2), cr)
+%!assert (rotdim (c, 3), cr')
+%!assert (rotdim (c, 3), rotdim (c, -1))
+%!assert (rotdim (c, 1), rotdim (c))
 
 %!shared m
 %! m = [1,2;3,4];
-%!assert (rotdim (m, 0), m);
-%!assert (rotdim (m, 1), [2,4;1,3]);
-%!assert (rotdim (m, 2), [4,3;2,1]);
-%!assert (rotdim (m, 3), [3,1;4,2]);
-%!assert (rotdim (m, 3), rotdim (m, -1));
-%!assert (rotdim (m, 1), rotdim (m));
+%!assert (rotdim (m, 0), m)
+%!assert (rotdim (m, 1), [2,4;1,3])
+%!assert (rotdim (m, 2), [4,3;2,1])
+%!assert (rotdim (m, 3), [3,1;4,2])
+%!assert (rotdim (m, 3), rotdim (m, -1))
+%!assert (rotdim (m, 1), rotdim (m))
 
 ## FIXME -- we need tests for multidimensional arrays and different
 ## values of PLANE.
+
+%!error rotdim ()
+%!error rotdim (1, 2, 3, 4)
+
--- a/scripts/general/saveobj.m
+++ b/scripts/general/saveobj.m
@@ -40,5 +40,5 @@
 ## @end deftypefn
 
 function b = saveobj (a)
-  error ("saveobj: not defined for class \"%s\"", class(a));
+  error ('saveobj: not defined for class "%s"', class (a));
 endfunction
--- a/scripts/general/shift.m
+++ b/scripts/general/shift.m
@@ -80,19 +80,19 @@
 %! r = [a, b, c];
 %! m = [a; b; c];
 %!
-%! assert(shift (r, 0), r);
-%! assert(shift (r, 3), [c, a, b]);
-%! assert(shift (r, -6), [c, a, b]);
-%! assert(shift (r, -3), [b, c, a]);
-%! assert(shift (m, 1), [c; a; b]);
-%! assert(shift (m, -2), [c; a; b]);
+%! assert (shift (r, 0), r);
+%! assert (shift (r, 3), [c, a, b]);
+%! assert (shift (r, -6), [c, a, b]);
+%! assert (shift (r, -3), [b, c, a]);
+%! assert (shift (m, 1), [c; a; b]);
+%! assert (shift (m, -2), [c; a; b]);
 
 %% Test input validation
 %!error shift ()
 %!error shift (1, 2, 3, 4)
 %!error shift ([], 1)
-%!error shift (ones(2), ones(2))
-%!error shift (ones(2), 1.5)
+%!error shift (ones (2), ones (2))
+%!error shift (ones (2), 1.5)
 %!error shift (1, 1, 1.5)
 %!error shift (1, 1, 0)
 %!error shift (1, 1, 3)
--- a/scripts/general/shiftdim.m
+++ b/scripts/general/shiftdim.m
@@ -90,11 +90,12 @@
 %! assert (ns, 2);
 %! assert (shiftdim (y, -2), x);
 %! assert (size (shiftdim (x, 2)), [4 2]);
-%!assert (size (shiftdim (rand (0, 1, 2))), [0 1 2]);
+
+%!assert (size (shiftdim (rand (0, 1, 2))), [0 1 2])
 
 %% Test input validation
-%!error(shiftdim ());
-%!error(shiftdim (1,2,3));
-%!error(shiftdim (1, ones (2)));
-%!error(shiftdim (1, 1.5));
+%!error (shiftdim ())
+%!error (shiftdim (1,2,3))
+%!error (shiftdim (1, ones (2)))
+%!error (shiftdim (1, 1.5))
 
--- a/scripts/general/sph2cart.m
+++ b/scripts/general/sph2cart.m
@@ -71,6 +71,7 @@
 
 endfunction
 
+
 %!test
 %! t = [0, 0, 0];
 %! p = [0, 0, 0];
@@ -110,5 +111,5 @@
 %!test
 %! S = [ 0, 0, 1; 0.5*pi, 0, 1; pi, 0, 1];
 %! C = [ 1, 0, 0; 0, 1, 0; -1, 0, 0];
-%! assert (sph2cart(S), C, eps);
+%! assert (sph2cart (S), C, eps);
 
--- a/scripts/general/structfun.m
+++ b/scripts/general/structfun.m
@@ -133,14 +133,15 @@
 %! d(1:2, 1, 1) = [1; 16];
 %! d(1:2, 1, 2) = [4; 25];
 %! d(1:2, 1, 3) = [9; 36];
-%! [aa, bb] = structfun(@__twoouts, s);
-%! assert(aa, c);
-%! assert(bb, d);
+%! [aa, bb] = structfun (@__twoouts, s);
+%! assert (aa, c);
+%! assert (bb, d);
 
 %!test
 %! s = struct ("a", {1, 2, 3}, "b", {4, 5, 6});
 %! c = struct ("a", {2, 4, 6}, "b", {8, 10, 12});
 %! d = struct ("a", {1, 4, 9}, "b", {16, 25, 36});
-%! [aa, bb] = structfun(@__twoouts, s, "UniformOutput", false);
-%! assert(aa, c);
-%! assert(bb, d);
+%! [aa, bb] = structfun (@__twoouts, s, "UniformOutput", false);
+%! assert (aa, c);
+%! assert (bb, d);
+
--- a/scripts/general/subsindex.m
+++ b/scripts/general/subsindex.m
@@ -60,6 +60,6 @@
 ## @end deftypefn
 
 function idx = subsindex (a)
-  error ("subsindex: not defined for class \"%s\"", class(a));
+  error ("subsindex: not defined for class \"%s\"", class (a));
 endfunction
 
--- a/scripts/general/trapz.m
+++ b/scripts/general/trapz.m
@@ -123,16 +123,16 @@
 endfunction
 
 
-%!assert (trapz(1:5), 12)
-%!assert (trapz(0:0.5:2,1:5), 6)
-%!assert (trapz([1:5;1:5].',1), [12,12])
-%!assert (trapz([1:5;1:5],2), [12;12])
-%!assert (trapz(repmat(reshape(1:5,1,1,5),2,2), 3), [12 12; 12 12])
-%!assert (trapz([0:0.5:2;0:0.5:2].',[1:5;1:5].',1), [6, 6])
-%!assert (trapz([0:0.5:2;0:0.5:2],[1:5;1:5],2), [6; 6])
-%!assert (trapz(repmat(reshape([0:0.5:2],1,1,5),2,2), ...
-%!              repmat(reshape(1:5,1,1,5),2,2), 3), [6 6; 6 6])
-%!assert (trapz(0:0.5:2,[(1:5)',(1:5)']), [6, 6])
-%!assert (trapz(0:0.5:2,[(1:5);(1:5)],2), [6; 6])
-%!assert (trapz(0:0.5:2,repmat(reshape(1:5,1,1,5),2,2),3), [6 6; 6 6])
+%!assert (trapz (1:5), 12)
+%!assert (trapz (0:0.5:2,1:5), 6)
+%!assert (trapz ([1:5;1:5].',1), [12,12])
+%!assert (trapz ([1:5;1:5],2), [12;12])
+%!assert (trapz (repmat (reshape (1:5,1,1,5),2,2), 3), [12 12; 12 12])
+%!assert (trapz ([0:0.5:2;0:0.5:2].',[1:5;1:5].',1), [6, 6])
+%!assert (trapz ([0:0.5:2;0:0.5:2],[1:5;1:5],2), [6; 6])
+%!assert (trapz (repmat (reshape ([0:0.5:2],1,1,5),2,2), ...
+%!               repmat (reshape (1:5,1,1,5),2,2), 3), [6 6; 6 6])
+%!assert (trapz (0:0.5:2,[(1:5)',(1:5)']), [6, 6])
+%!assert (trapz (0:0.5:2,[(1:5);(1:5)],2), [6; 6])
+%!assert (trapz (0:0.5:2,repmat (reshape (1:5,1,1,5),2,2),3), [6 6; 6 6])
 
--- a/scripts/general/triplequad.m
+++ b/scripts/general/triplequad.m
@@ -69,17 +69,17 @@
 endfunction
 
 function q = __triplequad_inner__ (y, z, f, xa, xb, tol, quadf, varargin)
-  q = zeros (size(y));
+  q = zeros (size (y));
   for i = 1 : length (y)
     q(i) = feval (quadf, @(x) f (x, y(i), z, varargin{:}), xa, xb, tol);
   endfor
 endfunction
 
 
-%!assert (triplequad (@(x,y,z) exp(-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [],  @quadcc), pi ^ (3/2) * erf(1).^3, 1e-6)
+%!assert (triplequad (@(x,y,z) exp (-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadcc), pi^(3/2) * erf (1).^3, 1e-6)
 
 %% These tests are too expensive to run normally (~30 sec each).  Disable them
-#%!assert (triplequad (@(x,y,z) exp(-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [],  @quadgk), pi ^ (3/2) * erf(1).^3, 1e-6)
-#%!#assert (triplequad (@(x,y,z) exp(-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [],  @quadl), pi ^ (3/2) * erf(1).^3, 1e-6)
-#%!#assert (triplequad (@(x,y,z) exp(-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [],  @quadv), pi ^ (3/2) * erf(1).^3, 1e-6)
+#%!assert (triplequad (@(x,y,z) exp (-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadgk), pi^(3/2) * erf (1).^3, 1e-6)
+#%!#assert (triplequad (@(x,y,z) exp (-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadl), pi^(3/2) * erf (1).^3, 1e-6)
+#%!#assert (triplequad (@(x,y,z) exp (-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadv), pi^(3/2) * erf (1).^3, 1e-6)
 
--- a/scripts/geometry/convhull.m
+++ b/scripts/geometry/convhull.m
@@ -20,7 +20,7 @@
 ## @deftypefn  {Function File} {@var{H} =} convhull (@var{x}, @var{y})
 ## @deftypefnx {Function File} {@var{H} =} convhull (@var{x}, @var{y}, @var{options})
 ## Compute the convex hull of the set of points defined by the
-## vectors @var{x} and @var{y}.  The hull @var{H} is an index vector into
+## arrays @var{x} and @var{y}.  The hull @var{H} is an index vector into
 ## the set of points and specifies which points form the enclosing hull.
 ##
 ## An optional third argument, which must be a string or cell array of strings,
@@ -45,17 +45,20 @@
     print_usage ();
   endif
 
-  if (! (isvector (x) && isvector (y) && length (x) == length (y))
-      && ! size_equal (x, y))
-    error ("convhull: X and Y must be the same size");
+  ## convhulln expects column vectors
+  x = x(:);
+  y = y(:);
+
+  if (length (x) != length (y))
+    error ("convhull: X and Y must have the same size");
   elseif (nargin == 3 && ! (ischar (options) || iscellstr (options)))
     error ("convhull: OPTIONS must be a string or cell array of strings");
   endif
 
   if (nargin == 2)
-    i = convhulln ([x(:), y(:)]);
+    i = convhulln ([x, y]);
   else
-    i = convhulln ([x(:), y(:)], options);
+    i = convhulln ([x, y], options);
   endif
 
   n = rows (i);
@@ -85,6 +88,7 @@
 
 
 %!demo
+%! clf;
 %! x = -3:0.05:3;
 %! y = abs (sin (x));
 %! k = convhull (x, y);
@@ -94,7 +98,7 @@
 %!testif HAVE_QHULL
 %! x = -3:0.5:3;
 %! y = abs (sin (x));
-%! assert (convhull (x, y), [1;7;13;12;11;10;4;3;2;1])
+%! assert (convhull (x, y), [1;7;13;12;11;10;4;3;2;1]);
 
 %% FIXME: Need input validation tests
 
--- a/scripts/geometry/delaunay.m
+++ b/scripts/geometry/delaunay.m
@@ -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>
@@ -102,8 +102,9 @@
 %! T = delaunay (x,y);
 %! VX = [ x(T(:,1)); x(T(:,2)); x(T(:,3)); x(T(:,1)) ];
 %! VY = [ y(T(:,1)); y(T(:,2)); y(T(:,3)); y(T(:,1)) ];
+%! clf;
+%! plot (VX,VY,"b", x,y,"r*");
 %! axis ([0,1,0,1]);
-%! plot (VX,VY,"b", x,y,"r*");
 
 %!testif HAVE_QHULL
 %! x = [-1, 0, 1, 0];
--- a/scripts/geometry/delaunay3.m
+++ b/scripts/geometry/delaunay3.m
@@ -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>
@@ -54,7 +54,7 @@
   endif
 
   if (! (isvector (x) && isvector (y) && isvector (z)
-         && length (x) == length (y) && length(x) == length (z)))
+         && length (x) == length (y) && length (x) == length (z)))
     error ("delaunay: X, Y, and Z must be the same size");
   elseif (nargin == 4 && ! (ischar (options) || iscellstr (options)))
     error ("delaunay3: OPTIONS must be a string or cell array of strings");
--- a/scripts/geometry/delaunayn.m
+++ b/scripts/geometry/delaunayn.m
@@ -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/dsearch.m
+++ b/scripts/geometry/dsearch.m
@@ -32,9 +32,11 @@
   idx = __dsearchn__ ([x(:), y(:)], [xi(:), yi(:)]);
 endfunction
 
+
 %!shared x, y, tri
 %! x = [-1;-1;1];
 %! y = [-1;1;-1];
 %! tri = [1,2,3];
-%!assert (dsearch(x,y,tri,1,1/3), 3);
-%!assert (dsearch(x,y,tri,1/3,1), 2);
+%!assert (dsearch (x,y,tri,1,1/3), 3)
+%!assert (dsearch (x,y,tri,1/3,1), 2)
+
--- a/scripts/geometry/dsearchn.m
+++ b/scripts/geometry/dsearchn.m
@@ -46,12 +46,14 @@
   endif
 endfunction
 
+
 %!shared x, tri
 %! x = [-1,-1;-1,1;1,-1];
 %! tri = [1,2,3];
-%!assert (dsearchn(x,tri,[1,1/3]), 3);
-%!assert (dsearchn(x,tri,[1,1/3],NaN), NaN);
-%!assert (dsearchn(x,tri,[1,1/3],NA), NA);
-%!assert (dsearchn(x,tri,[1/3,1]), 2);
-%!assert (dsearchn(x,tri,[1/3,1],NaN), NaN);
-%!assert (dsearchn(x,tri,[1/3,1],NA), NA);
+%!assert (dsearchn (x,tri,[1,1/3]), 3)
+%!assert (dsearchn (x,tri,[1,1/3],NaN), NaN)
+%!assert (dsearchn (x,tri,[1,1/3],NA), NA)
+%!assert (dsearchn (x,tri,[1/3,1]), 2)
+%!assert (dsearchn (x,tri,[1/3,1],NaN), NaN)
+%!assert (dsearchn (x,tri,[1/3,1],NA), NA)
+
--- a/scripts/geometry/griddata.m
+++ b/scripts/geometry/griddata.m
@@ -17,8 +17,9 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {@var{zi} =} griddata (@var{x}, @var{y}, @var{z}, @var{xi}, @var{yi}, @var{method})
-## @deftypefnx {Function File} {[@var{xi}, @var{yi}, @var{zi}] =} griddata (@var{x}, @var{y}, @var{z}, @var{xi}, @var{yi}, @var{method})
+## @deftypefn  {Function File} {@var{zi} =} griddata (@var{x}, @var{y}, @var{z}, @var{xi}, @var{yi})
+## @deftypefnx {Function File} {@var{zi} =} griddata (@var{x}, @var{y}, @var{z}, @var{xi}, @var{yi}, @var{method})
+## @deftypefnx {Function File} {[@var{xi}, @var{yi}, @var{zi}] =} griddata (@dots{})
 ##
 ## Generate a regular mesh from irregular data using interpolation.
 ## The function is defined by @code{@var{z} = f (@var{x}, @var{y})}.
@@ -30,7 +31,7 @@
 ##
 ## The interpolation method can be @code{"nearest"}, @code{"cubic"} or
 ## @code{"linear"}.  If method is omitted it defaults to @code{"linear"}.
-## @seealso{delaunay}
+## @seealso{griddata3, griddatan, delaunay}
 ## @end deftypefn
 
 ## Author:      Kai Habel <kai.habel@gmx.de>
@@ -38,11 +39,8 @@
 ##              xi and yi are not "meshgridded" if both are vectors
 ##              of the same size (for compatibility)
 
-function [rx, ry, rz] = griddata (x, y, z, xi, yi, method)
+function [rx, ry, rz] = griddata (x, y, z, xi, yi, method = "linear")
 
-  if (nargin == 5)
-    method = "linear";
-  endif
   if (nargin < 5 || nargin > 7)
     print_usage ();
   endif
@@ -51,27 +49,32 @@
     method = tolower (method);
   endif
 
+  ## Meshgrid if x and y are vectors but z is matrix
   if (isvector (x) && isvector (y) && all ([numel(y), numel(x)] == size (z)))
     [x, y] = meshgrid (x, y);
-  elseif (! all (size (x) == size (y) & size (x) == size (z)))
-    if (isvector (z))
-      error ("griddata: X, Y, and Z, be vectors of same length");
-    else
-      error ("griddata: lengths of X, Y must match the columns and rows of Z");
+  endif
+    
+  if (isvector (x) && isvector (y) && isvector (z))
+    if (! isequal (length (x), length (y), length (z)))
+      error ("griddata: X, Y, and Z must be vectors of the same length");
     endif
+  elseif (! size_equal (x, y, z))
+    error ("griddata: lengths of X, Y must match the columns and rows of Z");
   endif
 
   ## Meshgrid xi and yi if they are a row and column vector.
   if (rows (xi) == 1 && columns (yi) == 1)
     [xi, yi] = meshgrid (xi, yi);
+  elseif (isvector (xi) && isvector (yi))
+    ## Otherwise, convert to column vectors
+    xi = xi(:);
+    yi = yi(:);
   endif
 
   if (! size_equal (xi, yi))
     error ("griddata: XI and YI must be vectors or matrices of same size");
   endif
 
-  [nr, nc] = size (xi);
-
   x = x(:);
   y = y(:);
   z = z(:);
@@ -138,40 +141,64 @@
   elseif (nargout == 0)
     mesh (xi, yi, zi);
   endif
+
 endfunction
 
-%!testif HAVE_QHULL
-%! [xx,yy]=meshgrid(linspace(-1,1,32));
-%! x = xx(:);
-%! x = x + 10 * (2 * round(rand(size(x))) - 1) * eps;
-%! y = yy(:);
-%! y = y + 10 * (2 * round(rand(size(y))) - 1) * eps;
-%! z = sin(2*(x.^2+y.^2));
-%! zz = griddata(x,y,z,xx,yy,'linear');
-%! zz2 = sin(2*(xx.^2+yy.^2));
-%! zz2(isnan(zz)) = NaN;
-%! assert (zz, zz2, 100 * eps)
+
+%!demo
+%! clf;
+%! colormap ("default");
+%! x = 2*rand (100,1) - 1;
+%! y = 2*rand (size (x)) - 1;
+%! z = sin (2*(x.^2 + y.^2));
+%! [xx,yy] = meshgrid (linspace (-1,1,32));
+%! griddata (x,y,z,xx,yy);
+%! title ("nonuniform grid sampled at 100 points");
+
+%!demo
+%! clf;
+%! colormap ("default");
+%! x = 2*rand (1000,1) - 1;
+%! y = 2*rand (size (x)) - 1;
+%! z = sin (2*(x.^2 + y.^2));
+%! [xx,yy] = meshgrid (linspace (-1,1,32));
+%! griddata (x,y,z,xx,yy);
+%! title ("nonuniform grid sampled at 1000 points");
 
 %!demo
-%! x=2*rand(100,1)-1;
-%! y=2*rand(size(x))-1;
-%! z=sin(2*(x.^2+y.^2));
-%! [xx,yy]=meshgrid(linspace(-1,1,32));
-%! griddata(x,y,z,xx,yy);
-%! title('nonuniform grid sampled at 100 points');
+%! clf;
+%! colormap ("default");
+%! x = 2*rand (1000,1) - 1;
+%! y = 2*rand (size (x)) - 1;
+%! z = sin (2*(x.^2 + y.^2));
+%! [xx,yy] = meshgrid (linspace (-1,1,32));
+%! griddata (x,y,z,xx,yy,"nearest");
+%! title ("nonuniform grid sampled at 1000 points with nearest neighbor");
 
-%!demo
-%! x=2*rand(1000,1)-1;
-%! y=2*rand(size(x))-1;
-%! z=sin(2*(x.^2+y.^2));
-%! [xx,yy]=meshgrid(linspace(-1,1,32));
-%! griddata(x,y,z,xx,yy);
-%! title('nonuniform grid sampled at 1000 points');
+%!testif HAVE_QHULL
+%! [xx,yy] = meshgrid (linspace (-1,1,32));
+%! x = xx(:);
+%! x = x + 10*(2*round (rand (size (x))) - 1) * eps;
+%! y = yy(:);
+%! y = y + 10*(2*round (rand (size (y))) - 1) * eps;
+%! z = sin (2*(x.^2 + y.^2));
+%! zz = griddata (x,y,z,xx,yy,"linear");
+%! zz2 = sin (2*(xx.^2 + yy.^2));
+%! zz2(isnan (zz)) = NaN;
+%! assert (zz, zz2, 100*eps);
 
-%!demo
-%! x=2*rand(1000,1)-1;
-%! y=2*rand(size(x))-1;
-%! z=sin(2*(x.^2+y.^2));
-%! [xx,yy]=meshgrid(linspace(-1,1,32));
-%! griddata(x,y,z,xx,yy,'nearest');
-%! title('nonuniform grid sampled at 1000 points with nearest neighbor');
+%% Test input validation
+%!error griddata ()
+%!error griddata (1)
+%!error griddata (1,2)
+%!error griddata (1,2,3)
+%!error griddata (1,2,3,4)
+%!error griddata (1,2,3,4,5,6,7)
+%!error <vectors of the same length> griddata (1:3, 1:3, 1:4, 1:3, 1:3)
+%!error <vectors of the same length> griddata (1:3, 1:4, 1:3, 1:3, 1:3)
+%!error <vectors of the same length> griddata (1:4, 1:3, 1:3, 1:3, 1:3)
+%!error <the columns and rows of Z> griddata (1:4, 1:3, ones (4,4), 1:3, 1:3)
+%!error <the columns and rows of Z> griddata (1:4, 1:3, ones (3,5), 1:3, 1:3)
+%!error <matrices of same size> griddata (1:3, 1:3, 1:3, 1:4, 1:3)
+%!error <matrices of same size> griddata (1:3, 1:3, 1:3, 1:3, 1:4)
+
--- a/scripts/geometry/griddata3.m
+++ b/scripts/geometry/griddata3.m
@@ -17,7 +17,9 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v}, @var{xi}, @var{yi}, @var{zi}, @var{method}, @var{options})
+## @deftypefn  {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v}, @var{xi}, @var{yi}, @var{zi})
+## @deftypefnx {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v}, @var{xi}, @var{yi}, @var{zi}, @var{method})
+## @deftypefnx {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v}, @var{xi}, @var{yi}, @var{zi}, @var{method}, @var{options})
 ##
 ## Generate a regular mesh from irregular data using interpolation.
 ## The function is defined by @code{@var{v} = f (@var{x}, @var{y}, @var{z})}.
@@ -25,6 +27,11 @@
 ##
 ## The interpolation method can be @code{"nearest"} or @code{"linear"}.
 ## If method is omitted it defaults to @code{"linear"}.
+##
+## The optional argument @var{options} is passed directly to Qhull when
+## computing the Delaunay triangulation used for interpolation.  See
+## @code{delaunayn} for information on the defaults and how to pass different
+## values.
 ## @seealso{griddata, griddatan, delaunayn}
 ## @end deftypefn
 
@@ -36,19 +43,29 @@
     print_usage ();
   endif
 
-  if (!all (size (x) == size (y) & size (x) == size(z) & size(x) == size (v)))
-    error ("griddata3: X, Y, Z, and V must be vectors of same length");
+  if (isvector (x) && isvector (y) && isvector (z) && isvector (v))
+    if (! isequal (length (x), length (y), length (z), length (v)))
+      error ("griddata: X, Y, Z, and V must be vectors of the same length");
+    endif
+  elseif (! size_equal (x, y, z, v))
+    error ("griddata: X, Y, Z, and V must have equal sizes");
   endif
 
-  ## meshgrid xi, yi and zi if they are vectors unless they
-  ## are vectors of the same length
-  if (isvector (xi) && isvector (yi) && isvector (zi)
-      && (numel (xi) != numel (yi) || numel (xi) != numel (zi)))
-    [xi, yi, zi] = meshgrid (xi, yi, zi);
+  ## meshgrid xi, yi and zi if they are vectors unless
+  ## they are vectors of the same length.
+  if (isvector (xi) && isvector (yi) && isvector (zi))
+    if (! isequal (length (xi), length (yi), length (zi)))
+      [xi, yi, zi] = meshgrid (xi, yi, zi);
+    else
+      ## Otherwise, convert to column vectors
+      xi = xi(:);
+      yi = yi(:);
+      zi = zi(:);
+    endif
   endif
 
-  if (any (size(xi) != size(yi)) || any (size(xi) != size(zi)))
-    error ("griddata3: XI, YI and ZI must be vectors or matrices of same size");
+  if (! size_equal (xi, yi, zi))
+    error ("griddata3: XI, YI, and ZI must be vectors or matrices of the same size");
   endif
 
   vi = griddatan ([x(:), y(:), z(:)], v(:), [xi(:), yi(:), zi(:)], varargin{:});
@@ -66,7 +83,7 @@
 %! z = 2 * rand (1000, 1) - 1;
 %! v = x.^2 + y.^2 + z.^2;
 %! [xi, yi, zi] = meshgrid (-0.8:0.2:0.8);
-%! vi = griddata3 (x, y, z, v, xi, yi, zi, 'linear');
+%! vi = griddata3 (x, y, z, v, xi, yi, zi, "linear");
 %! vv = vi - xi.^2 - yi.^2 - zi.^2;
 %! assert (max (abs (vv(:))), 0, 0.1);
 
@@ -79,6 +96,7 @@
 %! z = 2 * rand (1000, 1) - 1;
 %! v = x.^2 + y.^2 + z.^2;
 %! [xi, yi, zi] = meshgrid (-0.8:0.2:0.8);
-%! vi = griddata3 (x, y, z, v, xi, yi, zi, 'nearest');
+%! vi = griddata3 (x, y, z, v, xi, yi, zi, "nearest");
 %! vv = vi - xi.^2 - yi.^2 - zi.^2;
 %! assert (max (abs (vv(:))), 0, 0.1)
+
--- a/scripts/geometry/griddatan.m
+++ b/scripts/geometry/griddatan.m
@@ -17,7 +17,9 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {@var{yi} =} griddatan (@var{x}, @var{y}, @var{xi}, @var{method}, @var{options})
+## @deftypefn  {Function File} {@var{yi} =} griddatan (@var{x}, @var{y}, @var{xi})
+## @deftypefnx {Function File} {@var{yi} =} griddatan (@var{x}, @var{y}, @var{xi}, @var{method})
+## @deftypefnx {Function File} {@var{yi} =} griddatan (@var{x}, @var{y}, @var{xi}, @var{method}, @var{options})
 ##
 ## Generate a regular mesh from irregular data using interpolation.
 ## The function is defined by @code{@var{y} = f (@var{x})}.
@@ -25,16 +27,18 @@
 ##
 ## The interpolation method can be @code{"nearest"} or @code{"linear"}.
 ## If method is omitted it defaults to @code{"linear"}.
-## @seealso{griddata, delaunayn}
+## 
+## The optional argument @var{options} is passed directly to Qhull when
+## computing the Delaunay triangulation used for interpolation.  See
+## @code{delaunayn} for information on the defaults and how to pass different
+## values.
+## @seealso{griddata, griddata3, delaunayn}
 ## @end deftypefn
 
 ## Author: David Bateman <dbateman@free.fr>
 
-function yi = griddatan (x, y, xi, method, varargin)
+function yi = griddatan (x, y, xi, method = "linear", varargin)
 
-  if (nargin == 3)
-    method = "linear";
-  endif
   if (nargin < 3)
     print_usage ();
   endif
@@ -46,13 +50,12 @@
   [m, n] = size (x);
   [mi, ni] = size (xi);
 
-  if (n != ni || size (y, 1) != m || size (y, 2) != 1)
+  if (n != ni || rows (y) != m || columns (y) != 1)
     error ("griddatan: dimensional mismatch");
   endif
 
   ## triangulate data
-  ## tri = delaunayn(x, varargin{:});
-  tri = delaunayn (x);
+  tri = delaunayn (x, varargin{:});
 
   yi = NaN (mi, 1);
 
@@ -85,22 +88,24 @@
 
 endfunction
 
-%!testif HAVE_QHULL
-%! [xx,yy] = meshgrid(linspace(-1,1,32));
-%! xi = [xx(:), yy(:)];
-%! x = (2 * rand(100,2) - 1);
-%! x = [x;1,1;1,-1;-1,-1;-1,1];
-%! y = sin(2*(sum(x.^2,2)));
-%! zz = griddatan(x,y,xi,'linear');
-%! zz2 = griddata(x(:,1),x(:,2),y,xi(:,1),xi(:,2),'linear');
-%! assert (zz, zz2, 1e-10)
 
 %!testif HAVE_QHULL
-%! [xx,yy] = meshgrid(linspace(-1,1,32));
+%! [xx,yy] = meshgrid (linspace (-1,1,32));
 %! xi = [xx(:), yy(:)];
-%! x = (2 * rand(100,2) - 1);
+%! x = 2*rand (100,2) - 1;
 %! x = [x;1,1;1,-1;-1,-1;-1,1];
-%! y = sin(2*(sum(x.^2,2)));
-%! zz = griddatan(x,y,xi,'nearest');
-%! zz2 = griddata(x(:,1),x(:,2),y,xi(:,1),xi(:,2),'nearest');
-%! assert (zz, zz2, 1e-10)
+%! y = sin (2 * sum (x.^2,2));
+%! zz = griddatan (x,y,xi,"linear");
+%! zz2 = griddata (x(:,1),x(:,2),y,xi(:,1),xi(:,2),"linear");
+%! assert (zz, zz2, 1e-10);
+
+%!testif HAVE_QHULL
+%! [xx,yy] = meshgrid (linspace (-1,1,32));
+%! xi = [xx(:), yy(:)];
+%! x = 2*rand (100,2) - 1;
+%! x = [x;1,1;1,-1;-1,-1;-1,1];
+%! y = sin (2*sum (x.^2,2));
+%! zz = griddatan (x,y,xi,"nearest");
+%! zz2 = griddata (x(:,1),x(:,2),y,xi(:,1),xi(:,2),"nearest");
+%! assert (zz, zz2, 1e-10);
+
--- a/scripts/geometry/inpolygon.m
+++ b/scripts/geometry/inpolygon.m
@@ -54,9 +54,9 @@
   npol = length (xv);
   do_boundary = (nargout >= 2);
 
-  in = zeros (size(x), "logical");
+  in = zeros (size (x), "logical");
   if (do_boundary)
-    on = zeros (size(x), "logical");
+    on = zeros (size (x), "logical");
   endif
 
   j = npol;
@@ -84,60 +84,64 @@
 
 endfunction
 
-%!demo
-%!  xv=[ 0.05840, 0.48375, 0.69356, 1.47478, 1.32158, \
-%!       1.94545, 2.16477, 1.87639, 1.18218, 0.27615, \
-%!       0.05840 ];
-%!  yv=[ 0.60628, 0.04728, 0.50000, 0.50000, 0.02015, \
-%!       0.18161, 0.78850, 1.13589, 1.33781, 1.04650, \
-%!       0.60628 ];
-%! xa=[0:0.1:2.3];
-%! ya=[0:0.1:1.4];
-%! [x,y]=meshgrid(xa,ya);
-%! [in,on]=inpolygon(x,y,xv,yv);
-%!
-%! inside=in & !on;
-%! plot(xv,yv)
-%! hold on
-%! plot(x(inside),y(inside),"@g")
-%! plot(x(~in),y(~in),"@m")
-%! plot(x(on),y(on),"@b")
-%! hold off
-%! disp("Green points are inside polygon, magenta are outside,");
-%! disp("and blue are on boundary.");
 
 %!demo
-%!  xv=[ 0.05840, 0.48375, 0.69356, 1.47478, 1.32158, \
-%!       1.94545, 2.16477, 1.87639, 1.18218, 0.27615, \
-%!       0.05840, 0.73295, 1.28913, 1.74221, 1.16023, \
-%!       0.73295, 0.05840 ];
-%!  yv=[ 0.60628, 0.04728, 0.50000, 0.50000, 0.02015, \
-%!       0.18161, 0.78850, 1.13589, 1.33781, 1.04650, \
-%!       0.60628, 0.82096, 0.67155, 0.96114, 1.14833, \
-%!       0.82096, 0.60628];
-%! xa=[0:0.1:2.3];
-%! ya=[0:0.1:1.4];
-%! [x,y]=meshgrid(xa,ya);
-%! [in,on]=inpolygon(x,y,xv,yv);
+%! xv = [ 0.05840, 0.48375, 0.69356, 1.47478, 1.32158, ...
+%!        1.94545, 2.16477, 1.87639, 1.18218, 0.27615, ...
+%!        0.05840 ];
+%! yv = [ 0.60628, 0.04728, 0.50000, 0.50000, 0.02015, ...
+%!        0.18161, 0.78850, 1.13589, 1.33781, 1.04650, ...
+%!        0.60628 ];
+%! xa = [0:0.1:2.3];
+%! ya = [0:0.1:1.4];
+%! [x,y] = meshgrid (xa, ya);
+%! [in,on] = inpolygon (x, y, xv, yv);
+%! inside = in & !on;
 %!
-%! inside=in & ~ on;
-%! plot(xv,yv)
-%! hold on
-%! plot(x(inside),y(inside),"@g")
-%! plot(x(~in),y(~in),"@m")
-%! plot(x(on),y(on),"@b")
-%! hold off
-%! disp("Green points are inside polygon, magenta are outside,");
-%! disp("and blue are on boundary.");
+%! clf;
+%! plot (xv, yv);
+%! hold on;
+%! plot (x(inside), y(inside), "@g")
+%! plot (x(!in), y(!in), "@m");
+%! plot (x(on), y(on), "@b");
+%! hold off;
+%! disp ("Green points are inside polygon, magenta are outside,");
+%! disp ("and blue are on boundary.");
 
-%!error inpolygon ();
-%!error inpolygon (1, 2);
-%!error inpolygon (1, 2, 3);
-
-%!error inpolygon (1, [1,2], [3, 4], [5, 6]);
-%!error inpolygon ([1,2], [3, 4], [5, 6], 1);
+%!demo
+%!  xv = [ 0.05840, 0.48375, 0.69356, 1.47478, 1.32158, ...
+%!         1.94545, 2.16477, 1.87639, 1.18218, 0.27615, ...
+%!         0.05840, 0.73295, 1.28913, 1.74221, 1.16023, ...
+%!         0.73295, 0.05840 ];
+%!  yv = [ 0.60628, 0.04728, 0.50000, 0.50000, 0.02015, ...
+%!         0.18161, 0.78850, 1.13589, 1.33781, 1.04650, ...
+%!         0.60628, 0.82096, 0.67155, 0.96114, 1.14833, ...
+%!         0.82096, 0.60628];
+%! xa = [0:0.1:2.3];
+%! ya = [0:0.1:1.4];
+%! [x,y] = meshgrid (xa, ya);
+%! [in,on] = inpolygon (x, y, xv, yv);
+%! inside = in & !on;
+%!
+%! clf;
+%! plot (xv, yv);
+%! hold on;
+%! plot (x(inside), y(inside), "@g");
+%! plot (x(!in), y(!in), "@m");
+%! plot (x(on), y(on), "@b");
+%! hold off;
+%! disp ("Green points are inside polygon, magenta are outside,");
+%! disp ("and blue are on boundary.");
 
 %!test
 %! [in, on] = inpolygon ([1, 0], [1, 0], [-1, -1, 1, 1], [-1, 1, 1, -1]);
 %! assert (in, [false, true]);
 %! assert (on, [true, false]);
+
+%% Test input validation
+%!error inpolygon ()
+%!error inpolygon (1, 2)
+%!error inpolygon (1, 2, 3)
+%!error inpolygon (1, [1,2], [3, 4], [5, 6])
+%!error inpolygon ([1,2], [3, 4], [5, 6], 1)
+
--- a/scripts/geometry/rectint.m
+++ b/scripts/geometry/rectint.m
@@ -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,27 +105,28 @@
 
   endfor
 
-  if swapinputs
+  if (swapinputs)
     area = area';
   endif
 
 endfunction
 
-## Tests
+
 ## Exactly overlapping
-%!assert(rectint([0 0 1 1], [0 0 1 1]), 1)
+%!assert (rectint ([0 0 1 1], [0 0 1 1]), 1)
 ## rect2 completely enclosed by rect1
-%!assert(rectint([-1 -1 3 3], [0 0 1 1]), 1)
+%!assert (rectint ([-1 -1 3 3], [0 0 1 1]), 1)
 ## rect1 completely enclosed by rect2
-%!assert(rectint([0 0 1 1], [-1 -1 3 3]), 1)
+%!assert (rectint ([0 0 1 1], [-1 -1 3 3]), 1)
 ## rect1 right and top in rect2
-%!assert(rectint([-1 -1 1.5 1.5], [0 0 1 1]), 0.25)
+%!assert (rectint ([-1 -1 1.5 1.5], [0 0 1 1]), 0.25)
 ## rect2 right and top in rect1
-%!assert(rectint([0 0 1 1], [-1 -1 1.5 1.5]), 0.25)
+%!assert (rectint ([0 0 1 1], [-1 -1 1.5 1.5]), 0.25)
 ## no overlap - shared corner
-%!assert(rectint([0 0 1 1], [1 1 2 2]), 0)
+%!assert (rectint ([0 0 1 1], [1 1 2 2]), 0)
 ## no overlap - shared edge
-%!assert(rectint([0 0 1 1], [0 1 2 2]), 0)
+%!assert (rectint ([0 0 1 1], [0 1 2 2]), 0)
 ## Correct orientation of output
-%!assert(rectint([0 0 1 1;0.5 0.5 1 1;-1 -1 2 2], [1 1 2 2]), [0;0.25;0])
-%!assert(rectint([1 1 2 2], [0 0 1 1;0.5 0.5 1 1;-1 -1 2 2]), [0 0.25 0])
+%!assert (rectint ([0 0 1 1;0.5 0.5 1 1;-1 -1 2 2], [1 1 2 2]), [0;0.25;0])
+%!assert (rectint ([1 1 2 2], [0 0 1 1;0.5 0.5 1 1;-1 -1 2 2]), [0 0.25 0])
+
--- a/scripts/geometry/tsearchn.m
+++ b/scripts/geometry/tsearchn.m
@@ -31,9 +31,9 @@
     print_usage ();
   endif
 
-  nt = size (t, 1);
+  nt = rows (t);
   [m, n] = size (x);
-  mi = size (xi, 1);
+  mi = rows (xi);
   idx = NaN (mi, 1);
   p = NaN (mi, n + 1);
 
@@ -44,8 +44,8 @@
     b = cart2bary (x (t (i, :), :), xi(ni,:));
 
     ## Our points xi are in the current triangle if
-    ## (all(b >= 0) && all (b <= 1)). However as we impose that
-    ## sum(b,2) == 1 we only need to test all(b>=0). Note need to add
+    ## (all (b >= 0) && all (b <= 1)). However as we impose that
+    ## sum (b,2) == 1 we only need to test all(b>=0). Note need to add
     ## a small margin for rounding errors
     intri = all (b >= -1e-12, 2);
     idx(ni(intri)) = i;
@@ -69,39 +69,41 @@
   ##
   ## and therefore we can write the above as
   ##
-  ## P - T(end, :) = Beta(1:end-1) * (T(1:end-1,:) - ones(N,1) * T(end,:))
+  ## P - T(end, :) = Beta(1:end-1) * (T(1:end-1,:) - ones (N,1) * T(end,:))
   ##
   ## and then we can solve for Beta as
   ##
-  ## Beta(1:end-1) = (P - T(end,:)) / (T(1:end-1,:) - ones(N,1) * T(end,:))
-  ## Beta(end) = sum(Beta)
+  ## Beta(1:end-1) = (P - T(end,:)) / (T(1:end-1,:) - ones (N,1) * T(end,:))
+  ## Beta(end) = sum (Beta)
   ##
   ## Note below is generalize for multiple values of P, one per row.
   [M, N] = size (P);
-  Beta = (P - ones (M,1) * T(end,:)) / (T(1:end-1,:) - ones(N,1) * T(end,:));
-  Beta (:,end+1) = 1 - sum(Beta, 2);
+  Beta = (P - ones (M,1) * T(end,:)) / (T(1:end-1,:) - ones (N,1) * T(end,:));
+  Beta (:,end+1) = 1 - sum (Beta, 2);
 endfunction
 
+
 %!shared x, tri
 %! x = [-1,-1;-1,1;1,-1];
 %! tri = [1, 2, 3];
 %!test
 %! [idx, p] = tsearchn (x,tri,[-1,-1]);
-%! assert (idx, 1)
-%! assert (p, [1,0,0], 1e-12)
+%! assert (idx, 1);
+%! assert (p, [1,0,0], 1e-12);
 %!test
 %! [idx, p] = tsearchn (x,tri,[-1,1]);
-%! assert (idx, 1)
-%! assert (p, [0,1,0], 1e-12)
+%! assert (idx, 1);
+%! assert (p, [0,1,0], 1e-12);
 %!test
 %! [idx, p] = tsearchn (x,tri,[1,-1]);
-%! assert (idx, 1)
-%! assert (p, [0,0,1], 1e-12)
+%! assert (idx, 1);
+%! assert (p, [0,0,1], 1e-12);
 %!test
 %! [idx, p] = tsearchn (x,tri,[-1/3,-1/3]);
-%! assert (idx, 1)
-%! assert (p, [1/3,1/3,1/3], 1e-12)
+%! assert (idx, 1);
+%! assert (p, [1/3,1/3,1/3], 1e-12);
 %!test
 %! [idx, p] = tsearchn (x,tri,[1,1]);
-%! assert (idx, NaN)
-%! assert (p, [NaN, NaN, NaN])
+%! assert (idx, NaN);
+%! assert (p, [NaN, NaN, NaN]);
+
--- a/scripts/geometry/voronoi.m
+++ b/scripts/geometry/voronoi.m
@@ -37,7 +37,7 @@
 ##
 ## If a single output argument is requested then the Voronoi diagram will be
 ## plotted and a graphics handle @var{h} to the plot is returned.
-## [@var{vx}, @var{vy}] = voronoi(@dots{}) returns the Voronoi vertices
+## [@var{vx}, @var{vy}] = voronoi (@dots{}) returns the Voronoi vertices
 ## instead of plotting the diagram.
 ##
 ## @example
@@ -146,7 +146,7 @@
                       edges(2, 1 :end - 1) != edges(2, 2 : end)), true]);
 
   ## Eliminate the edges of the diagram representing the box
-  poutside = (1 : rows(p)) ...
+  poutside = (1 : rows (p)) ...
       (p (:, 1) < xmin - xdelta | p (:, 1) > xmax + xdelta | ...
        p (:, 2) < ymin - ydelta | p (:, 2) > ymax + ydelta);
   edgeoutside = ismember (edges (1, :), poutside) & ...
@@ -174,14 +174,14 @@
 
 
 %!demo
-%! voronoi (rand(10,1), rand(10,1));
+%! voronoi (rand (10,1), rand (10,1));
 
 %!testif HAVE_QHULL
 %! phi = linspace (-pi, 3/4*pi, 8);
 %! [x,y] = pol2cart (phi, 1);
 %! [vx,vy] = voronoi (x,y);
-%! assert(vx(2,:), zeros (1, columns (vx)), eps);
-%! assert(vy(2,:), zeros (1, columns (vy)), eps);
+%! assert (vx(2,:), zeros (1, columns (vx)), eps);
+%! assert (vy(2,:), zeros (1, columns (vy)), eps);
 
 %% FIXME: Need input validation tests
 
deleted file mode 100644
--- a/scripts/gethelp.cc
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
-
-Copyright (C) 1999-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/>.
-
-*/
-
-#include <cstdio>
-
-#include <iostream>
-#include <string>
-
-static bool
-looks_like_octave_copyright (const std::string& s)
-{
-  // Perhaps someday we will want to do more here, so leave this as a
-  // separate function.
-
-  return (s.substr (0, 9) == "Copyright" || s.substr (0, 6) == "Author");
-}
-
-// Eat whitespace and comments from FFILE, returning the text of the
-// first block of comments that doesn't look like a copyright notice,
-
-static std::string
-extract_help_text (void)
-{
-  std::string help_txt;
-
-  bool first_comments_seen = false;
-  bool begin_comment = false;
-  bool have_help_text = false;
-  bool in_comment = false;
-  bool discard_space = true;
-  int c;
-
-  while ((c = std::cin.get ()) != EOF)
-    {
-      if (begin_comment)
-        {
-          if (c == '%' || c == '#')
-            continue;
-          else if (discard_space && c == ' ')
-            {
-              discard_space = false;
-              continue;
-            }
-          else
-            begin_comment = false;
-        }
-
-      if (in_comment)
-        {
-          if (! have_help_text)
-            {
-              first_comments_seen = true;
-              help_txt += static_cast<char> (c);
-            }
-
-          if (c == '\n')
-            {
-              in_comment = false;
-              discard_space = true;
-
-              if ((c = std::cin.get ()) != EOF)
-                {
-                  if (c == '\n')
-                    break;
-                }
-              else
-                break;
-            }
-        }
-      else
-        {
-          switch (c)
-            {
-            case ' ':
-            case '\t':
-              if (first_comments_seen)
-                have_help_text = true;
-              break;
-
-            case '\n':
-              if (first_comments_seen)
-                have_help_text = true;
-              continue;
-
-            case '%':
-            case '#':
-              begin_comment = true;
-              in_comment = true;
-              break;
-
-            default:
-              goto done;
-            }
-        }
-    }
-
- done:
-
-  if (! help_txt.empty ())
-    {
-      if (looks_like_octave_copyright (help_txt))
-        help_txt.resize (0);
-
-      if (help_txt.empty ())
-        help_txt = extract_help_text ();
-    }
-
-  return help_txt;
-}
-
-int
-main (int argc, char **argv)
-{
-  std::string name;
-  std::string file_name;
-
-  if (argc != 3)
-    {
-      std::cerr << "usage: gethelp name file-name\n";
-      return 1;
-    }
-  else
-    {
-      name = argv[1];
-      file_name = argv[2];
-    }
-
-  std::string help_text = extract_help_text ();
-
-  if (! help_text.empty ())
-    {
-      std::cout << "" << name << "\n"
-                << "@c " << name << " " << file_name << "\n"
-                << help_text;
-
-      if (help_text[help_text.length () - 1] != '\n')
-        std::cout << "\n";
-    }
-
-  return 0;
-}
--- a/scripts/help/__makeinfo__.m
+++ b/scripts/help/__makeinfo__.m
@@ -86,23 +86,23 @@
     error ("__makeinfo__: third input argument must be a function handle");
   endif
 
-
-  ## It seems like makeinfo sometimes gets angry if the first character
-  ## on a line is a space, so we remove these.
-  text = strrep (text, "\n ", "\n");
+  ## Formatting in m-files has an extra space at the beginning of every line.
+  ## Remove these unwanted spaces if present.  First text char is "\n" delim.
+  if (text(2) == " ")
+    text = strrep (text, "\n ", "\n");
+  endif
+  ## Texinfo crashes if @end tex does not appear first on the line.
+  text = regexprep (text, '^ +@end tex', '@end tex', 'lineanchors');
 
-  ## Handle @seealso macro
-  see_also_pat = '@seealso *\{(.*)\}';
-  args = regexp (text, see_also_pat, 'tokens');
-  for ii = 1:numel (args)
-    expanded = fsee_also (strtrim (strsplit (args{ii}{:}, ',', true)));
-    text = regexprep (text, see_also_pat, expanded, 'once');
-  endfor
-
-  ## Handle @nospell macro
-  text = regexprep (text, '@nospell *\{([^}]*)\}', "$1");
-  ## Handle @xcode macro
-  text = regexprep (text, '@xcode *\{([^}]*)\}', "$1");
+  file = texi_macros_file ();
+  fid = fopen (file, "r");
+  if (fid < 0)
+    error ("unable to open %s for reading", file);
+  else
+    macros_text = fread (fid, Inf, "*char")';
+    text = cstrcat (macros_text, text);
+  endif
+  fclose (fid);
 
   if (strcmpi (output_type, "texinfo"))
     status = 0;
@@ -145,6 +145,7 @@
   end_unwind_protect
 endfunction
 
+
 ## No test needed for internal helper function.
 %!assert (1)
 
--- a/scripts/help/doc.m
+++ b/scripts/help/doc.m
@@ -86,7 +86,7 @@
     have_fname = ! isempty (fname);
 
     if (have_fname)
-      status = system (sprintf ("%s --index-search %s", cmd, fname));
+      status = system (sprintf ("%s --index-search \"%s\"", cmd, fname));
     endif
 
     if (! (have_fname && status == 0))
@@ -106,6 +106,10 @@
 
 endfunction
 
-%!test if exist( info_file ()) != 2 && exist (sprintf ("%s.gz", info_file ())) != 2
-%!       error ("Info file %s or %s.gz does not exist!", info_file (), info_file ());
-%!     endif
+
+%!test
+%! ifile = info_file ();
+%! if (exist (ifile) != 2 && exist (sprintf ("%s.gz", ifile)) != 2)
+%!   error ("Info file %s or %s.gz does not exist!", ifile, ifile);
+%! endif
+
--- a/scripts/help/gen_doc_cache.m
+++ b/scripts/help/gen_doc_cache.m
@@ -34,23 +34,30 @@
 function gen_doc_cache (out_file = "doc-cache", directory = [])
 
   ## Check input
-  if (!ischar (out_file))
+  if (! ischar (out_file))
     print_usage ();
   endif
 
   ## Generate cache
   if (isempty (directory))
     cache = gen_builtin_cache ();
+  elseif (iscell (directory))
+    if (all (cellfun (@ischar, directory)))
+      cache = gen_doc_cache_in_dir (directory);
+    else
+      error ("gen_doc_cache: cell must contain only strings");
+    endif
   elseif (ischar (directory))
-    cache = gen_doc_cache_in_dir (directory);
+     cache = gen_doc_cache_in_dir (directory);
   else
-    error ("gen_doc_cache: second input argument must be a string");
+     error ("gen_doc_cache: second input argument must be a string or a cell of strings");
   endif
 
   ## Save cache
   if (! isempty (cache))
-    save ("-text", out_file, "cache");
+     save ("-text", out_file, "cache");
   endif
+
 endfunction
 
 function [text, first_sentence, status] = handle_function (f, text, format)
@@ -108,31 +115,33 @@
 endfunction
 
 function cache = gen_doc_cache_in_dir (directory)
+
   ## If 'directory' is not in the current path, add it so we search it
-  dir_in_path = false;
-  p = path ();
-  idx = find (p == pathsep ());
-  prev_idx = 1;
-  for n = 1:length (idx)
-    f = p (prev_idx:idx (n)-1);
-    if (strcmp (f, directory))
-      dir_in_path = true;
-      break;
-    endif
-    prev_idx = idx (n) + 1;
-  endfor
+  dir_in_path = ismember (directory, strsplit (path (), pathsep ()));
 
-  if (!dir_in_path)
-    addpath (directory);
+  # dirs not in path
+  if (! iscell (directory))
+    directory = {directory};
+  endif
+  dirs_notpath = {directory{!dir_in_path}};
+
+  # add them
+  if (! isempty (dirs_notpath))
+    cellfun (@addpath, dirs_notpath);
   endif
 
-  ## Get list of functions in directory and create cache
-  list = __list_functions__ (directory);
-  cache = create_cache (list);
+  # create cache
+  func = @(s_) create_cache (__list_functions__ (s_));
+  cache = cellfun (func, directory, 'UniformOutput', false);
 
-  if (!dir_in_path)
-    rmpath (directory);
+  # concatenate results
+  cache = [cache{:}];
+
+  #remove dirs form path
+  if (! isempty (dirs_notpath))
+    cellfun (@rmpath, dirs_notpath);
   endif
+
 endfunction
 
 function cache = gen_builtin_cache ()
@@ -148,4 +157,3 @@
 %% No true tests desirable for this function.
 %% Test input validation
 %!error gen_doc_cache (1)
-
--- a/scripts/help/get_first_help_sentence.m
+++ b/scripts/help/get_first_help_sentence.m
@@ -50,7 +50,7 @@
     error ("get_first_help_sentence: NAME must be a string");
   endif
 
-  if (!isnumeric (max_len) || max_len <= 0 || max_len != fix (max_len))
+  if (! isnumeric (max_len) || max_len <= 0 || max_len != fix (max_len))
     error ("get_first_help_sentence: MAX_LEN must be positive integer");
   endif
 
@@ -80,10 +80,13 @@
 
 ## This function extracts the first sentence from a plain text help text
 function [text, status] = first_sentence_plain_text (help_text, max_len)
-  ## Extract first line by searching for a period or a double line-end.
-  period_idx = find (help_text == '.', 1);
-  line_end_idx = strfind (help_text, "\n\n");
-  text = help_text (1:min ([period_idx(:); line_end_idx(:); max_len; length(help_text)]));
+  ## Extract first line by searching for a period followed by a space class
+  ## character (to support periods in numbers or words) ...
+  period_idx = regexp (help_text, '\.\s', "once");
+  ## ... or a double end-of-line (we subtract 1 because we are not interested
+  ## in capturing the first newline).
+  line_end_idx = regexp (help_text, "\n\n", "once") - 1;
+  text = help_text (1:min ([period_idx; line_end_idx; max_len; length(help_text)]));
   status = 0;
 endfunction
 
@@ -91,27 +94,27 @@
 ## The function works by removing @def* from the texinfo text. After this, we
 ## render the text to plain text using makeinfo, and then extract the first line.
 function [text, status] = first_sentence_texinfo (help_text, max_len)
-  ## Lines ending with "@\n" are continuation lines, so they should be concatenated
-  ## with the following line.
+  ## Lines ending with "@\n" are continuation lines, so they should be
+  ## concatenated with the following line.
   help_text = strrep (help_text, "@\n", " ");
 
   ## Find, and remove, lines that start with @def. This should remove things
   ## such as @deftypefn, @deftypefnx, @defvar, etc.
   keep = true (size (help_text));
   def_idx = strfind (help_text, "@def");
-  if (!isempty (def_idx))
+  if (! isempty (def_idx))
     endl_idx = find (help_text == "\n");
     for k = 1:length (def_idx)
-      endl = endl_idx (find (endl_idx > def_idx (k), 1));
+      endl = endl_idx(find (endl_idx > def_idx(k), 1));
       if (isempty (endl))
-        keep (def_idx (k):end) = false;
+        keep(def_idx(k):end) = false;
       else
-        keep (def_idx (k):endl) = false;
+        keep(def_idx(k):endl) = false;
       endif
     endfor
 
     ## Remove the @end ... that corresponds to the @def we removed above
-    def1 = def_idx (1);
+    def1 = def_idx(1);
     space_idx = find (help_text == " ");
     space_idx = space_idx (find (space_idx > def1, 1));
     bracket_idx = find (help_text == "{" | help_text == "}");
@@ -120,20 +123,20 @@
       error ("get_first_help_sentence: couldn't parse texinfo");
     endif
     sep_idx = min (space_idx, bracket_idx);
-    def_type = help_text (def1+1:sep_idx-1);
+    def_type = help_text(def1+1:sep_idx-1);
 
     end_idx = strfind (help_text, sprintf ("@end %s", def_type));
     if (isempty (end_idx))
       error ("get_first_help_sentence: couldn't parse texinfo");
     endif
-    endl = endl_idx (find (endl_idx > end_idx, 1));
+    endl = endl_idx(find (endl_idx > end_idx, 1));
     if (isempty (endl))
-      keep (end_idx:end) = false;
+      keep(end_idx:end) = false;
     else
-      keep (end_idx:endl) = false;
+      keep(end_idx:endl) = false;
     endif
 
-    help_text = help_text (keep);
+    help_text = help_text(keep);
   endif
 
   ## Run makeinfo to generate plain text
@@ -153,13 +156,14 @@
   text = first_sentence_plain_text (help_text, max_len);
 endfunction
 
-%!assert (strcmp (get_first_help_sentence('get_first_help_sentence'), "Return the first sentence of a function's help text."));
+
+%!assert (get_first_help_sentence ('get_first_help_sentence'), "Return the first sentence of a function's help text.")
 
 %% Test input validation
 %!error get_first_help_sentence ()
 %!error get_first_help_sentence (1, 2, 3)
-%!error get_first_help_sentence (1)
-%!error get_first_help_sentence ('ls', 'a')
-%!error get_first_help_sentence ('ls', 0)
-%!error get_first_help_sentence ('ls', 80.1)
+%!error <NAME must be a string> get_first_help_sentence (1)
+%!error <MAX_LEN must be positive integer> get_first_help_sentence ("ls", "a")
+%!error <MAX_LEN must be positive integer> get_first_help_sentence ("ls", 0)
+%!error <MAX_LEN must be positive integer> get_first_help_sentence ("ls", 80.1)
 
--- a/scripts/help/help.m
+++ b/scripts/help/help.m
@@ -181,5 +181,7 @@
 endfunction
 
 
-%!assert (! isempty (findstr (help ("ls"), "List directory contents")))
+%!assert (! isempty (strfind (help ("ls"), "List directory contents")))
 %!error <invalid input> help (42)
+
+
--- a/scripts/help/lookfor.m
+++ b/scripts/help/lookfor.m
@@ -20,11 +20,11 @@
 ## @deftypefn  {Command} {} lookfor @var{str}
 ## @deftypefnx {Command} {} lookfor -all @var{str}
 ## @deftypefnx {Function File} {[@var{func}, @var{helpstring}] =} lookfor (@var{str})
-## @deftypefnx {Function File} {[@var{func}, @var{helpstring}] =} lookfor ('-all', @var{str})
+## @deftypefnx {Function File} {[@var{func}, @var{helpstring}] =} lookfor ("-all", @var{str})
 ## Search for the string @var{str} in all functions found in the current
 ## function search path.  By default, @code{lookfor} searches for @var{str}
 ## in the first sentence of the help string of each function found.  The entire
-## help text of each function can be searched if the '-all' argument is
+## help text of each function can be searched if the "-all" argument is
 ## supplied.  All searches are case insensitive.
 ##
 ## Called with no output arguments, @code{lookfor} prints the list of
@@ -36,7 +36,7 @@
 ## sentence of the help text is dependent on the format of the
 ## function's help.  All Octave core functions are correctly
 ## formatted, but the same can not be guaranteed for external packages and
-## user-supplied functions.  Therefore, the use of the '-all' argument may
+## user-supplied functions.  Therefore, the use of the "-all" argument may
 ## be necessary to find related functions that are not a part of Octave.
 ## @seealso{help, doc, which}
 ## @end deftypefn
--- a/scripts/help/type.m
+++ b/scripts/help/type.m
@@ -111,14 +111,16 @@
   endfor
 endfunction
 
+
 %!test
 %! var = 1;
 %! typestr = type ("var");
 %! typestr = typestr{1}(1:17);
 %! assert (typestr, "var is a variable");
 
-%!assert (type ('dot'){1}, "dot is a dynamically-linked function")
-%!assert (type ('cat'){1}, "cat is a built-in function")
-%!assert (type ('+'){1}, "+ is an operator")
-%!assert (type ('end'){1}, "end is a keyword")
+%!assert (type ("dot"){1}, "dot is a dynamically-linked function")
+%!assert (type ("cat"){1}, "cat is a built-in function")
+%!assert (type ("+"){1}, "+ is an operator")
+%!assert (type ("end"){1}, "end is a keyword")
 %!error (type ('NO_NAME'))
+ 
--- a/scripts/help/unimplemented.m
+++ b/scripts/help/unimplemented.m
@@ -98,7 +98,6 @@
   "bar3",
   "bar3h",
   "bench",
-  "betaincinv",
   "bicgstabl",
   "brush",
   "builddocsearchdb",
@@ -144,7 +143,6 @@
   "condeig",
   "coneplot",
   "contourslice",
-  "copyobj",
   "createClassFromWsdl",
   "createSoapMessage",
   "customverctrl",
@@ -169,7 +167,6 @@
   "echodemo",
   "ellipj",
   "ellipke",
-  "erfcinv",
   "errordlg",
   "evalc",
   "exifread",
@@ -178,7 +175,6 @@
   "figurepalette",
   "filebrowser",
   "fill3",
-  "findfigs",
   "fitsinfo",
   "fitsread",
   "flow",
@@ -191,7 +187,6 @@
   "gco",
   "getframe",
   "getpixelposition",
-  "gmres",
   "grabcode",
   "graymon",
   "gsvd",
@@ -321,7 +316,6 @@
   "printdlg",
   "printopt",
   "printpreview",
-  "profile",
   "profsave",
   "propedit",
   "propertyeditor",
@@ -333,7 +327,6 @@
   "reducepatch",
   "reducevolume",
   "resample",
-  "rgbplot",
   "root",
   "rotate",
   "rotate3d",
@@ -342,7 +335,6 @@
   "serial",
   "setpixelposition",
   "showplottool",
-  "shrinkfaces",
   "smooth3",
   "snapnow",
   "sound",
@@ -362,7 +354,6 @@
   "surf2patch",
   "symmlq",
   "syntax",
-  "tetramesh",
   "texlabel",
   "textwrap",
   "tfqmr",
@@ -431,5 +422,4 @@
 %! assert (str(1:51), "quad2d is not implemented.  Consider using dblquad.");
 %! str = unimplemented ("MException");
 %! assert (str(1:58), "the `MException' function is not yet implemented in Octave");
-
-
+ 
--- a/scripts/help/which.m
+++ b/scripts/help/which.m
@@ -57,9 +57,10 @@
 
 %!test
 %! str = which ("ls");
-%! assert (str(end-17:end), strcat ("miscellaneous", filesep(), "ls.m"));
+%! assert (str(end-17:end), strcat ("miscellaneous", filesep (), "ls.m"));
 %!test
 %! str = which ("dot");
 %! assert (str(end-6:end), "dot.oct");
 
-%!assert (which ("NO_NAME"), "");
+%!assert (which ("_NO_SUCH_NAME_"), "")
+
--- a/scripts/image/autumn.m
+++ b/scripts/image/autumn.m
@@ -28,6 +28,9 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
+## PKG_ADD: colormap ("register", "autumn");
+## PKG_DEL: colormap ("unregister", "autumn");
+
 function map = autumn (n)
 
   if (nargin == 0)
@@ -44,18 +47,19 @@
     map = [1, 0, 0];
   elseif (n > 1)
     r = ones (n, 1);
-    g = (0:n - 1)' ./ (n - 1);
+    g = [0:(n-1)]' / (n - 1);
     b = zeros (n, 1);
     map = [r, g, b];
   else
-    map = [];
+    map = zeros (0, 3);
   endif
 
 endfunction
 
+
 %!demo
 %! ## Show the 'autumn' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
-%! axis ([1, 64, 0, 1], "ticy", "xy")
-%! colormap (autumn (64))
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (autumn (64));
 
--- a/scripts/image/bone.m
+++ b/scripts/image/bone.m
@@ -28,6 +28,9 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
+## PKG_ADD: colormap ("register", "bone");
+## PKG_DEL: colormap ("unregister", "bone");
+
 function map = bone (n)
 
   if (nargin == 0)
@@ -41,24 +44,27 @@
   endif
 
   if (n == 1)
-    map = [0, 0, 0];
+    map = [0.125, 0.125, 0.125];
   elseif (n > 1)
     x = linspace (0, 1, n)';
-
-    r = (x < 3/4) .* (7/8 * x) + (x >= 3/4) .* (11/8 * x - 3/8);
-    g = (x < 3/8) .* (7/8 * x)\
-      + (x >= 3/8 & x < 3/4) .* (29/24 * x - 1/8)\
+    r = (x < 3/4) .* (7/8 * x) ...
+      + (x >= 3/4) .* (11/8 * x - 3/8);
+    g = (x < 3/8) .* (7/8 * x) ...
+      + (x >= 3/8 & x < 3/4) .* (29/24 * x - 1/8) ...
       + (x >= 3/4) .* (7/8 * x + 1/8);
-    b = (x < 3/8) .* (29/24 * x) + (x >= 3/8) .* (7/8 * x + 1/8);
+    b = (x < 3/8) .* (29/24 * x) ...
+      + (x >= 3/8) .* (7/8 * x + 1/8);
     map = [r, g, b];
   else
-    map = [];
+    map = zeros (0, 3);
   endif
+
 endfunction
 
+
 %!demo
 %! ## Show the 'bone' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
-%! axis ([1, 64, 0, 1], "ticy", "xy")
-%! colormap (bone (64))
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (bone (64));
 
--- a/scripts/image/brighten.m
+++ b/scripts/image/brighten.m
@@ -18,20 +18,18 @@
 
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {@var{map_out} =} brighten (@var{map}, @var{beta})
+## @deftypefnx {Function File} {@var{map_out} =} brighten (@var{beta})
 ## @deftypefnx {Function File} {@var{map_out} =} brighten (@var{h}, @var{beta})
-## @deftypefnx {Function File} {@var{map_out} =} brighten (@var{beta})
-## Darken or brighten the given colormap.  If the @var{map} argument
-## is omitted, the function is applied to the current colormap.  The first
-## argument can also be a valid graphics handle @var{h}, in which case
-## @code{brighten} is applied to the colormap associated with this handle.
+## Brighten or darken a colormap.  If the @var{map} argument is omitted, the
+## function is applied to the current colormap.  The first argument can also be
+## a valid graphics handle @var{h}, in which case @code{brighten} is applied to
+## the colormap associated with this handle.
 ##
-## Should the resulting colormap @var{map_out} not be assigned, it will be
-## written to the current colormap.
+## The argument @var{beta} must be a scalar between -1 and 1, where a
+## negative value darkens and a positive value brightens the colormap.
 ##
-## The argument @var{beta} should be a scalar between -1 and 1,
-## where a negative value darkens and a positive value brightens
-## the colormap.
-## @seealso{colormap}
+## If no output is specified then the result is written to the current colormap.
+## @seealso{colormap, contrast}
 ## @end deftypefn
 
 function rmap = brighten (arg1, beta)
new file mode 100644
--- /dev/null
+++ b/scripts/image/colorcube.m
@@ -0,0 +1,96 @@
+## Copyright (C) 2012 Rik Wehbring
+##
+## 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{map} =} colorcube ()
+## @deftypefnx {Function File} {@var{map} =} colorcube (@var{n})
+## Create color colormap.  This colormap is composed of as many equally
+## spaced colors (not grays) in the RGB color space as possible.  If there
+## are not a perfect number @var{n} of regularly spaced colors then the
+## remaining entries in the colormap are gradients of pure red, green, blue,
+## and gray.
+## The argument @var{n} must be a scalar.
+## If unspecified, the length of the current colormap, or 64, is used.
+## @seealso{colormap}
+## @end deftypefn
+
+function map = colorcube (n)
+
+  if (nargin == 0)
+    n = rows (colormap);
+  elseif (nargin == 1)
+    if (! isscalar (n))
+      error ("colorcube: argument must be a scalar");
+    endif
+  else
+    print_usage ();
+  endif
+
+  if (n < 9)
+    map = gray (n);
+    return;
+  endif
+
+  # Create colorcube of evenly spaced points with side length of n^1/3
+  cubelen = fix (cbrt (n));
+  reserve = n - cubelen^3; 
+
+  if (reserve == 0)
+    # Steal space from blue to put the gray gradient
+    [r, g, b] = meshgrid (linspace (0,1,cubelen),
+                          linspace (0,1,cubelen),
+                          linspace (0,1,cubelen-1));
+  else
+    [r, g, b] = meshgrid (linspace (0,1,cubelen),
+                          linspace (0,1,cubelen),
+                          linspace (0,1,cubelen));
+  endif
+
+  # Create map and weed out grays
+  map = [r(:), g(:), b(:)];
+  idx = any (bsxfun (@ne, map(:, 1), map(:, 2:3)), 2);
+  map = map(idx, :);
+
+  # Weed out pure colors
+  idx = sum (map == 0, 2);
+  map = map(idx != 2, :);
+
+  # Put in remaining gradients of pure red, green, blue, and gray
+  reserve = n - rows (map) - 1;
+  csteps = fix (reserve/4);
+  cstepsz = 1 / csteps;
+  cgrad = (cstepsz:cstepsz:1)';
+  gsteps = reserve - 3*csteps;
+  gstepsz = 1 / gsteps;
+  ggrad = (gstepsz:gstepsz:1)';
+  map = [map
+         cgrad, zeros(csteps, 1), zeros(csteps, 1)
+         zeros(csteps, 1), cgrad, zeros(csteps, 1)
+         zeros(csteps, 1), zeros(csteps, 1), cgrad 
+         0, 0, 0
+         ggrad, ggrad, ggrad];
+
+endfunction
+
+
+%!demo
+%! ## Show the 'colorcube' colormap as an image
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (colorcube (64));
+
--- a/scripts/image/colormap.m
+++ b/scripts/image/colormap.m
@@ -1,4 +1,5 @@
 ## Copyright (C) 1994-2012 John W. Eaton
+## Copyright (C) 2012 Carnë Draug
 ##
 ## This file is part of Octave.
 ##
@@ -17,18 +18,26 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {} colormap (@var{map})
-## @deftypefnx {Function File} {} colormap ("default")
-## Set the current colormap.
+## @deftypefn  {Function File} {@var{cmap} =} colormap ()
+## @deftypefnx {Function File} {@var{cmap} =} colormap (@var{map})
+## @deftypefnx {Function File} {@var{cmap} =} colormap ("default")
+## @deftypefnx {Function File} {@var{cmap} =} colormap ("list")
+## @deftypefnx {Function File} {@var{cmap} =} colormap ("register", "name")
+## @deftypefnx {Function File} {@var{cmap} =} colormap ("unregister", "name")
+## Query or set the current colormap.
 ##
 ## @code{colormap (@var{map})} sets the current colormap to @var{map}.  The
-## color map should be an @var{n} row by 3 column matrix.  The columns
+## colormap should be an @var{n} row by 3 column matrix.  The columns
 ## contain red, green, and blue intensities respectively.  All entries
-## should be between 0 and 1 inclusive.  The new colormap is returned.
+## must be between 0 and 1 inclusive.  The new colormap is returned.
 ##
 ## @code{colormap ("default")} restores the default colormap (the
 ## @code{jet} map with 64 entries).  The default colormap is returned.
 ##
+## @code{colormap ("list")} returns a cell array with all the available
+## colormaps.  The options `register' and `unregister' will add or remove the
+## colormap @var{name} to it.
+##
 ## With no arguments, @code{colormap} returns the current color map.
 ## @seealso{jet}
 ## @end deftypefn
@@ -37,17 +46,22 @@
 ## Created: July 1994
 ## Adapted-By: jwe
 
-function cmap = colormap (map)
+function cmap = colormap (map, name)
 
-  if (nargin > 1)
+  if (nargin > 2)
     print_usage ();
   endif
 
+  persistent map_list = cell ();
+
   if (nargin == 1)
 
     if (ischar (map))
       if (strcmp (map, "default"))
         map = jet (64);
+      elseif (strcmp (map, "list"))
+        cmap = map_list;
+        return;
       else
         map = feval (map);
       endif
@@ -64,6 +78,16 @@
       set (gcf (), "colormap", map);
     endif
 
+  elseif (nargin == 2)
+    if (! ischar (map) || all (! strcmp (map, {"register", "unregister"})))
+      print_usage ();
+    elseif (! ischar (name))
+      error ("colormap: to register/unregister a colormap, NAME must be a string");
+    elseif (strcmp (map, "register"))
+      map_list{end+1} = name;
+    elseif (strcmp (map, "unregister"))
+      map_list(strcmp (name, map_list)) = [];
+    endif
   endif
 
   ## Return current color map.
--- a/scripts/image/contrast.m
+++ b/scripts/image/contrast.m
@@ -17,11 +17,12 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {} contrast (@var{x}, @var{n})
+## @deftypefn  {Function File} {@var{map} =} contrast (@var{x})
+## @deftypefnx {Function File} {@var{map} =} contrast (@var{x}, @var{n})
 ## Return a gray colormap that maximizes the contrast in an image.  The
 ## returned colormap will have @var{n} rows.  If @var{n} is not defined
-## then the size of the current colormap is used instead.
-## @seealso{colormap}
+## then the size of the current colormap is used.
+## @seealso{colormap, brighten}
 ## @end deftypefn
 
 function map = contrast (x, n)
@@ -42,9 +43,22 @@
   minm = min (map);
   map = (map - minm) ./ (max (map) - minm);
   map = [map, map, map];
+
 endfunction
 
-%!assert (contrast(1:100,10),[([0:9]/9)',([0:9]/9)',([0:9]/9)'],1e-10)
+
 %!demo
-%! image (reshape (1:100, 10, 10))
-%! colormap (contrast (1:100,10))
+%! clf;
+%! img = reshape (1:100, 10, 10);
+%! imagesc (img);
+%! colormap (gray (64));
+%! title ("Image with default 64 gray levels");
+%! pos = get (gcf, "position");
+%! pos(1) += pos(3) + 15;
+%! figure ("position", pos); 
+%! colormap (contrast (img, 10));
+%! imagesc (img);
+%! title ("Image with contrast enhanced");
+
+%!assert (contrast (1:100,10), [([0:9]/9)',([0:9]/9)',([0:9]/9)'], 1e-10)
+
--- a/scripts/image/cool.m
+++ b/scripts/image/cool.m
@@ -27,6 +27,9 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
+## PKG_ADD: colormap ("register", "cool");
+## PKG_DEL: colormap ("unregister", "cool");
+
 function map = cool (n)
 
   if (nargin == 0)
@@ -42,19 +45,20 @@
   if (n == 1)
     map = [0, 1, 1];
   elseif (n > 1)
-    r = (0:n - 1)' ./ (n - 1);
+    r = [0:(n-1)]' / (n - 1);
     g = 1 - r;
     b = ones (n, 1);
     map = [r, g, b];
   else
-    map = [];
+    map = zeros (0, 3);
   endif
 
 endfunction
 
+
 %!demo
 %! ## Show the 'cool' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
-%! axis ([1, 64, 0, 1], "ticy", "xy")
-%! colormap (cool (64))
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (cool (64));
 
--- a/scripts/image/copper.m
+++ b/scripts/image/copper.m
@@ -28,6 +28,9 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
+## PKG_ADD: colormap ("register", "copper");
+## PKG_DEL: colormap ("unregister", "copper");
+
 function map = copper (n)
 
   if (nargin == 0)
@@ -44,19 +47,21 @@
     map = [0, 0, 0];
   elseif (n > 1)
     x = linspace (0, 1, n)';
-    r = (x < 4/5) .* (5/4 * x) + (x >= 4/5);
+    r = (x < 4/5) .* (5/4 * x) ...
+      + (x >= 4/5);
     g = 4/5 * x;
     b = 1/2 * x;
     map = [r, g, b];
   else
-    map = [];
+    map = zeros (0, 3);
   endif
 
 endfunction
 
+
 %!demo
 %! ## Show the 'copper' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
-%! axis ([1, 64, 0, 1], "ticy", "xy")
-%! colormap (copper (64))
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (copper (64));
 
--- a/scripts/image/flag.m
+++ b/scripts/image/flag.m
@@ -19,7 +19,7 @@
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {@var{map} =} flag ()
 ## @deftypefnx {Function File} {@var{map} =} flag (@var{n})
-## Create color colormap.  This colormap cycles through red, white, blue
+## Create color colormap.  This colormap cycles through red, white, blue,
 ## and black with each index change.
 ## The argument @var{n} must be a scalar.
 ## If unspecified, the length of the current colormap, or 64, is used.
@@ -28,6 +28,9 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
+## PKG_ADD: colormap ("register", "flag");
+## PKG_DEL: colormap ("unregister", "flag");
+
 function map = flag (n)
 
   if (nargin == 0)
@@ -40,20 +43,21 @@
     print_usage ();
   endif
 
-  p = [1, 0, 0; 1, 1, 1; 0, 0, 1; 0, 0, 0];
-  if (rem(n,4) == 0)
-    map = kron (ones (n / 4, 1), p);
+  if (n == 1)
+    map = [1, 0, 0];
+  elseif (n > 1)
+    C = [1, 0, 0; 1, 1, 1; 0, 0, 1; 0, 0, 0];
+    map = C(rem (0:(n-1), 4) + 1, :);
   else
-    m1 = kron (ones (fix (n / 4), 1), p);
-    m2 = p(1:rem (n, 4), :);
-    map = [m1; m2];
+    map = zeros (0, 3);
   endif
 
 endfunction
 
+
 %!demo
 %! ## Show the 'flag' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
-%! axis ([1, 64, 0, 1], "ticy", "xy")
-%! colormap (flag (64))
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (flag (64));
 
--- a/scripts/image/gmap40.m
+++ b/scripts/image/gmap40.m
@@ -23,11 +23,14 @@
 ## magenta and cyan.  This colormap is specifically designed for users of
 ## gnuplot 4.0 where these 6 colors are the allowable ones for patch objects.
 ## The argument @var{n} must be a scalar.
-## If unspecified, a length of 6 is assumed.  Larger values
-## of @var{n} result in a repetition of the above colors.
+## If unspecified, a length of 6 is assumed.  Larger values of @var{n} result
+## in a repetition of the above colors.
 ## @seealso{colormap}
 ## @end deftypefn
 
+## PKG_ADD: colormap ("register", "gmap40");
+## PKG_DEL: colormap ("unregister", "gmap40");
+
 function map = gmap40 (n)
 
   if (nargin == 0)
@@ -40,18 +43,19 @@
     print_usage ();
   endif
 
-  if (n >= 1)
-    map = repmat ([1, 0, 0; 0, 1, 0; 0, 0, 1; 1, 1, 0; 1, 0, 1; 0, 1, 1],
-          ceil (n / 6), 1) (1:n, :);
+  if (n > 1)
+    C = [1, 0, 0; 0, 1, 0; 0, 0, 1; 1, 1, 0; 1, 0, 1; 0, 1, 1];
+    map = C(rem (0:(n-1), 6) + 1, :);
   else
-    map = [];
+    map = zeros (0, 3);
   endif
 
 endfunction
 
+
 %!demo
 %! ## Show the 'gmap40' colormap as an image
-%! image (1:6, linspace (0, 1, 6), repmat (1:6, 6, 1)')
-%! axis ([1, 6, 0, 1], "ticy", "xy")
-%! colormap (gmap40 (6))
+%! image (1:6, linspace (0, 1, 6), repmat ((1:6)', 1, 6));
+%! axis ([1, 6, 0, 1], "ticy", "xy");
+%! colormap (gmap40 (6));
 
--- a/scripts/image/gray.m
+++ b/scripts/image/gray.m
@@ -23,12 +23,16 @@
 ## shades of gray.
 ## The argument @var{n} must be a scalar.
 ## If unspecified, the length of the current colormap, or 64, is used.
+## @seealso{colormap}
 ## @end deftypefn
 
 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
 ## Created: July 1994
 ## Adapted-By: jwe
 
+## PKG_ADD: colormap ("register", "gray");
+## PKG_DEL: colormap ("unregister", "gray");
+
 function map = gray (n)
 
   if (nargin == 0)
@@ -41,15 +45,21 @@
     print_usage ();
   endif
 
-  gr = [0:(n-1)]';
-
-  map = [ gr, gr, gr ] / (n - 1);
+  if (n == 1)
+    map = [0, 0, 0];
+  elseif (n > 1)
+    gr = [0:(n-1)]' / (n - 1);
+    map = [gr, gr, gr];
+  else
+    map = zeros (0, 3);
+  endif
 
 endfunction
 
+
 %!demo
 %! ## Show the 'gray' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
-%! axis ([1, 64, 0, 1], "ticy", "xy")
-%! colormap (gray (64))
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (gray (64));
 
--- a/scripts/image/gray2ind.m
+++ b/scripts/image/gray2ind.m
@@ -17,10 +17,13 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {[@var{img}, @var{map}] =} gray2ind (@var{I}, @var{n})
+## @deftypefn  {Function File} {[@var{img} =} gray2ind (@var{I})
+## @deftypefnx {Function File} {[@var{img} =} gray2ind (@var{I}, @var{n})
+## @deftypefnx {Function File} {[@var{img}, @var{map} =} gray2ind (@dots{})
 ## Convert a gray scale intensity image to an Octave indexed image.
-## The indexed image will consist of @var{n} different intensity values.  If not
-## given @var{n} will default to 64.
+## The indexed image will consist of @var{n} different intensity values.
+## If not given @var{n} defaults to 64.
+## @seealso{ind2gray, rgb2ind} 
 ## @end deftypefn
 
 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
@@ -32,7 +35,7 @@
   if (nargin < 1 || nargin > 2)
     print_usage ();
   endif
-  C = class(I);
+  C = class (I);
   if (! ismatrix (I) || ndims (I) != 2)
     error ("gray2ind: first input argument must be a gray scale image");
   endif
--- a/scripts/image/hot.m
+++ b/scripts/image/hot.m
@@ -28,6 +28,9 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
+## PKG_ADD: colormap ("register", "hot");
+## PKG_DEL: colormap ("unregister", "hot");
+
 function map = hot (n)
 
   if (nargin == 0)
@@ -41,22 +44,25 @@
   endif
 
   if (n == 1)
-    map = [0, 0, 0];
+    map = [1, 1, 1];
   elseif (n > 1)
     x = linspace (0, 1, n)';
-    r = (x < 2/5) .* (5/2 * x) + (x >= 2/5);
-    g = (x >= 2/5 & x < 4/5) .* (5/2 * x - 1) + (x >= 4/5);
-    b = (x >= 4/5) .* (5*x - 4);
+    r = (x < 2/5) .* (5/2 * x) ...
+      + (x >= 2/5);
+    g = (x >= 2/5 & x < 4/5) .* (5/2 * x - 1) ...
+      + (x >= 4/5);
+    b = (x >= 4/5) .* (5 * x - 4);
     map = [r, g, b];
   else
-    map = [];
+    map = zeros (0, 3);
   endif
 
 endfunction
 
+
 %!demo
 %! ## Show the 'hot' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
-%! axis ([1, 64, 0, 1], "ticy", "xy")
-%! colormap (hot (64))
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (hot (64));
 
--- a/scripts/image/hsv.m
+++ b/scripts/image/hsv.m
@@ -20,9 +20,9 @@
 ## @deftypefn {Function File} {} hsv (@var{n})
 ## Create color colormap.  This colormap begins with red, changes through
 ## yellow, green, cyan, blue, and magenta, before returning to red.
-## It is useful for displaying periodic functions.  It is obtained by linearly
-## varying the hue through all possible values while keeping constant maximum
-## saturation and value and is equivalent to
+## It is useful for displaying periodic functions.  The map is obtained by
+## linearly varying the hue through all possible values while keeping constant
+## maximum saturation and value.  The equivalent code is
 ## @code{hsv2rgb ([linspace(0,1,N)', ones(N,2)])}.
 ##
 ## The argument @var{n} must be a scalar.
@@ -32,6 +32,9 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
+## PKG_ADD: colormap ("register", "hsv");
+## PKG_DEL: colormap ("unregister", "hsv");
+
 function map = hsv (n)
 
   if (nargin == 0)
@@ -47,17 +50,18 @@
   if (n == 1)
     map = [1, 0, 0];
   elseif (n > 1)
-    h = linspace (0, 1, n)';
-    map = hsv2rgb ([h, ones(n, 1), ones(n, 1)]);
+    hue = linspace (0, 1, n)';
+    map = hsv2rgb ([hue, ones(n,1), ones(n,1)]);
   else
-    map = [];
+    map = zeros (0, 3);
   endif
 
 endfunction
 
+
 %!demo
 %! ## Show the 'hsv' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
-%! axis ([1, 64, 0, 1], "ticy", "xy")
-%! colormap (hsv (64))
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (hsv (64));
 
--- a/scripts/image/hsv2rgb.m
+++ b/scripts/image/hsv2rgb.m
@@ -17,9 +17,11 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {@var{rgb_map} =} hsv2rgb (@var{hsv_map})
-## Transform a colormap or image from the HSV space to the RGB space.
-## @seealso{rgb2hsv}
+## @deftypefn  {Function File} {@var{rgb_map} =} hsv2rgb (@var{hsv_map})
+## @deftypefnx {Function File} {@var{rgb_img} =} hsv2rgb (@var{hsv_img})
+## Transform a colormap or image from hue-saturation-value (HSV) space to
+## red-green-blue (RGB) space.
+## @seealso{rgb2hsv, ind2rgb, ntsc2rgb}
 ## @end deftypefn
 
 ## Author: Kai Habel <kai.habel@gmx.de>
@@ -27,10 +29,10 @@
 
 function rgb_map = hsv2rgb (hsv_map)
 
-## Each color value x = (r,g,b) is calculated with
-## x = (1-sat)*val+sat*val*f_x(hue)
-## where f_x(hue) is a piecewise defined function for
-## each color with f_r(hue-2/3) = f_g(hue) = f_b(hue-1/3).
+  ## Each color value x = (r,g,b) is calculated with
+  ## x = (1-sat)*val+sat*val*f_x(hue)
+  ## where f_x(hue) is a piecewise defined function for
+  ## each color with f_r(hue-2/3) = f_g(hue) = f_b(hue-1/3).
 
   if (nargin != 1)
     print_usage ();
@@ -57,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/image.m
+++ b/scripts/image/image.m
@@ -20,24 +20,24 @@
 ## @deftypefn  {Function File} {} image (@var{img})
 ## @deftypefnx {Function File} {} image (@var{x}, @var{y}, @var{img})
 ## @deftypefnx {Function File} {@var{h} =} image (@dots{})
-## Display a matrix as a color image.  The elements of @var{img} are indices
-## into the current colormap, and the colormap will be scaled so that the
-## extremes of @var{img} are mapped to the extremes of the colormap.
+## Display a matrix as a color image.
 ##
+## The elements of @var{img} are indices into the current colormap.
 ## The axis values corresponding to the matrix elements are specified in
-## @var{x} and @var{y}.  If you're not using gnuplot 4.2 or later, these
+## @var{x} and @var{y}.  If you are using gnuplot 4.1 or earlier, these
 ## variables are ignored.
 ##
+## The optional return value @var{h} is a graphics handle to the image.
+##
 ## Implementation Note: The origin (0, 0) for images is located in the
 ## upper left.  For ordinary plots, the origin is located in the lower
 ## left.  Octave handles this inversion by plotting the data normally,
 ## and then reversing the direction of the y-axis by setting the
-## @code{ydir} property to @code{"reverse"}.  This has implications whenever
+## @code{ydir} property to "reverse".  This has implications whenever
 ## an image and an ordinary plot need to be overlaid.  The recommended
 ## solution is to display the image and then plot the reversed ydata
 ## using, for example, @code{flipud (ydata,1)}.
 ##
-## The optional return value @var{h} is a graphics handle to the image.
 ## @seealso{imshow, imagesc, colormap}
 ## @end deftypefn
 
@@ -90,7 +90,7 @@
 ## Generic image creation.
 ##
 ## The axis values corresponding to the matrix elements are specified in
-## @var{x} and @var{y}. If you're not using gnuplot 4.2 or later, these
+## @var{x} and @var{y}.  If you're not using gnuplot 4.2 or later, these
 ## variables are ignored.
 
 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
@@ -135,12 +135,12 @@
   if (xdata(2) < xdata(1))
     xdata = xdata(2:-1:1);
   elseif (xdata(2) == xdata(1))
-    xdata = xdata(1) + [0, size(img,2)-1];
+    xdata = xdata(1) + [0, columns(img)-1];
   endif
   if (ydata(2) < ydata(1))
     ydata = ydata(2:-1:1);
   elseif (ydata(2) == ydata(1))
-    ydata = ydata(1) + [0, size(img,1)-1];
+    ydata = ydata(1) + [0, rows(img)-1];
   endif
   xlim = xdata + [-px(1), px(1)];
   ylim = ydata + [-px(2), px(2)];
@@ -175,64 +175,69 @@
 
 endfunction
 
+
 %!demo
-%! clf
+%! clf;
+%! colormap ("default");
 %! img = 1 ./ hilb (11);
 %! x = -5:5;
 %! y = x;
-%! subplot (2,2,1)
-%! h = image (abs(x), abs(y), img);
-%! set (h, "cdatamapping", "scaled")
-%! ylabel ("limits = [4.5, 15.5]")
-%! title ('image (abs(x), abs(y), img)')
-%! subplot (2,2,2)
-%! h = image (-x, y, img);
-%! set (h, "cdatamapping", "scaled")
-%! title ('image (-x, y, img)')
-%! subplot (2,2,3)
-%! h = image (x, -y, img);
-%! set (h, "cdatamapping", "scaled")
-%! title ('image (x, -y, img)')
-%! ylabel ("limits = [-5.5, 5.5]")
-%! subplot (2,2,4)
-%! h = image (-x, -y, img);
-%! set (h, "cdatamapping", "scaled")
-%! title ('image (-x, -y, img)')
+%! subplot (2,2,1);
+%!  h = image (abs(x), abs(y), img);
+%!  set (h, "cdatamapping", "scaled");
+%!  ylabel ("limits = [4.5, 15.5]");
+%!  title ("image (abs(x), abs(y), img)");
+%! subplot (2,2,2);
+%!  h = image (-x, y, img);
+%!  set (h, "cdatamapping", "scaled");
+%!  title ("image (-x, y, img)");
+%! subplot (2,2,3);
+%!  h = image (x, -y, img);
+%!  set (h, "cdatamapping", "scaled");
+%!  title ("image (x, -y, img)");
+%!  ylabel ("limits = [-5.5, 5.5]");
+%! subplot (2,2,4);
+%!  h = image (-x, -y, img);
+%!  set (h, "cdatamapping", "scaled");
+%!  title ("image (-x, -y, img)");
 
 %!demo
-%! clf
+%! clf;
+%! colormap ("default");
 %! g = 0.1:0.1:10;
 %! h = g'*g;
 %! imagesc (g, g, sin (h));
-%! hold on
+%! hold on;
 %! imagesc (g, g+12, cos (h/2));
-%! axis ([0 10 0 22])
-%! hold off
-%! title ("two consecutive images")
+%! axis ([0 10 0 22]);
+%! hold off;
+%! title ("two consecutive images");
 
 %!demo
-%! clf
+%! clf;
+%! colormap ("default");
 %! g = 0.1:0.1:10;
 %! h = g'*g;
 %! imagesc (g, g, sin (h));
-%! hold all
-%! plot (g, 11.0 * ones (size (g)))
+%! hold all;
+%! plot (g, 11.0 * ones (size (g)));
 %! imagesc (g, g+12, cos (h/2));
-%! axis ([0 10 0 22])
-%! hold off
-%! title ("image, line, image")
+%! axis ([0 10 0 22]);
+%! hold off;
+%! title ("image, line, image");
 
 %!demo
-%! clf
+%! clf;
+%! colormap ("default");
 %! g = 0.1:0.1:10;
 %! h = g'*g;
-%! plot (g, 10.5 * ones (size (g)))
-%! hold all
+%! plot (g, 10.5 * ones (size (g)));
+%! hold all;
 %! imagesc (g, g, sin (h));
-%! plot (g, 11.0 * ones (size (g)))
+%! plot (g, 11.0 * ones (size (g)));
 %! imagesc (g, g+12, cos (h/2));
-%! plot (g, 11.5 * ones (size (g)))
-%! axis ([0 10 0 22])
-%! hold off
-%! title ("line, image, line, image, line")
+%! plot (g, 11.5 * ones (size (g)));
+%! axis ([0 10 0 22]);
+%! hold off;
+%! title ("line, image, line, image, line");
 
--- a/scripts/image/imagesc.m
+++ b/scripts/image/imagesc.m
@@ -25,7 +25,7 @@
 ## Display a scaled version of the matrix @var{A} as a color image.  The
 ## colormap is scaled so that the entries of the matrix occupy the entire
 ## colormap.  If @var{limits} = [@var{lo}, @var{hi}] are given, then that
-## range is set to the 'clim' of the current axes.
+## range is set to the "clim" of the current axes.
 ##
 ## The axis values corresponding to the matrix elements are specified in
 ## @var{x} and @var{y}, either as pairs giving the minimum and maximum
--- a/scripts/image/imread.m
+++ b/scripts/image/imread.m
@@ -89,6 +89,7 @@
 
 endfunction
 
+
 %!testif HAVE_MAGICK
 %! vpng = [ ...
 %!  137,  80,  78,  71,  13,  10,  26,  10,   0,   0, ...
@@ -107,11 +108,12 @@
 %!   16,  28, 160,  16,   0, 197, 214,  13,  34,  74, ...
 %!  117, 213,  17,   0,   0,   0,   0,  73,  69,  78, ...
 %!   68, 174,  66,  96, 130];
-%! fid = fopen('test.png', 'wb');
-%! fwrite(fid, vpng);
-%! fclose(fid);
-%! A = imread('test.png');
-%! delete('test.png');
-%! assert(A(:,:,1), uint8 ([0, 255, 0; 255, 237, 255; 0, 255, 0]));
-%! assert(A(:,:,2), uint8 ([0, 255, 0; 255,  28, 255; 0, 255, 0]));
-%! assert(A(:,:,3), uint8 ([0, 255, 0; 255,  36, 255; 0, 255, 0]));
+%! fid = fopen ("test.png", "wb");
+%! fwrite (fid, vpng);
+%! fclose (fid);
+%! A = imread ("test.png");
+%! delete ("test.png");
+%! assert (A(:,:,1), uint8 ([0, 255, 0; 255, 237, 255; 0, 255, 0]));
+%! assert (A(:,:,2), uint8 ([0, 255, 0; 255,  28, 255; 0, 255, 0]));
+%! assert (A(:,:,3), uint8 ([0, 255, 0; 255,  36, 255; 0, 255, 0]));
+
--- a/scripts/image/imshow.m
+++ b/scripts/image/imshow.m
@@ -41,6 +41,7 @@
 ##
 ## If given, the parameter @var{string_param1} has value
 ## @var{value1}.  @var{string_param1} can be any of the following:
+##
 ## @table @asis
 ## @item "displayrange"
 ## @var{value1} is the display range as described above.
@@ -176,35 +177,46 @@
 
 endfunction
 
-%!error imshow ()                           # no arguments
-%!error imshow ({"cell"})                   # No image or filename given
-%!error imshow (ones(4,4,4))                # Too many dimensions in image
+
+%!demo
+%! clf;
+%! imshow ("default.img");
 
 %!demo
-%!  imshow ("default.img");
+%! clf;
+%! imshow ("default.img");
+%! colormap (autumn (64));
 
 %!demo
-%!  imshow ("default.img");
-%!  colormap ("autumn");
+%! clf;
+%! [I, M] = imread ("default.img");
+%! imshow (I, M);
 
 %!demo
-%!  [I, M] = imread ("default.img");
-%!  imshow (I, M);
+%! clf;
+%! [I, M] = imread ("default.img");
+%! [R, G, B] = ind2rgb (I, M);
+%! imshow (cat (3, R, G*0.5, B*0.8));
 
 %!demo
-%!  [I, M] = imread ("default.img");
-%!  [R, G, B] = ind2rgb (I, M);
-%!  imshow (cat(3, R, G*0.5, B*0.8));
+%! clf;
+%! imshow (rand (100, 100));
 
 %!demo
-%!  imshow (rand (100, 100));
+%! clf;
+%! imshow (rand (100, 100, 3));
 
 %!demo
-%!  imshow (rand (100, 100, 3));
+%! clf;
+%! imshow (100*rand (100, 100, 3));
 
 %!demo
-%!  imshow (100*rand (100, 100, 3));
+%! clf;
+%! imshow (rand (100, 100));
+%! colormap (jet (64));
 
-%!demo
-%!  imshow (rand (100, 100));
-%!  colormap (jet);
+%% Test input validation
+%!error imshow ()
+%!error <IM must be an image> imshow ({"cell"})
+%!error <expecting MxN or MxNx3 matrix> imshow (ones (4,4,4))
+
--- a/scripts/image/imwrite.m
+++ b/scripts/image/imwrite.m
@@ -162,7 +162,7 @@
       error ("imwrite: %s: invalid class for indexed image data", img_class);
     endif
     if (isa (map, "double"))
-      if (ndims (map) != 2 || size (map, 2) != 3)
+      if (ndims (map) != 2 || columns (map) != 3)
         error ("imwrite: invalid size for colormap");
       endif
     else
@@ -187,14 +187,15 @@
 
 endfunction
 
+
 %% Test input validation
-%!error imwrite ()                           # Wrong # of args
-%!error imwrite (1)                          # Wrong # of args
-%!error imwrite ({"cell"}, "filename.jpg")   # Wrong class for img
-%!error imwrite (1, [], "filename.jpg")      # Empty image map
-%!error imwrite (1, 2, 3)                    # No filename specified
-%!error imwrite (1, "filename")              # No fmt specified
-%!error imwrite (1, "filename", "junk")      # Invalid fmt specified
-%!error imwrite ([], "filename.jpg")         # Empty img matrix
-%!error imwrite (spones(2), "filename.jpg")  # Invalid sparse img
+%!error imwrite ()                            # Wrong # of args
+%!error imwrite (1)                           # Wrong # of args
+%!error imwrite ({"cell"}, "filename.jpg")    # Wrong class for img
+%!error imwrite (1, [], "filename.jpg")       # Empty image map
+%!error imwrite (1, 2, 3)                     # No filename specified
+%!error imwrite (1, "filename")               # No fmt specified
+%!error imwrite (1, "filename", "junk")       # Invalid fmt specified
+%!error imwrite ([], "filename.jpg")          # Empty img matrix
+%!error imwrite (spones (2), "filename.jpg")  # Invalid sparse img
 
--- a/scripts/image/ind2gray.m
+++ b/scripts/image/ind2gray.m
@@ -17,11 +17,12 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {} ind2gray (@var{x}, @var{map})
-## Convert an Octave indexed image to a gray scale intensity image.
+## @deftypefn  {Function File} {} ind2gray (@var{x})
+## @deftypefnx {Function File} {} ind2gray (@var{x}, @var{map})
+## Convert a color indexed image to a gray scale intensity image.
 ## If @var{map} is omitted, the current colormap is used to determine the
 ## intensities.
-## @seealso{gray2ind, rgb2ntsc, image, colormap}
+## @seealso{gray2ind, ind2rgb}
 ## @end deftypefn
 
 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
--- a/scripts/image/ind2rgb.m
+++ b/scripts/image/ind2rgb.m
@@ -17,13 +17,14 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {@var{rgb} =} ind2rgb (@var{x}, @var{map})
-## @deftypefnx {Function File} {[@var{R}, @var{R}, @var{R}] =} ind2rgb (@var{x}, @var{map})
+## @deftypefn  {Function File} {@var{rgb} =} ind2rgb (@var{x})
+## @deftypefnx {Function File} {@var{rgb} =} ind2rgb (@var{x}, @var{map})
+## @deftypefnx {Function File} {[@var{R}, @var{G}, @var{B}] =} ind2rgb (@dots{})
 ## Convert an indexed image to red, green, and blue color components.
 ## If the colormap doesn't contain enough colors, pad it with the
 ## last color in the map.
 ## If @var{map} is omitted, the current colormap is used for the conversion.
-## @seealso{rgb2ind, image, imshow, ind2gray, gray2ind}
+## @seealso{rgb2ind, ind2gray, hsv2rgb, ntsc2rgb}
 ## @end deftypefn
 
 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
--- a/scripts/image/jet.m
+++ b/scripts/image/jet.m
@@ -28,6 +28,9 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
+## PKG_ADD: colormap ("register", "jet");
+## PKG_DEL: colormap ("unregister", "jet");
+
 function map = jet (n)
 
   if (nargin == 0)
@@ -41,25 +44,29 @@
   endif
 
   if (n == 1)
-    map = [0, 0, 0.5];
+    map = [0, 1, 1];
   elseif (n > 1)
-    x = linspace(0, 1, n)';
-    r = (x >= 3/8 & x < 5/8) .* (4 * x - 3/2)\
-      + (x >= 5/8 & x < 7/8) + (x >= 7/8) .* (-4 * x + 9/2);
-    g = (x >= 1/8 & x < 3/8) .* (4 * x - 1/2)\
-      + (x >= 3/8 & x < 5/8) + (x >= 5/8 & x < 7/8) .* (-4 * x + 7/2);
-    b = (x < 1/8) .* (4 * x + 1/2) + (x >= 1/8 & x < 3/8)\
+    x = linspace (0, 1, n)';
+    r = (x >= 3/8 & x < 5/8) .* (4 * x - 3/2) ...
+      + (x >= 5/8 & x < 7/8) ...
+      + (x >= 7/8) .* (-4 * x + 9/2);
+    g = (x >= 1/8 & x < 3/8) .* (4 * x - 1/2) ...
+      + (x >= 3/8 & x < 5/8) ...
+      + (x >= 5/8 & x < 7/8) .* (-4 * x + 7/2);
+    b = (x < 1/8) .* (4 * x + 1/2) ...
+      + (x >= 1/8 & x < 3/8) ...
       + (x >= 3/8 & x < 5/8) .* (-4 * x + 5/2);
     map = [r, g, b];
   else
-    map = [];
+    map = zeros (0, 3);
   endif
 
 endfunction
 
+
 %!demo
 %! ## Show the 'jet' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
-%! axis ([1, 64, 0, 1], "ticy", "xy")
-%! colormap (jet (64))
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (jet (64));
 
new file mode 100644
--- /dev/null
+++ b/scripts/image/lines.m
@@ -0,0 +1,63 @@
+## Copyright (C) 2012 Rik Wehbring
+##
+## 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{map} =} lines ()
+## @deftypefnx {Function File} {@var{map} =} lines (@var{n})
+## Create color colormap.  This colormap is composed of the list of colors
+## in the current axes "ColorOrder" property.  The default is blue,
+## green, red, cyan, pink, yellow, and gray.
+## The argument @var{n} must be a scalar.
+## If unspecified, the length of the current colormap, or 64, is used.
+## @seealso{colormap}
+## @end deftypefn
+
+## PKG_ADD: colormap ("register", "lines");
+## PKG_DEL: colormap ("unregister", "lines");
+
+function map = lines (n)
+
+  if (nargin == 0)
+    n = rows (colormap);
+  elseif (nargin == 1)
+    if (! isscalar (n))
+      error ("lines: argument must be a scalar");
+    endif
+  else
+    print_usage ();
+  endif
+
+  if (n == 1)
+    map = [0, 0, 1];
+  elseif (n > 1)
+    C = get (gca, "colororder");
+    nr = rows (C);
+    map = C(rem (0:(n-1), nr) + 1, :);
+  else
+    map = zeros (0, 3);
+  endif
+
+endfunction
+
+
+%!demo
+%! ## Show the 'lines' colormap as an image
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (lines (64));
+
--- a/scripts/image/module.mk
+++ b/scripts/image/module.mk
@@ -4,6 +4,7 @@
   image/autumn.m \
   image/bone.m \
   image/brighten.m \
+  image/colorcube.m \
   image/colormap.m \
   image/contrast.m \
   image/cool.m \
@@ -24,6 +25,7 @@
   image/ind2gray.m \
   image/ind2rgb.m \
   image/jet.m \
+  image/lines.m \
   image/ntsc2rgb.m \
   image/ocean.m \
   image/pink.m \
@@ -32,6 +34,8 @@
   image/rgb2hsv.m \
   image/rgb2ind.m \
   image/rgb2ntsc.m \
+  image/rgbplot.m \
+  image/spinmap.m \
   image/spring.m \
   image/summer.m \
   image/white.m \
--- a/scripts/image/ntsc2rgb.m
+++ b/scripts/image/ntsc2rgb.m
@@ -17,9 +17,11 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {} ntsc2rgb (@var{yiq})
-## Transform a colormap or image from NTSC to RGB.
-## @seealso{rgb2ntsc}
+## @deftypefn  {Function File} {@var{rgb_map} =} ntsc2rgb (@var{yiq_map})
+## @deftypefnx {Function File} {@var{rgb_img} =} ntsc2rgb (@var{yiq_img})
+## Transform a colormap or image from luminance-chrominance (NTSC) space to
+## red-green-blue (RGB) space.
+## @seealso{rgb2ntsc, hsv2rgb, ind2rgb}
 ## @end deftypefn
 
 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
--- a/scripts/image/ocean.m
+++ b/scripts/image/ocean.m
@@ -23,12 +23,16 @@
 ## of blue.
 ## The argument @var{n} must be a scalar.
 ## If unspecified, the length of the current colormap, or 64, is used.
+## @seealso{colormap}
 ## @end deftypefn
 
 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
 ## Created: July 1994
 ## Adapted-By: jwe
 
+## PKG_ADD: colormap ("register", "ocean");
+## PKG_DEL: colormap ("unregister", "ocean");
+
 function map = ocean (n)
 
   if (nargin == 0)
@@ -41,25 +45,30 @@
     print_usage ();
   endif
 
-  cutin = fix (n/3);
+  if (n == 1)
+    map = [0, 0, 0];
+  elseif (n > 1)
+    cutin = fix (n/3);
 
-  dr = (n - 1) / cutin;
-
-  r = prepad ([0:dr:(n-1)], n)';
+    dr = (n - 1) / cutin;
+    r = prepad ([0:dr:(n-1)], n)';
 
-  dg = (n - 1) / (2 * cutin);
+    dg = (n - 1) / (2 * cutin);
+    g = prepad ([0:dg:(n-1)], n)';
 
-  g = prepad([0:dg:(n-1)], n)';
+    b = [0:(n-1)]';
 
-  b = [0:(n-1)]';
-
-  map = [ r, g, b ] / (n - 1);
+    map = [r, g, b] / (n - 1);
+  else
+    map = zeros (0, 3);
+  endif
 
 endfunction
 
+
 %!demo
 %! ## Show the 'ocean' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
-%! axis ([1, 64, 0, 1], "ticy", "xy")
-%! colormap (ocean (64))
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (ocean (64));
 
--- a/scripts/image/pink.m
+++ b/scripts/image/pink.m
@@ -28,6 +28,9 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
+## PKG_ADD: colormap ("register", "pink");
+## PKG_DEL: colormap ("unregister", "pink");
+
 function map = pink (n)
 
   if (nargin == 0)
@@ -41,25 +44,27 @@
   endif
 
   if (n == 1)
-    map = [0, 0, 0];
+    map = sqrt ([1/3, 1/3, 1/3]);
   elseif (n > 1)
     x = linspace (0, 1, n)';
-    r = (x < 3/8) .* (14/9 * x) + (x >= 3/8) .* (2/3 * x + 1/3);
-    g = (x < 3/8) .* (2/3 * x)\
-      + (x >= 3/8 & x < 3/4) .* (14/9 * x - 1/3)\
+    r = (x < 3/8) .* (14/9 * x) ...
+      + (x >= 3/8) .* (2/3 * x + 1/3);
+    g = (x < 3/8) .* (2/3 * x) ...
+      + (x >= 3/8 & x < 3/4) .* (14/9 * x - 1/3) ...
       + (x >= 3/4) .* (2/3 * x + 1/3);
-    b = (x < 3/4) .* (2/3 * x) + (x >= 3/4) .* (2 * x - 1);
-
+    b = (x < 3/4) .* (2/3 * x) ...
+      + (x >= 3/4) .* (2 * x - 1);
     map = sqrt ([r, g, b]);
   else
-    map = [];
+    map = zeros (0, 3);
   endif
 
 endfunction
 
+
 %!demo
 %! ## Show the 'pink' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
-%! axis ([1, 64, 0, 1], "ticy", "xy")
-%! colormap (pink (64))
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (pink (64));
 
--- a/scripts/image/prism.m
+++ b/scripts/image/prism.m
@@ -28,6 +28,9 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
+## PKG_ADD: colormap ("register", "prism");
+## PKG_DEL: colormap ("unregister", "prism");
+
 function map = prism (n)
 
   if (nargin == 0)
@@ -40,19 +43,21 @@
     print_usage ();
   endif
 
-  p = [1, 0, 0; 1, 1/2, 0; 1, 1, 0; 0, 1, 0; 0, 0, 1; 2/3, 0, 1];
-
-  if (rem (n, 6) == 0)
-    map = kron(ones (fix (n / 6), 1), p);
+  if (n == 1)
+    map = [1 0 0];
+  elseif (n > 1)
+    C = [1, 0, 0; 1, 1/2, 0; 1, 1, 0; 0, 1, 0; 0, 0, 1; 2/3, 0, 1];
+    map = C(rem (0:(n-1), 6) + 1, :);
   else
-    map = [kron(ones (fix (n / 6), 1), p); p(1:rem (n, 6), :)];
+    map = zeros (0, 3);
   endif
 
 endfunction
 
+
 %!demo
 %! ## Show the 'prism' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
-%! axis ([1, 64, 0, 1], "ticy", "xy")
-%! colormap (prism (64))
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (prism (64));
 
--- a/scripts/image/rainbow.m
+++ b/scripts/image/rainbow.m
@@ -31,6 +31,9 @@
 ## this colormap is not part of matlab, it is like the prism
 ## colormap map but with a continuous map
 
+## PKG_ADD: colormap ("register", "rainbow");
+## PKG_DEL: colormap ("unregister", "rainbow");
+
 function map = rainbow (n)
 
   if (nargin == 0)
@@ -47,21 +50,28 @@
     map = [1, 0, 0];
   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);
-    g = (x < 2/5) .* (5/2 * x) + (x >= 2/5 & x < 3/5)\
-      + (x >= 3/5 & x < 4/5) .* (-5 * x + 4);
+
+    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));
+
     b = (x >= 3/5 & x < 4/5) .* (5 * x - 3) + (x >= 4/5);
+
     map = [r, g, b];
   else
-    map = [];
+    map = zeros (0, 3);
   endif
 
 endfunction
 
+
 %!demo
 %! ## Show the 'rainbow' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
-%! axis ([1, 64, 0, 1], "ticy", "xy")
-%! colormap (rainbow (64))
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (rainbow (64));
 
--- a/scripts/image/rgb2hsv.m
+++ b/scripts/image/rgb2hsv.m
@@ -17,16 +17,18 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {@var{hsv_map} =} rgb2hsv (@var{rgb})
-## Transform a colormap or image from the RGB space to the HSV space.
-##
-## A color in the RGB space consists of the red, green and blue intensities.
+## @deftypefn  {Function File} {@var{hsv_map} =} rgb2hsv (@var{rgb})
+## @deftypefnx {Function File} {@var{hsv_map} =} rgb2hsv (@var{rgb})
+## Transform a colormap or image from red-green-blue (RGB) space to
+## hue-saturation-value (HSV) space.
 ##
-## In the HSV space each color is represented by their hue, saturation
-## and value (brightness).  Value gives the amount of light in the color.
-## Hue describes the dominant wavelength.
-## Saturation is the amount of hue mixed into the color.
-## @seealso{hsv2rgb}
+## A color in the RGB space consists of red, green, and blue intensities.
+##
+## A color in HSV space is represented by hue, saturation and value
+## (brightness) levels.  Value gives the amount of light in the color.  Hue
+## describes the dominant wavelength.  Saturation is the amount of hue mixed
+## into the color.
+## @seealso{hsv2rgb, rgb2ind, rgb2ntsc}
 ## @end deftypefn
 
 ## Author: Kai Habel <kai.habel@gmx.de>
--- a/scripts/image/rgb2ind.m
+++ b/scripts/image/rgb2ind.m
@@ -19,8 +19,8 @@
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {[@var{x}, @var{map}] =} rgb2ind (@var{rgb})
 ## @deftypefnx {Function File} {[@var{x}, @var{map}] =} rgb2ind (@var{R}, @var{G}, @var{B})
-## Convert an RGB image to an Octave indexed image.
-## @seealso{ind2rgb, rgb2ntsc}
+## Convert an image in red-green-blue (RGB) space to an indexed image.
+## @seealso{ind2rgb, rgb2hsv, rgb2ntsc}
 ## @end deftypefn
 
 ## Bugs: The color map may have duplicate entries.
--- a/scripts/image/rgb2ntsc.m
+++ b/scripts/image/rgb2ntsc.m
@@ -17,9 +17,11 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {} rgb2ntsc (@var{rgb})
-## Transform a colormap or image from RGB to NTSC.
-## @seealso{ntsc2rgb}
+## @deftypefn  {Function File} {@var{yiq_map} =} rgb2ntsc (@var{rgb_map})
+## @deftypefnx {Function File} {@var{yiq_img} =} rgb2ntsc (@var{rgb_img})
+## Transform a colormap or image from red-green-blue (RGB) space to
+## luminance-chrominance (NTSC) space.
+## @seealso{ntsc2rgb, rgb2hsv, rgb2ind}
 ## @end deftypefn
 
 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
new file mode 100644
--- /dev/null
+++ b/scripts/image/rgbplot.m
@@ -0,0 +1,60 @@
+## Copyright (C) 2012 Rik Wehbring
+##
+## 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} {} rgbplot (@var{cmap})
+## Plot the components of a colormap.
+##
+## The first column is plotted in red, the second column in green, and
+## the third column in blue.  The values are between 0 and 1 and represent
+## the intensity of the RGB components in the given indexed color.
+## @seealso{colormap}
+## @end deftypefn
+
+function rgbplot (cmap)
+
+  if (nargin != 1)
+    print_usage ();
+  endif
+
+  if (! ismatrix (cmap) || ndims (cmap) != 2 || columns (cmap) != 3)
+    error ("rgbplot: CMAP must be a matrix of size Nx3");
+  elseif (any (cmap(:) < 0) || any (cmap(:) > 1))
+    error ("rgbplot: CMAP intensities must be in the range [0, 1]");
+  endif
+
+  plot (cmap(:,1),"r", cmap(:,2),"g", cmap(:,3),"b");
+  set (gca, 'ytick', 0:0.1:1);
+  xlabel ("color index");
+
+endfunction
+
+
+%!demo
+%! clf;
+%! rgbplot (ocean);
+
+%%test input validation
+%!error rgbplot ()
+%!error rgbplot (1,2)
+%!error <CMAP must be a matrix of size Nx3> rgbplot ({0 1 0})
+%!error <CMAP must be a matrix of size Nx3> rgbplot (ones (3,3,3))
+%!error <CMAP must be a matrix of size Nx3> rgbplot (ones (3,4))
+%!error <CMAP intensities must be in the range> rgbplot ([0 0 -2])
+%!error <CMAP intensities must be in the range> rgbplot ([0 0 2])
+
rename from scripts/plot/spinmap.m
rename to scripts/image/spinmap.m
--- a/scripts/plot/spinmap.m
+++ b/scripts/image/spinmap.m
@@ -17,41 +17,56 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {} spinmap (@var{t}, @var{inc})
-## Cycle the colormap for @var{t} seconds with an increment
-## of @var{inc}.  Both parameters are optional.  The default cycle time
-## is 5 seconds and the default increment is 2.
+## @deftypefn  {Function File} {} spinmap ()
+## @deftypefnx {Function File} {} spinmap (@var{t})
+## @deftypefnx {Function File} {} spinmap (@var{t}, @var{inc})
+## @deftypefnx {Function File} {} spinmap ("inf")
+## Cycle the colormap for @var{t} seconds with a color increment of @var{inc}.
+## Both parameters are optional.  The default cycle time is 5 seconds and the
+## default increment is 2.  If the option "inf" is given then cycle
+## continuously until @kbd{Control-C} is pressed.
 ##
-## A higher value of @var{inc} causes a faster cycle through the
-## colormap.
-## @seealso{gca, colorbar}
+## When rotating the original color 1 becomes color 2, color 2 becomes
+## color 3, etc.  A positive or negative increment is allowed and a higher
+## value of @var{inc} will cause faster cycling through the colormap.
+## @seealso{colormap}
 ## @end deftypefn
 
 ## Author: Kai Habel <kai.habel at gmx.de>
 
-function spinmap (t, inc)
+function spinmap (t = 5, inc = 2)
 
-  if (nargin == 0)
-    inc = 2;
-    t = 5;
-  elseif (nargin == 1)
-    inc = 2;
+  if (nargin > 2)
+    print_usage ();
+  elseif (ischar (t))
+    if (strcmpi (t, "inf")) 
+      t = Inf;
+    else
+      error ('spinmap: time T must be a real scalar or "inf"');
+    endif
+  elseif (! isscalar (t) || ! isreal (t))
+    error ("spinmap: time T must be a real scalar");
   endif
 
-  cmap = get (gcf (), "colormap");
-  clen = rows (cmap);
+  cmap = cmap_orig = get (gcf (), "colormap");
 
   t0 = clock;
-
   while (etime (clock, t0) < t)
-    for n = 1:inc:clen
-      newmap = shift (cmap, n, 1);
-      set (gcf (), "colormap", newmap);
-      drawnow ();
-    endfor
+    cmap = shift (cmap, inc, 1);
+    set (gcf (), "colormap", cmap);
+    drawnow ();
   endwhile
 
-  set (gcf (), "colormap", cmap);
+  set (gcf (), "colormap", cmap_orig);
 
 endfunction
 
+
+%!demo
+%! clf;
+%! colormap (rainbow (128));
+%! imagesc (1:8);
+%! axis off;
+%! title ("Rotate color bars to the right");
+%! spinmap (3, 1);
+
--- a/scripts/image/spring.m
+++ b/scripts/image/spring.m
@@ -27,6 +27,9 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
+## PKG_ADD: colormap ("register", "spring");
+## PKG_DEL: colormap ("unregister", "spring");
+
 function map = spring (n)
 
   if (nargin == 0)
@@ -43,18 +46,19 @@
     map = [1, 0, 1];
   elseif (n > 1)
     r = ones (n, 1);
-    g = (0:n - 1)' ./ (n - 1);
+    g = [0:(n-1)]' / (n - 1);
     b = 1 - g;
     map = [r, g, b];
   else
-    map = [];
+    map = zeros (0, 3);
   endif
 
 endfunction
 
+
 %!demo
 %! ## Show the 'spring' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
-%! axis ([1, 64, 0, 1], "ticy", "xy")
-%! colormap (spring (64))
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (spring (64));
 
--- a/scripts/image/summer.m
+++ b/scripts/image/summer.m
@@ -27,6 +27,10 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 ## Date:  06/03/2000
+
+## PKG_ADD: colormap ("register", "summer");
+## PKG_DEL: colormap ("unregister", "summer");
+
 function map = summer (n)
 
   if (nargin == 0)
@@ -42,20 +46,20 @@
   if (n == 1)
     map = [0, 0.5, 0.4];
   elseif (n > 1)
-    r = (0:n - 1)' ./ (n - 1);
-    g = 0.5 + r ./ 2;
+    r = [0:(n-1)]' / (n - 1);
+    g = 0.5 + r / 2;
     b = 0.4 * ones (n, 1);
-
     map = [r, g, b];
   else
-    map = [];
+    map = zeros (0, 3);
   endif
 
 endfunction
 
+
 %!demo
 %! ## Show the 'summer' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
-%! axis ([1, 64, 0, 1], "ticy", "xy")
-%! colormap (summer (64))
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (summer (64));
 
--- a/scripts/image/white.m
+++ b/scripts/image/white.m
@@ -27,6 +27,9 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
+## PKG_ADD: colormap ("register", "white");
+## PKG_DEL: colormap ("unregister", "white");
+
 function map = white (n)
 
   if (nargin == 0)
@@ -39,17 +42,14 @@
     print_usage ();
   endif
 
-  if (n > 0)
-    map = ones (n, 3);
-  else
-    map = [];
-  endif
+  map = ones (n, 3);
 
 endfunction
 
+
 %!demo
 %! ## Show the 'white' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
-%! axis ([1, 64, 0, 1], "ticy", "xy")
-%! colormap (white (64))
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (white (64));
 
--- a/scripts/image/winter.m
+++ b/scripts/image/winter.m
@@ -27,6 +27,9 @@
 
 ## Author:  Kai Habel <kai.habel@gmx.de>
 
+## PKG_ADD: colormap ("register", "winter");
+## PKG_DEL: colormap ("unregister", "winter");
+
 function map = winter (n)
 
   if (nargin == 0)
@@ -43,19 +46,19 @@
     map = [0, 0, 1];
   elseif (n > 1)
     r = zeros (n, 1);
-    g = (0:n - 1)' ./ (n - 1);
-    b = 1 - g ./ 2;
-
+    g = [0:(n-1)]' / (n - 1);
+    b = 1 - g / 2;
     map = [r, g, b];
   else
-    map = [];
+    map = zeros (0, 3);
   endif
 
 endfunction
 
+
 %!demo
 %! ## Show the 'winter' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)')
-%! axis ([1, 64, 0, 1], "ticy", "xy")
-%! colormap (winter (64))
+%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
+%! axis ([1, 64, 0, 1], "ticy", "xy");
+%! colormap (winter (64));
 
--- a/scripts/io/dlmwrite.m
+++ b/scripts/io/dlmwrite.m
@@ -146,7 +146,7 @@
       elseif (i == 3)
         c = varargin{i};
       else
-        print_usage();
+        print_usage ();
       endif
     endif
   endwhile
@@ -180,7 +180,7 @@
     endif
     if (iscomplex (M))
       M = M.';
-      b = zeros (2*rows(M), columns (M));
+      b = zeros (2*rows (M), columns (M));
       b(1: 2 : end, :) = real (M);
       b(2: 2 : end, :) = imag (M);
       fprintf (fid, template, b);
@@ -197,13 +197,13 @@
 
 %!test
 %! f = tmpnam ();
-%! dlmwrite (f,[1,2;3,4],'precision','%5.2f','newline','unix','roffset',1,'coffset',1);
+%! dlmwrite (f,[1,2;3,4],"precision","%5.2f","newline","unix","roffset",1,"coffset",1);
 %! fid = fopen (f,"rt");
-%! f1 = char (fread (fid,Inf,'char')');
+%! f1 = char (fread (fid,Inf,"char")');
 %! fclose (fid);
-%! dlmwrite (f,[5,6],'precision','%5.2f','newline','unix','coffset',1,'delimiter',',','-append');
+%! dlmwrite (f,[5,6],"precision","%5.2f","newline","unix","coffset",1,"delimiter",",","-append");
 %! fid = fopen (f,"rt");
-%! f2 = char (fread (fid,Inf,'char')');
+%! f2 = char (fread (fid,Inf,"char")');
 %! fclose (fid);
 %! unlink (f);
 %!
--- a/scripts/io/fileread.m
+++ b/scripts/io/fileread.m
@@ -38,7 +38,7 @@
   endif
 
   unwind_protect
-    str = fread (fid, "*char");
+    str = (fread (fid, "*char")).';
   unwind_protect_cleanup
     fclose (fid);
   end_unwind_protect
@@ -50,10 +50,10 @@
 %! cstr = {"Hello World", "The answer is 42", "Goodbye World"};
 %! fname = tmpnam ();
 %! fid = fopen (fname, "w");
-%! fprintf (fid, "%s\n", cstr{:})
+%! fprintf (fid, "%s\n", cstr{:});
 %! fclose (fid);
 %! str = fileread (fname);
-%! assert (str', [cstr{1} "\n" cstr{2} "\n" cstr{3} "\n"]);
+%! assert (str, [cstr{1} "\n" cstr{2} "\n" cstr{3} "\n"]);
 %! unlink (fname);
 
 %% Test input validation
--- a/scripts/io/is_valid_file_id.m
+++ b/scripts/io/is_valid_file_id.m
@@ -39,8 +39,10 @@
 
 endfunction
 
+
 %!assert (is_valid_file_id (stdout))
 %!assert (! is_valid_file_id ([1,2;3,4]))
 %!assert (! is_valid_file_id ("not_a_file_id"))
 %!assert (! is_valid_file_id (-1))
 %!assert (! is_valid_file_id (pi))
+
--- a/scripts/io/strread.m
+++ b/scripts/io/strread.m
@@ -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.
 ##
@@ -102,6 +102,7 @@
 ## @item "commentstyle"
 ## Parts of @var{str} are considered comments and will be skipped.
 ## @var{value} is the comment style and can be any of the following.
+##
 ## @itemize
 ## @item "shell"
 ## Everything from @code{#} characters to the nearest end-of-line is skipped.
@@ -153,6 +154,20 @@
 ##
 ## @end table
 ##
+## When the number of words in @var{str} doesn't match an exact multiple
+## of the number of format conversion specifiers, strread's behavior
+## depends on the last character of @var{str}:
+##
+## @table @asis
+## @item last character = "\n"
+## Data columns are padded with empty fields or Nan so that all columns
+## have equal length 
+##
+## @item last character is not "\n"
+## Data columns are not padded; strread returns columns of unequal length
+##
+## @end table
+##
 ## @seealso{textscan, textread, load, dlmread, fscanf}
 ## @end deftypefn
 
@@ -162,6 +177,12 @@
   if (nargin < 1)
     print_usage ();
   endif
+  
+  if (isempty (str))
+    ## Return empty args (no match), rather than raising an error
+    varargout = cell (1, nargout);
+    return;
+  endif
 
   if (isempty (format))
     format = "%f";
@@ -205,7 +226,7 @@
     switch (lower (varargin{n}))
       case "bufsize"
         ## We could synthesize this, but that just seems weird...
-        warning ('strread: property "bufsize" is not implemented');
+        warning ("strread: property 'bufsize' is not implemented");
       case "commentstyle"
         comment_flag = true;
         switch (lower (varargin{n+1}))
@@ -238,7 +259,7 @@
       case "emptyvalue"
         numeric_fill_value = varargin{n+1};
       case "expchars"
-        warning ('strread: property "expchars" is not implemented');
+        warning ("strread: property 'expchars' is not implemented");
       case "whitespace"
         white_spaces = varargin{n+1};
         if (strcmp (typeinfo (white_spaces), "sq_string"))
@@ -260,10 +281,10 @@
         elseif (ischar (varargin{n+1}))
           empty_str = varargin(n+1);
         else
-          error ('strread: "treatasempty" value must be string or cellstr');
+          error ("strread: 'treatasempty' value must be string or cellstr");
         endif
       otherwise
-        warning ('strread: unknown property "%s"', varargin{n});
+        warning ("strread: unknown property '%s'", varargin{n});
     endswitch
   endfor
 
@@ -276,16 +297,26 @@
     ## Determine the number of words per line as a first guess.  Forms
     ## like %f<literal>) (w/o delimiter in between) are fixed further on
     format = strrep (format, "%", " %");
-    fmt_words = regexp (format, '[^ ]+', 'match');
+    fmt_words = regexp (format, '[^ ]+', "match");
+    
+    ## Find position of conversion specifiers (they start with %)
+    idy2 = find (! cellfun ("isempty", regexp (fmt_words, '^%')));
+
+    ## Check for unsupported format specifiers
+    errpat = '(\[.*\]|[cq]|[nfdu]8|[nfdu]16|[nfdu]32|[nfdu]64)';
+    if (! all (cellfun ("isempty", regexp (fmt_words(idy2), errpat))))
+      error ("strread: %q, %c, %[] or bit width format specifiers are not supported yet.");
+    endif
+
     ## Format conversion specifiers following literals w/o space/delim
     ## in between are separate now.  Separate those w trailing literals
-    idy2 = find (! cellfun ("isempty", strfind (fmt_words, "%")));
     a = strfind (fmt_words(idy2), "%");
-    b = regexp (fmt_words(idy2), '[nfdus]', 'end');
+    b = regexp (fmt_words(idy2), '[nfdus]', "end");
     for jj = 1:numel (a)
+      ## From right to left to avoid losing track
       ii = numel (a) - jj + 1;
       if (! (length (fmt_words{idy2(ii)}) == b{ii}(1)))
-        ## Fix format_words
+        ## Split fmt_words(ii) into % conv specifier and trailing literal
         fmt_words(idy2(ii)+1 : end+1) = fmt_words(idy2(ii) : end);
         fmt_words{idy2(ii)} = fmt_words{idy2(ii)}(a{ii} : b{ii}(1));
         fmt_words{idy2(ii)+1} = fmt_words{idy2(ii)+1}(b{ii}+1:end);
@@ -305,7 +336,7 @@
   ## Remove comments in str
   if (comment_flag)
     ## Expand 'eol_char' here, after option processing which may have set value
-    comment_end = regexprep (comment_end, 'eol_char', eol_char);
+    comment_end = regexprep (comment_end, "eol_char", eol_char);
     cstart = strfind (str, comment_start);
     cstop  = strfind (str, comment_end);
     ## Treat end of string as additional comment stop
@@ -335,7 +366,8 @@
   endif
 
   if (! isempty (white_spaces))
-    ## For numeric fields, whitespace is always a delimiter, but not for text fields
+    ## For numeric fields, whitespace is always a delimiter, but not for text
+    ## fields
     if (isempty (strfind (format, "%s")))
       ## Add whitespace to delimiter set
       delimiter_str = unique ([white_spaces delimiter_str]);
@@ -371,16 +403,15 @@
        str = str(2:end);
     endif
     ## Check for single delimiter followed/preceded by whitespace
-    ## FIXME: Double strrep on str is enormously expensive of CPU time.
-    ## Can this be eliminated
     if (! isempty (delimiter_str))
       dlmstr = setdiff (delimiter_str, " ");
       rxp_dlmwsp = sprintf ("( [%s]|[%s] )", dlmstr, dlmstr);
       str = regexprep (str, rxp_dlmwsp, delimiter_str(1));
     endif
+    ## Wipe leading and trailing whitespace on each line (it may be
+    ## delimiter too)
     ## FIXME: Double strrep on str is enormously expensive of CPU time.
     ## Can this be eliminated
-    ## Wipe leading and trailing whitespace on each line (it may be delimiter too)
     if (! isempty (eol_char))
       str = strrep (str, [eol_char " "], eol_char);
       str = strrep (str, [" " eol_char], eol_char);
@@ -390,27 +421,25 @@
   ## Split 'str' into words
   words = split_by (str, delimiter_str, mult_dlms_s1, eol_char);
   if (! isempty (white_spaces))
-    ## Trim leading and trailing white_spaces
-    ## FIXME: Is this correct?  strtrim clears what matches isspace(), not
-    ## necessarily what is in white_spaces.
+    ## Trim leading and trailing 'white_spaces'. All whitespace has
+    ## been converted to space above
     words = strtrim (words);
   endif
   num_words = numel (words);
-  ## First guess at number of lines in file (ignoring leading/trailing literals)
+  ## First guess at nr. of lines in file (ignoring leading/trailing literals)
   num_lines = ceil (num_words / num_words_per_line);
 
   ## Replace TreatAsEmpty char sequences by empty strings
   if (! isempty (empty_str))
     for ii = 1:numel (empty_str)
-      idz = strmatch (empty_str{ii}, words, "exact");
+      idz = strncmp (empty_str{ii}, words, length (empty_str{ii}));
       words(idz) = {""};
     endfor
   endif
 
   ## fmt_words has been split properly now, but words{} has only been split on
-  ## delimiter positions. 
-  ## As numeric fields can also be separated by whitespace, more splits may be
-  ## needed.
+  ## delimiter positions. As numeric fields can also be separated by
+  ## whitespace, more splits may be needed.
   ## We also don't know the number of lines (as EndOfLine may have been set to
   ## "" (empty) by the caller).
   ##
@@ -419,6 +448,8 @@
   ## B: Leading literals (<literal>%f) w/o delimiter in between.
   ## C. Skipping leftover parts of specified skip fields (%*N )
   ## Some words columns may have to be split further to fix these.
+  ## To find out, we'll match fmt_words to the words array to see what
+  ## needs to be done. fwptr tracks which {fmt_words}# starts in what {words}#
 
   ## Find indices and pointers to possible literals in fmt_words
   idf = cellfun ("isempty", strfind (fmt_words, "%"));
@@ -426,7 +457,7 @@
   idg = ! cellfun ("isempty", regexp (fmt_words, '%\*?\d'));
   idy = find (idf | idg);
   ## Find indices to numeric conversion specifiers
-  idn = ! cellfun ("isempty", regexp (fmt_words, "%[dnfu]"));
+  idn = ! cellfun ("isempty", regexp (fmt_words, '%[dnfu]'));
 
   ## If needed, split up columns in three steps:
   if (! isempty (idy))
@@ -436,11 +467,16 @@
       ## 1. Assess "period" in the split-up words array ( < num_words_per_line).
       ## Could be done using EndOfLine but that prohibits EndOfLine = "" option.
       ## Alternative below goes by simply parsing a first grab of words
-      ## and counting words until the fmt_words array is exhausted:
-      iwrd = 1; iwrdp = 0; iwrdl = length (words{iwrd});
-      for ii = 1:numel (fmt_words)
+      ## and matching fmt_words to words until the fmt_words array is exhausted.
+      ## iwrd: ptr to current analyzed word; iwrdp: ptr to pos before analyzed char
+      iwrd = 1; iwrdp = 0; iwrdl = length (words{1});
+      fwptr = zeros (1, numel (fmt_words));
+      ii = 1;
+      while ii <= numel (fmt_words)
 
         nxt_wrd = 0;
+        ## Keep track of which words nr. every fmt_words{} is (starts) in.
+        fwptr(ii) = iwrd;
 
         if (idf(ii))
           ## Literal expected
@@ -464,8 +500,9 @@
 
         elseif (idg(ii))
           ## Fixed width specifier (%N or %*N): read just a part of word
-          iwrdp += floor ...
-           (str2double (fmt_words{ii}(regexp(fmt_words{ii}, '\d') : end-1)));
+          sw = regexp (fmt_words{ii}, '\d', "once");
+          ew = regexp (fmt_words{ii}, '[nfuds]') - 1;
+          iwrdp += floor (str2double (fmt_words{ii}(sw:ew)));
           if (iwrdp > iwrdl)
             ## Match error. Field extends beyond word boundary.
             warning  ...
@@ -500,30 +537,34 @@
 
         if (nxt_wrd)
           ++iwrd; iwrdp = 0;
-          if (ii < numel (fmt_words))
+          if (iwrd > numel (words))
+            ## Apparently EOF; assume incomplete row already at L.1 of data
+            ii = numel (fmt_words);
+          elseif (ii < numel (fmt_words) && iwrd <= numel (words))
             iwrdl = length (words{iwrd});
           endif
         endif
 
-      endfor
+        ++ii;
+
+      endwhile
       ## Done
       words_period = max (iwrd - 1, 1);
       num_lines = ceil (num_words / words_period);
 
       ## 2. Pad words array so that it can be reshaped
-      tmp_lines = ceil (num_words / words_period);
-      num_words_padded = tmp_lines * words_period - num_words;
+      num_words_padded = num_lines * words_period - num_words;
       if (num_words_padded)
         words = [words'; cell(num_words_padded, 1)];
       endif
-      words = reshape (words, words_period, tmp_lines);
+      words = reshape (words, words_period, num_lines);
 
       ## 3. Do the column splitting on rectangular words array
       icol = 1; ii = 1;    # icol = current column, ii = current fmt_word
       while (ii <= num_words_per_line)
 
         ## Check if fmt_words(ii) contains a literal or fixed-width
-        if ((idf(ii) || idg(ii)) && (rows(words) < num_words_per_line))
+        if ((idf(ii) || idg(ii)) && (rows (words) < num_words_per_line))
           if (idf(ii))
             s = strfind (words(icol, 1), fmt_words{ii});
             if (isempty (s{:}))
@@ -542,13 +583,14 @@
             if (! idg(ii) && ! isempty (s) && s(1) == 1)
               ## Leading literal.  Assign literal to icol, paste rest in icol + 1
               ## Apply only to those cells that do have something beyond literal
-              jptr = find (cellfun("length", words(icol+1, jptr), ...
-                            "UniformOutput", false) > e(1));
+              jptr = find (cellfun ("length", words(icol+1, jptr), ...
+                                    "UniformOutput", false) > e(1));
               words(icol+1, :) = {""};
               words(icol+1, jptr) = cellfun ...
-                (@(x) substr(x, e(1)+1, length(x)-e(1)), words(icol, jptr), ...
+                (@(x) substr (x, e(1)+1, length (x) - e(1)), words(icol, jptr), ...
                 "UniformOutput", false);
               words(icol, jptr) = fmt_words{ii};
+              fwptr = [fwptr(1:ii) (++fwptr(ii+1:end))];
 
             else
               if (! idg(ii) && ! isempty (strfind (fmt_words{ii-1}, "%s")))
@@ -556,27 +598,36 @@
                 warning ("Ambiguous '%s' specifier next to literal in column %d", icol);
               elseif (idg(ii))
                 ## Current field = fixed width. Strip into icol, rest in icol+1
-                wdth = floor (str2double (fmt_words{ii}(regexp(fmt_words{ii}, ...
-                              '\d') : end-1)));
+                sw = regexp (fmt_words{ii}, '\d', "once");
+                ew = regexp (fmt_words{ii}, '[nfuds]') - 1;
+                wdth = floor (str2double (fmt_words{ii}(sw:ew)));
                 words(icol+1, jptr) = cellfun (@(x) x(wdth+1:end),
                      words(icol,jptr), "UniformOutput", false);
-                words(icol, jptr) = strtrunc (words(icol, jptr), wdth);
+                if (isempty ([words(icol+1, :){:}]))
+                  ## Apparently split wasn't needed as turns out to cover
+                  ## entire column. So delete column again
+                  words(icol+1, :) = [];
+                else
+                  words(icol, jptr) = strtrunc (words(icol, jptr), wdth);
+                  fwptr = [fwptr(1:ii) (++fwptr(ii+1:end))];
+                endif
               else
                 ## FIXME: this assumes char(254)/char(255) won't occur in input!
                 clear wrds;
                 wrds(1:2:2*numel (words(icol, jptr))) = ...
                      strrep (words(icol, jptr), fmt_words{ii}, ...
                      [char(255) char(254)]);
-                wrds(2:2:2*numel (words(icol, jptr))-1) = char(255);
-                wrds = strsplit ([wrds{:}], char(255));
+                wrds(2:2:2*numel (words(icol, jptr))-1) = char (255);
+                wrds = strsplit ([wrds{:}], char (255));
                 words(icol, jptr) = ...
-                  wrds(find (cellfun ("isempty", strfind (wrds, char(254)))));
-                wrds(find (cellfun ("isempty", strfind (wrds, char(254))))) ...
-                   = char(255);
+                  wrds(find (cellfun ("isempty", strfind (wrds, char (254)))));
+                wrds(find (cellfun ("isempty", strfind (wrds, char (254))))) ...
+                   = char (255);
                 words(icol+1, jptr) = strsplit (strrep ([wrds{2:end}], ...
-                   char(254), fmt_words{ii}), char(255));
+                   char (254), fmt_words{ii}), char (255));
                 ## Former trailing literal may now be leading for next specifier
                 --ii;
+                fwptr = [fwptr(1:ii) (++fwptr(ii+1:end))];
               endif
             endif
           endif
@@ -584,9 +635,7 @@
         else
           ## Conv. specifier.  Peek if next fmt_word needs split from current column
           if (ii < num_words_per_line)
-            if (idf(ii+1) && (! isempty (strfind (words{icol, 1}, fmt_words{ii+1}))))
-              --icol;
-            elseif (idg(ii+1))
+            if (fwptr(ii) == fwptr(ii+1))
               --icol;
             endif
           endif
@@ -645,10 +694,12 @@
           varargout{k} = data.';
           k++;
         case {"%0", "%1", "%2", "%3", "%4", "%5", "%6", "%7", "%8", "%9"}
-          nfmt = strsplit (fmt_words{m}(2:end-1), '.');
+          sw = regexp (fmt_words{m}, '\d', "once");
+          ew = regexp (fmt_words{m}, '[nfudsq]') - 1;
+          nfmt = strsplit (fmt_words{m}(2:ew), ".");
           swidth = str2double (nfmt{1});
-          switch fmt_words{m}(end)
-            case {"d", "u", "f", "n%"}
+          switch fmt_words{m}(ew+1)
+            case {"d", "u", "f", "n"}
               n = cellfun ("isempty", data);
               ### FIXME - erroneously formatted data lead to NaN, not an error
               ###         => ReturnOnError can't be implemented for numeric data
@@ -711,7 +762,7 @@
     ## to avoid it being included in consecutive delim series
     enchr = ' ';
     ## However watch out if eol_char is also in delimiters
-    if (index (sep, eol_char)); enchr = char(255); endif
+    if (index (sep, eol_char)); enchr = char (255); endif
     text = strrep (text, eol_char, [enchr eol_char enchr]);
   else
     mult_dlms_s1 = false;
@@ -719,7 +770,7 @@
 
   ## Split text string along delimiters
   out = strsplit (text, sep, mult_dlms_s1);
-  if (index (sep, eol_char)); out = strrep (out, char(255), ''); endif
+  if (index (sep, eol_char)); out = strrep (out, char (255), ''); endif
   ## In case of trailing delimiter, strip stray last empty word
   if (!isempty (out) && any (sep == text(end)))
     out(end) = [];
@@ -737,34 +788,34 @@
 %! assert (b, 2);
 
 %!test
-%! str = '';
+%! str = "";
 %! a = rand (10, 1);
 %! b = char (randi ([65, 85], 10, 1));
 %! for k = 1:10
-%!   str = sprintf ('%s %.6f %s\n', str, a(k), b(k));
+%!   str = sprintf ("%s %.6f %s\n", str, a(k), b(k));
 %! endfor
-%! [aa, bb] = strread (str, '%f %s');
+%! [aa, bb] = strread (str, "%f %s");
 %! assert (a, aa, 1e-6);
 %! assert (cellstr (b), bb);
 
 %!test
-%! str = '';
+%! str = "";
 %! a = rand (10, 1);
 %! b = char (randi ([65, 85], 10, 1));
 %! for k = 1:10
-%!   str = sprintf ('%s %.6f %s\n', str, a(k), b(k));
+%!   str = sprintf ("%s %.6f %s\n", str, a(k), b(k));
 %! endfor
-%! aa = strread (str, '%f %*s');
+%! aa = strread (str, "%f %*s");
 %! assert (a, aa, 1e-6);
 
 %!test
-%! str = sprintf ('/* this is\nacomment*/ 1 2 3');
-%! a = strread (str, '%f', 'commentstyle', 'c');
+%! str = sprintf ("/* this is\nacomment*/ 1 2 3");
+%! a = strread (str, "%f", "commentstyle", "c");
 %! assert (a, [1; 2; 3]);
 
 %!test
 %! str = "# comment\n# comment\n1 2 3";
-%! [a, b] = strread (str, '%n %s', 'commentstyle', 'shell', 'endofline', "\n");
+%! [a, b] = strread (str, "%n %s", "commentstyle", "shell", "endofline", "\n");
 %! assert (a, [1; 3]);
 %! assert (b, {"2"});
 
@@ -783,9 +834,9 @@
 %!test
 %! # Bug #33536
 %! [a, b, c] = strread ("1,,2", "%s%s%s", "delimiter", ",");
-%! assert (a{1}, '1');
-%! assert (b{1}, '');
-%! assert (c{1}, '2');
+%! assert (a{1}, "1");
+%! assert (b{1}, "");
+%! assert (c{1}, "2");
 
 %!test
 %! # Bug #33536
@@ -794,17 +845,17 @@
 
 %!test
 %! dat = "Data file.\r\n=  =  =  =  =\r\nCOMPANY    : <Company name>\r\n";
-%! a = strread (dat, "%s", 'delimiter', "\n", 'whitespace', '', 'endofline', "\r\n");
+%! a = strread (dat, "%s", "delimiter", "\n", "whitespace", "", "endofline", "\r\n");
 %! assert (a{2}, "=  =  =  =  =");
 %! assert (double (a{3}(end-5:end)), [32 110 97 109 101 62]);
 
 %!test
-%! [a, b, c, d] = strread ("1,2,3,,5,6", "%d%f%d%f", 'delimiter', ',');
+%! [a, b, c, d] = strread ("1,2,3,,5,6", "%d%f%d%f", "delimiter", ",");
 %! assert (c, int32 (3));
 %! assert (d, NaN);
 
 %!test
-%! [a, b, c, d] = strread ("1,2,3,,5,6\n", "%d%d%f%d", 'delimiter', ',');
+%! [a, b, c, d] = strread ("1,2,3,,5,6\n", "%d%d%f%d", "delimiter", ",");
 %! assert (c, [3; NaN]);
 %! assert (d, int32 ([0; 0]));
 
@@ -816,12 +867,12 @@
 %1 assert (c, 0.3567);
 
 %!test
-%! [a, b] = strread('0.41 8.24 3.57 6.24 9.27', "%f%f", 2, 'delimiter', ' ');
+%! [a, b] = strread ("0.41 8.24 3.57 6.24 9.27", "%f%f", 2, "delimiter", " ");
 %1 assert (a, [0.41; 3.57]);
 
 %!test
 %! # TreatAsEmpty
-%! [a, b, c, d] = strread ("1,2,3,NN,5,6\n", "%d%d%d%f", 'delimiter', ',', 'TreatAsEmpty', 'NN');
+%! [a, b, c, d] = strread ("1,2,3,NN,5,6\n", "%d%d%d%f", "delimiter", ",", "TreatAsEmpty", "NN");
 %! assert (c, int32 ([3; 0]));
 %! assert (d, [NaN; NaN]);
 
@@ -830,13 +881,13 @@
 %! str = "Text1Text2Text\nText398Text4Text\nText57Text";
 %! [a, b] = strread (str, "Text%dText%1sText");
 %! assert (a, int32 ([1; 398; 57]));
-%! assert (b(1:2), {'2'; '4'});
+%! assert (b(1:2), {"2"; "4"});
 %! assert (isempty (b{3}), true);
 
 %% MultipleDelimsAsOne
 %!test
 %! str = "11, 12, 13,, 15\n21,, 23, 24, 25\n,, 33, 34, 35";
-%! [a b c d] = strread (str, "%f %f %f %f", 'delimiter', ',', 'multipledelimsasone', 1, 'endofline', "\n");
+%! [a b c d] = strread (str, "%f %f %f %f", "delimiter", ",", "multipledelimsasone", 1, "endofline", "\n");
 %! assert (a', [11, 21, NaN]);
 %! assert (b', [12, 23, 33]);
 %! assert (c', [13, 24, 34]);
@@ -887,3 +938,37 @@
 %! assert (a, [0.31; 0.60], 0.01)
 %! assert (b, [0.86; 0.72], 0.01)
 %! assert (c, [0.94; 0.87], 0.01)
+
+%!test
+%! [a, b] = strread (["Empty 1" char(10)], "Empty%s %f");
+%! assert (a{1}, '1');
+%! assert (b, NaN);
+
+%!test
+%! [a, b] = strread (["Empty" char(10)], "Empty%f %f");
+%! assert (a, NaN);
+%! assert (b, NaN);
+
+%!test
+%! # Bug #35999
+%! [a, b, c] = strread ("", "%f");
+%! assert (isempty (a));
+%! assert (isempty (b));
+%! assert (isempty (c));
+
+%% Unsupported format specifiers
+%!test
+%!error <format specifiers are not supported> strread ("a", "%c")
+%!error <format specifiers are not supported> strread ("a", "%*c %d")
+%!error <format specifiers are not supported> strread ("a", "%q")
+%!error <format specifiers are not supported> strread ("a", "%*q %d")
+%!error <format specifiers are not supported> strread ("a", "%[a]")
+%!error <format specifiers are not supported> strread ("a", "%*[a] %d")
+%!error <format specifiers are not supported> strread ("a", "%[^a]")
+%!error <format specifiers are not supported> strread ("a", "%*[^a] %d")
+%!error <format specifiers are not supported> strread ("a", "%d8")
+%!error <format specifiers are not supported> strread ("a", "%*d8 %s")
+%!error <format specifiers are not supported> strread ("a", "%f64")
+%!error <format specifiers are not supported> strread ("a", "%*f64 %s")
+%!error <format specifiers are not supported> strread ("a", "%u32")
+%!error <format specifiers are not supported> strread ("a", "%*u32 %d")
--- a/scripts/io/textread.m
+++ b/scripts/io/textread.m
@@ -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} specifies 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 (nargin > 2 && 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,25 +101,62 @@
       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 (findstr ("\r\n", str(1 : eol_srch_len))))
+    if (! isempty (strfind ("\r\n", str(1 : eol_srch_len))))
       eol_char = "\r\n";
     ## Perhaps old Macintosh? (CR)
-    elseif (! isempty (findstr ("\r", str(1 : eol_srch_len))))
+    elseif (! isempty (strfind ("\r", str(1 : eol_srch_len))))
       eol_char = "\r";
     ## Otherwise, use plain UNIX (LF)
     else
       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
@@ -131,18 +166,26 @@
 
 
 %!test
-%! f = tmpnam();
+%! f = tmpnam ();
 %! d = rand (5, 3);
-%! dlmwrite (f, d, 'precision', '%5.2f');
+%! dlmwrite (f, d, "precision", "%5.2f");
 %! [a, b, c] = textread (f, "%f %f %f", "delimiter", ",", "headerlines", 3);
-%! unlink(f);
+%! unlink (f);
 %! assert (a, d(4:5, 1), 1e-2);
 %! assert (b, d(4:5, 2), 1e-2);
 %! assert (c, d(4:5, 3), 1e-2);
 
+%!test
+%! f = tmpnam ();
+%! d = rand (7, 2);
+%! dlmwrite (f, d, "precision", "%5.2f");
+%! [a, b] = textread (f, "%f, %f", "headerlines", 1);
+%! unlink (f);
+%! assert (a, d(2:7, 1), 1e-2);
+
 %% Test input validation
 %!error textread ()
 %!error textread (1)
-%!error <arguments must be strings> textread (1, '%f')
+%!error <arguments must be strings> textread (1, "%f")
 %!error <arguments must be strings> textread ("fname", 1)
 
--- a/scripts/io/textscan.m
+++ b/scripts/io/textscan.m
@@ -25,13 +25,13 @@
 ## @deftypefnx {Function File} {[@var{C}, @var{position}] =} textscan (@var{fid}, @dots{})
 ## Read data from a text file or string.
 ##
-## The file associated with @var{fid} is read and parsed according to
-## @var{format}.  The function behaves like @code{strread} except it works by
-## parsing a file instead of a string.  See the documentation of
-## @code{strread} for details.
+## The string @var{str} or file associated with @var{fid} is read from and
+## parsed according to @var{format}.  The function behaves like @code{strread}
+## except it can also read from file instead of a string.  See the documentation
+## of @code{strread} for details.
 ##
-## In addition to the options supported by
-## @code{strread}, this function supports a few more:
+## In addition to the options supported by @code{strread}, this function
+## supports a few more:
 ##
 ## @itemize
 ## @item "collectoutput":
@@ -50,13 +50,19 @@
 ## @item "returnonerror":
 ## If set to numerical 1 or true (default), return normally when read errors
 ## have been encountered.  If set to 0 or false, return an error and no data.
+## As the string or file is read by columns rather than by rows, and because
+## textscan is fairly forgiving as regards read errors, setting this option
+## may have little or no actual effect.
 ## @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}
+## specifies the number of times @var{format} should be used (i.e., to limit
+## the amount of data read).
+## When reading from file, @var{n} specifies 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.
+## The output @var{C} is a cell array whose second dimension is determined
+## by the number of format specifiers.
 ##
 ## The second output, @var{position}, provides the position, in characters,
 ## from the beginning of the file.
@@ -66,6 +72,8 @@
 
 function [C, position] = textscan (fid, format = "%f", varargin)
 
+  BUFLENGTH = 4096;               ## Read buffer
+  
   ## Check input
   if (nargin < 1)
     print_usage ();
@@ -75,20 +83,28 @@
     format = "%f";
   endif
 
+  if (! ischar (format))
+    error ("textscan: FORMAT must be a string");
+  endif
+
+  ## Determine the number of data fields & initialize output array
+  num_fields = numel (strfind (format, "%")) - numel (strfind (format, "%*"));
+  C = cell (1, num_fields);
+
   if (! (isa (fid, "double") && fid > 0) && ! ischar (fid))
     error ("textscan: first argument must be a file id or character string");
   endif
 
-  if (! ischar (format))
-    error ("textscan: FORMAT must be a string");
-  endif
-
   args = varargin;
   if (nargin > 2 && isnumeric (args{1}))
     nlines = args{1};
   else
     nlines = Inf;
   endif
+  if (nlines < 1)
+    printf ("textscan: N = 0, no data read\n");
+    return
+  endif
 
   if (! any (strcmpi (args, "emptyvalue")))
     ## Matlab returns NaNs for missing values
@@ -104,14 +120,11 @@
     whitespace = " \b\t";
   else
     ## Check if there's at least one string format specifier
-    fmt = strrep (format, "%", " %");
-    fmt = regexp (fmt, '[^ ]+', 'match');
-    fmt = strtrim (fmt(strmatch ("%", fmt)))
-    has_str_fmt = all (cellfun ("isempty", strfind (strtrim (fmt(strmatch ("%", fmt))), 's')));
-    ## If there is a format, AND whitespace value = empty,
+    has_str_fmt = regexp (format, '%[*]?\d*s', "once");
+    ## If there is a string format AND whitespace value = empty,
     ## don't add a space (char(32)) to whitespace
-    if (! (isempty (args{ipos+1}) &&  has_str_fmt))
-      args{ipos+1} = unique ([" ", whitespace]);
+    if (! (isempty (args{ipos+1}) && has_str_fmt))
+      args{ipos+1} = unique ([" ", args{ipos+1}]);
     endif
   endif
 
@@ -151,32 +164,22 @@
     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
   if (isempty (str))
     warning ("textscan: no data read");
-    C = [];
     return;
   endif
 
@@ -185,36 +188,84 @@
   if (! isempty (endofline))
     if (ischar (args{endofline + 1}))
       eol_char = args{endofline + 1};
-      if (isempty (strmatch (eol_char, {"", "\n", "\r", "\r\n"}, 'exact')))
+      if (! any (strcmp (eol_char, {"", "\n", "\r", "\r\n"})))
         error ("textscan: illegal EndOfLine character value specified");
       endif
     else
       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 (findstr ("\r\n", str(1 : eol_srch_len))))
+    if (! isempty (strfind ("\r\n", str(1 : eol_srch_len))))
       eol_char = "\r\n";
     ## Perhaps old Macintosh? (CR)
-    elseif (! isempty (findstr ("\r", str(1 : eol_srch_len))))
+    elseif (! isempty (strfind ("\r", str(1 : eol_srch_len))))
       eol_char = "\r";
     ## Otherwise, use plain UNIX (LF)
     else
       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
   num_fields = numel (strfind (format, "%")) - numel (strfind (format, "%*"));
 
-  ## Strip trailing EOL to avoid returning stray missing values (f. strread)
-  if (strcmp (str(end-length (eol_char) + 1 : end), eol_char));
-    str(end-length (eol_char) + 1 : end) = "";
-  endif
+  ## Strip trailing EOL to avoid returning stray missing values (f. strread).
+  ## However, in case of CollectOutput request, presence of EOL is required
+  eol_at_end = strcmp (str(end-length (eol_char) + 1 : end), eol_char);
+  if (collop)
+    if (! eol_at_end)
+      str(end+1 : end+length (eol_char)) = eol_char;
+    endif
+  elseif (eol_at_end)
+     str(end-length (eol_char) + 1 : end) = "";
+    ## A corner case: str may now be empty....
+    if (isempty (str)); return; endif
+   endif
 
   ## Call strread to make it do the real work
   C = cell (1, num_fields);
@@ -226,6 +277,7 @@
   endif
 
   if (nargout == 2)
+    ## Remember file position (persistent var)
     position = ftell (fid);
   endif
 
@@ -237,10 +289,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
@@ -258,6 +310,7 @@
 
 endfunction
 
+
 %!test
 %! str = "1,  2,  3,  4\n 5,  ,  ,  8\n 9, 10, 11, 12";
 %! fmtstr = "%f %d %f %s";
@@ -276,14 +329,14 @@
 %! assert (b(1,:)', c{1}, 1e-5);
 %! assert (b(2,:)', c{2}, 1e-5);
 
-#%!test
-#%! str = "13, 72, NA, str1, 25\r\n// Middle line\r\n36, na, 05, str3, 6";
-#%! a = textscan(str, '%d %n %f %s %n', 'delimiter', ',','treatAsEmpty', {'NA', 'na'},'commentStyle', '//');
-#%! assert (a{1}, int32([13; 36]));
-#%! assert (a{2}, [72; NaN]);
-#%! assert (a{3}, [NaN; 5]);
-#%! assert (a{4}, {"str1"; "str3"});
-#%! assert (a{5}, [25; 6]);
+%!test
+%! str = "13, 72, NA, str1, 25\r\n// Middle line\r\n36, na, 05, str3, 6";
+%! a = textscan (str, "%d %n %f %s %n", "delimiter", ",","treatAsEmpty", {"NA", "na"},"commentStyle", "//");
+%! assert (a{1}, int32 ([13; 36]));
+%! assert (a{2}, [72; NaN]);
+%! assert (a{3}, [NaN; 5]);
+%! assert (a{4}, {"str1"; "str3"});
+%! assert (a{5}, [25; 6]);
 
 %!test
 %! str = "Km:10 = hhhBjjj miles16hour\r\n";
@@ -291,20 +344,20 @@
 %! str = [str "Km:2 = hhhRjjj miles3hour\r\n"];
 %! str = [str "Km:25 = hhhZ\r\n"];
 %! fmt = "Km:%d = hhh%1sjjj miles%dhour";
-%! a = textscan (str, fmt, 'delimiter', ' ');
-%! assert (a{1}', int32([10 15 2 25]));
+%! a = textscan (str, fmt, "delimiter", " ");
+%! assert (a{1}', int32 ([10 15 2 25]));
 %! assert (a{2}', {'B' 'J' 'R' 'Z'});
-%! assert (a{3}', int32([16 241 3 0]));
+%! assert (a{3}', int32 ([16 241 3 0]));
 
 %% Test with default endofline parameter
 %!test
 %! c = textscan ("L1\nL2", "%s");
 %! assert (c{:}, {"L1"; "L2"});
 
-%% Test with endofline parameter set to '' (empty) - newline should be in word
+%% Test with endofline parameter set to "" (empty) - newline should be in word
 %!test
-%! c = textscan ("L1\nL2", "%s", 'endofline', '');
-%! assert (int8(c{:}{:}), int8([ 76,  49,  10,  76,  50 ]));
+%! c = textscan ("L1\nL2", "%s", "endofline", "");
+%! assert (int8 (c{:}{:}), int8 ([ 76,  49,  10,  76,  50 ]));
 
 %!test
 %! # No delimiters at all besides EOL.  Skip fields, even empty fields
@@ -318,9 +371,24 @@
 %! b = [b; 8*b/5; 8*b*1000/5];
 %! str = sprintf ("%g miles/hr = %g (%g) kilometers (meters)/hr\n", b);
 %! fmt = "%f miles%s %s %f (%f) kilometers %*s";
-%! c = textscan (str, fmt, 'collectoutput', 1);
-%! assert (size(c{3}), [10, 2]);
-%! assert (size(c{2}), [10, 2]);
+%! c = textscan (str, fmt, "collectoutput", 1);
+%! assert (size (c{3}), [10, 2]);
+%! assert (size (c{2}), [10, 2]);
+
+%!test
+%% CollectOutput test with uneven column length files
+%! b = [10:10:100];
+%! b = [b; 8*b/5; 8*b*1000/5];
+%! str = sprintf ("%g miles/hr = %g (%g) kilometers (meters)/hr\n", b);
+%! str = [str "110 miles/hr"];
+%! fmt = "%f miles%s %s %f (%f) kilometers %*s";
+%! c = textscan (str, fmt, "collectoutput", 1);
+%! assert (size (c{1}), [11, 1]);
+%! assert (size (c{3}), [11, 2]);
+%! assert (size (c{2}), [11, 2]);
+%! assert (c{3}(end), NaN);
+%! assert (c{2}{11, 1}, "/hr");
+%! assert (isempty (c{2}{11, 2}), true);
 
 %% Test input validation
 %!error textscan ()
@@ -330,3 +398,7 @@
 %!error <cannot provide position information> [C, pos] = textscan ("Hello World")
 %!error <character value required> textscan ("Hello World", '%s', 'EndOfLine', 3)
 
+%! Test incomplete first data line
+%! R = textscan (['Empty1' char(10)], 'Empty%d %f');
+%! assert (R{1}, int32 (1));
+%! assert (isempty (R{2}), true);
--- a/scripts/linear-algebra/commutation_matrix.m
+++ b/scripts/linear-algebra/commutation_matrix.m
@@ -96,24 +96,26 @@
 
 endfunction
 
+
 %!test
-%! c = commutation_matrix(1,1);
-%! assert(c,1);
+%! c = commutation_matrix (1,1);
+%! assert (c,1);
 
 %!test
-%! A = rand(3,5);
-%! vc = vec(A);
-%! vr = vec(A');
-%! c = commutation_matrix(3,5);
-%! assert(c*vc,vr);
+%! A = rand (3,5);
+%! vc = vec (A);
+%! vr = vec (A');
+%! c = commutation_matrix (3,5);
+%! assert (c*vc, vr);
 
 %!test
-%! A = rand(4,6);
-%! vc = vec(A);
-%! vr = vec(A');
-%! c = commutation_matrix(4,6);
-%! assert(c*vc,vr);
+%! A = rand (4,6);
+%! vc = vec (A);
+%! vr = vec (A');
+%! c = commutation_matrix (4,6);
+%! assert (c*vc, vr);
 
-%!error commutation_matrix(0,0);
-%!error commutation_matrix(1,0);
-%!error commutation_matrix(0,1);
+%!error <M must be a positive integer> commutation_matrix (0,0)
+%!error <N must be a positive integer> commutation_matrix (1,0)
+%!error <M must be a positive integer> commutation_matrix (0,1)
+
--- a/scripts/linear-algebra/cond.m
+++ b/scripts/linear-algebra/cond.m
@@ -74,20 +74,19 @@
 
 endfunction
 
+
 %!test
-%! y= [7, 2, 3; 1, 3, 4; 6, 4, 5];
+%! y = [7, 2, 3; 1, 3, 4; 6, 4, 5];
 %! tol = 1e-6;
-%! type = {1, 2, 'fro', 'inf', inf};
-%! for n = 1:numel(type)
+%! type = {1, 2, "fro", "inf", inf};
+%! for n = 1:numel (type)
 %!   rcondition(n) = 1 / cond (y, type{n});
 %! endfor
 %! assert (rcondition, [0.017460, 0.019597, 0.018714, 0.012022, 0.012022], tol);
 
-%!assert (abs (cond ([1, 2; 2, 1]) - 3) < sqrt (eps));
-
-%!assert (cond ([1, 2, 3; 4, 5, 6; 7, 8, 9]) > 1.0e+16);
+%!assert (cond ([1, 2; 2, 1]), 3, sqrt (eps))
+%!assert (cond ([1, 2, 3; 4, 5, 6; 7, 8, 9]) > 1.0e+16)
 
-%!error cond ();
+%!error cond ()
+%!error cond (1, 2, 3)
 
-%!error cond (1, 2, 3);
-
--- a/scripts/linear-algebra/condest.m
+++ b/scripts/linear-algebra/condest.m
@@ -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)
@@ -194,45 +194,47 @@
 
 endfunction
 
+
 %!demo
-%!  N = 100;
-%!  A = randn (N) + eye (N);
-%!  condest (A)
-%!  [L,U,P] = lu (A);
-%!  condest (A, @(x) U\ (L\ (P*x)), @(x) P'*(L'\ (U'\x)))
-%!  condest (@(x) A*x, @(x) A'*x, @(x) U\ (L\ (P*x)), @(x) P'*(L'\ (U'\x)), N)
-%!  norm (inv (A), 1) * norm (A, 1)
+%! N = 100;
+%! A = randn (N) + eye (N);
+%! condest (A)
+%! [L,U,P] = lu (A);
+%! condest (A, @(x) U \ (L \ (P*x)), @(x) P'*(L' \ (U'\x)))
+%! condest (@(x) A*x, @(x) A'*x, @(x) U \ (L \ (P*x)), @(x) P'*(L' \ (U'\x)), N)
+%! norm (inv (A), 1) * norm (A, 1)
 
 ## Yes, these test bounds are really loose.  There's
 ## enough randomization to trigger odd cases with hilb().
 
 %!test
-%!  N = 6;
-%!  A = hilb (N);
-%!  cA = condest (A);
-%!  cA_test = norm (inv (A), 1) * norm (A, 1);
-%!  assert (cA, cA_test, -2^-8);
+%! N = 6;
+%! A = hilb (N);
+%! cA = condest (A);
+%! cA_test = norm (inv (A), 1) * norm (A, 1);
+%! assert (cA, cA_test, -2^-8);
 
 %!test
-%!  N = 6;
-%!  A = hilb (N);
-%!  solve = @(x) A\x; solve_t = @(x) A'\x;
-%!  cA = condest (A, solve, solve_t);
-%!  cA_test = norm (inv (A), 1) * norm (A, 1);
-%!  assert (cA, cA_test, -2^-8);
+%! N = 6;
+%! A = hilb (N);
+%! solve = @(x) A\x; solve_t = @(x) A'\x;
+%! cA = condest (A, solve, solve_t);
+%! cA_test = norm (inv (A), 1) * norm (A, 1);
+%! assert (cA, cA_test, -2^-8);
 
 %!test
-%!  N = 6;
-%!  A = hilb (N);
-%!  apply = @(x) A*x; apply_t = @(x) A'*x;
-%!  solve = @(x) A\x; solve_t = @(x) A'\x;
-%!  cA = condest (apply, apply_t, solve, solve_t, N);
-%!  cA_test = norm (inv (A), 1) * norm (A, 1);
-%!  assert (cA, cA_test, -2^-6);
+%! N = 6;
+%! A = hilb (N);
+%! apply = @(x) A*x; apply_t = @(x) A'*x;
+%! solve = @(x) A\x; solve_t = @(x) A'\x;
+%! cA = condest (apply, apply_t, solve, solve_t, N);
+%! cA_test = norm (inv (A), 1) * norm (A, 1);
+%! assert (cA, cA_test, -2^-6);
 
 %!test
-%!  N = 12;
-%!  A = hilb (N);
-%!  [rcondA, v] = condest (A);
-%!  x = A*v;
-%!  assert (norm(x, inf), 0, eps);
+%! N = 12;
+%! A = hilb (N);
+%! [rcondA, v] = condest (A);
+%! x = A*v;
+%! assert (norm (x, inf), 0, eps);
+
--- a/scripts/linear-algebra/cross.m
+++ b/scripts/linear-algebra/cross.m
@@ -91,25 +91,26 @@
 
 endfunction
 
+
 %!test
 %! x = [1 0 0];
 %! y = [0 1 0];
 %! r = [0 0 1];
-%! assert(cross(x, y), r, 2e-8);
+%! assert (cross (x, y), r, 2e-8);
 
 %!test
 %! x = [1 2 3];
 %! y = [4 5 6];
 %! r = [(2*6-3*5) (3*4-1*6) (1*5-2*4)];
-%! assert(cross(x, y), r, 2e-8);
+%! assert (cross (x, y), r, 2e-8);
 
 %!test
 %! x = [1 0 0; 0 1 0; 0 0 1];
 %! y = [0 1 0; 0 0 1; 1 0 0];
 %! r = [0 0 1; 1 0 0; 0 1 0];
-%! assert(cross(x, y, 2), r, 2e-8);
-%! assert(cross(x, y, 1), -r, 2e-8);
+%! assert (cross (x, y, 2), r, 2e-8);
+%! assert (cross (x, y, 1), -r, 2e-8);
 
-%!error cross(0,0);
-%!error cross();
+%!error cross (0,0)
+%!error cross ()
 
--- a/scripts/linear-algebra/duplication_matrix.m
+++ b/scripts/linear-algebra/duplication_matrix.m
@@ -87,9 +87,10 @@
 
 endfunction
 
+
 %!test
 %! N = 2;
-%! A = rand(N);
+%! A = rand (N);
 %! B = A * A';
 %! C = A + A';
 %! D = duplication_matrix (N);
@@ -98,7 +99,7 @@
 
 %!test
 %! N = 3;
-%! A = rand(N);
+%! A = rand (N);
 %! B = A * A';
 %! C = A + A';
 %! D = duplication_matrix (N);
@@ -107,14 +108,15 @@
 
 %!test
 %! N = 4;
-%! A = rand(N);
+%! A = rand (N);
 %! B = A * A';
 %! C = A + A';
 %! D = duplication_matrix (N);
 %! assert (D * vech (B), vec (B), 1e-6);
 %! assert (D * vech (C), vec (C), 1e-6);
 
-%!error duplication_matrix ();
-%!error duplication_matrix (0.5);
-%!error duplication_matrix (-1);
-%!error duplication_matrix (ones(1,4));
+%!error duplication_matrix ()
+%!error duplication_matrix (0.5)
+%!error duplication_matrix (-1)
+%!error duplication_matrix (ones (1,4))
+
--- a/scripts/linear-algebra/expm.m
+++ b/scripts/linear-algebra/expm.m
@@ -141,14 +141,16 @@
 
 endfunction
 
-%!assert(norm(expm([1 -1;0 1]) - [e -e; 0 e]) < 1e-5);
-%!assert(expm([1 -1 -1;0 1 -1; 0 0 1]), [e -e -e/2; 0 e -e; 0 0 e], 1e-5);
 
-%% Test input validation
-%!error expm ();
-%!error expm (1, 2);
-%!error <expm: A must be a square matrix> expm([1 0;0 1; 2 2]);
+%!assert (norm (expm ([1 -1;0 1]) - [e -e; 0 e]) < 1e-5);
+%!assert (expm ([1 -1 -1;0 1 -1; 0 0 1]), [e -e -e/2; 0 e -e; 0 0 e], 1e-5);
 
 %!assert (expm (10), expm (10))
 %!assert (full (expm (eye (3))), expm (full (eye (3))))
 %!assert (full (expm (10*eye (3))), expm (full (10*eye (3))), 8*eps)
+
+%% Test input validation
+%!error expm ()
+%!error expm (1, 2)
+%!error <expm: A must be a square matrix> expm ([1 0;0 1; 2 2])
+
--- a/scripts/linear-algebra/housh.m
+++ b/scripts/linear-algebra/housh.m
@@ -23,8 +23,8 @@
 ##
 ## @example
 ## @group
-## (I - beta*housv*housv')x =  norm(x)*e(j) if x(j) < 0,
-## (I - beta*housv*housv')x = -norm(x)*e(j) if x(j) >= 0
+## (I - beta*housv*housv')x =  norm (x)*e(j) if x(j) < 0,
+## (I - beta*housv*housv')x = -norm (x)*e(j) if x(j) >= 0
 ## @end group
 ## @end example
 ##
@@ -66,7 +66,7 @@
   ## Check for valid inputs.
   if (! isvector (x) && ! isscalar (x))
     error ("housh: first input must be a vector");
-  elseif (! isscalar(j))
+  elseif (! isscalar (j))
     error ("housh: second argment must be an integer scalar");
   else
     housv = x;
@@ -92,42 +92,43 @@
 
 endfunction
 
+
 %!test
 %! x = [1 2 3]';
 %! j = 3;
-%! [hv, b, z] = housh(x, j, 0);
-%! r = (eye(3) - b*hv*hv') * x;
-%! d = - norm(x) * [0 0 1]';
-%! assert(r, d, 2e-8);
-%! assert(z, 0, 2e-8);
+%! [hv, b, z] = housh (x, j, 0);
+%! r = (eye (3) - b*hv*hv') * x;
+%! d = - norm (x) * [0 0 1]';
+%! assert (r, d, 2e-8);
+%! assert (z, 0, 2e-8);
 
 %!test
 %! x = [7 -3 1]';
 %! j = 2;
-%! [hv, b, z] = housh(x, j, 0);
-%! r = (eye(3) - b*hv*hv') * x;
-%! d = norm(x) * [0 1 0]';
-%! assert(r, d, 2e-8);
-%! assert(z, 0, 2e-8);
+%! [hv, b, z] = housh (x, j, 0);
+%! r = (eye (3) - b*hv*hv') * x;
+%! d = norm (x) * [0 1 0]';
+%! assert (r, d, 2e-8);
+%! assert (z, 0, 2e-8);
 
 %!test
 %! x = [1 0 0]';
 %! j = 1;
-%! [hv, b, z] = housh(x, j, 10);
-%! r = (eye(3) - b*hv*hv') * x;
-%! d = norm(x) * [1 0 0]';
-%! assert(r, d, 2e-8);
-%! assert(z, 1, 2e-8);
+%! [hv, b, z] = housh (x, j, 10);
+%! r = (eye (3) - b*hv*hv') * x;
+%! d = norm (x) * [1 0 0]';
+%! assert (r, d, 2e-8);
+%! assert (z, 1, 2e-8);
 
 %!test
 %! x = [5 0 4 1]';
 %! j = 2;
-%! [hv, b, z] = housh(x, j, 0);
-%! r = (eye(4) - b*hv*hv') * x;
-%! d = - norm(x) * [0 1 0 0]';
-%! assert(r, d, 2e-8);
-%! assert(z, 0, 2e-8);
+%! [hv, b, z] = housh (x, j, 0);
+%! r = (eye (4) - b*hv*hv') * x;
+%! d = - norm (x) * [0 1 0 0]';
+%! assert (r, d, 2e-8);
+%! assert (z, 0, 2e-8);
 
-%!error housh([0]);
-%!error housh();
+%!error housh ([0])
+%!error housh ()
 
--- a/scripts/linear-algebra/isdefinite.m
+++ b/scripts/linear-algebra/isdefinite.m
@@ -67,19 +67,19 @@
 
 %!test
 %! A = [-1 0; 0 -1];
-%! assert (isdefinite (A), -1)
+%! assert (isdefinite (A), -1);
 
 %!test
 %! A = [1 0; 0 1];
-%! assert (isdefinite (A), 1)
+%! assert (isdefinite (A), 1);
 
 %!test
 %! A = [2 -1 0; -1 2 -1; 0 -1 2];
-%! assert (isdefinite (A), 1)
+%! assert (isdefinite (A), 1);
 
 %!test
 %! A = [1 0; 0 0];
-%! assert (isdefinite (A), 0)
+%! assert (isdefinite (A), 0);
 
 %!error isdefinite ()
 %!error isdefinite (1,2,3)
--- a/scripts/linear-algebra/ishermitian.m
+++ b/scripts/linear-algebra/ishermitian.m
@@ -50,18 +50,21 @@
 
 endfunction
 
-%!assert(ishermitian (1));
-%!assert(!(ishermitian ([1, 2])));
-%!assert(ishermitian ([]));
-%!assert(ishermitian ([1, 2; 2, 1]));
-%!assert(!(ishermitian ("test")));
-%!assert(ishermitian ([1, 2.1; 2, 1.1], 0.2));
-%!assert(ishermitian ([1, -2i; 2i, 1]));
-%!assert(!(ishermitian ("t")));
-%!assert(!(ishermitian (["te"; "et"])));
-%!error ishermitian ([1, 2; 2, 1], 0, 0);
-%!error ishermitian ();
+
+%!assert (ishermitian (1))
+%!assert (! ishermitian ([1, 2]))
+%!assert (ishermitian ([]))
+%!assert (ishermitian ([1, 2; 2, 1]))
+%!assert (! ishermitian ("test"))
+%!assert (ishermitian ([1, 2.1; 2, 1.1], 0.2))
+%!assert (ishermitian ([1, -2i; 2i, 1]))
+%!assert (! ishermitian ("t"))
+%!assert (! ishermitian (["te"; "et"]))
 
 %!test
 %! s.a = 1;
-%! assert(!(ishermitian (s)));
+%! assert (! ishermitian (s));
+
+%!error ishermitian ([1, 2; 2, 1], 0, 0)
+%!error ishermitian ()
+
--- a/scripts/linear-algebra/issymmetric.m
+++ b/scripts/linear-algebra/issymmetric.m
@@ -49,18 +49,21 @@
 
 endfunction
 
-%!assert(issymmetric (1));
-%!assert(!(issymmetric ([1, 2])));
-%!assert(issymmetric ([]));
-%!assert(issymmetric ([1, 2; 2, 1]));
-%!assert(!(issymmetric ("test")));
-%!assert(issymmetric ([1, 2.1; 2, 1.1], 0.2));
-%!assert(issymmetric ([1, 2i; 2i, 1]));
-%!assert(!(issymmetric ("t")));
-%!assert(!(issymmetric (["te"; "et"])));
-%!error issymmetric ([1, 2; 2, 1], 0, 0);
-%!error issymmetric ();
+
+%!assert (issymmetric (1))
+%!assert (! issymmetric ([1, 2]))
+%!assert (issymmetric ([]))
+%!assert (issymmetric ([1, 2; 2, 1]))
+%!assert (! (issymmetric ("test")))
+%!assert (issymmetric ([1, 2.1; 2, 1.1], 0.2))
+%!assert (issymmetric ([1, 2i; 2i, 1]))
+%!assert (! (issymmetric ("t")))
+%!assert (! (issymmetric (["te"; "et"])))
 
 %!test
 %! s.a = 1;
-%! assert(!(issymmetric (s)));
+%! assert (! issymmetric (s));
+
+%!error issymmetric ([1, 2; 2, 1], 0, 0)
+%!error issymmetric ()
+
--- a/scripts/linear-algebra/krylov.m
+++ b/scripts/linear-algebra/krylov.m
@@ -34,7 +34,7 @@
 ## meaningless.
 ##
 ## If @var{V} is a vector and @var{k} is greater than
-## @code{length(A)-1}, then @var{h} contains the Hessenberg matrix such
+## @code{length (A) - 1}, then @var{h} contains the Hessenberg matrix such
 ## that @code{a*u == u*h}.
 ##
 ## The value of @var{nu} is the dimension of the span of the Krylov
@@ -71,7 +71,7 @@
     pflg = 0;
   endif
 
-  if(nargin < 4)
+  if (nargin < 4)
     ## Default tolerance parameter.
     eps1 = defeps;
   endif
@@ -115,14 +115,14 @@
   iter = 0;
   alpha = [];
   nh = 0;
-  while (length(alpha) < na) && (columns(V) > 0) && (iter < k)
+  while (length (alpha) < na) && (columns (V) > 0) && (iter < k)
     iter++;
 
     ## Get orthogonal basis of V.
     jj = 1;
     while (jj <= columns (V) && length (alpha) < na)
       ## Index of next Householder reflection.
-      nu = length(alpha)+1;
+      nu = length (alpha)+1;
 
       short_pv = pivot_vec(nu:na);
       q = V(:,jj);
--- a/scripts/linear-algebra/logm.m
+++ b/scripts/linear-algebra/logm.m
@@ -104,7 +104,7 @@
   s = 2^k * u * s * u';
 
   ## Remove small complex values (O(eps)) which may have entered calculation
-  if (real_eig && isreal(A))
+  if (real_eig && isreal (A))
     s = real (s);
   endif
 
@@ -156,16 +156,16 @@
 endfunction
 
 
-%!assert(norm(logm([1 -1;0 1]) - [0 -1; 0 0]) < 1e-5);
-%!assert(norm(expm(logm([-1 2 ; 4 -1])) - [-1 2 ; 4 -1]) < 1e-5);
-%!assert(logm([1 -1 -1;0 1 -1; 0 0 1]), [0 -1 -1.5; 0 0 -1; 0 0 0], 1e-5);
+%!assert (norm (logm ([1 -1;0 1]) - [0 -1; 0 0]) < 1e-5)
+%!assert (norm (expm (logm ([-1 2 ; 4 -1])) - [-1 2 ; 4 -1]) < 1e-5)
+%!assert (logm ([1 -1 -1;0 1 -1; 0 0 1]), [0 -1 -1.5; 0 0 -1; 0 0 0], 1e-5)
+%!assert (logm (10), log (10))
+%!assert (full (logm (eye (3))), logm (full (eye (3))))
+%!assert (full (logm (10*eye (3))), logm (full (10*eye (3))), 8*eps)
 %!assert (logm (expm ([0 1i; -1i 0])), [0 1i; -1i 0], 10 * eps)
 
 %% Test input validation
-%!error logm ();
-%!error logm (1, 2, 3);
-%!error <logm: A must be a square matrix> logm([1 0;0 1; 2 2]);
+%!error logm ()
+%!error logm (1, 2, 3)
+%!error <logm: A must be a square matrix> logm ([1 0;0 1; 2 2])
 
-%!assert (logm (10), log (10))
-%!assert (full (logm (eye (3))), logm (full (eye (3))))
-%!assert (full (logm (10*eye (3))), logm (full (10*eye (3))), 8*eps)
--- a/scripts/linear-algebra/normest.m
+++ b/scripts/linear-algebra/normest.m
@@ -75,13 +75,14 @@
   rand ("state", v);    # restore state of random number generator
 endfunction
 
+
 %!test
 %! A = toeplitz ([-2,1,0,0]);
-%! assert (normest(A), norm(A), 1e-6);
+%! assert (normest (A), norm (A), 1e-6);
 
 %!test
 %! A = rand (10);
-%! assert (normest(A), norm(A), 1e-6);
+%! assert (normest (A), norm (A), 1e-6);
 
 %% Test input validation
 %!error normest ()
--- a/scripts/linear-algebra/null.m
+++ b/scripts/linear-algebra/null.m
@@ -67,9 +67,9 @@
     if (rank < cols)
       retval = V (:, rank+1:cols);
       if (isa (A, "single"))
-        retval(abs (retval) < eps ("single")) = 0;
+        retval (abs (retval) < eps ("single")) = 0;
       else
-        retval(abs (retval) < eps) = 0;
+        retval (abs (retval) < eps) = 0;
       endif
     else
       retval = zeros (cols, 0);
@@ -78,34 +78,38 @@
 
 endfunction
 
+
+%% FIXME: Need some tests for 'single' variables as well
+
 %!test
 %! A = 0;
-%! assert(null(A), 1);
+%! assert (null (A), 1);
 
 %!test
 %! A = 1;
-%! assert(null(A), zeros(1,0))
+%! assert (null (A), zeros (1,0));
 
 %!test
 %! A = [1 0; 0 1];
-%! assert(null(A), zeros(2,0));
+%! assert (null (A), zeros (2,0));
 
 %!test
 %! A = [1 0; 1 0];
-%! assert(null(A), [0 1]')
+%! assert (null (A), [0 1]');
 
 %!test
 %! A = [1 1; 0 0];
-%! assert(null(A), [-1/sqrt(2) 1/sqrt(2)]', eps)
+%! assert (null (A), [-1/sqrt(2) 1/sqrt(2)]', eps);
 
 %!test
 %! tol = 1e-4;
 %! A = [1 0; 0 tol-eps];
-%! assert(null(A,tol), [0 1]')
+%! assert (null (A,tol), [0; 1]);
 
 %!test
 %! tol = 1e-4;
 %! A = [1 0; 0 tol+eps];
-%! assert(null(A,tol), zeros(2,0));
+%! assert (null (A,tol), zeros (2,0));
 
-%!error null()
+%!error null ()
+
--- a/scripts/linear-algebra/onenormest.m
+++ b/scripts/linear-algebra/onenormest.m
@@ -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,62 +228,65 @@
     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
 
+
 %!demo
-%!  N = 100;
-%!  A = randn(N) + eye(N);
-%!  [L,U,P] = lu(A);
-%!  nm1inv = onenormest(@(x) U\(L\(P*x)), @(x) P'*(L'\(U'\x)), N, 30)
-%!  norm(inv(A), 1)
+%! N = 100;
+%! A = randn (N) + eye (N);
+%! [L,U,P] = lu (A);
+%! nm1inv = onenormest (@(x) U\(L\(P*x)), @(x) P'*(L'\(U'\x)), N, 30)
+%! norm (inv (A), 1)
 
 %!test
-%!  N = 10;
-%!  A = ones (N);
-%!  [nm1, v1, w1] = onenormest (A);
-%!  [nminf, vinf, winf] = onenormest (A', 6);
-%!  assert (nm1, N, -2*eps);
-%!  assert (nminf, N, -2*eps);
-%!  assert (norm (w1, 1), nm1 * norm (v1, 1), -2*eps)
-%!  assert (norm (winf, 1), nminf * norm (vinf, 1), -2*eps)
+%! N = 10;
+%! A = ones (N);
+%! [nm1, v1, w1] = onenormest (A);
+%! [nminf, vinf, winf] = onenormest (A', 6);
+%! assert (nm1, N, -2*eps);
+%! assert (nminf, N, -2*eps);
+%! assert (norm (w1, 1), nm1 * norm (v1, 1), -2*eps);
+%! assert (norm (winf, 1), nminf * norm (vinf, 1), -2*eps);
 
 %!test
-%!  N = 10;
-%!  A = ones (N);
-%!  [nm1, v1, w1] = onenormest (@(x) A*x, @(x) A'*x, N, 3);
-%!  [nminf, vinf, winf] = onenormest (@(x) A'*x, @(x) A*x, N, 3);
-%!  assert (nm1, N, -2*eps);
-%!  assert (nminf, N, -2*eps);
-%!  assert (norm (w1, 1), nm1 * norm (v1, 1), -2*eps)
-%!  assert (norm (winf, 1), nminf * norm (vinf, 1), -2*eps)
+%! N = 10;
+%! A = ones (N);
+%! [nm1, v1, w1] = onenormest (@(x) A*x, @(x) A'*x, N, 3);
+%! [nminf, vinf, winf] = onenormest (@(x) A'*x, @(x) A*x, N, 3);
+%! assert (nm1, N, -2*eps);
+%! assert (nminf, N, -2*eps);
+%! assert (norm (w1, 1), nm1 * norm (v1, 1), -2*eps);
+%! assert (norm (winf, 1), nminf * norm (vinf, 1), -2*eps);
 
 %!test
-%!  N = 5;
-%!  A = hilb (N);
-%!  [nm1, v1, w1] = onenormest (A);
-%!  [nminf, vinf, winf] = onenormest (A', 6);
-%!  assert (nm1, norm (A, 1), -2*eps);
-%!  assert (nminf, norm (A, inf), -2*eps);
-%!  assert (norm (w1, 1), nm1 * norm (v1, 1), -2*eps)
-%!  assert (norm (winf, 1), nminf * norm (vinf, 1), -2*eps)
+%! N = 5;
+%! A = hilb (N);
+%! [nm1, v1, w1] = onenormest (A);
+%! [nminf, vinf, winf] = onenormest (A', 6);
+%! assert (nm1, norm (A, 1), -2*eps);
+%! assert (nminf, norm (A, inf), -2*eps);
+%! assert (norm (w1, 1), nm1 * norm (v1, 1), -2*eps);
+%! assert (norm (winf, 1), nminf * norm (vinf, 1), -2*eps);
 
 ## Only likely to be within a factor of 10.
 %!test
-%!  old_state = rand ("state");
-%!  restore_state = onCleanup (@() rand ("state", old_state));
-%!  rand ('state', 42);  % Initialize to guarantee reproducible results
-%!  N = 100;
-%!  A = rand (N);
-%!  [nm1, v1, w1] = onenormest (A);
-%!  [nminf, vinf, winf] = onenormest (A', 6);
-%!  assert (nm1, norm (A, 1), -.1);
-%!  assert (nminf, norm (A, inf), -.1);
-%!  assert (norm (w1, 1), nm1 * norm (v1, 1), -2*eps)
-%!  assert (norm (winf, 1), nminf * norm (vinf, 1), -2*eps)
+%! old_state = rand ("state");
+%! restore_state = onCleanup (@() rand ("state", old_state));
+%! rand ('state', 42);  % Initialize to guarantee reproducible results
+%! N = 100;
+%! A = rand (N);
+%! [nm1, v1, w1] = onenormest (A);
+%! [nminf, vinf, winf] = onenormest (A', 6);
+%! assert (nm1, norm (A, 1), -.1);
+%! assert (nminf, norm (A, inf), -.1);
+%! assert (norm (w1, 1), nm1 * norm (v1, 1), -2*eps);
+%! assert (norm (winf, 1), nminf * norm (vinf, 1), -2*eps);
+
--- a/scripts/linear-algebra/orth.m
+++ b/scripts/linear-algebra/orth.m
@@ -80,11 +80,13 @@
 
 endfunction
 
+
 %!test
-%! for ii=1:20
+%! for i = 1:20
 %!   A = rand (10, 10);
 %!   V = orth (A);
 %!   if (det (A) != 0)
-%!     assert (V'*V, eye (10), 100*eps)
+%!     assert (V'*V, eye (10), 100*eps);
 %!   endif
 %! endfor
+
--- a/scripts/linear-algebra/planerot.m
+++ b/scripts/linear-algebra/planerot.m
@@ -35,13 +35,14 @@
   y = G * x(:);
 endfunction
 
+
 %!test
 %! x = [3 4];
-%! [g y] = planerot(x);
-%! assert(g - [x(1) x(2); -x(2) x(1)] / sqrt(x(1)^2 + x(2)^2), zeros(2), 2e-8);
-%! assert(y(2), 0, 2e-8);
+%! [g y] = planerot (x);
+%! assert (g, [x(1) x(2); -x(2) x(1)] / sqrt (x(1)^2 + x(2)^2), 2e-8);
+%! assert (y(2), 0, 2e-8);
 
-%!error planerot([0]);
-%!error planerot([0 0 0]);
-%!error planerot();
+%!error planerot ([0])
+%!error planerot ([0 0 0])
+%!error planerot ()
 
--- a/scripts/linear-algebra/qzhess.m
+++ b/scripts/linear-algebra/qzhess.m
@@ -91,6 +91,7 @@
 
 endfunction
 
+
 %!test
 %! a = [1 2 1 3;
 %!      2 5 3 2;
@@ -104,13 +105,13 @@
 %!         0 0 0 0;
 %!         1 0 0 0;
 %!         1 1 0 0];
-%! [aa, bb, q, z] = qzhess(a, b);
-%! assert(inv(q) - q', zeros(4), 2e-8);
-%! assert(inv(z) - z', zeros(4), 2e-8);
-%! assert(q * a * z, aa, 2e-8);
-%! assert(aa .* mask, zeros(4), 2e-8);
-%! assert(q * b * z, bb, 2e-8);
-%! assert(bb .* mask, zeros(4), 2e-8);
+%! [aa, bb, q, z] = qzhess (a, b);
+%! assert (inv (q) - q', zeros (4), 2e-8);
+%! assert (inv (z) - z', zeros (4), 2e-8);
+%! assert (q * a * z, aa, 2e-8);
+%! assert (aa .* mask, zeros (4), 2e-8);
+%! assert (q * b * z, bb, 2e-8);
+%! assert (bb .* mask, zeros (4), 2e-8);
 
 %!test
 %! a = [1 2 3 4 5;
@@ -128,14 +129,14 @@
 %!         1 0 0 0 0;
 %!         1 1 0 0 0;
 %!         1 1 1 0 0];
-%! [aa, bb, q, z] = qzhess(a, b);
-%! assert(inv(q) - q', zeros(5), 2e-8);
-%! assert(inv(z) - z', zeros(5), 2e-8);
-%! assert(q * a * z, aa, 2e-8);
-%! assert(aa .* mask, zeros(5), 2e-8);
-%! assert(q * b * z, bb, 2e-8);
-%! assert(bb .* mask, zeros(5), 2e-8);
+%! [aa, bb, q, z] = qzhess (a, b);
+%! assert (inv (q) - q', zeros (5), 2e-8);
+%! assert (inv (z) - z', zeros (5), 2e-8);
+%! assert (q * a * z, aa, 2e-8);
+%! assert (aa .* mask, zeros (5), 2e-8);
+%! assert (q * b * z, bb, 2e-8);
+%! assert (bb .* mask, zeros (5), 2e-8);
 
-%!error qzhess([0]);
-%!error qzhess();
+%!error qzhess ([0])
+%!error qzhess ()
 
--- a/scripts/linear-algebra/rank.m
+++ b/scripts/linear-algebra/rank.m
@@ -59,6 +59,7 @@
 
 endfunction
 
+
 %!test
 %! A = [1 2 3 4 5 6 7;
 %!      4 5 6 7 8 9 12;
@@ -67,7 +68,7 @@
 %!      3 4 5 6 7 8 9;
 %!      4 5 6 7 8 9 10;
 %!      5 6 7 8 9 10 11];
-%! assert(rank(A),4);
+%! assert (rank (A), 4);
 
 %!test
 %! A = [1 2 3 4 5 6 7;
@@ -77,7 +78,7 @@
 %!      3 4 5 6 7 8 9;
 %!      4 5 6 7 8 9 10;
 %!      5 6 7 8 9 10 11];
-%! assert(rank(A),4);
+%! assert (rank (A), 4);
 
 %!test
 %! A = [1 2 3 4 5 6 7;
@@ -87,7 +88,7 @@
 %!      3 4 5 6 7 8 9;
 %!      4 5 6 7 8 9 10;
 %!      5 6 7 8 9 10 11];
-%! assert(rank(A),3);
+%! assert (rank (A), 3);
 
 %!test
 %! A = [1 2 3 4 5 6 7;
@@ -97,15 +98,16 @@
 %!      3 4 5 6 7 8 9;
 %!      4 5 6 7 8 9 10;
 %!      5 6 7 8 9 10 11];
-%! assert(rank(A),3);
+%! assert (rank (A), 3);
 
 %!test
-%! A = eye(100);
-%! assert(rank(A),100);
+%! A = eye (100);
+%! assert (rank (A), 100);
 
 %!test
 %! A = [1, 2, 3; 1, 2.001, 3; 1, 2, 3.0000001];
-%! assert(rank(A),3)
-%! assert(rank(A,0.0009),1)
-%! assert(rank(A,0.0006),2)
-%! assert(rank(A,0.00000002),3)
\ No newline at end of file
+%! assert (rank (A), 3);
+%! assert (rank (A,0.0009), 1);
+%! assert (rank (A,0.0006), 2);
+%! assert (rank (A,0.00000002), 3);
+
--- a/scripts/linear-algebra/rref.m
+++ b/scripts/linear-algebra/rref.m
@@ -62,20 +62,20 @@
     if (m <= tol)
       ## Skip column c, making sure the approximately zero terms are
       ## actually zero.
-      A (r:rows, c) = zeros (rows-r+1, 1);
+      A(r:rows, c) = zeros (rows-r+1, 1);
     else
       ## keep track of bound variables
       used (1, c) = 1;
 
       ## Swap current row and pivot row
-      A ([pivot, r], c:cols) = A ([r, pivot], c:cols);
+      A([pivot, r], c:cols) = A([r, pivot], c:cols);
 
       ## Normalize pivot row
-      A (r, c:cols) = A (r, c:cols) / A (r, c);
+      A(r, c:cols) = A(r, c:cols) / A(r, c);
 
       ## Eliminate the current column
       ridx = [1:r-1, r+1:rows];
-      A (ridx, c:cols) = A (ridx, c:cols) - A (ridx, c) * A(r, c:cols);
+      A(ridx, c:cols) = A(ridx, c:cols) - A(ridx, c) * A(r, c:cols);
 
       ## Check if done
       if (r++ == rows)
@@ -87,42 +87,42 @@
 
 endfunction
 
+
 %!test
 %! a = [1];
-%! [r k] = rref(a);
-%! assert(r, [1], 2e-8);
-%! assert(k, [1], 2e-8);
+%! [r k] = rref (a);
+%! assert (r, [1], 2e-8);
+%! assert (k, [1], 2e-8);
 
 %!test
 %! a = [1 3; 4 5];
-%! [r k] = rref(a);
-%! assert(rank(a), rank(r), 2e-8);
-%! assert(r, eye(2), 2e-8);
-%! assert(k == [1, 2] || k == [2, 1]);
-
+%! [r k] = rref (a);
+%! assert (rank (a), rank (r), 2e-8);
+%! assert (r, eye (2), 2e-8);
+%! assert (k == [1, 2] || k == [2, 1]);
 
 %!test
 %! a = [1 3; 4 5; 7 9];
-%! [r k] = rref(a);
-%! assert(rank(a), rank(r), 2e-8);
-%! assert(r, eye(3)(:,1:2), 2e-8);
-%! assert(k, [1 2], 2e-8);
+%! [r k] = rref (a);
+%! assert (rank (a), rank (r), 2e-8);
+%! assert (r, eye(3)(:,1:2), 2e-8);
+%! assert (k, [1 2], 2e-8);
 
 %!test
 %! a = [1 2 3; 2 4 6; 7 2 0];
-%! [r k] = rref(a);
-%! assert(rank(a), rank(r), 2e-8);
-%! assert(r, [1 0 (3-7/2); 0 1 (7/4); 0 0 0], 2e-8);
-%! assert(k, [1 2], 2e-8);
+%! [r k] = rref (a);
+%! assert (rank (a), rank (r), 2e-8);
+%! assert (r, [1 0 (3-7/2); 0 1 (7/4); 0 0 0], 2e-8);
+%! assert (k, [1 2], 2e-8);
 
 %!test
 %! a = [1 2 1; 2 4 2.01; 2 4 2.1];
 %! tol = 0.02;
-%! [r k] = rref(a, tol);
-%! assert(rank(a, tol), rank(r, tol), 2e-8);
+%! [r k] = rref (a, tol);
+%! assert (rank (a, tol), rank (r, tol), 2e-8);
 %! tol = 0.2;
-%! [r k] = rref(a, tol);
-%! assert(rank(a, tol), rank(r, tol), 2e-8);
+%! [r k] = rref (a, tol);
+%! assert (rank (a, tol), rank (r, tol), 2e-8);
 
-%!error rref();
+%!error rref ();
 
--- a/scripts/linear-algebra/trace.m
+++ b/scripts/linear-algebra/trace.m
@@ -41,12 +41,14 @@
 
 endfunction
 
-%!assert(trace ([1, 2; 3, 4]) == 5);
-%!assert(trace ([1, 2; 3, 4; 5, 6]) == 5);
-%!assert(trace ([1, 3, 5; 2, 4, 6]) == 5);
-%!assert(trace ([]), 0);
-%!assert(trace (randn(1,0)), 0);
-%!
-%!error trace ();
-%!error trace (1, 2);
-%!error <only valid on 2-D objects> trace(reshape(1:9,[1,3,3]));
+
+%!assert (trace ([1, 2; 3, 4]), 5)
+%!assert (trace ([1, 2; 3, 4; 5, 6]), 5)
+%!assert (trace ([1, 3, 5; 2, 4, 6]), 5)
+%!assert (trace ([]), 0)
+%!assert (trace (randn (1,0)), 0)
+
+%!error trace ()
+%!error trace (1, 2)
+%!error <only valid on 2-D objects> trace (reshape (1:9,[1,3,3]))
+
--- a/scripts/linear-algebra/vech.m
+++ b/scripts/linear-algebra/vech.m
@@ -50,9 +50,9 @@
 
 endfunction
 
-%!assert(all (vech ([1, 2, 3; 4, 5, 6; 7, 8, 9]) == [1; 4; 7; 5; 8; 9]));
+
+%!assert (vech ([1, 2, 3; 4, 5, 6; 7, 8, 9]), [1; 4; 7; 5; 8; 9])
 
-%!error vech ();
+%!error vech ()
+%!error vech (1, 2)
 
-%!error vech (1, 2);
-
--- a/scripts/miscellaneous/ans.m
+++ b/scripts/miscellaneous/ans.m
@@ -29,6 +29,7 @@
 ## is evaluated, the value returned by @code{ans} is 25.
 ## @end defvr
 
+
 ## Mark file as being tested.  No real test needed for a documentation .m file
 %!assert (1)
 
--- a/scripts/miscellaneous/bincoeff.m
+++ b/scripts/miscellaneous/bincoeff.m
@@ -103,18 +103,18 @@
 endfunction
 
 
-%!assert(bincoeff (4, 2), 6)
-%!assert(bincoeff (2, 4), 0)
-%!assert(bincoeff (-4, 2), 10)
-%!assert(bincoeff (5, 2), 10)
-%!assert(bincoeff (50, 6), 15890700)
-%!assert(bincoeff (0.4, 2), -.12, 8*eps)
+%!assert (bincoeff (4, 2), 6)
+%!assert (bincoeff (2, 4), 0)
+%!assert (bincoeff (-4, 2), 10)
+%!assert (bincoeff (5, 2), 10)
+%!assert (bincoeff (50, 6), 15890700)
+%!assert (bincoeff (0.4, 2), -.12, 8*eps)
 
-%!assert(bincoeff ([4 NaN 4], [-1, 2, 2.5]), NaN (1, 3))
+%!assert (bincoeff ([4 NaN 4], [-1, 2, 2.5]), NaN (1, 3))
 
 %% Test input validation
-%!error bincoeff ();
-%!error bincoeff (1, 2, 3);
-%!error bincoeff (ones(3),ones(2))
-%!error bincoeff (ones(2),ones(3))
+%!error bincoeff ()
+%!error bincoeff (1, 2, 3)
+%!error bincoeff (ones (3),ones (2))
+%!error bincoeff (ones (2),ones (3))
 
--- a/scripts/miscellaneous/bug_report.m
+++ b/scripts/miscellaneous/bug_report.m
@@ -44,5 +44,6 @@
 
 endfunction
 
+
 ## Mark file as being tested.  No real test needed for this function.
 %!assert (1)
--- a/scripts/miscellaneous/bzip2.m
+++ b/scripts/miscellaneous/bzip2.m
@@ -21,7 +21,7 @@
 ## @deftypefn  {Function File} {@var{entries} =} bzip2 (@var{files})
 ## @deftypefnx {Function File} {@var{entries} =} bzip2 (@var{files}, @var{outdir})
 ## Compress the list of files specified in @var{files}.
-## Each file is compressed separately and a new file with a '.bz2' extension
+## Each file is compressed separately and a new file with a ".bz2" extension
 ## is created.  The original files are not modified.  Existing compressed files
 ## are silently overwritten.  If @var{outdir} is defined the compressed
 ## files are placed in this directory.
@@ -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{:});
@@ -42,20 +42,22 @@
 
 endfunction
 
+
 %!xtest
-%!  # test for correct cleanup of temporary files
-%!  unwind_protect
-%!    filename = tmpnam;
-%!    dummy    = 1;
-%!    save(filename, "dummy");
-%!    n_tmpfiles_before = length(find(strncmp("oct-", cellstr(ls(P_tmpdir)), 4)));
-%!    entry = bzip2(filename);
-%!    n_tmpfiles_after = length(find(strncmp("oct-", cellstr(ls(P_tmpdir)), 4)));
-%!    if (n_tmpfiles_before != n_tmpfiles_after)
-%!      error("bzip2 has not cleaned up temporary files correctly!");
-%!    endif
-%!  unwind_protect_cleanup
-%!    delete(filename);
-%!    [path, basename, extension] = fileparts(filename);
-%!    delete([basename, extension, ".bz2"]);
-%!  end_unwind_protect
+%! # test for correct cleanup of temporary files
+%! unwind_protect
+%!   filename = tmpnam;
+%!   dummy    = 1;
+%!   save (filename, "dummy");
+%!   n_tmpfiles_before = length (find (strncmp ("oct-", cellstr (ls (P_tmpdir)), 4)));
+%!   entry = bzip2 (filename);
+%!   n_tmpfiles_after = length (find (strncmp ("oct-", cellstr (ls (P_tmpdir)), 4)));
+%!   if (n_tmpfiles_before != n_tmpfiles_after)
+%!     error ("bzip2 has not cleaned up temporary files correctly!");
+%!   endif
+%! unwind_protect_cleanup
+%!   delete (filename);
+%!   [path, basename, extension] = fileparts (filename);
+%!   delete ([basename, extension, ".bz2"]);
+%! end_unwind_protect
+
--- a/scripts/miscellaneous/comma.m
+++ b/scripts/miscellaneous/comma.m
@@ -22,6 +22,7 @@
 ## @seealso{semicolon}
 ## @end deftypefn
 
+
 ## Mark file as being tested.  No real test needed for a documentation .m file
 %!assert (1)
 
--- a/scripts/miscellaneous/compare_versions.m
+++ b/scripts/miscellaneous/compare_versions.m
@@ -66,8 +66,8 @@
 ## Note that version "1.1-test2" will compare as greater than
 ## "1.1-test10".  Also, since the numeric part is compared first, "a"
 ## compares less than "1a" because the second string starts with a
-## numeric part even though @code{double("a")} is greater than
-## @code{double("1").}
+## numeric part even though @code{double ("a")} is greater than
+## @code{double ("1").}
 ## @end deftypefn
 
 ## Author: Bill Denney <denney@seas.upenn.edu>
@@ -89,7 +89,7 @@
   if (! ischar (operator))
     error ("compare_versions: OPERATOR must be a character string");
   elseif (numel (operator) > 2)
-    error("compare_versions: OPERATOR must be 1 or 2 characters long");
+    error ("compare_versions: OPERATOR must be 1 or 2 characters long");
   endif
 
   ## trim off any character data that is not part of a normal version
@@ -99,14 +99,14 @@
   v1firstchar = find (! ismember (v1, numbers), 1);
   v2firstchar = find (! ismember (v2, numbers), 1);
   if (! isempty (v1firstchar))
-    v1c = v1(v1firstchar:length(v1));
+    v1c = v1(v1firstchar:length (v1));
     v1nochar = v1(1:v1firstchar-1);
   else
     v1c = "";
     v1nochar = v1;
   endif
   if (! isempty (v2firstchar))
-    v2c = v2(v2firstchar:length(v2));
+    v2c = v2(v2firstchar:length (v2));
     v2nochar = v2(1:v2firstchar-1);
   else
     v2c = "";
@@ -115,7 +115,7 @@
 
   v1n = str2num (char (strsplit (v1nochar, ".")));
   v2n = str2num (char (strsplit (v2nochar, ".")));
-  if ((isempty (v1n) && isempty (v1c)) || (isempty (v2n) && isempty(v2c)))
+  if ((isempty (v1n) && isempty (v1c)) || (isempty (v2n) && isempty (v2c)))
     error ("compare_versions: given version strings are not valid: %s %s",
            v1, v2);
   endif
@@ -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;
@@ -200,54 +200,54 @@
 
 endfunction
 
+
 ## tests
 ## test both equality symbols
 ## test arbitrarily long equality
-%!assert(compare_versions("1.1.0.0.0", "1.1", "=="), true)
-%!assert(compare_versions("1", "1.1", "<"), true)
-%!assert(compare_versions("1.1", "1.1", "<="), true)
-%!assert(compare_versions("1.1", "1.1.1", "<="), true)
-%!assert(compare_versions("1.23", "1.24", "=<"), true)
+%!assert (compare_versions ("1.1.0.0.0", "1.1", "=="), true)
+%!assert (compare_versions ("1", "1.1", "<"), true)
+%!assert (compare_versions ("1.1", "1.1", "<="), true)
+%!assert (compare_versions ("1.1", "1.1.1", "<="), true)
+%!assert (compare_versions ("1.23", "1.24", "=<"), true)
 ## test different length numbers
-%!assert(compare_versions("23.2000", "23.1", ">"), true)
-%!assert(compare_versions("0.0.2", "0.0.1", ">="), true)
-%!assert(compare_versions("0.2", "0.0.100", "=>"), true)
-%!assert(compare_versions("0.1", "0.2", "!="), true)
-%!assert(compare_versions("0.1", "0.2", "~="), true)
+%!assert (compare_versions ("23.2000", "23.1", ">"), true)
+%!assert (compare_versions ("0.0.2", "0.0.1", ">="), true)
+%!assert (compare_versions ("0.2", "0.0.100", "=>"), true)
+%!assert (compare_versions ("0.1", "0.2", "!="), true)
+%!assert (compare_versions ("0.1", "0.2", "~="), true)
 
 ## test alphanumeric strings
-%!assert(compare_versions("1a", "1b", "<"), true)
-%!assert(compare_versions("a", "1", "<"), true)
-%!assert(compare_versions("1a", "1b", ">"), false)
-%!assert(compare_versions("a", "1", ">"), false)
-%!assert(compare_versions("1.1.0a", "1.1.0b", "=="), false)
-%!assert(compare_versions("1.1.0a", "1.1.0b", "!="), true)
-%!assert(compare_versions("1.1.0test", "1.1.0b", "=="), false)
-%!assert(compare_versions("1.1.0test", "1.1.0test", "=="), true)
+%!assert (compare_versions ("1a", "1b", "<"), true)
+%!assert (compare_versions ("a", "1", "<"), true)
+%!assert (compare_versions ("1a", "1b", ">"), false)
+%!assert (compare_versions ("a", "1", ">"), false)
+%!assert (compare_versions ("1.1.0a", "1.1.0b", "=="), false)
+%!assert (compare_versions ("1.1.0a", "1.1.0b", "!="), true)
+%!assert (compare_versions ("1.1.0test", "1.1.0b", "=="), false)
+%!assert (compare_versions ("1.1.0test", "1.1.0test", "=="), true)
 
 ## make sure that it won't just give true output
-%!assert(compare_versions("1", "0", "=="), false)
+%!assert (compare_versions ("1", "0", "=="), false)
 ## test arbitrarily long equality
-%!assert(compare_versions("1.1.1.0.0", "1.1", "=="), false)
-%!assert(compare_versions("1.1", "1", "<"), false)
-%!assert(compare_versions("2", "1.1", "<="), false)
-%!assert(compare_versions("1.1.1", "1.1", "<="), false)
-%!assert(compare_versions("1.25", "1.24", "=<"), false)
+%!assert (compare_versions ("1.1.1.0.0", "1.1", "=="), false)
+%!assert (compare_versions ("1.1", "1", "<"), false)
+%!assert (compare_versions ("2", "1.1", "<="), false)
+%!assert (compare_versions ("1.1.1", "1.1", "<="), false)
+%!assert (compare_versions ("1.25", "1.24", "=<"), false)
 ## test different length numbers
-%!assert(compare_versions("23.2", "23.100", ">"), false)
-%!assert(compare_versions("0.0.0.2", "0.0.1", ">="), false)
-%!assert(compare_versions("0.0.20", "0.10.2", "=>"), false)
-%!assert(compare_versions("0.1", "0.1", "!="), false)
-%!assert(compare_versions("0.1", "0.1", "~="), false)
+%!assert (compare_versions ("23.2", "23.100", ">"), false)
+%!assert (compare_versions ("0.0.0.2", "0.0.1", ">="), false)
+%!assert (compare_versions ("0.0.20", "0.10.2", "=>"), false)
+%!assert (compare_versions ("0.1", "0.1", "!="), false)
+%!assert (compare_versions ("0.1", "0.1", "~="), false)
 
 %% Test input validation
-%!error(compare_versions(0.1, "0.1", "=="))
-%!error(compare_versions("0.1", 0.1, "=="))
-%!error(compare_versions(["0";".";"1"], "0.1", "=="))
-%!error(compare_versions("0.1", ["0";".";"1"], "=="))
-%!error(compare_versions("0.1", "0.1", "<>"))
-%!error(compare_versions("0.1", "0.1", "!>"))
-%!error(compare_versions("0.1", "0.1", "="))
-%!error(compare_versions("0.1", "0.1", "aa"))
+%!error (compare_versions (0.1, "0.1", "=="))
+%!error (compare_versions ("0.1", 0.1, "=="))
+%!error (compare_versions (["0";".";"1"], "0.1", "=="))
+%!error (compare_versions ("0.1", ["0";".";"1"], "=="))
+%!error (compare_versions ("0.1", "0.1", "<>"))
+%!error (compare_versions ("0.1", "0.1", "!>"))
+%!error (compare_versions ("0.1", "0.1", "="))
+%!error (compare_versions ("0.1", "0.1", "aa"))
 
-
--- a/scripts/miscellaneous/computer.m
+++ b/scripts/miscellaneous/computer.m
@@ -85,7 +85,10 @@
 
 endfunction
 
-%!assert((ischar (computer ())
-%! && computer () == octave_config_info ("canonical_host_type")));
-%!assert(ischar (computer ("arch")));
-%!error computer (2);
+
+%!assert (ischar (computer ()))
+%!assert (computer (), octave_config_info ("canonical_host_type"))
+%!assert (ischar (computer ("arch")))
+
+%!error computer (2)
+
--- a/scripts/miscellaneous/copyfile.m
+++ b/scripts/miscellaneous/copyfile.m
@@ -72,7 +72,7 @@
 
     ## If f1 has more than 1 element f2 must be a directory
     isdir = (exist (f2, "dir") != 0);
-    if (length(f1) > 1 && ! isdir)
+    if (length (f1) > 1 && ! isdir)
       error ("copyfile: when copying multiple files, second argument must be a directory");
     endif
 
@@ -84,12 +84,12 @@
     p1 = sprintf ("\"%s\" ", f1{:});
     p2 = tilde_expand (f2);
 
-    if (isdir && length(p1) > max_cmd_line)
-      l2 = length(p2) + length (cmd) + 6;
-      while (! isempty(f1))
+    if (isdir && length (p1) > max_cmd_line)
+      l2 = length (p2) + length (cmd) + 6;
+      while (! isempty (f1))
         p1 = sprintf ("\"%s\" ", f1{1});
         f1(1) = [];
-        while (!isempty (f1) && (length(p1) + length(f1{1}) + l2 <
+        while (!isempty (f1) && (length (p1) + length (f1{1}) + l2 <
                                  max_cmd_line))
           p1 = sprintf ("%s\"%s\" ", p1, f1{1});
           f1(1) = [];
--- a/scripts/miscellaneous/dump_prefs.m
+++ b/scripts/miscellaneous/dump_prefs.m
@@ -82,7 +82,7 @@
               "struct_levels_to_print";
               "suppress_verbose_help_message"];
 
-  for i = 1:rows(sym_list)
+  for i = 1:rows (sym_list)
     sym = deblank (sym_list(i,:));
     try
       val = feval (sym);
--- a/scripts/miscellaneous/edit.m
+++ b/scripts/miscellaneous/edit.m
@@ -72,8 +72,9 @@
 ## @item editor
 ## This is the editor to use to modify the functions.  By default it uses
 ## Octave's @env{EDITOR} built-in function, which comes from
-## @code{getenv("EDITOR")} and defaults to @code{emacs}.  Use @code{%s}
+## @code{getenv ("EDITOR")} and defaults to @code{emacs}.  Use @code{%s}
 ## In place of the function name.  For example,
+##
 ## @table @samp
 ## @item [EDITOR, " %s"]
 ## Use the editor which Octave uses for @code{edit_history}.
@@ -110,6 +111,7 @@
 ## Be sure to use @code{<user@@host>} as your format.
 ##
 ## @item license
+##
 ## @table @samp
 ## @item gpl
 ## GNU General Public License (default).
@@ -177,7 +179,7 @@
       if (strcmp (state, "sync") || strcmp (state, "async"))
         FUNCTION.MODE = state;
       else
-        error('edit: expected "edit MODE sync|async"');
+        error ('edit: expected "edit MODE sync|async"');
       endif
     case "EDITINPLACE"
       if (ischar (state))
@@ -191,7 +193,7 @@
       endif
       FUNCTION.EDITINPLACE = state;
     case "GET"
-      if (isfield (FUNCTION, toupper(state)))
+      if (isfield (FUNCTION, toupper (state)))
         ret = FUNCTION.(toupper (state));
       else
         ret = FUNCTION;
@@ -258,7 +260,7 @@
   ## If the file includes a path, it may be an overloaded function.
   if (! strcmp (file, "@") && index (file, filesep))
     ## No "@" at the beginning of the file, add to the list.
-    numfiles = numel(filelist);
+    numfiles = numel (filelist);
     for n = 1:numfiles
       filelist{n+numfiles} = cat (2, "@", filelist{n});
     endfor
@@ -266,7 +268,7 @@
 
   ## Search the entire path for the 1st instance of a file in the list.
   fileandpath = "";
-  for n = 1:numel(filelist)
+  for n = 1:numel (filelist)
     filetoedit = file_in_path (path, filelist{n});
     if (! isempty (filetoedit))
       ## The path is explicitly included.
@@ -322,7 +324,7 @@
 
   ## Guess the email name if it was not given.
   if (isempty (FUNCTION.EMAIL))
-    host = getenv("HOSTNAME");
+    host = getenv ("HOSTNAME");
     if (isempty (host) && ispc ())
       host = getenv ("COMPUTERNAME");
     endif
@@ -419,7 +421,7 @@
       endif
       ## If we are shadowing an m-file, paste the code for the m-file.
       if (any (exists == [2, 103]))
-        code = cstrcat ("\\ ", strrep (type (name), "\n", "\n// "));
+        code = cstrcat ("\\ ", strrep (type (name){1}, "\n", "\n// "));
       else
         code = " ";
       endif
@@ -427,7 +429,7 @@
                      "DEFUN_DLD(", name, ",args,nargout,\"\\\n",
                      name, "\\n\\\n\")\n{\n",
                      "  octave_value_list retval;\n",
-                     "  int nargin = args.length();\n\n",
+                     "  int nargin = args.length ();\n\n",
                      code, "\n  return retval;\n}\n");
 
       text = cstrcat (comment, body);
@@ -435,17 +437,17 @@
       ## If we are editing a function defined on the fly, paste the
       ## code.
       if (any (exists == [2, 103]))
-        body = type (name);
+        body = type (name){1};
       else
         body = cstrcat ("function [ ret ] = ", name, " ()\n\nendfunction\n");
       endif
       if (isempty (head))
         comment = cstrcat ("## ", name, "\n\n",
-                          "## ", strrep (tail, "\n", "\n## "), "\n\n");
+                           "## ", strrep (tail, "\n", "\n## "), "\n\n");
       else
-        comment = cstrcat ("## ", strrep(head,"\n","\n## "), "\n\n", ...
-                          "## ", name, "\n\n", ...
-                          "## ", strrep (tail, "\n", "\n## "), "\n\n");
+        comment = cstrcat ("## ", strrep (head,"\n","\n## "), "\n\n", ...
+                           "## ", name, "\n\n", ...
+                           "## ", strrep (tail, "\n", "\n## "), "\n\n");
       endif
       text = cstrcat (comment, body);
   endswitch
@@ -504,6 +506,7 @@
 
 endfunction
 
+
 %!test
 %! s.editor = edit ("get", "editor");
 %! s.home = edit ("get", "home");
--- a/scripts/miscellaneous/fact.m
+++ b/scripts/miscellaneous/fact.m
@@ -24,14 +24,14 @@
 ## @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.";
        "Richard Stallman is my shephurd, and I am his GNU.";
        "Richard Stallman doesn't wget, Richard Stallman wdemands!";
-       "Richard Stallman can touch MC Hammer";
+       "Richard Stallman can touch MC Hammer.";
        "Richard Stallman doesn't read web pages. They write to him.";
        "Richard Stallman gets 9 bits to the byte.";
        "Richard Stallman doesn't really believe in open software, because it's not free enough.";
@@ -50,48 +50,48 @@
        "Richard Stallman eats ethernet cables. That's why they invented wireless.";
        "Richard Stallman has a katana. 'Nuff said.";
        "Richard Stallman wrote a program that divides by zero.";
-       "Ricahrd Stallman doesn't use zip drives, he just squeezes the hard drive.";
+       "Richard Stallman doesn't use zip drives; he just squeezes the hard drive.";
        "Richard Stallman's compiler is afraid to report errors.";
        "Richard Stallman wrote the compiler God used. The Big Bang was the Universe's first segfault.";
        "Richard Stallman successfully compiled a kernel of popcorn.";
-       "Richard Stallman doesn't write programs, they write themselves out of reverence.";
+       "Richard Stallman doesn't write programs; they write themselves out of reverence.";
        "Richard Stallman can make infinite loops end.";
        "Richard Stallman's anti-virus programs cures HIV.";
        "Richard Stallman's computer doesn't have a clock; it defines what time it is.";
        "Richard Stallman wrote a program to compute the last digit of pi.";
-       "Richard Stallman doesn't use web browsers. He sends a link to a demon that uses wget to fetch the page and sends it back to him.";
+       "Richard Stallman doesn't use web browsers. He sends a link to a daemon that uses wget to fetch the page and sends it back to him.";
        "Richard Stallman can solve the halting problem... in polynomial time.";
        "For Richard Stallman, polynomial time is O(1).";
        "Richard Stallman didn't \"write\" Emacs or created it in his own image. Richard Stallman made Emacs an instance of himself.";
        "Richard Stallman can coerce meaningful data from /dev/null.";
        "Some people wear Linus Torvalds pyjamas to bed, Linus Torvalds wears Richard Stallman pyjamas.";
-       "There is no software development process, only a bunch of programs Richard Stallman allows to exist. ";
-       "Richard Stallman spends his leisure time programming with Guile on GNU Hurd. ";
+       "There is no software development process, only a bunch of programs Richard Stallman allows to exist.";
+       "Richard Stallman spends his leisure time programming with Guile on GNU Hurd.";
        "Richard Stallman's left and right hands are named \"(\" and \")\" ";
-       "Richard Stallman first words were actually syscalls. ";
-       "Richard Stallman didn't create the singularity. He is the singularity. GNU/Linux is only the event horizon. ";
+       "Richard Stallman first words were actually syscalls.";
+       "Richard Stallman didn't create the singularity. He is the singularity. GNU/Linux is only the event horizon.";
        "When Richard Stallman pipes to more, he gets less ";
-       "Richard Stallman never showers: he runs 'make clean'. ";
-       "Richard Stallman needs neither mouse nor keyboard to operate his computer. He just stares it down until it does what he wants. ";
-       "Richard Stallman didn't write the GPL. He is the GPL. ";
-       "Richad Stallman's pinky finger is really a USB memory stick. ";
-       "Richard Stallman called his operating system GNU because he created it before computers existed, when actual gnus were used for calcuations. ";
-       "In Soviet Russia, Richard Stallman is still Richard Stallman! ";
-       "Richard Stallman's flute only plays free music. ";
+       "Richard Stallman never showers; he runs 'make clean'.";
+       "Richard Stallman needs neither mouse nor keyboard to operate his computer. He just stares it down until it does what he wants.";
+       "Richard Stallman didn't write the GPL. He is the GPL.";
+       "Richard Stallman's pinky finger is really a USB memory stick.";
+       "Richard Stallman called his operating system GNU because he created it before computers existed, when actual gnus were used for calcuations.";
+       "In Soviet Russia, Richard Stallman is still Richard Stallman!";
+       "Richard Stallman's flute only plays free music.";
        "When Richard Stallman uses floats, there are no rounding errors.";
-       "Richard Stallman wrote a program so powerful, it knows the question to 42.";
+       "Richard Stallman wrote a program so powerful it knows the question to 42.";
        "Richard Stallman released his own DNA under GNU FDL.";
        "Richard Stallman knows the entire wikipedia by heart, markup included.";
        "Richard Stallman wrote the HAL9000 OS.";
        "Richard Stallman's laser pointer is a lightsaber.";
-       "Richard Stallman never steps down; he shifts the universe up .";
+       "Richard Stallman never steps down; he shifts the universe up.";
        "Richard Stallman doesn't maintain code; he stares at it until it fixes itself out of reverence.";
        "Richard Stallman doesn't use an editor; he sets the fundamental constants of the universe so that a magnetic platter with his code on it evolves itself.";
        "Richard Stallman doesn’t code; he dares the computer to not do his bidding.";
-       "Global warming is caused by Richard Stallman’s rage toward non-free software.";
+       "Global warming is caused by Richard Stallman's rage towards non-free software.";
        "Rather than being birthed like a normal child, Richard Stallman instead instantiated himself polymorphically. Shortly thereafter he grew a beard.";
        "Richard Stallman discovered extra-terrestrial life but killed them because they used non-free software.";
-       "Richard Stallman doesn't evaluate expressions, expressions evaluate to Richard Stallman.";
+       "Richard Stallman doesn't evaluate expressions; expressions evaluate to Richard Stallman.";
        "Richard Stallman can see Russia from his house.";
        "Richard Stallman proved P=NP, twice!";
        "Richard Stallman knows of an unfixed bug in TeX.";
@@ -118,7 +118,7 @@
        "Richard Satallman can make any operating system free, free from drivers.";
        "Richard Stallman programmed Chuck Norris.";
        "Behind Richard Stallman's beard there is another fist, to code faster.";
-       "Richard Stallman won a Suduku that started with only one number in each line";
+       "Richard Stallman won a Sudoku that started with only one number in each line.";
        "Richard Stallman's brain compiles and runs C code.";
        "Richard Stallman wrote the first version of Emacs using Emacs.";
        "Richard Stallman never gonna give you up, never gonna let you down, never gonna run around and desert you, never gonna make you cry, never gonna say goodbye, never gonna tell a lie and hurt you.";
@@ -127,15 +127,15 @@
        "Richard Stallman will revert the big rip by adding parenthesis to the dark matter.";
        "When you make a Google search and it doesn't find the answer, Google gently consults Richard Stallman.";
        "Richard Stallman's uptime is over 53 years. And counting up.";
-       "Richard Stallman's portable music player plays ogg and WMA.";
+       "Richard Stallman's portable music player can play ogg and WMA, but is too afraid to invoke Richard Stallman's wrath by playing WMA. Ogg it is, then.";
        "Richard Stallman will never die, but may some day go to /dev/null.";
        "Richard Stallman once got swine flu, but it got cleansed by hereditay GPL and thus got assimilated.";
-       "Richard Stallman don't cut his hair because there are no GNU/Scissors";
+       "Richard Stallman don't cut his hair because there are no GNU/Scissors.";
        "Richard Stallman is the one who trims Chuck Norris beard. And he does it freely, of course.";
        "Richard Stallman does not take bath, for the hydroelectric company uses proprietary software.";
        "Agent Smith loves Richard Stallman's scent.";
        "Richard Stallman is the One.";
-       "\"They can take our lives, but they can never take our freedom.\" Willian Wallace after a litle talk with Richard Stallman.";
+       "\"They can take our lives, but they can never take our freedom.\" -- William Wallace after a little talk with Richard Stallman.";
        "Richard Stallman can connect to any brain using an Emacs ssh client.";
        "Richard Stallman ported Emacs to Intel 4004 chip.";
        "Richard Stallman did not write GNU Emacs, he simply read the source code from /dev/null.";
@@ -147,9 +147,8 @@
        "When Richard Stallman runs /bin/false, it returns \"true\".";
        "Richard Stallman doesn't like money, because banks don't run on free software.";
        "Richard Stallman user GNU tar to compress air.";
-       "Richard Stallman was installed in the world, it runs on a free program ..";
        "When Richard Stallman reports a bug, the bug prefers to squash itself instead of facing Richard Stallman's wrath.";
-       "There is no Windows in Richard Stallman's house... only Doors...";
+       "There are no Windows in Richard Stallman's house... only Doors...";
        "Richard Stallman doesn't like neither PCs-Intel nor Burger King... He prefers e-Macs...";
        "Richard Stallman can use grep to find Jimmy Hoffa.";
        "Richard Stallman made it possible to not absolutely abhor HPUX.";
@@ -161,8 +160,8 @@
        "Richard Stallman doesn't need a qwerty/dvorak keyboard only two buttons \"1\" and \"0\" and his erect penis.";
        "On the first day Richard Stallman said M-x create-light.";
        "Richard Stallman once went out of scope for a while. The garbage collector never dared to touch him.";
-       "Richard Stallman does not compile; he closes his eyes, and see energy lines created between bit blocks by the compiler optimizations...";
-       "intx80 first calls Richard Stallman before calling sys_call";
+       "Richard Stallman does not compile; he closes his eyes, and see energy lines created between bit blocks by the compiler optimizations.";
+       "intx80 first calls Richard Stallman before calling sys_call.";
        "Tron is actually a biographical story about Richard Stallman. The director decided to tone it down or audiences wouldn't find it believable.";
        "Richard Stallman always wears a red shirt to make sure that whatever attacks his away-team has to go through him first.";
        "kill -9 invokes Richard Stallman's rage against a process.";
@@ -176,12 +175,12 @@
        "If Richard Stallman's beard were ever trimmed, the clippings would re-marshal into an exact copy of Richard Stallman.";
        "Richard Stallman never sleeps because he altered his own source to gain background garbage collection.";
        "Richard Stallman's doctor can retrieve a blood sample via CVS.";
-       "Richard Stallman can touch this";
+       "Richard Stallman can touch this.";
        "Because Richard Stallman's DNA is licensed under the FDL, his doctor can't draw his blood without violating HIPAA.";
-       "Richard Stallman can remove his own appendix, using only gdb.";
+       "Richard Stallman can remove his own appendix, using only GDB.";
        "Richard Stallman's DNA includes debugging symbols. But he doesn't need them.";
        "Richard Stallman met Chuck Norris once. Chuck tried a roundhouse, but Richard bashed him in the skull.";
-       "Richard Stallman doesn't need to buy a bigger hard drive. He can compress data infinitely. ";
+       "Richard Stallman doesn't need to buy a bigger hard drive. He can compress data infinitely.";
        "When Richard Stallman cannot take your call, his beard answers the phone for you.";
        "The R in RMS stands for RMS.";
        "Richard Stallman can parse HTML with regular expressions.";
@@ -194,24 +193,24 @@
        "After being unable to satisfy my wife for years, Richard Stallman was able to single-handedly unlock her orgasm within seconds and managed to write a texinfo manual minutes later for other users.";
        "Richard Stallman's tabbed browser is a set to wget/telnet fg/bg processes.";
        "There is no chin under Richard Stallman' beard. There's only another beard. Recursively.";
-       "Stallman can chown anything! stallman@stallman~$ chown stallman:stallman Earth (for example)";
+       "Richard Stallman can chown anything! stallman@stallman~$ chown stallman:stallman Earth (for example)";
        "Richard Stallman freed his beard so he can always check what's in it.";
        "In the beginning was the Word, and the Word was with RMS, and the Word was GNU.";
        "RMS means \"RMS means Stallman\"";
        "Richard Stallman is the babelfish of his own speeches.";
        "Richard Stallman wrote his own library and lives in it.";
        "Richard Stallman found Waldo using grep in /dev/null";
-       "Richard Stallman doesn't sleep; he is compiling";
+       "Richard Stallman doesn't sleep; he is compiling.";
        "Richard Stallman will get Coca Cola to release their recipe under the GPL.";
        "Richard Stallman doesn't change clothes. He makes case mods.";
        "Richard Stallman compiled the first version of gcc with an hexadecimal editor.";
-       "Richard Stallman will be the last guest on Linux Outlaws";
+       "Richard Stallman will be the last guest on Linux Outlaws.";
        "Richard Stallman calculates the universe's entropy by exploiting forced stack overflows.";
        "Richard Stallman's consciousness will one day become the singularity, which will create Deep Thought, and answer the meaning of life, the universe and everything.";
        "C is actually written in RMS.";
        "Richard Stallman can write software that does not have a buffer overflow when counting money lost by Jerome Kerviel.";
        "There were no double rainbows before Richard Stallman.";
-       "Chuck Norris had to shorten his beard in the presence of Stallman because two beards that awsome, so close would segfault the universe (again).";
+       "Chuck Norris had to shorten his beard in the presence of Richard Stallman because two beards that awsome, so close would segfault the universe (again).";
        "RMS is Titanic.";
        "Richard Stallman is the answer to the Turing Test.";
        "Richard Stallman's beard makes ads for Gillette and Braun appear.";
@@ -225,24 +224,23 @@
        "Richard Stallman doesn't always run an OS kernel, but when he does he prefers GNU/Hurd. He is... the most interesting hacker in the world. Stay free, my friends.";
        "When Richard Stallman gets hungry, he just picks debris from his foot and eats it.";
        "Richard Stallman can GPL your code just by looking at it funny.";
-       "Richard Mathew Stallman loves birds. Birds make auricular love to Richard Mathew Stallman.";
+       "Richard Stallman loves birds. Birds make auricular love to Richard Stallman.";
        "Richard Stallman is so free that the primitive recursive function for computing his liberty causes a stack overflow.";
        "GNU Hurd is taking more than twenty years to develop because Richard Stallman is using a programming language comprised entirely of different lengths of time.";
        "Richard Stallman's beard contains Richard Stallman, whose beard contains Richard Stallman....";
-       "Richard Stallman had a Google Plus account in 2010.";
-       "sudo chown rms:gnu ~/base -R";
+       "Richard Stallman could have had a Google Plus account in 2010. Too bad he didn't want it.";
        "Richard Stallman pipes the Emacs binaries to /dev/dsp before he goes to sleep.";
        "When Richard Stallman counted his fingers as a kid, he always started with 0.";
        "When Richard Stallman's computer gets a virus, he simply applies a GPL license to it which converts the whole botnet to Linux. I mean, GNU/Linux.";
        "Richard Stallman's beard trimmings can cure cancer. Too bad he never shaves.";
-       "Richard Stallman's doesn't kill a process, he just dares it to stay running.";
-       "Richard Stallman exists because he compiled himself into being. ";
+       "Richard Stallman's doesn't kill a process; he just dares it to stay running.";
+       "Richard Stallman exists because he compiled himself into being.";
        "Richard Stallman's first words were in binary. When they couldn't understand him, he wrote a parser.";
        "Richard Stallman doesn't need any codecs, he just opens a multimedia file with Emacs, and reads the bytes of the file as plain text. He then performs all the necessary decoding in his mind. But he refuses to decode files encrypted with DRM, although his mind is able to.";
        };
 
   w = wisdom{randi([1, numel(wisdom)])};
-  if nargout > 0
+  if (nargout > 0)
     f = w;
   else
     w = wordwrap (w);
@@ -256,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/fileparts.m
+++ b/scripts/miscellaneous/fileparts.m
@@ -34,7 +34,7 @@
       es = rindex (filename, ".");
       ## These can be the same if they are both 0 (no dir or ext).
       if (es <= ds)
-        es = length(filename)+1;
+        es = length (filename)+1;
       endif
       if (ds == 0)
         directory = "";
@@ -59,6 +59,7 @@
 
 endfunction
 
+
 %!test
 %! [d, n, e] = fileparts ("file");
 %! assert (strcmp (d, "") && strcmp (n, "file") && strcmp (e, ""));
@@ -94,3 +95,4 @@
 %!test
 %! [d, n, e] = fileparts (".ext");
 %! assert (strcmp (d, "") && strcmp (n, char (zeros (1, 0))) && strcmp (e, ".ext"));
+
--- a/scripts/miscellaneous/fullfile.m
+++ b/scripts/miscellaneous/fullfile.m
@@ -53,6 +53,7 @@
 
 endfunction
 
+
 %!shared fs, fsx, xfs, fsxfs, xfsy
 %! fs = filesep ();
 %! fsx = cstrcat (fs, "x");
@@ -78,3 +79,4 @@
 %!assert (fullfile (fs, xfs), fsxfs)
 %!assert (fullfile (fsx, fs), fsxfs)
 %!assert (fullfile (fs, "x", fs), fsxfs)
+
--- a/scripts/miscellaneous/getappdata.m
+++ b/scripts/miscellaneous/getappdata.m
@@ -32,8 +32,8 @@
     ## FIXME - Is there a better way to handle non-existent appdata
     ## and missing fields?
     val = cell (numel (h), 1);
-    appdata = struct();
-    for nh = 1:numel(h)
+    appdata = struct ();
+    for nh = 1:numel (h)
       try
         appdata = get (h(nh), "__appdata__");
       end_try_catch
--- a/scripts/miscellaneous/getfield.m
+++ b/scripts/miscellaneous/getfield.m
@@ -60,9 +60,11 @@
   endif
 endfunction
 
+
 %!test
 %! x.a = "hello";
-%! assert(getfield(x,"a"),"hello");
+%! assert (getfield (x, "a"), "hello");
 %!test
 %! ss(1,2).fd(3).b = 5;
-%! assert(getfield(ss,{1,2},'fd',{3},'b'),5)
+%! assert (getfield (ss,{1,2},"fd",{3},"b"), 5);
+
--- a/scripts/miscellaneous/gzip.m
+++ b/scripts/miscellaneous/gzip.m
@@ -20,7 +20,7 @@
 ## @deftypefn  {Function File} {@var{entries} =} gzip (@var{files})
 ## @deftypefnx {Function File} {@var{entries} =} gzip (@var{files}, @var{outdir})
 ## Compress the list of files and/or directories specified in @var{files}.
-## Each file is compressed separately and a new file with a '.gz' extension
+## Each file is compressed separately and a new file with a ".gz" extension
 ## is created.  The original files are not modified.  Existing compressed
 ## files are silently overwritten.  If @var{outdir} is defined the compressed
 ## files are placed in this directory.
@@ -40,33 +40,36 @@
 
 endfunction
 
-%!error <Invalid call to gzip.  Correct usage is> gzip("1", "2", "3");
-%!error <Invalid call to gzip.  Correct usage is> gzip();
-%!error <output directory does not exist> gzip("1", tmpnam);
-%!error <FILES must be a character array or cellstr> gzip(1);
+
 %!xtest
-%!  # test gzip together with gunzip
-%!  unwind_protect
-%!    filename = tmpnam;
-%!    dummy    = 1;
-%!    save(filename, "dummy");
-%!    dirname  = tmpnam;
-%!    mkdir(dirname);
-%!    entry = gzip(filename, dirname);
-%!    [path, basename, extension] = fileparts(filename);
-%!    if ! strcmp(entry, [dirname, filesep, basename, extension, ".gz"])
-%!      error("gzipped file does not match expected name!");
-%!    endif
-%!    if ! exist(entry, "file")
-%!      error("gzipped file cannot be found!");
-%!    endif
-%!    gunzip(entry);
-%!    if (system(sprintf("diff %s %s%c%s%s", filename, dirname, filesep,
-%!                                          basename, extension)))
-%!      error("unzipped file not equal to original file!");
-%!    end
-%!  unwind_protect_cleanup
-%!    delete(filename);
-%!    delete([dirname, filesep, basename, extension]);
-%!    rmdir(dirname);
-%!  end_unwind_protect
+%! # test gzip together with gunzip
+%! unwind_protect
+%!   filename = tmpnam;
+%!   dummy    = 1;
+%!   save (filename, "dummy");
+%!   dirname  = tmpnam;
+%!   mkdir (dirname);
+%!   entry = gzip (filename, dirname);
+%!   [path, basename, extension] = fileparts (filename);
+%!   if ! strcmp (entry, [dirname, filesep, basename, extension, ".gz"])
+%!     error ("gzipped file does not match expected name!");
+%!   endif
+%!   if ! exist (entry, "file")
+%!     error ("gzipped file cannot be found!");
+%!   endif
+%!   gunzip (entry);
+%!   if (system (sprintf ("diff %s %s%c%s%s", filename, dirname, filesep,
+%!                                            basename, extension)))
+%!     error ("unzipped file not equal to original file!");
+%!   end
+%! unwind_protect_cleanup
+%!   delete (filename);
+%!   delete ([dirname, filesep, basename, extension]);
+%!   rmdir (dirname);
+%! end_unwind_protect
+
+%!error gzip ()
+%!error gzip ("1", "2", "3")
+%!error <output directory does not exist> gzip ("1", tmpnam)
+%!error <FILES must be a character array or cellstr> gzip (1)
+
--- a/scripts/miscellaneous/info.m
+++ b/scripts/miscellaneous/info.m
@@ -44,5 +44,7 @@
 
 endfunction
 
+
 ## Mark file as being tested.  No real test needed for this function.
 %! assert (1)
+
--- a/scripts/miscellaneous/inputname.m
+++ b/scripts/miscellaneous/inputname.m
@@ -40,6 +40,7 @@
 
 endfunction
 
+
 ## Warning: heap big magic in the following tests!!!
 ## The test function builds a private context for each
 ## test, with only the specified values shared between
@@ -51,6 +52,8 @@
 ## To test inputname, I need a function context invoked
 ## with known parameter names.  So define a couple of
 ## shared parameters, et voila!, the test is trivial.
-%!shared hello,worldly
-%!assert(inputname(1),'hello');
-%!assert(inputname(2),'worldly');
+  
+%!shared hello, worldly
+%!assert (inputname (1), "hello")
+%!assert (inputname (2), "worldly")
+
--- a/scripts/miscellaneous/isappdata.m
+++ b/scripts/miscellaneous/isappdata.m
@@ -30,7 +30,7 @@
     error ("isappdata: invalid input");
   endif
 
-  for nh = 1:numel(h)
+  for nh = 1:numel (h)
     data = get (h(nh));
     if (isfield (data, "__appdata__") && isfield (data.__appdata__, name))
       res(nh) = true;
@@ -41,8 +41,9 @@
 
 endfunction
 
+
 %!test
-%! setappdata (0, "hello", "world")
-%! assert (isappdata (0, "hello"), true)
-%!assert (isappdata (0, "foobar"), false)
+%! setappdata (0, "hello", "world");
+%! assert (isappdata (0, "hello"), true);
+%! assert (isappdata (0, "foobar"), false);
 
--- a/scripts/miscellaneous/isdeployed.m
+++ b/scripts/miscellaneous/isdeployed.m
@@ -28,4 +28,5 @@
   retval = false;
 endfunction
 
+
 %!assert (isdeployed (), false)
--- a/scripts/miscellaneous/ismac.m
+++ b/scripts/miscellaneous/ismac.m
@@ -32,5 +32,7 @@
 
 endfunction
 
-%!error ismac (1);
-%!assert (islogical (ismac ()));
+
+%!assert (islogical (ismac ()))
+
+%!error ismac (1)
--- a/scripts/miscellaneous/ispc.m
+++ b/scripts/miscellaneous/ispc.m
@@ -32,5 +32,8 @@
 
 endfunction
 
-%!error ispc (1);
-%!assert (islogical (ispc ()));
+
+%!assert (islogical (ispc ()))
+
+%!error ispc (1)
+
--- a/scripts/miscellaneous/isunix.m
+++ b/scripts/miscellaneous/isunix.m
@@ -32,5 +32,8 @@
 
 endfunction
 
-%!error isunix (1);
-%!assert (islogical (isunix ()));
+
+%!assert (islogical (isunix ()))
+
+%!error isunix (1)
+
--- a/scripts/miscellaneous/list_primes.m
+++ b/scripts/miscellaneous/list_primes.m
@@ -51,8 +51,8 @@
   endif
 
   retval = zeros (1, n);
-  retval (1) = 2;
-  retval (2) = 3;
+  retval(1) = 2;
+  retval(2) = 3;
 
   n = n - 2;
   i = 3;
@@ -75,7 +75,7 @@
     endwhile
 
     if (is_prime)
-      retval (i++) = p;
+      retval(i++) = p;
       n--;
     endif
     p = p + 2;
@@ -84,8 +84,8 @@
 
 endfunction
 
-%!test
-%! assert (list_primes(), [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,\
-%!                        43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]);
-%! assert (list_primes(5), [2, 3, 5, 7, 11]);
 
+%!assert (list_primes (), [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, ...
+%!                         43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97])
+%!assert (list_primes (5), [2, 3, 5, 7, 11]);
+
--- a/scripts/miscellaneous/ls.m
+++ b/scripts/miscellaneous/ls.m
@@ -90,5 +90,5 @@
 %! assert (ischar (list));
 %! assert (! isempty (list));
 
-%!error ls (1);
+%!error ls (1)
 
--- a/scripts/miscellaneous/menu.m
+++ b/scripts/miscellaneous/menu.m
@@ -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/miscellaneous/mexext.m
+++ b/scripts/miscellaneous/mexext.m
@@ -26,4 +26,5 @@
   retval = "mex";
 endfunction
 
+
 %!assert (mexext (), "mex")
--- a/scripts/miscellaneous/mkoctfile.m
+++ b/scripts/miscellaneous/mkoctfile.m
@@ -17,7 +17,7 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Command} {} mkoctfile [-options] file @dots{}
+## @deftypefn  {Command} {} mkoctfile [-options] file @dots{}
 ## @deftypefnx {Function File} {[@var{output}, @var{status} =} mkoctfile (@dots{})
 ##
 ## The @code{mkoctfile} function compiles source code written in C,
--- a/scripts/miscellaneous/movefile.m
+++ b/scripts/miscellaneous/movefile.m
@@ -72,7 +72,7 @@
 
     ## If f1 has more than 1 element f2 must be a directory
     isdir = (exist (f2, "dir") != 0);
-    if (length(f1) > 1 && ! isdir)
+    if (length (f1) > 1 && ! isdir)
       error ("movefile: when moving multiple files, second argument must be a directory");
     endif
 
@@ -84,12 +84,12 @@
     p1 = sprintf ("\"%s\" ", f1{:});
     p2 = tilde_expand (f2);
 
-    if (isdir && length(p1) > max_cmd_line)
-      l2 = length(p2) + length (cmd) + 6;
-      while (! isempty(f1))
+    if (isdir && length (p1) > max_cmd_line)
+      l2 = length (p2) + length (cmd) + 6;
+      while (! isempty (f1))
         p1 = sprintf ("\"%s\" ", f1{1});
         f1(1) = [];
-        while (!isempty (f1) && (length(p1) + length(f1{1}) + l2 <
+        while (!isempty (f1) && (length (p1) + length (f1{1}) + l2 <
                                  max_cmd_line))
           p1 = sprintf ("%s\"%s\" ", p1, f1{1});
           f1(1) = [];
--- a/scripts/miscellaneous/namelengthmax.m
+++ b/scripts/miscellaneous/namelengthmax.m
@@ -31,4 +31,4 @@
 endfunction
 
 
-%!assert (namelengthmax, 63)
+%!assert (namelengthmax (), 63)
--- a/scripts/miscellaneous/news.m
+++ b/scripts/miscellaneous/news.m
@@ -17,20 +17,27 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {} news (@var{package})
-## Display the current NEWS file for Octave or installed package.
+## @deftypefn  {Function File} {} news
+## @deftypefnx {Function File} {} news (@var{package})
+## Display the current NEWS file for Octave or an installed package.
 ##
-## If @var{package} is the name of an installed package, display the current
-## NEWS file for that package.
+## When called without an argument, display the NEWS file for Octave.
+## When given a package name @var{package}, display the current NEWS file for
+## that package.
 ## @end deftypefn
 
 function news (package = "octave")
 
-  if (ischar (package) && strcmpi (package, "octave"))
+  if (nargin > 1)
+    print_usage ();
+  elseif (! ischar (package))
+    error ("news: PACKAGE must be a string");
+  endif
+
+  if (strcmpi (package, "octave"))
     octetcdir = octave_config_info ("octetcdir");
     newsfile  = fullfile (octetcdir, "NEWS");
-
-  elseif (nargin == 1 && ischar (package))
+  else
     installed = pkg ("list");
     names     = cellfun (@(x) x.name, installed, "UniformOutput", false);
     ## we are nice and let the user use any case on the package name
@@ -39,25 +46,26 @@
       error ("Package '%s' is not installed.", package);
     endif
     newsfile = fullfile (installed{pos}.dir, "packinfo", "NEWS");
-
-  else
-    print_usage;
   endif
 
-  if (exist (newsfile, "file"))
-    f = fopen (newsfile, "r");
-    while (ischar (line = fgets (f)))
-      puts (line);
-    endwhile
-  else
+  if (! exist (newsfile, "file"))
     if (strcmpi (package, "octave"))
       error ("news: unable to locate NEWS file");
     else
-      error ("news: unable to locate NEWS file of %s package", package);
+      error ("news: unable to locate NEWS file for package %s", package);
     endif
   endif
 
+  fid = fopen (newsfile, "r");
+  while (ischar (line = fgets (fid)))
+    puts (line);
+  endwhile
+  fclose (fid);
+
 endfunction
 
-## Remove from test statistics.  No real tests possible
-%!assert (1)
+
+%!error news (1, 2)
+%!error <PACKAGE must be a string> news (1)
+%!error <Package .* is not installed> news ("__NOT_A_VALID_PKG_NAME__")
+
--- a/scripts/miscellaneous/orderfields.m
+++ b/scripts/miscellaneous/orderfields.m
@@ -37,7 +37,7 @@
 ##
 ## @example
 ## @group
-## s = struct("d", 4, "b", 2, "a", 1, "c", 3);
+## s = struct ("d", 4, "b", 2, "a", 1, "c", 3);
 ## t1 = orderfields (s)
 ##      @result{} t1 =
 ##         @{
@@ -48,7 +48,7 @@
 ##         @}
 ## @end group
 ## @group
-## t = struct("d", @{@}, "c", @{@}, "b", "a", @{@});
+## t = struct ("d", @{@}, "c", @{@}, "b", "a", @{@});
 ## t2 = orderfields (s, t)
 ##      @result{} t2 =
 ##         @{
@@ -162,27 +162,28 @@
 
 endfunction
 
+
 %!shared a, b, c
 %! a = struct ("foo", {1, 2}, "bar", {3, 4});
 %! b = struct ("bar", 6, "foo", 5);
 %! c = struct ("bar", {7, 8}, "foo", 9);
 %!test
 %! a(2) = orderfields (b, a);
-%! assert (a(2).foo, 5)
-%! assert (a(2).bar, 6)
+%! assert (a(2).foo, 5);
+%! assert (a(2).bar, 6);
 %!test
 %! [a(2), p] = orderfields (b, [2 1]);
-%! assert (a(2).foo, 5)
-%! assert (a(2).bar, 6)
+%! assert (a(2).foo, 5);
+%! assert (a(2).bar, 6);
 %! assert (p, [2; 1]);
 %!test
 %! a(2) = orderfields (b, fieldnames (a));
-%! assert (a(2).foo, 5)
-%! assert (a(2).bar, 6)
+%! assert (a(2).foo, 5);
+%! assert (a(2).bar, 6);
 %!test
 %! a(1:2) = orderfields (c, fieldnames (a));
-%! assert (a(2).foo, 9)
-%! assert (a(2).bar, 8)
+%! assert (a(2).foo, 9);
+%! assert (a(2).bar, 8);
 
 %!test
 %! aa.x = {1, 2};
@@ -193,3 +194,4 @@
 %! aa(2) = orderfields (bb, aa);
 %! assert (aa(2).x, 8);
 %! assert (aa(2).y{1}, 6);
+
--- a/scripts/miscellaneous/paren.m
+++ b/scripts/miscellaneous/paren.m
@@ -22,6 +22,7 @@
 ## Array index or function argument delimeter.
 ## @end deftypefn
 
+
 ## Mark file as being tested.  No real test needed for a documentation .m file
 %!assert (1)
 
--- a/scripts/miscellaneous/parseparams.m
+++ b/scripts/miscellaneous/parseparams.m
@@ -40,7 +40,7 @@
 ## @end group
 ## @end example
 ##
-## The parseparams function may be used to separate 'regular'
+## The parseparams function may be used to separate "regular"
 ## arguments and additional arguments given as property/value pairs of
 ## the @var{varargin} cell array.
 ##
@@ -88,7 +88,7 @@
       if (! size_equal (pnames, values) || ! all (strs(i:2:end)))
         error_as_caller ("options must be given as name-value pairs");
       endif
-      idx = lookup (toupper(names), toupper(pnames), "m");
+      idx = lookup (toupper (names), toupper (pnames), "m");
       if (! all (idx))
         error_as_caller ("unrecognized option: %s", pnames{find (idx == 0, 1)});
       else
--- a/scripts/miscellaneous/perl.m
+++ b/scripts/miscellaneous/perl.m
@@ -17,13 +17,14 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {[@var{output}, @var{status}] =} perl (@var{scriptfile})
-## @deftypefnx {Function File} {[@var{output}, @var{status}] =} perl (@var{scriptfile}, @var{argument1}, @var{argument2}, @dots{})
-## Invoke Perl script @var{scriptfile} with possibly a list of
-## command line arguments.
-## Returns output in @var{output} and status
-## in @var{status}.
-## @seealso{system}
+## @deftypefn  {Function File} {@var{output} =} perl (@var{scriptfile})
+## @deftypefnx {Function File} {@var{output} =} perl (@var{scriptfile}, @var{argument1}, @var{argument2}, @dots{})
+## @deftypefnx {Function File} {[@var{output}, @var{status}] =} perl (@dots{})
+## Invoke Perl script @var{scriptfile}, possibly with a list of command line
+## arguments.  Return output in @var{output} and optional status in
+## @var{status}.  If @var{scriptfile} is not an absolute file name it is
+## is searched for in the current directory and then in the Octave loadpath.
+## @seealso{system, python}
 ## @end deftypefn
 
 function [output, status] = perl (scriptfile = "-e ''", varargin)
@@ -33,8 +34,13 @@
   ## initial value in the argument list of the function definition.
 
   if (ischar (scriptfile)
-      && ((nargin != 1 && iscellstr (varargin))
-          || (nargin == 1 && ! isempty (scriptfile))))
+      && (   (nargin == 1 && ! isempty (scriptfile))
+          || (nargin != 1 && iscellstr (varargin))))
+    if (! strcmp (scriptfile(1:2), "-e"))
+      ## Attempt to find file in loadpath.  No effect for absolute filenames.
+      scriptfile = file_in_loadpath (scriptfile);
+    endif
+
     [status, output] = system (cstrcat ("perl ", scriptfile,
                                         sprintf (" %s", varargin{:})));
   else
--- a/scripts/miscellaneous/private/__xzip__.m
+++ b/scripts/miscellaneous/private/__xzip__.m
@@ -62,13 +62,13 @@
     files = glob (files);
 
     ## Ignore any file with the compress extension
-    files(cellfun (@(x) length(x) > length(extension)
-      && strcmp (x((end - length(extension) + 1):end), extension),
+    files(cellfun (@(x) length (x) > length (extension)
+      && strcmp (x((end - length (extension) + 1):end), extension),
       files)) = [];
 
     copyfile (files, outdir);
 
-    [d, f] = myfileparts(files);
+    [d, f] = myfileparts (files);
 
     cd (outdir);
 
@@ -87,12 +87,12 @@
             f, "uniformoutput", false);
       endif
     else
-      movefile (cellfun(@(x) sprintf ("%s.%s", x, extension), f,
+      movefile (cellfun (@(x) sprintf ("%s.%s", x, extension), f,
                         "uniformoutput", false), cwd);
       if (nargout > 0)
         ## FIXME this does not work when you try to compress directories
-        entries  = cellfun(@(x) sprintf ("%s.%s", x, extension),
-                           files, "uniformoutput", false);
+        entries  = cellfun (@(x) sprintf ("%s.%s", x, extension),
+                            files, "uniformoutput", false);
       endif
     endif
 
@@ -119,20 +119,20 @@
 ## functions directly.
 ##
 ## %!error <extension has to be a string with finite length>
-## %!  __xzip__("gzip", "", "gzip -r %s", "bla");
+## %!  __xzip__ ("gzip", "", "gzip -r %s", "bla");
 ## %!error <no files to move>
-## %!  __xzip__("gzip", ".gz", "gzip -r %s", tmpnam);
+## %!  __xzip__ ("gzip", ".gz", "gzip -r %s", tmpnam);
 ## %!error <command failed with exit status>
 ## %!  # test __xzip__ with invalid compression command
 ## %!  unwind_protect
 ## %!    filename = tmpnam;
 ## %!    dummy    = 1;
-## %!    save(filename, "dummy");
+## %!    save (filename, "dummy");
 ## %!    dirname  = tmpnam;
-## %!    mkdir(dirname);
-## %!    entry = __xzip__("gzip", ".gz", "xxxzipxxx -r %s 2>/dev/null",
+## %!    mkdir (dirname);
+## %!    entry = __xzip__ ("gzip", ".gz", "xxxzipxxx -r %s 2>/dev/null",
 ## %!                     filename, dirname);
 ## %!  unwind_protect_cleanup
-## %!    delete(filename);
-## %!    rmdir(dirname);
+## %!    delete (filename);
+## %!    rmdir (dirname);
 ## %!  end_unwind_protect
--- a/scripts/miscellaneous/python.m
+++ b/scripts/miscellaneous/python.m
@@ -18,26 +18,28 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {[@var{output}, @var{status}] =} python (@var{scriptfile})
-## @deftypefnx {Function File} {[@var{output}, @var{status}] =} python (@var{scriptfile}, @var{argument1}, @var{argument2}, @dots{})
-## Invoke python script @var{scriptfile} with possibly a list of
-## command line arguments.
-## Returns output in @var{output} and status
-## in @var{status}.
-## @seealso{system}
+## @deftypefn  {Function File} {@var{output} =} python (@var{scriptfile})
+## @deftypefnx {Function File} {@var{output} =} python (@var{scriptfile}, @var{argument1}, @var{argument2}, @dots{})
+## @deftypefnx {Function File} {[@var{output}, @var{status}] =} python (@dots{})
+## Invoke Python script @var{scriptfile}, possibly with a list of command line
+## arguments.  Return output in @var{output} and optional status in
+## @var{status}.  If @var{scriptfile} is not an absolute file name it is
+## is searched for in the current directory and then in the Octave loadpath.
+## @seealso{system, perl}
 ## @end deftypefn
 
 ## Author: Carnë Draug <carandraug+dev@gmail.com>
 
 function [output, status] = python (scriptfile = "-c ''", varargin)
 
-  ## VARARGIN is intialized to {}(1x0) if no additional arguments are
-  ## supplied, so there is no need to check for it, or provide an
-  ## initial value in the argument list of the function definition.
+  if (ischar (scriptfile)
+      && (   (nargin == 1 && ! isempty (scriptfile))
+          || (nargin != 1 && iscellstr (varargin))))
+    if (! strcmp (scriptfile(1:2), "-c"))
+      ## Attempt to find file in loadpath.  No effect for absolute filenames.
+      scriptfile = file_in_loadpath (scriptfile);
+    endif
 
-  if (ischar (scriptfile)
-      && ((nargin != 1 && iscellstr (varargin))
-          || (nargin == 1 && ! isempty (scriptfile))))
     [status, output] = system (cstrcat ("python ", scriptfile,
                                         sprintf (" %s", varargin{:})));
   else
--- a/scripts/miscellaneous/recycle.m
+++ b/scripts/miscellaneous/recycle.m
@@ -51,16 +51,18 @@
         error ("recycle: invalid value of STATE = `%s'", state);
       endif
     else
-      error ("recycle: expecting STATE to be a character string");
+      error ("recycle: STATE must be a character string");
     endif
   endif
 
 endfunction
 
-%!error recycle ("on");
-%!error recycle ("on", "and I mean it");
-%!error recycle (1);
 
 %!test
 %! recycle ("off");
 %! assert (recycle ("off"), "off");
+
+%!error <recycling files is not implemented> recycle ("on")
+%!error recycle ("on", "and I mean it")
+%!error <STATE must be a character string> recycle (1)
+
--- a/scripts/miscellaneous/rmappdata.m
+++ b/scripts/miscellaneous/rmappdata.m
@@ -29,7 +29,7 @@
     error ("rmappdata: invalid input");
   endif
 
-  for nh = 1:numel(h)
+  for nh = 1:numel (h)
     appdata = get (h(nh), "__appdata__");
     appdata = rmfield (appdata, varargin);
     set (h(nh), "__appdata__", appdata);
@@ -37,8 +37,9 @@
 
 endfunction
 
+
 %!test
-%! setappdata (0, "hello", "world")
-%! rmappdata (0, "hello")
-%! assert (isappdata (0, "hello"), false)
+%! setappdata (0, "hello", "world");
+%! rmappdata (0, "hello");
+%! assert (isappdata (0, "hello"), false);
 
--- a/scripts/miscellaneous/semicolon.m
+++ b/scripts/miscellaneous/semicolon.m
@@ -22,6 +22,7 @@
 ## @seealso{comma}
 ## @end deftypefn
 
+
 ## Mark file as being tested.  No real test needed for a documentation .m file
 %!assert (1)
 
--- a/scripts/miscellaneous/setappdata.m
+++ b/scripts/miscellaneous/setappdata.m
@@ -30,12 +30,12 @@
     error ("setappdata: invalid input");
   endif
 
-  for nh = 1:numel(h)
+  for nh = 1:numel (h)
     if (! isfield (get (h(nh)), "__appdata__"))
       addproperty ("__appdata__", h(nh), "any", struct ());
     endif
     appdata = get (h(nh), "__appdata__");
-    for narg = 1:2:numel(varargin)
+    for narg = 1:2:numel (varargin)
       if (iscellstr (varargin{narg}))
         ## Handle cell arrays like set() does.
         set (h(nh), "__appdata__", appdata);
@@ -52,8 +52,9 @@
 
 endfunction
 
+
 %!test
-%! setappdata (0, "hello", "world")
-%! assert (isappdata (0, "hello"), true)
-%!assert (getappdata (0, "hello"), "world")
+%! setappdata (0, "hello", "world");
+%! assert (isappdata (0, "hello"), true);
+%! assert (getappdata (0, "hello"), "world");
 
--- a/scripts/miscellaneous/setfield.m
+++ b/scripts/miscellaneous/setfield.m
@@ -60,12 +60,14 @@
   endif
 endfunction
 
+
 %!test
 %! x.a = "hello";
-%! x = setfield(x,"b","world");
-%! y = struct("a","hello","b","world");
-%! assert(x,y);
+%! x = setfield (x, "b", "world");
+%! y = struct ("a", "hello", "b", "world");
+%! assert (x,y);
 %!test
-%! oo(1,1).f0= 1;
-%! oo = setfield(oo,{1,2},"fd",{3},"b", 6);
-%! assert (oo(1,2).fd(3).b, 6)
+%! oo(1,1).f0 = 1;
+%! oo = setfield (oo,{1,2},"fd",{3},"b", 6);
+%! assert (oo(1,2).fd(3).b, 6);
+
--- a/scripts/miscellaneous/substruct.m
+++ b/scripts/miscellaneous/substruct.m
@@ -73,6 +73,7 @@
 
 endfunction
 
+
 %!test
 %! x(1,1).type = "()";
 %! x(1,2).type = "{}";
@@ -81,9 +82,11 @@
 %! x(1,2).subs = {":"};
 %! x(1,3).subs = "foo";
 %! y = substruct ("()", {1,2,3}, "{}", {":"}, ".", "foo");
-%! assert(x,y);
-%!error assert(substruct);
-%!error assert(substruct (1, 2, 3));
-%!error assert(substruct ("x", 1));
-%!error assert(substruct ("()", [1,2,3]));
-%!error assert(substruct (".", {1,2,3}));
+%! assert (x,y);
+
+%!error substruct ()
+%!error substruct (1, 2, 3)
+%!error substruct ("x", 1)
+%!error substruct ("()", [1,2,3])
+%!error substruct (".", {1,2,3})
+
--- a/scripts/miscellaneous/swapbytes.m
+++ b/scripts/miscellaneous/swapbytes.m
@@ -52,7 +52,7 @@
       error ("swapbytes: invalid class of object");
     endif
     y = reshape (typecast (reshape (typecast (x(:), "uint8"), nb, numel (x))
-                           ([nb : -1 : 1], :) (:), clx), size(x));
+                           ([nb : -1 : 1], :) (:), clx), size (x));
   endif
 
 endfunction
--- a/scripts/miscellaneous/symvar.m
+++ b/scripts/miscellaneous/symvar.m
@@ -29,5 +29,7 @@
   args = argnames (inline (s));
 endfunction
 
+
 ## This function is tested by the tests for argnames().
 %!assert (1)
+
--- a/scripts/miscellaneous/unpack.m
+++ b/scripts/miscellaneous/unpack.m
@@ -39,7 +39,7 @@
   endif
 
   if (! ischar (file) && ! iscellstr (file))
-    error ("unpack: invalid input file class, %s", class(file));
+    error ("unpack: invalid input file class, %s", class (file));
   endif
 
   ## character arrays of more than one string must be treated as cell strings
@@ -224,7 +224,7 @@
   ## Skip first line which is Archive header
   output(1) = [];
   for i = 1:length (output)
-    files{i} = output{i}(14:length(output{i}));
+    files{i} = output{i}(14:length (output{i}));
   endfor
 endfunction
 
@@ -246,7 +246,7 @@
                "Unable to parse line (gzip missing colon):\n%s", output{i});
     else
       midcolon = colons(ceil (length (colons)/2));
-      thisstr = output{i}(midcolon+2:length(output{i}));
+      thisstr = output{i}(midcolon+2:length (output{i}));
       idx = index (thisstr, "with") + 5;
       if (isempty (idx))
         warning ("unpack:parsing",
--- a/scripts/miscellaneous/usejava.m
+++ b/scripts/miscellaneous/usejava.m
@@ -1,4 +1,5 @@
 ## Copyright (C) 2012 Rik Wehbring
+## Parts Copyright (C) 2012 Philip Nienhuis <prnienhuis@users.sf.net>
 ##
 ## This file is part of Octave.
 ##
@@ -18,7 +19,7 @@
 
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} usejava (@var{feature})
-## Return true if the specific Sun Java element @var{feature} is available.
+## Return true if the Java element @var{feature} is available.
 ##
 ## Possible features are:
 ##
@@ -36,10 +37,12 @@
 ## Swing components for lightweight GUIs.
 ## @end table
 ##
-## This function is provided for compatibility with @sc{matlab} scripts which
-## may alter their behavior based on the availability of Java.  Octave does
-## not implement an interface to Java and this function always returns
-## @code{false}.
+## @code{usejava} determines if specific Java features are available in an
+## Octave session.  This function is provided for compatibility with scripts
+## which may alter their behavior based on the availability of Java.  The
+## feature "desktop" always returns @code{false} as Octave has no Java-based
+## desktop.  Other features may be available if the Octave-Forge Java package
+## has been installed.
 ## @end deftypefn
 
 function retval = usejava (feature)
@@ -48,16 +51,35 @@
     print_usage ();
   endif
 
-  if (! any (strcmp (feature, {"awt", "desktop", "jvm", "swing"})))
-    error ("usejava: unrecognized feature '%s'", feature);
-  endif
+  retval = false;
 
-  retval = false;
+  switch feature
+    ## For each feature, try javamethods() on a Java class of a feature
+    case "awt"
+      try
+        dum = javamethods ("java.awt.Frame");
+        retval = true;
+      end_try_catch
+    case "desktop"
+      ## Octave has no Java based GUI/desktop, leave retval = false
+    case "jvm"
+      try
+        dum = javamethods ("java.lang.Runtime");
+        retval = true;
+      end_try_catch
+    case "swing"
+      try
+        dum = javamethods ("javax.swing.Popup");
+        retval = true;
+      end_try_catch
+    otherwise
+      error ("usejava: unrecognized feature '%s'", feature);
+  endswitch
 
 endfunction
 
 
-%!assert (usejava ("awt"), false)
+%!assert (usejava ("desktop"), false)
 
 %% Test input validation
 %!error usejava ()
--- a/scripts/miscellaneous/ver.m
+++ b/scripts/miscellaneous/ver.m
@@ -94,7 +94,7 @@
   else
     if (! isempty (package))
       n = [];
-      for r = 1:numel(ret)
+      for r = 1:numel (ret)
         if (strcmpi (ret(r).Name, package))
           n = r;
           break;
@@ -107,17 +107,18 @@
 
 endfunction
 
+
 %!test
 %! result = ver;
-%! assert (result(1).Name, "Octave")
-%! assert (result(1).Version, version)
+%! assert (result(1).Name, "Octave");
+%! assert (result(1).Version, version);
 %! result = ver ("octave");
-%! assert (result(1).Name, "Octave")
-%! assert (result(1).Version, version)
+%! assert (result(1).Name, "Octave");
+%! assert (result(1).Version, version);
 
 %!test
 %! lst = pkg ("list");
-%! for n=1:numel(lst)
+%! for n = 1:numel (lst)
 %!   expected = lst{n}.name;
 %!   result = ver (expected);
 %!   assert (result.Name, expected);
--- a/scripts/miscellaneous/version.m
+++ b/scripts/miscellaneous/version.m
@@ -37,7 +37,9 @@
 
 endfunction
 
-%!assert(ischar (version ()) && strcmp (version (), OCTAVE_VERSION));
+
+%!assert (ischar (version ()))
+%!assert (version (), OCTAVE_VERSION)
 
 %!warning version (1);
 
--- a/scripts/miscellaneous/warning_ids.m
+++ b/scripts/miscellaneous/warning_ids.m
@@ -18,6 +18,7 @@
 
 ## -*- texinfo -*-
 ## @cindex warning ids
+##
 ## @table @code
 ## @item Octave:abbreviated-property-match
 ## By default, the @code{Octave:abbreviated-property-match} warning is enabled.
@@ -320,5 +321,7 @@
   help ("warning_ids");
 endfunction
 
+
 ## Remove from test statistics.  No real tests possible
 %!assert (1)
+
--- a/scripts/miscellaneous/what.m
+++ b/scripts/miscellaneous/what.m
@@ -32,7 +32,7 @@
     d = pwd ();
   elseif (isempty (strfind (d, filesep ())))
     ## Find the appropriate directory on the path.
-    p = strtrim (strsplit (path (), pathsep()));
+    p = strtrim (strsplit (path (), pathsep ()));
     d = p{find (cellfun (@(x) ! isempty (strfind (x, d)), p))(end)};
   else
     [status, msg, msgid] = fileattrib (d);
@@ -91,7 +91,7 @@
     printf ("%s %s:\n\n", msg, p);
 
     maxlen = max (cellfun ("length", f));
-    ncols = max (1, floor (terminal_size()(2) / (maxlen + 3)));
+    ncols = max (1, floor (terminal_size ()(2) / (maxlen + 3)));
     fmt = "";
     for i = 1: ncols
       fmt = sprintf ("%s   %%-%ds", fmt, maxlen);
--- a/scripts/miscellaneous/xor.m
+++ b/scripts/miscellaneous/xor.m
@@ -60,12 +60,12 @@
 
 endfunction
 
-%!assert((xor ([1, 1, 0, 0], [0, 1, 0, 1]) == [1, 0, 0, 1]
-%! && xor ([i, i, 0, 0], [1, 0, 1, 0]) == [0, 1, 1, 0]));
 
-%!assert(all (all (xor (eye (2), fliplr (eye (2))) == ones (2))));
+%!assert (xor ([1, 1, 0, 0], [0, 1, 0, 1]), logical ([1, 0, 0, 1]))
+%!assert (xor ([i, i, 0, 0], [1, 0, 1, 0]), logical ([0, 1, 1, 0]))
 
-%!error xor ();
+%!assert (xor (eye (2), fliplr (eye (2))), logical (ones (2)))
 
-%!error xor (1, 2, 3);
+%!error xor ()
+%!error xor (1, 2, 3)
 
new file mode 100755
--- /dev/null
+++ b/scripts/mkdoc.pl
@@ -0,0 +1,103 @@
+#! /usr/bin/perl -w
+#
+# Copyright (C) 2012 Rik Wehbring
+#
+# 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/>.
+
+## Expecting arguments in this order:
+##
+##  SRCDIR SRCDIR-FILES ... -- LOCAL-FILES ...
+
+unless (@ARGV >= 2) { die "Usage: $0 srcdir m_filename1 ..." ; }
+
+$srcdir = shift (@ARGV) . '/';
+
+print <<__END_OF_MSG__;
+### DO NOT EDIT!
+###
+### This file is generated automatically from Octave source files.
+### Edit source files directly and run make to update this file.
+
+__END_OF_MSG__
+
+MFILE: foreach $m_fname (@ARGV)
+{
+  if ($m_fname eq "--")
+  {
+    $srcdir = "./";
+    next MFILE;
+  }
+
+  $full_fname = $srcdir . $m_fname;
+  next MFILE unless ( $full_fname =~ m{(.*)/(@|)([^/]*)/(.*)\.m} );
+  if ($2)
+    { $fcn = "$2$3/$4"; }
+  else
+    { $fcn = $4; }
+
+  @help_txt = gethelp ($fcn, $full_fname);
+  next MFILE if ($help_txt[0] eq "");
+
+  print "$fcn\n";
+  print "\@c $fcn scripts/$m_fname\n";
+
+  foreach $_ (@help_txt)
+  {
+    s/^\s+\@/\@/ unless $in_example;
+    s/^\s+\@group/\@group/;
+    s/^\s+\@end\s+group/\@end group/;
+    $in_example = (/\s*\@example\b/ .. /\s*\@end\s+example\b/);
+    print $_;
+  }
+}
+
+################################################################################
+# Subroutines
+################################################################################
+sub gethelp
+{
+  ($fcn, $fname) = @_[0..1]; 
+  open (FH, $fname) or return "";
+
+  do
+  {
+    @help_txt = ();
+
+    ## Advance to non-blank line
+    while (defined ($_ = <FH>) and /^\s*$/) {;}
+
+    if (! /^\s*(?:#|%)/ or eof (FH))
+    {
+      ## No comment block found.  Return empty string
+      close (FH);
+      return "";
+    }
+
+    ## Extract help text stopping when comment block ends
+    do
+    {
+      ## Remove comment characters at start of line
+      s/^\s*(?:#|%){1,2} ?//;
+      push (@help_txt, $_);
+    } until (! defined ($_ = <FH>) or ! /^\s*(?:#|%)/);
+
+  } until ($help_txt[0] !~ /^(?:Copyright|Author)/); 
+
+  close (FH);
+
+  return @help_txt;
+}
--- a/scripts/optimization/fminbnd.m
+++ b/scripts/optimization/fminbnd.m
@@ -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
 
@@ -88,7 +88,7 @@
   nfev = 0;
   sqrteps = eps (class (xmin + xmax));
 
-  c = 0.5*(3-sqrt(5));
+  c = 0.5*(3 - sqrt (5));
   a = xmin; b = xmax;
   v = a + c*(b-a);
   w = x = v;
@@ -98,9 +98,9 @@
 
   while (niter < maxiter && nfev < maxfev)
     xm = 0.5*(a+b);
-    ## FIXME: the golden section search can actually get closer than sqrt(eps)...
-    ## sometimes. Sometimes not, it depends on the function. This is the strategy
-    ## from the Netlib code. Something yet smarter would be good.
+    ## FIXME: the golden section search can actually get closer than sqrt(eps)
+    ## sometimes.  Sometimes not, it depends on the function.  This is the
+    ## strategy from the Netlib code.  Something yet smarter would be good.
     tol = 2 * sqrteps * abs (x) + tolx / 3;
     if (abs (x - xm) <= (2*tol - 0.5*(b-a)))
       info = 1;
@@ -205,9 +205,11 @@
   endif
 endfunction
 
+
 %!shared opt0
 %! opt0 = optimset ("tolx", 0);
-%!assert (fminbnd (@cos, pi/2, 3*pi/2, opt0), pi, 10*sqrt(eps))
-%!assert (fminbnd (@(x) (x - 1e-3)^4, -1, 1, opt0), 1e-3, 10e-3*sqrt(eps))
-%!assert (fminbnd (@(x) abs(x-1e7), 0, 1e10, opt0), 1e7, 10e7*sqrt(eps))
-%!assert (fminbnd (@(x) x^2 + sin(2*pi*x), 0.4, 1, opt0), fzero (@(x) 2*x + 2*pi*cos(2*pi*x), [0.4, 1], opt0), sqrt(eps))
+%!assert (fminbnd (@cos, pi/2, 3*pi/2, opt0), pi, 10*sqrt (eps))
+%!assert (fminbnd (@(x) (x - 1e-3)^4, -1, 1, opt0), 1e-3, 10e-3*sqrt (eps))
+%!assert (fminbnd (@(x) abs (x-1e7), 0, 1e10, opt0), 1e7, 10e7*sqrt (eps))
+%!assert (fminbnd (@(x) x^2 + sin (2*pi*x), 0.4, 1, opt0), fzero (@(x) 2*x + 2*pi*cos (2*pi*x), [0.4, 1], opt0), sqrt (eps))
+
--- a/scripts/optimization/fminunc.m
+++ b/scripts/optimization/fminunc.m
@@ -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
 
@@ -260,7 +260,7 @@
       endif
 
       ## Update delta.
-      if (ratio < min(max(0.1, 0.8*lastratio), 0.9))
+      if (ratio < min (max (0.1, 0.8*lastratio), 0.9))
         delta *= decfac;
         decfac ^= 1.4142;
         if (delta <= 1e1*macheps*xn)
@@ -354,9 +354,12 @@
     error ("fminunc:notreal", "fminunc: non-real value encountered");
   elseif (any (isnan (fx(:))))
     error ("fminunc:isnan", "fminunc: NaN value encountered");
+  elseif (any (isinf (fx(:))))
+    error ("fminunc:isinf", "fminunc: Inf value encountered");
   endif
 endfunction
 
+
 %!function f = __rosenb (x)
 %!  n = length (x);
 %!  f = sumsq (1 - x(1:n-1)) + 100 * sumsq (x(2:n) - x(1:n-1).^2);
@@ -373,6 +376,12 @@
 %! assert (info > 0);
 %! assert (x, ones (1, 4), tol);
 %! assert (fval, 0, tol);
+%% Test FunValCheck works correctly
+%!assert (fminunc (@(x) x^2, 1, optimset ("FunValCheck", "on")), 0, eps)
+%!error <non-real value> fminunc (@(x) x + i, 1, optimset ("FunValCheck", "on"))
+%!error <NaN value> fminunc (@(x) x + NaN, 1, optimset ("FunValCheck", "on"))
+%!error <Inf value> fminunc (@(x) x + Inf, 1, optimset ("FunValCheck", "on"))
+
 
 ## Solve the double dogleg trust-region minimization problem:
 ## Minimize 1/2*norm(r*x)^2  subject to the constraint norm(d.*x) <= delta,
--- a/scripts/optimization/fsolve.m
+++ b/scripts/optimization/fsolve.m
@@ -327,7 +327,7 @@
       endif
 
       ## Update delta.
-      if (ratio < min(max(0.1, 0.8*lastratio), 0.9))
+      if (ratio < min (max (0.1, 0.8*lastratio), 0.9))
         nsuc = 0;
         nfail ++;
         delta *= decfac;
@@ -446,10 +446,12 @@
 
   if (! complexeqn && ! (isreal (fx) && isreal (jx)))
     error ("fsolve:notreal", "fsolve: non-real value encountered");
-  elseif (complexeqn && ! (isnumeric (fx) && isnumeric(jx)))
+  elseif (complexeqn && ! (isnumeric (fx) && isnumeric (jx)))
     error ("fsolve:notnum", "fsolve: non-numeric value encountered");
   elseif (any (isnan (fx(:))))
     error ("fsolve:isnan", "fsolve: NaN value encountered");
+  elseif (any (isinf (fx(:))))
+    error ("fsolve:isinf", "fsolve: Inf value encountered");
   endif
 endfunction
 
@@ -465,14 +467,14 @@
 %!  y = p(2);
 %!  z = p(3);
 %!  retval = zeros (3, 1);
-%!  retval(1) = sin(x) + y**2 + log(z) - 7;
-%!  retval(2) = 3*x + 2**y -z**3 + 1;
+%!  retval(1) = sin (x) + y^2 + log (z) - 7;
+%!  retval(2) = 3*x + 2^y -z^3 + 1;
 %!  retval(3) = x + y + z - 5;
 %!endfunction
 %!test
 %! x_opt = [ 0.599054;
-%! 2.395931;
-%! 2.005014 ];
+%!           2.395931;
+%!           2.005014 ];
 %! tol = 1.0e-5;
 %! [x, fval, info] = fsolve (@__f, [ 0.5; 2.0; 2.5 ]);
 %! assert (info > 0);
@@ -491,7 +493,8 @@
 %!  retval(4) = x^2 + 2*y^3 + z - w - 4;
 %!endfunction
 %!test
-%! x_opt = [ -0.767297326653401, 0.590671081117440, 1.47190018629642, -1.52719341133957 ];
+%! x_opt = [ -0.767297326653401, 0.590671081117440, ...
+%!            1.47190018629642, -1.52719341133957 ];
 %! tol = 1.0e-5;
 %! [x, fval, info] = fsolve (@__f, [-1, 1, 2, -1]);
 %! assert (info > 0);
@@ -503,15 +506,15 @@
 %!  y = p(2);
 %!  z = p(3);
 %!  retval = zeros (3, 1);
-%!  retval(1) = sin(x) + y**2 + log(z) - 7;
-%!  retval(2) = 3*x + 2**y -z**3 + 1;
+%!  retval(1) = sin (x) + y^2 + log (z) - 7;
+%!  retval(2) = 3*x + 2^y -z^3 + 1;
 %!  retval(3) = x + y + z - 5;
-%!  retval(4) = x*x + y - z*log(z) - 1.36;
+%!  retval(4) = x*x + y - z*log (z) - 1.36;
 %!endfunction
 %!test
 %! x_opt = [ 0.599054;
-%! 2.395931;
-%! 2.005014 ];
+%!           2.395931;
+%!           2.005014 ];
 %! tol = 1.0e-5;
 %! [x, fval, info] = fsolve (@__f, [ 0.5; 2.0; 2.5 ]);
 %! assert (info > 0);
@@ -523,14 +526,14 @@
 %!  y = p(2);
 %!  z = p(3);
 %!  retval = zeros (3, 1);
-%!  retval(1) = sin(x) + y**2 + log(z) - 7;
-%!  retval(2) = 3*x + 2**y -z**3 + 1;
+%!  retval(1) = sin (x) + y^2 + log (z) - 7;
+%!  retval(2) = 3*x + 2^y -z^3 + 1;
 %!  retval(3) = x + y + z - 5;
 %!endfunction
 %!test
 %! x_opt = [ 0.599054;
-%! 2.395931;
-%! 2.005014 ];
+%!           2.395931;
+%!           2.005014 ];
 %! tol = 1.0e-5;
 %! opt = optimset ("Updating", "qrp");
 %! [x, fval, info] = fsolve (@__f, [ 0.5; 2.0; 2.5 ], opt);
@@ -552,7 +555,6 @@
 %! assert (norm (c - c_opt, Inf) < tol);
 %! assert (norm (fval) < norm (noise));
 
-
 %!function y = cfun (x)
 %!  y(1) = (1+i)*x(1)^2 - (1-i)*x(2) - 2;
 %!  y(2) = sqrt (x(1)*x(2)) - (1-2i)*x(3) + (3-4i);
--- a/scripts/optimization/fzero.m
+++ b/scripts/optimization/fzero.m
@@ -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
 
@@ -359,5 +359,6 @@
 
 %!shared opt0
 %! opt0 = optimset ("tolx", 0);
-%!assert(fzero(@cos, [0, 3], opt0), pi/2, 10*eps)
-%!assert(fzero(@(x) x^(1/3) - 1e-8, [0,1], opt0), 1e-24, 1e-22*eps)
+%!assert (fzero (@cos, [0, 3], opt0), pi/2, 10*eps)
+%!assert (fzero (@(x) x^(1/3) - 1e-8, [0,1], opt0), 1e-24, 1e-22*eps)
+
--- a/scripts/optimization/glpk.m
+++ b/scripts/optimization/glpk.m
@@ -106,6 +106,7 @@
 ## An array of characters containing the sense of each constraint in the
 ## constraint matrix.  Each element of the array may be one of the
 ## following values
+##
 ## @table @asis
 ## @item "F"
 ## A free (unbounded) constraint (the constraint is ignored).
@@ -126,6 +127,7 @@
 ##
 ## @item vartype
 ## A column array containing the types of the variables.
+##
 ## @table @asis
 ## @item "C"
 ## A continuous variable.
@@ -149,6 +151,7 @@
 ## @table @code
 ## @item msglev (@w{@code{LPX_K_MSGLEV}}, default: 1)
 ## Level of messages output by solver routines:
+##
 ## @table @asis
 ## @item 0
 ## No output.
@@ -165,6 +168,7 @@
 ##
 ## @item scale (@w{@code{LPX_K_SCALE}}, default: 1)
 ## Scaling option:
+##
 ## @table @asis
 ## @item 0
 ## No scaling.
@@ -178,6 +182,7 @@
 ##
 ## @item dual    (@w{@code{LPX_K_DUAL}}, default: 0)
 ## Dual simplex option:
+##
 ## @table @asis
 ## @item 0
 ## Do not use the dual simplex.
@@ -188,6 +193,7 @@
 ##
 ## @item price   (@w{@code{LPX_K_PRICE}}, default: 1)
 ## Pricing option (for both primal and dual simplex):
+##
 ## @table @asis
 ## @item 0
 ## Textbook pricing.
@@ -198,6 +204,7 @@
 ##
 ## @item round   (@w{@code{LPX_K_ROUND}}, default: 0)
 ## Solution rounding option:
+##
 ## @table @asis
 ## @item 0
 ## Report all primal and dual values "as is".
@@ -219,6 +226,7 @@
 ##
 ## @item branch (@w{@code{LPX_K_BRANCH}}, default: 2)
 ## Branching heuristic option (for MIP only):
+##
 ## @table @asis
 ## @item 0
 ## Branch on the first variable.
@@ -232,6 +240,7 @@
 ##
 ## @item btrack (@w{@code{LPX_K_BTRACK}}, default: 2)
 ## Backtracking heuristic option (for MIP only):
+##
 ## @table @asis
 ## @item 0
 ## Depth first search.
@@ -250,6 +259,7 @@
 ## @item lpsolver (default: 1)
 ## Select which solver to use.  If the problem is a MIP problem this flag
 ## will be ignored.
+##
 ## @table @asis
 ## @item 1
 ## Revised simplex method.
@@ -339,6 +349,7 @@
 ## Status of the optimization.
 ##
 ## Simplex Method:
+##
 ## @table @asis
 ## @item 180 (@w{@code{LPX_OPT}})
 ## Solution is optimal.
@@ -359,6 +370,7 @@
 ## Solution status is undefined.
 ## @end table
 ## Interior Point Method:
+##
 ## @table @asis
 ## @item 150 (@w{@code{LPX_T_UNDEF}})
 ## The interior point method is undefined.
@@ -367,6 +379,7 @@
 ## The interior point method is optimal.
 ## @end table
 ## Mixed Integer Method:
+##
 ## @table @asis
 ## @item 170 (@w{@code{LPX_I_UNDEF}})
 ## The status is undefined.
@@ -421,6 +434,7 @@
 ##
 ## @item extra
 ## A data structure containing the following fields:
+##
 ## @table @code
 ## @item lambda
 ## Dual variables.
@@ -486,7 +500,7 @@
     error ("glpk: A cannot be an empty matrix");
     return;
   endif
-  [nc, nxa] = size(A);
+  [nc, nxa] = size (A);
   if (! isreal (A) || nxa != nx)
     error ("glpk: A must be a real valued %d by %d matrix", nc, nx);
     return;
--- a/scripts/optimization/lsqnonneg.m
+++ b/scripts/optimization/lsqnonneg.m
@@ -21,6 +21,7 @@
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {@var{x} =} lsqnonneg (@var{c}, @var{d})
 ## @deftypefnx {Function File} {@var{x} =} lsqnonneg (@var{c}, @var{d}, @var{x0})
+## @deftypefnx {Function File} {@var{x} =} lsqnonneg (@var{c}, @var{d}, @var{x0}, @var{options})
 ## @deftypefnx {Function File} {[@var{x}, @var{resnorm}] =} lsqnonneg (@dots{})
 ## @deftypefnx {Function File} {[@var{x}, @var{resnorm}, @var{residual}] =} lsqnonneg (@dots{})
 ## @deftypefnx {Function File} {[@var{x}, @var{resnorm}, @var{residual}, @var{exitflag}] =} lsqnonneg (@dots{})
@@ -29,12 +30,16 @@
 ## Minimize @code{norm (@var{c}*@var{x} - d)} subject to
 ## @code{@var{x} >= 0}.  @var{c} and @var{d} must be real.  @var{x0} is an
 ## optional initial guess for @var{x}.
+## Currently, @code{lsqnonneg}
+## recognizes these options: @code{"MaxIter"}, @code{"TolX"}.
+## For a description of these options, see @ref{doc-optimset,,optimset}.
 ##
 ## Outputs:
+##
 ## @itemize @bullet
 ## @item resnorm
 ##
-## The squared 2-norm of the residual: norm(@var{c}*@var{x}-@var{d})^2
+## The squared 2-norm of the residual: norm (@var{c}*@var{x}-@var{d})^2
 ##
 ## @item residual
 ##
@@ -50,6 +55,7 @@
 ## @item output
 ##
 ## A structure with two fields:
+##
 ## @itemize @bullet
 ## @item "algorithm": The algorithm used ("nnls")
 ##
@@ -145,7 +151,8 @@
     ## compute the gradient.
     w = c'*(d - c*x);
     w(p) = [];
-    if (! any (w > 0))
+    tolx = optimget (options, "TolX", 10*eps*norm (c, 1)*length (c));
+    if (! any (w > tolx))
       if (useqr)
         ## verify the solution achieved using qr updating.
         ## in the best case, this should only take a single step.
@@ -198,14 +205,15 @@
 
 endfunction
 
-## Tests
+
 %!test
 %! C = [1 0;0 1;2 1];
 %! d = [1;3;-2];
-%! assert (lsqnonneg (C, d), [0;0.5], 100*eps)
+%! assert (lsqnonneg (C, d), [0;0.5], 100*eps);
 
 %!test
 %! C = [0.0372 0.2869;0.6861 0.7071;0.6233 0.6245;0.6344 0.6170];
 %! d = [0.8587;0.1781;0.0747;0.8405];
 %! xnew = [0;0.6929];
-%! assert (lsqnonneg (C, d), xnew, 0.0001)
+%! assert (lsqnonneg (C, d), xnew, 0.0001);
+
--- a/scripts/optimization/optimset.m
+++ b/scripts/optimization/optimset.m
@@ -25,6 +25,7 @@
 ## Create options struct for optimization functions.
 ##
 ## Valid parameters are:
+##
 ## @itemize @bullet
 ## @item AutoScaling
 ##
@@ -33,8 +34,11 @@
 ## @item FinDiffType
 ##
 ## @item FunValCheck
-## When enabled, display an error if the objective function returns a complex
-## value or NaN@.  Must be set to "on" or "off" [default].
+## When enabled, display an error if the objective function returns an invalid
+## value (a complex value, NaN, or Inf).  Must be set to "on" or "off"
+## [default].  Note: the functions @code{fzero} and @code{fminbnd} correctly
+## handle Inf values and only complex values or NaN will cause an error in this
+## case. 
 ##
 ## @item GradObj
 ## When set to "on", the function to be minimized must return a second argument
@@ -141,8 +145,8 @@
 endfunction
 
 
-%!assert (optimget (optimset ('tolx', 1e-2), 'tOLx'), 1e-2)
-%!assert (isfield (optimset ('tolFun', 1e-3), 'TolFun'))
+%!assert (optimget (optimset ("tolx", 1e-2), "tOLx"), 1e-2)
+%!assert (isfield (optimset ("tolFun", 1e-3), "TolFun"))
 
 %!error (optimset ("%NOT_A_REAL_FUNCTION_NAME%"))
 
--- a/scripts/optimization/pqpnonneg.m
+++ b/scripts/optimization/pqpnonneg.m
@@ -30,6 +30,7 @@
 ## definite.  @var{x0} is an optional initial guess for @var{x}.
 ##
 ## Outputs:
+##
 ## @itemize @bullet
 ## @item minval
 ##
@@ -45,6 +46,7 @@
 ## @item output
 ##
 ## A structure with two fields:
+##
 ## @itemize @bullet
 ## @item "algorithm": The algorithm used ("nnls")
 ##
@@ -198,14 +200,15 @@
 
 endfunction
 
-## Tests
+
 %!test
 %! C = [5 2;2 2];
 %! d = [3; -1];
-%! assert (pqpnonneg (C, d), [0;0.5], 100*eps)
+%! assert (pqpnonneg (C, d), [0;0.5], 100*eps);
 
 ## Test equivalence of lsq and pqp
 %!test
 %! C = rand (20, 10);
 %! d = rand (20, 1);
-%! assert (pqpnonneg (C'*C, -C'*d), lsqnonneg (C, d), 100*eps)
+%! assert (pqpnonneg (C'*C, -C'*d), lsqnonneg (C, d), 100*eps);
+
--- a/scripts/optimization/qp.m
+++ b/scripts/optimization/qp.m
@@ -228,15 +228,15 @@
       if (! isempty (lb) && ! isempty (ub))
         rtol = sqrt (eps);
         for i = 1:n
-          if (abs(lb (i) - ub(i)) < rtol*(1 + max (abs (lb(i) + ub(i)))))
+          if (abs (lb (i) - ub(i)) < rtol*(1 + max (abs (lb(i) + ub(i)))))
             ## These are actually an equality constraint
-            tmprow = zeros(1,n);
+            tmprow = zeros (1,n);
             tmprow(i) = 1;
             A = [A;tmprow];
             b = [b; 0.5*(lb(i) + ub(i))];
             n_eq = n_eq + 1;
           else
-            tmprow = zeros(1,n);
+            tmprow = zeros (1,n);
             tmprow(i) = 1;
             Ain = [Ain; tmprow; -tmprow];
             bin = [bin; lb(i); -ub(i)];
--- a/scripts/optimization/sqp.m
+++ b/scripts/optimization/sqp.m
@@ -122,7 +122,7 @@
 ## iterations.  The default value is 100.
 ##
 ## The eighth argument @var{tol} specifies the tolerance for the
-## stopping criteria.  The default value is @code{sqrt(eps)}.
+## stopping criteria.  The default value is @code{sqrt (eps)}.
 ##
 ## The value returned in @var{info} may be one of the following:
 ##
@@ -186,12 +186,8 @@
 
 function [x, obj, info, iter, nf, lambda] = sqp (x0, objf, cef, cif, lb, ub, maxiter, tolerance)
 
-  global __sqp_nfun__;
-  global __sqp_obj_fun__;
-  global __sqp_ce_fun__;
-  global __sqp_ci_fun__;
-  global __sqp_cif__;
-  global __sqp_cifcn__;
+  globals = struct (); # data and handles, needed and changed by
+                       # subfunctions
 
   if (nargin < 2 || nargin > 8 || nargin == 5)
     print_usage ();
@@ -204,12 +200,12 @@
     x0 = x0';
   endif
 
-  obj_grd = @fd_obj_grd;
   have_hess = 0;
   if (iscell (objf))
     switch (numel (objf))
      case 1
        obj_fun = objf{1};
+       obj_grd = @ (x) fd_obj_grd (x, obj_fun);
      case 2
        obj_fun = objf{1};
        obj_grd = objf{2};
@@ -223,17 +219,17 @@
     endswitch
   else
     obj_fun = objf;   # No cell array, only obj_fun set
+    obj_grd = @ (x) fd_obj_grd (x, obj_fun);
   endif
-  __sqp_obj_fun__ = obj_fun;
 
   ce_fun = @empty_cf;
   ce_grd = @empty_jac;
   if (nargin > 2)
-    ce_grd = @fd_ce_jac;
     if (iscell (cef))
       switch (numel (cef))
        case 1
          ce_fun = cef{1};
+         ce_grd = @ (x) fd_ce_jac (x, ce_fun);
        case 2
          ce_fun = cef{1};
          ce_grd = cef{2};
@@ -242,28 +238,28 @@
       endswitch
     elseif (! isempty (cef))
       ce_fun = cef;   # No cell array, only constraint equality function set
+      ce_grd = @ (x) fd_ce_jac (x, ce_fun);
     endif
   endif
-  __sqp_ce_fun__ = ce_fun;
 
   ci_fun = @empty_cf;
   ci_grd = @empty_jac;
   if (nargin > 3)
     ## constraint function given by user with possible gradient
-    __sqp_cif__ = cif;
+    globals.cif = cif;
     ## constraint function given by user without gradient
-    __sqp_cifcn__ = @empty_cf;
+    globals.cifcn = @empty_cf;
     if (iscell (cif))
       if (length (cif) > 0)
-        __sqp_cifcn__ = cif{1};
+        globals.cifcn = cif{1};
       endif
     elseif (! isempty (cif))
-      __sqp_cifcn__ = cif;
+      globals.cifcn = cif;
     endif
 
     if (nargin < 5 || (nargin > 5 && isempty (lb) && isempty (ub)))
       ## constraint inequality function only without any bounds
-      ci_grd = @fd_ci_jac;
+      ci_grd = @ (x) fd_ci_jac (x, globals.cifcn);
       if (iscell (cif))
         switch length (cif)
          case {1}
@@ -279,35 +275,33 @@
       endif
     else
       ## constraint inequality function with bounds present
-      global __sqp_lb__;
       lb_idx = ub_idx = true (size (x0));
       ub_grad = - (lb_grad = eye (rows (x0)));
       if (isvector (lb))
-        __sqp_lb__ = tmp_lb = lb(:);
+        globals.lb = tmp_lb = lb(:);
         lb_idx(:) = tmp_idx = (lb != -Inf);
-        __sqp_lb__ = __sqp_lb__(tmp_idx, 1);
+        globals.lb = globals.lb(tmp_idx, 1);
         lb_grad = lb_grad(lb_idx, :);
       elseif (isempty (lb))
         if (isa (x0, "single"))
-          __sqp_lb__ = tmp_lb = -realmax ("single");
+          globals.lb = tmp_lb = -realmax ("single");
         else
-          __sqp_lb__ = tmp_lb = -realmax;
+          globals.lb = tmp_lb = -realmax;
         endif
       else
         error ("sqp: invalid lower bound");
       endif
 
-      global __sqp_ub__;
       if (isvector (ub))
-        __sqp_ub__ = tmp_ub = ub(:);
+        globals.ub = tmp_ub = ub(:);
         ub_idx(:) = tmp_idx = (ub != Inf);
-        __sqp_ub__ = __sqp_ub__(tmp_idx, 1);
+        globals.ub = globals.ub(tmp_idx, 1);
         ub_grad = ub_grad(ub_idx, :);
       elseif (isempty (ub))
         if (isa (x0, "single"))
-          __sqp_ub__ = tmp_ub = realmax ("single");
+          globals.ub = tmp_ub = realmax ("single");
         else
-          __sqp_ub__ = tmp_ub = realmax;
+          globals.ub = tmp_ub = realmax;
         endif
       else
         error ("sqp: invalid upper bound");
@@ -317,11 +311,10 @@
         error ("sqp: upper bound smaller than lower bound");
       endif
       bounds_grad = [lb_grad; ub_grad];
-      ci_fun = @ (x) cf_ub_lb (x, lb_idx, ub_idx);
-      ci_grd = @ (x) cigrad_ub_lb (x, bounds_grad);
+      ci_fun = @ (x) cf_ub_lb (x, lb_idx, ub_idx, globals);
+      ci_grd = @ (x) cigrad_ub_lb (x, bounds_grad, globals);
     endif
 
-    __sqp_ci_fun__ = ci_fun;
   endif   # if (nargin > 3)
 
   iter_max = 100;
@@ -354,7 +347,7 @@
   x = x0;
 
   obj = feval (obj_fun, x0);
-  __sqp_nfun__ = 1;
+  globals.nfun = 1;
 
   c = feval (obj_grd, x0);
 
@@ -432,8 +425,9 @@
 
     ## Choose mu such that p is a descent direction for the chosen
     ## merit function phi.
-    [x_new, alpha, obj_new] = linesearch_L1 (x, p, obj_fun, obj_grd,
-                                             ce_fun, ci_fun, lambda, obj);
+    [x_new, alpha, obj_new, globals] = \
+        linesearch_L1 (x, p, obj_fun, obj_grd, ce_fun, ci_fun, lambda, \
+                       obj, globals);
 
     ## Evaluate objective function, constraints, and gradients at x_new.
     c_new = feval (obj_grd, x_new);
@@ -521,14 +515,13 @@
     info = 103;
   endif
 
-  nf = __sqp_nfun__;
+  nf = globals.nfun;
 
 endfunction
 
 
-function [merit, obj] = phi_L1 (obj, obj_fun, ce_fun, ci_fun, x, mu)
-
-  global __sqp_nfun__;
+function [merit, obj, globals] = phi_L1 (obj, obj_fun, ce_fun, ci_fun, \
+                                         x, mu, globals)
 
   ce = feval (ce_fun, x);
   ci = feval (ci_fun, x);
@@ -539,7 +532,7 @@
 
   if (isempty (obj))
     obj = feval (obj_fun, x);
-    __sqp_nfun__++;
+    globals.nfun++;
   endif
 
   merit = obj;
@@ -552,8 +545,9 @@
 endfunction
 
 
-function [x_new, alpha, obj] = linesearch_L1 (x, p, obj_fun, obj_grd,
-                                              ce_fun, ci_fun, lambda, obj)
+function [x_new, alpha, obj, globals] = \
+      linesearch_L1 (x, p, obj_fun, obj_grd, ce_fun, ci_fun, lambda, \
+                     obj, globals)
 
   ## Choose parameters
   ##
@@ -576,7 +570,8 @@
   c = feval (obj_grd, x);
   ce = feval (ce_fun, x);
 
-  [phi_x_mu, obj] = phi_L1 (obj, obj_fun, ce_fun, ci_fun, x, mu);
+  [phi_x_mu, obj, globals] = phi_L1 (obj, obj_fun, ce_fun, ci_fun, x, \
+                                     mu, globals);
 
   D_phi_x_mu = c' * p;
   d = feval (ci_fun, x);
@@ -589,7 +584,8 @@
   endif
 
   while (1)
-    [p1, obj] = phi_L1 ([], obj_fun, ce_fun, ci_fun, x+alpha*p, mu);
+    [p1, obj, globals] = phi_L1 ([], obj_fun, ce_fun, ci_fun, \
+                                 x+alpha*p, mu, globals);
     p2 = phi_x_mu+eta*alpha*D_phi_x_mu;
     if (p1 > p2)
       ## Reset alpha = tau_alpha * alpha for some tau_alpha in the
@@ -648,11 +644,9 @@
 endfunction
 
 
-function grd = fd_obj_grd (x)
+function grd = fd_obj_grd (x, obj_fun)
 
-  global __sqp_obj_fun__;
-
-  grd = fdgrd (__sqp_obj_fun__, x);
+  grd = fdgrd (obj_fun, x);
 
 endfunction
 
@@ -671,47 +665,40 @@
 endfunction
 
 
-function jac = fd_ce_jac (x)
+function jac = fd_ce_jac (x, ce_fun)
 
-  global __sqp_ce_fun__;
-
-  jac = fdjac (__sqp_ce_fun__, x);
+  jac = fdjac (ce_fun, x);
 
 endfunction
 
 
-function jac = fd_ci_jac (x)
+function jac = fd_ci_jac (x, cifcn)
 
-  global __sqp_cifcn__;
-  ## __sqp_cifcn__ = constraint function without gradients and lb or ub
-  jac = fdjac (__sqp_cifcn__, x);
+  ## cifcn = constraint function without gradients and lb or ub
+  jac = fdjac (cifcn, x);
 
 endfunction
 
 
-function res = cf_ub_lb (x, lbidx, ubidx)
+function res = cf_ub_lb (x, lbidx, ubidx, globals)
 
   ## combine constraint function with ub and lb
-  global __sqp_cifcn__ __sqp_lb__ __sqp_ub__
-
-  if (isempty (__sqp_cifcn__))
-    res = [x(lbidx,1)-__sqp_lb__; __sqp_ub__-x(ubidx,1)];
+  if (isempty (globals.cifcn))
+    res = [x(lbidx,1)-globals.lb; globals.ub-x(ubidx,1)];
   else
-    res = [feval(__sqp_cifcn__,x); \
-           x(lbidx,1)-__sqp_lb__; __sqp_ub__-x(ubidx,1)];
+    res = [feval(globals.cifcn,x); x(lbidx,1)-globals.lb;
+           globals.ub-x(ubidx,1)];
   endif
 
 endfunction
 
 
-function res = cigrad_ub_lb (x, bgrad)
-
-  global __sqp_cif__
+function res = cigrad_ub_lb (x, bgrad, globals)
 
-  cigradfcn = @fd_ci_jac;
+  cigradfcn = @ (x) fd_ci_jac (x, globals.cifcn);
 
-  if (iscell (__sqp_cif__) && length (__sqp_cif__) > 1)
-    cigradfcn = __sqp_cif__{2};
+  if (iscell (globals.cif) && length (globals.cif) > 1)
+    cigradfcn = globals.cif{2};
   endif
 
   if (isempty (cigradfcn))
@@ -733,6 +720,7 @@
 
 endfunction
 
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% Test Code
 
@@ -743,7 +731,7 @@
 %!endfunction
 %!
 %!function obj = __phi (x)
-%!  obj = exp(prod(x)) - 0.5*(x(1)^3+x(2)^3+1)^2;
+%!  obj = exp (prod (x)) - 0.5*(x(1)^3 + x(2)^3 + 1)^2;
 %!endfunction
 %!
 %!test
@@ -760,22 +748,23 @@
 %!
 %! obj_opt = 0.0539498477702739;
 %!
-%! assert (all (abs (x-x_opt) < 5*sqrt (eps)) && abs (obj-obj_opt) < sqrt (eps));
+%! assert (x, x_opt, 5*sqrt (eps));
+%! assert (obj, obj_opt, sqrt (eps));
 
 %% Test input validation
 %!error sqp ()
 %!error sqp (1)
 %!error sqp (1,2,3,4,5,6,7,8,9)
 %!error sqp (1,2,3,4,5)
-%!error sqp (ones(2,2))
-%!error sqp (1,cell(4,1))
-%!error sqp (1,cell(3,1),cell(3,1))
-%!error sqp (1,cell(3,1),cell(2,1),cell(3,1))
-%!error sqp (1,cell(3,1),cell(2,1),cell(2,1),ones(2,2),[])
-%!error sqp (1,cell(3,1),cell(2,1),cell(2,1),[],ones(2,2))
-%!error sqp (1,cell(3,1),cell(2,1),cell(2,1),1,-1)
-%!error sqp (1,cell(3,1),cell(2,1),cell(2,1),[],[],ones(2,2))
-%!error sqp (1,cell(3,1),cell(2,1),cell(2,1),[],[],-1)
-%!error sqp (1,cell(3,1),cell(2,1),cell(2,1),[],[],1.5)
-%!error sqp (1,cell(3,1),cell(2,1),cell(2,1),[],[],[],ones(2,2))
-%!error sqp (1,cell(3,1),cell(2,1),cell(2,1),[],[],[],-1)
+%!error sqp (ones (2,2))
+%!error sqp (1, cell (4,1))
+%!error sqp (1, cell (3,1), cell (3,1))
+%!error sqp (1, cell (3,1), cell (2,1), cell (3,1))
+%!error sqp (1, cell (3,1), cell (2,1), cell (2,1), ones (2,2),[])
+%!error sqp (1, cell (3,1), cell (2,1), cell (2,1),[], ones (2,2))
+%!error sqp (1, cell (3,1), cell (2,1), cell (2,1),1,-1)
+%!error sqp (1, cell (3,1), cell (2,1), cell (2,1),[],[], ones (2,2))
+%!error sqp (1, cell (3,1), cell (2,1), cell (2,1),[],[],-1)
+%!error sqp (1, cell (3,1), cell (2,1), cell (2,1),[],[],1.5)
+%!error sqp (1, cell (3,1), cell (2,1), cell (2,1),[],[],[], ones (2,2))
+%!error sqp (1, cell (3,1), cell (2,1), cell (2,1),[],[],[],-1)
--- a/scripts/path/matlabroot.m
+++ b/scripts/path/matlabroot.m
@@ -25,11 +25,13 @@
 ## @seealso{OCTAVE_HOME}
 ## @end deftypefn
 
-function val = matlabroot ()
+function retval = matlabroot ()
 
-  val = OCTAVE_HOME;
+  retval = OCTAVE_HOME;
 
 endfunction
 
-%!assert (matlabroot(), OCTAVE_HOME())
+
 
+%!assert (matlabroot (), OCTAVE_HOME ())
+
--- a/scripts/path/pathdef.m
+++ b/scripts/path/pathdef.m
@@ -21,7 +21,7 @@
 ## @deftypefn {Function File} {@var{val} =} pathdef ()
 ## Return the default path for Octave.
 ## The path information is extracted from one of three sources.
-## In order of preference, those are;
+## The possible sources, in order of preference, are:
 ##
 ## @enumerate
 ## @item @file{~/.octaverc}
@@ -30,7 +30,7 @@
 ##
 ## @item Octave's path prior to changes by any octaverc.
 ## @end enumerate
-## @seealso{path, addpath, rmpath, genpath, savepath, pathsep}
+## @seealso{path, addpath, rmpath, genpath, savepath}
 ## @end deftypefn
 
 function val = pathdef ()
@@ -39,10 +39,10 @@
   pathdir = octave_config_info ("localstartupfiledir");
   site_octaverc = fullfile (pathdir, "octaverc");
 
-  ## Locate the user ~\.octaverc file.
+  ## Locate the user's ~/.octaverc file.
   user_octaverc = fullfile ("~", ".octaverc");
 
-  ## Extract the specified paths from the site and user octaverc"s.
+  ## Extract the specified paths from the site and user octavercs.
   site_path = __extractpath__ (site_octaverc);
   if (exist (user_octaverc, "file"))
     user_path = __extractpath__ (user_octaverc);
@@ -50,9 +50,7 @@
     user_path = "";
   endif
 
-  ## A path definition in the user octaverc has precedence over the
-  ## site.
-
+  ## A path definition in the user rcfile has precedence over the site rcfile.
   if (! isempty (user_path))
     val = user_path;
   elseif (! isempty (site_path))
@@ -73,9 +71,10 @@
 function specifiedpath = __extractpath__ (savefile)
 
   ## The majority of this code was borrowed from savepath.m.
-  ## FIXME -- is there some way to share the common parts instead of
-  ## duplicating?
-
+  ## FIXME: is there some way to share the common parts instead of duplicating?
+  ## ANSWER: Yes.  Create a private directory and extract this section of code
+  ##         and place it there in a new function only visible by pathdef() and
+  ##         savepath().
   beginstring = "## Begin savepath auto-created section, do not edit";
   endstring   = "## End savepath auto-created section";
 
@@ -85,31 +84,22 @@
 
   ## Parse the file if it exists to see if we should replace a section
   ## or create a section.
-  startline = 0;
-  endline = 0;
+  startline = endline = 0;
   filelines = {};
   if (exist (savefile) == 2)
-    ## read in all lines of the file
     [fid, msg] = fopen (savefile, "rt");
     if (fid < 0)
       error ("__extractpath__: could not open savefile, %s: %s", savefile, msg);
     endif
     unwind_protect
       linenum = 0;
-      while (linenum >= 0)
-        result = fgetl (fid);
-        if (isnumeric (result))
-          ## End at the end of file.
-          linenum = -1;
-        else
-          linenum++;
-          filelines{linenum} = result;
-          ## Find the first and last lines if they exist in the file.
-          if (strcmp (result, beginstring))
-            startline = linenum + 1;
-          elseif (strcmp (result, endstring))
-            endline = linenum - 1;
-          endif
+      while (ischar (line = fgetl (fid)))
+        filelines{++linenum} = line;
+        ## find the first and last lines if they exist in the file
+        if (strcmp (line, beginstring))
+          startline = linenum;
+        elseif (strcmp (line, endstring))
+          endline = linenum;
         endif
       endwhile
     unwind_protect_cleanup
--- a/scripts/path/savepath.m
+++ b/scripts/path/savepath.m
@@ -17,19 +17,21 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {} savepath (@var{file})
-## Save the portion of the current function search path, that is
-## not set during Octave's initialization process, to @var{file}.
+## @deftypefn  {Function File} {} savepath ()
+## @deftypefnx {Function File} {} savepath (@var{file})
+## @deftypefnx {Function File} {@var{status} =} savepath (@dots{})
+## Save the unique portion of the current function search path that is
+## not set during Octave's initialization process to @var{file}.
 ## If @var{file} is omitted, @file{~/.octaverc} is used.  If successful,
 ## @code{savepath} returns 0.
-## @seealso{path, addpath, rmpath, genpath, pathdef, pathsep}
+## @seealso{path, addpath, rmpath, genpath, pathdef}
 ## @end deftypefn
 
 ## Author: Bill Denney <bill@givebillmoney.com>
 
-function varargout = savepath (file)
+function retval = savepath (file)
 
-  retval = 1;
+  ret = 1;
 
   beginstring = "## Begin savepath auto-created section, do not edit";
   endstring   = "## End savepath auto-created section";
@@ -38,40 +40,30 @@
     file = fullfile ("~", ".octaverc");
   endif
 
-  ## parse the file if it exists to see if we should replace a section
-  ## or create a section
-  startline = 0;
-  endline = 0;
+  ## parse the file if it exists to see if we should replace an
+  ## existing section or create a new section
+  startline = endline = 0;
   filelines = {};
   if (exist (file) == 2)
-    ## read in all lines of the file
     [fid, msg] = fopen (file, "rt");
     if (fid < 0)
       error ("savepath: could not open file, %s: %s", file, msg);
     endif
     unwind_protect
       linenum = 0;
-      while (linenum >= 0)
-        result = fgetl (fid);
-        if (isnumeric (result))
-          ## end at the end of file
-          linenum = -1;
-        else
-          linenum = linenum + 1;
-          filelines{linenum} = result;
-          ## find the first and last lines if they exist in the file
-          if (strcmp (result, beginstring))
-            startline = linenum;
-          elseif (strcmp (result, endstring))
-            endline = linenum;
-          endif
+      while (ischar (line = fgetl (fid)))
+        filelines{++linenum} = line;
+        ## find the first and last lines if they exist in the file
+        if (strcmp (line, beginstring))
+          startline = linenum;
+        elseif (strcmp (line, endstring))
+          endline = linenum;
         endif
       endwhile
     unwind_protect_cleanup
       closeread = fclose (fid);
       if (closeread < 0)
-        error ("savepath: could not close file after reading, %s",
-               file);
+        error ("savepath: could not close file after reading, %s", file);
       endif
     end_unwind_protect
   endif
@@ -116,15 +108,16 @@
     workingpath = parsepath (path);
     command_line_path = parsepath (command_line_path ());
     octave_path = parsepath (getenv ("OCTAVE_PATH"));
-    if (isempty (pathdef ()))
+    pathdef = pathdef ();
+    if (isempty (pathdef))
       ## This occurs when running octave via run-octave. In this instance
       ## the entire path is specified via the command line and pathdef()
       ## is empty.
-      [tmp, n] = setdiff (workingpath, octave_path);
+      [~, n] = setdiff (workingpath, octave_path);
       default_path = command_line_path;
     else
-      [tmp, n] = setdiff (workingpath, union (command_line_path, octave_path));
-      default_path = parsepath (pathdef ());
+      [~, n] = setdiff (workingpath, union (command_line_path, octave_path));
+      default_path = parsepath (pathdef);
     endif
     ## This is the path we'd like to preserve when octave is run.
     path_to_preserve = workingpath (sort (n));
@@ -133,34 +126,33 @@
     [pkg_user, pkg_system] = pkg ("list");
     pkg_user_path = cell (1, numel (pkg_user));
     pkg_system_path = cell (1, numel (pkg_system));
-    for n = 1:numel(pkg_user)
+    for n = 1:numel (pkg_user)
       pkg_user_path{n} = pkg_user{n}.archprefix;
     endfor
-    for n = 1:numel(pkg_system)
+    for n = 1:numel (pkg_system)
       pkg_system_path{n} = pkg_system{n}.archprefix;
     endfor
     pkg_path = union (pkg_user_path, pkg_system_path);
 
     ## Rely on Octave's initialization to include the pkg path elements.
     if (! isempty (pkg_path))
-      [tmp, n] = setdiff (path_to_preserve, strcat (pkg_path, ":"));
-      path_to_preserve = path_to_preserve (sort (n));
+      [~, n] = setdiff (path_to_preserve, strcat (pkg_path, ":"));
+      path_to_preserve = path_to_preserve(sort (n));
     endif
 
     ## Split the path to be saved into two groups. Those path elements that
     ## belong at the beginning and those at the end.
     if (! isempty (default_path))
-      n1 = strmatch (default_path{1}, path_to_preserve, "exact");
-      n2 = strmatch (default_path{end}, path_to_preserve, "exact");
+      n1 = find (strcmp (default_path{1}, path_to_preserve));
+      n2 = find (strcmp (default_path{end}, path_to_preserve));
       n_middle = round (0.5*(n1+n2));
-      [tmp, n] = setdiff (path_to_preserve, default_path);
-      path_to_save = path_to_preserve (sort (n));
+      [~, n] = setdiff (path_to_preserve, default_path);
+      path_to_save = path_to_preserve(sort (n));
       ## Remove pwd
-      path_to_save = path_to_save (! strcmpi (path_to_save,
-                                              strcat (".", pathsep)));
+      path_to_save = path_to_save(! strcmp (path_to_save, ["." pathsep]));
       n = ones (size (path_to_save));
-      for m = 1:numel(path_to_save)
-        n(m) = strmatch (path_to_save{m}, path_to_preserve);
+      for m = 1:numel (path_to_save)
+        n(m) = find (strcmp (path_to_save{m}, path_to_preserve));
       endfor
       path_to_save_begin = path_to_save(n <= n_middle);
       path_to_save_end   = path_to_save(n > n_middle);
@@ -199,16 +191,16 @@
     endif
   end_unwind_protect
 
-  retval = 0;
+  ret = 0;
 
-  if (nargout == 1)
-    varargout{1} = retval;
+  if (nargout > 0)
+    retval = ret;
   endif
 
 endfunction
 
 function path_elements = parsepath (p)
   pat = sprintf ('([^%s]+[%s$])', pathsep, pathsep);
-  [~, ~, ~, path_elements] = regexpi (strcat (p, pathsep), pat);
+  path_elements = regexpi (strcat (p, pathsep), pat, "match");
 endfunction
 
--- a/scripts/pkg/module.mk
+++ b/scripts/pkg/module.mk
@@ -1,7 +1,45 @@
 FCN_FILE_DIRS += pkg
 
 pkg_PRIVATE_FCN_FILES = \
-  pkg/private/get_forge_pkg.m
+  pkg/private/absolute_pathname.m \
+  pkg/private/build.m \
+  pkg/private/configure_make.m \
+  pkg/private/copy_files.m \
+  pkg/private/create_pkgadddel.m \
+  pkg/private/describe.m \
+  pkg/private/dirempty.m \
+  pkg/private/extract_pkg.m \
+  pkg/private/finish_installation.m \
+  pkg/private/fix_depends.m \
+  pkg/private/fix_version.m \
+  pkg/private/generate_lookfor_cache.m \
+  pkg/private/get_description.m \
+  pkg/private/get_forge_download.m \
+  pkg/private/get_forge_pkg.m \
+  pkg/private/getarch.m \
+  pkg/private/getarchdir.m \
+  pkg/private/getarchprefix.m \
+  pkg/private/get_unsatisfied_deps.m \
+  pkg/private/install.m \
+  pkg/private/installed_packages.m \
+  pkg/private/is_architecture_dependent.m \
+  pkg/private/list_forge_packages.m \
+  pkg/private/load_package_dirs.m \
+  pkg/private/load_packages.m \
+  pkg/private/load_packages_and_dependencies.m \
+  pkg/private/packinfo_copy_file.m \
+  pkg/private/parse_pkg_idx.m \
+  pkg/private/prepare_installation.m \
+  pkg/private/print_package_description.m \
+  pkg/private/rebuild.m \
+  pkg/private/repackage.m \
+  pkg/private/save_order.m \
+  pkg/private/shell.m \
+  pkg/private/uninstall.m \
+  pkg/private/unload_packages.m \
+  pkg/private/verify_directory.m \
+  pkg/private/write_index.m
+
 
 pkg_FCN_FILES = \
   pkg/pkg.m \
--- a/scripts/pkg/pkg.m
+++ b/scripts/pkg/pkg.m
@@ -1,5 +1,6 @@
 ## Copyright (C) 2005-2012 S�ren Hauberg
 ## Copyright (C) 2010 VZLU Prague, a.s.
+## Copyright (C) 2012 Carlo de Falco
 ##
 ## This file is part of Octave.
 ##
@@ -136,7 +137,7 @@
 ## [user_packages, system_packages] = pkg ("list")
 ## @end example
 ##
-## The option '-forge' lists packages available at the Octave-Forge repository.
+## The option "-forge" lists packages available at the Octave-Forge repository.
 ## This requires an internet connection and the cURL library.  For example:
 ##
 ## @example
@@ -145,7 +146,7 @@
 ##
 ## @item describe
 ## Show a short description of the named installed packages, with the option
-## '-verbose' also list functions provided by the package.  For example,
+## "-verbose" also list functions provided by the package.  For example,
 ##
 ## @example
 ## pkg describe -verbose all
@@ -267,9 +268,14 @@
   persistent local_list = tilde_expand (fullfile ("~", ".octave_packages"));
   persistent global_list = fullfile (OCTAVE_HOME (), "share", "octave",
                                      "octave_packages");
+
+  confirm_recursive_rmdir (false, "local");
+
   mlock ();
 
-  global_install = issuperuser ();
+  ## If user is superuser set global_istall to true
+  ## FIXME: is it OK to set this always true on windows?
+  global_install = ((ispc () && ! isunix ()) || (geteuid () == 0));
 
   if (prefix == -1)
     if (global_install)
@@ -415,6 +421,16 @@
         global_packages = archprefix;
       elseif (length (files) >= 1 && nargout <= 2 && ischar (files{1}))
         prefix = files{1};
+        try
+          prefix = absolute_pathname (prefix);
+        catch
+          [status, msg, msgid] = mkdir (prefix);
+          if (status == 0)
+            error("cannot create prefix %s: %s", prefix, msg);
+          endif
+          warning ("creating the directory %s\n", prefix);
+          prefix = absolute_pathname (prefix);
+        end_try_catch
         prefix = absolute_pathname (prefix);
         local_packages = prefix;
         user_prefix = true;
@@ -423,7 +439,10 @@
           try
             archprefix = absolute_pathname (archprefix);
           catch
-            mkdir (archprefix);
+            [status, msg, msgid] = mkdir (archprefix);
+            if (status == 0)
+              error("cannot create archprefix %s: %s", archprefix, msg);
+            endif
             warning ("creating the directory %s\n", archprefix);
             archprefix = absolute_pathname (archprefix);
           end_try_catch
@@ -533,1905 +552,3 @@
       error ("you must specify a valid action for 'pkg'. See 'help pkg' for details");
   endswitch
 endfunction
-
-function descriptions = rebuild (prefix, archprefix, list, files, auto, verbose)
-  if (isempty (files))
-    [dirlist, err, msg] = readdir (prefix);
-    if (err)
-      error ("couldn't read directory %s: %s", prefix, msg);
-    endif
-    ## the two first entries of dirlist are "." and ".."
-    dirlist([1,2]) = [];
-  else
-    old_descriptions = installed_packages (list, list);
-    wd = pwd ();
-    unwind_protect
-      cd (prefix);
-      dirlist = glob (cellfun(@(x) cstrcat(x, '-*'), files, 'uniformoutput', 0));
-    unwind_protect_cleanup
-      cd (wd);
-    end_unwind_protect
-  endif
-  descriptions = {};
-  for k = 1:length (dirlist)
-    descfile = fullfile (prefix, dirlist{k}, "packinfo", "DESCRIPTION");
-    if (verbose)
-      printf ("recreating package description from %s\n", dirlist{k});
-    endif
-    if (exist (descfile, "file"))
-      desc = get_description (descfile);
-      desc.dir = fullfile (prefix, dirlist{k});
-      desc.archprefix = fullfile (archprefix, cstrcat (desc.name, "-",
-                                  desc.version));
-      if (auto != 0)
-        if (exist (fullfile (desc.dir, "packinfo", ".autoload"), "file"))
-          unlink (fullfile (desc.dir, "packinfo", ".autoload"));
-        endif
-        if (auto < 0)
-          desc.autoload = 0;
-        elseif (auto > 0)
-          desc.autoload = 1;
-          fclose (fopen (fullfile (desc.dir, "packinfo", ".autoload"), "wt"));
-        endif
-      else
-        if (exist (fullfile (desc.dir, "packinfo", ".autoload"), "file"))
-          desc.autoload = 1;
-        else
-          desc.autoload = 0;
-        endif
-      endif
-      descriptions{end + 1} = desc;
-    elseif (verbose)
-      warning ("directory %s is not a valid package", dirlist{k});
-    endif
-  endfor
-
-  if (! isempty (files))
-    ## We are rebuilding for a particular package(s) so we should take
-    ## care to keep the other untouched packages in the descriptions
-    descriptions = {descriptions{:}, old_descriptions{:}};
-
-    dup = [];
-    for i = 1:length (descriptions)
-      if (find (dup, i))
-        continue;
-      endif
-      for j = (i+1):length (descriptions)
-        if (find (dup, j))
-          continue;
-        endif
-        if (strcmp (descriptions{i}.name, descriptions{j}.name))
-          dup = [dup, j];
-        endif
-      endfor
-    endfor
-    if (! isempty (dup))
-      descriptions (dup) = [];
-    endif
-  endif
-endfunction
-
-function build (files, handle_deps, autoload, verbose)
-  if (length (files) < 1)
-    error ("insufficient number of files");
-  endif
-  builddir = files{1};
-  if (! exist (builddir, "dir"))
-    warning ("creating build directory %s", builddir);
-    [status, msg] = mkdir (builddir);
-    if (status != 1)
-      error ("could not create installation directory: %s", msg);
-    endif
-  endif
-  builddir = absolute_pathname (builddir);
-  installdir = fullfile (builddir, "install");
-  if (! exist (installdir, "dir"))
-    [status, msg] = mkdir (installdir);
-    if (status != 1)
-      error ("could not create installation directory: %s", msg);
-    endif
-  endif
-  files(1) = [];
-  buildlist = fullfile (builddir, "octave_packages");
-  install (files, handle_deps, autoload, installdir, installdir, verbose,
-           buildlist, "", false);
-  unwind_protect
-    repackage (builddir, buildlist);
-  unwind_protect_cleanup
-    unload_packages ({"all"}, handle_deps, buildlist, "");
-    if (exist (installdir, "dir"))
-      rm_rf (installdir);
-    endif
-    if (exist (buildlist, "file"))
-      unlink (buildlist);
-    endif
-  end_unwind_protect
-endfunction
-
-function install (files, handle_deps, autoload, prefix, archprefix, verbose,
-                  local_list, global_list, global_install)
-
-  ## Check that the directory in prefix exist. If it doesn't: create it!
-  if (! exist (prefix, "dir"))
-    warning ("creating installation directory %s", prefix);
-    [status, msg] = mkdir (prefix);
-    if (status != 1)
-      error ("could not create installation directory: %s", msg);
-    endif
-  endif
-
-  ## Get the list of installed packages.
-  [local_packages, global_packages] = installed_packages (local_list,
-                                                          global_list);
-
-  installed_pkgs_lst = {local_packages{:}, global_packages{:}};
-
-  if (global_install)
-    packages = global_packages;
-  else
-    packages = local_packages;
-  endif
-
-  ## Uncompress the packages and read the DESCRIPTION files.
-  tmpdirs = packdirs = descriptions = {};
-  try
-    ## Warn about non existent files.
-    for i = 1:length (files)
-      if (isempty (glob(files{i})))
-        warning ("file %s does not exist", files{i});
-      endif
-    endfor
-
-    ## Unpack the package files and read the DESCRIPTION files.
-    files = glob (files);
-    packages_to_uninstall = [];
-    for i = 1:length (files)
-      tgz = files{i};
-
-      if (exist (tgz, "file"))
-        ## Create a temporary directory.
-        tmpdir = tmpnam ();
-        tmpdirs{end+1} = tmpdir;
-        if (verbose)
-          printf ("mkdir (%s)\n", tmpdir);
-        endif
-        [status, msg] = mkdir (tmpdir);
-        if (status != 1)
-          error ("couldn't create temporary directory: %s", msg);
-        endif
-
-        ## Uncompress the package.
-        if (verbose)
-          printf ("untar (%s, %s)\n", tgz, tmpdir);
-        endif
-        untar (tgz, tmpdir);
-
-        ## Get the name of the directories produced by tar.
-        [dirlist, err, msg] = readdir (tmpdir);
-        if (err)
-          error ("couldn't read directory produced by tar: %s", msg);
-        endif
-
-        if (length (dirlist) > 3)
-          error ("bundles of packages are not allowed");
-        endif
-      endif
-
-      ## The filename pointed to an uncompressed package to begin with.
-      if (exist (tgz, "dir"))
-        dirlist = {".", "..", tgz};
-      endif
-
-      if (exist (tgz, "file") || exist (tgz, "dir"))
-        ## The two first entries of dirlist are "." and "..".
-        if (exist (tgz, "file"))
-          packdir = fullfile (tmpdir, dirlist{3});
-        else
-          packdir = fullfile (pwd(), dirlist{3});
-        endif
-        packdirs{end+1} = packdir;
-
-        ## Make sure the package contains necessary files.
-        verify_directory (packdir);
-
-        ## Read the DESCRIPTION file.
-        filename = fullfile (packdir, "DESCRIPTION");
-        desc = get_description (filename);
-
-        ## Verify that package name corresponds with filename.
-        [dummy, nm] = fileparts (tgz);
-        if ((length (nm) >= length (desc.name))
-            && ! strcmp (desc.name, nm(1:length(desc.name))))
-          error ("package name '%s' doesn't correspond to its filename '%s'",
-                 desc.name, nm);
-        endif
-
-        ## Set default installation directory.
-        desc.dir = fullfile (prefix, cstrcat (desc.name, "-", desc.version));
-
-        ## Set default architectire dependent installation directory.
-        desc.archprefix = fullfile (archprefix, cstrcat (desc.name, "-",
-                                                         desc.version));
-
-        ## Save desc.
-        descriptions{end+1} = desc;
-
-        ## Are any of the new packages already installed?
-        ## If so we'll remove the old version.
-        for j = 1:length (packages)
-          if (strcmp (packages{j}.name, desc.name))
-            packages_to_uninstall(end+1) = j;
-          endif
-        endfor
-      endif
-    endfor
-  catch
-    ## Something went wrong, delete tmpdirs.
-    for i = 1:length (tmpdirs)
-      rm_rf (tmpdirs{i});
-    endfor
-    rethrow (lasterror ());
-  end_try_catch
-
-  ## Check dependencies.
-  if (handle_deps)
-    ok = true;
-    error_text = "";
-    for i = 1:length (descriptions)
-      desc = descriptions{i};
-      idx2 = setdiff (1:length(descriptions), i);
-      if (global_install)
-        ## Global installation is not allowed to have dependencies on locally
-        ## installed packages.
-        idx1 = setdiff (1:length(global_packages), packages_to_uninstall);
-        pseudo_installed_packages = {global_packages{idx1}, ...
-                                     descriptions{idx2}};
-      else
-        idx1 = setdiff (1:length(local_packages), packages_to_uninstall);
-        pseudo_installed_packages = {local_packages{idx1}, ...
-                                     global_packages{:}, ...
-                                     descriptions{idx2}};
-      endif
-      bad_deps = get_unsatisfied_deps (desc, pseudo_installed_packages);
-      ## Are there any unsatisfied dependencies?
-      if (! isempty (bad_deps))
-        ok = false;
-        for i = 1:length (bad_deps)
-          dep = bad_deps{i};
-          error_text = cstrcat (error_text, " ", desc.name, " needs ",
-                               dep.package, " ", dep.operator, " ",
-                               dep.version, "\n");
-        endfor
-      endif
-    endfor
-
-    ## Did we find any unsatisfied dependencies?
-    if (! ok)
-      error ("the following dependencies where unsatisfied:\n  %s", error_text);
-    endif
-  endif
-
-  ## Prepare each package for installation.
-  try
-    for i = 1:length (descriptions)
-      desc = descriptions{i};
-      pdir = packdirs{i};
-      prepare_installation (desc, pdir);
-      configure_make (desc, pdir, verbose);
-    endfor
-  catch
-    ## Something went wrong, delete tmpdirs.
-    for i = 1:length (tmpdirs)
-      rm_rf (tmpdirs{i});
-    endfor
-    rethrow (lasterror ());
-  end_try_catch
-
-  ## Uninstall the packages that will be replaced.
-  try
-    for i = packages_to_uninstall
-      if (global_install)
-        uninstall ({global_packages{i}.name}, false, verbose, local_list,
-                   global_list, global_install);
-      else
-        uninstall ({local_packages{i}.name}, false, verbose, local_list,
-                   global_list, global_install);
-      endif
-    endfor
-  catch
-    ## Something went wrong, delete tmpdirs.
-    for i = 1:length (tmpdirs)
-      rm_rf (tmpdirs{i});
-    endfor
-    rethrow (lasterror ());
-  end_try_catch
-
-  ## Install each package.
-  try
-    for i = 1:length (descriptions)
-      desc = descriptions{i};
-      pdir = packdirs{i};
-      copy_files (desc, pdir, global_install);
-      create_pkgadddel (desc, pdir, "PKG_ADD", global_install);
-      create_pkgadddel (desc, pdir, "PKG_DEL", global_install);
-      finish_installation (desc, pdir, global_install);
-      generate_lookfor_cache (desc);
-    endfor
-  catch
-    ## Something went wrong, delete tmpdirs.
-    for i = 1:length (tmpdirs)
-      rm_rf (tmpdirs{i});
-    endfor
-    for i = 1:length (descriptions)
-      rm_rf (descriptions{i}.dir);
-      rm_rf (getarchdir (descriptions{i}));
-    endfor
-    rethrow (lasterror ());
-  end_try_catch
-
-  ## Check if the installed directory is empty. If it is remove it
-  ## from the list.
-  for i = length (descriptions):-1:1
-    if (dirempty (descriptions{i}.dir, {"packinfo", "doc"})
-        && dirempty (getarchdir (descriptions{i})))
-      warning ("package %s is empty\n", descriptions{i}.name);
-      rm_rf (descriptions{i}.dir);
-      rm_rf (getarchdir (descriptions{i}));
-      descriptions(i) = [];
-    endif
-  endfor
-
-  ## If the package requested that it is autoloaded, or the installer
-  ## requested that it is, then mark the package as autoloaded.
-  for i = length (descriptions):-1:1
-    if (autoload > 0 || (autoload == 0 && isautoload (descriptions(i))))
-      fclose (fopen (fullfile (descriptions{i}.dir, "packinfo",
-                               ".autoload"), "wt"));
-      descriptions{i}.autoload = 1;
-    endif
-  endfor
-
-  ## Add the packages to the package list.
-  try
-    if (global_install)
-      idx = setdiff (1:length(global_packages), packages_to_uninstall);
-      global_packages = save_order ({global_packages{idx}, descriptions{:}});
-      save (global_list, "global_packages");
-      installed_pkgs_lst = {local_packages{:}, global_packages{:}};
-    else
-      idx = setdiff (1:length(local_packages), packages_to_uninstall);
-      local_packages = save_order ({local_packages{idx}, descriptions{:}});
-      save (local_list, "local_packages");
-      installed_pkgs_lst = {local_packages{:}, global_packages{:}};
-    endif
-  catch
-    ## Something went wrong, delete tmpdirs.
-    for i = 1:length (tmpdirs)
-      rm_rf (tmpdirs{i});
-    endfor
-    for i = 1:length (descriptions)
-      rm_rf (descriptions{i}.dir);
-    endfor
-    if (global_install)
-      printf ("error: couldn't append to %s\n", global_list);
-    else
-      printf ("error: couldn't append to %s\n", local_list);
-    endif
-    rethrow (lasterror ());
-  end_try_catch
-
-  ## All is well, let's clean up.
-  for i = 1:length (tmpdirs)
-    [status, msg] = rm_rf (tmpdirs{i});
-    if (status != 1)
-      warning ("couldn't clean up after my self: %s\n", msg);
-    endif
-  endfor
-
-  ## Add the newly installed packages to the path, so the user
-  ## can begin using them. Only load them if they are marked autoload.
-  if (length (descriptions) > 0)
-    idx = [];
-    for i = 1:length (descriptions)
-      if (isautoload (descriptions(i)))
-        nm = descriptions{i}.name;
-        for j = 1:length (installed_pkgs_lst)
-          if (strcmp (nm, installed_pkgs_lst{j}.name))
-            idx (end + 1) = j;
-            break;
-          endif
-        endfor
-      endif
-    endfor
-    load_packages_and_dependencies (idx, handle_deps, installed_pkgs_lst,
-                                    global_install);
-  endif
-
-  ## If there's a NEWS file, mention it
-  ## we are checking if desc exists too because it's possible to ge to this point
-  ## without creating it such as giving an invalid filename for the package
-  if (exist ("desc", "var") && exist (fullfile (desc.dir, "packinfo", "NEWS"), "file"))
-    printf ("For information about changes from previous versions of the %s package, run 'news (\"%s\")'.\n",
-            desc.name, desc.name);
-  endif
-
-endfunction
-
-function uninstall (pkgnames, handle_deps, verbose, local_list,
-                    global_list, global_install)
-  ## Get the list of installed packages.
-  [local_packages, global_packages] = installed_packages(local_list,
-                                                         global_list);
-  if (global_install)
-    installed_pkgs_lst = {local_packages{:}, global_packages{:}};
-  else
-    installed_pkgs_lst = local_packages;
-  endif
-
-  num_packages = length (installed_pkgs_lst);
-  delete_idx = [];
-  for i = 1:num_packages
-    cur_name = installed_pkgs_lst{i}.name;
-    if (any (strcmp (cur_name, pkgnames)))
-      delete_idx(end+1) = i;
-    endif
-  endfor
-
-  ## Are all the packages that should be uninstalled already installed?
-  if (length (delete_idx) != length (pkgnames))
-    if (global_install)
-      ## Try again for a locally installed package.
-      installed_pkgs_lst = local_packages;
-
-      num_packages = length (installed_pkgs_lst);
-      delete_idx = [];
-      for i = 1:num_packages
-        cur_name = installed_pkgs_lst{i}.name;
-        if (any (strcmp (cur_name, pkgnames)))
-          delete_idx(end+1) = i;
-        endif
-      endfor
-      if (length (delete_idx) != length (pkgnames))
-        ## FIXME: We should have a better error message.
-        warning ("some of the packages you want to uninstall are not installed");
-      endif
-    else
-      ## FIXME: We should have a better error message.
-      warning ("some of the packages you want to uninstall are not installed");
-    endif
-  endif
-
-  ## Compute the packages that will remain installed.
-  idx = setdiff (1:num_packages, delete_idx);
-  remaining_packages = {installed_pkgs_lst{idx}};
-
-  ## Check dependencies.
-  if (handle_deps)
-    error_text = "";
-    for i = 1:length (remaining_packages)
-      desc = remaining_packages{i};
-      bad_deps = get_unsatisfied_deps (desc, remaining_packages);
-
-      ## Will the uninstallation break any dependencies?
-      if (! isempty (bad_deps))
-        for i = 1:length (bad_deps)
-          dep = bad_deps{i};
-          error_text = cstrcat (error_text, " ", desc.name, " needs ",
-                               dep.package, " ", dep.operator, " ",
-                               dep.version, "\n");
-        endfor
-      endif
-    endfor
-
-    if (! isempty (error_text))
-      error ("the following dependencies where unsatisfied:\n  %s", error_text);
-    endif
-  endif
-
-  ## Delete the directories containing the packages.
-  for i = delete_idx
-    desc = installed_pkgs_lst{i};
-    ## If an 'on_uninstall.m' exist, call it!
-    if (exist (fullfile (desc.dir, "packinfo", "on_uninstall.m"), "file"))
-      wd = pwd ();
-      cd (fullfile (desc.dir, "packinfo"));
-      on_uninstall (desc);
-      cd (wd);
-    endif
-    ## Do the actual deletion.
-    if (desc.loaded)
-      rmpath (desc.dir);
-      if (exist (getarchdir (desc)))
-        rmpath (getarchdir (desc));
-      endif
-    endif
-    if (exist (desc.dir, "dir"))
-      [status, msg] = rm_rf (desc.dir);
-      if (status != 1)
-        error ("couldn't delete directory %s: %s", desc.dir, msg);
-      endif
-      [status, msg] = rm_rf (getarchdir (desc));
-      if (status != 1)
-        error ("couldn't delete directory %s: %s", getarchdir (desc), msg);
-      endif
-      if (dirempty (desc.archprefix))
-        rm_rf (desc.archprefix);
-      endif
-    else
-      warning ("directory %s previously lost", desc.dir);
-    endif
-  endfor
-
-  ## Write a new ~/.octave_packages.
-  if (global_install)
-    if (length (remaining_packages) == 0)
-      unlink (global_list);
-    else
-      global_packages = save_order (remaining_packages);
-      save (global_list, "global_packages");
-    endif
-  else
-    if (length (remaining_packages) == 0)
-      unlink (local_list);
-    else
-      local_packages = save_order (remaining_packages);
-      save (local_list, "local_packages");
-    endif
-  endif
-
-endfunction
-
-function [pkg_desc_list, flag] = describe (pkgnames, verbose,
-                                           local_list, global_list)
-
-  ## Get the list of installed packages.
-  installed_pkgs_lst = installed_packages(local_list, global_list);
-  num_packages = length (installed_pkgs_lst);
-
-
-  describe_all = false;
-  if (any (strcmp ("all", pkgnames)))
-    describe_all = true;
-    flag(1:num_packages) = {"Not Loaded"};
-    num_pkgnames = num_packages;
-  else
-    num_pkgnames = length (pkgnames);
-    flag(1:num_pkgnames) = {"Not installed"};
-  endif
-
-  for i = 1:num_packages
-    curr_name = installed_pkgs_lst{i}.name;
-    if (describe_all)
-      name_pos = i;
-    else
-      name_pos = find(strcmp (curr_name, pkgnames));
-    endif
-
-    if (! isempty (name_pos))
-      if (installed_pkgs_lst{i}.loaded)
-        flag{name_pos} = "Loaded";
-      else
-        flag{name_pos} = "Not loaded";
-      endif
-
-      pkg_desc_list{name_pos}.name = installed_pkgs_lst{i}.name;
-      pkg_desc_list{name_pos}.version = installed_pkgs_lst{i}.version;
-      pkg_desc_list{name_pos}.description = installed_pkgs_lst{i}.description;
-      pkg_desc_list{name_pos}.provides = parse_pkg_idx (installed_pkgs_lst{i}.dir);
-
-    endif
-  endfor
-
-  non_inst = find (strcmp (flag, "Not installed"));
-  if (! isempty (non_inst))
-    if (nargout < 2)
-      non_inst_str = sprintf (" %s ", pkgnames{non_inst});
-      error ("some packages are not installed: %s", non_inst_str);
-    else
-      pkg_desc_list{non_inst} = struct ("name", {}, "description",
-                                        {}, "provides", {});
-    endif
-  endif
-
-  if (nargout == 0)
-    for i = 1:num_pkgnames
-      print_package_description (pkg_desc_list{i}.name,
-                                 pkg_desc_list{i}.version,
-                                 pkg_desc_list{i}.provides,
-                                 pkg_desc_list{i}.description,
-                                 flag{i}, verbose);
-    endfor
-  endif
-
-endfunction
-
-## AUXILIARY FUNCTIONS
-
-## Read an INDEX file.
-function [pkg_idx_struct] = parse_pkg_idx (packdir)
-
-  index_file = fullfile (packdir, "packinfo", "INDEX");
-
-  if (! exist (index_file, "file"))
-    error ("could not find any INDEX file in directory %s, try 'pkg rebuild all' to generate missing INDEX files", packdir);
-  endif
-
-
-  [fid, msg] = fopen (index_file, "r");
-  if (fid == -1)
-    error ("the INDEX file %s could not be read: %s",
-           index_file, msg);
-  endif
-
-  cat_num = 1;
-  pkg_idx_struct{1}.category = "Uncategorized";
-  pkg_idx_struct{1}.functions = {};
-
-  line = fgetl (fid);
-  while (isempty (strfind (line, ">>")) && ! feof (fid))
-    line = fgetl (fid);
-  endwhile
-
-  while (! feof (fid) || line != -1)
-    if (! any (! isspace (line)) || line(1) == "#" || any (line == "="))
-      ## Comments,  blank lines or comments about unimplemented
-      ## functions: do nothing
-      ## FIXME: probably comments and pointers to external functions
-      ## could be treated better when printing to screen?
-    elseif (! isempty (strfind (line, ">>")))
-      ## Skip package name and description as they are in DESCRIPTION
-      ## already.
-    elseif (! isspace (line(1)))
-      ## Category.
-      if (! isempty (pkg_idx_struct{cat_num}.functions))
-        pkg_idx_struct{++cat_num}.functions = {};
-      endif
-      pkg_idx_struct{cat_num}.category = deblank (line);
-    else
-      ## Function names.
-      while (any (! isspace (line)))
-        [fun_name, line] = strtok (line);
-        pkg_idx_struct{cat_num}.functions{end+1} = deblank (fun_name);
-      endwhile
-    endif
-    line = fgetl (fid);
-  endwhile
-  fclose (fid);
-endfunction
-
-function print_package_description (pkg_name, pkg_ver, pkg_idx_struct,
-                                    pkg_desc, status, verbose)
-
-  printf ("---\nPackage name:\n\t%s\n", pkg_name);
-  printf ("Version:\n\t%s\n", pkg_ver);
-  printf ("Short description:\n\t%s\n", pkg_desc);
-  printf ("Status:\n\t%s\n", status);
-  if (verbose)
-    printf ("---\nProvides:\n");
-    for i = 1:length(pkg_idx_struct)
-      if (! isempty (pkg_idx_struct{i}.functions))
-        printf ("%s\n", pkg_idx_struct{i}.category);
-        for j = 1:length(pkg_idx_struct{i}.functions)
-          printf ("\t%s\n", pkg_idx_struct{i}.functions{j});
-        endfor
-      endif
-    endfor
-  endif
-
-endfunction
-
-
-function pth = absolute_pathname (pth)
-  [status, msg, msgid] = fileattrib (pth);
-  if (status != 1)
-    error ("could not find the file or path %s", pth);
-  else
-    pth = msg.Name;
-  endif
-endfunction
-
-function repackage (builddir, buildlist)
-  packages = installed_packages (buildlist, buildlist);
-
-  wd = pwd();
-  for i = 1 : length(packages)
-    pack = packages{i};
-    unwind_protect
-      cd (builddir);
-      mkdir (pack.name);
-      mkdir (fullfile (pack.name, "inst"));
-      copyfile (fullfile (pack.dir, "*"), fullfile (pack.name, "inst"));
-      movefile (fullfile (pack.name, "inst","packinfo", "*"), pack.name);
-      if (exist (fullfile (pack.name, "inst","packinfo", ".autoload"), "file"))
-        unlink (fullfile (pack.name, "inst","packinfo", ".autoload"));
-      endif
-      rmdir (fullfile (pack.name, "inst", "packinfo"));
-      if (exist (fullfile (pack.name, "inst", "doc"), "dir"))
-        movefile (fullfile (pack.name, "inst", "doc"), pack.name);
-      endif
-      if (exist (fullfile (pack.name, "inst", "bin"), "dir"))
-        movefile (fullfile (pack.name, "inst", "bin"), pack.name);
-      endif
-      archdir = fullfile (pack.archprefix, cstrcat (pack.name, "-",
-                          pack.version), getarch ());
-      if (exist (archdir, "dir"))
-        if (exist (fullfile (pack.name, "inst", "PKG_ADD"), "file"))
-          unlink (fullfile (pack.name, "inst", "PKG_ADD"));
-        endif
-        if (exist (fullfile (pack.name, "inst", "PKG_DEL"), "file"))
-          unlink (fullfile (pack.name, "inst", "PKG_DEL"));
-        endif
-        if (exist (fullfile (archdir, "PKG_ADD"), "file"))
-          movefile (fullfile (archdir, "PKG_ADD"),
-                    fullfile (pack.name, "PKG_ADD"));
-        endif
-        if (exist (fullfile (archdir, "PKG_DEL"), "file"))
-          movefile (fullfile (archdir, "PKG_DEL"),
-                    fullfile (pack.name, "PKG_DEL"));
-        endif
-      else
-        if (exist (fullfile (pack.name, "inst", "PKG_ADD"), "file"))
-          movefile (fullfile (pack.name, "inst", "PKG_ADD"),
-                    fullfile (pack.name, "PKG_ADD"));
-        endif
-        if (exist (fullfile (pack.name, "inst", "PKG_DEL"), "file"))
-          movefile (fullfile (pack.name, "inst", "PKG_DEL"),
-                    fullfile (pack.name, "PKG_DEL"));
-        endif
-      endif
-      tfile = cstrcat (pack.name, "-", pack.version, ".tar");
-      tar (tfile, pack.name);
-      try
-        gzip (tfile);
-        unlink (tfile);
-      catch
-        warning ("failed to compress %s", tfile);
-      end_try_catch
-    unwind_protect_cleanup
-      if (exist (pack.name, "dir"))
-        rm_rf (pack.name);
-      endif
-      cd (wd);
-    end_unwind_protect
-  endfor
-endfunction
-
-function auto = isautoload (desc)
-  auto = false;
-  if (isfield (desc{1}, "autoload"))
-    a = desc{1}.autoload;
-    if ((isnumeric (a) && a > 0)
-        || (ischar (a) && (strcmpi (a, "true")
-                         || strcmpi (a, "on")
-                         || strcmpi (a, "yes")
-                         || strcmpi (a, "1"))))
-      auto = true;
-    endif
-  endif
-endfunction
-
-function prepare_installation (desc, packdir)
-  ## Is there a pre_install to call?
-  if (exist (fullfile (packdir, "pre_install.m"), "file"))
-    wd = pwd ();
-    try
-      cd (packdir);
-      pre_install (desc);
-      cd (wd);
-    catch
-      cd (wd);
-      rethrow (lasterror ());
-    end_try_catch
-  endif
-
-  ## If the directory "inst" doesn't exist, we create it.
-  inst_dir = fullfile (packdir, "inst");
-  if (! exist (inst_dir, "dir"))
-    [status, msg] = mkdir (inst_dir);
-    if (status != 1)
-      rm_rf (desc.dir);
-      error ("the 'inst' directory did not exist and could not be created: %s",
-             msg);
-    endif
-  endif
-endfunction
-
-function configure_make (desc, packdir, verbose)
-  ## Perform ./configure, make, make install in "src".
-  if (exist (fullfile (packdir, "src"), "dir"))
-    src = fullfile (packdir, "src");
-    octave_bindir = octave_config_info ("bindir");
-    ver = version ();
-    mkoctfile = fullfile (octave_bindir, sprintf ("mkoctfile-%s", ver));
-    octave_config = fullfile (octave_bindir, sprintf ("octave-config-%s", ver));
-    octave_binary = fullfile (octave_bindir, sprintf ("octave-%s", ver));
-    cenv = {"MKOCTFILE"; mkoctfile;
-            "OCTAVE_CONFIG"; octave_config;
-            "OCTAVE"; octave_binary;
-            "INSTALLDIR"; desc.dir};
-    scenv = sprintf ("%s=\"%s\" ", cenv{:});
-    ## Configure.
-    if (exist (fullfile (src, "configure"), "file"))
-      flags = "";
-      if (isempty (getenv ("CC")))
-        flags = cstrcat (flags, " CC=\"", octave_config_info ("CC"), "\"");
-      endif
-      if (isempty (getenv ("CXX")))
-        flags = cstrcat (flags, " CXX=\"", octave_config_info ("CXX"), "\"");
-      endif
-      if (isempty (getenv ("AR")))
-        flags = cstrcat (flags, " AR=\"", octave_config_info ("AR"), "\"");
-      endif
-      if (isempty (getenv ("RANLIB")))
-        flags = cstrcat (flags, " RANLIB=\"", octave_config_info ("RANLIB"), "\"");
-      endif
-      [status, output] = shell (cstrcat ("cd '", src, "'; ", scenv,
-                                         "./configure --prefix=\"",
-                                         desc.dir, "\"", flags));
-      if (status != 0)
-        rm_rf (desc.dir);
-        error ("the configure script returned the following error: %s", output);
-      elseif (verbose)
-        printf("%s", output);
-      endif
-
-    endif
-
-    ## Make.
-    if (exist (fullfile (src, "Makefile"), "file"))
-      [status, output] = shell (cstrcat (scenv, "make -C '", src, "'"));
-      if (status != 0)
-        rm_rf (desc.dir);
-        error ("'make' returned the following error: %s", output);
-      elseif (verbose)
-        printf("%s", output);
-      endif
-    endif
-
-    ## Copy files to "inst" and "inst/arch" (this is instead of 'make
-    ## install').
-    files = fullfile (src, "FILES");
-    instdir = fullfile (packdir, "inst");
-    archdir = fullfile (packdir, "inst", getarch ());
-
-    ## Get file names.
-    if (exist (files, "file"))
-      [fid, msg] = fopen (files, "r");
-      if (fid < 0)
-        error ("couldn't open %s: %s", files, msg);
-      endif
-      filenames = char (fread (fid))';
-      fclose (fid);
-      if (filenames(end) == "\n")
-        filenames(end) = [];
-      endif
-      filenames = split_by (filenames, "\n");
-      delete_idx =  [];
-      for i = 1:length (filenames)
-        if (! all (isspace (filenames{i})))
-          filenames{i} = fullfile (src, filenames{i});
-        else
-          delete_idx(end+1) = i;
-        endif
-      endfor
-      filenames(delete_idx) = [];
-    else
-      m = dir (fullfile (src, "*.m"));
-      oct = dir (fullfile (src, "*.oct"));
-      mex = dir (fullfile (src, "*.mex"));
-
-      filenames = cellfun (@(x) fullfile (src, x),
-                           {m.name, oct.name, mex.name},
-                           "uniformoutput", false);
-    endif
-
-    ## Split into architecture dependent and independent files.
-    if (isempty (filenames))
-      idx = [];
-    else
-      idx = cellfun ("is_architecture_dependent", filenames);
-    endif
-    archdependent = filenames (idx);
-    archindependent = filenames (!idx);
-
-    ## Copy the files.
-    if (! all (isspace ([filenames{:}])))
-        if (! exist (instdir, "dir"))
-          mkdir (instdir);
-        endif
-        if (! all (isspace ([archindependent{:}])))
-          if (verbose)
-            printf ("copyfile");
-            printf (" %s", archindependent{:});
-            printf ("%s\n", instdir);
-          endif
-          [status, output] = copyfile (archindependent, instdir);
-          if (status != 1)
-            rm_rf (desc.dir);
-            error ("Couldn't copy files from 'src' to 'inst': %s", output);
-          endif
-        endif
-        if (! all (isspace ([archdependent{:}])))
-          if (verbose)
-            printf ("copyfile");
-            printf (" %s", archdependent{:});
-            printf (" %s\n", archdir);
-          endif
-          if (! exist (archdir, "dir"))
-            mkdir (archdir);
-          endif
-          [status, output] = copyfile (archdependent, archdir);
-          if (status != 1)
-            rm_rf (desc.dir);
-            error ("Couldn't copy files from 'src' to 'inst': %s", output);
-          endif
-        endif
-    endif
-  endif
-endfunction
-
-function pkg = extract_pkg (nm, pat)
-  fid = fopen (nm, "rt");
-  pkg = "";
-  if (fid >= 0)
-    while (! feof (fid))
-      ln = fgetl (fid);
-      if (ln > 0)
-        t = regexp (ln, pat, "tokens");
-        if (! isempty (t))
-          pkg = cstrcat (pkg, "\n", t{1}{1});
-        endif
-      endif
-    endwhile
-    if (! isempty (pkg))
-      pkg = cstrcat (pkg, "\n");
-    endif
-    fclose (fid);
-  endif
-endfunction
-
-function create_pkgadddel (desc, packdir, nm, global_install)
-  instpkg = fullfile (desc.dir, nm);
-  instfid = fopen (instpkg, "wt");
-  ## If it is exists, most of the  PKG_* file should go into the
-  ## architecture dependent directory so that the autoload/mfilename
-  ## commands work as expected. The only part that doesn't is the
-  ## part in the main directory.
-  archdir = fullfile (getarchprefix (desc), cstrcat (desc.name, "-",
-                      desc.version), getarch ());
-  if (exist (getarchdir (desc, global_install), "dir"))
-    archpkg = fullfile (getarchdir (desc, global_install), nm);
-    archfid = fopen (archpkg, "at");
-  else
-    archpkg = instpkg;
-    archfid = instfid;
-  endif
-
-  if (archfid >= 0 && instfid >= 0)
-    ## Search all dot-m files for PKG commands.
-    lst = dir (fullfile (packdir, "inst", "*.m"));
-    for i = 1:length (lst)
-      nam = fullfile (packdir, "inst", lst(i).name);
-      fwrite (instfid, extract_pkg (nam, ['^[#%][#%]* *' nm ': *(.*)$']));
-    endfor
-
-    ## Search all C++ source files for PKG commands.
-    lst = dir (fullfile (packdir, "src", "*.cc"));
-    for i = 1:length (lst)
-      nam = fullfile (packdir, "src", lst(i).name);
-      fwrite (archfid, extract_pkg (nam, ['^//* *' nm ': *(.*)$']));
-      fwrite (archfid, extract_pkg (nam, ['^/\** *' nm ': *(.*) *\*/$']));
-    endfor
-
-    ## Add developer included PKG commands.
-    packdirnm = fullfile (packdir, nm);
-    if (exist (packdirnm, "file"))
-      fid = fopen (packdirnm, "rt");
-      if (fid >= 0)
-        while (! feof (fid))
-          ln = fgets (fid);
-          if (ln > 0)
-            fwrite (archfid, ln);
-          endif
-        endwhile
-        fclose (fid);
-      endif
-    endif
-
-    ## If the files is empty remove it.
-    fclose (instfid);
-    t = dir (instpkg);
-    if (t.bytes <= 0)
-      unlink (instpkg);
-    endif
-
-    if (instfid != archfid)
-      fclose (archfid);
-      t = dir (archpkg);
-      if (t.bytes <= 0)
-        unlink (archpkg);
-      endif
-    endif
-  endif
-endfunction
-
-function copy_files (desc, packdir, global_install)
-  ## Create the installation directory.
-  if (! exist (desc.dir, "dir"))
-    [status, output] = mkdir (desc.dir);
-    if (status != 1)
-      error ("couldn't create installation directory %s : %s",
-      desc.dir, output);
-    endif
-  endif
-
-  octfiledir = getarchdir (desc);
-
-  ## Copy the files from "inst" to installdir.
-  instdir = fullfile (packdir, "inst");
-  if (! dirempty (instdir))
-    [status, output] = copyfile (fullfile (instdir, "*"), desc.dir);
-    if (status != 1)
-      rm_rf (desc.dir);
-      error ("couldn't copy files to the installation directory");
-    endif
-    if (exist (fullfile (desc.dir, getarch ()), "dir")
-        && ! strcmp (fullfile (desc.dir, getarch ()), octfiledir))
-      if (! exist (octfiledir, "dir"))
-        ## Can be required to create upto three levels of dirs.
-        octm1 = fileparts (octfiledir);
-        if (! exist (octm1, "dir"))
-          octm2 = fileparts (octm1);
-          if (! exist (octm2, "dir"))
-            octm3 = fileparts (octm2);
-            if (! exist (octm3, "dir"))
-              [status, output] = mkdir (octm3);
-              if (status != 1)
-                rm_rf (desc.dir);
-                error ("couldn't create installation directory %s : %s",
-                       octm3, output);
-              endif
-            endif
-            [status, output] = mkdir (octm2);
-            if (status != 1)
-              rm_rf (desc.dir);
-              error ("couldn't create installation directory %s : %s",
-                     octm2, output);
-            endif
-          endif
-          [status, output] = mkdir (octm1);
-          if (status != 1)
-            rm_rf (desc.dir);
-            error ("couldn't create installation directory %s : %s",
-                   octm1, output);
-          endif
-        endif
-        [status, output] = mkdir (octfiledir);
-        if (status != 1)
-          rm_rf (desc.dir);
-          error ("couldn't create installation directory %s : %s",
-          octfiledir, output);
-        endif
-      endif
-      [status, output] = movefile (fullfile (desc.dir, getarch (), "*"),
-                                   octfiledir);
-      rm_rf (fullfile (desc.dir, getarch ()));
-
-      if (status != 1)
-        rm_rf (desc.dir);
-        rm_rf (octfiledir);
-        error ("couldn't copy files to the installation directory");
-      endif
-    endif
-
-  endif
-
-  ## Create the "packinfo" directory.
-  packinfo = fullfile (desc.dir, "packinfo");
-  [status, msg] = mkdir (packinfo);
-  if (status != 1)
-    rm_rf (desc.dir);
-    rm_rf (octfiledir);
-    error ("couldn't create packinfo directory: %s", msg);
-  endif
-
-  packinfo_copy_file ("DESCRIPTION", "required", packdir, packinfo, desc, octfiledir);
-  packinfo_copy_file ("COPYING", "required", packdir, packinfo, desc, octfiledir);
-
-  packinfo_copy_file ("NEWS", "optional", packdir, packinfo, desc, octfiledir);
-  packinfo_copy_file ("ONEWS", "optional", packdir, packinfo, desc, octfiledir);
-  packinfo_copy_file ("ChangeLog", "optional", packdir, packinfo, desc, octfiledir);
-
-  ## Is there an INDEX file to copy or should we generate one?
-  index_file = fullfile (packdir, "INDEX");
-  if (exist(index_file, "file"))
-    packinfo_copy_file ("INDEX", "required", packdir, packinfo, desc, octfiledir);
-  else
-    try
-      write_index (desc, fullfile (packdir, "inst"),
-                   fullfile (packinfo, "INDEX"), global_install);
-    catch
-      rm_rf (desc.dir);
-      rm_rf (octfiledir);
-      rethrow (lasterror ());
-    end_try_catch
-  endif
-
-  ## Is there an 'on_uninstall.m' to install?
-  packinfo_copy_file ("on_uninstall.m", "optional", packdir, packinfo, desc, octfiledir);
-
-  ## Is there a doc/ directory that needs to be installed?
-  docdir = fullfile (packdir, "doc");
-  if (exist (docdir, "dir") && ! dirempty (docdir))
-    [status, output] = copyfile (docdir, desc.dir);
-  endif
-
-  ## Is there a bin/ directory that needs to be installed?
-  ## FIXME: Need to treat architecture dependent files in bin/
-  bindir = fullfile (packdir, "bin");
-  if (exist (bindir, "dir") && ! dirempty (bindir))
-    [status, output] = copyfile (bindir, desc.dir);
-  endif
-endfunction
-
-function packinfo_copy_file (filename, requirement, packdir, packinfo, desc, octfiledir)
-  filepath = fullfile (packdir, filename);
-  if (!exist (filepath, "file") && strcmpi (requirement, "optional"))
-    ## do nothing, it's still OK
-  else
-    [status, output] = copyfile (filepath, packinfo);
-    if (status != 1)
-      rm_rf (desc.dir);
-      rm_rf (octfiledir);
-      error ("Couldn't copy %s file: %s", filename, output);
-    endif
-  endif
-endfunction
-
-function finish_installation (desc, packdir, global_install)
-  ## Is there a post-install to call?
-  if (exist (fullfile (packdir, "post_install.m"), "file"))
-    wd = pwd ();
-    try
-      cd (packdir);
-      post_install (desc);
-      cd (wd);
-    catch
-      cd (wd);
-      rm_rf (desc.dir);
-      rm_rf (getarchdir (desc), global_install);
-      rethrow (lasterror ());
-    end_try_catch
-  endif
-endfunction
-
-function generate_lookfor_cache (desc)
-  dirs = split_by (genpath (desc.dir), pathsep ());
-  for i = 1 : length (dirs)
-    gen_doc_cache (fullfile (dirs{i}, "doc-cache"), dirs{i});
-  endfor
-endfunction
-
-## Make sure the package contains the essential files.
-function verify_directory (dir)
-  needed_files = {"COPYING", "DESCRIPTION"};
-  for f = needed_files
-    if (! exist (fullfile (dir, f{1}), "file"))
-      error ("package is missing file: %s", f{1});
-    endif
-  endfor
-endfunction
-
-## Parse the DESCRIPTION file.
-function desc = get_description (filename)
-  [fid, msg] = fopen (filename, "r");
-  if (fid == -1)
-    error ("the DESCRIPTION file %s could not be read: %s", filename, msg);
-  endif
-
-  desc = struct ();
-
-  line = fgetl (fid);
-  while (line != -1)
-    if (line(1) == "#")
-      ## Comments, do nothing.
-    elseif (isspace(line(1)))
-      ## Continuation lines
-      if (exist ("keyword", "var") && isfield (desc, keyword))
-        desc.(keyword) = cstrcat (desc.(keyword), " ", rstrip(line));
-      endif
-    else
-      ## Keyword/value pair
-      colon = find (line == ":");
-      if (length (colon) == 0)
-        disp ("skipping line");
-      else
-        colon = colon(1);
-        keyword = tolower (strip (line(1:colon-1)));
-        value = strip (line (colon+1:end));
-        if (length (value) == 0)
-            fclose (fid);
-            error ("The keyword `%s' of the package `%s' has an empty value",
-                    keyword, desc.name);
-        endif
-        desc.(keyword) = value;
-      endif
-    endif
-    line = fgetl (fid);
-  endwhile
-  fclose (fid);
-
-  ## Make sure all is okay.
-  needed_fields = {"name", "version", "date", "title", ...
-                   "author", "maintainer", "description"};
-  for f = needed_fields
-    if (! isfield (desc, f{1}))
-      error ("description is missing needed field %s", f{1});
-    endif
-  endfor
-  desc.version = fix_version (desc.version);
-  if (isfield (desc, "depends"))
-    desc.depends = fix_depends (desc.depends);
-  else
-    desc.depends = "";
-  endif
-  desc.name = tolower (desc.name);
-endfunction
-
-## Make sure the version string v is a valid x.y.z version string
-## Examples: "0.1" => "0.1.0", "monkey" => error(...).
-function out = fix_version (v)
-  dots = find (v == ".");
-  if (length (dots) == 1)
-    major = str2num (v(1:dots-1));
-    minor = str2num (v(dots+1:end));
-    if (length (major) != 0 && length (minor) != 0)
-      out = sprintf ("%d.%d.0", major, minor);
-      return;
-    endif
-  elseif (length (dots) == 2)
-    major = str2num (v(1:dots(1)-1));
-    minor = str2num (v(dots(1)+1:dots(2)-1));
-    rev = str2num (v(dots(2)+1:end));
-    if (length (major) != 0 && length (minor) != 0 && length (rev) != 0)
-      out = sprintf ("%d.%d.%d", major, minor, rev);
-      return;
-    endif
-  endif
-  error ("bad version string: %s", v);
-endfunction
-
-## Make sure the depends field is of the right format.
-## This function returns a cell of structures with the following fields:
-##   package, version, operator
-function deps_cell = fix_depends (depends)
-  deps = split_by (tolower (depends), ",");
-  deps_cell = cell (1, length (deps));
-
-  ## For each dependency.
-  for i = 1:length (deps)
-    dep = deps{i};
-    lpar = find (dep == "(");
-    rpar = find (dep == ")");
-    ## Does the dependency specify a version
-    ## Example: package(>= version).
-    if (length (lpar) == 1 && length (rpar) == 1)
-      package = tolower (strip (dep(1:lpar-1)));
-      sub = dep(lpar(1)+1:rpar(1)-1);
-      parts = strsplit (sub, " ", true);
-      if (length (parts) != 2)
-        error ("incorrect syntax for dependency `%s' in the DESCRIPTION file\n",
-               dep);
-      endif
-      operator = parts{1};
-      if (! any (strcmp (operator, {">", ">=", "<=", "<", "=="})))
-        error ("unsupported operator: %s", operator);
-      endif
-      version  = fix_version (parts{2});
-
-  ## If no version is specified for the dependency
-  ## we say that the version should be greater than
-  ## or equal to "0.0.0".
-  else
-    package = tolower (strip (dep));
-    operator = ">=";
-    version  = "0.0.0";
-  endif
-  deps_cell{i} = struct ("package", package, "operator", operator,
-                         "version", version);
-  endfor
-endfunction
-
-## Strip the text of spaces from the right
-## Example: "  hello world  " => "  hello world"
-## FIXME -- is this the same as deblank?
-function text = rstrip (text)
-  chars = find (! isspace (text));
-  if (length (chars) > 0)
-    ## FIXME: shouldn't it be text = text(1:chars(end));
-    text = text (chars(1):end);
-  else
-    text = "";
-  endif
-endfunction
-
-## Strip the text of spaces from the left and the right.
-## Example: "  hello world  " => "hello world"
-function text = strip (text)
-  chars = find (! isspace (text));
-  if (length (chars) > 0)
-    text = text(chars(1):chars(end));
-  else
-    text = "";
-  endif
-endfunction
-
-## Split the text into a cell array of strings by sep.
-## Example: "A, B" => {"A", "B"} (with sep = ",")
-function out = split_by (text, sep)
-  out = strtrim (strsplit (text, sep));
-endfunction
-
-## Create an INDEX file for a package that doesn't provide one.
-##   'desc'  describes the package.
-##   'dir'   is the 'inst' directory in temporary directory.
-##   'index_file' is the name (including path) of resulting INDEX file.
-function write_index (desc, dir, index_file, global_install)
-  ## Get names of functions in dir
-  [files, err, msg] = readdir (dir);
-  if (err)
-    error ("couldn't read directory %s: %s", dir, msg);
-  endif
-
-  ## Get classes in dir
-  class_idx = strmatch ("@", files);
-  for k = 1:length (class_idx)
-    class_name = files {class_idx (k)};
-    class_dir = fullfile (dir, class_name);
-    if (exist (class_dir, "dir"))
-      [files2, err, msg] = readdir (class_dir);
-      if (err)
-        error ("couldn't read directory %s: %s", class_dir, msg);
-      endif
-      files2 = strcat (class_name, filesep (), files2);
-      files = [files; files2];
-    endif
-  endfor
-
-  ## Check for architecture dependent files.
-  tmpdir = getarchdir (desc);
-  if (exist (tmpdir, "dir"))
-    [files2, err, msg] = readdir (tmpdir);
-    if (err)
-      error ("couldn't read directory %s: %s", tmpdir, msg);
-    endif
-    files = [files; files2];
-  endif
-
-  functions = {};
-  for i = 1:length (files)
-    file = files{i};
-    lf = length (file);
-    if (lf > 2 && strcmp (file(end-1:end), ".m"))
-      functions{end+1} = file(1:end-2);
-    elseif (lf > 4 && strcmp (file(end-3:end), ".oct"))
-      functions{end+1} = file(1:end-4);
-    endif
-  endfor
-
-  ## Does desc have a categories field?
-  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, ",");
-  if (length (categories) < 1)
-      error ("the Category field is empty");
-  endif
-
-  ## Write INDEX.
-  fid = fopen (index_file, "w");
-  if (fid == -1)
-    error ("couldn't open %s for writing", index_file);
-  endif
-  fprintf (fid, "%s >> %s\n", desc.name, desc.title);
-  fprintf (fid, "%s\n", categories{1});
-  fprintf (fid, "  %s\n", functions{:});
-  fclose (fid);
-endfunction
-
-function bad_deps = get_unsatisfied_deps (desc, installed_pkgs_lst)
-  bad_deps = {};
-
-  ## For each dependency.
-  for i = 1:length (desc.depends)
-    dep = desc.depends{i};
-
-    ## Is the current dependency Octave?
-    if (strcmp (dep.package, "octave"))
-      if (! compare_versions (OCTAVE_VERSION, dep.version, dep.operator))
-        bad_deps{end+1} = dep;
-      endif
-      ## Is the current dependency not Octave?
-    else
-      ok = false;
-      for i = 1:length (installed_pkgs_lst)
-        cur_name = installed_pkgs_lst{i}.name;
-        cur_version = installed_pkgs_lst{i}.version;
-        if (strcmp (dep.package, cur_name)
-            && compare_versions (cur_version, dep.version, dep.operator))
-          ok = true;
-          break;
-        endif
-      endfor
-      if (! ok)
-        bad_deps{end+1} = dep;
-      endif
-    endif
-  endfor
-endfunction
-
-function [out1, out2] = installed_packages (local_list, global_list)
-  ## Get the list of installed packages.
-  try
-    local_packages = load (local_list).local_packages;
-  catch
-    local_packages = {};
-  end_try_catch
-  try
-    global_packages = load (global_list).global_packages;
-  catch
-    global_packages = {};
-  end_try_catch
-  installed_pkgs_lst = {local_packages{:}, global_packages{:}};
-
-  ## Eliminate duplicates in the installed package list.
-  ## Locally installed packages take precedence.
-  dup = [];
-  for i = 1:length (installed_pkgs_lst)
-    if (find (dup, i))
-      continue;
-    endif
-    for j = (i+1):length (installed_pkgs_lst)
-      if (find (dup, j))
-        continue;
-      endif
-      if (strcmp (installed_pkgs_lst{i}.name, installed_pkgs_lst{j}.name))
-        dup = [dup, j];
-      endif
-    endfor
-  endfor
-  if (! isempty(dup))
-    installed_pkgs_lst(dup) = [];
-  endif
-
-  ## Now check if the package is loaded.
-  tmppath = strrep (path(), "\\", "/");
-  for i = 1:length (installed_pkgs_lst)
-    if (findstr (tmppath, strrep (installed_pkgs_lst{i}.dir, "\\", "/")))
-      installed_pkgs_lst{i}.loaded = true;
-    else
-      installed_pkgs_lst{i}.loaded = false;
-    endif
-  endfor
-  for i = 1:length (local_packages)
-    if (findstr (tmppath, strrep (local_packages{i}.dir, "\\", "/")))
-      local_packages{i}.loaded = true;
-    else
-      local_packages{i}.loaded = false;
-    endif
-  endfor
-  for i = 1:length (global_packages)
-    if (findstr (tmppath, strrep (global_packages{i}.dir, "\\", "/")))
-      global_packages{i}.loaded = true;
-    else
-      global_packages{i}.loaded = false;
-    endif
-  endfor
-
-  ## Should we return something?
-  if (nargout == 2)
-    out1 = local_packages;
-    out2 = global_packages;
-    return;
-  elseif (nargout == 1)
-    out1 = installed_pkgs_lst;
-    return;
-  endif
-
-  ## We shouldn't return something, so we'll print something.
-  num_packages = length (installed_pkgs_lst);
-  if (num_packages == 0)
-    printf ("no packages installed.\n");
-    return;
-  endif
-
-  ## Compute the maximal lengths of name, version, and dir.
-  h1 = "Package Name";
-  h2 = "Version";
-  h3 = "Installation directory";
-  max_name_length = length (h1);
-  max_version_length = length (h2);
-  names = cell (num_packages, 1);
-  for i = 1:num_packages
-    max_name_length = max (max_name_length,
-                           length (installed_pkgs_lst{i}.name));
-    max_version_length = max (max_version_length,
-                              length (installed_pkgs_lst{i}.version));
-    names{i} = installed_pkgs_lst{i}.name;
-  endfor
-  max_dir_length = terminal_size()(2) - max_name_length - ...
-                                             max_version_length - 7;
-  if (max_dir_length < 20)
-     max_dir_length = Inf;
-  endif
-
-  h1 = postpad (h1, max_name_length + 1, " ");
-  h2 = postpad (h2, max_version_length, " ");;
-
-  ## Print a header.
-  header = sprintf("%s | %s | %s\n", h1, h2, h3);
-  printf (header);
-  tmp = sprintf (repmat ("-", 1, length(header)-1));
-  tmp(length(h1)+2) = "+";
-  tmp(length(h1)+length(h2)+5) = "+";
-  printf ("%s\n", tmp);
-
-  ## Print the packages.
-  format = sprintf ("%%%ds %%1s| %%%ds | %%s\n", max_name_length,
-                    max_version_length);
-  [dummy, idx] = sort (names);
-  for i = 1:num_packages
-    cur_name = installed_pkgs_lst{idx(i)}.name;
-    cur_version = installed_pkgs_lst{idx(i)}.version;
-    cur_dir = installed_pkgs_lst{idx(i)}.dir;
-    if (length (cur_dir) > max_dir_length)
-      first_char = length (cur_dir) - max_dir_length + 4;
-      first_filesep = strfind (cur_dir(first_char:end), filesep());
-      if (! isempty (first_filesep))
-        cur_dir = cstrcat ("...",
-                          cur_dir((first_char + first_filesep(1) - 1):end));
-      else
-        cur_dir = cstrcat ("...", cur_dir(first_char:end));
-      endif
-    endif
-    if (installed_pkgs_lst{idx(i)}.loaded)
-      cur_loaded = "*";
-    else
-      cur_loaded = " ";
-    endif
-    printf (format, cur_name, cur_loaded, cur_version, cur_dir);
-  endfor
-endfunction
-
-function load_packages (files, handle_deps, local_list, global_list)
-  installed_pkgs_lst = installed_packages (local_list, global_list);
-  num_packages = length (installed_pkgs_lst);
-
-  ## Read package names and installdirs into a more convenient format.
-  pnames = pdirs = cell (1, num_packages);
-  for i = 1:num_packages
-    pnames{i} = installed_pkgs_lst{i}.name;
-    pdirs{i} = installed_pkgs_lst{i}.dir;
-  endfor
-
-  ## Load all.
-  if (length (files) == 1 && strcmp (files{1}, "all"))
-    idx = [1:length(installed_pkgs_lst)];
-  ## Load auto.
-  elseif (length (files) == 1 && strcmp (files{1}, "auto"))
-    idx = [];
-    for i = 1:length (installed_pkgs_lst)
-      if (exist (fullfile (pdirs{i}, "packinfo", ".autoload"), "file"))
-        idx (end + 1) = i;
-      endif
-    endfor
-  ## Load package_name1 ...
-  else
-    idx = [];
-    for i = 1:length (files)
-      idx2 = find (strcmp (pnames, files{i}));
-      if (! any (idx2))
-          error ("package %s is not installed", files{i});
-      endif
-      idx (end + 1) = idx2;
-    endfor
-  endif
-
-  ## Load the packages, but take care of the ordering of dependencies.
-  load_packages_and_dependencies (idx, handle_deps, installed_pkgs_lst, true);
-endfunction
-
-function unload_packages (files, handle_deps, local_list, global_list)
-  installed_pkgs_lst = installed_packages (local_list, global_list);
-  num_packages = length (installed_pkgs_lst);
-
-  ## Read package names and installdirs into a more convenient format.
-  pnames = pdirs = cell (1, num_packages);
-  for i = 1:num_packages
-    pnames{i} = installed_pkgs_lst{i}.name;
-    pdirs{i} = installed_pkgs_lst{i}.dir;
-    pdeps{i} = installed_pkgs_lst{i}.depends;
-  endfor
-
-  ## Get the current octave path.
-  p = split_by (path(), pathsep ());
-
-  if (length (files) == 1 && strcmp (files{1}, "all"))
-    ## Unload all.
-    dirs = pdirs;
-    desc = installed_pkgs_lst;
-  else
-    ## Unload package_name1 ...
-    dirs = {};
-    desc = {};
-    for i = 1:length (files)
-      idx = strcmp (pnames, files{i});
-      if (! any (idx))
-        error ("package %s is not installed", files{i});
-      endif
-        dirs{end+1} = pdirs{idx};
-        desc{end+1} = installed_pkgs_lst{idx};
-      endfor
-  endif
-
-  ## Check for architecture dependent directories.
-  archdirs = {};
-  for i = 1:length (dirs)
-    tmpdir = getarchdir (desc{i});
-    if (exist (tmpdir, "dir"))
-      archdirs{end+1} = dirs{i};
-      archdirs{end+1} = tmpdir;
-    else
-      archdirs{end+1} = dirs{i};
-    endif
-  endfor
-
-  ## Unload the packages.
-  for i = 1:length (archdirs)
-    d = archdirs{i};
-    idx = strcmp (p, d);
-    if (any (idx))
-      rmpath (d);
-      ## FIXME: We should also check if we need to remove items from
-      ## EXEC_PATH.
-    endif
-  endfor
-endfunction
-
-function [status_out, msg_out] = rm_rf (dir)
-  if (exist (dir))
-    crr = confirm_recursive_rmdir (false, "local");
-    [status, msg] = rmdir (dir, "s");
-  else
-    status = 1;
-    msg = "";
-  endif
-  if (nargout > 0)
-    status_out = status;
-  endif
-  if (nargout > 1)
-    msg_out = msg;
-  endif
-endfunction
-
-function emp = dirempty (nm, ign)
-  if (exist (nm, "dir"))
-    if (nargin < 2)
-      ign = {".", ".."};
-    else
-      ign = [{".", ".."}, ign];
-    endif
-    l = dir (nm);
-    for i = 1:length (l)
-      found = false;
-      for j = 1:length (ign)
-        if (strcmp (l(i).name, ign{j}))
-          found = true;
-          break;
-        endif
-      endfor
-      if (! found)
-        emp = false;
-        return
-      endif
-    endfor
-    emp = true;
-  else
-    emp = true;
-  endif
-endfunction
-
-function arch = getarch ()
-  persistent _arch = cstrcat (octave_config_info ("canonical_host_type"),
-                              "-", octave_config_info ("api_version"));
-  arch = _arch;
-endfunction
-
-function archprefix = getarchprefix (desc, global_install)
-  if ((nargin == 2 && global_install) || (nargin < 2 && issuperuser ()))
-    archprefix = fullfile (octave_config_info ("libdir"), "octave",
-                           "packages", cstrcat(desc.name, "-", desc.version));
-  else
-    archprefix = desc.dir;
-  endif
-endfunction
-
-function archdir = getarchdir (desc)
-  archdir = fullfile (desc.archprefix, getarch());
-endfunction
-
-function s = issuperuser ()
-  if ((ispc () && ! isunix ()) || (geteuid() == 0))
-    s = true;
-  else
-    s = false;
-  endif
-endfunction
-
-function [status, output] = shell (cmd)
-  persistent have_sh;
-
-  cmd = strrep (cmd, "\\", "/");
-  if (ispc () && ! isunix ())
-    if (isempty(have_sh))
-      if (system("sh.exe -c \"exit\""))
-        have_sh = false;
-      else
-        have_sh = true;
-      endif
-    endif
-    if (have_sh)
-      [status, output] = system (cstrcat ("sh.exe -c \"", cmd, "\""));
-    else
-      error ("Can not find the command shell");
-    endif
-  else
-    [status, output] = system (cmd);
-  endif
-endfunction
-
-function newdesc = save_order (desc)
-  newdesc = {};
-  for i = 1 : length(desc)
-    deps = desc{i}.depends;
-    if (isempty (deps)
-        || (length (deps) == 1 && strcmp(deps{1}.package, "octave")))
-      newdesc {end + 1} = desc{i};
-    else
-      tmpdesc = {};
-      for k = 1 : length (deps)
-        for j = 1 : length (desc)
-          if (strcmp (desc{j}.name, deps{k}.package))
-            tmpdesc{end+1} = desc{j};
-            break;
-          endif
-        endfor
-      endfor
-      if (! isempty (tmpdesc))
-        newdesc = {newdesc{:}, save_order(tmpdesc){:}, desc{i}};
-      else
-        newdesc{end+1} = desc{i};
-      endif
-    endif
-  endfor
-  ## Eliminate the duplicates.
-  idx = [];
-  for i = 1 : length (newdesc)
-    for j = (i + 1) : length (newdesc)
-      if (strcmp (newdesc{i}.name, newdesc{j}.name))
-        idx (end + 1) = j;
-      endif
-    endfor
-  endfor
-  newdesc(idx) = [];
-endfunction
-
-function load_packages_and_dependencies (idx, handle_deps, installed_pkgs_lst,
-                                         global_install)
-  idx = load_package_dirs (idx, [], handle_deps, installed_pkgs_lst);
-  dirs = {};
-  execpath = EXEC_PATH ();
-  for i = idx;
-    ndir = installed_pkgs_lst{i}.dir;
-    dirs{end+1} = ndir;
-    if (exist (fullfile (dirs{end}, "bin"), "dir"))
-      execpath = cstrcat (execpath, pathsep (), fullfile (dirs{end}, "bin"));
-    endif
-    tmpdir = getarchdir (installed_pkgs_lst{i});
-    if (exist (tmpdir, "dir"))
-      dirs{end + 1} = tmpdir;
-      if (exist (fullfile (dirs{end}, "bin"), "dir"))
-        execpath = cstrcat (execpath, pathsep (), fullfile (dirs{end}, "bin"));
-      endif
-    endif
-  endfor
-
-  ## Load the packages.
-  if (length (dirs) > 0)
-    addpath (dirs{:});
-  endif
-
-  ## Add the binaries to exec_path.
-  if (! strcmp (EXEC_PATH, execpath))
-    EXEC_PATH (execpath);
-  endif
-endfunction
-
-function idx = load_package_dirs (lidx, idx, handle_deps, installed_pkgs_lst)
-  for i = lidx
-    if (isfield (installed_pkgs_lst{i}, "loaded")
-        && installed_pkgs_lst{i}.loaded)
-      continue;
-    else
-      if (handle_deps)
-        deps = installed_pkgs_lst{i}.depends;
-        if ((length (deps) > 1)
-            || (length (deps) == 1 && ! strcmp(deps{1}.package, "octave")))
-          tmplidx = [];
-          for k = 1 : length (deps)
-            for j = 1 : length (installed_pkgs_lst)
-              if (strcmp (installed_pkgs_lst{j}.name, deps{k}.package))
-                tmplidx (end + 1) = j;
-                break;
-              endif
-            endfor
-          endfor
-          idx = load_package_dirs (tmplidx, idx, handle_deps,
-                                 installed_pkgs_lst);
-        endif
-      endif
-      if (isempty (find(idx == i)))
-        idx (end + 1) = i;
-      endif
-    endif
-  endfor
-endfunction
-
-function dep = is_architecture_dependent (nm)
-  persistent archdepsuffix = {".oct",".mex",".a",".lib",".so",".so.*",".dll","dylib"};
-
-  dep = false;
-  for i = 1 : length (archdepsuffix)
-    ext = archdepsuffix{i};
-    if (ext(end) == "*")
-      isglob = true;
-      ext(end) = [];
-    else
-      isglob = false;
-    endif
-    pos = findstr (nm, ext);
-    if (pos)
-      if (! isglob && (length(nm) - pos(end) != length(ext) - 1))
-        continue;
-      endif
-      dep = true;
-      break;
-    endif
-  endfor
-endfunction
-
-function [url, local_file] = get_forge_download (name)
-  [ver, url] = get_forge_pkg (name);
-  local_file = [name, "-", ver, ".tar.gz"];
-endfunction
-
-function list = list_forge_packages ()
-  [list, succ] = urlread ("http://octave.sourceforge.net/list_packages.php");
-  if (succ)
-    list = strsplit (list, " \n\t", true);
-  else
-    error ("pkg: could not read URL, please verify internet connection");
-  endif
-  if (nargout == 0)
-    page_screen_output (false, "local");
-    puts ("OctaveForge provides these packages:\n");
-    for i = 1:length (list)
-      try
-        ver = get_forge_pkg (list{i});
-      catch
-        ver = "unknown";
-      end_try_catch
-      printf ("  %s %s\n", list{i}, ver);
-    endfor
-  endif
-endfunction
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/absolute_pathname.m
@@ -0,0 +1,33 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{pth} =} absolute_pathname (@var{pth})
+## Undocumented internal function.
+## @end deftypefn
+
+function pth = absolute_pathname (pth)
+  [status, msg, msgid] = fileattrib (pth);
+  if (status != 1)
+    error ("could not find the file or path %s", pth);
+  else
+    pth = msg.Name;
+  endif
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/build.m
@@ -0,0 +1,60 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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} {} build (@var{files}, @var{handle_deps}, @var{autoload}, @var{verbose})
+## Undocumented internal function.
+## @end deftypefn
+
+function build (files, handle_deps, autoload, verbose)
+  if (length (files) < 1)
+    error ("insufficient number of files");
+  endif
+  builddir = files{1};
+  if (! exist (builddir, "dir"))
+    warning ("creating build directory %s", builddir);
+    [status, msg] = mkdir (builddir);
+    if (status != 1)
+      error ("could not create installation directory: %s", msg);
+    endif
+  endif
+  builddir = absolute_pathname (builddir);
+  installdir = fullfile (builddir, "install");
+  if (! exist (installdir, "dir"))
+    [status, msg] = mkdir (installdir);
+    if (status != 1)
+      error ("could not create installation directory: %s", msg);
+    endif
+  endif
+  files(1) = [];
+  buildlist = fullfile (builddir, "octave_packages");
+  install (files, handle_deps, autoload, installdir, installdir, verbose,
+           buildlist, "", false);
+  unwind_protect
+    repackage (builddir, buildlist);
+  unwind_protect_cleanup
+    unload_packages ({"all"}, handle_deps, buildlist, "");
+    if (exist (installdir, "dir"))
+      rmdir (installdir, "s");
+    endif
+    if (exist (buildlist, "file"))
+      unlink (buildlist);
+    endif
+  end_unwind_protect
+endfunction
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/configure_make.m
@@ -0,0 +1,158 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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} {} configure_make (@var{desc}, @var{packdir}, @var{verbose})
+## Undocumented internal function.
+## @end deftypefn
+
+function configure_make (desc, packdir, verbose)
+  ## Perform ./configure, make, make install in "src".
+  if (exist (fullfile (packdir, "src"), "dir"))
+    src = fullfile (packdir, "src");
+    octave_bindir = octave_config_info ("bindir");
+    ver = version ();
+    mkoctfile = fullfile (octave_bindir, sprintf ("mkoctfile-%s", ver));
+    octave_config = fullfile (octave_bindir, sprintf ("octave-config-%s", ver));
+    octave_binary = fullfile (octave_bindir, sprintf ("octave-%s", ver));
+    cenv = {"MKOCTFILE"; mkoctfile;
+            "OCTAVE_CONFIG"; octave_config;
+            "OCTAVE"; octave_binary;
+            "INSTALLDIR"; desc.dir};
+    scenv = sprintf ("%s=\"%s\" ", cenv{:});
+    ## Configure.
+    if (exist (fullfile (src, "configure"), "file"))
+      flags = "";
+      if (isempty (getenv ("CC")))
+        flags = cstrcat (flags, " CC=\"", octave_config_info ("CC"), "\"");
+      endif
+      if (isempty (getenv ("CXX")))
+        flags = cstrcat (flags, " CXX=\"", octave_config_info ("CXX"), "\"");
+      endif
+      if (isempty (getenv ("AR")))
+        flags = cstrcat (flags, " AR=\"", octave_config_info ("AR"), "\"");
+      endif
+      if (isempty (getenv ("RANLIB")))
+        flags = cstrcat (flags, " RANLIB=\"", octave_config_info ("RANLIB"), "\"");
+      endif
+      [status, output] = shell (cstrcat ("cd '", src, "'; ", scenv,
+                                         "./configure --prefix=\"",
+                                         desc.dir, "\"", flags));
+      if (status != 0)
+        rmdir (desc.dir, "s");
+        error ("the configure script returned the following error: %s", output);
+      elseif (verbose)
+        printf ("%s", output);
+      endif
+
+    endif
+
+    ## Make.
+    if (exist (fullfile (src, "Makefile"), "file"))
+      [status, output] = shell (cstrcat (scenv, "make -C '", src, "'"));
+      if (status != 0)
+        rmdir (desc.dir, "s");
+        error ("'make' returned the following error: %s", output);
+      elseif (verbose)
+        printf ("%s", output);
+      endif
+    endif
+
+    ## Copy files to "inst" and "inst/arch" (this is instead of 'make
+    ## install').
+    files = fullfile (src, "FILES");
+    instdir = fullfile (packdir, "inst");
+    archdir = fullfile (packdir, "inst", getarch ());
+
+    ## Get file names.
+    if (exist (files, "file"))
+      [fid, msg] = fopen (files, "r");
+      if (fid < 0)
+        error ("couldn't open %s: %s", files, msg);
+      endif
+      filenames = char (fread (fid))';
+      fclose (fid);
+      if (filenames(end) == "\n")
+        filenames(end) = [];
+      endif
+      filenames = strtrim (strsplit (filenames, "\n"));
+      delete_idx =  [];
+      for i = 1:length (filenames)
+        if (! all (isspace (filenames{i})))
+          filenames{i} = fullfile (src, filenames{i});
+        else
+          delete_idx(end+1) = i;
+        endif
+      endfor
+      filenames(delete_idx) = [];
+    else
+      m = dir (fullfile (src, "*.m"));
+      oct = dir (fullfile (src, "*.oct"));
+      mex = dir (fullfile (src, "*.mex"));
+
+      filenames = cellfun (@(x) fullfile (src, x),
+                           {m.name, oct.name, mex.name},
+                           "uniformoutput", false);
+    endif
+
+    ## Split into architecture dependent and independent files.
+    if (isempty (filenames))
+      idx = [];
+    else
+      idx = cellfun ("is_architecture_dependent", filenames);
+    endif
+    archdependent = filenames (idx);
+    archindependent = filenames (!idx);
+
+    ## Copy the files.
+    if (! all (isspace ([filenames{:}])))
+        if (! exist (instdir, "dir"))
+          mkdir (instdir);
+        endif
+        if (! all (isspace ([archindependent{:}])))
+          if (verbose)
+            printf ("copyfile");
+            printf (" %s", archindependent{:});
+            printf ("%s\n", instdir);
+          endif
+          [status, output] = copyfile (archindependent, instdir);
+          if (status != 1)
+            rmdir (desc.dir, "s");
+            error ("Couldn't copy files from 'src' to 'inst': %s", output);
+          endif
+        endif
+        if (! all (isspace ([archdependent{:}])))
+          if (verbose)
+            printf ("copyfile");
+            printf (" %s", archdependent{:});
+            printf (" %s\n", archdir);
+          endif
+          if (! exist (archdir, "dir"))
+            mkdir (archdir);
+          endif
+          [status, output] = copyfile (archdependent, archdir);
+          if (status != 1)
+            rmdir (desc.dir, "s");
+            error ("Couldn't copy files from 'src' to 'inst': %s", output);
+          endif
+        endif
+    endif
+  endif
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/copy_files.m
@@ -0,0 +1,143 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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} {} copy_files (@var{desc}, @var{packdir}, @var{global_install})
+## Undocumented internal function.
+## @end deftypefn
+
+function copy_files (desc, packdir, global_install)
+  ## Create the installation directory.
+  if (! exist (desc.dir, "dir"))
+    [status, output] = mkdir (desc.dir);
+    if (status != 1)
+      error ("couldn't create installation directory %s : %s",
+      desc.dir, output);
+    endif
+  endif
+
+  octfiledir = getarchdir (desc);
+
+  ## Copy the files from "inst" to installdir.
+  instdir = fullfile (packdir, "inst");
+  if (! dirempty (instdir))
+    [status, output] = copyfile (fullfile (instdir, "*"), desc.dir);
+    if (status != 1)
+      rmdir (desc.dir, "s");
+      error ("couldn't copy files to the installation directory");
+    endif
+    if (exist (fullfile (desc.dir, getarch ()), "dir")
+        && ! strcmp (fullfile (desc.dir, getarch ()), octfiledir))
+      if (! exist (octfiledir, "dir"))
+        ## Can be required to create upto three levels of dirs.
+        octm1 = fileparts (octfiledir);
+        if (! exist (octm1, "dir"))
+          octm2 = fileparts (octm1);
+          if (! exist (octm2, "dir"))
+            octm3 = fileparts (octm2);
+            if (! exist (octm3, "dir"))
+              [status, output] = mkdir (octm3);
+              if (status != 1)
+                rmdir (desc.dir, "s");
+                error ("couldn't create installation directory %s : %s",
+                       octm3, output);
+              endif
+            endif
+            [status, output] = mkdir (octm2);
+            if (status != 1)
+              rmdir (desc.dir, "s");
+              error ("couldn't create installation directory %s : %s",
+                     octm2, output);
+            endif
+          endif
+          [status, output] = mkdir (octm1);
+          if (status != 1)
+            rmdir (desc.dir, "s");
+            error ("couldn't create installation directory %s : %s",
+                   octm1, output);
+          endif
+        endif
+        [status, output] = mkdir (octfiledir);
+        if (status != 1)
+          rmdir (desc.dir, "s");
+          error ("couldn't create installation directory %s : %s",
+          octfiledir, output);
+        endif
+      endif
+      [status, output] = movefile (fullfile (desc.dir, getarch (), "*"),
+                                   octfiledir);
+      rmdir (fullfile (desc.dir, getarch ()), "s");
+
+      if (status != 1)
+        rmdir (desc.dir, "s");
+        rmdir (octfiledir, "s");
+        error ("couldn't copy files to the installation directory");
+      endif
+    endif
+
+  endif
+
+  ## Create the "packinfo" directory.
+  packinfo = fullfile (desc.dir, "packinfo");
+  [status, msg] = mkdir (packinfo);
+  if (status != 1)
+    rmdir (desc.dir, "s");
+    rmdir (octfiledir, "s");
+    error ("couldn't create packinfo directory: %s", msg);
+  endif
+
+  packinfo_copy_file ("DESCRIPTION", "required", packdir, packinfo, desc, octfiledir);
+  packinfo_copy_file ("COPYING", "required", packdir, packinfo, desc, octfiledir);
+
+  packinfo_copy_file ("NEWS", "optional", packdir, packinfo, desc, octfiledir);
+  packinfo_copy_file ("ONEWS", "optional", packdir, packinfo, desc, octfiledir);
+  packinfo_copy_file ("ChangeLog", "optional", packdir, packinfo, desc, octfiledir);
+
+  ## Is there an INDEX file to copy or should we generate one?
+  index_file = fullfile (packdir, "INDEX");
+  if (exist (index_file, "file"))
+    packinfo_copy_file ("INDEX", "required", packdir, packinfo, desc, octfiledir);
+  else
+    try
+      write_index (desc, fullfile (packdir, "inst"),
+                   fullfile (packinfo, "INDEX"), global_install);
+    catch
+      rmdir (desc.dir, "s");
+      rmdir (octfiledir, "s");
+      rethrow (lasterror ());
+    end_try_catch
+  endif
+
+  ## Is there an 'on_uninstall.m' to install?
+  packinfo_copy_file ("on_uninstall.m", "optional", packdir, packinfo, desc, octfiledir);
+
+  ## Is there a doc/ directory that needs to be installed?
+  docdir = fullfile (packdir, "doc");
+  if (exist (docdir, "dir") && ! dirempty (docdir))
+    [status, output] = copyfile (docdir, desc.dir);
+  endif
+
+  ## Is there a bin/ directory that needs to be installed?
+  ## FIXME: Need to treat architecture dependent files in bin/
+  bindir = fullfile (packdir, "bin");
+  if (exist (bindir, "dir") && ! dirempty (bindir))
+    [status, output] = copyfile (bindir, desc.dir);
+  endif
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/create_pkgadddel.m
@@ -0,0 +1,89 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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} {} create_pkgadddel (@var{desc}, @var{packdir}, @var{nm}, @var{global_install})
+## Undocumented internal function.
+## @end deftypefn
+
+function create_pkgadddel (desc, packdir, nm, global_install)
+  instpkg = fullfile (desc.dir, nm);
+  instfid = fopen (instpkg, "wt");
+  ## If it is exists, most of the  PKG_* file should go into the
+  ## architecture dependent directory so that the autoload/mfilename
+  ## commands work as expected. The only part that doesn't is the
+  ## part in the main directory.
+  archdir = fullfile (getarchprefix (desc, global_install), cstrcat (desc.name,
+                      "-", desc.version), getarch ());
+  if (exist (getarchdir (desc, global_install), "dir"))
+    archpkg = fullfile (getarchdir (desc, global_install), nm);
+    archfid = fopen (archpkg, "at");
+  else
+    archpkg = instpkg;
+    archfid = instfid;
+  endif
+
+  if (archfid >= 0 && instfid >= 0)
+    ## Search all dot-m files for PKG commands.
+    lst = dir (fullfile (packdir, "inst", "*.m"));
+    for i = 1:length (lst)
+      nam = fullfile (packdir, "inst", lst(i).name);
+      fwrite (instfid, extract_pkg (nam, ['^[#%][#%]* *' nm ': *(.*)$']));
+    endfor
+
+    ## Search all C++ source files for PKG commands.
+    lst = dir (fullfile (packdir, "src", "*.cc"));
+    for i = 1:length (lst)
+      nam = fullfile (packdir, "src", lst(i).name);
+      fwrite (archfid, extract_pkg (nam, ['^//* *' nm ': *(.*)$']));
+      fwrite (archfid, extract_pkg (nam, ['^/\** *' nm ': *(.*) *\*/$']));
+    endfor
+
+    ## Add developer included PKG commands.
+    packdirnm = fullfile (packdir, nm);
+    if (exist (packdirnm, "file"))
+      fid = fopen (packdirnm, "rt");
+      if (fid >= 0)
+        while (! feof (fid))
+          ln = fgets (fid);
+          if (ln > 0)
+            fwrite (archfid, ln);
+          endif
+        endwhile
+        fclose (fid);
+      endif
+    endif
+
+    ## If the files is empty remove it.
+    fclose (instfid);
+    t = dir (instpkg);
+    if (t.bytes <= 0)
+      unlink (instpkg);
+    endif
+
+    if (instfid != archfid)
+      fclose (archfid);
+      t = dir (archpkg);
+      if (t.bytes <= 0)
+        unlink (archpkg);
+      endif
+    endif
+  endif
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/describe.m
@@ -0,0 +1,87 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{pkg_desc_list}, @var{flag}] =} describe (@var{pkgnames}, @var{verbose}, @var{local_list}, @var{global_list})
+## Undocumented internal function.
+## @end deftypefn
+
+function [pkg_desc_list, flag] = describe (pkgnames, verbose,
+                                           local_list, global_list)
+
+  ## Get the list of installed packages.
+  installed_pkgs_lst = installed_packages(local_list, global_list);
+  num_packages = length (installed_pkgs_lst);
+
+
+  describe_all = false;
+  if (any (strcmp ("all", pkgnames)))
+    describe_all = true;
+    flag(1:num_packages) = {"Not Loaded"};
+    num_pkgnames = num_packages;
+  else
+    num_pkgnames = length (pkgnames);
+    flag(1:num_pkgnames) = {"Not installed"};
+  endif
+
+  for i = 1:num_packages
+    curr_name = installed_pkgs_lst{i}.name;
+    if (describe_all)
+      name_pos = i;
+    else
+      name_pos = find (strcmp (curr_name, pkgnames));
+    endif
+
+    if (! isempty (name_pos))
+      if (installed_pkgs_lst{i}.loaded)
+        flag{name_pos} = "Loaded";
+      else
+        flag{name_pos} = "Not loaded";
+      endif
+
+      pkg_desc_list{name_pos}.name = installed_pkgs_lst{i}.name;
+      pkg_desc_list{name_pos}.version = installed_pkgs_lst{i}.version;
+      pkg_desc_list{name_pos}.description = installed_pkgs_lst{i}.description;
+      pkg_desc_list{name_pos}.provides = parse_pkg_idx (installed_pkgs_lst{i}.dir);
+
+    endif
+  endfor
+
+  non_inst = find (strcmp (flag, "Not installed"));
+  if (! isempty (non_inst))
+    if (nargout < 2)
+      non_inst_str = sprintf (" %s ", pkgnames{non_inst});
+      error ("some packages are not installed: %s", non_inst_str);
+    else
+      pkg_desc_list{non_inst} = struct ("name", {}, "description",
+                                        {}, "provides", {});
+    endif
+  endif
+
+  if (nargout == 0)
+    for i = 1:num_pkgnames
+      print_package_description (pkg_desc_list{i}.name,
+                                 pkg_desc_list{i}.version,
+                                 pkg_desc_list{i}.provides,
+                                 pkg_desc_list{i}.description,
+                                 flag{i}, verbose);
+    endfor
+  endif
+
+endfunction
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/dirempty.m
@@ -0,0 +1,50 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{emp} =} dirempty (@var{nm}, @var{ign})
+## Undocumented internal function.
+## @end deftypefn
+
+function emp = dirempty (nm, ign)
+  if (exist (nm, "dir"))
+    if (nargin < 2)
+      ign = {".", ".."};
+    else
+      ign = [{".", ".."}, ign];
+    endif
+    l = dir (nm);
+    for i = 1:length (l)
+      found = false;
+      for j = 1:length (ign)
+        if (strcmp (l(i).name, ign{j}))
+          found = true;
+          break;
+        endif
+      endfor
+      if (! found)
+        emp = false;
+        return
+      endif
+    endfor
+    emp = true;
+  else
+    emp = true;
+  endif
+endfunction
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/extract_pkg.m
@@ -0,0 +1,44 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{pkg} =} extract_pkg (@var{nm}, @var{pat})
+## Undocumented internal function.
+## @end deftypefn
+
+function pkg = extract_pkg (nm, pat)
+  fid = fopen (nm, "rt");
+  pkg = "";
+  if (fid >= 0)
+    while (! feof (fid))
+      ln = fgetl (fid);
+      if (ln > 0)
+        t = regexp (ln, pat, "tokens");
+        if (! isempty (t))
+          pkg = cstrcat (pkg, "\n", t{1}{1});
+        endif
+      endif
+    endwhile
+    if (! isempty (pkg))
+      pkg = cstrcat (pkg, "\n");
+    endif
+    fclose (fid);
+  endif
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/finish_installation.m
@@ -0,0 +1,41 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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} {} finish_installation (@var{desc}, @var{packdir}, @var{global_install})
+## Undocumented internal function.
+## @end deftypefn
+
+function finish_installation (desc, packdir, global_install)
+  ## Is there a post-install to call?
+  if (exist (fullfile (packdir, "post_install.m"), "file"))
+    wd = pwd ();
+    try
+      cd (packdir);
+      post_install (desc);
+      cd (wd);
+    catch
+      cd (wd);
+      rmdir (desc.dir, "s");
+      rmdir (getarchdir (desc), "s");
+      rethrow (lasterror ());
+    end_try_catch
+  endif
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/fix_depends.m
@@ -0,0 +1,65 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{deps_cell} =} fix_depends (@var{depends})
+## Undocumented internal function.
+## @end deftypefn
+
+## Make sure the depends field is of the right format.
+## This function returns a cell of structures with the following fields:
+##   package, version, operator
+function deps_cell = fix_depends (depends)
+  deps = strtrim (strsplit (tolower (depends), ","));
+  deps_cell = cell (1, length (deps));
+
+  ## For each dependency.
+  for i = 1:length (deps)
+    dep = deps{i};
+    lpar = find (dep == "(");
+    rpar = find (dep == ")");
+    ## Does the dependency specify a version
+    ## Example: package(>= version).
+    if (length (lpar) == 1 && length (rpar) == 1)
+      package = tolower (strtrim (dep(1:lpar-1)));
+      sub = dep(lpar(1)+1:rpar(1)-1);
+      parts = strsplit (sub, " ", true);
+      if (length (parts) != 2)
+        error ("incorrect syntax for dependency `%s' in the DESCRIPTION file\n",
+               dep);
+      endif
+      operator = parts{1};
+      if (! any (strcmp (operator, {">", ">=", "<=", "<", "=="})))
+        error ("unsupported operator: %s", operator);
+      endif
+      version  = fix_version (parts{2});
+
+  ## If no version is specified for the dependency
+  ## we say that the version should be greater than
+  ## or equal to "0.0.0".
+  else
+    package = tolower (strtrim (dep));
+    operator = ">=";
+    version  = "0.0.0";
+  endif
+  deps_cell{i} = struct ("package", package, "operator", operator,
+                         "version", version);
+  endfor
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/fix_version.m
@@ -0,0 +1,47 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{out} =} fix_version (@var{v})
+## Undocumented internal function.
+## @end deftypefn
+
+## Make sure the version string v is a valid x.y.z version string
+## Examples: "0.1" => "0.1.0", "monkey" => error(...).
+function out = fix_version (v)
+  dots = find (v == ".");
+  if (length (dots) == 1)
+    major = str2num (v(1:dots-1));
+    minor = str2num (v(dots+1:end));
+    if (length (major) != 0 && length (minor) != 0)
+      out = sprintf ("%d.%d.0", major, minor);
+      return;
+    endif
+  elseif (length (dots) == 2)
+    major = str2num (v(1:dots(1)-1));
+    minor = str2num (v(dots(1)+1:dots(2)-1));
+    rev = str2num (v(dots(2)+1:end));
+    if (length (major) != 0 && length (minor) != 0 && length (rev) != 0)
+      out = sprintf ("%d.%d.%d", major, minor, rev);
+      return;
+    endif
+  endif
+  error ("bad version string: %s", v);
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/generate_lookfor_cache.m
@@ -0,0 +1,31 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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} {} generate_lookfor_cache (@var{desc})
+## Undocumented internal function.
+## @end deftypefn
+
+function generate_lookfor_cache (desc)
+  dirs = strtrim (strsplit (genpath (desc.dir), pathsep ()));
+  for i = 1 : length (dirs)
+    gen_doc_cache (fullfile (dirs{i}, "doc-cache"), dirs{i});
+  endfor
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/get_description.m
@@ -0,0 +1,80 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{desc} =} get_description (@var{filename})
+## Undocumented internal function.
+## @end deftypefn
+
+## Parse the DESCRIPTION file.
+function desc = get_description (filename)
+  [fid, msg] = fopen (filename, "r");
+  if (fid == -1)
+    error ("the DESCRIPTION file %s could not be read: %s", filename, msg);
+  endif
+
+  desc = struct ();
+
+  line = fgetl (fid);
+  while (line != -1)
+    if (line(1) == "#")
+      ## Comments, do nothing.
+    elseif (isspace (line(1)))
+      ## Continuation lines
+      if (exist ("keyword", "var") && isfield (desc, keyword))
+        desc.(keyword) = cstrcat (desc.(keyword), " ", deblank (line));
+      endif
+    else
+      ## Keyword/value pair
+      colon = find (line == ":");
+      if (length (colon) == 0)
+        disp ("skipping line");
+      else
+        colon = colon(1);
+        keyword = tolower (strtrim (line(1:colon-1)));
+        value = strtrim (line (colon+1:end));
+        if (length (value) == 0)
+            fclose (fid);
+            error ("The keyword `%s' of the package `%s' has an empty value",
+                    keyword, desc.name);
+        endif
+        desc.(keyword) = value;
+      endif
+    endif
+    line = fgetl (fid);
+  endwhile
+  fclose (fid);
+
+  ## Make sure all is okay.
+  needed_fields = {"name", "version", "date", "title", ...
+                   "author", "maintainer", "description"};
+  for f = needed_fields
+    if (! isfield (desc, f{1}))
+      error ("description is missing needed field %s", f{1});
+    endif
+  endfor
+  desc.version = fix_version (desc.version);
+  if (isfield (desc, "depends"))
+    desc.depends = fix_depends (desc.depends);
+  else
+    desc.depends = "";
+  endif
+  desc.name = tolower (desc.name);
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/get_forge_download.m
@@ -0,0 +1,28 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{url}, @var{local_file}] =} list_forge_packages ()
+## Undocumented internal function.
+## @end deftypefn
+
+function [url, local_file] = get_forge_download (name)
+  [ver, url] = get_forge_pkg (name);
+  local_file = [name, "-", ver, ".tar.gz"];
+endfunction
--- a/scripts/pkg/private/get_forge_pkg.m
+++ b/scripts/pkg/private/get_forge_pkg.m
@@ -1,3 +1,4 @@
+## Copyright (C) 2005-2012 Søren Hauberg
 ## Copyright (C) 2010-2012 VZLU Prague, a.s.
 ##
 ## This file is part of Octave.
@@ -45,7 +46,7 @@
     ## Good. Let's grep for the version.
     pat = "<tdclass=""package_table"">PackageVersion:</td><td>([\\d.]*)</td>";
     t = regexp (html, pat, "tokens");
-    if (isempty (t) || isempty(t{1}))
+    if (isempty (t) || isempty (t{1}))
       error ("get_forge_pkg: could not read version number from package's page");
     else
       ver = t{1}{1};
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/get_unsatisfied_deps.m
@@ -0,0 +1,54 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{bad_deps} =} get_unsatisfied_deps (@var{desc}, @var{installed_pkgs_lst})
+## Undocumented internal function.
+## @end deftypefn
+
+function bad_deps = get_unsatisfied_deps (desc, installed_pkgs_lst)
+  bad_deps = {};
+
+  ## For each dependency.
+  for i = 1:length (desc.depends)
+    dep = desc.depends{i};
+
+    ## Is the current dependency Octave?
+    if (strcmp (dep.package, "octave"))
+      if (! compare_versions (OCTAVE_VERSION, dep.version, dep.operator))
+        bad_deps{end+1} = dep;
+      endif
+      ## Is the current dependency not Octave?
+    else
+      ok = false;
+      for i = 1:length (installed_pkgs_lst)
+        cur_name = installed_pkgs_lst{i}.name;
+        cur_version = installed_pkgs_lst{i}.version;
+        if (strcmp (dep.package, cur_name)
+            && compare_versions (cur_version, dep.version, dep.operator))
+          ok = true;
+          break;
+        endif
+      endfor
+      if (! ok)
+        bad_deps{end+1} = dep;
+      endif
+    endif
+  endfor
+endfunction
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/getarch.m
@@ -0,0 +1,30 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{arch} =} getarch ()
+## Undocumented internal function.
+## @end deftypefn
+
+function arch = getarch ()
+  persistent _arch = cstrcat (octave_config_info ("canonical_host_type"),
+                              "-", octave_config_info ("api_version"));
+  arch = _arch;
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/getarchdir.m
@@ -0,0 +1,28 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{archdir} =} getarchdir (@var{desc})
+## Undocumented internal function.
+## @end deftypefn
+
+function archdir = getarchdir (desc)
+  archdir = fullfile (desc.archprefix, getarch ());
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/getarchprefix.m
@@ -0,0 +1,33 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{archprefix} =} getarchprefix (@var{desc}, @var{global_install})
+## Undocumented internal function.
+## @end deftypefn
+
+function archprefix = getarchprefix (desc, global_install)
+  if (global_install)
+    archprefix = fullfile (octave_config_info ("libdir"), "octave",
+                           "packages", cstrcat (desc.name, "-", desc.version));
+  else
+    archprefix = desc.dir;
+  endif
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/install.m
@@ -0,0 +1,345 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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} {} install (@var{files}, @var{handle_deps}, @var{autoload}, @var{prefix}, @var{archprefix}, @var{verbose}, @var{local_list}, @var{global_list}, @var{global_install})
+## Undocumented internal function.
+## @end deftypefn
+
+function install (files, handle_deps, autoload, prefix, archprefix, verbose,
+                  local_list, global_list, global_install)
+
+  ## Check that the directory in prefix exist. If it doesn't: create it!
+  if (! exist (prefix, "dir"))
+    warning ("creating installation directory %s", prefix);
+    [status, msg] = mkdir (prefix);
+    if (status != 1)
+      error ("could not create installation directory: %s", msg);
+    endif
+  endif
+
+  ## Get the list of installed packages.
+  [local_packages, global_packages] = installed_packages (local_list,
+                                                          global_list);
+
+  installed_pkgs_lst = {local_packages{:}, global_packages{:}};
+
+  if (global_install)
+    packages = global_packages;
+  else
+    packages = local_packages;
+  endif
+
+  ## Uncompress the packages and read the DESCRIPTION files.
+  tmpdirs = packdirs = descriptions = {};
+  try
+    ## Warn about non existent files.
+    for i = 1:length (files)
+      if (isempty (glob (files{i})))
+        warning ("file %s does not exist", files{i});
+      endif
+    endfor
+
+    ## Unpack the package files and read the DESCRIPTION files.
+    files = glob (files);
+    packages_to_uninstall = [];
+    for i = 1:length (files)
+      tgz = files{i};
+
+      if (exist (tgz, "file"))
+        ## Create a temporary directory.
+        tmpdir = tmpnam ();
+        tmpdirs{end+1} = tmpdir;
+        if (verbose)
+          printf ("mkdir (%s)\n", tmpdir);
+        endif
+        [status, msg] = mkdir (tmpdir);
+        if (status != 1)
+          error ("couldn't create temporary directory: %s", msg);
+        endif
+
+        ## Uncompress the package.
+        if (verbose)
+          printf ("untar (%s, %s)\n", tgz, tmpdir);
+        endif
+        untar (tgz, tmpdir);
+
+        ## Get the name of the directories produced by tar.
+        [dirlist, err, msg] = readdir (tmpdir);
+        if (err)
+          error ("couldn't read directory produced by tar: %s", msg);
+        endif
+
+        if (length (dirlist) > 3)
+          error ("bundles of packages are not allowed");
+        endif
+      endif
+
+      ## The filename pointed to an uncompressed package to begin with.
+      if (exist (tgz, "dir"))
+        dirlist = {".", "..", tgz};
+      endif
+
+      if (exist (tgz, "file") || exist (tgz, "dir"))
+        ## The two first entries of dirlist are "." and "..".
+        if (exist (tgz, "file"))
+          packdir = fullfile (tmpdir, dirlist{3});
+        else
+          packdir = fullfile (pwd (), dirlist{3});
+        endif
+        packdirs{end+1} = packdir;
+
+        ## Make sure the package contains necessary files.
+        verify_directory (packdir);
+
+        ## Read the DESCRIPTION file.
+        filename = fullfile (packdir, "DESCRIPTION");
+        desc = get_description (filename);
+
+        ## Verify that package name corresponds with filename.
+        [dummy, nm] = fileparts (tgz);
+        if ((length (nm) >= length (desc.name))
+            && ! strcmp (desc.name, nm(1:length (desc.name))))
+          error ("package name '%s' doesn't correspond to its filename '%s'",
+                 desc.name, nm);
+        endif
+
+        ## Set default installation directory.
+        desc.dir = fullfile (prefix, cstrcat (desc.name, "-", desc.version));
+
+        ## Set default architectire dependent installation directory.
+        desc.archprefix = fullfile (archprefix, cstrcat (desc.name, "-",
+                                                         desc.version));
+
+        ## Save desc.
+        descriptions{end+1} = desc;
+
+        ## Are any of the new packages already installed?
+        ## If so we'll remove the old version.
+        for j = 1:length (packages)
+          if (strcmp (packages{j}.name, desc.name))
+            packages_to_uninstall(end+1) = j;
+          endif
+        endfor
+      endif
+    endfor
+  catch
+    ## Something went wrong, delete tmpdirs.
+    for i = 1:length (tmpdirs)
+      rmdir (tmpdirs{i}, "s");
+    endfor
+    rethrow (lasterror ());
+  end_try_catch
+
+  ## Check dependencies.
+  if (handle_deps)
+    ok = true;
+    error_text = "";
+    for i = 1:length (descriptions)
+      desc = descriptions{i};
+      idx2 = setdiff (1:length (descriptions), i);
+      if (global_install)
+        ## Global installation is not allowed to have dependencies on locally
+        ## installed packages.
+        idx1 = setdiff (1:length (global_packages), packages_to_uninstall);
+        pseudo_installed_packages = {global_packages{idx1}, ...
+                                     descriptions{idx2}};
+      else
+        idx1 = setdiff (1:length (local_packages), packages_to_uninstall);
+        pseudo_installed_packages = {local_packages{idx1}, ...
+                                     global_packages{:}, ...
+                                     descriptions{idx2}};
+      endif
+      bad_deps = get_unsatisfied_deps (desc, pseudo_installed_packages);
+      ## Are there any unsatisfied dependencies?
+      if (! isempty (bad_deps))
+        ok = false;
+        for i = 1:length (bad_deps)
+          dep = bad_deps{i};
+          error_text = cstrcat (error_text, " ", desc.name, " needs ",
+                               dep.package, " ", dep.operator, " ",
+                               dep.version, "\n");
+        endfor
+      endif
+    endfor
+
+    ## Did we find any unsatisfied dependencies?
+    if (! ok)
+      error ("the following dependencies where unsatisfied:\n  %s", error_text);
+    endif
+  endif
+
+  ## Prepare each package for installation.
+  try
+    for i = 1:length (descriptions)
+      desc = descriptions{i};
+      pdir = packdirs{i};
+      prepare_installation (desc, pdir);
+      configure_make (desc, pdir, verbose);
+    endfor
+  catch
+    ## Something went wrong, delete tmpdirs.
+    for i = 1:length (tmpdirs)
+      rmdir (tmpdirs{i}, "s");
+    endfor
+    rethrow (lasterror ());
+  end_try_catch
+
+  ## Uninstall the packages that will be replaced.
+  try
+    for i = packages_to_uninstall
+      if (global_install)
+        uninstall ({global_packages{i}.name}, false, verbose, local_list,
+                   global_list, global_install);
+      else
+        uninstall ({local_packages{i}.name}, false, verbose, local_list,
+                   global_list, global_install);
+      endif
+    endfor
+  catch
+    ## Something went wrong, delete tmpdirs.
+    for i = 1:length (tmpdirs)
+      rmdir (tmpdirs{i}, "s");
+    endfor
+    rethrow (lasterror ());
+  end_try_catch
+
+  ## Install each package.
+  try
+    for i = 1:length (descriptions)
+      desc = descriptions{i};
+      pdir = packdirs{i};
+      copy_files (desc, pdir, global_install);
+      create_pkgadddel (desc, pdir, "PKG_ADD", global_install);
+      create_pkgadddel (desc, pdir, "PKG_DEL", global_install);
+      finish_installation (desc, pdir, global_install);
+      generate_lookfor_cache (desc);
+    endfor
+  catch
+    ## Something went wrong, delete tmpdirs.
+    for i = 1:length (tmpdirs)
+      rmdir (tmpdirs{i}, "s");
+    endfor
+    for i = 1:length (descriptions)
+      rmdir (descriptions{i}.dir, "s");
+      rmdir (getarchdir (descriptions{i}), "s");
+    endfor
+    rethrow (lasterror ());
+  end_try_catch
+
+  ## Check if the installed directory is empty. If it is remove it
+  ## from the list.
+  for i = length (descriptions):-1:1
+    if (dirempty (descriptions{i}.dir, {"packinfo", "doc"})
+        && dirempty (getarchdir (descriptions{i})))
+      warning ("package %s is empty\n", descriptions{i}.name);
+      rmdir (descriptions{i}.dir, "s");
+      rmdir (getarchdir (descriptions{i}), "s");
+      descriptions(i) = [];
+    endif
+  endfor
+
+  ## If the package requested that it is autoloaded, or the installer
+  ## requested that it is, then mark the package as autoloaded.
+  str_true = {"true", "on", "yes", "1"};
+  for i = length (descriptions):-1:1
+
+    desc_autoload = false;
+    if (isfield (descriptions{i}, "autoload"))
+      a = descriptions{i}.autoload;
+      desc_autoload = ((isnumeric (a) && a > 0)
+                       || (ischar (a) 
+                           && any (strcmpi (a, str_true))));
+    endif
+
+    if (autoload > 0 || (autoload == 0 && desc_autoload))
+      fclose (fopen (fullfile (descriptions{i}.dir, "packinfo",
+                               ".autoload"), "wt"));
+      descriptions{i}.autoload = 1;
+    else
+      descriptions{i}.autoload = 0;
+    endif
+
+  endfor
+
+  ## Add the packages to the package list.
+  try
+    if (global_install)
+      idx = setdiff (1:length (global_packages), packages_to_uninstall);
+      global_packages = save_order ({global_packages{idx}, descriptions{:}});
+      save (global_list, "global_packages");
+      installed_pkgs_lst = {local_packages{:}, global_packages{:}};
+    else
+      idx = setdiff (1:length (local_packages), packages_to_uninstall);
+      local_packages = save_order ({local_packages{idx}, descriptions{:}});
+      save (local_list, "local_packages");
+      installed_pkgs_lst = {local_packages{:}, global_packages{:}};
+    endif
+  catch
+    ## Something went wrong, delete tmpdirs.
+    for i = 1:length (tmpdirs)
+      rmdir (tmpdirs{i}, "s");
+    endfor
+    for i = 1:length (descriptions)
+      rmdir (descriptions{i}.dir, "s");
+    endfor
+    if (global_install)
+      printf ("error: couldn't append to %s\n", global_list);
+    else
+      printf ("error: couldn't append to %s\n", local_list);
+    endif
+    rethrow (lasterror ());
+  end_try_catch
+
+  ## All is well, let's clean up.
+  for i = 1:length (tmpdirs)
+    [status, msg] = rmdir (tmpdirs{i}, "s");
+    if (status != 1 && exist (tmpdirs{i}, "dir"))
+      warning ("couldn't clean up after my self: %s\n", msg);
+    endif
+  endfor
+
+  ## Add the newly installed packages to the path, so the user
+  ## can begin using them. Only load them if they are marked autoload.
+  if (length (descriptions) > 0)
+    idx = [];
+    for i = 1:length (descriptions)
+      if (descriptions{i}.autoload > 0)
+        nm = descriptions{i}.name;
+        for j = 1:length (installed_pkgs_lst)
+          if (strcmp (nm, installed_pkgs_lst{j}.name))
+            idx (end + 1) = j;
+            break;
+          endif
+        endfor
+      endif
+    endfor
+    load_packages_and_dependencies (idx, handle_deps, installed_pkgs_lst,
+                                    global_install);
+  endif
+
+  ## If there's a NEWS file, mention it
+  ## we are checking if desc exists too because it's possible to ge to this point
+  ## without creating it such as giving an invalid filename for the package
+  if (exist ("desc", "var") && exist (fullfile (desc.dir, "packinfo", "NEWS"), "file"))
+    printf ("For information about changes from previous versions of the %s package, run 'news (\"%s\")'.\n",
+            desc.name, desc.name);
+  endif
+
+endfunction
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/installed_packages.m
@@ -0,0 +1,157 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{out1}, @var{out2}] =} installed_packages (@var{local_list}, @var{global_list})
+## Undocumented internal function.
+## @end deftypefn
+
+function [out1, out2] = installed_packages (local_list, global_list)
+  ## Get the list of installed packages.
+  try
+    local_packages = load (local_list).local_packages;
+  catch
+    local_packages = {};
+  end_try_catch
+  try
+    global_packages = load (global_list).global_packages;
+  catch
+    global_packages = {};
+  end_try_catch
+  installed_pkgs_lst = {local_packages{:}, global_packages{:}};
+
+  ## Eliminate duplicates in the installed package list.
+  ## Locally installed packages take precedence.
+  dup = [];
+  for i = 1:length (installed_pkgs_lst)
+    if (any (dup == i))
+      continue;
+    endif
+    for j = (i+1):length (installed_pkgs_lst)
+      if (any (dup == j))
+        continue;
+      endif
+      if (strcmp (installed_pkgs_lst{i}.name, installed_pkgs_lst{j}.name))
+        dup = [dup, j];
+      endif
+    endfor
+  endfor
+  if (! isempty (dup))
+    installed_pkgs_lst(dup) = [];
+  endif
+
+  ## Now check if the package is loaded.
+  tmppath = strrep (path (), "\\", "/");
+  for i = 1:length (installed_pkgs_lst)
+    if (strfind (tmppath, strrep (installed_pkgs_lst{i}.dir, '\', '/')))
+      installed_pkgs_lst{i}.loaded = true;
+    else
+      installed_pkgs_lst{i}.loaded = false;
+    endif
+  endfor
+  for i = 1:length (local_packages)
+    if (strfind (tmppath, strrep (local_packages{i}.dir, '\', '/')))
+      local_packages{i}.loaded = true;
+    else
+      local_packages{i}.loaded = false;
+    endif
+  endfor
+  for i = 1:length (global_packages)
+    if (strfind (tmppath, strrep (global_packages{i}.dir, '\', '/')))
+      global_packages{i}.loaded = true;
+    else
+      global_packages{i}.loaded = false;
+    endif
+  endfor
+
+  ## Should we return something?
+  if (nargout == 2)
+    out1 = local_packages;
+    out2 = global_packages;
+    return;
+  elseif (nargout == 1)
+    out1 = installed_pkgs_lst;
+    return;
+  endif
+
+  ## We shouldn't return something, so we'll print something.
+  num_packages = length (installed_pkgs_lst);
+  if (num_packages == 0)
+    printf ("no packages installed.\n");
+    return;
+  endif
+
+  ## Compute the maximal lengths of name, version, and dir.
+  h1 = "Package Name";
+  h2 = "Version";
+  h3 = "Installation directory";
+  max_name_length = length (h1);
+  max_version_length = length (h2);
+  names = cell (num_packages, 1);
+  for i = 1:num_packages
+    max_name_length = max (max_name_length,
+                           length (installed_pkgs_lst{i}.name));
+    max_version_length = max (max_version_length,
+                              length (installed_pkgs_lst{i}.version));
+    names{i} = installed_pkgs_lst{i}.name;
+  endfor
+  max_dir_length = terminal_size ()(2) - max_name_length - ...
+                                             max_version_length - 7;
+  if (max_dir_length < 20)
+     max_dir_length = Inf;
+  endif
+
+  h1 = postpad (h1, max_name_length + 1, " ");
+  h2 = postpad (h2, max_version_length, " ");;
+
+  ## Print a header.
+  header = sprintf ("%s | %s | %s\n", h1, h2, h3);
+  printf (header);
+  tmp = sprintf (repmat ("-", 1, length (header) - 1));
+  tmp(length(h1)+2) = "+";
+  tmp(length(h1)+length(h2)+5) = "+";
+  printf ("%s\n", tmp);
+
+  ## Print the packages.
+  format = sprintf ("%%%ds %%1s| %%%ds | %%s\n", max_name_length,
+                    max_version_length);
+  [dummy, idx] = sort (names);
+  for i = 1:num_packages
+    cur_name = installed_pkgs_lst{idx(i)}.name;
+    cur_version = installed_pkgs_lst{idx(i)}.version;
+    cur_dir = installed_pkgs_lst{idx(i)}.dir;
+    if (length (cur_dir) > max_dir_length)
+      first_char = length (cur_dir) - max_dir_length + 4;
+      first_filesep = strfind (cur_dir(first_char:end), filesep ());
+      if (! isempty (first_filesep))
+        cur_dir = cstrcat ("...",
+                          cur_dir((first_char + first_filesep(1) - 1):end));
+      else
+        cur_dir = cstrcat ("...", cur_dir(first_char:end));
+      endif
+    endif
+    if (installed_pkgs_lst{idx(i)}.loaded)
+      cur_loaded = "*";
+    else
+      cur_loaded = " ";
+    endif
+    printf (format, cur_name, cur_loaded, cur_version, cur_dir);
+  endfor
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/is_architecture_dependent.m
@@ -0,0 +1,46 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{dep} =} is_architecture_dependent (@var{nm})
+## Undocumented internal function.
+## @end deftypefn
+
+function dep = is_architecture_dependent (nm)
+  persistent archdepsuffix = {".oct",".mex",".a",".lib",".so",".so.*",".dll","dylib"};
+
+  dep = false;
+  for i = 1 : length (archdepsuffix)
+    ext = archdepsuffix{i};
+    if (ext(end) == "*")
+      isglob = true;
+      ext(end) = [];
+    else
+      isglob = false;
+    endif
+    pos = strfind (nm, ext);
+    if (pos)
+      if (! isglob && (length (nm) - pos(end) != length (ext) - 1))
+        continue;
+      endif
+      dep = true;
+      break;
+    endif
+  endfor
+endfunction
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/list_forge_packages.m
@@ -0,0 +1,44 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{list} =} list_forge_packages ()
+## Undocumented internal function.
+## @end deftypefn
+
+function list = list_forge_packages ()
+  [list, succ] = urlread ("http://octave.sourceforge.net/list_packages.php");
+  if (succ)
+    list = strsplit (list, " \n\t", true);
+  else
+    error ("pkg: could not read URL, please verify internet connection");
+  endif
+  if (nargout == 0)
+    page_screen_output (false, "local");
+    puts ("OctaveForge provides these packages:\n");
+    for i = 1:length (list)
+      try
+        ver = get_forge_pkg (list{i});
+      catch
+        ver = "unknown";
+      end_try_catch
+      printf ("  %s %s\n", list{i}, ver);
+    endfor
+  endif
+endfunction
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/load_package_dirs.m
@@ -0,0 +1,58 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{idx} =} load_package_dirs (@var{lidx}, @var{idx}, @var{handle_deps}, @var{installed_pkgs_lst})
+## Undocumented internal function.
+## @end deftypefn
+
+function idx = load_package_dirs (lidx, idx, handle_deps, installed_pkgs_lst)
+  for i = lidx
+    if (isfield (installed_pkgs_lst{i}, "loaded")
+        && installed_pkgs_lst{i}.loaded)
+      continue;
+    else
+      ## Insert this package at the front before recursing over dependencies.
+      if (! any (idx == i))
+        idx = [i, idx];
+      endif
+
+      if (handle_deps)
+        deps = installed_pkgs_lst{i}.depends;
+        if ((length (deps) > 1)
+            || (length (deps) == 1 && ! strcmp (deps{1}.package, "octave")))
+          tmplidx = [];
+          for k = 1 : length (deps)
+            for j = 1 : length (installed_pkgs_lst)
+              if (strcmp (installed_pkgs_lst{j}.name, deps{k}.package))
+                if (! any (idx == j))
+                  tmplidx (end + 1) = j;
+                  break;
+                endif
+              endif
+            endfor
+          endfor
+          idx = load_package_dirs (tmplidx, idx, handle_deps,
+                                 installed_pkgs_lst);
+        endif
+      endif
+    endif
+  endfor
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/load_packages.m
@@ -0,0 +1,62 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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} {} load_packages (@var{files}, @var{handle_deps}, @var{local_list}, @var{global_list})
+## Undocumented internal function.
+## @end deftypefn
+
+function load_packages (files, handle_deps, local_list, global_list)
+  installed_pkgs_lst = installed_packages (local_list, global_list);
+  num_packages = length (installed_pkgs_lst);
+
+  ## Read package names and installdirs into a more convenient format.
+  pnames = pdirs = cell (1, num_packages);
+  for i = 1:num_packages
+    pnames{i} = installed_pkgs_lst{i}.name;
+    pdirs{i} = installed_pkgs_lst{i}.dir;
+  endfor
+
+  ## Load all.
+  if (length (files) == 1 && strcmp (files{1}, "all"))
+    idx = [1:length(installed_pkgs_lst)];
+  ## Load auto.
+  elseif (length (files) == 1 && strcmp (files{1}, "auto"))
+    idx = [];
+    for i = 1:length (installed_pkgs_lst)
+      if (exist (fullfile (pdirs{i}, "packinfo", ".autoload"), "file"))
+        idx (end + 1) = i;
+      endif
+    endfor
+  ## Load package_name1 ...
+  else
+    idx = [];
+    for i = 1:length (files)
+      idx2 = find (strcmp (pnames, files{i}));
+      if (! any (idx2))
+          error ("package %s is not installed", files{i});
+      endif
+      idx (end + 1) = idx2;
+    endfor
+  endif
+
+  ## Load the packages, but take care of the ordering of dependencies.
+  load_packages_and_dependencies (idx, handle_deps, installed_pkgs_lst, true);
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/load_packages_and_dependencies.m
@@ -0,0 +1,55 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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} {} load_packages_and_dependencies (@var{idx}, @var{handle_deps}, @var{installed_pkgs_lst}, @var{global_install})
+## Undocumented internal function.
+## @end deftypefn
+
+function load_packages_and_dependencies (idx, handle_deps, installed_pkgs_lst,
+                                         global_install)
+  idx = load_package_dirs (idx, [], handle_deps, installed_pkgs_lst);
+  dirs = {};
+  execpath = EXEC_PATH ();
+  for i = idx;
+    ndir = installed_pkgs_lst{i}.dir;
+    dirs{end+1} = ndir;
+    if (exist (fullfile (dirs{end}, "bin"), "dir"))
+      execpath = cstrcat (execpath, pathsep (), fullfile (dirs{end}, "bin"));
+    endif
+    tmpdir = getarchdir (installed_pkgs_lst{i});
+    if (exist (tmpdir, "dir"))
+      dirs{end + 1} = tmpdir;
+      if (exist (fullfile (dirs{end}, "bin"), "dir"))
+        execpath = cstrcat (execpath, pathsep (), fullfile (dirs{end}, "bin"));
+      endif
+    endif
+  endfor
+
+  ## Load the packages.
+  if (length (dirs) > 0)
+    addpath (dirs{:});
+  endif
+
+  ## Add the binaries to exec_path.
+  if (! strcmp (EXEC_PATH, execpath))
+    EXEC_PATH (execpath);
+  endif
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/packinfo_copy_file.m
@@ -0,0 +1,38 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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} {} packinfo_copy_file (@var{filename}, @var{requirement}, @var{packdir}, @var{packinfo}, @var{desc}, @var{octfiledir})
+## Undocumented internal function.
+## @end deftypefn
+
+function packinfo_copy_file (filename, requirement, packdir, packinfo, desc, octfiledir)
+  filepath = fullfile (packdir, filename);
+  if (!exist (filepath, "file") && strcmpi (requirement, "optional"))
+    ## do nothing, it's still OK
+  else
+    [status, output] = copyfile (filepath, packinfo);
+    if (status != 1)
+      rmdir (desc.dir, "s");
+      rmdir (octfiledir, "s");
+      error ("Couldn't copy %s file: %s", filename, output);
+    endif
+  endif
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/parse_pkg_idx.m
@@ -0,0 +1,77 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{pkg_idx_struct} =} parse_pkg_idx (@var{packdir})
+## Undocumented internal function.
+## @end deftypefn
+
+
+## Read an INDEX file.
+function pkg_idx_struct = parse_pkg_idx (packdir)
+
+  index_file = fullfile (packdir, "packinfo", "INDEX");
+
+  if (! exist (index_file, "file"))
+    error ("could not find any INDEX file in directory %s, try 'pkg rebuild all' to generate missing INDEX files", packdir);
+  endif
+
+
+  [fid, msg] = fopen (index_file, "r");
+  if (fid == -1)
+    error ("the INDEX file %s could not be read: %s",
+           index_file, msg);
+  endif
+
+  cat_num = 1;
+  pkg_idx_struct{1}.category = "Uncategorized";
+  pkg_idx_struct{1}.functions = {};
+
+  line = fgetl (fid);
+  while (isempty (strfind (line, ">>")) && ! feof (fid))
+    line = fgetl (fid);
+  endwhile
+
+  while (! feof (fid) || line != -1)
+    if (! any (! isspace (line)) || line(1) == "#" || any (line == "="))
+      ## Comments,  blank lines or comments about unimplemented
+      ## functions: do nothing
+      ## FIXME: probably comments and pointers to external functions
+      ## could be treated better when printing to screen?
+    elseif (! isempty (strfind (line, ">>")))
+      ## Skip package name and description as they are in DESCRIPTION
+      ## already.
+    elseif (! isspace (line(1)))
+      ## Category.
+      if (! isempty (pkg_idx_struct{cat_num}.functions))
+        pkg_idx_struct{++cat_num}.functions = {};
+      endif
+      pkg_idx_struct{cat_num}.category = deblank (line);
+    else
+      ## Function names.
+      while (any (! isspace (line)))
+        [fun_name, line] = strtok (line);
+        pkg_idx_struct{cat_num}.functions{end+1} = deblank (fun_name);
+      endwhile
+    endif
+    line = fgetl (fid);
+  endwhile
+  fclose (fid);
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/prepare_installation.m
@@ -0,0 +1,50 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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} {} prepare_installation (@var{desc}, @var{packdir})
+## Undocumented internal function.
+## @end deftypefn
+
+function prepare_installation (desc, packdir)
+  ## Is there a pre_install to call?
+  if (exist (fullfile (packdir, "pre_install.m"), "file"))
+    wd = pwd ();
+    try
+      cd (packdir);
+      pre_install (desc);
+      cd (wd);
+    catch
+      cd (wd);
+      rethrow (lasterror ());
+    end_try_catch
+  endif
+
+  ## If the directory "inst" doesn't exist, we create it.
+  inst_dir = fullfile (packdir, "inst");
+  if (! exist (inst_dir, "dir"))
+    [status, msg] = mkdir (inst_dir);
+    if (status != 1)
+      rmdir (desc.dir, "s");
+      error ("the 'inst' directory did not exist and could not be created: %s",
+             msg);
+    endif
+  endif
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/print_package_description.m
@@ -0,0 +1,46 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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} {} print_package_description (@var{pkg_name}, @var{pkg_ver}, @var{pkg_idx_struct}, @var{pkg_desc}, @var{status}, @var{verbose})
+## Undocumented internal function.
+## @end deftypefn
+
+function print_package_description (pkg_name, pkg_ver, pkg_idx_struct,
+                                    pkg_desc, status, verbose)
+
+  printf ("---\nPackage name:\n\t%s\n", pkg_name);
+  printf ("Version:\n\t%s\n", pkg_ver);
+  printf ("Short description:\n\t%s\n", pkg_desc);
+  printf ("Status:\n\t%s\n", status);
+  if (verbose)
+    printf ("---\nProvides:\n");
+    for i = 1:length (pkg_idx_struct)
+      if (! isempty (pkg_idx_struct{i}.functions))
+        printf ("%s\n", pkg_idx_struct{i}.category);
+        for j = 1:length (pkg_idx_struct{i}.functions)
+          printf ("\t%s\n", pkg_idx_struct{i}.functions{j});
+        endfor
+      endif
+    endfor
+  endif
+
+endfunction
+
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/rebuild.m
@@ -0,0 +1,100 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{descriptions} =} rebuild (@var{prefix}, @var{archprefix}, @var{list}, @var{files}, @var{auto}, @var{verbose})
+## Undocumented internal function.
+## @end deftypefn
+
+function descriptions = rebuild (prefix, archprefix, list, files, auto, verbose)
+  if (isempty (files))
+    [dirlist, err, msg] = readdir (prefix);
+    if (err)
+      error ("couldn't read directory %s: %s", prefix, msg);
+    endif
+    ## the two first entries of dirlist are "." and ".."
+    dirlist([1,2]) = [];
+  else
+    old_descriptions = installed_packages (list, list);
+    wd = pwd ();
+    unwind_protect
+      cd (prefix);
+      dirlist = glob (cellfun(@(x) cstrcat (x, '-*'), files, 'uniformoutput', 0));
+    unwind_protect_cleanup
+      cd (wd);
+    end_unwind_protect
+  endif
+  descriptions = {};
+  for k = 1:length (dirlist)
+    descfile = fullfile (prefix, dirlist{k}, "packinfo", "DESCRIPTION");
+    if (verbose)
+      printf ("recreating package description from %s\n", dirlist{k});
+    endif
+    if (exist (descfile, "file"))
+      desc = get_description (descfile);
+      desc.dir = fullfile (prefix, dirlist{k});
+      desc.archprefix = fullfile (archprefix, cstrcat (desc.name, "-",
+                                  desc.version));
+      if (auto != 0)
+        if (exist (fullfile (desc.dir, "packinfo", ".autoload"), "file"))
+          unlink (fullfile (desc.dir, "packinfo", ".autoload"));
+        endif
+        if (auto < 0)
+          desc.autoload = 0;
+        elseif (auto > 0)
+          desc.autoload = 1;
+          fclose (fopen (fullfile (desc.dir, "packinfo", ".autoload"), "wt"));
+        endif
+      else
+        if (exist (fullfile (desc.dir, "packinfo", ".autoload"), "file"))
+          desc.autoload = 1;
+        else
+          desc.autoload = 0;
+        endif
+      endif
+      descriptions{end + 1} = desc;
+    elseif (verbose)
+      warning ("directory %s is not a valid package", dirlist{k});
+    endif
+  endfor
+
+  if (! isempty (files))
+    ## We are rebuilding for a particular package(s) so we should take
+    ## care to keep the other untouched packages in the descriptions
+    descriptions = {descriptions{:}, old_descriptions{:}};
+
+    dup = [];
+    for i = 1:length (descriptions)
+      if (any (dup == i))
+        continue;
+      endif
+      for j = (i+1):length (descriptions)
+        if (any (dup == j))
+          continue;
+        endif
+        if (strcmp (descriptions{i}.name, descriptions{j}.name))
+          dup = [dup, j];
+        endif
+      endfor
+    endfor
+    if (! isempty (dup))
+      descriptions (dup) = [];
+    endif
+  endif
+endfunction
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/repackage.m
@@ -0,0 +1,90 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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} {} repackage (@var{builddir}, @var{buildlist})
+## Undocumented internal function.
+## @end deftypefn
+
+function repackage (builddir, buildlist)
+  packages = installed_packages (buildlist, buildlist);
+
+  wd = pwd ();
+  for i = 1 : length (packages)
+    pack = packages{i};
+    unwind_protect
+      cd (builddir);
+      mkdir (pack.name);
+      mkdir (fullfile (pack.name, "inst"));
+      copyfile (fullfile (pack.dir, "*"), fullfile (pack.name, "inst"));
+      movefile (fullfile (pack.name, "inst","packinfo", "*"), pack.name);
+      if (exist (fullfile (pack.name, "inst","packinfo", ".autoload"), "file"))
+        unlink (fullfile (pack.name, "inst","packinfo", ".autoload"));
+      endif
+      rmdir (fullfile (pack.name, "inst", "packinfo"));
+      if (exist (fullfile (pack.name, "inst", "doc"), "dir"))
+        movefile (fullfile (pack.name, "inst", "doc"), pack.name);
+      endif
+      if (exist (fullfile (pack.name, "inst", "bin"), "dir"))
+        movefile (fullfile (pack.name, "inst", "bin"), pack.name);
+      endif
+      archdir = fullfile (pack.archprefix, cstrcat (pack.name, "-",
+                          pack.version), getarch ());
+      if (exist (archdir, "dir"))
+        if (exist (fullfile (pack.name, "inst", "PKG_ADD"), "file"))
+          unlink (fullfile (pack.name, "inst", "PKG_ADD"));
+        endif
+        if (exist (fullfile (pack.name, "inst", "PKG_DEL"), "file"))
+          unlink (fullfile (pack.name, "inst", "PKG_DEL"));
+        endif
+        if (exist (fullfile (archdir, "PKG_ADD"), "file"))
+          movefile (fullfile (archdir, "PKG_ADD"),
+                    fullfile (pack.name, "PKG_ADD"));
+        endif
+        if (exist (fullfile (archdir, "PKG_DEL"), "file"))
+          movefile (fullfile (archdir, "PKG_DEL"),
+                    fullfile (pack.name, "PKG_DEL"));
+        endif
+      else
+        if (exist (fullfile (pack.name, "inst", "PKG_ADD"), "file"))
+          movefile (fullfile (pack.name, "inst", "PKG_ADD"),
+                    fullfile (pack.name, "PKG_ADD"));
+        endif
+        if (exist (fullfile (pack.name, "inst", "PKG_DEL"), "file"))
+          movefile (fullfile (pack.name, "inst", "PKG_DEL"),
+                    fullfile (pack.name, "PKG_DEL"));
+        endif
+      endif
+      tfile = cstrcat (pack.name, "-", pack.version, ".tar");
+      tar (tfile, pack.name);
+      try
+        gzip (tfile);
+        unlink (tfile);
+      catch
+        warning ("failed to compress %s", tfile);
+      end_try_catch
+    unwind_protect_cleanup
+      if (exist (pack.name, "dir"))
+        rmdir (pack.name, "s");
+      endif
+      cd (wd);
+    end_unwind_protect
+  endfor
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/save_order.m
@@ -0,0 +1,60 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{newdesc} =} save_order (@var{desc})
+## Undocumented internal function.
+## @end deftypefn
+
+function newdesc = save_order (desc)
+  newdesc = {};
+  for i = 1 : length (desc)
+    deps = desc{i}.depends;
+    if (isempty (deps)
+        || (length (deps) == 1 && strcmp (deps{1}.package, "octave")))
+      newdesc {end + 1} = desc{i};
+    else
+      tmpdesc = {};
+      for k = 1 : length (deps)
+        for j = 1 : length (desc)
+          if (strcmp (desc{j}.name, deps{k}.package))
+            tmpdesc{end+1} = desc{j};
+            break;
+          endif
+        endfor
+      endfor
+      if (! isempty (tmpdesc))
+        newdesc = {newdesc{:}, save_order(tmpdesc){:}, desc{i}};
+      else
+        newdesc{end+1} = desc{i};
+      endif
+    endif
+  endfor
+  ## Eliminate the duplicates.
+  idx = [];
+  for i = 1 : length (newdesc)
+    for j = (i + 1) : length (newdesc)
+      if (strcmp (newdesc{i}.name, newdesc{j}.name))
+        idx (end + 1) = j;
+      endif
+    endfor
+  endfor
+  newdesc(idx) = [];
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/shell.m
@@ -0,0 +1,46 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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{status}, @var{output}] =} shell (@var{cmd})
+## Undocumented internal function.
+## @end deftypefn
+
+function [status, output] = shell (cmd)
+  persistent have_sh;
+
+  cmd = strrep (cmd, "\\", "/");
+  if (ispc () && ! isunix ())
+    if (isempty (have_sh))
+      if (system ("sh.exe -c \"exit\""))
+        have_sh = false;
+      else
+        have_sh = true;
+      endif
+    endif
+    if (have_sh)
+      [status, output] = system (cstrcat ("sh.exe -c \"", cmd, "\""));
+    else
+      error ("Can not find the command shell");
+    endif
+  else
+    [status, output] = system (cmd);
+  endif
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/uninstall.m
@@ -0,0 +1,147 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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} {} uninstall (@var{pkgnames}, @var{handle_deps}, @var{verbose}, @var{local_list}, @var{global_list}, @var{global_install})
+## Undocumented internal function.
+## @end deftypefn
+
+function uninstall (pkgnames, handle_deps, verbose, local_list,
+                    global_list, global_install)
+  ## Get the list of installed packages.
+  [local_packages, global_packages] = installed_packages(local_list,
+                                                         global_list);
+  if (global_install)
+    installed_pkgs_lst = {local_packages{:}, global_packages{:}};
+  else
+    installed_pkgs_lst = local_packages;
+  endif
+
+  num_packages = length (installed_pkgs_lst);
+  delete_idx = [];
+  for i = 1:num_packages
+    cur_name = installed_pkgs_lst{i}.name;
+    if (any (strcmp (cur_name, pkgnames)))
+      delete_idx(end+1) = i;
+    endif
+  endfor
+
+  ## Are all the packages that should be uninstalled already installed?
+  if (length (delete_idx) != length (pkgnames))
+    if (global_install)
+      ## Try again for a locally installed package.
+      installed_pkgs_lst = local_packages;
+
+      num_packages = length (installed_pkgs_lst);
+      delete_idx = [];
+      for i = 1:num_packages
+        cur_name = installed_pkgs_lst{i}.name;
+        if (any (strcmp (cur_name, pkgnames)))
+          delete_idx(end+1) = i;
+        endif
+      endfor
+      if (length (delete_idx) != length (pkgnames))
+        ## FIXME: We should have a better error message.
+        warning ("some of the packages you want to uninstall are not installed");
+      endif
+    else
+      ## FIXME: We should have a better error message.
+      warning ("some of the packages you want to uninstall are not installed");
+    endif
+  endif
+
+  ## Compute the packages that will remain installed.
+  idx = setdiff (1:num_packages, delete_idx);
+  remaining_packages = {installed_pkgs_lst{idx}};
+
+  ## Check dependencies.
+  if (handle_deps)
+    error_text = "";
+    for i = 1:length (remaining_packages)
+      desc = remaining_packages{i};
+      bad_deps = get_unsatisfied_deps (desc, remaining_packages);
+
+      ## Will the uninstallation break any dependencies?
+      if (! isempty (bad_deps))
+        for i = 1:length (bad_deps)
+          dep = bad_deps{i};
+          error_text = cstrcat (error_text, " ", desc.name, " needs ",
+                               dep.package, " ", dep.operator, " ",
+                               dep.version, "\n");
+        endfor
+      endif
+    endfor
+
+    if (! isempty (error_text))
+      error ("the following dependencies where unsatisfied:\n  %s", error_text);
+    endif
+  endif
+
+  ## Delete the directories containing the packages.
+  for i = delete_idx
+    desc = installed_pkgs_lst{i};
+    ## If an 'on_uninstall.m' exist, call it!
+    if (exist (fullfile (desc.dir, "packinfo", "on_uninstall.m"), "file"))
+      wd = pwd ();
+      cd (fullfile (desc.dir, "packinfo"));
+      on_uninstall (desc);
+      cd (wd);
+    endif
+    ## Do the actual deletion.
+    if (desc.loaded)
+      rmpath (desc.dir);
+      if (exist (getarchdir (desc)))
+        rmpath (getarchdir (desc));
+      endif
+    endif
+    if (exist (desc.dir, "dir"))
+      [status, msg] = rmdir (desc.dir, "s");
+      if (status != 1 && exist (desc.dir, "dir"))
+        error ("couldn't delete directory %s: %s", desc.dir, msg);
+      endif
+      [status, msg] = rmdir (getarchdir (desc), "s");
+      if (status != 1 && exist (getarchdir (desc), "dir"))
+        error ("couldn't delete directory %s: %s", getarchdir (desc), msg);
+      endif
+      if (dirempty (desc.archprefix))
+        rmdir (desc.archprefix, "s");
+      endif
+    else
+      warning ("directory %s previously lost", desc.dir);
+    endif
+  endfor
+
+  ## Write a new ~/.octave_packages.
+  if (global_install)
+    if (length (remaining_packages) == 0)
+      unlink (global_list);
+    else
+      global_packages = save_order (remaining_packages);
+      save (global_list, "global_packages");
+    endif
+  else
+    if (length (remaining_packages) == 0)
+      unlink (local_list);
+    else
+      local_packages = save_order (remaining_packages);
+      save (local_list, "local_packages");
+    endif
+  endif
+
+endfunction
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/unload_packages.m
@@ -0,0 +1,81 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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} {} unload_packages (@var{files}, @var{handle_deps}, @var{local_list}, @var{global_list})
+## Undocumented internal function.
+## @end deftypefn
+
+function unload_packages (files, handle_deps, local_list, global_list)
+  installed_pkgs_lst = installed_packages (local_list, global_list);
+  num_packages = length (installed_pkgs_lst);
+
+  ## Read package names and installdirs into a more convenient format.
+  pnames = pdirs = cell (1, num_packages);
+  for i = 1:num_packages
+    pnames{i} = installed_pkgs_lst{i}.name;
+    pdirs{i} = installed_pkgs_lst{i}.dir;
+    pdeps{i} = installed_pkgs_lst{i}.depends;
+  endfor
+
+  ## Get the current octave path.
+  p = strtrim (strsplit (path (), pathsep ()));
+
+  if (length (files) == 1 && strcmp (files{1}, "all"))
+    ## Unload all.
+    dirs = pdirs;
+    desc = installed_pkgs_lst;
+  else
+    ## Unload package_name1 ...
+    dirs = {};
+    desc = {};
+    for i = 1:length (files)
+      idx = strcmp (pnames, files{i});
+      if (! any (idx))
+        error ("package %s is not installed", files{i});
+      endif
+        dirs{end+1} = pdirs{idx};
+        desc{end+1} = installed_pkgs_lst{idx};
+      endfor
+  endif
+
+  ## Check for architecture dependent directories.
+  archdirs = {};
+  for i = 1:length (dirs)
+    tmpdir = getarchdir (desc{i});
+    if (exist (tmpdir, "dir"))
+      archdirs{end+1} = dirs{i};
+      archdirs{end+1} = tmpdir;
+    else
+      archdirs{end+1} = dirs{i};
+    endif
+  endfor
+
+  ## Unload the packages.
+  for i = 1:length (archdirs)
+    d = archdirs{i};
+    idx = strcmp (p, d);
+    if (any (idx))
+      rmpath (d);
+      ## FIXME: We should also check if we need to remove items from
+      ## EXEC_PATH.
+    endif
+  endfor
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/verify_directory.m
@@ -0,0 +1,34 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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} {} verify_directory (@var{dir})
+## Undocumented internal function.
+## @end deftypefn
+
+## Make sure the package contains the essential files.
+function verify_directory (dir)
+  needed_files = {"COPYING", "DESCRIPTION"};
+  for f = needed_files
+    if (! exist (fullfile (dir, f{1}), "file"))
+      error ("package is missing file: %s", f{1});
+    endif
+  endfor
+endfunction
+
new file mode 100644
--- /dev/null
+++ b/scripts/pkg/private/write_index.m
@@ -0,0 +1,92 @@
+## Copyright (C) 2005-2012 Søren Hauberg
+## Copyright (C) 2010 VZLU Prague, a.s.
+##
+## 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} {} write_index (@var{desc}, @var{dir}, @var{index_file}, @var{global_install})
+## Undocumented internal function.
+## @end deftypefn
+
+## Create an INDEX file for a package that doesn't provide one.
+##   'desc'  describes the package.
+##   'dir'   is the 'inst' directory in temporary directory.
+##   'index_file' is the name (including path) of resulting INDEX file.
+
+function write_index (desc, dir, index_file, global_install)
+  ## Get names of functions in dir
+  [files, err, msg] = readdir (dir);
+  if (err)
+    error ("couldn't read directory %s: %s", dir, msg);
+  endif
+
+  ## Get classes in dir
+  class_idx = find (strncmp (files, '@', 1));
+  for k = 1:length (class_idx)
+    class_name = files {class_idx (k)};
+    class_dir = fullfile (dir, class_name);
+    if (exist (class_dir, "dir"))
+      [files2, err, msg] = readdir (class_dir);
+      if (err)
+        error ("couldn't read directory %s: %s", class_dir, msg);
+      endif
+      files2 = strcat (class_name, filesep (), files2);
+      files = [files; files2];
+    endif
+  endfor
+
+  ## Check for architecture dependent files.
+  tmpdir = getarchdir (desc);
+  if (exist (tmpdir, "dir"))
+    [files2, err, msg] = readdir (tmpdir);
+    if (err)
+      error ("couldn't read directory %s: %s", tmpdir, msg);
+    endif
+    files = [files; files2];
+  endif
+
+  functions = {};
+  for i = 1:length (files)
+    file = files{i};
+    lf = length (file);
+    if (lf > 2 && strcmp (file(end-1:end), ".m"))
+      functions{end+1} = file(1:end-2);
+    elseif (lf > 4 && strcmp (file(end-3:end), ".oct"))
+      functions{end+1} = file(1:end-4);
+    endif
+  endfor
+
+  ## Does desc have a categories field?
+  if (! isfield (desc, "categories"))
+    error ("the DESCRIPTION file must have a Categories field, when no INDEX file is given");
+  endif
+  categories = strtrim (strsplit (desc.categories, ","));
+  if (length (categories) < 1)
+      error ("the Category field is empty");
+  endif
+
+  ## Write INDEX.
+  fid = fopen (index_file, "w");
+  if (fid == -1)
+    error ("couldn't open %s for writing", index_file);
+  endif
+  fprintf (fid, "%s >> %s\n", desc.name, desc.title);
+  fprintf (fid, "%s\n", categories{1});
+  fprintf (fid, "  %s\n", functions{:});
+  fclose (fid);
+endfunction
+
--- a/scripts/plot/__gnuplot_drawnow__.m
+++ b/scripts/plot/__gnuplot_drawnow__.m
@@ -122,8 +122,8 @@
     ## toolkit.
     [term, opts_str] = gnuplot_trim_term (term);
     term = lower (term);
-    if (strcmpi (term, "lua"))
-      ## Replace "lau tikz" with
+    if (strcmp (term, "lua"))
+      ## Replace "lua tikz" with just "tikz"
       term = "tikz";
       opts_str = strrep (opts_str, "tikz", "");
     endif
@@ -147,10 +147,10 @@
     if (! isempty (h) && isfigure (h))
 
       ## Generate gnuplot title string for plot windows.
-      if (output_to_screen (term) && ~strcmp (term, "dumb"))
+      if (output_to_screen (term) && ! strcmp (term, "dumb"))
         fig.numbertitle = get (h, "numbertitle");
         fig.name = strrep (get (h, "name"), "\"", "\\\"");
-        if (strcmpi (get (h, "numbertitle"), "on"))
+        if (strcmp (get (h, "numbertitle"), "on"))
           title_str = sprintf ("Figure %d", h);
         else
           title_str = "";
@@ -186,8 +186,8 @@
         gnuplot_pos = position_in_pixels(1:2);
         gnuplot_size = position_in_pixels(3:4);
         if (! (output_to_screen (term)
-               || any (strcmp (term, {"emf", "gif", "jpeg", "pbm", "png", ...
-                                      "pngcairo", "svg"}))))
+               || any (strcmp (term, {"canvas", "emf", "gif", "jpeg", ...
+                                      "pbm", "png", "pngcairo", "svg"}))))
           ## Convert to inches
           gnuplot_pos = gnuplot_pos / 72;
           gnuplot_size = gnuplot_size / 72;
@@ -197,6 +197,9 @@
                                  "gif", "jpeg", "latex", "pbm", "pdf", ...
                                  "pdfcairo", "postscript", "png", "pngcairo", ...
                                  "pstex", "pslatex", "svg", "tikz"};
+          if (__gnuplot_has_feature__ ("windows_figure_position"))
+            terminals_with_size{end+1} = "windows";
+          endif
           if (__gnuplot_has_feature__ ("x11_figure_position"))
             terminals_with_size{end+1} = "x11";
           endif
@@ -205,12 +208,12 @@
           endif
           switch (term)
           case terminals_with_size
-            size_str = sprintf ("size %g,%g", gnuplot_size);
+            size_str = sprintf ("size %.12g,%.12g", gnuplot_size);
           case "tikz"
             size_str = sprintf ("size %gin,%gin", gnuplot_size);
           case "dumb"
             new_stream = 1;
-            if (~isempty (getenv ("COLUMNS")) && ~isempty (getenv ("LINES")))
+            if (! isempty (getenv ("COLUMNS")) && ! isempty (getenv ("LINES")))
               ## Let dumb use full text screen size (minus prompt lines).
               n = sprintf ("%i", -2 - length (find (sprintf ("%s", PS1) == "\n")));
               ## n = the number of times \n appears in PS1
@@ -226,9 +229,11 @@
           otherwise
             size_str = "";
           endswitch
-          if (strncmpi (term, "x11", 3)
-              && __gnuplot_has_feature__ ("x11_figure_position"))
-            ## X11 allows the window to be positioned as well.
+          if ((strncmpi (term, "x11", 3)
+               && __gnuplot_has_feature__ ("x11_figure_position"))
+              || (strcmpi (term, "windows")
+                  && __gnuplot_has_feature__ ("windows_figure_position")))
+            ## X11/Windows allows the window to be positioned as well.
             units = get (0, "units");
             unwind_protect
               set (0, "units", "pixels");
@@ -237,7 +242,7 @@
               set (0, "units", units);
             end_unwind_protect
             if (all (screen_size > 0))
-              ## For X11, set the figure positon as well as the size
+              ## For X11/Windows, set the figure positon as well as the size
               ## gnuplot position is UL, Octave's is LL (same for screen/window)
               gnuplot_pos(2) = screen_size(2) - gnuplot_pos(2) - gnuplot_size(2);
               gnuplot_pos = max (gnuplot_pos, 1);
@@ -254,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 = "";
@@ -390,3 +395,4 @@
 
 ## No test needed for internal helper function.
 %!assert (1)
+
--- a/scripts/plot/__plt_get_axis_arg__.m
+++ b/scripts/plot/__plt_get_axis_arg__.m
@@ -80,3 +80,4 @@
 
 ## No test needed for internal helper function.
 %!assert (1)
+
--- a/scripts/plot/allchild.m
+++ b/scripts/plot/allchild.m
@@ -49,7 +49,7 @@
 %! hf = figure ("visible", "off");
 %! unwind_protect
 %!   l = line;
-%!   assert(get (allchild (hf),"type"),{"axes"; "uimenu"; "uimenu"; "uimenu"});
+%!   assert (get (allchild (hf),"type"),{"axes"; "uimenu"; "uimenu"; "uimenu"});
 %! unwind_protect_cleanup
 %!   close (hf);
 %!   graphics_toolkit (toolkit);
--- a/scripts/plot/ancestor.m
+++ b/scripts/plot/ancestor.m
@@ -18,7 +18,7 @@
 
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {@var{parent} =} ancestor (@var{h}, @var{type})
-## @deftypefnx {Function File} {@var{parent} =} ancestor (@var{h}, @var{type}, 'toplevel')
+## @deftypefnx {Function File} {@var{parent} =} ancestor (@var{h}, @var{type}, "toplevel")
 ## Return the first ancestor of handle object @var{h} whose type matches
 ## @var{type}, where @var{type} is a character string.  If @var{type} is a
 ## cell array of strings, return the first parent whose type matches
@@ -49,7 +49,7 @@
         endif
       endif
       h = num2cell (h);
-      for nh = 1:numel(h)
+      for nh = 1:numel (h)
         while (true)
           if (isempty (h{nh}) || ! ishandle (h{nh}))
             break;
@@ -75,6 +75,7 @@
 
 endfunction
 
+
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
@@ -84,3 +85,4 @@
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
+
--- a/scripts/plot/area.m
+++ b/scripts/plot/area.m
@@ -80,9 +80,9 @@
       y = y(:);
     endif
     if (isempty (x))
-      x = repmat ([1:size(y, 1)]', 1, size (y, 2));
+      x = repmat ([1:rows(y)]', 1, columns (y));
     elseif (isvector (x))
-      x = repmat (x(:),  1, size (y, 2));
+      x = repmat (x(:),  1, columns (y));
     endif
 
     oldax = gca ();
@@ -107,7 +107,7 @@
   y0 = bv * ones (1, rows (y));
   y0 = zeros (1, rows (y));
   retval = [];
-  for i = 1: size (y, 2);
+  for i = 1: columns (y);
     hg = hggroup ();
     retval = [retval; hg];
     args = __add_datasource__ ("area", hg, {"x", "y"}, varargin{:});
--- a/scripts/plot/axes.m
+++ b/scripts/plot/axes.m
@@ -43,7 +43,7 @@
   else
     ## arg is axes handle.
     tmp = varargin{1};
-    if (length(tmp) == 1 && ishandle (tmp)
+    if (length (tmp) == 1 && ishandle (tmp)
         && strcmp (get (tmp, "type"), "axes"))
       if (__is_handle_visible__ (tmp))
         parent = ancestor (tmp, "figure");
--- a/scripts/plot/axis.m
+++ b/scripts/plot/axis.m
@@ -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,14 +321,14 @@
     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);
       n = cellfun (@isempty, data);
       data(n) = cellfun (@(x) x(x<0), tmp(n), "uniformoutput", false);
     endif
-    data = cellfun (@(x) x(isfinite(x)), data, "uniformoutput", false);
+    data = cellfun (@(x) x(isfinite (x)), data, "uniformoutput", false);
     data = data(! cellfun ("isempty", data));
     if (! isempty (data))
       lims_min = min (cellfun (@(x) min (x(:)), data(:)));
@@ -346,214 +346,221 @@
   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
 
 endfunction
 
-%!demo
-%! clf
-%! t=0:0.01:2*pi; x=sin(t);
-%!
-%! subplot(221);
-%! plot(t, x);
-%! title("normal plot");
-%!
-%! subplot(222);
-%! plot(t, x);
-%! title("square plot");
-%! axis("square");
-%!
-%! subplot(223);
-%! plot(t, x);
-%! title("equal plot");
-%! axis("equal");
-%!
-%! subplot(224);
-%! plot(t, x);
-%! title("normal plot again");
-%! axis("normal");
 
 %!demo
-%! clf
-%! t=0:0.01:2*pi; x=sin(t);
+%! clf;
+%! t = 0:0.01:2*pi;
+%! x = sin (t);
+%!
+%! subplot (221);
+%!  plot (t, x);
+%!  title ('normal plot');
+%!
+%! subplot (222);
+%!  plot (t, x);
+%!  title ('square plot');
+%!  axis ('square');
+%!
+%! subplot (223);
+%!  plot (t, x);
+%!  title ('equal plot');
+%!  axis ('equal');
 %!
-%! subplot(121);
-%! plot(t, x);
-%! title("ij plot");
-%! axis("ij");
+%! subplot (224);
+%!  plot (t, x);
+%!  title ('normal plot again');
+%!  axis ('normal');
+
+%!demo
+%! clf;
+%! t = 0:0.01:2*pi;
+%! x = sin (t);
 %!
-%! subplot(122);
-%! plot(t, x);
-%! title("xy plot");
-%! axis("xy");
+%! subplot (121);
+%!  plot (t, x);
+%!  title ('ij plot');
+%!  axis ('ij');
+%!
+%! subplot (122);
+%!  plot (t, x);
+%!  title ('xy plot');
+%!  axis ('xy');
 
 %!demo
-%! clf
-%! t=0:0.01:2*pi; x=sin(t);
+%! clf;
+%! t = 0:0.01:2*pi;
+%! x = sin (t);
 %!
-%! subplot(331);
-%! plot(t, x);
-%! title("x tics and labels");
-%! axis("ticx");
+%! subplot (331);
+%!  plot (t, x);
+%!  title ('x tics and labels');
+%!  axis ('ticx');
 %!
-%! subplot(332);
-%! plot(t, x);
-%! title("y tics and labels");
-%! axis("ticy");
+%! subplot (332);
+%!  plot (t, x);
+%!  title ('y tics and labels');
+%!  axis ('ticy');
 %!
-%! subplot(333);
-%! plot(t, x);
-%! title("axis off");
-%! axis("off");
+%! subplot (333);
+%!  plot (t, x);
+%!  title ('axis off');
+%!  axis ('off');
 %!
-%! subplot(334);
-%! plot(t, x);
-%! title("x and y tics, x labels");
-%! axis("labelx","tic");
+%! subplot (334);
+%!  plot (t, x);
+%!  title ('x and y tics, x labels');
+%!  axis ('labelx','tic');
 %!
-%! subplot(335);
-%! plot(t, x);
-%! title("x and y tics, y labels");
-%! axis("labely","tic");
+%! subplot (335);
+%!  plot (t, x);
+%!  title ('x and y tics, y labels');
+%!  axis ('labely','tic');
 %!
-%! subplot(336);
-%! plot(t, x);
-%! title("all tics but no labels");
-%! axis("nolabel","tic");
+%! subplot (336);
+%!  plot (t, x);
+%!  title ('all tics but no labels');
+%!  axis ('nolabel','tic');
 %!
-%! subplot(337);
-%! plot(t, x);
-%! title("x tics, no labels");
-%! axis("nolabel","ticx");
+%! subplot (337);
+%!  plot (t, x);
+%!  title ('x tics, no labels');
+%!  axis ('nolabel','ticx');
 %!
-%! subplot(338);
-%! plot(t, x);
-%! title("y tics, no labels");
-%! axis("nolabel","ticy");
+%! subplot (338);
+%!  plot (t, x);
+%!  title ('y tics, no labels');
+%!  axis ('nolabel','ticy');
 %!
-%! subplot(339);
-%! plot(t, x);
-%! title("all tics and labels");
-%! axis("on");
+%! subplot (339);
+%!  plot (t, x);
+%!  title ('all tics and labels');
+%!  axis ('on');
 
 %!demo
-%! clf
-%! t=0:0.01:2*pi; x=sin(t);
+%! clf;
+%! t = 0:0.01:2*pi;
+%! x = sin (t);
 %!
-%! subplot(321);
-%! plot(t, x);
-%! title("axes at [0 3 0 1]")
-%! axis([0,3,0,1]);
+%! subplot (321);
+%!  plot (t, x);
+%!  title ('axes at [0 3 0 1]');
+%!  axis ([0,3,0,1]);
 %!
-%! subplot(322);
-%! plot(t, x);
-%! title("auto");
-%! axis("auto");
+%! subplot (322);
+%!  plot (t, x);
+%!  title ('auto');
+%!  axis ('auto');
 %!
-%! subplot(323);
-%! plot(t, x, ";sine [0:2pi];"); hold on;
-%! plot(-3:3,-3:3, ";line (-3,-3)->(3,3);"); hold off;
-%! title("manual");
-%! axis("manual");
+%! subplot (323);
+%!  plot (t, x, ';sine [0:2pi];'); hold on;
+%!  plot (-3:3,-3:3, ';line (-3,-3)->(3,3);'); hold off;
+%!  title ('manual');
+%!  axis ('manual');
 %!
-%! subplot(324);
-%! plot(t, x, ";sine [0:2pi];");
-%! title("axes at [0 3 0 1], then autox");
-%! axis([0,3,0,1]); axis("autox");
+%! subplot (324);
+%!  plot (t, x, ';sine [0:2pi];');
+%!  title ('axes at [0 3 0 1], then autox');
+%!  axis ([0,3,0,1]);
+%!  axis ('autox');
 %!
-%! subplot(325);
-%! plot(t, x, ";sine [0:2p];");
-%! axis([3,6,0,1]); axis("autoy");
-%! title("axes at [3 6 0 1], then autoy");
+%! subplot (325);
+%!  plot (t, x, ';sine [0:2p];');
+%!  title ('axes at [3 6 0 1], then autoy');
+%!  axis ([3,6,0,1]);
+%!  axis ('autoy');
 %!
-%! subplot(326);
-%! plot(t, sin(t), t, -2*sin(t/2))
-%! axis("tight");
-%! title("tight");
+%! subplot (326);
+%!  plot (t, sin(t), t, -2*sin(t/2));
+%!  axis ('tight');
+%!  title ('tight');
 
 %!demo
-%! clf
-%! axis image
-%! x=0:0.1:10;
-%! plot(x,sin(x))
-%! axis image
-%! title("image")
+%! clf;
+%! x = 0:0.1:10;
+%! plot (x, sin(x));
+%! axis image;
+%! title ('image');
 
 %!demo
-%! clf
-%! [x,y,z] = peaks(50);
-%! x1 = max(x(:));
-%! pcolor(x-x1,y-x1/2,z)
-%! hold on
-%! [x,y,z] = sombrero;
-%! s = x1/max(x(:));
-%! pcolor(s*x+x1,s*y+x1/2,5*z)
-%! axis tight
+%! clf;
+%! colormap ('default');
+%! [x,y,z] = peaks (50);
+%! x1 = max (x(:));
+%! pcolor (x-x1, y-x1/2, z);
+%! hold on;
+%! [x,y,z] = sombrero ();
+%! s = x1 / max (x(:));
+%! pcolor (s*x+x1, s*y+x1/2, 5*z);
+%! axis tight;
 
 %!demo
-%! clf
+%! clf;
 %! x = -10:10;
-%! plot (x, x, x, -x)
-%! set (gca, "yscale", "log")
-%! legend ({"x >= 1", "x <= 1"}, "location", "north")
-%! title ("ylim = [1, 10]")
+%! plot (x,x, x,-x);
+%! set (gca, 'yscale', 'log');
+%! legend ({'x >= 1', 'x <= 1'}, 'location', 'north');
+%! title ('ylim = [1, 10]');
 
 %!demo
-%! clf
-%! loglog (1:20, "-s")
-%! axis tight
+%! clf;
+%! loglog (1:20, '-s');
+%! axis tight;
 
 %!demo
-%! clf
+%! clf;
 %! x = -10:0.1:10;
-%! y = sin(x)./(1+abs(x)) + x*0.1 - .4;
-%! plot (x, y)
-%! title ("no plot box")
-%! set (gca, "xaxislocation", "zero")
-%! set (gca, "yaxislocation", "zero")
-%! box off
+%! y = sin (x)./(1 + abs (x)) + 0.1*x - 0.4;
+%! plot (x, y);
+%! title ('no plot box');
+%! set (gca, 'xaxislocation', 'zero');
+%! set (gca, 'yaxislocation', 'zero');
+%! box off;
 
 %!demo
-%! clf
+%! clf;
 %! x = -10:0.1:10;
-%! y = sin(x)./(1+abs(x)) + x*0.1 - .4;
-%! plot (x, y)
-%! title ("no plot box")
-%! set (gca, "xaxislocation", "zero")
-%! set (gca, "yaxislocation", "left")
-%! box off
+%! y = sin (x)./(1+abs (x)) + 0.1*x - 0.4;
+%! plot (x, y);
+%! title ('no plot box');
+%! set (gca, 'xaxislocation', 'zero');
+%! set (gca, 'yaxislocation', 'left');
+%! box off;
 
 %!demo
-%! clf
+%! clf;
 %! x = -10:0.1:10;
-%! y = sin(x)./(1+abs(x)) + x*0.1 - .4;
-%! plot (x, y)
-%! title ("no plot box")
-%! set (gca, "xaxislocation", "zero")
-%! set (gca, "yaxislocation", "right")
-%! box off
+%! y = sin (x)./(1+abs (x)) + 0.1*x - 0.4;
+%! plot (x, y);
+%! title ('no plot box');
+%! set (gca, 'xaxislocation', 'zero');
+%! set (gca, 'yaxislocation', 'right');
+%! box off;
 
 %!demo
-%! clf
+%! clf;
 %! x = -10:0.1:10;
-%! y = sin(x)./(1+abs(x)) + x*0.1 - .4;
-%! plot (x, y)
-%! title ("no plot box")
-%! set (gca, "xaxislocation", "bottom")
-%! set (gca, "yaxislocation", "zero")
-%! box off
+%! y = sin (x)./(1+abs (x)) + 0.1*x - 0.4;
+%! plot (x, y);
+%! title ('no plot box');
+%! set (gca, 'xaxislocation', 'bottom');
+%! set (gca, 'yaxislocation', 'zero');
+%! box off;
 
 %!demo
-%! clf
+%! clf;
 %! x = -10:0.1:10;
-%! y = sin(x)./(1+abs(x)) + x*0.1 - .4;
-%! plot (x, y)
-%! title ("no plot box")
-%! set (gca, "xaxislocation", "top")
-%! set (gca, "yaxislocation", "zero")
-%! box off
+%! y = sin (x)./(1+abs (x)) + 0.1*x - 0.4;
+%! plot (x, y);
+%! title ('no plot box');
+%! set (gca, 'xaxislocation', 'top');
+%! set (gca, 'yaxislocation', 'zero');
+%! box off;
 
 %!test
 %! hf = figure ("visible", "off");
@@ -571,9 +578,9 @@
 %! hf = figure ("visible", "off");
 %! unwind_protect
 %!   a = logspace (-5, 1, 10);
-%!   loglog (a, -a)
+%!   loglog (a, -a);
 %!   axis tight;
-%!   assert (axis (), [1e-5, 10, -10, -1e-5])
+%!   assert (axis (), [1e-5, 10, -10, -1e-5]);
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
--- a/scripts/plot/box.m
+++ b/scripts/plot/box.m
@@ -17,11 +17,16 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {} box (@var{arg})
-## @deftypefnx {Function File} {} box (@var{h}, @dots{})
+## @deftypefn  {Function File} {} box
+## @deftypefnx {Function File} {} box ("on")
+## @deftypefnx {Function File} {} box ("off")
+## @deftypefnx {Function File} {} box (@var{hax}, @dots{})
 ## Control the display of a border around the plot.
 ## The argument may be either @code{"on"} or @code{"off"}.  If it is
 ## omitted, the current box state is toggled.
+##
+## If the first argument is an axis handle, @var{hax}, operate on the
+## specified axis object.
 ## @seealso{grid}
 ## @end deftypefn
 
@@ -29,14 +34,11 @@
 
 function box (varargin)
 
-  h = gca ();
-
-  box_state = get (h, "box");
-
-  nargs = numel (varargin);
+  [ax, varargin, nargs] = __plt_get_axis_arg__ ("box", varargin{:});
 
   if (nargs == 0)
-    if (strcmpi (box_state, "on"))
+    box_state = get (ax, "box");
+    if (strcmp (box_state, "on"))
       box_state = "off";
     else
       box_state = "on";
@@ -49,13 +51,15 @@
       elseif (strcmpi (state, "on"))
         box_state = "on";
       else
-        print_usage ();
+        error ('box: argument must be "on" or "off"');
       endif
+    else
+      error ('box: argument must be "on" or "off"');
     endif
   else
     print_usage ();
   endif
 
-  set (h, "box", box_state);
+  set (ax, "box", box_state);
 
 endfunction
--- a/scripts/plot/caxis.m
+++ b/scripts/plot/caxis.m
@@ -26,8 +26,8 @@
 ## colormap.  Values outside this range are clamped to the first and last
 ## colormap entries.
 ##
-## If @var{limits} is 'auto', then automatic colormap scaling is applied,
-## whereas if @var{limits} is 'manual' the colormap scaling is set to manual.
+## If @var{limits} is "auto", then automatic colormap scaling is applied,
+## whereas if @var{limits} is "manual" the colormap scaling is set to manual.
 ##
 ## Called without any arguments to current color axis limits are returned.
 ##
--- a/scripts/plot/cla.m
+++ b/scripts/plot/cla.m
@@ -89,14 +89,16 @@
 
 endfunction
 
+
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
-%!   plot (1:10)
-%!   cla ()
+%!   plot (1:10);
+%!   cla ();
 %!   kids = get (gca, "children");
-%!   cla ()
+%!   cla ();
 %! unwind_protect_cleanup
-%!   close (hf)
+%!   close (hf);
 %! end_unwind_protect
-%! assert (numel (kids), 0)
+%! assert (numel (kids), 0);
+
--- a/scripts/plot/clabel.m
+++ b/scripts/plot/clabel.m
@@ -67,7 +67,7 @@
     hparent = gca ();
   else
     arg = varargin{1};
-    if (isscalar (arg) && ishandle(arg)
+    if (isscalar (arg) && ishandle (arg)
         && strcmp (get (arg, "type"), "hggroup"))
       obj = get (arg);
       if (! isfield (obj, "contourmatrix"))
@@ -81,7 +81,7 @@
     endif
   endif
 
-  if (length(varargin) > 0 && isnumeric (varargin{1}))
+  if (length (varargin) > 0 && isnumeric (varargin{1}))
     v = varargin{1}(:);
     varargin(1) = [];
   else
@@ -127,16 +127,19 @@
   else
     retval =  __clabel__ (c, v, hparent, label_spacing, [], varargin{:});
   endif
+
 endfunction
 
 
 %!demo
-%! clf
-%! [c, h] = contour (peaks(), -4:6);
-%! clabel (c, h, -4:2:6, "fontsize", 12);
+%! clf;
+%! colormap ('default');
+%! [c, h] = contour (peaks (), -4:6);
+%! clabel (c, h, -4:2:6, 'fontsize', 12);
 
 %!demo
-%! clf
-%! [c, h] = contourf (peaks(), -7:6);
-%! clabel (c, h, -6:2:6, "fontsize", 12);
+%! clf;
+%! colormap ('default');
+%! [c, h] = contourf (peaks (), -7:6);
+%! clabel (c, h, -6:2:6, 'fontsize', 12);
 
--- a/scripts/plot/clf.m
+++ b/scripts/plot/clf.m
@@ -89,7 +89,7 @@
 %! hf = figure ("visible", "off");
 %! unwind_protect
 %!   l = line;
-%!   assert (!isempty (get (gcf, "children")));
+%!   assert (! isempty (get (gcf, "children")));
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
--- a/scripts/plot/close.m
+++ b/scripts/plot/close.m
@@ -46,7 +46,7 @@
       close_all_figures (false);
     elseif (isfigure (arg1))
       figs = arg1;
-    elseif (isempty(arg1))
+    elseif (isempty (arg1))
       figs = [];
     else
       error ("close: expecting argument to be \"all\" or a figure handle");
@@ -80,6 +80,7 @@
 
 endfunction
 
+
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
@@ -91,3 +92,4 @@
 %!     close (hf);
 %!   endif
 %! end_unwind_protect
+
--- a/scripts/plot/colorbar.m
+++ b/scripts/plot/colorbar.m
@@ -63,7 +63,7 @@
   i = 1;
   while (i <= nargin)
     arg = varargin {i++};
-    if (ischar(arg))
+    if (ischar (arg))
       if (strcmpi (arg, "peer"))
         if (i > nargin)
           error ("colorbar: missing axes handle after \"peer\"");
@@ -162,7 +162,7 @@
                   "yliminclude", "off", "zliminclude", "off",
                   "deletefcn", {@deletecolorbar, cax, obj});
 
-    set (cax, "deletefcn", {@resetaxis, obj});
+    set (cax, "deletefcn", {@resetaxis, ax, obj});
 
     addlistener (ax, "clim", {@update_colorbar_clim, hi, vertical});
     addlistener (ax, "plotboxaspectratio", {@update_colorbar_axis, cax, obj});
@@ -182,7 +182,7 @@
   ## Don't delete the colorbar and reset the axis size if the
   ## parent figure is being deleted.
   if (ishandle (hc) && strcmp (get (hc, "type"), "axes")
-      && (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off")))
+      && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"),"off")))
     if (strcmp (get (hc, "beingdeleted"), "off"))
       delete (hc);
     endif
@@ -195,19 +195,21 @@
   endif
 endfunction
 
-function resetaxis (h, d, orig_props)
-  if (ishandle (h) && strcmp (get (h, "type"), "axes")
-      && (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off"))
-      && ishandle (get (h, "axes")))
-     set (get (h, "axes"), "position", orig_props.position, ...
-                           "outerposition", orig_props.outerposition, ...
-                   "activepositionproperty", orig_props.activepositionproperty);
+function resetaxis (cax, d, ax, orig_props)
+  if (ishandle (ax) && strcmp (get (ax, "type"), "axes"))
+    dellistener (ax, "position")
+    units = get (ax, "units");
+    set (ax, "units", orig_props.units)
+    set (ax, "position", orig_props.position, ...
+             "outerposition", orig_props.outerposition, ...
+             "activepositionproperty", orig_props.activepositionproperty);
+    set (ax, "units", units)
   endif
 endfunction
 
 function update_colorbar_clim (h, d, hi, vert)
   if (ishandle (h) && strcmp (get (h, "type"), "image")
-      && (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off")))
+      && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"),"off")))
     clen = rows (get (get (h, "parent"), "colormap"));
     cext = get (h, "clim");
     cdiff = (cext(2) - cext(1)) / clen / 2;
@@ -227,7 +229,7 @@
 function update_colorbar_axis (h, d, cax, orig_props)
 
   if (ishandle (cax) && strcmp (get (cax, "type"), "axes")
-      && (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off")))
+      && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"),"off")))
     loc = get (cax, "location");
     obj = get (h);
     obj.__my_handle__ = h;
@@ -362,252 +364,288 @@
 
 endfunction
 
-%!demo
-%! clf
-%! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.');
-%! imagesc(x)
-%! colorbar();
-
-%!demo
-%! clf
-%! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.');
-%! imagesc(x)
-%! colorbar("westoutside");
-
-%!demo
-%! clf
-%! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.');
-%! imagesc(x)
-%! colorbar("peer", gca (), "northoutside");
-
-%!demo
-%! clf
-%! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.');
-%! imagesc(x)
-%! colorbar("southoutside");
-
-%!demo
-%! clf
-%! contour(peaks())
-%! colorbar("west");
-
-%!demo
-%! clf
-%! subplot(2,2,1)
-%! contour(peaks())
-%! colorbar("east");
-%! subplot(2,2,2)
-%! contour(peaks())
-%! colorbar("west");
-%! subplot(2,2,3)
-%! contour(peaks())
-%! colorbar("north");
-%! subplot(2,2,4)
-%! contour(peaks())
-%! colorbar("south");
-
-%!demo
-%! clf
-%! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.');
-%! subplot(2,2,1)
-%! imagesc(x)
-%! colorbar();
-%! subplot(2,2,2)
-%! imagesc(x)
-%! colorbar("westoutside");
-%! subplot(2,2,3)
-%! imagesc(x)
-%! colorbar("northoutside");
-%! subplot(2,2,4)
-%! imagesc(x)
-%! colorbar("southoutside");
-
-%!demo
-%! clf
-%! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.');
-%! subplot(1,2,1)
-%! imagesc(x)
-%! axis square;
-%! colorbar();
-%! subplot(1,2,2)
-%! imagesc(x)
-%! axis square;
-%! colorbar("westoutside");
-
-%!demo
-%! clf
-%! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.');
-%! subplot(1,2,1)
-%! imagesc(x)
-%! axis square;
-%! colorbar("northoutside");
-%! subplot(1,2,2)
-%! imagesc(x)
-%! axis square;
-%! colorbar("southoutside");
 
 %!demo
-%! clf
-%! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.');
-%! subplot(2,1,1)
-%! imagesc(x)
-%! axis square;
-%! colorbar();
-%! subplot(2,1,2)
-%! imagesc(x)
-%! axis square;
-%! colorbar("westoutside");
-
-%!demo
-%! clf
-%! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.');
-%! subplot(2,1,1)
-%! imagesc(x)
-%! axis square;
-%! colorbar("northoutside");
-%! subplot(2,1,2)
-%! imagesc(x)
-%! axis square;
-%! colorbar("southoutside");
-
-%!demo
-%! clf
-%! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.');
-%! subplot(1,2,1)
-%! imagesc(x)
-%! colorbar();
-%! subplot(1,2,2)
-%! imagesc(x)
-%! colorbar("westoutside");
-
-%!demo
-%! clf
-%! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.');
-%! subplot(1,2,1)
-%! imagesc(x)
-%! colorbar("northoutside");
-%! subplot(1,2,2)
-%! imagesc(x)
-%! colorbar("southoutside");
-
-%!demo
-%! clf
-%! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.');
-%! subplot(2,1,1)
-%! imagesc(x)
-%! colorbar();
-%! subplot(2,1,2)
-%! imagesc(x)
-%! colorbar("westoutside");
-
-%!demo
-%! clf
-%! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.');
-%! subplot(2,1,1)
-%! imagesc(x)
-%! colorbar("northoutside");
-%! subplot(2,1,2)
-%! imagesc(x)
-%! colorbar("southoutside");
-
-%!demo
-%! clf
-%! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.');
-%! subplot(1,2,1)
-%! contour(x)
-%! axis square;
-%! colorbar("east");
-%! xlim ([1, 64])
-%! ylim ([1, 64])
-%! subplot(1,2,2)
-%! contour(x)
-%! colorbar("west");
-%! xlim ([1, 64])
-%! ylim ([1, 64])
-
-%!demo
-%! clf
-%! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.');
-%! contour (x)
-%! xlim ([1, 64])
-%! ylim ([1, 64])
-%! colorbar ();
-%! colorbar off
-
-%!demo
-%! clf
-%! n = 64; x = kron (1:n,ones(n,1)); x = abs(x - x.');
-%! contour (x)
-%! xlim ([1, 64])
-%! ylim ([1, 64])
-%! colorbar ();
+%! clf;
+%! colormap ('default');
+%! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.');
+%! imagesc (x);
 %! colorbar ();
 
 %!demo
-%! clf
-%! imagesc (1./hilb(99));
-%! h = colorbar;
+%! clf;
+%! colormap ('default');
+%! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.');
+%! imagesc (x);
+%! colorbar ('westoutside');
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.');
+%! imagesc (x);
+%! colorbar ('peer', gca, 'northoutside');
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.');
+%! imagesc (x);
+%! colorbar ('southoutside');
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! contour (peaks ());
+%! colorbar ('west');
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! subplot (2,2,1);
+%!  contour (peaks ());
+%!  colorbar ('east');
+%! subplot (2,2,2);
+%!  contour (peaks ());
+%!  colorbar ('west');
+%! subplot (2,2,3);
+%!  contour (peaks ());
+%!  colorbar ('north');
+%! subplot (2,2,4);
+%!  contour (peaks ());
+%!  colorbar ('south');
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.');
+%! subplot (2,2,1);
+%!  imagesc (x);
+%!  colorbar ();
+%! subplot (2,2,2);
+%!  imagesc (x);
+%!  colorbar ('westoutside');
+%! subplot (2,2,3);
+%!  imagesc (x);
+%!  colorbar ('northoutside');
+%! subplot (2,2,4);
+%!  imagesc (x);
+%!  colorbar ('southoutside');
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.');
+%! subplot (1,2,1);
+%!  imagesc (x);
+%!  axis square;
+%!  colorbar ();
+%! subplot (1,2,2);
+%!  imagesc (x);
+%!  axis square;
+%!  colorbar ('westoutside');
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.');
+%! subplot (1,2,1);
+%!  imagesc (x);
+%!  axis square;
+%!  colorbar ('northoutside');
+%! subplot (1,2,2);
+%!  imagesc (x);
+%!  axis square;
+%!  colorbar ('southoutside');
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.');
+%! subplot (2,1,1);
+%!  imagesc (x);
+%!  axis square;
+%!  colorbar ();
+%! subplot (2,1,2);
+%!  imagesc (x);
+%!  axis square;
+%!  colorbar ('westoutside');
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.');
+%! subplot (2,1,1);
+%!  imagesc (x);
+%!  axis square;
+%!  colorbar ('northoutside');
+%! subplot (2,1,2);
+%!  imagesc (x);
+%!  axis square;
+%!  colorbar ('southoutside');
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.');
+%! subplot (1,2,1);
+%!  imagesc (x);
+%!  colorbar ();
+%! subplot (1,2,2);
+%!  imagesc (x);
+%!  colorbar ('westoutside');
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.');
+%! subplot (1,2,1);
+%!  imagesc (x);
+%!  colorbar ('northoutside');
+%! subplot (1,2,2);
+%!  imagesc (x);
+%!  colorbar ('southoutside');
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.');
+%! subplot (2,1,1);
+%!  imagesc (x);
+%!  colorbar ();
+%! subplot (2,1,2);
+%!  imagesc (x);
+%!  colorbar ('westoutside');
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.');
+%! subplot (2,1,1);
+%!  imagesc (x);
+%!  colorbar ('northoutside');
+%! subplot (2,1,2);
+%!  imagesc (x);
+%!  colorbar ('southoutside');
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.');
+%! subplot (1,2,1);
+%!  contour (x);
+%!  axis square;
+%!  colorbar ('east');
+%!  xlim ([1, 64]);
+%!  ylim ([1, 64]);
+%! subplot (1,2,2);
+%!  contour (x);
+%!  colorbar ('west');
+%!  xlim ([1, 64]);
+%!  ylim ([1, 64]);
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.');
+%! contour (x);
+%! xlim ([1, 64]);
+%! ylim ([1, 64]);
+%! colorbar ();
+%! colorbar off;
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.');
+%! contour (x);
+%! xlim ([1, 64]);
+%! ylim ([1, 64]);
+%! colorbar ();
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! imagesc (1 ./ hilb (99));
+%! h = colorbar ();
 %! set (h, 'yscale', 'log');
 
 %!demo
-%! clf
+%! clf;
+%! colormap ('default');
 %! imagesc (log10 (1 ./ hilb (99)));
-%! h = colorbar;
-%! ytick = get(h, "ytick");
-%! set (h, "yticklabel", sprintf ('10^{%g}|', ytick));
-
-%!demo
-%! clf
-%! n=5;x=linspace(0,5,n);y=linspace(0,1,n);
-%! imagesc(1./hilb(n)); axis equal; colorbar
+%! h = colorbar ();
+%! ytick = get (h, 'ytick');
+%! set (h, 'yticklabel', sprintf ('10^{%g}|', ytick));
 
 %!demo
-%! clf
-%! n=5;x=linspace(0,5,n);y=linspace(0,1,n);
-%! imagesc(x,y,1./hilb(n)); axis equal; colorbar
+%! clf;
+%! colormap ('default');
+%! n = 5; x = linspace (0,5,n); y = linspace (0,1,n);
+%! imagesc (1 ./ hilb (n));
+%! axis equal;
+%! colorbar ();
 
 %!demo
-%! clf
-%! n=5;x=linspace(0,5,n);y=linspace(0,1,n);
-%! imagesc(y,x,1./hilb(n)); axis equal; colorbar
-## This requires that the axes position be properly determined for "axes equal"
-
-%!demo
-%! clf
-%! axes
-%! colorbar
-%! hold on
-%! contour(peaks)
-%! hold off
+%! clf;
+%! colormap ('default');
+%! n = 5; x = linspace (0,5,n); y = linspace (0,1,n);
+%! imagesc (x, y, 1 ./ hilb (n));
+%! axis equal;
+%! colorbar ();
 
 %!demo
-%! clf
-%! plot([0, 2])
-%! colorbar ("east")
-%! axis square
+%! clf;
+%! colormap ('default');
+%! n = 5; x = linspace (0,5,n); y = linspace (0,1,n);
+%! imagesc (y, x, 1 ./ hilb (n));
+%! axis equal;
+%! colorbar ();
+
+## This requires that the axes position be properly determined for 'axis equal'
+%!demo
+%! clf;
+%! colormap ('default');
+%! axes;
+%! colorbar ();
+%! hold on;
+%! contour (peaks ());
+%! hold off;
 
 %!demo
-%! clf
-%! plot([0, 2])
-%! colorbar ("eastoutside")
-%! axis square
+%! clf;
+%! colormap ('default');
+%! plot ([0, 2]);
+%! colorbar ('east');
+%! axis square;
 
 %!demo
-%! clf
-%! pcolor (peaks (20))
-%! shading ("interp")
-%! axis ("tight", "square")
-%! colorbar ()
-#%! axes('color','none','box','on','activepositionproperty','position')
+%! clf;
+%! colormap ('default');
+%! plot ([0, 2]);
+%! colorbar ('eastoutside');
+%! axis square;
 
 %!demo
-%! clf
-%! plot([0, 2])
-%! colorbar ("east")
-%! axis equal
+%! clf;
+%! colormap ('default');
+%! pcolor (peaks (20));
+%! shading interp;
+%! axis ('tight', 'square');
+%! colorbar ();
+#%! axes ('color','none','box','on','activepositionproperty','position');
 
 %!demo
-%! clf
-%! plot([0, 2])
-%! colorbar ("eastoutside")
-%! axis equal
+%! clf;
+%! colormap ('default');
+%! plot ([0, 2]);
+%! colorbar ('east');
+%! axis equal;
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! plot ([0, 2]);
+%! colorbar ('eastoutside');
+%! axis equal;
+
--- a/scripts/plot/colstyle.m
+++ b/scripts/plot/colstyle.m
@@ -64,6 +64,7 @@
 
 endfunction
 
+
 %!test
 %! [l, c, m, msg] = colstyle ("r:x");
 %! assert (isempty (msg));
--- a/scripts/plot/comet.m
+++ b/scripts/plot/comet.m
@@ -44,7 +44,7 @@
     print_usage ();
   elseif (nargin == 1)
     y = varargin{1};
-    x = 1:numel(y);
+    x = 1:numel (y);
     p = 0.1;
   elseif (nargin == 2)
     x = varargin{1};
@@ -78,11 +78,11 @@
 
 endfunction
 
+
 %!demo
-%! clf
+%! clf;
 %! t = 0:.1:2*pi;
-%! x = cos(2*t).*(cos(t).^2);
-%! y = sin(2*t).*(sin(t).^2);
-%! comet(x,y)
+%! x = cos (2*t) .* (cos (t).^2);
+%! y = sin (2*t) .* (sin (t).^2);
+%! comet (x, y);
 
-
--- a/scripts/plot/comet3.m
+++ b/scripts/plot/comet3.m
@@ -43,7 +43,7 @@
     print_usage ();
   elseif (nargin == 1)
     z = varargin{1};
-    x = y = 1:numel(z);
+    x = y = 1:numel (z);
     p = 0.1;
   elseif (nargin == 3)
     x = varargin{1};
@@ -80,7 +80,9 @@
 
 endfunction
 
+
 %!demo
-%! clf
+%! clf;
 %! t = 0:pi/20:5*pi;
-%! comet3 (cos(t), sin(t), t, 0.01);
+%! comet3 (cos (t), sin (t), t, 0.01);
+
--- a/scripts/plot/compass.m
+++ b/scripts/plot/compass.m
@@ -112,7 +112,7 @@
 
 
 %!demo
-%! clf
+%! clf;
 %! randn_9x1_data = [-2.555884; 0.394974; -0.191871; -1.147024; 1.355425; -0.437335; -0.014370; -0.941312; 1.240300];
 %! randn_1x9_data = [1.42934, -1.10821, -1.70404, 0.63357, -0.68337, -1.19771, -0.96502, -1.12810, 0.22457];
 %! a = toeplitz ([1;randn_9x1_data], [1,randn_1x9_data]);
--- a/scripts/plot/contour.m
+++ b/scripts/plot/contour.m
@@ -70,23 +70,27 @@
 
 endfunction
 
+
 %!demo
-%! clf ()
+%! clf;
+%! colormap ('default');
 %! [x, y, z] = peaks ();
 %! contour (x, y, z);
 
 %!demo
-%! clf ()
-%! [theta, r] = meshgrid (linspace (0, 2*pi, 64), linspace(0,1,64));
+%! clf;
+%! colormap ('default');
+%! [theta, r] = meshgrid (linspace (0,2*pi,64), linspace (0,1,64));
 %! [X, Y] = pol2cart (theta, r);
-%! Z = sin(2*theta).*(1-r);
-%! contour(X, Y, abs(Z), 10)
+%! Z = sin (2*theta) .* (1-r);
+%! contour (X, Y, abs (Z), 10);
 
 %!demo
-%! clf ()
+%! clf;
+%! colormap ('default');
 %! x = linspace (-2, 2);
 %! [x, y] = meshgrid (x);
-%! z = sqrt (x.^2 + y.^2) ./ (x.^2 + y.^2+1);
-%! contourf (x, y, z, [0.4, 0.4])
-%! title ("The hole should be filled with the background color")
+%! z = sqrt (x.^2 + y.^2) ./ (x.^2 + y.^2 + 1);
+%! contourf (x, y, z, [0.4, 0.4]);
+%! title ('The hole should be filled with the background color');
 
--- a/scripts/plot/contour3.m
+++ b/scripts/plot/contour3.m
@@ -74,13 +74,15 @@
 
 endfunction
 
+
 %!demo
-%! clf
+%! clf;
 %! contour3 (peaks (19));
-%! hold on
-%! surface (peaks (19), "facecolor", "none", "edgecolor", "black")
-%! colormap hot
-%! axis tight
-%! zlim auto
-%! hold off
-%! box off
+%! hold on;
+%! surface (peaks (19), 'facecolor', 'none', 'edgecolor', 'black');
+%! colormap (hot (64));
+%! axis tight;
+%! zlim auto;
+%! box off;
+%! hold off;
+
--- a/scripts/plot/contourc.m
+++ b/scripts/plot/contourc.m
@@ -101,8 +101,8 @@
     c = __contourc__ (x(:)', y(:)', z, vv);
   else
     ## Indexes x,y for the purpose of __contourc__.
-    ii = 1:size (z,2);
-    jj = 1:size (z,1);
+    ii = 1:columns (z);
+    jj = 1:rows (z);
 
     ## Now call __contourc__ for the real work...
     c = __contourc__ (ii, jj, z, vv);
@@ -111,7 +111,7 @@
     ## to the original grid (x,y)
     i = 1;
 
-    while (i < size (c,2))
+    while (i < columns (c))
       clen = c(2, i);
       ind = i + [1 : clen];
 
@@ -123,8 +123,8 @@
       ## return NA for those values.
       ## The permitted range is enforced here:
 
-      ci = max (ci, 1); ci = min (ci, size (z, 2));
-      cj = max (cj, 1); cj = min (cj, size (z, 1));
+      ci = max (ci, 1); ci = min (ci, columns (z));
+      cj = max (cj, 1); cj = min (cj, rows (z));
 
       c(1, ind) = interp2 (ii, jj, x, ci, cj);
       c(2, ind) = interp2 (ii, jj, y, ci, cj);
@@ -140,6 +140,7 @@
 
 endfunction
 
+
 %!test
 %! x = 0:2;
 %! y = x;
@@ -147,7 +148,6 @@
 %! [c_actual, lev_actual]= contourc (x, y, z, 2:3);
 %! c_expected = [2, 1, 1, 2, 2, 3, 1.5, 2; 4, 2, 2, 1, 1, 2, 2, 1.5];
 %! lev_expected = [2 3];
-%! assert (c_actual, c_expected, eps)
-%! assert (lev_actual, lev_expected, eps)
+%! assert (c_actual, c_expected, eps);
+%! assert (lev_actual, lev_expected, eps);
 
-
--- a/scripts/plot/contourf.m
+++ b/scripts/plot/contourf.m
@@ -78,16 +78,21 @@
     c = ctmp;
     h = htmp;
   endif
+
 endfunction
 
+
 %!demo
-%! clf
+%! clf;
+%! colormap ('default');
 %! [x, y, z] = peaks (50);
-%! contourf (x, y, z, -7:9)
+%! contourf (x, y, z, -7:9);
 
 %!demo
-%! clf
-%! [theta, r] = meshgrid (linspace (0, 2*pi, 64), linspace(0,1,64));
+%! clf;
+%! colormap ('default');
+%! [theta, r] = meshgrid (linspace (0,2*pi,64), linspace (0,1,64));
 %! [X, Y] = pol2cart (theta, r);
-%! Z = sin(2*theta).*(1-r);
-%! contourf(X, Y, abs(Z), 10)
+%! Z = sin (2*theta) .* (1-r);
+%! contourf (X, Y, abs (Z), 10);
+
new file mode 100644
--- /dev/null
+++ b/scripts/plot/copyobj.m
@@ -0,0 +1,127 @@
+## Copyright (C) 2012 pdiribarne
+##
+## This program 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.
+##
+## This program 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{hnew} =} copyobj (@var{horig})
+## @deftypefnx  {Function File} {@var{hnew} =} copyobj (@var{horig}, @var{hparent})
+## Constructs a copy of the object associated with handle @var{horig}
+## and returns a handle, @var{hnew}, to the new object.
+## If a parent handle @var{hparent} (root, figure, axes or hggroup) is specified,
+## the copied object will be created as a child to @var{hparent}.
+## @seealso{findobj, get, set, struct2hdl, hdl2struct}
+## @end deftypefn
+
+## Author: pdiribarne <pdiribarne@new-host.home>
+## Created: 2012-04-01
+
+function hout = copyobj (hin, hpar = 0)
+
+  partypes = {"root", "figure", "axes", "hggroup"};
+  othertypes = {"line", "patch", "surface", "image", "text"};
+  alltypes = [partypes othertypes];
+
+  if (! ishandle (hin) || nargin > 2)
+    print_usage ();
+  elseif (! ishandle (hpar))
+    hpar = figure (floor (hpar));
+  elseif (! any (strcmpi (get (hpar).type, partypes)))
+    print_usage ();
+  endif
+
+  ## compatibility of input handles
+  kididx = find (strcmp (alltypes, get (hin).type));
+  paridx = find (strcmp (alltypes, get (hpar).type));
+
+  if (kididx <= paridx)
+    error ("copyobj: %s object can't be children to %s.",
+           alltypes{kididx}, alltypes{paridx})
+  elseif nargin == 1
+    str = hdl2struct (hin);
+    hout = struct2hdl (str);
+  else
+    str = hdl2struct (hin);
+    hout = struct2hdl (str, hpar);
+  endif
+endfunction
+
+%!test
+%! h1 = figure ();
+%! set (h1, "visible", "off")
+%! x = 0:0.1:2*pi;
+%! y1 = sin (x);
+%! y2 = exp (x - 1);
+%! ax = plotyy (x,y1, x-1,y2, @plot, @semilogy);
+%! xlabel ("X");
+%! ylabel (ax(1), "Axis 1");
+%! ylabel (ax(2), "Axis 2");
+%! axes (ax(1));
+%! text (0.5, 0.5, "Left Axis", ...
+%!       "color", [0 0 1], "horizontalalignment", "center");
+%! axes (ax(2));
+%! text (4.5, 80, "Right Axis", ...
+%!       "color", [0 0.5 0], "horizontalalignment", "center");
+%! s1 = hdl2struct (h1);
+%! h2 = struct2hdl (s1);
+%! s2 = hdl2struct (h2);
+%! png1 = strcat (tmpnam (), ".png");
+%! png2 = strcat (tmpnam (), ".png");
+%! unwind_protect
+%!   print (h1, png1)
+%!   [img1, map1, alpha1] = imread (png1);
+%!   print (h2, png2)
+%!   [img2, map2, alpha2] = imread (png2);
+%! unwind_protect_cleanup
+%!   unlink (png1);
+%!   unlink (png2);
+%! end_unwind_protect
+%! assert (img1, img2)
+%! assert (map1, map2)
+%! assert (alpha1, alpha2)
+
+%!demo
+%! hdl = figure (1234);
+%! clf ()
+%! hold on
+%! x = 1:10;
+%! y = x.^2;
+%! dy = 2 * (.2 * x);
+%! y2 = (x - 3).^2;
+%! hg = errorbar (x, y, dy,'#~');
+%! set (hg, 'marker', '^', 'markerfacecolor', rand(1,3))
+%! plot (x, y2, 'ok-')
+%! legend ('errorbar', 'line')
+%! hout = copyobj (1234);
+
+%!demo
+%! hdl = figure (1234);
+%! clf ()
+%! subplot (2, 2, 1);
+%! hold on
+%! [C, H] = contourf (rand(10, 10));
+%! colorbar
+%! subplot (2, 2, 2);
+%! hold on
+%! quiver (rand(10, 10), rand(10, 10))
+%! subplot (2, 2, 3);
+%! colormap (jet (64))
+%! sombrero;
+%! colorbar('peer', gca, 'NorthOutside')
+%! subplot (2, 2, 4);
+%! imagesc (rand (30, 30));
+%! text (15, 15, 'Rotated text', ...
+%!      'HorizontAlalignment', 'Center', 'Rotation', 30);
+%! hout = copyobj (1234);
+
--- a/scripts/plot/cylinder.m
+++ b/scripts/plot/cylinder.m
@@ -65,13 +65,13 @@
   endif
 
   if (length (r) < 2)
-    error ("cylinder: length(R) must be larger than 2");
+    error ("cylinder: length (R) must be larger than 2");
   endif
 
   phi = linspace (0, 2*pi, n+1);
-  idx = 1:length(r);
-  [phi, idx] = meshgrid(phi, idx);
-  z = (idx - 1) / (length(r) - 1);
+  idx = 1:length (r);
+  [phi, idx] = meshgrid (phi, idx);
+  z = (idx - 1) / (length (r) - 1);
   r = r(idx);
   [x, y] = pol2cart (phi, r);
 
@@ -85,8 +85,11 @@
 
 endfunction
 
+
 %!demo
-%! clf
+%! clf;
+%! colormap ('default');
 %! [x, y, z] = cylinder (10:-1:0,50);
 %! surf (x, y, z);
-%! title ("a cone")
+%! title ('a cone');
+
--- a/scripts/plot/daspect.m
+++ b/scripts/plot/daspect.m
@@ -89,45 +89,46 @@
 
 endfunction
 
-%!demo
-%! x = 0:0.01:4;
-%! clf
-%! plot (x, cos (x), x, sin (x))
-%! axis square
-%! daspect ([1 1 1])
-%! title ("square plot-box with axis limits [0, 4, -2, 2]")
 
 %!demo
+%! clf;
 %! x = 0:0.01:4;
-%! clf
-%! plot (x, cos (x), x, sin (x))
-%! axis ([0 4 -1 1])
-%! daspect ([2 1 1])
-%! title ("square plot-box with axis limits [0, 4, -1, 1]")
+%! plot (x,cos(x), x,sin(x));
+%! axis square;
+%! daspect ([1 1 1]);
+%! title ('square plot-box with axis limits [0, 4, -2, 2]');
+
+%!demo
+%! clf;
+%! x = 0:0.01:4;
+%! plot (x,cos (x), x,sin (x));
+%! axis ([0 4 -1 1]);
+%! daspect ([2 1 1]);
+%! title ('square plot-box with axis limits [0, 4, -1, 1]');
 
 %!demo
+%! clf;
 %! x = 0:0.01:4;
-%! clf
-%! plot (x, cos (x), x, sin (x))
-%! daspect ([1 2 1])
-%! pbaspect ([2 1 1])
-%! title ("2x1 plot box with axis limits [0, 4, -2, 2]")
+%! plot (x,cos(x), x,sin(x));
+%! daspect ([1 2 1]);
+%! pbaspect ([2 1 1]);
+%! title ('2x1 plot box with axis limits [0, 4, -2, 2]');
 
 %!demo
+%! clf;
 %! x = 0:0.01:4;
-%! clf
-%! plot (x, cos (x), x, sin (x))
-%! axis square
-%! set (gca, "activepositionproperty", "position")
-%! daspect ([1 1 1])
-%! title ("square plot-box with axis limits [0, 4, -2, 2]")
+%! plot (x,cos(x), x, sin(x));
+%! axis square;
+%! set (gca, 'activepositionproperty', 'position');
+%! daspect ([1 1 1]);
+%! title ('square plot-box with axis limits [0, 4, -2, 2]');
 
 %!demo
+%! clf;
 %! x = 0:0.01:4;
-%! clf
-%! plot (x, cos (x), x, sin (x))
-%! axis ([0 4 -1 1])
-%! set (gca, "activepositionproperty", "position")
-%! daspect ([2 1 1])
-%! title ("square plot-box with axis limits [0, 4, -1, 1]")
+%! plot (x,cos(x), x,sin(x));
+%! axis ([0 4 -1 1]);
+%! set (gca, 'activepositionproperty', 'position');
+%! daspect ([2 1 1]);
+%! title ('square plot-box with axis limits [0, 4, -1, 1]');
 
--- a/scripts/plot/ellipsoid.m
+++ b/scripts/plot/ellipsoid.m
@@ -69,6 +69,8 @@
 
 endfunction
 
+
 %!demo
-%! clf
+%! clf;
 %! ellipsoid (0, 0, 1, 2, 3, 4, 20);
+
--- a/scripts/plot/errorbar.m
+++ b/scripts/plot/errorbar.m
@@ -138,39 +138,39 @@
 
 
 %!demo
-%! clf
+%! clf;
 %! rand_1x11_data1 = [0.82712, 0.50325, 0.35613, 0.77089, 0.20474, 0.69160, 0.30858, 0.88225, 0.35187, 0.14168, 0.54270];
 %! rand_1x11_data2 = [0.506375, 0.330106, 0.017982, 0.859270, 0.140641, 0.327839, 0.275886, 0.162453, 0.807592, 0.318509, 0.921112];
 %! errorbar (0:10, rand_1x11_data1, 0.25*rand_1x11_data2);
 
 %!demo
-%! clf
+%! clf;
 %! rand_1x11_data3 = [0.423650, 0.142331, 0.213195, 0.129301, 0.975891, 0.012872, 0.635327, 0.338829, 0.764997, 0.401798, 0.551850];
 %! rand_1x11_data4 = [0.682566, 0.456342, 0.132390, 0.341292, 0.108633, 0.601553, 0.040455, 0.146665, 0.309187, 0.586291, 0.540149];
-%! errorbar(0:10, rand_1x11_data3, rand_1x11_data4, ">");
+%! errorbar (0:10, rand_1x11_data3, rand_1x11_data4, '>');
 
 %!demo
-%! clf
+%! clf;
 %! x = 0:0.5:2*pi;
 %! err = x/100;
 %! y1 = sin (x);
 %! y2 = cos (x);
-%! hg = errorbar (x, y1, err, "~", x, y2, err, ">");
+%! hg = errorbar (x, y1, err, '~', x, y2, err, '>');
 
 %!demo
-%! clf
+%! clf;
 %! x = 0:0.5:2*pi;
 %! err = x/100;
 %! y1 = sin (x);
 %! y2 = cos (x);
-%! hg = errorbar (x, y1, err, err, "#r", x, y2, err, err, "#~");
+%! hg = errorbar (x, y1, err, err, '#r', x, y2, err, err, '#~');
 
 %!demo
-%! clf
+%! clf;
 %! x = 0:0.5:2*pi;
 %! err = x/100;
 %! y1 = sin (x);
 %! y2 = cos (x);
-%! hg = errorbar (x, y1, err, err, err, err, "~>", ...
-%!                x, y2, err, err, err, err, "#~>-*");
+%! hg = errorbar (x, y1, err, err, err, err, '~>', ...
+%!                x, y2, err, err, err, err, '#~>-*');
 
--- a/scripts/plot/ezcontour.m
+++ b/scripts/plot/ezcontour.m
@@ -58,11 +58,13 @@
   if (nargout > 0)
     retval = h;
   endif
+
 endfunction
 
 
 %!demo
-%! clf
-%! f = @(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2);
+%! clf;
+%! colormap ('default');
+%! f = @(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2);
 %! ezcontour (f, [-3, 3]);
 
--- a/scripts/plot/ezcontourf.m
+++ b/scripts/plot/ezcontourf.m
@@ -58,10 +58,13 @@
   if (nargout > 0)
     retval = h;
   endif
+
 endfunction
 
 
 %!demo
-%! clf
-%! f = @(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2);
+%! clf;
+%! colormap ('default');
+%! f = @(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2);
 %! ezcontourf (f, [-3, 3]);
+
--- a/scripts/plot/ezmesh.m
+++ b/scripts/plot/ezmesh.m
@@ -21,7 +21,7 @@
 ## @deftypefnx {Function File} {} ezmesh (@var{fx}, @var{fy}, @var{fz})
 ## @deftypefnx {Function File} {} ezmesh (@dots{}, @var{dom})
 ## @deftypefnx {Function File} {} ezmesh (@dots{}, @var{n})
-## @deftypefnx {Function File} {} ezmesh (@dots{}, 'circ')
+## @deftypefnx {Function File} {} ezmesh (@dots{}, "circ")
 ## @deftypefnx {Function File} {} ezmesh (@var{h}, @dots{})
 ## @deftypefnx {Function File} {@var{h} =} ezmesh (@dots{})
 ##
@@ -41,7 +41,7 @@
 ## function @code{[@var{fx} (@var{s}, @var{t}), @var{fy} (@var{s}, @var{t}),
 ## @var{fz} (@var{s}, @var{t})]}.
 ##
-## If the argument 'circ' is given, then the function is plotted over a disk
+## If the argument "circ" is given, then the function is plotted over a disk
 ## centered on the middle of the domain @var{dom}.
 ##
 ## The optional return value @var{h} is a graphics handle to the created 
@@ -58,9 +58,9 @@
 ##
 ## @example
 ## @group
-## fx = @@(s,t) cos (s) .* cos(t);
-## fy = @@(s,t) sin (s) .* cos(t);
-## fz = @@(s,t) sin(t);
+## fx = @@(s,t) cos (s) .* cos (t);
+## fy = @@(s,t) sin (s) .* cos (t);
+## fz = @@(s,t) sin (t);
 ## ezmesh (fx, fy, fz, [-pi, pi, -pi/2, pi/2], 20);
 ## @end group
 ## @end example
@@ -79,18 +79,21 @@
   if (nargout > 0)
     retval = h;
   endif
+
 endfunction
 
 
 %!demo
-%! clf
-%! f = @(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2);
+%! clf;
+%! colormap ('default');
+%! f = @(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2);
 %! ezmesh (f, [-3, 3]);
 
 %!demo
-%! clf
-%! fx = @(s,t) cos (s) .* cos(t);
-%! fy = @(s,t) sin (s) .* cos(t);
+%! clf;
+%! colormap ('default');
+%! fx = @(s,t) cos (s) .* cos (t);
+%! fy = @(s,t) sin (s) .* cos (t);
 %! fz = @(s,t) sin (t);
 %! ezmesh (fx, fy, fz, [-pi,pi,-pi/2,pi/2], 20);
 
--- a/scripts/plot/ezmeshc.m
+++ b/scripts/plot/ezmeshc.m
@@ -21,7 +21,7 @@
 ## @deftypefnx {Function File} {} ezmeshc (@var{fx}, @var{fy}, @var{fz})
 ## @deftypefnx {Function File} {} ezmeshc (@dots{}, @var{dom})
 ## @deftypefnx {Function File} {} ezmeshc (@dots{}, @var{n})
-## @deftypefnx {Function File} {} ezmeshc (@dots{}, 'circ')
+## @deftypefnx {Function File} {} ezmeshc (@dots{}, "circ")
 ## @deftypefnx {Function File} {} ezmeshc (@var{h}, @dots{})
 ## @deftypefnx {Function File} {@var{h} =} ezmeshc (@dots{})
 ##
@@ -41,7 +41,7 @@
 ## function @code{[@var{fx} (@var{s}, @var{t}), @var{fy} (@var{s}, @var{t}),
 ## @var{fz} (@var{s}, @var{t})]}.
 ##
-## If the argument 'circ' is given, then the function is plotted over a disk
+## If the argument "circ" is given, then the function is plotted over a disk
 ## centered on the middle of the domain @var{dom}.
 ##
 ## The optional return value @var{h} is a 2-element vector with a graphics
@@ -69,11 +69,13 @@
   if (nargout > 0)
     retval = h;
   endif
+
 endfunction
 
 
 %!demo
-%! clf
-%! f = @(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2);
+%! clf;
+%! colormap ('default');
+%! f = @(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2);
 %! ezmeshc (f, [-3, 3]);
 
--- a/scripts/plot/ezplot.m
+++ b/scripts/plot/ezplot.m
@@ -77,18 +77,19 @@
   if (nargout > 0)
     retval = h;
   endif
+
 endfunction
 
 
 %!demo
-%! clf
-%! ezplot (@cos, @sin)
+%! clf;
+%! ezplot (@cos, @sin);
 
 %!demo
-%! clf
-%! ezplot ("1/x")
+%! clf;
+%! ezplot ('1/x');
 
 %!demo
-%! clf
-%! ezplot (inline ("x^2 - y^2 = 1"))
+%! clf;
+%! ezplot (inline ('x^2 - y^2 = 1'));
 
--- a/scripts/plot/ezplot3.m
+++ b/scripts/plot/ezplot3.m
@@ -57,11 +57,12 @@
   if (nargout > 0)
     retval = h;
   endif
+
 endfunction
 
 
 %!demo
-%! clf
+%! clf;
 %! fx = @(t) cos (t);
 %! fy = @(t) sin (t);
 %! fz = @(t) t;
--- a/scripts/plot/ezpolar.m
+++ b/scripts/plot/ezpolar.m
@@ -20,20 +20,25 @@
 ## @deftypefn  {Function File} {} ezpolar (@var{f})
 ## @deftypefnx {Function File} {} ezpolar (@dots{}, @var{dom})
 ## @deftypefnx {Function File} {} ezpolar (@dots{}, @var{n})
-## @deftypefnx {Function File} {} ezpolar (@var{h}, @dots{})
+## @deftypefnx {Function File} {} ezpolar (@var{hax}, @dots{})
 ## @deftypefnx {Function File} {@var{h} =} ezpolar (@dots{})
 ##
-## Plot a function in polar coordinates.  The function @var{f} is either
-## a string, inline function or function handle with one arguments defining
-## the function.  By default the plot is over the domain @code{0 < @var{x} <
-## 2*pi} with 60 points.
+## Plot a function in polar coordinates.  The function @var{f} is
+## a string, inline function, or function handle with a single argument.
+## The expected form of the function is
+## @code{@var{rho} = @var{f}(@var{theta})}.
+## By default the plot is over the domain @code{0 < @var{theta} < 2*pi} with 60
+## points.
 ##
 ## If @var{dom} is a two element vector, it represents the minimum and maximum
-## value of both @var{t}.  @var{n} is a scalar defining the number of points to
-## use.
+## values of @var{theta}.  @var{n} is a scalar defining the number of points to
+## use.  If the optional input @var{hax} is given then the plot is placed into
+## the specified axes rather than the current axes.
 ##
 ## The optional return value @var{h} is a graphics handle to the created plot.
 ##
+## Example:
+##
 ## @example
 ## ezpolar (@@(t) 1 + sin (t));
 ## @end example
@@ -52,10 +57,11 @@
   if (nargout > 0)
     retval = h;
   endif
+
 endfunction
 
 
 %!demo
-%! clf
+%! clf;
 %! ezpolar (@(t) 1 + sin (t));
 
--- a/scripts/plot/ezsurf.m
+++ b/scripts/plot/ezsurf.m
@@ -21,7 +21,7 @@
 ## @deftypefnx {Function File} {} ezsurf (@var{fx}, @var{fy}, @var{fz})
 ## @deftypefnx {Function File} {} ezsurf (@dots{}, @var{dom})
 ## @deftypefnx {Function File} {} ezsurf (@dots{}, @var{n})
-## @deftypefnx {Function File} {} ezsurf (@dots{}, 'circ')
+## @deftypefnx {Function File} {} ezsurf (@dots{}, "circ")
 ## @deftypefnx {Function File} {} ezsurf (@var{h}, @dots{})
 ## @deftypefnx {Function File} {@var{h} =} ezsurf (@dots{})
 ##
@@ -41,7 +41,7 @@
 ## function @code{[@var{fx} (@var{s}, @var{t}), @var{fy} (@var{s}, @var{t}),
 ## @var{fz} (@var{s}, @var{t})]}.
 ##
-## If the argument 'circ' is given, then the function is plotted over a disk
+## If the argument "circ" is given, then the function is plotted over a disk
 ## centered on the middle of the domain @var{dom}.
 ##
 ## The optional return value @var{h} is a graphics handle to the created
@@ -79,18 +79,21 @@
   if (nargout > 0)
     retval = h;
   endif
+
 endfunction
 
 
 %!demo
-%! clf
-%! f = @(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2);
+%! clf;
+%! colormap ('default');
+%! f = @(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2);
 %! ezsurf (f, [-3, 3]);
 
 %!demo
-%! clf
-%! fx = @(s,t) cos (s) .* cos(t);
-%! fy = @(s,t) sin (s) .* cos(t);
+%! clf;
+%! colormap ('default');
+%! fx = @(s,t) cos (s) .* cos (t);
+%! fy = @(s,t) sin (s) .* cos (t);
 %! fz = @(s,t) sin (t);
 %! ezsurf (fx, fy, fz, [-pi,pi,-pi/2,pi/2], 20);
 
--- a/scripts/plot/ezsurfc.m
+++ b/scripts/plot/ezsurfc.m
@@ -21,7 +21,7 @@
 ## @deftypefnx {Function File} {} ezsurfc (@var{fx}, @var{fy}, @var{fz})
 ## @deftypefnx {Function File} {} ezsurfc (@dots{}, @var{dom})
 ## @deftypefnx {Function File} {} ezsurfc (@dots{}, @var{n})
-## @deftypefnx {Function File} {} ezsurfc (@dots{}, 'circ')
+## @deftypefnx {Function File} {} ezsurfc (@dots{}, "circ")
 ## @deftypefnx {Function File} {} ezsurfc (@var{h}, @dots{})
 ## @deftypefnx {Function File} {@var{h} =} ezsurfc (@dots{})
 ##
@@ -41,7 +41,7 @@
 ## function @code{[@var{fx} (@var{s}, @var{t}), @var{fy} (@var{s}, @var{t}),
 ## @var{fz} (@var{s}, @var{t})]}.
 ##
-## If the argument 'circ' is given, then the function is plotted over a disk
+## If the argument "circ" is given, then the function is plotted over a disk
 ## centered on the middle of the domain @var{dom}.
 ##
 ## The optional return value @var{h} is a 2-element vector with a graphics
@@ -69,11 +69,13 @@
   if (nargout > 0)
     retval = h;
   endif
+
 endfunction
 
 
 %!demo
-%! clf
-%! f = @(x,y) sqrt(abs(x .* y)) ./ (1 + x.^2 + y.^2);
+%! clf;
+%! colormap ('default');
+%! f = @(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2);
 %! ezsurfc (f, [-3, 3]);
 
--- a/scripts/plot/feather.m
+++ b/scripts/plot/feather.m
@@ -111,7 +111,7 @@
 
 
 %!demo
-%! clf
-%! phi = [0 : 15 : 360] * pi / 180;
-%! feather (sin (phi), cos (phi))
+%! clf;
+%! phi = [0 : 15 : 360] * pi/180;
+%! feather (sin (phi), cos (phi));
 
--- a/scripts/plot/figure.m
+++ b/scripts/plot/figure.m
@@ -17,8 +17,10 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {} figure (@var{n})
-## @deftypefnx {Function File} {} figure (@var{n}, @var{property}, @var{value}, @dots{})
+## @deftypefn  {Command} {} figure
+## @deftypefnx {Command} {} figure @var{n}
+## @deftypefnx {Function File} {} figure (@var{n})
+## @deftypefnx {Function File} {} figure (@var{n}, "@var{property}", @var{value}, @dots{})
 ## Set the current plot window to plot window @var{n}.  If no arguments are
 ## specified, the next available window number is chosen.
 ##
@@ -37,7 +39,10 @@
   init_new_figure = false;
   if (mod (nargs, 2) == 1)
     tmp = varargin{1};
-    if (ishandle (tmp) && strcmp (get (tmp, "type"), "figure"))
+    if (ischar (tmp))
+      tmp = str2double (tmp);
+    endif
+    if (isfigure (tmp))
       f = tmp;
       varargin(1) = [];
       nargs--;
@@ -54,7 +59,7 @@
   ## Check to see if we already have a figure on the screen.  If we do,
   ## then update it if it is different from the figure we are creating
   ## or switching to.
-  cf = get (0, "currentfigure");
+  cf = get (0, "currentfigure");   # Can't use gcf () because it calls figure ()
   if (! isempty (cf) && cf != 0)
     if (isnan (f) || cf != f)
       drawnow ();
@@ -64,7 +69,7 @@
   if (rem (nargs, 2) == 0)
     if (isnan (f) || init_new_figure)
       if (ismac () && strcmp (graphics_toolkit (), "fltk"))
-        ## FIXME - Hack for fltk-aqua to work around bug # 31931
+        ## FIXME - Hack for fltk-aqua to work around bug #31931
         f = __go_figure__ (f);
         drawnow ();
         if (! isempty (varargin))
@@ -81,9 +86,8 @@
     print_usage ();
   endif
 
-  cf = get (0, "currentfigure");
-  if (strcmp (get (cf, "__graphics_toolkit__"), "fltk"))
-    __add_default_menu__ (cf);
+  if (strcmp (get (f, "__graphics_toolkit__"), "fltk"))
+    __add_default_menu__ (f);
   endif
 
   if (nargout > 0)
@@ -92,6 +96,7 @@
 
 endfunction
 
+
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
@@ -100,3 +105,4 @@
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
+
--- a/scripts/plot/fill.m
+++ b/scripts/plot/fill.m
@@ -46,16 +46,16 @@
         set (h, "nextplot", "add");
       endif
       if (i == length (iargs))
-        args = varargin (iargs(i):end);
+        args = varargin(iargs(i):end);
       else
-        args = varargin (iargs(i):iargs(i+1)-1);
+        args = varargin(iargs(i):iargs(i+1)-1);
       endif
       newplot ();
       [tmp, fail] = __patch__ (h, args{:});
       if (fail)
-        print_usage();
+        print_usage ();
       endif
-      htmp (end + 1) = tmp;
+      htmp(end + 1, 1) = tmp;
     endfor
     if (strncmp (nextplot, "replace", 7))
       set (h, "nextplot", nextplot);
@@ -74,7 +74,7 @@
   iargs = [];
   i = 1;
   while (i < nargin)
-    iargs (end + 1) = i;
+    iargs(end + 1) = i;
     if (ischar (varargin{i})
         && (strcmpi (varargin{i}, "faces")
             || strcmpi (varargin{i}, "vertices")))
@@ -96,17 +96,10 @@
         elseif (ischar (varargin{i}))
           colspec = tolower (varargin{i});
           collen = length (colspec);
-
-          if (strncmp (colspec, "blue", collen)
-              || strncmp (colspec, "black", collen)
-              || strncmp (colspec, "k", collen)
-              || strncmp (colspec, "black", collen)
-              || strncmp (colspec, "red", collen)
-              || strncmp (colspec, "green", collen)
-              || strncmp (colspec, "yellow", collen)
-              || strncmp (colspec, "magenta", collen)
-              || strncmp (colspec, "cyan", collen)
-              || strncmp (colspec, "white", collen))
+          if (any (strncmp (colspec, 
+                            {"blue", "black", "k", "red", "green", ...
+                             "yellow", "magenta", "cyan", "white"},
+                            collen)))
             i++;
             break;
           endif
@@ -116,13 +109,14 @@
       endwhile
     endif
   endwhile
+
 endfunction
 
 
 %!demo
-%! clf
-%! t1 = (1/16:1/8:1)*2*pi;
-%! t2 = ((1/16:1/8:1) + 1/32)*2*pi;
+%! clf;
+%! t1 = (1/16:1/8:1) * 2*pi;
+%! t2 = ((1/16:1/8:1) + 1/32) * 2*pi;
 %! x1 = sin (t1) - 0.8;
 %! y1 = cos (t1);
 %! x2 = sin (t2) + 0.8;
new file mode 100644
--- /dev/null
+++ b/scripts/plot/findfigs.m
@@ -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
+++ b/scripts/plot/findobj.m
@@ -146,18 +146,18 @@
           na = na + 1;
           pvalue{np} = args{na};
           na = na + 1;
-          if (na <= numel(args))
+          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
@@ -192,7 +192,7 @@
   while (numel (handles) && ! (idepth >= depth))
     children = [];
     for n = 1 : numel (handles)
-      children = union (children, get(handles(n), "children"));
+      children = union (children, get (handles(n), "children"));
     endfor
     handles = children;
     h = union (h, children);
@@ -201,7 +201,7 @@
 
   keepers = ones (size (h));
   if (numpairs > 0)
-    for nh = 1 : numel(h)
+    for nh = 1 : numel (h)
       p = get (h (nh));
       for np = 1 : numpairs
         fields = fieldnames (p);
@@ -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/fplot.m
+++ b/scripts/plot/fplot.m
@@ -80,7 +80,7 @@
     error ("fplot: first input argument must be a function handle, inline function or string");
   endif
 
-  if (floor(n) != n)
+  if (floor (n) != n)
     tol = n;
     x0 = linspace (limits(1), limits(2), 5)';
     y0 = feval (fn, x0);
@@ -127,10 +127,12 @@
   endif
 endfunction
 
-%!demo
-%! clf
-%! fplot ("cos", [0, 2*pi])
 
 %!demo
-%! clf
-%! fplot ("[cos(x), sin(x)]", [0, 2*pi])
+%! clf;
+%! fplot ('cos', [0, 2*pi]);
+
+%!demo
+%! clf;
+%! fplot ('[cos(x), sin(x)]', [0, 2*pi]);
+
--- a/scripts/plot/gca.m
+++ b/scripts/plot/gca.m
@@ -50,6 +50,7 @@
 
 endfunction
 
+
 %!test
 %! hf = figure ("visible", "off");
 %! ax = axes;
@@ -58,3 +59,4 @@
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
+
--- a/scripts/plot/gcbf.m
+++ b/scripts/plot/gcbf.m
@@ -32,5 +32,6 @@
 
 endfunction
 
-%!test
-%! assert (isempty (gcbf ));
+
+%!assert (isempty (gcbf))
+
--- a/scripts/plot/gcbo.m
+++ b/scripts/plot/gcbo.m
@@ -42,5 +42,7 @@
 
 endfunction
 
+
 %!test
-%! assert (isempty (gcbo ));
+%! assert (isempty (gcbo));
+
--- a/scripts/plot/gcf.m
+++ b/scripts/plot/gcf.m
@@ -54,6 +54,7 @@
 
 endfunction
 
+
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
@@ -61,3 +62,4 @@
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
+
new file mode 100644
--- /dev/null
+++ b/scripts/plot/gco.m
@@ -0,0 +1,45 @@
+## Copyright (C) 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/>.
+
+## -*- texinfo -*-
+## @deftypefn  {Function File} {@var{h} =} gco ()
+## @deftypefnx {Function File} {@var{h} =} gco (@var{fig})
+## Return a handle to the current object of the current figure, or a handle
+## to the current object of the figure with handle @var{fig}. The current
+## object of a figure is the object that was last clicked on. It is stored
+## in the CurrentObject property of the target figure.
+##
+## If the last mouse click didn't occur on any child object of the figure,
+## the current object is the figure itself.
+##
+## If no mouse click occured in the target figure, this function returns and
+## empty matrix.
+##
+## Note that the value returned by this function is not necessarily the same
+## as the one returned by gcbo during callback execution. An executing
+## callback can be interrupted by another callback and the current object
+## can be modified.
+##
+##@seealso{gcbo, gcf}
+##@end deftypefn
+
+function h = gco ()
+
+  h = get (gcf (), "currentobject");
+
+endfunction
--- a/scripts/plot/ginput.m
+++ b/scripts/plot/ginput.m
@@ -43,6 +43,8 @@
 
 endfunction
 
+
 ## Remove from test statistics.  No real tests possible.
 %!test
 %! assert (1);
+
--- a/scripts/plot/graphics_toolkit.m
+++ b/scripts/plot/graphics_toolkit.m
@@ -17,15 +17,18 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {@var{name} =} graphics_toolkit ()
-## @deftypefnx {Function File} {@var{old_name} =} graphics_toolkit (@var{name})
+## @deftypefn {Function File} {@var{name} =} graphics_toolkit ()
+## Return the default graphics toolkit.  The default graphics toolkit value
+## is assigned to new figures.
+## @deftypefnx {Function File} {@var{name} =} graphics_toolkit (@var{hlist})
+## Return the graphics toolkits for the figures with handles @var{hlist}.
+## @deftypefnx {Function File} {} graphics_toolkit (@var{name})
+## Set the default graphics toolkit to @var{name}.  If the toolkit is not
+## already loaded, it is initialized by calling the function
+## @code{__init_@var{name}__}.
 ## @deftypefnx {Function File} {} graphics_toolkit (@var{hlist}, @var{name})
-## Query or set the default graphics toolkit to @var{name}.  If the
-## toolkit is not already loaded, it is first initialized by calling the
-## function @code{__init_@var{name}__}.
-##
-## When called with a list of figure handles, @var{hlist}, the graphics
-## toolkit is changed only for the listed figures.
+## Set the graphics toolkit for the figures with handles @var{hlist} to
+## @var{name}.
 ## @seealso{available_graphics_toolkits}
 ## @end deftypefn
 
@@ -42,7 +45,11 @@
   if (nargin == 0)
     return;
   elseif (nargin == 1)
-    if (! ischar (name))
+    if (all (isfigure (name)))
+      hlist = name;
+      retval = get (hlist, "__graphics_toolkit__");
+      return
+    elseif (! ischar (name))
       error ("graphics_toolkit: invalid graphics toolkit NAME");
     endif
   elseif (nargin == 2)
@@ -77,19 +84,19 @@
 %!   toolkit = graphics_toolkit ();
 %!   assert (get (0, "defaultfigure__graphics_toolkit__"), toolkit);
 %!   graphics_toolkit (hf, "fltk"); 
-%!   assert (get (hf, "__graphics_toolkit__"), "fltk");
+%!   assert (graphics_toolkit (hf), "fltk");
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
 
 %!testif HAVE_FLTK
-%!  old_toolkit = graphics_toolkit ();
-%!  switch old_toolkit
-%!    case {"gnuplot"}
-%!      new_toolkit = "fltk";
-%!    otherwise
-%!      new_toolkit = "gnuplot";
-%!  endswitch
-%!  assert (graphics_toolkit (new_toolkit), old_toolkit)
-%!  assert (graphics_toolkit (old_toolkit), new_toolkit)
+%! old_toolkit = graphics_toolkit ();
+%! switch old_toolkit
+%!   case {"gnuplot"}
+%!     new_toolkit = "fltk";
+%!   otherwise
+%!     new_toolkit = "gnuplot";
+%! endswitch
+%! assert (graphics_toolkit (new_toolkit), old_toolkit);
+%! assert (graphics_toolkit (old_toolkit), new_toolkit);
 
--- a/scripts/plot/grid.m
+++ b/scripts/plot/grid.m
@@ -98,24 +98,23 @@
 
 endfunction
 
+
 %!demo
-%! clf
-%! subplot (2,2,1)
-%! plot (1:100)
-%! grid minor
-%! grid minor
-%! grid
-%! title ("no grid")
-%! subplot (2,2,2)
-%! plot (1:100)
-%! grid
-%! title ("grid on")
-%! subplot (2,2,3)
-%! plot (1:100)
-%! grid minor
-%! title ("grid minor")
-%! subplot (2,2,4)
-%! semilogy (1:100)
-%! grid minor
-%! title ("grid minor")
+%! clf;
+%! subplot (2,2,1);
+%!  plot (1:100);
+%!  grid off;
+%!  title ('no grid');
+%! subplot (2,2,2);
+%!  plot (1:100);
+%!  grid on;
+%!  title ('grid on');
+%! subplot (2,2,3);
+%!  plot (1:100);
+%!  grid minor;
+%!  title ('grid minor');
+%! subplot (2,2,4);
+%!  semilogy (1:100);
+%!  grid minor;
+%!  title ('grid minor');
 
--- a/scripts/plot/gtext.m
+++ b/scripts/plot/gtext.m
@@ -44,6 +44,7 @@
 
 endfunction
 
+
 ## Remove from test statistics.  No real tests possible.
-%!test
-%! assert (1);
+%!assert (1)
+
new file mode 100644
--- /dev/null
+++ b/scripts/plot/hdl2struct.m
@@ -0,0 +1,166 @@
+## Copyright (C) 2012 pdiribarne
+##
+## This program 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.
+##
+## This program 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{s} =} hdl2struct (@var{h})
+## Returns a structure, @var{s}, whose fields describe the properties
+## of the object, and its children, associated with the handle, @var{h}.
+## The fields of the structure, @var{s}, are "type", "handle", "properties",
+## "children" and "special".
+## @seealso{findobj, get, set, struct2hdl}
+## @end deftypefn
+
+## Author: pdiribarne <pdiribarne@new-host.home>
+## Created: 2012-03-04
+
+function hgS = hdl2struct (h)
+  if (nargin != 1 || !ishandle (h))
+    print_usage ();
+  endif
+
+  hiddenh = get (0, "showhiddenhandles");
+  if strcmp (hiddenh, "on")
+    set (0, "showhiddenhandles", "off");
+  endif
+
+  ## main object
+  main = get (h);
+  hgS.handle = h;
+  hgS.type =  main.type;
+  hgS.properties  = getprops (h);
+  hgS.children = [];
+  hgS.special = [];
+
+  ## sweep all children but legends, colorbars, uimenu and hggroup children
+  ## in reverse order
+  kids = main.children;
+  lg = findobj (h, "-depth", 1, "tag", "legend");
+  cb = findobj (h, "-depth", 1, "tag", "colorbar");
+  ui = findobj (h, "-depth", 1, "type", "uimenu");
+  nkids = length (kids);
+  ii = 0;
+  while nkids
+    if (! any (kids (nkids) == lg) && !any (kids (nkids) == cb)
+          && ! any (kids (nkids) == ui) && !strcmpi (main.type, "hggroup"))
+      ii++;
+      hgS.children(ii) = hdl2struct(kids(nkids));
+    endif
+    nkids--;
+  endwhile
+
+  ## add non "children" children objects (title, xlabel, ...) and
+  ## hggroup children and tag theim in "special"
+  special = [];
+  if (strcmpi (main.type, "hggroup"))
+    special = main.children;
+  endif
+  special = [special getspecial(h)];
+  nsp = length (special);
+  while nsp
+    ii++;
+    hgS.children(ii) = hdl2struct (special(nsp));
+    hgS.special(nsp) = ii;
+    nsp--;
+  endwhile
+
+  ## look for legends and colorbars among "main"'s brothers and add them
+  ## to the children list
+  if (strcmpi (main.type, "axes"))
+    par = main.parent;
+    lg = findobj (par, "-depth", 1, "tag", "legend");
+    if !isempty (lg)
+      idx = arrayfun (@(x) get(x).userdata.handle(end) == h, lg);
+      lg = lg(find(idx));
+    endif
+    nlg = length (lg);
+    if nlg == 1
+      ii++;
+      hgS.children(ii) = hdl2struct (lg);
+    elseif (nlg > 1)
+      error ("hdl2struct: more than one legend found")
+    endif
+
+    cb = findobj (par, "-depth", 1, "tag", "colorbar");
+    if (! isempty (cb))
+      idx = arrayfun (@(x) get(x).axes == h, cb);
+      cb = cb(find(idx));
+    endif
+
+    ncb = length (cb);
+    if (ncb == 1)
+      ii++;
+      hgS.children(ii) = hdl2struct(cb);
+    elseif (nlg > 1)
+      error ("hdl2struct: more than one colorbar found")
+    endif
+  endif
+
+  set (0, "showhiddenhandles", hiddenh);
+
+endfunction
+
+function hdlist = getspecial (h)
+  obj = get (h);
+  ## return handles to special children
+  fields = fieldnames (obj);
+  hdlist = [];
+
+  regkids = get ( h, "children");
+  set (0, "showhiddenhandles", "on")
+  allkids = get ( h, "children");
+  set (0, "showhiddenhandles", "off")
+  speckids = arrayfun (@(x) ! any (x == regkids), allkids);
+  hdlist = allkids (find (speckids));
+  hdlist = reshape (hdlist, 1, numel (hdlist));
+
+endfunction
+
+function prpstr = getprops (h)
+  obj = get (h);
+  ## get usefull properties rejecting readonly, children, handles ...
+  fields = fieldnames (obj);
+  hdlist = [];
+
+  forbid = {"beingdeleted", "busyaction", "buttondownfcn", ...
+            "children", "clipping", "createfcn", ...
+            "deletefcn", "handlevisibility", "hittest", ...
+            "interruptible", "parent", "selected" ,...
+            "selectionhighlight", "type", "__modified__", ...
+            "uicontextmenu", "__graphics_toolkit__", "currentaxes", ...
+            "currentcharacter", "currentobject","tightinset", ...
+            "currentpoint", "extent"};
+
+  nflds = length (fields);
+  ii = 0;
+  while nflds
+    prop = fields{nflds};
+    val = obj.(fields{nflds});
+    ii++;
+    if !any (strcmp (prop, forbid))
+      prpstr.(prop) = val;
+    endif
+    nflds--;
+  endwhile
+
+  ## hidden properties
+  hidden = {"autopos_tag", "looseinset"};
+  for ii = 1:numel (hidden)
+    if (isprop (h, hidden{ii}))
+      prpstr.(hidden{ii}) = get (h, hidden{ii});
+    endif
+  endfor
+endfunction
+
--- a/scripts/plot/hggroup.m
+++ b/scripts/plot/hggroup.m
@@ -42,6 +42,7 @@
 
 endfunction
 
+
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
@@ -51,3 +52,4 @@
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
+
--- a/scripts/plot/hidden.m
+++ b/scripts/plot/hidden.m
@@ -21,7 +21,7 @@
 ## @deftypefnx {Function File} {} hidden ()
 ## Manipulation the mesh hidden line removal.  Called with no argument
 ## the hidden line removal is toggled.  The argument @var{mode} can be either
-## 'on' or 'off' and the set of the hidden line removal is set accordingly.
+## "on" or "off" and the set of the hidden line removal is set accordingly.
 ## @seealso{mesh, meshc, surf}
 ## @end deftypefn
 
--- a/scripts/plot/hist.m
+++ b/scripts/plot/hist.m
@@ -93,7 +93,7 @@
   if (nargin == 1 || ischar (varargin{iarg}))
     n = 10;
     x = [0.5:n]'/n;
-    x = x * (max_val - min_val) + ones(size(x)) * min_val;
+    x = x * (max_val - min_val) + ones (size (x)) * min_val;
   else
     ## nargin is either 2 or 3
     x = varargin{iarg++};
@@ -149,7 +149,7 @@
   if (nargin > 2 && ! ischar (varargin{iarg}))
     ## Normalise the histogram.
     norm = varargin{iarg++};
-    freq = freq / rows (y) * norm;
+    freq = freq / sum(! isnan (y)) * norm;
   endif
 
   if (nargout > 0)
@@ -160,7 +160,7 @@
       nn = freq;
       xx = x;
     endif
-  elseif (size (freq, 2) != 1)
+  elseif (columns (freq) != 1)
     bar (x, freq, 0.8, varargin{iarg:end});
   else
     bar (x, freq, 1.0, varargin{iarg:end});
@@ -168,30 +168,35 @@
 
 endfunction
 
+
 %!test
-%!  [nn,xx]=hist([1:4],3);
-%!  assert(xx, [1.5,2.5,3.5]);
-%!  assert(nn, [2,1,1]);
+%! [nn,xx] = hist ([1:4], 3);
+%! assert (xx, [1.5,2.5,3.5]);
+%! assert (nn, [2,1,1]);
 %!test
-%!  [nn,xx]=hist([1:4]',3);
-%!  assert(xx, [1.5,2.5,3.5]);
-%!  assert(nn, [2,1,1]);
+%! [nn,xx] = hist ([1:4]', 3);
+%! assert (xx, [1.5,2.5,3.5]);
+%! assert (nn, [2,1,1]);
 %!test
-%!  [nn,xx]=hist([1 1 1 NaN NaN NaN 2 2 3],[1 2 3]);
-%!  assert(xx, [1,2,3]);
-%!  assert(nn, [3,2,1]);
+%! [nn,xx] = hist ([1 1 1 NaN NaN NaN 2 2 3],[1 2 3]);
+%! assert (xx, [1,2,3]);
+%! assert (nn, [3,2,1]);
 %!test
-%!  [nn,xx]=hist([[1:4]',[1:4]'],3);
-%!  assert(xx, [1.5;2.5;3.5]);
-%!  assert(nn, [[2,1,1]',[2,1,1]']);
-%!assert(hist(1,1),1);
+%! [nn,xx] = hist ([1 1 1 NaN NaN NaN 2 2 3],[1 2 3], 6);
+%! assert (xx, [1,2,3]);
+%! assert (nn, [3,2,1]);
+%!test
+%! [nn,xx] = hist ([[1:4]', [1:4]'], 3);
+%! assert (xx, [1.5;2.5;3.5]);
+%! assert (nn, [[2,1,1]',[2,1,1]']);
 %!test
-%!  for n = [10, 30, 100, 1000]
-%!    assert(sum(hist([1:n], n)), n);
-%!    assert(sum(hist([1:n], [2:n-1])), n);
-%!    assert(sum(hist([1:n], [1:n])), n);
-%!    assert(sum(hist([1:n], 29)), n);
-%!    assert(sum(hist([1:n], 30)), n);
-%!  endfor
-%!test
-%!  assert (size (hist(randn(750,240), 200)), [200,240]);
+%! for n = [10, 30, 100, 1000]
+%!   assert (sum (hist ([1:n], n)), n);
+%!   assert (sum (hist ([1:n], [2:n-1])), n);
+%!   assert (sum (hist ([1:n], [1:n])), n);
+%!   assert (sum (hist ([1:n], 29)), n);
+%!   assert (sum (hist ([1:n], 30)), n);
+%! endfor
+%!assert (hist (1,1), 1)
+%!assert (size (hist (randn (750,240), 200)), [200,240])
+
--- a/scripts/plot/hold.m
+++ b/scripts/plot/hold.m
@@ -20,7 +20,7 @@
 ## @deftypefn  {Command} {} hold
 ## @deftypefnx {Command} {} hold @var{state}
 ## @deftypefnx {Function File} {} hold (@var{hax}, @dots{})
-## Toggle or set the 'hold' state of the plotting engine which determines
+## Toggle or set the "hold" state of the plotting engine which determines
 ## whether new graphic objects are added to the plot or replace the existing
 ## objects.
 ##
@@ -39,13 +39,13 @@
 ## command.  (default).
 ##
 ## @item hold
-## Toggle the current 'hold' state.
+## Toggle the current hold state.
 ## @end table
 ##
 ## When given the additional argument @var{hax}, the hold state is modified
 ## only for the given axis handle.
 ##
-## To query the current 'hold' state use the @code{ishold} function.
+## To query the current hold state use the @code{ishold} function.
 ## @seealso{ishold, cla, newplot, clf}
 ## @end deftypefn
 
@@ -94,60 +94,64 @@
 
 endfunction
 
+
 %!demo
-%! clf
+%! clf;
 %! A = rand (100);
 %! [X, Y] = find (A > 0.9);
-%! imshow (A)
-%! hold on
-%! plot (X, Y, 'o')
-%! hold off
+%! imshow (A);
+%! hold on;
+%! plot (X, Y, 'o');
+%! hold off;
 
 %!demo
-%! clf
-%! hold on
-%! imagesc(1./hilb(4));
-%! plot (1:4, "-s")
-%! hold off
+%! clf;
+%! colormap ('default');
+%! hold on;
+%! imagesc (1 ./ hilb (4));
+%! plot (1:4, '-s');
+%! hold off;
 
 %!demo
-%! clf
-%! hold on
-%! imagesc(1./hilb(2));
-%! imagesc(1./hilb(4));
-%! hold off
+%! clf;
+%! colormap ('default');
+%! hold on;
+%! imagesc (1 ./ hilb (2));
+%! imagesc (1 ./ hilb (4));
+%! hold off;
 
 %!demo
-%! clf
-%! hold on
-%! plot (1:4, "-s")
-%! imagesc(1./hilb(4));
-%! hold off
+%! clf;
+%! colormap ('default');
+%! hold on;
+%! plot (1:4, '-s');
+%! imagesc (1 ./ hilb (4));
+%! hold off;
 
 %!demo
-%! clf
-%! colormap (jet)
+%! clf;
+%! colormap ('default');
 %! t = linspace (-3, 3, 50);
 %! [x, y] = meshgrid (t, t);
 %! z = peaks (x, y);
 %! contourf (x, y, z, 10);
-%! hold ("on");
-%! plot (vec (x), vec (y), "^");
-%! patch ([-1.0 1.0 1.0 -1.0 -1.0], [-1.0 -1.0 1.0 1.0 -1.0], "red");
+%! hold on;
+%! plot (x(:), y(:), '^');
+%! patch ([-1.0 1.0 1.0 -1.0 -1.0], [-1.0 -1.0 1.0 1.0 -1.0], 'red');
 %! xlim ([-2.0 2.0]);
 %! ylim ([-2.0 2.0]);
-%! colorbar ("SouthOutside");
-%! title ("Test script for some plot functions");
+%! colorbar ('SouthOutside');
+%! title ('Test script for some plot functions');
 
 ##hold on
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
 %!   p = plot ([0 1]);
-%!   assert (!ishold);
+%!   assert (! ishold);
 %!   hold on;
 %!   assert (ishold);
-%!   p1 = fill ([0 1 1], [0 0 1],"black");
+%!   p1 = fill ([0 1 1], [0 0 1], "black");
 %!   p2 = fill ([0 1 0], [0 1 1], "red");
 %!   assert (length (get (hf, "children")), 1);
 %!   assert (length (get (gca, "children")), 3);
@@ -160,14 +164,15 @@
 %! hf = figure ("visible", "off");
 %! unwind_protect
 %!   p = plot ([0 1]);
-%!   assert (!ishold);
+%!   assert (! ishold);
 %!   hold on;
 %!   assert (ishold);
-%!   p1 = fill ([0 1 1], [0 0 1],"black");
-%!   hold off
+%!   p1 = fill ([0 1 1], [0 0 1], "black");
+%!   hold off;
 %!   p2 = fill ([0 1 0], [0 1 1], "red");
 %!   assert (length (get (hf, "children")), 1);
 %!   assert (length (get (gca, "children")), 1);
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
+
--- a/scripts/plot/isfigure.m
+++ b/scripts/plot/isfigure.m
@@ -35,11 +35,13 @@
 
 endfunction
 
+
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
 %!   assert (isfigure (hf));
-%!   assert (!isfigure (-hf));
+%!   assert (! isfigure (-hf));
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
+
--- a/scripts/plot/ishghandle.m
+++ b/scripts/plot/ishghandle.m
@@ -27,32 +27,33 @@
   retval = ishandle (h);
 endfunction
 
+
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
 %!   assert (ishghandle (hf));
-%!   assert (!ishghandle (-hf));
+%!   assert (! ishghandle (-hf));
 %!   l = line;
-%!   ax = gca();
+%!   ax = gca;
 %!   assert (ishghandle (ax));
-%!   assert (!ishghandle (-ax));
+%!   assert (! ishghandle (-ax));
 %!   assert (ishghandle (l));
-%!   assert (!ishghandle (-l));
+%!   assert (! ishghandle (-l));
 %!   p = patch;
 %!   assert (ishghandle (p));
-%!   assert (!ishghandle (-p));
+%!   assert (! ishghandle (-p));
 %!   s = surface;
 %!   assert (ishghandle (s));
-%!   assert (!ishghandle (-s));
+%!   assert (! ishghandle (-s));
 %!   t = text;
 %!   assert (ishghandle (t));
-%!   assert (!ishghandle (-t));
+%!   assert (! ishghandle (-t));
 %!   i = image;
 %!   assert (ishghandle (i));
-%!   assert (!ishghandle (-i));
+%!   assert (! ishghandle (-i));
 %!   hg = hggroup;
 %!   assert (ishghandle (hg));
-%!   assert (!ishghandle (-hg));
+%!   assert (! ishghandle (-hg));
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
--- a/scripts/plot/ishold.m
+++ b/scripts/plot/ishold.m
@@ -55,15 +55,16 @@
 
 endfunction
 
+
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
-%!   assert (!ishold);
+%!   assert (! ishold);
 %!   assert (isempty (get (hf, "currentaxes")));
 %!   assert (get (hf, "NextPlot"), "add");
 %!   l = plot ([0 1]);
-%!   assert (!ishold);
-%!   assert (!ishold (gca));
+%!   assert (! ishold);
+%!   assert (! ishold (gca));
 %!   assert (get (gca, "NextPlot"), "replace");
 %!   assert (get (hf, "NextPlot"), "add");
 %!   hold;
@@ -77,3 +78,4 @@
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
+
--- a/scripts/plot/isocolors.m
+++ b/scripts/plot/isocolors.m
@@ -98,7 +98,7 @@
 
 ## Author: Martin Helm <martin@mhelm.de>
 
-function varargout = isocolors(varargin)
+function varargout = isocolors (varargin)
   calc_rgb = false;
   switch (nargin)
     case 2
@@ -134,7 +134,7 @@
     otherwise
       print_usage ();
   endswitch
-  if (ismatrix (vp) && size (vp,2) == 3)
+  if (ismatrix (vp) && columns (vp) == 3)
     pa = [];
     v = vp;
   elseif ( ishandle (vp) )
@@ -144,7 +144,7 @@
     error ("isocolors: last argument is not a vertex list or patch handle");
   endif
   if (calc_rgb)
-    new_col = zeros (size (v, 1), 3);
+    new_col = zeros (rows (v), 3);
     new_col(:,1) = __interp_cube__ (x, y, z, R, v, "values" );
     new_col(:,2) = __interp_cube__ (x, y, z, G, v, "values" );
     new_col(:,3) = __interp_cube__ (x, y, z, B, v, "values" );
@@ -163,10 +163,12 @@
   endswitch
 endfunction
 
+
 %!test
-%!  [x, y, z] = meshgrid (0:.5:2, 0:.5:2, 0:.5:2);
-%!  c = (x-.5).^2 + (y-.5).^2 + (z-.5).^2;
-%!  [f, v] = isosurface (x, y, z, c, .4);
-%!  cdat = isocolors (x, y, z, c, v);
-%!  assert (size (cdat, 1) == size (v, 1));
+%! [x, y, z] = meshgrid (0:.5:2, 0:.5:2, 0:.5:2);
+%! c = (x-.5).^2 + (y-.5).^2 + (z-.5).^2;
+%! [f, v] = isosurface (x, y, z, c, .4);
+%! cdat = isocolors (x, y, z, c, v);
+%! assert (rows (cdat) == rows (v));
 ## Can't create a patch handle for tests without a figure
+
--- a/scripts/plot/isonormals.m
+++ b/scripts/plot/isonormals.m
@@ -95,7 +95,7 @@
 
 ## Author: Martin Helm <martin@mhelm.de>
 
-function varargout = isonormals(varargin)
+function varargout = isonormals (varargin)
   na = nargin;
   negate = false;
   if (ischar (varargin{nargin}))
@@ -122,7 +122,7 @@
     otherwise
       print_usage ();
   endswitch
-  if (ismatrix (vp) && size (vp,2) == 3)
+  if (ismatrix (vp) && columns (vp) == 3)
     pa = [];
     v = vp;
   elseif (ishandle (vp))
@@ -148,16 +148,18 @@
   endswitch
 endfunction
 
+
 %!test
-%!  [x, y, z] = meshgrid (0:.5:2, 0:.5:2, 0:.5:2);
-%!  c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2);
-%!  [f, v, cdat] = isosurface (x, y, z, c, .4, y);
-%!  n = isonormals (x, y, z, c, v);
-%!  assert (size (v), size (n));
+%! [x, y, z] = meshgrid (0:.5:2, 0:.5:2, 0:.5:2);
+%! c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2);
+%! [f, v, cdat] = isosurface (x, y, z, c, .4, y);
+%! n = isonormals (x, y, z, c, v);
+%! assert (size (v), size (n));
 %!test
-%!  [x, y, z] = meshgrid (0:.5:2, 0:.5:2, 0:.5:2);
-%!  c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2);
-%!  [f, v, cdat] = isosurface (x, y, z, c, .4, y);
-%!  np = isonormals (x, y, z, c, v);
-%!  nn = isonormals (x, y, z, c, v, "negate");
-%!  assert (all (np == -nn));
+%! [x, y, z] = meshgrid (0:.5:2, 0:.5:2, 0:.5:2);
+%! c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2);
+%! [f, v, cdat] = isosurface (x, y, z, c, .4, y);
+%! np = isonormals (x, y, z, c, v);
+%! nn = isonormals (x, y, z, c, v, "negate");
+%! assert (np, -nn);
+
--- a/scripts/plot/isosurface.m
+++ b/scripts/plot/isosurface.m
@@ -118,7 +118,7 @@
 
 ## Author: Martin Helm <martin@mhelm.de>
 
-function varargout = isosurface(varargin)
+function varargout = isosurface (varargin)
 
   if (nargin < 2 || nargin > 8 || nargout > 3)
     print_usage ();
@@ -174,7 +174,7 @@
                     "FaceColor", "g", "EdgeColor", "k");
       endif
       if (! ishold ())
-        set (gca(), "view", [-37.5, 30],
+        set (gca (), "view", [-37.5, 30],
              "xgrid", "on", "ygrid", "on", "zgrid", "on");
       endif
     case 1
@@ -190,36 +190,37 @@
 endfunction
 
 
+%!demo
+%! clf;
+%! [x,y,z] = meshgrid (-2:0.5:2, -2:0.5:2, -2:0.5:2);
+%! v = x.^2 + y.^2 + z.^2;
+%! isosurface (x, y, z, v, 1);
+
 %!shared x, y, z, val
-%!  [x, y, z]  = meshgrid (0:1, 0:1, 0:1); ## Points for single
-%!  val        = [0, 0; 0, 0];             ## cube and a 3--dim
-%!  val(:,:,2) = [0, 0; 1, 0];             ## array of values
+%! [x, y, z]  = meshgrid (0:1, 0:1, 0:1); %% Points for single
+%! val        = [0, 0; 0, 0];             %% cube and a 3-D
+%! val(:,:,2) = [0, 0; 1, 0];             %% array of values
 %!test
-%!  fv = isosurface (x, y, z, val, 0.3);
-%!  assert (isfield (fv, "vertices"), true);
-%!  assert (isfield (fv, "faces"), true);
-%!  assert (size (fv.vertices), [3 3]);
-%!  assert (size (fv.faces), [1 3]);
+%! fv = isosurface (x, y, z, val, 0.3);
+%! assert (isfield (fv, "vertices"), true);
+%! assert (isfield (fv, "faces"), true);
+%! assert (size (fv.vertices), [3 3]);
+%! assert (size (fv.faces), [1 3]);
 %!test
-%!  fvc = isosurface (x, y, z, val, .3, y);
-%!  assert (isfield (fvc, "vertices"), true);
-%!  assert (isfield (fvc, "faces"), true);
-%!  assert (isfield (fvc, "facevertexcdata"), true);
-%!  assert (size (fvc.vertices), [3 3]);
-%!  assert (size (fvc.faces), [1 3]);
-%!  assert (size (fvc.facevertexcdata), [3 1]);
+%! fvc = isosurface (x, y, z, val, .3, y);
+%! assert (isfield (fvc, "vertices"), true);
+%! assert (isfield (fvc, "faces"), true);
+%! assert (isfield (fvc, "facevertexcdata"), true);
+%! assert (size (fvc.vertices), [3 3]);
+%! assert (size (fvc.faces), [1 3]);
+%! assert (size (fvc.facevertexcdata), [3 1]);
 %!test
-%!  [f, v] = isosurface (x, y, z, val, .3);
-%!  assert (size (f), [1 3]);
-%!  assert (size (v), [3 3]);
+%! [f, v] = isosurface (x, y, z, val, .3);
+%! assert (size (f), [1 3]);
+%! assert (size (v), [3 3]);
 %!test
-%!  [f, v, c] = isosurface (x, y, z, val, .3, y);
-%!  assert (size (f), [1 3]);
-%!  assert (size (v), [3 3]);
-%!  assert (size (c), [3 1]);
+%! [f, v, c] = isosurface (x, y, z, val, .3, y);
+%! assert (size (f), [1 3]);
+%! assert (size (v), [3 3]);
+%! assert (size (c), [3 1]);
 
-%!demo
-%! clf
-%! [x,y,z] = meshgrid(-2:0.5:2, -2:0.5:2, -2:0.5:2);
-%! v = x.^2 + y.^2 + z.^2;
-%! isosurface (x, y, z, v, 1)
--- a/scripts/plot/isprop.m
+++ b/scripts/plot/isprop.m
@@ -37,7 +37,7 @@
   endif
 
   res = false (size (h));
-  for n = 1:numel(res)
+  for n = 1:numel (res)
     res(n) = true;
     try
       v = get (h(n), prop);
@@ -47,9 +47,8 @@
   endfor
 endfunction
 
+
 %!assert (isprop (0, "foobar"), false)
-
 %!assert (isprop (0, "screenpixelsperinch"), true)
-
 %!assert (isprop (zeros (2, 3), "visible"), true (2, 3))
 
--- a/scripts/plot/legend.m
+++ b/scripts/plot/legend.m
@@ -19,7 +19,7 @@
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {} legend (@var{str1}, @var{str2}, @dots{})
 ## @deftypefnx {Function File} {} legend (@var{matstr})
-## @deftypefnx {Function File} {} legend (@var{cell})
+## @deftypefnx {Function File} {} legend (@var{cellstr})
 ## @deftypefnx {Function File} {} legend (@dots{}, "location", @var{pos})
 ## @deftypefnx {Function File} {} legend (@dots{}, "orientation", @var{orient})
 ## @deftypefnx {Function File} {} legend (@var{hax}, @dots{})
@@ -145,9 +145,9 @@
     kids = ca;
     kids (strcmp (get (ca, "tag"), "legend")) = [];
     if (isscalar (kids))
-      kids = get(kids, "children")(:);
+      kids = get (kids, "children")(:);
     else
-      kids = [get(kids, "children"){:}](:);
+      kids = flipud ([get(kids, "children"){:}](:));
     endif
   endif
   nargs = numel (varargin);
@@ -195,7 +195,7 @@
 
   ## Validate the position type is valid
   outside = false;
-  inout = findstr (position, "outside");
+  inout = strfind (position, "outside");
   if (! isempty (inout))
     outside = true;
     position = position(1:inout-1);
@@ -215,7 +215,7 @@
 
   hlegend = [];
   fkids = get (fig, "children");
-  for i = 1 : numel(fkids)
+  for i = 1 : numel (fkids)
     if (ishandle (fkids (i)) && strcmp (get (fkids (i), "type"), "axes")
         && (strcmp (get (fkids (i), "tag"), "legend")))
       udata = get (fkids (i), "userdata");
@@ -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,14 +440,14 @@
         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");
         endif
         if (strcmp (position, "default"))
           position = get (hlegend, "location");
-          inout = findstr (position, "outside");
+          inout = strfind (position, "outside");
           if (! isempty (inout))
             outside = true;
             position = position(1:inout-1);
@@ -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.
@@ -497,24 +498,25 @@
       ## FIXME hlegend should inherit properties from "ca"
       curaxes = get (fig, "currentaxes");
       unwind_protect
-        ud = ancestor(hplots, "axes");
-        if (!isscalar(ud))
+        ud = ancestor (hplots, "axes");
+        if (!isscalar (ud))
           ud = unique ([ud{:}]);
         endif
         if (isempty (hlegend))
           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",
-                          "activepositionproperty", "position");
+                          "xtick", [], "ytick", [],
+                          "xticklabel", "", "yticklabel", "", "zticklabel", "",
+                          "xlim", [0, 1], "ylim", [0, 1],
+                          "visible", ifelse (strcmp (box, "on"), "on", "off"),
+                          "activepositionproperty", "position",
+                          "fontsize", ca_fontsize);
         else
           addprops = false;
           axes (hlegend);
           delete (get (hlegend, "children"));
         endif
-
         ## Add text label to the axis first, checking their extents
         nentries = numel (hplots);
         texthandle = [];
@@ -524,11 +526,13 @@
           if (strcmp (textpos, "right"))
             texthandle = [texthandle, text(0, 0, text_strings {k},
                                            "horizontalalignment", "left",
-                                           "userdata", hplots(k))];
+                                           "userdata", hplots(k),
+                                           "fontsize", ca_fontsize)];
           else
             texthandle = [texthandle, text(0, 0, text_strings {k},
                                            "horizontalalignment", "right",
-                                           "userdata", hplots(k))];
+                                           "userdata", hplots(k),
+                                           "fontsize", ca_fontsize)];
           endif
           units = get (texthandle (end), "units");
           unwind_protect
@@ -703,14 +707,26 @@
               hobjects = [hobjects, l1];
             endif
 
-            addlistener(hplots(k), "color", {@updateline, hlegend, linelength});
-            addlistener(hplots(k), "linestyle", {@updateline, hlegend, linelength});
-            addlistener(hplots(k), "marker", {@updateline, hlegend, linelength});
-            addlistener(hplots(k), "markeredgecolor", {@updateline, hlegend, linelength});
-            addlistener(hplots(k), "markerfacecolor", {@updateline, hlegend, linelength});
-            addlistener(hplots(k), "markersize", {@updateline, hlegend, linelength});
-            addlistener(hplots(k), "displayname", {@updateline, hlegend, linelength});
+            addlistener (hplots(k), "color", {@updateline, hlegend, linelength});
+            addlistener (hplots(k), "linestyle", {@updateline, hlegend, linelength});
+            addlistener (hplots(k), "marker", {@updateline, hlegend, linelength});
+            addlistener (hplots(k), "markeredgecolor", {@updateline, hlegend, linelength});
+            addlistener (hplots(k), "markerfacecolor", {@updateline, hlegend, linelength});
+            addlistener (hplots(k), "markersize", {@updateline, hlegend, linelength});
+            addlistener (hplots(k), "displayname", {@updateline, hlegend, linelength});
           case "patch"
+            facecolor = get (hplots(k), "facecolor");
+            edgecolor = get (hplots(k), "edgecolor");
+            cdata = get (hplots(k), "cdata");
+            if (! strcmp (facecolor, "none") || ! strcmp (edgecolor, "none"))
+              p1 = patch ("xdata", ([0, linelength, linelength, 0] +
+                                   xoffset + xk * xstep) / lpos(3),
+                         "ydata", (lpos(4) - yoffset -
+                                   [yk-0.3, yk-0.3, yk+0.3, yk+0.3] .* ystep) / lpos(4),
+                         "facecolor", facecolor, "edgecolor", edgecolor, "cdata", cdata,
+                         "userdata", hplots (k));
+              hobjects = [hobjects, p1];
+            endif
           case "surface"
           endswitch
           set (texthandle (k), "position", [(txoffset + xk * xstep) / lpos(3), ...
@@ -823,9 +839,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)
@@ -842,7 +856,7 @@
 
   for i = 1 : numel (ca)
     if (ishandle (ca(i)) && strcmp (get (ca(i), "type"), "axes")
-        && (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off"))
+        && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"),"off"))
         && strcmp (get (ca(i), "beingdeleted"), "off"))
       units = get (ca(i), "units");
       unwind_protect
@@ -861,7 +875,7 @@
 
 function deletelegend1 (h, d, ca)
   if (ishandle (ca) && strcmp (get (ca, "type"), "axes")
-      && (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off"))
+      && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"),"off"))
       && strcmp (get (ca, "beingdeleted"), "off"))
     delete (ca);
   endif
@@ -870,7 +884,7 @@
 function deletelegend2 (h, d, ca, pos, outpos, t1, hplots)
   for i = 1 : numel (ca)
     if (ishandle (ca(i)) && strcmp (get (ca(i), "type"), "axes")
-        && (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off"))
+        && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"),"off"))
         && strcmp (get (ca(i), "beingdeleted"), "off"))
       if (!isempty (pos) && !isempty(outpos))
         units = get (ca(i), "units");
@@ -945,7 +959,7 @@
       ypos1 = get (ll,"ydata");
       xpos1 = get (ll,"xdata");
       ypos2 = ypos1(1);
-      xpos2 = sum(xpos1) / 2;
+      xpos2 = sum (xpos1) / 2;
       delete (ll);
       if (! isempty (lm))
         delete (lm);
@@ -973,189 +987,210 @@
 endfunction
 
 %!demo
-%! clf
-%! x = 0:1;
-%! plot (x, x, ";I am Blue;", x, 2*x, ";I am Green;", x, 3*x, ";I am Red;")
+%! plot (rand (2))
+%! legend ({'foo'}, 'bar', 'boxoff')
+%! title ('legend() should warn about an extra label')
 
 %!demo
-%! clf
-%! x = 0:1;
-%! plot (x, x, ";I am Blue;", x, 2*x, x, 3*x, ";I am Red;")
-%! title ("Blue and Green keys, with Green mising")
+%! 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
-%! plot(1:10, 1:10, 1:10, fliplr(1:10));
-%! title("incline is blue and decline is green");
-%! legend({"I am blue", "I am green"}, "location", "east");
-%! legend({"I am blue", "I am green"}, "location", "east");
+%! 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
-%! plot(1:10, 1:10, 1:10, fliplr(1:10));
-%! title("Legend is hidden")
-%! legend({"I am blue", "I am green"}, "location", "east");
-%! legend hide
+%! clf;
+%! x = 0:1;
+%! plot (x, x, ';\alpha;',  ...
+%!       x, 2*x, ';\beta=2\alpha;',  ...
+%!       x, 3*x, ';\gamma=3\alpha;');
 
 %!demo
-%! clf
-%! plot(1:10, 1:10, 1:10, fliplr(1:10));
-%! title("Legend with box on")
-%! legend({"I am blue", "I am green"}, "location", "east");
-%! legend boxon
+%! clf;
+%! x = 0:1;
+%! plot (x,x,';I am Blue;', x,2*x, x,3*x,';I am Red;');
+%! title ('Blue and Green keys, with Green missing');
+
+%!demo
+%! clf;
+%! plot (1:10, 1:10, 1:10, fliplr (1:10));
+%! title ('incline is blue and decline is green');
+%! legend ({'I am blue', 'I am green'}, 'location', 'east');
 
 %!demo
-%! clf
-%! plot(1:10, 1:10, 1:10, fliplr(1:10));
-%! title("Legend with text to the right")
-%! legend({"I am blue", "I am green"}, "location", "east");
-%! legend right
+%! clf;
+%! plot (1:10, 1:10, 1:10, fliplr (1:10));
+%! title ('Legend is hidden')
+%! legend ({'I am blue', 'I am green'}, 'location', 'east');
+%! legend hide;
 
 %!demo
-%! clf
-%! plot(1:10, 1:10);
-%! title("a very long label can sometimes cause problems");
-%! legend({"hello world"}, "location", "northeastoutside");
+%! clf;
+%! plot (1:10, 1:10, 1:10, fliplr (1:10));
+%! title ('Legend with box off');
+%! legend ({'I am blue', 'I am green'}, 'location', 'east');
+%! legend boxoff;
 
 %!demo
-%! clf
-%! plot(1:10, 1:10);
-%! title("a very long label can sometimes cause problems");
-%! legend("hello world", "location", "northeastoutside");
+%! clf;
+%! plot (1:10, 1:10, 1:10, fliplr (1:10));
+%! title ('Legend with text to the right');
+%! legend ({'I am blue', 'I am green'}, 'location', 'east');
+%! legend right;
 
 %!demo
-%! clf
-%! labels = {};
-%! colororder = get (gca, "colororder");
-%! for i = 1:5
-%!   h = plot(1:100, i + rand(100,1)); hold on;
-%!   set (h, "color", colororder(i,:))
-%!   labels = {labels{:}, cstrcat("Signal ", num2str(i))};
-%! endfor
-%! hold off;
-%! title("Signals with random offset and uniform noise")
-%! xlabel("Sample Nr [k]"); ylabel("Amplitude [V]");
-%! legend(labels, "location", "southoutside");
-%! legend("boxon");
+%! clf;
+%! plot (1:10, 1:10);
+%! title ('a very long label can sometimes cause problems');
+%! legend ({'hello world'}, 'location', 'northeastoutside');
+
+%!demo
+%! clf;
+%! plot (1:10, 1:10);
+%! title ('a very long label can sometimes cause problems');
+%! legend ('hello world', 'location', 'northeastoutside');
 
 %!demo
-%! clf
+%! clf;
 %! labels = {};
-%! colororder = get (gca, "colororder");
+%! colororder = get (gca, 'colororder');
 %! for i = 1:5
-%!   h = plot(1:100, i + rand(100,1)); hold on;
-%!   set (h, "color", colororder(i,:))
-%!   labels = {labels{:}, cstrcat("Signal ", num2str(i))};
-%! endfor
+%!   h = plot (1:100, i + rand (100,1)); hold on;
+%!   set (h, 'color', colororder(i,:));
+%!   labels = {labels{:}, ['Signal ', num2str(i)]};
+%! end
 %! hold off;
-%! title("Signals with random offset and uniform noise")
-%! xlabel("Sample Nr [k]"); ylabel("Amplitude [V]");
-%! legend(labels{:}, "location", "southoutside")
-%! legend("boxon")
+%! title ('Signals with random offset and uniform noise');
+%! xlabel ('Sample Nr [k]'); ylabel ('Amplitude [V]');
+%! legend (labels, 'location', 'southoutside');
 
 %!demo
-%! clf
+%! clf;
 %! x = linspace (0, 10);
 %! plot (x, x);
-%! hold ("on");
-%! stem (x, x.^2, 'g')
-%! legend ("linear");
-%! hold ("off");
+%! hold on;
+%! stem (x, x.^2, 'g');
+%! legend ('linear');
+%! hold off;
 
 %!demo
-%! clf
+%! clf;
 %! x = linspace (0, 10);
 %! plot (x, x, x, x.^2);
-%! legend ("linear");
+%! legend ('linear');
 
 %!demo
-%! clf
+%! clf;
 %! x = linspace (0, 10);
 %! plot (x, x, x, x.^2);
-%! legend ("linear", "quadratic");
+%! legend ('linear', 'quadratic');
 
 %!demo
-%! clf
+%! clf;
 %! rand_2x3_data1 = [0.341447, 0.171220, 0.284370; 0.039773, 0.731725, 0.779382];
 %! bar (rand_2x3_data1);
 %! ylim ([0 1.0]);
-%! legend ({"1st Bar", "2nd Bar", "3rd Bar"});
+%! legend ({'1st Bar', '2nd Bar', '3rd Bar'});
 
 %!demo
-%! clf
+%! clf;
 %! rand_2x3_data2 = [0.44804, 0.84368, 0.23012; 0.72311, 0.58335, 0.90531];
 %! bar (rand_2x3_data2);
 %! ylim ([0 1.2]);
-%! legend ("1st Bar", "2nd Bar", "3rd Bar");
-%! legend right
+%! legend ('1st Bar', '2nd Bar', '3rd Bar');
+%! legend right;
 
 %!demo
-%! clf
+%! clf;
 %! x = 0:0.1:7;
-%! h = plot (x, sin(x), x, cos(x), x, sin(x.^2/10), x, cos(x.^2/10));
-%! title ("Only the sin() objects have keylabels");
-%! legend (h([1, 3]), {"sin(x)", "sin(x^2/10)"}, "location", "southwest");
+%! h = plot (x,sin(x), x,cos(x), x,sin(x.^2/10), x,cos(x.^2/10));
+%! title ('Only the sin() objects have keylabels');
+%! legend (h([1, 3]), {'sin (x)', 'sin (x^2/10)'}, 'location', 'southwest');
 
 %!demo
-%! clf
+%! clf;
 %! x = 0:0.1:10;
-%! plot (x, sin(x), ";sin(x);")
-%! hold all
-%! plot (x, cos(x), ";cos(x);")
-%! hold off
+%! plot (x, sin (x), ';sin (x);');
+%! hold all;
+%! plot (x, cos (x), ';cos (x);');
+%! hold off;
 
 %!demo
-%! clf
+%! clf;
 %! x = 0:0.1:10;
-%! plot (x, sin(x), ";sin(x);")
-%! hold all
-%! plot (x, cos(x), ";cos(x);")
-%! hold off
-%! legend ({"sin(x)", "cos(x)"}, "location", "northeastoutside")
+%! plot (x, sin (x), ';sin (x);');
+%! hold all;
+%! plot (x, cos (x), ';cos (x);');
+%! hold off;
+%! legend ({'sin (x)', 'cos (x)'}, 'location', 'northeastoutside');
 
 %!demo
-%! clf
+%! clf;
 %! x = 0:10;
 %! plot (x, rand (11));
-%! xlabel ("Indices")
-%! ylabel ("Random Values")
-%! title ("Legend ""off"" should delete the legend")
-%! legend (cellstr (num2str ((1:10)')), "location", "northeastoutside")
-%! legend off
-%! axis ([0, 10, 0 1])
+%! xlabel ('Indices');
+%! ylabel ('Random Values');
+%! title ('Legend ''off'' should delete the legend');
+%! legend (cellstr (num2str ((1:10)')), 'location', 'northeastoutside');
+%! legend off;
+%! axis ([0, 10, 0 1]);
+
+%!demo
+%! clf;
+%! x = (1:5)';
+%! subplot (2,2,1);
+%!  plot (x, rand (numel (x)));
+%!  legend (cellstr (num2str (x)), 'location', 'northwestoutside');
+%! subplot (2,2,2);
+%!  plot (x, rand (numel (x)));
+%!  legend (cellstr (num2str (x)), 'location', 'northeastoutside');
+%! subplot (2,2,3);
+%!  plot (x, rand (numel (x)));
+%!  legend (cellstr (num2str (x)), 'location', 'southwestoutside');
+%! subplot (2,2,4);
+%!  plot (x, rand (numel (x)));
+%!  legend (cellstr (num2str (x)), 'location', 'southeastoutside');
 
 %!demo
-%! clf
-%! x = 1:5;
-%! 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
+%! clf;
+%! plot (rand (2));
+%! title ('Warn of extra labels');
+%! legend ('Hello', 'World', 'interpreter', 'foobar');
+
+%!demo
+%! clf;
+%! plot (rand (2));
+%! title ('Turn off TeX interpreter');
+%! h = legend ('Hello_World', 'foo^bar');
+%! set (h, 'interpreter', 'none');
 
 %!demo
-%! clf
-%! plot (rand (2))
-%! title ("Warn of extra labels")
-%! legend ("Hello", "World", "interpreter", "foobar")
+%! x = 0:10;
+%! y1 = rand (size (x));
+%! y2 = rand (size (x));
+%! [ax, h1, h2] = plotyy (x, y1, x, y2);
+%! legend ([h1, h2], {'Blue', 'Green'}, 'location', 'south');
 
 %!demo
-%! clf
-%! plot (rand (2))
-%! title ("Turn off TeX interpreter")
-%! h = legend ("Hello_World", "foo^bar");
-%! set (h, "interpreter", "none")
+%! x = 0:10;
+%! y1 = rand (size (x));
+%! y2 = rand (size (x));
+%! [ax, h1, h2] = plotyy (x, y1, x, y2);
+%! legend ({'Blue', 'Green'}, 'location', 'south');
 
+%!demo
+%! x = 0:10;
+%! y1 = rand (size (x));
+%! y2 = rand (size (x));
+%! [ax, h1, h2] = plotyy (x, y1, x, y2);
+%! legend ('Blue', 'Green', 'location', 'south');
+
--- a/scripts/plot/line.m
+++ b/scripts/plot/line.m
@@ -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
@@ -57,3 +72,4 @@
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
+
--- a/scripts/plot/loglog.m
+++ b/scripts/plot/loglog.m
@@ -38,7 +38,7 @@
   [h, varargin, nargs] = __plt_get_axis_arg__ ("loglog", varargin{:});
 
   if (nargs < 1)
-    print_usage();
+    print_usage ();
   endif
 
   oldh = gca ();
@@ -62,37 +62,38 @@
 
 endfunction
 
+
 %!demo
-%! clf ();
+%! clf;
 %! t = 1:0.01:10;
 %! x = sort ((t .* (1 + rand (size (t)))) .^ 2);
-%! y = ((t .* (1 + rand (size (t)))) .^ 2);
+%! y = (t .* (1 + rand (size (t)))) .^ 2;
 %! loglog (x, y);
 
 %!demo
-%! clf ();
+%! clf;
 %! a = logspace (-5, 1, 10);
 %! b =-logspace (-5, 1, 10);
 %!
-%! subplot (1, 2, 1)
-%! loglog (a, b)
-%! xlabel ('loglog (a, b)')
+%! subplot (1,2,1);
+%!  loglog (a, b);
+%!  xlabel ('loglog (a, b)');
 %!
-%! subplot (1, 2, 2)
-%! loglog (a, abs (b))
-%! set (gca, 'ydir', 'reverse')
-%! xlabel ('loglog (a, abs (b))')
+%! subplot (1,2,2);
+%!  loglog (a, abs (b));
+%!  set (gca, 'ydir', 'reverse');
+%!  xlabel ('loglog (a, abs (b))');
 
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
 %!   a = logspace (-5, 1, 10);
 %!   b = logspace (-5, 1, 10);
-%!   loglog (a, b)
+%!   loglog (a, b);
 %!   assert (get (gca, "yscale"), "log");
 %!   assert (get (gca, "xscale"), "log");
 %! unwind_protect_cleanup
-%! close (hf);
+%!   close (hf);
 %! end_unwind_protect
 
 %!test
@@ -100,10 +101,10 @@
 %! unwind_protect
 %!   a = logspace (-5, 1, 10);
 %!   b =-logspace (-5, 1, 10);
-%!   loglog (a, b)
-%!   axis tight
+%!   loglog (a, b);
+%!   axis tight;
 %!   assert (all (get (gca, "ytick") < 0));
 %! unwind_protect_cleanup
-%! close (hf);
+%!   close (hf);
 %! end_unwind_protect
 
--- a/scripts/plot/loglogerr.m
+++ b/scripts/plot/loglogerr.m
@@ -60,12 +60,13 @@
 
 endfunction
 
+
 %!demo
-%! clf
-%! x = exp (log(0.01):0.2:log(10));
+%! clf;
+%! x = exp (log (0.01):0.2:log (10));
 %! y = wblpdf (x, 3, 2);
 %! eyu = 2*rand (size (y)) .* y;
 %! eyl = 0.5*rand (size (y)) .* y;
-%! loglogerr (x, y, eyl, eyu, "#~x-")
-%! xlim (x([1, end]))
+%! loglogerr (x, y, eyl, eyu, '#~x-');
+%! xlim (x([1, end]));
 
--- a/scripts/plot/mesh.m
+++ b/scripts/plot/mesh.m
@@ -63,5 +63,25 @@
 endfunction
 
 
-%% FIXME: Need demo or test for function
+%!demo
+%! clf ();
+%! x = logspace (0,1,11);
+%! z = x'*x;
+%! mesh (x, x, z, z.^2);
+%! xlabel xlabel
+%! ylabel ylabel
+%! zlabel "linear scale"
 
+%!demo
+%! clf ();
+%! x = logspace (0,1,11);
+%! z = x'*x;
+%! mesh (x, x, z, z.^2);
+%! set (gca, "zscale", "log")
+%! xlabel xlabel
+%! ylabel ylabel
+%! zlabel "log scale"
+%! if (strcmp (get (gcf, "__graphics_toolkit__"), "gnuplot"))
+%!   title ({"Gnuplot: mesh color is wrong", "This a Gnuplot bug"})
+%! endif
+
--- a/scripts/plot/meshgrid.m
+++ b/scripts/plot/meshgrid.m
@@ -71,6 +71,7 @@
 
 endfunction
 
+
 %!test
 %! x = 1:2;
 %! y = 1:3;
@@ -100,4 +101,5 @@
 %! assert (ndims (XX1), 2);
 %! assert (size (XX1), [3, 3]);
 %! assert (XX1, XX2);
-%! assert (YY1, YY2);
\ No newline at end of file
+%! assert (YY1, YY2);
+
--- a/scripts/plot/meshz.m
+++ b/scripts/plot/meshz.m
@@ -68,10 +68,10 @@
          y(end, 1), y(end, :), y(end, end)];
   endif
 
-  zref = min(z(isfinite(z)));
-  z = [zref .* ones(1, size(z, 2) + 2);
-       zref .* ones(size(z, 1), 1), z, zref .* ones(size(z, 1), 1);
-       zref.* ones(1, size(z, 2) + 2)];
+  zref = min (z(isfinite (z)));
+  z = [zref .* ones(1, columns(z) + 2);
+       zref .* ones(rows(z), 1), z, zref .* ones(rows(z), 1);
+       zref.* ones(1, columns(z) + 2)];
 
   oldh = gca ();
   unwind_protect
--- a/scripts/plot/module.mk
+++ b/scripts/plot/module.mk
@@ -80,6 +80,7 @@
   plot/contour3.m \
   plot/contourc.m \
   plot/contourf.m \
+  plot/copyobj.m \
   plot/cylinder.m \
   plot/daspect.m \
   plot/diffuse.m \
@@ -98,18 +99,21 @@
   plot/figure.m \
   plot/fill.m \
   plot/findall.m \
+  plot/findfigs.m \
   plot/findobj.m \
   plot/fplot.m \
   plot/gca.m \
   plot/gcbf.m \
   plot/gcbo.m \
   plot/gcf.m \
+  plot/gco.m \
   plot/ginput.m \
   plot/graphics_toolkit.m \
   plot/grid.m \
   plot/gtext.m \
   plot/guidata.m \
   plot/guihandles.m \
+  plot/hdl2struct.m \
   plot/hggroup.m \
   plot/hidden.m \
   plot/hist.m \
@@ -162,20 +166,22 @@
   plot/semilogyerr.m \
   plot/shading.m \
   plot/shg.m \
+  plot/shrinkfaces.m \
   plot/slice.m \
   plot/sombrero.m \
   plot/specular.m \
   plot/sphere.m \
-  plot/spinmap.m \
   plot/stairs.m \
   plot/stem.m \
   plot/stem3.m \
+  plot/struct2hdl.m \
   plot/subplot.m \
   plot/surf.m \
   plot/surface.m \
   plot/surfc.m \
   plot/surfl.m \
   plot/surfnorm.m \
+  plot/tetramesh.m \
   plot/text.m \
   plot/title.m \
   plot/trimesh.m \
--- a/scripts/plot/ndgrid.m
+++ b/scripts/plot/ndgrid.m
@@ -20,13 +20,13 @@
 ## @deftypefn  {Function File} {[@var{y1}, @var{y2}, @dots{}, @var{y}n] =} ndgrid (@var{x1}, @var{x2}, @dots{}, @var{x}n)
 ## @deftypefnx {Function File} {[@var{y1}, @var{y2}, @dots{}, @var{y}n] =} ndgrid (@var{x})
 ## Given n vectors @var{x1}, @dots{} @var{x}n, @code{ndgrid} returns
-## n arrays of dimension n. The elements of the i-th output argument
+## n arrays of dimension n.  The elements of the i-th output argument
 ## contains the elements of the vector @var{x}i repeated over all
 ## dimensions different from the i-th dimension.  Calling ndgrid with
 ## only one input argument @var{x} is equivalent of calling ndgrid with
 ## all n input arguments equal to @var{x}:
 ##
-## [@var{y1}, @var{y2}, @dots{},  @var{y}n] = ndgrid (@var{x}, @dots{}, @var{x})
+## [@var{y1}, @var{y2}, @dots{}, @var{y}n] = ndgrid (@var{x}, @dots{}, @var{x})
 ## @seealso{meshgrid}
 ## @end deftypefn
 
@@ -70,6 +70,7 @@
 
 endfunction
 
+
 %!test
 %! x = 1:2;
 %! y = 1:3;
@@ -95,3 +96,4 @@
 %! assert (XX2(end) * YY2(end), x(end) * y(end));
 %! assert (XX1, XX2.');
 %! assert (YY1, YY2.');
+
--- a/scripts/plot/newplot.m
+++ b/scripts/plot/newplot.m
@@ -65,6 +65,7 @@
 
 endfunction
 
+
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
@@ -74,3 +75,4 @@
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
+
--- a/scripts/plot/orient.m
+++ b/scripts/plot/orient.m
@@ -70,40 +70,42 @@
 
 endfunction
 
+
 %!shared papersize, paperposition, tallpaperposition, hfig
-%!  papersize = [8.5, 11];
-%!  paperposition = [0.25, 2.5, 8, 6];
-%!  tallpaperposition = [0.25, 0.25, (papersize-0.5)];
-%!  hfig = figure ();
-%!  set (hfig, "visible", "off")
-%!  set (hfig, "paperorientation", "portrait")
-%!  set (hfig, "papersize", papersize)
-%!  set (hfig, "paperposition", paperposition)
+%! papersize = [8.5, 11];
+%! paperposition = [0.25, 2.5, 8, 6];
+%! tallpaperposition = [0.25, 0.25, (papersize-0.5)];
+%! hfig = figure ();
+%! set (hfig, "visible", "off");
+%! set (hfig, "paperorientation", "portrait");
+%! set (hfig, "papersize", papersize);
+%! set (hfig, "paperposition", paperposition);
 %!test
-%!  orient portrait
-%!  assert (orient, "portrait") # default
-%!  assert (get (hfig, "papersize"), papersize)
-%!  assert (get (hfig, "paperposition"), paperposition)
+%! orient portrait;
+%! assert (orient, "portrait")   # default
+%! assert (get (hfig, "papersize"), papersize);
+%! assert (get (hfig, "paperposition"), paperposition);
 %!test
-%!  orient landscape
-%!  assert (orient,"landscape") # change to landscape
-%!  assert (get (hfig, "papersize"), papersize([2, 1]))
-%!  assert (get (hfig, "paperposition"), paperposition([2, 1, 4, 3]))
+%! orient landscape;
+%! assert (orient,"landscape")   # change to landscape
+%! assert (get (hfig, "papersize"), papersize([2, 1]));
+%! assert (get (hfig, "paperposition"), paperposition([2, 1, 4, 3]));
 %!test
-%!  orient portrait # change back to portrait
-%!  assert (orient, "portrait")
-%!  assert (get (hfig, "papersize"), papersize)
-%!  assert (get (hfig, "paperposition"), paperposition)
+%! orient portrait   # change back to portrait
+%! assert (orient, "portrait");
+%! assert (get (hfig, "papersize"), papersize);
+%! assert (get (hfig, "paperposition"), paperposition);
 %!test
-%!  orient landscape
-%!  orient tall
-%!  assert (orient, "portrait")
-%!  assert (get (hfig, "papersize"), papersize)
-%!  assert (get (hfig, "paperposition"), tallpaperposition)
+%! orient landscape;
+%! orient tall;
+%! assert (orient, "portrait");
+%! assert (get (hfig, "papersize"), papersize);
+%! assert (get (hfig, "paperposition"), tallpaperposition);
 %!fail ("orient ('nobody')", "unknown ORIENTATION")
 %!test
-%!  orient portrait # errors don't change the state
-%!  assert (orient, "portrait")
-%!  assert (get (hfig, "papersize"), papersize)
-%!  assert (get (hfig, "paperposition"), tallpaperposition)
-%!  close (hfig)
+%! orient portrait   # errors don't change the state
+%! assert (orient, "portrait");
+%! assert (get (hfig, "papersize"), papersize);
+%! assert (get (hfig, "paperposition"), tallpaperposition);
+%! close (hfig);
+
--- a/scripts/plot/pareto.m
+++ b/scripts/plot/pareto.m
@@ -74,20 +74,20 @@
       endif
     endif
   else
-    y = cellfun ("int2str", num2cell (1 : numel(x)),
+    y = cellfun ("int2str", num2cell (1 : numel (x)),
                  "uniformoutput", false);
   endif
 
   [x, idx] = sort (x, "descend");
   y = y (idx);
   cdf = cumsum (x);
-  maxcdf = max(cdf);
+  maxcdf = max (cdf);
   cdf = cdf ./ maxcdf;
   cdf95 = cdf - 0.95;
-  idx95 = find(sign(cdf95(1:end-1)) != sign(cdf95(2:end)))(1);
+  idx95 = find (sign (cdf95(1:end-1)) != sign (cdf95(2:end)))(1);
 
   [ax, hbar, hline] = plotyy (1 : idx95, x (1 : idx95),
-                              1 : length(cdf), 100 .* cdf,
+                              1 : length (cdf), 100 .* cdf,
                               @bar, @plot);
 
   axis (ax(1), [1 - 0.6, idx95 + 0.6, 0, maxcdf]);
@@ -105,16 +105,16 @@
 
 
 %!demo
-%! clf
+%! clf;
 %! colormap (jet (64));
-%! Cheese = {"Cheddar", "Swiss", "Camembert", "Munster", "Stilton", "Blue"};
+%! Cheese = {'Cheddar', 'Swiss', 'Camembert', 'Munster', 'Stilton', 'Blue'};
 %! Sold = [105, 30, 70, 10, 15, 20];
 %! pareto (Sold, Cheese);
 
 %!demo
-%! clf
-%! % Suppose that we want establish which products makes 80 % of turnover.
-%! Codes = {"AB4","BD7","CF8","CC5","AD11","BB5","BB3","AD8","DF3","DE7"};
+%! clf;
+%! % Suppose that we want establish which products makes 80% of turnover.
+%! Codes = {'AB4','BD7','CF8','CC5','AD11','BB5','BB3','AD8','DF3','DE7'};
 %! Value = [2.35 7.9 2.45 1.1 0.15 13.45 5.4 2.05 0.85  1.65]';
 %! SoldUnits = [54723 41114 16939 1576091 168000 687197 120222 168195, ...
 %!              1084118 55576]';
--- a/scripts/plot/patch.m
+++ b/scripts/plot/patch.m
@@ -21,7 +21,7 @@
 ## @deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{c})
 ## @deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{z}, @var{c})
 ## @deftypefnx {Function File} {} patch (@var{fv})
-## @deftypefnx {Function File} {} patch ('Faces', @var{f}, 'Vertices', @var{v}, @dots{})
+## @deftypefnx {Function File} {} patch ("Faces", @var{f}, "Vertices", @var{v}, @dots{})
 ## @deftypefnx {Function File} {} patch (@dots{}, @var{prop}, @var{val})
 ## @deftypefnx {Function File} {} patch (@var{h}, @dots{})
 ## @deftypefnx {Function File} {@var{h} =} patch (@dots{})
@@ -59,69 +59,70 @@
 
 endfunction
 
+
 %!demo
-%! ## Patches with same number of vertices
-%! clf
-%! t1 = (1/16:1/8:1)'*2*pi;
-%! t2 = ((1/16:1/8:1)' + 1/32)*2*pi;
+%! %% Patches with same number of vertices
+%! clf;
+%! t1 = (1/16:1/8:1)' * 2*pi;
+%! t2 = ((1/16:1/8:1)' + 1/32) * 2*pi;
 %! x1 = sin (t1) - 0.8;
 %! y1 = cos (t1);
 %! x2 = sin (t2) + 0.8;
 %! y2 = cos (t2);
-%! patch([x1,x2],[y1,y2],'r');
+%! patch ([x1,x2], [y1,y2], 'r');
 
 %!demo
-%! ## Unclosed patch
-%! clf
-%! t1 = (1/16:1/8:1)'*2*pi;
-%! t2 = ((1/16:1/16:1)' + 1/32)*2*pi;
+%! %% Unclosed patch
+%! clf;
+%! t1 = (1/16:1/8:1)' * 2*pi;
+%! t2 = ((1/16:1/16:1)' + 1/32) * 2*pi;
 %! x1 = sin (t1) - 0.8;
 %! y1 = cos (t1);
 %! x2 = sin (t2) + 0.8;
 %! y2 = cos (t2);
-%! patch([[x1;NaN(8,1)],x2],[[y1;NaN(8,1)],y2],'r');
+%! patch ([[x1;NaN(8,1)],x2], [[y1;NaN(8,1)],y2], 'r');
 
 %!demo
-%! ## Specify vertices and faces separately
-%! clf
-%! t1 = (1/16:1/8:1)'*2*pi;
-%! t2 = ((1/16:1/16:1)' + 1/32)*2*pi;
+%! %% Specify vertices and faces separately
+%! clf;
+%! t1 = (1/16:1/8:1)' * 2*pi;
+%! t2 = ((1/16:1/16:1)' + 1/32) * 2*pi;
 %! x1 = sin (t1) - 0.8;
 %! y1 = cos (t1);
 %! x2 = sin (t2) + 0.8;
 %! y2 = cos (t2);
 %! vert = [x1, y1; x2, y2];
 %! fac = [1:8,NaN(1,8);9:24];
-%! patch('Faces',fac,'Vertices',vert,'FaceColor','r');
+%! patch ('Faces',fac, 'Vertices',vert, 'FaceColor','r');
 
 %!demo
-%! ## Specify vertices and faces separately
-%! clf
-%! t1 = (1/16:1/8:1)'*2*pi;
-%! t2 = ((1/16:1/16:1)' + 1/32)*2*pi;
+%! %% Specify vertices and faces separately
+%! clf;
+%! t1 = (1/16:1/8:1)' * 2*pi;
+%! t2 = ((1/16:1/16:1)' + 1/32) * 2*pi;
 %! x1 = sin (t1) - 0.8;
 %! y1 = cos (t1);
 %! x2 = sin (t2) + 0.8;
 %! y2 = cos (t2);
 %! vert = [x1, y1; x2, y2];
 %! fac = [1:8,NaN(1,8);9:24];
-%! patch('Faces',fac,'Vertices',vert,'FaceVertexCData', [0, 1, 0; 0, 0, 1]);
+%! patch ('Faces',fac, 'Vertices',vert, 'FaceVertexCData',[0, 1, 0; 0, 0, 1]);
 
 %!demo
-%! ## Property change on multiple patches
-%! clf
-%! t1 = (1/16:1/8:1)'*2*pi;
-%! t2 = ((1/16:1/8:1)' + 1/32)*2*pi;
+%! %% Property change on multiple patches
+%! clf;
+%! t1 = (1/16:1/8:1)' * 2*pi;
+%! t2 = ((1/16:1/8:1)' + 1/32) * 2*pi;
 %! x1 = sin (t1) - 0.8;
 %! y1 = cos (t1);
 %! x2 = sin (t2) + 0.8;
 %! y2 = cos (t2);
-%! h = patch([x1,x2],[y1,y2],cat (3,[0,0],[1,0],[0,1]));
+%! h = patch ([x1,x2], [y1,y2], cat (3, [0,0],[1,0],[0,1]));
 %! pause (1);
 %! set (h, 'FaceColor', 'r');
 
 %!demo
-%! clf
+%! clf;
 %! vertices = [0, 0, 0;
 %!             1, 0, 0;
 %!             1, 1, 0;
@@ -132,11 +133,11 @@
 %!          3, 4, 5;
 %!          4, 1, 5];
 %! patch ('Vertices', vertices, 'Faces', faces, ...
-%!        'FaceVertexCData', jet(4), 'FaceColor', 'flat');
+%!        'FaceVertexCData', jet (4), 'FaceColor', 'flat');
 %! view (-37.5, 30);
 
 %!demo
-%! clf
+%! clf;
 %! vertices = [0, 0, 0;
 %!             1, 0, 0;
 %!             1, 1, 0;
@@ -146,64 +147,64 @@
 %!          2, 3, 5;
 %!          3, 4, 5;
 %!          4, 1, 5];
-%! patch ('Vertices', vertices, 'Faces', faces, ...
-%!        'FaceVertexCData', jet(5), 'FaceColor', 'interp');
+%! patch  ('Vertices', vertices, 'Faces', faces, ...
+%!        'FaceVertexCData', jet (5), 'FaceColor', 'interp');
 %! view (-37.5, 30);
 
 %!demo
-%! clf
-%! colormap (jet);
+%! clf;
+%! colormap (jet (64));
 %! x = [0 1 1 0];
 %! y = [0 0 1 1];
-%! subplot (2, 1, 1);
-%! title ("Blue, Light-Green, and Red Horizontal Bars");
-%! patch (x, y + 0, 1);
-%! patch (x, y + 1, 2);
-%! patch (x, y + 2, 3);
-%! subplot (2, 1, 2);
-%! title ("Blue, Light-Green, and Red Vertical Bars");
-%! patch (x + 0, y, 1 * ones (size (x)));
-%! patch (x + 1, y, 2 * ones (size (x)));
-%! patch (x + 2, y, 3 * ones (size (x)));
-
-%!demo
-%! clf
-%! colormap (jet);
-%! x = [0 1 1 0];
-%! y = [0 0 1 1];
-%! subplot (2, 1, 1);
-%! title ("Blue horizontal bars: Dark to Light");
-%! patch (x, y + 0, 1, "cdatamapping", "direct");
-%! patch (x, y + 1, 9, "cdatamapping", "direct");
-%! patch (x, y + 2, 17, "cdatamapping", "direct");
-%! subplot (2, 1, 2);
-%! title ("Blue vertical bars: Dark to Light")
-%! patch (x + 0, y, 1 * ones (size (x)), "cdatamapping", "direct");
-%! patch (x + 1, y, 9 * ones (size (x)), "cdatamapping", "direct");
-%! patch (x + 2, y, 17 * ones (size (x)), "cdatamapping", "direct");
+%! subplot (2,1,1);
+%!  title ('Blue, Light-Green, and Red Horizontal Bars');
+%!  patch (x, y + 0, 1);
+%!  patch (x, y + 1, 2);
+%!  patch (x, y + 2, 3);
+%! subplot (2,1,2);
+%!  title ('Blue, Light-Green, and Red Vertical Bars');
+%!  patch (x + 0, y, 1 * ones (size (x)));
+%!  patch (x + 1, y, 2 * ones (size (x)));
+%!  patch (x + 2, y, 3 * ones (size (x)));
 
 %!demo
 %! clf;
-%! colormap (jet);
-%! x = [ 0 0; 1 1; 1 0 ];
-%! y = [ 0 0; 0 1; 1 1 ];
-%! p = patch (x, y, "facecolor", "b");
-%! title ("Two blue triangles");
-%! set (p, "cdatamapping", "direct", "facecolor", "flat", "cdata", [1 32]);
-%! title ("Direct mapping of colors: Light-Green UL and Blue LR triangles");
+%! colormap (jet (64));
+%! x = [0 1 1 0];
+%! y = [0 0 1 1];
+%! subplot (2,1,1);
+%!  title ('Blue horizontal bars: Dark to Light');
+%!  patch (x, y + 0, 1, 'cdatamapping', 'direct');
+%!  patch (x, y + 1, 9, 'cdatamapping', 'direct');
+%!  patch (x, y + 2, 17, 'cdatamapping', 'direct');
+%! subplot (2,1,2);
+%!  title ('Blue vertical bars: Dark to Light');
+%!  patch (x + 0, y, 1 * ones (size (x)), 'cdatamapping', 'direct');
+%!  patch (x + 1, y, 9 * ones (size (x)), 'cdatamapping', 'direct');
+%!  patch (x + 2, y, 17 * ones (size (x)), 'cdatamapping', 'direct');
 
 %!demo
 %! clf;
-%! colormap (jet);
+%! colormap (jet (64));
+%! x = [ 0 0; 1 1; 1 0 ];
+%! y = [ 0 0; 0 1; 1 1 ];
+%! p = patch (x, y, 'facecolor', 'b');
+%! title ('Two blue triangles');
+%! set (p, 'cdatamapping', 'direct', 'facecolor', 'flat', 'cdata', [1 32]);
+%! title ('Direct mapping of colors: Light-Green UL and Blue LR triangles');
+
+%!demo
+%! clf;
+%! colormap (jet (64));
 %! x = [ 0 0; 1 1; 1 0 ];
 %! y = [ 0 0; 0 1; 1 1 ];
 %! p = patch (x, y, [1 32]);
-%! title ("Autoscaling of colors: Red UL and Blue LR triangles");
+%! title ('Autoscaling of colors: Red UL and Blue LR triangles');
 
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
-%!   h = patch;
+%!   h = patch ();
 %!   assert (findobj (hf, "type", "patch"), h);
 %!   assert (get (h, "xdata"), [0; 1; 0], eps);
 %!   assert (get (h, "ydata"), [1; 1; 0], eps);
--- a/scripts/plot/pbaspect.m
+++ b/scripts/plot/pbaspect.m
@@ -89,25 +89,26 @@
 
 endfunction
 
+
 %!demo
+%! clf;
 %! x = 0:0.01:4;
-%! clf
-%! plot (x, cos (x), x, sin (x))
-%! pbaspect ([1 1 1])
-%! title ("plot box should be square")
+%! plot (x,cos(x), x,sin(x));
+%! pbaspect ([1 1 1]);
+%! title ('plot box is square');
 
 %!demo
-%! x = 0:0.01:4;
-%! clf
-%! plot (x, cos (x), x, sin (x))
-%! pbaspect ([2 1 1])
-%! title ("plot box aspect ratio should be 2x1")
+%! clf;
+%! x = 0:0.01:4;;
+%! plot (x,cos(x), x,sin(x));
+%! pbaspect ([2 1 1]);
+%! title ('plot box aspect ratio is 2x1');
 
 %!demo
+%! clf;
 %! x = 0:0.01:4;
-%! clf
-%! plot (x, cos (x), x, sin (x))
-%! daspect ([1 1 1])
-%! pbaspect ([2 1 1])
-%! title ("plot box should be 2x1, and axes [0 4 -1 1]")
+%! plot (x,cos(x), x,sin(x));
+%! daspect ([1 1 1]);
+%! pbaspect ([2 1 1]);
+%! title ('plot box is 2x1, and axes [0 4 -1 1]');
 
--- a/scripts/plot/pcolor.m
+++ b/scripts/plot/pcolor.m
@@ -55,7 +55,7 @@
 
   if (nargin == 1)
     c = x;
-    [nr, nc] = size(c);
+    [nr, nc] = size (c);
     z = zeros (nr, nc);
     [x, y] = meshgrid (1:nc, 1:nr);
   elseif (nargin == 3)
@@ -81,14 +81,18 @@
 
 endfunction
 
+
 %!demo
-%! clf
-%! [~,~,Z]=peaks;
-%! pcolor(Z);
+%! clf;
+%! colormap ('default');
+%! [~,~,Z] = peaks ();
+%! pcolor (Z);
 
 %!demo
-%! clf
-%! [X,Y,Z]=sombrero;
-%! [Fx,Fy] = gradient(Z);
-%! pcolor(X,Y,Fx+Fy);
+%! clf;
+%! colormap ('default');
+%! [X,Y,Z] = sombrero ();
+%! [Fx,Fy] = gradient (Z);
+%! pcolor (X,Y,Fx+Fy);
 %! shading interp;
+
--- a/scripts/plot/peaks.m
+++ b/scripts/plot/peaks.m
@@ -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,9 +69,9 @@
     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) \
-      - 1 / 3 * exp(- (X + 1) .^ 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)
     surf (x, y, Z);
--- a/scripts/plot/pie.m
+++ b/scripts/plot/pie.m
@@ -29,7 +29,7 @@
 ## size of the values of @var{x}.
 ##
 ## The variable @var{explode} is a vector of the same length as @var{x} that
-## if non zero 'explodes' the slice from the pie chart.
+## if non zero "explodes" the slice from the pie chart.
 ##
 ## If given @var{labels} is a cell array of strings of the same length as
 ## @var{x}, giving the labels of each of the slices of the pie chart.
@@ -68,20 +68,20 @@
 
 
 %!demo
-%! clf
+%! clf;
 %! pie ([3, 2, 1], [0, 0, 1]);
 %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]);
 
 %!demo
-%! clf
-%! pie ([3, 2, 1], [0, 0, 1], {"Cheddar", "Swiss", "Camembert"});
+%! clf;
+%! pie ([3, 2, 1], [0, 0, 1], {'Cheddar', 'Swiss', 'Camembert'});
 %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]);
 %! axis ([-2,2,-2,2]);
 
 %!demo
-%! clf
-%! pie ([0.17, 0.34, 0.41], {"Cheddar", "Swiss", "Camembert"});
+%! clf;
+%! pie ([0.17, 0.34, 0.41], {'Cheddar', 'Swiss', 'Camembert'});
 %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]);
 %! axis ([-2,2,-2,2]);
-%! title ("missing slice");
+%! title ('missing slice');
 
--- a/scripts/plot/pie3.m
+++ b/scripts/plot/pie3.m
@@ -30,7 +30,7 @@
 ## size of the values of @var{x}.
 ##
 ## The variable @var{explode} is a vector of the same length as @var{x} that
-## if non zero 'explodes' the slice from the pie chart.
+## if non zero "explodes" the slice from the pie chart.
 ##
 ## If given @var{labels} is a cell array of strings of the same length as
 ## @var{x}, giving the labels of each of the slices of the pie chart.
@@ -69,20 +69,20 @@
 
 
 %!demo
-%! clf
+%! clf;
 %! pie3 ([5:-1:1], [0, 0, 1, 0, 0]);
 %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]);
 
 %!demo
-%! clf
-%! pie3 ([3, 2, 1], [0, 0, 1], {"Cheddar", "Swiss", "Camembert"});
+%! clf;
+%! pie3 ([3, 2, 1], [0, 0, 1], {'Cheddar', 'Swiss', 'Camembert'});
 %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]);
 %! axis ([-2,2,-2,2]);
 
 %!demo
-%! clf
-%! pie3 ([0.17, 0.34, 0.41], {"Cheddar", "Swiss", "Camembert"});
+%! clf;
+%! pie3 ([0.17, 0.34, 0.41], {'Cheddar', 'Swiss', 'Camembert'});
 %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]);
 %! axis ([-2,2,-2,2]);
-%! title ("missing slice");
+%! title ('missing slice');
 
--- a/scripts/plot/plot.m
+++ b/scripts/plot/plot.m
@@ -186,7 +186,7 @@
   [h, varargin, nargs] = __plt_get_axis_arg__ ("plot", varargin{:});
 
   if (nargs < 1)
-    print_usage();
+    print_usage ();
   endif
 
   oldh = gca ();
--- a/scripts/plot/plot3.m
+++ b/scripts/plot/plot3.m
@@ -121,10 +121,10 @@
             y = real (x);
             y_set = 1;
             z_set = 1;
-            if (rows(x) > 1)
-              x = repmat ((1:rows(x))', 1, columns(x));
+            if (rows (x) > 1)
+              x = repmat ((1:rows (x))', 1, columns (x));
             else
-              x = 1:columns(x);
+              x = 1:columns (x);
             endif
           endif
         else
@@ -164,7 +164,7 @@
         elseif (length (x) == rows (z) && length (y) == columns (z))
           [x, y] = meshgrid (x, y);
         else
-          error ("plot3: [length(x), length(y)] must match size(z)");
+          error ("plot3: [length(x), length(y)] must match size (z)");
         endif
       endif
 
@@ -218,7 +218,7 @@
         elseif (length (x) == rows (z) && length (y) == columns (z))
           [x, y] = meshgrid (x, y);
         else
-          error ("plot3: [length(x), length(y)] must match size(z)");
+          error ("plot3: [length(x), length(y)] must match size (z)");
         endif
       endif
 
@@ -278,9 +278,9 @@
       y_set = 1;
       z_set = 1;
       if (rows (x) > 1)
-        x = repmat ((1:rows (x))', 1, columns(x));
+        x = repmat ((1:rows (x))', 1, columns (x));
       else
-        x = 1:columns(x);
+        x = 1:columns (x);
       endif
     endif
 
@@ -292,7 +292,7 @@
       elseif (length (x) == rows (z) && length (y) == columns (z))
         [x, y] = meshgrid (x, y);
       else
-        error ("plot3: [length(x), length(y)] must match size(z)");
+        error ("plot3: [length(x), length(y)] must match size (z)");
       endif
     endif
 
@@ -327,7 +327,7 @@
   endif
 
   if (!isempty (hlgnd))
-    legend (gca(), hlgnd, tlgnd);
+    legend (gca (), hlgnd, tlgnd);
   endif
 
   set (gca (), "view", [-37.5, 30]);
@@ -338,8 +338,10 @@
 
 endfunction
 
+
 %!demo
-%! clf
+%! clf;
 %! z = [0:0.05:5];
-%! plot3 (cos(2*pi*z), sin(2*pi*z), z, ";helix;");
-%! plot3 (z, exp(2i*pi*z), ";complex sinusoid;");
+%! plot3 (cos (2*pi*z), sin (2*pi*z), z, ';helix;');
+%! plot3 (z, exp (2i*pi*z), ';complex sinusoid;');
+
--- a/scripts/plot/plotmatrix.m
+++ b/scripts/plot/plotmatrix.m
@@ -94,8 +94,8 @@
 endfunction
 
 %!demo
-%! clf
-%! plotmatrix (randn (100, 3), 'g+')
+%! clf;
+%! plotmatrix (randn (100, 3), 'g+');
 
 function plotmatrixdelete (h, d, ax)
   for i = 1 : numel (ax)
@@ -145,7 +145,7 @@
     returm;
   endif
 
-  if (rows(X) != rows(Y))
+  if (rows (X) != rows (Y))
     error ("plotmatrix: dimension mismatch in the arguments");
   endif
 
--- a/scripts/plot/plotyy.m
+++ b/scripts/plot/plotyy.m
@@ -56,8 +56,8 @@
 function [Ax, H1, H2] = plotyy (varargin)
 
   ## Don't use __plt_get_axis_arg__ here as ax is a two vector for plotyy
-  if (nargin > 1 && length (varargin{1}) == 2 && ishandle(varargin{1}(1))
-      && ishandle(varargin{1}(2))
+  if (nargin > 1 && length (varargin{1}) == 2 && ishandle (varargin{1}(1))
+      && ishandle (varargin{1}(2))
       && all (floor (varargin{1}) != varargin{1}))
     obj1 = get (varargin{1}(1));
     obj2 = get (varargin{1}(2));
@@ -91,6 +91,7 @@
       ax = ax(1:2);
     elseif (length (ax) == 1)
       ax(2) = axes ();
+      set (ax(2), "nextplot", get (ax(1), "nextplot"))
     elseif (isempty (ax))
       ax(1) = axes ();
       ax(2) = axes ();
@@ -110,7 +111,7 @@
     [ax, h1, h2] = __plotyy__ (ax, varargin{:});
   unwind_protect_cleanup
     ## Only change back to the old axis if we didn't delete it
-    if (ishandle(oldh) && strcmp (get (oldh, "type"), "axes"))
+    if (ishandle (oldh) && strcmp (get (oldh, "type"), "axes"))
       axes (oldh);
     endif
   end_unwind_protect
@@ -137,7 +138,7 @@
 
   xlim = [min([x1(:); x2(:)]), max([x1(:); x2(:)])];
 
-  if (ishandle(ax(1)) && strcmp (get (ax(1), "type"), "axes"))
+  if (ishandle (ax(1)) && strcmp (get (ax(1), "type"), "axes"))
     axes (ax(1));
   else
     ax(1) = axes ();
@@ -152,10 +153,11 @@
   cf = gcf ();
   set (cf, "nextplot", "add");
 
-  if (ishandle(ax(2)) && strcmp (get (ax(2), "type"), "axes"))
+  if (ishandle (ax(2)) && strcmp (get (ax(2), "type"), "axes"))
     axes (ax(2));
   else
     ax(2) = axes ();
+    set (ax(2), "nextplot", get (ax(1), "nextplot"))
   endif
   newplot ();
 
@@ -172,7 +174,6 @@
   set (ax(2), "yaxislocation", "right");
   set (ax(2), "ycolor", getcolor (h2(1)));
 
-
   if (strcmp (get(ax(1), "activepositionproperty"), "position"))
     set (ax(2), "position", get (ax(1), "position"));
   else
@@ -208,6 +209,8 @@
   addlistener (ax(2), "plotboxaspectratio", {@update_position, ax(1)});
   addlistener (ax(1), "plotboxaspectratiomode", {@update_position, ax(2)});
   addlistener (ax(2), "plotboxaspectratiomode", {@update_position, ax(1)});
+  addlistener (ax(1), "nextplot", {@update_nextplot, ax(2)});
+  addlistener (ax(2), "nextplot", {@update_nextplot, ax(1)});
 
   ## Store the axes handles for the sister axes.
   if (ishandle (ax(1)) && ! isprop (ax(1), "__plotyy_axes__"))
@@ -226,53 +229,81 @@
   endif
 endfunction
 
+
 %!demo
-%! clf
+%! clf;
 %! x = 0:0.1:2*pi;
 %! y1 = sin (x);
 %! y2 = exp (x - 1);
-%! ax = plotyy (x, y1, x - 1, y2, @plot, @semilogy);
-%! xlabel ("X");
-%! ylabel (ax(1), "Axis 1");
-%! ylabel (ax(2), "Axis 2");
-%! axes (ax(1))
-%! text (0.5, 0.5, "Left Axis", ...
-%!       "color", [0 0 1], "horizontalalignment", "center")
-%! axes (ax(2))
-%! text (4.5, 80, "Right Axis", ...
-%!       "color", [0 0.5 0], "horizontalalignment", "center")
+%! ax = plotyy (x,y1, x-1,y2, @plot, @semilogy);
+%! xlabel ('X');
+%! ylabel (ax(1), 'Axis 1');
+%! ylabel (ax(2), 'Axis 2');
+%! axes (ax(1));
+%! text (0.5, 0.5, 'Left Axis', ...
+%!       'color', [0 0 1], 'horizontalalignment', 'center');
+%! axes (ax(2));
+%! text (4.5, 80, 'Right Axis', ...
+%!       'color', [0 0.5 0], 'horizontalalignment', 'center');
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! x = linspace (-1, 1, 201);
+%! subplot (2,2,1);
+%!  plotyy (x,sin(pi*x), x,10*cos(pi*x));
+%! subplot (2,2,2);
+%!  surf (peaks (25));
+%! subplot (2,2,3);
+%!  contour (peaks (25));
+%! subplot (2,2,4);
+%!  plotyy (x,10*sin(2*pi*x), x,cos(2*pi*x));
+%! axis square;
+
+%!demo
+%! clf;
+%! x = linspace (-1, 1, 201);
+%! hax = plotyy (x, sin (pi*x), x, cos (pi*x));
+%! ylabel (hax(1), 'Blue on the Left');
+%! ylabel (hax(2), 'Green on the Right');
+%! xlabel ('xlabel');
 
 %!demo
 %! clf
-%! x = linspace (-1, 1, 201);
-%! subplot (2, 2, 1)
-%! plotyy (x, sin(pi*x), x, 10*cos(pi*x))
-%! subplot (2, 2, 2)
-%! surf (peaks (25))
-%! subplot (2, 2, 3)
-%! contour (peaks (25))
-%! subplot (2, 2, 4)
-%! plotyy (x, 10*sin(2*pi*x), x, cos(2*pi*x))
-%! axis square
-
-%!demo
-%! clf
-%! x = linspace (-1, 1, 201);
-%! subplot (1, 1, 1);
-%! hax = plotyy (x, sin(pi*x), x, cos(pi*x));
-%! ylabel ("Blue and on the Left")
-%! ylabel (hax(2), "Green and on the Right")
-%! xlabel ("xlabel")
+%! hold on
+%! t = (0:0.1:9);
+%! x = sin (t);
+%! y = 5 * cos (t);
+%! [hax, h1, h2] = plotyy (t, x, t, y);
+%! [~, h3, h4] = plotyy (t+1, x, t+1, y);
+%! set ([h3, h4], "linestyle", "--")
+%! xlabel (hax(1), 'xlabel')
+%! title (hax(2), 'title')
+%! ylabel (hax(1), 'Left axis is Blue')
+%! ylabel (hax(2), 'Right axis is Green')
 
 function deleteplotyy (h, d, ax2, t2)
   if (ishandle (ax2) && strcmp (get (ax2, "type"), "axes")
-      && (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off"))
+      && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"),"off"))
       && strcmp (get (ax2, "beingdeleted"), "off"))
     set (t2, "deletefcn", []);
     delete (ax2);
   endif
 endfunction
 
+function update_nextplot (h, d, ax2)
+  persistent recursion = false;
+  prop = "nextplot";
+  if (! recursion)
+    unwind_protect
+      recursion = true;
+      set (ax2, prop, get (h, prop));
+    unwind_protect_cleanup
+      recursion = false;
+    end_unwind_protect
+  endif
+endfunction
+
 function update_position (h, d, ax2)
   persistent recursion = false;
 
--- a/scripts/plot/polar.m
+++ b/scripts/plot/polar.m
@@ -38,7 +38,7 @@
   [h, varargin, nargs] = __plt_get_axis_arg__ ("polar", varargin{:});
 
   if (nargs < 1)
-    print_usage();
+    print_usage ();
   endif
 
   oldh = gca ();
@@ -55,8 +55,8 @@
     elseif (nargs == 2)
       if (ischar (varargin{2}))
         tmp = __plr1__ (h, varargin{:});
-        if (iscomplex(varargin{1}))
-          maxr = max (imag(varargin{1})(:));
+        if (iscomplex (varargin{1}))
+          maxr = max (imag (varargin{1})(:));
         else
           maxr = max (varargin{1}(:));
         endif
@@ -68,8 +68,8 @@
     elseif (nargs == 1)
       fmt = "";
       tmp = __plr1__ (h, varargin{:}, fmt);
-      if (iscomplex(varargin{1}))
-        maxr = max (imag(varargin{1})(:));
+      if (iscomplex (varargin{1}))
+        maxr = max (imag (varargin{1})(:));
       else
         maxr = max (varargin{1}(:));
       endif
@@ -217,14 +217,14 @@
 
 
 %!demo
-%! clf
-%! theta = linspace (0, 2*pi, 1000);
+%! clf;
+%! theta = linspace (0,2*pi,1000);
 %! rho = sin (7*theta);
 %! polar (theta, rho);
 
 %!demo
-%! clf
-%! theta = linspace (0, 10*pi, 1000);
+%! clf;
+%! theta = linspace (0,10*pi,1000);
 %! rho = sin (5/4*theta);
 %! polar (theta, rho);
 
--- a/scripts/plot/print.m
+++ b/scripts/plot/print.m
@@ -21,17 +21,29 @@
 ## @deftypefnx {Function File} {} print (@var{options})
 ## @deftypefnx {Function File} {} print (@var{filename}, @var{options})
 ## @deftypefnx {Function File} {} print (@var{h}, @var{filename}, @var{options})
-## Print a graph, or save it to a file
-##
-## @var{filename} defines the file name of the output file.  If the
-## file name has no suffix, one is inferred from the specified
-## device and appended to the file name.  If no
-## filename is specified, the output is sent to the printer.
+## Print a graph, or save it to a file.  Both output formatted for 
+## printing (PDF and PostScript), and many bitmapped and vector
+## image formats are supported.
 ##
 ## @var{h} specifies the figure handle.  If no handle is specified
 ## the handle for the current figure is used.
 ##
-## @var{options}:
+## @var{filename} defines the name of the output file.  If the
+## file name has no suffix, one is inferred from the specified
+## device and appended to the file name.  If no filename is
+## specified, the output is sent to the printer.
+##
+## For output to a printer, to a PostScript file, or a PDF file,
+## the paper size is specified by the figure's @code{papersize}
+## property.  The location and size of the image on the page are
+## specified by the figure's @code{paperposition} property.  The
+## orientation of the page is specified by the figure's
+## @code{paperorientation} property.
+##
+## The width and height of images are specified by the figure's
+## @code{paperpositon(3:4)} property values.
+##
+## The @code{print} command supports several @var{options}:
 ##
 ## @table @code
 ## @item -f@var{h}
@@ -62,8 +74,19 @@
 ## orientation specified.  This options is equivalent to changing
 ## the figure's "paperorientation" property.
 ##
+## @item -TextAlphaBits=@var{n}
+## @itemx -GraphicsAlphaBits=@var{n}
+##   Octave is able to produce output for various printers, bitmaps, and
+## vector formats by using Ghostscript.
+## For bitmap and printer output anti-aliasing is applied using
+## Ghostscript's TextAlphaBits and GraphicsAlphaBits options.
+## The default number of bits for each is 4.
+## Allowed values, for @var{N}, are 1, 2, or 4.
+##
 ## @item -d@var{device}
-##   Output device, where @var{device} is one of:
+##   The available output format is specified by the option @var{device},
+##   and is one of:
+##
 ##   @table @code
 ##   @item ps
 ##   @itemx ps2
@@ -283,26 +306,34 @@
     ## Modify properties as specified by options
     props = [];
 
+    drawnow ();
+
+    ## print() requires figure units to be "pixels"
+    props(1).h = opts.figure;
+    props(1).name = "units";
+    props(1).value = {get(opts.figure, "units")};
+    set (opts.figure, "units", "pixels");
+
     ## graphics toolkit tranlates figure position to eps bbox in points
     fpos = get (opts.figure, "position");
-    props(1).h = opts.figure;
-    props(1).name = "position";
-    props(1).value = {fpos};
+    props(2).h = opts.figure;
+    props(2).name = "position";
+    props(2).value = {fpos};
     fpos(3:4) = opts.canvas_size;
     set (opts.figure, "position", fpos);
 
     ## Set figure background to none. This is done both for
     ## consistency with Matlab and to elliminate the visible
     ## box along the figure's perimeter.
-    props(2).h = opts.figure;
-    props(2).name = "color";
-    props(2).value{1} = get (props(2).h, props(2).name);
-    set (props(2).h, props(2).name, "none");
+    props(3).h = opts.figure;
+    props(3).name = "color";
+    props(3).value{1} = get (props(3).h, props(3).name);
+    set (props(3).h, "color", "none");
 
     if (opts.force_solid != 0)
       h = findall (opts.figure, "-property", "linestyle");
       m = numel (props);
-      for n = 1:numel(h)
+      for n = 1:numel (h)
         props(m+n).h = h(n);
         props(m+n).name = "linestyle";
         props(m+n).value = {get(h(n), "linestyle")};
@@ -318,12 +349,12 @@
     if (opts.use_color < 0
         && ! strcmp (get (opts.figure, "__graphics_toolkit__"), "gnuplot"))
       color_props = {"color", "facecolor", "edgecolor", "colormap"};
-      for c = 1:numel(color_props)
+      for c = 1:numel (color_props)
         h = findall (opts.figure, "-property", color_props{c});
         hnone = findall (opts.figure, color_props{c}, "none");
         h = setdiff (h, hnone);
         m = numel (props);
-        for n = 1:numel(h)
+        for n = 1:numel (h)
           if (ishandle (h(n)))
             ## Need to verify objects exist since callbacks may delete objects
             ## as the colors for others are modified.
@@ -333,7 +364,7 @@
             props(end).value = {get(h(n), color_props{c})};
             if (isnumeric (rgb))
               ## convert RGB color to RGB gray scale
-              xfer = repmat ([0.30, 0.59, 0.11], size (rgb, 1), 1);
+              xfer = repmat ([0.30, 0.59, 0.11], rows (rgb), 1);
               ggg = repmat (sum (xfer .* rgb, 2), 1, 3);
               set (h(n), color_props{c}, ggg);
             endif
@@ -345,7 +376,7 @@
     if (! isempty (opts.font) || ! isempty (opts.fontsize))
       h = findall (opts.figure, "-property", "fontname");
       m = numel (props);
-      for n = 1:numel(h)
+      for n = 1:numel (h)
         if (ishandle (h(n)))
           if (! isempty (opts.font))
             props(end+1).h = h(n);
@@ -362,7 +393,7 @@
         endif
       endfor
       if (! isempty (opts.font))
-        set (h(ishandle(h)), "fontname", opts.font);
+        set (h(ishandle (h)), "fontname", opts.font);
       endif
       if (! isempty (opts.fontsize))
         if (ischar (opts.fontsize))
@@ -370,7 +401,11 @@
         else
           fontsize = opts.fontsize;
         endif
-        set (h(ishandle(h)), "fontsize", fontsize);
+        if (! isempty (opts.scalefontsize) && ! opt.scalefontsize != 1)
+          ## This is done to work around the bbox being whole numbers.
+          fontsize = fontsize * opts.scalefontsize;
+        endif
+        set (h(ishandle (h)), "fontsize", fontsize);
       endif
     endif
 
@@ -385,7 +420,7 @@
   unwind_protect_cleanup
     ## restore modified properties
     if (isstruct (props))
-      for n = 1:numel(props)
+      for n = numel (props):-1:1
         if (ishandle (props(n).h))
           set (props(n).h, props(n).name, props(n).value{1});
         endif
@@ -393,7 +428,7 @@
     endif
 
     ## Unlink temporary files
-    for n = 1:numel(opts.unlink)
+    for n = 1:numel (opts.unlink)
       [status, output] = unlink (opts.unlink{n});
       if (status != 0)
         warning ("print.m: %s, '%s'", output, opts.unlink{n});
--- a/scripts/plot/private/__add_datasource__.m
+++ b/scripts/plot/private/__add_datasource__.m
@@ -39,7 +39,7 @@
   newargs = {};
   while (i < numel (varargin))
     arg = varargin{++i};
-    if (i != numel(varargin) && ischar (arg)
+    if (i != numel (varargin) && ischar (arg)
         && length (arg) > 9 && strcmpi (arg(end-9:end), "datasource"))
       arg = tolower (arg);
       val = varargin{++i};
--- a/scripts/plot/private/__add_default_menu__.m
+++ b/scripts/plot/private/__add_default_menu__.m
@@ -98,12 +98,12 @@
 endfunction
 
 function guimode_cb (h, e)
-  lbl = get(h, "label");
-  if (strncmp(lbl, "Pan+Zoom", 8))
-    gui_mode("2D");
-  elseif (strncmp(lbl, "Rotate+Zoom", 11))
-    gui_mode("3D");
-  elseif (strncmp(lbl, "None", 4))
-    gui_mode("None");
+  lbl = get (h, "label");
+  if (strncmp (lbl, "Pan+Zoom", 8))
+    gui_mode ("2D");
+  elseif (strncmp (lbl, "Rotate+Zoom", 11))
+    gui_mode ("3D");
+  elseif (strncmp (lbl, "None", 4))
+    gui_mode ("None");
   endif
 endfunction
--- a/scripts/plot/private/__axes_limits__.m
+++ b/scripts/plot/private/__axes_limits__.m
@@ -41,7 +41,7 @@
         set (h, fcnmode, arg);
       endif
     else
-      if (!isnumeric (arg) && any (size(arg(:)) != [2, 1]))
+      if (!isnumeric (arg) && any (size (arg(:)) != [2, 1]))
         error ("%s: argument must be a 2 element vector", fcn);
       else
         if (arg(1) >= arg(2))
--- a/scripts/plot/private/__bar__.m
+++ b/scripts/plot/private/__bar__.m
@@ -45,12 +45,12 @@
     if (isvector (y))
       y = y(:);
     endif
-    if (size (x, 1) != size (y, 1))
+    if (rows (x) != rows (y))
       y = varargin{1};
       if (isvector (y))
         y = y(:);
       endif
-      x = [1:size(y,1)]';
+      x = [1:rows(y)]';
       idx = 2;
     else
       if (! isvector (x))
@@ -63,7 +63,7 @@
     if (isvector (y))
       y = y(:);
     endif
-    x = [1:size(y,1)]';
+    x = [1:rows(y)]';
     idx = 2;
   endif
 
@@ -82,12 +82,14 @@
         [linespec, valid] = __pltopt__ (func, varargin{idx}, false);
         if (valid)
           have_line_spec = true;
-          newargs = [{"facecolor", linespec.color}, newargs]
+          ## FIXME: strange parse error requires semicolon to be spaced
+          ##        away from closing ']' on next line.
+          newargs = [{"facecolor", linespec.color}, newargs] ;
           idx++;
           continue;
         endif
       endif
-      if (isscalar(varargin{idx}))
+      if (isscalar (varargin{idx}))
         width = varargin{idx++};
       elseif (idx == nargin - 2)
         newargs = [newargs,varargin(idx++)];
@@ -103,8 +105,8 @@
     endif
   endwhile
 
-  xlen = size (x, 1);
-  ylen = size (y, 1);
+  xlen = rows (x);
+  ylen = rows (y);
 
   if (xlen != ylen)
     error ("%s: length of x and y must be equal", func);
@@ -113,9 +115,9 @@
     error ("%s: x vector values must be in ascending order", func);
   endif
 
-  ycols = size (y, 2);
+  ycols = columns (y);
   if (numel (x) > 1)
-    cutoff = min (diff (double(x))) / 2;
+    cutoff = min (diff (double (x))) / 2;
   else
     cutoff = 1;
   endif
@@ -137,7 +139,7 @@
     y0 = zeros (size (y)) + bv;
     y1 = y;
   else
-    y1 = cumsum(y,2);
+    y1 = cumsum (y,2);
     y0 = [zeros(ylen,1)+bv, y1(:,1:end-1)];
   endif
 
@@ -194,10 +196,10 @@
         else
           lev = (i - 1) * (clim(2) - clim(1)) / (ycols - 1) - clim(1);
         endif
-        h = patch(xb(:,:,i), yb(:,:,i), "FaceColor", "flat",
-                  "cdata", lev, "parent", hg);
+        h = patch (xb(:,:,i), yb(:,:,i), "FaceColor", "flat",
+                   "cdata", lev, "parent", hg);
       else
-        h = patch(xb(:,:,i), yb(:,:,i), "parent", hg);
+        h = patch (xb(:,:,i), yb(:,:,i), "parent", hg);
       endif
     else
       if (! have_color_spec)
@@ -206,10 +208,10 @@
         else
           lev = (i - 1) * (clim(2) - clim(1)) / (ycols - 1) - clim(1);
         endif
-        h = patch(yb(:,:,i), xb(:,:,i), "FaceColor", "flat",
-                  "cdata", lev, "parent", hg);
+        h = patch (yb(:,:,i), xb(:,:,i), "FaceColor", "flat",
+                   "cdata", lev, "parent", hg);
       else
-        h = patch(yb(:,:,i), xb(:,:,i), "parent", hg);
+        h = patch (yb(:,:,i), xb(:,:,i), "parent", hg);
       endif
     endif
 
@@ -401,7 +403,7 @@
     unwind_protect
       recursion = true;
       hlist = get (h, "bargroup");
-      barwidth = get(h, "barwidth");
+      barwidth = get (h, "barwidth");
       barlayout = get (h, "barlayout");
       horizontal = get (h, "horizontal");
 
--- a/scripts/plot/private/__clabel__.m
+++ b/scripts/plot/private/__clabel__.m
@@ -25,10 +25,10 @@
   ## FIXME
   ## Assume that the plot size is 4 by 3 inches.
   lims = axis ();
-  xspacing = 72 * 4 / abs(lims(1) - lims(2));
-  yspacing = 72 * 3 / abs(lims(3) - lims(4));
+  xspacing = 72 * 4 / abs (lims(1) - lims(2));
+  yspacing = 72 * 3 / abs (lims(3) - lims(4));
 
-  if (isscalar (hparent) && ishandle(hparent)
+  if (isscalar (hparent) && ishandle (hparent)
       && strcmp (get (hparent, "type"), "hggroup"))
     x = get (hparent, "xdata");
     xmin = min (x(:));
@@ -67,14 +67,14 @@
     p = c(:, i1+1:i1+clen) .* repmat ([xspacing; yspacing], 1, clen);
     d = sqrt (sumsq (diff (p, 1, 2)));
     cumd = cumsum (d);
-    td = sum(d);
+    td = sum (d);
     ntag = ceil (td / label_spacing);
 
     if (all (c(:,i1+1) == c(:,i1+clen)))
       Spacing = td / ntag;
       pos = Spacing / 2 + [0:ntag-1] * Spacing;
     else
-      pos = zeros(1, ntag);
+      pos = zeros (1, ntag);
       pos(1) = (td - label_spacing * (ntag - 1)) ./ 2;
       pos(2:ntag) = pos(1) + [1:ntag-1] * label_spacing;
     endif
@@ -87,7 +87,7 @@
       while (j1 < clen && cumd(j1) < tagpos)
         j1++;
       endwhile
-      tpos = sum(c(:,i1+j1-1:i1+j1), 2) ./ 2;
+      tpos = sum (c(:,i1+j1-1:i1+j1), 2) ./ 2;
 
       if (tpos(1) != xmin &&  tpos(1) != xmax
           && tpos(2) != ymin &&  tpos(2) != ymax)
@@ -112,4 +112,4 @@
     endfor
     i1 += clen+1;
   endwhile
-endfunction
\ No newline at end of file
+endfunction
--- a/scripts/plot/private/__contour__.m
+++ b/scripts/plot/private/__contour__.m
@@ -79,10 +79,10 @@
     endif
   endwhile
 
-  if (length(varargin) < 5)
+  if (length (varargin) < 5)
     z1 = varargin{3};
-    x1 = 1 : columns(z1);
-    y1 = 1 : rows(z1);
+    x1 = 1 : columns (z1);
+    y1 = 1 : rows (z1);
   else
     x1 = varargin{3};
     y1 = varargin{4};
@@ -100,7 +100,7 @@
   endif
 
   if (isscalar (vn))
-    lvl = linspace (min (z1(!isinf(z1))), max (z1(!isinf(z1))),
+    lvl = linspace (min (z1(!isinf (z1))), max (z1(!isinf (z1))),
                     vn + 2)(1:end-1);
   else
     lvl = vn;
@@ -111,13 +111,13 @@
       [x1, y1] = meshgrid (x1, y1);
     endif
     [nr, nc] = size (z1);
-    x0 = prepad(x1, nc+1, 2 * x1(1, 1) - x1(1, 2), 2);
-    x0 = postpad(x0, nc+2, 2 * x1(1, nc) - x1(1, nc - 1), 2);
+    x0 = prepad (x1, nc+1, 2 * x1(1, 1) - x1(1, 2), 2);
+    x0 = postpad (x0, nc+2, 2 * x1(1, nc) - x1(1, nc - 1), 2);
     x0 = [x0(1, :); x0; x0(1, :)];
-    y0 = prepad(y1, nr+1, 2 * y1(1, 1) - y1(2, 1), 1);
-    y0 = postpad(y0, nr+2, 2 * y1(nr, 1) - y1(nr - 1, 1));
+    y0 = prepad (y1, nr+1, 2 * y1(1, 1) - y1(2, 1), 1);
+    y0 = postpad (y0, nr+2, 2 * y1(nr, 1) - y1(nr - 1, 1));
     y0 = [y0(:, 1), y0, y0(:, 1)];
-    z0 = -Inf(nr+2, nc+2);
+    z0 = -Inf (nr+2, nc+2);
     z0(2:nr+1, 2:nc+1) = z1;
     [c, lev] = contourc (x0, y0, z0, lvl);
   else
@@ -211,7 +211,7 @@
 
   add_patch_children (hg);
 
-  axis("tight");
+  axis ("tight");
 
   if (!isempty (opts))
     set (hg, opts{:});
@@ -258,7 +258,7 @@
       lvl_idx = find (abs (cont_lev - lev(k)) < lvl_eps);
       len = numel (lvl_idx);
       if (len > 1)
-        ## mark = logical(zeros(size(lvl_idx)));
+        ## mark = logical (zeros (size (lvl_idx)));
         mark = false (size (lvl_idx));
         a = 1;
         while (a < len)
@@ -283,7 +283,7 @@
           ma_idx = lvl_idx(mark);
           if (k > 1)
             ## Find color of level below.
-            tmp = find(abs(cont_lev - lev(k - 1)) < lvl_eps);
+            tmp = find (abs (cont_lev - lev(k - 1)) < lvl_eps);
             lvl_bel_idx = tmp(1);
             ## Set color of patches found.
             cont_lev(ma_idx) = cont_lev(lvl_bel_idx);
@@ -319,7 +319,7 @@
       else
         ## Special case unclosed contours
       endif
-      if (isnan(cont_lev(idx)))
+      if (isnan (cont_lev (idx)))
         fc = get (ca, "color");
         if (strcmp (fc, "none"))
           fc = get (ancestor (ca, "figure"), "color");
@@ -458,13 +458,13 @@
         [X, Y] = meshgrid (X, Y);
       endif
       [nr, nc] = size (Z);
-      X0 = prepad(X, nc+1, 2 * X(1, 1) - X(1, 2), 2);
-      X0 = postpad(X0, nc+2, 2 * X(1, nc) - X(1, nc - 1), 2);
+      X0 = prepad (X, nc+1, 2 * X(1, 1) - X(1, 2), 2);
+      X0 = postpad (X0, nc+2, 2 * X(1, nc) - X(1, nc - 1), 2);
       X0 = [X0(1, :); X0; X0(1, :)];
-      Y0 = prepad(Y, nr+1, 2 * Y(1, 1) - Y(2, 1), 1);
-      Y0 = postpad(Y0, nr+2, 2 * Y(nr, 1) - Y(nr - 1, 1));
+      Y0 = prepad (Y, nr+1, 2 * Y(1, 1) - Y(2, 1), 1);
+      Y0 = postpad (Y0, nr+2, 2 * Y(nr, 1) - Y(nr - 1, 1));
       Y0 = [Y0(:, 1), Y0, Y0(:, 1)];
-      Z0 = -Inf(nr+2, nc+2);
+      Z0 = -Inf (nr+2, nc+2);
       Z0(2:nr+1, 2:nc+1) = Z;
       [c, lev] = contourc (X0, Y0, Z0, lvl);
     else
@@ -480,7 +480,7 @@
     else
       set (h, "levellist", lev);
       z = get (h, "zdata");
-      lvlstep = (max(z(:)) - min(z(:))) / 10;
+      lvlstep = (max (z(:)) - min (z(:))) / 10;
       set (h, "levelstep", lvlstep);
     endif
 
--- a/scripts/plot/private/__errcomm__.m
+++ b/scripts/plot/private/__errcomm__.m
@@ -34,7 +34,7 @@
   nargs = length (varargin);
   retval = [];
   k = 1;
-  data = cell(6,1);
+  data = cell (6,1);
   while (k <= nargs)
     a = varargin{k++};
     if (isvector (a))
--- a/scripts/plot/private/__errplot__.m
+++ b/scripts/plot/private/__errplot__.m
@@ -71,7 +71,7 @@
           (__line__ (hg, "linestyle", "-", "marker", "none",
                    "color", fmt.color))];
 
-    switch (numel(varargin))
+    switch (numel (varargin))
       case 2
         ydata = varargin{1}(:,i);
         xdata = 1:numel (ydata);
@@ -196,7 +196,7 @@
   ## Process legend key
   if (! isempty (fmt.key))    
     hlegend = [];
-    fkids = get (gcf(), "children");
+    fkids = get (gcf (), "children");
     for i = 1 : numel (fkids)
       if (ishandle (fkids(i)) && strcmp (get (fkids(i), "type"), "axes")
           && (strcmp (get (fkids(i), "tag"), "legend")))
@@ -218,8 +218,8 @@
     hlgnd(end+1) = hg;
     tlgnd(end+1) = fmt.key;
 
-    legend (gca(), hlgnd, tlgnd);
-  end 
+    legend (gca (), hlgnd, tlgnd);
+  endif
 
 endfunction
 
@@ -232,7 +232,7 @@
     xhi = xdata + dx;
   else
     n = xdata > 0;
-    rx = exp(0.01 * (max (log(xdata(n))) - min (log(xdata(n)))));
+    rx = exp (0.01 * (max (log (xdata(n))) - min (log (xdata(n)))));
     xlo = xdata/rx;
     xhi = xdata*rx;
   endif
@@ -242,7 +242,7 @@
     yhi = ydata + dy;
   else
     n = ydata > 0;
-    ry = exp(0.01 * (max (log(ydata(n))) - min (log(ydata(n)))));
+    ry = exp (0.01 * (max (log (ydata(n))) - min (log (ydata(n)))));
     ylo = ydata/ry;
     yhi = ydata*ry;
   endif
--- a/scripts/plot/private/__ezplot__.m
+++ b/scripts/plot/private/__ezplot__.m
@@ -74,9 +74,9 @@
     endif
     fstr = formula (fun);
     if (isplot)
-      xarg = argnames(fun){1};
+      xarg = (argnames (fun)){1};
       if (nargs == 2)
-        yarg = argnames(fun){2};
+        yarg = (argnames (fun)){2};
       else
         yarg = "";
       endif
@@ -87,8 +87,8 @@
       xarg = "";
       yarg = "";
     else
-      xarg = argnames(fun){1};
-      yarg = argnames(fun){2};
+      xarg = (argnames (fun)){1};
+      yarg = (argnames (fun)){2};
     endif
   elseif (strcmp (typeinfo (fun), "inline function"))
     if (isplot && length (argnames (fun)) == 2)
@@ -99,9 +99,9 @@
     fun = vectorize (fun);
     fstr = formula (fun);
     if (isplot)
-      xarg = argnames(fun){1};
+      xarg = (argnames (fun)){1};
       if (nargs == 2)
-        yarg = argnames(fun){2};
+        yarg = (argnames (fun)){2};
       else
         yarg = "";
       endif
@@ -112,15 +112,15 @@
       xarg = "";
       yarg = "";
     else
-      xarg = argnames(fun)(1);
-      yarg = argnames(fun)(2);
+      xarg = (argnames (fun))(1);
+      yarg = (argnames (fun))(2);
     endif
   elseif (isa (fun, "function_handle"))
     fstr = func2str (fun);
-    if (length (findstr (fstr, ")")) != 0)
-      args = regexp (substr (fstr, 3, findstr (fstr, ")")(1) - 3),
+    if (! isempty (strfind (fstr, ')')))
+      args = regexp (substr (fstr, 3, strfind (fstr, ')')(1) - 3),
                      '(\w+)', 'tokens');
-    fstr = substr (fstr, findstr (fstr, ")")(1) + 1);
+    fstr = substr (fstr, strfind (fstr, ')')(1) + 1);
     else
       args = {{"x"}};
     endif
@@ -175,10 +175,10 @@
     elseif (isa (funy, "function_handle"))
       parametric = true;
       fstry = func2str (funy);
-      if (length (findstr (fstry, ")")) != 0)
-        args = regexp (substr (fstry, 3, findstr (fstry, ")")(1) - 3),
+      if (! isempty (strfind (fstry, ')')))
+        args = regexp (substr (fstry, 3, strfind (fstry, ')')(1) - 3),
                        '(\w+)', 'tokens');
-        fstry = substr (fstry, findstr (fstry, ")")(1) + 1);
+        fstry = substr (fstry, strfind (fstry, ')')(1) + 1);
       else
         args = {{"y"}};
       endif
@@ -216,12 +216,12 @@
         fstrz = formula (funz);
       elseif (isa (funz, "function_handle"))
         fstrz = func2str (funz);
-        args = regexp (substr (fstrz, 3, findstr (fstrz, ")")(1) - 3),
+        args = regexp (substr (fstrz, 3, strfind (fstrz, ')')(1) - 3),
                        '(\w+)', 'tokens');
         if (length (args) != nargs)
           error ("%s: excepting a function of %d arguments", func, nargs);
         endif
-        fstrz = substr (fstrz, findstr (fstrz, ")")(1) + 1);
+        fstrz = substr (fstrz, strfind (fstrz, ')')(1) + 1);
       else
         error ("%s: parametric plots expect 3 functions", func);
       endif
@@ -392,10 +392,10 @@
           yrange = [XX(1), XX(end)];
         endif
 
-        idx = 2 : length(Z);
+        idx = 2 : length (Z);
         idx = find (((Z(idx) > yrange(2) / 2) & (Z(idx-1) < yrange(1) / 2)) |
                  ((Z(idx) < yrange(1) / 2) & (Z(idx-1) > yrange (2) / 2)));
-        if (any(idx))
+        if (any (idx))
           Z(idx) = NaN;
         endif
       else
@@ -441,5 +441,5 @@
 
 function x = __eliminate_sing__ (x)
   x (isinf (x)) = NaN;
-  x (abs (del2 (x)) > 0.2 * (max(x(:)) - min(x(:)))) = NaN;
+  x (abs (del2 (x)) > 0.2 * (max (x(:)) - min (x(:)))) = NaN;
 endfunction
--- a/scripts/plot/private/__file_filter__.m
+++ b/scripts/plot/private/__file_filter__.m
@@ -81,7 +81,7 @@
   endswitch
 
   if (isempty (name))
-    extlist = strsplit(filterext, ";");
+    extlist = strsplit (filterext, ";");
     extlist = strrep (extlist, "*.", "");
     extlist = toupper (extlist);
     extlist(end+1, :) = repmat ({","}, 1, length (extlist));
--- a/scripts/plot/private/__fltk_print__.m
+++ b/scripts/plot/private/__fltk_print__.m
@@ -125,9 +125,9 @@
     [cmd_gs, cmd_cleanup] = __ghostscript__ (opts.ghostscript);
     if (opts.send_to_printer || isempty (opts.name))
       cmd_lpr = opts.lpr_cmd (opts);
-      cmd = sprintf("%s | %s", cmd_gs, cmd_lpr);
+      cmd = sprintf ("%s | %s", cmd_gs, cmd_lpr);
     else
-      cmd = sprintf("%s", cmd_gs);
+      cmd = sprintf ("%s", cmd_gs);
     endif
     if (! isempty (cmd_cleanup))
       gl2ps_device = {"eps"};
@@ -148,11 +148,22 @@
 
   opts.pipeline = pipeline;
 
-  for n = 1:numel(pipeline)
+  ## Tell gl2ps to use different rendering options for 2D plots
+  haxes = findall (opts.figure, "type", "axes");
+  vw = get (haxes, "view");
+  if (iscell (vw))
+    vw = vertcat (vw{:});
+  endif
+  is2D = all (abs (vw(:,2)) == 90);
+  if (is2D)
+    gl2ps_device{end} = [gl2ps_device{end}, "is2D"];
+  endif
+
+  for n = 1:numel (pipeline)
     if (opts.debug)
       fprintf ("fltk-pipeline: '%s'\n", pipeline{n});
     endif
-    drawnow (gl2ps_device{n}, strcat('|',pipeline{n}));
+    drawnow (gl2ps_device{n}, strcat ('|',pipeline{n}));
   endfor
 
   if (! isempty (strfind (opts.devopt, "standalone")))
--- a/scripts/plot/private/__ghostscript__.m
+++ b/scripts/plot/private/__ghostscript__.m
@@ -32,6 +32,8 @@
   opts.device = "";
   opts.epscrop = false;
   opts.antialiasing  = false;
+  opts.antialiasing_textalphabits = 4;,
+  opts.antialiasing_graphicsalphabits = 4;
   opts.resolution = 150;
   opts.papersize = "";
   opts.pageoffset = [0 0];
@@ -47,12 +49,12 @@
   n = find (cellfun ("isclass", args, "struct"));
   if (! isempty (n))
     f = fieldnames (args{n});
-    for m = 1:numel(f)
+    for m = 1:numel (f)
       opts.(f{m}) = args{n}.(f{m});
     endfor
     args(n) = [];
   endif
-  for n = 1:2:numel(args)
+  for n = 1:2:numel (args)
     opts.(args{n}) = args{n+1};
   endfor
 
@@ -70,7 +72,9 @@
 
   if (opts.antialiasing && isempty (strfind (opts.device, "write")))
     ## Apply anti-aliasing to all bitmap formats/devices
-    gs_opts = sprintf ("%s -dTextAlphaBits=4 -dGraphicsAlphaBits=4", gs_opts);
+    gs_opts = sprintf ("%s -dTextAlphaBits=%d -dGraphicsAlphaBits=%d",
+                       gs_opts, opts.antialiasing_textalphabits,
+                       opts.antialiasing_graphicsalphabits);
     gs_opts = sprintf ("%s -r%dx%d", gs_opts, [1, 1] * opts.resolution);
   elseif (any (strcmp (opts.device, {"pswrite", "ps2write", "pdfwrite"})))
     gs_opts = sprintf ("%s -dEmbedAllFonts=true", gs_opts);
@@ -114,13 +118,13 @@
     unwind_protect
       fid = fopen (offsetfile, "w");
       if (fid == -1)
-        error ("print:fopenfailed", "__ghostscript__.m: fopen() failed");
+        error ("print:fopenfailed", "__ghostscript__.m: fopen () failed");
       endif
       fprintf (fid, "%s\n", offset_ps{:});
     unwind_protect_cleanup
       status = fclose (fid);
       if (status == -1)
-        error ("print:fclosefailed", "__ghostscript__.m: fclose() failed");
+        error ("print:fclosefailed", "__ghostscript__.m: fclose () failed");
       endif
     end_unwind_protect
     if (opts.debug)
@@ -135,7 +139,7 @@
   elseif (isempty (opts.output))
     cmd = sprintf ("%s %s", opts.binary, gs_opts);
   else
-    cmd = sprintf ("%s %s -sOutputFile=%s", opts.binary, gs_opts, opts.output);
+    cmd = sprintf ("%s %s -sOutputFile=\"%s\"", opts.binary, gs_opts, opts.output);
   endif
   if (! isempty (opts.prepend)
       && any (strcmpi (opts.device, {"pswrite", "ps2write", "pdfwrite"})))
--- a/scripts/plot/private/__gnuplot_has_feature__.m
+++ b/scripts/plot/private/__gnuplot_has_feature__.m
@@ -34,7 +34,8 @@
               "epslatexstandalone_terminal",
               "screen_coordinates_for_{lrtb}margin",
               "variable_GPVAL_TERMINALS",
-              "key_has_font_properties"};
+              "key_has_font_properties",
+              "windows_figure_position"};
 
   if (isempty (has_features))
     try
@@ -43,8 +44,8 @@
       ## Don't throw an error if gnuplot isn't installed
       gnuplot_version = "0.0.0";
     end_try_catch
-    versions = {"4.2.5", "4.4", "4.4", "4.4", "4.2", "4.2", "4.4", "4.4", "4.4"};
-    operators = {">=", ">=", ">=", ">=", ">=", ">=", ">=", ">=", ">="};
+    versions = {"4.2.5", "4.4", "4.4", "4.4", "4.2", "4.2", "4.4", "4.4", "4.4", "4.4"};
+    operators = {">=", ">=", ">=", ">=", ">=", ">=", ">=", ">=", ">=", ">="};
     have_features = logical (zeros (size (features)));
     for n = 1 : numel (have_features)
       has_features(n) = compare_versions (gnuplot_version, versions{n}, operators{n});
--- a/scripts/plot/private/__gnuplot_print__.m
+++ b/scripts/plot/private/__gnuplot_print__.m
@@ -151,7 +151,7 @@
 
   opts.pipeline = pipeline;
 
-  for n = 1:numel(pipeline)
+  for n = 1:numel (pipeline)
     if (opts.debug)
       fprintf ("gnuplot-pipeline: '%s'\n", pipeline{n});
     endif
@@ -170,12 +170,12 @@
 function eps_drawnow (opts, epsfile, gp_opts)
   [h, fontsize] = get_figure_text_objs (opts);
   unwind_protect
-    for n = 1:numel(h)
+    for n = 1:numel (h)
       set (h(n), "fontsize", 2 * fontsize{n});
     endfor
     local_drawnow (sprintf ("postscript eps %s", gp_opts), epsfile, opts);
   unwind_protect_cleanup
-    for n = 1:numel(h)
+    for n = 1:numel (h)
       set (h(n), "fontsize", fontsize{n});
     endfor
   end_unwind_protect
@@ -196,7 +196,7 @@
 endfunction
 
 function f = font_spec (opts, varargin)
-  for n = 1:2:numel(varargin)
+  for n = 1:2:numel (varargin)
     opts.(varargin{n}) = varargin{n+1};
   endfor
   f = "";
--- a/scripts/plot/private/__go_draw_axes__.m
+++ b/scripts/plot/private/__go_draw_axes__.m
@@ -90,7 +90,7 @@
           x = [1, 1];
         else
           ## 3D plots need to be sized down to fit in the window.
-          x = 1.0 ./ sqrt([2, 2.5]);
+          x = 1.0 ./ sqrt ([2, 2.5]);
         endif
         fprintf (plot_stream, "set tmargin screen %.15g;\n",
                  pos(2)+pos(4)/2+x(2)*pos(4)/2);
@@ -453,7 +453,7 @@
       endif
       kids = kids(1:(end-1));
 
-      if (strcmpi (obj.visible, "off"))
+      if (strcmp (obj.visible, "off"))
         continue;
       endif
 
@@ -495,13 +495,13 @@
             img_xdata = img_xdata(2:-1:1);
             img_data = img_data(:,end:-1:1,:);
           elseif (img_xdata(1) == img_xdata(2))
-            img_xdata = img_xdata(1) + [0, size(img_data,2)-1];
+            img_xdata = img_xdata(1) + [0, columns(img_data)-1];
           endif
           if (img_ydata(2) < img_ydata(1))
             img_ydata = img_ydata(2:-1:1);
             img_data = img_data(end:-1:1,:,:);
           elseif (img_ydata(1) == img_ydata(2))
-            img_ydata = img_ydata(1) + [0, size(img_data,1)-1];
+            img_ydata = img_ydata(1) + [0, rows(img_data)-1];
           endif
 
           [y_dim, x_dim] = size (img_data(:,:,1));
@@ -574,7 +574,7 @@
             ydat = obj.ydata(:);
             data{data_idx} = [xdat, ydat]';
             usingclause{data_idx} = sprintf ("record=%d using ($1):($2) axes %s%s",
-                                            rows(xdat), xaxisloc_using, yaxisloc_using);
+                                            rows (xdat), xaxisloc_using, yaxisloc_using);
           endif
 
           style = do_linestyle_command (obj, obj.color, data_idx, mono,
@@ -680,14 +680,14 @@
                      || strncmp (obj.facecolor, "interp", 6))
                      && isfield (obj, "cdata"))
                    if (ndims (obj.cdata) == 2
-                       && (size (obj.cdata, 2) == nc
-                           && (size (obj.cdata, 1) == 1
-                               || size (obj.cdata, 1) == 3)))
+                       && (columns (obj.cdata) == nc
+                           && (rows (obj.cdata) == 1
+                               || rows (obj.cdata) == 3)))
                      ccol = cdat (:, i);
                    elseif (ndims (obj.cdata) == 2
-                       && (size (obj.cdata, 1) == nc
-                           && (size (obj.cdata, 2) == 1
-                               || size (obj.cdata, 2) == 3)))
+                       && (rows (obj.cdata) == nc
+                           && (columns (obj.cdata) == 1
+                               || columns (obj.cdata) == 3)))
                      ccol = cdat (i, :);
                    elseif (ndims (obj.cdata) == 3)
                      ccol = permute (cdat (:, i, :), [1, 3, 2]);
@@ -704,17 +704,17 @@
                        if (cdatadirect)
                          r = round (ccol);
                        else
-                         r = 1 + round ((size (cmap, 1) - 1)
+                         r = 1 + round ((rows (cmap) - 1)
                                         * (ccol - clim(1))/(clim(2) - clim(1)));
                        endif
-                       r = max (1, min (r, size (cmap, 1)));
+                       r = max (1, min (r, rows (cmap)));
                        color = cmap(r, :);
                      endif
                    elseif (strncmp (obj.facecolor, "interp", 6))
                      if (nd == 3 && numel (xcol) == 3)
                        ccdat = ccol;
                        if (! isvector (ccdat))
-                         tmp = rows(cmap) + rows(addedcmap) + ...
+                         tmp = rows (cmap) + rows (addedcmap) + ...
                               [1 : rows(ccdat)];
                          addedcmap = [addedcmap; ccdat];
                          ccdat = tmp(:);
@@ -728,10 +728,10 @@
                        if (cdatadirect)
                          r = round (ccol);
                        else
-                         r = 1 + round ((size (cmap, 1) - 1)
+                         r = 1 + round ((rows (cmap) - 1)
                                         * (ccol - clim(1))/(clim(2) - clim(1)));
                        endif
-                       r = max (1, min (r, size (cmap, 1)));
+                       r = max (1, min (r, rows (cmap)));
                        color = cmap(r(1),:);
                      endif
                    endif
@@ -746,7 +746,7 @@
 
                if (nd == 3 && numel (xcol) == 3)
                  if (isnan (ccdat))
-                   ccdat = (rows (cmap) + rows(addedcmap) + 1) * ones(3, 1);
+                   ccdat = (rows (cmap) + rows (addedcmap) + 1) * ones(3, 1);
                    addedcmap = [addedcmap; reshape(color, 1, 3)];
                  endif
                  data{data_3d_idx} = [data{data_3d_idx}, ...
@@ -812,14 +812,14 @@
                     || strncmp (ec, "interp", 6))
                    && isfield (obj, "cdata"))
                  if (ndims (obj.cdata) == 2
-                     && (size (obj.cdata, 2) == nc
-                         && (size (obj.cdata, 1) == 1
-                             || size (obj.cdata, 1) == 3)))
+                     && (columns (obj.cdata) == nc
+                         && (rows (obj.cdata) == 1
+                             || rows (obj.cdata) == 3)))
                    ccol = cdat (:, i);
                  elseif (ndims (obj.cdata) == 2
-                         && (size (obj.cdata, 1) == nc
-                             && (size (obj.cdata, 2) == 1
-                                 || size (obj.cdata, 2) == 3)))
+                         && (rows (obj.cdata) == nc
+                             && (columns (obj.cdata) == 1
+                                 || columns (obj.cdata) == 3)))
                    ccol = cdat (i, :);
                  elseif (ndims (obj.cdata) == 3)
                    ccol = permute (cdat (:, i, :), [1, 3, 2]);
@@ -827,22 +827,22 @@
                    ccol = cdat;
                  endif
                  if (strncmp (ec, "flat", 4))
-                   if (numel(ccol) == 3)
+                   if (numel (ccol) == 3)
                      color = ccol;
                    else
                      if (isscalar (ccol))
-                       ccol = repmat(ccol, numel (xcol), 1);
+                       ccol = repmat (ccol, numel (xcol), 1);
                      endif
                      color = "flat";
                      have_cdata(data_idx) = true;
                    endif
                  elseif (strncmp (ec, "interp", 6))
-                   if (numel(ccol) == 3)
+                   if (numel (ccol) == 3)
                      warning ("\"interp\" not supported, using 1st entry of cdata");
                      color = ccol(1,:);
                    else
                      if (isscalar (ccol))
-                       ccol = repmat(ccol, numel (xcol), 1);
+                       ccol = repmat (ccol, numel (xcol), 1);
                      endif
                      color = "interp";
                      have_cdata(data_idx) = true;
@@ -877,7 +877,7 @@
              endif
 
              if (isfield (obj, "linewidth"))
-               lw = sprintf("linewidth %f", obj.linewidth);
+               lw = sprintf ("linewidth %f", obj.linewidth);
              else
                lw  = "";
              endif
@@ -923,7 +923,7 @@
                    else
                      m = mdat;
                    endif
-                   ps = sprintf("pointsize %f", m / 3);
+                   ps = sprintf ("pointsize %f", m / 3);
                  else
                    ps = "";
                  endif
@@ -950,7 +950,7 @@
                    else
                      m = mdat;
                    endif
-                   ps = sprintf("pointsize %f", m / 3);
+                   ps = sprintf ("pointsize %f", m / 3);
                  else
                    ps = "";
                  endif
@@ -977,7 +977,7 @@
                      else
                        m = mdat;
                      endif
-                     ps = sprintf("pointsize %f", m / 3);
+                     ps = sprintf ("pointsize %f", m / 3);
                    else
                      ps = "";
                    endif
@@ -987,7 +987,7 @@
                  endif
                else
                  if (!isempty (style))
-                   if (length(tmpwith) < sidx || isempty (tmpwith{sidx}))
+                   if (length (tmpwith) < sidx || isempty (tmpwith{sidx}))
                      tmpwith{sidx} = sprintf ("with %s %s %s %s",
                                               style, lw, lt,
                                               colorspec);
@@ -1012,7 +1012,7 @@
                      else
                        m = mdat;
                      endif
-                     ps = sprintf("pointsize %f", m / 3);
+                     ps = sprintf ("pointsize %f", m / 3);
                    else
                      ps = "";
                    endif
@@ -1122,7 +1122,7 @@
             cdat = obj.cdata;
 
             err = false;
-            if (! size_equal(zdat, cdat))
+            if (! size_equal (zdat, cdat))
               err = true;
             endif
             if (isvector (xdat) && isvector (ydat) && ismatrix (zdat))
@@ -1188,11 +1188,11 @@
               if (all (obj.facecolor == 1))
                 hidden_removal = true;
               endif
-              fputs(plot_stream,"unset pm3d;\n");
-              fputs(plot_stream,"set style increment user;\n");
+              fputs (plot_stream,"unset pm3d;\n");
+              fputs (plot_stream,"set style increment user;\n");
               withpm3d = false;
-              withclause{data_idx} = sprintf("with %s linestyle %d",
-                                             style{1}, data_idx);
+              withclause{data_idx} = sprintf ("with %s linestyle %d",
+                                              style{1}, data_idx);
               fputs (plot_stream, "unset pm3d\n");
             endif
 
@@ -1267,7 +1267,7 @@
                                               style{3}, data_idx);
             endif
             if (withpm3d && strncmp (style {1}, "linespoints", 11))
-              if (isempty(zz))
+              if (isempty (zz))
                 len = 3 * xlen;
                 zz = zeros (ylen, len);
                 k = 1;
@@ -1315,7 +1315,7 @@
           endif
 
           if (ischar (obj.string))
-            num_lines = size (obj.string, 1);
+            num_lines = rows (obj.string);
           else
             num_lines = numel (obj.string);
           endif
@@ -1335,7 +1335,7 @@
           ## Gnuplot's Character units are different for x/y and vary with fontsize. The aspect ratio
           ## of 1:1.7 was determined by experiment to work for eps/ps/etc. For the MacOS aqua terminal
           ## a value of 2.5 is needed. However, the difference is barely noticable.
-          dx_and_dy = [(-dy * sind (angle)), (dy * cosd(angle))] .* [1.7 1];
+          dx_and_dy = [(-dy * sind (angle)), (dy * cosd (angle))] .* [1.7 1];
 
           ## FIXME - Multiline text produced the gnuplot "warning: ft_render: skipping glyph"
           if (nd == 3)
@@ -1376,7 +1376,7 @@
       fputs (plot_stream, "set pm3d explicit;\n");
     endif
 
-    if (isnan(hidden_removal) || hidden_removal)
+    if (isnan (hidden_removal) || hidden_removal)
       fputs (plot_stream, "set hidden3d;\n");
     else
       fputs (plot_stream, "unset hidden3d;\n");
@@ -1425,19 +1425,19 @@
     endif
 
     cmap = parent_figure_obj.colormap;
-    cmap_sz = rows(cmap);
+    cmap_sz = rows (cmap);
     if (! any (isinf (clim)))
       if (truecolor || ! cdatadirect)
-        if (rows(addedcmap) > 0)
+        if (rows (addedcmap) > 0)
           for i = 1:data_idx
             if (have_3d_patch(i))
               data{i}(end,:) = clim(2) * (data{i}(end, :) - 0.5) / cmap_sz;
              endif
           endfor
-          fprintf (plot_stream, "set cbrange [%g:%g];\n", clim(1), clim(2) *
-                   (cmap_sz + rows(addedcmap)) / cmap_sz);
+          fprintf (plot_stream, "set cbrange [%.15e:%.15e];\n", clim(1), clim(2) *
+                   (cmap_sz + rows (addedcmap)) / cmap_sz);
         else
-          fprintf (plot_stream, "set cbrange [%g:%g];\n", clim);
+          fprintf (plot_stream, "set cbrange [%.15e:%.15e];\n", clim);
         endif
       else
         fprintf (plot_stream, "set cbrange [1:%d];\n", cmap_sz +
@@ -1544,7 +1544,7 @@
       keypos = hlgnd.location;
       if (ischar (keypos))
         keypos = lower (keypos);
-        keyout = findstr (keypos, "outside");
+        keyout = strfind (keypos, "outside");
         if (! isempty (keyout))
           inout = "outside";
           keypos = keypos(1:keyout-1);
@@ -1581,16 +1581,17 @@
       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
     fputs (plot_stream, "set style data lines;\n");
 
     cmap = [cmap; addedcmap];
-    cmap_sz = cmap_sz + rows(addedcmap);
-    if (length(cmap) > 0)
+    cmap_sz = cmap_sz + rows (addedcmap);
+    if (length (cmap) > 0)
       fprintf (plot_stream,
                "set palette positive color model RGB maxcolors %i;\n",
                cmap_sz);
@@ -1628,7 +1629,7 @@
         if (numel (is_image_data) > 1 && is_image_data(2))
           ## Remove terminating semicolon
           n = max (strfind (withclause{1}, ";"));
-          if (! isempty(n))
+          if (! isempty (n))
             withclause{1} = withclause{1}(1:n-1);
           endif
         endif
@@ -1656,7 +1657,7 @@
             if (numel (is_image_data) > i && is_image_data(i+1))
               ## Remove terminating semicolon
               n = max (strfind (withclause{i}, ";"));
-              if (! isempty(n))
+              if (! isempty (n))
                 withclause{i} = withclause{i}(1:n-1);
               endif
             endif
@@ -1689,7 +1690,7 @@
           ## Can't write 3d patch data as binary as can't plot more than
           ## a single patch at a time and have to plot all patches together
           ## so that the gnuplot depth ordering is done correctly
-          for j = 1 : 4 : columns(data{i})
+          for j = 1 : 4 : columns (data{i})
             if (j != 1)
               fputs (plot_stream, "\n\n");
             endif
@@ -1729,9 +1730,9 @@
 endfunction
 
 function x = flip (x)
-  if (size (x, 1) == 1)
+  if (rows (x) == 1)
     x = fliplr (x);
-  elseif (size (x, 2) == 1 || ischar (x))
+  elseif (columns (x) == 1 || ischar (x))
     x = flipud (x);
   else
     x = flipud (fliplr (x));
@@ -2096,7 +2097,7 @@
                     fontname, fontspec, interpreter, scale, sgn, gnuplot_term)
   persistent warned_latex = false;
   if (strcmpi (interpreter, "tex"))
-    for n = 1 : numel(labels)
+    for n = 1 : numel (labels)
       labels{n} = __tex2enhanced__ (labels{n}, fontname, false, false);
     endfor
   elseif (strcmpi (interpreter, "latex"))
@@ -2146,7 +2147,7 @@
                    tickdir, ticklength, axispos);
         endif
 
-        labels = regexprep(labels, '%', "%%");
+        labels = regexprep (labels, '%', "%%");
         for i = 1:ntics
           fprintf (plot_stream, " \"%s\" %.15g", labels{k++}, tics(i));
           if (i < ntics)
@@ -2205,8 +2206,7 @@
     ticklabel = num2str (ticklabel(:), 5);
   endif
   if (ischar (ticklabel))
-    if (size (ticklabel, 1) == 1 && any (ticklabel == "|"))
-      n = setdiff (findstr (ticklabel, "|"), findstr (ticklabel, '\|'));
+    if (rows (ticklabel) == 1 && any (ticklabel == "|"))
       ticklabel = strsplit (ticklabel, "|");
     else
       ticklabel = cellstr (ticklabel);
@@ -2237,7 +2237,7 @@
   it = false;
   bld = false;
   if (! isempty (t.fontweight) && strcmpi (t.fontweight, "bold"))
-    if (! isempty(t.fontangle)
+    if (! isempty (t.fontangle)
         && (strcmpi (t.fontangle, "italic")
             || strcmpi (t.fontangle, "oblique")))
       f = cstrcat (f, "-bolditalic");
@@ -2247,7 +2247,7 @@
       f = cstrcat (f, "-bold");
       bld = true;
     endif
-  elseif (! isempty(t.fontangle)
+  elseif (! isempty (t.fontangle)
           && (strcmpi (t.fontangle, "italic")
               || strcmpi (t.fontangle, "oblique")))
     f = cstrcat (f, "-italic");
@@ -2276,13 +2276,13 @@
 
   ## The text object maybe multiline, and may be of any class
   str = getfield (obj, fld);
-  if (ischar (str) && size (str, 1) > 1)
+  if (ischar (str) && rows (str) > 1)
     str = cellstr (str);
   elseif (isnumeric (str))
     str = cellstr (num2str (str(:)));
   endif
   if (iscellstr (str))
-    for n = 1:numel(str)
+    for n = 1:numel (str)
       if (isnumeric (str{n}))
         str{n} = num2str (str{n});
       endif
@@ -2293,7 +2293,7 @@
   if (enhanced)
     if (strcmpi (obj.interpreter, "tex"))
       if (iscellstr (str))
-        for n = 1:numel(str)
+        for n = 1:numel (str)
           str{n} = __tex2enhanced__ (str{n}, fnt, it, bld);
         endfor
       else
@@ -2317,14 +2317,14 @@
     labels = cellstr (str);
   endif
   for marker = "_^" 
-    for m = 1 : numel(labels)
+    for m = 1 : numel (labels)
       n1 = strfind (labels{m}, sprintf ("\\%s", marker));
       n2 = strfind (labels{m}, marker);
       if (! isempty (n1))
         n1 = n1 + 1;
         n2 = setdiff (n2, n1);
-      end
-      for n = numel(n2):-1:1
+      endif
+      for n = numel (n2):-1:1
         labels{m} = [labels{m}(1:n2(n)-1), "\\", labels{m}(n2(n):end)];
       endfor
     endfor
@@ -2340,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}'
@@ -2349,7 +2349,7 @@
     else
       f = m{i}(2:end);
       if (isfield (sym, f))
-        g = getfield(sym, f);
+        g = getfield (sym, f);
         ## FIXME The symbol font doesn't seem to support bold or italic
         ##if (bld)
         ##  if (it)
@@ -2369,54 +2369,54 @@
         it = true;
         if (bld)
           str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ',
-                        str(s(i) + 3:end));
+                         str(s(i) + 3:end));
         else
           str = cstrcat (str(1:s(i) - 1), '/', fnt, '-italic ',
-                        str(s(i) + 3:end));
+                         str(s(i) + 3:end));
         endif
       elseif (strncmp (f, "bf", 2))
         bld = true;
         if (it)
           str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ',
-                        str(2(i) + 3:end));
+                         str(2(i) + 3:end));
         else
           str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bold ',
-                        str(s(i) + 3:end));
+                         str(s(i) + 3:end));
         endif
       elseif (strcmpi (f, "color"))
         ## FIXME Ignore \color but remove trailing {} block as well
-        d = strfind(str(e(i) + 1:end),'}');
+        d = strfind (str(e(i) + 1:end),'}');
         if (isempty (d))
           warning ('syntax error in \color argument');
         else
           str = cstrcat (str(1:s(i) - 1), str(e(i) + d + 1:end));
         endif
-      elseif(strcmpi (f, "fontname"))
-        b1 = strfind(str(e(i) + 1:end),'{');
-        b2 = strfind(str(e(i) + 1:end),'}');
-        if (isempty(b1) || isempty(b2))
+      elseif (strcmpi (f, "fontname"))
+        b1 = strfind (str(e(i) + 1:end),'{');
+        b2 = strfind (str(e(i) + 1:end),'}');
+        if (isempty (b1) || isempty (b2))
           warning ('syntax error in \fontname argument');
         else
           str = cstrcat (str(1:s(i) - 1), '/',
-                        str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}',
-                        str(e(i) + b2(1) + 1:end));
+                         str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}',
+                         str(e(i) + b2(1) + 1:end));
         endif
-      elseif(strcmpi (f, "fontsize"))
-        b1 = strfind(str(e(i) + 1:end),'{');
-        b2 = strfind(str(e(i) + 1:end),'}');
-        if (isempty(b1) || isempty(b2))
+      elseif (strcmpi (f, "fontsize"))
+        b1 = strfind (str(e(i) + 1:end),'{');
+        b2 = strfind (str(e(i) + 1:end),'}');
+        if (isempty (b1) || isempty (b2))
           warning ('syntax error in \fontname argument');
         else
           str = cstrcat (str(1:s(i) - 1), '/=',
-                        str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}',
-                        str(e(i) + b2(1) + 1:end));
+                         str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}',
+                         str(e(i) + b2(1) + 1:end));
         endif
       else
         ## Last desperate attempt to treat the symbol. Look for things
         ## like \pix, that should be translated to the symbol Pi and x
         for j = 1 : length (flds)
           if (strncmp (flds{j}, f, length (flds{j})))
-            g = getfield(sym, flds{j});
+            g = getfield (sym, flds{j});
             ## FIXME The symbol font doesn't seem to support bold or italic
             ##if (bld)
             ##  if (it)
@@ -2428,7 +2428,7 @@
             ##  g = regexprep (g, '/Symbol', '/Symbol-italic');
             ##endif
             str = cstrcat (str(1:s(i) - 1), g,
-                          str(s(i) + length (flds{j}) + 1:end));
+                           str(s(i) + length (flds{j}) + 1:end));
             break;
           endif
         endfor
@@ -2444,15 +2444,15 @@
 
   ## FIXME -- This is a mess... Is it worth it just for a "@" character?
 
-  [s, m] = regexp(str,'[_\^]','start','matches');
+  [s, m] = regexp (str,'[_\^]','start','matches');
   i = 1;
   p = 0;
   while (i < length (s))
-    if (i < length(s))
+    if (i < length (s))
       if (str(s(i) + p + 1) == "{")
-        s1 = strfind(str(s(i) + p + 2:end),'{');
+        s1 = strfind (str(s(i) + p + 2:end),'{');
         si = 1;
-        l1 = strfind(str(s(i) + p + 1:end),'}');
+        l1 = strfind (str(s(i) + p + 1:end),'}');
         li = 1;
         while (li <= length (l1) && si <= length (s1))
           if (l1(li) < s1(si))
@@ -2464,12 +2464,12 @@
             si++;
           endif
         endwhile
-        l1 = l1 (min (length(l1), si));
+        l1 = l1 (min (length (l1), si));
         if (s(i) + l1 + 1 == s(i+1))
           if (str(s(i + 1) + p + 1) == "{")
-            s2 = strfind(str(s(i + 1) + p + 2:end),'{');
+            s2 = strfind (str(s(i + 1) + p + 2:end),'{');
             si = 1;
-            l2 = strfind(str(s(i + 1) + p + 1:end),'}');
+            l2 = strfind (str(s(i + 1) + p + 1:end),'}');
             li = 1;
             while (li <= length (l2) && si <= length (s2))
               if (l2(li) < s2(si))
@@ -2481,20 +2481,20 @@
                 si++;
               endif
             endwhile
-            l2 = l2 (min (length(l2), si));
+            l2 = l2 (min (length (l2), si));
             if (length_string (str(s(i)+p+2:s(i)+p+l1-1)) <=
-                length_string(str(s(i+1)+p+2:s(i+1)+p+l2-1)))
+                length_string (str(s(i+1)+p+2:s(i+1)+p+l2-1)))
               ## Shortest already first!
               str = cstrcat (str(1:s(i)+p-1), "@", str(s(i)+p:end));
             else
               ## Have to swap sub/super-script to get shortest first.
               str = cstrcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+l2),
-                            str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+l2+1:end));
+                             str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+l2+1:end));
             endif
           else
             ## Have to swap sub/super-script to get shortest first.
             str = cstrcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+1),
-                          str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+2:end));
+                           str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+2:end));
           endif
           i += 2;
           p ++;
@@ -2519,7 +2519,7 @@
 endfunction
 
 function l = length_string (s)
-  l = length (s) - length (strfind(s,'{')) - length (strfind(s,'}'));
+  l = length (s) - length (strfind (s,'{')) - length (strfind (s,'}'));
   m = regexp (s, '/([\w-]+|[\w-]+=\d+)', 'matches');
   if (!isempty (m))
     l = l - sum (cellfun ("length", m));
--- a/scripts/plot/private/__go_draw_figure__.m
+++ b/scripts/plot/private/__go_draw_figure__.m
@@ -44,6 +44,7 @@
         else
           bg_is_set = false;
         endif
+        fg_was_set = false;
 
         for i = nkids:-1:1
           type = get (kids(i), "type");
@@ -142,6 +143,11 @@
                   if (isnumeric (fg) && strcmp (get (kids(i), "visible"), "on"))
                     fprintf (plot_stream, "set obj 2 rectangle from graph 0,0 to graph 1,1 behind fc rgb \"#%02x%02x%02x\"\n", 255 * fg);
                     fg_is_set = true;
+                    fg_was_set = true;
+                  elseif (fg_was_set)
+                    fprintf (plot_stream, "unset obj 2\n");
+                    fg_is_set = false;
+                    fg_was_set = false;
                   else
                     fg_is_set = false;
                   endif
@@ -152,12 +158,12 @@
                   ## to __go_draw_axes__
                   hlegend = [];
                   fkids = get (h, "children");
-                  for j = 1 : numel(fkids)
+                  for j = 1 : numel (fkids)
                     if (ishandle (fkids (j))
                         && strcmp (get (fkids (j), "type"), "axes")
                         && (strcmp (get (fkids (j), "tag"), "legend")))
                       udata = get (fkids (j), "userdata");
-                      if (isscalar(udata.handle)
+                      if (isscalar (udata.handle)
                           && ! isempty (intersect (udata.handle, kids (i))))
                         hlegend = get (fkids (j));
                         break;
@@ -177,11 +183,17 @@
               endif
             case "uimenu"
               ## ignore uimenu objects
+              kids(i) = [];
             otherwise
               error ("__go_draw_figure__: unknown object class, %s", type);
           endswitch
         endfor
-        fputs (plot_stream, "\nunset multiplot;\n");
+        if (isempty (kids))
+          fputs (plot_stream, "\nreset; clear;\n");
+          fflush (plot_stream);
+        else
+          fputs (plot_stream, "\nunset multiplot;\n");
+        endif
       else
         fputs (plot_stream, "\nreset; clear;\n");
         fflush (plot_stream);
--- a/scripts/plot/private/__interp_cube__.m
+++ b/scripts/plot/private/__interp_cube__.m
@@ -23,7 +23,7 @@
 ## Undocumented internal function.
 ## @end deftypefn
 
-function [Vxyz, idx, frac] = __interp_cube__(x, y, z, val, v, req = "values" )
+function [Vxyz, idx, frac] = __interp_cube__ (x, y, z, val, v, req = "values" )
   if (ismatrix (x) && ndims (x) == 3 && ismatrix (y) && ndims (y) == 3 ...
        && ismatrix (z) && ndims (z) == 3 && size_equal (x, y, z, val))
     x = squeeze (x(1,:,1))(:);
@@ -34,12 +34,12 @@
     y = y(:);
     z = z(:);
   else
-    error("__interp_cube__: X, Y, Z have wrong dimensions");
+    error ("__interp_cube__: X, Y, Z have wrong dimensions");
   endif
   if (size (val) != [length(x), length(y), length(z)])
     error ("__interp_cube__: VAL has wrong dimensions");
   endif
-  if (size (v, 2) != 3)
+  if (columns (v) != 3)
     error ( "v has to be N*3 matrix");
   endif
   if (!ischar (req))
@@ -101,7 +101,7 @@
   endswitch
 endfunction
 
-function [Vxyz, idx, frac] = interp_cube_trilin(x, y, z, val, v)
+function [Vxyz, idx, frac] = interp_cube_trilin (x, y, z, val, v)
   [idx, frac] = cube_idx (x(:), y(:), z(:), v);
   sval = size (val);
   i000 = sub2ind (sval, idx(:, 1), idx(:, 2), idx(:, 3));
@@ -126,7 +126,7 @@
     val( i111 ) .* Bx .* By .* Bz;
 endfunction
 
-function [Dx, Dy, Dz, idx, frac] = interp_cube_trilin_grad(x, y, z, val, v)
+function [Dx, Dy, Dz, idx, frac] = interp_cube_trilin_grad (x, y, z, val, v)
   [idx, frac] = cube_idx (x(:), y(:), z(:), v);
   sval = size (val);
   i000 = sub2ind (sval, idx(:, 1), idx(:, 2), idx(:, 3));
@@ -169,7 +169,7 @@
     val( i111 ) .* Bx .* By;
 endfunction
 
-function [idx, frac] = cube_idx(x, y, z, v)
+function [idx, frac] = cube_idx (x, y, z, v)
   idx = zeros (size (v));
   frac = zeros (size (v));
   idx(:, 2) = lookup (x(2:end-1), v(:, 1)) + 1;
--- a/scripts/plot/private/__line__.m
+++ b/scripts/plot/private/__line__.m
@@ -35,8 +35,8 @@
 
   nvargs = numel (varargin);
 
-  if (nvargs > 1 && isnumeric (varargin{1}) && isnumeric (varargin{2}))
-    if (nvargs > 2 && isnumeric (varargin{3}))
+  if (nvargs > 1 && ! ischar (varargin{1}) && ! ischar (varargin{2}))
+    if (nvargs > 2 && ! ischar (varargin{3}))
       num_data_args = 3;
     else
       num_data_args = 2;
@@ -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)
@@ -90,11 +98,14 @@
   data = cell (1, 3);
 
   if (num_data_args > 1)
-    data(1) = varargin{1};
-    data(2) = varargin{2};
-    if (num_data_args == 3)
-      data(3) = varargin{3};
-    endif
+    data(1:num_data_args) = varargin(1:num_data_args);
+    for i = 1:num_data_args
+      if (islogical (data{i}))
+        data(i) = double (data{i});
+      elseif (iscomplex (data{i}))
+        data(i) = real (data{i});
+      endif
+    endfor
   endif
 
   data_args = reshape ({"xdata", "ydata", "zdata"; data{:}}, [1, 6]);
--- a/scripts/plot/private/__marching_cube__.m
+++ b/scripts/plot/private/__marching_cube__.m
@@ -169,13 +169,13 @@
     if (calc_cols)
       pp(id__, 1:5, jj) = [vertex_interp(iso, xx(id1), yy(id1), zz(id1), ...
         xx(id2), yy(id2), zz(id2), c(id1), c(id2), colors(id1), colors(id2)), ...
-        (1:size (id_, 1))' + ix_offset ];
+        (1:rows (id_))' + ix_offset ];
     else
       pp(id__, 1:4, jj) = [vertex_interp(iso, xx(id1), yy(id1), zz(id1), ...
         xx(id2), yy(id2), zz(id2), c(id1), c(id2)), ...
-        (1:size (id_, 1))' + ix_offset ];
+        (1:rows (id_))' + ix_offset ];
     endif
-    ix_offset += size (id_, 1);
+    ix_offset += rows (id_);
   endfor
 
   ## phase III: calculate the triangulation from the point list
@@ -183,7 +183,7 @@
   tri = tri_table(cc(id)+1, :);
   for jj=1:3:15
     id_ = find (tri(:, jj)>0);
-    p = [id_, lindex*ones(size (id_, 1), 1),tri(id_, jj:jj+2)];
+    p = [id_, lindex*ones(rows (id_), 1),tri(id_, jj:jj+2)];
     if (!isempty (p))
       p1 = sub2ind (size (pp), p(:,1), p(:,2), p(:,3));
       p2 = sub2ind (size (pp), p(:,1), p(:,2), p(:,4));
@@ -205,7 +205,7 @@
   endfor
 endfunction
 
-function p = vertex_interp(isolevel,p1x, p1y, p1z,...
+function p = vertex_interp (isolevel,p1x, p1y, p1z,...
   p2x, p2y, p2z,valp1,valp2, col1, col2)
 
   if (nargin == 9)
@@ -235,7 +235,7 @@
   endif
 endfunction
 
-function [edge_table, tri_table] = init_mc()
+function [edge_table, tri_table] = init_mc ()
   edge_table = [
   0x0  , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, ...
   0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00, ...
--- a/scripts/plot/private/__patch__.m
+++ b/scripts/plot/private/__patch__.m
@@ -40,12 +40,12 @@
   elseif (isstruct (varargin{1}))
     if (isfield (varargin{1}, "vertices") && isfield (varargin{1}, "faces"))
       args{1} = "faces";
-      args{2} = getfield(varargin{1}, "faces");
+      args{2} = getfield (varargin{1}, "faces");
       args{3} = "vertices";
-      args{4} = getfield(varargin{1}, "vertices");
+      args{4} = getfield (varargin{1}, "vertices");
       args{5} = "facevertexcdata";
       if (isfield (varargin{1}, "facevertexcdata"))
-        args{6} = getfield(varargin{1}, "facevertexcdata");
+        args{6} = getfield (varargin{1}, "facevertexcdata");
       else
         args{6} = [];
       endif
@@ -97,7 +97,7 @@
         if (isnumeric (c))
           if (isvector (c) && numel (c) == numel (x))
             c = c(:);
-          elseif (size (c, 1) != numel (x) && size (c, 2) == numel (x))
+          elseif (rows (c) != numel (x) && columns (c) == numel (x))
             c = c.';
           endif
         endif
@@ -111,7 +111,7 @@
 
       if (isnumeric (c))
 
-        if (ndims (c) == 3 && size (c, 2) == 1)
+        if (ndims (c) == 3 && columns (c) == 1)
           c = permute (c, [1, 3, 2]);
         endif
 
@@ -136,14 +136,14 @@
           args{10} = [];
         elseif (ndims (c) == 3 && size (c, 3) == 3)
           ## CDATA is specified as RGB data
-          if ((size (c, 1) == 1 && size (c, 2) == 1) ...
-              || (size (c, 1) == 1 && size (c, 2) == columns (x)))
+          if ((rows (c) == 1 && columns (c) == 1) ...
+              || (rows (c) == 1 && columns (c) == columns (x)))
             ## Single patch color or per-face color
             args{7} = "facecolor";
             args{8} = "flat";
             args{9} = "cdata";
             args{10} = c;
-          elseif (size (c, 1) == rows (x) && size (c, 2) == columns (x))
+          elseif (rows (c) == rows (x) && columns (c) == columns (x))
             ## Per-vertex color
             args{7} = "facecolor";
             args{8} = "interp";
@@ -209,7 +209,7 @@
   endif
 endfunction
 
-function args = delfields(args, flds)
+function args = delfields (args, flds)
   idx = cellfun (@(x) any (strcmpi (x, flds)), args);
   if (rows (idx) == 1)
     idx = idx | [false, idx(1:end-1)];
@@ -237,13 +237,13 @@
     vert = args {idx};
   endif
   idx = find (strcmpi (args, "facevertexcdata"), 1, "last") + 1;
-  if (isempty(idx) || idx > nargs)
+  if (isempty (idx) || idx > nargs)
     fvc = [];
   else
     fvc = args {idx};
   endif
   idx = find (strcmpi (args, "facecolor"), 1, "last") + 1;
-  if (isempty(idx) || idx > nargs)
+  if (isempty (idx) || idx > nargs)
     if (!isempty (fvc))
       fc = "flat";
     else
@@ -252,7 +252,7 @@
     args = {"facecolor", fc, args{:}};
   endif
 
-  nc = size (faces, 1);
+  nc = rows (faces);
   idx = faces .';
   t1 = isnan (idx);
   for i = find (any (t1))
@@ -261,22 +261,22 @@
   endfor
   x = reshape (vert(:,1)(idx), size (idx));
   y = reshape (vert(:,2)(idx), size (idx));
-  if (size(vert,2) > 2)
+  if (columns (vert) > 2)
     z = reshape (vert(:,3)(idx), size (idx));
   else
     z = [];
   endif
 
-  if (size(fvc, 1) == nc || size (fvc, 1) == 1)
+  if (rows (fvc) == nc || rows (fvc) == 1)
     c = reshape (fvc, [1, size(fvc)]);
   else
-    if (size(fvc, 2) == 3)
-      c = cat(3, reshape (fvc(idx, 1), size(idx)),
-              reshape (fvc(idx, 2), size(idx)),
-              reshape (fvc(idx, 3), size(idx)));
+    if (columns (fvc) == 3)
+      c = cat (3, reshape (fvc(idx, 1), size (idx)),
+               reshape (fvc(idx, 2), size (idx)),
+               reshape (fvc(idx, 3), size (idx)));
     elseif (isempty (fvc))
       c = [];
-    else ## if (size (fvc, 2) == 1)
+    else ## if (columnns (fvc) == 1)
       c = permute (fvc(faces), [2, 1]);
     endif
   endif
@@ -301,19 +301,19 @@
     y = args {idx};
   endif
   idx = find (strcmpi (args, "zdata"), 1, "last") + 1;
-  if (isempty(idx) || idx > nargs)
+  if (isempty (idx) || idx > nargs)
     z = [];
   else
     z = args {idx};
   endif
   idx = find (strcmpi (args, "cdata"), 1, "last") + 1;
-  if (isempty(idx) || idx > nargs)
+  if (isempty (idx) || idx > nargs)
     c = [];
   else
     c = args {idx};
   endif
   idx = find (strcmpi (args, "facecolor"), 1, "last") + 1;
-  if (isempty(idx) || idx > nargs)
+  if (isempty (idx) || idx > nargs)
     if (!isempty (c))
       fc = "flat";
     else
@@ -326,17 +326,17 @@
   if (nr == 1 && nc > 1)
     nr = nc;
     nc = 1;
-  end
+  endif
   if (!isempty (z))
     vert = [x(:), y(:), z(:)];
   else
     vert = [x(:), y(:)];
   endif
-  faces = reshape (1:numel(x), nr, nc);
+  faces = reshape (1:numel (x), nr, nc);
   faces = faces';
 
   if (ndims (c) == 3)
-    fvc = reshape (c, size (c, 1) * size (c, 2), size(c, 3));
+    fvc = reshape (c, rows (c) * columns (c), size (c, 3));
   else
     fvc = c(:);
   endif
--- a/scripts/plot/private/__pie__.m
+++ b/scripts/plot/private/__pie__.m
@@ -123,10 +123,10 @@
       sc = i * ones (size (sz));
 
       hlist = [hlist;
-        patch(xoff + [0, - sind(xn)], yoff + [0, cosd(xn)], zeros (1, ln + 1), i);
-        surface(sx, sy, sz, sc);
-        patch(xoff + [0, - sind(xn)], yoff + [0, cosd(xn)], zlvl * ones (1, ln + 1), i);
-        text(xt, yt, zlvl, labels{i})];
+        patch (xoff + [0, - sind(xn)], yoff + [0, cosd(xn)], zeros (1, ln + 1), i);
+        surface (sx, sy, sz, sc);
+        patch (xoff + [0, - sind(xn)], yoff + [0, cosd(xn)], zlvl * ones (1, ln + 1), i);
+        text (xt, yt, zlvl, labels{i})];
 
     elseif (strncmp (caller, "pie", 3))
       if (xt > 0)
@@ -136,14 +136,14 @@
       endif
 
       hlist = [hlist; patch(xoff + [0, - sind(xn)], yoff + [0, cosd(xn)], i);
-               text(xt, yt, labels{i}, "horizontalalignment", align)];
+               text (xt, yt, labels{i}, "horizontalalignment", align)];
 
     else
       error ("__pie__: unknown caller `%s'", caller);
     endif
   endfor
 
-  addlistener(gca, "view", {@update_text_pos, hlist});
+  addlistener (gca, "view", {@update_text_pos, hlist});
 
   if (strncmp (caller, "pie3", 4))
     axis ([-1.25, 1.25, -1.25, 1.25, -0.05, 0.4], "equal", "off");
--- a/scripts/plot/private/__plt__.m
+++ b/scripts/plot/private/__plt__.m
@@ -37,8 +37,8 @@
     properties = {};
 
     hlegend = [];
-    fkids = get (gcf(), "children");
-    for i = 1 : numel(fkids)
+    fkids = get (gcf (), "children");
+    for i = 1 : numel (fkids)
       if (ishandle (fkids (i)) && strcmp (get (fkids (i), "type"), "axes")
           && (strcmp (get (fkids (i), "tag"), "legend")))
         udata = get (fkids (i), "userdata");
@@ -132,7 +132,7 @@
     endwhile
 
     if (setlgnd)
-      legend (gca(), hlgnd, tlgnd);
+      legend (gca (), hlgnd, tlgnd);
     endif
   else
     error ("__plt__: invalid number of arguments");
@@ -177,14 +177,17 @@
   [nr, nc] = size (x1);
   if (nr == 1)
     x1 = x1.';
-    tmp = nr;
-    nr = nc;
-    nc = tmp;
+    [nr, nc] = deal (nc, nr);   # Swap rows and columns
   endif
-  x1_i = imag (x1);
-  if (any (any (x1_i)))
-    x2 = x1_i;
-    x1 = real (x1);
+  if (iscomplex (x1))
+    x1_i = imag (x1);
+    if (any ((x1_i(:))))
+      x2 = x1_i;
+      x1 = real (x1);
+    else
+      x2 = x1;
+      x1 = (1:nr)';
+    endif
   else
     x2 = x1;
     x1 = (1:nr)';
@@ -212,11 +215,15 @@
     error ("__plt1__: options must be a struct array");
   endif
 
-  if (any (any (imag (x1))))
+  if (islogical (x1))
+    x1 = int8 (x1);
+  elseif (iscomplex ((x1)))
     x1 = real (x1);
   endif
 
-  if (any (any (imag (x2))))
+  if (islogical (x2))
+    x2 = int8 (x2);
+  elseif (iscomplex (x2))
     x2 = real (x2);
   endif
 
--- a/scripts/plot/private/__pltopt__.m
+++ b/scripts/plot/private/__pltopt__.m
@@ -206,7 +206,7 @@
       elseif (topt == ";")
         t = index (opt(2:end), ";");
         if (t)
-          options.key = undo_string_escapes (opt(2:t));
+          options.key = opt(2:t);
           n = t+1;
         else
           if (err_on_invalid)
--- a/scripts/plot/private/__print_parse_opts__.m
+++ b/scripts/plot/private/__print_parse_opts__.m
@@ -17,7 +17,7 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {@var{args} =} __print_parse_opts__ (@var{propname}, @var{propvalue})
+## @deftypefn  {Function File} {@var{args} =} __print_parse_opts__ (@var{propname}, @var{propvalue})
 ## @deftypefnx {Function File} {@var{args} =} __print_parse_opts__ (@var{struct})
 ## Undocumented internal function.
 ## @end deftypefn
@@ -36,6 +36,7 @@
   arg_st.fig2dev_binary = __quote_path__ (__find_binary__ ("fig2dev"));
   arg_st.fontsize = "";
   arg_st.font = "";
+  arg_st.scalefontsize = 1;
   arg_st.force_solid = 0; # 0=default, -1=dashed, +1=solid
   arg_st.formatted_for_printing = false;
   arg_st.ghostscript.binary = __quote_path__ (__ghostscript_binary__ ());
@@ -48,6 +49,8 @@
   arg_st.ghostscript.pageoffset = [];
   arg_st.ghostscript.resolution = 150;
   arg_st.ghostscript.antialiasing = false;
+  arg_st.ghostscript.antialiasing_textalphabits = 4;
+  arg_st.ghostscript.antialiasing_graphicsalphabits = 4;
   arg_st.loose = false;
   arg_st.lpr_binary = __quote_path__ (__find_binary__ ("lpr"));
   arg_st.name = "";
@@ -74,7 +77,7 @@
     varargin(1) = [];
   endif
 
-  for i = 1:numel(varargin)
+  for i = 1:numel (varargin)
     arg = strtrim (varargin{i});
     if (ischar (arg))
       if (strcmp (arg, "-color"))
@@ -117,6 +120,20 @@
         arg_st.fig2dev_binary = arg{10:end};
       elseif (strncmp (arg, "-PSTOEDIT:", 9))
         arg_st.pstoedit_binary = arg{10:end};
+      elseif (strncmpi (arg, "-textalphabits=", 15))
+        n = find (arg == "=");
+        if (! isempty (n) && n == numel (arg) - 1 && ismember (arg(end), "124"))
+          arg_st.ghostscript.antialiasing_textalphabits = str2num (arg(end));
+        else
+          error ("print: improper syntax, or value, for TextAlphaBits")
+        endif
+      elseif (strncmpi (arg, "-graphicsalphabits=", 19))
+        n = find (arg == "=");
+        if (! isempty (n) && n == numel (arg) - 1 && ismember (arg(end), "124"))
+          arg_st.ghostscript.antialiasing_graphicsalphabits = str2num (arg(end));
+        else
+          error ("print: improper syntax, or value, for GraphicsAlphaBits")
+        endif
       elseif ((length (arg) > 2) && arg(1:2) == "-G")
         arg_st.ghostscript.binary = file_in_path (getenv ("PATH"), arg(3:end));
         if (isempty (arg_st.ghostscript.binary))
@@ -326,8 +343,12 @@
       arg_st.ghostscript.pageoffset = paperposition(1:2);
     endif
   else
-    ## Convert canvas size to points from pixles.
-    arg_st.canvas_size = arg_st.canvas_size * 72 / arg_st.ghostscript.resolution;
+    ## Convert canvas size to points from pixels.
+    if (! isempty (arg_st.fontsize))
+      ## Work around the eps bbox having whole numbers (both gnuplot & gl2ps).
+      arg_st.scalefontsize = arg_st.ghostscript.resolution / 72;
+    endif
+    arg_st.ghostscript.resolution = 72;
     arg_st.ghostscript.papersize = arg_st.canvas_size;
     arg_st.ghostscript.epscrop = true;
     arg_st.ghostscript.pageoffset = [0, 0];
@@ -366,7 +387,7 @@
 %! assert (opts.use_color, 1);
 %! assert (opts.send_to_printer, true);
 %! assert (opts.canvas_size, [576, 432]);
-%! assert (opts.ghostscript.device, "pswrite")
+%! assert (opts.ghostscript.device, "pswrite");
 
 #%!test
 %! opts = __print_parse_opts__ ("test.pdf", "-S640,480");
@@ -378,7 +399,7 @@
 %! assert (opts.send_to_printer, true);
 %! assert (opts.use_color, 1);
 %! assert (opts.append_to_file, false);
-%! assert (opts.ghostscript.device, "pswrite")
+%! assert (opts.ghostscript.device, "pswrite");
 %! assert (opts.ghostscript.epscrop, false);
 
 #%!test
@@ -386,13 +407,13 @@
 %! assert (opts.tight_flag, true);
 %! assert (opts.send_to_printer, true);
 %! assert (opts.use_color, -1);
-%! assert (opts.ghostscript.device, "")
+%! assert (opts.ghostscript.device, "");
 
 #%!test
 %! opts = __print_parse_opts__ ("-djpg", "foobar", "-mono", "-loose");
-%! assert (opts.devopt, "jpeg")
-%! assert (opts.name, "foobar.jpg")
-%! assert (opts.ghostscript.device, "jpeg")
+%! assert (opts.devopt, "jpeg");
+%! assert (opts.name, "foobar.jpg");
+%! assert (opts.ghostscript.device, "jpeg");
 %! assert (opts.ghostscript.epscrop, true);
 %! assert (opts.ghostscript.papersize, "");
 %! assert (opts.ghostscript.pageoffset, [0, 0]);
@@ -402,24 +423,33 @@
 
 #%!test
 %! opts = __print_parse_opts__ ("-ddeskjet", "foobar", "-mono", "-Pmyprinter");
-%! assert (opts.ghostscript.output, "foobar.deskjet")
-%! assert (opts.ghostscript.device, "deskjet")
-%! assert (opts.devopt, "deskjet")
+%! assert (opts.ghostscript.output, "foobar.deskjet");
+%! assert (opts.ghostscript.device, "deskjet");
+%! assert (opts.devopt, "deskjet");
 %! assert (opts.send_to_printer, true);
 %! assert (opts.printer, "-Pmyprinter");
 %! assert (opts.use_color, -1);
 
 #%!test
 %! opts = __print_parse_opts__ ("-f5", "-dljet3");
-%! assert (opts.ghostscript.device, "ljet3")
-%! assert (strfind (opts.ghostscript.output, ".ljet3"))
-%! assert (opts.devopt, "ljet3")
+%! assert (opts.ghostscript.device, "ljet3");
+%! assert (strfind (opts.ghostscript.output, ".ljet3"));
+%! assert (opts.devopt, "ljet3");
 %! assert (opts.send_to_printer, true);
-%! assert (opts.figure, 5)
+%! assert (opts.figure, 5);
 
 function cmd = __quote_path__ (cmd)
-  if (any (cmd == " ") && ! (cmd(1) == """" && cmd(end) == """"))
-    cmd = strcat ("""", strrep (cmd, """", """"""), """");
+  if (! isempty (cmd))
+    is_quoted = all (cmd([1, end]) == "'");
+    if (! is_quoted)
+      dos_shell = ! isunix () && ispc ();
+      if (dos_shell && any (cmd == "/"))
+        cmd = strrep (cmd, "/", "\\");
+      endif
+      if (any (cmd == " "))
+        cmd = strcat ('"', strrep (cmd, '"', '""') ,'"');
+      endif
+    endif
   endif
 endfunction
 
@@ -539,7 +569,7 @@
   ##         Papersize is tall when portrait,and wide when landscape.
   if ((papersize(1) > papersize(2) && strcmpi (paperorientation, "portrait"))
       || (papersize(1) < papersize(2) && strcmpi (paperorientation, "landscape")))
-    papersize = papersize ([2,1]);
+    papersize = papersize([2,1]);
     paperposition = paperposition([2,1,4,3]);
   endif
 
--- a/scripts/plot/private/__quiver__.m
+++ b/scripts/plot/private/__quiver__.m
@@ -43,9 +43,9 @@
     v = varargin{ioff++};
     if (is3d)
       w = varargin{ioff++};
-      [x, y, z] = meshgrid (1:size(u,2), 1:size(u,1), 1:max(size(w)));
+      [x, y, z] = meshgrid (1:columns (u), 1:rows (u), 1:max (size (w)));
     else
-      [x, y] = meshgrid (1:size(u,2), 1:size(u,1));
+      [x, y] = meshgrid (1:columns (u), 1:rows (u));
     endif
     if (nargin >= ioff && isnumeric (varargin{ioff})
         && isscalar (varargin{ioff}))
@@ -62,7 +62,7 @@
     if (is3d)
       w = varargin{ioff++};
       if (isvector (x) && isvector (y) && isvector (z)
-          && (! isvector (u) || ! isvector (v) || ! isvector(w)))
+          && (! isvector (u) || ! isvector (v) || ! isvector (w)))
         [x, y, z] = meshgrid (x, y, z);
       endif
     else
@@ -112,10 +112,10 @@
     else
       [nx, ny] = size (x);
     endif
-    dx = (max(x(:)) - min(x(:))) ./ nx;
-    dy = (max(y(:)) - min(y(:))) ./ ny;
+    dx = (max (x(:)) - min (x(:))) ./ nx;
+    dy = (max (y(:)) - min (y(:))) ./ ny;
     if (is3d)
-      dz = (max(z(:)) - min(z(:))) ./ max (size (z));
+      dz = (max (z(:)) - min (z(:))) ./ max (size (z));
       len = max (sqrt (u(:).^2 + v(:).^2 + w(:).^2));
     else
       dz = 0;
@@ -124,7 +124,7 @@
     if (len > 0)
       sd = sqrt (dx.^2 + dy.^2 + dz.^2) / len;
       if (sd != 0)
-        s = sqrt(2) * autoscale * sd;
+        s = sqrt (2) * autoscale * sd;
       else # special case of identical points with multiple vectors
         s = autoscale;
       endif
@@ -349,10 +349,10 @@
     else
       [nx, ny] = size (x);
     endif
-    dx = (max(x(:)) - min(x(:))) ./ nx;
-    dy = (max(y(:)) - min(y(:))) ./ ny;
+    dx = (max (x(:)) - min (x(:))) ./ nx;
+    dy = (max (y(:)) - min (y(:))) ./ ny;
     if (is3d)
-      dz = (max(z(:)) - min(z(:))) ./ max (size (z));
+      dz = (max (z(:)) - min (z(:))) ./ max (size (z));
       len = max (sqrt (u(:).^2 + v(:).^2 + w(:).^2));
     else
       dz = 0;
@@ -361,7 +361,7 @@
     if (len > 0)
       sd = sqrt (dx.^2 + dy.^2 + dz.^2) / len;
       if (sd != 0)
-        s *= sqrt(2) * sd;
+        s *= sqrt (2) * sd;
       endif
       u = s * u;
       v = s * v;
--- a/scripts/plot/private/__scatter__.m
+++ b/scripts/plot/private/__scatter__.m
@@ -32,13 +32,13 @@
 
   if (nd == 3)
     z = varargin{6}(:);
-    idx = isnan(x) | isnan (y) | isnan (z);
+    idx = isnan (x) | isnan (y) | isnan (z);
     x (idx) = [];
     y (idx) = [];
     z (idx) = [];
     istart = 7;
   else
-    idx = isnan(x) | isnan (y);
+    idx = isnan (x) | isnan (y);
     x (idx) = [];
     y (idx) = [];
     z = zeros (length (x), 0);
@@ -111,7 +111,7 @@
   endwhile
 
   if (isempty (c))
-    c = __next_line_color__();
+    c = __next_line_color__ ();
   endif
 
   hg = hggroup ();
@@ -140,7 +140,7 @@
     ## For small number of points, we'll construct an object for each point.
 
     if (numel (s) == 1)
-      s = repmat (s, numel(x), 1);
+      s = repmat (s, numel (x), 1);
     endif
 
     if (one_explicit_color)
@@ -222,11 +222,11 @@
   if (! ischar (c) && rows (c) > 1)
     ax = get (hg, "parent");
     clim = get (ax, "clim");
-    if (min(c(:)) < clim(1))
-      clim(1) = min(c(:));
+    if (min (c(:)) < clim(1))
+      clim(1) = min (c(:));
       set (ax, "clim", clim);
     endif
-    if (max(c(:)) > clim(2))
+    if (max (c(:)) > clim(2))
       set (ax, "clim", [clim(1), max(c(:))]);
     endif
   endif
@@ -259,7 +259,7 @@
 
 endfunction
 
-function h = render_size_color(hg, vert, s, c, marker, filled, isflat)
+function h = render_size_color (hg, vert, s, c, marker, filled, isflat)
   if (isscalar (s))
     x = vert(:,1);
     y = vert(:,2);
@@ -268,11 +268,12 @@
     ## Does gnuplot only support triangles with different vertex colors ?
     ## TODO - Verify gnuplot can only support one color. If RGB triplets
     ##        can be assigned to each vertex, then fix __go_draw_axe__.m
-    gnuplot_hack = numel (x) > 1 && strcmp (toolkit, "gnuplot");
+    gnuplot_hack = (numel (x) > 1 && columns (c) == 3
+                    && strcmp (toolkit, "gnuplot"));
     if (ischar (c) || ! isflat || gnuplot_hack)
       if (filled)
         h = __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z,
-                          "faces", 1:numel(x), "vertices", vert,
+                          "faces", 1:numel (x), "vertices", vert,
                           "facecolor", "none", "edgecolor", "none",
                           "marker", marker,
                           "markeredgecolor", "none",
@@ -280,7 +281,7 @@
                           "markersize", s, "linestyle", "none");
       else
         h = __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z,
-                          "faces", 1:numel(x), "vertices", vert,
+                          "faces", 1:numel (x), "vertices", vert,
                           "facecolor", "none", "edgecolor", "none",
                           "marker", marker,
                           "markeredgecolor", c(1,:),
@@ -290,7 +291,7 @@
     else
       if (filled)
         h = __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z,
-                          "faces", 1:numel(x), "vertices", vert,
+                          "faces", 1:numel (x), "vertices", vert,
                           "facecolor", "none", "edgecolor", "none",
                           "marker", marker, "markersize", s,
                           "markeredgecolor", "none",
@@ -299,7 +300,7 @@
                           "linestyle", "none");
       else
         h = __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z,
-                          "faces", 1:numel(x), "vertices", vert,
+                          "faces", 1:numel (x), "vertices", vert,
                           "facecolor", "none", "edgecolor", "none",
                           "marker", marker, "markersize", s,
                           "markeredgecolor", "flat",
@@ -361,14 +362,14 @@
     if (isempty (z1))
       for i = 1 : length (hlist)
         set (hlist(i), "vertices", [x1(i), y1(i)], "cdata",
-             reshape(c1(i,:),[1, size(c1)(2:end)]),
+             reshape (c1(i,:),[1, size(c1)(2:end)]),
              "facevertexcdata", c1(i,:),
              "markersize", size1(i));
       endfor
     else
       for i = 1 : length (hlist)
         set (hlist(i), "vertices", [x1(i), y1(i), z1(i)], "cdata",
-             reshape(c1(i,:),[1, size(c1)(2:end)]),
+             reshape (c1(i,:),[1, size(c1)(2:end)]),
              "facevertexcdata", c1(i,:),
              "markersize", size1(i));
       endfor
--- a/scripts/plot/private/__stem__.m
+++ b/scripts/plot/private/__stem__.m
@@ -147,7 +147,7 @@
       if (! isempty (args))
         set (hg, args{:});
       endif
-      if (i == 1 && !isempty(h_baseline))
+      if (i == 1 && ! isempty (h_baseline))
         set (h_baseline, "parent", get (hg, "parent"));
       endif
     endfor
@@ -296,7 +296,7 @@
           error ("stem: X and Y must be matrices");
         endif
       endif
-    endif # if ischar(varargin{2})
+    endif # if ischar (varargin{2})
     if (! have_z)
       ## varargin{3} must be char.
       ## Check for "fill.
@@ -436,7 +436,7 @@
   [lc, ls, mc, ms] = set_default_values ();
   ## Parse the line specifier string.
   cur_props = __pltopt__ ("stem", str, false);
-  for i = 1:length(cur_props)
+  for i = 1:length (cur_props)
     if (isfield (cur_props(i), "color") && ! isempty (cur_props(i).color)); # means line color
       mc = lc = cur_props(i).color;
     elseif (isfield (cur_props(i), "linestyle"))
@@ -508,7 +508,7 @@
   endif
 
   kids = get (h, "children");
-  yt = get(h, "ydata")(:)';
+  yt = get (h, "ydata")(:)';
   ny = length (yt);
   yt = [b0 * ones(1, ny); yt; NaN(1, ny)](:);
   set (kids(2), "ydata", yt);
@@ -532,7 +532,7 @@
 
   if (!isempty (z) && size_equal (x, y, z))
     error ("stem3: inconsistent size of x, y and z");
-  elseif (numel(x) != numel (y))
+  elseif (numel (x) != numel (y))
     error ("stem: inconsistent size of x and y");
   else
     bl = get (h, "basevalue");
--- a/scripts/plot/private/__tight_eps_bbox__.m
+++ b/scripts/plot/private/__tight_eps_bbox__.m
@@ -58,12 +58,12 @@
     looking_for_bbox = true;
     while (looking_for_bbox)
       current_line = fgetl (fid);
-      if (strncmpi (current_line, box_string, numel(box_string)))
+      if (strncmpi (current_line, box_string, numel (box_string)))
         line_length = numel (current_line);
         num_spaces = line_length - numel (tight_bbox_line);
         if (numel (current_line) >= numel (tight_bbox_line))
           new_line = tight_bbox_line;
-          new_line(end+1:numel(current_line)) = " ";
+          new_line(end+1:numel (current_line)) = " ";
           bbox_replaced = true;
           ## Back up to the beginning of the line (include EOL characters).
           if (ispc ())
@@ -113,12 +113,12 @@
 function bbox_line = get_bbox (lines)
   box_string = "%%BoundingBox:";
   pattern = strcat (box_string, "[^%]*");
-  pattern = pattern(1:find(double(pattern)>32, 1, "last"));
+  pattern = pattern(1:find (double (pattern) > 32, 1, "last"));
   bbox_line = regexp (lines, pattern, "match");
   if (iscell (bbox_line))
     bbox_line = bbox_line{1};
   endif
   ## Remove the EOL characters.
-  bbox_line(double(bbox_line)<32) = "";
+  bbox_line(double (bbox_line) < 32) = "";
 endfunction
 
--- a/scripts/plot/private/__uigetdir_fltk__.m
+++ b/scripts/plot/private/__uigetdir_fltk__.m
@@ -25,7 +25,7 @@
 
 function dirname = __uigetdir_fltk__ (start_path, dialog_title)
 
-  if (exist("__fltk_uigetfile__") != 3)
+  if (exist ("__fltk_uigetfile__") != 3)
     error ("uigetdir: fltk graphics toolkit required");
   endif
 
--- a/scripts/plot/private/__uigetfile_fltk__.m
+++ b/scripts/plot/private/__uigetfile_fltk__.m
@@ -25,7 +25,7 @@
 
 function [retval, retpath, retindex] = __uigetfile_fltk__ (filters, title, defval, position, multiselect, defdir)
 
-  if (exist("__fltk_uigetfile__") != 3)
+  if (exist ("__fltk_uigetfile__") != 3)
     error ("uigetfile: fltk graphics toolkit required");
   endif
 
--- a/scripts/plot/private/__uiputfile_fltk__.m
+++ b/scripts/plot/private/__uiputfile_fltk__.m
@@ -25,7 +25,7 @@
 
 function [retval, retpath, retindex] = __uiputfile_fltk__ (filters, title, defval, position, tag, defdir)
 
-  if (exist("__fltk_uigetfile__") != 3)
+  if (exist ("__fltk_uigetfile__") != 3)
     error ("uiputfile: fltk graphics toolkit required");
   endif
 
--- a/scripts/plot/quiver.m
+++ b/scripts/plot/quiver.m
@@ -21,7 +21,7 @@
 ## @deftypefnx {Function File} {} quiver (@var{x}, @var{y}, @var{u}, @var{v})
 ## @deftypefnx {Function File} {} quiver (@dots{}, @var{s})
 ## @deftypefnx {Function File} {} quiver (@dots{}, @var{style})
-## @deftypefnx {Function File} {} quiver (@dots{}, 'filled')
+## @deftypefnx {Function File} {} quiver (@dots{}, "filled")
 ## @deftypefnx {Function File} {} quiver (@var{h}, @dots{})
 ## @deftypefnx {Function File} {@var{h} =} quiver (@dots{})
 ##
@@ -31,7 +31,7 @@
 ##
 ## If @var{x} and @var{y} are undefined they are assumed to be
 ## @code{(1:@var{m}, 1:@var{n})} where @code{[@var{m}, @var{n}] =
-## size(@var{u})}.
+## size (@var{u})}.
 ##
 ## The variable @var{s} is a scalar defining a scaling factor to use for
 ## the arrows of the field relative to the mesh spacing.  A value of 0
@@ -40,7 +40,7 @@
 ## The style to use for the plot can be defined with a line style @var{style}
 ## in a similar manner to the line styles used with the @code{plot} command.
 ## If a marker is specified then markers at the grid points of the vectors are
-## printed rather than arrows.  If the argument 'filled' is given then the
+## printed rather than arrows.  If the argument "filled" is given then the
 ## markers as filled.
 ##
 ## The optional return value @var{h} is a graphics handle to a quiver object.
@@ -83,17 +83,17 @@
 
 
 %!demo
-%! clf
+%! clf;
 %! [x,y] = meshgrid (1:2:20);
 %! h = quiver (x,y, sin (2*pi*x/10), sin (2*pi*y/10));
-%! set (h, "maxheadsize", 0.33);
+%! set (h, 'maxheadsize', 0.33);
 
 %!demo
-%! clf
-%! axis ("equal");
-%! x = linspace (0,3,80);
+%! clf;
+%! axis ('equal');
+%! x = linspace (0, 3, 80);
 %! y = sin (2*pi*x);
 %! theta = 2*pi*x + pi/2;
 %! quiver (x, y, sin (theta)/10, cos (theta)/10);
-%! hold on; plot(x,y,"r"); hold off;
+%! hold on; plot (x,y,'r'); hold off;
 
--- a/scripts/plot/quiver3.m
+++ b/scripts/plot/quiver3.m
@@ -21,7 +21,7 @@
 ## @deftypefnx {Function File} {} quiver3 (@var{x}, @var{y}, @var{z}, @var{u}, @var{v}, @var{w})
 ## @deftypefnx {Function File} {} quiver3 (@dots{}, @var{s})
 ## @deftypefnx {Function File} {} quiver3 (@dots{}, @var{style})
-## @deftypefnx {Function File} {} quiver3 (@dots{}, 'filled')
+## @deftypefnx {Function File} {} quiver3 (@dots{}, "filled")
 ## @deftypefnx {Function File} {} quiver3 (@var{h}, @dots{})
 ## @deftypefnx {Function File} {@var{h} =} quiver3 (@dots{})
 ##
@@ -31,7 +31,7 @@
 ##
 ## If @var{x}, @var{y} and @var{z} are undefined they are assumed to be
 ## @code{(1:@var{m}, 1:@var{n}, 1:@var{p})} where @code{[@var{m}, @var{n}] =
-## size(@var{u})} and @code{@var{p} = max (size (@var{w}))}.
+## size (@var{u})} and @code{@var{p} = max (size (@var{w}))}.
 ##
 ## The variable @var{s} is a scalar defining a scaling factor to use for
 ##  the arrows of the field relative to the mesh spacing.  A value of 0
@@ -40,7 +40,7 @@
 ## The style to use for the plot can be defined with a line style @var{style}
 ## in a similar manner to the line styles used with the @code{plot} command.
 ## If a marker is specified then markers at the grid points of the vectors are
-## printed rather than arrows.  If the argument 'filled' is given then the
+## printed rather than arrows.  If the argument "filled" is given then the
 ## markers as filled.
 ##
 ## The optional return value @var{h} is a graphics handle to a quiver object.
@@ -84,35 +84,38 @@
 
 endfunction
 
+
 %!demo
-%! clf
-%! colormap (jet (64));
+%! clf;
+%! colormap ('default');
 %! [x,y] = meshgrid (-1:0.1:1);
-%! z = sin (2*pi * sqrt (x.^2+y.^2));
-%! theta = 2*pi * sqrt (x.^2+y.^2) + pi/2;
+%! z = sin (2*pi * sqrt (x.^2 + y.^2));
+%! theta = 2*pi * sqrt (x.^2 + y.^2) + pi/2;
 %! quiver3 (x, y, z, sin (theta), cos (theta), ones (size (z)));
 %! hold on;
-%! mesh (x,y,z);
+%! mesh (x, y, z);
 %! hold off;
 
 %!demo
-%! clf
+%! clf;
+%! colormap ('default');
 %! [x, y, z] = peaks (25);
 %! surf (x, y, z);
 %! hold on;
 %! [u, v, w] = surfnorm (x, y, z / 10);
 %! h = quiver3 (x, y, z, u, v, w);
-%! set (h, "maxheadsize", 0.33);
+%! set (h, 'maxheadsize', 0.33);
 %! hold off;
 
 %!demo
-%! clf
+%! clf;
+%! colormap ('default');
 %! [x, y, z] = peaks (25);
 %! surf (x, y, z);
 %! hold on;
 %! [u, v, w] = surfnorm (x, y, z / 10);
 %! h = quiver3 (x, y, z, u, v, w);
-%! set (h, "maxheadsize", 0.33);
+%! set (h, 'maxheadsize', 0.33);
 %! hold off;
-%! shading interp
+%! shading interp;
 
--- a/scripts/plot/rectangle.m
+++ b/scripts/plot/rectangle.m
@@ -72,7 +72,7 @@
 
   while (iarg < length (varargin))
     arg = varargin{iarg};
-    if (ischar(arg))
+    if (ischar (arg))
       if (strcmpi (arg, "position"))
         pos = varargin{iarg+1};
         varargin(iarg:iarg+1) = [];
@@ -205,18 +205,18 @@
 
 
 %!demo
-%! clf
-%! axis equal
-%! rectangle ("Position", [0.05, 0.05, 0.9, 0.9], "Curvature", [0.5, 0.5]);
+%! clf;
+%! axis equal;
+%! rectangle ('Position', [0.05, 0.05, 0.9, 0.9], 'Curvature', [0.5, 0.5]);
 
 %!demo
-%! clf
-%! axis equal
-%! rectangle ("Position", [0.05, 0.05, 0.9, 0.4], "Curvature", 1.0);
+%! clf;
+%! axis equal;
+%! rectangle ('Position', [0.05, 0.05, 0.9, 0.4], 'Curvature', 1.0);
 
 %!demo
-%! clf
-%! axis equal
-%! h = rectangle ("Position", [0.05, 0.05, 0.9, 0.4], "Curvature",  1.0);
-%! set (h, "FaceColor", [0, 1, 0]);
+%! clf;
+%! axis equal;
+%! h = rectangle ('Position', [0.05, 0.05, 0.9, 0.4], 'Curvature', 1.0);
+%! set (h, 'FaceColor', [0, 1, 0]);
 
--- a/scripts/plot/refresh.m
+++ b/scripts/plot/refresh.m
@@ -19,24 +19,25 @@
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {} refresh ()
 ## @deftypefnx {Function File} {} refresh (@var{h})
-## Refresh a figure, forcing it to be redrawn.  Called without an
-## argument the current figure is redrawn, otherwise the figure pointed
+## Refresh a figure, forcing it to be redrawn.  When called without an
+## argument the current figure is redrawn.  Otherwise, the figure pointed
 ## to by @var{h} is redrawn.
 ## @seealso{drawnow}
 ## @end deftypefn
 
 function refresh (h)
 
-  if (nargin == 1)
-    if (!ishandle (h) || !strcmp (get (h, "type"), "figure"))
-      error ("refresh: expecting argument to be a valid figure handle");
+  if (nargin > 1)
+    print_usage ();
+  elseif (nargin == 1)
+    if (! isfigure (h))
+      error ("refresh: H must be a valid figure handle");
     endif
-  elseif (nargin > 1)
-    print_usage ();
   else
     h = gcf ();
   endif
 
-  set(h,"__modified__", "on");
+  set (h, "__modified__", "on");
   drawnow ();
+
 endfunction
--- a/scripts/plot/refreshdata.m
+++ b/scripts/plot/refreshdata.m
@@ -82,7 +82,7 @@
   for i = 1 : numel (h)
     obj = get (h (i));
     fldnames = fieldnames (obj);
-    m = regexpi (fieldnames(obj), '^.+datasource$', "match");
+    m = regexpi (fieldnames (obj), '^.+datasource$', "match");
     idx = ! cellfun ("isempty", m);
     if (any (idx))
       tmp = m(idx);
@@ -103,15 +103,18 @@
       endif
     endfor
   endfor
+
 endfunction
 
+
 %!demo
-%! clf
+%! clf;
 %! x = 0:0.1:10;
 %! y = sin (x);
-%! plot (x, y, "ydatasource", "y");
+%! plot (x, y, 'ydatasource', 'y');
 %! for i = 1 : 100
-%!   pause(0.1)
+%!   pause (0.1);
 %!   y = sin (x + 0.1 * i);
-%!   refreshdata(gcf(), "caller");
-%! endfor
+%!   refreshdata (gcf, 'caller');
+%! end
+
--- a/scripts/plot/ribbon.m
+++ b/scripts/plot/ribbon.m
@@ -23,7 +23,7 @@
 ## Plot a ribbon plot for the columns of @var{y} vs.  @var{x}.  The
 ## optional parameter @var{width} specifies the width of a single ribbon
 ## (default is 0.75).  If @var{x} is omitted, a vector containing the
-## row numbers is assumed (1:rows(Y)).
+## row numbers is assumed (1:rows (Y)).
 ##
 ## The optional return value @var{h} is a vector of graphics handles to
 ## the surface objects representing each ribbon.
@@ -31,9 +31,11 @@
 
 ## Author: Kai Habel <kai.habel at gmx.de>
 
-function h = ribbon (x, y, width)
+function h = ribbon (x, y, width = 0.75)
 
-  newplot ();
+  if (nargin < 1 || nargin > 3)
+    print_usage ();
+  endif
 
   if (nargin == 1)
     y = x;
@@ -42,54 +44,53 @@
     endif
     [nr, nc] = size (y);
     x = repmat ((1:nr)', 1, nc);
-    width = 0.75;
-  elseif (nargin == 2)
-    width = 0.75;
-  elseif (nargin != 3)
-    print_usage ();
   endif
 
   if (isvector (x) && isvector (y))
     if (length (x) != length (y))
-      error ("ribbon: in case of vectors, X and Y must have same length");
+      error ("ribbon: vectors X and Y must have the same length");
     else
       [x, y] = meshgrid (x, y);
     endif
   else
-    if (! size_equal(x, y))
-      error ("ribbon: in case of matrices, X and Y must have same size");
+    if (! size_equal (x, y))
+      error ("ribbon: matrices X and Y must have the same size");
     endif
   endif
 
+  newplot ();
+
   [nr, nc] = size (y);
-  tmp = zeros (1, nc);
+  htmp = zeros (nc, 1);
 
   for c = nc:-1:1
     zz = [y(:,c), y(:,c)];
     yy = x(:,c);
     xx = [c - width / 2, c + width / 2];
     [xx, yy] = meshgrid (xx, yy);
-    cc = ones (size (zz)) * c;
-    tmp(c) = surface (xx, yy, zz, cc);
+    cc = repmat (c, size (zz));
+    htmp(c) = surface (xx, yy, zz, cc);
   endfor
 
-  ax = get (tmp(c), "parent");
-
   if (! ishold ())
-    set (ax, "view", [-37.5, 30], "box", "off", "xgrid", "on",
-         "ygrid", "on", "zgrid", "on");
+    ax = get (htmp(1), "parent");
+    set (ax, "view", [-37.5, 30], "box", "off", 
+             "xgrid", "on", "ygrid", "on", "zgrid", "on");
   endif
 
   if (nargout > 0)
-    h = tmp;
+    h = htmp;
   endif
 
 endfunction
 
 
 %!demo
-%! clf
+%! clf;
+%! colormap ('default');
 %! [x, y, z] = sombrero ();
 %! [x, y] = meshgrid (x, y);
 %! ribbon (y, z);
 
+%!FIXME: Could have some input validation tests here
+
--- a/scripts/plot/rose.m
+++ b/scripts/plot/rose.m
@@ -80,7 +80,7 @@
   x1 = xx(1:end-1) + diff (xx, 1) / 2;
   x1 = [x1 ; x1; x1; x1](:);
   th = [0; 0; x1; 2*pi ; 2*pi];
-  r = zeros (4 * size (nn, 1), size (nn, 2));
+  r = zeros (4 * rows (nn), columns (nn));
   r(2:4:end, :) = nn;
   r(3:4:end, :) = nn;
 
@@ -106,6 +106,6 @@
 
 
 %!demo
-%! clf
+%! clf;
 %! rose ([2*randn(1e5, 1), pi + 2*randn(1e5, 1)]);
 
--- a/scripts/plot/scatter.m
+++ b/scripts/plot/scatter.m
@@ -50,7 +50,7 @@
 ## @group
 ## x = randn (100, 1);
 ## y = randn (100, 1);
-## scatter (x, y, [], sqrt(x.^2 + y.^2));
+## scatter (x, y, [], sqrt (x.^2 + y.^2));
 ## @end group
 ## @end example
 ##
@@ -82,102 +82,115 @@
 
 
 %!demo
-%! clf
+%! clf;
 %! x = randn (100, 1);
 %! y = randn (100, 1);
-%! scatter (x, y, "r");
+%! scatter (x, y, 'r');
+%! title ('Scatter plot with red bubbles');
 
 %!demo
-%! clf
+%! clf;
+%! x = randn (100, 1);
+%! y = randn (100, 1);
+%! c = x .* y;
+%! scatter (x, y, 20, c, 'filled');
+%! title ('Scatter with colors');
+
+%!demo
+%! clf;
 %! x = randn (100, 1);
 %! y = randn (100, 1);
 %! scatter (x, y, [], sqrt (x.^2 + y.^2));
+%! title ('Scatter plot with bubble color determined by distance from origin');
 
 %!demo
-%! clf
+%! clf;
 %! rand_10x1_data1 = [0.171577, 0.404796, 0.025469, 0.335309, 0.047814, 0.898480, 0.639599, 0.700247, 0.497798, 0.737940];
 %! rand_10x1_data2 = [0.75495, 0.83991, 0.80850, 0.73603, 0.19360, 0.72573, 0.69371, 0.74388, 0.13837, 0.54143];
 %! x = rand_10x1_data1;
 %! y = rand_10x1_data2;
 %! s = 10 - 10*log (x.^2 + y.^2);
-%! h = scatter (x, y, s, s, "s", "filled");
+%! h = scatter (x, y, s, s, 's', 'filled');
+%! title ({'Scatter plot with filled square markers', ...
+%!         'size and color of markers determined by algorithm'});
 
 %!demo
-%! clf
+%! clf;
 %! rand_10x1_data3 = [0.42262, 0.51623, 0.65992, 0.14999, 0.68385, 0.55929, 0.52251, 0.92204, 0.19762, 0.93726];
 %! rand_10x1_data4 = [0.020207, 0.527193, 0.443472, 0.061683, 0.370277, 0.947349, 0.249591, 0.666304, 0.134247, 0.920356];
 %! x = rand_10x1_data3;
 %! y = rand_10x1_data4;
 %! s = 10 - 10*log (x.^2 + y.^2);
-%! h = scatter (x, y, [], "r", "s", "filled");
+%! h = scatter (x, y, [], 'r', 's', 'filled');
 
 %!demo
-%! clf
+%! clf;
 %! rand_10x1_data5 = [0.777753, 0.093848, 0.183162, 0.399499, 0.337997, 0.686724, 0.073906, 0.651808, 0.869273, 0.137949];
 %! rand_10x1_data6 = [0.37460, 0.25027, 0.19510, 0.51182, 0.54704, 0.56087, 0.24853, 0.75443, 0.42712, 0.44273];
 %! x = rand_10x1_data5;
 %! y = rand_10x1_data6;
 %! s = 10 - 10*log (x.^2 + y.^2);
-%! h = scatter (x, y, [], "r", "s");
+%! h = scatter (x, y, [], 'r', 's');
 
 %!demo
+%! clf;
 %! k = 1;
-%! clf
 %! for m = [1, 3]
 %!   for n = [101, 50, 1]
 %!     x = rand (n, 1);
 %!     y = rand (n, 1);
 %!     if (m > 1)
-%!       str = "Three Colors";
+%!       str = 'Three Colors';
 %!       idx = ceil (rand (n, 1) * 3);
-%!       colors = eye(3);
+%!       colors = eye (3);
 %!       colors = colors(idx, :);
 %!     else
-%!       str = "Random Colors";
+%!       str = 'Random Colors';
 %!       colors = rand (n, m);
-%!     endif
+%!     end
 %!     if (n == 1)
-%!       str = sprintf ("%s: 1 point", str);
+%!       str = sprintf ('%s: 1 point', str);
 %!     elseif (n < 100)
-%!       str = sprintf ("%s: < 100 points", str);
+%!       str = sprintf ('%s: < 100 points', str);
 %!     else
-%!       str = sprintf ("%s: > 100 points", str);
-%!     endif
-%!     subplot (2, 3, k)
+%!       str = sprintf ('%s: > 100 points', str);
+%!     end
+%!     subplot (2,3,k);
 %!     k = k + 1;
-%!     scatter (x, y, 15, colors, "filled")
-%!     axis ([0 1 0 1])
-%!     title (str)
-%!   endfor
-%! endfor
+%!     scatter (x, y, 15, colors, 'filled');
+%!     axis ([0 1 0 1]);
+%!     title (str);
+%!   end
+%! end
 
 %!demo
+%! clf;
 %! k = 1;
-%! clf
 %! for m = [1, 3]
 %!   for n = [101, 50, 1]
 %!     x = rand (n, 1);
 %!     y = rand (n, 1);
 %!     if (m > 1)
-%!       str = "Three Colors";
+%!       str = 'Three Colors';
 %!       idx = ceil (rand (n, 1) * 3);
-%!       colors = eye(3);
+%!       colors = eye (3);
 %!       colors = colors(idx, :);
 %!     else
-%!       str = "Random Colors";
+%!       str = 'Random Colors';
 %!       colors = rand (n, m);
-%!     endif
+%!     end
 %!     if (n == 1)
-%!       str = sprintf ("%s: 1 point", str);
+%!       str = sprintf ('%s: 1 point', str);
 %!     elseif (n < 100)
-%!       str = sprintf ("%s: < 100 points", str);
+%!       str = sprintf ('%s: < 100 points', str);
 %!     else
-%!       str = sprintf ("%s: > 100 points", str);
-%!     endif
-%!     subplot (2, 3, k)
+%!       str = sprintf ('%s: > 100 points', str);
+%!     end
+%!     subplot (2,3,k);
 %!     k = k + 1;
-%!     scatter (x, y, 15, colors)
-%!     axis ([0 1 0 1])
-%!     title (str)
-%!   endfor
-%! endfor
+%!     scatter (x, y, 15, colors);
+%!     axis ([0 1 0 1]);
+%!     title (str);
+%!   end
+%! end
+
--- a/scripts/plot/scatter3.m
+++ b/scripts/plot/scatter3.m
@@ -18,7 +18,7 @@
 
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {} scatter3 (@var{x}, @var{y}, @var{z}, @var{s}, @var{c})
-## @deftypefnx {Function File} {} scatter3 (@dots{}, 'filled')
+## @deftypefnx {Function File} {} scatter3 (@dots{}, "filled")
 ## @deftypefnx {Function File} {} scatter3 (@dots{}, @var{style})
 ## @deftypefnx {Function File} {} scatter3 (@dots{}, @var{prop}, @var{val})
 ## @deftypefnx {Function File} {} scatter3 (@var{h}, @dots{})
@@ -38,7 +38,7 @@
 ##
 ## The marker to use can be changed with the @var{style} argument, that is a
 ## string defining a marker in the same manner as the @code{plot} command.
-## If the argument 'filled' is given then the markers as filled.  All
+## If the argument "filled" is given then the markers as filled.  All
 ## additional arguments are passed to the underlying patch command.
 ##
 ## The optional return value @var{h} is a graphics handle to the hggroup
@@ -84,28 +84,27 @@
 
 
 %!demo
-%! clf
+%! clf;
 %! [x, y, z] = peaks (20);
 %! scatter3 (x(:), y(:), z(:), [], z(:));
+%! %% Default scatter3 with constant size bubbles and color determined by Z
 
 %!demo
-%! clf
-%! x = rand (20,1);
-%! y = rand (20,1);
-%! z = rand (20,1);
-%! scatter3 (x(:), y(:), z(:), 10, z(:), "s");
+%! clf;
+%! x = rand (20,1);  y = rand (20,1);  z = rand (20,1);
+%! scatter3 (x(:), y(:), z(:), 10, z(:), 's');
+%! %% scatter3 using a square marker of size 10 and color determined by Z
 
 %!demo
-%! clf
-%! x = rand (20,1);
-%! y = rand (20,1);
-%! z = rand (20,1);
-%! scatter3 (x(:), y(:), z(:), 20*z(:), z(:), "s");
+%! clf;
+%! x = rand (20,1);  y = rand (20,1);  z = rand (20,1);
+%! scatter3 (x(:), y(:), z(:), 20*z(:), [], 's');
+%! %% scatter3 using a square marker whose size is determined by Z
 
 %!demo
-%! clf
-%! x = rand (20,1);
-%! y = rand (20,1);
-%! z = rand (20,1);
-%! scatter3 (x(:), y(:), z(:), 20*z(:), [], "s");
+%! clf;
+%! x = rand (20,1);  y = rand (20,1);  z = rand (20,1);
+%! scatter3 (x(:), y(:), z(:), 20*z(:), z(:), 's');
+%! %% scatter3 using a square marker.
+%! %% Size and color of marker are determined by Z
 
--- a/scripts/plot/semilogx.m
+++ b/scripts/plot/semilogx.m
@@ -38,7 +38,7 @@
   [h, varargin, nargs] = __plt_get_axis_arg__ ("semilogx", varargin{:});
 
   if (nargs < 1)
-    print_usage();
+    print_usage ();
   endif
 
   oldh = gca ();
@@ -64,45 +64,45 @@
 
 
 %!demo
-%! clf ();
+%! clf;
 %! x = 1:0.01:10;
 %! y = (x .* (1 + rand (size (x)))) .^ 2;
 %! semilogx (y, x);
 
 %!demo
-%! clf ();
+%! clf;
 %! x = logspace (-5, 1, 10);
 %! y = logspace (-5, 1, 10);
 %!
-%! subplot (1, 2, 1);
-%! semilogx (x, y);
-%! xlabel ("semilogx (x, y)");
+%! subplot (1,2,1);
+%!  semilogx (x, y);
+%!  xlabel ('semilogx (x, y)');
 %!
-%! subplot (1, 2, 2);
-%! semilogx (-x, y);
-%! xlabel ("semilogx (-x, y)");
+%! subplot (1,2,2);
+%!  semilogx (-x, y);
+%!  xlabel ('semilogx (-x, y)');
 
 %!demo
-%! clf ();
+%! clf;
 %! x = logspace (-5, 1, 10);
 %! y = logspace (-5, 1, 10);
 %!
-%! subplot (1, 2, 1);
-%! semilogx (x, y);
-%! set (gca, "xdir", "reverse", "activepositionproperty", "outerposition")
-%! xlabel ({"semilogx (x, y)", "xdir = reversed"})
+%! subplot (1,2,1);
+%!  semilogx (x, y);
+%!  set (gca, 'xdir', 'reverse', 'activepositionproperty', 'outerposition');
+%!  xlabel ({'semilogx (x, y)', 'xdir = reversed'});
 %!
-%! subplot (1, 2, 2);
-%! semilogx (-x, y);
-%! set (gca, "xdir", "reverse", "activepositionproperty", "outerposition");
-%! xlabel ({"semilogx (-x, y)", "xdir = reversed"});
+%! subplot (1,2,2);
+%!  semilogx (-x, y);
+%!  set (gca, 'xdir', 'reverse', 'activepositionproperty', 'outerposition');
+%!  xlabel ({'semilogx (-x, y)', 'xdir = reversed'});
 
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
 %!   a = logspace (-5, 1, 10);
 %!   b = logspace (-5, 1, 10);
-%!   semilogx (a, b)
+%!   semilogx (a, b);
 %!   assert (get (gca, "xscale"), "log");
 %!   assert (get (gca, "yscale"), "linear");
 %! unwind_protect_cleanup
--- a/scripts/plot/semilogxerr.m
+++ b/scripts/plot/semilogxerr.m
@@ -60,10 +60,12 @@
 
 endfunction
 
+
 %!demo
-%! clf
-%! x = exp (log(0.01):0.2:log(10));
+%! clf;
+%! x = exp (log (0.01):0.2:log (10));
 %! y = wblpdf (x, 2, 2);
 %! ey = 0.5*rand (size (y)) .* y;
-%! semilogxerr (x, y, ey, "#~x-")
-%! xlim (x([1, end]))
+%! semilogxerr (x, y, ey, '#~x-');
+%! xlim (x([1, end]));
+
--- a/scripts/plot/semilogy.m
+++ b/scripts/plot/semilogy.m
@@ -38,7 +38,7 @@
   [h, varargin, nargs] = __plt_get_axis_arg__ ("semilogy", varargin{:});
 
   if (nargs < 1)
-    print_usage();
+    print_usage ();
   endif
 
   oldh = gca ();
@@ -47,7 +47,7 @@
     newplot ();
 
     set (h, "yscale", "log");
-    if (any( strcmp (get (gca, "nextplot"), {"new", "replace"})))
+    if (any (strcmp (get (gca, "nextplot"), {"new", "replace"})))
       set (h, "yminortick", "on");
     endif
 
@@ -63,39 +63,40 @@
 
 endfunction
 
+
 %!demo
-%! clf ();
+%! clf;
 %! x = 1:0.01:10;
 %! y = (x .* (1 + rand (size (x)))) .^ 2;
 %! semilogy (x, y);
 
 %!demo
-%! clf ();
+%! clf;
 %! x = logspace (-5, 1, 10);
 %! y = logspace (-5, 1, 10);
 %!
-%! subplot (2, 1, 1);
+%! subplot (2,1,1);
 %! semilogy (x, y);
-%! ylabel ("semilogy (x, y)");
+%! ylabel ('semilogy (x, y)');
 %!
-%! subplot (2, 1, 2);
+%! subplot (2,1,2);
 %! semilogy (x, -y);
-%! ylabel ("semilogy (x, -y)");
+%! ylabel ('semilogy (x, -y)');
 
 %!demo
-%! clf ();
+%! clf;
 %! x = logspace (-5, 1, 10);
 %! y = logspace (-5, 1, 10);
 %!
-%! subplot (2, 1, 1);
+%! subplot (2,1,1);
 %! semilogy (x, y);
-%! set (gca, "ydir", "reverse", "activepositionproperty", "outerposition");
-%! ylabel ({"semilogy (x, y)", "ydir = reversed"});
+%! set (gca, 'ydir', 'reverse', 'activepositionproperty', 'outerposition');
+%! ylabel ({'semilogy (x, y)', 'ydir = reversed'});
 %!
-%! subplot (2, 1, 2);
+%! subplot (2,1,2);
 %! semilogy (x, -y);
-%! set (gca, "ydir", "reverse", "activepositionproperty", "outerposition");
-%! ylabel ({"semilogy (x, -y)", "ydir = reversed"});
+%! set (gca, 'ydir', 'reverse', 'activepositionproperty', 'outerposition');
+%! ylabel ({'semilogy (x, -y)', 'ydir = reversed'});
 
 %!test
 %! hf = figure ("visible", "off");
--- a/scripts/plot/semilogyerr.m
+++ b/scripts/plot/semilogyerr.m
@@ -60,12 +60,13 @@
 
 endfunction
 
+
 %!demo
-%! clf
+%! clf;
 %! x = 0.25:0.25:10;
 %! y = wblpdf (x, 4, 2);
 %! eyu = rand (size (y));
 %! eyl = 1.0 - 1./(1+eyu);
-%! semilogyerr (x, y, eyl.*y, eyu.*y, "~-d")
-%! xlim ([0 10])
+%! semilogyerr (x, y, eyl.*y, eyu.*y, '~-d');
+%! xlim ([0 10]);
 
--- a/scripts/plot/shading.m
+++ b/scripts/plot/shading.m
@@ -55,7 +55,7 @@
 
   obj = [h1(:); h2(:)];
 
-  for n = 1:numel(obj)
+  for n = 1:numel (obj)
     h = obj(n);
     if (strcmpi (mode, "flat"))
       set (h, "facecolor", "flat");
@@ -75,39 +75,44 @@
 
 
 %!demo
-%! clf
-%! colormap (jet)
-%! sombrero
-%! shading faceted
-%! title ('shading "faceted"')
+%! clf;
+%! colormap ('default');
+%! sombrero ();
+%! shading faceted;
+%! title ('shading ''faceted''');
 
 %!demo
-%! clf
-%! sombrero
-%! shading flat
-%! title ('shading "flat"')
+%! clf;
+%! colormap ('default');
+%! sombrero ();
+%! shading flat;
+%! title ('shading ''flat''');
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! sombrero ();
+%! shading interp;
+%! title ('shading ''interp''');
 
 %!demo
-%! clf
-%! sombrero
-%! shading interp
-%! title ('shading "interp"')
-
-%!demo
-%! clf
-%! pcolor (peaks ())
-%! shading faceted
-%! title ('shading "faceted"')
+%! clf;
+%! colormap ('default');
+%! pcolor (peaks ());
+%! shading faceted;
+%! title ('shading ''faceted''');
 
 %!demo
-%! clf
-%! pcolor (peaks ())
-%! shading flat
-%! title ('shading "flat"')
+%! clf;
+%! colormap ('default');
+%! pcolor (peaks ());
+%! shading flat;
+%! title ('shading ''flat''');
 
 %!demo
-%! clf
-%! pcolor (peaks ())
-%! shading interp
-%! title ('shading "interp"')
+%! clf;
+%! colormap ('default');
+%! pcolor (peaks ());
+%! shading interp;
+%! title ('shading ''interp''');
 
new file mode 100644
--- /dev/null
+++ b/scripts/plot/shrinkfaces.m
@@ -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 shrunken
+## 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 = columns (vertices);
+  if (n < 2 || n > 3)
+    error ("shrinkfaces: only 2D and 3D patches are supported")
+  endif
+
+  m = columns (faces);
+  if (m < 3)
+    error ("shrinkfaces: faces must consist of at least 3 vertices")
+  endif
+
+  v = vertices(faces'(:), :);
+  if (isempty (colors) || rows (colors) == rows (faces))
+    c = colors;
+  elseif (rows (colors) == rows (vertices))
+    c = colors(faces'(:), :);
+  else
+    ## Discard inconsistent color data.
+    c = [];
+  endif
+  sv = rows (v);
+  ## 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);
--- a/scripts/plot/slice.m
+++ b/scripts/plot/slice.m
@@ -104,7 +104,7 @@
     x = varargin{1};
     y = varargin{2};
     z = varargin{3};
-    if (all ([isvector(x), isvector(y), isvector(z)]))
+    if (isvector (x) && isvector (y) && isvector (z)]))
       [x, y, z] = meshgrid (x, y, z);
     elseif (ndims (x) == 3 && size_equal (x, y, z))
       ## Do nothing.
@@ -120,7 +120,7 @@
 
   if (any ([isvector(sx), isvector(sy), isvector(sz)]))
     have_sval = true;
-  elseif (ndims(sx) == 2 && size_equal (sx, sy, sz))
+  elseif (ndims (sx) == 2 && size_equal (sx, sy, sz))
     have_sval = false;
   else
     error ("slice: dimensional mismatch for (XI, YI, ZI) or (SX, SY, SZ)");
@@ -135,10 +135,10 @@
 
   if (have_sval)
     ns = length (sx) + length (sy) + length (sz);
-    hs = zeros(ns,1);
+    hs = zeros (ns,1);
     [ny, nx, nz] = size (v);
-    if (length(sz) > 0)
-      for i = 1:length(sz)
+    if (length (sz) > 0)
+      for i = 1:length (sz)
         [xi, yi, zi] = meshgrid (squeeze (x(1,:,1)),
                                  squeeze (y(:,1,1)), sz(i));
         vz = squeeze (interp3 (x, y, z, v, xi, yi, zi, method));
@@ -147,7 +147,7 @@
     endif
 
     if (length (sy) > 0)
-      for i = length(sy):-1:1
+      for i = length (sy):-1:1
         [xi, yi, zi] = meshgrid (squeeze (x(1,:,1)), sy(i), squeeze (z(1,1,:)));
         vy = squeeze (interp3 (x, y, z, v, xi, yi, zi, method));
         tmp(sidx++) = surface (squeeze (xi),
@@ -157,7 +157,7 @@
     endif
 
     if (length (sx) > 0)
-      for i = length(sx):-1:1
+      for i = length (sx):-1:1
         [xi, yi, zi] = meshgrid (sx(i), squeeze (y(:,1,1)), squeeze (z(1,1,:)));
         vx = squeeze (interp3 (x, y, z, v, xi, yi, zi, method));
         tmp(sidx++) = surface (squeeze (sx(i) * ones (size (zi))),
@@ -182,13 +182,15 @@
 
 
 %!demo
-%! clf
+%! clf;
+%! colormap ('default');
 %! [x, y, z] = meshgrid (linspace (-8, 8, 32));
 %! v = sin (sqrt (x.^2 + y.^2 + z.^2)) ./ (sqrt (x.^2 + y.^2 + z.^2));
 %! slice (x, y, z, v, [], 0, []);
 
 %!demo
-%! clf
+%! clf;
+%! colormap ('default');
 %! [x, y, z] = meshgrid (linspace (-8, 8, 32));
 %! v = sin (sqrt (x.^2 + y.^2 + z.^2)) ./ (sqrt (x.^2 + y.^2 + z.^2));
 %! [xi, yi] = meshgrid (linspace (-7, 7));
--- a/scripts/plot/sombrero.m
+++ b/scripts/plot/sombrero.m
@@ -61,6 +61,9 @@
 
 endfunction
 
+
 %!demo
-%! clf
+%! clf;
+%! colormap ('default');
 %! sombrero ();
+
--- a/scripts/plot/stairs.m
+++ b/scripts/plot/stairs.m
@@ -156,7 +156,7 @@
     h = [];
     unwind_protect
       hold_state = get (gca (), "nextplot");
-      for i = 1 : size(y, 2)
+      for i = 1 : columns (y)
         hg = hggroup ();
         h = [h; hg];
         args = __add_datasource__ ("stairs", hg, {"x", "y"}, varargin{:});
@@ -210,14 +210,14 @@
 
 
 %!demo
-%! clf
+%! clf;
 %! x = 1:10;
 %! rand_1x10_data1 = [0.073, 0.455, 0.837, 0.124, 0.426, 0.781, 0.004, 0.024, 0.519, 0.698];
 %! y = rand_1x10_data1;
 %! stairs (x, y);
 
 %!demo
-%! clf
+%! clf;
 %! x = 1:10;
 %! rand_1x10_data2 = [0.014, 0.460, 0.622, 0.394, 0.531, 0.378, 0.466, 0.788, 0.342, 0.893];
 %! y = rand_1x10_data2;
@@ -225,11 +225,11 @@
 %! plot (xs, ys);
 
 %!demo
-%! clf
+%! clf;
 %! stairs (1:9);
 
 %!demo
-%! clf
+%! clf;
 %! [xs, ys] = stairs (9:-1:1);
 %! plot (xs, ys);
 
--- a/scripts/plot/stem.m
+++ b/scripts/plot/stem.m
@@ -88,45 +88,45 @@
 
 
 %!demo
-%! clf
+%! clf;
 %! x = 1:10;
 %! stem (x);
 
 %!demo
-%! clf
+%! clf;
 %! x = 1:10;
 %! y = 2*x;
 %! stem (x, y);
 
 %!demo
-%! clf
+%! clf;
 %! x = 1:10;
 %! y = 2*x;
-%! h = stem (x, y, "r");
+%! h = stem (x, y, 'r');
 
 %!demo
-%! clf
+%! clf;
 %! x = 1:10;
 %! y = 2*x;
-%! h = stem (x, y, "-.k");
+%! h = stem (x, y, '-.k');
 
 %!demo
-%! clf
+%! clf;
 %! x = 1:10;
 %! y = 2*x;
-%! h = stem (x, y, "-.k.");
+%! h = stem (x, y, '-.k.');
 
 %!demo
-%! clf
+%! clf;
 %! x = 1:10;
 %! y = 2*x;
-%! h = stem (x, y, "filled");
+%! h = stem (x, y, 'filled');
 
 %!demo
-%! clf
-%! x = [0 : 10]';
+%! clf;
+%! x = (0 : 10)';
 %! y = [sin(x), cos(x)];
 %! h = stem (x, y);
-%! set (h(2), "color", "g");
-%! set (h(1), "basevalue", -1)
+%! set (h(2), 'color', 'g');
+%! set (h(1), 'basevalue', -1);
 
--- a/scripts/plot/stem3.m
+++ b/scripts/plot/stem3.m
@@ -52,7 +52,9 @@
 
 endfunction
 
+
 %!demo
-%! clf
+%! clf;
 %! theta = 0:0.2:6;
-%! stem3 (cos (theta), sin (theta), theta)
+%! stem3 (cos (theta), sin (theta), theta);
+
new file mode 100644
--- /dev/null
+++ b/scripts/plot/struct2hdl.m
@@ -0,0 +1,615 @@
+## Copyright (C) 2012 pdiribarne
+##
+## This program 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.
+##
+## This program 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{h} =} struct2hdl (@var{s})
+## @deftypefnx {Function File} {@var{h} =} struct2hdl (@var{s}, @var{p})
+## @deftypefnx {Function File} {@var{h} =} struct2hdl (@var{s}, @var{p}, @var{hilev})
+## Constructs an object from the structure @var{s}. The structure must
+## contain the fields "handle", "type", "children", "properties", and
+## "special".  If the handle of an existing figure or axes is specified,
+## @var{p}, the new object will be created as a child to that object.
+## If no object handle is provided, then a new figure and the necessary
+## children will be constructed using the default object values from
+## the root figure.
+##
+## A third boolean argument @var{hilev} can be passed to specify wether
+## the function should try to preserve listeners/calbacks e.g for
+## legends or hggroups. Default is false.
+## @seealso{findobj, get, hdl2struct, set}
+## @end deftypefn
+
+## Author: pdiribarne <pdiribarne@new-host.home>
+## Created: 2012-03-04
+
+function [ h, matchout ] = struct2hdl (hgS, matchin=[], hilev = false)
+
+  fields = { "handle", "type", "children", "properties", "special"};
+  partypes = {"root", "figure", "axes", "hggroup"};
+  othertypes = {"line", "patch", "surface", "image", "text"};
+  alltypes = [partypes othertypes];
+
+  if (nargin > 3 || ! isstruct (hgS))
+    print_usage ();
+  elseif (! all (isfield (hgS, fields)))
+    print_usage ();
+  elseif (isscalar (matchin))
+    if (! ishandle (matchin))
+      error ("struct2hdl: argument #2 is not a handle to graphic object")
+    endif
+    if (any (strcmp (get (matchin).type, partypes)))
+      paridx = find (strcmp (get (matchin).type, alltypes));
+      kididx = find (strcmp (hgS.type, alltypes));
+      if (kididx <= paridx)
+        error ("struct2hdl: incompatible input handles")
+      endif
+    else
+      error ("struct2hdl: %s object can't be parent object", get (matchin).type)
+    endif
+    hpar = matchin;
+    matchin = [NaN; hpar];
+    ## create appropriate parent if needed
+    if (any (strcmp (hgS.type, othertypes)))
+      for ii = (paridx+1) : (numel (partypes)-1)
+        eval (["hpar = " partypes{ii} "(\"parent\", hpar);"]);
+        matchin = [matchin [NaN; hpar]];
+      endfor
+    elseif (any (strcmp (hgS.type, {"hggroup", "axes"})))
+      for ii = (paridx+1) : (kididx-1)
+        eval (["hpar = " partypes{ii} "(\"parent\", hpar);"]);
+        matchin = [matchin [NaN; hpar]];
+      endfor
+    else
+      par = NaN;
+    endif
+  elseif (isempty (matchin))
+    if (any (strcmp (hgS.type, othertypes)))
+      par = axes ();
+    elseif (any (strcmp (hgS.type, {"hggroup", "axes"})))
+      par = figure ();
+    else
+      par = NaN;
+    endif
+    matchin = [NaN; par];
+  endif
+  ## read parent (last column) in matchin and remove it if duplicate
+  par = matchin (2,end);
+  tst = find (matchin (2,:) == par);
+  if (numel (tst) > 1)
+    matchin = matchin (1:2, 1:(tst(end)-1));
+  endif
+
+  ## create object
+  if (strcmpi (hgS.type, "root"))
+    h = 0;
+    hgS.properties = rmfield (hgS.properties, ...
+                              {"callbackobject", "commandwindowsize", ...
+                               "screendepth", "screenpixelsperinch", ...
+                               "screensize"});
+  elseif (strcmpi (hgS.type, "figure"))
+    h = figure ();
+  elseif (strcmpi (hgS.type, "axes"))
+    ## legends and colorbars are "transformed" in normal axes
+    ## if hilev is not requested
+    if (! hilev)
+      if (strcmp (hgS.properties.tag, "legend"))
+        hgS.properties.tag = "";
+        hgS.properties.userdata = [];
+        par = gcf;
+      elseif (strcmp (hgS.properties.tag, "colorbar"))
+        hgS.properties.tag = "";
+        hgS.properties.userdata = [];
+        par = gcf;
+      endif
+    endif
+
+    [h, hgS] = createaxes (hgS, matchin, par);
+  elseif (strcmpi (hgS.type, "line"))
+    h = createline (hgS, par);
+  elseif (strcmpi (hgS.type, "patch"))
+    [h, hgS] = createpatch (hgS, par);
+  elseif (strcmpi (hgS.type, "text"))
+    h = createtext (hgS, par);
+  elseif (strcmpi (hgS.type, "image"))
+    h = createimage (hgS, par);
+  elseif (strcmpi (hgS.type, "surface"))
+    h = createsurface (hgS, par);
+  elseif (strcmpi (hgS.type, "hggroup"))
+    [h, hgS, matchin] = createhg (hgS, matchin, par, hilev);
+  endif
+
+  ## children
+  matchin = [matchin [hgS.handle; h]]; # [original; new]
+  kids = hgS.children;
+  nkids = length (kids);
+  ii = 0;
+  while nkids
+    ii++;
+    if (! any (ii == hgS.special))
+      [h2, matchin] = struct2hdl (hgS.children(ii),
+                                  [matchin [hgS.handle; h]], hilev);
+    endif
+    nkids--;
+  endwhile
+
+  ## paste properties
+  setprops (hgS, h, matchin, hilev);
+
+  matchout = matchin;
+
+endfunction
+
+function [h, hgSout] = createaxes (hgS, matchin, par);
+  ## regular axes
+  if (strcmpi (hgS.properties.tag, ""))
+    propval = {"position", hgS.properties.position};
+    hid = {"autopos_tag", "looseinset"};
+    for ii = 1:numel (hid)
+      prop = hid{ii};
+      if (isfield (hgS.properties, prop))
+        val = hgS.properties.(prop);
+        propval = [propval, prop, val];
+      endif
+    endfor
+    h = axes (propval{:}, "parent", par);
+
+    if isfield (hgS.properties, "__plotyy_axes__")
+      plty = hgS.properties.__plotyy_axes__;
+      addproperty ("__plotyy_axes__", h, "any")
+      tmp = [matchin [hgS.handle; h]];
+      tst = arrayfun (@(x) any (plty == x), tmp (1:2:end));
+      if sum (tst) == numel (plty)
+        for ii = 1:numel (plty)
+          plty(ii) = tmp (find (tmp == plty(ii)) + 1);
+        endfor
+        for ii = 1:numel (plty)
+          set (plty(ii), "__plotyy_axes__", plty);
+        endfor
+      endif
+      hgS.properties = rmfield (hgS.properties, "__plotyy_axes__");
+    endif
+
+    ## delete non-default and already set properties
+    fields = fieldnames (hgS.properties);
+    tst = cellfun (@(x) isprop (h, x), fields);
+    hgS.properties = rmfield (hgS.properties,  fields(find (tst == 0)));
+
+  elseif (strcmpi (hgS.properties.tag, "legend"))
+    ## legends
+    oldax = hgS.properties.userdata.handle;
+    idx = find (matchin == oldax);
+    newax = matchin(idx+1);
+    strings = {};
+    kids = hgS.children;
+    kids(hgS.special) = [];
+    oldh = unique (arrayfun (@(x) x.properties.userdata(end), kids));
+    for ii = 1:length (oldh)
+      idx = find (matchin(1:2:end) == oldh(ii)) * 2;
+      if (! isempty (idx))
+        newh(ii) = matchin (idx);
+        if (! strcmp (get (newh(ii), "type"), "hggroup"))
+          str = get (newh(ii), "displayname");
+          strings = [strings str];
+        else
+          str = get (get (newh(ii), "children")(1), "displayname");
+          strings = [strings str];
+        endif
+      else
+        error ("struct2hdl: didn't find a legend item")
+      endif
+    endfor
+    location = hgS.properties.location;
+    orientation = hgS.properties.orientation;
+    textpos = hgS.properties.textposition;
+    box = hgS.properties.box;
+
+    h = legend (newax, newh, strings, "location", location, ...
+                "orientation", orientation);
+    set (h, "textposition", textpos); # bug makes "textposition"
+                                # redefine the legend
+    h = legend (newax, newh, strings, "location", location, ...
+                "orientation", orientation);
+    ## box
+    if (strcmp (box, "on"))
+      legend boxon
+    endif
+
+    ## visibility
+    tst = arrayfun (@(x) strcmp (x.properties.visible, "on"), kids);
+    if !any (tst)
+      legend ("hide");
+    endif
+
+    ## remove all properties such as "textposition" that redefines
+    ## the entire legend. Also remove chidren
+    hgS.properties = rmfield (hgS.properties, ...
+                                {"userdata", "xlabel",...
+                                 "ylabel", "zlabel", "location", ...
+                                 "title", "string","orientation", ...
+                                 "visible", "textposition"});
+
+    hgS.children = [];
+
+  elseif (strcmpi (hgS.properties.tag, "colorbar"))
+    ## colorbar
+    oldax = hgS.properties.axes;
+    if (! isempty (idx = find (oldax == matchin)))
+      ax = matchin(idx+1);
+      location = hgS.properties.location;
+      h = colorbar ("peer", ax, location);
+      hgS.properties = rmfield (hgS.properties, ...
+                              {"userdata", "xlabel" ...
+                               "ylabel", "zlabel", ...
+                               "title", "axes"});
+      hgS.children= [];
+    else
+      error ("hdl2struct: didn't find an object")
+    endif
+  endif
+  hgSout = hgS;
+endfunction
+
+function [h] = createline (hgS, par);
+  h = line ("parent", par);
+  addmissingprops (h, hgS.properties);
+endfunction
+
+function [h, hgSout] = createpatch (hgS, par);
+  prp.faces = hgS.properties.faces;
+  prp.vertices = hgS.properties.vertices;
+  prp.facevertexcdata = hgS.properties.facevertexcdata;
+  h = patch (prp);
+  set (h, "parent", par);
+  hgS.properties = rmfield (hgS.properties,
+                            {"faces", "vertices", "facevertexcdata"});
+  addmissingprops (h, hgS.properties);
+  hgSout = hgS;
+endfunction
+
+function [h] = createtext (hgS, par);
+  h = text ("parent", par);
+  addmissingprops (h, hgS.properties)
+endfunction
+
+function [h] = createimage (hgS, par);
+  h = image ("parent", par);
+  addmissingprops (h, hgS.properties)
+endfunction
+
+function [h] = createsurface (hgS, par);
+  h = surface ("parent", par);
+  addmissingprops (h, hgS.properties)
+endfunction
+
+function [h, hgSout, matchout] = createhg (hgS, matchin, par, hilev)
+  ## Here we infer from properties the type of hggroup we should build
+  ## an call corresponding high level functions
+  ## We manually set "hold on" to avoid next hggroup be deleted
+  ## the proper value of axes "nextplot" will finally be recovered
+
+  hold on;
+  if (hilev)
+    [h, hgS, matchin] = createhg_hilev (hgS, matchin, par);
+    if (numel (hgS.children) != numel (get (h).children))
+      warning (["struct2hdl: couldn't infer the hggroup type. ", ...
+                "Will build objects but listener/callback functions ", ...
+                "will be lost"]);
+      if isfield (h, "bargroup")
+        delete (get (h).bargroup);
+      else
+        delete (h);
+      endif
+      h = hggroup ("parent", par);
+      addmissingprops (h, hgS.properties);
+      hgS.special = [];
+    else
+      oldkids = hgS.children;
+      newkids = get (h).children;
+      nkids = numel (oldkids);
+      ii = 1;
+      while nkids
+        matchin = [matchin [oldkids(ii++).handle; newkids(nkids--)]];
+      endwhile
+    endif
+  else
+    h = hggroup ("parent", par);
+    addmissingprops (h, hgS.properties);
+    hgS.special = [];
+  endif
+  hgSout = hgS;
+  matchout = matchin;
+endfunction
+
+function [h, hgSout, matchout] = createhg_hilev (hgS, matchin, par)
+  fields = hgS.properties;
+  if (isfield (fields, "contourmatrix"))
+    ## contours
+    xdata = hgS.properties.xdata;
+    ydata = hgS.properties.ydata;
+    zdata = hgS.properties.zdata;
+    levellist = hgS.properties.levellist;
+    textlist = hgS.properties.textlist;
+
+    ## contour creation
+    if (isempty (hgS.children(1).properties.zdata))
+      if (strcmpi (hgS.properties.fill, "on"))
+        [cm2, h] = contourf (xdata, ydata, zdata, levellist);
+      else
+        [cm2, h] = contour (xdata, ydata, zdata, levellist);
+      endif
+
+      ## labels
+      if (strcmpi (hgS.properties.showtext, "on"))
+        clabel (cm2, h, textlist);
+      endif
+    else
+      [cm2, h] = contour3 (xdata, ydata, zdata, levellist);
+    endif
+
+    ## delete already set properties and children
+    hgS.properties = rmfield (hgS.properties, ...
+                              {"xdata", "ydata", "zdata", ...
+                               "contourmatrix", "levellist", ...
+                               "fill", "labelspacing", ...
+                               "levellistmode", "levelstep", ...
+                               "levelstepmode", "textlist"...
+                               "textlistmode" , "textstep", ...
+                               "textstepmode", "zlevel", ...
+                               "zlevelmode"});
+
+  elseif (isfield (fields, "udata") && isfield (fields, "vdata"))
+    ## quiver
+    xdata = hgS.properties.xdata;
+    ydata = hgS.properties.ydata;
+
+    udata = hgS.properties.udata;
+    vdata = hgS.properties.vdata;
+
+    h = quiver (xdata, ydata, udata, vdata);
+
+    ## delete already set properties and children
+    hgS.properties = rmfield (hgS.properties, ...
+                              {"xdata", "ydata", "zdata", ...
+                               "xdatasource", "ydatasource", "zdatasource", ...
+                               "udata", "vdata", "wdata", ...
+                               "udatasource", "vdatasource", "wdatasource"});
+
+  elseif (isfield (fields, "format"))
+    ##errorbar
+    form = hgS.properties.format;
+    xdata = hgS.properties.xdata;
+    ydata = hgS.properties.ydata;
+    xldata = hgS.properties.xldata;
+    ldata = hgS.properties.ldata;
+    xudata = hgS.properties.xudata;
+    udata = hgS.properties.udata;
+
+    switch form
+      case "xerr"
+        h = errorbar (xdata, ydata, xldata, xudata, ">");
+      case "yerr"
+        h = errorbar (xdata, ydata, ldata, udata, "~");
+      case "xyerr"
+        h = errorbar (xdata, ydata, xldata, xudata, ldata, udata, "~>");
+      case "box"
+        h = errorbar (xdata, ydata, xldata, xudata, "#");
+      case "boxy"
+        h = errorbar (xdata, ydata, ldata, udata, "#~");
+      case "boxxy"
+        h = errorbar (xdata, ydata, xldata, xudata, ldata, udata, "#~>");
+      otherwise
+        error ("struct2hdl: couldn't guess the errorbar format")
+    endswitch
+    ## delete already set properties
+    hgS.properties = rmfield (hgS.properties, ...
+                              {"xdata", "ydata", ...
+                               "xldata", "ldata", ...
+                               "xudata", "udata", ...
+                               "xldatasource", "ldatasource", ...
+                               "xudatasource", "udatasource", ...
+                               "format"});
+
+  elseif (isfield (fields, "bargroup"))
+    ## bar plot
+    ## FIXME - here we don't have access to brothers so we first create all
+    ## the barseries of the bargroup (but the last), then retrieve information,
+    ## and rebuild the whole bargroup.
+    ## The duplicate are deleted after calling "setprops"
+
+    bargroup = hgS.properties.bargroup;
+    oldh = hgS.handle;
+
+    temp = arrayfun (@(x) any(x == bargroup), [matchin(1:2:end) oldh]);
+    tst = sum (temp) == length (bargroup);
+
+    if (isscalar (bargroup) || !tst)
+      xdata = hgS.properties.xdata;
+      ydata = hgS.properties.ydata;
+
+      h = bar (xdata, ydata);
+
+      ## delete already set properties,
+      hgS.properties = rmfield (hgS.properties, ...
+                                {"xdata", "ydata", ...
+                                 "xdatasource", "ydatasource", ...
+                                 "bargroup", ...
+                                 "barwidth", "baseline"});
+    else
+      xdata = [];
+      ydata = [];
+
+      ##build x/y matrix
+      nbar = length (bargroup);
+      tmp = struct ("handle", NaN,"type", "", "children", [], "special", []);
+      for ii = 1:(nbar - 1)
+        idx = find (matchin(1:2:end) == bargroup(ii)) * 2;
+        hdl = matchin (idx);
+        xdata = [xdata get(hdl).xdata];
+        ydata = [ydata get(hdl).ydata];
+        tmp.children(ii) = hdl2struct (hdl);
+      endfor
+
+      xdata = [xdata hgS.properties.xdata];
+      ydata = [ydata hgS.properties.ydata];
+      width = hgS.properties.barwidth;
+      h = bar (ydata, width);
+
+      ## replace previous handles in "match", copy props and delete redundant
+      for ii = 1:(nbar - 1)
+        props = tmp.children(ii).properties;
+        bl = props.baseline;
+        tmp.children(ii).properties = rmfield (props, {"baseline", "bargroup"});
+        setprops (tmp.children(ii), h(ii), matchin, 1);
+        delete (tmp.children(ii).handle);
+        delete (bl);
+        idxpar = find (matchin == tmp.children(ii).handle);
+        matchin (idxpar) = h(ii);
+        idxkid = idxpar - 2;
+        matchin (idxkid) = get (h(ii), "children");
+      endfor
+      matchin (2,((end-nbar+2):end)) = h (1:(end-1));
+      h = h (end);
+
+      ## delete already set properties ,
+      hgS.properties = rmfield (hgS.properties, ...
+                                {"xdata", "ydata", "bargroup"...
+                                 "barwidth", "baseline"});
+    endif
+  elseif (isfield (fields, "baseline"))
+    ## stem plot
+    xdata = hgS.properties.xdata;
+    ydata = hgS.properties.ydata;
+
+    h = stem (xdata, ydata);
+
+    ## delete already set properties,
+    hgS.properties = rmfield (hgS.properties, ...
+                              {"xdata", "ydata", ...
+                               "xdatasource", "ydatasource", ...
+                               "baseline"});
+  elseif (isfield (fields, "basevalue"))
+    ## area plot
+    xdata = hgS.properties.xdata;
+    ydata = hgS.properties.ydata;
+    level = hgS.properties.basevalue;
+
+    h = area (xdata, ydata, level);
+
+    ## delete already set properties,
+    hgS.properties = rmfield (hgS.properties, ...
+                              {"xdata", "ydata", ...
+                               "xdatasource", "ydatasource"});
+  else
+    warning ("struct2hdl: couldn't infer the hggroup type. Will build objects but listener/callback functions will be lost");
+    h = hggroup ("parent", par);
+    addmissingprops (h, hgS.properties);
+    hgS.special = [];           # children will be treated as normal children
+  endif
+  hgSout = hgS;
+  matchout = matchin;
+endfunction
+
+function setprops (hgS, h, matchin, hilev)
+  more off
+  if (strcmpi (hgS.properties.tag, ""))
+    specs = hgS.children(hgS.special);
+    hdls = arrayfun (@(x) x.handle, specs);
+    nh = length(hdls);
+    msg = "";
+    if (! nh)
+      set (h, hgS.properties);
+    else
+      ## Specials are objects that where automatically constructed with
+      ## current object. Among them are "x(yz)labels", "title", high
+      ## level hggroup children
+      fields = fieldnames (hgS.properties);
+      vals = struct2cell (hgS.properties);
+      idx = find (cellfun (@(x) valcomp(x, hdls) , vals));
+      hgS.properties = rmfield (hgS.properties, fields(idx));
+
+      ## set all properties but special handles
+      set (h, hgS.properties);
+
+      ## find  props with val == (one of special handles)
+      nf = length (idx);
+      fields = fields(idx);
+      vals = vals(idx);
+      while nf
+        field = fields{nf};
+        idx = find (hdls == vals{nf});
+        spec = specs(idx);
+        if (isprop (h, field))
+           h2 = get (h , field);
+           set (h2, spec.properties);
+        endif
+        nf--;
+      endwhile
+
+      ## If hggroup children  were created by high level functions,
+      ## copy only usefull properties.
+      if (hilev)
+        if (strcmpi (hgS.type, "hggroup"))
+          nold = numel (hgS.children);
+          nnew = numel (get(h).children);
+
+          if (nold == nnew)
+            hnew = get(h).children;
+            ii = 1;
+            while ii <= nnew
+              try
+                set (hnew (ii), "displayname", ...
+                     hgS.children(ii).properties.displayname);
+              catch
+                sprintf ("struct2hdl: couldn't set hggroup children #%d props.", ii)
+              end_try_catch
+              ii ++;
+            endwhile
+
+          else
+            error ("struct2hdl: non-conformant number of children in hgggroup")
+          endif
+        endif
+      endif
+    endif
+
+  elseif (strcmpi (hgS.properties.tag, "legend")
+          || strcmpi (hgS.properties.tag, "colorbar"))
+    set (h, hgS.properties);
+  endif
+
+endfunction
+
+function out = valcomp (x, hdls)
+  if (isfloat(x) && isscalar(x))
+    out = any (x == hdls);
+  else
+    out = 0;
+  endif
+endfunction
+
+function addmissingprops (h, props)
+  hid = {"autopos_tag", "looseinset"};
+  oldfields = fieldnames (props);
+  curfields = fieldnames (get (h));
+  missing = cellfun (@(x) !any (strcmp (x, curfields)), oldfields);
+  idx = find (missing);
+  for ii = 1:length(idx)
+    prop = oldfields{idx(ii)};
+    if (! any (strcmp (prop, hid)))
+      addproperty (prop, h, "any");
+    endif
+  endfor
+endfunction
--- a/scripts/plot/subplot.m
+++ b/scripts/plot/subplot.m
@@ -313,7 +313,7 @@
   x0 = xi .* (width + margins.column) + margins.left;
   y0 = yi .* (height + margins.row) + margins.bottom;
 
-  if (numel(x0) > 1)
+  if (numel (x0) > 1)
     ## subplot (row, col, m:n)
     x1 = max (x0(:)) + width;
     y1 = max (y0(:)) + height;
@@ -327,39 +327,40 @@
 
 endfunction
 
+
 %!demo
-%! clf
+%! clf;
 %! r = 3;
 %! c = 3;
 %! fmt = {'horizontalalignment', 'center', 'verticalalignment', 'middle'};
-%! for n = 1:(r*c)
-%!   subplot (r, c, n)
-%!   xlabel (sprintf ("xlabel #%d", n))
-%!   ylabel (sprintf ("ylabel #%d", n))
-%!   title (sprintf ("title #%d", n))
-%!   text (0.5, 0.5, sprintf('subplot(%d,%d,%d)', r, c, n), fmt{:})
-%!   axis ([0 1 0 1])
-%! endfor
-%! subplot (r, c, 1:3)
-%! xlabel (sprintf ("xlabel #%d:%d", 1, 3))
-%! ylabel (sprintf ("ylabel #%d:%d", 1, 3))
-%! title (sprintf ("title #%d:%d", 1, 3))
-%! text (0.5, 0.5, sprintf('subplot(%d,%d,%d:%d)', r, c, 1, 3), fmt{:})
-%! axis ([0 1 0 1])
+%! for n = 1 : r*c
+%!   subplot (r, c, n);
+%!   xlabel (sprintf ('xlabel #%d', n));
+%!   ylabel (sprintf ('ylabel #%d', n));
+%!   title (sprintf ('title #%d', n));
+%!   text (0.5, 0.5, sprintf ('subplot(%d,%d,%d)', r, c, n), fmt{:});
+%!   axis ([0 1 0 1]);
+%! end
+%! subplot (r, c, 1:3);
+%! xlabel (sprintf ('xlabel #%d:%d', 1, 3));
+%! ylabel (sprintf ('ylabel #%d:%d', 1, 3));
+%! title (sprintf ('title #%d:%d', 1, 3));
+%! text (0.5, 0.5, sprintf ('subplot(%d,%d,%d:%d)', r, c, 1, 3), fmt{:});
+%! axis ([0 1 0 1]);
 
 %!demo
-%! clf
+%! clf;
 %! x = 0:1;
 %! for n = 1:4
-%!   subplot (2, 2, n, "align")
-%!   plot (x, x)
-%!   xlabel (sprintf ("xlabel (2,2,%d)", n))
-%!   ylabel (sprintf ("ylabel (2,2,%d)", n))
-%!   title (sprintf ("title (2,2,%d)", n))
-%! endfor
-%! subplot (1, 2, 1, "align")
-%! plot (x, x)
-%! xlabel ("xlabel (1,2,1)")
-%! ylabel ("ylabel (1,2,1)")
-%! title ("title (1,2,1)")
+%!   subplot (2,2,n, 'align');
+%!   plot (x, x);
+%!   xlabel (sprintf ('xlabel (2,2,%d)', n));
+%!   ylabel (sprintf ('ylabel (2,2,%d)', n));
+%!   title (sprintf ('title (2,2,%d)', n));
+%! end
+%! subplot (1,2,1, 'align');
+%! plot (x, x);
+%! xlabel ('xlabel (1,2,1)');
+%! ylabel ('ylabel (1,2,1)');
+%! title ('title (1,2,1)');
 
--- a/scripts/plot/surf.m
+++ b/scripts/plot/surf.m
@@ -66,20 +66,23 @@
 
 
 %!demo
-%! clf
-%! [~,~,Z] = peaks;
+%! clf;
+%! colormap ('default');
+%! [~,~,Z] = peaks ();
 %! surf (Z);
 
 %!demo
-%! clf
-%! [~,~,Z] = sombrero;
+%! clf;
+%! colormap ('default');
+%! [~,~,Z] = sombrero ();
 %! [Fx,Fy] = gradient (Z);
 %! surf (Z, Fx+Fy);
 %! shading interp;
 
 %!demo
-%! clf
-%! [X,Y,Z] = sombrero;
+%! clf;
+%! colormap ('default');
+%! [X,Y,Z] = sombrero ();
 %! [~,Fy] = gradient (Z);
 %! surf (X, Y, Z, Fy);
 %! shading interp;
--- a/scripts/plot/surface.m
+++ b/scripts/plot/surface.m
@@ -145,7 +145,7 @@
   elseif (firststring == 1)
     x = 1:3;
     y = (x).';
-    c = z = eye(3);
+    c = z = eye (3);
   else
     bad_usage = true;
   endif
@@ -166,8 +166,8 @@
 
 endfunction
 
+
 ## Functional tests for surface() are in surf.m, surfc.m, surfl.m, and pcolor.m
-
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
@@ -175,8 +175,8 @@
 %!   assert (findobj (hf, "type", "surface"), h);
 %!   assert (get (h, "xdata"), 1:3, eps);
 %!   assert (get (h, "ydata"), (1:3)', eps);
-%!   assert (get (h, "zdata"), eye(3));
-%!   assert (get (h, "cdata"), eye(3));
+%!   assert (get (h, "zdata"), eye (3));
+%!   assert (get (h, "cdata"), eye (3));
 %!   assert (get (h, "type"), "surface");
 %!   assert (get (h, "linestyle"), get (0, "defaultsurfacelinestyle"));
 %!   assert (get (h, "linewidth"), get (0, "defaultsurfacelinewidth"), eps);
--- a/scripts/plot/surfc.m
+++ b/scripts/plot/surfc.m
@@ -74,21 +74,26 @@
 
 endfunction
 
-%!demo
-%! clf
-%! [~,~,Z]=peaks;
-%! surfc(Z);
 
 %!demo
-%! clf
-%! [~,~,Z]=sombrero;
-%! [Fx,Fy] = gradient(Z);
-%! surfc(Z,Fx+Fy);
+%! clf;
+%! colormap ('default');
+%! [~,~,Z] = peaks ();
+%! surfc (Z);
+
+%!demo
+%! clf;
+%! colormap ('default');
+%! [~,~,Z] = sombrero ();
+%! [Fx,Fy] = gradient (Z);
+%! surfc (Z, Fx+Fy);
 %! shading interp;
 
 %!demo
-%! clf
-%! [X,Y,Z]=sombrero;
-%! [~,Fy] = gradient(Z);
-%! surfc(X,Y,Z,Fy);
+%! clf;
+%! colormap ('default');
+%! [X,Y,Z] = sombrero ();
+%! [~,Fy] = gradient (Z);
+%! surfc (X,Y,Z,Fy);
 %! shading interp;
+
--- a/scripts/plot/surfl.m
+++ b/scripts/plot/surfl.m
@@ -23,21 +23,21 @@
 ## @deftypefnx {Function File} {} surfl (@var{x}, @var{y}, @var{z}, @var{L}, @var{P})
 ## @deftypefnx {Function File} {} surfl (@dots{}, "light")
 ## Plot a lighted surface given matrices @var{x}, and @var{y} from
-## @code{meshgrid} and
-## a matrix @var{z} corresponding to the @var{x} and @var{y} coordinates of
-## the mesh.  If @var{x} and @var{y} are vectors, then a typical vertex
-## is (@var{x}(j), @var{y}(i), @var{z}(i,j)).  Thus, columns of @var{z}
-## correspond to different @var{x} values and rows of @var{z} correspond
-## to different @var{y} values.
+## @code{meshgrid} and a matrix @var{z} corresponding to the @var{x} and
+## @var{y} coordinates of the mesh.  If @var{x} and @var{y} are vectors, then
+## a typical vertex is (@var{x}(j), @var{y}(i), @var{z}(i,j)).  Thus, columns
+## of @var{z} correspond to different @var{x} values and rows of @var{z}
+## correspond to different @var{y} values.
 ##
-## The light direction can be specified using @var{L}.  It can be
-## given as 2-element vector [azimuth, elevation] in degrees or as 3-element
-## vector [lx, ly, lz].
-## The default value is rotated 45° counter-clockwise from the current view.
+## The light direction can be specified using @var{L}.  It can be given as a
+## 2-element vector [azimuth, elevation] in degrees or as a 3-element vector
+## [lx, ly, lz].  The default value is rotated 45 degrees counterclockwise
+## from the current view.
 ##
 ## The material properties of the surface can specified using a 4-element vector
 ## @var{P} = [@var{AM} @var{D} @var{SP} @var{exp}] which defaults to
 ## @var{p} = [0.55 0.6 0.4 10].
+##
 ## @table @asis
 ## @item "AM" strength of ambient light
 ##
@@ -49,10 +49,9 @@
 ## @end table
 ##
 ## The default lighting mode "cdata", changes the cdata property to give the
-## impression
-## of a lighted surface.  Please note: the alternative "light" mode, which
-## creates a light
-## object to illuminate the surface is not implemented (yet).
+## impression of a lighted surface.  Please note: the alternative "light"
+## mode, which creates a light object to illuminate the surface is not
+## implemented (yet).
 ##
 ## Example:
 ##
@@ -80,12 +79,12 @@
     ## Check for lighting type.
     use_cdata = true;
     if (ischar (varargin{end}))
-      lstr = varargin{end};
-      if (strncmp (tolower (lstr), "light", 5))
+      lstr = tolower (varargin{end});
+      if (strncmp (lstr, "light", 5))
         warning ("light method not supported (yet), using cdata method instead");
         ## This can be implemented when light objects are supported.
         use_cdata = false;
-      elseif (strncmp (tolower (lstr), "cdata", 5))
+      elseif (strncmp (lstr, "cdata", 5))
         use_cdata = true;
       else
         error ("surfl: unknown lighting method");
@@ -123,7 +122,7 @@
       endif
     endif
 
-    tmp = surface (varargin{:});
+    htmp = surface (varargin{:});
     if (! ishold ())
       set (h, "view", [-37.5, 30],
            "xgrid", "on", "ygrid", "on", "zgrid", "on", "clim", [0 1]);
@@ -144,7 +143,7 @@
       lv = (R * vv.').';
     endif
 
-    vn = get (tmp, "vertexnormals");
+    vn = get (htmp, "vertexnormals");
     dar = get (h, "plotboxaspectratio");
     vn(:,:,1) *= dar(1);
     vn(:,:,2) *= dar(2);
@@ -152,37 +151,38 @@
 
     ## Normalize vn.
     vn = vn ./ repmat (sqrt (sumsq (vn, 3)), [1, 1, 3]);
-    [nr, nc] = size(get(tmp, "zdata"));
+    [nr, nc] = size (get (htmp, "zdata"));
 
     ## Ambient, diffuse, and specular term.
     cdata = (r(1) * ones (nr, nc)
              + r(2) * diffuse  (vn(:,:,1), vn(:,:,2), vn(:,:,3), lv)
              + r(3) * specular (vn(:,:,1), vn(:,:,2), vn(:,:,3), lv, vv, r(4)));
 
-    set (tmp, "cdata", cdata ./ sum (r(1:3)));
+    set (htmp, "cdata", cdata ./ sum (r(1:3)));
 
   unwind_protect_cleanup
     axes (oldh);
   end_unwind_protect
 
   if (nargout > 0)
-    retval = tmp;
+    retval = htmp;
   endif
 
 endfunction
 
+
 %!demo
-%! clf
-%! [X,Y,Z]=sombrero;
-%! colormap(copper);
-%! surfl(X,Y,Z);
+%! clf;
+%! [X,Y,Z] = sombrero ();
+%! colormap (copper (64));
+%! surfl (X,Y,Z);
 %! shading interp;
 
 %!demo
-%! clf
-%! [X,Y,Z]=sombrero;
-%! colormap(copper);
-%! [az, el] = view;
-%! surfl(X,Y,Z,[az+225,el],[0.2 0.6 0.4 25]);
+%! clf;
+%! [X,Y,Z] = sombrero ();
+%! colormap (copper (64));
+%! [az, el] = view ();
+%! surfl (X,Y,Z, [az+225,el], [0.2 0.6 0.4 25]);
 %! shading interp;
 
--- a/scripts/plot/surfnorm.m
+++ b/scripts/plot/surfnorm.m
@@ -27,8 +27,8 @@
 ##
 ## @example
 ## @group
-## [@var{x}, @var{y}] = meshgrid (1:size (@var{z}, 1),
-##                    1:size (@var{z}, 2));
+## [@var{x}, @var{y}] = meshgrid (1:rows (@var{z}),
+##                    1:columns (@var{z}));
 ## @end group
 ## @end example
 ##
@@ -62,7 +62,7 @@
 
   if (nargin == 1)
     z = varargin{1};
-    [x, y] = meshgrid (1:size(z,1), 1:size(z,2));
+    [x, y] = meshgrid (1:rows (z), 1:columns (z));
     ioff = 2;
   else
     x = varargin{1};
@@ -96,9 +96,9 @@
   v.z = zz(1:end-1,2:end) - zz(2:end,1:end-1);
 
   c = cross ([u.x(:), u.y(:), u.z(:)], [v.x(:), v.y(:), v.z(:)]);
-  w.x = reshape (c(:,1), size(u.x));
-  w.y = reshape (c(:,2), size(u.y));
-  w.z = reshape (c(:,3), size(u.z));
+  w.x = reshape (c(:,1), size (u.x));
+  w.y = reshape (c(:,2), size (u.y));
+  w.z = reshape (c(:,3), size (u.z));
 
   ## Create normal vectors as mesh vectices from normals at mesh centers
   nx = (w.x(1:end-1,1:end-1) + w.x(1:end-1,2:end) +
@@ -141,17 +141,21 @@
 
 endfunction
 
+
 %!demo
-%! clf
-%! colormap (jet (64))
-%! [x, y, z] = peaks(10);
+%! clf;
+%! colormap ('default');
+%! [x, y, z] = peaks (10);
 %! surfnorm (x, y, z);
 
 %!demo
-%! clf
-%! surfnorm (peaks(10));
+%! clf;
+%! colormap ('default');
+%! surfnorm (peaks (10));
 
 %!demo
-%! clf
-%! surfnorm (peaks(32));
-%! shading interp
+%! clf;
+%! colormap ('default');
+%! surfnorm (peaks (32));
+%! shading interp;
+
new file mode 100644
--- /dev/null
+++ b/scripts/plot/tetramesh.m
@@ -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 = rows (colmap);
+    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/plot/text.m
+++ b/scripts/plot/text.m
@@ -57,7 +57,7 @@
     ny = numel (y);
     nz = numel (z);
     if (ischar (label) || isnumeric (label))
-      nt = size (label, 1);
+      nt = rows (label);
       if (nx > 1 && nt == 1)
         ## Mutiple text objects with same string
         label = repmat ({label}, [nx, 1]);
@@ -126,97 +126,98 @@
 
 endfunction
 
-%!demo
-%! clf
-%! ha = {"left", "center", "right"};
-%! va = {"bottom", "middle", "top"};
-%! x = [0.25 0.5 0.75];
-%! y = [0.25 0.5 0.75];
-%! for t = 0:30:359;
-%!   for nh = 1:numel(ha)
-%!     for nv = 1:numel(va)
-%!       text (x(nh), y(nv), "Hello World", ...
-%!             "rotation", t, ...
-%!             "horizontalalignment", ha{nh}, ...
-%!             "verticalalignment", va{nv});
-%!     endfor
-%!   endfor
-%! endfor
-%! set (gca, "xtick", [0.25, 0.5, 0.75], ...
-%!           "xticklabel", ha, ...
-%!           "ytick", [0.25, 0.5, 0.75], ...
-%!           "yticklabel", va);
-%! axis ([0 1 0 1]);
-%! xlabel ("horizontal alignment");
-%! ylabel ("vertical alignment");
-%! title ("text alignment and rotation (0:30:360 degrees)")
 
 %!demo
-%! clf
-%! h = mesh (peaks, "edgecolor", 0.7 * [1 1 1], ...
-%!                  "facecolor", "none", ...
-%!                  "facealpha", 0);
+%! clf;
+%! ha = {'left', 'center', 'right'};
+%! va = {'bottom', 'middle', 'top'};
+%! x = [0.25 0.5 0.75];
+%! y = x;
+%! for t = 0:30:359;
+%!   for nh = 1:numel (ha)
+%!     for nv = 1:numel (va)
+%!       text (x(nh), y(nv), 'Hello World', ...
+%!             'rotation', t, ...
+%!             'horizontalalignment', ha{nh}, ...
+%!             'verticalalignment', va{nv});
+%!     end
+%!   end
+%! end
+%! set (gca, 'xtick', [0.25, 0.5, 0.75], ...
+%!           'xticklabel', ha, ...
+%!           'ytick', [0.25, 0.5, 0.75], ...
+%!           'yticklabel', va);
+%! axis ([0 1 0 1]);
+%! xlabel ('horizontal alignment');
+%! ylabel ('vertical alignment');
+%! title ('text alignment and rotation (0:30:360 degrees)');
+
+%!demo
+%! clf;
+%! h = mesh (peaks, 'edgecolor', 0.7 * [1 1 1], ...
+%!                  'facecolor', 'none', ...
+%!                  'facealpha', 0);
 %! for t = 0:45:359;
-%!   text (25, 25, 0, "Vertical Alignment = Bottom", ...
-%!                    "rotation", t, ...
-%!                    "horizontalalignment", "left", ...
-%!                    "verticalalignment", "bottom");
-%! endfor
+%!   text (25, 25, 0, 'Vertical Alignment = Bottom', ...
+%!                    'rotation', t, ...
+%!                    'horizontalalignment', 'left', ...
+%!                    'verticalalignment', 'bottom');
+%! end
 %! caxis ([-100 100]);
-%! title ("Vertically Aligned at Bottom");
+%! title ('Vertically Aligned at Bottom');
 
 %!demo
-%! clf
+%! clf;
 %! axis ([0 8 0 8]);
-%! title (["1st title";"2nd title"]);
-%! xlabel (["1st xlabel";"2nd xlabel"]);
-%! ylabel (["1st ylabel";"2nd ylabel"]);
-%! text (4, 4, {"Hello", "World"}, ...
-%!       "horizontalalignment", "center", ...
-%!       "verticalalignment", "middle");
-%! grid on
+%! title (['1st title';'2nd title']);
+%! xlabel (['1st xlabel';'2nd xlabel']);
+%! ylabel (['1st ylabel';'2nd ylabel']);
+%! text (4, 4, {'Hello', 'World'}, ...
+%!       'horizontalalignment', 'center', ...
+%!       'verticalalignment', 'middle');
+%! grid on;
 
 %!demo
-%! clf
-%! h = mesh (peaks, "edgecolor", 0.7 * [1 1 1], ...
-%!                  "facecolor", "none", ...
-%!                  "facealpha", 0);
-%! title (["1st title";"2nd title"]);
-%! xlabel (["1st xlabel";"2nd xlabel"]);
-%! ylabel (["1st ylabel";"2nd ylabel"]);
-%! zlabel (["1st zlabel";"2nd zlabel"]);
-%! text (0, 0, 5, {"Hello", "World"}, ...
-%!       "horizontalalignment", "center", ...
-%!       "verticalalignment", "middle");
+%! clf;
+%! h = mesh (peaks (), 'edgecolor', 0.7 * [1 1 1], ...
+%!                     'facecolor', 'none', ...
+%!                     'facealpha', 0);
+%! title (['1st title';'2nd title']);
+%! xlabel (['1st xlabel';'2nd xlabel']);
+%! ylabel (['1st ylabel';'2nd ylabel']);
+%! zlabel (['1st zlabel';'2nd zlabel']);
+%! text (0, 0, 5, {'Hello', 'World'}, ...
+%!       'horizontalalignment', 'center', ...
+%!       'verticalalignment', 'middle');
 %! hold on;
-%! plot3 (0, 0, 5, "+k");
+%! plot3 (0, 0, 5, '+k');
 
 %!demo
-%! clf
-%! h = text (0.5, 0.3, "char");
-%! assert ("char", class (get (h, "string")));
-%! h = text (0.5, 0.4, ["char row 1"; "char row 2"]);
-%! assert ("char", class (get (h, "string")));
-%! h = text (0.5, 0.6, {"cell2str (1,1)", "cell2str (1,2)"; "cell2str (2,1)", "cell2str (2,2)"});
-%! assert ("cell", class (get (h, "string")));
-%! h = text (0.5, 0.8, "foobar");
-%! set (h, "string", 1:3);
-%! h = text ([0.1, 0.1], [0.3, 0.4], "one string & two objects");
-%! assert ("char", class (get (h(1), "string")));
-%! assert ("char", class (get (h(2), "string")));
-%! h = text ([0.1, 0.1], [0.5, 0.6], {"one cellstr & two objects"});
-%! assert ("cell", class (get (h(1), "string")));
-%! assert ("cell", class (get (h(2), "string")));
-%! h = text ([0.1, 0.1], [0.7, 0.8], {"cellstr 1 object 1", "cellstr 2 object 2"});
-%! assert ("char", class (get (h(1), "string")));
-%! assert ("char", class (get (h(2), "string")));
-%! h = text ([0.1, 0.1], [0.1, 0.2], ["1st string & 1st object"; "2nd string & 2nd object"]);
-%! assert ("char", class (get (h(1), "string")));
-%! assert ("char", class (get (h(2), "string")));
-%! h = text (0.7, 0.6, "single string");
-%! assert ("char", class (get (h, "string")));
-%! h = text (0.7, 0.5, {"single cell-string"});
-%! assert ("cell", class (get (h, "string")));
+%! clf;
+%! h = text (0.5, 0.3, 'char');
+%! assert ('char', class (get (h, 'string')));
+%! h = text (0.5, 0.4, ['char row 1'; 'char row 2']);
+%! assert ('char', class (get (h, 'string')));
+%! h = text (0.5, 0.6, {'cell2str (1,1)', 'cell2str (1,2)'; 'cell2str (2,1)', 'cell2str (2,2)'});
+%! assert ('cell', class (get (h, 'string')));
+%! h = text (0.5, 0.8, 'foobar');
+%! set (h, 'string', 1:3);
+%! h = text ([0.1, 0.1], [0.3, 0.4], 'one string & two objects');
+%! assert ('char', class (get (h(1), 'string')));
+%! assert ('char', class (get (h(2), 'string')));
+%! h = text ([0.1, 0.1], [0.5, 0.6], {'one cellstr & two objects'});
+%! assert ('cell', class (get (h(1), 'string')));
+%! assert ('cell', class (get (h(2), 'string')));
+%! h = text ([0.1, 0.1], [0.7, 0.8], {'cellstr 1 object 1', 'cellstr 2 object 2'});
+%! assert ('char', class (get (h(1), 'string')));
+%! assert ('char', class (get (h(2), 'string')));
+%! h = text ([0.1, 0.1], [0.1, 0.2], ['1st string & 1st object'; '2nd string & 2nd object']);
+%! assert ('char', class (get (h(1), 'string')));
+%! assert ('char', class (get (h(2), 'string')));
+%! h = text (0.7, 0.6, 'single string');
+%! assert ('char', class (get (h, 'string')));
+%! h = text (0.7, 0.5, {'single cell-string'});
+%! assert ('cell', class (get (h, 'string')));
 %! xlabel (1:2);
 %! ylabel (1:2);
 %! title (1:2);
--- a/scripts/plot/title.m
+++ b/scripts/plot/title.m
@@ -46,26 +46,26 @@
 
 
 %!demo
-%! clf ();
-%! ax = axes();
-%! xl = get (ax,"title");
-%! title ("Testing title");
-%! assert (get (xl,"string"), "Testing title");
+%! clf;
+%! ax = axes ();
+%! xl = get (ax, 'title');
+%! title ('Testing title');
+%! assert (get (xl, 'string'), 'Testing title');
 
 %!demo
-%! clf ();
+%! clf;
 %! plot3 ([0,1], [0,1], [0,1]);
-%! xl = get(gca (), "title");
-%! title ("Testing title");
-%! assert (get (xl,"string"),"Testing title");
+%! xl = get (gca, 'title');
+%! title ('Testing title');
+%! assert (get (xl, 'string'), 'Testing title');
 
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
-%!   ax = axes();
-%!   xl = get (ax,"title");
+%!   ax = axes ();
+%!   xl = get (ax, "title");
 %!   title ("Testing title");
-%!   assert (get (xl,"string"), "Testing title");
+%!   assert (get (xl, "string"), "Testing title");
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
@@ -74,9 +74,9 @@
 %! hf = figure ("visible", "off");
 %! unwind_protect
 %!   plot3 ([0,1], [0,1], [0,1]);
-%!   xl = get (gca (), "title");
-%!   title("Testing title");
-%!   assert (get (xl,"string"), "Testing title");
+%!   xl = get (gca, "title");
+%!   title ("Testing title");
+%!   assert (get (xl, "string"), "Testing title");
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
--- a/scripts/plot/trimesh.m
+++ b/scripts/plot/trimesh.m
@@ -41,10 +41,10 @@
   else
     newplot ();
     handle = patch ("Vertices", [x(:), y(:), z(:)], "Faces", tri,
-                    "FaceColor", "none", "EdgeColor", __next_line_color__(),
+                    "FaceColor", "none", "EdgeColor", __next_line_color__ (),
                     varargin{:});
     if (! ishold ())
-      set (gca(), "view", [-37.5, 30],
+      set (gca (), "view", [-37.5, 30],
            "xgrid", "on", "ygrid", "on", "zgrid", "on");
     endif
     if (nargout > 0)
@@ -56,10 +56,10 @@
 
 
 %!demo
-%! clf
-%! old_state = rand ("state");
-%! restore_state = onCleanup (@() rand ("state", old_state));
-%! rand ("state", 10);
+%! clf;
+%! old_state = rand ('state');
+%! restore_state = onCleanup (@() rand ('state', old_state));
+%! rand ('state', 10);
 %! N = 10;
 %! x = 3 - 6 * rand (N, N);
 %! y = 3 - 6 * rand (N, N);
--- a/scripts/plot/triplot.m
+++ b/scripts/plot/triplot.m
@@ -48,10 +48,10 @@
 
 
 %!demo
-%! clf
-%! old_state = rand ("state");
-%! restore_state = onCleanup (@() rand ("state", old_state));
-%! rand ("state", 2);
+%! clf;
+%! old_state = rand ('state');
+%! restore_state = onCleanup (@() rand ('state', old_state));
+%! rand ('state', 2);
 %! N = 20;
 %! x = rand (N, 1);
 %! y = rand (N, 1);
--- a/scripts/plot/trisurf.m
+++ b/scripts/plot/trisurf.m
@@ -64,40 +64,44 @@
     endif
 
     if (! ishold ())
-      set (gca(), "view", [-37.5, 30],
+      set (gca (), "view", [-37.5, 30],
            "xgrid", "on", "ygrid", "on", "zgrid", "on");
     endif
   endif
 
 endfunction
 
+
 %!demo
-%! clf
+%! clf;
+%! colormap ('default');
 %! N = 31;
 %! [x, y] = meshgrid (1:N);
 %! tri = delaunay (x, y);
 %! z = peaks (N);
-%! h = trisurf (tri, x, y, z, "facecolor", "interp");
-%! axis tight
-%! zlim auto
-%! title (sprintf ("facecolor = %s", get (h, "facecolor")))
+%! h = trisurf (tri, x, y, z, 'facecolor', 'interp');
+%! axis tight;
+%! zlim auto;
+%! title (sprintf ('facecolor = %s', get (h, 'facecolor')));
 
 %!demo
-%! clf
+%! clf;
+%! colormap ('default');
 %! N = 31;
 %! [x, y] = meshgrid (1:N);
 %! tri = delaunay (x, y);
 %! z = peaks (N);
-%! h = trisurf (tri, x, y, z, "facecolor", "flat");
-%! axis tight
-%! zlim auto
-%! title (sprintf ("facecolor = %s", get (h, "facecolor")))
+%! h = trisurf (tri, x, y, z, 'facecolor', 'flat');
+%! axis tight;
+%! zlim auto;
+%! title (sprintf ('facecolor = %s', get (h, 'facecolor')));
 
 %!demo
-%! clf
-%! old_state = rand ("state");
-%! restore_state = onCleanup (@() rand ("state", old_state));
-%! rand ("state", 10);
+%! clf;
+%! colormap ('default');
+%! old_state = rand ('state');
+%! restore_state = onCleanup (@() rand ('state', old_state));
+%! rand ('state', 10);
 %! N = 10;
 %! x = 3 - 6 * rand (N, N);
 %! y = 3 - 6 * rand (N, N);
@@ -106,7 +110,8 @@
 %! trisurf (tri, x(:), y(:), z(:));
 
 %!demo
-%! clf
+%! clf;
+%! colormap ('default');
 %! x = rand (100, 1);
 %! y = rand (100, 1);
 %! z = x.^2 + y.^2;
@@ -114,18 +119,20 @@
 %! trisurf (tri, x, y, z);
 
 %!demo
-%! clf
+%! clf;
+%! colormap ('default');
 %! x = rand (100, 1);
 %! y = rand (100, 1);
 %! z = x.^2 + y.^2;
 %! tri = delaunay (x, y);
-%! trisurf (tri, x, y, z, "facecolor", "interp");
+%! trisurf (tri, x, y, z, 'facecolor', 'interp');
 
 %!demo
-%! clf
+%! clf;
+%! colormap ('default');
 %! x = rand (100, 1);
 %! y = rand (100, 1);
 %! z = x.^2 + y.^2;
 %! tri = delaunay (x, y);
-%! trisurf (tri, x, y, z, "facecolor", "interp", "edgecolor", "k");
+%! trisurf (tri, x, y, z, 'facecolor', 'interp', 'edgecolor', 'k');
 
--- a/scripts/plot/uicontextmenu.m
+++ b/scripts/plot/uicontextmenu.m
@@ -17,7 +17,7 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {@var{handle} =} uicontextmenu ('Name', value, @dots{})
+## @deftypefn {Function File} {@var{handle} =} uicontextmenu ("Name", value, @dots{})
 ## @end deftypefn
 
 ## Author: goffioul
--- a/scripts/plot/uicontrol.m
+++ b/scripts/plot/uicontrol.m
@@ -17,8 +17,8 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {@var{handle} =} uicontrol ('Name', value, @dots{})
-## @deftypefnx {Function File} {@var{handle} =} uicontrol (@var{parent}, 'Name', value, @dots{})
+## @deftypefn  {Function File} {@var{handle} =} uicontrol ("Name", value, @dots{})
+## @deftypefnx {Function File} {@var{handle} =} uicontrol (@var{parent}, "Name", value, @dots{})
 ## @deftypefnx {Function File} {} uicontrol (@var{handle})
 ## @end deftypefn
 
--- a/scripts/plot/uigetdir.m
+++ b/scripts/plot/uigetdir.m
@@ -58,9 +58,10 @@
 
 endfunction
 
+
 %!demo
-%! uigetdir(pwd, "Select Directory")
+%! uigetdir (pwd, 'Select Directory');
 
 ## Remove from test statistics.  No real tests possible.
-%!test
-%! assert (1);
+%!assert (1)
+
--- a/scripts/plot/uigetfile.m
+++ b/scripts/plot/uigetfile.m
@@ -81,7 +81,7 @@
     error ("uigetfile: number of input arguments must be less than eight");
   endif
 
-  defaultvals = {cell(0, 2),         # File Filter
+  defaultvals = {cell (0, 2),        # File Filter
                  "Open File",        # Dialog Title
                  "",                 # Default file name
                  [240, 120],         # Dialog Position (pixel x/y)
@@ -98,9 +98,10 @@
     for i = 1 : length (varargin)
       val = varargin{i};
       if (ischar (val))
-        if (strncmpi (val, "multiselect", 11))
+        val = tolower (val);
+        if (strncmp (val, "multiselect", 11))
           idx1 = i;
-        elseif (strncmpi (val, "position", 8))
+        elseif (strncmp (val, "position", 8))
           idx2 = i;
         endif
       endif
@@ -164,7 +165,7 @@
       prop = varargin{i};
       val = varargin{i + 1};
       if (strncmp (tolower (prop), "position", 8))
-        if (ismatrix (val) && length(val) == 2)
+        if (ismatrix (val) && length (val) == 2)
           outargs{4} = val;
         else
           error ("uigetfile: expecting 2-element vector for position argument");
@@ -185,9 +186,10 @@
 
 endfunction
 
+
 %!demo
-%! uigetfile({"*.gif;*.png;*.jpg", "Supported Picture Formats"})
+%! uigetfile ({'*.gif;*.png;*.jpg', 'Supported Picture Formats'});
 
 ## Remove from test statistics.  No real tests possible.
-%!test
-%! assert (1);
+%!assert (1)
+
--- a/scripts/plot/uimenu.m
+++ b/scripts/plot/uimenu.m
@@ -91,14 +91,14 @@
 
 
 %!demo
-%! clf
+%! clf;
 %! surfl (peaks);
-%! colormap (copper);
-%! shading ("interp");
-%! f = uimenu ("label", "&File", "accelerator", "f");
-%! e = uimenu ("label", "&Edit", "accelerator", "e");
-%! uimenu (f, "label", "Close", "accelerator", "q", "callback", "close (gcf)");
-%! uimenu (e, "label", "Toggle &Grid", "accelerator", "g", "callback", "grid (gca)");
+%! colormap (copper (64));
+%! shading ('interp');
+%! f = uimenu ('label', '&File', 'accelerator', 'f');
+%! e = uimenu ('label', '&Edit', 'accelerator', 'e');
+%! uimenu (f, 'label', 'Close', 'accelerator', 'q', 'callback', 'close (gcf)');
+%! uimenu (e, 'label', 'Toggle &Grid', 'accelerator', 'g', 'callback', 'grid (gca)');
 
 %!testif HAVE_FLTK
 %! toolkit = graphics_toolkit ();
@@ -124,11 +124,11 @@
 %! hf = figure ("visible", "off");
 %! unwind_protect
 %!   uif = findall (hf, "label", "&file");
-%!   assert (ishghandle (uif))
+%!   assert (ishghandle (uif));
 %!   uie = findall (hf, "label", "&edit");
-%!   assert (ishghandle (uie))
+%!   assert (ishghandle (uie));
 %!   uih = findall (hf, "label", "&help");
-%!   assert (ishghandle (uih))
+%!   assert (ishghandle (uih));
 %! unwind_protect_cleanup
 %!   close (hf);
 %!   graphics_toolkit (toolkit);
@@ -141,7 +141,7 @@
 %! unwind_protect
 %!   uie = findall (hf, "label", "&edit");
 %!   myui = uimenu (uie, "label", "mylabel");
-%!   assert (ancestor (myui, "uimenu", "toplevel"), uie)
+%!   assert (ancestor (myui, "uimenu", "toplevel"), uie);
 %! unwind_protect_cleanup
 %!   close (hf);
 %!   graphics_toolkit (toolkit);
--- a/scripts/plot/uipanel.m
+++ b/scripts/plot/uipanel.m
@@ -17,8 +17,8 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {@var{handle} =} uipanel ('Name', value, @dots{})
-## @deftypefnx {Function File} {@var{handle} =} uipanel (@var{parent}, 'Name', value, @dots{})
+## @deftypefn  {Function File} {@var{handle} =} uipanel ("Name", value, @dots{})
+## @deftypefnx {Function File} {@var{handle} =} uipanel (@var{parent}, "Name", value, @dots{})
 ## @end deftypefn
 
 ## Author: goffioul
--- a/scripts/plot/uipushtool.m
+++ b/scripts/plot/uipushtool.m
@@ -17,8 +17,8 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {@var{handle} =} uipushtool ('Name', value, @dots{})
-## @deftypefnx {Function File} {@var{handle} =} uipushtool (@var{parent}, 'Name', value, @dots{})
+## @deftypefn  {Function File} {@var{handle} =} uipushtool ("Name", value, @dots{})
+## @deftypefnx {Function File} {@var{handle} =} uipushtool (@var{parent}, "Name", value, @dots{})
 ## @end deftypefn
 
 ## Author: goffioul
--- a/scripts/plot/uiputfile.m
+++ b/scripts/plot/uiputfile.m
@@ -30,21 +30,21 @@
 ## extracted and used as filter.
 ## In addition the path is selected as current path and the filename is selected
 ## as default file.
-## Example: uiputfile("myfun.m");
+## Example: uiputfile ("myfun.m");
 ##
 ## @item "*.ext"
 ## A single file extension.
-## Example: uiputfile("*.ext");
+## Example: uiputfile ("*.ext");
 ##
 ## @item @{"*.ext","My Description"@}
 ## A 2-column cell array containing the file extension in the 1st column and
 ## a brief description in the 2nd column.
-## Example: uiputfile(@{"*.ext","My Description";"*.xyz","XYZ-Format"@});
+## Example: uiputfile (@{"*.ext","My Description";"*.xyz","XYZ-Format"@});
 ## @end table
 ##
 ## The filter string can also contain a semicolon separated list of filter
 ## extensions.
-## Example: uiputfile(@{"*.gif;*.png;*.jpg", "Supported Picture Formats"@});
+## Example: uiputfile (@{"*.gif;*.png;*.jpg", "Supported Picture Formats"@});
 ##
 ## @var{dialog_name} can be used to customize the dialog title.
 ## If @var{default_file} is given it is preselected in the GUI dialog.
@@ -72,14 +72,14 @@
     print_usage ();
   endif
 
-  defaultvals = {cell(0, 2),     # File Filter
+  defaultvals = {cell (0, 2),    # File Filter
                  "Save File",    # Dialog Title
                  "",             # Default file name
                  [240, 120],     # Dialog Position (pixel x/y)
                  "create",
                  pwd};           # Default directory
 
-  outargs = cell(6, 1);
+  outargs = cell (6, 1);
   for i = 1 : 6
     outargs{i} = defaultvals{i};
   endfor
@@ -120,9 +120,10 @@
 
 endfunction
 
+
 %!demo
-%! uiputfile({"*.gif;*.png;*.jpg", "Supported Picture Formats"})
+%! uiputfile ({'*.gif;*.png;*.jpg', 'Supported Picture Formats'});
 
 ## Remove from test statistics.  No real tests possible.
-%!test
-%! assert (1);
+%!assert (1)
+
--- a/scripts/plot/uiresume.m
+++ b/scripts/plot/uiresume.m
@@ -29,8 +29,8 @@
 
 function uiresume (h)
 
-  if (! ishandle (h) || ! strcmp (get (h, "type"), "figure"))
-    error ("uiresume: invalid figure handle");
+  if (! isfigure (h))
+    error ("uiresume: invalid figure handle H");
   endif
 
   try
--- a/scripts/plot/uitoggletool.m
+++ b/scripts/plot/uitoggletool.m
@@ -17,8 +17,8 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {@var{handle} =} uitoggletool ('Name', value, @dots{})
-## @deftypefnx {Function File} {@var{handle} =} uitoggletool (@var{parent}, 'Name', value, @dots{})
+## @deftypefn  {Function File} {@var{handle} =} uitoggletool ("Name", value, @dots{})
+## @deftypefnx {Function File} {@var{handle} =} uitoggletool (@var{parent}, "Name", value, @dots{})
 ## @end deftypefn
 
 ## Author: goffioul
--- a/scripts/plot/uitoolbar.m
+++ b/scripts/plot/uitoolbar.m
@@ -17,8 +17,8 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {@var{handle} =} uitoolbar ('Name', value, @dots{})
-## @deftypefnx {Function File} {@var{handle} =} uitoolbar (@var{parent}, 'Name', value, @dots{})
+## @deftypefn  {Function File} {@var{handle} =} uitoolbar ("Name", value, @dots{})
+## @deftypefnx {Function File} {@var{handle} =} uitoolbar (@var{parent}, "Name", value, @dots{})
 ## @end deftypefn
 
 ## Author: goffioul
--- a/scripts/plot/uiwait.m
+++ b/scripts/plot/uiwait.m
@@ -29,9 +29,9 @@
 ##
 ## When specified, @var{timeout} defines the number of seconds to wait
 ## for the figure deletion or the @code{uiresume} call.  The timeout value
-## must be at least 1. If a smaller value is specified, a warning is issued
+## must be at least 1.  If a smaller value is specified, a warning is issued
 ## and a timeout value of 1 is used instead.  If a non-integer value is
-## specified, it is truncated towards 0. If @var{timeout} is not specified,
+## specified, it is truncated towards 0.  If @var{timeout} is not specified,
 ## the program execution is suspended indefinitely.
 ## @seealso{uiresume, waitfor}
 ## @end deftypefn
@@ -47,8 +47,8 @@
     h = get (0, "currentfigure");
   else
     h = varargin{1};
-    if (! ishandle (h) || ! strcmp (get (h, "type"), "figure"))
-      error ("uiwait: invalid figure handle");
+    if (! isfigure (h))
+      error ("uiwait: invalid figure handle H");
     endif
     if (nargin > 1)
       timeout = varargin{2};
@@ -63,7 +63,7 @@
         if (! strcmp (get (h, "__uiwait_state__"), "none"))
           error ("uiwait: an active uiwait call for this figure already exists");
         endif
-	set (h, "__uiwait_state__", "active");
+        set (h, "__uiwait_state__", "active");
       end_try_catch
       waitfor_args = {h, "__uiwait_state__", "triggered"};
       if (! isempty (timeout))
--- a/scripts/plot/view.m
+++ b/scripts/plot/view.m
@@ -94,6 +94,7 @@
 
 endfunction
 
+
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
@@ -122,3 +123,4 @@
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
+
--- a/scripts/plot/waitbar.m
+++ b/scripts/plot/waitbar.m
@@ -26,7 +26,7 @@
 ## Return a handle @var{h} to a new waitbar object.  The waitbar is
 ## filled to fraction @var{frac} which must be in the range [0, 1].  The
 ## optional message @var{msg} is centered and displayed above the waitbar.
-## The appearance of the waitbar figure window can be configured by passing 
+## The appearance of the waitbar figure window can be configured by passing
 ## property/value pairs to the function.
 ## 
 ## When called with a single input the current waitbar, if it exists, is
@@ -136,46 +136,46 @@
 
 
 %!demo
-%! h = waitbar (0, "0.00%");
+%! h = waitbar (0, '0.00%');
 %! for i = 0:0.01:1
-%!   waitbar (i, h, sprintf ("%.2f%%", 100*i));
-%! endfor
+%!   waitbar (i, h, sprintf ('%.2f%%', 100*i));
+%! end
 %! close (h);
 
 %!demo
-%! h = waitbar (0, "please wait...");
+%! h = waitbar (0, 'please wait...');
 %! for i = 0:0.01:0.6
 %!   waitbar (i);
-%! endfor
+%! end
 %! i = 0.3;
-%! waitbar (i, h, "don't you hate taking a step backward?")
+%! waitbar (i, h, 'don''t you hate taking a step backward?');
 %! pause (0.5);
 %! for i = i:0.005:0.7
 %!   waitbar (i, h);
-%! endfor
-%! waitbar (i, h, "or stalling?")
+%! end
+%! waitbar (i, h, 'or stalling?');
 %! pause (1);
 %! for i = i:0.003:0.8
-%!   waitbar (i, h, "just a little longer now")
-%! endfor
+%!   waitbar (i, h, 'just a little longer now');
+%! end
 %! for i = i:0.001:1
-%!   waitbar (i, h, "please don't be impatient")
-%! endfor
+%!   waitbar (i, h, 'please don''t be impatient');
+%! end
 %! close (h);
 
 %!demo
-%! h1 = waitbar (0, "Waitbar #1");
-%! h2 = waitbar (0, "Waitbar #2");
-%! h2pos = get (h2, "position");
-%! h2pos(1) += h2pos(3) + 50;
-%! set (h2, "position", h2pos);
+%! h1 = waitbar (0, 'Waitbar #1');
+%! h2 = waitbar (0, 'Waitbar #2');
+%! h2pos = get (h2, 'position');
+%! h2pos(1) = h2pos(1) + (h2pos(3) + 50);
+%! set (h2, 'position', h2pos);
 %! pause (0.5);
 %! for i = 1:4
 %!   waitbar (i/4, h1);
 %!   pause (0.5);
 %!   waitbar (i/4, h2);
 %!   pause (0.5);
-%! endfor
+%! end
 %! pause (0.5);
 %! close (h1);
 %! close (h2);
--- a/scripts/plot/whitebg.m
+++ b/scripts/plot/whitebg.m
@@ -74,7 +74,7 @@
     if (isroot)
       fac = get (0, "factory");
       fields = fieldnames (fac);
-      fieldindex = intersect (find (!cellfun ("isempty", regexp(fields, 'color'))), union (find (!cellfun ("isempty", regexp(fields, 'factoryaxes.*'))), find (!cellfun ("isempty", regexp(fields, 'factoryfigure.*')))));
+      fieldindex = intersect (find (!cellfun ("isempty", regexp (fields, 'color'))), union (find (!cellfun ("isempty", regexp (fields, 'factoryaxes.*'))), find (!cellfun ("isempty", regexp (fields, 'factoryfigure.*')))));
 
       ## Check whether the factory value has been replaced
       for nf = 1 : numel (fieldindex);
@@ -95,21 +95,21 @@
     while (numel (handles))
       children = [];
       for n = 1 : numel (handles)
-        children = union (children, get(handles(n), "children"));
+        children = union (children, get (handles(n), "children"));
       endfor
       handles = children;
       h = union (h, children);
     endwhile
 
-    for nh = 1 : numel(h)
+    for nh = 1 : numel (h)
       p = get (h (nh));
       fields = fieldnames (p);
-      fieldindex = find (!cellfun ("isempty", regexp(fields, 'color')));
+      fieldindex = find (!cellfun ("isempty", regexp (fields, 'color')));
       if (numel (fieldindex))
         for nf = 1 : numel (fieldindex);
           field = fields {fieldindex (nf)};
           c = subsref (p, struct ("type", ".", "subs", field));
-          if (! ischar(c) && columns(c) == 3)
+          if (! ischar (c) && columns (c) == 3)
             set (h (nh), field, 1 - c);
           endif
         endfor
@@ -121,7 +121,7 @@
         def = get (h (nh), "default");
         fields = fieldnames (def);
         if (! isempty (fields))
-          fieldindex = find (!cellfun ("isempty", regexp(fields, 'color')));
+          fieldindex = find (!cellfun ("isempty", regexp (fields, 'color')));
           for nf = 1 : numel (fieldindex)
             defaultfield = fields {fieldindex (nf)};
             defaultvalue = 1 - subsref (def, struct ("type", ".", "subs", defaultfield));
@@ -144,6 +144,7 @@
   endif
 endfunction
 
+
 %!test
 %! dac = get (0, "defaultaxescolor");
 %! dfc = get (0, "defaultfigurecolor");
@@ -162,3 +163,4 @@
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
+
--- a/scripts/plot/xlim.m
+++ b/scripts/plot/xlim.m
@@ -23,7 +23,7 @@
 ##
 ## @deftypefn  {Function File} {@var{xl} =} xlim ()
 ## @deftypefnx {Function File} {} xlim (@var{xl})
-## @deftypefnx {Function File} {@var{m} =} xlim ('mode')
+## @deftypefnx {Function File} {@var{m} =} xlim ("mode")
 ## @deftypefnx {Function File} {} xlim (@var{m})
 ## @deftypefnx {Function File} {} xlim (@var{h}, @dots{})
 ## Get or set the limits of the x-axis of the current plot.  Called without
@@ -32,8 +32,8 @@
 ## to this value.
 ##
 ## The current mode for calculation of the x-axis can be returned with a
-## call @code{xlim ('mode')}, and can be either 'auto' or 'manual'.  The
-## current plotting mode can be set by passing either 'auto' or 'manual'
+## call @code{xlim ("mode")}, and can be either "auto" or "manual".  The
+## current plotting mode can be set by passing either "auto" or "manual"
 ## as the argument.
 ##
 ## If passed a handle as the first argument, then operate on this handle
@@ -49,34 +49,34 @@
   endif
 endfunction
 
+
 %!demo
-%! clf ();
+%! clf;
 %! line ();
 %! xlim ([0.2, 0.8]);
-%! title ("xlim is [0.2, 0.8]");
+%! title ('xlim is [0.2, 0.8]');
 %! assert (xlim (), [0.2, 0.8]);
 
 %!demo
-%! clf ();
+%! clf;
 %! line ();
 %! xlim ('auto');
-%! title ("xlim is auto");
-%! assert (xlim ("mode"), "auto");
+%! title ('xlim is auto');
+%! assert (xlim ('mode'), 'auto');
 
 %!demo
-%! clf ();
+%! clf;
 %! plot3 ([0,1], [0,1], [0,1]);
 %! xlim ([0.2, 0.8]);
-%! title ("xlim is [0.2, 0.8]");
+%! title ('xlim is [0.2, 0.8]');
 %! assert (xlim (), [0.2, 0.8]);
 
 %!demo
-%! clf ();
+%! clf;
 %! plot3 ([0,1], [0,1], [0,1]);
 %! xlim ('auto');
-%! title ("xlim is auto");
-%! assert (xlim ("mode"), "auto");
-
+%! title ('xlim is auto');
+%! assert (xlim ('mode'), 'auto');
 
 %!test
 %! hf = figure ("visible", "off");
@@ -98,3 +98,4 @@
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
+
--- a/scripts/plot/ylim.m
+++ b/scripts/plot/ylim.m
@@ -19,7 +19,7 @@
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {@var{yl} =} ylim ()
 ## @deftypefnx {Function File} {} ylim (@var{yl})
-## @deftypefnx {Function File} {@var{m} =} ylim ('mode')
+## @deftypefnx {Function File} {@var{m} =} ylim ("mode")
 ## @deftypefnx {Function File} {} ylim (@var{m})
 ## @deftypefnx {Function File} {} ylim (@var{h}, @dots{})
 ## Get or set the limits of the y-axis of the current plot.  Called without
@@ -28,8 +28,8 @@
 ## to this value.
 ##
 ## The current mode for calculation of the y-axis can be returned with a
-## call @code{ylim ('mode')}, and can be either 'auto' or 'manual'.  The
-## current plotting mode can be set by passing either 'auto' or 'manual'
+## call @code{ylim ("mode")}, and can be either "auto" or "manual".  The
+## current plotting mode can be set by passing either "auto" or "manual"
 ## as the argument.
 ##
 ## If passed a handle as the first argument, then operate on this handle
@@ -45,33 +45,34 @@
   endif
 endfunction
 
+
 %!demo
-%! clf ();
+%! clf;
 %! line ();
 %! ylim ([0.2, 0.8]);
-%! title ("ylim is [0.2, 0.8]");
+%! title ('ylim is [0.2, 0.8]');
 %! assert (ylim (), [0.2, 0.8]);
 
 %!demo
-%! clf ();
+%! clf;
 %! line ();
 %! ylim ('auto');
-%! title ("ylim is auto");
-%! assert (ylim ("mode"), "auto");
+%! title ('ylim is auto');
+%! assert (ylim ('mode'), 'auto');
 
 %!demo
-%! clf ();
+%! clf;
 %! plot3 ([0,1], [0,1], [0,1]);
 %! ylim ([0.2, 0.8]);
-%! title ("ylim is [0.2, 0.8]");
+%! title ('ylim is [0.2, 0.8]');
 %! assert (ylim (), [0.2, 0.8]);
 
 %!demo
-%! clf ();
+%! clf;
 %! plot3 ([0,1], [0,1], [0,1]);
 %! ylim ('auto');
-%! title ("ylim is auto");
-%! assert (ylim ("mode"), "auto");
+%! title ('ylim is auto');
+%! assert (ylim ('mode'), 'auto');
 
 %!test
 %! hf = figure ("visible", "off");
@@ -94,3 +95,4 @@
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
+
--- a/scripts/plot/zlim.m
+++ b/scripts/plot/zlim.m
@@ -19,7 +19,7 @@
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {@var{zl} =} zlim ()
 ## @deftypefnx {Function File} {} zlim (@var{zl})
-## @deftypefnx {Function File} {@var{m} =} zlim ('mode')
+## @deftypefnx {Function File} {@var{m} =} zlim ("mode")
 ## @deftypefnx {Function File} {} zlim (@var{m})
 ## @deftypefnx {Function File} {} zlim (@var{h}, @dots{})
 ## Get or set the limits of the z-axis of the current plot.  Called without
@@ -28,8 +28,8 @@
 ## to this value.
 ##
 ## The current mode for calculation of the z-axis can be returned with a
-## call @code{zlim ('mode')}, and can be either 'auto' or 'manual'.  The
-## current plotting mode can be set by passing either 'auto' or 'manual'
+## call @code{zlim ("mode")}, and can be either "auto" or "manual".  The
+## current plotting mode can be set by passing either "auto" or "manual"
 ## as the argument.
 ##
 ## If passed a handle as the first argument, then operate on this handle
@@ -45,33 +45,34 @@
   endif
 endfunction
 
+
 %!demo
-%! clf ();
+%! clf;
 %! line ();
 %! zlim ([0.2, 0.8]);
-%! title ("zlim is [0.2, 0.8]");
+%! title ('zlim is [0.2, 0.8]');
 %! assert (zlim (), [0.2, 0.8]);
 
 %!demo
-%! clf ();
+%! clf;
 %! line ();
 %! zlim ('auto');
-%! title ("zlim is auto");
-%! assert (zlim ("mode"), "auto");
+%! title ('zlim is auto');
+%! assert (zlim ('mode'), 'auto');
 
 %!demo
-%! clf ();
+%! clf;
 %! plot3 ([0,1], [0,1], [0,1]);
 %! zlim ([0.2, 0.8]);
-%! title ("zlim is [0.2, 0.8]");
+%! title ('zlim is [0.2, 0.8]');
 %! assert (zlim (), [0.2, 0.8]);
 
 %!demo
-%! clf ();
+%! clf;
 %! plot3 ([0,1], [0,1], [0,1]);
 %! zlim ('auto');
-%! title ("zlim is auto");
-%! assert (zlim ("mode"), "auto");
+%! title ('zlim is auto');
+%! assert (zlim ('mode'), 'auto');
 
 %!test
 %! hf = figure ("visible", "off");
@@ -94,3 +95,4 @@
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
+
--- a/scripts/polynomial/compan.m
+++ b/scripts/polynomial/compan.m
@@ -79,15 +79,12 @@
 
 endfunction
 
-%!assert(all (all (compan ([1, 2, 3]) == [-2, -3; 1, 0])));
-
-%!assert(all (all (compan ([1; 2; 3]) == [-2, -3; 1, 0])));
-
-%!assert(isempty (compan (4)));
 
-%!assert(all (all (compan ([3, 2, 1]) == [-2/3, -1/3; 1, 0])));
+%!assert (compan ([1, 2, 3]), [-2, -3; 1, 0])
+%!assert (compan ([1; 2; 3]), [-2, -3; 1, 0])
+%!assert (isempty (compan (4)))
+%!assert (compan ([3, 2, 1]), [-2/3, -1/3; 1, 0])
 
-%!error compan ([1,2;3,4]);
+%!error compan ([1,2;3,4])
+%!error compan ([])
 
-%!error compan ([]);
-
--- a/scripts/polynomial/conv.m
+++ b/scripts/polynomial/conv.m
@@ -51,12 +51,12 @@
 
   if (! (isvector (a) && isvector (b)))
     error ("conv: both arguments A and B must be vectors");
-  elseif (nargin == 3 && ! any (strcmpi (shape, {"full", "same"})))
-    error ('conv: SHAPE argument must be "full" or "same"');
+  elseif (nargin == 3 && ! any (strcmpi (shape, {"full", "same", "valid"})))
+    error ('conv: SHAPE argument must be "full", "same", or "valid"');
   endif
 
-  la = length (a);
-  lb = length (b);
+  la = la_orig = length (a);
+  lb = lb_orig = length (b);
 
   ly = la + lb - 1;
 
@@ -79,63 +79,68 @@
 
   y = filter (a, 1, x);
 
-  if (strcmp (shape, "same"))
+  if (strcmpi (shape, "same"))
     idx = ceil ((ly - la) / 2);
     y = y(idx+1:idx+la);
+  elseif (strcmpi (shape, "valid"))
+    len = la_orig - lb_orig;
+    y = y(lb_orig:lb_orig+len);
   endif
 
 endfunction
 
 
 %!test
-%!  x = ones(3,1);
-%!  y = ones(1,3);
-%!  b = 2;
-%!  c = 3;
-%!  assert (conv (x, x), [1; 2; 3; 2; 1]);
-%!  assert (conv (y, y), [1, 2, 3, 2, 1]);
-%!  assert (conv (x, y), [1, 2, 3, 2, 1]);
-%!  assert (conv (y, x), [1; 2; 3; 2; 1]);
-%!  assert (conv (c, x), [3; 3; 3]);
-%!  assert (conv (c, y), [3, 3, 3]);
-%!  assert (conv (x, c), [3; 3; 3]);
-%!  assert (conv (y, c), [3, 3, 3]);
-%!  assert (conv (b, c), 6);
+%! x = ones (3,1);
+%! y = ones (1,3);
+%! b = 2;
+%! c = 3;
+%! assert (conv (x, x), [1; 2; 3; 2; 1]);
+%! assert (conv (y, y), [1, 2, 3, 2, 1]);
+%! assert (conv (x, y), [1, 2, 3, 2, 1]);
+%! assert (conv (y, x), [1; 2; 3; 2; 1]);
+%! assert (conv (c, x), [3; 3; 3]);
+%! assert (conv (c, y), [3, 3, 3]);
+%! assert (conv (x, c), [3; 3; 3]);
+%! assert (conv (y, c), [3, 3, 3]);
+%! assert (conv (b, c), 6);
 
+%!shared a,b
 %!test
-%!  a = 1:10;
-%!  b = 1:3;
-%!  assert (size (conv(a,b)), [1, numel(a)+numel(b)-1]);
-%!  assert (size (conv(b,a)), [1, numel(a)+numel(b)-1]);
+%! a = 1:10;
+%! b = 1:3;
+%!assert (size (conv (a,b)), [1, numel(a)+numel(b)-1])
+%!assert (size (conv (b,a)), [1, numel(a)+numel(b)-1])
 
 %!test
-%!  a = (1:10).';
-%!  b = 1:3;
-%!  assert (size (conv(a,b)), [numel(a)+numel(b)-1, 1]);
-%!  assert (size (conv(b,a)), [numel(a)+numel(b)-1, 1]);
+%! a = (1:10).';
+%!assert (size (conv (a,b)), [numel(a)+numel(b)-1, 1])
+%!assert (size (conv (b,a)), [numel(a)+numel(b)-1, 1])
+
+%!test
+%! a = 1:10;
+%! b = (1:3).';
+%!assert (size (conv (a,b)), [1, numel(a)+numel(b)-1])
+%!assert (size (conv (b,a)), [1, numel(a)+numel(b)-1])
 
 %!test
-%!  a = 1:10;
-%!  b = (1:3).';
-%!  assert (size (conv(a,b)), [1, numel(a)+numel(b)-1]);
-%!  assert (size (conv(b,a)), [1, numel(a)+numel(b)-1]);
+%! a = 1:10;
+%! b = 1:3;
+
+%!assert (conv (a,b,"full"), conv (a,b))
+%!assert (conv (b,a,"full"), conv (b,a))
 
-%!test
-%!  a = 1:10;
-%!  b = 1:3;
-%!  assert (conv (a,b,"full"), conv (a,b));
-%!  assert (conv (b,a,"full"), conv (b,a));
+%!assert (conv (a,b,"same"), [4, 10, 16, 22, 28, 34, 40, 46, 52, 47])
+%!assert (conv (b,a,"same"), [28, 34, 40])
 
-%!test
-%!  a = 1:10;
-%!  b = 1:3;
-%!  assert (conv (a,b,"same"), [4, 10, 16, 22, 28, 34, 40, 46, 52, 47]);
-%!  assert (conv (b,a,"same"), [28, 34, 40]);
+%!assert (conv (a,b,"valid"), [10, 16, 22, 28, 34, 40, 46, 52])
+%!assert (conv (b,a,"valid"), zeros (1,0))
+
 
 %% Test input validation
 %!error conv (1)
 %!error conv (1,2,3,4)
-%!error conv ([1, 2; 3, 4], 3)
-%!error conv (3, [1, 2; 3, 4])
-%!error conv (2, 3, "XXXX")
+%!error <A and B must be vectors> conv ([1, 2; 3, 4], 3)
+%!error <A and B must be vectors> conv (3, [1, 2; 3, 4])
+%!error <SHAPE argument must be> conv (2, 3, "INVALID_SHAPE")
 
--- a/scripts/polynomial/deconv.m
+++ b/scripts/polynomial/deconv.m
@@ -40,7 +40,7 @@
   endif
 
   if (! (isvector (y) && isvector (a)))
-    error("deconv: both arguments must be vectors");
+    error ("deconv: both arguments must be vectors");
   endif
 
   la = length (a);
@@ -68,7 +68,7 @@
     r = y - conv (a, b);
   else
     ## Respect the orientation of Y"
-    if (size (y, 1) <= size (y, 2))
+    if (rows (y) <= columns (y))
       r = [(zeros (1, lc - ly)), y] - conv (a, b);
     else
       r = [(zeros (lc - ly, 1)); y] - conv (a, b);
@@ -81,30 +81,34 @@
 
 endfunction
 
+
 %!test
 %! [b, r] = deconv ([3, 6, 9, 9], [1, 2, 3]);
-%! assert(all (all (b == [3, 0])) && all (all (r == [0, 0, 0, 9])));
+%! assert (b, [3, 0]);
+%! assert (r, [0, 0, 0, 9]);
 
 %!test
 %! [b, r] = deconv ([3, 6], [1, 2, 3]);
-%! assert(b == 0 && all (all (r == [3, 6])));
+%! assert (b, 0);
+%! assert (r, [3, 6]);
 
 %!test
 %! [b, r] = deconv ([3, 6], [1; 2; 3]);
-%! assert(b == 0 && all (all (r == [3, 6])));
+%! assert (b, 0);
+%! assert (r, [3, 6]);
 
 %!test
 %! [b,r] = deconv ([3; 6], [1; 2; 3]);
-%! assert (b == 0 && all (all (r == [3; 6])))
+%! assert (b, 0);
+%! assert (r, [3; 6]);
 
 %!test
 %! [b, r] = deconv ([3; 6], [1, 2, 3]);
-%! assert (b == 0 && all (all (r == [3; 6])))
-
-%!test
-%! assert (deconv ((1:3)',[1, 1]), [1; 1])
+%! assert (b, 0);
+%! assert (r, [3; 6]);
 
-%!error [b, r] = deconv ([3, 6], [1, 2; 3, 4]);
+%!assert (deconv ((1:3)',[1, 1]), [1; 1])
 
-%!error [b, r] = deconv ([3, 6; 1, 2], [1, 2, 3]);
+%!error [b, r] = deconv ([3, 6], [1, 2; 3, 4])
+%!error [b, r] = deconv ([3, 6; 1, 2], [1, 2, 3])
 
--- a/scripts/polynomial/mkpp.m
+++ b/scripts/polynomial/mkpp.m
@@ -79,34 +79,36 @@
 
 endfunction
 
+
 %!demo # linear interpolation
-%! x=linspace(0,pi,5)';
-%! t=[sin(x),cos(x)];
-%! m=diff(t)./(x(2)-x(1));
-%! b=t(1:4,:);
-%! pp = mkpp(x, [m(:),b(:)]);
-%! xi=linspace(0,pi,50);
-%! plot(x,t,"x",xi,ppval(pp,xi));
-%! legend("control","interp");
+%! x = linspace (0,pi,5)';
+%! t = [sin(x), cos(x)];
+%! m = diff (t) ./ (x(2)-x(1));
+%! b = t(1:4,:);
+%! pp = mkpp (x, [m(:),b(:)]);
+%! xi = linspace (0,pi,50);
+%! plot (x,t,"x", xi,ppval (pp,xi));
+%! legend ("control", "interp");
 
 %!shared b,c,pp
-%! b = 1:3; c = 1:24; pp=mkpp(b,c);
-%!assert (pp.pieces,2);
-%!assert (pp.order,12);
-%!assert (pp.dim,1);
-%!assert (size(pp.coefs),[2,12]);
-%! pp=mkpp(b,c,2);
-%!assert (pp.pieces,2);
-%!assert (pp.order,6);
-%!assert (pp.dim,2);
-%!assert (size(pp.coefs),[4,6]);
-%! pp=mkpp(b,c,3);
-%!assert (pp.pieces,2);
-%!assert (pp.order,4);
-%!assert (pp.dim,3);
-%!assert (size(pp.coefs),[6,4]);
-%! pp=mkpp(b,c,[2,3]);
-%!assert (pp.pieces,2);
-%!assert (pp.order,2);
-%!assert (pp.dim,[2,3]);
-%!assert (size(pp.coefs),[12,2]);
+%! b = 1:3; c = 1:24; pp = mkpp (b,c);
+%!assert (pp.pieces, 2)
+%!assert (pp.order, 12)
+%!assert (pp.dim, 1)
+%!assert (size (pp.coefs), [2,12])
+%! pp = mkpp (b,c,2);
+%!assert (pp.pieces, 2)
+%!assert (pp.order, 6)
+%!assert (pp.dim, 2)
+%!assert (size (pp.coefs), [4,6])
+%! pp = mkpp (b,c,3);
+%!assert (pp.pieces, 2)
+%!assert (pp.order, 4)
+%!assert (pp.dim, 3)
+%!assert (size (pp.coefs), [6,4])
+%! pp = mkpp (b,c,[2,3]);
+%!assert (pp.pieces, 2)
+%!assert (pp.order, 2)
+%!assert (pp.dim, [2,3])
+%!assert (size (pp.coefs), [12,2])
+
--- a/scripts/polynomial/module.mk
+++ b/scripts/polynomial/module.mk
@@ -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,7 +27,9 @@
   polynomial/residue.m \
   polynomial/roots.m \
   polynomial/spline.m \
-  polynomial/unmkpp.m
+  polynomial/splinefit.m \
+  polynomial/unmkpp.m \
+  $(polynomial_PRIVATE_FCN_FILES)
 
 FCN_FILES += $(polynomial_FCN_FILES)
 
--- a/scripts/polynomial/mpoles.m
+++ b/scripts/polynomial/mpoles.m
@@ -116,7 +116,8 @@
 
 endfunction
 
+
 %!test
 %! [mp, n] = mpoles ([0 0], 0.01);
-%! assert (mp, [1; 2])
+%! assert (mp, [1; 2]);
 
--- a/scripts/polynomial/pchip.m
+++ b/scripts/polynomial/pchip.m
@@ -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);
@@ -129,44 +129,44 @@
 %! x = 0:8;
 %! y = [1, 1, 1, 1, 0.5, 0, 0, 0, 0];
 %! xi = 0:0.01:8;
-%! yspline = spline(x,y,xi);
-%! ypchip = pchip(x,y,xi);
-%! title("pchip and spline fit to discontinuous function");
-%! plot(xi,yspline,xi,ypchip,"-",x,y,"+");
-%! legend ("spline","pchip","data");
+%! yspline = spline (x,y,xi);
+%! ypchip = pchip (x,y,xi);
+%! title ("pchip and spline fit to discontinuous function");
+%! plot (xi,yspline, xi,ypchip,"-", x,y,"+");
+%! legend ("spline", "pchip", "data");
 %! %-------------------------------------------------------------------
 %! % confirm that pchip agreed better to discontinuous data than spline
 
-%!shared x,y,y2,pp,yi1,yi2,yi3
+%!shared x, y, y2, pp, yi1, yi2, yi3
 %! x = 0:8;
 %! y = [1, 1, 1, 1, 0.5, 0, 0, 0, 0];
-%!assert (pchip(x,y,x), y);
-%!assert (pchip(x,y,x'), y');
-%!assert (pchip(x',y',x'), y');
-%!assert (pchip(x',y',x), y);
-%!assert (isempty(pchip(x',y',[])));
-%!assert (isempty(pchip(x,y,[])));
-%!assert (pchip(x,[y;y],x), [pchip(x,y,x);pchip(x,y,x)])
-%!assert (pchip(x,[y;y],x'), [pchip(x,y,x);pchip(x,y,x)])
-%!assert (pchip(x',[y;y],x), [pchip(x,y,x);pchip(x,y,x)])
-%!assert (pchip(x',[y;y],x'), [pchip(x,y,x);pchip(x,y,x)])
+%!assert (pchip (x,y,x), y)
+%!assert (pchip (x,y,x'), y')
+%!assert (pchip (x',y',x'), y')
+%!assert (pchip (x',y',x), y)
+%!assert (isempty (pchip (x',y',[])))
+%!assert (isempty (pchip (x,y,[])))
+%!assert (pchip (x,[y;y],x), [pchip(x,y,x);pchip(x,y,x)])
+%!assert (pchip (x,[y;y],x'), [pchip(x,y,x);pchip(x,y,x)])
+%!assert (pchip (x',[y;y],x), [pchip(x,y,x);pchip(x,y,x)])
+%!assert (pchip (x',[y;y],x'), [pchip(x,y,x);pchip(x,y,x)])
 %!test
-%! x=(0:8)*pi/4;y=[sin(x);cos(x)];
-%! y2(:,:,1)=y;y2(:,:,2)=y+1;y2(:,:,3)=y-1;
-%! pp=pchip(x,shiftdim(y2,2));
-%! yi1=ppval(pp,(1:4)*pi/4);
-%! yi2=ppval(pp,repmat((1:4)*pi/4,[5,1]));
-%! yi3=ppval(pp,[pi/2,pi]);
-%!assert(size(pp.coefs),[48,4]);
-%!assert(pp.pieces,8);
-%!assert(pp.order,4);
-%!assert(pp.dim,[3,2]);
-%!assert(ppval(pp,pi),[0,-1;1,0;-1,-2],1e-14);
-%!assert(yi3(:,:,2),ppval(pp,pi),1e-14);
-%!assert(yi3(:,:,1),[1,0;2,1;0,-1],1e-14);
-%!assert(squeeze(yi1(1,2,:)),[1/sqrt(2); 0; -1/sqrt(2);-1],1e-14);
-%!assert(size(yi2),[3,2,5,4]);
-%!assert(squeeze(yi2(1,2,3,:)),[1/sqrt(2); 0; -1/sqrt(2);-1],1e-14);
+%! x = (0:8)*pi/4; y = [sin(x); cos(x)];
+%! y2(:,:,1) = y; y2(:,:,2) = y+1; y2(:,:,3) = y-1;
+%! pp = pchip (x, shiftdim (y2,2));
+%! yi1 = ppval (pp, (1:4)*pi/4);
+%! yi2 = ppval (pp, repmat ((1:4)*pi/4, [5,1]));
+%! yi3 = ppval (pp, [pi/2,pi]);
+%!assert (size (pp.coefs), [48,4])
+%!assert (pp.pieces, 8)
+%!assert (pp.order, 4)
+%!assert (pp.dim, [3,2])
+%!assert (ppval (pp,pi), [0,-1;1,0;-1,-2], 1e-14)
+%!assert (yi3(:,:,2), ppval (pp,pi), 1e-14)
+%!assert (yi3(:,:,1), [1,0;2,1;0,-1], 1e-14)
+%!assert (squeeze (yi1(1,2,:)), [1/sqrt(2); 0; -1/sqrt(2);-1], 1e-14)
+%!assert (size (yi2), [3,2,5,4])
+%!assert (squeeze (yi2(1,2,3,:)), [1/sqrt(2); 0; -1/sqrt(2);-1], 1e-14)
 
 %!error (pchip (1,2));
 %!error (pchip (1,2,3));
--- a/scripts/polynomial/poly.m
+++ b/scripts/polynomial/poly.m
@@ -81,11 +81,10 @@
 
 endfunction
 
-%!assert(all (all (poly ([1, 2, 3]) == [1, -6, 11, -6])));
-
-%!assert(all (all (abs (poly ([1, 2; 3, 4]) - [1, -5, -2]) < sqrt (eps))));
 
-%!error poly ([1, 2, 3; 4, 5, 6]);
+%!assert (poly ([]), 1)
+%!assert (poly ([1, 2, 3]), [1, -6, 11, -6])
+%!assert (poly ([1, 2; 3, 4]), [1, -5, -2], sqrt (eps))
 
-%!assert(poly ([]),1);
+%!error poly ([1, 2, 3; 4, 5, 6])
 
--- a/scripts/polynomial/polyaffine.m
+++ b/scripts/polynomial/polyaffine.m
@@ -30,7 +30,6 @@
 ## @seealso{polyval, polyfit}
 ## @end deftypefn
 
-
 function g = polyaffine (f, mu)
 
    if (nargin != 2)
@@ -73,16 +72,16 @@
 %!demo
 %! f = [1/5 4/5 -7/5 -2];
 %! g = polyaffine (f, [1, 1.2]);
-%! x = linspace (-4, 4, 100);
-%! plot(x, polyval (f, x), x, polyval (g, x));
+%! x = linspace (-4,4,100);
+%! plot (x,polyval (f, x), x,polyval (g, x));
 %! legend ("original", "affine");
 %! axis ([-4 4 -3 5]);
-%! grid ("on");
+%! grid on;
 
 %!test
 %! f = [1/5 4/5 -7/5 -2];
 %! mu = [1, 1.2];
 %! g = polyaffine (f, mu);
-%! x = linspace (-4, 4, 100);
+%! x = linspace (-4,4,100);
 %! assert (polyval (f, x, [], mu), polyval (g, x), 1e-10);
 
--- a/scripts/polynomial/polyder.m
+++ b/scripts/polynomial/polyder.m
@@ -60,7 +60,7 @@
 
         ## remove common factors from numerator and denominator
         x = polygcd (q, d);
-        if (length(x) != 1)
+        if (length (x) != 1)
           q = deconv (q, x);
           d = deconv (d, x);
         endif
@@ -91,9 +91,10 @@
 endfunction
 
 
-%!assert(all (all (polyder ([1, 2, 3]) == [2, 2])));
-%!assert(polyder (13) == 0);
+%!assert (polyder ([1, 2, 3], [2, 2]))
+%!assert (polyder (13), 0)
 
-%!error polyder ([]);
-%!error polyder ([1, 2; 3, 4]);
+%!error polyder ([])
+%!error polyder (1,2,3)
+%!error <argument must be a vector> polyder ([1, 2; 3, 4])
 
--- a/scripts/polynomial/polyfit.m
+++ b/scripts/polynomial/polyfit.m
@@ -22,7 +22,9 @@
 ## @deftypefnx {Function File} {[@var{p}, @var{s}, @var{mu}] =} polyfit (@var{x}, @var{y}, @var{n})
 ## Return the coefficients of a polynomial @var{p}(@var{x}) of degree
 ## @var{n} that minimizes the least-squares-error of the fit to the points
-## @code{[@var{x}, @var{y}]}.
+## @code{[@var{x}, @var{y}]}.  If @var{n} is a logical vector, it is used
+## as a mask to selectively force the corresponding polynomial
+## coefficients to be used or ignored.
 ##
 ## The polynomial coefficients are returned in a row vector.
 ##
@@ -35,6 +37,11 @@
 ## @item X
 ## The Vandermonde matrix used to compute the polynomial coefficients.
 ##
+## @item C
+## The unscaled covariance matrix, formally equal to the inverse of
+## @var{x'}*@var{x}, but computed in a way minimizing roundoff error
+## propagation.
+## 
 ## @item df
 ## The degrees of freedom.
 ##
@@ -46,7 +53,9 @@
 ## @end table
 ##
 ## The second output may be used by @code{polyval} to calculate the
-## statistical error limits of the predicted values.
+## statistical error limits of the predicted values.  In particular, the
+## standard deviation of @var{p} coefficients is given by @*
+## @code{sqrt (diag (s.C)/s.df)*s.normr}.
 ##
 ## When the third output, @var{mu}, is present the
 ## coefficients, @var{p}, are associated with a polynomial in
@@ -60,6 +69,8 @@
 ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
 ## Created: 13 December 1994
 ## Adapted-By: jwe
+## Modified on 20120204 by P. Dupuis; added the ability to specify a
+## polynomial mask instead of a polynomial degree.
 
 function [p, s, mu] = polyfit (x, y, n)
 
@@ -77,8 +88,16 @@
     error ("polyfit: X and Y must be vectors of the same size");
   endif
 
-  if (! (isscalar (n) && n >= 0 && ! isinf (n) && n == fix (n)))
-    error ("polyfit: N must be a non-negative integer");
+  if (islogical (n))
+    polymask = n;
+    ## n is the polynomial degree as given the polymask size; m is the
+    ## effective number of used coefficients.
+    n = length (polymask) - 1; m = sum (polymask) - 1;
+  else
+    if (! (isscalar (n) && n >= 0 && ! isinf (n) && n == fix (n)))
+      error ("polyfit: N must be a non-negative integer");
+    endif
+    polymask = logical (ones (1, n+1)); m = n;
   endif
 
   y_is_row_vector = (rows (y) == 1);
@@ -92,10 +111,15 @@
   v = vander (x, n+1);
 
   ## Solve by QR decomposition.
-  [q, r, k] = qr (v, 0);
+  [q, r, k] = qr (v(:, polymask), 0);
   p = r \ (q' * y);
   p(k) = p;
-
+  
+  if (n ~= m)
+    q = p; p = zeros (n+1, 1); 
+    p(polymask) = q;
+  endif
+  
   if (nargout > 1)
     yf = v*p;
 
@@ -104,10 +128,28 @@
     else
       s.yf = yf;
     endif
+    s.X = v; 
 
-    s.R = r;
-    s.X = v;
-    s.df = l - n - 1;
+    ## r.'*r is positive definite if X(:, polymask) is of full rank.
+    ## Invert it by cholinv to avoid taking the square root of squared
+    ## quantities. If cholinv fails, then X(:, polymask) is rank
+    ## deficient and not invertible.
+    try
+      C = cholinv (r.'*r)(k, k);
+    catch
+      C = NaN * ones (m+1, m+1);
+    end_try_catch
+
+    if (n ~= m)
+      ## fill matrices if required
+      s.X(:, ~polymask) = 0;
+      s.R = zeros (n+1, n+1); s.R(polymask, polymask) = r;
+      s.C = zeros (n+1, n+1); s.C(polymask, polymask) = C;
+    else
+      s.R = r; 
+      s.C = C;
+    endif
+    s.df = l - m - 1;
     s.normr = norm (yf - y);
   endif
 
@@ -116,23 +158,13 @@
 
 endfunction
 
-%!test
-%! x = [-2, -1, 0, 1, 2];
-%! assert(all (all (abs (polyfit (x, x.^2+x+1, 2) - [1, 1, 1]) < sqrt (eps))));
 
-%!error(polyfit ([1, 2; 3, 4], [1, 2, 3, 4], 2))
-
-%!test
+%!shared x
 %! x = [-2, -1, 0, 1, 2];
-%! assert(all (all (abs (polyfit (x, x.^2+x+1, 3) - [0, 1, 1, 1]) < sqrt (eps))));
-
-%!test
-%! x = [-2, -1, 0, 1, 2];
-%! fail("polyfit (x, x.^2+x+1)");
-
-%!test
-%! x = [-2, -1, 0, 1, 2];
-%! fail("polyfit (x, x.^2+x+1, [])");
+%!assert (polyfit (x, x.^2+x+1, 2), [1, 1, 1], sqrt (eps))
+%!assert (polyfit (x, x.^2+x+1, 3), [0, 1, 1, 1], sqrt (eps))
+%!fail ("polyfit (x, x.^2+x+1)")
+%!fail ("polyfit (x, x.^2+x+1, [])")
 
 ## Test difficult case where scaling is really needed. This example
 ## demonstrates the rather poor result which occurs when the dependent
@@ -146,32 +178,33 @@
 %!       315600.7143, 315602.9508, 315605.1765 ];
 %! [p1, s1] = polyfit (x, y, 10);
 %! [p2, s2, mu] = polyfit (x, y, 10);
-%! assert (s2.normr < s1.normr)
+%! assert (s2.normr < s1.normr);
 
 %!test
 %! x = 1:4;
 %! p0 = [1i, 0, 2i, 4];
 %! y0 = polyval (p0, x);
-%! p = polyfit (x, y0, numel(p0)-1);
-%! assert (p, p0, 1000*eps)
+%! p = polyfit (x, y0, numel (p0) - 1);
+%! assert (p, p0, 1000*eps);
 
 %!test
 %! x = 1000 + (-5:5);
 %! xn = (x - mean (x)) / std (x);
 %! pn = ones (1,5);
 %! y = polyval (pn, xn);
-%! [p, s, mu] = polyfit (x, y, numel(pn)-1);
-%! [p2, s2] = polyfit (x, y, numel(pn)-1);
-%! assert (p, pn, s.normr)
-%! assert (s.yf, y, s.normr)
-%! assert (mu, [mean(x), std(x)])
-%! assert (s.normr/s2.normr < sqrt(eps))
+%! [p, s, mu] = polyfit (x, y, numel (pn) - 1);
+%! [p2, s2] = polyfit (x, y, numel (pn) - 1);
+%! assert (p, pn, s.normr);
+%! assert (s.yf, y, s.normr);
+%! assert (mu, [mean(x), std(x)]);
+%! assert (s.normr/s2.normr < sqrt (eps));
 
 %!test
 %! x = [1, 2, 3; 4, 5, 6];
 %! y = [0, 0, 1; 1, 0, 0];
 %! p = polyfit (x, y, 5);
-%! expected = [0, 1, -14, 65, -112, 60]/12;
-%! assert (p, expected, sqrt(eps))
+%! expected = [0, 1, -14, 65, -112, 60] / 12;
+%! assert (p, expected, sqrt (eps));
 
+%!error <vectors of the same size> polyfit ([1, 2; 3, 4], [1, 2, 3, 4], 2)
 
--- a/scripts/polynomial/polygcd.m
+++ b/scripts/polynomial/polygcd.m
@@ -23,7 +23,7 @@
 ## Find the greatest common divisor of two polynomials.  This is equivalent
 ## to the polynomial found by multiplying together all the common roots.
 ## Together with deconv, you can reduce a ratio of two polynomials.
-## The tolerance @var{tol} defaults to @code{sqrt(eps)}.
+## The tolerance @var{tol} defaults to @code{sqrt (eps)}.
 ##
 ## @strong{Caution:} This is a numerically unstable algorithm and should not
 ## be used on large polynomials.
@@ -34,7 +34,7 @@
 ## @group
 ## polygcd (poly (1:8), poly (3:12)) - poly (3:8)
 ## @result{} [ 0, 0, 0, 0, 0, 0, 0 ]
-## deconv (poly (1:8), polygcd (poly (1:8), poly (3:12))) - poly(1:2)
+## deconv (poly (1:8), polygcd (poly (1:8), poly (3:12))) - poly (1:2)
 ## @result{} [ 0, 0, 0 ]
 ## @end group
 ## @end example
@@ -82,21 +82,19 @@
 
 
 %!test
-%! poly1 = [1 6 11 6]; % (x+1)(x+2)(x+3)
-%! poly2 = [1 3 2]; % (x+1)(x+2)
+%! poly1 = [1 6 11 6]; # (x+1)(x+2)(x+3);
+%! poly2 = [1 3 2];    # (x+1)(x+2);
 %! poly3 = polygcd (poly1, poly2);
-%! assert (poly3, poly2, sqrt (eps))
+%! assert (poly3, poly2, sqrt (eps));
 
-%!test
-%! assert (polygcd (poly(1:8), poly(3:12)), poly(3:8), sqrt (eps))
-
-%!test
-%! assert (deconv (poly(1:8), polygcd (poly(1:8), poly(3:12))), poly(1:2), sqrt (eps))
+%!assert (polygcd (poly (1:8), poly (3:12)), poly (3:8), sqrt (eps))
+%!assert (deconv (poly (1:8), polygcd (poly (1:8), poly (3:12))), poly (1:2), sqrt (eps))
 
 %!test
 %! for ii=1:10
 %!   p  = (unique (randn (10, 1)) * 10).';
 %!   p1 = p(3:end);
 %!   p2 = p(1:end-2);
-%!   assert (polygcd (poly (-p1), poly (-p2)), poly (- intersect (p1, p2)), sqrt (eps))
+%!   assert (polygcd (poly (-p1), poly (-p2)), poly (- intersect (p1, p2)), sqrt (eps));
 %! endfor
+
--- a/scripts/polynomial/polyint.m
+++ b/scripts/polynomial/polyint.m
@@ -61,17 +61,19 @@
 
 endfunction
 
+
 %!test
 %! A = [3, 2, 1];
-%! assert (polyint(A),polyint(A,0));
-%! assert (polyint(A),polyint(A'));
-%! assert (polyint(A),[1, 1, 1, 0]);
-%! assert (polyint(A,1),ones(1,4));
+%! assert (polyint (A), polyint (A,0));
+%! assert (polyint (A), polyint (A'));
+%! assert (polyint (A), [1, 1, 1, 0]);
+%! assert (polyint (A,1), ones (1,4));
 
 %!test
-%! A = ones(1,8);
+%! A = ones (1,8);
 %! B = [length(A):-1:1];
-%! assert (polyint(A),[1./B, 0]);
+%! assert (polyint (A), [1./B, 0]);
 
-%!error polyint()
-%!error polyint(ones(2,2))
+%!error polyint ()
+%!error polyint (ones (2,2))
+
--- a/scripts/polynomial/polyout.m
+++ b/scripts/polynomial/polyout.m
@@ -76,7 +76,7 @@
     tmp = " ";
   endif
 
-  if(nargout == 0)
+  if (nargout == 0)
     disp (tmp);
   else
     y = tmp;
@@ -96,8 +96,11 @@
   endif
 endfunction
 
-%!assert (polyout ([3 2 1]), '3*s^2 + 2*s^1 + 1')
-%!assert (polyout ([3 2 1], 'x'), '3*x^2 + 2*x^1 + 1')
-%!assert (polyout ([3 2 1], 'wxyz'), '3*wxyz^2 + 2*wxyz^1 + 1')
-%!assert (polyout ([5 4 3 2 1], '1'),'5*1^4 + 4*1^3 + 3*1^2 + 2*1^1 + 1')
+
+%!assert (polyout ([3 2 1]), "3*s^2 + 2*s^1 + 1")
+%!assert (polyout ([3 2 1], "x"), "3*x^2 + 2*x^1 + 1")
+%!assert (polyout ([3 2 1], "wxyz"), "3*wxyz^2 + 2*wxyz^1 + 1")
+%!assert (polyout ([5 4 3 2 1], "1"),"5*1^4 + 4*1^3 + 3*1^2 + 2*1^1 + 1")
+
 %!error polyout ([])
+
--- a/scripts/polynomial/polyreduce.m
+++ b/scripts/polynomial/polyreduce.m
@@ -31,35 +31,28 @@
 
   if (nargin != 1)
     print_usage ();
-  endif
-
-  if (!isvector (c) || isempty (c))
+  elseif (! isvector (c) || isempty (c))
     error ("polyreduce: C must be a non-empty vector");
   endif
 
-  if (! isempty (c))
-
-    index = find (c != 0);
-
-    if (isempty (index))
+  idx = find (c != 0, 1);
 
-      p = 0;
-
-    else
-
-      p = c(index (1):length (c));
-
-    endif
-
+  if (isempty (idx))
+    p = 0;
+  else
+    p = c(idx:end);
   endif
 
 endfunction
 
-%!assert(all (all (polyreduce ([0, 0, 1, 2, 3]) == [1, 2, 3])));
 
-%!assert(all (all (polyreduce ([1, 2, 3, 0, 0]) == [1, 2, 3, 0, 0])));
+%!assert (polyreduce ([0, 0, 1, 2, 3]), [1, 2, 3])
+%!assert (polyreduce ([1, 2, 3, 0, 0]), [1, 2, 3, 0, 0])
+%!assert (polyreduce ([1, 0, 3]), [1, 0, 3])
+%!assert (polyreduce ([0, 0, 0]), 0)
 
-%!assert(all (all (polyreduce ([1, 0, 3]) == [1, 0, 3])));
+%!error polyreduce ()
+%!error polyreduce (1, 2)
+%!error <C must be a non-empty vector> polyreduce ([1, 2; 3, 4])
+%!error <C must be a non-empty vector> polyreduce ([])
 
-%!error polyreduce ([1, 2; 3, 4]);
-
--- a/scripts/polynomial/polyval.m
+++ b/scripts/polynomial/polyval.m
@@ -93,20 +93,20 @@
 
 endfunction
 
-%!test
-%! fail("polyval([1,0;0,1],0:10)");
+
+%!fail ("polyval ([1,0;0,1],0:10)")
 
 %!test
 %! r = 0:10:50;
 %! p = poly (r);
-%! p = p / max(abs(p));
-%! x = linspace(0,50,11);
-%! y = polyval(p,x) + 0.25*sin(100*x);
-%! [pf, s] = polyfit (x, y, numel(r));
+%! p = p / max (abs (p));
+%! x = linspace (0,50,11);
+%! y = polyval (p,x) + 0.25*sin (100*x);
+%! [pf, s] = polyfit (x, y, numel (r));
 %! [y1, delta] = polyval (pf, x, s);
 %! expected = [0.37235, 0.35854, 0.32231, 0.32448, 0.31328, ...
 %!    0.32036, 0.31328, 0.32448, 0.32231, 0.35854, 0.37235];
-%! assert (delta, expected, 0.00001)
+%! assert (delta, expected, 0.00001);
 
 %!test
 %! x = 10 + (-2:2);
@@ -115,38 +115,39 @@
 %! [pn, s, mu] = polyfit (x, y, numel (x) - 1);
 %! y1 = polyval (p, x);
 %! yn = polyval (pn, x, [], mu);
-%! assert (y1, y, sqrt(eps))
-%! assert (yn, y, sqrt(eps))
+%! assert (y1, y, sqrt (eps));
+%! assert (yn, y, sqrt (eps));
 
 %!test
 %! p = [0, 1, 0];
 %! x = 1:10;
-%! assert (x, polyval(p,x), eps)
+%! assert (x, polyval (p,x), eps);
 %! x = x(:);
-%! assert (x, polyval(p,x), eps)
-%! x = reshape(x, [2, 5]);
-%! assert (x, polyval(p,x), eps)
-%! x = reshape(x, [5, 2]);
-%! assert (x, polyval(p,x), eps)
-%! x = reshape(x, [1, 1, 5, 2]);
-%! assert (x, polyval(p,x), eps)
+%! assert (x, polyval (p,x), eps);
+%! x = reshape (x, [2, 5]);
+%! assert (x, polyval (p,x), eps);
+%! x = reshape (x, [5, 2]);
+%! assert (x, polyval (p,x), eps);
+%! x = reshape (x, [1, 1, 5, 2]);
+%! assert (x, polyval (p,x), eps);
 
 %!test
 %! p = [1];
 %! x = 1:10;
-%! y = ones(size(x));
-%! assert (y, polyval(p,x), eps)
+%! y = ones (size (x));
+%! assert (y, polyval (p,x), eps);
 %! x = x(:);
-%! y = ones(size(x));
-%! assert (y, polyval(p,x), eps)
-%! x = reshape(x, [2, 5]);
-%! y = ones(size(x));
-%! assert (y, polyval(p,x), eps)
-%! x = reshape(x, [5, 2]);
-%! y = ones(size(x));
-%! assert (y, polyval(p,x), eps)
-%! x = reshape(x, [1, 1, 5, 2]);
+%! y = ones (size (x));
+%! assert (y, polyval (p,x), eps);
+%! x = reshape (x, [2, 5]);
+%! y = ones (size (x));
+%! assert (y, polyval (p,x), eps);
+%! x = reshape (x, [5, 2]);
+%! y = ones (size (x));
+%! assert (y, polyval (p,x), eps);
+%! x = reshape (x, [1, 1, 5, 2]);
 
 %!assert (zeros (1, 10), polyval ([], 1:10))
 %!assert ([], polyval (1, []))
 %!assert ([], polyval ([], []))
+
--- a/scripts/polynomial/polyvalm.m
+++ b/scripts/polynomial/polyvalm.m
@@ -61,8 +61,8 @@
 endfunction
 
 
-%!assert(! any (polyvalm ([], [1, 2; 3, 4]))(:));
-%!assert(polyvalm ([1, 2, 3, 4], [3, -4, 1; -2, 0, 2; -1, 4, -3]), [117, -124, 11; -70, 36, 38; -43, 92, -45])
+%!assert (! any (polyvalm ([], [1, 2; 3, 4]))(:));
+%!assert (polyvalm ([1, 2, 3, 4], [3, -4, 1; -2, 0, 2; -1, 4, -3]), [117, -124, 11; -70, 36, 38; -43, 92, -45])
 
-%!error polyvalm ([1, 1, 1], [1, 2; 3, 4; 5, 6]);
+%!error <must be a square matrix> polyvalm ([1, 1, 1], [1, 2; 3, 4; 5, 6])
 
--- a/scripts/polynomial/ppder.m
+++ b/scripts/polynomial/ppder.m
@@ -51,20 +51,24 @@
   ppd = mkpp (x, pd, d);
 endfunction
 
+
 %!shared x,y,pp,ppd
-%! x=0:8;y=[x.^2;x.^3+1];pp=spline(x,y);
-%! ppd=ppder(pp);
-%!assert(ppval(ppd,x),[2*x;3*x.^2],1e-14)
-%!assert(ppd.order,3)
-%! ppd=ppder(pp,2);
-%!assert(ppval(ppd,x),[2*ones(size(x));6*x],1e-14)
-%!assert(ppd.order,2)
-%! ppd=ppder(pp,3);
-%!assert(ppd.order,1)
-%!assert(ppd.pieces,8)
-%!assert(size(ppd.coefs),[16,1])
-%! ppd=ppder(pp,4);
-%!assert(ppd.order,1)
-%!assert(ppd.pieces,1)
-%!assert(size(ppd.coefs),[2,1])
-%!assert(ppval(ppd,x),zeros(size(y)),1e-14)
+%! x = 0:8;
+%! y = [x.^2; x.^3+1];
+%! pp = spline (x, y);
+%! ppd = ppder (pp);
+%!assert (ppval (ppd, x), [2*x; 3*x.^2], 1e-14)
+%!assert (ppd.order, 3)
+%! ppd = ppder (pp, 2);
+%!assert (ppval (ppd, x), [2*ones(size (x)); 6*x], 1e-14)
+%!assert (ppd.order, 2)
+%! ppd = ppder (pp, 3);
+%!assert (ppd.order, 1)
+%!assert (ppd.pieces, 8)
+%!assert (size (ppd.coefs), [16, 1])
+%! ppd = ppder (pp, 4);
+%!assert (ppd.order, 1)
+%!assert (ppd.pieces, 1)
+%!assert (size (ppd.coefs), [2, 1])
+%!assert (ppval (ppd,x), zeros (size (y)), 1e-14)
+
--- a/scripts/polynomial/ppint.m
+++ b/scripts/polynomial/ppint.m
@@ -47,12 +47,16 @@
   ppi = mkpp (x, pi, d);
 
   tmp = -cumsum (ppjumps (ppi), length (d) + 1);
-  ppi.coefs(prod(d)+1:end, k) = tmp(:);
+  ppi.coefs(prod (d)+1 : end, k) = tmp(:);
 
 endfunction
 
+
 %!shared x,y,pp,ppi
-%! x=0:8;y=[ones(size(x));x+1];pp=spline(x,y);
-%! ppi=ppint(pp);
-%!assert(ppval(ppi,x),[x;0.5*x.^2+x],1e-14)
-%!assert(ppi.order,5)
+%! x = 0:8;
+%! y = [ ones(size(x)); x+1 ];
+%! pp = spline (x, y);
+%! ppi = ppint (pp);
+%!assert (ppval (ppi, x), [x; 0.5*x.^2 + x], 1e-14)
+%!assert (ppi.order, 5)
+
--- a/scripts/polynomial/ppjumps.m
+++ b/scripts/polynomial/ppjumps.m
@@ -34,18 +34,18 @@
   endif
 
   ## Extract info.
-  [x, P, n, k, d] = unmkpp(pp);
+  [x, P, n, k, d] = unmkpp (pp);
   nd = length (d) + 1;
 
   ## Offsets.
-  dx = diff(x(1:n));
+  dx = diff (x(1:n));
   dx = repmat (dx, [prod(d), 1]);
   dx = reshape (dx, [d, n-1]);
   dx = shiftdim (dx, nd - 1);
 
   ## Use Horner scheme.
   if (k>1)
-    llim = shiftdim (reshape (P(1:(n-1) * prod(d), 1), [d, n-1]), nd - 1);
+    llim = shiftdim (reshape (P(1:(n-1) * prod (d), 1), [d, n-1]), nd - 1);
   endif
 
   for i = 2 : k;
@@ -64,21 +64,20 @@
 %! y = polyval (p, x);
 %! pp = spline (x, y);
 %! jj = ppjumps (pp);
-%! assert (jj, [0 0], eps)
+%! assert (jj, [0 0], eps);
 
 %!test
-%!
 %! breaks = [0 1 2];
 %! pp1 = poly (-[1 2 3]);
 %! pp2 = poly (-([1 2 3]+1));
 %! pp = mkpp (breaks, [pp1;pp2]);
-%! assert (ppjumps (pp), 0, eps)
+%! assert (ppjumps (pp), 0, eps);
 
 %!test
-%!
 %! breaks = [0 1 2];
 %! pp1 = poly (-[1 2 3]);
 %! pp2 = poly (([1 2 3]+1));
 %! pp = mkpp (breaks, [pp1;pp2]);
 %! j  = - 2 * polyval (pp1, 1);
-%! assert (ppjumps (pp), j, eps)
+%! assert (ppjumps (pp), j, eps);
+
--- a/scripts/polynomial/ppval.m
+++ b/scripts/polynomial/ppval.m
@@ -56,7 +56,7 @@
   P = reshape (P, [n, k, d]);
   Pidx = P(idx(:), :);#2d matrix size x: coefs*prod(d) y: prod(sxi)
 
-  if (isvector(xi))
+  if (isvector (xi))
     Pidx = reshape (Pidx, [xn, k, d]);
     Pidx = shiftdim (Pidx, 1);
     dimvec = [d, xn];
@@ -68,7 +68,7 @@
   ndv = length (dimvec);
 
   ## Offsets.
-  dx = (xi - x(idx));
+  dx = (xi - x(idx))(:)';
   dx = repmat (dx, [prod(d), 1]);
   dx = reshape (dx, dimvec);
   dx = shiftdim (dx, ndv - 1);
@@ -92,7 +92,7 @@
   if (isvector (xi) && (d == 1))
     yi = reshape (yi, sxi);
   elseif (isfield (pp, "orient") && strcmp (pp.orient, "first"))
-    yi = shiftdim(yi, nd);
+    yi = shiftdim (yi, nd);
   endif
 
   ##
@@ -102,15 +102,28 @@
 
 endfunction
 
-%!shared b,c,pp,pp2,xi,abserr
-%! b = 1:3; c = ones(2); pp=mkpp(b,c);abserr = 1e-14;pp2=mkpp(b,[c;c],2);
+
+%!shared b, c, pp, pp2, xi, abserr
+%! b = 1:3;
+%! c = ones (2);
+%! pp = mkpp (b, c);
+%! abserr = 1e-14;
+%! pp2 = mkpp (b, [c;c], 2);
 %! xi = [1.1 1.3 1.9 2.1];
-%!assert (ppval(pp,1.1), 1.1, abserr);
-%!assert (ppval(pp,2.1), 1.1, abserr);
-%!assert (ppval(pp,xi), [1.1 1.3 1.9 1.1], abserr);
-%!assert (ppval(pp,xi.'), [1.1 1.3 1.9 1.1].', abserr);
-%!assert (ppval(pp2,1.1), [1.1;1.1], abserr);
-%!assert (ppval(pp2,2.1), [1.1;1.1], abserr);
-%!assert (ppval(pp2,xi), [1.1 1.3 1.9 1.1;1.1 1.3 1.9 1.1], abserr);
-%!assert (ppval(pp2,xi'), [1.1 1.3 1.9 1.1;1.1 1.3 1.9 1.1], abserr);
-%!assert (size(ppval(pp2,[xi;xi])), [2 2 4]);
+%!assert (ppval (pp, 1.1), 1.1, abserr)
+%!assert (ppval (pp, 2.1), 1.1, abserr)
+%!assert (ppval (pp, xi), [1.1 1.3 1.9 1.1], abserr)
+%!assert (ppval (pp, xi.'), [1.1 1.3 1.9 1.1].', abserr)
+%!assert (ppval (pp2, 1.1), [1.1;1.1], abserr)
+%!assert (ppval (pp2, 2.1), [1.1;1.1], abserr)
+%!assert (ppval (pp2, xi), [1.1 1.3 1.9 1.1;1.1 1.3 1.9 1.1], abserr)
+%!assert (ppval (pp2, xi'), [1.1 1.3 1.9 1.1;1.1 1.3 1.9 1.1], abserr)
+%!assert (size (ppval (pp2, [xi;xi])), [2 2 4])
+%!test
+%! breaks = [0, 1, 2, 3];
+%! coefs = rand (6, 4);
+%! pp = mkpp (breaks, coefs, 2);
+%! ret = zeros (2, 4, 2);
+%! ret(:,:,1) = ppval (pp, breaks');
+%! ret(:,:,2) = ppval (pp, breaks');
+%! assert (ppval (pp, [breaks',breaks']), ret)
new file mode 100644
--- /dev/null
+++ b/scripts/polynomial/private/__splinefit__.m
@@ -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
+++ b/scripts/polynomial/residue.m
@@ -252,7 +252,7 @@
 
   A = zeros (border+1, border+1);
   B = prepad (reshape (b, [numel(b), 1]), border+1, 0);
-  for ip = 1:numel(p)
+  for ip = 1:numel (p)
     ri = zeros (size (p));
     ri(ip) = 1;
     A(:,ip) = prepad (rresidue (ri, p, [], toler), border+1, 0).';
@@ -285,19 +285,19 @@
     k = [];
   endif
 
-  if numel (e)
-    indx = 1:numel(p);
+  if (numel (e))
+    indx = 1:numel (p);
   else
     [e, indx] = mpoles (p, toler, 0);
     p = p (indx);
     r = r (indx);
   endif
 
-  indx = 1:numel(p);
+  indx = 1:numel (p);
 
   for n = indx
     pn = [1, -p(n)];
-    if n == 1
+    if (n == 1)
       pden = pn;
     else
       pden = conv (pden, pn);
@@ -351,23 +351,24 @@
 
 endfunction
 
+
 %!test
 %! b = [1, 1, 1];
 %! a = [1, -5, 8, -4];
 %! [r, p, k, e] = residue (b, a);
-%! assert (abs (r - [-2; 7; 3]) < 1e-12
-%!   && abs (p - [2; 2; 1]) < 1e-12
-%!   && isempty (k)
-%!   && e == [1; 2; 1]);
+%! assert (r, [-2; 7; 3], 1e-12);
+%! assert (p, [2; 2; 1], 1e-12);
+%! assert (isempty (k));
+%! assert (e, [1; 2; 1]);
 %! k = [1 0];
 %! b = conv (k, a) + prepad (b, numel (k) + numel (a) - 1, 0);
 %! a = a;
 %! [br, ar] = residue (r, p, k);
-%! assert ((abs (br - b) < 1e-12
-%!   && abs (ar - a) < 1e-12));
+%! assert (br, b, 1e-12);
+%! assert (ar, a, 1e-12);
 %! [br, ar] = residue (r, p, k, e);
-%! assert ((abs (br - b) < 1e-12
-%!   && abs (ar - a) < 1e-12));
+%! assert (br, b, 1e-12);
+%! assert (ar, a, 1e-12);
 
 %!test
 %! b = [1, 0, 1];
@@ -375,12 +376,13 @@
 %! [r, p, k, e] = residue (b, a);
 %! r1 = [-5i; 12; +5i; 12]/54;
 %! p1 = [+3i; +3i; -3i; -3i];
-%! assert (abs (r - r1) < 1e-12 && abs (p - p1) < 1e-12
-%!   && isempty (k)
-%!   && e == [1; 2; 1; 2]);
+%! assert (r, r1, 1e-12);
+%! assert (p, p1, 1e-12);
+%! assert (isempty (k));
+%! assert (e, [1; 2; 1; 2]);
 %! [br, ar] = residue (r, p, k);
-%! assert ((abs (br - b) < 1e-12
-%!   && abs (ar - a) < 1e-12));
+%! assert (br, b, 1e-12);
+%! assert (ar, a, 1e-12);
 
 %!test
 %! r = [7; 3; -2];
@@ -388,14 +390,14 @@
 %! k = [1 0];
 %! e = [2; 1; 1];
 %! [b, a] = residue (r, p, k, e);
-%! assert ((abs (b - [1, -5, 9, -3, 1]) < 1e-12
-%!   && abs (a - [1, -5, 8, -4]) < 1e-12));
+%! assert (b, [1, -5, 9, -3, 1], 1e-12);
+%! assert (a, [1, -5, 8, -4], 1e-12);
 %! [rr, pr, kr, er] = residue (b, a);
-%! [jnk, n] = mpoles(p);
-%! assert ((abs (rr - r(n)) < 1e-12
-%!   && abs (pr - p(n)) < 1e-12
-%!   && abs (kr - k) < 1e-12
-%!   && abs (er - e(n)) < 1e-12));
+%! [jnk, n] = mpoles (p);
+%! assert (rr, r(n), 1e-12);
+%! assert (pr, p(n), 1e-12);
+%! assert (kr, k, 1e-12);
+%! assert (er, e(n), 1e-12);
 
 %!test
 %! b = [1];
@@ -403,12 +405,13 @@
 %! [r, p, k, e] = residue (b, a);
 %! r1 = [0; 1];
 %! p1 = [-5; -5];
-%! assert (abs (r - r1) < 1e-12 && abs (p - p1) < 1e-12
-%!   && isempty (k)
-%!   && e == [1; 2]);
+%! assert (r, r1, 1e-12);
+%! assert (p, p1, 1e-12);
+%! assert (isempty (k));
+%! assert (e, [1; 2]);
 %! [br, ar] = residue (r, p, k);
-%! assert ((abs (br - b) < 1e-12
-%!   && abs (ar - a) < 1e-12));
+%! assert (br, b, 1e-12);
+%! assert (ar, a, 1e-12);
 
 ## The following test is due to Bernard Grung (bug #34266)
 %!xtest
@@ -428,3 +431,4 @@
 %! [br, ar] = residue (r, p, k, e);
 %! assert (br, b, 1e-8);
 %! assert (ar, a, 1e-8);
+
--- a/scripts/polynomial/roots.m
+++ b/scripts/polynomial/roots.m
@@ -81,7 +81,7 @@
 
   if (nargin != 1 || min (size (v)) > 1)
     print_usage ();
-  elseif (any (isnan(v) | isinf(v)))
+  elseif (any (isnan (v) | isinf (v)))
     error ("roots: inputs must not contain Inf or NaN");
   endif
 
@@ -118,24 +118,22 @@
 
 endfunction
 
+
 %!test
 %! p = [poly([3 3 3 3]), 0 0 0 0];
 %! r = sort (roots (p));
-%! assert (r, [0; 0; 0; 0; 3; 3; 3; 3], 0.001)
-
-%!assert(all (all (abs (roots ([1, -6, 11, -6]) - [3; 2; 1]) < sqrt (eps))));
-
-%!assert(isempty (roots ([])));
-
-%!error roots ([1, 2; 3, 4]);
+%! assert (r, [0; 0; 0; 0; 3; 3; 3; 3], 0.001);
 
-%!assert(isempty (roots (1)));
-
-%!error roots ([1, 2; 3, 4]);
-
-%!error roots ([1 Inf 1]);
-
-%!error roots ([1 NaN 1]);
+%!assert (isempty (roots ([])))
+%!assert (isempty (roots (1)))
+%!assert (roots ([1, -6, 11, -6]), [3; 2; 1], sqrt (eps))
 
 %!assert(roots ([1e-200, -1e200, 1]), 1e-200)
 %!assert(roots ([1e-200, -1e200 * 1i, 1]), -1e-200 * 1i)
+
+%!error roots ()
+%!error roots (1,2)
+%!error roots ([1, 2; 3, 4])
+%!error <inputs must not contain Inf or NaN> roots ([1 Inf 1])
+%!error <inputs must not contain Inf or NaN> roots ([1 NaN 1])
+
--- a/scripts/polynomial/spline.m
+++ b/scripts/polynomial/spline.m
@@ -100,15 +100,15 @@
   endfor
 
   complete = false;
-  if (size (a, 1) == n + 2)
+  if (rows (a) == n + 2)
     complete = true;
     dfs = a(1,:);
     dfe = a(end,:);
     a = a(2:end-1,:);
   endif
 
-  if (~issorted (x))
-    [x, idx] = sort(x);
+  if (! issorted (x))
+    [x, idx] = sort (x);
     a = a(idx,:);
   endif
 
@@ -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));
@@ -244,37 +225,38 @@
 
 endfunction
 
+
 %!demo
-%! x = 0:10; y = sin(x);
-%! xspline = 0:0.1:10; yspline = spline(x,y,xspline);
-%! title("spline fit to points from sin(x)");
-%! plot(xspline,sin(xspline),"r",xspline,yspline,"g-",x,y,"b+");
-%! legend("original","interpolation","interpolation points");
+%! x = 0:10; y = sin (x);
+%! xspline = 0:0.1:10;  yspline = spline (x,y,xspline);
+%! title ("spline fit to points from sin (x)");
+%! plot (xspline,sin(xspline),"r", xspline,yspline,"g-", x,y,"b+");
+%! legend ("original", "interpolation", "interpolation points");
 %! %--------------------------------------------------------
 %! % confirm that interpolated function matches the original
 
 %!shared x,y,abserr
-%! x = [0:10]; y = sin(x); abserr = 1e-14;
-%!assert (spline(x,y,x), y, abserr);
-%!assert (spline(x,y,x'), y', abserr);
-%!assert (spline(x',y',x'), y', abserr);
-%!assert (spline(x',y',x), y, abserr);
-%!assert (isempty(spline(x',y',[])));
-%!assert (isempty(spline(x,y,[])));
-%!assert (spline(x,[y;y],x), [spline(x,y,x);spline(x,y,x)],abserr)
-%!assert (spline(x,[y;y],x'), [spline(x,y,x);spline(x,y,x)],abserr)
-%!assert (spline(x',[y;y],x), [spline(x,y,x);spline(x,y,x)],abserr)
-%!assert (spline(x',[y;y],x'), [spline(x,y,x);spline(x,y,x)],abserr)
-%! y = cos(x) + i*sin(x);
-%!assert (spline(x,y,x), y, abserr)
-%!assert (real(spline(x,y,x)), real(y), abserr);
-%!assert (real(spline(x,y,x.')), real(y).', abserr);
-%!assert (real(spline(x.',y.',x.')), real(y).', abserr);
-%!assert (real(spline(x.',y,x)), real(y), abserr);
-%!assert (imag(spline(x,y,x)), imag(y), abserr);
-%!assert (imag(spline(x,y,x.')), imag(y).', abserr);
-%!assert (imag(spline(x.',y.',x.')), imag(y).', abserr);
-%!assert (imag(spline(x.',y,x)), imag(y), abserr);
+%! x = [0:10]; y = sin (x); abserr = 1e-14;
+%!assert (spline (x,y,x), y, abserr)
+%!assert (spline (x,y,x'), y', abserr)
+%!assert (spline (x',y',x'), y', abserr)
+%!assert (spline (x',y',x), y, abserr)
+%!assert (isempty (spline (x',y',[])))
+%!assert (isempty (spline (x,y,[])))
+%!assert (spline (x,[y;y],x), [spline(x,y,x);spline(x,y,x)], abserr)
+%!assert (spline (x,[y;y],x'), [spline(x,y,x);spline(x,y,x)], abserr)
+%!assert (spline (x',[y;y],x), [spline(x,y,x);spline(x,y,x)], abserr)
+%!assert (spline (x',[y;y],x'), [spline(x,y,x);spline(x,y,x)], abserr)
+%! y = cos (x) + i*sin (x);
+%!assert (spline (x,y,x), y, abserr)
+%!assert (real (spline (x,y,x)), real (y), abserr)
+%!assert (real (spline (x,y,x.')), real (y).', abserr)
+%!assert (real (spline (x.',y.',x.')), real (y).', abserr)
+%!assert (real (spline (x.',y,x)), real (y), abserr)
+%!assert (imag (spline (x,y,x)), imag (y), abserr)
+%!assert (imag (spline (x,y,x.')), imag (y).', abserr)
+%!assert (imag (spline (x.',y.',x.')), imag (y).', abserr)
+%!assert (imag (spline (x.',y,x)), imag (y), abserr)
 %!test
 %! xnan = 5;
 %! y(x==xnan) = NaN;
@@ -296,10 +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);
+
new file mode 100644
--- /dev/null
+++ b/scripts/polynomial/splinefit.m
@@ -0,0 +1,239 @@
+## 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})
+## Fit 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 N-D array.  If @var{y} is an N-D array, then @var{x}(j)
+## is matched to @var{y}(:,@dots{},:,j).
+##
+## The fitted spline is returned as a piecewise 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"
+## Constraining 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 piecewise 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/addpref.m
+++ b/scripts/prefs/addpref.m
@@ -45,7 +45,7 @@
         endif
       elseif (iscellstr (pref))
         if (size_equal (pref, val))
-          for i = 1:numel(pref)
+          for i = 1:numel (pref)
             if (isfield (group, pref{i}))
               error ("preference %s already exists in group %s",
                      pref{i}, group);
--- a/scripts/prefs/getpref.m
+++ b/scripts/prefs/getpref.m
@@ -69,7 +69,7 @@
       endif
     elseif (iscellstr (pref))
       if (nargin == 2 || size_equal (pref, default))
-        for i = 1:numel(pref)
+        for i = 1:numel (pref)
           if (isfield (grp, pref{i}))
             retval.(pref) = grp.(pref{i});
           elseif (nargin == 3)
--- a/scripts/prefs/private/prefsfile.m
+++ b/scripts/prefs/private/prefsfile.m
@@ -27,25 +27,6 @@
 
   retval = "~/.octave_prefs";
 
-  ## Transition users to new filename if necessary
-  ## FIXME: Delete before 3.6.0 release
-  oldname = tilde_expand ("~/.octave-prefs");
-  if (exist (oldname, "file"))
-    newname = tilde_expand (retval); 
-    if (exist (newname, "file"))
-      error (["Octave uses the file ~/.octave_prefs to store preferences.\n",...
-              "       The old file name was ~/.octave-prefs.\n",...
-              "       Both files exist."...
-              "  User must manually delete one of the files.\n"]);
-    endif
-    status = movefile (oldname, newname);
-    if (! status)
-      error (["Octave uses the file ~/.octave_prefs to store preferences.\n",
-             "        The old file name was ~/.octave-prefs.\n",
-             "        User must manually rename the old file to the new name.\n"]);
-    endif
-  endif
-
 endfunction
 
 %% Testing these functions will require some care to avoid wiping out
--- a/scripts/prefs/rmpref.m
+++ b/scripts/prefs/rmpref.m
@@ -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/prefs/setpref.m
+++ b/scripts/prefs/setpref.m
@@ -43,7 +43,7 @@
         prefs.(group).(pref) = val;
       elseif (iscellstr (pref))
         if (size_equal (pref, val))
-          for i = 1:numel(pref)
+          for i = 1:numel (pref)
             prefs.(group).(pref{i}) = val;
           endfor
         else
--- a/scripts/set/intersect.m
+++ b/scripts/set/intersect.m
@@ -75,7 +75,7 @@
       ib = jb(ic(ii+1) - len_a);        ## b(ib) == c
     endif
 
-    if (nargin == 2 && (size (b, 1) == 1 || size (a, 1) == 1))
+    if (nargin == 2 && (rows (b) == 1 || rows (a) == 1))
       c = c.';
     endif
   endif
@@ -87,29 +87,30 @@
 %!test
 %! a = [3 2 4 5 7 6 5 1 0 13 13];
 %! b = [3 5 12 1 1 7];
-%! [c,ia,ib] = intersect(a,b);
-%! assert(c,[1 3 5 7]);
-%! assert(ia,[8 1 7 5]);
-%! assert(ib,[5 1 2 6]);
-%! assert(a(ia),c);
-%! assert(b(ib),c);
+%! [c,ia,ib] = intersect (a, b);
+%! assert (c, [1 3 5 7]);
+%! assert (ia, [8 1 7 5]);
+%! assert (ib, [5 1 2 6]);
+%! assert (a(ia), c);
+%! assert (b(ib), c);
 %!test
 %! a = [1,1,2;1,4,5;2,1,7];
 %! b = [1,4,5;2,3,4;1,1,2;9,8,7];
-%! [c,ia,ib] = intersect(a,b,'rows');
-%! assert(c,[1,1,2;1,4,5]);
-%! assert(ia,[1;2]);
-%! assert(ib,[3;1]);
-%! assert(a(ia,:),c);
-%! assert(b(ib,:),c);
+%! [c,ia,ib] = intersect (a, b, "rows");
+%! assert (c, [1,1,2;1,4,5]);
+%! assert (ia, [1;2]);
+%! assert (ib, [3;1]);
+%! assert (a(ia,:), c);
+%! assert (b(ib,:), c);
 %!test
 %! a = [1 1 1 2 2 2];
 %! b = [1 2 3 4 5 6];
-%! c = intersect(a,b);
+%! c = intersect (a, b);
 %! assert(c, [1,2]);
 %!test
 %! a = [1 2 3 4; 5 6 7 8; 9 10 11 12];
-%! [b, ia, ib] = intersect(a, a, "rows");
-%! assert(b, a);
-%! assert(ia, [1:3]');
-%! assert(ib, [1:3]');
+%! [b, ia, ib] = intersect (a, a, "rows");
+%! assert (b, a);
+%! assert (ia, [1:3]');
+%! assert (ib, [1:3]');
+
--- a/scripts/set/ismember.m
+++ b/scripts/set/ismember.m
@@ -40,8 +40,8 @@
 ##
 ## @example
 ## @group
-## a = @{'abc'@};
-## s = @{'abc', 'def'@};
+## a = @{"abc"@};
+## s = @{"abc", "def"@};
 ## [tf, s_idx] = ismember (a, s)
 ##      @result{} tf = [1, 0]
 ##      @result{} s_idx = [1, 0]
@@ -56,7 +56,7 @@
 ## @group
 ## a = [1:3; 5:7; 4:6];
 ## s = [0:2; 1:3; 2:4; 3:5; 4:6];
-## [tf, s_idx] = ismember(a, s, "rows")
+## [tf, s_idx] = ismember (a, s, "rows")
 ##      @result{} tf = logical ([1; 0; 1])
 ##      @result{} s_idx = [2; 0; 5];
 ## @end group
@@ -133,29 +133,30 @@
 
 endfunction
 
-%!assert (ismember ({''}, {'abc', 'def'}), false);
-%!assert (ismember ('abc', {'abc', 'def'}), true);
-%!assert (isempty (ismember ([], [1, 2])), true);
-%!assert (isempty (ismember ({}, {'a', 'b'})), true);
-%!assert (ismember ('', {'abc', 'def'}), false);
-%!fail ('ismember ([], {1, 2})');
-%!fail ('ismember ({[]}, {1, 2})');
-%!fail ('ismember ({}, {1, 2})');
-%!fail ('ismember ({1}, {''1'', ''2''})');
-%!fail ('ismember (1, ''abc'')');
-%!fail ('ismember ({''1''}, {''1'', ''2''},''rows'')');
-%!fail ('ismember ([1 2 3], [5 4 3 1], ''rows'')');
-%!assert (ismember ({'foo', 'bar'}, {'foobar'}), logical ([0, 0]));
-%!assert (ismember ({'foo'}, {'foobar'}), false);
-%!assert (ismember ({'bar'}, {'foobar'}), false);
-%!assert (ismember ({'bar'}, {'foobar', 'bar'}), true);
-%!assert (ismember ({'foo', 'bar'}, {'foobar', 'bar'}), logical ([0, 1]));
-%!assert (ismember ({'xfb', 'f', 'b'}, {'fb', 'b'}), logical ([0, 0, 1]));
-%!assert (ismember ("1", "0123456789."), true);
+
+%!assert (ismember ({""}, {"abc", "def"}), false)
+%!assert (ismember ("abc", {"abc", "def"}), true)
+%!assert (isempty (ismember ([], [1, 2])), true)
+%!assert (isempty (ismember ({}, {'a', 'b'})), true)
+%!assert (ismember ("", {"abc", "def"}), false)
+%!fail ("ismember ([], {1, 2})")
+%!fail ("ismember ({[]}, {1, 2})")
+%!fail ("ismember ({}, {1, 2})")
+%!fail ("ismember ({1}, {'1', '2'})")
+%!fail ("ismember (1, 'abc')")
+%!fail ("ismember ({'1'}, {'1' '2'},'rows')")
+%!fail ("ismember ([1 2 3], [5 4 3 1], 'rows')")
+%!assert (ismember ({"foo", "bar"}, {"foobar"}), [false false])
+%!assert (ismember ({"foo"}, {"foobar"}), false)
+%!assert (ismember ({"bar"}, {"foobar"}), false)
+%!assert (ismember ({"bar"}, {"foobar", "bar"}), true)
+%!assert (ismember ({"foo", "bar"}, {"foobar", "bar"}), [false true])
+%!assert (ismember ({"xfb", "f", "b"}, {"fb", "b"}), [false false true])
+%!assert (ismember ("1", "0123456789."), true)
 
 %!test
 %! [result, a_idx] = ismember ([1, 2], []);
-%! assert (result, logical ([0, 0]))
+%! assert (result, [false false])
 %! assert (a_idx, [0, 0]);
 
 %!test
@@ -164,46 +165,52 @@
 %! assert (a_idx, []);
 
 %!test
-%! [result, a_idx] = ismember ({'a', 'b'}, '');
-%! assert (result, logical ([0, 0]))
+%! [result, a_idx] = ismember ({"a", "b"}, "");
+%! assert (result, [false false])
 %! assert (a_idx, [0, 0]);
 
 %!test
-%! [result, a_idx] = ismember ({'a', 'b'}, {});
-%! assert (result, logical ([0, 0]))
+%! [result, a_idx] = ismember ({"a", "b"}, {});
+%! assert (result, [false false])
 %! assert (a_idx, [0, 0]);
 
 %!test
-%! [result, a_idx] = ismember ('', {'a', 'b'});
+%! [result, a_idx] = ismember ("", {"a", "b"});
 %! assert (result, false)
 %! assert (a_idx, 0);
 
 %!test
-%! [result, a_idx] = ismember ({}, {'a', 'b'});
+%! [result, a_idx] = ismember ({}, {"a", "b"});
 %! assert (result, logical ([]))
 %! assert (a_idx, []);
 
 %!test
-%! [result, a_idx] = ismember([1 2 3 4 5], [3]);
-%! assert (all (result == logical ([0 0 1 0 0])) && all (a_idx == [0 0 1 0 0]));
+%! [result, a_idx] = ismember ([1 2 3 4 5], [3]);
+%! assert (result, logical ([0 0 1 0 0]))
+%! assert (a_idx , [0 0 1 0 0]);
 
 %!test
-%! [result, a_idx] = ismember([1 6], [1 2 3 4 5 1 6 1]);
-%! assert (all (result == logical ([1 1])) && a_idx(2) == 7);
+%! [result, a_idx] = ismember ([1 6], [1 2 3 4 5 1 6 1]);
+%! assert (result, [true true]);
+%! assert (a_idx(2), 7);
 
 %!test
 %! [result, a_idx] = ismember ([3,10,1], [0,1,2,3,4,5,6,7,8,9]);
-%! assert (all (result == logical ([1, 0, 1])) && all (a_idx == [4, 0, 2]));
+%! assert (result, [true false true]);
+%! assert (a_idx, [4, 0, 2]);
 
 %!test
 %! [result, a_idx] = ismember ("1.1", "0123456789.1");
-%! assert (all (result == logical ([1, 1, 1])) && all (a_idx == [12, 11, 12]));
+%! assert (result, [true true true]);
+%! assert (a_idx, [12, 11, 12]);
 
 %!test
-%! [result, a_idx] = ismember([1:3; 5:7; 4:6], [0:2; 1:3; 2:4; 3:5; 4:6], 'rows');
-%! assert (all (result == logical ([1; 0; 1])) && all (a_idx == [2; 0; 5]));
+%! [result, a_idx] = ismember ([1:3; 5:7; 4:6], [0:2; 1:3; 2:4; 3:5; 4:6], "rows");
+%! assert (result, [true; false; true]);
+%! assert (a_idx, [2; 0; 5]);
 
 %!test
-%! [result, a_idx] = ismember([1.1,1.2,1.3; 2.1,2.2,2.3; 10,11,12], [1.1,1.2,1.3; 10,11,12; 2.12,2.22,2.32], 'rows');
-%! assert (all (result == logical ([1; 0; 1])) && all (a_idx == [1; 0; 2]));
+%! [result, a_idx] = ismember ([1.1,1.2,1.3; 2.1,2.2,2.3; 10,11,12], [1.1,1.2,1.3; 10,11,12; 2.12,2.22,2.32], "rows");
+%! assert (result, [true; false; true]);
+%! assert (a_idx, [1; 0; 2]);
 
--- a/scripts/set/powerset.m
+++ b/scripts/set/powerset.m
@@ -81,3 +81,4 @@
 %! c = sort (cellstr ({ [], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]}));
 %! p = sort (cellstr (powerset ([1, 2, 3])));
 %! assert (p, c);
+
--- a/scripts/set/setdiff.m
+++ b/scripts/set/setdiff.m
@@ -82,7 +82,7 @@
         i(idx(dups)) = [];
       endif
       ## Reshape if necessary.
-      if (size (c, 1) != 1 && size (b, 1) == 1)
+      if (rows (c) != 1 && rows (b) == 1)
         c = c.';
       endif
     endif
@@ -90,16 +90,18 @@
 
 endfunction
 
-%!assert(setdiff(["bb";"zz";"bb";"zz"],["bb";"cc";"bb"],"rows"), "zz")
-%!assert(setdiff(["b";"z";"b";"z"],["b";"c";"b"],"rows"), "z")
-%!assert(setdiff(["b";"z";"b";"z"],["b";"c";"b"]), "z")
-%!assert(setdiff([1, 1; 2, 2; 3, 3; 4, 4], [1, 1; 2, 2; 4, 4], "rows"), [3 3])
-%!assert(setdiff([1; 2; 3; 4], [1; 2; 4], "rows"), 3)
-%!assert(setdiff([1, 2; 3, 4], [1, 2; 3, 6], "rows"), [3, 4])
-%!assert(setdiff({"one","two";"three","four"},{"one","two";"three","six"}), {"four"})
+
+%!assert (setdiff (["bb";"zz";"bb";"zz"], ["bb";"cc";"bb"], "rows"), "zz")
+%!assert (setdiff (["b";"z";"b";"z"], ["b";"c";"b"], "rows"), "z")
+%!assert (setdiff (["b";"z";"b";"z"], ["b";"c";"b"]), "z")
+%!assert (setdiff ([1, 1; 2, 2; 3, 3; 4, 4], [1, 1; 2, 2; 4, 4], "rows"), [3 3])
+%!assert (setdiff ([1; 2; 3; 4], [1; 2; 4], "rows"), 3)
+%!assert (setdiff ([1, 2; 3, 4], [1, 2; 3, 6], "rows"), [3, 4])
+%!assert (setdiff ({"one","two";"three","four"}, {"one","two";"three","six"}), {"four"})
 
 %!test
-%! a = [3, 1, 4, 1, 5]; b = [1, 2, 3, 4];
+%! a = [3, 1, 4, 1, 5];  b = [1, 2, 3, 4];
 %! [y, i] = setdiff (a, b.');
-%! assert(y, [5]);
-%! assert(y, a(i));
+%! assert (y, [5]);
+%! assert (y, a(i));
+
--- a/scripts/set/setxor.m
+++ b/scripts/set/setxor.m
@@ -19,7 +19,7 @@
 
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {} setxor (@var{a}, @var{b})
-## @deftypefnx {Function File} {} setxor (@var{a}, @var{b}, 'rows')
+## @deftypefnx {Function File} {} setxor (@var{a}, @var{b}, "rows")
 ## @deftypefnx {Function File} {[@var{c}, @var{ia}, @var{ib}] =} setxor (@var{a}, @var{b})
 ##
 ## Return the elements exclusive to @var{a} or @var{b}, sorted in ascending
@@ -79,7 +79,7 @@
         c([idx, idx+1]) = [];
         i([idx, idx+1]) = [];
       endif
-      if (size (a, 1) == 1 || size (b, 1) == 1)
+      if (rows (a) == 1 || rows (b) == 1)
         c = c.';
       endif
     endif
@@ -91,11 +91,12 @@
 
 endfunction
 
-%!assert(setxor([1,2,3],[2,3,4]),[1,4])
-%!assert(setxor({'a'}, {'a', 'b'}), {'b'});
+
+%!assert (setxor ([1,2,3],[2,3,4]),[1,4])
+%!assert (setxor ({'a'}, {'a', 'b'}), {'b'})
 %!test
-%! a = [3, 1, 4, 1, 5]; b = [1, 2, 3, 4];
+%! a = [3, 1, 4, 1, 5];  b = [1, 2, 3, 4];
 %! [y, ia, ib] = setxor (a, b.');
-%! assert(y, [2, 5]);
-%! assert(y, sort([a(ia), b(ib)]));
+%! assert (y, [2, 5]);
+%! assert (y, sort ([a(ia), b(ib)]));
 
--- a/scripts/set/union.m
+++ b/scripts/set/union.m
@@ -65,7 +65,7 @@
   if (nargin == 2)
     y = [a(:); b(:)];
     na = numel (a); nb = numel (b);
-    if (size (a, 1) == 1 || size (b, 1) == 1)
+    if (rows (a) == 1 || rows (b) == 1)
       y = y.';
     endif
   else
@@ -83,18 +83,17 @@
 
 endfunction
 
-%!assert(all (all (union ([1, 2, 4], [2, 3, 5]) == [1, 2, 3, 4, 5])));
 
-%!assert(all (all (union ([1; 2; 4], [2, 3, 5]) == [1, 2, 3, 4, 5])));
-
-%!assert(all (all (union ([1, 2, 3], [5; 7; 9]) == [1, 2, 3, 5, 7, 9])));
-
-%!error union (1);
-
-%!error union (1, 2, 3);
+%!assert (union ([1, 2, 4], [2, 3, 5]), [1, 2, 3, 4, 5]);
+%!assert (union ([1; 2; 4], [2, 3, 5]), [1, 2, 3, 4, 5]);
+%!assert (union ([1, 2, 3], [5; 7; 9]), [1, 2, 3, 5, 7, 9]);
 
 %!test
-%! a = [3, 1, 4, 1, 5]; b = [1, 2, 3, 4];
+%! a = [3, 1, 4, 1, 5];  b = [1, 2, 3, 4];
 %! [y, ia, ib] = union (a, b.');
-%! assert(y, [1, 2, 3, 4, 5]);
-%! assert(y, sort([a(ia), b(ib)]));
+%! assert (y, [1, 2, 3, 4, 5]);
+%! assert (y, sort ([a(ia), b(ib)]));
+
+%!error union (1)
+%!error union (1, 2, 3)
+
--- a/scripts/set/unique.m
+++ b/scripts/set/unique.m
@@ -163,52 +163,54 @@
 
 endfunction
 
-%!assert(unique([1 1 2; 1 2 1; 1 1 2]),[1;2])
-%!assert(unique([1 1 2; 1 0 1; 1 1 2],'rows'),[1 0 1; 1 1 2])
-%!assert(unique([]),[])
-%!assert(unique([1]),[1])
-%!assert(unique([1 2]),[1 2])
-%!assert(unique([1;2]),[1;2])
-%!assert(unique([1,NaN,Inf,NaN,Inf]),[1,Inf,NaN,NaN])
-%!assert(unique({'Foo','Bar','Foo'}),{'Bar','Foo'})
-%!assert(unique({'Foo','Bar','FooBar'}'),{'Bar','Foo','FooBar'}')
-%!assert(unique(zeros(1,0)), zeros(0,1))
-%!assert(unique(zeros(1,0), 'rows'), zeros(1,0))
-%!assert(unique(cell(1,0)), cell(0,1))
-%!assert(unique({}), {})
-%!assert(unique([1,2,2,3,2,4], 'rows'), [1,2,2,3,2,4])
-%!assert(unique([1,2,2,3,2,4]), [1,2,3,4])
-%!assert(unique([1,2,2,3,2,4]', 'rows'), [1,2,3,4]')
-%!assert(unique(sparse([2,0;2,0])), [0,2]')
-%!assert(unique(sparse([1,2;2,3])), [1,2,3]')
-%!assert(unique([1,2,2,3,2,4]', 'rows'), [1,2,3,4]')
-%!assert(unique(single([1,2,2,3,2,4]), 'rows'), single([1,2,2,3,2,4]))
-%!assert(unique(single([1,2,2,3,2,4])), single([1,2,3,4]))
-%!assert(unique(single([1,2,2,3,2,4]'), 'rows'), single([1,2,3,4]'))
-%!assert(unique(uint8([1,2,2,3,2,4]), 'rows'), uint8([1,2,2,3,2,4]))
-%!assert(unique(uint8([1,2,2,3,2,4])), uint8([1,2,3,4]))
-%!assert(unique(uint8([1,2,2,3,2,4]'), 'rows'), uint8([1,2,3,4]'))
+
+%!assert (unique ([1 1 2; 1 2 1; 1 1 2]),[1;2])
+%!assert (unique ([1 1 2; 1 0 1; 1 1 2],"rows"),[1 0 1; 1 1 2])
+%!assert (unique ([]),[])
+%!assert (unique ([1]),[1])
+%!assert (unique ([1 2]),[1 2])
+%!assert (unique ([1;2]),[1;2])
+%!assert (unique ([1,NaN,Inf,NaN,Inf]),[1,Inf,NaN,NaN])
+%!assert (unique ({"Foo","Bar","Foo"}),{"Bar","Foo"})
+%!assert (unique ({"Foo","Bar","FooBar"}'),{"Bar","Foo","FooBar"}')
+%!assert (unique (zeros (1,0)), zeros (0,1))
+%!assert (unique (zeros (1,0), "rows"), zeros (1,0))
+%!assert (unique (cell (1,0)), cell (0,1))
+%!assert (unique ({}), {})
+%!assert (unique ([1,2,2,3,2,4], "rows"), [1,2,2,3,2,4])
+%!assert (unique ([1,2,2,3,2,4]), [1,2,3,4])
+%!assert (unique ([1,2,2,3,2,4]', "rows"), [1,2,3,4]')
+%!assert (unique (sparse ([2,0;2,0])), [0,2]')
+%!assert (unique (sparse ([1,2;2,3])), [1,2,3]')
+%!assert (unique ([1,2,2,3,2,4]', "rows"), [1,2,3,4]')
+%!assert (unique (single ([1,2,2,3,2,4]), "rows"), single ([1,2,2,3,2,4]))
+%!assert (unique (single ([1,2,2,3,2,4])), single ([1,2,3,4]))
+%!assert (unique (single ([1,2,2,3,2,4]'), "rows"), single ([1,2,3,4]'))
+%!assert (unique (uint8 ([1,2,2,3,2,4]), "rows"), uint8 ([1,2,2,3,2,4]))
+%!assert (unique (uint8 ([1,2,2,3,2,4])), uint8 ([1,2,3,4]))
+%!assert (unique (uint8 ([1,2,2,3,2,4]'), "rows"), uint8 ([1,2,3,4]'))
 %!test
-%! [a,i,j] = unique([1,1,2,3,3,3,4]);
-%! assert(a,[1,2,3,4])
-%! assert(i,[2,3,6,7])
-%! assert(j,[1,1,2,3,3,3,4])
+%! [a,i,j] = unique ([1,1,2,3,3,3,4]);
+%! assert (a, [1,2,3,4]);
+%! assert (i, [2,3,6,7]);
+%! assert (j, [1,1,2,3,3,3,4]);
 %!
 %!test
-%! [a,i,j] = unique([1,1,2,3,3,3,4]','first');
-%! assert(a,[1,2,3,4]')
-%! assert(i,[1,3,4,7]')
-%! assert(j,[1,1,2,3,3,3,4]')
+%! [a,i,j] = unique ([1,1,2,3,3,3,4]', "first");
+%! assert (a, [1,2,3,4]');
+%! assert (i, [1,3,4,7]');
+%! assert (j, [1,1,2,3,3,3,4]');
 %!
 %!test
-%! [a,i,j] = unique({'z'; 'z'; 'z'});
-%! assert(a,{'z'})
-%! assert(i,[3]')
-%! assert(j,[1,1,1]')
+%! [a,i,j] = unique ({"z"; "z"; "z"});
+%! assert (a, {"z"});
+%! assert (i, [3]');
+%! assert (j, [1;1;1]);
 %!
 %!test
-%! A=[1,2,3;1,2,3];
-%! [a,i,j] = unique(A,'rows');
-%! assert(a,[1,2,3])
-%! assert(A(i,:),a)
-%! assert(a(j,:),A)
+%! A = [1,2,3;1,2,3];
+%! [a,i,j] = unique (A, "rows");
+%! assert (a, [1,2,3]);
+%! assert (A(i,:), a);
+%! assert (a(j,:), A);
+
--- a/scripts/signal/arch_fit.m
+++ b/scripts/signal/arch_fit.m
@@ -109,7 +109,7 @@
     esq = e .^ 2;
     Z   = autoreg_matrix (esq, p);
     h   = Z * a;
-    f   = esq ./ h - ones(T,1);
+    f   = esq ./ h - ones (T,1);
     Z_tilde = Z ./ (h * ones (1, p+1));
     delta_a = inv (Z_tilde' * Z_tilde) * Z_tilde' * f;
     a   = a + gamma * delta_a;
--- a/scripts/signal/arch_rnd.m
+++ b/scripts/signal/arch_rnd.m
@@ -71,7 +71,7 @@
     b  = [b, 0];
     lb = lb + 1;
   endif
-  m  = max([la, lb]);
+  m  = max ([la, lb]);
 
   e  = zeros (t, 1);
   h  = zeros (t, 1);
--- a/scripts/signal/arch_test.m
+++ b/scripts/signal/arch_test.m
@@ -80,9 +80,9 @@
   if ((rx == 1) && (cx == 1))
     x = autoreg_matrix (y, x);
   elseif (! (rx == T))
-    error ("arch_test: either rows(X) == length(Y), or X is a scalar");
+    error ("arch_test: either rows (X) == length (Y), or X is a scalar");
   endif
-  if (! (isscalar(p) && (rem(p, 1) == 0) && (p > 0)))
+  if (! (isscalar (p) && (rem (p, 1) == 0) && (p > 0)))
     error ("arch_test: P must be a positive integer");
   endif
 
--- a/scripts/signal/autoreg_matrix.m
+++ b/scripts/signal/autoreg_matrix.m
@@ -50,13 +50,14 @@
 
 
 %!test
-%! K=4;
-%! A = zeros(1,K+1);
+%! K = 4;
+%! A = zeros (1,K+1);
 %! A(1) = 1;
-%! B = eye(K+1);
+%! B = eye (K+1);
 %! B(:,1) = 1;
-%! assert (autoreg_matrix(A,K),B);
+%! assert (autoreg_matrix (A,K), B);
 
-%!error autoreg_matrix()
-%!error autoreg_matrix(1)
-%!error autoreg_matrix(ones(4,1),5)
+%!error autoreg_matrix ()
+%!error autoreg_matrix (1)
+%!error autoreg_matrix (ones (4,1), 5)
+
--- a/scripts/signal/bartlett.m
+++ b/scripts/signal/bartlett.m
@@ -48,16 +48,18 @@
 
 endfunction
 
-%!assert (bartlett (1), 1);
-%!assert (bartlett (2), zeros (2,1));
-%!assert (bartlett (16), fliplr (bartlett (16)));
-%!assert (bartlett (15), fliplr (bartlett (15)));
+
+%!assert (bartlett (1), 1)
+%!assert (bartlett (2), zeros (2,1))
+%!assert (bartlett (16), fliplr (bartlett (16)))
+%!assert (bartlett (15), fliplr (bartlett (15)))
 %!test
 %! N = 9;
 %! A = bartlett (N);
-%! assert (A (ceil (N/2)), 1);
+%! assert (A(ceil (N/2)), 1);
 
-%!error bartlett ();
-%!error bartlett (0.5);
-%!error bartlett (-1);
-%!error bartlett (ones(1,4));
+%!error bartlett ()
+%!error bartlett (0.5)
+%!error bartlett (-1)
+%!error bartlett (ones (1,4))
+
--- a/scripts/signal/blackman.m
+++ b/scripts/signal/blackman.m
@@ -47,17 +47,19 @@
 
 endfunction
 
-%!assert (blackman (1), 1);
-%!assert (blackman (2), zeros(2,1), 1e-6);
-%!assert (blackman (16), fliplr (blackman (16)));
-%!assert (blackman (15), fliplr (blackman (15)));
+
+%!assert (blackman (1), 1)
+%!assert (blackman (2), zeros (2,1), 1e-6)
+%!assert (blackman (16), fliplr (blackman (16)))
+%!assert (blackman (15), fliplr (blackman (15)))
 %!test
 %! N = 9;
 %! A = blackman (N);
 %! assert (A (ceil (N/2)), 1, 1e-6);
 %! assert ([A(1), A(length (A))], zeros (1, 2), 1e-6);
 
-%!error blackman ();
-%!error blackman (0.5);
-%!error blackman (-1);
-%!error blackman (ones(1,4));
+%!error blackman ()
+%!error blackman (0.5)
+%!error blackman (-1)
+%!error blackman (ones (1,4))
+
--- a/scripts/signal/detrend.m
+++ b/scripts/signal/detrend.m
@@ -67,23 +67,24 @@
 
 endfunction
 
-%!test
-%! N=32;
-%! x = (0:1:N-1)/N + 2;
-%! y = detrend(x);
-%! assert(all (all (abs (y) < 20*eps)));
 
 %!test
-%! N=32;
+%! N = 32;
+%! x = (0:1:N-1)/N + 2;
+%! y = detrend (x);
+%! assert (abs (y(:)) < 20*eps);
+
+%!test
+%! N = 32;
 %! t = (0:1:N-1)/N;
 %! x = t .* t + 2;
-%! y = detrend(x,2);
-%! assert(all (all (abs (y) < 30*eps)));
+%! y = detrend (x,2);
+%! assert (abs (y(:)) < 30*eps);
 
 %!test
-%! N=32;
+%! N = 32;
 %! t = (0:1:N-1)/N;
 %! x = [t;4*t-3]';
-%! y = detrend(x);
-%! assert(all (all (abs (y) < 20*eps)));
+%! y = detrend (x);
+%! assert (abs (y(:)) < 20*eps);
 
--- a/scripts/signal/diffpara.m
+++ b/scripts/signal/diffpara.m
@@ -49,7 +49,7 @@
       k = 1;
       x = reshape (x, n, 1);
     else
-      [n, k] = size(x);
+      [n, k] = size (x);
     endif
     if (nargin == 1)
       a = 0.5 * sqrt (n);
--- a/scripts/signal/fftconv.m
+++ b/scripts/signal/fftconv.m
@@ -67,8 +67,8 @@
 
 %% FIXME: Borrow tests from conv.m.  May need a tolerance on the assert comparison
 %!test
-%!  x = ones(3,1);
-%!  y = ones(1,3);
+%!  x = ones (3,1);
+%!  y = ones (1,3);
 %!  b = 2;
 %!  c = 3;
 %!  assert (fftconv (x, x), [1; 2; 3; 2; 1], 5*eps);
@@ -84,23 +84,24 @@
 %!test
 %!  a = 1:10;
 %!  b = 1:3;
-%!  assert (size(conv(a,b)), [1, numel(a)+numel(b)-1])
-%!  assert (size(conv(b,a)), [1, numel(a)+numel(b)-1])
+%!  assert (size (conv (a,b)), [1, numel(a)+numel(b)-1])
+%!  assert (size (conv (b,a)), [1, numel(a)+numel(b)-1])
 
 %!  a = (1:10).';
 %!  b = 1:3;
-%!  assert (size(conv(a,b)), [numel(a)+numel(b)-1, 1])
-%!  assert (size(conv(b,a)), [numel(a)+numel(b)-1, 1])
+%!  assert (size (conv (a,b)), [numel(a)+numel(b)-1, 1])
+%!  assert (size (conv (b,a)), [numel(a)+numel(b)-1, 1])
 
 %!test
 %!  a = 1:10;
 %!  b = (1:3).';
-%!  assert (size(conv(a,b)), [1, numel(a)+numel(b)-1])
-%!  assert (size(conv(b,a)), [1, numel(a)+numel(b)-1])
+%!  assert (size (conv (a,b)), [1, numel(a)+numel(b)-1])
+%!  assert (size (conv (b,a)), [1, numel(a)+numel(b)-1])
 
 %% Test input validation
-%!error fftconv (1);
-%!error fftconv (1,2,3,4);
-%!error fftconv ([1, 2; 3, 4], 3);
-%!error fftconv (2, []);
-%!error fftconv ([1,1], [2,2] , [3, 4]);
+%!error fftconv (1)
+%!error fftconv (1,2,3,4)
+%!error fftconv ([1, 2; 3, 4], 3)
+%!error fftconv (2, [])
+%!error fftconv ([1,1], [2,2] , [3, 4])
+
--- a/scripts/signal/fftfilt.m
+++ b/scripts/signal/fftfilt.m
@@ -114,33 +114,33 @@
 
 %!shared b, x, r
 %!test
-%!  b = [1 1];
-%!  x = [1, zeros(1,9)];
-%!  assert(fftfilt(b,  x  ), [1 1 0 0 0 0 0 0 0 0]  , eps);
-%!  assert(fftfilt(b,  x.'), [1 1 0 0 0 0 0 0 0 0].', eps);
-%!  assert(fftfilt(b.',x  ), [1 1 0 0 0 0 0 0 0 0]  , eps);
-%!  assert(fftfilt(b.',x.'), [1 1 0 0 0 0 0 0 0 0].', eps);
+%! b = [1 1];
+%! x = [1, zeros(1,9)];
+%! assert (fftfilt (b,  x  ), [1 1 0 0 0 0 0 0 0 0]  , eps);
+%! assert (fftfilt (b,  x.'), [1 1 0 0 0 0 0 0 0 0].', eps);
+%! assert (fftfilt (b.',x  ), [1 1 0 0 0 0 0 0 0 0]  , eps);
+%! assert (fftfilt (b.',x.'), [1 1 0 0 0 0 0 0 0 0].', eps);
 
 %!test
-%!  r = sqrt(1/2) * (1+i);
-%!  b = b*r;
-%!  assert(fftfilt(b, x  ), r*[1 1 0 0 0 0 0 0 0 0]  , eps);
-%!  assert(fftfilt(b, r*x), r*r*[1 1 0 0 0 0 0 0 0 0], eps);
-%!  assert(fftfilt(b, x.'), r*[1 1 0 0 0 0 0 0 0 0].', eps);
+%! r = sqrt (1/2) * (1+i);
+%! b = b*r;
+%! assert (fftfilt (b, x  ), r*[1 1 0 0 0 0 0 0 0 0]  , eps);
+%! assert (fftfilt (b, r*x), r*r*[1 1 0 0 0 0 0 0 0 0], eps);
+%! assert (fftfilt (b, x.'), r*[1 1 0 0 0 0 0 0 0 0].', eps);
 
 %!test
-%!  b = [1 1];
-%!  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 = fftfilt (b, x);
-%!  assert (y,y0);
+%! b = [1 1];
+%! 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 = fftfilt (b, x);
+%! assert (y,y0);
 
 %!test
-%!  b  = rand (10, 1);
-%!  x  = rand (10, 1);
-%!  y0 = filter (b, 1, x);
-%!  y  = filter (b, 1, x);
-%!  assert (y, y0);
+%! b  = rand (10, 1);
+%! x  = rand (10, 1);
+%! y0 = filter (b, 1, x);
+%! y  = filter (b, 1, x);
+%! assert (y, y0);
 
 %% Test input validation
 %!error fftfilt (1)
--- a/scripts/signal/fftshift.m
+++ b/scripts/signal/fftshift.m
@@ -87,45 +87,45 @@
 %!test
 %!  x = [0:7];
 %!  y = fftshift (x);
-%!  assert(y, [4 5 6 7 0 1 2 3]);
-%!  assert(fftshift (y), x);
+%!  assert (y, [4 5 6 7 0 1 2 3]);
+%!  assert (fftshift (y), x);
 
 %!test
 %!  x = [0:6];
 %!  y = fftshift (x);
-%!  assert(y, [4 5 6 0 1 2 3]);
-%!  assert(fftshift (y), [1 2 3 4 5 6 0]);
+%!  assert (y, [4 5 6 0 1 2 3]);
+%!  assert (fftshift (y), [1 2 3 4 5 6 0]);
 
 %!test
 %!  x = [0:7]';
 %!  y = fftshift (x);
-%!  assert(y, [4;5;6;7;0;1;2;3]);
-%!  assert(fftshift (y), x);
+%!  assert (y, [4;5;6;7;0;1;2;3]);
+%!  assert (fftshift (y), x);
 
 %!test
 %!  x = [0:6]';
 %!  y = fftshift (x);
-%!  assert(y, [4;5;6;0;1;2;3]);
-%!  assert(fftshift (y), [1;2;3;4;5;6;0]);
+%!  assert (y, [4;5;6;0;1;2;3]);
+%!  assert (fftshift (y), [1;2;3;4;5;6;0]);
 
 %!test
 %!  x = [0:3];
 %!  x = [x;2*x;3*x+1;4*x+1];
 %!  y = fftshift (x);
-%!  assert(y, [[7 10 1 4];[9 13 1 5];[2 3 0 1];[4 6 0 2]]);
-%!  assert(fftshift (y), x);
+%!  assert (y, [[7 10 1 4];[9 13 1 5];[2 3 0 1];[4 6 0 2]]);
+%!  assert (fftshift (y), x);
 
 %!test
 %!  x = [0:3];
 %!  x = [x;2*x;3*x+1;4*x+1];
 %!  y = fftshift (x,1);
-%!  assert(y, [[1 4 7 10];[1 5 9 13];[0 1 2 3];[0 2 4 6]]);
-%!  assert(fftshift (y,1), x);
+%!  assert (y, [[1 4 7 10];[1 5 9 13];[0 1 2 3];[0 2 4 6]]);
+%!  assert (fftshift (y,1), x);
 
 %!test
 %!  x = [0:3];
 %!  x = [x;2*x;3*x+1;4*x+1];
 %!  y = fftshift (x,2);
-%!  assert(y, [[2 3 0 1];[4 6 0 2];[7 10 1 4];[9 13 1 5]]);
-%!  assert(fftshift (y,2), x);
+%!  assert (y, [[2 3 0 1];[4 6 0 2];[7 10 1 4];[9 13 1 5]]);
+%!  assert (fftshift (y,2), x);
 
--- a/scripts/signal/filter2.m
+++ b/scripts/signal/filter2.m
@@ -24,13 +24,13 @@
 ## Possible values are:
 ##
 ## @table @asis
-## @item 'full'
+## @item "full"
 ## pad @var{x} with zeros on all sides before filtering.
 ##
-## @item 'same'
+## @item "same"
 ## unpadded @var{x} (default)
 ##
-## @item 'valid'
+## @item "valid"
 ## trim @var{x} after filtering so edge effects are no included.
 ## @end table
 ##
@@ -52,7 +52,7 @@
     shape = "same";
   endif
 
-  [nr, nc] = size(b);
+  [nr, nc] = size (b);
   y = conv2 (x, b(nr:-1:1, nc:-1:1), shape);
 endfunction
 
--- a/scripts/signal/freqz.m
+++ b/scripts/signal/freqz.m
@@ -169,29 +169,30 @@
 
 endfunction
 
+
 %!test # correct values and fft-polyval consistency
 %! # butterworth filter, order 2, cutoff pi/2 radians
 %! b = [0.292893218813452  0.585786437626905  0.292893218813452];
 %! a = [1  0  0.171572875253810];
-%! [h,w] = freqz(b,a,32);
-%! assert(h(1),1,10*eps);
-%! assert(abs(h(17)).^2,0.5,10*eps);
-%! assert(h,freqz(b,a,w),10*eps); # fft should be consistent with polyval
+%! [h,w] = freqz (b,a,32);
+%! assert (h(1),1,10*eps);
+%! assert (abs (h(17)).^2,0.5,10*eps);
+%! assert (h,freqz (b,a,w),10*eps); # fft should be consistent with polyval
 
 %!test # whole-half consistency
 %! b = [1 1 1]/3; # 3-sample average
-%! [h,w] = freqz(b,1,32,'whole');
-%! assert(h(2:16),conj(h(32:-1:18)),20*eps);
-%! [h2,w2] = freqz(b,1,16,'half');
-%! assert(h(1:16),h2,20*eps);
-%! assert(w(1:16),w2,20*eps);
+%! [h,w] = freqz (b,1,32,"whole");
+%! assert (h(2:16),conj (h(32:-1:18)),20*eps);
+%! [h2,w2] = freqz (b,1,16,"half");
+%! assert (h(1:16),h2,20*eps);
+%! assert (w(1:16),w2,20*eps);
 
 %!test # Sampling frequency properly interpreted
 %! b = [1 1 1]/3; a = [1 0.2];
-%! [h,f] = freqz(b,a,16,320);
-%! assert(f,[0:15]'*10,10*eps);
-%! [h2,f2] = freqz(b,a,[0:15]*10,320);
-%! assert(f2,[0:15]*10,10*eps);
-%! assert(h,h2.',20*eps);
-%! [h3,f3] = freqz(b,a,32,'whole',320);
-%! assert(f3,[0:31]'*10,10*eps);
+%! [h,f] = freqz (b,a,16,320);
+%! assert (f,[0:15]'*10,10*eps);
+%! [h2,f2] = freqz (b,a,[0:15]*10,320);
+%! assert (f2,[0:15]*10,10*eps);
+%! assert (h,h2.',20*eps);
+%! [h3,f3] = freqz (b,a,32,"whole",320);
+%! assert (f3,[0:31]'*10,10*eps);
--- a/scripts/signal/hamming.m
+++ b/scripts/signal/hamming.m
@@ -46,16 +46,18 @@
 
 endfunction
 
-%!assert (hamming (1), 1);
-%!assert (hamming (2), (0.54 - 0.46)*ones(2,1));
-%!assert (hamming (16), fliplr (hamming (16)));
-%!assert (hamming (15), fliplr (hamming (15)));
+
+%!assert (hamming (1), 1)
+%!assert (hamming (2), (0.54 - 0.46)*ones (2,1))
+%!assert (hamming (16), fliplr (hamming (16)))
+%!assert (hamming (15), fliplr (hamming (15)))
 %!test
 %! N = 15;
 %! A = hamming (N);
 %! assert (A (ceil (N/2)), 1);
 
-%!error hamming ();
-%!error hamming (0.5);
-%!error hamming (-1);
-%!error hamming (ones(1,4));
+%!error hamming ()
+%!error hamming (0.5)
+%!error hamming (-1)
+%!error hamming (ones (1,4))
+
--- a/scripts/signal/hanning.m
+++ b/scripts/signal/hanning.m
@@ -46,16 +46,18 @@
 
 endfunction
 
+
 %!assert (hanning (1), 1);
-%!assert (hanning (2), zeros(2,1));
+%!assert (hanning (2), zeros (2,1));
 %!assert (hanning (16), fliplr (hanning (16)));
 %!assert (hanning (15), fliplr (hanning (15)));
 %!test
 %! N = 15;
 %! A = hanning (N);
-%! assert (A (ceil (N/2)), 1);
+%! assert (A(ceil (N/2)), 1);
 
-%!error hanning ();
-%!error hanning (0.5);
-%!error hanning (-1);
-%!error hanning (ones(1,4));
+%!error hanning ()
+%!error hanning (0.5)
+%!error hanning (-1)
+%!error hanning (ones (1,4))
+
--- a/scripts/signal/hurst.m
+++ b/scripts/signal/hurst.m
@@ -42,7 +42,7 @@
 
   s = std (x);
   w = cumsum (x - mean (x));
-  RS = (max(w) - min(w)) ./ s;
+  RS = (max (w) - min (w)) ./ s;
   H = log (RS) / log (xr);
 
 endfunction
--- a/scripts/signal/ifftshift.m
+++ b/scripts/signal/ifftshift.m
@@ -69,48 +69,49 @@
 
 endfunction
 
+
 %!test
-%!  x = [0:7];
-%!  y = ifftshift (x);
-%!  assert(y, [4 5 6 7 0 1 2 3]);
-%!  assert(ifftshift (y), x);
+%! x = [0:7];
+%! y = ifftshift (x);
+%! assert (y, [4 5 6 7 0 1 2 3]);
+%! assert (ifftshift (y), x);
 
 %!test
-%!  x = [0:6];
-%!  y = ifftshift (x);
-%!  assert(y, [3 4 5 6 0 1 2]);
-%!  assert(ifftshift (y), [6 0 1 2 3 4 5]);
+%! x = [0:6];
+%! y = ifftshift (x);
+%! assert (y, [3 4 5 6 0 1 2]);
+%! assert (ifftshift (y), [6 0 1 2 3 4 5]);
 
 %!test
-%!  x = [0:7]';
-%!  y = ifftshift (x);
-%!  assert(y, [4;5;6;7;0;1;2;3]);
-%!  assert(ifftshift (y), x);
+%! x = [0:7]';
+%! y = ifftshift (x);
+%! assert (y, [4;5;6;7;0;1;2;3]);
+%! assert (ifftshift (y), x);
 
 %!test
-%!  x = [0:6]';
-%!  y = ifftshift (x);
-%!  assert(y, [3;4;5;6;0;1;2]);
-%!  assert(ifftshift (y), [6;0;1;2;3;4;5]);
+%! x = [0:6]';
+%! y = ifftshift (x);
+%! assert (y, [3;4;5;6;0;1;2]);
+%! assert (ifftshift (y), [6;0;1;2;3;4;5]);
 
 %!test
-%!  x = [0:3];
-%!  x = [x;2*x;3*x+1;4*x+1];
-%!  y = ifftshift (x);
-%!  assert(y, [[7 10 1 4];[9 13 1 5];[2 3 0 1];[4 6 0 2]]);
-%!  assert(ifftshift (y), x);
+%! x = [0:3];
+%! x = [x;2*x;3*x+1;4*x+1];
+%! y = ifftshift (x);
+%! assert (y, [[7 10 1 4];[9 13 1 5];[2 3 0 1];[4 6 0 2]]);
+%! assert (ifftshift (y), x);
 
 %!test
-%!  x = [0:3];
-%!  x = [x;2*x;3*x+1;4*x+1];
-%!  y = ifftshift (x,1);
-%!  assert(y, [[1 4 7 10];[1 5 9 13];[0 1 2 3];[0 2 4 6]]);
-%!  assert(ifftshift (y,1), x);
+%! x = [0:3];
+%! x = [x;2*x;3*x+1;4*x+1];
+%! y = ifftshift (x,1);
+%! assert (y, [[1 4 7 10];[1 5 9 13];[0 1 2 3];[0 2 4 6]]);
+%! assert (ifftshift (y,1), x);
 
 %!test
-%!  x = [0:3];
-%!  x = [x;2*x;3*x+1;4*x+1];
-%!  y = ifftshift (x,2);
-%!  assert(y, [[2 3 0 1];[4 6 0 2];[7 10 1 4];[9 13 1 5]]);
-%!  assert(ifftshift (y,2), x);
+%! x = [0:3];
+%! x = [x;2*x;3*x+1;4*x+1];
+%! y = ifftshift (x,2);
+%! assert (y, [[2 3 0 1];[4 6 0 2];[7 10 1 4];[9 13 1 5]]);
+%! assert (ifftshift (y,2), x);
 
--- a/scripts/signal/periodogram.m
+++ b/scripts/signal/periodogram.m
@@ -40,7 +40,7 @@
 ## @item win: weight data with window, x.*win is used for further computation,
 ## if window is empty, a rectangular window is used.
 ##
-## @item nfft: number of frequency bins, default max(256, 2.^ceil(log2(length(x)))).
+## @item nfft: number of frequency bins, default max (256, 2.^ceil (log2 (length (x)))).
 ##
 ## @item Fs: sampling rate, default 1.
 ##
@@ -108,7 +108,7 @@
   if (!  isempty (window))
     if (all (size (x) == size (window)))
       x .*= window;
-    elseif (size (x, 1) == size (window, 1) && size (window, 2) == 1)
+    elseif (rows (x) == rows (window) && columns (window) == 1)
       x .*= window (:,ones (1,c));
     endif;
   endif
@@ -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/signal/private/rectangle_lw.m
+++ b/scripts/signal/private/rectangle_lw.m
@@ -34,6 +34,6 @@
   retval = zeros (n, 1);
   t = floor (1 / b);
 
-  retval (1:t, 1) = ones (t, 1);
+  retval(1:t, 1) = ones (t, 1);
 
 endfunction
--- a/scripts/signal/private/triangle_sw.m
+++ b/scripts/signal/private/triangle_sw.m
@@ -31,7 +31,7 @@
     print_usage ();
   endif
 
-  retval = zeros(n,1);
+  retval = zeros (n,1);
   retval(1) = 1 / b;
 
   l = (2:n)' - 1;
--- a/scripts/signal/sinc.m
+++ b/scripts/signal/sinc.m
@@ -23,7 +23,7 @@
 ## $ \sin (\pi x)/(\pi x)$.
 ## @end tex
 ## @ifnottex
-##  sin(pi*x)/(pi*x).
+##  sin (pi*x) / (pi*x).
 ## @end ifnottex
 ## @end deftypefn
 
@@ -47,8 +47,9 @@
 endfunction
 
 
-%!assert (sinc (0), 1);
-%!assert (sinc (1), 0,1e-6);
+%!assert (sinc (0), 1)
+%!assert (sinc (1), 0,1e-6)
 %!assert (sinc (1/2), 2/pi, 1e-6)
 
 %!error sinc()
+
--- a/scripts/signal/sinetone.m
+++ b/scripts/signal/sinetone.m
@@ -58,10 +58,11 @@
   retval = zeros (ns, n);
 
   for k = 1:n
-    retval (:, k) = ampl(k) * sin (2 * pi * (1:ns) / rate * freq(k))';
+    retval(:, k) = ampl(k) * sin (2 * pi * (1:ns) / rate * freq(k))';
   endfor
 
 endfunction
 
 
-%!assert (size (sinetone (18e6, 150e6, 19550/150e6, 1)), [19550, 1]);
+%!assert (size (sinetone (18e6, 150e6, 19550/150e6, 1)), [19550, 1])
+
--- a/scripts/signal/sinewave.m
+++ b/scripts/signal/sinewave.m
@@ -44,12 +44,14 @@
 
 endfunction
 
-%!assert (sinewave (1), 0);
-%!assert (sinewave (1, 4, 1), 1);
-%!assert (sinewave (1, 12, 1), 1/2, 1e-6);
-%!assert (sinewave (1, 12, 2), sqrt (3)/2, 1e-6);
-%!assert (sinewave (1, 20, 1), (sqrt (5)-1)/4, 1e-6);
-%!assert (sinewave (1), sinewave (1, 1,0));
-%!assert (sinewave (3, 4), sinewave(3, 4, 0));
 
-%!error sinewave ();
+%!assert (sinewave (1), 0)
+%!assert (sinewave (1, 4, 1), 1)
+%!assert (sinewave (1, 12, 1), 1/2, 1e-6)
+%!assert (sinewave (1, 12, 2), sqrt (3)/2, 1e-6)
+%!assert (sinewave (1, 20, 1), (sqrt (5)-1)/4, 1e-6)
+%!assert (sinewave (1), sinewave (1, 1,0))
+%!assert (sinewave (3, 4), sinewave (3, 4, 0))
+
+%!error sinewave ()
+
--- a/scripts/signal/spectral_xdf.m
+++ b/scripts/signal/spectral_xdf.m
@@ -53,7 +53,7 @@
   x = x - sum (x) / xr;
 
   retval = (abs (fft (x)) / xr).^2;
-  retval = real (ifft (fft(retval) .* fft(w)));
+  retval = real (ifft (fft (retval) .* fft (w)));
 
   retval = [(zeros (xr, 1)), retval];
   retval(:, 1) = (0 : xr-1)' / xr;
--- a/scripts/signal/spencer.m
+++ b/scripts/signal/spencer.m
@@ -31,15 +31,15 @@
     print_usage ();
   endif
 
-  [xr, xc] = size(x);
+  [xr, xc] = size (x);
 
   n = xr;
   c = xc;
 
-  if (isvector(x))
-   n = length(x);
+  if (isvector (x))
+   n = length (x);
    c = 1;
-   x = reshape(x, n, 1);
+   x = reshape (x, n, 1);
   endif
 
   w = [-3, -6, -5, 3, 21, 46, 67, 74, 67, 46, 21, 3, -5, -6, -3] / 320;
@@ -47,7 +47,7 @@
   retval = fftfilt (w, x);
   retval = [zeros(7,c); retval(15:n,:); zeros(7,c);];
 
-  retval = reshape(retval, xr, xc);
+  retval = reshape (retval, xr, xc);
 
 endfunction
 
--- a/scripts/signal/stft.m
+++ b/scripts/signal/stft.m
@@ -55,7 +55,7 @@
 ## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at>
 ## Description: Short-Time Fourier Transform
 
-function [y, c] = stft(x, win_size, inc, num_coef, win_type)
+function [y, c] = stft (x, win_size, inc, num_coef, win_type)
 
   ## Default values of unspecified arguments.
   if (nargin < 5)
--- a/scripts/signal/synthesis.m
+++ b/scripts/signal/synthesis.m
@@ -62,11 +62,11 @@
   z = z(st:st+inc-1, :);
   w_coeff = w_coeff(st:st+inc-1);
 
-  nc = columns(z);
+  nc = columns (z);
   for i = 1:nc
     z(:, i) = z(:, i) ./ w_coeff;
   endfor
 
-  x = reshape(z, inc * nc, 1);
+  x = reshape (z, inc * nc, 1);
 
 endfunction
--- a/scripts/signal/unwrap.m
+++ b/scripts/signal/unwrap.m
@@ -36,7 +36,7 @@
     print_usage ();
   endif
 
-  if (!isnumeric(x))
+  if (!isnumeric (x))
     error ("unwrap: X must be a numeric matrix or vector");
   endif
 
@@ -78,7 +78,7 @@
   ## Find only the peaks, and multiply them by the appropriate amount
   ## of ranges so that there are kronecker deltas at each wrap point
   ## multiplied by the appropriate amount of range values.
-  p =  ceil(abs(d)./rng) .* rng .* (((d > tol) > 0) - ((d < -tol) > 0));
+  p =  ceil (abs (d)./rng) .* rng .* (((d > tol) > 0) - ((d < -tol) > 0));
 
   ## Now need to "integrate" this so that the deltas become steps.
   r = cumsum (p, dim);
@@ -89,16 +89,17 @@
 
 endfunction
 
-%!function t = __xassert(a,b,tol)
+
+%!function t = __xassert (a,b,tol)
 %!  if (nargin == 1)
-%!    t = all(a(:));
+%!    t = all (a(:));
 %!  else
 %!    if (nargin == 2)
 %!      tol = 0;
 %!    endif
-%!    if (any (size(a) != size(b)))
+%!    if (any (size (a) != size (b)))
 %!      t = 0;
-%!    elseif (any (abs(a(:) - b(:)) > tol))
+%!    elseif (any (abs (a(:) - b(:)) > tol))
 %!      t = 0;
 %!    else
 %!      t = 1;
@@ -112,29 +113,29 @@
 %! t = [];
 %!
 %! r = [0:100];                        # original vector
-%! w = r - 2*pi*floor((r+pi)/(2*pi));  # wrapped into [-pi,pi]
+%! w = r - 2*pi*floor ((r+pi)/(2*pi)); # wrapped into [-pi,pi]
 %! tol = 1e3*eps;                      # maximum expected deviation
 %!
-%! t(++i) = __xassert(r, unwrap(w), tol);               #unwrap single row
-%! t(++i) = __xassert(r', unwrap(w'), tol);             #unwrap single column
-%! t(++i) = __xassert([r',r'], unwrap([w',w']), tol);   #unwrap 2 columns
-%! t(++i) = __xassert([r;r], unwrap([w;w],[],2), tol);  #check that dim works
-%! t(++i) = __xassert(r+10, unwrap(10+w), tol);         #check r(1)>pi works
+%! t(++i) = __xassert (r, unwrap (w), tol);              #unwrap single row
+%! t(++i) = __xassert (r', unwrap (w'), tol);            #unwrap single column
+%! t(++i) = __xassert ([r',r'], unwrap ([w',w']), tol);  #unwrap 2 columns
+%! t(++i) = __xassert ([r;r], unwrap ([w;w],[],2), tol); #check that dim works
+%! t(++i) = __xassert (r+10, unwrap (10+w), tol);        #check r(1)>pi works
 %!
-%! t(++i) = __xassert(w', unwrap(w',[],2));  #unwrap col by rows should not change it
-%! t(++i) = __xassert(w, unwrap(w,[],1));    #unwrap row by cols should not change it
-%! t(++i) = __xassert([w;w], unwrap([w;w])); #unwrap 2 rows by cols should not change them
+%! t(++i) = __xassert (w', unwrap (w',[],2));  #unwrap col by rows should not change it
+%! t(++i) = __xassert (w, unwrap (w,[],1));    #unwrap row by cols should not change it
+%! t(++i) = __xassert ([w;w], unwrap ([w;w])); #unwrap 2 rows by cols should not change them
 %!
 %! ## verify that setting tolerance too low will cause bad results.
-%! t(++i) = __xassert(any(abs(r - unwrap(w,0.8)) > 100));
+%! t(++i) = __xassert (any (abs (r - unwrap (w,0.8)) > 100));
 %!
-%! assert(all(t));
+%! assert (all (t));
 %!
 %!test
 %! A = [pi*(-4), pi*(-2+1/6), pi/4, pi*(2+1/3), pi*(4+1/2), pi*(8+2/3), pi*(16+1), pi*(32+3/2), pi*64];
-%! assert (unwrap(A), unwrap(A, pi));
-%! assert (unwrap(A, pi), unwrap(A, pi, 2));
-%! assert (unwrap(A', pi), unwrap(A', pi, 1));
+%! assert (unwrap (A), unwrap (A, pi));
+%! assert (unwrap (A, pi), unwrap (A, pi, 2));
+%! assert (unwrap (A', pi), unwrap (A', pi, 1));
 %!
 %!test
 %! A = [pi*(-4); pi*(2+1/3); pi*(16+1)];
@@ -145,12 +146,13 @@
 %! E(:, :, 2) = [A+B, B+C, C+D, D+A];
 %! F(:, :, 1) = [unwrap(A), unwrap(B), unwrap(C), unwrap(D)];
 %! F(:, :, 2) = [unwrap(A+B), unwrap(B+C), unwrap(C+D), unwrap(D+A)];
-%! assert (unwrap(E), F);
+%! assert (unwrap (E), F);
 %!
 %!test
 %! A = [0, 2*pi, 4*pi, 8*pi, 16*pi, 65536*pi];
 %! B = [pi*(-2+1/6), pi/4, pi*(2+1/3), pi*(4+1/2), pi*(8+2/3), pi*(16+1), pi*(32+3/2), pi*64];
-%! assert (unwrap(A), zeros(1, length(A)));
-%! assert (diff(unwrap(B), 1)<2*pi, true(1, length(B)-1));
-%!
+%! assert (unwrap (A), zeros (1, length (A)));
+%! assert (diff (unwrap (B), 1) < 2*pi, true (1, length (B)-1));
+
 %!error unwrap()
+
--- a/scripts/signal/yulewalker.m
+++ b/scripts/signal/yulewalker.m
@@ -41,7 +41,7 @@
   endif
 
   cp = c(2 : p+1);
-  CP = zeros(p, p);
+  CP = zeros (p, p);
 
   for i = 1:p
     for j = 1:p
--- a/scripts/sparse/bicg.m
+++ b/scripts/sparse/bicg.m
@@ -15,7 +15,6 @@
 ## along with this program; If not, see <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-##
 ## @deftypefn  {Function File} {@var{x} =} bicg (@var{A}, @var{b}, @var{rtol}, @var{maxit}, @var{M1}, @var{M2}, @var{x0})
 ## @deftypefnx {Function File} {@var{x} =} bicg (@var{A}, @var{b}, @var{rtol}, @var{maxit}, @var{P})
 ## @deftypefnx {Function File} {[@var{x}, @var{flag}, @var{relres}, @var{iter}, @var{resvec}] =} bicg (@var{A}, @var{b}, @dots{})
@@ -40,13 +39,14 @@
 ## The preconditioner @var{P} is given as @code{P = M1 * M2}.
 ## Both @var{M1} and @var{M2} can be passed as a matrix or as
 ## a function handle or inline function @code{g} such that
-## @code{g(x, 'notransp') = M1 \ x} or @code{g(x, 'notransp') = M2 \ x} and
-## @code{g(x, 'transp') = M1' \ x} or @code{g(x, 'transp') = M2' \ x}.
+## @code{g(x, "notransp") = M1 \ x} or @code{g(x, "notransp") = M2 \ x} and
+## @code{g(x, "transp") = M1' \ x} or @code{g(x, "transp") = M2' \ x}.
 ##
 ## If called with more than one output parameter
 ##
 ## @itemize @minus
 ## @item @var{flag} indicates the exit status:
+##
 ## @itemize @minus
 ## @item 0: iteration converged to the within the chosen tolerance
 ##
@@ -228,7 +228,6 @@
 %! M2 = spdiags ([4*ones(n,1) -ones(n,1)], 0:1, n, n);
 %! [x, flag, relres, iter, resvec] = bicg (A, b, tol, maxit, M1, M2);
 %! assert (x, ones (size (b)), 1e-7);
-%!
 
 %!function y = afun (x, t, a)
 %!  switch t
@@ -260,3 +259,4 @@
 %! b = sum (A, 2);
 %! [x, flag, relres, iter, resvec] = bicg (A, b, tol, [], diag (diag (A)));
 %! assert (x, ones (size (b)), 1e-7);
+
--- a/scripts/sparse/bicgstab.m
+++ b/scripts/sparse/bicgstab.m
@@ -18,7 +18,6 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-##
 ## @deftypefn  {Function File} {@var{x} =} bicgstab (@var{A}, @var{b}, @var{rtol}, @var{maxit}, @var{M1}, @var{M2}, @var{x0})
 ## @deftypefnx {Function File} {@var{x} =} bicgstab (@var{A}, @var{b}, @var{rtol}, @var{maxit}, @var{P})
 ## @deftypefnx {Function File} {[@var{x}, @var{flag}, @var{relres}, @var{iter}, @var{resvec}] =} bicgstab (@var{A}, @var{b}, @dots{})
@@ -49,6 +48,7 @@
 ##
 ## @itemize @minus
 ## @item @var{flag} indicates the exit status:
+##
 ## @itemize @minus
 ## @item 0: iteration converged to the within the chosen tolerance
 ##
@@ -138,7 +138,7 @@
     rr = res;
 
     ## Vector of the residual norms for each iteration.
-    resvec = norm(res) / norm_b;
+    resvec = norm (res) / norm_b;
 
     ## Default behaviour we don't reach tolerance tol within maxit iterations.
     flag = 1;
@@ -206,11 +206,12 @@
 
 endfunction
 
+
 %!demo
 %! % Solve system of A*x=b
-%! A = [5 -1 3;-1 2 -2;3 -2 3]
-%! b = [7;-1;4]
-%! [x, flag, relres, iter, resvec] = bicgstab(A, b)
+%! A = [5 -1 3;-1 2 -2;3 -2 3];
+%! b = [7;-1;4];
+%! [x, flag, relres, iter, resvec] = bicgstab (A, b)
 
 %!shared A, b, n, M1, M2
 %!
@@ -245,3 +246,4 @@
 %! b = sum (A, 2);
 %! [x, flag, relres, iter, resvec] = bicgstab (A, b, tol, [], diag (diag (A)));
 %! assert (x, ones (size (b)), 1e-7);
+
--- a/scripts/sparse/cgs.m
+++ b/scripts/sparse/cgs.m
@@ -18,7 +18,6 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-##
 ## @deftypefn  {Function File} {@var{x} =} cgs (@var{A}, @var{b}, @var{rtol}, @var{maxit}, @var{M1}, @var{M2}, @var{x0})
 ## @deftypefnx {Function File} {@var{x} =} cgs (@var{A}, @var{b}, @var{rtol}, @var{maxit}, @var{P})
 ## @deftypefnx {Function File} {[@var{x}, @var{flag}, @var{relres}, @var{iter}, @var{resvec}] =} cgs (@var{A}, @var{b}, @dots{})
@@ -49,6 +48,7 @@
 ##
 ## @itemize @minus
 ## @item @var{flag} indicates the exit status:
+##
 ## @itemize @minus
 ## @item 0: iteration converged to the within the chosen tolerance
 ##
@@ -189,12 +189,11 @@
 endfunction
 
 
-
 %!demo
 %! % Solve system of A*x=b
-%! A=[5 -1 3;-1 2 -2;3 -2 3]
-%! b=[7;-1;4]
-%! [a,b,c,d,e]=cgs(A,b)
+%! A = [5 -1 3;-1 2 -2;3 -2 3];
+%! b = [7;-1;4];
+%! [a,b,c,d,e] = cgs (A,b)
 
 %!shared A, b, n, M
 %!
@@ -223,3 +222,4 @@
 %! b = sum (A, 2);
 %! [x, flag, relres, iter, resvec] = cgs (A, b, tol, [], diag (diag (A)));
 %! assert (x, ones (size (b)), 1e-7);
+
--- a/scripts/sparse/gmres.m
+++ b/scripts/sparse/gmres.m
@@ -32,7 +32,7 @@
 ## @code{min (10, numel (b) / restart)} is used.
 ##
 ## @item @var{x0} is the initial guess,
-## if not given or set to [] the default value @code{zeros(size (b))} is used.
+## if not given or set to [] the default value @code{zeros (size (b))} is used.
 ##
 ## @item @var{m} is the restart parameter,
 ## if not given or set to [] the default value @code{numel (b)} is used.
@@ -49,6 +49,7 @@
 ##
 ## @itemize @minus
 ## @item @var{flag} indicates the exit status:
+##
 ## @table @asis
 ## @item 0 : iteration converged to within the specified tolerance
 ##
@@ -56,7 +57,7 @@
 ##
 ## @item 2 : unused, but skipped for compatibility
 ##
-## @item 3 : algorithm reached stagnation
+## @item 3 : algorithm reached stagnation (no change between iterations)
 ## @end table
 ##
 ## @item @var{relres} is the final value of the relative residual.
@@ -71,7 +72,7 @@
 ## @seealso{bicg, bicgstab, cgs, pcg}
 ## @end deftypefn
 
-function [x, flag, presn, it, resids] = gmres (A, b, restart, rtol, maxit, M1, M2, x0)
+function [x, flag, relres, it, resvec] = gmres (A, b, restart, rtol, maxit, M1, M2, x0)
 
   if (nargin < 2 || nargin > 8)
     print_usage ();
@@ -141,10 +142,10 @@
   ## begin loop
   iter = 1;
   restart_it  = restart + 1;
-  resids      = zeros (maxit, 1);
-  resids(1)   = presn;
+  resvec      = zeros (maxit, 1);
+  resvec(1)   = presn;
   prec_b_norm = norm (Pm1x (b), 2);
-  flag        = 1;
+  flag        = 1;  # Default flag is maximum # of iterations exceeded
 
   while (iter <= maxit * restart && presn > rtol * prec_b_norm)
 
@@ -173,46 +174,63 @@
 
     x = x_old + V(:, 1:restart_it) * Y(1:restart_it);
 
-    resids(iter) = presn;
+    resvec(iter+1) = presn;
     if (norm (x - x_old, inf) <= eps)
-      flag = 3;
-      break
+      flag = 3;  # Stagnation: no change between iterations
+      break;
     endif
 
     restart_it++ ;
     iter++;
   endwhile
 
-  if (presn > rtol * prec_b_norm)
-    flag = 0;
+  if (nargout > 1)
+    ## Calculate extra outputs as requested
+    relres = presn / prec_b_norm;
+    if (relres <= rtol)
+      flag = 0;  # Converged to solution within tolerance
+    endif
+
+    it = [floor(iter/restart), restart_it-1];
   endif
 
-  resids = resids(1:iter-1);
-  it = [ceil(iter / restart), rem(iter, restart)];
-
 endfunction
 
 
+%!demo
+%! dim = 20;
+%! A = spdiags ([-ones(dim,1) 2*ones(dim,1) ones(dim,1)], [-1:1], dim, dim);
+%! b = ones (dim, 1);
+%! [x, flag, relres, iter, resvec] = gmres (A, b, 10, 1e-10, dim, @(x) x ./ diag (A), [], b)
+
 %!shared A, b, dim
 %! dim = 100;
 %!test
 %! A = spdiags ([-ones(dim,1) 2*ones(dim,1) ones(dim,1)], [-1:1], dim, dim);
-%! b = ones(dim, 1);
-%! x = gmres (A, b, 10, 1e-10, dim, @(x) x./diag(A), [],  b);
-%! assert(x, A\b, 1e-9*norm(x,inf));
+%! b = ones (dim, 1);
+%! x = gmres (A, b, 10, 1e-10, dim, @(x) x ./ diag (A), [], b);
+%! assert (x, A\b, 1e-9*norm (x, Inf));
 %!
 %!test
-%! x = gmres (A, b, dim, 1e-10, 1e4, @(x) diag(diag(A))\x, [],  b);
-%! assert(x, A\b, 1e-7*norm(x,inf));
+%! x = gmres (A, b, dim, 1e-10, 1e4, @(x) diag (diag (A)) \ x, [], b);
+%! assert(x, A\b, 1e-7*norm (x, Inf));
 %!
 %!test
 %! A = spdiags ([[1./(2:2:2*(dim-1)) 0]; 1./(1:2:2*dim-1); [0 1./(2:2:2*(dim-1))]]', -1:1, dim, dim);
 %! A = A'*A;
 %! b = rand (dim, 1);
-%! [x, resids] = gmres (@(x) A*x, b, dim, 1e-10, dim, @(x) x./diag(A), [],  []);
-%! assert(x, A\b, 1e-9*norm(x,inf))
-%! x = gmres (@(x) A*x, b, dim, 1e-10, 1e6, @(x) diag(diag(A))\x, [],  []);
-%! assert(x, A\b, 1e-9*norm(x,inf));
+%! [x, resvec] = gmres (@(x) A*x, b, dim, 1e-10, dim, @(x) x./diag (A), [], []);
+%! assert (x, A\b, 1e-9*norm (x, Inf));
+%! x = gmres (@(x) A*x, b, dim, 1e-10, 1e6, @(x) diag (diag (A)) \ x, [], []);
+%! assert (x, A\b, 1e-9*norm (x, Inf));
 %!test
-%! x =  gmres (@(x) A*x, b, dim, 1e-10, 1e6, @(x) x./diag(A), [],  []);
-%! assert(x, A\b, 1e-7*norm(x,inf));
+%! x = gmres (@(x) A*x, b, dim, 1e-10, 1e6, @(x) x ./ diag (A), [], []);
+%! assert (x, A\b, 1e-7*norm (x, Inf));
+
+
+%!error gmres (1)
+%!error gmres (1,2,3,4,5,6,7,8,9)
+%!error <A must be> gmres ({1},2)
+%!error <A must be a function or matrix> gmres ({1},2)
+%!error <M1 must be a function or matrix> gmres (1,2,3,4,5,{6})
+%!error <M2 must be a function or matrix> gmres (1,2,3,4,5,6,{7})
--- a/scripts/sparse/gplot.m
+++ b/scripts/sparse/gplot.m
@@ -66,13 +66,13 @@
 %!      0 0 0 0 1 0 0
 %!      0 0 0 0 1 0 0];
 %!
-%! xy = [1, 0
+%! xy = [1  , 0
 %!       1.5, 1
-%!       2, 0
+%!       2  , 0
 %!       2.5, 2
 %!       3.5, 1
-%!       3, 0
-%!       4, 0];
+%!       3  , 0
+%!       4  , 0];
 %!
 %! clf;
 %! gplot (A, xy, "o-");
@@ -80,5 +80,5 @@
 %! title ("gplot() of Binary Tree Adjacency matrix");
 
 %% Mark graphical function as tested by demo block
-%!assert (1);
+%!assert (1)
 
--- a/scripts/sparse/nonzeros.m
+++ b/scripts/sparse/nonzeros.m
@@ -34,7 +34,8 @@
 endfunction
 
 
-%!assert(nonzeros([1,2;3,0]),[1;3;2])
-%!assert(nonzeros([1,2,3,0]),[1;2;3])
-%!assert(nonzeros(sparse([1,2;3,0])),[1;3;2])
-%!assert(nonzeros(sparse([1,2,3,0])),[1;2;3])
+%!assert (nonzeros ([1,2;3,0]), [1;3;2])
+%!assert (nonzeros ([1,2,3,0]), [1;2;3])
+%!assert (nonzeros (sparse ([1,2;3,0])), [1;3;2])
+%!assert (nonzeros (sparse ([1,2,3,0])), [1;2;3])
+
--- a/scripts/sparse/pcg.m
+++ b/scripts/sparse/pcg.m
@@ -241,7 +241,7 @@
   endif
 
   if (nargin < 4 || isempty (maxit))
-    maxit = min (size (b, 1), 20);
+    maxit = min (rows (b), 20);
   endif
 
   maxit += 2;
@@ -275,7 +275,7 @@
 
   while (resvec (iter-1,1) > tol * resvec (1,1) && iter < maxit)
     if (exist_m1)
-      if(isnumeric (m1))
+      if (isnumeric (m1))
         y = m1 \ r;
       else
         y = feval (m1, r, varargin{:});
@@ -316,8 +316,8 @@
     if (nargout > 5 && iter > 2)
       T(iter-1:iter, iter-1:iter) = T(iter-1:iter, iter-1:iter) + ...
           [1 sqrt(beta); sqrt(beta) beta]./oldalpha;
-      ## EVS = eig(T(2:iter-1,2:iter-1));
-      ## fprintf(stderr,"PCG condest: %g (iteration: %d)\n", max(EVS)/min(EVS),iter);
+      ## EVS = eig (T(2:iter-1,2:iter-1));
+      ## fprintf (stderr,"PCG condest: %g (iteration: %d)\n", max (EVS)/min (EVS),iter);
     endif
     resvec (iter,1) = norm (r);
     iter++;
@@ -388,145 +388,153 @@
   endif
 endfunction
 
+
 %!demo
-%!
-%!      # Simplest usage of pcg (see also 'help pcg')
-%!
-%!      N = 10;
-%!      A = diag ([1:N]); b = rand (N, 1); y =  A \ b; #y is the true solution
-%!      x = pcg (A, b);
-%!      printf('The solution relative error is %g\n', norm (x - y) / norm (y));
-%!
-%!      # You shouldn't be afraid if pcg issues some warning messages in this
-%!      # example: watch out in the second example, why it takes N iterations
-%!      # of pcg to converge to (a very accurate, by the way) solution
+%!  # Simplest usage of pcg (see also 'help pcg')
+%! 
+%!  N = 10;
+%!  A = diag ([1:N]); b = rand (N, 1);
+%!  y = A \ b;  # y is the true solution
+%!  x = pcg (A, b);
+%!  printf ("The solution relative error is %g\n", norm (x - y) / norm (y));
+%! 
+%!  # You shouldn't be afraid if pcg issues some warning messages in this
+%!  # example: watch out in the second example, why it takes N iterations
+%!  # of pcg to converge to (a very accurate, by the way) solution
+
 %!demo
-%!
-%!      # Full output from pcg, except for the eigenvalue estimates
-%!      # We use this output to plot the convergence history
-%!
-%!      N = 10;
-%!      A = diag ([1:N]); b = rand (N, 1); X =  A \ b; #X is the true solution
-%!      [x, flag, relres, iter, resvec] = pcg (A, b);
-%!      printf('The solution relative error is %g\n', norm (x - X) / norm (X));
-%!      title('Convergence history'); xlabel('Iteration'); ylabel('log(||b-Ax||/||b||)');
-%!      semilogy([0:iter], resvec / resvec(1),'o-g');
-%!      legend('relative residual');
+%!  # Full output from pcg, except for the eigenvalue estimates
+%!  # We use this output to plot the convergence history
+%! 
+%!  N = 10;
+%!  A = diag ([1:N]); b = rand (N, 1);
+%!  X = A \ b;  # X is the true solution
+%!  [x, flag, relres, iter, resvec] = pcg (A, b);
+%!  printf ("The solution relative error is %g\n", norm (x - X) / norm (X));
+%!  title ("Convergence history");
+%!  semilogy ([0:iter], resvec / resvec(1), "o-g");
+%!  xlabel ("Iteration"); ylabel ("log(||b-Ax||/||b||)");
+%!  legend ("relative residual");
+
 %!demo
-%!
-%!      # Full output from pcg, including the eigenvalue estimates
-%!      # Hilbert matrix is extremely ill conditioned, so pcg WILL have problems
+%!  # Full output from pcg, including the eigenvalue estimates
+%!  # Hilbert matrix is extremely ill-conditioned, so pcg WILL have problems
+%! 
+%!  N = 10;
+%!  A = hilb (N); b = rand (N, 1);
+%!  X = A \ b;  # X is the true solution
+%!  [x, flag, relres, iter, resvec, eigest] = pcg (A, b, [], 200);
+%!  printf ("The solution relative error is %g\n", norm (x - X) / norm (X));
+%!  printf ("Condition number estimate is %g\n", eigest(2) / eigest(1));
+%!  printf ("Actual condition number is   %g\n", cond (A));
+%!  title ("Convergence history");
+%!  semilogy ([0:iter], resvec, ["o-g";"+-r"]);
+%!  xlabel ("Iteration"); ylabel ("log(||b-Ax||)");
+%!  legend ("absolute residual", "absolute preconditioned residual");
+
+%!demo
+%!  # Full output from pcg, including the eigenvalue estimates
+%!  # We use the 1-D Laplacian matrix for A, and cond(A) = O(N^2)
+%!  # and that's the reason we need some preconditioner; here we take
+%!  # a very simple and not powerful Jacobi preconditioner,
+%!  # which is the diagonal of A
 %!
-%!      N = 10;
-%!      A = hilb (N); b = rand (N, 1); X = A \ b; #X is the true solution
-%!      [x, flag, relres, iter, resvec, eigest] = pcg (A, b, [], 200);
-%!      printf('The solution relative error is %g\n', norm (x - X) / norm (X));
-%!      printf('Condition number estimate is %g\n', eigest(2) / eigest (1));
-%!      printf('Actual condition number is   %g\n', cond (A));
-%!      title('Convergence history'); xlabel('Iteration'); ylabel('log(||b-Ax||)');
-%!      semilogy([0:iter], resvec,['o-g';'+-r']);
-%!      legend('absolute residual','absolute preconditioned residual');
-%!demo
-%!
-%!      # Full output from pcg, including the eigenvalue estimates
-%!      # We use the 1-D Laplacian matrix for A, and cond(A) = O(N^2)
-%!      # and that's the reasone we need some preconditioner; here we take
-%!      # a very simple and not powerful Jacobi preconditioner,
-%!      # which is the diagonal of A
+%!  N = 100;
+%!  A = zeros (N, N);
+%!  for i = 1 : N - 1 # form 1-D Laplacian matrix
+%!    A(i:i+1, i:i+1) = [2 -1; -1 2];
+%!  endfor
+%!  b = rand (N, 1);
+%!  X = A \ b;  # X is the true solution
+%!  maxit = 80;
+%!  printf ("System condition number is %g\n", cond (A));
+%!  # No preconditioner: the convergence is very slow!
 %!
-%!      N = 100;
-%!      A = zeros (N, N);
-%!      for i=1 : N - 1 # form 1-D Laplacian matrix
-%!              A (i:i+1, i:i+1) = [2 -1; -1 2];
-%!      endfor
-%!      b = rand (N, 1); X = A \ b; #X is the true solution
-%!      maxit = 80;
-%!      printf('System condition number is %g\n', cond (A));
-%!      # No preconditioner: the convergence is very slow!
+%!  [x, flag, relres, iter, resvec, eigest] = pcg (A, b, [], maxit);
+%!  printf ("System condition number estimate is %g\n", eigest(2) / eigest(1));
+%!  title ("Convergence history");
+%!  semilogy ([0:iter], resvec(:,1), "o-g");
+%!  xlabel ("Iteration"); ylabel ("log(||b-Ax||)");
+%!  legend ("NO preconditioning: absolute residual");
 %!
-%!      [x, flag, relres, iter, resvec, eigest] = pcg (A, b, [], maxit);
-%!      printf('System condition number estimate is %g\n', eigest(2) / eigest(1));
-%!      title('Convergence history'); xlabel('Iteration'); ylabel('log(||b-Ax||)');
-%!      semilogy([0:iter], resvec(:,1), 'o-g');
-%!      legend('NO preconditioning: absolute residual');
-%!
-%!      pause(1);
-%!      # Test Jacobi preconditioner: it will not help much!!!
+%!  pause (1);
+%!  # Test Jacobi preconditioner: it will not help much!!!
 %!
-%!      M = diag (diag (A)); # Jacobi preconditioner
-%!      [x, flag, relres, iter, resvec, eigest] = pcg (A, b, [], maxit, M);
-%!      printf('JACOBI preconditioned system condition number estimate is %g\n', eigest(2) / eigest(1));
-%!      hold on;
-%!      semilogy([0:iter], resvec(:,1), 'o-r');
-%!      legend('NO preconditioning: absolute residual', ...
-%!             'JACOBI preconditioner: absolute residual');
+%!  M = diag (diag (A)); # Jacobi preconditioner
+%!  [x, flag, relres, iter, resvec, eigest] = pcg (A, b, [], maxit, M);
+%!  printf ("JACOBI preconditioned system condition number estimate is %g\n", eigest(2) / eigest(1));
+%!  hold on;
+%!  semilogy ([0:iter], resvec(:,1), "o-r");
+%!  legend ("NO preconditioning: absolute residual", ...
+%!          "JACOBI preconditioner: absolute residual");
 %!
-%!      pause(1);
-%!      # Test nonoverlapping block Jacobi preconditioner: it will help much!
+%!  pause (1);
+%!  # Test nonoverlapping block Jacobi preconditioner: it will help much!
 %!
-%!      M = zeros (N, N); k = 4;
-%!      for i = 1 : k : N # form 1-D Laplacian matrix
-%!              M (i:i+k-1, i:i+k-1) = A (i:i+k-1, i:i+k-1);
-%!      endfor
-%!      [x, flag, relres, iter, resvec, eigest] = pcg (A, b, [], maxit, M);
-%!      printf('BLOCK JACOBI preconditioned system condition number estimate is %g\n', eigest(2) / eigest(1));
-%!      semilogy ([0:iter], resvec(:,1),'o-b');
-%!      legend('NO preconditioning: absolute residual', ...
-%!             'JACOBI preconditioner: absolute residual', ...
-%!             'BLOCK JACOBI preconditioner: absolute residual');
-%!      hold off;
+%!  M = zeros (N, N); k = 4;
+%!  for i = 1 : k : N # form 1-D Laplacian matrix
+%!    M(i:i+k-1, i:i+k-1) = A(i:i+k-1, i:i+k-1);
+%!  endfor
+%!  [x, flag, relres, iter, resvec, eigest] = pcg (A, b, [], maxit, M);
+%!  printf ("BLOCK JACOBI preconditioned system condition number estimate is %g\n", eigest(2) / eigest(1));
+%!  semilogy ([0:iter], resvec(:,1), "o-b");
+%!  legend ("NO preconditioning: absolute residual", ...
+%!          "JACOBI preconditioner: absolute residual", ...
+%!          "BLOCK JACOBI preconditioner: absolute residual");
+%!  hold off;
+
 %!test
+%! # solve small diagonal system
 %!
-%!      #solve small diagonal system
-%!
-%!      N = 10;
-%!      A = diag ([1:N]); b = rand (N, 1); X = A \ b; #X is the true solution
-%!      [x, flag] = pcg (A, b, [], N+1);
-%!      assert(norm (x - X) / norm (X), 0, 1e-10);
-%!      assert(flag, 0);
-%!
+%! N = 10;
+%! A = diag ([1:N]); b = rand (N, 1);
+%! X = A \ b;  # X is the true solution
+%! [x, flag] = pcg (A, b, [], N+1);
+%! assert (norm (x - X) / norm (X), 0, 1e-10);
+%! assert (flag, 0);
+
 %!test
-%!
-%!      #solve small indefinite diagonal system
-%!      #despite A is indefinite, the iteration continues and converges
-%!      #indefiniteness of A is detected
+%! # solve small indefinite diagonal system
+%! # despite A is indefinite, the iteration continues and converges
+%! # indefiniteness of A is detected
 %!
-%!      N = 10;
-%!      A = diag([1:N] .* (-ones(1, N) .^ 2)); b = rand (N, 1); X = A \ b; #X is the true solution
-%!      [x, flag] = pcg (A, b, [], N+1);
-%!      assert(norm (x - X) / norm (X), 0, 1e-10);
-%!      assert(flag, 3);
-%!
+%! N = 10;
+%! A = diag([1:N] .* (-ones(1, N) .^ 2)); b = rand (N, 1);
+%! X = A \ b;  # X is the true solution
+%! [x, flag] = pcg (A, b, [], N+1);
+%! assert (norm (x - X) / norm (X), 0, 1e-10);
+%! assert (flag, 3);
+
 %!test
-%!
-%!      #solve tridiagonal system, do not converge in default 20 iterations
+%! # solve tridiagonal system, do not converge in default 20 iterations
 %!
-%!      N = 100;
-%!      A = zeros (N, N);
-%!      for i = 1 : N - 1 # form 1-D Laplacian matrix
-%!              A (i:i+1, i:i+1) = [2 -1; -1 2];
-%!      endfor
-%!      b = ones (N, 1); X = A \ b; #X is the true solution
-%!      [x, flag, relres, iter, resvec, eigest] = pcg (A, b, 1e-12);
-%!      assert(flag);
-%!      assert(relres > 1.0);
-%!      assert(iter, 20); #should perform max allowable default number of iterations
-%!
+%! N = 100;
+%! A = zeros (N, N);
+%! for i = 1 : N - 1 # form 1-D Laplacian matrix
+%!   A(i:i+1, i:i+1) = [2 -1; -1 2];
+%! endfor
+%! b = ones (N, 1);
+%! X = A \ b;  # X is the true solution
+%! [x, flag, relres, iter, resvec, eigest] = pcg (A, b, 1e-12);
+%! assert (flag);
+%! assert (relres > 1.0);
+%! assert (iter, 20); # should perform max allowable default number of iterations
+
 %!test
+%! # solve tridiagonal system with 'perfect' preconditioner
+%! # which converges in one iteration, so the eigest does not
+%! # work and issues a warning
 %!
-%!      #solve tridiagonal system with 'prefect' preconditioner
-%!      #converges in one iteration, so the eigest does not work
-%!      #and issues a warning
-%!
-%!      N = 100;
-%!      A = zeros (N, N);
-%!      for i = 1 : N - 1 # form 1-D Laplacian matrix
-%!              A (i:i+1, i:i+1) = [2 -1; -1 2];
-%!      endfor
-%!      b = ones (N, 1); X = A \ b; #X is the true solution
-%!      [x, flag, relres, iter, resvec, eigest] = pcg (A, b, [], [], A, [], b);
-%!      assert(norm (x - X) / norm (X), 0, 1e-6);
-%!      assert(flag, 0);
-%!      assert(iter, 1); #should converge in one iteration
-%!      assert(isnan (eigest), isnan ([NaN, NaN]));
-%!
+%! N = 100;
+%! A = zeros (N, N);
+%! for i = 1 : N - 1 # form 1-D Laplacian matrix
+%!         A (i:i+1, i:i+1) = [2 -1; -1 2];
+%! endfor
+%! b = ones (N, 1);
+%! X = A \ b;  # X is the true solution
+%! [x, flag, relres, iter, resvec, eigest] = pcg (A, b, [], [], A, [], b);
+%! assert (norm (x - X) / norm (X), 0, 1e-6);
+%! assert (flag, 0);
+%! assert (iter, 1); # should converge in one iteration
+%! assert (isnan (eigest), isnan ([NaN, NaN]));
+
--- a/scripts/sparse/pcr.m
+++ b/scripts/sparse/pcr.m
@@ -252,7 +252,7 @@
     x += lambda*p;
     r -= lambda*q;
 
-    if (isnumeric(A))           # is A a matrix?
+    if (isnumeric (A))          # is A a matrix?
       t = A*s;
     else                        # then A should be a function!
       t = feval (A, s, varargin{:});
@@ -301,132 +301,143 @@
 
 endfunction
 
+
 %!demo
-%!
-%!      # Simplest usage of PCR (see also 'help pcr')
+%! # Simplest usage of PCR (see also 'help pcr')
 %!
-%!      N = 20;
-%!      A = diag(linspace(-3.1,3,N)); b = rand(N,1); y = A\b; #y is the true solution
-%!      x = pcr(A,b);
-%!      printf('The solution relative error is %g\n', norm(x-y)/norm(y));
-%!
-%!      # You shouldn't be afraid if PCR issues some warning messages in this
-%!      # example: watch out in the second example, why it takes N iterations
-%!      # of PCR to converge to (a very accurate, by the way) solution
-%!demo
+%! N = 20;
+%! A = diag (linspace (-3.1,3,N)); b = rand (N,1);
+%! y = A \ b;  # y is the true solution
+%! x = pcr (A,b);
+%! printf ("The solution relative error is %g\n", norm (x-y) / norm (y));
 %!
-%!      # Full output from PCR
-%!      # We use this output to plot the convergence history
+%! # You shouldn't be afraid if PCR issues some warning messages in this
+%! # example: watch out in the second example, why it takes N iterations
+%! # of PCR to converge to (a very accurate, by the way) solution
+
+%!demo
+%! # Full output from PCR
+%! # We use this output to plot the convergence history
 %!
-%!      N = 20;
-%!      A = diag(linspace(-3.1,30,N)); b = rand(N,1); X = A\b; #X is the true solution
-%!      [x, flag, relres, iter, resvec] = pcr(A,b);
-%!      printf('The solution relative error is %g\n', norm(x-X)/norm(X));
-%!      title('Convergence history'); xlabel('Iteration'); ylabel('log(||b-Ax||/||b||)');
-%!      semilogy([0:iter],resvec/resvec(1),'o-g;relative residual;');
+%! N = 20;
+%! A = diag (linspace (-3.1,30,N)); b = rand (N,1);
+%! X = A \ b;  # X is the true solution
+%! [x, flag, relres, iter, resvec] = pcr (A,b);
+%! printf ("The solution relative error is %g\n", norm (x-X) / norm (X));
+%! clf;
+%! title ("Convergence history");
+%! xlabel ("Iteration"); ylabel ("log(||b-Ax||/||b||)");
+%! semilogy ([0:iter], resvec/resvec(1), "o-g;relative residual;");
+
 %!demo
-%!
-%!      # Full output from PCR
-%!      # We use indefinite matrix based on the Hilbert matrix, with one
-%!      # strongly negative eigenvalue
-%!      # Hilbert matrix is extremely ill conditioned, so is ours,
-%!      # and that's why PCR WILL have problems
+%! # Full output from PCR
+%! # We use indefinite matrix based on the Hilbert matrix, with one
+%! # strongly negative eigenvalue
+%! # Hilbert matrix is extremely ill conditioned, so is ours,
+%! # and that's why PCR WILL have problems
 %!
-%!      N = 10;
-%!      A = hilb(N); A(1,1)=-A(1,1); b = rand(N,1); X = A\b; #X is the true solution
-%!      printf('Condition number of A is   %g\n', cond(A));
-%!      [x, flag, relres, iter, resvec] = pcr(A,b,[],200);
-%!      if (flag == 3)
-%!        printf('PCR breakdown. System matrix is [close to] singular\n');
-%!      end
-%!      title('Convergence history'); xlabel('Iteration'); ylabel('log(||b-Ax||)');
-%!      semilogy([0:iter],resvec,'o-g;absolute residual;');
+%! N = 10;
+%! A = hilb (N); A(1,1) = -A(1,1); b = rand (N,1);
+%! X = A \ b;  # X is the true solution
+%! printf ("Condition number of A is   %g\n", cond (A));
+%! [x, flag, relres, iter, resvec] = pcr (A,b,[],200);
+%! if (flag == 3)
+%!   printf ("PCR breakdown.  System matrix is [close to] singular\n");
+%! end
+%! clf;
+%! title ("Convergence history");
+%! xlabel ("Iteration"); ylabel ("log(||b-Ax||)");
+%! semilogy ([0:iter], resvec, "o-g;absolute residual;");
+
 %!demo
+%! # Full output from PCR
+%! # We use an indefinite matrix based on the 1-D Laplacian matrix for A,
+%! # and here we have cond(A) = O(N^2)
+%! # That's the reason we need some preconditioner; here we take
+%! # a very simple and not powerful Jacobi preconditioner,
+%! # which is the diagonal of A
 %!
-%!      # Full output from PCR
-%!      # We use an indefinite matrix based on the 1-D Laplacian matrix for A,
-%!      # and here we have cond(A) = O(N^2)
-%!      # That's the reason we need some preconditioner; here we take
-%!      # a very simple and not powerful Jacobi preconditioner,
-%!      # which is the diagonal of A
-%!
-%!      # Note that we use here indefinite preconditioners!
+%! # Note that we use here indefinite preconditioners!
 %!
-%!      N = 100;
-%!      A = zeros(N,N);
-%!      for i=1:N-1 # form 1-D Laplacian matrix
-%!              A(i:i+1,i:i+1) = [2 -1; -1 2];
-%!      endfor
-%!      A = [A, zeros(size(A)); zeros(size(A)), -A];
-%!      b = rand(2*N,1); X = A\b; #X is the true solution
-%!      maxit = 80;
-%!      printf('System condition number is %g\n',cond(A));
-%!      # No preconditioner: the convergence is very slow!
+%! N = 100;
+%! A = zeros (N,N);
+%! for i=1:N-1 # form 1-D Laplacian matrix
+%!   A(i:i+1,i:i+1) = [2 -1; -1 2];
+%! endfor
+%! A = [A, zeros(size(A)); zeros(size(A)), -A];
+%! b = rand (2*N,1);
+%! X = A \ b;  # X is the true solution
+%! maxit = 80;
+%! printf ("System condition number is %g\n", cond (A));
+%! # No preconditioner: the convergence is very slow!
 %!
-%!      [x, flag, relres, iter, resvec] = pcr(A,b,[],maxit);
-%!      title('Convergence history'); xlabel('Iteration'); ylabel('log(||b-Ax||)');
-%!      semilogy([0:iter],resvec,'o-g;NO preconditioning: absolute residual;');
-%!
-%!      pause(1);
-%!      # Test Jacobi preconditioner: it will not help much!!!
+%! [x, flag, relres, iter, resvec] = pcr (A,b,[],maxit);
+%! clf;
+%! title ("Convergence history");
+%! xlabel ("Iteration"); ylabel ("log(||b-Ax||)");
+%! semilogy ([0:iter], resvec, "o-g;NO preconditioning: absolute residual;");
 %!
-%!      M = diag(diag(A)); # Jacobi preconditioner
-%!      [x, flag, relres, iter, resvec] = pcr(A,b,[],maxit,M);
-%!      hold on;
-%!      semilogy([0:iter],resvec,'o-r;JACOBI preconditioner: absolute residual;');
+%! pause (1);
+%! # Test Jacobi preconditioner: it will not help much!!!
 %!
-%!      pause(1);
-%!      # Test nonoverlapping block Jacobi preconditioner: this one should give
-%!      # some convergence speedup!
+%! M = diag (diag (A)); # Jacobi preconditioner
+%! [x, flag, relres, iter, resvec] = pcr (A,b,[],maxit,M);
+%! hold on;
+%! semilogy ([0:iter],resvec,"o-r;JACOBI preconditioner: absolute residual;");
 %!
-%!      M = zeros(N,N);k=4;
-%!      for i=1:k:N # get k x k diagonal blocks of A
-%!              M(i:i+k-1,i:i+k-1) = A(i:i+k-1,i:i+k-1);
-%!      endfor
-%!      M = [M, zeros(size(M)); zeros(size(M)), -M];
-%!      [x, flag, relres, iter, resvec] = pcr(A,b,[],maxit,M);
-%!      semilogy([0:iter],resvec,'o-b;BLOCK JACOBI preconditioner: absolute residual;');
-%!      hold off;
+%! pause (1);
+%! # Test nonoverlapping block Jacobi preconditioner: this one should give
+%! # some convergence speedup!
+%!
+%! M = zeros (N,N); k = 4;
+%! for i=1:k:N # get k x k diagonal blocks of A
+%!   M(i:i+k-1,i:i+k-1) = A(i:i+k-1,i:i+k-1);
+%! endfor
+%! M = [M, zeros(size (M)); zeros(size(M)), -M];
+%! [x, flag, relres, iter, resvec] = pcr (A,b,[],maxit,M);
+%! semilogy ([0:iter], resvec, "o-b;BLOCK JACOBI preconditioner: absolute residual;");
+%! hold off;
+
 %!test
-%!
-%!      #solve small indefinite diagonal system
-%!
-%!      N = 10;
-%!      A = diag(linspace(-10.1,10,N)); b = ones(N,1); X = A\b; #X is the true solution
-%!      [x, flag] = pcr(A,b,[],N+1);
-%!      assert(norm(x-X)/norm(X)<1e-10);
-%!      assert(flag,0);
+%! # solve small indefinite diagonal system
 %!
-%!test
-%!
-%!      #solve tridiagonal system, do not converge in default 20 iterations
-%!      #should perform max allowable default number of iterations
-%!
-%!      N = 100;
-%!      A = zeros(N,N);
-%!      for i=1:N-1 # form 1-D Laplacian matrix
-%!              A(i:i+1,i:i+1) = [2 -1; -1 2];
-%!      endfor
-%!      b = ones(N,1); X = A\b; #X is the true solution
-%!      [x, flag, relres, iter, resvec] = pcr(A,b,1e-12);
-%!      assert(flag,1);
-%!      assert(relres>0.6);
-%!      assert(iter,20);
-%!
+%! N = 10;
+%! A = diag (linspace (-10.1,10,N)); b = ones (N,1);
+%! X = A \ b;  # X is the true solution
+%! [x, flag] = pcr (A,b,[],N+1);
+%! assert (norm (x-X) / norm (X) < 1e-10);
+%! assert (flag, 0);
+
 %!test
-%!
-%!      #solve tridiagonal system with 'prefect' preconditioner
-%!      #converges in one iteration
+%! # solve tridiagonal system, do not converge in default 20 iterations
+%! # should perform max allowable default number of iterations
 %!
-%!      N = 100;
-%!      A = zeros(N,N);
-%!      for i=1:N-1 # form 1-D Laplacian matrix
-%!              A(i:i+1,i:i+1) = [2 -1; -1 2];
-%!      endfor
-%!      b = ones(N,1); X = A\b; #X is the true solution
-%!      [x, flag, relres, iter] = pcr(A,b,[],[],A,b);
-%!      assert(norm(x-X)/norm(X)<1e-6);
-%!      assert(relres<1e-6);
-%!      assert(flag,0);
-%!      assert(iter,1); #should converge in one iteration
+%! N = 100;
+%! A = zeros (N,N);
+%! for i=1:N-1 # form 1-D Laplacian matrix
+%!   A(i:i+1,i:i+1) = [2 -1; -1 2];
+%! endfor
+%! b = ones (N,1);
+%! X = A \ b;  # X is the true solution
+%! [x, flag, relres, iter, resvec] = pcr (A,b,1e-12);
+%! assert (flag, 1);
+%! assert (relres > 0.6);
+%! assert (iter, 20);
+
+%!test
+%! # solve tridiagonal system with "perfect" preconditioner
+%! # converges in one iteration
 %!
+%! N = 100;
+%! A = zeros (N,N);
+%! for i=1:N-1 # form 1-D Laplacian matrix
+%!   A(i:i+1,i:i+1) = [2 -1; -1 2];
+%! endfor
+%! b = ones (N,1);
+%! X = A \ b;  # X is the true solution
+%! [x, flag, relres, iter] = pcr (A,b,[],[],A,b);
+%! assert (norm (x-X) / norm(X) < 1e-6);
+%! assert (relres < 1e-6);
+%! assert (flag, 0);
+%! assert (iter, 1); # should converge in one iteration
+
--- a/scripts/sparse/private/__sprand_impl__.m
+++ b/scripts/sparse/private/__sprand_impl__.m
@@ -39,7 +39,7 @@
     return;
   endif
 
-  [m, n, d, funname, randfun] = deal(varargin{:});
+  [m, n, d, funname, randfun] = deal (varargin{:});
 
   if (!(isscalar (m) && m == fix (m) && m > 0))
     error ("%s: M must be an integer greater than 0", funname);
@@ -60,4 +60,4 @@
   [i, j] = ind2sub ([m, n], idx);
   S = sparse (i, j, randfun (k, 1), m, n);
 
-endfunction
\ No newline at end of file
+endfunction
--- a/scripts/sparse/spaugment.m
+++ b/scripts/sparse/spaugment.m
@@ -90,12 +90,14 @@
   s = [ c * speye(m, m), A; A', sparse(n, n)];
 endfunction
 
+
 %!testif HAVE_UMFPACK
-%! m = 11; n = 10; mn = max(m ,n);
+%! m = 11; n = 10; mn = max (m ,n);
 %! A = spdiags ([ones(mn,1), 10*ones(mn,1), -ones(mn,1)],[-1,0,1], m, n);
 %! x0 = A \ ones (m,1);
 %! s = spaugment (A);
 %! [L, U, P, Q] = lu (s);
 %! x1 = Q * (U \ (L \ (P  * [ones(m,1); zeros(n,1)])));
 %! x1 = x1(end - n + 1 : end);
-%! assert (x1, x0, 1e-6)
+%! assert (x1, x0, 1e-6);
+
--- a/scripts/sparse/spconvert.m
+++ b/scripts/sparse/spconvert.m
@@ -65,3 +65,4 @@
 %!error spconvert ([1 2])
 %!error spconvert ([1 2 3i])
 %!error spconvert ([1 2 3 4 5])
+
--- a/scripts/sparse/spdiags.m
+++ b/scripts/sparse/spdiags.m
@@ -79,16 +79,15 @@
     ## Create new matrix of size mxn using v,c
     [j, i, v] = find (v);
     offset = max (min (c(:), n-m), 0);
-    j = j + offset(i);
-    i = j-c(:)(i);
+    j = j(:) + offset(i(:));
+    i = j - c(:)(i(:));
     idx = i > 0 & i <= m & j > 0 & j <= n;
     A = sparse (i(idx), j(idx), v(idx), m, n);
   endif
 
 endfunction
 
-%!test
-%assert(spdiags(zeros(1,0),1,1,1),0)
 
-%!test
-%assert(spdiags(zeros(0,1),1,1,1),0)
+%!assert (spdiags (zeros (1,0),1,1,1), sparse (0))
+%!assert (spdiags (zeros (0,1),1,1,1), sparse (0))
+%!assert (spdiags ([0.5 -1 0.5], 0:2, 1, 1), sparse(0.5))
--- a/scripts/sparse/speye.m
+++ b/scripts/sparse/speye.m
@@ -32,7 +32,7 @@
 
 function s = speye (m, n)
   if (nargin == 1)
-    if (isvector (m) && length(m) == 2)
+    if (isvector (m) && length (m) == 2)
       n = m(2);
       m = m(1);
     elseif (isscalar (m))
@@ -50,8 +50,10 @@
   s = sparse (1:lo, 1:lo, 1, m, n);
 endfunction
 
-%!assert(issparse(speye(4)))
-%!assert(speye(4),sparse(1:4,1:4,1))
-%!assert(speye(2,4),sparse(1:2,1:2,1,2,4))
-%!assert(speye(4,2),sparse(1:2,1:2,1,4,2))
-%!assert(speye([4,2]),sparse(1:2,1:2,1,4,2))
+
+%!assert (issparse (speye (4)))
+%!assert (speye (4), sparse (1:4,1:4,1))
+%!assert (speye (2,4), sparse (1:2,1:2,1,2,4))
+%!assert (speye (4,2), sparse (1:2,1:2,1,4,2))
+%!assert (speye ([4,2]), sparse (1:2,1:2,1,4,2))
+
--- a/scripts/sparse/spfun.m
+++ b/scripts/sparse/spfun.m
@@ -37,13 +37,14 @@
   if (isa (f, "function_handle") || isa (f, "inline function"))
     y = sparse (i, j, f(v), m, n);
   else
-    y = sparse(i, j, feval (f, v), m, n);
+    y = sparse (i, j, feval (f, v), m, n);
   endif
 
 endfunction
 
-%!assert(spfun('exp',[1,2;3,0]),sparse([exp(1),exp(2);exp(3),0]))
-%!assert(spfun('exp',sparse([1,2;3,0])),sparse([exp(1),exp(2);exp(3),0]))
-%!assert(spfun(@exp,[1,2;3,0]),sparse([exp(1),exp(2);exp(3),0]))
-%!assert(spfun(@exp,sparse([1,2;3,0])),sparse([exp(1),exp(2);exp(3),0]))
 
+%!assert (spfun ("exp", [1,2;3,0]), sparse ([exp(1),exp(2);exp(3),0]))
+%!assert (spfun ("exp", sparse ([1,2;3,0])), sparse ([exp(1),exp(2);exp(3),0]))
+%!assert (spfun (@exp, [1,2;3,0]), sparse ([exp(1),exp(2);exp(3),0]))
+%!assert (spfun (@exp, sparse ([1,2;3,0])), sparse ([exp(1),exp(2);exp(3),0]))
+
--- a/scripts/sparse/spones.m
+++ b/scripts/sparse/spones.m
@@ -35,6 +35,8 @@
 
 endfunction
 
-%!assert(issparse(spones([1,2;3,0])))
-%!assert(spones([1,2;3,0]),sparse([1,1;1,0]))
-%!assert(spones(sparse([1,2;3,0])),sparse([1,1;1,0]))
+
+%!assert (issparse (spones ([1,2;3,0])))
+%!assert (spones ([1,2;3,0]), sparse ([1,1;1,0]))
+%!assert (spones (sparse ([1,2;3,0])), sparse ([1,1;1,0]))
+
--- a/scripts/sparse/sprand.m
+++ b/scripts/sparse/sprand.m
@@ -54,6 +54,7 @@
 
 endfunction
 
+
 %!test
 %! s = sprand (4, 10, 0.1);
 %! assert (size (s), [4, 10]);
@@ -71,10 +72,10 @@
 %!error sprand ()
 %!error sprand (1, 2)
 %!error sprand (1, 2, 3, 4)
-%!error sprand (ones(3), 3, 0.5)
+%!error sprand (ones (3), 3, 0.5)
 %!error sprand (3.5, 3, 0.5)
 %!error sprand (0, 3, 0.5)
-%!error sprand (3, ones(3), 0.5)
+%!error sprand (3, ones (3), 0.5)
 %!error sprand (3, 3.5, 0.5)
 %!error sprand (3, 0, 0.5)
 %!error sprand (3, 3, -1)
--- a/scripts/sparse/sprandn.m
+++ b/scripts/sparse/sprandn.m
@@ -24,7 +24,7 @@
 ## @deftypefnx {Function File} {} sprandn (@var{s})
 ## Generate a random sparse matrix.  The size of the matrix will be
 ## @var{m} by @var{n}, with a density of values given by @var{d}.
-## @var{d} should be between 0 and 1. Values will be normally
+## @var{d} should be between 0 and 1.  Values will be normally
 ## distributed with mean of zero and variance 1.
 ##
 ## If called with a single matrix argument, a random sparse matrix is
@@ -63,10 +63,10 @@
 %!error sprandn ()
 %!error sprandn (1, 2)
 %!error sprandn (1, 2, 3, 4)
-%!error sprandn (ones(3), 3, 0.5)
+%!error sprandn (ones (3), 3, 0.5)
 %!error sprandn (3.5, 3, 0.5)
 %!error sprandn (0, 3, 0.5)
-%!error sprandn (3, ones(3), 0.5)
+%!error sprandn (3, ones (3), 0.5)
 %!error sprandn (3, 3.5, 0.5)
 %!error sprandn (3, 0, 0.5)
 %!error sprandn (3, 3, -1)
--- a/scripts/sparse/sprandsym.m
+++ b/scripts/sparse/sprandsym.m
@@ -22,7 +22,7 @@
 ## @deftypefnx {Function File} {} sprandsym (@var{s})
 ## Generate a symmetric random sparse matrix.  The size of the matrix will be
 ## @var{n} by @var{n}, with a density of values given by @var{d}.
-## @var{d} should be between 0 and 1. Values will be normally
+## @var{d} should be between 0 and 1.  Values will be normally
 ## distributed with mean of zero and variance 1.
 ##
 ## If called with a single matrix argument, a random sparse matrix is
@@ -119,7 +119,7 @@
   ## numerically to avoid overflow.
 
   ## Degenerate case
-  if k == 1
+  if (k == 1)
     r = 1;
     return
   endif
@@ -151,6 +151,7 @@
 
 endfunction
 
+
 %!test
 %! s = sprandsym (10, 0.1);
 %! assert (issparse (s));
@@ -168,7 +169,7 @@
 %% Test input validation
 %!error sprandsym ()
 %!error sprandsym (1, 2, 3)
-%!error sprandsym (ones(3), 0.5)
+%!error sprandsym (ones (3), 0.5)
 %!error sprandsym (3.5, 0.5)
 %!error sprandsym (0, 0.5)
 %!error sprandsym (3, -1)
--- a/scripts/sparse/spstats.m
+++ b/scripts/sparse/spstats.m
@@ -51,7 +51,7 @@
   endif
   if (nargout > 2)
     ## FIXME Variance with count = 0 or 1?
-    diff = S - sparse (i, j, mean(j), n, m);
+    diff = S - sparse (i, j, mean (j), n, m);
     var = sum (diff .* diff) ./ (count - 1);
   endif
 
@@ -59,7 +59,8 @@
 
 
 %!test
-%! [n,m,v] = spstats([1 2 1 2 3 4],[2 2 1 1 1 1]);
-%! assert(n,sparse([4,2]));
-%! assert(m,sparse([10/4,3/2]),10*eps);
-%! assert(v,sparse([5/3,1/2]),10*eps);
+%! [n,m,v] = spstats ([1 2 1 2 3 4],[2 2 1 1 1 1]);
+%! assert (n, sparse ([4,2]));
+%! assert (m, sparse ([10/4,3/2]), 10*eps);
+%! assert (v, sparse ([5/3,1/2]), 10*eps);
+
--- a/scripts/sparse/spy.m
+++ b/scripts/sparse/spy.m
@@ -72,4 +72,5 @@
 %! spy (sprand (10,10, 0.2));
 
 %% Mark graphical function as tested by demo block
-%!assert (1);
+%!assert (1)
+
--- a/scripts/sparse/svds.m
+++ b/scripts/sparse/svds.m
@@ -85,7 +85,7 @@
 ## @end example
 ##
 ## @code{svds} is best for finding only a few singular values from a large
-## sparse matrix.  Otherwise, @code{svd (full(@var{A}))} will likely be more
+## sparse matrix.  Otherwise, @code{svd (full (@var{A}))} will likely be more
 ## efficient.
 ## @end deftypefn
 ## @seealso{svd, eigs}
@@ -98,7 +98,7 @@
     print_usage ();
   endif
 
-  if (ndims(A) > 2)
+  if (ndims (A) > 2)
     error ("svds: A must be a 2D matrix");
   endif
 
@@ -194,7 +194,7 @@
     ## norm since if we don't we might end up with too many singular
     ## values.
     tol = norma * opts.tol;
-    ind = find(s > tol);
+    ind = find (s > tol);
     if (length (ind) < k)
       ## Too few eigenvalues returned.  Add in any zero eigenvalues of B,
       ## including the nominally negative ones.
@@ -241,13 +241,14 @@
 
 endfunction
 
+
 %!shared n, k, A, u, s, v, opts, rand_state, randn_state
 %! n = 100;
 %! k = 7;
 %! A = sparse ([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),0.4*n*ones(1,n),ones(1,n-2)]);
 %! [u,s,v] = svd (full (A));
 %! s = diag (s);
-%! [~, idx] = sort (abs(s));
+%! [~, idx] = sort (abs (s));
 %! s = s(idx);
 %! u = u(:, idx);
 %! v = v(:, idx);
@@ -271,7 +272,7 @@
 %! assert (s2, s(k:-1:1), 1e-10);
 %!
 %!testif HAVE_ARPACK, HAVE_UMFPACK
-%! idx = floor(n/2);
+%! idx = floor (n/2);
 %! % Don't put sigma right on a singular value or there are convergence issues
 %! sigma = 0.99*s(idx) + 0.01*s(idx+1);
 %! [u2,s2,v2,flag] = svds (A,k,sigma,opts);
--- a/scripts/sparse/treelayout.m
+++ b/scripts/sparse/treelayout.m
@@ -141,7 +141,7 @@
 
       ## We are in top level separator when we have one child and the
       ## flag is 1
-      if (columns(idx) == 1 && top_level == 1)
+      if (columns (idx) == 1 && top_level == 1)
         s++;
       else
         # We aren't in top level separator now.
@@ -152,7 +152,7 @@
        left_most++;
        x_coordinate_r(par_number) = left_most;
        max_ht = min (max_ht, level);
-       if (length(stk) > 1 && find ((shift(stk,1)-stk) == 0) > 1
+       if (length (stk) > 1 && find ((shift (stk,1) - stk) == 0) > 1
            && stk(end,2) != stk(end-1,2))
           ## Return to the nearest branching the position to return
           ## position is the position on the stack, where should be
@@ -202,6 +202,7 @@
   endif
 endfunction
 
+
 %!test
 %! % Compute a simple tree layout
 %! [x, y, h, s] = treelayout ([0, 1, 2, 2]);
@@ -225,3 +226,4 @@
 %! assert (y, [0, 0, 0, 3]);
 %! assert (h, 0);
 %! assert (s, 1);
+
--- a/scripts/sparse/treeplot.m
+++ b/scripts/sparse/treeplot.m
@@ -116,13 +116,13 @@
       left_most++;
       x_coordinate_r(par_number) = left_most;
       max_ht = min (max_ht, level);
-      if (length(stk) > 1 && find ((shift(stk,1)-stk) == 0) > 1
+      if (length (stk) > 1 && find ((shift (stk,1) - stk) == 0) > 1
           && stk(end,2) != stk(end-1,2))
         ## Return to the nearest branching the position to return
         ## position is the position on the stack, where should be
         ## started further search (there are two nodes which has the
         ## same parent node).
-        position = (find ((shift(stk(:,2),1)-stk(:,2)) == 0))(end) + 1;
+        position = (find ((shift (stk(:,2),1) - stk(:,2)) == 0))(end) + 1;
         par_number_vec = stk(position:end,2);
         ## The vector of removed nodes (the content of stack form
         ## position to end).
@@ -173,7 +173,7 @@
 
     hold ("on");
     ## Plot each tree component in one loop.
-    for i = 2:length(idx)
+    for i = 2:length (idx)
       ## Tree component start.
       istart = idx(i-1) + 1;
       ## Tree component end.
@@ -196,10 +196,14 @@
 
 endfunction
 
-%!demo
-%! % Plot a simple tree plot
-%! treeplot([2 4 2 0 6 4 6])
 
 %!demo
+%! clf;
+%! treeplot ([2 4 2 0 6 4 6]);
+%! % Plot a simple tree plot
+
+%!demo
+%! clf;
+%! treeplot ([2 4 2 0 6 4 6], "b+", "g");
 %! % Plot a simple tree plot defining the edge and node styles
-%! treeplot([2 4 2 0 6 4 6], "b+", "g")
+
--- a/scripts/specfun/bessel.m
+++ b/scripts/specfun/bessel.m
@@ -27,21 +27,21 @@
 ## @table @code
 ## @item besselj
 ## Bessel functions of the first kind.  If the argument @var{opt} is supplied,
-## the result is multiplied by @code{exp(-abs(imag(x)))}.
+## the result is multiplied by @code{exp (-abs (imag (x)))}.
 ##
 ## @item bessely
 ## Bessel functions of the second kind.  If the argument @var{opt} is supplied,
-## the result is multiplied by @code{exp(-abs(imag(x)))}.
+## the result is multiplied by @code{exp (-abs (imag (x)))}.
 ##
 ## @item besseli
 ## Modified Bessel functions of the first kind.  If the argument @var{opt} is
 ## supplied,
-## the result is multiplied by @code{exp(-abs(real(x)))}.
+## the result is multiplied by @code{exp (-abs (real (x)))}.
 ##
 ## @item besselk
 ## Modified Bessel functions of the second kind.  If the argument @var{opt} is
 ## supplied,
-## the result is multiplied by @code{exp(x)}.
+## the result is multiplied by @code{exp (x)}.
 ##
 ## @item besselh
 ## Compute Hankel functions of the first (@var{k} = 1) or second (@var{k}
@@ -91,4 +91,5 @@
   error ("bessel: you must use besselj, bessely, besseli, or besselk");
 endfunction
 
+
 %!error bessel ()
--- a/scripts/specfun/beta.m
+++ b/scripts/specfun/beta.m
@@ -31,6 +31,7 @@
 ## @end example
 ##
 ## @end ifnottex
+## @seealso{betaln, betainc}
 ## @end deftypefn
 
 ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
@@ -55,28 +56,30 @@
 
 endfunction
 
+
 %!test
-%! a=[1, 1.5, 2, 3];
-%! b=[4, 3, 2, 1];
-%! v1=beta(a,b);
-%! v2=beta(b,a);
-%! v3=gamma(a).*gamma(b)./gamma(a+b);
-%! assert(all(abs(v1-v2)<sqrt(eps)) && all(abs(v2-v3)<sqrt(eps)));
+%! a = [1, 1.5, 2, 3];
+%! b = [4, 3, 2, 1];
+%! v1 = beta (a,b);
+%! v2 = beta (b,a);
+%! v3 = gamma (a).*gamma (b) ./ gamma (a+b);
+%! assert (v1, v2, sqrt (eps));
+%! assert (v2, v3, sqrt (eps));
 
-%!error beta();
-
-%!error beta(1);
-
-%!assert (1, beta (1, 1))
+%!assert (beta (1, 1), 1)
 
 %!test
 %! a = 2:10;
 %! tol = 10 * max (a) * eps;
-%! assert (-a, beta (-1./a, 1), tol)
-%! assert (-a, beta (1, -1./a), tol)
+%! assert (-a, beta (-1./a, 1), tol);
+%! assert (-a, beta (1, -1./a), tol);
 
 %!test
 %! a = 0.25 + (0:5) * 0.5;
 %! tol = 10 * max (a) * eps;
-%! assert (zeros (size (a)), beta (a, -a), tol)
-%! assert (zeros (size (a)), beta (-a, a), tol)
+%! assert (zeros (size (a)), beta (a, -a), tol);
+%! assert (zeros (size (a)), beta (-a, a), tol);
+
+%!error beta ()
+%!error beta (1)
+
--- a/scripts/specfun/betaln.m
+++ b/scripts/specfun/betaln.m
@@ -50,7 +50,7 @@
 endfunction
 
 
-%!assert (betaln (3,4), log (beta(3,4)),eps);
+%!assert (betaln (3,4), log (beta (3,4)), eps)
 
 %% Test input validation
 %!error (betaln (1))
--- a/scripts/specfun/factor.m
+++ b/scripts/specfun/factor.m
@@ -76,20 +76,21 @@
   ## Determine muliplicity.
   if (nargout > 1)
     idx = find ([0, x] != [x, 0]);
-    x = x(idx(1:length(idx)-1));
+    x = x(idx(1:length (idx)-1));
     n = diff (idx);
   endif
 
 endfunction
 
+
+%!assert (factor (1), 1)
 %!test
-%!  assert(factor(1),1);
-%!  for i=2:20
-%!     p = factor(i);
-%!     assert(prod(p),i);
-%!     assert(all(isprime(p)));
-%!     [p,n] = factor(i);
-%!     assert(prod(p.^n),i);
-%!     assert(all([0,p]!=[p,0]));
-%!  endfor
+%! for i = 2:20
+%!   p = factor (i);
+%!   assert (prod (p), i);
+%!   assert (all (isprime (p)));
+%!   [p,n] = factor (i);
+%!   assert (prod (p.^n), i);
+%!   assert (all ([0,p] != [p,0]));
+%! endfor
 
--- a/scripts/specfun/factorial.m
+++ b/scripts/specfun/factorial.m
@@ -35,8 +35,11 @@
   x = round (gamma (n+1));
 endfunction
 
-%!assert (factorial(5), prod(1:5))
-%!assert (factorial([1,2;3,4]), [1,2;6,24])
-%!assert (factorial(70), exp(sum(log(1:70))), -128*eps)
-%!fail ('factorial(5.5)', "must all be non-negative integers")
-%!fail ('factorial(-3)', "must all be non-negative integers")
+
+%!assert (factorial (5), prod (1:5))
+%!assert (factorial ([1,2;3,4]), [1,2;6,24])
+%!assert (factorial (70), exp (sum (log (1:70))), -128*eps)
+
+%!fail ("factorial (5.5)", "must all be non-negative integers")
+%!fail ("factorial (-3)", "must all be non-negative integers")
+
--- a/scripts/specfun/isprime.m
+++ b/scripts/specfun/isprime.m
@@ -80,8 +80,10 @@
 endfunction
 
 
-%!assert (isprime (4), logical (0));
-%!assert (isprime (3), logical (1));
-%!assert (isprime (magic (3)), logical ([0, 0, 0; 1, 1, 1; 0, 0, 1]));
+%!assert (isprime (3), true)
+%!assert (isprime (4), false)
+%!assert (isprime (magic (3)), logical ([0, 0, 0; 1, 1, 1; 0, 0, 1]))
+
 %!error isprime ()
 %!error isprime (1, 2)
+
--- a/scripts/specfun/lcm.m
+++ b/scripts/specfun/lcm.m
@@ -51,11 +51,11 @@
 
 endfunction
 
-%!assert(lcm (3, 5, 7, 15) == 105);
+
+%!assert (lcm (3, 5, 7, 15), 105)
 
 %!error lcm ();
-
 %!test
 %! s.a = 1;
-%! fail("lcm (s)");
+%! fail ("lcm (s)");
 
--- a/scripts/specfun/legendre.m
+++ b/scripts/specfun/legendre.m
@@ -196,7 +196,7 @@
   ## http://en.wikipedia.org/wiki/Associated_Legendre_function
 
   overflow = false;
-  retval = zeros([n+1, size(x)]);
+  retval = zeros ([n+1, size(x)]);
   for m = 1:n
     lpm1 = scale;
     lpm2 = (2*m-1) .* x .* scale;
@@ -222,7 +222,7 @@
       ## normalization == "sch" or normalization == "norm"
       scale = scale / sqrt ((n-m+1)*(n+m))*(2*m-1);
     endif
-    scale = scale .* sqrt(1-x.^2);
+    scale = scale .* sqrt (1-x.^2);
   endfor
 
   retval(n+1,:) = scale(:);
@@ -286,7 +286,7 @@
 
 %!test
 %! result = legendre (0, 0:0.1:1);
-%! assert (result, full(ones(1,11)));
+%! assert (result, full (ones (1,11)));
 
 %!test
 %! result = legendre (3, [-1,0,1;1,0,-1]);
@@ -303,13 +303,14 @@
 %! assert (result, expected);
 
 %% Check correct invocation
-%!error legendre ();
-%!error legendre (1);
-%!error legendre (1,2,3,4);
-%!error legendre ([1, 2], [-1, 0, 1]);
-%!error legendre (-1, [-1, 0, 1]);
-%!error legendre (1.1, [-1, 0, 1]);
-%!error legendre (1, [-1+i, 0, 1]);
-%!error legendre (1, [-2, 0, 1]);
-%!error legendre (1, [-1, 0, 2]);
-%!error legendre (1, [-1, 0, 1], "badnorm");
+%!error legendre ()
+%!error legendre (1)
+%!error legendre (1,2,3,4)
+%!error legendre ([1, 2], [-1, 0, 1])
+%!error legendre (-1, [-1, 0, 1])
+%!error legendre (1.1, [-1, 0, 1])
+%!error legendre (1, [-1+i, 0, 1])
+%!error legendre (1, [-2, 0, 1])
+%!error legendre (1, [-1, 0, 2])
+%!error legendre (1, [-1, 0, 1], "badnorm")
+
--- a/scripts/specfun/nchoosek.m
+++ b/scripts/specfun/nchoosek.m
@@ -141,7 +141,7 @@
 
 
 %!assert (nchoosek (80,10), bincoeff (80,10))
-%!assert (nchoosek(1:5,3), [1:3;1,2,4;1,2,5;1,3,4;1,3,5;1,4,5;2:4;2,3,5;2,4,5;3:5])
+%!assert (nchoosek (1:5,3), [1:3;1,2,4;1,2,5;1,3,4;1,3,5;1,4,5;2:4;2,3,5;2,4,5;3:5])
 
 %% Test input validation
 %!warning nchoosek (100,45);
--- a/scripts/specfun/nthroot.m
+++ b/scripts/specfun/nthroot.m
@@ -81,11 +81,12 @@
 
 endfunction
 
-%!assert (nthroot(-32,5), -2);
-%!assert (nthroot(81,4), 3);
-%!assert (nthroot(Inf,4), Inf);
-%!assert (nthroot(-Inf,7), -Inf);
-%!assert (nthroot(-Inf,-7), 0);
+
+%!assert (nthroot (-32,5), -2);
+%!assert (nthroot (81,4), 3);
+%!assert (nthroot (Inf,4), Inf);
+%!assert (nthroot (-Inf,7), -Inf);
+%!assert (nthroot (-Inf,-7), 0);
 
 %% Test input validation
 %!error (nthroot ())
--- a/scripts/specfun/perms.m
+++ b/scripts/specfun/perms.m
@@ -24,7 +24,7 @@
 ## result has size @code{factorial (@var{n}) * @var{n}}, where @var{n}
 ## is the length of @var{v}.
 ##
-## As an example, @code{perms([1, 2, 3])} returns the matrix
+## As an example, @code{perms ([1, 2, 3])} returns the matrix
 ##
 ## @example
 ## @group
@@ -52,7 +52,7 @@
     for j = 2:n
       B = A;
       A = zeros (prod (2:j), n, class (v));
-      k = size (B, 1);
+      k = rows (B);
       idx = 1:k;
       for i = j:-1:1
         A(idx,1:i-1) = B(:,1:i-1);
@@ -64,10 +64,11 @@
   endif
 endfunction
 
-%!error perms ();
-%!error perms (1, 2);
 
-%!assert (perms ([1,2,3]), [1,2,3;2,1,3;1,3,2;2,3,1;3,1,2;3,2,1]);
-%!assert (perms (1:3), perms ([1,2,3]));
+%!assert (perms ([1,2,3]), [1,2,3;2,1,3;1,3,2;2,3,1;3,1,2;3,2,1])
+%!assert (perms (1:3), perms ([1,2,3]))
+%!assert (perms (int8 ([1,2,3])), int8 ([1,2,3;2,1,3;1,3,2;2,3,1;3,1,2;3,2,1]))
 
-%!assert (perms (int8([1,2,3])), int8([1,2,3;2,1,3;1,3,2;2,3,1;3,1,2;3,2,1]));
+%!error perms ()
+%!error perms (1, 2)
+
--- a/scripts/specfun/pow2.m
+++ b/scripts/specfun/pow2.m
@@ -54,16 +54,17 @@
 
 endfunction
 
+
 %!test
 %! x = [3, 0, -3];
 %! v = [8, 1, .125];
-%! assert(all (abs (pow2 (x) - v) < sqrt (eps)));
+%! assert (pow2 (x), v, sqrt (eps));
 
 %!test
 %! x = [3, 0, -3, 4, 0, -4, 5, 0, -5];
 %! y = [-2, -2, -2, 1, 1, 1, 3, 3, 3];
 %! z = x .* (2 .^ y);
-%! assert(all (abs (pow2 (x,y) - z) < sqrt (eps)));
+%! assert (pow2 (x,y), z, sqrt (eps));
 
-%!error pow2();
+%!error pow2 ()
 
--- a/scripts/specfun/primes.m
+++ b/scripts/specfun/primes.m
@@ -31,7 +31,7 @@
 ## $k \log (5 k)$.
 ## @end tex
 ## @ifnottex
-## k*log(5*k).
+## k*log (5*k).
 ## @end ifnottex
 ## @seealso{list_primes, isprime}
 ## @end deftypefn
@@ -61,7 +61,7 @@
     sievem = true (1, lenm);      # assume every number of form 6n-1 is prime
     sievep = true (1, lenp);      # assume every number of form 6n+1 is prime
 
-    for i = 1:(sqrt(n)+1)/6       # check up to sqrt(n)
+    for i = 1:(sqrt (n)+1)/6      # check up to sqrt (n)
       if (sievem(i))              # if i is prime, eliminate multiples of i
         sievem(7*i-1:6*i-1:lenm) = false;
         sievep(5*i-1:6*i-1:lenp) = false;
@@ -71,11 +71,11 @@
         sievem(5*i+1:6*i+1:lenm) = false;
       endif
     endfor
-    x = sort([2, 3, 6*find(sievem)-1, 6*find(sievep)+1]);
+    x = sort ([2, 3, 6*find(sievem)-1, 6*find(sievep)+1]);
   elseif (n > 352)                # nothing magical about 352; must be >2
     len = floor ((n-1)/2);        # length of the sieve
     sieve = true (1, len);        # assume every odd number is prime
-    for i = 1:(sqrt(n)-1)/2       # check up to sqrt(n)
+    for i = 1:(sqrt (n)-1)/2      # check up to sqrt (n)
       if (sieve(i))               # if i is prime, eliminate multiples of i
         sieve(3*i+1:2*i+1:len) = false; # do it
       endif
@@ -93,10 +93,10 @@
 
 endfunction
 
-%!error primes ();
-%!error primes (1, 2);
+
+%!assert (size (primes (350)), [1, 70])
+%!assert (primes (357)(end), 353)
 
-%!assert (size (primes (350)), [1, 70]);
-%!assert (size (primes (350)), [1, 70]);
+%!error primes ()
+%!error primes (1, 2)
 
-%!assert (primes (357)(end), 353);
--- a/scripts/specfun/reallog.m
+++ b/scripts/specfun/reallog.m
@@ -33,8 +33,11 @@
   endif
 endfunction
 
-%!assert (log(1:5),reallog(1:5))
+
+%!assert (log (1:5), reallog (1:5))
 %!test
 %! x = rand (10,10);
-%! assert (log(x),reallog(x))
-%!error (reallog(-1))
+%! assert (log (x),reallog (x));
+
+%!error <produced complex result> reallog (-1)
+
--- a/scripts/specfun/realpow.m
+++ b/scripts/specfun/realpow.m
@@ -35,11 +35,14 @@
   endif
 endfunction
 
+
 %!assert (power (1:10, 0.5:0.5:5), realpow (1:10, 0.5:0.5:5))
 %!assert ([1:10] .^ [0.5:0.5:5], realpow (1:10, 0.5:0.5:5))
 %!test
 %! x = rand (10,10);
 %! y = randn (10,10);
-%! assert (x.^y,realpow(x,y))
-%!assert (realpow(1i,2),-1)
-%!error (realpow(-1, 1/2))
+%! assert (x.^y, realpow (x,y));
+%!assert (realpow (1i,2), -1)
+
+%!error <produced complex result> realpow (-1, 1/2)
+
--- a/scripts/specfun/realsqrt.m
+++ b/scripts/specfun/realsqrt.m
@@ -33,8 +33,11 @@
   endif
 endfunction
 
-%!assert (sqrt(1:5),realsqrt(1:5))
+
+%!assert (sqrt (1:5), realsqrt (1:5))
 %!test
 %! x = rand (10,10);
-%! assert (sqrt(x),realsqrt(x))
-%!error (realsqrt(-1))
+%! assert (sqrt (x), realsqrt (x));
+
+%!error <produced complex result> realsqrt (-1)
+
--- a/scripts/special-matrix/hadamard.m
+++ b/scripts/special-matrix/hadamard.m
@@ -165,7 +165,7 @@
 %!assert (hadamard (2), [1,1;1,-1])
 %!test
 %! for n = [1,2,4,8,12,24,48,20,28,2^9]
-%!   h = hadamard(n);
+%!   h = hadamard (n);
 %!   assert (norm (h*h' - n*eye (n)), 0);
 %! endfor
 
--- a/scripts/special-matrix/hankel.m
+++ b/scripts/special-matrix/hankel.m
@@ -91,8 +91,8 @@
 %!assert (hankel (1:3,3:4), [1,2;2,3;3,4])
 %!assert (hankel (1:3,4:6), [1,2,3;2,3,5;3,5,6])
 
-%!error hankel ();
-%!error hankel (1, 2, 3);
+%!error hankel ()
+%!error hankel (1, 2, 3)
 %!error <C must be a vector> hankel ([1, 2; 3, 4])
 %!error <C and R must be vectors> hankel (1:4, [1, 2; 3, 4])
 
--- a/scripts/special-matrix/hilb.m
+++ b/scripts/special-matrix/hilb.m
@@ -75,5 +75,5 @@
 
 %!error hilb ()
 %!error hilb (1, 2)
-%!error <N must be a scalar integer> hilb (ones(2))
+%!error <N must be a scalar integer> hilb (ones (2))
 
--- a/scripts/special-matrix/invhilb.m
+++ b/scripts/special-matrix/invhilb.m
@@ -120,7 +120,7 @@
 %!            240 , -2700, 6480 , -4200;
 %!            -140, 1680 , -4200, 2800];
 %! assert (invhilb (4), result4);
-%!assert (abs (invhilb (7) * hilb (7) - eye (7)) < sqrt (eps))
+%!assert (invhilb (7) * hilb (7), eye (7), sqrt (eps))
 
 %!error invhilb ()
 %!error invhilb (1, 2)
--- a/scripts/special-matrix/magic.m
+++ b/scripts/special-matrix/magic.m
@@ -26,7 +26,7 @@
 ## Note: @var{n} must be greater than 2 for the magic square to exist.
 ## @end deftypefn
 
-function A = magic(n)
+function A = magic (n)
 
   if (nargin != 1)
     print_usage ();
@@ -80,13 +80,13 @@
 
 
 %!test
-%! for i=3:30
+%! for i = 3:30
 %!   A = magic (i);
 %!   assert (norm(diff([sum(diag(A)),sum(diag(flipud(A))),sum(A),sum(A')])),0);
 %! endfor
 
 %!assert (isempty (magic (0)))
-%!assert (magic(1), 1)
+%!assert (magic (1), 1)
 
 %% Test input validation
 %!error magic ()
--- a/scripts/special-matrix/rosser.m
+++ b/scripts/special-matrix/rosser.m
@@ -44,5 +44,9 @@
 
 endfunction
 
-%!assert (size(rosser()), [8,8])
-%!error (rosser(1))
+
+%!assert (size (rosser ()), [8,8])
+%!assert (rosser ()([1, end]), [611, 99])
+
+%!error (rosser (1))
+
--- a/scripts/special-matrix/toeplitz.m
+++ b/scripts/special-matrix/toeplitz.m
@@ -105,8 +105,8 @@
     ridx = ridx(ridx > 1);
 
     ## Form matrix.
-    retval = spdiags(repmat (c(cidx),nr,1),1-cidx,nr,nc) + ...
-             spdiags(repmat (r(ridx),nr,1),ridx-1,nr,nc);
+    retval = spdiags (repmat (c(cidx),nr,1),1-cidx,nr,nc) + ...
+             spdiags (repmat (r(ridx),nr,1),ridx-1,nr,nc);
   else
     ## Concatenate data into a single column vector.
     data = [r(end:-1:2)(:); c(:)];
--- a/scripts/special-matrix/vander.m
+++ b/scripts/special-matrix/vander.m
@@ -79,17 +79,17 @@
 %!test
 %! c = [0,1,2,3];
 %! expect = [0,0,0,1; 1,1,1,1; 8,4,2,1; 27,9,3,1];
-%! assert(vander (c), expect);
+%! assert (vander (c), expect);
 
 %!assert (vander (1), 1)
 %!assert (vander ([1, 2, 3]), vander ([1; 2; 3]))
 %!assert (vander ([1, 2, 3]), [1, 1, 1; 4, 2, 1; 9, 3, 1])
 %!assert (vander ([1, 2, 3]*i), [-1, i, 1; -4, 2i, 1; -9, 3i, 1])
 
-%!assert(vander (2, 3), [4, 2, 1])
-%!assert(vander ([2, 3], 3), [4, 2, 1; 9, 3, 1])
+%!assert (vander (2, 3), [4, 2, 1])
+%!assert (vander ([2, 3], 3), [4, 2, 1; 9, 3, 1])
 
-%!error vander ();
-%!error vander (1, 2, 3);
-%!error <polynomial C must be a vector> vander ([1, 2; 3, 4]);
+%!error vander ()
+%!error vander (1, 2, 3)
+%!error <polynomial C must be a vector> vander ([1, 2; 3, 4])
 
--- a/scripts/startup/__finish__.m
+++ b/scripts/startup/__finish__.m
@@ -23,9 +23,9 @@
 
 ## Check for the existence of the function/script, @file{finish}, in the
 ## path or current working directory and execute it.  This function is
-## intended to be excecuted upon a clean exit form Octave.  This is
+## intended to be excecuted upon a clean exit from Octave.  This is
 ## accomplished in the system script @file{startup/octaverc} by use of
-## the built-in function @code{onexit}.
+## the built-in function @code{atexit}.
 
 function __finish__ ()
 
@@ -36,5 +36,7 @@
 
 endfunction
 
+
+
 ## No test needed for internal helper function.
 %!assert (1)
--- a/scripts/statistics/base/center.m
+++ b/scripts/statistics/base/center.m
@@ -65,19 +65,21 @@
 
 endfunction
 
-%!assert(center ([1,2,3]), [-1,0,1])
-%!assert(center (single([1,2,3])), single([-1,0,1]))
-%!assert(center (int8 ([1,2,3])), [-1,0,1])
-%!assert(center (logical ([1, 0, 0, 1])), [0.5, -0.5, -0.5, 0.5])
-%!assert(center (ones (3,2,0,2)), zeros (3,2,0,2))
-%!assert(center (ones (3,2,0,2, 'single')), zeros (3,2,0,2, 'single'))
-%!assert(center (magic (3)), [3,-4,1;-2,0,2;-1,4,-3])
-%!assert(center ([1 2 3; 6 5 4], 2), [-1 0 1; 1 0 -1])
+
+%!assert (center ([1,2,3]), [-1,0,1])
+%!assert (center (single ([1,2,3])), single ([-1,0,1]))
+%!assert (center (int8 ([1,2,3])), [-1,0,1])
+%!assert (center (logical ([1, 0, 0, 1])), [0.5, -0.5, -0.5, 0.5])
+%!assert (center (ones (3,2,0,2)), zeros (3,2,0,2))
+%!assert (center (ones (3,2,0,2, "single")), zeros (3,2,0,2, "single"))
+%!assert (center (magic (3)), [3,-4,1;-2,0,2;-1,4,-3])
+%!assert (center ([1 2 3; 6 5 4], 2), [-1 0 1; 1 0 -1])
 
 %% Test input validation
 %!error center ()
 %!error center (1, 2, 3)
-%!error center (1, ones(2,2))
+%!error center (1, ones (2,2))
 %!error center (1, 1.5)
 %!error center (1, 0)
 %!error center (1, 3)
+
--- a/scripts/statistics/base/cloglog.m
+++ b/scripts/statistics/base/cloglog.m
@@ -46,10 +46,12 @@
 
 endfunction
 
-%!assert(cloglog(0), -Inf)
-%!assert(cloglog(1), Inf)
-%!assert(cloglog(1/e), 0)
+
+%!assert (cloglog (0), -Inf)
+%!assert (cloglog (1), Inf)
+%!assert (cloglog (1/e), 0)
 
 %% Test input validation
 %!error cloglog ()
 %!error cloglog (1, 2)
+
--- a/scripts/statistics/base/corr.m
+++ b/scripts/statistics/base/corr.m
@@ -56,7 +56,7 @@
 
   ## Special case, scalar is always 100% correlated with itself
   if (isscalar (x))
-    if (isa (x, 'single'))
+    if (isa (x, "single"))
       retval = single (1);
     else
       retval = 1;
@@ -89,24 +89,24 @@
 %!test
 %! x = [1:3]';
 %! y = [3:-1:1]';
-%! assert (corr (x,y), -1, 5*eps)
-%! assert (corr (x,flipud (y)), 1, 5*eps)
-%! assert (corr ([x, y]), [1 -1; -1 1], 5*eps)
+%! assert (corr (x, y), -1, 5*eps);
+%! assert (corr (x, flipud (y)), 1, 5*eps);
+%! assert (corr ([x, y]), [1 -1; -1 1], 5*eps);
 
 %!test
 %! x = single ([1:3]');
 %! y = single ([3:-1:1]');
-%! assert (corr (x,y), single (-1), 5*eps)
-%! assert (corr (x,flipud (y)), single (1), 5*eps)
-%! assert (corr ([x, y]), single ([1 -1; -1 1]), 5*eps)
+%! assert (corr (x, y), single (-1), 5*eps);
+%! assert (corr (x, flipud (y)), single (1), 5*eps);
+%! assert (corr ([x, y]), single ([1 -1; -1 1]), 5*eps);
 
-%!assert (corr (5), 1);
-%!assert (corr (single(5)), single(1));
+%!assert (corr (5), 1)
+%!assert (corr (single (5)), single (1))
 
 %% Test input validation
-%!error corr ();
-%!error corr (1, 2, 3);
-%!error corr ([1; 2], ["A", "B"]);
-%!error corr (ones (2,2,2));
-%!error corr (ones (2,2), ones (2,2,2));
+%!error corr ()
+%!error corr (1, 2, 3)
+%!error corr ([1; 2], ["A", "B"])
+%!error corr (ones (2,2,2))
+%!error corr (ones (2,2), ones (2,2,2))
 
--- a/scripts/statistics/base/cov.m
+++ b/scripts/statistics/base/cov.m
@@ -86,7 +86,7 @@
 
   ## Special case, scalar has zero covariance
   if (isscalar (x))
-    if (isa (x, 'single'))
+    if (isa (x, "single"))
       c = single (0);
     else
       c = 0;
@@ -121,22 +121,22 @@
 %! x = rand (10);
 %! cx1 = cov (x);
 %! cx2 = cov (x, x);
-%! assert(size (cx1) == [10, 10] && size (cx2) == [10, 10]);
-%! assert(cx1, cx2, 1e1*eps);
+%! assert (size (cx1) == [10, 10] && size (cx2) == [10, 10]);
+%! assert (cx1, cx2, 1e1*eps);
 
 %!test
 %! x = [1:3]';
 %! y = [3:-1:1]';
-%! assert (cov (x,y), -1, 5*eps)
-%! assert (cov (x,flipud (y)), 1, 5*eps)
-%! assert (cov ([x, y]), [1 -1; -1 1], 5*eps)
+%! assert (cov (x, y), -1, 5*eps);
+%! assert (cov (x, flipud (y)), 1, 5*eps);
+%! assert (cov ([x, y]), [1 -1; -1 1], 5*eps);
 
 %!test
 %! x = single ([1:3]');
 %! y = single ([3:-1:1]');
-%! assert (cov (x,y), single (-1), 5*eps)
-%! assert (cov (x,flipud (y)), single (1), 5*eps)
-%! assert (cov ([x, y]), single ([1 -1; -1 1]), 5*eps)
+%! assert (cov (x, y), single (-1), 5*eps);
+%! assert (cov (x, flipud (y)), single (1), 5*eps);
+%! assert (cov ([x, y]), single ([1 -1; -1 1]), 5*eps);
 
 %!test
 %! x = [1:5];
@@ -144,22 +144,22 @@
 %! assert (isscalar (c));
 %! assert (c, 2.5);
 
-%!assert(cov (5), 0);
-%!assert(cov (single(5)), single(0));
+%!assert (cov (5), 0)
+%!assert (cov (single (5)), single (0))
 
 %!test
 %! x = [1:5];
 %! c = cov (x, 0);
-%! assert(c, 2.5);
+%! assert (c, 2.5);
 %! c = cov (x, 1);
-%! assert(c, 2);
+%! assert (c, 2);
 
 %% Test input validation
-%!error cov ();
-%!error cov (1, 2, 3, 4);
-%!error cov ([1; 2], ["A", "B"]);
-%!error cov (ones (2,2,2));
-%!error cov (ones (2,2), ones (2,2,2));
-%!error cov (1, 3);
-%!error cov (ones (2,2), ones (3,2));
+%!error cov ()
+%!error cov (1, 2, 3, 4)
+%!error cov ([1; 2], ["A", "B"])
+%!error cov (ones (2,2,2))
+%!error cov (ones (2,2), ones (2,2,2))
+%!error cov (1, 3)
+%!error cov (ones (2,2), ones (3,2))
 
--- a/scripts/statistics/base/gls.m
+++ b/scripts/statistics/base/gls.m
@@ -140,6 +140,6 @@
 %!error gls (ones (2,2,2), ones (2,2), ones (4,4))
 %!error gls (ones (2,2), ones (2,2,2), ones (4,4))
 %!error gls (ones (2,2), ones (2,2), ones (4,4,4))
-%!error gls (ones(1,2), ones(2,2), ones (2,2))
-%!error gls (ones(2,2), ones(2,2), ones (2,2))
+%!error gls (ones (1,2), ones (2,2), ones (2,2))
+%!error gls (ones (2,2), ones (2,2), ones (2,2))
 
--- a/scripts/statistics/base/histc.m
+++ b/scripts/statistics/base/histc.m
@@ -168,9 +168,10 @@
 %! n = histc (x, 0:10, 2);
 %! assert (n, repmat ([repmat(100, 1, 10), 1], [2, 1, 3]));
 
-%!error histc ();
-%!error histc (1);
-%!error histc (1, 2, 3, 4);
-%!error histc ([1:10 1+i], 2);
-%!error histc (1:10, []);
-%!error histc (1, 1, 3);
+%!error histc ()
+%!error histc (1)
+%!error histc (1, 2, 3, 4)
+%!error histc ([1:10 1+i], 2)
+%!error histc (1:10, [])
+%!error histc (1, 1, 3)
+
--- a/scripts/statistics/base/iqr.m
+++ b/scripts/statistics/base/iqr.m
@@ -60,8 +60,8 @@
   ## can take a matrix, rather than just a vector argument.
   n = sz(dim);
   sz(dim) = 1;
-  if (isa (x, 'single'))
-    y = zeros (sz, 'single');
+  if (isa (x, "single"))
+    y = zeros (sz, "single");
   else
     y = zeros (sz);
   endif
@@ -82,17 +82,17 @@
 endfunction
 
 
-%!assert (iqr (1:101), 50);
-%!assert (iqr (single(1:101)), single(50));
+%!assert (iqr (1:101), 50)
+%!assert (iqr (single (1:101)), single (50))
 
 %%!test
 %%! x = [1:100];
 %%! n = iqr (x, 0:10);
 %%! assert (n, [repmat(100, 1, 10), 1]);
 
-%!error iqr ();
-%!error iqr (1, 2, 3);
-%!error iqr (1);
-%!error iqr (['A'; 'B']);
-%!error iqr (1:10, 3);
+%!error iqr ()
+%!error iqr (1, 2, 3)
+%!error iqr (1)
+%!error iqr (['A'; 'B'])
+%!error iqr (1:10, 3)
 
--- a/scripts/statistics/base/kendall.m
+++ b/scripts/statistics/base/kendall.m
@@ -99,10 +99,10 @@
     endif
   endif
 
-  if (isa (x, 'single') || isa (y, 'single'))
-    cls = 'single';
+  if (isa (x, "single") || isa (y, "single"))
+    cls = "single";
   else
-    cls = 'double';
+    cls = "double";
   endif
   r   = ranks (x);
   m   = sign (kron (r, ones (n, 1, cls)) - kron (ones (n, 1, cls), r));
@@ -121,14 +121,15 @@
 %! assert (kendall (x,y), 1, 5*eps);
 %! assert (kendall (x,fliplr (y)), -1, 5*eps);
 
-%!assert (kendall (logical(1)), 1);
-%!assert (kendall (single(1)), single(1));
+%!assert (kendall (logical (1)), 1)
+%!assert (kendall (single (1)), single (1))
 
 %% Test input validation
-%!error kendall ();
-%!error kendall (1, 2, 3);
-%!error kendall (['A'; 'B']);
-%!error kendall (ones(2,1), ['A'; 'B']);
-%!error kendall (ones (2,2,2));
-%!error kendall (ones (2,2), ones (2,2,2));
-%!error kendall (ones (2,2), ones (3,2));
+%!error kendall ()
+%!error kendall (1, 2, 3)
+%!error kendall (['A'; 'B'])
+%!error kendall (ones (2,1), ['A'; 'B'])
+%!error kendall (ones (2,2,2))
+%!error kendall (ones (2,2), ones (2,2,2))
+%!error kendall (ones (2,2), ones (3,2))
+
--- a/scripts/statistics/base/kurtosis.m
+++ b/scripts/statistics/base/kurtosis.m
@@ -29,7 +29,11 @@
 ## @ifnottex
 ##
 ## @example
-## kurtosis (x) = 1/N std(x)^(-4) sum ((x - mean(x)).^4) - 3
+## @group
+##                 1    sum ((x - mean(x)).^4)
+## kurtosis (x) = --- * ----------------------  -  3
+##                 N           std(x)^4
+## @end group
 ## @end example
 ##
 ## @end ifnottex
@@ -87,13 +91,13 @@
 %! y = [x, 2*x];
 %! assert (kurtosis (y), [-1.4, -1.4], sqrt (eps));
 
-%!assert (kurtosis (single(1)), single(0));
+%!assert (kurtosis (single (1)), single (0))
 
 %% Test input validation
 %!error kurtosis ()
 %!error kurtosis (1, 2, 3)
 %!error kurtosis (['A'; 'B'])
-%!error kurtosis (1, ones(2,2))
+%!error kurtosis (1, ones (2,2))
 %!error kurtosis (1, 1.5)
 %!error kurtosis (1, 0)
 %!error kurtosis (1, 3)
--- a/scripts/statistics/base/logit.m
+++ b/scripts/statistics/base/logit.m
@@ -50,10 +50,11 @@
 
 %!test
 %! p = [0.01:0.01:0.99];
-%! assert(logit (p), log (p ./ (1-p)), 25*eps)
+%! assert (logit (p), log (p ./ (1-p)), 25*eps);
 
-%!assert(logit ([-1, 0, 0.5, 1, 2]), [NaN, -Inf, 0, +Inf, NaN])
+%!assert (logit ([-1, 0, 0.5, 1, 2]), [NaN, -Inf, 0, +Inf, NaN])
 
 %% Test input validation
 %!error logit ()
 %!error logit (1, 2)
+
--- a/scripts/statistics/base/mahalanobis.m
+++ b/scripts/statistics/base/mahalanobis.m
@@ -71,10 +71,11 @@
 
 
 %% Test input validation
-%!error mahalanobis ();
-%!error mahalanobis (1, 2, 3);
-%!error mahalanobis ('A', 'B');
-%!error mahalanobis ([1, 2], ['A', 'B']);
-%!error mahalanobis (ones (2,2,2));
-%!error mahalanobis (ones (2,2), ones (2,2,2));
-%!error mahalanobis (ones (2,2), ones (2,3));
+%!error mahalanobis ()
+%!error mahalanobis (1, 2, 3)
+%!error mahalanobis ('A', 'B')
+%!error mahalanobis ([1, 2], ['A', 'B'])
+%!error mahalanobis (ones (2,2,2))
+%!error mahalanobis (ones (2,2), ones (2,2,2))
+%!error mahalanobis (ones (2,2), ones (2,3))
+
--- a/scripts/statistics/base/mean.m
+++ b/scripts/statistics/base/mean.m
@@ -127,25 +127,25 @@
 %! x = -10:10;
 %! y = x';
 %! z = [y, y+10];
-%! assert(mean (x) == 0);
-%! assert(mean (y) == 0);
-%! assert(mean (z) == [0, 10]);
+%! assert (mean (x), 0);
+%! assert (mean (y), 0);
+%! assert (mean (z), [0, 10]);
 
-%!assert(mean (magic(3), 1), [5, 5, 5]);
-%!assert(mean (magic(3), 2), [5; 5; 5]);
-%!assert(mean ([2 8], 'g'), 4);
-%!assert(mean ([4 4 2], 'h'), 3);
-%!assert(mean (logical ([1 0 1 1])), 0.75);
-%!assert(mean (single ([1 0 1 1])), single (0.75));
+%!assert (mean (magic (3), 1), [5, 5, 5])
+%!assert (mean (magic (3), 2), [5; 5; 5])
+%!assert (mean ([2 8], "g"), 4)
+%!assert (mean ([4 4 2], "h"), 3)
+%!assert (mean (logical ([1 0 1 1])), 0.75)
+%!assert (mean (single ([1 0 1 1])), single (0.75))
 
 %% Test input validation
-%!error mean ();
-%!error mean (1, 2, 3, 4);
-%!error mean ({1:5});
-%!error mean (1, 2, 3);
-%!error mean (1, ones(2,2));
-%!error mean (1, 1.5);
-%!error mean (1, 0);
-%!error mean (1, 3);
-%!error mean (1, 'b');
+%!error mean ()
+%!error mean (1, 2, 3, 4)
+%!error mean ({1:5})
+%!error mean (1, 2, 3)
+%!error mean (1, ones (2,2))
+%!error mean (1, 1.5)
+%!error mean (1, 0)
+%!error mean (1, 3)
+%!error mean (1, "b")
 
--- a/scripts/statistics/base/meansq.m
+++ b/scripts/statistics/base/meansq.m
@@ -73,16 +73,16 @@
 endfunction
 
 
-%!assert(meansq (1:5), 11);
-%!assert(meansq (single(1:5)), single(11));
-%!assert(meansq (magic (4)), [94.5, 92.5, 92.5, 94.5]);
-%!assert(meansq (magic (4), 2), [109.5; 77.5; 77.5; 109.5]);
+%!assert (meansq (1:5), 11)
+%!assert (meansq (single (1:5)), single (11))
+%!assert (meansq (magic (4)), [94.5, 92.5, 92.5, 94.5])
+%!assert (meansq (magic (4), 2), [109.5; 77.5; 77.5; 109.5])
 
 %% Test input validation
 %!error meansq ()
 %!error meansq (1, 2, 3)
-%!error meansq (['A'; 'B']);
-%!error meansq (1, ones(2,2))
+%!error meansq (['A'; 'B'])
+%!error meansq (1, ones (2,2))
 %!error meansq (1, 1.5)
 %!error meansq (1, 0)
 %!error meansq (1, 3)
--- a/scripts/statistics/base/median.m
+++ b/scripts/statistics/base/median.m
@@ -94,10 +94,13 @@
 %! y = [1, 2, 3, 4, 5, 6, 7];
 %! y2 = y';
 %!
-%! assert(median (x) == median (x2) && median (x) == 3.5);
-%! assert(median (y) == median (y2) && median (y) == 4);
-%! assert(median ([x2, 2*x2]) == [3.5, 7]);
-%! assert(median ([y2, 3*y2]) == [4, 12]);
+%! assert (median (x) == median (x2) && median (x) == 3.5);
+%! assert (median (y) == median (y2) && median (y) == 4);
+%! assert (median ([x2, 2*x2]), [3.5, 7]);
+%! assert (median ([y2, 3*y2]), [4, 12]);
+
+%!assert (median (single ([1,2,3])), single (2))
+%!assert (median ([1,2,NaN;4,5,6;NaN,8,9]), [NaN, 5, NaN])
 
 %% Test multidimensional arrays (bug #35679)
 %!shared a, b, x, y
@@ -109,15 +112,12 @@
 %!assert (median (a, 4), x(:, :, :, 3));
 %!assert (median (b, 3), (y(:, :, 3, :) + y(:, :, 4, :))/2);
 
-%!assert(median (single([1,2,3])), single(2));
-%!assert(median ([1,2,NaN;4,5,6;NaN,8,9]), [NaN, 5, NaN]);
+%% Test input validation
+%!error median ()
+%!error median (1, 2, 3)
+%!error median ({1:5})
+%!error median (['A'; 'B'])
+%!error median (1, ones (2,2))
+%!error median (1, 1.5)
+%!error median (1, 0)
 
-%% Test input validation
-%!error median ();
-%!error median (1, 2, 3);
-%!error median ({1:5});
-%!error median (['A'; 'B']);
-%!error median (1, ones(2,2));
-%!error median (1, 1.5);
-%!error median (1, 0);
-
--- a/scripts/statistics/base/mode.m
+++ b/scripts/statistics/base/mode.m
@@ -112,19 +112,19 @@
 %! [m2, f2, c2] = mode (full (a));
 %! assert (m, sparse (m2));
 %! assert (f, sparse (f2));
-%! c_exp(1:length(a)) = { sparse (0) };
+%! c_exp(1:length (a)) = { sparse (0) };
 %! assert (c ,c_exp);
 %! assert (c2,c_exp );
 
-%!assert(mode ([2,3,1,2,3,4],1),[2,3,1,2,3,4]);
-%!assert(mode ([2,3,1,2,3,4],2),2);
-%!assert(mode ([2,3,1,2,3,4]),2);
-%!assert(mode (single([2,3,1,2,3,4])), single(2));
-%!assert(mode (int8([2,3,1,2,3,4])), int8(2));
+%!assert (mode ([2,3,1,2,3,4],1),[2,3,1,2,3,4])
+%!assert (mode ([2,3,1,2,3,4],2),2)
+%!assert (mode ([2,3,1,2,3,4]),2)
+%!assert (mode (single ([2,3,1,2,3,4])), single (2))
+%!assert (mode (int8 ([2,3,1,2,3,4])), int8 (2))
 
-%!assert(mode ([2;3;1;2;3;4],1),2);
-%!assert(mode ([2;3;1;2;3;4],2),[2;3;1;2;3;4]);
-%!assert(mode ([2;3;1;2;3;4]),2);
+%!assert (mode ([2;3;1;2;3;4],1),2)
+%!assert (mode ([2;3;1;2;3;4],2),[2;3;1;2;3;4])
+%!assert (mode ([2;3;1;2;3;4]),2)
 
 %!shared x
 %! x(:,:,1) = toeplitz (1:3);
@@ -160,7 +160,7 @@
 %!error mode (1, 2, 3)
 %!error mode ({1 2 3})
 %!error mode (['A'; 'B'])
-%!error mode (1, ones(2,2))
+%!error mode (1, ones (2,2))
 %!error mode (1, 1.5)
 %!error mode (1, 0)
 %!error mode (1, 3)
--- a/scripts/statistics/base/moment.m
+++ b/scripts/statistics/base/moment.m
@@ -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
 
@@ -179,21 +179,21 @@
 %! assert (moment (x,1), mean (x), 1e1*eps);
 %! assert (moment (x,2), meansq (x), 1e1*eps);
 %! assert (moment (x,1,2), mean (x,2), 1e1*eps);
-%! assert (moment (x,1,'c'), mean (center (x)), 1e1*eps);
-%! assert (moment (x,1,'a'), mean (abs (x)), 1e1*eps);
+%! assert (moment (x,1,"c"), mean (center (x)), 1e1*eps);
+%! assert (moment (x,1,"a"), mean (abs (x)), 1e1*eps);
 
-%!assert (moment (single([1 2 3]),1), single(2));
+%!assert (moment (single ([1 2 3]), 1), single (2))
 
 %% Test input validation
 %!error moment ()
 %!error moment (1)
 %!error moment (1, 2, 3, 4, 5)
 %!error moment (['A'; 'B'], 2)
-%!error moment (ones(2,0,3), 2)
+%!error moment (ones (2,0,3), 2)
 %!error moment (1, true)
-%!error moment (1, ones(2,2))
+%!error moment (1, ones (2,2))
 %!error moment (1, 2, 3, 4)
-%!error moment (1, 2, ones(2,2))
+%!error moment (1, 2, ones (2,2))
 %!error moment (1, 2, 1.5)
 %!error moment (1, 2, 4)
 
--- a/scripts/statistics/base/ols.m
+++ b/scripts/statistics/base/ols.m
@@ -139,7 +139,7 @@
 %! x = [1:5]';
 %! y = 3*x + 2;
 %! x = [x, ones(5,1)];
-%! assert (ols(y,x), [3; 2], 50*eps)
+%! assert (ols (y,x), [3; 2], 50*eps)
 
 %!test
 %! x = [1, 2; 3, 4];
@@ -163,11 +163,12 @@
 %! assert (b, [1.4, 2], 2*eps);
 
 %% Test input validation
-%!error ols ();
-%!error ols (1);
-%!error ols (1, 2, 3);
-%!error ols ([true, true], [1, 2]);
-%!error ols ([1, 2], [true, true]);
-%!error ols (ones (2,2,2), ones (2,2));
-%!error ols (ones (2,2), ones (2,2,2));
-%!error ols (ones(1,2), ones(2,2));
+%!error ols ()
+%!error ols (1)
+%!error ols (1, 2, 3)
+%!error ols ([true, true], [1, 2])
+%!error ols ([1, 2], [true, true])
+%!error ols (ones (2,2,2), ones (2,2))
+%!error ols (ones (2,2), ones (2,2,2))
+%!error ols (ones (1,2), ones (2,2))
+
--- a/scripts/statistics/base/ppplot.m
+++ b/scripts/statistics/base/ppplot.m
@@ -79,6 +79,6 @@
 
 
 %% Test input validation
-%!error ppplot ();
-%!error ppplot (ones(2,2));
+%!error ppplot ()
+%!error ppplot (ones (2,2))
 
--- a/scripts/statistics/base/prctile.m
+++ b/scripts/statistics/base/prctile.m
@@ -173,3 +173,4 @@
 %!error prctile (1, 1, 1.5)
 %!error prctile (1, 1, 0)
 %!error prctile (1, 1, 3)
+
--- a/scripts/statistics/base/probit.m
+++ b/scripts/statistics/base/probit.m
@@ -36,7 +36,8 @@
 
 endfunction
 
-%!assert(probit([-1, 0, 0.5, 1, 2]), [NaN, -Inf, 0, Inf, NaN]);
+
+%!assert (probit ([-1, 0, 0.5, 1, 2]), [NaN, -Inf, 0, Inf, NaN])
 
 %% Test input validation
 %!error probit ()
--- a/scripts/statistics/base/qqplot.m
+++ b/scripts/statistics/base/qqplot.m
@@ -58,7 +58,7 @@
     print_usage ();
   endif
 
-  if (!(isnumeric (x) && isvector(x)))
+  if (!(isnumeric (x) && isvector (x)))
     error ("qqplot: X must be a numeric vector");
   endif
 
--- a/scripts/statistics/base/quantile.m
+++ b/scripts/statistics/base/quantile.m
@@ -17,7 +17,8 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {@var{q} =} quantile (@var{x}, @var{p})
+## @deftypefn  {Function File} {@var{q} =} quantile (@var{x})
+## @deftypefnx {Function File} {@var{q} =} quantile (@var{x}, @var{p})
 ## @deftypefnx {Function File} {@var{q} =} quantile (@var{x}, @var{p}, @var{dim})
 ## @deftypefnx {Function File} {@var{q} =} quantile (@var{x}, @var{p}, @var{dim}, @var{method})
 ## For a sample, @var{x}, calculate the quantiles, @var{q}, corresponding to
@@ -28,6 +29,8 @@
 ## return them in a matrix, such that the i-th row of @var{q} contains
 ## the @var{p}(i)th quantiles of each column of @var{x}.
 ##
+## If @var{p} is unspecified, return the quantiles for
+## @code{[0.00 0.25 0.50 0.75 1.00]}.
 ## The optional argument @var{dim} determines the dimension along which
 ## the quantiles are calculated.  If @var{dim} is omitted, and @var{x} is
 ## a vector or matrix, it defaults to 1 (column-wise quantiles).  If
@@ -51,10 +54,10 @@
 ## interpolation function respecting each methods' representative cdf.
 ##
 ## @enumerate 4
-## @item Method 4: p(k) = k / n. That is, linear interpolation of the
+## @item Method 4: p(k) = k / n.  That is, linear interpolation of the
 ## empirical cdf.
 ##
-## @item Method 5: p(k) = (k - 0.5) / n. That is a piecewise linear function
+## @item Method 5: p(k) = (k - 0.5) / n.  That is a piecewise linear function
 ## where the knots are the values midway through the steps of the empirical
 ## cdf.
 ##
@@ -128,7 +131,7 @@
   endif
 
   ## Set the permutation vector.
-  perm = 1:ndims(x);
+  perm = 1:ndims (x);
   perm(1) = dim;
   perm(dim) = 1;
 
@@ -157,7 +160,7 @@
 %! p = 0.5;
 %! x = sort (rand (11));
 %! q = quantile (x, p);
-%! assert (q, x(6,:))
+%! assert (q, x(6,:));
 %! x = x.';
 %! q = quantile (x, p, 2);
 %! assert (q, x(:,6));
@@ -174,9 +177,9 @@
 %!      1.0000   1.7500   2.5000   3.2500   4.0000
 %!      1.0000   1.4167   2.5000   3.5833   4.0000
 %!      1.0000   1.4375   2.5000   3.5625   4.0000];
-%! for m = (1:9)
+%! for m = 1:9
 %!   q = quantile (x, p, 1, m).';
-%!   assert (q, a(m,:), 0.0001)
+%!   assert (q, a(m,:), 0.0001);
 %! endfor
 
 %!test
@@ -191,9 +194,9 @@
 %!      1.0000   2.0000   3.0000   4.0000   5.0000
 %!      1.0000   1.6667   3.0000   4.3333   5.0000
 %!      1.0000   1.6875   3.0000   4.3125   5.0000];
-%! for m = (1:9)
+%! for m = 1:9
 %!   q = quantile (x, p, 1, m).';
-%!   assert (q, a(m,:), 0.0001)
+%!   assert (q, a(m,:), 0.0001);
 %! endfor
 
 %!test
@@ -208,9 +211,9 @@
 %!      1.0000   1.7500   3.5000   6.0000   9.0000
 %!      1.0000   1.4167   3.5000   7.3333   9.0000
 %!      1.0000   1.4375   3.5000   7.2500   9.0000];
-%! for m = (1:9)
+%! for m = 1:9
 %!   q = quantile (x, p, 1, m).';
-%!   assert (q, a(m,:), 0.0001)
+%!   assert (q, a(m,:), 0.0001);
 %! endfor
 
 %!test
@@ -225,9 +228,9 @@
 %!      1.0000    2.0000    5.0000    9.0000   11.0000
 %!      1.0000    1.6667    5.0000    9.6667   11.0000
 %!      1.0000    1.6875    5.0000    9.6250   11.0000];
-%! for m = (1:9)
+%! for m = 1:9
 %!   q = quantile (x, p, 1, m).';
-%!   assert (q, a(m,:), 0.0001)
+%!   assert (q, a(m,:), 0.0001);
 %! endfor
 
 %!test
@@ -242,9 +245,9 @@
 %!      6.0000   10.2500   11.5000   14.2500   16.0000
 %!      6.0000    9.8333   11.5000   15.0000   16.0000
 %!      6.0000    9.8750   11.5000   15.0000   16.0000];
-%! for m = (1:9)
+%! for m = 1:9
 %!   q = quantile (x, p, 1, m).';
-%!   assert (q, a(m,:), 0.0001)
+%!   assert (q, a(m,:), 0.0001);
 %! endfor
 
 %!test
@@ -260,9 +263,9 @@
 %!      -2.551474  -0.571522  -0.067751   0.106855   0.495271
 %!      -2.551474  -0.591566  -0.067751   0.146459   0.495271
 %!      -2.551474  -0.590801  -0.067751   0.140686   0.495271];
-%! for m = (1:9)
+%! for m = 1:9
 %!   q = quantile (x, p, 1, m).';
-%!   assert (q, a(m,:), 0.0001)
+%!   assert (q, a(m,:), 0.0001);
 %! endfor
 
 %!test
@@ -274,11 +277,11 @@
 %!      0.933100, 0.931200, 0.963500, 0.779600, 0.846100];
 %! tol = 0.00001;
 %! x(5,5) = NaN;
-%! assert (quantile(x, p, 1), [0.27950, 0.79780, 0.32960, 0.55670, 0.44460], tol);
+%! assert (quantile (x, p, 1), [0.27950, 0.79780, 0.32960, 0.55670, 0.44460], tol);
 %! x(1,1) = NaN;
-%! assert (quantile(x, p, 1), [0.35415, 0.79780, 0.32960, 0.55670, 0.44460], tol);
+%! assert (quantile (x, p, 1), [0.35415, 0.79780, 0.32960, 0.55670, 0.44460], tol);
 %! x(3,3) = NaN;
-%! assert (quantile(x, p, 1), [0.35415, 0.79780, 0.42590, 0.55670, 0.44460], tol);
+%! assert (quantile (x, p, 1), [0.35415, 0.79780, 0.42590, 0.55670, 0.44460], tol);
 
 %!test
 %! sx = [2, 3, 4];
--- a/scripts/statistics/base/range.m
+++ b/scripts/statistics/base/range.m
@@ -50,12 +50,13 @@
 endfunction
 
 
-%!assert(range (1:10), 9);
-%!assert(range (single(1:10)), single(9));
-%!assert(range (magic (3)), [5, 8, 5]);
-%!assert(range (magic (3), 2), [7; 4; 7]);
-%!assert(range (2), 0);
+%!assert (range (1:10), 9)
+%!assert (range (single (1:10)), single (9))
+%!assert (range (magic (3)), [5, 8, 5])
+%!assert (range (magic (3), 2), [7; 4; 7])
+%!assert (range (2), 0)
 
 %% Test input validation
 %!error range ()
 %!error range (1, 2, 3)
+
--- a/scripts/statistics/base/ranks.m
+++ b/scripts/statistics/base/ranks.m
@@ -54,7 +54,7 @@
   endif
 
   if (sz(dim) == 1)
-    y = ones(sz);
+    y = ones (sz);
   else
     ## The algorithm works only on dim = 1, so permute if necesary.
     if (dim != 1)
@@ -73,7 +73,7 @@
       runs = setdiff (eq_el, eq_el+1);
       len = diff (find (diff ([Inf; eq_el; -Inf]) != 1)) + 1;
       [eq_el, y] = sort (xi);
-      for i = 1 : length(runs)
+      for i = 1 : length (runs)
         y (xi (runs (i) + [0:(len(i)-1)]) + floor (runs (i) ./ sz(1))
            * sz(1)) = eq_el(runs(i)) + (len(i) - 1) / 2;
       endfor
@@ -86,12 +86,12 @@
 endfunction
 
 
-%!assert(ranks (1:2:10), 1:5);
-%!assert(ranks (10:-2:1), 5:-1:1);
-%!assert(ranks ([2, 1, 2, 4]), [2.5, 1, 2.5, 4]);
-%!assert(ranks (ones(1, 5)), 3*ones(1, 5));
-%!assert(ranks (1e6*ones(1, 5)), 3*ones(1, 5));
-%!assert(ranks (rand (1, 5), 1), ones(1, 5));
+%!assert (ranks (1:2:10), 1:5)
+%!assert (ranks (10:-2:1), 5:-1:1)
+%!assert (ranks ([2, 1, 2, 4]), [2.5, 1, 2.5, 4])
+%!assert (ranks (ones (1, 5)), 3*ones (1, 5))
+%!assert (ranks (1e6*ones (1, 5)), 3*ones (1, 5))
+%!assert (ranks (rand (1, 5), 1), ones (1, 5))
 
 %% Test input validation
 %!error ranks ()
--- a/scripts/statistics/base/run_count.m
+++ b/scripts/statistics/base/run_count.m
@@ -93,10 +93,10 @@
 endfunction
 
 
-%!assert(run_count (magic(3), 4), [1,0,1;1,0,1;0,1,0;0,0,0])
-%!assert(run_count (magic(3), 4, 2), [1,0,1;1,0,1;0,1,0;0,0,0]')
-%!assert(run_count (5:-1:1, 5), [5, 0, 0, 0, 0])
-%!assert(run_count (ones(3), 4), [0,0,0;0,0,0;1,1,1;0,0,0])
+%!assert (run_count (magic (3), 4), [1,0,1;1,0,1;0,1,0;0,0,0])
+%!assert (run_count (magic (3), 4, 2), [1,0,1;1,0,1;0,1,0;0,0,0]')
+%!assert (run_count (5:-1:1, 5), [5, 0, 0, 0, 0])
+%!assert (run_count (ones (3), 4), [0,0,0;0,0,0;1,1,1;0,0,0])
 
 %% Test input validation
 %!error run_count ()
@@ -104,10 +104,10 @@
 %!error run_count (1, 2, 3, 4)
 %!error run_count ({1, 2}, 3)
 %!error run_count (['A'; 'A'; 'B'], 3)
-%!error run_count (1:5, ones(2,2))
+%!error run_count (1:5, ones (2,2))
 %!error run_count (1:5, 1.5)
 %!error run_count (1:5, -2)
-%!error run_count (1:5, 3, ones(2,2))
+%!error run_count (1:5, 3, ones (2,2))
 %!error run_count (1:5, 3, 1.5)
 %!error run_count (1:5, 3, 0)
 
--- a/scripts/statistics/base/runlength.m
+++ b/scripts/statistics/base/runlength.m
@@ -52,8 +52,8 @@
 endfunction
 
 
-%!assert (runlength([2 2 0 4 4 4 0 1 1 1 1]), [2 1 3 1 4]);
-%!assert (runlength([2 2 0 4 4 4 0 1 1 1 1]'), [2 1 3 1 4]);
+%!assert (runlength ([2 2 0 4 4 4 0 1 1 1 1]), [2 1 3 1 4])
+%!assert (runlength ([2 2 0 4 4 4 0 1 1 1 1]'), [2 1 3 1 4])
 %!test
 %! [c, v] = runlength ([2 2 0 4 4 4 0 1 1 1 1]);
 %! assert (c, [2 1 3 1 4]);
@@ -63,4 +63,5 @@
 %!error runlength ()
 %!error runlength (1, 2)
 %!error runlength (['A'; 'B'])
-%!error runlength (ones(2,2))
+%!error runlength (ones (2,2))
+
--- a/scripts/statistics/base/skewness.m
+++ b/scripts/statistics/base/skewness.m
@@ -79,22 +79,23 @@
 endfunction
 
 
-%!assert(skewness ([-1,0,1]), 0);
-%!assert(skewness ([-2,0,1]) < 0);
-%!assert(skewness ([-1,0,2]) > 0);
-%!assert(skewness ([-3,0,1]) == -1*skewness([-1,0,3]));
+%!assert (skewness ([-1,0,1]), 0)
+%!assert (skewness ([-2,0,1]) < 0)
+%!assert (skewness ([-1,0,2]) > 0)
+%!assert (skewness ([-3,0,1]) == -1*skewness ([-1,0,3]))
 %!test
 %! x = [0; 0; 0; 1];
 %! y = [x, 2*x];
 %! assert(all (abs (skewness (y) - [0.75, 0.75]) < sqrt (eps)));
 
-%!assert (skewness (single(1)), single(0));
+%!assert (skewness (single (1)), single (0))
 
 %% Test input validation
 %!error skewness ()
 %!error skewness (1, 2, 3)
 %!error skewness (['A'; 'B'])
-%!error skewness (1, ones(2,2))
+%!error skewness (1, ones (2,2))
 %!error skewness (1, 1.5)
 %!error skewness (1, 0)
 %!error skewness (1, 3)
+
--- a/scripts/statistics/base/spearman.m
+++ b/scripts/statistics/base/spearman.m
@@ -69,7 +69,7 @@
   endif
 
   ## Restore class cleared by ranks
-  if (isa (x, 'single') || isa (y, 'single'))
+  if (isa (x, "single") || isa (y, "single"))
     rho = single (rho);
   endif
 
@@ -82,13 +82,14 @@
 %! assert (spearman (x,y), 1, 5*eps);
 %! assert (spearman (x,-y), -1, 5*eps);
 
-%!assert(spearman ([1 2 3], [-1 1 -2]), -0.5, 5*eps)
+%!assert (spearman ([1 2 3], [-1 1 -2]), -0.5, 5*eps)
 
 %% Test input validation
-%!error spearman ();
-%!error spearman (1, 2, 3);
-%!error spearman (['A'; 'B']);
-%!error spearman (ones(1,2), {1, 2});
-%!error spearman (ones (2,2,2));
-%!error spearman (ones (2,2), ones (2,2,2));
-%!error spearman (ones (2,2), ones (3,2));
+%!error spearman ()
+%!error spearman (1, 2, 3)
+%!error spearman (['A'; 'B'])
+%!error spearman (ones (1,2), {1, 2})
+%!error spearman (ones (2,2,2))
+%!error spearman (ones (2,2), ones (2,2,2))
+%!error spearman (ones (2,2), ones (3,2))
+
--- a/scripts/statistics/base/statistics.m
+++ b/scripts/statistics/base/statistics.m
@@ -81,7 +81,7 @@
 %!error statistics ()
 %!error statistics (1, 2, 3)
 %!error statistics (['A'; 'B'])
-%!error statistics (1, ones(2,2))
+%!error statistics (1, ones (2,2))
 %!error statistics (1, 1.5)
 %!error statistics (1, 0)
 %!error statistics (1, 3)
--- a/scripts/statistics/base/std.m
+++ b/scripts/statistics/base/std.m
@@ -92,8 +92,8 @@
 
   n = sz(dim);
   if (n == 1 || isempty (x))
-    if (isa (x, 'single'))
-      retval = zeros (sz, 'single');
+    if (isa (x, "single"))
+      retval = zeros (sz, "single");
     else
       retval = zeros (sz);
     endif
@@ -107,21 +107,21 @@
 %!test
 %! x = ones (10, 2);
 %! y = [1, 3];
-%! assert(std (x) == [0, 0]);
-%! assert(std (y), sqrt (2), sqrt (eps));
-%! assert(std (x, 0, 2), zeros (10, 1));
+%! assert (std (x), [0, 0]);
+%! assert (std (y), sqrt (2), sqrt (eps));
+%! assert (std (x, 0, 2), zeros (10, 1));
 
-%!assert(std (ones (3, 1, 2), 0, 2), zeros (3, 1, 2));
-%!assert(std ([1 2], 0), sqrt(2)/2, 5*eps);
-%!assert(std ([1 2], 1), 0.5, 5*eps);
-%!assert(std(1), 0);
-%!assert(std(single(1)), single(0));
-%!assert(std([]), []);
-%!assert(std(ones (1,3,0,2)), ones (1,3,0,2));
+%!assert (std (ones (3, 1, 2), 0, 2), zeros (3, 1, 2));
+%!assert (std ([1 2], 0), sqrt (2)/2, 5*eps);
+%!assert (std ([1 2], 1), 0.5, 5*eps);
+%!assert (std (1), 0);
+%!assert (std (single (1)), single (0));
+%!assert (std ([]), []);
+%!assert (std (ones (1,3,0,2)), ones (1,3,0,2));
 
 %% Test input validation
-%!error std ();
-%!error std (1, 2, 3, 4);
+%!error std ()
+%!error std (1, 2, 3, 4)
 %!error std (['A'; 'B'])
-%!error std (1, -1);
+%!error std (1, -1)
 
--- a/scripts/statistics/base/table.m
+++ b/scripts/statistics/base/table.m
@@ -71,3 +71,4 @@
 %!error table (ones (2,2), ones (2,1))
 %!error table (ones (2,1), ones (2,2))
 %!error table (ones (2,1), ones (3,1))
+
--- a/scripts/statistics/base/var.m
+++ b/scripts/statistics/base/var.m
@@ -51,6 +51,9 @@
 ##   normalizes with @math{N}, this provides the second moment around the mean
 ## @end table
 ##
+## If @math{N==1} the value of @var{opt} is ignored and normalization 
+## by @math{N} is used.
+##
 ## If the optional argument @var{dim} is given, operate along this dimension.
 ## @seealso{cov, std, skewness, kurtosis, moment}
 ## @end deftypefn
@@ -89,8 +92,8 @@
 
   n = sz(dim);
   if (n == 1)
-    if (isa (x, 'single'))
-      retval = zeros (sz, 'single');
+    if (isa (x, "single"))
+      retval = zeros (sz, "single");
     else
       retval = zeros (sz);
     endif
@@ -103,16 +106,16 @@
 endfunction
 
 
-%!assert(var (13), 0);
-%!assert(var (single(13)), single(0));
-%!assert(var ([1,2,3]), 1);
-%!assert(var ([1,2,3], 1), 2/3, eps);
-%!assert(var ([1,2,3], [], 1), [0,0,0]);
+%!assert (var (13), 0)
+%!assert (var (single (13)), single (0))
+%!assert (var ([1,2,3]), 1)
+%!assert (var ([1,2,3], 1), 2/3, eps)
+%!assert (var ([1,2,3], [], 1), [0,0,0])
 
 %% Test input validation
 %!error var ()
 %!error var (1,2,3,4)
 %!error var (['A'; 'B'])
-%!error var (1, -1);
-%!error var ([],1)
+%!error var (1, -1)
+%!error var ([], 1)
 
--- a/scripts/statistics/base/zscore.m
+++ b/scripts/statistics/base/zscore.m
@@ -17,23 +17,31 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {} zscore (@var{x})
-## @deftypefnx {Function File} {} zscore (@var{x}, @var{dim})
+## @deftypefn  {Function File} {[@var{z}, @var{mu}, @var{sigma}] =} zscore (@var{x})
+## @deftypefnx {Function File} {[@var{z}, @var{mu}, @var{sigma}] =} zscore (@var{x}, @var{opt})
+## @deftypefnx {Function File} {[@var{z}, @var{mu}, @var{sigma}] =} zscore (@var{x}, @var{opt}, @var{dim})
 ## If @var{x} is a vector, subtract its mean and divide by its standard
-## deviation.
+## deviation.  If the standard deviation is zero, divide by 1 instead.
+## The optional parameter @var{opt} determines the normalization to use
+## when computing the standard deviation and is the same as the
+## corresponding parameter for @code{std}.
 ##
 ## If @var{x} is a matrix, do the above along the first non-singleton
-## dimension.
-## If the optional argument @var{dim} is given, operate along this dimension.
-## @seealso{center}
+## dimension.  If the third optional argument @var{dim} is given, operate
+## along this dimension.
+##
+## The mean and standard deviation along @var{dim} are given in @var{mu}
+## and @var{sigma} respectively.
+##
+## @seealso{mean, std, center}
 ## @end deftypefn
 
 ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
 ## Description: Subtract mean and divide by standard deviation
 
-function z = zscore (x, dim)
+function [z, mu, sigma] = zscore (x, opt, dim)
 
-  if (nargin != 1 && nargin != 2)
+  if (nargin < 1 || nargin > 3 )
     print_usage ();
   endif
 
@@ -41,9 +49,17 @@
     error ("zscore: X must be a numeric vector or matrix");
   endif
 
+  if (nargin < 2)
+    opt = 0;
+  else
+    if (opt != 0 && opt != 1 || ! isscalar (opt))
+      error ("zscore: OPT must be empty, 0, or 1");
+    endif
+  endif
+
   nd = ndims (x);
   sz = size (x);
-  if (nargin != 2)
+  if (nargin < 3)
     ## Find the first non-singleton dimension.
     (dim = find (sz > 1, 1)) || (dim = 1);
   else
@@ -57,28 +73,34 @@
   if (n == 0)
     z = x;
   else
-    x = center (x, dim); # center also promotes integer to double for next line
-    z = zeros (sz, class (x));
-    s = std (x, [], dim);
+
+    if (isinteger (x))
+      x = double (x);
+    endif
+
+    mu = mean (x, dim);
+    sigma = std (x, opt, dim);
+    s = sigma;
     s(s==0) = 1;
-    z = bsxfun (@rdivide, x, s);
+    ## FIXME: Use normal broadcasting once we can disable that warning
+    z = bsxfun (@rdivide, bsxfun (@minus, x, mu), s);
   endif
 
 endfunction
 
 
-%!assert(zscore ([1,2,3]), [-1,0,1])
-%!assert(zscore (single([1,2,3])), single([-1,0,1]))
-%!assert(zscore (int8([1,2,3])), [-1,0,1])
-%!assert(zscore (ones (3,2,2,2)), zeros (3,2,2,2))
-%!assert(zscore ([2,0,-2;0,2,0;-2,-2,2]), [1,0,-1;0,1,0;-1,-1,1])
+%!assert (zscore ([1,2,3]), [-1,0,1])
+%!assert (zscore (single ([1,2,3])), single ([-1,0,1]))
+%!assert (zscore (int8 ([1,2,3])), [-1,0,1])
+%!assert (zscore (ones (3,2,2,2)), zeros (3,2,2,2))
+%!assert (zscore ([2,0,-2;0,2,0;-2,-2,2]), [1,0,-1;0,1,0;-1,-1,1])
 
 %% Test input validation
 %!error zscore ()
 %!error zscore (1, 2, 3)
 %!error zscore (['A'; 'B'])
-%!error zscore (1, ones(2,2))
+%!error zscore (1, ones (2,2))
 %!error zscore (1, 1.5)
-%!error zscore (1, 0)
+%!error zscore (1, 1, 0)
 %!error zscore (1, 3)
 
--- a/scripts/statistics/distributions/betacdf.m
+++ b/scripts/statistics/distributions/betacdf.m
@@ -69,25 +69,25 @@
 %!shared x,y
 %! x = [-1 0 0.5 1 2];
 %! y = [0 0 0.75 1 1];
-%!assert(betacdf (x, ones(1,5), 2*ones(1,5)), y);
-%!assert(betacdf (x, 1, 2*ones(1,5)), y);
-%!assert(betacdf (x, ones(1,5), 2), y);
-%!assert(betacdf (x, [0 1 NaN 1 1], 2), [NaN 0 NaN 1 1]);
-%!assert(betacdf (x, 1, 2*[0 1 NaN 1 1]), [NaN 0 NaN 1 1]);
-%!assert(betacdf ([x(1:2) NaN x(4:5)], 1, 2), [y(1:2) NaN y(4:5)]);
+%!assert (betacdf (x, ones (1,5), 2*ones (1,5)), y)
+%!assert (betacdf (x, 1, 2*ones (1,5)), y)
+%!assert (betacdf (x, ones (1,5), 2), y)
+%!assert (betacdf (x, [0 1 NaN 1 1], 2), [NaN 0 NaN 1 1])
+%!assert (betacdf (x, 1, 2*[0 1 NaN 1 1]), [NaN 0 NaN 1 1])
+%!assert (betacdf ([x(1:2) NaN x(4:5)], 1, 2), [y(1:2) NaN y(4:5)])
 
 %% Test class of input preserved
-%!assert(betacdf ([x, NaN], 1, 2), [y, NaN]);
-%!assert(betacdf (single([x, NaN]), 1, 2), single([y, NaN]));
-%!assert(betacdf ([x, NaN], single(1), 2), single([y, NaN]));
-%!assert(betacdf ([x, NaN], 1, single(2)), single([y, NaN]));
+%!assert (betacdf ([x, NaN], 1, 2), [y, NaN])
+%!assert (betacdf (single ([x, NaN]), 1, 2), single ([y, NaN]))
+%!assert (betacdf ([x, NaN], single (1), 2), single ([y, NaN]))
+%!assert (betacdf ([x, NaN], 1, single (2)), single ([y, NaN]))
 
 %% Test input validation
 %!error betacdf ()
 %!error betacdf (1)
 %!error betacdf (1,2)
 %!error betacdf (1,2,3,4)
-%!error betacdf (ones(3),ones(2),ones(2))
-%!error betacdf (ones(2),ones(3),ones(2))
-%!error betacdf (ones(2),ones(2),ones(3))
+%!error betacdf (ones (3), ones (2), ones (2))
+%!error betacdf (ones (2), ones (3), ones (2))
+%!error betacdf (ones (2), ones (2), ones (3))
 
--- a/scripts/statistics/distributions/betainv.m
+++ b/scripts/statistics/distributions/betainv.m
@@ -109,27 +109,27 @@
 
 %!shared x
 %! x = [-1 0 0.75 1 2];
-%!assert(betainv (x, ones(1,5), 2*ones(1,5)), [NaN 0 0.5 1 NaN]);
-%!assert(betainv (x, 1, 2*ones(1,5)), [NaN 0 0.5 1 NaN]);
-%!assert(betainv (x, ones(1,5), 2), [NaN 0 0.5 1 NaN]);
-%!assert(betainv (x, [1 0 NaN 1 1], 2), [NaN NaN NaN 1 NaN]);
-%!assert(betainv (x, 1, 2*[1 0 NaN 1 1]), [NaN NaN NaN 1 NaN]);
-%!assert(betainv ([x(1:2) NaN x(4:5)], 1, 2), [NaN 0 NaN 1 NaN]);
+%!assert (betainv (x, ones (1,5), 2*ones (1,5)), [NaN 0 0.5 1 NaN])
+%!assert (betainv (x, 1, 2*ones (1,5)), [NaN 0 0.5 1 NaN])
+%!assert (betainv (x, ones (1,5), 2), [NaN 0 0.5 1 NaN])
+%!assert (betainv (x, [1 0 NaN 1 1], 2), [NaN NaN NaN 1 NaN])
+%!assert (betainv (x, 1, 2*[1 0 NaN 1 1]), [NaN NaN NaN 1 NaN])
+%!assert (betainv ([x(1:2) NaN x(4:5)], 1, 2), [NaN 0 NaN 1 NaN])
 
 %% Test class of input preserved
-%!assert(betainv ([x, NaN], 1, 2), [NaN 0 0.5 1 NaN NaN]);
-%!assert(betainv (single([x, NaN]), 1, 2), single([NaN 0 0.5 1 NaN NaN]));
-%!assert(betainv ([x, NaN], single(1), 2), single([NaN 0 0.5 1 NaN NaN]));
-%!assert(betainv ([x, NaN], 1, single(2)), single([NaN 0 0.5 1 NaN NaN]));
+%!assert (betainv ([x, NaN], 1, 2), [NaN 0 0.5 1 NaN NaN])
+%!assert (betainv (single ([x, NaN]), 1, 2), single ([NaN 0 0.5 1 NaN NaN]))
+%!assert (betainv ([x, NaN], single (1), 2), single ([NaN 0 0.5 1 NaN NaN]))
+%!assert (betainv ([x, NaN], 1, single (2)), single ([NaN 0 0.5 1 NaN NaN]))
 
 %% Test input validation
 %!error betainv ()
 %!error betainv (1)
 %!error betainv (1,2)
 %!error betainv (1,2,3,4)
-%!error betainv (ones(3),ones(2),ones(2))
-%!error betainv (ones(2),ones(3),ones(2))
-%!error betainv (ones(2),ones(2),ones(3))
+%!error betainv (ones (3), ones (2), ones (2))
+%!error betainv (ones (2), ones (3), ones (2))
+%!error betainv (ones (2), ones (2), ones (3))
 %!error betainv (i, 2, 2)
 %!error betainv (2, i, 2)
 %!error betainv (2, 2, i)
--- a/scripts/statistics/distributions/betapdf.m
+++ b/scripts/statistics/distributions/betapdf.m
@@ -95,35 +95,35 @@
 %!shared x,y
 %! x = [-1 0 0.5 1 2];
 %! y = [0 2 1 0 0];
-%!assert(betapdf (x, ones(1,5), 2*ones(1,5)), y);
-%!assert(betapdf (x, 1, 2*ones(1,5)), y);
-%!assert(betapdf (x, ones(1,5), 2), y);
-%!assert(betapdf (x, [0 NaN 1 1 1], 2), [NaN NaN y(3:5)]);
-%!assert(betapdf (x, 1, 2*[0 NaN 1 1 1]), [NaN NaN y(3:5)]);
-%!assert(betapdf ([x, NaN], 1, 2), [y, NaN]);
+%!assert (betapdf (x, ones (1,5), 2*ones (1,5)), y)
+%!assert (betapdf (x, 1, 2*ones (1,5)), y)
+%!assert (betapdf (x, ones (1,5), 2), y)
+%!assert (betapdf (x, [0 NaN 1 1 1], 2), [NaN NaN y(3:5)])
+%!assert (betapdf (x, 1, 2*[0 NaN 1 1 1]), [NaN NaN y(3:5)])
+%!assert (betapdf ([x, NaN], 1, 2), [y, NaN])
 
 %% Test class of input preserved
-%!assert(betapdf (single([x, NaN]), 1, 2), single([y, NaN]));
-%!assert(betapdf ([x, NaN], single(1), 2), single([y, NaN]));
-%!assert(betapdf ([x, NaN], 1, single(2)), single([y, NaN]));
+%!assert (betapdf (single ([x, NaN]), 1, 2), single ([y, NaN]))
+%!assert (betapdf ([x, NaN], single (1), 2), single ([y, NaN]))
+%!assert (betapdf ([x, NaN], 1, single (2)), single ([y, NaN]))
 
 %% Beta (1/2,1/2) == arcsine distribution
 %!test
 %! x = rand (10,1);
 %! y = 1./(pi * sqrt (x.*(1-x)));
-%! assert(betapdf (x, 1/2, 1/2), y, 50*eps);
+%! assert (betapdf (x, 1/2, 1/2), y, 50*eps);
 
 %% Test large input values to betapdf
-%!assert (betapdf(0.5, 1000, 1000), 35.678, 1e-3)
+%!assert (betapdf (0.5, 1000, 1000), 35.678, 1e-3)
 
 %% Test input validation
 %!error betapdf ()
 %!error betapdf (1)
 %!error betapdf (1,2)
 %!error betapdf (1,2,3,4)
-%!error betapdf (ones(3),ones(2),ones(2))
-%!error betapdf (ones(2),ones(3),ones(2))
-%!error betapdf (ones(2),ones(2),ones(3))
+%!error betapdf (ones (3), ones (2), ones (2))
+%!error betapdf (ones (2), ones (3), ones (2))
+%!error betapdf (ones (2), ones (2), ones (3))
 %!error betapdf (i, 2, 2)
 %!error betapdf (2, i, 2)
 %!error betapdf (2, 2, i)
--- a/scripts/statistics/distributions/betarnd.m
+++ b/scripts/statistics/distributions/betarnd.m
@@ -84,11 +84,8 @@
 
   if (isscalar (a) && isscalar (b))
     if ((a > 0) && (a < Inf) && (b > 0) && (b < Inf))
-      r = randg (a, sz);
-      rnd = r ./ (r + randg (b, sz));
-      if (strcmp (cls, "single"))
-        rnd = single (rnd);
-      endif
+      r = randg (a, sz, cls);
+      rnd = r ./ (r + randg (b, sz, cls));
     else
       rnd = NaN (sz, cls);
     endif
@@ -96,42 +93,42 @@
     rnd = NaN (sz, cls);
 
     k = (a > 0) & (a < Inf) & (b > 0) & (b < Inf);
-    r = randg (a(k));
-    rnd(k) = r ./ (r + randg (b(k)));
+    r = randg (a(k), cls);
+    rnd(k) = r ./ (r + randg (b(k), cls));
   endif
 
 endfunction
 
 
-%!assert(size (betarnd (1,2)), [1, 1]);
-%!assert(size (betarnd (ones(2,1), 2)), [2, 1]);
-%!assert(size (betarnd (ones(2,2), 2)), [2, 2]);
-%!assert(size (betarnd (1, 2*ones(2,1))), [2, 1]);
-%!assert(size (betarnd (1, 2*ones(2,2))), [2, 2]);
-%!assert(size (betarnd (1, 2, 3)), [3, 3]);
-%!assert(size (betarnd (1, 2, [4 1])), [4, 1]);
-%!assert(size (betarnd (1, 2, 4, 1)), [4, 1]);
+%!assert (size (betarnd (1,2)), [1, 1])
+%!assert (size (betarnd (ones (2,1), 2)), [2, 1])
+%!assert (size (betarnd (ones (2,2), 2)), [2, 2])
+%!assert (size (betarnd (1, 2*ones (2,1))), [2, 1])
+%!assert (size (betarnd (1, 2*ones (2,2))), [2, 2])
+%!assert (size (betarnd (1, 2, 3)), [3, 3])
+%!assert (size (betarnd (1, 2, [4 1])), [4, 1])
+%!assert (size (betarnd (1, 2, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (betarnd (1, 2)), "double");
-%!assert(class (betarnd (single(1), 2)), "single");
-%!assert(class (betarnd (single([1 1]), 2)), "single");
-%!assert(class (betarnd (1, single(2))), "single");
-%!assert(class (betarnd (1, single([2 2]))), "single");
+%!assert (class (betarnd (1, 2)), "double")
+%!assert (class (betarnd (single (1), 2)), "single")
+%!assert (class (betarnd (single ([1 1]), 2)), "single")
+%!assert (class (betarnd (1, single (2))), "single")
+%!assert (class (betarnd (1, single ([2 2]))), "single")
 
 %% Test input validation
 %!error betarnd ()
 %!error betarnd (1)
-%!error betarnd (ones(3),ones(2))
-%!error betarnd (ones(2),ones(3))
+%!error betarnd (ones (3), ones (2))
+%!error betarnd (ones (2), ones (3))
 %!error betarnd (i, 2)
 %!error betarnd (2, i)
 %!error betarnd (1,2, -1)
-%!error betarnd (1,2, ones(2))
+%!error betarnd (1,2, ones (2))
 %!error binornd (1,2, [2 -1 2])
-%!error betarnd (1,2, 1, ones(2))
+%!error betarnd (1,2, 1, ones (2))
 %!error betarnd (1,2, 1, -1)
-%!error betarnd (ones(2,2), 2, 3)
-%!error betarnd (ones(2,2), 2, [3, 2])
-%!error betarnd (ones(2,2), 2, 2, 3)
+%!error betarnd (ones (2,2), 2, 3)
+%!error betarnd (ones (2,2), 2, [3, 2])
+%!error betarnd (ones (2,2), 2, 2, 3)
 
--- a/scripts/statistics/distributions/binocdf.m
+++ b/scripts/statistics/distributions/binocdf.m
@@ -71,27 +71,27 @@
 %!shared x,y
 %! x = [-1 0 1 2 3];
 %! y = [0 1/4 3/4 1 1];
-%!assert(binocdf (x, 2*ones(1,5), 0.5*ones(1,5)), y);
-%!assert(binocdf (x, 2, 0.5*ones(1,5)), y);
-%!assert(binocdf (x, 2*ones(1,5), 0.5), y);
-%!assert(binocdf (x, 2*[0 -1 NaN 1.1 1], 0.5), [0 NaN NaN NaN 1]);
-%!assert(binocdf (x, 2, 0.5*[0 -1 NaN 3 1]), [0 NaN NaN NaN 1]);
-%!assert(binocdf ([x(1:2) NaN x(4:5)], 2, 0.5), [y(1:2) NaN y(4:5)]);
+%!assert (binocdf (x, 2*ones (1,5), 0.5*ones (1,5)), y)
+%!assert (binocdf (x, 2, 0.5*ones (1,5)), y)
+%!assert (binocdf (x, 2*ones (1,5), 0.5), y)
+%!assert (binocdf (x, 2*[0 -1 NaN 1.1 1], 0.5), [0 NaN NaN NaN 1])
+%!assert (binocdf (x, 2, 0.5*[0 -1 NaN 3 1]), [0 NaN NaN NaN 1])
+%!assert (binocdf ([x(1:2) NaN x(4:5)], 2, 0.5), [y(1:2) NaN y(4:5)])
 
 %% Test class of input preserved
-%!assert(binocdf ([x, NaN], 2, 0.5), [y, NaN]);
-%!assert(binocdf (single([x, NaN]), 2, 0.5), single([y, NaN]));
-%!assert(binocdf ([x, NaN], single(2), 0.5), single([y, NaN]));
-%!assert(binocdf ([x, NaN], 2, single(0.5)), single([y, NaN]));
+%!assert (binocdf ([x, NaN], 2, 0.5), [y, NaN])
+%!assert (binocdf (single ([x, NaN]), 2, 0.5), single ([y, NaN]))
+%!assert (binocdf ([x, NaN], single (2), 0.5), single ([y, NaN]))
+%!assert (binocdf ([x, NaN], 2, single (0.5)), single ([y, NaN]))
 
 %% Test input validation
 %!error binocdf ()
 %!error binocdf (1)
 %!error binocdf (1,2)
 %!error binocdf (1,2,3,4)
-%!error binocdf (ones(3),ones(2),ones(2))
-%!error binocdf (ones(2),ones(3),ones(2))
-%!error binocdf (ones(2),ones(2),ones(3))
+%!error binocdf (ones (3), ones (2), ones (2))
+%!error binocdf (ones (2), ones (3), ones (2))
+%!error binocdf (ones (2), ones (2), ones (3))
 %!error binocdf (i, 2, 2)
 %!error binocdf (2, i, 2)
 %!error binocdf (2, 2, i)
--- a/scripts/statistics/distributions/binoinv.m
+++ b/scripts/statistics/distributions/binoinv.m
@@ -88,27 +88,27 @@
 
 %!shared x
 %! x = [-1 0 0.5 1 2];
-%!assert(binoinv (x, 2*ones(1,5), 0.5*ones(1,5)), [NaN 0 1 2 NaN]);
-%!assert(binoinv (x, 2, 0.5*ones(1,5)), [NaN 0 1 2 NaN]);
-%!assert(binoinv (x, 2*ones(1,5), 0.5), [NaN 0 1 2 NaN]);
-%!assert(binoinv (x, 2*[0 -1 NaN 1.1 1], 0.5), [NaN NaN NaN NaN NaN]);
-%!assert(binoinv (x, 2, 0.5*[0 -1 NaN 3 1]), [NaN NaN NaN NaN NaN]);
-%!assert(binoinv ([x(1:2) NaN x(4:5)], 2, 0.5), [NaN 0 NaN 2 NaN]);
+%!assert (binoinv (x, 2*ones (1,5), 0.5*ones (1,5)), [NaN 0 1 2 NaN])
+%!assert (binoinv (x, 2, 0.5*ones (1,5)), [NaN 0 1 2 NaN])
+%!assert (binoinv (x, 2*ones (1,5), 0.5), [NaN 0 1 2 NaN])
+%!assert (binoinv (x, 2*[0 -1 NaN 1.1 1], 0.5), [NaN NaN NaN NaN NaN])
+%!assert (binoinv (x, 2, 0.5*[0 -1 NaN 3 1]), [NaN NaN NaN NaN NaN])
+%!assert (binoinv ([x(1:2) NaN x(4:5)], 2, 0.5), [NaN 0 NaN 2 NaN])
 
 %% Test class of input preserved
-%!assert(binoinv ([x, NaN], 2, 0.5), [NaN 0 1 2 NaN NaN]);
-%!assert(binoinv (single([x, NaN]), 2, 0.5), single([NaN 0 1 2 NaN NaN]));
-%!assert(binoinv ([x, NaN], single(2), 0.5), single([NaN 0 1 2 NaN NaN]));
-%!assert(binoinv ([x, NaN], 2, single(0.5)), single([NaN 0 1 2 NaN NaN]));
+%!assert (binoinv ([x, NaN], 2, 0.5), [NaN 0 1 2 NaN NaN])
+%!assert (binoinv (single ([x, NaN]), 2, 0.5), single ([NaN 0 1 2 NaN NaN]))
+%!assert (binoinv ([x, NaN], single (2), 0.5), single ([NaN 0 1 2 NaN NaN]))
+%!assert (binoinv ([x, NaN], 2, single (0.5)), single ([NaN 0 1 2 NaN NaN]))
 
 %% Test input validation
 %!error binoinv ()
 %!error binoinv (1)
 %!error binoinv (1,2)
 %!error binoinv (1,2,3,4)
-%!error binoinv (ones(3),ones(2),ones(2))
-%!error binoinv (ones(2),ones(3),ones(2))
-%!error binoinv (ones(2),ones(2),ones(3))
+%!error binoinv (ones (3), ones (2), ones (2))
+%!error binoinv (ones (2), ones (3), ones (2))
+%!error binoinv (ones (2), ones (2), ones (3))
 %!error binoinv (i, 2, 2)
 %!error binoinv (2, i, 2)
 %!error binoinv (2, 2, i)
--- a/scripts/statistics/distributions/binopdf.m
+++ b/scripts/statistics/distributions/binopdf.m
@@ -75,26 +75,26 @@
 %! endif
 %! x = [-1 0 1 2 3];
 %! y = [0 1/4 1/2 1/4 0];
-%!assert(binopdf (x, 2*ones(1,5), 0.5*ones(1,5)), y, tol);
-%!assert(binopdf (x, 2, 0.5*ones(1,5)), y, tol);
-%!assert(binopdf (x, 2*ones(1,5), 0.5), y, tol);
-%!assert(binopdf (x, 2*[0 -1 NaN 1.1 1], 0.5), [0 NaN NaN NaN 0]);
-%!assert(binopdf (x, 2, 0.5*[0 -1 NaN 3 1]), [0 NaN NaN NaN 0]);
-%!assert(binopdf ([x, NaN], 2, 0.5), [y, NaN], tol);
+%!assert (binopdf (x, 2*ones (1,5), 0.5*ones (1,5)), y, tol)
+%!assert (binopdf (x, 2, 0.5*ones (1,5)), y, tol)
+%!assert (binopdf (x, 2*ones (1,5), 0.5), y, tol)
+%!assert (binopdf (x, 2*[0 -1 NaN 1.1 1], 0.5), [0 NaN NaN NaN 0])
+%!assert (binopdf (x, 2, 0.5*[0 -1 NaN 3 1]), [0 NaN NaN NaN 0])
+%!assert (binopdf ([x, NaN], 2, 0.5), [y, NaN], tol)
 
 %% Test class of input preserved
-%!assert(binopdf (single([x, NaN]), 2, 0.5), single([y, NaN]));
-%!assert(binopdf ([x, NaN], single(2), 0.5), single([y, NaN]));
-%!assert(binopdf ([x, NaN], 2, single(0.5)), single([y, NaN]));
+%!assert (binopdf (single ([x, NaN]), 2, 0.5), single ([y, NaN]))
+%!assert (binopdf ([x, NaN], single (2), 0.5), single ([y, NaN]))
+%!assert (binopdf ([x, NaN], 2, single (0.5)), single ([y, NaN]))
 
 %% Test input validation
 %!error binopdf ()
 %!error binopdf (1)
 %!error binopdf (1,2)
 %!error binopdf (1,2,3,4)
-%!error binopdf (ones(3),ones(2),ones(2))
-%!error binopdf (ones(2),ones(3),ones(2))
-%!error binopdf (ones(2),ones(2),ones(3))
+%!error binopdf (ones (3), ones (2), ones (2))
+%!error binopdf (ones (2), ones (3), ones (2))
+%!error binopdf (ones (2), ones (2), ones (3))
 %!error binopdf (i, 2, 2)
 %!error binopdf (2, i, 2)
 %!error binopdf (2, 2, i)
--- a/scripts/statistics/distributions/binornd.m
+++ b/scripts/statistics/distributions/binornd.m
@@ -120,35 +120,35 @@
 %!assert (binornd (0, 0, 1), 0)
 %!assert (binornd ([0, 0], [0, 0], 1, 2), [0, 0])
 
-%!assert(size (binornd (2, 1/2)), [1, 1]);
-%!assert(size (binornd (2*ones(2,1), 1/2)), [2, 1]);
-%!assert(size (binornd (2*ones(2,2), 1/2)), [2, 2]);
-%!assert(size (binornd (2, 1/2*ones(2,1))), [2, 1]);
-%!assert(size (binornd (2, 1/2*ones(2,2))), [2, 2]);
-%!assert(size (binornd (2, 1/2, 3)), [3, 3]);
-%!assert(size (binornd (2, 1/2, [4 1])), [4, 1]);
-%!assert(size (binornd (2, 1/2, 4, 1)), [4, 1]);
+%!assert (size (binornd (2, 1/2)), [1, 1])
+%!assert (size (binornd (2*ones (2,1), 1/2)), [2, 1])
+%!assert (size (binornd (2*ones (2,2), 1/2)), [2, 2])
+%!assert (size (binornd (2, 1/2*ones (2,1))), [2, 1])
+%!assert (size (binornd (2, 1/2*ones (2,2))), [2, 2])
+%!assert (size (binornd (2, 1/2, 3)), [3, 3])
+%!assert (size (binornd (2, 1/2, [4 1])), [4, 1])
+%!assert (size (binornd (2, 1/2, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (binornd (2, 0.5)), "double");
-%!assert(class (binornd (single(2), 0.5)), "single");
-%!assert(class (binornd (single([2 2]), 0.5)), "single");
-%!assert(class (binornd (2, single(0.5))), "single");
-%!assert(class (binornd (2, single([0.5 0.5]))), "single");
+%!assert (class (binornd (2, 0.5)), "double")
+%!assert (class (binornd (single (2), 0.5)), "single")
+%!assert (class (binornd (single ([2 2]), 0.5)), "single")
+%!assert (class (binornd (2, single (0.5))), "single")
+%!assert (class (binornd (2, single ([0.5 0.5]))), "single")
 
 %% Test input validation
 %!error binornd ()
 %!error binornd (1)
-%!error binornd (ones(3),ones(2))
-%!error binornd (ones(2),ones(3))
+%!error binornd (ones (3), ones (2))
+%!error binornd (ones (2), ones (3))
 %!error binornd (i, 2)
 %!error binornd (2, i)
 %!error binornd (1,2, -1)
-%!error binornd (1,2, ones(2))
+%!error binornd (1,2, ones (2))
 %!error binornd (1,2, [2 -1 2])
-%!error binornd (1,2, 1, ones(2))
+%!error binornd (1,2, 1, ones (2))
 %!error binornd (1,2, 1, -1)
-%!error binornd (ones(2,2), 2, 3)
-%!error binornd (ones(2,2), 2, [3, 2])
-%!error binornd (ones(2,2), 2, 2, 3)
+%!error binornd (ones (2,2), 2, 3)
+%!error binornd (ones (2,2), 2, [3, 2])
+%!error binornd (ones (2,2), 2, 2, 3)
 
--- a/scripts/statistics/distributions/cauchy_cdf.m
+++ b/scripts/statistics/distributions/cauchy_cdf.m
@@ -65,26 +65,26 @@
 %!shared x,y
 %! x = [-1 0 0.5 1 2];
 %! y = 1/pi * atan ((x-1) / 2) + 1/2;
-%!assert(cauchy_cdf (x, ones(1,5), 2*ones(1,5)), y);
-%!assert(cauchy_cdf (x, 1, 2*ones(1,5)), y);
-%!assert(cauchy_cdf (x, ones(1,5), 2), y);
-%!assert(cauchy_cdf (x, [-Inf 1 NaN 1 Inf], 2), [NaN y(2) NaN y(4) NaN]);
-%!assert(cauchy_cdf (x, 1, 2*[0 1 NaN 1 Inf]), [NaN y(2) NaN y(4) NaN]);
-%!assert(cauchy_cdf ([x(1:2) NaN x(4:5)], 1, 2), [y(1:2) NaN y(4:5)]);
+%!assert (cauchy_cdf (x, ones (1,5), 2*ones (1,5)), y)
+%!assert (cauchy_cdf (x, 1, 2*ones (1,5)), y)
+%!assert (cauchy_cdf (x, ones (1,5), 2), y)
+%!assert (cauchy_cdf (x, [-Inf 1 NaN 1 Inf], 2), [NaN y(2) NaN y(4) NaN])
+%!assert (cauchy_cdf (x, 1, 2*[0 1 NaN 1 Inf]), [NaN y(2) NaN y(4) NaN])
+%!assert (cauchy_cdf ([x(1:2) NaN x(4:5)], 1, 2), [y(1:2) NaN y(4:5)])
 
 %% Test class of input preserved
-%!assert(cauchy_cdf ([x, NaN], 1, 2), [y, NaN]);
-%!assert(cauchy_cdf (single([x, NaN]), 1, 2), single([y, NaN]), eps("single"));
-%!assert(cauchy_cdf ([x, NaN], single(1), 2), single([y, NaN]), eps("single"));
-%!assert(cauchy_cdf ([x, NaN], 1, single(2)), single([y, NaN]), eps("single"));
+%!assert (cauchy_cdf ([x, NaN], 1, 2), [y, NaN])
+%!assert (cauchy_cdf (single ([x, NaN]), 1, 2), single ([y, NaN]), eps ("single"))
+%!assert (cauchy_cdf ([x, NaN], single (1), 2), single ([y, NaN]), eps ("single"))
+%!assert (cauchy_cdf ([x, NaN], 1, single (2)), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error cauchy_cdf ()
 %!error cauchy_cdf (1,2)
 %!error cauchy_cdf (1,2,3,4)
-%!error cauchy_cdf (ones(3),ones(2),ones(2))
-%!error cauchy_cdf (ones(2),ones(3),ones(2))
-%!error cauchy_cdf (ones(2),ones(2),ones(3))
+%!error cauchy_cdf (ones (3), ones (2), ones (2))
+%!error cauchy_cdf (ones (2), ones (3), ones (2))
+%!error cauchy_cdf (ones (2), ones (2), ones (3))
 %!error cauchy_cdf (i, 2, 2)
 %!error cauchy_cdf (2, i, 2)
 %!error cauchy_cdf (2, 2, i)
--- a/scripts/statistics/distributions/cauchy_inv.m
+++ b/scripts/statistics/distributions/cauchy_inv.m
@@ -72,26 +72,26 @@
 
 %!shared x
 %! x = [-1 0 0.5 1 2];
-%!assert(cauchy_inv (x, ones(1,5), 2*ones(1,5)), [NaN -Inf 1 Inf NaN], eps);
-%!assert(cauchy_inv (x, 1, 2*ones(1,5)), [NaN -Inf 1 Inf NaN], eps);
-%!assert(cauchy_inv (x, ones(1,5), 2), [NaN -Inf 1 Inf NaN], eps);
-%!assert(cauchy_inv (x, [1 -Inf NaN Inf 1], 2), [NaN NaN NaN NaN NaN]);
-%!assert(cauchy_inv (x, 1, 2*[1 0 NaN Inf 1]), [NaN NaN NaN NaN NaN]);
-%!assert(cauchy_inv ([x(1:2) NaN x(4:5)], 1, 2), [NaN -Inf NaN Inf NaN]);
+%!assert (cauchy_inv (x, ones (1,5), 2*ones (1,5)), [NaN -Inf 1 Inf NaN], eps)
+%!assert (cauchy_inv (x, 1, 2*ones (1,5)), [NaN -Inf 1 Inf NaN], eps)
+%!assert (cauchy_inv (x, ones (1,5), 2), [NaN -Inf 1 Inf NaN], eps)
+%!assert (cauchy_inv (x, [1 -Inf NaN Inf 1], 2), [NaN NaN NaN NaN NaN])
+%!assert (cauchy_inv (x, 1, 2*[1 0 NaN Inf 1]), [NaN NaN NaN NaN NaN])
+%!assert (cauchy_inv ([x(1:2) NaN x(4:5)], 1, 2), [NaN -Inf NaN Inf NaN])
 
 %% Test class of input preserved
-%!assert(cauchy_inv ([x, NaN], 1, 2), [NaN -Inf 1 Inf NaN NaN], eps);
-%!assert(cauchy_inv (single([x, NaN]), 1, 2), single([NaN -Inf 1 Inf NaN NaN]), eps("single"));
-%!assert(cauchy_inv ([x, NaN], single(1), 2), single([NaN -Inf 1 Inf NaN NaN]), eps("single"));
-%!assert(cauchy_inv ([x, NaN], 1, single(2)), single([NaN -Inf 1 Inf NaN NaN]), eps("single"));
+%!assert (cauchy_inv ([x, NaN], 1, 2), [NaN -Inf 1 Inf NaN NaN], eps)
+%!assert (cauchy_inv (single ([x, NaN]), 1, 2), single ([NaN -Inf 1 Inf NaN NaN]), eps ("single"))
+%!assert (cauchy_inv ([x, NaN], single (1), 2), single ([NaN -Inf 1 Inf NaN NaN]), eps ("single"))
+%!assert (cauchy_inv ([x, NaN], 1, single (2)), single ([NaN -Inf 1 Inf NaN NaN]), eps ("single"))
 
 %% Test input validation
 %!error cauchy_inv ()
 %!error cauchy_inv (1,2)
 %!error cauchy_inv (1,2,3,4)
-%!error cauchy_inv (ones(3),ones(2),ones(2))
-%!error cauchy_inv (ones(2),ones(3),ones(2))
-%!error cauchy_inv (ones(2),ones(2),ones(3))
+%!error cauchy_inv (ones (3), ones (2), ones (2))
+%!error cauchy_inv (ones (2), ones (3), ones (2))
+%!error cauchy_inv (ones (2), ones (2), ones (3))
 %!error cauchy_inv (i, 2, 2)
 %!error cauchy_inv (2, i, 2)
 %!error cauchy_inv (2, 2, i)
--- a/scripts/statistics/distributions/cauchy_pdf.m
+++ b/scripts/statistics/distributions/cauchy_pdf.m
@@ -67,30 +67,30 @@
 %!shared x,y
 %! x = [-1 0 0.5 1 2];
 %! y = 1/pi * ( 2 ./ ((x-1).^2 + 2^2) );
-%!assert(cauchy_pdf (x, ones(1,5), 2*ones(1,5)), y);
-%!assert(cauchy_pdf (x, 1, 2*ones(1,5)), y);
-%!assert(cauchy_pdf (x, ones(1,5), 2), y);
-%!assert(cauchy_pdf (x, [-Inf 1 NaN 1 Inf], 2), [NaN y(2) NaN y(4) NaN]);
-%!assert(cauchy_pdf (x, 1, 2*[0 1 NaN 1 Inf]), [NaN y(2) NaN y(4) NaN]);
-%!assert(cauchy_pdf ([x, NaN], 1, 2), [y, NaN]);
+%!assert (cauchy_pdf (x, ones (1,5), 2*ones (1,5)), y)
+%!assert (cauchy_pdf (x, 1, 2*ones (1,5)), y)
+%!assert (cauchy_pdf (x, ones (1,5), 2), y)
+%!assert (cauchy_pdf (x, [-Inf 1 NaN 1 Inf], 2), [NaN y(2) NaN y(4) NaN])
+%!assert (cauchy_pdf (x, 1, 2*[0 1 NaN 1 Inf]), [NaN y(2) NaN y(4) NaN])
+%!assert (cauchy_pdf ([x, NaN], 1, 2), [y, NaN])
 
 %% Test class of input preserved
-%!assert(cauchy_pdf (single([x, NaN]), 1, 2), single([y, NaN]), eps("single"));
-%!assert(cauchy_pdf ([x, NaN], single(1), 2), single([y, NaN]), eps("single"));
-%!assert(cauchy_pdf ([x, NaN], 1, single(2)), single([y, NaN]), eps("single"));
+%!assert (cauchy_pdf (single ([x, NaN]), 1, 2), single ([y, NaN]), eps ("single"))
+%!assert (cauchy_pdf ([x, NaN], single (1), 2), single ([y, NaN]), eps ("single"))
+%!assert (cauchy_pdf ([x, NaN], 1, single (2)), single ([y, NaN]), eps ("single"))
 
 %% Cauchy (0,1) == Student's T distribution with 1 DOF
 %!test
 %! x = rand (10, 1);
-%! assert(cauchy_pdf (x, 0, 1), tpdf (x, 1), eps);
+%! assert (cauchy_pdf (x, 0, 1), tpdf (x, 1), eps);
 
 %% Test input validation
 %!error cauchy_pdf ()
 %!error cauchy_pdf (1,2)
 %!error cauchy_pdf (1,2,3,4)
-%!error cauchy_pdf (ones(3),ones(2),ones(2))
-%!error cauchy_pdf (ones(2),ones(3),ones(2))
-%!error cauchy_pdf (ones(2),ones(2),ones(3))
+%!error cauchy_pdf (ones (3), ones (2), ones (2))
+%!error cauchy_pdf (ones (2), ones (3), ones (2))
+%!error cauchy_pdf (ones (2), ones (2), ones (3))
 %!error cauchy_pdf (i, 2, 2)
 %!error cauchy_pdf (2, i, 2)
 %!error cauchy_pdf (2, 2, i)
--- a/scripts/statistics/distributions/cauchy_rnd.m
+++ b/scripts/statistics/distributions/cauchy_rnd.m
@@ -84,7 +84,7 @@
 
   if (isscalar (location) && isscalar (scale))
     if (!isinf (location) && (scale > 0) && (scale < Inf))
-      rnd = location - cot (pi * rand (sz)) * scale;
+      rnd = location - cot (pi * rand (sz, cls)) * scale;
     else
       rnd = NaN (sz, cls);
     endif
@@ -92,41 +92,41 @@
     rnd = NaN (sz, cls);
 
     k = !isinf (location) & (scale > 0) & (scale < Inf);
-    rnd(k) = location(k)(:) - cot (pi * rand (sum (k(:)), 1)) .* scale(k)(:);
+    rnd(k) = location(k)(:) - cot (pi * rand (sum (k(:)), 1, cls)) .* scale(k)(:);
   endif
 
 endfunction
 
 
-%!assert(size (cauchy_rnd (1,2)), [1, 1]);
-%!assert(size (cauchy_rnd (ones(2,1), 2)), [2, 1]);
-%!assert(size (cauchy_rnd (ones(2,2), 2)), [2, 2]);
-%!assert(size (cauchy_rnd (1, 2*ones(2,1))), [2, 1]);
-%!assert(size (cauchy_rnd (1, 2*ones(2,2))), [2, 2]);
-%!assert(size (cauchy_rnd (1, 2, 3)), [3, 3]);
-%!assert(size (cauchy_rnd (1, 2, [4 1])), [4, 1]);
-%!assert(size (cauchy_rnd (1, 2, 4, 1)), [4, 1]);
+%!assert (size (cauchy_rnd (1,2)), [1, 1])
+%!assert (size (cauchy_rnd (ones (2,1), 2)), [2, 1])
+%!assert (size (cauchy_rnd (ones (2,2), 2)), [2, 2])
+%!assert (size (cauchy_rnd (1, 2*ones (2,1))), [2, 1])
+%!assert (size (cauchy_rnd (1, 2*ones (2,2))), [2, 2])
+%!assert (size (cauchy_rnd (1, 2, 3)), [3, 3])
+%!assert (size (cauchy_rnd (1, 2, [4 1])), [4, 1])
+%!assert (size (cauchy_rnd (1, 2, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (cauchy_rnd (1, 2)), "double");
-%!assert(class (cauchy_rnd (single(1), 2)), "single");
-%!assert(class (cauchy_rnd (single([1 1]), 2)), "single");
-%!assert(class (cauchy_rnd (1, single(2))), "single");
-%!assert(class (cauchy_rnd (1, single([2 2]))), "single");
+%!assert (class (cauchy_rnd (1, 2)), "double")
+%!assert (class (cauchy_rnd (single (1), 2)), "single")
+%!assert (class (cauchy_rnd (single ([1 1]), 2)), "single")
+%!assert (class (cauchy_rnd (1, single (2))), "single")
+%!assert (class (cauchy_rnd (1, single ([2 2]))), "single")
 
 %% Test input validation
 %!error cauchy_rnd ()
 %!error cauchy_rnd (1)
-%!error cauchy_rnd (ones(3),ones(2))
-%!error cauchy_rnd (ones(2),ones(3))
+%!error cauchy_rnd (ones (3), ones (2))
+%!error cauchy_rnd (ones (2), ones (3))
 %!error cauchy_rnd (i, 2)
 %!error cauchy_rnd (2, i)
 %!error cauchy_rnd (1,2, -1)
-%!error cauchy_rnd (1,2, ones(2))
+%!error cauchy_rnd (1,2, ones (2))
 %!error cauchy_rnd (1,2, [2 -1 2])
-%!error cauchy_rnd (1,2, 1, ones(2))
+%!error cauchy_rnd (1,2, 1, ones (2))
 %!error cauchy_rnd (1,2, 1, -1)
-%!error cauchy_rnd (ones(2,2), 2, 3)
-%!error cauchy_rnd (ones(2,2), 2, [3, 2])
-%!error cauchy_rnd (ones(2,2), 2, 2, 3)
+%!error cauchy_rnd (ones (2,2), 2, 3)
+%!error cauchy_rnd (ones (2,2), 2, [3, 2])
+%!error cauchy_rnd (ones (2,2), 2, 2, 3)
 
--- a/scripts/statistics/distributions/chi2cdf.m
+++ b/scripts/statistics/distributions/chi2cdf.m
@@ -52,22 +52,22 @@
 %!shared x,y
 %! x = [-1 0 0.5 1 2];
 %! y = [0, 1 - exp(-x(2:end)/2)];
-%!assert(chi2cdf (x, 2*ones(1,5)), y, eps);
-%!assert(chi2cdf (x, 2), y, eps);
-%!assert(chi2cdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)], eps);
-%!assert(chi2cdf ([x(1:2) NaN x(4:5)], 2), [y(1:2) NaN y(4:5)], eps);
+%!assert (chi2cdf (x, 2*ones (1,5)), y, eps)
+%!assert (chi2cdf (x, 2), y, eps)
+%!assert (chi2cdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)], eps)
+%!assert (chi2cdf ([x(1:2) NaN x(4:5)], 2), [y(1:2) NaN y(4:5)], eps)
 
 %% Test class of input preserved
-%!assert(chi2cdf ([x, NaN], 2), [y, NaN], eps);
-%!assert(chi2cdf (single([x, NaN]), 2), single([y, NaN]), eps("single"));
-%!assert(chi2cdf ([x, NaN], single(2)), single([y, NaN]), eps("single"));
+%!assert (chi2cdf ([x, NaN], 2), [y, NaN], eps)
+%!assert (chi2cdf (single ([x, NaN]), 2), single ([y, NaN]), eps ("single"))
+%!assert (chi2cdf ([x, NaN], single (2)), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error chi2cdf ()
 %!error chi2cdf (1)
 %!error chi2cdf (1,2,3)
-%!error chi2cdf (ones(3),ones(2))
-%!error chi2cdf (ones(2),ones(3))
+%!error chi2cdf (ones (3), ones (2))
+%!error chi2cdf (ones (2), ones (3))
 %!error chi2cdf (i, 2)
 %!error chi2cdf (2, i)
 
--- a/scripts/statistics/distributions/chi2inv.m
+++ b/scripts/statistics/distributions/chi2inv.m
@@ -51,22 +51,22 @@
 
 %!shared x
 %! x = [-1 0 0.3934693402873666 1 2];
-%!assert(chi2inv (x, 2*ones(1,5)), [NaN 0 1 Inf NaN], 5*eps);
-%!assert(chi2inv (x, 2), [NaN 0 1 Inf NaN], 5*eps);
-%!assert(chi2inv (x, 2*[0 1 NaN 1 1]), [NaN 0 NaN Inf NaN], 5*eps);
-%!assert(chi2inv ([x(1:2) NaN x(4:5)], 2), [NaN 0 NaN Inf NaN], 5*eps);
+%!assert (chi2inv (x, 2*ones (1,5)), [NaN 0 1 Inf NaN], 5*eps)
+%!assert (chi2inv (x, 2), [NaN 0 1 Inf NaN], 5*eps)
+%!assert (chi2inv (x, 2*[0 1 NaN 1 1]), [NaN 0 NaN Inf NaN], 5*eps)
+%!assert (chi2inv ([x(1:2) NaN x(4:5)], 2), [NaN 0 NaN Inf NaN], 5*eps)
 
 %% Test class of input preserved
-%!assert(chi2inv ([x, NaN], 2), [NaN 0 1 Inf NaN NaN], 5*eps);
-%!assert(chi2inv (single([x, NaN]), 2), single([NaN 0 1 Inf NaN NaN]), 5*eps("single"));
-%!assert(chi2inv ([x, NaN], single(2)), single([NaN 0 1 Inf NaN NaN]), 5*eps("single"));
+%!assert (chi2inv ([x, NaN], 2), [NaN 0 1 Inf NaN NaN], 5*eps)
+%!assert (chi2inv (single ([x, NaN]), 2), single ([NaN 0 1 Inf NaN NaN]), 5*eps ("single"))
+%!assert (chi2inv ([x, NaN], single (2)), single ([NaN 0 1 Inf NaN NaN]), 5*eps ("single"))
 
 %% Test input validation
 %!error chi2inv ()
 %!error chi2inv (1)
 %!error chi2inv (1,2,3)
-%!error chi2inv (ones(3),ones(2))
-%!error chi2inv (ones(2),ones(3))
+%!error chi2inv (ones (3), ones (2))
+%!error chi2inv (ones (2), ones (3))
 %!error chi2inv (i, 2)
 %!error chi2inv (2, i)
 
--- a/scripts/statistics/distributions/chi2pdf.m
+++ b/scripts/statistics/distributions/chi2pdf.m
@@ -52,21 +52,21 @@
 %!shared x,y
 %! x = [-1 0 0.5 1 Inf];
 %! y = [0, 1/2 * exp(-x(2:5)/2)];
-%!assert(chi2pdf (x, 2*ones(1,5)), y);
-%!assert(chi2pdf (x, 2), y);
-%!assert(chi2pdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)]);
-%!assert(chi2pdf ([x, NaN], 2), [y, NaN]);
+%!assert (chi2pdf (x, 2*ones (1,5)), y)
+%!assert (chi2pdf (x, 2), y)
+%!assert (chi2pdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)])
+%!assert (chi2pdf ([x, NaN], 2), [y, NaN])
 
 %% Test class of input preserved
-%!assert(chi2pdf (single([x, NaN]), 2), single([y, NaN]));
-%!assert(chi2pdf ([x, NaN], single(2)), single([y, NaN]));
+%!assert (chi2pdf (single ([x, NaN]), 2), single ([y, NaN]))
+%!assert (chi2pdf ([x, NaN], single (2)), single ([y, NaN]))
 
 %% Test input validation
 %!error chi2pdf ()
 %!error chi2pdf (1)
 %!error chi2pdf (1,2,3)
-%!error chi2pdf (ones(3),ones(2))
-%!error chi2pdf (ones(2),ones(3))
+%!error chi2pdf (ones (3), ones (2))
+%!error chi2pdf (ones (2), ones (3))
 %!error chi2pdf (i, 2)
 %!error chi2pdf (2, i)
 
--- a/scripts/statistics/distributions/chi2rnd.m
+++ b/scripts/statistics/distributions/chi2rnd.m
@@ -77,10 +77,7 @@
 
   if (isscalar (n))
     if ((n > 0) && (n < Inf))
-      rnd = 2 * randg (n/2, sz);
-      if (strcmp (cls, "single"))
-        rnd = single (rnd);
-      endif
+      rnd = 2 * randg (n/2, sz, cls);
     else
       rnd = NaN (sz, cls);
     endif
@@ -88,33 +85,33 @@
     rnd = NaN (sz, cls);
 
     k = (n > 0) | (n < Inf);
-    rnd(k) = 2 * randg (n(k)/2);
+    rnd(k) = 2 * randg (n(k)/2, cls);
   endif
 
 endfunction
 
 
-%!assert(size (chi2rnd (2)), [1, 1]);
-%!assert(size (chi2rnd (ones(2,1))), [2, 1]);
-%!assert(size (chi2rnd (ones(2,2))), [2, 2]);
-%!assert(size (chi2rnd (1, 3)), [3, 3]);
-%!assert(size (chi2rnd (1, [4 1])), [4, 1]);
-%!assert(size (chi2rnd (1, 4, 1)), [4, 1]);
+%!assert (size (chi2rnd (2)), [1, 1])
+%!assert (size (chi2rnd (ones (2,1))), [2, 1])
+%!assert (size (chi2rnd (ones (2,2))), [2, 2])
+%!assert (size (chi2rnd (1, 3)), [3, 3])
+%!assert (size (chi2rnd (1, [4 1])), [4, 1])
+%!assert (size (chi2rnd (1, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (chi2rnd (2)), "double");
-%!assert(class (chi2rnd (single(2))), "single");
-%!assert(class (chi2rnd (single([2 2]))), "single");
+%!assert (class (chi2rnd (2)), "double")
+%!assert (class (chi2rnd (single (2))), "single")
+%!assert (class (chi2rnd (single ([2 2]))), "single")
 
 %% Test input validation
 %!error chi2rnd ()
-%!error chi2rnd (ones(3),ones(2))
-%!error chi2rnd (ones(2),ones(3))
+%!error chi2rnd (ones (3), ones (2))
+%!error chi2rnd (ones (2), ones (3))
 %!error chi2rnd (i)
 %!error chi2rnd (1, -1)
-%!error chi2rnd (1, ones(2))
+%!error chi2rnd (1, ones (2))
 %!error chi2rnd (1, [2 -1 2])
-%!error chi2rnd (ones(2,2), 3)
-%!error chi2rnd (ones(2,2), [3, 2])
-%!error chi2rnd (ones(2,2), 2, 3)
+%!error chi2rnd (ones (2,2), 3)
+%!error chi2rnd (ones (2,2), [3, 2])
+%!error chi2rnd (ones (2,2), 2, 3)
 
--- a/scripts/statistics/distributions/discrete_cdf.m
+++ b/scripts/statistics/distributions/discrete_cdf.m
@@ -58,24 +58,24 @@
 %!shared x,v,p,y
 %! x = [-1 0.1 1.1 1.9 3];
 %! v = 0.1:0.2:1.9;
-%! p = 1/length(v) * ones(1, length(v));
+%! p = 1/length(v) * ones (1, length(v));
 %! y = [0 0.1 0.6 1 1];
-%!assert(discrete_cdf ([x, NaN], v, p), [y, NaN], eps);
+%!assert (discrete_cdf ([x, NaN], v, p), [y, NaN], eps)
 
 %% Test class of input preserved
-%!assert(discrete_cdf (single([x, NaN]), v, p), single([y, NaN]), 2*eps("single"));
-%!assert(discrete_cdf ([x, NaN], single(v), p), single([y, NaN]), 2*eps("single"));
-%!assert(discrete_cdf ([x, NaN], v, single(p)), single([y, NaN]), 2*eps("single"));
+%!assert (discrete_cdf (single ([x, NaN]), v, p), single ([y, NaN]), 2*eps ("single"))
+%!assert (discrete_cdf ([x, NaN], single (v), p), single ([y, NaN]), 2*eps ("single"))
+%!assert (discrete_cdf ([x, NaN], v, single (p)), single ([y, NaN]), 2*eps ("single"))
 
 %% Test input validation
 %!error discrete_cdf ()
 %!error discrete_cdf (1)
 %!error discrete_cdf (1,2)
 %!error discrete_cdf (1,2,3,4)
-%!error discrete_cdf (1, ones(2), ones(2,1))
-%!error discrete_cdf (1, [1 ; NaN], ones(2,1))
-%!error discrete_cdf (1, ones(2,1), ones(1,1))
-%!error discrete_cdf (1, ones(2,1), [1 -1])
-%!error discrete_cdf (1, ones(2,1), [1 NaN])
-%!error discrete_cdf (1, ones(2,1), [0  0])
+%!error discrete_cdf (1, ones (2), ones (2,1))
+%!error discrete_cdf (1, [1 ; NaN], ones (2,1))
+%!error discrete_cdf (1, ones (2,1), ones (1,1))
+%!error discrete_cdf (1, ones (2,1), [1 -1])
+%!error discrete_cdf (1, ones (2,1), [1 NaN])
+%!error discrete_cdf (1, ones (2,1), [0  0])
 
--- a/scripts/statistics/distributions/discrete_inv.m
+++ b/scripts/statistics/distributions/discrete_inv.m
@@ -73,23 +73,23 @@
 %!shared x,v,p,y
 %! x = [-1 0 0.1 0.5 1 2];
 %! v = 0.1:0.2:1.9;
-%! p = 1/length(v) * ones(1, length(v));
+%! p = 1/length(v) * ones (1, length(v));
 %! y = [NaN v(1) v(1) v(end/2) v(end) NaN];
-%!assert(discrete_inv ([x, NaN], v, p), [y, NaN], eps);
+%!assert (discrete_inv ([x, NaN], v, p), [y, NaN], eps)
 
 %% Test class of input preserved
-%!assert(discrete_inv (single([x, NaN]), v, p), single([y, NaN]), eps("single"));
-%!assert(discrete_inv ([x, NaN], single(v), p), single([y, NaN]), eps("single"));
-%!assert(discrete_inv ([x, NaN], v, single(p)), single([y, NaN]), eps("single"));
+%!assert (discrete_inv (single ([x, NaN]), v, p), single ([y, NaN]), eps ("single"))
+%!assert (discrete_inv ([x, NaN], single (v), p), single ([y, NaN]), eps ("single"))
+%!assert (discrete_inv ([x, NaN], v, single (p)), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error discrete_inv ()
 %!error discrete_inv (1)
 %!error discrete_inv (1,2)
 %!error discrete_inv (1,2,3,4)
-%!error discrete_inv (1, ones(2), ones(2,1))
-%!error discrete_inv (1, ones(2,1), ones(1,1))
-%!error discrete_inv (1, ones(2,1), [1 NaN])
-%!error discrete_inv (1, ones(2,1), [1 -1])
-%!error discrete_inv (1, ones(2,1), [0  0])
+%!error discrete_inv (1, ones (2), ones (2,1))
+%!error discrete_inv (1, ones (2,1), ones (1,1))
+%!error discrete_inv (1, ones (2,1), [1 NaN])
+%!error discrete_inv (1, ones (2,1), [1 -1])
+%!error discrete_inv (1, ones (2,1), [0  0])
 
--- a/scripts/statistics/distributions/discrete_pdf.m
+++ b/scripts/statistics/distributions/discrete_pdf.m
@@ -62,24 +62,24 @@
 %!shared x,v,p,y
 %! x = [-1 0.1 1.1 1.9 3];
 %! v = 0.1:0.2:1.9;
-%! p = 1/length(v) * ones(1, length(v));
+%! p = 1/length (v) * ones (1, length (v));
 %! y = [0 0.1 0.1 0.1 0];
-%!assert(discrete_pdf ([x, NaN], v, p), [y, NaN], 5*eps);
+%!assert (discrete_pdf ([x, NaN], v, p), [y, NaN], 5*eps)
 
 %% Test class of input preserved
-%!assert(discrete_pdf (single([x, NaN]), v, p), single([y, NaN]), 5*eps("single"));
-%!assert(discrete_pdf ([x, NaN], single(v), p), single([y, NaN]), 5*eps("single"));
-%!assert(discrete_pdf ([x, NaN], v, single(p)), single([y, NaN]), 5*eps("single"));
+%!assert (discrete_pdf (single ([x, NaN]), v, p), single ([y, NaN]), 5*eps ("single"))
+%!assert (discrete_pdf ([x, NaN], single (v), p), single ([y, NaN]), 5*eps ("single"))
+%!assert (discrete_pdf ([x, NaN], v, single (p)), single ([y, NaN]), 5*eps ("single"))
 
 %% Test input validation
 %!error discrete_pdf ()
 %!error discrete_pdf (1)
 %!error discrete_pdf (1,2)
 %!error discrete_pdf (1,2,3,4)
-%!error discrete_pdf (1, ones(2), ones(2,1))
-%!error discrete_pdf (1, [1 ; NaN], ones(2,1))
-%!error discrete_pdf (1, ones(2,1), ones(1,1))
-%!error discrete_pdf (1, ones(2,1), [1 -1])
-%!error discrete_pdf (1, ones(2,1), [1 NaN])
-%!error discrete_pdf (1, ones(2,1), [0  0])
+%!error discrete_pdf (1, ones (2), ones (2,1))
+%!error discrete_pdf (1, [1 ; NaN], ones (2,1))
+%!error discrete_pdf (1, ones (2,1), ones (1,1))
+%!error discrete_pdf (1, ones (2,1), [1 -1])
+%!error discrete_pdf (1, ones (2,1), [1 NaN])
+%!error discrete_pdf (1, ones (2,1), [0  0])
 
--- a/scripts/statistics/distributions/discrete_rnd.m
+++ b/scripts/statistics/distributions/discrete_rnd.m
@@ -77,13 +77,13 @@
 endfunction
 
 
-%!assert(size (discrete_rnd (1:2, 1:2, 3)), [3, 3]);
-%!assert(size (discrete_rnd (1:2, 1:2, [4 1])), [4, 1]);
-%!assert(size (discrete_rnd (1:2, 1:2, 4, 1)), [4, 1]);
+%!assert (size (discrete_rnd (1:2, 1:2, 3)), [3, 3])
+%!assert (size (discrete_rnd (1:2, 1:2, [4 1])), [4, 1])
+%!assert (size (discrete_rnd (1:2, 1:2, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (discrete_rnd (1:2, 1:2)), "double");
-%!assert(class (discrete_rnd (single(1:2), 1:2)), "single");
+%!assert (class (discrete_rnd (1:2, 1:2)), "double")
+%!assert (class (discrete_rnd (single (1:2), 1:2)), "single")
 ## FIXME: Maybe this should work, maybe it shouldn't.
 #%!assert(class (discrete_rnd (1:2, single(1:2))), "single");
 
@@ -91,14 +91,14 @@
 %!error discrete_rnd ()
 %!error discrete_rnd (1)
 %!error discrete_rnd (1:2,1:2, -1)
-%!error discrete_rnd (1:2,1:2, ones(2))
+%!error discrete_rnd (1:2,1:2, ones (2))
 %!error discrete_rnd (1:2,1:2, [2 -1 2])
-%!error discrete_rnd (1:2,1:2, 1, ones(2))
+%!error discrete_rnd (1:2,1:2, 1, ones (2))
 %!error discrete_rnd (1:2,1:2, 1, -1)
 %% test v,p verification
-%!error discrete_rnd (1, ones(2), ones(2,1))
-%!error discrete_rnd (1, ones(2,1), ones(1,1))
-%!error discrete_rnd (1, ones(2,1), [1 -1])
-%!error discrete_rnd (1, ones(2,1), [1 NaN])
-%!error discrete_rnd (1, ones(2,1), [0  0])
+%!error discrete_rnd (1, ones (2), ones (2,1))
+%!error discrete_rnd (1, ones (2,1), ones (1,1))
+%!error discrete_rnd (1, ones (2,1), [1 -1])
+%!error discrete_rnd (1, ones (2,1), [1 NaN])
+%!error discrete_rnd (1, ones (2,1), [0  0])
 
--- a/scripts/statistics/distributions/empirical_cdf.m
+++ b/scripts/statistics/distributions/empirical_cdf.m
@@ -46,17 +46,17 @@
 %! x = [-1 0.1 1.1 1.9 3];
 %! v = 0.1:0.2:1.9;
 %! y = [0 0.1 0.6 1 1];
-%!assert(empirical_cdf (x, v), y, eps);
-%!assert(empirical_cdf ([x(1) NaN x(3:5)], v), [0 NaN 0.6 1 1], eps);
+%!assert (empirical_cdf (x, v), y, eps)
+%!assert (empirical_cdf ([x(1) NaN x(3:5)], v), [0 NaN 0.6 1 1], eps)
 
 %% Test class of input preserved
-%!assert(empirical_cdf ([x, NaN], v), [y, NaN], eps);
-%!assert(empirical_cdf (single([x, NaN]), v), single([y, NaN]), eps);
-%!assert(empirical_cdf ([x, NaN], single(v)), single([y, NaN]), eps);
+%!assert (empirical_cdf ([x, NaN], v), [y, NaN], eps)
+%!assert (empirical_cdf (single ([x, NaN]), v), single ([y, NaN]), eps)
+%!assert (empirical_cdf ([x, NaN], single (v)), single ([y, NaN]), eps)
 
 %% Test input validation
 %!error empirical_cdf ()
 %!error empirical_cdf (1)
 %!error empirical_cdf (1,2,3)
-%!error empirical_cdf (1, ones(2))
+%!error empirical_cdf (1, ones (2))
 
--- a/scripts/statistics/distributions/empirical_inv.m
+++ b/scripts/statistics/distributions/empirical_inv.m
@@ -46,16 +46,16 @@
 %! x = [-1 0 0.1 0.5 1 2];
 %! v = 0.1:0.2:1.9;
 %! y = [NaN v(1) v(1) v(end/2) v(end) NaN];
-%!assert(empirical_inv (x, v), y, eps);
+%!assert (empirical_inv (x, v), y, eps)
 
 %% Test class of input preserved
-%!assert(empirical_inv ([x, NaN], v), [y, NaN], eps);
-%!assert(empirical_inv (single([x, NaN]), v), single([y, NaN]), eps);
-%!assert(empirical_inv ([x, NaN], single(v)), single([y, NaN]), eps);
+%!assert (empirical_inv ([x, NaN], v), [y, NaN], eps)
+%!assert (empirical_inv (single ([x, NaN]), v), single ([y, NaN]), eps)
+%!assert (empirical_inv ([x, NaN], single (v)), single ([y, NaN]), eps)
 
 %% Test input validation
 %!error empirical_inv ()
 %!error empirical_inv (1)
 %!error empirical_inv (1,2,3)
-%!error empirical_inv (1, ones(2))
+%!error empirical_inv (1, ones (2))
 
--- a/scripts/statistics/distributions/empirical_pdf.m
+++ b/scripts/statistics/distributions/empirical_pdf.m
@@ -46,15 +46,15 @@
 %! x = [-1 0.1 1.1 1.9 3];
 %! v = 0.1:0.2:1.9;
 %! y = [0 0.1 0.1 0.1 0];
-%!assert(empirical_pdf (x, v), y);
+%!assert (empirical_pdf (x, v), y)
 
 %% Test class of input preserved
-%!assert(empirical_pdf (single(x), v), single (y));
-%!assert(empirical_pdf (x, single(v)), single (y));
+%!assert (empirical_pdf (single (x), v), single (y))
+%!assert (empirical_pdf (x, single (v)), single (y))
 
 %% Test input validation
 %!error empirical_pdf ()
 %!error empirical_pdf (1)
 %!error empirical_pdf (1,2,3)
-%!error empirical_inv (1, ones(2))
+%!error empirical_inv (1, ones (2))
 
--- a/scripts/statistics/distributions/empirical_rnd.m
+++ b/scripts/statistics/distributions/empirical_rnd.m
@@ -53,17 +53,17 @@
 endfunction
 
 
-%!assert(size (empirical_rnd (ones (3, 1))), [3, 1]);
-%!assert(size (empirical_rnd (1:2, [4 1])), [4, 1]);
-%!assert(size (empirical_rnd (1:2, 4, 1)), [4, 1]);
+%!assert (size (empirical_rnd (ones (3, 1))), [3, 1])
+%!assert (size (empirical_rnd (1:2, [4 1])), [4, 1])
+%!assert (size (empirical_rnd (1:2, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (empirical_rnd (1:2, 1)), "double");
-%!assert(class (empirical_rnd (single(1:2), 1)), "single");
+%!assert (class (empirical_rnd (1:2, 1)), "double")
+%!assert (class (empirical_rnd (single (1:2), 1)), "single")
 
 %% Test input validation
 %!error empirical_rnd ()
-%!error empirical_rnd (ones(2), 1)
+%!error empirical_rnd (ones (2), 1)
 %% test data verification
-%!error empirical_rnd (ones(2), 1, 1)
+%!error empirical_rnd (ones (2), 1, 1)
 
--- a/scripts/statistics/distributions/expcdf.m
+++ b/scripts/statistics/distributions/expcdf.m
@@ -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
@@ -71,21 +71,21 @@
 %!shared x,y
 %! x = [-1 0 0.5 1 Inf];
 %! y = [0, 1 - exp(-x(2:end)/2)];
-%!assert(expcdf (x, 2*ones(1,5)), y);
-%!assert(expcdf (x, 2), y);
-%!assert(expcdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)]);
+%!assert (expcdf (x, 2*ones (1,5)), y)
+%!assert (expcdf (x, 2), y)
+%!assert (expcdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)])
 
 %% Test class of input preserved
-%!assert(expcdf ([x, NaN], 2), [y, NaN]);
-%!assert(expcdf (single([x, NaN]), 2), single([y, NaN]));
-%!assert(expcdf ([x, NaN], single(2)), single([y, NaN]));
+%!assert (expcdf ([x, NaN], 2), [y, NaN])
+%!assert (expcdf (single ([x, NaN]), 2), single ([y, NaN]))
+%!assert (expcdf ([x, NaN], single (2)), single ([y, NaN]))
 
 %% Test input validation
 %!error expcdf ()
 %!error expcdf (1)
 %!error expcdf (1,2,3)
-%!error expcdf (ones(3),ones(2))
-%!error expcdf (ones(2),ones(3))
+%!error expcdf (ones (3), ones (2))
+%!error expcdf (ones (2), ones (3))
 %!error expcdf (i, 2)
 %!error expcdf (2, i)
 
--- a/scripts/statistics/distributions/expinv.m
+++ b/scripts/statistics/distributions/expinv.m
@@ -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));
@@ -74,22 +74,22 @@
 
 %!shared x
 %! x = [-1 0 0.3934693402873666 1 2];
-%!assert(expinv (x, 2*ones(1,5)), [NaN 0 1 Inf NaN], eps);
-%!assert(expinv (x, 2), [NaN 0 1 Inf NaN], eps);
-%!assert(expinv (x, 2*[1 0 NaN 1 1]), [NaN NaN NaN Inf NaN], eps);
-%!assert(expinv ([x(1:2) NaN x(4:5)], 2), [NaN 0 NaN Inf NaN], eps);
+%!assert (expinv (x, 2*ones (1,5)), [NaN 0 1 Inf NaN], eps)
+%!assert (expinv (x, 2), [NaN 0 1 Inf NaN], eps)
+%!assert (expinv (x, 2*[1 0 NaN 1 1]), [NaN NaN NaN Inf NaN], eps)
+%!assert (expinv ([x(1:2) NaN x(4:5)], 2), [NaN 0 NaN Inf NaN], eps)
 
 %% Test class of input preserved
-%!assert(expinv ([x, NaN], 2), [NaN 0 1 Inf NaN NaN], eps);
-%!assert(expinv (single([x, NaN]), 2), single([NaN 0 1 Inf NaN NaN]), eps);
-%!assert(expinv ([x, NaN], single(2)), single([NaN 0 1 Inf NaN NaN]), eps);
+%!assert (expinv ([x, NaN], 2), [NaN 0 1 Inf NaN NaN], eps)
+%!assert (expinv (single ([x, NaN]), 2), single ([NaN 0 1 Inf NaN NaN]), eps)
+%!assert (expinv ([x, NaN], single (2)), single ([NaN 0 1 Inf NaN NaN]), eps)
 
 %% Test input validation
 %!error expinv ()
 %!error expinv (1)
 %!error expinv (1,2,3)
-%!error expinv (ones(3),ones(2))
-%!error expinv (ones(2),ones(3))
+%!error expinv (ones (3), ones (2))
+%!error expinv (ones (2), ones (3))
 %!error expinv (i, 2)
 %!error expinv (2, i)
 
--- a/scripts/statistics/distributions/exppdf.m
+++ b/scripts/statistics/distributions/exppdf.m
@@ -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
@@ -65,20 +65,20 @@
 %!shared x,y
 %! x = [-1 0 0.5 1 Inf];
 %! y = gampdf (x, 1, 2);
-%!assert(exppdf (x, 2*ones(1,5)), y);
-%!assert(exppdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)]);
-%!assert(exppdf ([x, NaN], 2), [y, NaN]);
+%!assert (exppdf (x, 2*ones (1,5)), y)
+%!assert (exppdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)])
+%!assert (exppdf ([x, NaN], 2), [y, NaN])
 
 %% Test class of input preserved
-%!assert(exppdf (single([x, NaN]), 2), single([y, NaN]));
-%!assert(exppdf ([x, NaN], single(2)), single([y, NaN]));
+%!assert (exppdf (single ([x, NaN]), 2), single ([y, NaN]))
+%!assert (exppdf ([x, NaN], single (2)), single ([y, NaN]))
 
 %% Test input validation
 %!error exppdf ()
 %!error exppdf (1)
 %!error exppdf (1,2,3)
-%!error exppdf (ones(3),ones(2))
-%!error exppdf (ones(2),ones(3))
+%!error exppdf (ones (3), ones (2))
+%!error exppdf (ones (2), ones (3))
 %!error exppdf (i, 2)
 %!error exppdf (2, i)
 
--- a/scripts/statistics/distributions/exprnd.m
+++ b/scripts/statistics/distributions/exprnd.m
@@ -77,7 +77,7 @@
 
   if (isscalar (lambda))
     if ((lambda > 0) && (lambda < Inf))
-      rnd = rande (sz) * lambda;
+      rnd = rande (sz, cls) * lambda;
     else
       rnd = NaN (sz, cls);
     endif
@@ -85,33 +85,33 @@
     rnd = NaN (sz, cls);
 
     k = (lambda > 0) & (lambda < Inf);
-    rnd(k) = rande (sum (k(:)), 1) .* lambda(k)(:);
+    rnd(k) = rande (sum (k(:)), 1, cls) .* lambda(k)(:);
   endif
 
 endfunction
 
 
-%!assert(size (exprnd (2)), [1, 1]);
-%!assert(size (exprnd (ones(2,1))), [2, 1]);
-%!assert(size (exprnd (ones(2,2))), [2, 2]);
-%!assert(size (exprnd (1, 3)), [3, 3]);
-%!assert(size (exprnd (1, [4 1])), [4, 1]);
-%!assert(size (exprnd (1, 4, 1)), [4, 1]);
+%!assert (size (exprnd (2)), [1, 1])
+%!assert (size (exprnd (ones (2,1))), [2, 1])
+%!assert (size (exprnd (ones (2,2))), [2, 2])
+%!assert (size (exprnd (1, 3)), [3, 3])
+%!assert (size (exprnd (1, [4 1])), [4, 1])
+%!assert (size (exprnd (1, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (exprnd (1)), "double");
-%!assert(class (exprnd (single(1))), "single");
-%!assert(class (exprnd (single([1 1]))), "single");
+%!assert (class (exprnd (1)), "double")
+%!assert (class (exprnd (single (1))), "single")
+%!assert (class (exprnd (single ([1 1]))), "single")
 
 %% Test input validation
 %!error exprnd ()
 %!error exprnd (1, -1)
-%!error exprnd (1, ones(2))
+%!error exprnd (1, ones (2))
 %!error exprnd (i)
 %!error exprnd (1, [2 -1 2])
 %!error exprnd (1, 2, -1)
-%!error exprnd (1, 2, ones(2))
-%!error exprnd (ones(2,2), 3)
-%!error exprnd (ones(2,2), [3, 2])
-%!error exprnd (ones(2,2), 2, 3)
+%!error exprnd (1, 2, ones (2))
+%!error exprnd (ones (2,2), 3)
+%!error exprnd (ones (2,2), [3, 2])
+%!error exprnd (ones (2,2), 2, 3)
 
--- a/scripts/statistics/distributions/fcdf.m
+++ b/scripts/statistics/distributions/fcdf.m
@@ -69,27 +69,27 @@
 %!shared x,y
 %! x = [-1 0 0.5 1 2 Inf];
 %! y = [0 0 1/3 1/2 2/3 1];
-%!assert(fcdf (x, 2*ones(1,6), 2*ones(1,6)), y, eps);
-%!assert(fcdf (x, 2, 2*ones(1,6)), y, eps);
-%!assert(fcdf (x, 2*ones(1,6), 2), y, eps);
-%!assert(fcdf (x, [0 NaN Inf 2 2 2], 2), [NaN NaN NaN y(4:6)], eps);
-%!assert(fcdf (x, 2, [0 NaN Inf 2 2 2]), [NaN NaN NaN y(4:6)], eps);
-%!assert(fcdf ([x(1:2) NaN x(4:6)], 2, 2), [y(1:2) NaN y(4:6)], eps);
+%!assert (fcdf (x, 2*ones (1,6), 2*ones (1,6)), y, eps)
+%!assert (fcdf (x, 2, 2*ones (1,6)), y, eps)
+%!assert (fcdf (x, 2*ones (1,6), 2), y, eps)
+%!assert (fcdf (x, [0 NaN Inf 2 2 2], 2), [NaN NaN NaN y(4:6)], eps)
+%!assert (fcdf (x, 2, [0 NaN Inf 2 2 2]), [NaN NaN NaN y(4:6)], eps)
+%!assert (fcdf ([x(1:2) NaN x(4:6)], 2, 2), [y(1:2) NaN y(4:6)], eps)
 
 %% Test class of input preserved
-%!assert(fcdf ([x, NaN], 2, 2), [y, NaN], eps);
-%!assert(fcdf (single([x, NaN]), 2, 2), single([y, NaN]), eps("single"));
-%!assert(fcdf ([x, NaN], single(2), 2), single([y, NaN]), eps("single"));
-%!assert(fcdf ([x, NaN], 2, single(2)), single([y, NaN]), eps("single"));
+%!assert (fcdf ([x, NaN], 2, 2), [y, NaN], eps)
+%!assert (fcdf (single ([x, NaN]), 2, 2), single ([y, NaN]), eps ("single"))
+%!assert (fcdf ([x, NaN], single (2), 2), single ([y, NaN]), eps ("single"))
+%!assert (fcdf ([x, NaN], 2, single (2)), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error fcdf ()
 %!error fcdf (1)
 %!error fcdf (1,2)
 %!error fcdf (1,2,3,4)
-%!error fcdf (ones(3),ones(2),ones(2))
-%!error fcdf (ones(2),ones(3),ones(2))
-%!error fcdf (ones(2),ones(2),ones(3))
+%!error fcdf (ones (3), ones (2), ones (2))
+%!error fcdf (ones (2), ones (3), ones (2))
+%!error fcdf (ones (2), ones (2), ones (3))
 %!error fcdf (i, 2, 2)
 %!error fcdf (2, i, 2)
 %!error fcdf (2, 2, i)
--- a/scripts/statistics/distributions/finv.m
+++ b/scripts/statistics/distributions/finv.m
@@ -66,27 +66,27 @@
 
 %!shared x
 %! x = [-1 0 0.5 1 2];
-%!assert(finv (x, 2*ones(1,5), 2*ones(1,5)), [NaN 0 1 Inf NaN]);
-%!assert(finv (x, 2, 2*ones(1,5)), [NaN 0 1 Inf NaN]);
-%!assert(finv (x, 2*ones(1,5), 2), [NaN 0 1 Inf NaN]);
-%!assert(finv (x, [2 -Inf NaN Inf 2], 2), [NaN NaN NaN NaN NaN]);
-%!assert(finv (x, 2, [2 -Inf NaN Inf 2]), [NaN NaN NaN NaN NaN]);
-%!assert(finv ([x(1:2) NaN x(4:5)], 2, 2), [NaN 0 NaN Inf NaN]);
+%!assert (finv (x, 2*ones (1,5), 2*ones (1,5)), [NaN 0 1 Inf NaN])
+%!assert (finv (x, 2, 2*ones (1,5)), [NaN 0 1 Inf NaN])
+%!assert (finv (x, 2*ones (1,5), 2), [NaN 0 1 Inf NaN])
+%!assert (finv (x, [2 -Inf NaN Inf 2], 2), [NaN NaN NaN NaN NaN])
+%!assert (finv (x, 2, [2 -Inf NaN Inf 2]), [NaN NaN NaN NaN NaN])
+%!assert (finv ([x(1:2) NaN x(4:5)], 2, 2), [NaN 0 NaN Inf NaN])
 
 %% Test class of input preserved
-%!assert(finv ([x, NaN], 2, 2), [NaN 0 1 Inf NaN NaN]);
-%!assert(finv (single([x, NaN]), 2, 2), single([NaN 0 1 Inf NaN NaN]));
-%!assert(finv ([x, NaN], single(2), 2), single([NaN 0 1 Inf NaN NaN]));
-%!assert(finv ([x, NaN], 2, single(2)), single([NaN 0 1 Inf NaN NaN]));
+%!assert (finv ([x, NaN], 2, 2), [NaN 0 1 Inf NaN NaN])
+%!assert (finv (single ([x, NaN]), 2, 2), single ([NaN 0 1 Inf NaN NaN]))
+%!assert (finv ([x, NaN], single (2), 2), single ([NaN 0 1 Inf NaN NaN]))
+%!assert (finv ([x, NaN], 2, single (2)), single ([NaN 0 1 Inf NaN NaN]))
 
 %% Test input validation
 %!error finv ()
 %!error finv (1)
 %!error finv (1,2)
 %!error finv (1,2,3,4)
-%!error finv (ones(3),ones(2),ones(2))
-%!error finv (ones(2),ones(3),ones(2))
-%!error finv (ones(2),ones(2),ones(3))
+%!error finv (ones (3), ones (2), ones (2))
+%!error finv (ones (2), ones (3), ones (2))
+%!error finv (ones (2), ones (2), ones (3))
 %!error finv (i, 2, 2)
 %!error finv (2, i, 2)
 %!error finv (2, 2, i)
--- a/scripts/statistics/distributions/fpdf.m
+++ b/scripts/statistics/distributions/fpdf.m
@@ -74,31 +74,31 @@
 %! x = rand (10,1);
 %! x = x(x > 0.1 & x < 0.9);
 %! y = tpdf (sqrt (x), 2) ./ sqrt (x);
-%! assert(fpdf (x, 1, 2), y, 5*eps);
+%! assert (fpdf (x, 1, 2), y, 5*eps);
 
 %!shared x,y
 %! x = [-1 0 0.5 1 2];
 %! y = [0 0 4/9 1/4 1/9];
-%!assert(fpdf (x, 2*ones(1,5), 2*ones(1,5)), y, eps);
-%!assert(fpdf (x, 2, 2*ones(1,5)), y, eps);
-%!assert(fpdf (x, 2*ones(1,5), 2), y, eps);
-%!assert(fpdf (x, [0 NaN Inf 2 2], 2), [NaN NaN NaN y(4:5)], eps);
-%!assert(fpdf (x, 2, [0 NaN Inf 2 2]), [NaN NaN NaN y(4:5)], eps);
-%!assert(fpdf ([x, NaN], 2, 2), [y, NaN], eps);
+%!assert (fpdf (x, 2*ones (1,5), 2*ones (1,5)), y, eps)
+%!assert (fpdf (x, 2, 2*ones (1,5)), y, eps)
+%!assert (fpdf (x, 2*ones (1,5), 2), y, eps)
+%!assert (fpdf (x, [0 NaN Inf 2 2], 2), [NaN NaN NaN y(4:5)], eps)
+%!assert (fpdf (x, 2, [0 NaN Inf 2 2]), [NaN NaN NaN y(4:5)], eps)
+%!assert (fpdf ([x, NaN], 2, 2), [y, NaN], eps)
 
 %% Test class of input preserved
-%!assert(fpdf (single([x, NaN]), 2, 2), single([y, NaN]), eps("single"));
-%!assert(fpdf ([x, NaN], single(2), 2), single([y, NaN]), eps("single"));
-%!assert(fpdf ([x, NaN], 2, single(2)), single([y, NaN]), eps("single"));
+%!assert (fpdf (single ([x, NaN]), 2, 2), single ([y, NaN]), eps ("single"))
+%!assert (fpdf ([x, NaN], single (2), 2), single ([y, NaN]), eps ("single"))
+%!assert (fpdf ([x, NaN], 2, single (2)), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error fpdf ()
 %!error fpdf (1)
 %!error fpdf (1,2)
 %!error fpdf (1,2,3,4)
-%!error fpdf (ones(3),ones(2),ones(2))
-%!error fpdf (ones(2),ones(3),ones(2))
-%!error fpdf (ones(2),ones(2),ones(3))
+%!error fpdf (ones (3), ones (2), ones (2))
+%!error fpdf (ones (2), ones (3), ones (2))
+%!error fpdf (ones (2), ones (2), ones (3))
 %!error fpdf (i, 2, 2)
 %!error fpdf (2, i, 2)
 %!error fpdf (2, 2, i)
--- a/scripts/statistics/distributions/frnd.m
+++ b/scripts/statistics/distributions/frnd.m
@@ -84,7 +84,7 @@
 
   if (isscalar (m) && isscalar (n))
     if ((m > 0) && (m < Inf) && (n > 0) && (n < Inf))
-      rnd = n/m * randg (m/2, sz) ./ randg (n/2, sz);
+      rnd = n/m * randg (m/2, sz, cls) ./ randg (n/2, sz, cls);
     else
       rnd = NaN (sz, cls);
     endif
@@ -92,41 +92,41 @@
     rnd = NaN (sz, cls);
 
     k = (m > 0) & (m < Inf) & (n > 0) & (n < Inf);
-    rnd(k) = n(k) ./ m(k) .* randg (m(k)/2) ./ randg (n(k)/2);
+    rnd(k) = n(k) ./ m(k) .* randg (m(k)/2, cls) ./ randg (n(k)/2, cls);
   endif
 
 endfunction
 
 
-%!assert(size (frnd (1,2)), [1, 1]);
-%!assert(size (frnd (ones(2,1), 2)), [2, 1]);
-%!assert(size (frnd (ones(2,2), 2)), [2, 2]);
-%!assert(size (frnd (1, 2*ones(2,1))), [2, 1]);
-%!assert(size (frnd (1, 2*ones(2,2))), [2, 2]);
-%!assert(size (frnd (1, 2, 3)), [3, 3]);
-%!assert(size (frnd (1, 2, [4 1])), [4, 1]);
-%!assert(size (frnd (1, 2, 4, 1)), [4, 1]);
+%!assert (size (frnd (1,2)), [1, 1])
+%!assert (size (frnd (ones (2,1), 2)), [2, 1])
+%!assert (size (frnd (ones (2,2), 2)), [2, 2])
+%!assert (size (frnd (1, 2*ones (2,1))), [2, 1])
+%!assert (size (frnd (1, 2*ones (2,2))), [2, 2])
+%!assert (size (frnd (1, 2, 3)), [3, 3])
+%!assert (size (frnd (1, 2, [4 1])), [4, 1])
+%!assert (size (frnd (1, 2, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (frnd (1, 2)), "double");
-%!assert(class (frnd (single(1), 2)), "single");
-%!assert(class (frnd (single([1 1]), 2)), "single");
-%!assert(class (frnd (1, single(2))), "single");
-%!assert(class (frnd (1, single([2 2]))), "single");
+%!assert (class (frnd (1, 2)), "double")
+%!assert (class (frnd (single (1), 2)), "single")
+%!assert (class (frnd (single ([1 1]), 2)), "single")
+%!assert (class (frnd (1, single (2))), "single")
+%!assert (class (frnd (1, single ([2 2]))), "single")
 
 %% Test input validation
 %!error frnd ()
 %!error frnd (1)
-%!error frnd (ones(3),ones(2))
-%!error frnd (ones(2),ones(3))
+%!error frnd (ones (3), ones (2))
+%!error frnd (ones (2), ones (3))
 %!error frnd (i, 2)
 %!error frnd (2, i)
 %!error frnd (1,2, -1)
-%!error frnd (1,2, ones(2))
+%!error frnd (1,2, ones (2))
 %!error frnd (1, 2, [2 -1 2])
-%!error frnd (1,2, 1, ones(2))
+%!error frnd (1,2, 1, ones (2))
 %!error frnd (1,2, 1, -1)
-%!error frnd (ones(2,2), 2, 3)
-%!error frnd (ones(2,2), 2, [3, 2])
-%!error frnd (ones(2,2), 2, 2, 3)
+%!error frnd (ones (2,2), 2, 3)
+%!error frnd (ones (2,2), 2, [3, 2])
+%!error frnd (ones (2,2), 2, 2, 3)
 
--- a/scripts/statistics/distributions/gamcdf.m
+++ b/scripts/statistics/distributions/gamcdf.m
@@ -66,25 +66,25 @@
 %!shared x,y
 %! x = [-1 0 0.5 1 2 Inf];
 %! y = [0, gammainc(x(2:end), 1)];
-%!assert(gamcdf (x, ones(1,6), ones(1,6)), y);
-%!assert(gamcdf (x, 1, ones(1,6)), y);
-%!assert(gamcdf (x, ones(1,6), 1), y);
-%!assert(gamcdf (x, [0 -Inf NaN Inf 1 1], 1), [NaN NaN NaN NaN y(5:6)]);
-%!assert(gamcdf (x, 1, [0 -Inf NaN Inf 1 1]), [NaN NaN NaN NaN y(5:6)]);
-%!assert(gamcdf ([x(1:2) NaN x(4:6)], 1, 1), [y(1:2) NaN y(4:6)]);
+%!assert (gamcdf (x, ones (1,6), ones (1,6)), y)
+%!assert (gamcdf (x, 1, ones (1,6)), y)
+%!assert (gamcdf (x, ones (1,6), 1), y)
+%!assert (gamcdf (x, [0 -Inf NaN Inf 1 1], 1), [NaN NaN NaN NaN y(5:6)])
+%!assert (gamcdf (x, 1, [0 -Inf NaN Inf 1 1]), [NaN NaN NaN NaN y(5:6)])
+%!assert (gamcdf ([x(1:2) NaN x(4:6)], 1, 1), [y(1:2) NaN y(4:6)])
 
 %% Test class of input preserved
-%!assert(gamcdf ([x, NaN], 1, 1), [y, NaN]);
-%!assert(gamcdf (single([x, NaN]), 1, 1), single([y, NaN]), eps("single"));
+%!assert (gamcdf ([x, NaN], 1, 1), [y, NaN])
+%!assert (gamcdf (single ([x, NaN]), 1, 1), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error gamcdf ()
 %!error gamcdf (1)
 %!error gamcdf (1,2)
 %!error gamcdf (1,2,3,4)
-%!error gamcdf (ones(3),ones(2),ones(2))
-%!error gamcdf (ones(2),ones(3),ones(2))
-%!error gamcdf (ones(2),ones(2),ones(3))
+%!error gamcdf (ones (3), ones (2), ones (2))
+%!error gamcdf (ones (2), ones (3), ones (2))
+%!error gamcdf (ones (2), ones (2), ones (3))
 %!error gamcdf (i, 2, 2)
 %!error gamcdf (2, i, 2)
 %!error gamcdf (2, 2, i)
--- a/scripts/statistics/distributions/gaminv.m
+++ b/scripts/statistics/distributions/gaminv.m
@@ -102,27 +102,27 @@
 
 %!shared x
 %! x = [-1 0 0.63212055882855778 1 2];
-%!assert(gaminv (x, ones(1,5), ones(1,5)), [NaN 0 1 Inf NaN], eps);
-%!assert(gaminv (x, 1, ones(1,5)), [NaN 0 1 Inf NaN], eps);
-%!assert(gaminv (x, ones(1,5), 1), [NaN 0 1 Inf NaN], eps);
-%!assert(gaminv (x, [1 -Inf NaN Inf 1], 1), [NaN NaN NaN NaN NaN]);
-%!assert(gaminv (x, 1, [1 -Inf NaN Inf 1]), [NaN NaN NaN NaN NaN]);
-%!assert(gaminv ([x(1:2) NaN x(4:5)], 1, 1), [NaN 0 NaN Inf NaN]);
+%!assert (gaminv (x, ones (1,5), ones (1,5)), [NaN 0 1 Inf NaN], eps)
+%!assert (gaminv (x, 1, ones (1,5)), [NaN 0 1 Inf NaN], eps)
+%!assert (gaminv (x, ones (1,5), 1), [NaN 0 1 Inf NaN], eps)
+%!assert (gaminv (x, [1 -Inf NaN Inf 1], 1), [NaN NaN NaN NaN NaN])
+%!assert (gaminv (x, 1, [1 -Inf NaN Inf 1]), [NaN NaN NaN NaN NaN])
+%!assert (gaminv ([x(1:2) NaN x(4:5)], 1, 1), [NaN 0 NaN Inf NaN])
 
 %% Test class of input preserved
-%!assert(gaminv ([x, NaN], 1, 1), [NaN 0 1 Inf NaN NaN], eps);
-%!assert(gaminv (single([x, NaN]), 1, 1), single([NaN 0 1 Inf NaN NaN]), eps("single"));
-%!assert(gaminv ([x, NaN], single(1), 1), single([NaN 0 1 Inf NaN NaN]), eps("single"));
-%!assert(gaminv ([x, NaN], 1, single(1)), single([NaN 0 1 Inf NaN NaN]), eps("single"));
+%!assert (gaminv ([x, NaN], 1, 1), [NaN 0 1 Inf NaN NaN], eps)
+%!assert (gaminv (single ([x, NaN]), 1, 1), single ([NaN 0 1 Inf NaN NaN]), eps ("single"))
+%!assert (gaminv ([x, NaN], single (1), 1), single ([NaN 0 1 Inf NaN NaN]), eps ("single"))
+%!assert (gaminv ([x, NaN], 1, single (1)), single ([NaN 0 1 Inf NaN NaN]), eps ("single"))
 
 %% Test input validation
 %!error gaminv ()
 %!error gaminv (1)
 %!error gaminv (1,2)
 %!error gaminv (1,2,3,4)
-%!error gaminv (ones(3),ones(2),ones(2))
-%!error gaminv (ones(2),ones(3),ones(2))
-%!error gaminv (ones(2),ones(2),ones(3))
+%!error gaminv (ones (3), ones (2), ones (2))
+%!error gaminv (ones (2), ones (3), ones (2))
+%!error gaminv (ones (2), ones (2), ones (3))
 %!error gaminv (i, 2, 2)
 %!error gaminv (2, i, 2)
 %!error gaminv (2, 2, i)
--- a/scripts/statistics/distributions/gampdf.m
+++ b/scripts/statistics/distributions/gampdf.m
@@ -77,26 +77,26 @@
 %!shared x,y
 %! x = [-1 0 0.5 1 Inf];
 %! y = [0 exp(-x(2:end))];
-%!assert(gampdf (x, ones(1,5), ones(1,5)), y);
-%!assert(gampdf (x, 1, ones(1,5)), y);
-%!assert(gampdf (x, ones(1,5), 1), y);
-%!assert(gampdf (x, [0 -Inf NaN Inf 1], 1), [NaN NaN NaN NaN y(5)]);
-%!assert(gampdf (x, 1, [0 -Inf NaN Inf 1]), [NaN NaN NaN 0 y(5)]);
-%!assert(gampdf ([x, NaN], 1, 1), [y, NaN]);
+%!assert (gampdf (x, ones (1,5), ones (1,5)), y)
+%!assert (gampdf (x, 1, ones (1,5)), y)
+%!assert (gampdf (x, ones (1,5), 1), y)
+%!assert (gampdf (x, [0 -Inf NaN Inf 1], 1), [NaN NaN NaN NaN y(5)])
+%!assert (gampdf (x, 1, [0 -Inf NaN Inf 1]), [NaN NaN NaN 0 y(5)])
+%!assert (gampdf ([x, NaN], 1, 1), [y, NaN])
 
 %% Test class of input preserved
-%!assert(gampdf (single([x, NaN]), 1, 1), single([y, NaN]));
-%!assert(gampdf ([x, NaN], single(1), 1), single([y, NaN]));
-%!assert(gampdf ([x, NaN], 1, single(1)), single([y, NaN]));
+%!assert (gampdf (single ([x, NaN]), 1, 1), single ([y, NaN]))
+%!assert (gampdf ([x, NaN], single (1), 1), single ([y, NaN]))
+%!assert (gampdf ([x, NaN], 1, single (1)), single ([y, NaN]))
 
 %% Test input validation
 %!error gampdf ()
 %!error gampdf (1)
 %!error gampdf (1,2)
 %!error gampdf (1,2,3,4)
-%!error gampdf (ones(3),ones(2),ones(2))
-%!error gampdf (ones(2),ones(3),ones(2))
-%!error gampdf (ones(2),ones(2),ones(3))
+%!error gampdf (ones (3), ones (2), ones (2))
+%!error gampdf (ones (2), ones (3), ones (2))
+%!error gampdf (ones (2), ones (2), ones (3))
 %!error gampdf (i, 2, 2)
 %!error gampdf (2, i, 2)
 %!error gampdf (2, 2, i)
--- a/scripts/statistics/distributions/gamrnd.m
+++ b/scripts/statistics/distributions/gamrnd.m
@@ -84,10 +84,7 @@
 
   if (isscalar (a) && isscalar (b))
     if ((a > 0) && (a < Inf) && (b > 0) && (b < Inf))
-      rnd = b * randg (a, sz);
-      if (strcmp (cls, "single"))
-        rnd = single (rnd);
-      endif
+      rnd = b * randg (a, sz, cls);
     else 
       rnd = NaN (sz, cls);
     endif
@@ -95,41 +92,41 @@
     rnd = NaN (sz, cls);
 
     k = (a > 0) & (a < Inf) & (b > 0) & (b < Inf);
-    rnd(k) = b(k) .* randg (a(k));
+    rnd(k) = b(k) .* randg (a(k), cls);
   endif
 
 endfunction
 
 
-%!assert(size (gamrnd (1,2)), [1, 1]);
-%!assert(size (gamrnd (ones(2,1), 2)), [2, 1]);
-%!assert(size (gamrnd (ones(2,2), 2)), [2, 2]);
-%!assert(size (gamrnd (1, 2*ones(2,1))), [2, 1]);
-%!assert(size (gamrnd (1, 2*ones(2,2))), [2, 2]);
-%!assert(size (gamrnd (1, 2, 3)), [3, 3]);
-%!assert(size (gamrnd (1, 2, [4 1])), [4, 1]);
-%!assert(size (gamrnd (1, 2, 4, 1)), [4, 1]);
+%!assert (size (gamrnd (1,2)), [1, 1])
+%!assert (size (gamrnd (ones (2,1), 2)), [2, 1])
+%!assert (size (gamrnd (ones (2,2), 2)), [2, 2])
+%!assert (size (gamrnd (1, 2*ones (2,1))), [2, 1])
+%!assert (size (gamrnd (1, 2*ones (2,2))), [2, 2])
+%!assert (size (gamrnd (1, 2, 3)), [3, 3])
+%!assert (size (gamrnd (1, 2, [4 1])), [4, 1])
+%!assert (size (gamrnd (1, 2, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (gamrnd (1, 2)), "double");
-%!assert(class (gamrnd (single(1), 2)), "single");
-%!assert(class (gamrnd (single([1 1]), 2)), "single");
-%!assert(class (gamrnd (1, single(2))), "single");
-%!assert(class (gamrnd (1, single([2 2]))), "single");
+%!assert (class (gamrnd (1, 2)), "double")
+%!assert (class (gamrnd (single (1), 2)), "single")
+%!assert (class (gamrnd (single ([1 1]), 2)), "single")
+%!assert (class (gamrnd (1, single (2))), "single")
+%!assert (class (gamrnd (1, single ([2 2]))), "single")
 
 %% Test input validation
 %!error gamrnd ()
 %!error gamrnd (1)
-%!error gamrnd (ones(3),ones(2))
-%!error gamrnd (ones(2),ones(3))
+%!error gamrnd (ones (3), ones (2))
+%!error gamrnd (ones (2), ones (3))
 %!error gamrnd (i, 2)
 %!error gamrnd (2, i)
 %!error gamrnd (1,2, -1)
-%!error gamrnd (1,2, ones(2))
+%!error gamrnd (1,2, ones (2))
 %!error gamrnd (1, 2, [2 -1 2])
-%!error gamrnd (1,2, 1, ones(2))
+%!error gamrnd (1,2, 1, ones (2))
 %!error gamrnd (1,2, 1, -1)
-%!error gamrnd (ones(2,2), 2, 3)
-%!error gamrnd (ones(2,2), 2, [3, 2])
-%!error gamrnd (ones(2,2), 2, 2, 3)
+%!error gamrnd (ones (2,2), 2, 3)
+%!error gamrnd (ones (2,2), 2, [3, 2])
+%!error gamrnd (ones (2,2), 2, 2, 3)
 
--- a/scripts/statistics/distributions/geocdf.m
+++ b/scripts/statistics/distributions/geocdf.m
@@ -68,22 +68,22 @@
 %!shared x,y
 %! x = [-1 0 1 Inf];
 %! y = [0 0.5 0.75 1];
-%!assert(geocdf (x, 0.5*ones(1,4)), y);
-%!assert(geocdf (x, 0.5), y);
-%!assert(geocdf (x, 0.5*[-1 NaN 4 1]), [NaN NaN NaN y(4)]);
-%!assert(geocdf ([x(1:2) NaN x(4)], 0.5), [y(1:2) NaN y(4)]);
+%!assert (geocdf (x, 0.5*ones (1,4)), y)
+%!assert (geocdf (x, 0.5), y)
+%!assert (geocdf (x, 0.5*[-1 NaN 4 1]), [NaN NaN NaN y(4)])
+%!assert (geocdf ([x(1:2) NaN x(4)], 0.5), [y(1:2) NaN y(4)])
 
 %% Test class of input preserved
-%!assert(geocdf ([x, NaN], 0.5), [y, NaN]);
-%!assert(geocdf (single([x, NaN]), 0.5), single([y, NaN]));
-%!assert(geocdf ([x, NaN], single(0.5)), single([y, NaN]));
+%!assert (geocdf ([x, NaN], 0.5), [y, NaN])
+%!assert (geocdf (single ([x, NaN]), 0.5), single ([y, NaN]))
+%!assert (geocdf ([x, NaN], single (0.5)), single ([y, NaN]))
 
 %% Test input validation
 %!error geocdf ()
 %!error geocdf (1)
 %!error geocdf (1,2,3)
-%!error geocdf (ones(3),ones(2))
-%!error geocdf (ones(2),ones(3))
+%!error geocdf (ones (3), ones (2))
+%!error geocdf (ones (2), ones (3))
 %!error geocdf (i, 2)
 %!error geocdf (2, i)
 
--- a/scripts/statistics/distributions/geoinv.m
+++ b/scripts/statistics/distributions/geoinv.m
@@ -64,22 +64,22 @@
 
 %!shared x
 %! x = [-1 0 0.75 1 2];
-%!assert(geoinv (x, 0.5*ones(1,5)), [NaN 0 1 Inf NaN]);
-%!assert(geoinv (x, 0.5), [NaN 0 1 Inf NaN]);
-%!assert(geoinv (x, 0.5*[1 -1 NaN 4 1]), [NaN NaN NaN NaN NaN]);
-%!assert(geoinv ([x(1:2) NaN x(4:5)], 0.5), [NaN 0 NaN Inf NaN]);
+%!assert (geoinv (x, 0.5*ones (1,5)), [NaN 0 1 Inf NaN])
+%!assert (geoinv (x, 0.5), [NaN 0 1 Inf NaN])
+%!assert (geoinv (x, 0.5*[1 -1 NaN 4 1]), [NaN NaN NaN NaN NaN])
+%!assert (geoinv ([x(1:2) NaN x(4:5)], 0.5), [NaN 0 NaN Inf NaN])
 
 %% Test class of input preserved
-%!assert(geoinv ([x, NaN], 0.5), [NaN 0 1 Inf NaN NaN]);
-%!assert(geoinv (single([x, NaN]), 0.5), single([NaN 0 1 Inf NaN NaN]));
-%!assert(geoinv ([x, NaN], single(0.5)), single([NaN 0 1 Inf NaN NaN]));
+%!assert (geoinv ([x, NaN], 0.5), [NaN 0 1 Inf NaN NaN])
+%!assert (geoinv (single ([x, NaN]), 0.5), single ([NaN 0 1 Inf NaN NaN]))
+%!assert (geoinv ([x, NaN], single (0.5)), single ([NaN 0 1 Inf NaN NaN]))
 
 %% Test input validation
 %!error geoinv ()
 %!error geoinv (1)
 %!error geoinv (1,2,3)
-%!error geoinv (ones(3),ones(2))
-%!error geoinv (ones(2),ones(3))
+%!error geoinv (ones (3), ones (2))
+%!error geoinv (ones (2), ones (3))
 %!error geoinv (i, 2)
 %!error geoinv (2, i)
 
--- a/scripts/statistics/distributions/geopdf.m
+++ b/scripts/statistics/distributions/geopdf.m
@@ -65,21 +65,21 @@
 %!shared x,y
 %! x = [-1 0 1 Inf];
 %! y = [0, 1/2, 1/4, NaN];
-%!assert(geopdf (x, 0.5*ones(1,4)), y);
-%!assert(geopdf (x, 0.5), y);
-%!assert(geopdf (x, 0.5*[-1 NaN 4 1]), [NaN NaN NaN y(4)]);
-%!assert(geopdf ([x, NaN], 0.5), [y, NaN]);
+%!assert (geopdf (x, 0.5*ones (1,4)), y)
+%!assert (geopdf (x, 0.5), y)
+%!assert (geopdf (x, 0.5*[-1 NaN 4 1]), [NaN NaN NaN y(4)])
+%!assert (geopdf ([x, NaN], 0.5), [y, NaN])
 
 %% Test class of input preserved
-%!assert(geopdf (single([x, NaN]), 0.5), single([y, NaN]), 5*eps("single"));
-%!assert(geopdf ([x, NaN], single(0.5)), single([y, NaN]), 5*eps("single"));
+%!assert (geopdf (single ([x, NaN]), 0.5), single ([y, NaN]), 5*eps ("single"))
+%!assert (geopdf ([x, NaN], single (0.5)), single ([y, NaN]), 5*eps ("single"))
 
 %% Test input validation
 %!error geopdf ()
 %!error geopdf (1)
 %!error geopdf (1,2,3)
-%!error geopdf (ones(3),ones(2))
-%!error geopdf (ones(2),ones(3))
+%!error geopdf (ones (3), ones (2))
+%!error geopdf (ones (2), ones (3))
 %!error geopdf (i, 2)
 %!error geopdf (2, i)
 
--- a/scripts/statistics/distributions/geornd.m
+++ b/scripts/statistics/distributions/geornd.m
@@ -77,7 +77,7 @@
 
   if (isscalar (p))
     if (p > 0 && p < 1);
-      rnd = floor (- rande (sz) ./ log (1 - p));
+      rnd = floor (- rande (sz, cls) ./ log (1 - p));
     elseif (p == 0)
       rnd = Inf (sz, cls);
     elseif (p == 1)
@@ -86,10 +86,10 @@
       rnd = NaN (sz, cls);
     endif
   else
-    rnd = floor (- rande (sz) ./ log (1 - p));
+    rnd = floor (- rande (sz, cls) ./ log (1 - p));
 
     k = !(p >= 0) | !(p <= 1);
-  rnd(k) = NaN;
+    rnd(k) = NaN;
 
     k = (p == 0);
     rnd(k) = Inf;
@@ -98,28 +98,28 @@
 endfunction
 
 
-%!assert(size (geornd (0.5)), [1, 1]);
-%!assert(size (geornd (0.5*ones(2,1))), [2, 1]);
-%!assert(size (geornd (0.5*ones(2,2))), [2, 2]);
-%!assert(size (geornd (0.5, 3)), [3, 3]);
-%!assert(size (geornd (0.5, [4 1])), [4, 1]);
-%!assert(size (geornd (0.5, 4, 1)), [4, 1]);
+%!assert (size (geornd (0.5)), [1, 1])
+%!assert (size (geornd (0.5*ones (2,1))), [2, 1])
+%!assert (size (geornd (0.5*ones (2,2))), [2, 2])
+%!assert (size (geornd (0.5, 3)), [3, 3])
+%!assert (size (geornd (0.5, [4 1])), [4, 1])
+%!assert (size (geornd (0.5, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (geornd (0.5)), "double");
-%!assert(class (geornd (single(0.5))), "single");
-%!assert(class (geornd (single([0.5 0.5]))), "single");
-%!assert(class (geornd (single(0))), "single");
-%!assert(class (geornd (single(1))), "single");
+%!assert (class (geornd (0.5)), "double")
+%!assert (class (geornd (single (0.5))), "single")
+%!assert (class (geornd (single ([0.5 0.5]))), "single")
+%!assert (class (geornd (single (0))), "single")
+%!assert (class (geornd (single (1))), "single")
 
 %% Test input validation
 %!error geornd ()
-%!error geornd (ones(3),ones(2))
-%!error geornd (ones(2),ones(3))
+%!error geornd (ones (3), ones (2))
+%!error geornd (ones (2), ones (3))
 %!error geornd (i)
 %!error geornd (1, -1)
-%!error geornd (1, ones(2))
+%!error geornd (1, ones (2))
 %!error geornd (1, [2 -1 2])
-%!error geornd (ones(2,2), 2, 3)
-%!error geornd (ones(2,2), 3, 2)
+%!error geornd (ones (2,2), 2, 3)
+%!error geornd (ones (2,2), 3, 2)
 
--- a/scripts/statistics/distributions/hygecdf.m
+++ b/scripts/statistics/distributions/hygecdf.m
@@ -76,22 +76,22 @@
 %!shared x,y
 %! x = [-1 0 1 2 3];
 %! y = [0 1/6 5/6 1 1];
-%!assert(hygecdf (x, 4*ones(1,5), 2, 2), y, eps);
-%!assert(hygecdf (x, 4, 2*ones(1,5), 2), y, eps);
-%!assert(hygecdf (x, 4, 2, 2*ones(1,5)), y, eps);
-%!assert(hygecdf (x, 4*[1 -1 NaN 1.1 1], 2, 2), [y(1) NaN NaN NaN y(5)], eps);
-%!assert(hygecdf (x, 4, 2*[1 -1 NaN 1.1 1], 2), [y(1) NaN NaN NaN y(5)], eps);
-%!assert(hygecdf (x, 4, 5, 2), [NaN NaN NaN NaN NaN]);
-%!assert(hygecdf (x, 4, 2, 2*[1 -1 NaN 1.1 1]), [y(1) NaN NaN NaN y(5)], eps);
-%!assert(hygecdf (x, 4, 2, 5), [NaN NaN NaN NaN NaN]);
-%!assert(hygecdf ([x(1:2) NaN x(4:5)], 4, 2, 2), [y(1:2) NaN y(4:5)], eps);
+%!assert (hygecdf (x, 4*ones (1,5), 2, 2), y, eps)
+%!assert (hygecdf (x, 4, 2*ones (1,5), 2), y, eps)
+%!assert (hygecdf (x, 4, 2, 2*ones (1,5)), y, eps)
+%!assert (hygecdf (x, 4*[1 -1 NaN 1.1 1], 2, 2), [y(1) NaN NaN NaN y(5)], eps)
+%!assert (hygecdf (x, 4, 2*[1 -1 NaN 1.1 1], 2), [y(1) NaN NaN NaN y(5)], eps)
+%!assert (hygecdf (x, 4, 5, 2), [NaN NaN NaN NaN NaN])
+%!assert (hygecdf (x, 4, 2, 2*[1 -1 NaN 1.1 1]), [y(1) NaN NaN NaN y(5)], eps)
+%!assert (hygecdf (x, 4, 2, 5), [NaN NaN NaN NaN NaN])
+%!assert (hygecdf ([x(1:2) NaN x(4:5)], 4, 2, 2), [y(1:2) NaN y(4:5)], eps)
 
 %% Test class of input preserved
-%!assert(hygecdf ([x, NaN], 4, 2, 2), [y, NaN], eps);
-%!assert(hygecdf (single([x, NaN]), 4, 2, 2), single([y, NaN]), eps("single"));
-%!assert(hygecdf ([x, NaN], single(4), 2, 2), single([y, NaN]), eps("single"));
-%!assert(hygecdf ([x, NaN], 4, single(2), 2), single([y, NaN]), eps("single"));
-%!assert(hygecdf ([x, NaN], 4, 2, single(2)), single([y, NaN]), eps("single"));
+%!assert (hygecdf ([x, NaN], 4, 2, 2), [y, NaN], eps)
+%!assert (hygecdf (single ([x, NaN]), 4, 2, 2), single ([y, NaN]), eps ("single"))
+%!assert (hygecdf ([x, NaN], single (4), 2, 2), single ([y, NaN]), eps ("single"))
+%!assert (hygecdf ([x, NaN], 4, single (2), 2), single ([y, NaN]), eps ("single"))
+%!assert (hygecdf ([x, NaN], 4, 2, single (2)), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error hygecdf ()
@@ -99,9 +99,9 @@
 %!error hygecdf (1,2)
 %!error hygecdf (1,2,3)
 %!error hygecdf (1,2,3,4,5)
-%!error hygecdf (ones(2), ones(3), 1, 1)
-%!error hygecdf (1, ones(2), ones(3), 1)
-%!error hygecdf (1, 1, ones(2), ones(3))
+%!error hygecdf (ones (2), ones (3), 1, 1)
+%!error hygecdf (1, ones (2), ones (3), 1)
+%!error hygecdf (1, 1, ones (2), ones (3))
 %!error hygecdf (i, 2, 2, 2)
 %!error hygecdf (2, i, 2, 2)
 %!error hygecdf (2, 2, i, 2)
--- a/scripts/statistics/distributions/hygeinv.m
+++ b/scripts/statistics/distributions/hygeinv.m
@@ -80,23 +80,23 @@
 
 %!shared x
 %! x = [-1 0 0.5 1 2];
-%!assert(hygeinv (x, 4*ones(1,5), 2*ones(1,5), 2*ones(1,5)), [NaN 0 1 2 NaN]);
-%!assert(hygeinv (x, 4*ones(1,5), 2, 2), [NaN 0 1 2 NaN]);
-%!assert(hygeinv (x, 4, 2*ones(1,5), 2), [NaN 0 1 2 NaN]);
-%!assert(hygeinv (x, 4, 2, 2*ones(1,5)), [NaN 0 1 2 NaN]);
-%!assert(hygeinv (x, 4*[1 -1 NaN 1.1 1], 2, 2), [NaN NaN NaN NaN NaN]);
-%!assert(hygeinv (x, 4, 2*[1 -1 NaN 1.1 1], 2), [NaN NaN NaN NaN NaN]);
-%!assert(hygeinv (x, 4, 5, 2), [NaN NaN NaN NaN NaN]);
-%!assert(hygeinv (x, 4, 2, 2*[1 -1 NaN 1.1 1]), [NaN NaN NaN NaN NaN]);
-%!assert(hygeinv (x, 4, 2, 5), [NaN NaN NaN NaN NaN]);
-%!assert(hygeinv ([x(1:2) NaN x(4:5)], 4, 2, 2), [NaN 0 NaN 2 NaN]);
+%!assert (hygeinv (x, 4*ones (1,5), 2*ones (1,5), 2*ones (1,5)), [NaN 0 1 2 NaN])
+%!assert (hygeinv (x, 4*ones (1,5), 2, 2), [NaN 0 1 2 NaN])
+%!assert (hygeinv (x, 4, 2*ones (1,5), 2), [NaN 0 1 2 NaN])
+%!assert (hygeinv (x, 4, 2, 2*ones (1,5)), [NaN 0 1 2 NaN])
+%!assert (hygeinv (x, 4*[1 -1 NaN 1.1 1], 2, 2), [NaN NaN NaN NaN NaN])
+%!assert (hygeinv (x, 4, 2*[1 -1 NaN 1.1 1], 2), [NaN NaN NaN NaN NaN])
+%!assert (hygeinv (x, 4, 5, 2), [NaN NaN NaN NaN NaN])
+%!assert (hygeinv (x, 4, 2, 2*[1 -1 NaN 1.1 1]), [NaN NaN NaN NaN NaN])
+%!assert (hygeinv (x, 4, 2, 5), [NaN NaN NaN NaN NaN])
+%!assert (hygeinv ([x(1:2) NaN x(4:5)], 4, 2, 2), [NaN 0 NaN 2 NaN])
 
 %% Test class of input preserved
-%!assert(hygeinv ([x, NaN], 4, 2, 2), [NaN 0 1 2 NaN NaN]);
-%!assert(hygeinv (single([x, NaN]), 4, 2, 2), single([NaN 0 1 2 NaN NaN]));
-%!assert(hygeinv ([x, NaN], single(4), 2, 2), single([NaN 0 1 2 NaN NaN]));
-%!assert(hygeinv ([x, NaN], 4, single(2), 2), single([NaN 0 1 2 NaN NaN]));
-%!assert(hygeinv ([x, NaN], 4, 2, single(2)), single([NaN 0 1 2 NaN NaN]));
+%!assert (hygeinv ([x, NaN], 4, 2, 2), [NaN 0 1 2 NaN NaN])
+%!assert (hygeinv (single ([x, NaN]), 4, 2, 2), single ([NaN 0 1 2 NaN NaN]))
+%!assert (hygeinv ([x, NaN], single (4), 2, 2), single ([NaN 0 1 2 NaN NaN]))
+%!assert (hygeinv ([x, NaN], 4, single (2), 2), single ([NaN 0 1 2 NaN NaN]))
+%!assert (hygeinv ([x, NaN], 4, 2, single (2)), single ([NaN 0 1 2 NaN NaN]))
 
 %% Test input validation
 %!error hygeinv ()
@@ -104,9 +104,9 @@
 %!error hygeinv (1,2)
 %!error hygeinv (1,2,3)
 %!error hygeinv (1,2,3,4,5)
-%!error hygeinv (ones(2), ones(3), 1, 1)
-%!error hygeinv (1, ones(2), ones(3), 1)
-%!error hygeinv (1, 1, ones(2), ones(3))
+%!error hygeinv (ones (2), ones (3), 1, 1)
+%!error hygeinv (1, ones (2), ones (3), 1)
+%!error hygeinv (1, 1, ones (2), ones (3))
 %!error hygeinv (i, 2, 2, 2)
 %!error hygeinv (2, i, 2, 2)
 %!error hygeinv (2, 2, i, 2)
--- a/scripts/statistics/distributions/hygepdf.m
+++ b/scripts/statistics/distributions/hygepdf.m
@@ -80,21 +80,21 @@
 %!shared x,y
 %! x = [-1 0 1 2 3];
 %! y = [0 1/6 4/6 1/6 0];
-%!assert(hygepdf (x, 4*ones(1,5), 2, 2), y);
-%!assert(hygepdf (x, 4, 2*ones(1,5), 2), y);
-%!assert(hygepdf (x, 4, 2, 2*ones(1,5)), y);
-%!assert(hygepdf (x, 4*[1 -1 NaN 1.1 1], 2, 2), [0 NaN NaN NaN 0]);
-%!assert(hygepdf (x, 4, 2*[1 -1 NaN 1.1 1], 2), [0 NaN NaN NaN 0]);
-%!assert(hygepdf (x, 4, 5, 2), [NaN NaN NaN NaN NaN]);
-%!assert(hygepdf (x, 4, 2, 2*[1 -1 NaN 1.1 1]), [0 NaN NaN NaN 0]);
-%!assert(hygepdf (x, 4, 2, 5), [NaN NaN NaN NaN NaN]);
-%!assert(hygepdf ([x, NaN], 4, 2, 2), [y, NaN], eps);
+%!assert (hygepdf (x, 4*ones (1,5), 2, 2), y)
+%!assert (hygepdf (x, 4, 2*ones (1,5), 2), y)
+%!assert (hygepdf (x, 4, 2, 2*ones (1,5)), y)
+%!assert (hygepdf (x, 4*[1 -1 NaN 1.1 1], 2, 2), [0 NaN NaN NaN 0])
+%!assert (hygepdf (x, 4, 2*[1 -1 NaN 1.1 1], 2), [0 NaN NaN NaN 0])
+%!assert (hygepdf (x, 4, 5, 2), [NaN NaN NaN NaN NaN])
+%!assert (hygepdf (x, 4, 2, 2*[1 -1 NaN 1.1 1]), [0 NaN NaN NaN 0])
+%!assert (hygepdf (x, 4, 2, 5), [NaN NaN NaN NaN NaN])
+%!assert (hygepdf ([x, NaN], 4, 2, 2), [y, NaN], eps)
 
 %% Test class of input preserved
-%!assert(hygepdf (single([x, NaN]), 4, 2, 2), single([y, NaN]));
-%!assert(hygepdf ([x, NaN], single(4), 2, 2), single([y, NaN]));
-%!assert(hygepdf ([x, NaN], 4, single(2), 2), single([y, NaN]));
-%!assert(hygepdf ([x, NaN], 4, 2, single(2)), single([y, NaN]));
+%!assert (hygepdf (single ([x, NaN]), 4, 2, 2), single ([y, NaN]))
+%!assert (hygepdf ([x, NaN], single (4), 2, 2), single ([y, NaN]))
+%!assert (hygepdf ([x, NaN], 4, single (2), 2), single ([y, NaN]))
+%!assert (hygepdf ([x, NaN], 4, 2, single (2)), single ([y, NaN]))
 
 %% Test input validation
 %!error hygepdf ()
@@ -102,9 +102,9 @@
 %!error hygepdf (1,2)
 %!error hygepdf (1,2,3)
 %!error hygepdf (1,2,3,4,5)
-%!error hygepdf (1, ones(3),ones(2),ones(2))
-%!error hygepdf (1, ones(2),ones(3),ones(2))
-%!error hygepdf (1, ones(2),ones(2),ones(3))
+%!error hygepdf (1, ones (3), ones (2), ones (2))
+%!error hygepdf (1, ones (2), ones (3), ones (2))
+%!error hygepdf (1, ones (2), ones (2), ones (3))
 %!error hygepdf (i, 2, 2, 2)
 %!error hygepdf (2, i, 2, 2)
 %!error hygepdf (2, 2, i, 2)
--- a/scripts/statistics/distributions/hygernd.m
+++ b/scripts/statistics/distributions/hygernd.m
@@ -110,39 +110,39 @@
 endfunction
 
 
-%!assert(size (hygernd (4,2,2)), [1, 1]);
-%!assert(size (hygernd (4*ones(2,1), 2,2)), [2, 1]);
-%!assert(size (hygernd (4*ones(2,2), 2,2)), [2, 2]);
-%!assert(size (hygernd (4, 2*ones(2,1), 2)), [2, 1]);
-%!assert(size (hygernd (4, 2*ones(2,2), 2)), [2, 2]);
-%!assert(size (hygernd (4, 2, 2*ones(2,1))), [2, 1]);
-%!assert(size (hygernd (4, 2, 2*ones(2,2))), [2, 2]);
-%!assert(size (hygernd (4, 2, 2, 3)), [3, 3]);
-%!assert(size (hygernd (4, 2, 2, [4 1])), [4, 1]);
-%!assert(size (hygernd (4, 2, 2, 4, 1)), [4, 1]);
+%!assert (size (hygernd (4,2,2)), [1, 1])
+%!assert (size (hygernd (4*ones (2,1), 2,2)), [2, 1])
+%!assert (size (hygernd (4*ones (2,2), 2,2)), [2, 2])
+%!assert (size (hygernd (4, 2*ones (2,1), 2)), [2, 1])
+%!assert (size (hygernd (4, 2*ones (2,2), 2)), [2, 2])
+%!assert (size (hygernd (4, 2, 2*ones (2,1))), [2, 1])
+%!assert (size (hygernd (4, 2, 2*ones (2,2))), [2, 2])
+%!assert (size (hygernd (4, 2, 2, 3)), [3, 3])
+%!assert (size (hygernd (4, 2, 2, [4 1])), [4, 1])
+%!assert (size (hygernd (4, 2, 2, 4, 1)), [4, 1])
 
-%!assert(class (hygernd (4,2,2)), "double");
-%!assert(class (hygernd (single(4),2,2)), "single");
-%!assert(class (hygernd (single([4 4]),2,2)), "single");
-%!assert(class (hygernd (4,single(2),2)), "single");
-%!assert(class (hygernd (4,single([2 2]),2)), "single");
-%!assert(class (hygernd (4,2,single(2))), "single");
-%!assert(class (hygernd (4,2,single([2 2]))), "single");
+%!assert (class (hygernd (4,2,2)), "double")
+%!assert (class (hygernd (single (4),2,2)), "single")
+%!assert (class (hygernd (single ([4 4]),2,2)), "single")
+%!assert (class (hygernd (4,single (2),2)), "single")
+%!assert (class (hygernd (4,single ([2 2]),2)), "single")
+%!assert (class (hygernd (4,2,single (2))), "single")
+%!assert (class (hygernd (4,2,single ([2 2]))), "single")
 
 %% Test input validation
 %!error hygernd ()
 %!error hygernd (1)
 %!error hygernd (1,2)
-%!error hygernd (ones(3),ones(2),ones(2), 2)
-%!error hygernd (ones(2),ones(3),ones(2), 2)
-%!error hygernd (ones(2),ones(2),ones(3), 2)
+%!error hygernd (ones (3), ones (2), ones (2), 2)
+%!error hygernd (ones (2), ones (3), ones (2), 2)
+%!error hygernd (ones (2), ones (2), ones (3), 2)
 %!error hygernd (i, 2, 2)
 %!error hygernd (2, i, 2)
 %!error hygernd (2, 2, i)
 %!error hygernd (4,2,2, -1)
-%!error hygernd (4,2,2, ones(2))
+%!error hygernd (4,2,2, ones (2))
 %!error hygernd (4,2,2, [2 -1 2])
-%!error hygernd (4*ones(2),2,2, 3)
-%!error hygernd (4*ones(2),2,2, [3, 2])
-%!error hygernd (4*ones(2),2,2, 3, 2)
+%!error hygernd (4*ones (2),2,2, 3)
+%!error hygernd (4*ones (2),2,2, [3, 2])
+%!error hygernd (4*ones (2),2,2, 3, 2)
 
--- a/scripts/statistics/distributions/kolmogorov_smirnov_cdf.m
+++ b/scripts/statistics/distributions/kolmogorov_smirnov_cdf.m
@@ -90,6 +90,6 @@
 %% Test input validation
 %!error kolmogorov_smirnov_cdf ()
 %!error kolmogorov_smirnov_cdf (1,2,3)
-%!error kolmogorov_smirnov_cdf (1, ones(2))
+%!error kolmogorov_smirnov_cdf (1, ones (2))
 %!error kolmogorov_smirnov_cdf ([], 1)
 
--- a/scripts/statistics/distributions/laplace_cdf.m
+++ b/scripts/statistics/distributions/laplace_cdf.m
@@ -44,10 +44,10 @@
 %!shared x,y
 %! x = [-Inf -log(2) 0 log(2) Inf];
 %! y = [0, 1/4, 1/2, 3/4, 1]; 
-%!assert(laplace_cdf ([x, NaN]), [y, NaN]);
+%!assert (laplace_cdf ([x, NaN]), [y, NaN])
 
 %% Test class of input preserved
-%!assert(laplace_cdf (single([x, NaN])), single([y, NaN]));
+%!assert (laplace_cdf (single ([x, NaN])), single ([y, NaN]))
 
 %% Test input validation
 %!error laplace_cdf ()
--- a/scripts/statistics/distributions/laplace_inv.m
+++ b/scripts/statistics/distributions/laplace_inv.m
@@ -51,11 +51,11 @@
 
 %!shared x
 %! x = [-1 0 0.5 1 2];
-%!assert(laplace_inv (x), [NaN -Inf 0 Inf NaN]);
+%!assert (laplace_inv (x), [NaN -Inf 0 Inf NaN])
 
 %% Test class of input preserved
-%!assert(laplace_inv ([x, NaN]), [NaN -Inf 0 Inf NaN NaN]);
-%!assert(laplace_inv (single([x, NaN])), single([NaN -Inf 0 Inf NaN NaN]));
+%!assert (laplace_inv ([x, NaN]), [NaN -Inf 0 Inf NaN NaN])
+%!assert (laplace_inv (single ([x, NaN])), single ([NaN -Inf 0 Inf NaN NaN]))
 
 %% Test input validation
 %!error laplace_inv ()
--- a/scripts/statistics/distributions/laplace_pdf.m
+++ b/scripts/statistics/distributions/laplace_pdf.m
@@ -44,10 +44,10 @@
 %!shared x,y
 %! x = [-Inf -log(2) 0 log(2) Inf];
 %! y = [0, 1/4, 1/2, 1/4, 0]; 
-%!assert(laplace_pdf ([x, NaN]), [y, NaN]);
+%!assert (laplace_pdf ([x, NaN]), [y, NaN])
 
 %% Test class of input preserved
-%!assert(laplace_pdf (single([x, NaN])), single([y, NaN]));
+%!assert (laplace_pdf (single ([x, NaN])), single ([y, NaN]))
 
 %% Test input validation
 %!error laplace_pdf ()
--- a/scripts/statistics/distributions/laplace_rnd.m
+++ b/scripts/statistics/distributions/laplace_rnd.m
@@ -60,15 +60,15 @@
 endfunction
 
 
-%!assert(size (laplace_rnd (3)), [3, 3]);
-%!assert(size (laplace_rnd ([4 1])), [4, 1]);
-%!assert(size (laplace_rnd (4,1)), [4, 1]);
+%!assert (size (laplace_rnd (3)), [3, 3])
+%!assert (size (laplace_rnd ([4 1])), [4, 1])
+%!assert (size (laplace_rnd (4,1)), [4, 1])
 
 %% Test input validation
 %!error laplace_rnd ()
 %!error laplace_rnd (-1)
-%!error laplace_rnd (ones(2))
+%!error laplace_rnd (ones (2))
 %!error laplace_rnd ([2 -1 2])
-%!error laplace_rnd (1, ones(2))
+%!error laplace_rnd (1, ones (2))
 %!error laplace_rnd (1, -1)
 
--- a/scripts/statistics/distributions/logistic_cdf.m
+++ b/scripts/statistics/distributions/logistic_cdf.m
@@ -44,10 +44,10 @@
 %!shared x,y
 %! x = [-Inf -log(3) 0 log(3) Inf];
 %! y = [0, 1/4, 1/2, 3/4, 1]; 
-%!assert(logistic_cdf ([x, NaN]), [y, NaN], eps);
+%!assert (logistic_cdf ([x, NaN]), [y, NaN], eps)
 
 %% Test class of input preserved
-%!assert(logistic_cdf (single([x, NaN])), single([y, NaN]), eps ("single"));
+%!assert (logistic_cdf (single ([x, NaN])), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error logistic_cdf ()
--- a/scripts/statistics/distributions/logistic_inv.m
+++ b/scripts/statistics/distributions/logistic_inv.m
@@ -56,11 +56,11 @@
 
 %!shared x
 %! x = [-1 0 0.5 1 2];
-%!assert(logistic_inv (x), [NaN -Inf 0 Inf NaN]);
+%!assert (logistic_inv (x), [NaN -Inf 0 Inf NaN])
 
 %% Test class of input preserved
-%!assert(logistic_inv ([x, NaN]), [NaN -Inf 0 Inf NaN NaN]);
-%!assert(logistic_inv (single([x, NaN])), single([NaN -Inf 0 Inf NaN NaN]));
+%!assert (logistic_inv ([x, NaN]), [NaN -Inf 0 Inf NaN NaN])
+%!assert (logistic_inv (single ([x, NaN])), single ([NaN -Inf 0 Inf NaN NaN]))
 
 %% Test input validation
 %!error logistic_inv ()
--- a/scripts/statistics/distributions/logistic_pdf.m
+++ b/scripts/statistics/distributions/logistic_pdf.m
@@ -44,10 +44,10 @@
 %!shared x,y
 %! x = [-Inf -log(4) 0 log(4) Inf];
 %! y = [0, 0.16, 1/4, 0.16, 0]; 
-%!assert(logistic_pdf ([x, NaN]), [y, NaN], eps);
+%!assert (logistic_pdf ([x, NaN]), [y, NaN], eps)
 
 %% Test class of input preserved
-%!assert(logistic_pdf (single([x, NaN])), single([y, NaN]), eps ("single"));
+%!assert (logistic_pdf (single ([x, NaN])), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error logistic_pdf ()
--- a/scripts/statistics/distributions/logistic_rnd.m
+++ b/scripts/statistics/distributions/logistic_rnd.m
@@ -59,15 +59,15 @@
 endfunction
 
 
-%!assert(size (logistic_rnd (3)), [3, 3]);
-%!assert(size (logistic_rnd ([4 1])), [4, 1]);
-%!assert(size (logistic_rnd (4,1)), [4, 1]);
+%!assert (size (logistic_rnd (3)), [3, 3])
+%!assert (size (logistic_rnd ([4 1])), [4, 1])
+%!assert (size (logistic_rnd (4,1)), [4, 1])
 
 %% Test input validation
 %!error logistic_rnd ()
 %!error logistic_rnd (-1)
-%!error logistic_rnd (ones(2))
+%!error logistic_rnd (ones (2))
 %!error logistic_rnd ([2 -1 2])
-%!error logistic_rnd (1, ones(2))
+%!error logistic_rnd (1, ones (2))
 %!error logistic_rnd (1, -1)
 
--- a/scripts/statistics/distributions/logncdf.m
+++ b/scripts/statistics/distributions/logncdf.m
@@ -74,26 +74,26 @@
 %!shared x,y
 %! x = [-1 0 1 e Inf];
 %! y = [0, 0, 0.5, 1/2+1/2*erf(1/2), 1];
-%!assert(logncdf (x, zeros(1,5), sqrt(2)*ones(1,5)), y);
-%!assert(logncdf (x, 0, sqrt(2)*ones(1,5)), y);
-%!assert(logncdf (x, zeros(1,5), sqrt(2)), y);
-%!assert(logncdf (x, [0 1 NaN 0 1], sqrt(2)), [0 0 NaN y(4:5)]);
-%!assert(logncdf (x, 0, sqrt(2)*[0 NaN Inf 1 1]), [NaN NaN NaN y(4:5)]);
-%!assert(logncdf ([x(1:3) NaN x(5)], 0, sqrt(2)), [y(1:3) NaN y(5)]);
+%!assert (logncdf (x, zeros (1,5), sqrt(2)*ones (1,5)), y, eps)
+%!assert (logncdf (x, 0, sqrt(2)*ones (1,5)), y, eps)
+%!assert (logncdf (x, zeros (1,5), sqrt(2)), y, eps)
+%!assert (logncdf (x, [0 1 NaN 0 1], sqrt(2)), [0 0 NaN y(4:5)], eps)
+%!assert (logncdf (x, 0, sqrt(2)*[0 NaN Inf 1 1]), [NaN NaN NaN y(4:5)], eps)
+%!assert (logncdf ([x(1:3) NaN x(5)], 0, sqrt(2)), [y(1:3) NaN y(5)], eps)
 
 %% Test class of input preserved
-%!assert(logncdf ([x, NaN], 0, sqrt(2)), [y, NaN]);
-%!assert(logncdf (single([x, NaN]), 0, sqrt(2)), single([y, NaN]), eps("single"));
-%!assert(logncdf ([x, NaN], single(0), sqrt(2)), single([y, NaN]), eps("single"));
-%!assert(logncdf ([x, NaN], 0, single(sqrt(2))), single([y, NaN]), eps("single"));
+%!assert (logncdf ([x, NaN], 0, sqrt(2)), [y, NaN], eps)
+%!assert (logncdf (single ([x, NaN]), 0, sqrt(2)), single ([y, NaN]), eps ("single"))
+%!assert (logncdf ([x, NaN], single (0), sqrt(2)), single ([y, NaN]), eps ("single"))
+%!assert (logncdf ([x, NaN], 0, single (sqrt(2))), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error logncdf ()
 %!error logncdf (1,2)
 %!error logncdf (1,2,3,4)
-%!error logncdf (ones(3),ones(2),ones(2))
-%!error logncdf (ones(2),ones(3),ones(2))
-%!error logncdf (ones(2),ones(2),ones(3))
+%!error logncdf (ones (3), ones (2), ones (2))
+%!error logncdf (ones (2), ones (3), ones (2))
+%!error logncdf (ones (2), ones (2), ones (3))
 %!error logncdf (i, 2, 2)
 %!error logncdf (2, i, 2)
 %!error logncdf (2, 2, i)
--- a/scripts/statistics/distributions/logninv.m
+++ b/scripts/statistics/distributions/logninv.m
@@ -73,26 +73,26 @@
 
 %!shared x
 %! x = [-1 0 0.5 1 2];
-%!assert(logninv (x, ones(1,5), ones(1,5)), [NaN 0 e Inf NaN]);
-%!assert(logninv (x, 1, ones(1,5)), [NaN 0 e Inf NaN]);
-%!assert(logninv (x, ones(1,5), 1), [NaN 0 e Inf NaN]);
-%!assert(logninv (x, [1 1 NaN 0 1], 1), [NaN 0 NaN Inf NaN]);
-%!assert(logninv (x, 1, [1 0 NaN Inf 1]), [NaN NaN NaN NaN NaN]);
-%!assert(logninv ([x(1:2) NaN x(4:5)], 1, 2), [NaN 0 NaN Inf NaN]);
+%!assert (logninv (x, ones (1,5), ones (1,5)), [NaN 0 e Inf NaN])
+%!assert (logninv (x, 1, ones (1,5)), [NaN 0 e Inf NaN])
+%!assert (logninv (x, ones (1,5), 1), [NaN 0 e Inf NaN])
+%!assert (logninv (x, [1 1 NaN 0 1], 1), [NaN 0 NaN Inf NaN])
+%!assert (logninv (x, 1, [1 0 NaN Inf 1]), [NaN NaN NaN NaN NaN])
+%!assert (logninv ([x(1:2) NaN x(4:5)], 1, 2), [NaN 0 NaN Inf NaN])
 
 %% Test class of input preserved
-%!assert(logninv ([x, NaN], 1, 1), [NaN 0 e Inf NaN NaN]);
-%!assert(logninv (single([x, NaN]), 1, 1), single([NaN 0 e Inf NaN NaN]));
-%!assert(logninv ([x, NaN], single(1), 1), single([NaN 0 e Inf NaN NaN]));
-%!assert(logninv ([x, NaN], 1, single(1)), single([NaN 0 e Inf NaN NaN]));
+%!assert (logninv ([x, NaN], 1, 1), [NaN 0 e Inf NaN NaN])
+%!assert (logninv (single ([x, NaN]), 1, 1), single ([NaN 0 e Inf NaN NaN]))
+%!assert (logninv ([x, NaN], single (1), 1), single ([NaN 0 e Inf NaN NaN]))
+%!assert (logninv ([x, NaN], 1, single (1)), single ([NaN 0 e Inf NaN NaN]))
 
 %% Test input validation
 %!error logninv ()
 %!error logninv (1,2)
 %!error logninv (1,2,3,4)
-%!error logninv (ones(3),ones(2),ones(2))
-%!error logninv (ones(2),ones(3),ones(2))
-%!error logninv (ones(2),ones(2),ones(3))
+%!error logninv (ones (3), ones (2), ones (2))
+%!error logninv (ones (2), ones (3), ones (2))
+%!error logninv (ones (2), ones (2), ones (3))
 %!error logninv (i, 2, 2)
 %!error logninv (2, i, 2)
 %!error logninv (2, 2, i)
--- a/scripts/statistics/distributions/lognpdf.m
+++ b/scripts/statistics/distributions/lognpdf.m
@@ -71,25 +71,25 @@
 %!shared x,y
 %! x = [-1 0 e Inf];
 %! y = [0, 0, 1/(e*sqrt(2*pi)) * exp(-1/2), 0];
-%!assert(lognpdf (x, zeros(1,4), ones(1,4)), y, eps);
-%!assert(lognpdf (x, 0, ones(1,4)), y, eps);
-%!assert(lognpdf (x, zeros(1,4), 1), y, eps);
-%!assert(lognpdf (x, [0 1 NaN 0], 1), [0 0 NaN y(4)], eps);
-%!assert(lognpdf (x, 0, [0 NaN Inf 1]), [NaN NaN NaN y(4)], eps);
-%!assert(lognpdf ([x, NaN], 0, 1), [y, NaN], eps);
+%!assert (lognpdf (x, zeros (1,4), ones (1,4)), y, eps)
+%!assert (lognpdf (x, 0, ones (1,4)), y, eps)
+%!assert (lognpdf (x, zeros (1,4), 1), y, eps)
+%!assert (lognpdf (x, [0 1 NaN 0], 1), [0 0 NaN y(4)], eps)
+%!assert (lognpdf (x, 0, [0 NaN Inf 1]), [NaN NaN NaN y(4)], eps)
+%!assert (lognpdf ([x, NaN], 0, 1), [y, NaN], eps)
 
 %% Test class of input preserved
-%!assert(lognpdf (single([x, NaN]), 0, 1), single([y, NaN]), eps("single"));
-%!assert(lognpdf ([x, NaN], single(0), 1), single([y, NaN]), eps("single"));
-%!assert(lognpdf ([x, NaN], 0, single(1)), single([y, NaN]), eps("single"));
+%!assert (lognpdf (single ([x, NaN]), 0, 1), single ([y, NaN]), eps ("single"))
+%!assert (lognpdf ([x, NaN], single (0), 1), single ([y, NaN]), eps ("single"))
+%!assert (lognpdf ([x, NaN], 0, single (1)), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error lognpdf ()
 %!error lognpdf (1,2)
 %!error lognpdf (1,2,3,4)
-%!error lognpdf (ones(3),ones(2),ones(2))
-%!error lognpdf (ones(2),ones(3),ones(2))
-%!error lognpdf (ones(2),ones(2),ones(3))
+%!error lognpdf (ones (3), ones (2), ones (2))
+%!error lognpdf (ones (2), ones (3), ones (2))
+%!error lognpdf (ones (2), ones (2), ones (3))
 %!error lognpdf (i, 2, 2)
 %!error lognpdf (2, i, 2)
 %!error lognpdf (2, 2, i)
--- a/scripts/statistics/distributions/lognrnd.m
+++ b/scripts/statistics/distributions/lognrnd.m
@@ -84,12 +84,12 @@
 
   if (isscalar (mu) && isscalar (sigma))
     if ((sigma > 0) && (sigma < Inf))
-      rnd = exp (mu + sigma * randn (sz));
+      rnd = exp (mu + sigma * randn (sz, cls));
     else
       rnd = NaN (sz, cls);
     endif
   else
-    rnd = exp (mu + sigma .* randn (sz));
+    rnd = exp (mu + sigma .* randn (sz, cls));
 
     k = (sigma < 0) | (sigma == Inf);
     rnd(k) = NaN;
@@ -98,35 +98,35 @@
 endfunction
 
 
-%!assert(size (lognrnd (1,2)), [1, 1]);
-%!assert(size (lognrnd (ones(2,1), 2)), [2, 1]);
-%!assert(size (lognrnd (ones(2,2), 2)), [2, 2]);
-%!assert(size (lognrnd (1, 2*ones(2,1))), [2, 1]);
-%!assert(size (lognrnd (1, 2*ones(2,2))), [2, 2]);
-%!assert(size (lognrnd (1, 2, 3)), [3, 3]);
-%!assert(size (lognrnd (1, 2, [4 1])), [4, 1]);
-%!assert(size (lognrnd (1, 2, 4, 1)), [4, 1]);
+%!assert (size (lognrnd (1,2)), [1, 1])
+%!assert (size (lognrnd (ones (2,1), 2)), [2, 1])
+%!assert (size (lognrnd (ones (2,2), 2)), [2, 2])
+%!assert (size (lognrnd (1, 2*ones (2,1))), [2, 1])
+%!assert (size (lognrnd (1, 2*ones (2,2))), [2, 2])
+%!assert (size (lognrnd (1, 2, 3)), [3, 3])
+%!assert (size (lognrnd (1, 2, [4 1])), [4, 1])
+%!assert (size (lognrnd (1, 2, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (lognrnd (1, 2)), "double");
-%!assert(class (lognrnd (single(1), 2)), "single");
-%!assert(class (lognrnd (single([1 1]), 2)), "single");
-%!assert(class (lognrnd (1, single(2))), "single");
-%!assert(class (lognrnd (1, single([2 2]))), "single");
+%!assert (class (lognrnd (1, 2)), "double")
+%!assert (class (lognrnd (single (1), 2)), "single")
+%!assert (class (lognrnd (single ([1 1]), 2)), "single")
+%!assert (class (lognrnd (1, single (2))), "single")
+%!assert (class (lognrnd (1, single ([2 2]))), "single")
 
 %% Test input validation
 %!error lognrnd ()
 %!error lognrnd (1)
-%!error lognrnd (ones(3),ones(2))
-%!error lognrnd (ones(2),ones(3))
+%!error lognrnd (ones (3), ones (2))
+%!error lognrnd (ones (2), ones (3))
 %!error lognrnd (i, 2)
 %!error lognrnd (2, i)
 %!error lognrnd (1,2, -1)
-%!error lognrnd (1,2, ones(2))
+%!error lognrnd (1,2, ones (2))
 %!error lognrnd (1, 2, [2 -1 2])
-%!error lognrnd (1,2, 1, ones(2))
+%!error lognrnd (1,2, 1, ones (2))
 %!error lognrnd (1,2, 1, -1)
-%!error lognrnd (ones(2,2), 2, 3)
-%!error lognrnd (ones(2,2), 2, [3, 2])
-%!error lognrnd (ones(2,2), 2, 2, 3)
+%!error lognrnd (ones (2,2), 2, 3)
+%!error lognrnd (ones (2,2), 2, [3, 2])
+%!error lognrnd (ones (2,2), 2, 2, 3)
 
--- a/scripts/statistics/distributions/nbincdf.m
+++ b/scripts/statistics/distributions/nbincdf.m
@@ -78,27 +78,27 @@
 %!shared x,y
 %! x = [-1 0 1 2 Inf];
 %! y = [0 1/2 3/4 7/8 1];
-%!assert(nbincdf (x, ones(1,5), 0.5*ones(1,5)), y);
-%!assert(nbincdf (x, 1, 0.5*ones(1,5)), y);
-%!assert(nbincdf (x, ones(1,5), 0.5), y);
-%!assert(nbincdf ([x(1:3) 0 x(5)], [0 1 NaN 1.5 Inf], 0.5), [NaN 1/2 NaN nbinpdf(0,1.5,0.5) NaN], eps);
-%!assert(nbincdf (x, 1, 0.5*[-1 NaN 4 1 1]), [NaN NaN NaN y(4:5)]);
-%!assert(nbincdf ([x(1:2) NaN x(4:5)], 1, 0.5), [y(1:2) NaN y(4:5)]);
+%!assert (nbincdf (x, ones (1,5), 0.5*ones (1,5)), y)
+%!assert (nbincdf (x, 1, 0.5*ones (1,5)), y)
+%!assert (nbincdf (x, ones (1,5), 0.5), y)
+%!assert (nbincdf ([x(1:3) 0 x(5)], [0 1 NaN 1.5 Inf], 0.5), [NaN 1/2 NaN nbinpdf(0,1.5,0.5) NaN], eps)
+%!assert (nbincdf (x, 1, 0.5*[-1 NaN 4 1 1]), [NaN NaN NaN y(4:5)])
+%!assert (nbincdf ([x(1:2) NaN x(4:5)], 1, 0.5), [y(1:2) NaN y(4:5)])
 
 %% Test class of input preserved
-%!assert(nbincdf ([x, NaN], 1, 0.5), [y, NaN]);
-%!assert(nbincdf (single([x, NaN]), 1, 0.5), single([y, NaN]));
-%!assert(nbincdf ([x, NaN], single(1), 0.5), single([y, NaN]));
-%!assert(nbincdf ([x, NaN], 1, single(0.5)), single([y, NaN]));
+%!assert (nbincdf ([x, NaN], 1, 0.5), [y, NaN])
+%!assert (nbincdf (single ([x, NaN]), 1, 0.5), single ([y, NaN]))
+%!assert (nbincdf ([x, NaN], single (1), 0.5), single ([y, NaN]))
+%!assert (nbincdf ([x, NaN], 1, single (0.5)), single ([y, NaN]))
 
 %% Test input validation
 %!error nbincdf ()
 %!error nbincdf (1)
 %!error nbincdf (1,2)
 %!error nbincdf (1,2,3,4)
-%!error nbincdf (ones(3),ones(2),ones(2))
-%!error nbincdf (ones(2),ones(3),ones(2))
-%!error nbincdf (ones(2),ones(2),ones(3))
+%!error nbincdf (ones (3), ones (2), ones (2))
+%!error nbincdf (ones (2), ones (3), ones (2))
+%!error nbincdf (ones (2), ones (2), ones (3))
 %!error nbincdf (i, 2, 2)
 %!error nbincdf (2, i, 2)
 %!error nbincdf (2, 2, i)
--- a/scripts/statistics/distributions/nbininv.m
+++ b/scripts/statistics/distributions/nbininv.m
@@ -100,28 +100,28 @@
 
 %!shared x
 %! x = [-1 0 3/4 1 2];
-%!assert(nbininv (x, ones(1,5), 0.5*ones(1,5)), [NaN 0 1 Inf NaN]);
-%!assert(nbininv (x, 1, 0.5*ones(1,5)), [NaN 0 1 Inf NaN]);
-%!assert(nbininv (x, ones(1,5), 0.5), [NaN 0 1 Inf NaN]);
-%!assert(nbininv (x, [1 0 NaN Inf 1], 0.5), [NaN NaN NaN NaN NaN]);
-%!assert(nbininv (x, [1 0 1.5 Inf 1], 0.5), [NaN NaN 2 NaN NaN]);
-%!assert(nbininv (x, 1, 0.5*[1 -Inf NaN Inf 1]), [NaN NaN NaN NaN NaN]);
-%!assert(nbininv ([x(1:2) NaN x(4:5)], 1, 0.5), [NaN 0 NaN Inf NaN]);
+%!assert (nbininv (x, ones (1,5), 0.5*ones (1,5)), [NaN 0 1 Inf NaN])
+%!assert (nbininv (x, 1, 0.5*ones (1,5)), [NaN 0 1 Inf NaN])
+%!assert (nbininv (x, ones (1,5), 0.5), [NaN 0 1 Inf NaN])
+%!assert (nbininv (x, [1 0 NaN Inf 1], 0.5), [NaN NaN NaN NaN NaN])
+%!assert (nbininv (x, [1 0 1.5 Inf 1], 0.5), [NaN NaN 2 NaN NaN])
+%!assert (nbininv (x, 1, 0.5*[1 -Inf NaN Inf 1]), [NaN NaN NaN NaN NaN])
+%!assert (nbininv ([x(1:2) NaN x(4:5)], 1, 0.5), [NaN 0 NaN Inf NaN])
 
 %% Test class of input preserved
-%!assert(nbininv ([x, NaN], 1, 0.5), [NaN 0 1 Inf NaN NaN]);
-%!assert(nbininv (single([x, NaN]), 1, 0.5), single([NaN 0 1 Inf NaN NaN]));
-%!assert(nbininv ([x, NaN], single(1), 0.5), single([NaN 0 1 Inf NaN NaN]));
-%!assert(nbininv ([x, NaN], 1, single(0.5)), single([NaN 0 1 Inf NaN NaN]));
+%!assert (nbininv ([x, NaN], 1, 0.5), [NaN 0 1 Inf NaN NaN])
+%!assert (nbininv (single ([x, NaN]), 1, 0.5), single ([NaN 0 1 Inf NaN NaN]))
+%!assert (nbininv ([x, NaN], single (1), 0.5), single ([NaN 0 1 Inf NaN NaN]))
+%!assert (nbininv ([x, NaN], 1, single (0.5)), single ([NaN 0 1 Inf NaN NaN]))
 
 %% Test input validation
 %!error nbininv ()
 %!error nbininv (1)
 %!error nbininv (1,2)
 %!error nbininv (1,2,3,4)
-%!error nbininv (ones(3),ones(2),ones(2))
-%!error nbininv (ones(2),ones(3),ones(2))
-%!error nbininv (ones(2),ones(2),ones(3))
+%!error nbininv (ones (3), ones (2), ones (2))
+%!error nbininv (ones (2), ones (3), ones (2))
+%!error nbininv (ones (2), ones (2), ones (3))
 %!error nbininv (i, 2, 2)
 %!error nbininv (2, i, 2)
 %!error nbininv (2, 2, i)
--- a/scripts/statistics/distributions/nbinpdf.m
+++ b/scripts/statistics/distributions/nbinpdf.m
@@ -76,26 +76,26 @@
 %!shared x,y
 %! x = [-1 0 1 2 Inf];
 %! y = [0 1/2 1/4 1/8 NaN];
-%!assert(nbinpdf (x, ones(1,5), 0.5*ones(1,5)), y);
-%!assert(nbinpdf (x, 1, 0.5*ones(1,5)), y);
-%!assert(nbinpdf (x, ones(1,5), 0.5), y);
-%!assert(nbinpdf (x, [0 1 NaN 1.5 Inf], 0.5), [NaN 1/2 NaN 1.875*0.5^1.5/4 NaN], eps);
-%!assert(nbinpdf (x, 1, 0.5*[-1 NaN 4 1 1]), [NaN NaN NaN y(4:5)]);
-%!assert(nbinpdf ([x, NaN], 1, 0.5), [y, NaN]);
+%!assert (nbinpdf (x, ones (1,5), 0.5*ones (1,5)), y)
+%!assert (nbinpdf (x, 1, 0.5*ones (1,5)), y)
+%!assert (nbinpdf (x, ones (1,5), 0.5), y)
+%!assert (nbinpdf (x, [0 1 NaN 1.5 Inf], 0.5), [NaN 1/2 NaN 1.875*0.5^1.5/4 NaN], eps)
+%!assert (nbinpdf (x, 1, 0.5*[-1 NaN 4 1 1]), [NaN NaN NaN y(4:5)])
+%!assert (nbinpdf ([x, NaN], 1, 0.5), [y, NaN])
 
 %% Test class of input preserved
-%!assert(nbinpdf (single([x, NaN]), 1, 0.5), single([y, NaN]));
-%!assert(nbinpdf ([x, NaN], single(1), 0.5), single([y, NaN]));
-%!assert(nbinpdf ([x, NaN], 1, single(0.5)), single([y, NaN]));
+%!assert (nbinpdf (single ([x, NaN]), 1, 0.5), single ([y, NaN]))
+%!assert (nbinpdf ([x, NaN], single (1), 0.5), single ([y, NaN]))
+%!assert (nbinpdf ([x, NaN], 1, single (0.5)), single ([y, NaN]))
 
 %% Test input validation
 %!error nbinpdf ()
 %!error nbinpdf (1)
 %!error nbinpdf (1,2)
 %!error nbinpdf (1,2,3,4)
-%!error nbinpdf (ones(3),ones(2),ones(2))
-%!error nbinpdf (ones(2),ones(3),ones(2))
-%!error nbinpdf (ones(2),ones(2),ones(3))
+%!error nbinpdf (ones (3), ones (2), ones (2))
+%!error nbinpdf (ones (2), ones (3), ones (2))
+%!error nbinpdf (ones (2), ones (2), ones (3))
 %!error nbinpdf (i, 2, 2)
 %!error nbinpdf (2, i, 2)
 %!error nbinpdf (2, 2, i)
--- a/scripts/statistics/distributions/nbinrnd.m
+++ b/scripts/statistics/distributions/nbinrnd.m
@@ -84,10 +84,7 @@
 
   if (isscalar (n) && isscalar (p))
     if ((n > 0) && (n < Inf) && (p > 0) && (p <= 1))
-      rnd = randp ((1 - p) ./ p .* randg (n, sz));
-      if (strcmp (cls, "single"))
-        rnd = single (rnd);
-      endif
+      rnd = randp ((1 - p) ./ p .* randg (n, sz, cls), cls);
     elseif ((n > 0) && (n < Inf) && (p == 0))
       rnd = zeros (sz, cls);
     else
@@ -100,41 +97,41 @@
     rnd(k) = 0;
 
     k = (n > 0) & (n < Inf) & (p > 0) & (p <= 1);
-    rnd(k) = randp ((1 - p(k)) ./ p(k) .* randg (n(k)));
+    rnd(k) = randp ((1 - p(k)) ./ p(k) .* randg (n(k), cls));
   endif
 
 endfunction
 
 
-%!assert(size (nbinrnd (2, 1/2)), [1, 1]);
-%!assert(size (nbinrnd (2*ones(2,1), 1/2)), [2, 1]);
-%!assert(size (nbinrnd (2*ones(2,2), 1/2)), [2, 2]);
-%!assert(size (nbinrnd (2, 1/2*ones(2,1))), [2, 1]);
-%!assert(size (nbinrnd (2, 1/2*ones(2,2))), [2, 2]);
-%!assert(size (nbinrnd (2, 1/2, 3)), [3, 3]);
-%!assert(size (nbinrnd (2, 1/2, [4 1])), [4, 1]);
-%!assert(size (nbinrnd (2, 1/2, 4, 1)), [4, 1]);
+%!assert (size (nbinrnd (2, 1/2)), [1, 1])
+%!assert (size (nbinrnd (2*ones (2,1), 1/2)), [2, 1])
+%!assert (size (nbinrnd (2*ones (2,2), 1/2)), [2, 2])
+%!assert (size (nbinrnd (2, 1/2*ones (2,1))), [2, 1])
+%!assert (size (nbinrnd (2, 1/2*ones (2,2))), [2, 2])
+%!assert (size (nbinrnd (2, 1/2, 3)), [3, 3])
+%!assert (size (nbinrnd (2, 1/2, [4 1])), [4, 1])
+%!assert (size (nbinrnd (2, 1/2, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (nbinrnd (2, 1/2)), "double");
-%!assert(class (nbinrnd (single(2), 1/2)), "single");
-%!assert(class (nbinrnd (single([2 2]), 1/2)), "single");
-%!assert(class (nbinrnd (2, single(1/2))), "single");
-%!assert(class (nbinrnd (2, single([1/2 1/2]))), "single");
+%!assert (class (nbinrnd (2, 1/2)), "double")
+%!assert (class (nbinrnd (single (2), 1/2)), "single")
+%!assert (class (nbinrnd (single ([2 2]), 1/2)), "single")
+%!assert (class (nbinrnd (2, single (1/2))), "single")
+%!assert (class (nbinrnd (2, single ([1/2 1/2]))), "single")
 
 %% Test input validation
 %!error nbinrnd ()
 %!error nbinrnd (1)
-%!error nbinrnd (ones(3),ones(2))
-%!error nbinrnd (ones(2),ones(3))
+%!error nbinrnd (ones (3), ones (2))
+%!error nbinrnd (ones (2), ones (3))
 %!error nbinrnd (i, 2)
 %!error nbinrnd (2, i)
 %!error nbinrnd (1,2, -1)
-%!error nbinrnd (1,2, ones(2))
+%!error nbinrnd (1,2, ones (2))
 %!error nbinrnd (1, 2, [2 -1 2])
-%!error nbinrnd (1,2, 1, ones(2))
+%!error nbinrnd (1,2, 1, ones (2))
 %!error nbinrnd (1,2, 1, -1)
-%!error nbinrnd (ones(2,2), 2, 3)
-%!error nbinrnd (ones(2,2), 2, [3, 2])
-%!error nbinrnd (ones(2,2), 2, 2, 3)
+%!error nbinrnd (ones (2,2), 2, 3)
+%!error nbinrnd (ones (2,2), 2, [3, 2])
+%!error nbinrnd (ones (2,2), 2, 2, 3)
 
--- a/scripts/statistics/distributions/normcdf.m
+++ b/scripts/statistics/distributions/normcdf.m
@@ -73,26 +73,26 @@
 %!shared x,y
 %! x = [-Inf 1 2 Inf];
 %! y = [0, 0.5, 1/2*(1+erf(1/sqrt(2))), 1];
-%!assert(normcdf (x, ones(1,4), ones(1,4)), y);
-%!assert(normcdf (x, 1, ones(1,4)), y);
-%!assert(normcdf (x, ones(1,4), 1), y);
-%!assert(normcdf (x, [0 -Inf NaN Inf], 1), [y(1) NaN NaN NaN]);
-%!assert(normcdf (x, 1, [Inf NaN -1 0]), [NaN NaN NaN NaN]);
-%!assert(normcdf ([x(1:2) NaN x(4)], 1, 1), [y(1:2) NaN y(4)]);
+%!assert (normcdf (x, ones (1,4), ones (1,4)), y)
+%!assert (normcdf (x, 1, ones (1,4)), y)
+%!assert (normcdf (x, ones (1,4), 1), y)
+%!assert (normcdf (x, [0 -Inf NaN Inf], 1), [y(1) NaN NaN NaN])
+%!assert (normcdf (x, 1, [Inf NaN -1 0]), [NaN NaN NaN NaN])
+%!assert (normcdf ([x(1:2) NaN x(4)], 1, 1), [y(1:2) NaN y(4)])
 
 %% Test class of input preserved
-%!assert(normcdf ([x, NaN], 1, 1), [y, NaN]);
-%!assert(normcdf (single([x, NaN]), 1, 1), single([y, NaN]), eps("single"));
-%!assert(normcdf ([x, NaN], single(1), 1), single([y, NaN]), eps("single"));
-%!assert(normcdf ([x, NaN], 1, single(1)), single([y, NaN]), eps("single"));
+%!assert (normcdf ([x, NaN], 1, 1), [y, NaN])
+%!assert (normcdf (single ([x, NaN]), 1, 1), single ([y, NaN]), eps ("single"))
+%!assert (normcdf ([x, NaN], single (1), 1), single ([y, NaN]), eps ("single"))
+%!assert (normcdf ([x, NaN], 1, single (1)), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error normcdf ()
 %!error normcdf (1,2)
 %!error normcdf (1,2,3,4)
-%!error normcdf (ones(3),ones(2),ones(2))
-%!error normcdf (ones(2),ones(3),ones(2))
-%!error normcdf (ones(2),ones(2),ones(3))
+%!error normcdf (ones (3), ones (2), ones (2))
+%!error normcdf (ones (2), ones (3), ones (2))
+%!error normcdf (ones (2), ones (2), ones (3))
 %!error normcdf (i, 2, 2)
 %!error normcdf (2, i, 2)
 %!error normcdf (2, 2, i)
--- a/scripts/statistics/distributions/norminv.m
+++ b/scripts/statistics/distributions/norminv.m
@@ -67,26 +67,26 @@
 
 %!shared x
 %! x = [-1 0 0.5 1 2];
-%!assert(norminv (x, ones(1,5), ones(1,5)), [NaN -Inf 1 Inf NaN]);
-%!assert(norminv (x, 1, ones(1,5)), [NaN -Inf 1 Inf NaN]);
-%!assert(norminv (x, ones(1,5), 1), [NaN -Inf 1 Inf NaN]);
-%!assert(norminv (x, [1 -Inf NaN Inf 1], 1), [NaN NaN NaN NaN NaN]);
-%!assert(norminv (x, 1, [1 0 NaN Inf 1]), [NaN NaN NaN NaN NaN]);
-%!assert(norminv ([x(1:2) NaN x(4:5)], 1, 1), [NaN -Inf NaN Inf NaN]);
+%!assert (norminv (x, ones (1,5), ones (1,5)), [NaN -Inf 1 Inf NaN])
+%!assert (norminv (x, 1, ones (1,5)), [NaN -Inf 1 Inf NaN])
+%!assert (norminv (x, ones (1,5), 1), [NaN -Inf 1 Inf NaN])
+%!assert (norminv (x, [1 -Inf NaN Inf 1], 1), [NaN NaN NaN NaN NaN])
+%!assert (norminv (x, 1, [1 0 NaN Inf 1]), [NaN NaN NaN NaN NaN])
+%!assert (norminv ([x(1:2) NaN x(4:5)], 1, 1), [NaN -Inf NaN Inf NaN])
 
 %% Test class of input preserved
-%!assert(norminv ([x, NaN], 1, 1), [NaN -Inf 1 Inf NaN NaN]);
-%!assert(norminv (single([x, NaN]), 1, 1), single([NaN -Inf 1 Inf NaN NaN]));
-%!assert(norminv ([x, NaN], single(1), 1), single([NaN -Inf 1 Inf NaN NaN]));
-%!assert(norminv ([x, NaN], 1, single(1)), single([NaN -Inf 1 Inf NaN NaN]));
+%!assert (norminv ([x, NaN], 1, 1), [NaN -Inf 1 Inf NaN NaN])
+%!assert (norminv (single ([x, NaN]), 1, 1), single ([NaN -Inf 1 Inf NaN NaN]))
+%!assert (norminv ([x, NaN], single (1), 1), single ([NaN -Inf 1 Inf NaN NaN]))
+%!assert (norminv ([x, NaN], 1, single (1)), single ([NaN -Inf 1 Inf NaN NaN]))
 
 %% Test input validation
 %!error norminv ()
 %!error norminv (1,2)
 %!error norminv (1,2,3,4)
-%!error norminv (ones(3),ones(2),ones(2))
-%!error norminv (ones(2),ones(3),ones(2))
-%!error norminv (ones(2),ones(2),ones(3))
+%!error norminv (ones (3), ones (2), ones (2))
+%!error norminv (ones (2), ones (3), ones (2))
+%!error norminv (ones (2), ones (2), ones (3))
 %!error norminv (i, 2, 2)
 %!error norminv (2, i, 2)
 %!error norminv (2, 2, i)
--- a/scripts/statistics/distributions/normpdf.m
+++ b/scripts/statistics/distributions/normpdf.m
@@ -73,25 +73,25 @@
 %!shared x,y
 %! x = [-Inf 1 2 Inf];
 %! y = 1/sqrt(2*pi)*exp (-(x-1).^2/2);
-%!assert(normpdf (x, ones(1,4), ones(1,4)), y);
-%!assert(normpdf (x, 1, ones(1,4)), y);
-%!assert(normpdf (x, ones(1,4), 1), y);
-%!assert(normpdf (x, [0 -Inf NaN Inf], 1), [y(1) NaN NaN NaN]);
-%!assert(normpdf (x, 1, [Inf NaN -1 0]), [NaN NaN NaN NaN]);
-%!assert(normpdf ([x, NaN], 1, 1), [y, NaN]);
+%!assert (normpdf (x, ones (1,4), ones (1,4)), y)
+%!assert (normpdf (x, 1, ones (1,4)), y)
+%!assert (normpdf (x, ones (1,4), 1), y)
+%!assert (normpdf (x, [0 -Inf NaN Inf], 1), [y(1) NaN NaN NaN])
+%!assert (normpdf (x, 1, [Inf NaN -1 0]), [NaN NaN NaN NaN])
+%!assert (normpdf ([x, NaN], 1, 1), [y, NaN])
 
 %% Test class of input preserved
-%!assert(normpdf (single([x, NaN]), 1, 1), single([y, NaN]), eps("single"));
-%!assert(normpdf ([x, NaN], single(1), 1), single([y, NaN]), eps("single"));
-%!assert(normpdf ([x, NaN], 1, single(1)), single([y, NaN]), eps("single"));
+%!assert (normpdf (single ([x, NaN]), 1, 1), single ([y, NaN]), eps ("single"))
+%!assert (normpdf ([x, NaN], single (1), 1), single ([y, NaN]), eps ("single"))
+%!assert (normpdf ([x, NaN], 1, single (1)), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error normpdf ()
 %!error normpdf (1,2)
 %!error normpdf (1,2,3,4)
-%!error normpdf (ones(3),ones(2),ones(2))
-%!error normpdf (ones(2),ones(3),ones(2))
-%!error normpdf (ones(2),ones(2),ones(3))
+%!error normpdf (ones (3), ones (2), ones (2))
+%!error normpdf (ones (2), ones (3), ones (2))
+%!error normpdf (ones (2), ones (2), ones (3))
 %!error normpdf (i, 2, 2)
 %!error normpdf (2, i, 2)
 %!error normpdf (2, 2, i)
--- a/scripts/statistics/distributions/normrnd.m
+++ b/scripts/statistics/distributions/normrnd.m
@@ -84,12 +84,12 @@
 
   if (isscalar (mu) && isscalar (sigma))
     if (!isnan (mu) && !isinf (mu) && (sigma > 0) && (sigma < Inf))
-      rnd =  mu + sigma * randn (sz);
+      rnd =  mu + sigma * randn (sz, cls);
     else
       rnd = NaN (sz, cls);
     endif
   else
-    rnd = mu + sigma .* randn (sz);
+    rnd = mu + sigma .* randn (sz, cls);
     k = isnan (mu) | isinf (mu) | !(sigma > 0) | !(sigma < Inf);
     rnd(k) = NaN;
   endif
@@ -97,35 +97,35 @@
 endfunction
 
 
-%!assert(size (normrnd (1,2)), [1, 1]);
-%!assert(size (normrnd (ones(2,1), 2)), [2, 1]);
-%!assert(size (normrnd (ones(2,2), 2)), [2, 2]);
-%!assert(size (normrnd (1, 2*ones(2,1))), [2, 1]);
-%!assert(size (normrnd (1, 2*ones(2,2))), [2, 2]);
-%!assert(size (normrnd (1, 2, 3)), [3, 3]);
-%!assert(size (normrnd (1, 2, [4 1])), [4, 1]);
-%!assert(size (normrnd (1, 2, 4, 1)), [4, 1]);
+%!assert (size (normrnd (1,2)), [1, 1])
+%!assert (size (normrnd (ones (2,1), 2)), [2, 1])
+%!assert (size (normrnd (ones (2,2), 2)), [2, 2])
+%!assert (size (normrnd (1, 2*ones (2,1))), [2, 1])
+%!assert (size (normrnd (1, 2*ones (2,2))), [2, 2])
+%!assert (size (normrnd (1, 2, 3)), [3, 3])
+%!assert (size (normrnd (1, 2, [4 1])), [4, 1])
+%!assert (size (normrnd (1, 2, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (normrnd (1, 2)), "double");
-%!assert(class (normrnd (single(1), 2)), "single");
-%!assert(class (normrnd (single([1 1]), 2)), "single");
-%!assert(class (normrnd (1, single(2))), "single");
-%!assert(class (normrnd (1, single([2 2]))), "single");
+%!assert (class (normrnd (1, 2)), "double")
+%!assert (class (normrnd (single (1), 2)), "single")
+%!assert (class (normrnd (single ([1 1]), 2)), "single")
+%!assert (class (normrnd (1, single (2))), "single")
+%!assert (class (normrnd (1, single ([2 2]))), "single")
 
 %% Test input validation
 %!error normrnd ()
 %!error normrnd (1)
-%!error normrnd (ones(3),ones(2))
-%!error normrnd (ones(2),ones(3))
+%!error normrnd (ones (3), ones (2))
+%!error normrnd (ones (2), ones (3))
 %!error normrnd (i, 2)
 %!error normrnd (2, i)
 %!error normrnd (1,2, -1)
-%!error normrnd (1,2, ones(2))
+%!error normrnd (1,2, ones (2))
 %!error normrnd (1, 2, [2 -1 2])
-%!error normrnd (1,2, 1, ones(2))
+%!error normrnd (1,2, 1, ones (2))
 %!error normrnd (1,2, 1, -1)
-%!error normrnd (ones(2,2), 2, 3)
-%!error normrnd (ones(2,2), 2, [3, 2])
-%!error normrnd (ones(2,2), 2, 2, 3)
+%!error normrnd (ones (2,2), 2, 3)
+%!error normrnd (ones (2,2), 2, [3, 2])
+%!error normrnd (ones (2,2), 2, 2, 3)
 
--- a/scripts/statistics/distributions/poisscdf.m
+++ b/scripts/statistics/distributions/poisscdf.m
@@ -68,23 +68,23 @@
 
 %!shared x,y
 %! x = [-1 0 1 2 Inf];
-%! y = [0, gammainc(1, (x(2:4) +1), 'upper'), 1];
-%!assert(poisscdf (x, ones(1,5)), y);
-%!assert(poisscdf (x, 1), y);
-%!assert(poisscdf (x, [1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)]);
-%!assert(poisscdf ([x(1:2) NaN Inf x(5)], 1), [y(1:2) NaN 1 y(5)]);
+%! y = [0, gammainc(1, (x(2:4) +1), "upper"), 1];
+%!assert (poisscdf (x, ones (1,5)), y)
+%!assert (poisscdf (x, 1), y)
+%!assert (poisscdf (x, [1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)])
+%!assert (poisscdf ([x(1:2) NaN Inf x(5)], 1), [y(1:2) NaN 1 y(5)])
 
 %% Test class of input preserved
-%!assert(poisscdf ([x, NaN], 1), [y, NaN]);
-%!assert(poisscdf (single([x, NaN]), 1), single([y, NaN]), eps("single"));
-%!assert(poisscdf ([x, NaN], single(1)), single([y, NaN]), eps("single"));
+%!assert (poisscdf ([x, NaN], 1), [y, NaN])
+%!assert (poisscdf (single ([x, NaN]), 1), single ([y, NaN]), eps ("single"))
+%!assert (poisscdf ([x, NaN], single (1)), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error poisscdf ()
 %!error poisscdf (1)
 %!error poisscdf (1,2,3)
-%!error poisscdf (ones(3),ones(2))
-%!error poisscdf (ones(2),ones(3))
+%!error poisscdf (ones (3), ones (2))
+%!error poisscdf (ones (2), ones (3))
 %!error poisscdf (i, 2)
 %!error poisscdf (2, i)
 
--- a/scripts/statistics/distributions/poissinv.m
+++ b/scripts/statistics/distributions/poissinv.m
@@ -82,22 +82,22 @@
 
 %!shared x
 %! x = [-1 0 0.5 1 2];
-%!assert(poissinv (x, ones(1,5)), [NaN 0 1 Inf NaN]);
-%!assert(poissinv (x, 1), [NaN 0 1 Inf NaN]);
-%!assert(poissinv (x, [1 0 NaN 1 1]), [NaN NaN NaN Inf NaN]);
-%!assert(poissinv ([x(1:2) NaN x(4:5)], 1), [NaN 0 NaN Inf NaN]);
+%!assert (poissinv (x, ones (1,5)), [NaN 0 1 Inf NaN])
+%!assert (poissinv (x, 1), [NaN 0 1 Inf NaN])
+%!assert (poissinv (x, [1 0 NaN 1 1]), [NaN NaN NaN Inf NaN])
+%!assert (poissinv ([x(1:2) NaN x(4:5)], 1), [NaN 0 NaN Inf NaN])
 
 %% Test class of input preserved
-%!assert(poissinv ([x, NaN], 1), [NaN 0 1 Inf NaN NaN]);
-%!assert(poissinv (single([x, NaN]), 1), single([NaN 0 1 Inf NaN NaN]));
-%!assert(poissinv ([x, NaN], single(1)), single([NaN 0 1 Inf NaN NaN]));
+%!assert (poissinv ([x, NaN], 1), [NaN 0 1 Inf NaN NaN])
+%!assert (poissinv (single ([x, NaN]), 1), single ([NaN 0 1 Inf NaN NaN]))
+%!assert (poissinv ([x, NaN], single (1)), single ([NaN 0 1 Inf NaN NaN]))
 
 %% Test input validation
 %!error poissinv ()
 %!error poissinv (1)
 %!error poissinv (1,2,3)
-%!error poissinv (ones(3),ones(2))
-%!error poissinv (ones(2),ones(3))
+%!error poissinv (ones (3), ones (2))
+%!error poissinv (ones (2), ones (3))
 %!error poissinv (i, 2)
 %!error poissinv (2, i)
 
--- a/scripts/statistics/distributions/poisspdf.m
+++ b/scripts/statistics/distributions/poisspdf.m
@@ -65,21 +65,21 @@
 %!shared x,y
 %! x = [-1 0 1 2 Inf];
 %! y = [0, exp(-1)*[1 1 0.5], 0];
-%!assert(poisspdf (x, ones(1,5)), y, eps);
-%!assert(poisspdf (x, 1), y, eps);
-%!assert(poisspdf (x, [1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)], eps);
-%!assert(poisspdf ([x, NaN], 1), [y, NaN], eps);
+%!assert (poisspdf (x, ones (1,5)), y, eps)
+%!assert (poisspdf (x, 1), y, eps)
+%!assert (poisspdf (x, [1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)], eps)
+%!assert (poisspdf ([x, NaN], 1), [y, NaN], eps)
 
 %% Test class of input preserved
-%!assert(poisspdf (single([x, NaN]), 1), single([y, NaN]), eps("single"));
-%!assert(poisspdf ([x, NaN], single(1)), single([y, NaN]), eps("single"));
+%!assert (poisspdf (single ([x, NaN]), 1), single ([y, NaN]), eps ("single"))
+%!assert (poisspdf ([x, NaN], single (1)), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error poisspdf ()
 %!error poisspdf (1)
 %!error poisspdf (1,2,3)
-%!error poisspdf (ones(3),ones(2))
-%!error poisspdf (ones(2),ones(3))
+%!error poisspdf (ones (3), ones (2))
+%!error poisspdf (ones (2), ones (3))
 %!error poisspdf (i, 2)
 %!error poisspdf (2, i)
 
--- a/scripts/statistics/distributions/poissrnd.m
+++ b/scripts/statistics/distributions/poissrnd.m
@@ -77,10 +77,7 @@
 
   if (isscalar (lambda))
     if (lambda >= 0 && lambda < Inf)
-      rnd = randp (lambda, sz);
-      if (strcmp (cls, "single"))
-        rnd = single (rnd);
-      endif
+      rnd = randp (lambda, sz, cls);
     else
       rnd = NaN (sz, cls);
     endif
@@ -88,34 +85,35 @@
     rnd = NaN (sz, cls);
 
     k = (lambda >= 0) & (lambda < Inf);
-    rnd(k) = randp (lambda(k));
+    rnd(k) = randp (lambda(k), cls);
   endif
 
 endfunction
 
-%!assert(size (poissrnd (2)), [1, 1]);
-%!assert(size (poissrnd (ones(2,1))), [2, 1]);
-%!assert(size (poissrnd (ones(2,2))), [2, 2]);
-%!assert(size (poissrnd (1, 3)), [3, 3]);
-%!assert(size (poissrnd (1, [4 1])), [4, 1]);
-%!assert(size (poissrnd (1, 4, 1)), [4, 1]);
+
+%!assert (size (poissrnd (2)), [1, 1])
+%!assert (size (poissrnd (ones (2,1))), [2, 1])
+%!assert (size (poissrnd (ones (2,2))), [2, 2])
+%!assert (size (poissrnd (1, 3)), [3, 3])
+%!assert (size (poissrnd (1, [4 1])), [4, 1])
+%!assert (size (poissrnd (1, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (poissrnd (2)), "double");
-%!assert(class (poissrnd (single(2))), "single");
-%!assert(class (poissrnd (single([2 2]))), "single");
+%!assert (class (poissrnd (2)), "double")
+%!assert (class (poissrnd (single (2))), "single")
+%!assert (class (poissrnd (single ([2 2]))), "single")
 
 %% Test input validation
 %!error poissrnd ()
 %!error poissrnd (1, -1)
-%!error poissrnd (1, ones(2))
-%!error poissrnd (1, 2, ones(2))
+%!error poissrnd (1, ones (2))
+%!error poissrnd (1, 2, ones (2))
 %!error poissrnd (i)
 %!error poissrnd (1, 2, -1)
 %!error poissrnd (1, [2 -1 2])
-%!error poissrnd (ones(2,2), 3)
-%!error poissrnd (ones(2,2), [3, 2])
-%!error poissrnd (ones(2,2), 2, 3)
+%!error poissrnd (ones (2,2), 3)
+%!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/distributions/stdnormal_cdf.m
+++ b/scripts/statistics/distributions/stdnormal_cdf.m
@@ -45,10 +45,10 @@
 %!shared x,y
 %! x = [-Inf 0 1 Inf];
 %! y = [0, 0.5, 1/2*(1+erf(1/sqrt(2))), 1];
-%!assert(stdnormal_cdf ([x, NaN]), [y, NaN]);
+%!assert (stdnormal_cdf ([x, NaN]), [y, NaN])
 
 %% Test class of input preserved
-%!assert(stdnormal_cdf (single([x, NaN])), single([y, NaN]), eps("single"));
+%!assert (stdnormal_cdf (single ([x, NaN])), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error stdnormal_cdf ()
--- a/scripts/statistics/distributions/stdnormal_inv.m
+++ b/scripts/statistics/distributions/stdnormal_inv.m
@@ -37,18 +37,18 @@
     error ("stdnormal_inv: X must not be complex");
   endif
 
-  inv = sqrt (2) * erfinv (2 * x - 1);
+  inv = - sqrt (2) * erfcinv (2 * x);
 
 endfunction
 
 
 %!shared x
 %! x = [-1 0 0.5 1 2];
-%!assert(stdnormal_inv (x), [NaN -Inf 0 Inf NaN]);
+%!assert (stdnormal_inv (x), [NaN -Inf 0 Inf NaN])
 
 %% Test class of input preserved
-%!assert(stdnormal_inv ([x, NaN]), [NaN -Inf 0 Inf NaN NaN]);
-%!assert(stdnormal_inv (single([x, NaN])), single([NaN -Inf 0 Inf NaN NaN]));
+%!assert (stdnormal_inv ([x, NaN]), [NaN -Inf 0 Inf NaN NaN])
+%!assert (stdnormal_inv (single ([x, NaN])), single ([NaN -Inf 0 Inf NaN NaN]))
 
 %% Test input validation
 %!error stdnormal_inv ()
--- a/scripts/statistics/distributions/stdnormal_pdf.m
+++ b/scripts/statistics/distributions/stdnormal_pdf.m
@@ -45,10 +45,10 @@
 %!shared x,y
 %! x = [-Inf 0 1 Inf];
 %! y = 1/sqrt(2*pi)*exp (-x.^2/2);
-%!assert(stdnormal_pdf ([x, NaN]), [y, NaN], eps);
+%!assert (stdnormal_pdf ([x, NaN]), [y, NaN], eps)
 
 %% Test class of input preserved
-%!assert(stdnormal_pdf (single([x, NaN])), single([y, NaN]), eps("single"));
+%!assert (stdnormal_pdf (single ([x, NaN])), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error stdnormal_pdf ()
--- a/scripts/statistics/distributions/stdnormal_rnd.m
+++ b/scripts/statistics/distributions/stdnormal_rnd.m
@@ -60,15 +60,15 @@
 endfunction
 
 
-%!assert(size (stdnormal_rnd (3)), [3, 3]);
-%!assert(size (stdnormal_rnd ([4 1])), [4, 1]);
-%!assert(size (stdnormal_rnd (4,1)), [4, 1]);
+%!assert (size (stdnormal_rnd (3)), [3, 3])
+%!assert (size (stdnormal_rnd ([4 1])), [4, 1])
+%!assert (size (stdnormal_rnd (4,1)), [4, 1])
 
 %% Test input validation
 %!error stdnormal_rnd ()
 %!error stdnormal_rnd (-1)
-%!error stdnormal_rnd (ones(2))
+%!error stdnormal_rnd (ones (2))
 %!error stdnormal_rnd ([2 -1 2])
-%!error stdnormal_rnd (1, ones(2))
+%!error stdnormal_rnd (1, ones (2))
 %!error stdnormal_rnd (1, -1)
 
--- a/scripts/statistics/distributions/tcdf.m
+++ b/scripts/statistics/distributions/tcdf.m
@@ -73,22 +73,22 @@
 %!shared x,y
 %! x = [-Inf 0 1 Inf];
 %! y = [0 1/2 3/4 1];
-%!assert(tcdf (x, ones(1,4)), y, eps);
-%!assert(tcdf (x, 1), y, eps);
-%!assert(tcdf (x, [0 1 NaN 1]), [NaN 1/2 NaN 1], eps);
-%!assert(tcdf ([x(1:2) NaN x(4)], 1), [y(1:2) NaN y(4)], eps);
+%!assert (tcdf (x, ones (1,4)), y, eps)
+%!assert (tcdf (x, 1), y, eps)
+%!assert (tcdf (x, [0 1 NaN 1]), [NaN 1/2 NaN 1], eps)
+%!assert (tcdf ([x(1:2) NaN x(4)], 1), [y(1:2) NaN y(4)], eps)
 
 %% Test class of input preserved
-%!assert(tcdf ([x, NaN], 1), [y, NaN], eps);
-%!assert(tcdf (single([x, NaN]), 1), single([y, NaN]), eps("single"));
-%!assert(tcdf ([x, NaN], single(1)), single([y, NaN]), eps("single"));
+%!assert (tcdf ([x, NaN], 1), [y, NaN], eps)
+%!assert (tcdf (single ([x, NaN]), 1), single ([y, NaN]), eps ("single"))
+%!assert (tcdf ([x, NaN], single (1)), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error tcdf ()
 %!error tcdf (1)
 %!error tcdf (1,2,3)
-%!error tcdf (ones(3),ones(2))
-%!error tcdf (ones(2),ones(3))
+%!error tcdf (ones (3), ones (2))
+%!error tcdf (ones (2), ones (3))
 %!error tcdf (i, 2)
 %!error tcdf (2, i)
 
--- a/scripts/statistics/distributions/tinv.m
+++ b/scripts/statistics/distributions/tinv.m
@@ -87,22 +87,22 @@
 
 %!shared x
 %! x = [-1 0 0.5 1 2];
-%!assert(tinv (x, ones(1,5)), [NaN -Inf 0 Inf NaN]);
-%!assert(tinv (x, 1), [NaN -Inf 0 Inf NaN], eps);
-%!assert(tinv (x, [1 0 NaN 1 1]), [NaN NaN NaN Inf NaN], eps);
-%!assert(tinv ([x(1:2) NaN x(4:5)], 1), [NaN -Inf NaN Inf NaN]);
+%!assert (tinv (x, ones (1,5)), [NaN -Inf 0 Inf NaN])
+%!assert (tinv (x, 1), [NaN -Inf 0 Inf NaN], eps)
+%!assert (tinv (x, [1 0 NaN 1 1]), [NaN NaN NaN Inf NaN], eps)
+%!assert (tinv ([x(1:2) NaN x(4:5)], 1), [NaN -Inf NaN Inf NaN])
 
 %% Test class of input preserved
-%!assert(tinv ([x, NaN], 1), [NaN -Inf 0 Inf NaN NaN], eps);
-%!assert(tinv (single([x, NaN]), 1), single([NaN -Inf 0 Inf NaN NaN]), eps("single"));
-%!assert(tinv ([x, NaN], single(1)), single([NaN -Inf 0 Inf NaN NaN]), eps("single"));
+%!assert (tinv ([x, NaN], 1), [NaN -Inf 0 Inf NaN NaN], eps)
+%!assert (tinv (single ([x, NaN]), 1), single ([NaN -Inf 0 Inf NaN NaN]), eps ("single"))
+%!assert (tinv ([x, NaN], single (1)), single ([NaN -Inf 0 Inf NaN NaN]), eps ("single"))
 
 %% Test input validation
 %!error tinv ()
 %!error tinv (1)
 %!error tinv (1,2,3)
-%!error tinv (ones(3),ones(2))
-%!error tinv (ones(2),ones(3))
+%!error tinv (ones (3), ones (2))
+%!error tinv (ones (2), ones (3))
 %!error tinv (i, 2)
 %!error tinv (2, i)
 
--- a/scripts/statistics/distributions/tpdf.m
+++ b/scripts/statistics/distributions/tpdf.m
@@ -68,26 +68,26 @@
 %!test
 %! x = rand (10,1);
 %! y = 1./(pi * (1 + x.^2));
-%! assert(tpdf (x, 1), y, 5*eps);
+%! assert (tpdf (x, 1), y, 5*eps);
 
 %!shared x,y
 %! x = [-Inf 0 0.5 1 Inf];
 %! y = 1./(pi * (1 + x.^2));
-%!assert(tpdf (x, ones(1,5)), y, eps);
-%!assert(tpdf (x, 1), y, eps);
-%!assert(tpdf (x, [0 NaN 1 1 1]), [NaN NaN y(3:5)], eps);
+%!assert (tpdf (x, ones (1,5)), y, eps)
+%!assert (tpdf (x, 1), y, eps)
+%!assert (tpdf (x, [0 NaN 1 1 1]), [NaN NaN y(3:5)], eps)
 
 %% Test class of input preserved
-%!assert(tpdf ([x, NaN], 1), [y, NaN], eps);
-%!assert(tpdf (single([x, NaN]), 1), single([y, NaN]), eps("single"));
-%!assert(tpdf ([x, NaN], single(1)), single([y, NaN]), eps("single"));
+%!assert (tpdf ([x, NaN], 1), [y, NaN], eps)
+%!assert (tpdf (single ([x, NaN]), 1), single ([y, NaN]), eps ("single"))
+%!assert (tpdf ([x, NaN], single (1)), single ([y, NaN]), eps ("single"))
 
 %% Test input validation
 %!error tpdf ()
 %!error tpdf (1)
 %!error tpdf (1,2,3)
-%!error tpdf (ones(3),ones(2))
-%!error tpdf (ones(2),ones(3))
+%!error tpdf (ones (3), ones (2))
+%!error tpdf (ones (2), ones (3))
 %!error tpdf (i, 2)
 %!error tpdf (2, i)
 
--- a/scripts/statistics/distributions/trnd.m
+++ b/scripts/statistics/distributions/trnd.m
@@ -77,7 +77,7 @@
 
   if (isscalar (n))
     if ((n > 0) && (n < Inf))
-      rnd = randn (sz) ./ sqrt (2*randg (n/2, sz) / n);
+      rnd = randn (sz, cls) ./ sqrt (2*randg (n/2, sz, cls) / n);
     else
       rnd = NaN (sz, cls);
     endif
@@ -85,33 +85,33 @@
     rnd = NaN (sz, cls);
 
     k = (n > 0) & (n < Inf);
-    rnd(k) = randn (sum (k(:)), 1) ./ sqrt (2*randg (n(k)/2) ./ n(k))(:);
+    rnd(k) = randn (sum (k(:)), 1, cls) ./ sqrt (2*randg (n(k)/2, cls) ./ n(k))(:);
   endif
 
 endfunction
 
 
-%!assert(size (trnd (2)), [1, 1]);
-%!assert(size (trnd (ones(2,1))), [2, 1]);
-%!assert(size (trnd (ones(2,2))), [2, 2]);
-%!assert(size (trnd (1, 3)), [3, 3]);
-%!assert(size (trnd (1, [4 1])), [4, 1]);
-%!assert(size (trnd (1, 4, 1)), [4, 1]);
+%!assert (size (trnd (2)), [1, 1])
+%!assert (size (trnd (ones (2,1))), [2, 1])
+%!assert (size (trnd (ones (2,2))), [2, 2])
+%!assert (size (trnd (1, 3)), [3, 3])
+%!assert (size (trnd (1, [4 1])), [4, 1])
+%!assert (size (trnd (1, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (trnd (1)), "double");
-%!assert(class (trnd (single(1))), "single");
-%!assert(class (trnd (single([1 1]))), "single");
+%!assert (class (trnd (1)), "double")
+%!assert (class (trnd (single (1))), "single")
+%!assert (class (trnd (single ([1 1]))), "single")
 
 %% Test input validation
 %!error trnd ()
 %!error trnd (1, -1)
-%!error trnd (1, ones(2))
+%!error trnd (1, ones (2))
 %!error trnd (i)
 %!error trnd (1, [2 -1 2])
-%!error trnd (1, 2, ones(2))
+%!error trnd (1, 2, ones (2))
 %!error trnd (1, 2, -1)
-%!error trnd (ones(2,2), 3)
-%!error trnd (ones(2,2), [3, 2])
-%!error trnd (ones(2,2), 2, 3)
+%!error trnd (ones (2,2), 3)
+%!error trnd (ones (2,2), [3, 2])
+%!error trnd (ones (2,2), 2, 3)
 
--- a/scripts/statistics/distributions/unidcdf.m
+++ b/scripts/statistics/distributions/unidcdf.m
@@ -68,22 +68,22 @@
 %!shared x,y
 %! x = [0 1 2.5 10 11];
 %! y = [0, 0.1 0.2 1.0 1.0];
-%!assert(unidcdf (x, 10*ones(1,5)), y);
-%!assert(unidcdf (x, 10), y);
-%!assert(unidcdf (x, 10*[0 1 NaN 1 1]), [NaN 0.1 NaN y(4:5)]);
-%!assert(unidcdf ([x(1:2) NaN Inf x(5)], 10), [y(1:2) NaN 1 y(5)]);
+%!assert (unidcdf (x, 10*ones (1,5)), y)
+%!assert (unidcdf (x, 10), y)
+%!assert (unidcdf (x, 10*[0 1 NaN 1 1]), [NaN 0.1 NaN y(4:5)])
+%!assert (unidcdf ([x(1:2) NaN Inf x(5)], 10), [y(1:2) NaN 1 y(5)])
 
 %% Test class of input preserved
-%!assert(unidcdf ([x, NaN], 10), [y, NaN]);
-%!assert(unidcdf (single([x, NaN]), 10), single([y, NaN]));
-%!assert(unidcdf ([x, NaN], single(10)), single([y, NaN]));
+%!assert (unidcdf ([x, NaN], 10), [y, NaN])
+%!assert (unidcdf (single ([x, NaN]), 10), single ([y, NaN]))
+%!assert (unidcdf ([x, NaN], single (10)), single ([y, NaN]))
 
 %% Test input validation
 %!error unidcdf ()
 %!error unidcdf (1)
 %!error unidcdf (1,2,3)
-%!error unidcdf (ones(3),ones(2))
-%!error unidcdf (ones(2),ones(3))
+%!error unidcdf (ones (3), ones (2))
+%!error unidcdf (ones (2), ones (3))
 %!error unidcdf (i, 2)
 %!error unidcdf (2, i)
 
--- a/scripts/statistics/distributions/unidinv.m
+++ b/scripts/statistics/distributions/unidinv.m
@@ -60,22 +60,22 @@
 
 %!shared x
 %! x = [-1 0 0.5 1 2];
-%!assert(unidinv (x, 10*ones(1,5)), [NaN NaN 5 10 NaN], eps);
-%!assert(unidinv (x, 10), [NaN NaN 5 10 NaN], eps);
-%!assert(unidinv (x, 10*[0 1 NaN 1 1]), [NaN NaN NaN 10 NaN], eps);
-%!assert(unidinv ([x(1:2) NaN x(4:5)], 10), [NaN NaN NaN 10 NaN], eps);
+%!assert (unidinv (x, 10*ones (1,5)), [NaN NaN 5 10 NaN], eps)
+%!assert (unidinv (x, 10), [NaN NaN 5 10 NaN], eps)
+%!assert (unidinv (x, 10*[0 1 NaN 1 1]), [NaN NaN NaN 10 NaN], eps)
+%!assert (unidinv ([x(1:2) NaN x(4:5)], 10), [NaN NaN NaN 10 NaN], eps)
 
 %% Test class of input preserved
-%!assert(unidinv ([x, NaN], 10), [NaN NaN 5 10 NaN NaN], eps);
-%!assert(unidinv (single([x, NaN]), 10), single([NaN NaN 5 10 NaN NaN]), eps);
-%!assert(unidinv ([x, NaN], single(10)), single([NaN NaN 5 10 NaN NaN]), eps);
+%!assert (unidinv ([x, NaN], 10), [NaN NaN 5 10 NaN NaN], eps)
+%!assert (unidinv (single ([x, NaN]), 10), single ([NaN NaN 5 10 NaN NaN]), eps)
+%!assert (unidinv ([x, NaN], single (10)), single ([NaN NaN 5 10 NaN NaN]), eps)
 
 %% Test input validation
 %!error unidinv ()
 %!error unidinv (1)
 %!error unidinv (1,2,3)
-%!error unidinv (ones(3),ones(2))
-%!error unidinv (ones(2),ones(3))
+%!error unidinv (ones (3), ones (2))
+%!error unidinv (ones (2), ones (3))
 %!error unidinv (i, 2)
 %!error unidinv (2, i)
 
--- a/scripts/statistics/distributions/unidpdf.m
+++ b/scripts/statistics/distributions/unidpdf.m
@@ -67,21 +67,21 @@
 %!shared x,y
 %! x = [-1 0 1 2 10 11];
 %! y = [0 0 0.1 0.1 0.1 0];
-%!assert(unidpdf (x, 10*ones(1,6)), y);
-%!assert(unidpdf (x, 10), y);
-%!assert(unidpdf (x, 10*[0 NaN 1 1 1 1]), [NaN NaN y(3:6)]);
-%!assert(unidpdf ([x, NaN], 10), [y, NaN]);
+%!assert (unidpdf (x, 10*ones (1,6)), y)
+%!assert (unidpdf (x, 10), y)
+%!assert (unidpdf (x, 10*[0 NaN 1 1 1 1]), [NaN NaN y(3:6)])
+%!assert (unidpdf ([x, NaN], 10), [y, NaN])
 
 %% Test class of input preserved
-%!assert(unidpdf (single([x, NaN]), 10), single([y, NaN]));
-%!assert(unidpdf ([x, NaN], single(10)), single([y, NaN]));
+%!assert (unidpdf (single ([x, NaN]), 10), single ([y, NaN]))
+%!assert (unidpdf ([x, NaN], single (10)), single ([y, NaN]))
 
 %% Test input validation
 %!error unidpdf ()
 %!error unidpdf (1)
 %!error unidpdf (1,2,3)
-%!error unidpdf (ones(3),ones(2))
-%!error unidpdf (ones(2),ones(3))
+%!error unidpdf (ones (3), ones (2))
+%!error unidpdf (ones (2), ones (3))
 %!error unidpdf (i, 2)
 %!error unidpdf (2, i)
 
--- a/scripts/statistics/distributions/unidrnd.m
+++ b/scripts/statistics/distributions/unidrnd.m
@@ -77,12 +77,12 @@
 
   if (isscalar (n))
     if (n > 0 && n == fix (n))
-      rnd = ceil (rand (sz) * n);
+      rnd = ceil (rand (sz, cls) * n);
     else
       rnd = NaN (sz, cls);
     endif
   else
-    rnd = ceil (rand (sz) .* n);
+    rnd = ceil (rand (sz, cls) .* n);
 
     k = ! (n > 0 & n == fix (n));
     rnd(k) = NaN;
@@ -91,21 +91,21 @@
 endfunction
 
 
-%!assert(size (unidrnd (2)), [1, 1]);
-%!assert(size (unidrnd (ones(2,1))), [2, 1]);
-%!assert(size (unidrnd (ones(2,2))), [2, 2]);
-%!assert(size (unidrnd (10, [4 1])), [4, 1]);
-%!assert(size (unidrnd (10, 4, 1)), [4, 1]);
+%!assert (size (unidrnd (2)), [1, 1])
+%!assert (size (unidrnd (ones (2,1))), [2, 1])
+%!assert (size (unidrnd (ones (2,2))), [2, 2])
+%!assert (size (unidrnd (10, [4 1])), [4, 1])
+%!assert (size (unidrnd (10, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (unidrnd (2)), "double");
-%!assert(class (unidrnd (single(2))), "single");
-%!assert(class (unidrnd (single([2 2]))), "single");
+%!assert (class (unidrnd (2)), "double")
+%!assert (class (unidrnd (single (2))), "single")
+%!assert (class (unidrnd (single ([2 2]))), "single")
 
 %% Test input validation
 %!error unidrnd ()
 %!error unidrnd (10, [1;2;3])
-%!error unidrnd (10, 2, ones(2))
-%!error unidrnd (10*ones(2), 2, 1)
+%!error unidrnd (10, 2, ones (2))
+%!error unidrnd (10*ones (2), 2, 1)
 %!error unidrnd (i)
 
--- a/scripts/statistics/distributions/unifcdf.m
+++ b/scripts/statistics/distributions/unifcdf.m
@@ -72,26 +72,26 @@
 %!shared x,y
 %! x = [-1 0 0.5 1 2] + 1;
 %! y = [0 0 0.5 1 1];
-%!assert(unifcdf (x, ones(1,5), 2*ones(1,5)), y);
-%!assert(unifcdf (x, 1, 2*ones(1,5)), y);
-%!assert(unifcdf (x, ones(1,5), 2), y);
-%!assert(unifcdf (x, [2 1 NaN 1 1], 2), [NaN 0 NaN 1 1]);
-%!assert(unifcdf (x, 1, 2*[0 1 NaN 1 1]), [NaN 0 NaN 1 1]);
-%!assert(unifcdf ([x(1:2) NaN x(4:5)], 1, 2), [y(1:2) NaN y(4:5)]);
+%!assert (unifcdf (x, ones (1,5), 2*ones (1,5)), y)
+%!assert (unifcdf (x, 1, 2*ones (1,5)), y)
+%!assert (unifcdf (x, ones (1,5), 2), y)
+%!assert (unifcdf (x, [2 1 NaN 1 1], 2), [NaN 0 NaN 1 1])
+%!assert (unifcdf (x, 1, 2*[0 1 NaN 1 1]), [NaN 0 NaN 1 1])
+%!assert (unifcdf ([x(1:2) NaN x(4:5)], 1, 2), [y(1:2) NaN y(4:5)])
 
 %% Test class of input preserved
-%!assert(unifcdf ([x, NaN], 1, 2), [y, NaN]);
-%!assert(unifcdf (single([x, NaN]), 1, 2), single([y, NaN]));
-%!assert(unifcdf ([x, NaN], single(1), 2), single([y, NaN]));
-%!assert(unifcdf ([x, NaN], 1, single(2)), single([y, NaN]));
+%!assert (unifcdf ([x, NaN], 1, 2), [y, NaN])
+%!assert (unifcdf (single ([x, NaN]), 1, 2), single ([y, NaN]))
+%!assert (unifcdf ([x, NaN], single (1), 2), single ([y, NaN]))
+%!assert (unifcdf ([x, NaN], 1, single (2)), single ([y, NaN]))
 
 %% Test input validation
 %!error unifcdf ()
 %!error unifcdf (1,2)
 %!error unifcdf (1,2,3,4)
-%!error unifcdf (ones(3),ones(2),ones(2))
-%!error unifcdf (ones(2),ones(3),ones(2))
-%!error unifcdf (ones(2),ones(2),ones(3))
+%!error unifcdf (ones (3), ones (2), ones (2))
+%!error unifcdf (ones (2), ones (3), ones (2))
+%!error unifcdf (ones (2), ones (2), ones (3))
 %!error unifcdf (i, 2, 2)
 %!error unifcdf (2, i, 2)
 %!error unifcdf (2, 2, i)
--- a/scripts/statistics/distributions/unifinv.m
+++ b/scripts/statistics/distributions/unifinv.m
@@ -65,26 +65,26 @@
 
 %!shared x
 %! x = [-1 0 0.5 1 2];
-%!assert(unifinv (x, ones(1,5), 2*ones(1,5)), [NaN 1 1.5 2 NaN]);
-%!assert(unifinv (x, 1, 2*ones(1,5)), [NaN 1 1.5 2 NaN]);
-%!assert(unifinv (x, ones(1,5), 2), [NaN 1 1.5 2 NaN]);
-%!assert(unifinv (x, [1 2 NaN 1 1], 2), [NaN NaN NaN 2 NaN]);
-%!assert(unifinv (x, 1, 2*[1 0 NaN 1 1]), [NaN NaN NaN 2 NaN]);
-%!assert(unifinv ([x(1:2) NaN x(4:5)], 1, 2), [NaN 1 NaN 2 NaN]);
+%!assert (unifinv (x, ones (1,5), 2*ones (1,5)), [NaN 1 1.5 2 NaN])
+%!assert (unifinv (x, 1, 2*ones (1,5)), [NaN 1 1.5 2 NaN])
+%!assert (unifinv (x, ones (1,5), 2), [NaN 1 1.5 2 NaN])
+%!assert (unifinv (x, [1 2 NaN 1 1], 2), [NaN NaN NaN 2 NaN])
+%!assert (unifinv (x, 1, 2*[1 0 NaN 1 1]), [NaN NaN NaN 2 NaN])
+%!assert (unifinv ([x(1:2) NaN x(4:5)], 1, 2), [NaN 1 NaN 2 NaN])
 
 %% Test class of input preserved
-%!assert(unifinv ([x, NaN], 1, 2), [NaN 1 1.5 2 NaN NaN]);
-%!assert(unifinv (single([x, NaN]), 1, 2), single([NaN 1 1.5 2 NaN NaN]));
-%!assert(unifinv ([x, NaN], single(1), 2), single([NaN 1 1.5 2 NaN NaN]));
-%!assert(unifinv ([x, NaN], 1, single(2)), single([NaN 1 1.5 2 NaN NaN]));
+%!assert (unifinv ([x, NaN], 1, 2), [NaN 1 1.5 2 NaN NaN])
+%!assert (unifinv (single ([x, NaN]), 1, 2), single ([NaN 1 1.5 2 NaN NaN]))
+%!assert (unifinv ([x, NaN], single (1), 2), single ([NaN 1 1.5 2 NaN NaN]))
+%!assert (unifinv ([x, NaN], 1, single (2)), single ([NaN 1 1.5 2 NaN NaN]))
 
 %% Test input validation
 %!error unifinv ()
 %!error unifinv (1,2)
 %!error unifinv (1,2,3,4)
-%!error unifinv (ones(3),ones(2),ones(2))
-%!error unifinv (ones(2),ones(3),ones(2))
-%!error unifinv (ones(2),ones(2),ones(3))
+%!error unifinv (ones (3), ones (2), ones (2))
+%!error unifinv (ones (2), ones (3), ones (2))
+%!error unifinv (ones (2), ones (2), ones (3))
 %!error unifinv (i, 2, 2)
 %!error unifinv (2, i, 2)
 %!error unifinv (2, 2, i)
--- a/scripts/statistics/distributions/unifpdf.m
+++ b/scripts/statistics/distributions/unifpdf.m
@@ -68,25 +68,25 @@
 %!shared x,y
 %! x = [-1 0 0.5 1 2] + 1;
 %! y = [0 1 1 1 0];
-%!assert(unifpdf (x, ones(1,5), 2*ones(1,5)), y);
-%!assert(unifpdf (x, 1, 2*ones(1,5)), y);
-%!assert(unifpdf (x, ones(1,5), 2), y);
-%!assert(unifpdf (x, [2 NaN 1 1 1], 2), [NaN NaN y(3:5)]);
-%!assert(unifpdf (x, 1, 2*[0 NaN 1 1 1]), [NaN NaN y(3:5)]);
-%!assert(unifpdf ([x, NaN], 1, 2), [y, NaN]);
+%!assert (unifpdf (x, ones (1,5), 2*ones (1,5)), y)
+%!assert (unifpdf (x, 1, 2*ones (1,5)), y)
+%!assert (unifpdf (x, ones (1,5), 2), y)
+%!assert (unifpdf (x, [2 NaN 1 1 1], 2), [NaN NaN y(3:5)])
+%!assert (unifpdf (x, 1, 2*[0 NaN 1 1 1]), [NaN NaN y(3:5)])
+%!assert (unifpdf ([x, NaN], 1, 2), [y, NaN])
 
 %% Test class of input preserved
-%!assert(unifpdf (single([x, NaN]), 1, 2), single([y, NaN]));
-%!assert(unifpdf (single([x, NaN]), single(1), 2), single([y, NaN]));
-%!assert(unifpdf ([x, NaN], 1, single(2)), single([y, NaN]));
+%!assert (unifpdf (single ([x, NaN]), 1, 2), single ([y, NaN]))
+%!assert (unifpdf (single ([x, NaN]), single (1), 2), single ([y, NaN]))
+%!assert (unifpdf ([x, NaN], 1, single (2)), single ([y, NaN]))
 
 %% Test input validation
 %!error unifpdf ()
 %!error unifpdf (1,2)
 %!error unifpdf (1,2,3,4)
-%!error unifpdf (ones(3),ones(2),ones(2))
-%!error unifpdf (ones(2),ones(3),ones(2))
-%!error unifpdf (ones(2),ones(2),ones(3))
+%!error unifpdf (ones (3), ones (2), ones (2))
+%!error unifpdf (ones (2), ones (3), ones (2))
+%!error unifpdf (ones (2), ones (2), ones (3))
 %!error unifpdf (i, 2, 2)
 %!error unifpdf (2, i, 2)
 %!error unifpdf (2, 2, i)
--- a/scripts/statistics/distributions/unifrnd.m
+++ b/scripts/statistics/distributions/unifrnd.m
@@ -84,12 +84,12 @@
 
   if (isscalar (a) && isscalar (b))
     if ((-Inf < a) && (a < b) && (b < Inf))
-      rnd =  a + (b - a) * rand (sz);
+      rnd =  a + (b - a) * rand (sz, cls);
     else
       rnd = NaN (sz, cls);
     endif
   else
-    rnd =  a + (b - a) .* rand (sz);
+    rnd =  a + (b - a) .* rand (sz, cls);
 
     k = !(-Inf < a) | !(a < b) | !(b < Inf);
     rnd(k) = NaN;
@@ -98,35 +98,35 @@
 endfunction
 
 
-%!assert(size (unifrnd (1,2)), [1, 1]);
-%!assert(size (unifrnd (ones(2,1), 2)), [2, 1]);
-%!assert(size (unifrnd (ones(2,2), 2)), [2, 2]);
-%!assert(size (unifrnd (1, 2*ones(2,1))), [2, 1]);
-%!assert(size (unifrnd (1, 2*ones(2,2))), [2, 2]);
-%!assert(size (unifrnd (1, 2, 3)), [3, 3]);
-%!assert(size (unifrnd (1, 2, [4 1])), [4, 1]);
-%!assert(size (unifrnd (1, 2, 4, 1)), [4, 1]);
+%!assert (size (unifrnd (1,2)), [1, 1])
+%!assert (size (unifrnd (ones (2,1), 2)), [2, 1])
+%!assert (size (unifrnd (ones (2,2), 2)), [2, 2])
+%!assert (size (unifrnd (1, 2*ones (2,1))), [2, 1])
+%!assert (size (unifrnd (1, 2*ones (2,2))), [2, 2])
+%!assert (size (unifrnd (1, 2, 3)), [3, 3])
+%!assert (size (unifrnd (1, 2, [4 1])), [4, 1])
+%!assert (size (unifrnd (1, 2, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (unifrnd (1, 2)), "double");
-%!assert(class (unifrnd (single(1), 2)), "single");
-%!assert(class (unifrnd (single([1 1]), 2)), "single");
-%!assert(class (unifrnd (1, single(2))), "single");
-%!assert(class (unifrnd (1, single([2 2]))), "single");
+%!assert (class (unifrnd (1, 2)), "double")
+%!assert (class (unifrnd (single (1), 2)), "single")
+%!assert (class (unifrnd (single ([1 1]), 2)), "single")
+%!assert (class (unifrnd (1, single (2))), "single")
+%!assert (class (unifrnd (1, single ([2 2]))), "single")
 
 %% Test input validation
 %!error unifrnd ()
 %!error unifrnd (1)
-%!error unifrnd (ones(3),ones(2))
-%!error unifrnd (ones(2),ones(3))
+%!error unifrnd (ones (3), ones (2))
+%!error unifrnd (ones (2), ones (3))
 %!error unifrnd (i, 2)
 %!error unifrnd (2, i)
 %!error unifrnd (1,2, -1)
-%!error unifrnd (1,2, ones(2))
+%!error unifrnd (1,2, ones (2))
 %!error unifrnd (1, 2, [2 -1 2])
-%!error unifrnd (1,2, 1, ones(2))
+%!error unifrnd (1,2, 1, ones (2))
 %!error unifrnd (1,2, 1, -1)
-%!error unifrnd (ones(2,2), 2, 3)
-%!error unifrnd (ones(2,2), 2, [3, 2])
-%!error unifrnd (ones(2,2), 2, 2, 3)
+%!error unifrnd (ones (2,2), 2, 3)
+%!error unifrnd (ones (2,2), 2, [3, 2])
+%!error unifrnd (ones (2,2), 2, 2, 3)
 
--- a/scripts/statistics/distributions/wblcdf.m
+++ b/scripts/statistics/distributions/wblcdf.m
@@ -88,25 +88,25 @@
 %!shared x,y
 %! x = [-1 0 0.5 1 Inf];
 %! y = [0, 1-exp(-x(2:4)), 1];
-%!assert(wblcdf (x, ones(1,5), ones(1,5)), y);
-%!assert(wblcdf (x, 1, ones(1,5)), y);
-%!assert(wblcdf (x, ones(1,5), 1), y);
-%!assert(wblcdf (x, [0 1 NaN Inf 1], 1), [NaN 0 NaN NaN 1]);
-%!assert(wblcdf (x, 1, [0 1 NaN Inf 1]), [NaN 0 NaN NaN 1]);
-%!assert(wblcdf ([x(1:2) NaN x(4:5)], 1, 1), [y(1:2) NaN y(4:5)]);
+%!assert (wblcdf (x, ones (1,5), ones (1,5)), y)
+%!assert (wblcdf (x, 1, ones (1,5)), y)
+%!assert (wblcdf (x, ones (1,5), 1), y)
+%!assert (wblcdf (x, [0 1 NaN Inf 1], 1), [NaN 0 NaN NaN 1])
+%!assert (wblcdf (x, 1, [0 1 NaN Inf 1]), [NaN 0 NaN NaN 1])
+%!assert (wblcdf ([x(1:2) NaN x(4:5)], 1, 1), [y(1:2) NaN y(4:5)])
 
 %% Test class of input preserved
-%!assert(wblcdf ([x, NaN], 1, 1), [y, NaN]);
-%!assert(wblcdf (single([x, NaN]), 1, 1), single([y, NaN]));
-%!assert(wblcdf ([x, NaN], single(1), 1), single([y, NaN]));
-%!assert(wblcdf ([x, NaN], 1, single(1)), single([y, NaN]));
+%!assert (wblcdf ([x, NaN], 1, 1), [y, NaN])
+%!assert (wblcdf (single ([x, NaN]), 1, 1), single ([y, NaN]))
+%!assert (wblcdf ([x, NaN], single (1), 1), single ([y, NaN]))
+%!assert (wblcdf ([x, NaN], 1, single (1)), single ([y, NaN]))
 
 %% Test input validation
 %!error wblcdf ()
 %!error wblcdf (1,2,3,4)
-%!error wblcdf (ones(3),ones(2),ones(2))
-%!error wblcdf (ones(2),ones(3),ones(2))
-%!error wblcdf (ones(2),ones(2),ones(3))
+%!error wblcdf (ones (3), ones (2), ones (2))
+%!error wblcdf (ones (2), ones (3), ones (2))
+%!error wblcdf (ones (2), ones (2), ones (3))
 %!error wblcdf (i, 2, 2)
 %!error wblcdf (2, i, 2)
 %!error wblcdf (2, 2, i)
--- a/scripts/statistics/distributions/wblinv.m
+++ b/scripts/statistics/distributions/wblinv.m
@@ -74,25 +74,25 @@
 
 %!shared x
 %! x = [-1 0 0.63212055882855778 1 2];
-%!assert(wblinv (x, ones(1,5), ones(1,5)), [NaN 0 1 Inf NaN], eps);
-%!assert(wblinv (x, 1, ones(1,5)), [NaN 0 1 Inf NaN], eps);
-%!assert(wblinv (x, ones(1,5), 1), [NaN 0 1 Inf NaN], eps);
-%!assert(wblinv (x, [1 -1 NaN Inf 1], 1), [NaN NaN NaN NaN NaN]);
-%!assert(wblinv (x, 1, [1 -1 NaN Inf 1]), [NaN NaN NaN NaN NaN]);
-%!assert(wblinv ([x(1:2) NaN x(4:5)], 1, 1), [NaN 0 NaN Inf NaN]);
+%!assert (wblinv (x, ones (1,5), ones (1,5)), [NaN 0 1 Inf NaN], eps)
+%!assert (wblinv (x, 1, ones (1,5)), [NaN 0 1 Inf NaN], eps)
+%!assert (wblinv (x, ones (1,5), 1), [NaN 0 1 Inf NaN], eps)
+%!assert (wblinv (x, [1 -1 NaN Inf 1], 1), [NaN NaN NaN NaN NaN])
+%!assert (wblinv (x, 1, [1 -1 NaN Inf 1]), [NaN NaN NaN NaN NaN])
+%!assert (wblinv ([x(1:2) NaN x(4:5)], 1, 1), [NaN 0 NaN Inf NaN])
 
 %% Test class of input preserved
-%!assert(wblinv ([x, NaN], 1, 1), [NaN 0 1 Inf NaN NaN], eps);
-%!assert(wblinv (single([x, NaN]), 1, 1), single([NaN 0 1 Inf NaN NaN]), eps("single"));
-%!assert(wblinv ([x, NaN], single(1), 1), single([NaN 0 1 Inf NaN NaN]), eps("single"));
-%!assert(wblinv ([x, NaN], 1, single(1)), single([NaN 0 1 Inf NaN NaN]), eps("single"));
+%!assert (wblinv ([x, NaN], 1, 1), [NaN 0 1 Inf NaN NaN], eps)
+%!assert (wblinv (single ([x, NaN]), 1, 1), single ([NaN 0 1 Inf NaN NaN]), eps ("single"))
+%!assert (wblinv ([x, NaN], single (1), 1), single ([NaN 0 1 Inf NaN NaN]), eps ("single"))
+%!assert (wblinv ([x, NaN], 1, single (1)), single ([NaN 0 1 Inf NaN NaN]), eps ("single"))
 
 %% Test input validation
 %!error wblinv ()
 %!error wblinv (1,2,3,4)
-%!error wblinv (ones(3),ones(2),ones(2))
-%!error wblinv (ones(2),ones(3),ones(2))
-%!error wblinv (ones(2),ones(2),ones(3))
+%!error wblinv (ones (3), ones (2), ones (2))
+%!error wblinv (ones (2), ones (3), ones (2))
+%!error wblinv (ones (2), ones (2), ones (3))
 %!error wblinv (i, 2, 2)
 %!error wblinv (2, i, 2)
 %!error wblinv (2, 2, i)
--- a/scripts/statistics/distributions/wblpdf.m
+++ b/scripts/statistics/distributions/wblpdf.m
@@ -88,24 +88,24 @@
 %!shared x,y
 %! x = [-1 0 0.5 1 Inf];
 %! y = [0, exp(-x(2:4)), NaN];
-%!assert(wblpdf (x, ones(1,5), ones(1,5)), y);
-%!assert(wblpdf (x, 1, ones(1,5)), y);
-%!assert(wblpdf (x, ones(1,5), 1), y);
-%!assert(wblpdf (x, [0 NaN Inf 1 1], 1), [NaN NaN NaN y(4:5)]);
-%!assert(wblpdf (x, 1, [0 NaN Inf 1 1]), [NaN NaN NaN y(4:5)]);
-%!assert(wblpdf ([x, NaN], 1, 1), [y, NaN]);
+%!assert (wblpdf (x, ones (1,5), ones (1,5)), y)
+%!assert (wblpdf (x, 1, ones (1,5)), y)
+%!assert (wblpdf (x, ones (1,5), 1), y)
+%!assert (wblpdf (x, [0 NaN Inf 1 1], 1), [NaN NaN NaN y(4:5)])
+%!assert (wblpdf (x, 1, [0 NaN Inf 1 1]), [NaN NaN NaN y(4:5)])
+%!assert (wblpdf ([x, NaN], 1, 1), [y, NaN])
 
 %% Test class of input preserved
-%!assert(wblpdf (single([x, NaN]), 1, 1), single([y, NaN]));
-%!assert(wblpdf ([x, NaN], single(1), 1), single([y, NaN]));
-%!assert(wblpdf ([x, NaN], 1, single(1)), single([y, NaN]));
+%!assert (wblpdf (single ([x, NaN]), 1, 1), single ([y, NaN]))
+%!assert (wblpdf ([x, NaN], single (1), 1), single ([y, NaN]))
+%!assert (wblpdf ([x, NaN], 1, single (1)), single ([y, NaN]))
 
 %% Test input validation
 %!error wblpdf ()
 %!error wblpdf (1,2,3,4)
-%!error wblpdf (ones(3),ones(2),ones(2))
-%!error wblpdf (ones(2),ones(3),ones(2))
-%!error wblpdf (ones(2),ones(2),ones(3))
+%!error wblpdf (ones (3), ones (2), ones (2))
+%!error wblpdf (ones (2), ones (3), ones (2))
+%!error wblpdf (ones (2), ones (2), ones (3))
 %!error wblpdf (i, 2, 2)
 %!error wblpdf (2, i, 2)
 %!error wblpdf (2, 2, i)
--- a/scripts/statistics/distributions/wblrnd.m
+++ b/scripts/statistics/distributions/wblrnd.m
@@ -84,12 +84,12 @@
 
   if (isscalar (scale) && isscalar (shape))
     if ((scale > 0) && (scale < Inf) && (shape > 0) && (shape < Inf))
-      rnd = scale * rande (sz) .^ (1/shape);
+      rnd = scale * rande (sz, cls) .^ (1/shape);
     else
       rnd = NaN (sz, cls);
     endif
   else
-    rnd = scale .* rande (sz) .^ (1./shape);
+    rnd = scale .* rande (sz, cls) .^ (1./shape);
 
     k = (scale <= 0) | (scale == Inf) | (shape <= 0) | (shape == Inf);
     rnd(k) = NaN;
@@ -98,35 +98,35 @@
 endfunction
 
 
-%!assert(size (wblrnd (1,2)), [1, 1]);
-%!assert(size (wblrnd (ones(2,1), 2)), [2, 1]);
-%!assert(size (wblrnd (ones(2,2), 2)), [2, 2]);
-%!assert(size (wblrnd (1, 2*ones(2,1))), [2, 1]);
-%!assert(size (wblrnd (1, 2*ones(2,2))), [2, 2]);
-%!assert(size (wblrnd (1, 2, 3)), [3, 3]);
-%!assert(size (wblrnd (1, 2, [4 1])), [4, 1]);
-%!assert(size (wblrnd (1, 2, 4, 1)), [4, 1]);
+%!assert (size (wblrnd (1,2)), [1, 1])
+%!assert (size (wblrnd (ones (2,1), 2)), [2, 1])
+%!assert (size (wblrnd (ones (2,2), 2)), [2, 2])
+%!assert (size (wblrnd (1, 2*ones (2,1))), [2, 1])
+%!assert (size (wblrnd (1, 2*ones (2,2))), [2, 2])
+%!assert (size (wblrnd (1, 2, 3)), [3, 3])
+%!assert (size (wblrnd (1, 2, [4 1])), [4, 1])
+%!assert (size (wblrnd (1, 2, 4, 1)), [4, 1])
 
 %% Test class of input preserved
-%!assert(class (wblrnd (1, 2)), "double");
-%!assert(class (wblrnd (single(1), 2)), "single");
-%!assert(class (wblrnd (single([1 1]), 2)), "single");
-%!assert(class (wblrnd (1, single(2))), "single");
-%!assert(class (wblrnd (1, single([2 2]))), "single");
+%!assert (class (wblrnd (1, 2)), "double")
+%!assert (class (wblrnd (single (1), 2)), "single")
+%!assert (class (wblrnd (single ([1 1]), 2)), "single")
+%!assert (class (wblrnd (1, single (2))), "single")
+%!assert (class (wblrnd (1, single ([2 2]))), "single")
 
 %% Test input validation
 %!error wblrnd ()
 %!error wblrnd (1)
-%!error wblrnd (ones(3),ones(2))
-%!error wblrnd (ones(2),ones(3))
+%!error wblrnd (ones (3), ones (2))
+%!error wblrnd (ones (2), ones (3))
 %!error wblrnd (i, 2)
 %!error wblrnd (2, i)
 %!error wblrnd (1,2, -1)
-%!error wblrnd (1,2, ones(2))
+%!error wblrnd (1,2, ones (2))
 %!error wblrnd (1, 2, [2 -1 2])
-%!error wblrnd (1,2, 1, ones(2))
+%!error wblrnd (1,2, 1, ones (2))
 %!error wblrnd (1,2, 1, -1)
-%!error wblrnd (ones(2,2), 2, 3)
-%!error wblrnd (ones(2,2), 2, [3, 2])
-%!error wblrnd (ones(2,2), 2, 2, 3)
+%!error wblrnd (ones (2,2), 2, 3)
+%!error wblrnd (ones (2,2), 2, [3, 2])
+%!error wblrnd (ones (2,2), 2, 2, 3)
 
--- a/scripts/statistics/models/private/logistic_regression_likelihood.m
+++ b/scripts/statistics/models/private/logistic_regression_likelihood.m
@@ -35,7 +35,7 @@
 
   e = exp ([z, x] * beta); e1 = exp ([z1, x] * beta);
   g = e ./ (1 + e); g1 = e1 ./ (1 + e1);
-  g = max (y == max (y), g); g1 = min (y > min(y), g1);
+  g = max (y == max (y), g); g1 = min (y > min (y), g1);
 
   p = g - g1;
   dev = -2 * sum (log (p));
--- a/scripts/statistics/tests/bartlett_test.m
+++ b/scripts/statistics/tests/bartlett_test.m
@@ -61,7 +61,7 @@
   pval  = 1 - chi2cdf (chisq, df);
 
   if (nargout == 0)
-    printf("  pval: %g\n", pval);
+    printf ("  pval: %g\n", pval);
   endif
 
 endfunction
--- a/scripts/statistics/tests/chisquare_test_homogeneity.m
+++ b/scripts/statistics/tests/chisquare_test_homogeneity.m
@@ -42,7 +42,7 @@
     print_usage ();
   endif
 
-  if (! (isvector(x) && isvector(y) && isvector(c)))
+  if (! (isvector (x) && isvector (y) && isvector (c)))
     error ("chisquare_test_homogeneity: X, Y and C must be vectors");
   endif
   ## Now test c for strictly increasing entries
@@ -57,12 +57,12 @@
   n_x   = sum (x * ones (1, df+1) < ones (l_x, 1) * c);
   l_y   = length (y);
   y     = reshape (y, l_y, 1);
-  n_y   = sum(y * ones (1, df+1) < ones (l_y, 1) * c);
+  n_y   = sum (y * ones (1, df+1) < ones (l_y, 1) * c);
   chisq = l_x * l_y * sum ((n_x/l_x - n_y/l_y).^2 ./ (n_x + n_y));
   pval  = 1 - chi2cdf (chisq, df);
 
   if (nargout == 0)
-    printf("  pval: %g\n", pval);
+    printf ("  pval: %g\n", pval);
   endif
 
 endfunction
--- a/scripts/statistics/tests/chisquare_test_independence.m
+++ b/scripts/statistics/tests/chisquare_test_independence.m
@@ -47,7 +47,7 @@
   pval  = 1 - chi2cdf (chisq, df);
 
   if (nargout == 0)
-    printf("  pval: %g\n", pval);
+    printf ("  pval: %g\n", pval);
   endif
 
 endfunction
--- a/scripts/statistics/tests/kolmogorov_smirnov_test.m
+++ b/scripts/statistics/tests/kolmogorov_smirnov_test.m
@@ -28,7 +28,7 @@
 ## a uniform distribution on [2,4], use
 ##
 ## @example
-## kolmogorov_smirnov_test(x, "unif", 2, 4)
+## kolmogorov_smirnov_test (x, "unif", 2, 4)
 ## @end example
 ##
 ## @noindent
@@ -110,17 +110,18 @@
 
 endfunction
 
-%!error <Invalid call to kolmogorov_smirnov_test>
-%!  kolmogorov_smirnov_test (1);
-%!error <kolmogorov_smirnov_test: X must be a vector>
-%!  kolmogorov_smirnov_test ({}, "unif", 2, 4);
-%!error <kolmogorov_smirnov_test: no not_a_distcdf or not_a_dist_cdf function found>
+
+## test for recognition of unifcdf function
+%!assert (kolmogorov_smirnov_test (0:100, "unif", 0, 100), 1.0, eps)
+## test for recognition of logistic_cdf function
+%!assert (kolmogorov_smirnov_test (0:100, "logistic"), 0)
+## test for  F < G
+%!assert (kolmogorov_smirnov_test (50:100, "unif", 0, 50, "<"))
+
+%!error kolmogorov_smirnov_test (1)
+%!error <X must be a vector> kolmogorov_smirnov_test ({}, "unif", 2, 4)
+%!error <no not_a_distcdf or not_a_dist_cdf function found>
 %!  kolmogorov_smirnov_test (1, "not_a_dist");
-%!error <kolmogorov_smirnov_test: alternative bla not recognized>
-%!  kolmogorov_smirnov_test (1, "unif", 2, 4, "bla");
-%!test # for recognition of unifcdf function
-%!  assert (kolmogorov_smirnov_test (0:100, "unif", 0, 100), 1.0, eps);
-%!test # for recognition of logistic_cdf function
-%!  assert (kolmogorov_smirnov_test (0:100, "logistic"), 0);
-%!test # F < G
-%!  assert (kolmogorov_smirnov_test (50:100, "unif", 0, 50, "<"));
+%!error <alternative foo not recognized>
+%!  kolmogorov_smirnov_test (1, "unif", 2, 4, "foo");
+
--- a/scripts/statistics/tests/kruskal_wallis_test.m
+++ b/scripts/statistics/tests/kruskal_wallis_test.m
@@ -94,5 +94,6 @@
 
 endfunction
 
+
 ## Test with ties
-%!assert (abs(kruskal_wallis_test([86 86], [74]) - 0.157299207050285) < 0.0000000000001)
+%!assert (abs (kruskal_wallis_test ([86 86], [74]) - 0.157299207050285) < 0.0000000000001)
--- a/scripts/statistics/tests/prop_test_2.m
+++ b/scripts/statistics/tests/prop_test_2.m
@@ -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/run_test.m
+++ b/scripts/statistics/tests/run_test.m
@@ -46,13 +46,13 @@
   b = [1/6; 5/24; 11/120; 19/720; 29/5040; 1/840];
 
   n = rows (x);
-  r = run_count (x, 6) - n * b * ones (1, columns(x));
+  r = run_count (x, 6) - n * b * ones (1, columns (x));
 
   chisq = diag (r' * A * r)' / n;
   pval  = chi2cdf (chisq, 6);
 
   if (nargout == 0)
-    printf("pval: %g\n", pval);
+    printf ("pval: %g\n", pval);
   endif
 
 endfunction
--- a/scripts/statistics/tests/sign_test.m
+++ b/scripts/statistics/tests/sign_test.m
@@ -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
+++ b/scripts/statistics/tests/t_test.m
@@ -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
+++ b/scripts/statistics/tests/t_test_2.m
@@ -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
+++ b/scripts/statistics/tests/t_test_regression.m
@@ -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/statistics/tests/u_test.m
+++ b/scripts/statistics/tests/u_test.m
@@ -66,7 +66,7 @@
   endif
 
   if (! ischar (alt))
-    error("u_test: ALT must be a string");
+    error ("u_test: ALT must be a string");
   endif
   if (strcmp (alt, "!=") || strcmp (alt, "<>"))
     pval = 2 * min (cdf, 1 - cdf);
--- a/scripts/statistics/tests/wilcoxon_test.m
+++ b/scripts/statistics/tests/wilcoxon_test.m
@@ -73,7 +73,7 @@
   endif
 
   if (! ischar (alt))
-    error("wilcoxon_test: ALT must be a string");
+    error ("wilcoxon_test: ALT must be a string");
   elseif (strcmp (alt, "!=") || strcmp (alt, "<>"))
     pval = 2 * min (cdf, 1 - cdf);
   elseif (strcmp (alt, ">"))
--- a/scripts/statistics/tests/z_test.m
+++ b/scripts/statistics/tests/z_test.m
@@ -79,8 +79,8 @@
 
   if (nargout == 0)
     s = cstrcat ("Z-test of mean(x) == %g against mean(x) %s %g,\n",
-                "with known var(x) == %g:\n",
-                "  pval = %g\n");
+                 "with known var(x) == %g:\n",
+                 "  pval = %g\n");
     printf (s, m, alt, m, v, pval);
   endif
 
--- a/scripts/statistics/tests/z_test_2.m
+++ b/scripts/statistics/tests/z_test_2.m
@@ -48,7 +48,7 @@
   endif
 
   if (! (isvector (x) && isvector (y)))
-    error("z_test_2: both X and Y must be vectors");
+    error ("z_test_2: both X and Y must be vectors");
   elseif (! (isscalar (v_x) && (v_x > 0)
              && isscalar (v_y) && (v_y > 0)))
     error ("z_test_2: both V_X and V_Y must be positive scalars");
@@ -79,9 +79,9 @@
 
   if (nargout == 0)
     s = cstrcat ("Two-sample Z-test of mean(x) == mean(y) against ",
-                "mean(x) %s mean(y),\n",
-                "with known var(x) == %g and var(y) == %g:\n",
-                "  pval = %g\n");
+                 "mean(x) %s mean(y),\n",
+                 "with known var(x) == %g and var(y) == %g:\n",
+                 "  pval = %g\n");
     printf (s, alt, v_x, v_y, pval);
   endif
 
--- a/scripts/strings/base2dec.m
+++ b/scripts/strings/base2dec.m
@@ -117,20 +117,20 @@
 endfunction
 
 
-%!assert(base2dec ("11120", 3), 123);
-%!assert(base2dec ("yyyzx", "xyz"), 123);
-%!assert(base2dec ("-1", 2), NaN);
-%!assert(base2dec ({"A1", "1A"}, 16), [161; 26]);
+%!assert (base2dec ("11120", 3), 123)
+%!assert (base2dec ("yyyzx", "xyz"), 123)
+%!assert (base2dec ("-1", 2), NaN)
+%!assert (base2dec ({"A1", "1A"}, 16), [161; 26])
 
 %% Bug #35621
 %!assert (base2dec (["0"; "1"], 2), [0; 1])
 
 %%Test input validation
-%!error base2dec ();
-%!error base2dec ("11120");
-%!error base2dec ("11120", 3, 4);
-%!error base2dec ("11120", "1231");
-%!error base2dec ("11120", "12 3");
-%!error base2dec ("11120", ones(2));
-%!error base2dec ("11120", 37);
+%!error base2dec ()
+%!error base2dec ("11120")
+%!error base2dec ("11120", 3, 4)
+%!error base2dec ("11120", "1231")
+%!error base2dec ("11120", "12 3")
+%!error base2dec ("11120", ones (2))
+%!error base2dec ("11120", 37)
 
--- a/scripts/strings/bin2dec.m
+++ b/scripts/strings/bin2dec.m
@@ -60,15 +60,15 @@
 endfunction
 
 
-%!assert(bin2dec ("0000"), 0);
-%!assert(bin2dec ("1110"), 14);
-%!assert(bin2dec ("11111111111111111111111111111111111111111111111111111"), 2^53-1);
-%!assert(bin2dec ({"1110", "1111"}), [14; 15]);
+%!assert (bin2dec ("0000"), 0)
+%!assert (bin2dec ("1110"), 14)
+%!assert (bin2dec ("11111111111111111111111111111111111111111111111111111"), 2^53-1)
+%!assert (bin2dec ({"1110", "1111"}), [14; 15])
 %!assert (bin2dec ("1 0 1"), 5)
-%!assert (bin2dec (char ("1 0 1", "   1111")), [5; 15]);
+%!assert (bin2dec (char ("1 0 1", "   1111")), [5; 15])
 
 %%Test input validation
-%!error bin2dec ();
-%!error bin2dec (1);
-%!error bin2dec ("1", 2);
+%!error bin2dec ()
+%!error bin2dec (1)
+%!error bin2dec ("1", 2)
 
--- a/scripts/strings/blanks.m
+++ b/scripts/strings/blanks.m
@@ -23,7 +23,7 @@
 ## @example
 ## @group
 ## blanks (10);
-## whos ans;
+## whos ans
 ##      @result{}
 ##       Attr Name        Size                     Bytes  Class
 ##       ==== ====        ====                     =====  =====
@@ -52,9 +52,9 @@
 
 
 ## There really isn't that much to test here
-%!assert(blanks (0), "")
-%!assert(blanks (5), "     ")
-%!assert(blanks (10), "          ")
+%!assert (blanks (0), "")
+%!assert (blanks (5), "     ")
+%!assert (blanks (10), "          ")
 
 %% Test input validation
 %!error blanks ()
--- a/scripts/strings/cstrcat.m
+++ b/scripts/strings/cstrcat.m
@@ -32,8 +32,8 @@
 ## @group
 ## s = [ "ab"; "cde" ];
 ## cstrcat (s, s, s)
-##      @result{} "ab ab ab "
-##         "cdecdecde"
+##       @result{} "ab ab ab "
+##          "cdecdecde"
 ## @end group
 ## @end example
 ## @seealso{strcat, char, strvcat}
@@ -64,6 +64,6 @@
 %!assert (cstrcat (["a"; "bb"], ["foo"; "bar"]), ["a foo"; "bbbar"])
 
 %% Test input validation
-%!error cstrcat ();
-%!error cstrcat (1, 2);
+%!error cstrcat ()
+%!error cstrcat (1, 2)
 
--- a/scripts/strings/deblank.m
+++ b/scripts/strings/deblank.m
@@ -75,15 +75,15 @@
 endfunction
 
 
-%!assert (deblank (" f o o \0"), " f o o");
-%!assert (deblank ('   '), '');
-%!assert (deblank ("   "), "");
-%!assert (deblank (""), "");
-%!assert (deblank ({}), {});
-%!assert (deblank ({" abc   ", {"   def   "}}), {" abc", {"   def"}});
+%!assert (deblank (" f o o \0"), " f o o")
+%!assert (deblank ('   '), '')
+%!assert (deblank ("   "), "")
+%!assert (deblank (""), "")
+%!assert (deblank ({}), {})
+%!assert (deblank ({" abc   ", {"   def   "}}), {" abc", {"   def"}})
 
-%!error <Invalid call to deblank> deblank ();
-%!error <Invalid call to deblank> deblank ("foo", "bar");
-%!error <argument must be a string> deblank (1);
-%!error <argument must be a string> deblank ({[]});
+%!error <Invalid call to deblank> deblank ()
+%!error <Invalid call to deblank> deblank ("foo", "bar")
+%!error <argument must be a string> deblank (1)
+%!error <argument must be a string> deblank ({[]})
 
--- a/scripts/strings/dec2base.m
+++ b/scripts/strings/dec2base.m
@@ -119,23 +119,23 @@
 
 
 %!test
-%! s0 = '';
+%! s0 = "";
 %! for n = 1:13
 %!   for b = 2:16
 %!     pp = dec2base (b^n+1, b);
-%!     assert (dec2base(b^n, b), ['1',s0,'0']);
-%!     assert (dec2base(b^n+1, b), ['1',s0,'1']);
+%!     assert (dec2base (b^n, b), ['1',s0,'0']);
+%!     assert (dec2base (b^n+1, b), ['1',s0,'1']);
 %!   endfor
 %!   s0 = [s0,'0'];
 %! endfor
 
 %!test
-%! digits='0123456789ABCDEF';
+%! digits = "0123456789ABCDEF";
 %! for n = 1:13
 %!   for b = 2:16
-%!     pm = dec2base(b^n-1, b);
+%!     pm = dec2base (b^n-1, b);
 %!     assert (length (pm), n);
-%!     assert (all (pm==digits(b)));
+%!     assert (all (pm == digits(b)));
 %!   endfor
 %! endfor
 
@@ -144,12 +144,12 @@
 %!   assert (dec2base (0, b), '0');
 %! endfor
 
-%!assert(dec2base (0, 2, 4), "0000");
-%!assert(dec2base (2^51-1, 2), ...
-%!       '111111111111111111111111111111111111111111111111111');
-%!assert(dec2base(uint64(2)^63-1, 16), '7FFFFFFFFFFFFFFF');
-%!assert(dec2base([1, 2; 3, 4], 2, 3), ["001"; "011"; "010"; "100"]);
-%!assert(dec2base({1, 2; 3, 4}, 2, 3), ["001"; "011"; "010"; "100"]);
+%!assert (dec2base (0, 2, 4), "0000")
+%!assert (dec2base (2^51-1, 2), ...
+%!        "111111111111111111111111111111111111111111111111111")
+%!assert (dec2base (uint64 (2)^63-1, 16), "7FFFFFFFFFFFFFFF")
+%!assert (dec2base ([1, 2; 3, 4], 2, 3), ["001"; "011"; "010"; "100"])
+%!assert (dec2base ({1, 2; 3, 4}, 2, 3), ["001"; "011"; "010"; "100"])
 
 %%Test input validation
 %!error dec2base ()
@@ -161,7 +161,7 @@
 %!error dec2base (1.1)
 %!error dec2base (1, "ABA")
 %!error dec2base (1, "A B")
-%!error dec2base (1, ones(2))
+%!error dec2base (1, ones (2))
 %!error dec2base (1, 1)
 %!error dec2base (1, 37)
 
--- a/scripts/strings/dec2bin.m
+++ b/scripts/strings/dec2bin.m
@@ -53,11 +53,11 @@
 endfunction
 
 
-%!assert(dec2bin (14), "1110");
-%!assert(dec2bin (14, 6), "001110");
-%!assert(dec2bin ({1, 2; 3, 4}), ["001"; "011"; "010"; "100"]);
+%!assert (dec2bin (14), "1110")
+%!assert (dec2bin (14, 6), "001110")
+%!assert (dec2bin ({1, 2; 3, 4}), ["001"; "011"; "010"; "100"])
 
 %%Test input validation
-%!error dec2bin ();
-%!error dec2bin (1, 2, 3);
+%!error dec2bin ()
+%!error dec2bin (1, 2, 3)
 
--- a/scripts/strings/dec2hex.m
+++ b/scripts/strings/dec2hex.m
@@ -53,11 +53,11 @@
 endfunction
 
 
-%!assert(dec2hex (2748), "ABC");
-%!assert(dec2hex (2748, 5), "00ABC");
-%!assert(dec2hex ({2748, 2746}), ["ABC"; "ABA"]);
+%!assert (dec2hex (2748), "ABC")
+%!assert (dec2hex (2748, 5), "00ABC")
+%!assert (dec2hex ({2748, 2746}), ["ABC"; "ABA"])
 
 %% Test input validation
-%!error dec2hex ();
-%!error dec2hex (1, 2, 3);
+%!error dec2hex ()
+%!error dec2hex (1, 2, 3)
 
--- a/scripts/strings/findstr.m
+++ b/scripts/strings/findstr.m
@@ -133,11 +133,11 @@
 
 
 %!assert (findstr ("abababa", "a"), [1, 3, 5, 7])
-%!assert (findstr ("abababa", "aba"), [1, 3, 5]);
-%!assert (findstr ("aba", "abababa", 0), [1, 5]);
+%!assert (findstr ("abababa", "aba"), [1, 3, 5])
+%!assert (findstr ("aba", "abababa", 0), [1, 5])
 
 %% Test input validation
 %!error findstr ()
-%!error findstr ("foo", "bar", 3, 4);
-%!error findstr (["AB" ; "CD"], "C");
+%!error findstr ("foo", "bar", 3, 4)
+%!error <must have only one non-singleton dimension> findstr (["AB" ; "CD"], "C")
 
--- a/scripts/strings/hex2dec.m
+++ b/scripts/strings/hex2dec.m
@@ -24,9 +24,9 @@
 ## @example
 ## @group
 ## hex2dec ("12B")
-##      @result{} 299
+##       @result{} 299
 ## hex2dec ("12b")
-##      @result{} 299
+##       @result{} 299
 ## @end group
 ## @end example
 ##
@@ -53,13 +53,13 @@
 endfunction
 
 
-%!assert(hex2dec ("0000"), 0);
-%!assert(hex2dec ("1FFFFFFFFFFFFF"), 2^53-1);
-%!assert(hex2dec (["12b"; "12B"]), [299; 299]);
-%!assert(hex2dec ({"A1", "1A"}), [161; 26]);
+%!assert (hex2dec ("0000"), 0)
+%!assert (hex2dec ("1FFFFFFFFFFFFF"), 2^53-1)
+%!assert (hex2dec (["12b"; "12B"]), [299; 299])
+%!assert (hex2dec ({"A1", "1A"}), [161; 26])
 
 %%Test input validation
-%!error hex2dec ();
-%!error hex2dec (1);
-%!error hex2dec ("1", 2);
+%!error hex2dec ()
+%!error hex2dec (1)
+%!error hex2dec ("1", 2)
 
--- a/scripts/strings/index.m
+++ b/scripts/strings/index.m
@@ -28,7 +28,7 @@
 ## @example
 ## @group
 ## index ("Teststring", "t")
-##    @result{} 4
+##     @result{} 4
 ## @end group
 ## @end example
 ##
@@ -84,20 +84,21 @@
 endfunction
 
 
-%!assert (index ("foobarbaz", "b") == 4 && index ("foobarbaz", "z") == 9);
+%!assert (index ("foobarbaz", "b"), 4)
+%!assert (index ("foobarbaz", "z"), 9)
 
-%!assert (index("astringbstringcstring", "s"), 2)
-%!assert (index("astringbstringcstring", "st"), 2)
-%!assert (index("astringbstringcstring", "str"), 2)
-%!assert (index("astringbstringcstring", "string"), 2)
-%!assert (index("abc---", "abc+++"), 0)
+%!assert (index ("astringbstringcstring", "s"), 2)
+%!assert (index ("astringbstringcstring", "st"), 2)
+%!assert (index ("astringbstringcstring", "str"), 2)
+%!assert (index ("astringbstringcstring", "string"), 2)
+%!assert (index ("abc---", "abc+++"), 0)
 
 ## test everything out in reverse
-%!assert (index("astringbstringcstring", "s", "last"), 16)
-%!assert (index("astringbstringcstring", "st", "last"), 16)
-%!assert (index("astringbstringcstring", "str", "last"), 16)
-%!assert (index("astringbstringcstring", "string", "last"), 16)
-%!assert (index("abc---", "abc+++", "last"), 0)
+%!assert (index ("astringbstringcstring", "s", "last"), 16)
+%!assert (index ("astringbstringcstring", "st", "last"), 16)
+%!assert (index ("astringbstringcstring", "str", "last"), 16)
+%!assert (index ("astringbstringcstring", "string", "last"), 16)
+%!assert (index ("abc---", "abc+++", "last"), 0)
 
 %!test
 %! str = char ("Hello", "World", "Goodbye", "World");
--- a/scripts/strings/isletter.m
+++ b/scripts/strings/isletter.m
@@ -36,5 +36,7 @@
 
 endfunction
 
-%!error isletter();
-%!error isletter("a", "b");
+
+%!error isletter ()
+%!error isletter ("a", "b")
+
--- a/scripts/strings/mat2str.m
+++ b/scripts/strings/mat2str.m
@@ -41,7 +41,7 @@
 ## mat2str ([ -1/3 +i/7; 1/3 -i/7 ], [4 2])
 ##      @result{} "[-0.3333+0i 0+0.14i;0.3333+0i -0-0.14i]"
 ##
-## mat2str (int16([1 -1]), "class")
+## mat2str (int16 ([1 -1]), "class")
 ##      @result{} "int16([1 -1])"
 ##
 ## mat2str (logical (eye (2)))
@@ -128,20 +128,20 @@
 endfunction
 
 
-%!assert (mat2str (0.7), "0.7");
-%!assert (mat2str (pi), "3.14159265358979");
-%!assert (mat2str (pi, 5), "3.1416");
-%!assert (mat2str (single (pi), 5, "class"), "single(3.1416)");
+%!assert (mat2str (0.7), "0.7")
+%!assert (mat2str (pi), "3.14159265358979")
+%!assert (mat2str (pi, 5), "3.1416")
+%!assert (mat2str (single (pi), 5, "class"), "single(3.1416)")
 %!assert (mat2str ([-1/3 + i/7; 1/3 - i/7], [4 2]), "[-0.3333+0.14i;0.3333-0.14i]")
 %!assert (mat2str ([-1/3 +i/7; 1/3 -i/7], [4 2]), "[-0.3333+0i 0+0.14i;0.3333+0i -0-0.14i]")
-%!assert (mat2str (int16 ([1 -1]), 'class'), "int16([1 -1])")
-%!assert (mat2str (true), "true");
-%!assert (mat2str (false), "false");
-%!assert (mat2str (logical (eye (2))), "[true false;false true]");
+%!assert (mat2str (int16 ([1 -1]), "class"), "int16([1 -1])")
+%!assert (mat2str (true), "true")
+%!assert (mat2str (false), "false")
+%!assert (mat2str (logical (eye (2))), "[true false;false true]")
 
 %% Test input validation
 %!error mat2str ()
 %!error mat2str (1,2,3,4)
 %!error mat2str (["Hello"])
-%!error mat2str (ones(3,3,2))
+%!error <X must be two dimensional> mat2str (ones (3,3,2))
 
--- a/scripts/strings/regexptranslate.m
+++ b/scripts/strings/regexptranslate.m
@@ -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/strings/rindex.m
+++ b/scripts/strings/rindex.m
@@ -52,7 +52,8 @@
 endfunction
 
 
-%!assert(rindex ("foobarbaz", "b") == 7 && rindex ("foobarbaz", "o") == 3);
+%!assert (rindex ("foobarbaz", "b"), 7)
+%!assert (rindex ("foobarbaz", "o"), 3)
 
 %!test
 %! str = char ("Hello", "World", "Goodbye", "World");
--- a/scripts/strings/str2num.m
+++ b/scripts/strings/str2num.m
@@ -68,8 +68,8 @@
 endfunction
 
 
-%!assert(str2num ("-1.3e2"), -130);
-%!assert(str2num ("[1, 2; 3, 4]"), [1, 2; 3, 4]);
+%!assert (str2num ("-1.3e2"), -130)
+%!assert (str2num ("[1, 2; 3, 4]"), [1, 2; 3, 4])
 
 %!test
 %! [x, state] = str2num ("pi");
--- a/scripts/strings/strcat.m
+++ b/scripts/strings/strcat.m
@@ -23,11 +23,35 @@
 ## horizontally.  If the arguments are cells strings,  @code{strcat}
 ## returns a cell string with the individual cells concatenated.
 ## For numerical input, each element is converted to the
-## corresponding ASCII character.  Trailing white space is eliminated.
+## corresponding ASCII character.  Trailing white space for each of
+## the inputs (@var{s1}, @var{S2}, @dots{}) is eliminated before they
+## are concatenated.
+##
 ## For example:
 ##
 ## @example
 ## @group
+## strcat ("|", " leading space is preserved", "|")
+##     @result{} | leading space is perserved|
+## @end group
+## @end example
+##
+## @example
+## @group
+## strcat ("|", "trailing space is eliminated ", "|")
+##     @result{} |trailing space is eliminated|
+## @end group
+## @end example
+##
+## @example
+## @group
+## strcat ("homogeneous space |", "  ", "| is also eliminated")
+##     @result{} homogeneous space || is also eliminated
+## @end group
+## @end example
+##
+## @example
+## @group
 ## s = [ "ab"; "cde" ];
 ## strcat (s, s, s)
 ##     @result{}
@@ -96,32 +120,31 @@
 
 ## test the dimensionality
 ## 1d
-%!assert(strcat("ab ", "ab "), "abab")
-%!assert(strcat({"ab "}, "ab "), {"ab ab"})
-%!assert(strcat("ab ", {"ab "}), {"abab "})
-%!assert(strcat({"ab "}, {"ab "}), {"ab ab "})
-%!assert(strcat("", "ab"), "ab")
-%!assert(strcat("", {"ab"}, {""}), {"ab"})
+%!assert (strcat ("ab ", "ab "), "abab")
+%!assert (strcat ({"ab "}, "ab "), {"ab ab"})
+%!assert (strcat ("ab ", {"ab "}), {"abab "})
+%!assert (strcat ({"ab "}, {"ab "}), {"ab ab "})
+%!assert (strcat ("", "ab"), "ab")
+%!assert (strcat ("", {"ab"}, {""}), {"ab"})
 ## 2d
-%!assert(strcat(["ab ";"cde"], ["ab ";"cde"]), ["abab  ";"cdecde"])
+%!assert (strcat (["ab ";"cde"], ["ab ";"cde"]), ["abab  ";"cdecde"])
 
 ## test for deblanking implied trailing spaces of character input
-%!assert((strcmp (strcat ("foo", "bar"), "foobar")
-%!        && strcmp (strcat (["a"; "bb"], ["foo"; "bar"]), ["afoo "; "bbbar"])));
+%!assert (strcat ("foo", "bar"), "foobar")
+%!assert (strcat (["a"; "bb"], ["foo"; "bar"]), ["afoo "; "bbbar"])
 
 ## test for mixing character and cell inputs
-%!assert(all (strcmp (strcat ("a", {"bc", "de"}, "f"), {"abcf", "adef"})))
+%!assert (strcat ("a", {"bc", "de"}, "f"), {"abcf", "adef"})
 
 ## test for scalar strings with vector strings
-%!assert(all (strcmp (strcat (["a"; "b"], "c"), ["ac"; "bc"])))
+%!assert (strcat (["a"; "b"], "c"), ["ac"; "bc"])
 
 ## test with cells with strings of differing lengths
-%!assert(all (strcmp (strcat ({"a", "bb"}, "ccc"), {"accc", "bbccc"})))
-%!assert(all (strcmp (strcat ("a", {"bb", "ccc"}), {"abb", "accc"})))
-
-%!error strcat ();
+%!assert (all (strcmp (strcat ({"a", "bb"}, "ccc"), {"accc", "bbccc"})))
+%!assert (all (strcmp (strcat ("a", {"bb", "ccc"}), {"abb", "accc"})))
 
-%!assert (strcat (1, 2), strcat (char(1), char(2)))
+%!assert (strcat (1, 2), strcat (char (1), char (2)))
+%!assert (strcat ("", 2), strcat ([], char (2)))
 
-%!assert (strcat ('', 2), strcat ([], char(2)))
+%!error strcat ()
 
--- a/scripts/strings/strchr.m
+++ b/scripts/strings/strchr.m
@@ -53,7 +53,7 @@
     ## Index the str into a mask of valid values.
     ## This is slower than it could be because of the +1 issue.
     f = false (256, 1);
-    f(uint8(chars)+1) = true;
+    f(uint8 (chars) + 1) = true;
     ## Default goes via double -- unnecessarily long.
     si = uint32 (str);
     ## in-place is faster than str+1
--- a/scripts/strings/strjust.m
+++ b/scripts/strings/strjust.m
@@ -87,7 +87,7 @@
   endif
 
   ## Adjust the column indices.
-  jdx += shift(idx);
+  jdx += shift (idx);
 
   ## Create a blank matrix and position the nonblank characters.
   y = repmat (" ", nr, nc);
@@ -97,16 +97,16 @@
 
 
 %!assert (strjust (["a"; "ab"; "abc"; "abcd"]),
-%!        ["   a";"  ab"; " abc"; "abcd"]);
+%!        ["   a";"  ab"; " abc"; "abcd"])
 %!assert (strjust ([" a"; "  ab"; "abc"; "abcd"], "left"),
-%!        ["a   "; "ab  "; "abc "; "abcd"]);
+%!        ["a   "; "ab  "; "abc "; "abcd"])
 %!assert (strjust (["a"; "ab"; "abc"; "abcd"], "CENTER"),
-%!        [" a  "; " ab"; "abc "; "abcd"]);
-%!assert (strjust (["";""]), "");
+%!        [" a  "; " ab"; "abc "; "abcd"])
+%!assert (strjust (["";""]), "")
 
 %% Test input validation
 %!error <Invalid call to strjust> strjust ()
 %!error <Invalid call to strjust> strjust (["a";"ab"], "center", 1)
-%!error <S must be a string> strjust (ones(3,3))
-%!error <S must be a string> strjust (char (ones(3,3,3)))
+%!error <S must be a string> strjust (ones (3,3))
+%!error <S must be a string> strjust (char (ones (3,3,3)))
 
--- a/scripts/strings/strmatch.m
+++ b/scripts/strings/strmatch.m
@@ -26,7 +26,6 @@
 ## array of strings.  If the third argument @code{"exact"} is not given, then
 ## @var{s} only needs to match @var{A} up to the length of @var{s}.
 ## Trailing spaces and nulls in @var{s} and @var{A} are ignored when matching.
-## option.
 ##
 ## For example:
 ##
@@ -44,7 +43,8 @@
 ## @end example
 ##
 ## @strong{Caution:} @code{strmatch} is scheduled for deprecation.  Use
-## @code{strcmpi} or @code{strncmpi} in all new code.
+## @code{strncmp} (normal case), or @code{strcmp} ("exact" case), or
+## @code{regexp} in all new code.
 ## @seealso{strfind, findstr, strcmp, strncmp, strcmpi, strncmpi, find}
 ## @end deftypefn
 
@@ -97,23 +97,23 @@
 endfunction
 
 
-%!assert (strmatch("a", {"aaa", "bab", "bbb"}), 1);
-%!assert (strmatch ("apple", "apple juice"), 1);
-%!assert (strmatch ("apple", ["apple pie"; "apple juice"; "an apple"]), [1; 2]);
-%!assert (strmatch ("apple", {"apple pie"; "apple juice"; "tomato"}), [1; 2]);
-%!assert (strmatch ("apple pie", "apple"), []);
-%!assert (strmatch ("a ", "a"), 1);
-%!assert (strmatch ("a", "a \0", "exact"), 1);
-%!assert (strmatch ("a b", {"a b", "a c", "c d"}), 1);
-%!assert (strmatch ("", {"", "foo", "bar", ""}), [1, 4]);
-%!assert (strmatch ('', { '', '% comment', 'var a = 5', ''}, 'exact'), [1,4]);
+%!assert (strmatch ("a", {"aaa", "bab", "bbb"}), 1)
+%!assert (strmatch ("apple", "apple juice"), 1)
+%!assert (strmatch ("apple", ["apple pie"; "apple juice"; "an apple"]), [1; 2])
+%!assert (strmatch ("apple", {"apple pie"; "apple juice"; "tomato"}), [1; 2])
+%!assert (strmatch ("apple pie", "apple"), [])
+%!assert (strmatch ("a ", "a"), 1)
+%!assert (strmatch ("a", "a \0", "exact"), 1)
+%!assert (strmatch ("a b", {"a b", "a c", "c d"}), 1)
+%!assert (strmatch ("", {"", "foo", "bar", ""}), [1, 4])
+%!assert (strmatch ('', { '', '% comment', 'var a = 5', ''}, 'exact'), [1,4])
 
 %% Test input validation
-%!error <Invalid call to strmatch> strmatch();
-%!error <Invalid call to strmatch> strmatch("a");
-%!error <Invalid call to strmatch> strmatch("a", "aaa", "exact", 1);
-%!error <S must be a string> strmatch(1, "aaa");
-%!error <S must be a string> strmatch(char ("a", "bb"), "aaa");
-%!error <A must be a string> strmatch("a", 1);
-%!error <A must be a string> strmatch("a", {"hello", [1]});
+%!error <Invalid call to strmatch> strmatch ()
+%!error <Invalid call to strmatch> strmatch ("a")
+%!error <Invalid call to strmatch> strmatch ("a", "aaa", "exact", 1)
+%!error <S must be a string> strmatch (1, "aaa")
+%!error <S must be a string> strmatch (char ("a", "bb"), "aaa")
+%!error <A must be a string> strmatch ("a", 1)
+%!error <A must be a string> strmatch ("a", {"hello", [1]})
 
--- a/scripts/strings/strsplit.m
+++ b/scripts/strings/strsplit.m
@@ -114,5 +114,5 @@
 %!error strsplit ("abc", "b", true, 4)
 %!error <S and SEP must be string values> strsplit (123, "b")
 %!error <S and SEP must be string values> strsplit ("abc", 1)
-%!error <STRIP_EMPTY must be a scalar value> strsplit ("abc", "def", ones(3,3))
+%!error <STRIP_EMPTY must be a scalar value> strsplit ("abc", "def", ones (3,3))
 
--- a/scripts/strings/strtok.m
+++ b/scripts/strings/strtok.m
@@ -75,7 +75,7 @@
       ## Index the str into a mask of valid values.  Faster for large N.
       f = false (256, 1);
       ## This is slower than it could be because of the +1 issue.
-      f(uint8(delim)+1) = true;
+      f(uint8 (delim)+1) = true;
       ## Default goes via double -- unnecessarily long.
       si = uint32 (str);
       ## in-place is faster than str+1
@@ -133,7 +133,7 @@
 
 
 %!demo
-%! strtok("this is the life")
+%! strtok ("this is the life")
 %! % split at the first space, returning "this"
 
 %!demo
@@ -146,7 +146,7 @@
 %!   endif
 %!   printf ("<%s>", s(1));
 %! endwhile
-%! printf("\n");
+%! printf ("\n");
 %! % ----------------------------------------------------
 %! % Demonstrates processing of an entire string split on
 %! % a variety of delimiters.  Tokens and delimiters are
@@ -190,19 +190,19 @@
 %! assert (r{7}, "");
 
 %% Simple check for 2, 3, and 4 delimeters
-%!assert(strtok ("this is", "i "), "th");
-%!assert(strtok ("this is", "ij "), "th");
-%!assert(strtok ("this is", "ijk "), "th");
+%!assert (strtok ("this is", "i "), "th")
+%!assert (strtok ("this is", "ij "), "th")
+%!assert (strtok ("this is", "ijk "), "th")
 
 %% Test all cases for 8 delimiters since a different
 %!# algorithm is used when more than 7 delimiters
-%!assert (strtok ("","jklmnop "), "");
-%!assert (strtok ("this","jklmnop "), "this");
-%!assert (strtok ("this ","jklmnop "), "this");
-%!assert (strtok ("this is","jklmnop "), "this");
-%!assert (strtok (" this","jklmnop "), "this");
-%!assert (strtok (" this ","jklmnop "), "this");
-%!assert (strtok (" ","jklmnop "), ""(1:0));
+%!assert (strtok ("","jklmnop "), "")
+%!assert (strtok ("this","jklmnop "), "this")
+%!assert (strtok ("this ","jklmnop "), "this")
+%!assert (strtok ("this is","jklmnop "), "this")
+%!assert (strtok (" this","jklmnop "), "this")
+%!assert (strtok (" this ","jklmnop "), "this")
+%!assert (strtok (" ","jklmnop "), ""(1:0))
 
 %% Test 'bad' string orientations
 %!assert (strtok (" this ".'), "this".');   # delimiter at start and end
@@ -213,7 +213,7 @@
 %! for ch = "\t\n\v\f\r"
 %!   [t, r] = strtok (cstrcat ("beg", ch, "end"));
 %!   assert (t, "beg");
-%!   assert (r, cstrcat (ch, "end"))
+%!   assert (r, cstrcat (ch, "end"));
 %! endfor
 
 %% Test input validation
--- a/scripts/strings/strtrim.m
+++ b/scripts/strings/strtrim.m
@@ -74,15 +74,15 @@
 endfunction
 
 
-%!assert (strtrim ("    abc  "), "abc");
-%!assert (strtrim ("  "), "");
-%!assert (strtrim ("abc"), "abc");
-%!assert (strtrim ([" abc   "; "   def   "]), ["abc  "; "  def"]);
-%!assert (strtrim ({" abc   "; "   def   "}), {"abc"; "def"});
-%!assert (strtrim ({" abc   ", {"   def   "}}), {"abc", {"def"}});
+%!assert (strtrim ("    abc  "), "abc")
+%!assert (strtrim ("  "), "")
+%!assert (strtrim ("abc"), "abc")
+%!assert (strtrim ([" abc   "; "   def   "]), ["abc  "; "  def"])
+%!assert (strtrim ({" abc   "; "   def   "}), {"abc"; "def"})
+%!assert (strtrim ({" abc   ", {"   def   "}}), {"abc", {"def"}})
 
-%!error <Invalid call to strtrim> strtrim ();
-%!error <Invalid call to strtrim> strtrim ("abc", "def");
-%!error <argument must be a string> strtrim (1);
-%!error <argument must be a string> strtrim ({[]});
+%!error <Invalid call to strtrim> strtrim ()
+%!error <Invalid call to strtrim> strtrim ("abc", "def")
+%!error <argument must be a string> strtrim (1)
+%!error <argument must be a string> strtrim ({[]})
 
--- a/scripts/strings/strtrunc.m
+++ b/scripts/strings/strtrunc.m
@@ -55,12 +55,12 @@
 endfunction
 
 
-%!assert (strtrunc("abcdefg", 4), "abcd");
-%!assert (strtrunc("abcdefg", 10), "abcdefg");
-%!assert (strtrunc(char ("abcdef", "fedcba"), 3), ["abc"; "fed"]);
-%!assert (strtrunc({"abcdef", "fedcba"}, 3), {"abc", "fed"});
-%!assert (strtrunc({"", "1", "21", "321"}, 1), {"", "1", "2", "3"})
-%!assert (strtrunc({"1", "", "2"}, 1), {"1", "", "2"})
+%!assert (strtrunc ("abcdefg", 4), "abcd")
+%!assert (strtrunc ("abcdefg", 10), "abcdefg")
+%!assert (strtrunc (char ("abcdef", "fedcba"), 3), ["abc"; "fed"])
+%!assert (strtrunc ({"abcdef", "fedcba"}, 3), {"abc", "fed"})
+%!assert (strtrunc ({"", "1", "21", "321"}, 1), {"", "1", "2", "3"})
+%!assert (strtrunc ({"1", "", "2"}, 1), {"1", "", "2"})
 %!test
 %! cstr = {"line1"; ["line2"; "line3"]; "line4"};
 %! y = strtrunc (cstr, 4);
--- a/scripts/strings/substr.m
+++ b/scripts/strings/substr.m
@@ -92,19 +92,19 @@
 endfunction
 
 
-%!assert (substr ("This is a test string", 6, 9), "is a test");
-%!assert (substr ("This is a test string", -11), "test string");
-%!assert (substr ("This is a test string", -11, 4), "test");
-%!assert (substr ("This is a test string", -11, -7), "test");
-%!assert (substr ("This is a test string", 1, -7), "This is a test");
-%!assert (isempty (substr ("This is a test string", 1, 0)));
+%!assert (substr ("This is a test string", 6, 9), "is a test")
+%!assert (substr ("This is a test string", -11), "test string")
+%!assert (substr ("This is a test string", -11, 4), "test")
+%!assert (substr ("This is a test string", -11, -7), "test")
+%!assert (substr ("This is a test string", 1, -7), "This is a test")
+%!assert (isempty (substr ("This is a test string", 1, 0)))
 
 %% Test input validation
 %!error substr ()
 %!error substr ("foo", 2, 3, 4)
 %!error substr (ones (5, 1), 1, 1)
-%!error substr ("foo", ones(2,2))
-%!error substr ("foo", 1, ones(2,2))
+%!error substr ("foo", ones (2,2))
+%!error substr ("foo", 1, ones (2,2))
 %!error substr ("foo", 0)
 %!error substr ("foo", 5)
 %!error substr ("foo", 1, 5)
--- a/scripts/strings/untabify.m
+++ b/scripts/strings/untabify.m
@@ -82,10 +82,10 @@
     nr = rows (t);
     sc = cell (nr, 1);
     for j = 1:nr
-      n = 1:numel(t(j,:));
+      n = 1:numel (t(j,:));
       m = find (t(j,:) == "\t");
       t(j,m) = " ";
-      for i = 1:numel(m)
+      for i = 1:numel (m)
         k = tw * ceil (n(m(i)) / tw);
         dn = k - n(m(i));
         n(m(i):end) += dn;
--- a/scripts/strings/validatestring.m
+++ b/scripts/strings/validatestring.m
@@ -138,12 +138,13 @@
 
 
 %!shared strarray
-%!  strarray = {"octave" "Oct" "octopus" "octaves"};
+%! strarray = {"octave" "Oct" "octopus" "octaves"};
 %!assert (validatestring ("octave", strarray), "octave")
 %!assert (validatestring ("oct", strarray), "Oct")
 %!assert (validatestring ("octa", strarray), "octave")
-%!  strarray = {"abc1" "def" "abc2"};
+%! strarray = {"abc1" "def" "abc2"};
 %!assert (validatestring ("d", strarray), "def")
+
 %!error <'xyz' does not match any> validatestring ("xyz", strarray)
 %!error <Function: DUMMY_TEST> validatestring ("xyz", strarray, "DUMMY_TEST")
 %!error <Function: DUMMY_TEST Variable: DUMMY_VAR:> validatestring ("xyz", strarray, "DUMMY_TEST", "DUMMY_VAR")
--- a/scripts/testfun/assert.m
+++ b/scripts/testfun/assert.m
@@ -43,10 +43,10 @@
 ## Produce an error if observed is not the same as expected but equality
 ## comparison for numeric data uses a tolerance @var{tol}.
 ## If @var{tol} is positive then it is an absolute tolerance which will produce
-## an error if @code{abs(@var{observed} - @var{expected}) > abs(@var{tol})}.
+## an error if @code{abs (@var{observed} - @var{expected}) > abs (@var{tol})}.
 ## If @var{tol} is negative then it is a relative tolerance which will produce
-## an error if @code{abs(@var{observed} - @var{expected}) >
-## abs(@var{tol} * @var{expected})}.  If @var{expected} is zero @var{tol} will
+## an error if @code{abs (@var{observed} - @var{expected}) >
+## abs (@var{tol} * @var{expected})}.  If @var{expected} is zero @var{tol} will
 ## always be interpreted as an absolute tolerance.
 ## @end table
 ## @seealso{test, fail, error}
@@ -249,9 +249,9 @@
 %!assert (isempty ([]))
 %!assert (1)
 %!error assert (0)
-%!assert (ones(3,1))
-%!assert (ones(1,3))
-%!assert (ones(3,4))
+%!assert (ones (3,1))
+%!assert (ones (1,3))
+%!assert (ones (3,4))
 %!error assert ([1,0,1])
 %!error assert ([1;1;0])
 %!error assert ([1,0;1,1])
--- a/scripts/testfun/demo.m
+++ b/scripts/testfun/demo.m
@@ -19,8 +19,8 @@
 ## -*- texinfo -*-
 ## @deftypefn  {Command} {} demo @var{name}
 ## @deftypefnx {Command} {} demo @var{name} @var{n}
-## @deftypefnx {Function File} {} demo ('@var{name}')
-## @deftypefnx {Function File} {} demo ('@var{name}', @var{n})
+## @deftypefnx {Function File} {} demo ("@var{name}")
+## @deftypefnx {Function File} {} demo ("@var{name}", @var{n})
 ##
 ## Run example code block @var{n} associated with the function @var{name}.
 ## If @var{n} is not specified, all examples are run.
@@ -35,8 +35,9 @@
 ## @example
 ## @group
 ## %!demo
-## %! t=0:0.01:2*pi; x = sin (t);
-## %! plot (t,x)
+## %! t = 0:0.01:2*pi;
+## %! x = sin (t);
+## %! plot (t, x);
 ## %! %-------------------------------------------------
 ## %! % the figure window shows one cycle of a sine wave
 ## @end group
@@ -64,7 +65,7 @@
 ## Also, because demo evaluates within a function context, you cannot
 ## define new functions inside a demo.  If you must have function blocks,
 ## rather than just anonymous functions or inline functions, you will have to
-## use @code{eval(example('function',n))} to see them.  Because eval only
+## use @code{eval (example ("function",n))} to see them.  Because eval only
 ## evaluates one line, or one statement if the statement crosses
 ## multiple lines, you must wrap your demo in "if 1 <demo stuff> endif"
 ## with the 'if' on the same line as 'demo'.  For example:
@@ -111,7 +112,7 @@
   if (n > 0)
     doidx = n;
   else
-    doidx = 1:length(idx)-1;
+    doidx = 1:(length (idx) - 1);
   endif
   for i = 1:length (doidx)
     ## Pause between demos
@@ -127,7 +128,7 @@
       embed_func = regexp (block, '^\s*function ', 'once', 'lineanchors');
       if (isempty (embed_func))
         ## Use an environment without variables
-        eval (cstrcat ("function __demo__()\n", block, "\nendfunction"));
+        eval (cstrcat ("function __demo__ ()\n", block, "\nendfunction"));
         ## Display the code that will be executed before executing it
         printf ("%s example %d:%s\n\n", name, doidx(i), block);
         __demo__;
@@ -144,11 +145,14 @@
 
 endfunction
 
+
 %!demo
-%! t=0:0.01:2*pi; x = sin(t);
-%! plot (t,x)
+%! t = 0:0.01:2*pi;
+%! x = sin (t);
+%! plot (t, x);
 %! %-------------------------------------------------
 %! % the figure window shows one cycle of a sine wave
 
-%!error demo ();
-%!error demo (1, 2, 3);
+%!error demo ()
+%!error demo (1, 2, 3)
+
--- a/scripts/testfun/example.m
+++ b/scripts/testfun/example.m
@@ -19,12 +19,12 @@
 ## -*- texinfo -*-
 ## @deftypefn  {Command} {} example @var{name}
 ## @deftypefnx {Command} {} example @var{name} @var{n}
-## @deftypefnx {Function File} {} example ('@var{name}')
-## @deftypefnx {Function File} {} example ('@var{name}', @var{n})
+## @deftypefnx {Function File} {} example ("@var{name}")
+## @deftypefnx {Function File} {} example ("@var{name}", @var{n})
 ## @deftypefnx {Function File} {[@var{s}, @var{idx}] =} example (@dots{})
 ##
 ## Display the code for example @var{n} associated with the function
-## '@var{name}', but do not run it.  If @var{n} is not specified, all examples
+## "@var{name}", but do not run it.  If @var{n} is not specified, all examples
 ## are displayed.
 ##
 ## When called with output arguments, the examples are returned in the form of
@@ -65,13 +65,13 @@
     if (n > 0)
       doidx = n;
     else
-      doidx = 1:length(idx)-1;
+      doidx = 1:length (idx) - 1;
     endif
     if (isempty (idx))
       warning ("no example available for %s", name);
       return;
-    elseif (n >= length(idx))
-      warning ("only %d examples available for %s", length(idx)-1, name);
+    elseif (n >= length (idx))
+      warning ("only %d examples available for %s", length (idx) - 1, name);
       return;
     endif
 
@@ -84,21 +84,23 @@
 endfunction
 
 
-%!## warning: don't modify the demos without modifying the tests!
+## WARNING: don't modify the demos without modifying the tests!
 %!demo
-%! example ('example');
+%! example ("example");
+
 %!demo
-%! t=0:0.01:2*pi; x = sin(t);
+%! clf;
+%! t = 0:0.01:2*pi;  x = sin (t);
 %! plot (t,x)
 
-%!assert (example('example',1), "\n example ('example');");
+%!assert (example ("example",1), "\n example (\"example\");");
 %!test
-%! [code, idx] = example ('example');
+%! [code, idx] = example ("example");
 %! assert (code, ...
-%!         "\n example ('example');\n t=0:0.01:2*pi; x = sin(t);\n plot (t,x)")
-%! assert (idx, [1, 23, 63]);
+%!         "\n example (\"example\");\n clf;\n t = 0:0.01:2*pi;  x = sin (t);\n plot (t,x)")
+%! assert (idx, [1, 23, 73]);
 
 %% Test input validation
 %!error example
-%!error example ('example', 3, 5)
+%!error example ("example", 3, 5)
 
--- a/scripts/testfun/fail.m
+++ b/scripts/testfun/fail.m
@@ -22,7 +22,7 @@
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {} fail (@var{code})
 ## @deftypefnx {Function File} {} fail (@var{code}, @var{pattern})
-## @deftypefnx {Function File} {} fail (@var{code}, 'warning', @var{pattern})
+## @deftypefnx {Function File} {} fail (@var{code}, "warning", @var{pattern})
 ##
 ## Return true if @var{code} fails with an error message matching
 ## @var{pattern}, otherwise produce an error.  Note that @var{code}
@@ -44,7 +44,7 @@
 ## The angle brackets are not part of the output.
 ##
 ## Called with three arguments, the behavior is similar to
-## @code{fail(@var{code}, @var{pattern})}, but produces an error if no
+## @code{fail (@var{code}, @var{pattern})}, but produces an error if no
 ## warning is given during code execution or if the code fails.
 ## @seealso{assert}
 ## @end deftypefn
@@ -70,7 +70,7 @@
     pattern = ".";
   endif
 
-  ## allow assert(fail())
+  ## allow assert (fail ())
   if (nargout)
     ret = 1;
   endif
@@ -83,9 +83,9 @@
     state = warning ("query", "quiet");
     warning ("on", "quiet");
     try
-      ## printf("lastwarn before %s: %s\n",code,lastwarn);
+      ## printf ("lastwarn before %s: %s\n",code,lastwarn);
       evalin ("caller", sprintf ("%s;", code));
-      ## printf("lastwarn after %s: %s\n",code,lastwarn);
+      ## printf ("lastwarn after %s: %s\n",code,lastwarn);
       ## Retrieve new warnings.
       err = lastwarn ();
       warning (state.state, "quiet");
@@ -130,15 +130,16 @@
 endfunction
 
 
-%!fail ('[1,2]*[2,3]', 'nonconformant')
-%!fail ("fail('[1,2]*[2;3]', 'nonconformant')", "expected error <nonconformant> but got none")
-%!fail ("fail('[1,2]*[2,3]','usage:')", "expected error <usage:>\nbut got.*nonconformant")
-%!fail ("warning('test warning')", 'warning','test warning');
+%!fail ("[1,2]*[2,3]", "nonconformant")
+%!fail ("fail ('[1,2]*[2;3]', 'nonconformant')", "expected error <nonconformant> but got none")
+%!fail ("fail ('[1,2]*[2,3]', 'usage:')", "expected error <usage:>\nbut got.*nonconformant")
+%!fail ("warning ('test warning')", "warning", "test warning");
 
-##% !fail ("warning('next test')",'warning','next test');  ## only allowed one warning test?!?
+##% !fail ("warning ('next test')",'warning','next test');  ## only allowed one warning test?!?
 
 %% Test that fail() itself will generate an error
-%!error fail ("1");
-%!error <undefined> fail ('a*[2;3]', 'nonconformant')
-%!error <expected error>  fail ('a*[2,3]', 'usage:')
-%!error <warning failure> fail ("warning('warning failure')", 'warning', 'success')
+%!error fail ("1")
+%!error <undefined> fail ("a*[2;3]", "nonconformant")
+%!error <expected error>  fail ("a*[2,3]", "usage:")
+%!error <warning failure> fail ("warning ('warning failure')", "warning", "success")
+
--- a/scripts/testfun/rundemos.m
+++ b/scripts/testfun/rundemos.m
@@ -82,8 +82,11 @@
   else
     str = fscanf (fid, "%s");
     fclose (fid);
-    retval = findstr (str, "%!demo");
+    retval = strfind (str, "%!demo");
   endif
 endfunction
 
-%!error rundemos ("foo", 1);
+
+%!error rundemos ("foo", 1)
+%!error <DIRECTORY argument> rundemos ("#_TOTALLY_/_INVALID_/_PATHNAME_#")
+
--- a/scripts/testfun/speed.m
+++ b/scripts/testfun/speed.m
@@ -323,13 +323,13 @@
     endif
     v = polyval (p, log (__test_n(tailidx)));
 
-    loglog (__test_n(tailidx), exp(v)*1000, sprintf ("b;%s;", order));
+    loglog (__test_n(tailidx), exp (v) * 1000, sprintf ("b;%s;", order));
     title ({"Time Complexity", __f1});
     xlabel ("test length");
 
     ## Get base time to 1 digit of accuracy.
     dt = exp (p(2));
-    dt = floor (dt/10^floor(log10(dt)))*10^floor(log10(dt));
+    dt = floor (dt/10^floor (log10 (dt)))*10^floor (log10 (dt));
     if (log10 (dt) >= -0.5)
       time = sprintf ("%g s", dt);
     elseif (log10 (dt) >= -3.5)
@@ -356,62 +356,63 @@
 %%        Unfortunately, we can't remove them from the user's workspace
 %%        because of another bug (#34497).
 %!demo
-%!  fstr_build_orig = cstrcat (
-%!  "function x = build_orig (n)\n",
-%!  "  ## extend the target vector on the fly\n",
-%!  "  for i=0:n-1, x([1:100]+i*100) = 1:100; endfor\n",
-%!  "endfunction");
-%!  fstr_build = cstrcat (
-%!  "function x = build (n)\n",
-%!  "  ## preallocate the target vector\n",
-%!  "  x = zeros (1, n*100);\n",
-%!  "  for i=0:n-1, x([1:100]+i*100) = 1:100; endfor\n",
-%!  "endfunction");
+%! fstr_build_orig = cstrcat (
+%!   "function x = build_orig (n)\n",
+%!   "  ## extend the target vector on the fly\n",
+%!   "  for i=0:n-1, x([1:100]+i*100) = 1:100; endfor\n",
+%!   "endfunction");
+%! fstr_build = cstrcat (
+%!   "function x = build (n)\n",
+%!   "  ## preallocate the target vector\n",
+%!   "  x = zeros (1, n*100);\n",
+%!   "  for i=0:n-1, x([1:100]+i*100) = 1:100; endfor\n",
+%!   "endfunction");
 %!
-%!  disp ("-----------------------");
-%!  disp (fstr_build_orig);
-%!  disp ("-----------------------");
-%!  disp (fstr_build);
-%!  disp ("-----------------------");
+%! disp ("-----------------------");
+%! disp (fstr_build_orig);
+%! disp ("-----------------------");
+%! disp (fstr_build);
+%! disp ("-----------------------");
 %!
-%!  ## Eval functions strings to create them in the current context
-%!  eval (fstr_build_orig);
-%!  eval (fstr_build);
+%! ## Eval functions strings to create them in the current context
+%! eval (fstr_build_orig);
+%! eval (fstr_build);
 %!
-%!  disp ("Preallocated vector test.\nThis takes a little while...");
-%!  speed("build (n)", "", 1000, "build_orig (n)");
-%!  clear -f build build_orig
-%!  disp ("Note how much faster it is to pre-allocate a vector.");
-%!  disp ("Notice the peak speedup ratio.");
+%! disp ("Preallocated vector test.\nThis takes a little while...");
+%! speed ("build (n)", "", 1000, "build_orig (n)");
+%! clear -f build build_orig
+%! disp ("-----------------------");
+%! disp ("Note how much faster it is to pre-allocate a vector.");
+%! disp ("Notice the peak speedup ratio.");
 
 %!demo
-%!  fstr_build_orig = cstrcat (
-%!  "function x = build_orig (n)\n",
-%!  "  for i=0:n-1, x([1:100]+i*100) = 1:100; endfor\n",
-%!  "endfunction");
-%!  fstr_build = cstrcat (
-%!  "function x = build (n)\n",
-%!  "  idx = [1:100]';\n",
-%!  "  x = idx(:,ones(1,n));\n",
-%!  "  x = reshape (x, 1, n*100);\n",
-%!  "endfunction");
+%! fstr_build_orig = cstrcat (
+%!   "function x = build_orig (n)\n",
+%!   "  for i=0:n-1, x([1:100]+i*100) = 1:100; endfor\n",
+%!   "endfunction");
+%! fstr_build = cstrcat (
+%!   "function x = build (n)\n",
+%!   "  idx = [1:100]';\n",
+%!   "  x = idx(:,ones(1,n));\n",
+%!   "  x = reshape (x, 1, n*100);\n",
+%!   "endfunction");
 %!
-%!  disp ("-----------------------");
-%!  disp (fstr_build_orig);
-%!  disp ("-----------------------");
-%!  disp (fstr_build);
-%!  disp ("-----------------------");
+%! disp ("-----------------------");
+%! disp (fstr_build_orig);
+%! disp ("-----------------------");
+%! disp (fstr_build);
+%! disp ("-----------------------");
 %!
-%!  ## Eval functions strings to create them in the current context
-%!  eval (fstr_build_orig);
-%!  eval (fstr_build);
+%! ## Eval functions strings to create them in the current context
+%! eval (fstr_build_orig);
+%! eval (fstr_build);
 %!
-%!  disp ("Vectorized test.\nThis takes a little while...");
-%!  speed("build (n)", "", 1000, "build_orig (n)");
-%!  clear -f build build_orig
-%!  disp ("-----------------------");
-%!  disp ("This time, the for loop is done away with entirely.");
-%!  disp ("Notice how much bigger the speedup is than in example 1.");
+%! disp ("Vectorized test.\nThis takes a little while...");
+%! speed ("build (n)", "", 1000, "build_orig (n)");
+%! clear -f build build_orig
+%! disp ("-----------------------");
+%! disp ("This time, the for loop is done away with entirely.");
+%! disp ("Notice how much bigger the speedup is than in example 1.");
 
 %!test
 %! [order, n, T_f1, T_f2] = speed ("airy (x)", "x = rand (n, 10)", [100, 1000]);
@@ -425,7 +426,8 @@
 %! assert (isnumeric (T_f2));
 %! assert (length (T_f2) > 10);
 
-%% This test is known to fail on operating systems with low resolution timers such as MinGW
+%% This test is known to fail on operating systems with low resolution timers
+%% such as MinGW
 %!xtest
 %! [order, n, T_f1, T_f2] = speed ("sum (x)", "", [100, 1000], "v = 0; for i = 1:length (x), v += x(i); endfor");
 %! assert (isstruct (order));
@@ -439,6 +441,6 @@
 %! assert (length (T_f2) > 10);
 
 %% Test input validation
-%!error speed ();
-%!error speed (1, 2, 3, 4, 5, 6, 7);
+%!error speed ()
+%!error speed (1, 2, 3, 4, 5, 6, 7)
 
--- a/scripts/testfun/test.m
+++ b/scripts/testfun/test.m
@@ -19,11 +19,11 @@
 ## -*- texinfo -*-
 ## @deftypefn  {Command} {} test @var{name}
 ## @deftypefnx {Command} {} test @var{name} quiet|normal|verbose
-## @deftypefnx {Function File} {} test ('@var{name}', 'quiet|normal|verbose', @var{fid})
-## @deftypefnx {Function File} {} test ([], 'explain', @var{fid})
+## @deftypefnx {Function File} {} test ("@var{name}", "quiet|normal|verbose", @var{fid})
+## @deftypefnx {Function File} {} test ([], "explain", @var{fid})
 ## @deftypefnx {Function File} {@var{success} =} test (@dots{})
 ## @deftypefnx {Function File} {[@var{n}, @var{max}] =} test (@dots{})
-## @deftypefnx {Function File} {[@var{code}, @var{idx}] =} test ('@var{name}', 'grabdemo')
+## @deftypefnx {Function File} {[@var{code}, @var{idx}] =} test ("@var{name}", "grabdemo")
 ##
 ## Perform tests from the first file in the loadpath matching @var{name}.
 ## @code{test} can be called as a command or as a function.  Called with
@@ -34,14 +34,14 @@
 ## output is selected.
 ##
 ## @table @asis
-## @item 'quiet'
+## @item "quiet"
 ##  Don't report all the tests as they happen, just the errors.
 ##
-## @item 'normal'
+## @item "normal"
 ## Report all tests as they happen, but don't do tests which require
 ## user interaction.
 ##
-## @item 'verbose'
+## @item "verbose"
 ## Do tests which require user interaction.
 ## @end table
 ##
@@ -58,12 +58,12 @@
 ## @var{n} and @var{max}, the number of successful tests and the total number
 ## of tests in the file @var{name} are returned.
 ##
-## If the second argument is the string 'grabdemo', the contents of the demo
+## If the second argument is the string "grabdemo", the contents of the demo
 ## blocks are extracted but not executed.  Code for all code blocks is
 ## concatenated and returned as @var{code} with @var{idx} being a vector of
 ## positions of the ends of the demo blocks.
 ##
-## If the second argument is 'explain', then @var{name} is ignored and an
+## If the second argument is "explain", then @var{name} is ignored and an
 ## explanation of the line markers used is written to the file @var{fid}.
 ## @seealso{assert, fail, error, demo, example}
 ## @end deftypefn
@@ -145,7 +145,7 @@
     fprintf (__fid, "# success (in which case no error will be reported).\n");
     fflush (__fid);
     if (__close_fid)
-      fclose(__fid);
+      fclose (__fid);
     endif
     return;
   else
@@ -184,7 +184,7 @@
       endif
     endif
     if (__close_fid)
-      fclose(__fid);
+      fclose (__fid);
     endif
     return;
   endif
@@ -204,12 +204,12 @@
       endif
     endif
     if (__close_fid)
-      fclose(__fid);
+      fclose (__fid);
     endif
     return;
   else
     ## Add a dummy comment block to the end for ease of indexing.
-    if (__body (length(__body)) == "\n")
+    if (__body (length (__body)) == "\n")
       __body = sprintf ("\n%s#", __body);
     else
       __body = sprintf ("\n%s\n#", __body);
@@ -233,7 +233,7 @@
   __shared = " ";
   __shared_r = " ";
   __clear = "";
-  for __i = 1:length(__blockidx)-1
+  for __i = 1:length (__blockidx)-1
 
     ## Extract the block.
     __block = __body(__blockidx(__i):__blockidx(__i+1)-2);
@@ -251,7 +251,7 @@
       __code = "";
     else
       __type = __block(1:__idx(1)-1);
-      __code = __block(__idx(1):length(__block));
+      __code = __block(__idx(1):length (__block));
     endif
 
     ## Assume the block will succeed.
@@ -270,18 +270,18 @@
       __istest = 0;
 
       if (__grabdemo && __isdemo)
-        if (isempty(__demo_code))
+        if (isempty (__demo_code))
           __demo_code = __code;
           __demo_idx = [1, length(__demo_code)+1];
         else
-          __demo_code = cstrcat(__demo_code, __code);
+          __demo_code = cstrcat (__demo_code, __code);
           __demo_idx = [__demo_idx, length(__demo_code)+1];
         endif
 
       elseif (__rundemo && __isdemo)
         try
           ## process the code in an environment without variables
-          eval (sprintf ("function __test__()\n%s\nendfunction", __code));
+          eval (sprintf ("function __test__ ()\n%s\nendfunction", __code));
           __test__;
           input ("Press <enter> to continue: ", "s");
         catch
@@ -306,7 +306,7 @@
         __code = "";
       else
         __vars = __code (1:__idx(1)-1);
-        __code = __code (__idx(1):length(__code));
+        __code = __code (__idx(1):length (__code));
       endif
 
       ## Strip comments off the variables.
@@ -354,7 +354,7 @@
         __name = __block(__name_position(1):__name_position(2));
         __code = __block;
         try
-          eval(__code); ## Define the function
+          eval (__code); ## Define the function
           __clear = sprintf ("%sclear %s;\n", __clear, __name);
         catch
           __success = 0;
@@ -382,7 +382,7 @@
 
 ### ERROR/WARNING
 
-    elseif (strcmp (__type, "error") || strcmp(__type, "warning"))
+    elseif (strcmp (__type, "error") || strcmp (__type, "warning"))
       __istest = 1;
       __warning = strcmp (__type, "warning");
       [__pattern, __id, __code] = getpattern (__code);
@@ -547,7 +547,7 @@
           __ret1 = __ret2 = 0;
         endif
         if (__close_fid)
-          fclose(__fid);
+          fclose (__fid);
         endif
         return;
       endif
@@ -644,7 +644,7 @@
 ## Strip leading blanks from string.
 function str = trimleft (str)
   idx = find (isspace (str));
-  leading = find (idx == 1:length(idx));
+  leading = find (idx == 1:length (idx));
   if (! isempty (leading))
     str = str(leading(end)+1:end);
   endif
@@ -666,7 +666,7 @@
       ln = fgetl (fid);
       if (length (ln) >= 2 && strcmp (ln(1:2), "%!"))
         body = [body, "\n"];
-        if (length(ln) > 2)
+        if (length (ln) > 2)
           body = cstrcat (body, ln(3:end));
         endif
       endif
@@ -683,29 +683,29 @@
 ### Disable this test to avoid spurious skipped test for "make check"
 % !testif HAVE_FOOBAR
 % ! ## missing feature. Fail if this test is run
-% ! error("Failed missing feature test");
+% ! error ("Failed missing feature test");
 
 ### Test for a known failure
-%!xtest error("This test is known to fail")
+%!xtest error ("This test is known to fail")
 
 ### example from toeplitz
 %!shared msg1,msg2
 %! msg1="C must be a vector";
 %! msg2="C and R must be vectors";
-%!fail ('toeplitz([])', msg1);
-%!fail ('toeplitz([1,2;3,4])', msg1);
-%!fail ('toeplitz([1,2],[])', msg2);
-%!fail ('toeplitz([1,2],[1,2;3,4])', msg2);
+%!fail ('toeplitz ([])', msg1);
+%!fail ('toeplitz ([1,2;3,4])', msg1);
+%!fail ('toeplitz ([1,2],[])', msg2);
+%!fail ('toeplitz ([1,2],[1,2;3,4])', msg2);
 %!fail ('toeplitz ([1,2;3,4],[1,2])', msg2);
 % !fail ('toeplitz','usage: toeplitz'); # usage doesn't generate an error
-% !fail ('toeplitz(1, 2, 3)', 'usage: toeplitz');
+% !fail ('toeplitz (1, 2, 3)', 'usage: toeplitz');
 %!test  assert (toeplitz ([1,2,3], [1,4]), [1,4; 2,1; 3,2]);
 %!demo  toeplitz ([1,2,3,4],[1,5,6])
 
 ### example from kron
 %!#error kron  # FIXME suppress these until we can handle output
 %!#error kron(1,2,3)
-%!test assert (isempty (kron ([], rand(3, 4))))
+%!test assert (isempty (kron ([], rand (3, 4))))
 %!test assert (isempty (kron (rand (3, 4), [])))
 %!test assert (isempty (kron ([], [])))
 %!shared A, B
@@ -729,16 +729,16 @@
 ### an extended demo from specgram
 %!#demo
 %! ## Speech spectrogram
-%! [x, Fs] = auload(file_in_loadpath("sample.wav")); # audio file
-%! step = fix(5*Fs/1000);     # one spectral slice every 5 ms
-%! window = fix(40*Fs/1000);  # 40 ms data window
-%! fftn = 2^nextpow2(window); # next highest power of 2
-%! [S, f, t] = specgram(x, fftn, Fs, window, window-step);
-%! S = abs(S(2:fftn*4000/Fs,:)); # magnitude in range 0<f<=4000 Hz.
-%! S = S/max(max(S));         # normalize magnitude so that max is 0 dB.
-%! S = max(S, 10^(-40/10));   # clip below -40 dB.
-%! S = min(S, 10^(-3/10));    # clip above -3 dB.
-%! imagesc(flipud(20*log10(S)), 1);
+%! [x, Fs] = auload (file_in_loadpath ("sample.wav")); # audio file
+%! step = fix (5*Fs/1000);     # one spectral slice every 5 ms
+%! window = fix (40*Fs/1000);  # 40 ms data window
+%! fftn = 2^nextpow2 (window); # next highest power of 2
+%! [S, f, t] = specgram (x, fftn, Fs, window, window-step);
+%! S = abs (S (2:fftn*4000/Fs,:)); # magnitude in range 0<f<=4000 Hz.
+%! S = S/max(max(S));          # normalize magnitude so that max is 0 dB.
+%! S = max (S, 10^(-40/10));   # clip below -40 dB.
+%! S = min (S, 10^(-3/10));    # clip above -3 dB.
+%! imagesc (flipud (20*log10 (S)), 1);
 %! % you should now see a spectrogram in the image window
 
 
@@ -746,74 +746,74 @@
 
 %!## usage and error testing
 % !fail ('test','usage.*test')           # no args, generates usage()
-% !fail ('test(1,2,3,4)','usage.*test')  # too many args, generates usage()
-%!fail ('test("test", "bogus")','unknown flag')      # incorrect args
+% !fail ('test (1,2,3,4)','usage.*test') # too many args, generates usage()
+%!fail ('test ("test", "bogus")','unknown flag')  # incorrect args
 %!fail ('garbage','garbage.*undefined')  # usage on nonexistent function should be
 
 %!error test                     # no args, generates usage()
-%!error test(1,2,3,4)            # too many args, generates usage()
-%!error <unknown flag> test("test", 'bogus');  # incorrect args, generates error()
+%!error test (1,2,3,4)           # too many args, generates usage()
+%!error <unknown flag> test ("test", 'bogus'); # incorrect args, generates error()
 %!error <garbage' undefined> garbage           # usage on nonexistent function should be
 
-%!error test("test", 'bogus');           # test without pattern
+%!error test ("test", 'bogus');  # test without pattern
 
 %!test
 %! lastwarn();            # clear last warning just in case
 
-%!warning <warning message> warning('warning message');
+%!warning <warning message> warning ('warning message');
 
 %!## test of shared variables
 %!shared a                # create a shared variable
 %!test   a=3;             # assign to a shared variable
-%!test   assert(a,3)      # variable should equal 3
+%!test   assert (a,3)     # variable should equal 3
 %!shared b,c              # replace shared variables
-%!test assert (!exist("a"));   # a no longer exists
-%!test assert (isempty(b));    # variables start off empty
+%!test assert (!exist ("a"));  # a no longer exists
+%!test assert (isempty (b));   # variables start off empty
 %!shared a,b,c            # recreate a shared variable
-%!test assert (isempty(a));    # value is empty even if it had a previous value
+%!test assert (isempty (a));   # value is empty even if it had a previous value
 %!test a=1; b=2; c=3;   # give values to all variables
 %!test assert ([a,b,c],[1,2,3]); # test all of them together
 %!test c=6;             # update a value
-%!test assert([a, b, c],[1, 2, 6]); # show that the update sticks
-%!shared                    # clear all shared variables
-%!test assert(!exist("a"))  # show that they are cleared
-%!shared a,b,c              # support for initializer shorthand
+%!test assert ([a, b, c],[1, 2, 6]); # show that the update sticks
+%!shared                     # clear all shared variables
+%!test assert (!exist ("a")) # show that they are cleared
+%!shared a,b,c               # support for initializer shorthand
 %! a=1; b=2; c=4;
 
-%!function x = __test_a(y)
+%!function x = __test_a (y)
 %! x = 2*y;
 %!endfunction
-%!assert(__test_a(2),4);       # Test a test function
+%!assert (__test_a (2),4);       # Test a test function
 
 %!function __test_a (y)
 %! x = 2*y;
 %!endfunction
 %!test
-%! __test_a(2);                # Test a test function with no return value
+%! __test_a (2);                # Test a test function with no return value
 
 %!function [x,z] = __test_a (y)
 %! x = 2*y;
 %! z = 3*y;
 %!endfunction
 %!test                   # Test a test function with multiple returns
-%! [x,z] = __test_a(3);
-%! assert(x,6);
-%! assert(z,9);
+%! [x,z] = __test_a (3);
+%! assert (x,6);
+%! assert (z,9);
 
 %!## test of assert block
-%!assert (isempty([]))      # support for test assert shorthand
+%!assert (isempty ([]))      # support for test assert shorthand
 
 %!## demo blocks
 %!demo                   # multiline demo block
-%! t=[0:0.01:2*pi]; x=sin(t);
-%! plot(t,x);
+%! t = [0:0.01:2*pi]; x = sin (t);
+%! plot (t,x);
 %! % you should now see a sine wave in your figure window
 %!demo a=3               # single line demo blocks work too
 
 %!## this is a comment block. it can contain anything.
 %!##
 %! it is the "#" as the block type that makes it a comment
-%! and it  stays as a comment even through continuation lines
+%! and it stays as a comment even through continuation lines
 %! which means that it works well with commenting out whole tests
 
 % !# failure tests.  All the following should fail. These tests should
@@ -838,3 +838,4 @@
 % ! ## These don't signal an error, so the test for an error fails. Note
 % ! ## that the call doesn't reference the current fid (it is unavailable),
 % ! ## so of course the informational message is not printed in the log.
+
--- a/scripts/time/addtodate.m
+++ b/scripts/time/addtodate.m
@@ -77,7 +77,7 @@
 
 ## tests
 %!shared d
-%!  d = datenum (2008, 1, 1);
+%! d = datenum (2008, 1, 1);
 ## Identity
 %!assert (addtodate (d, 0, "year"), d)
 %!assert (addtodate (d, 0, "month"), d)
--- a/scripts/time/asctime.m
+++ b/scripts/time/asctime.m
@@ -47,8 +47,8 @@
 
 %!test
 %! t = time ();
-%! assert(strcmp (asctime (localtime (t)), ctime (t)));
+%! assert (strcmp (asctime (localtime (t)), ctime (t)));
 
-%!error asctime ();
-%!error asctime (1, 2);
+%!error asctime ()
+%!error asctime (1, 2)
 
--- a/scripts/time/calendar.m
+++ b/scripts/time/calendar.m
@@ -88,14 +88,14 @@
 endfunction
 
 
-## demos
 %!demo
 %! ## Calendar for current month
 %! calendar ()
+
 %!demo
+%! ## Calendar for October, 1957
 %! calendar (1957, 10)
 
-## tests
 %!assert ((calendar(2000,2))'(2:31), [0:29])
 %!assert ((calendar(1957,10))'(2:33), [0:31])
 
--- a/scripts/time/clock.m
+++ b/scripts/time/clock.m
@@ -57,5 +57,5 @@
 %!test
 %! t1 = clock;
 %! t2 = str2num (strftime ("[%Y, %m, %d, %H, %M, %S]", localtime (time ())));
-%! assert(etime (t1, t2) < 1);
+%! assert (etime (t1, t2) < 1);
 
--- a/scripts/time/ctime.m
+++ b/scripts/time/ctime.m
@@ -47,8 +47,8 @@
 
 %!test
 %! t = time ();
-%! assert(strcmp (asctime (localtime (t)), ctime (t)));
+%! assert (strcmp (asctime (localtime (t)), ctime (t)));
 
-%!error ctime ();
-%!error ctime (1, 2);
+%!error ctime ()
+%!error ctime (1, 2)
 
--- a/scripts/time/date.m
+++ b/scripts/time/date.m
@@ -39,5 +39,6 @@
 
 endfunction
 
-%!assert(strcmp (date (), strftime ("%d-%b-%Y", localtime (time ()))));
 
+%!assert (strcmp (date (), strftime ("%d-%b-%Y", localtime (time ()))))
+
--- a/scripts/time/datenum.m
+++ b/scripts/time/datenum.m
@@ -67,7 +67,7 @@
 ## @end itemize
 ##
 ## @strong{Caution:} this function does not attempt to handle Julian
-## calendars so dates before Octave 15, 1582 are wrong by as much
+## calendars so dates before October 15, 1582 are wrong by as much
 ## as eleven days.  Also, be aware that only Roman Catholic countries
 ## adopted the calendar in 1582.  It took until 1924 for it to be
 ## adopted everywhere.  See the Wikipedia entry on the Gregorian
@@ -85,6 +85,7 @@
 
   ## Days until start of month assuming year starts March 1.
   persistent monthstart = [306; 337; 0; 31; 61; 92; 122; 153; 184; 214; 245; 275];
+  persistent monthlength = [31; 28; 31; 30; 31; 30; 31; 31; 30; 31; 30; 31];
 
   if (nargin == 0 || nargin > 6 || 
      (nargin > 2 && (ischar (year) || iscellstr (year))))
@@ -108,7 +109,25 @@
     endif
   endif
 
-  month(month<1) = 1; ## For compatibility.  Otherwise allow negative months.
+  if (! (isa (year, "double") && isa (month, "double") && isa (day, "double") &&
+         isa (hour, "double") && isa (minute, "double") && isa (second, "double")))
+    error ("datenum: all inputs must be of class double");
+  endif
+
+  month(month<1) = 1;  # For compatibility.  Otherwise allow negative months.
+
+  ## Treat fractional months, by converting the fraction to days
+  if (floor (month) != month)
+    fracmonth = month - floor (month);
+    month = floor (month);
+    if ((mod (month-1,12) + 1) == 2 && 
+        (floor (year/4) - floor (year/100) + floor (year/400)) != 0)
+      ## leap year
+      day += fracmonth * 29;
+    else
+      day += fracmonth * monthlength ((mod (month-1,12) + 1));
+    endif
+  endif
 
   ## Set start of year to March by moving Jan. and Feb. to previous year.
   ## Correct for months > 12 by moving to subsequent years.
@@ -159,19 +178,19 @@
 %! assert (datenum (t(1,:), t(2,:), t(3,:), t(4,:), t(5,:), t(6,:)), n, 2*eps);
 
 ## Test mixed vectors and scalars
-%!assert (datenum([2008;2009], 1, 1), [datenum(2008, 1, 1);datenum(2009, 1, 1)]);
-%!assert (datenum(2008, [1;2], 1), [datenum(2008, 1, 1);datenum(2008, 2, 1)]);
-%!assert (datenum(2008, 1, [1;2]), [datenum(2008, 1, 1);datenum(2008, 1, 2)]);
-%!assert (datenum([2008;2009], [1;2], 1), [datenum(2008, 1, 1);datenum(2009, 2, 1)]);
-%!assert (datenum([2008;2009], 1, [1;2]), [datenum(2008, 1, 1);datenum(2009, 1, 2)]);
-%!assert (datenum(2008, [1;2], [1;2]), [datenum(2008, 1, 1);datenum(2008, 2, 2)]);
+%!assert (datenum ([2008;2009],1,1), [datenum(2008,1,1);datenum(2009,1,1)])
+%!assert (datenum (2008, [1;2], 1), [datenum(2008,1,1);datenum(2008,2,1)])
+%!assert (datenum (2008, 1, [1;2]), [datenum(2008,1,1);datenum(2008,1,2)])
+%!assert (datenum ([2008;2009], [1;2], 1), [datenum(2008,1,1);datenum(2009,2,1)])
+%!assert (datenum ([2008;2009], 1, [1;2]), [datenum(2008,1,1);datenum(2009,1,2)])
+%!assert (datenum (2008, [1;2], [1;2]), [datenum(2008,1,1);datenum(2008,2,2)])
 ## And the other orientation
-%!assert (datenum([2008 2009], 1, 1), [datenum(2008, 1, 1) datenum(2009, 1, 1)]);
-%!assert (datenum(2008, [1 2], 1), [datenum(2008, 1, 1) datenum(2008, 2, 1)]);
-%!assert (datenum(2008, 1, [1 2]), [datenum(2008, 1, 1) datenum(2008, 1, 2)]);
-%!assert (datenum([2008 2009], [1 2], 1), [datenum(2008, 1, 1) datenum(2009, 2, 1)]);
-%!assert (datenum([2008 2009], 1, [1 2]), [datenum(2008, 1, 1) datenum(2009, 1, 2)]);
-%!assert (datenum(2008, [1 2], [1 2]), [datenum(2008, 1, 1) datenum(2008, 2, 2)]);
+%!assert (datenum ([2008 2009], 1, 1), [datenum(2008,1,1) datenum(2009,1,1)])
+%!assert (datenum (2008, [1 2], 1), [datenum(2008,1,1) datenum(2008,2,1)])
+%!assert (datenum (2008, 1, [1 2]), [datenum(2008,1,1) datenum(2008,1,2)])
+%!assert (datenum ([2008 2009], [1 2], 1), [datenum(2008,1,1) datenum(2009,2,1)])
+%!assert (datenum ([2008 2009], 1, [1 2]), [datenum(2008,1,1) datenum(2009,1,2)])
+%!assert (datenum (2008, [1 2], [1 2]), [datenum(2008,1,1) datenum(2008,2,2)])
 ## Test string and cellstr inputs
 %!assert (datenum ("5/19/2001"), 730990)
 %!assert (datenum ({"5/19/2001"}), 730990)
@@ -181,5 +200,6 @@
 %% Test input validation
 %!error datenum ()
 %!error datenum (1,2,3,4,5,6,7)
-%!error datenum ([1, 2])
-%!error datenum ([1,2,3,4,5,6,7])
+%!error <expected date vector containing> datenum ([1, 2])
+%!error <expected date vector containing> datenum ([1,2,3,4,5,6,7])
+%!error <all inputs must be of class double> datenum (int32 (2000), int32 (1), int32 (1))
--- a/scripts/time/datestr.m
+++ b/scripts/time/datestr.m
@@ -56,19 +56,19 @@
 ## @item 16 @tab HH:MM PM               @tab 03:38 PM
 ## @item 17 @tab QQ-YY                  @tab Q3-00
 ## @item 18 @tab QQ                     @tab Q3
-## @item 19 @tab dd/mm                  @tab 13/03
-## @item 20 @tab dd/mm/yy               @tab 13/03/95
-## @item 21 @tab mmm.dd.yyyy HH:MM:SS   @tab Mar.03.1962 13:53:06
-## @item 22 @tab mmm.dd.yyyy            @tab Mar.03.1962
-## @item 23 @tab mm/dd/yyyy             @tab 03/13/1962
-## @item 24 @tab dd/mm/yyyy             @tab 12/03/1962
-## @item 25 @tab yy/mm/dd               @tab 95/03/13
-## @item 26 @tab yyyy/mm/dd             @tab 1995/03/13
-## @item 27 @tab QQ-YYYY                @tab Q4-2132
-## @item 28 @tab mmmyyyy                @tab Mar2047
-## @item 29 @tab yyyymmdd               @tab 20470313
-## @item 30 @tab yyyymmddTHHMMSS        @tab 20470313T132603
-## @item 31 @tab yyyy-mm-dd HH:MM:SS    @tab 1047-03-13 13:26:03
+## @item 19 @tab dd/mm                  @tab 07/09
+## @item 20 @tab dd/mm/yy               @tab 07/09/00
+## @item 21 @tab mmm.dd,yyyy HH:MM:SS   @tab Sep.07,2000 15:38:08
+## @item 22 @tab mmm.dd,yyyy            @tab Sep.07,2000
+## @item 23 @tab mm/dd/yyyy             @tab 09/07/2000
+## @item 24 @tab dd/mm/yyyy             @tab 07/09/2000
+## @item 25 @tab yy/mm/dd               @tab 00/09/07
+## @item 26 @tab yyyy/mm/dd             @tab 2000/09/07
+## @item 27 @tab QQ-YYYY                @tab Q3-2000
+## @item 28 @tab mmmyyyy                @tab Sep2000
+## @item 29 @tab yyyy-mm-dd             @tab 2000-09-07
+## @item 30 @tab yyyymmddTHHMMSS        @tab 20000907T153808
+## @item 31 @tab yyyy-mm-dd HH:MM:SS    @tab 2000-09-07 15:38:08
 ## @end multitable
 ##
 ## If @var{f} is a format string, the following symbols are recognized:
@@ -76,7 +76,7 @@
 ## @multitable @columnfractions 0.1 0.7 0.2
 ## @headitem Symbol @tab Meaning @tab Example
 ## @item yyyy @tab Full year                                    @tab 2005
-## @item yy   @tab Two-digit year                               @tab 2005
+## @item yy   @tab Two-digit year                               @tab 05
 ## @item mmmm @tab Full month name                              @tab December
 ## @item mmm  @tab Abbreviated month name                       @tab Dec
 ## @item mm   @tab Numeric month number (padded with zeros)     @tab 01, 08, 12
@@ -281,13 +281,14 @@
 endfunction
 
 
-## demos
 %!demo
 %! ## Current date and time in default format
 %! datestr (now ())
+
 %!demo
 %! ## Current date (integer portion of datenum)
 %! datestr (fix (now ()))
+
 %!demo
 %! ## Current time (fractional portion of datenum)
 %! datestr (rem (now (), 1))
@@ -335,3 +336,4 @@
 %% Test input validation
 %!error datestr ()
 %!error datestr (1, 2, 3, 4)
+
--- a/scripts/time/datetick.m
+++ b/scripts/time/datetick.m
@@ -46,7 +46,9 @@
 
 endfunction
 
+
 %!demo
+%! clf;
 %! yr = 1900:10:2000;
 %! pop = [76.094, 92.407, 106.461, 123.077 131.954, 151.868, 179.979, ...
 %!        203.984, 227.225, 249.623, 282.224];
@@ -56,16 +58,17 @@
 %! datetick ("x", "YYYY");
 
 %!demo
-%! yr =1988:2:2002;
-%! yr =datenum(yr,1,1);
+%! clf;
+%! yr = 1988:2:2002;
+%! yr = datenum (yr,1,1);
 %! pr = [12.1 13.3 12.6 13.1 13.3 14.1 14.4 15.2];
-%! plot(yr,pr);
-%! xlabel('year')
-%! ylabel('average price')
-%! ax=gca;
-%! set(ax,'xtick',datenum(1990:5:2005,1,1))
-%! datetick(2,'keepticks')
-%! set(ax,'ytick',12:16)
+%! plot (yr, pr);
+%! xlabel ("year");
+%! ylabel ("average price");
+%! ax = gca;
+%! set (ax, "xtick", datenum (1990:5:2005,1,1));
+%! datetick (2, "keepticks");
+%! set (ax, "ytick", 12:16);
 
 ## Remove from test statistics.  No real tests possible.
 %!assert (1)
@@ -132,7 +135,7 @@
   else
     ## Need to do our own axis tick position calculation as
     ## year, etc, don't fallback on nice datenum values.
-    objs = findall (gca());
+    objs = findall (gca ());
     xmax = NaN;
     xmin = NaN;
     for i = 1 : length (objs)
@@ -156,7 +159,7 @@
       ## Day scale or less
       if (xmax - xmin < N / 24 / 60 / 60)
         scl = 1 / 24 / 60 / 60;
-      elseif (xmax - xmin < N / 24 / 6)
+      elseif (xmax - xmin < N / 24 / 60)
         scl = 1 / 24 / 60;
       else
         scl = 1 / 24;
@@ -183,7 +186,7 @@
       elseif (maxyear - minyear < N)
         sep = __calc_tick_sep__ (minmonth , maxmonth);
         xmin = datenum (ymin, sep * floor (minmonth / sep), 1);
-        xmax = datenum (ymin, sep * ceil (maxmonth / sep), 1);
+        xmax = datenum (ymax, sep * ceil (maxmonth / sep), 1);
         nticks = ceil (maxmonth / sep) - floor (minmonth / sep) + 1;
       else
         sep = __calc_tick_sep__ (minyear , maxyear);
@@ -196,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
@@ -241,16 +244,16 @@
 
   if (keepticks)
     if (keeplimits)
-      set (gca(), strcat (ax, "ticklabel"), sticks);
+      set (gca (), strcat (ax, "ticklabel"), sticks);
     else
-      set (gca(), strcat (ax, "ticklabel"), sticks, strcat (ax, "lim"),
+      set (gca (), strcat (ax, "ticklabel"), sticks, strcat (ax, "lim"),
       [min(ticks), max(ticks)]);
     endif
   else
     if (keeplimits)
-      set (gca(), strcat (ax, "tick"), ticks, strcat (ax, "ticklabel"), sticks);
+      set (gca (), strcat (ax, "tick"), ticks, strcat (ax, "ticklabel"), sticks);
     else
-      set (gca(), strcat (ax, "tick"), ticks, strcat (ax, "ticklabel"), sticks,
+      set (gca (), strcat (ax, "tick"), ticks, strcat (ax, "ticklabel"), sticks,
       strcat (ax, "lim"), [min(ticks), max(ticks)]);
     endif
   endif
--- a/scripts/time/datevec.m
+++ b/scripts/time/datevec.m
@@ -29,7 +29,12 @@
 ## month, day, hour, minute, and seconds respectively.
 ##
 ## @var{f} is the format string used to interpret date strings
-## (see @code{datestr}).
+## (see @code{datestr}).  If @var{date} is a string, but no format is
+## specified, then a relatively slow search is performed through various
+## formats.  It is always preferable to specify the format string @var{f}
+## if it is known.  Formats which do not specify a particular time component
+## will have the value set to zero.  Formats which do not specify a date will
+## default to January 1st of the current year.
 ##
 ## @var{p} is the year at the start of the century to which two-digit years
 ## will be referenced.  If not specified, it defaults to the current year
@@ -53,7 +58,7 @@
   if (isempty (std_formats))
     std_formats = cell ();
     nfmt = 0;
-    ## These formats are specified by Matlab to be parsed
+    ## These formats are specified by Matlab documentation to be parsed
     ## The '# XX' refers to the datestr numerical format code
     std_formats{++nfmt} = "dd-mmm-yyyy HH:MM:SS";   # 0
     std_formats{++nfmt} = "dd-mmm-yyyy";            # 1
@@ -65,6 +70,14 @@
     std_formats{++nfmt} = "HH:MM PM";               # 16
     std_formats{++nfmt} = "mm/dd/yyyy";             # 23
 
+    ## These formats are undocumented but parsed by Matlab
+    std_formats{++nfmt} = "mmmyy";                  # 12
+    std_formats{++nfmt} = "mmm.dd,yyyy HH:MM:SS";   # 21
+    std_formats{++nfmt} = "mmm.dd,yyyy";            # 22
+    std_formats{++nfmt} = "yyyy/mm/dd";             # 26
+    std_formats{++nfmt} = "yyyy-mm-dd";             # 29
+    std_formats{++nfmt} = "yyyy-mm-dd HH:MM:SS";    # 31
+
     ## These are other formats that Octave tries
     std_formats{++nfmt} = "mmm-dd-yyyy HH:MM:SS";
     std_formats{++nfmt} = "mmm-dd-yyyy";
@@ -76,7 +89,6 @@
     std_formats{++nfmt} = "dd.mmm.yyyy";
     std_formats{++nfmt} = "mmm.dd.yyyy HH:MM:SS";
     std_formats{++nfmt} = "mmm.dd.yyyy";
-    std_formats{++nfmt} = "mmmyy";                  # 12
     std_formats{++nfmt} = "mm/dd/yyyy HH:MM";
   endif
 
@@ -254,9 +266,10 @@
     endif
     if (! fy && ! fm && ! fd)
       tmp = localtime (time ());
+      ## default is January 1st of current year
       y = tmp.year + 1900;
-      m = tmp.mon + 1;
-      d = tmp.mday;
+      m = 1;
+      d = 1;
     elseif (! fy && fm && fd)
       tmp = localtime (time ());
       y = tmp.year + 1900;
@@ -280,24 +293,24 @@
 %! ## Current date and time
 %! datevec (now ())
 
-%!shared nowvec
-%! nowvec = datevec (now); # Some tests could fail around midnight!
-%!# tests for standard formats: 0, 1, 2, 6, 13, 14, 15, 16, 23
+%!shared yr
+%! yr = datevec (now)(1);  # Some tests could fail around midnight!
+## tests for standard formats: 0, 1, 2, 6, 13, 14, 15, 16, 23
 %!assert (datevec ("07-Sep-2000 15:38:09"), [2000,9,7,15,38,9])
 %!assert (datevec ("07-Sep-2000"), [2000,9,7,0,0,0])
 %!assert (datevec ("09/07/00"), [2000,9,7,0,0,0])
-%!assert (datevec ("09/13"), [nowvec(1),9,13,0,0,0])
-%!assert (datevec ("15:38:09"), [nowvec(1:3),15,38,9])
-%!assert (datevec ("3:38:09 PM"), [nowvec(1:3),15,38,9])
-%!assert (datevec ("15:38"), [nowvec(1:3),15,38,0])
-%!assert (datevec ("03:38 PM"), [nowvec(1:3),15,38,0])
+%!assert (datevec ("09/13"), [yr,9,13,0,0,0])
+%!assert (datevec ("15:38:09"), [yr,1,1,15,38,9])
+%!assert (datevec ("3:38:09 PM"), [yr,1,1,15,38,9])
+%!assert (datevec ("15:38"), [yr,1,1,15,38,0])
+%!assert (datevec ("03:38 PM"), [yr,1,1,15,38,0])
 %!assert (datevec ("03/13/1962"), [1962,3,13,0,0,0])
 
 %% Test millisecond format FFF
-%!assert (datevec ("15:38:21.25", "HH:MM:SS.FFF"), [nowvec(1:3),15,38,21.025])
+%!assert (datevec ("15:38:21.25", "HH:MM:SS.FFF"), [yr,1,1,15,38,21.025])
 
 # Other tests
-%!assert (datenum (datevec ([-1e4:1e4])), [-1e4:1e4]')
+%!assert (datenum (datevec ([-1e4:1e4])), [-1e4:1e4]');
 %!test
 %! t = linspace (-2e5, 2e5, 10993);
 %! assert (all (abs (datenum (datevec (t)) - t') < 1e-5));
--- a/scripts/time/eomday.m
+++ b/scripts/time/eomday.m
@@ -54,7 +54,7 @@
 %!assert (eomday ([-800,800],2), [29,29])
 %!assert (eomday (2001,1:12), [31,28,31,30,31,30,31,31,30,31,30,31])
 %!assert (eomday (1:3,1:3), [31,28,31])
-%!assert (eomday (1:2000,2)', datevec(datenum(1:2000,3,0))(:,3))
+%!assert (eomday (1:2000,2)', datevec (datenum (1:2000,3,0))(:,3))
 %!assert ([1900:1999](find(eomday(1900:1999,2*ones(1,100))==29)), [1904,1908,1912,1916,1920,1924,1928,1932,1936,1940,1944,1948,1952,1956,1960,1964,1968,1972,1976,1980,1984,1988,1992,1996])
 %!assert (eomday ([2004;2005], [2;2]), [29;28])
 
--- a/scripts/time/etime.m
+++ b/scripts/time/etime.m
@@ -51,14 +51,14 @@
 endfunction
 
 
-%!assert (etime ([1900,12,31,23,59,59],[1901,1,1,0,0,0]),-1)
-%!assert (etime ([1900,2,28,23,59,59],[1900,3,1,0,0,0]),-1)
-%!assert (etime ([2000,2,28,23,59,59],[2000,3,1,0,0,0]),-86401)
-%!assert (etime ([1996,2,28,23,59,59],[1996,3,1,0,0,0]),-86401)
+%!assert (etime ([1900,12,31,23,59,59], [1901,1,1,0,0,0]), -1)
+%!assert (etime ([1900,2,28,23,59,59], [1900,3,1,0,0,0]), -1)
+%!assert (etime ([2000,2,28,23,59,59], [2000,3,1,0,0,0]), -86401)
+%!assert (etime ([1996,2,28,23,59,59], [1996,3,1,0,0,0]), -86401)
 %!test
 %! t1 = [1900,12,31,23,59,59; 1900,2,28,23,59,59];
 %! t2 = [1901,1,1,0,0,0; 1900,3,1,0,0,0];
-%! assert(etime(t2, t1), [1;1]);
+%! assert (etime (t2, t1), [1;1]);
 
 %!test
 %! t1 = [1993, 8, 20, 4, 56, 1];
--- a/scripts/time/is_leap_year.m
+++ b/scripts/time/is_leap_year.m
@@ -56,5 +56,5 @@
 %!assert (is_leap_year (1800), false)
 %!assert (is_leap_year (1600), true)
 
-%!error is_leap_year (1, 2);
+%!error is_leap_year (1, 2)
 
--- a/scripts/time/now.m
+++ b/scripts/time/now.m
@@ -47,15 +47,16 @@
   ##   divided by 86400 sec/day plus day num for 1970-1-1
   ##   t = (time - mktime(gmtime(0)))/86400 + 719529;
   ##
-  ## mktime(gmtime(0)) does indeed return the offset from Greenwich to the
+  ## mktime (gmtime (0)) does indeed return the offset from Greenwich to the
   ## local time zone, but we need to account for daylight savings time
   ## changing by an hour the offset from CUT for part of the year.
 
 endfunction
 
 
-%!assert (isnumeric (now ()));
-%!assert (now () > 0);
-%!assert (now () <= now ());
+%!assert (isnumeric (now ()))
+%!assert (now () > 0)
+%!assert (now () <= now ())
 
-%!error now (1);
+%!error now (1)
+
--- a/scripts/time/weekday.m
+++ b/scripts/time/weekday.m
@@ -84,12 +84,14 @@
 %!demo
 %! ## Current weekday
 %! [n, s] = weekday (now ())
+
 %!demo
 %! ## Weekday from datenum input
 %! [n, s] = weekday (728647)
+
 %!demo
 %! ## Weekday of new millennium from datestr input
-%! [n, s] = weekday ('1-Jan-2000')
+%! [n, s] = weekday ("1-Jan-2000")
 
 # tests
 %!assert (weekday (728647), 2)
--- a/src/Cell.cc
+++ b/src/Cell.cc
@@ -97,7 +97,7 @@
 // SV as possible.
 
 Cell::Cell (const dim_vector& dv, const string_vector& sv, bool trim)
-  : Array<octave_value> (dv, resize_fill_value ())
+  : Array<octave_value> (dv, Matrix ())
 {
   octave_idx_type n = sv.length ();
 
@@ -173,8 +173,7 @@
         idx_vector i = idx_arg(0).index_vector ();
 
         if (! error_state)
-          retval = Array<octave_value>::index (i, resize_ok,
-                                               resize_fill_value ());
+          retval = Array<octave_value>::index (i, resize_ok, Matrix ());
       }
       break;
 
@@ -187,8 +186,7 @@
             idx_vector j = idx_arg(1).index_vector ();
 
             if (! error_state)
-              retval = Array<octave_value>::index (i, j, resize_ok,
-                                                    resize_fill_value ());
+              retval = Array<octave_value>::index (i, j, resize_ok, Matrix ());
           }
       }
       break;
@@ -206,8 +204,7 @@
           }
 
         if (!error_state)
-          retval = Array<octave_value>::index (iv, resize_ok,
-                                                resize_fill_value ());
+          retval = Array<octave_value>::index (iv, resize_ok, Matrix ());
       }
       break;
     }
@@ -315,3 +312,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
+++ b/src/Cell.h
@@ -48,10 +48,10 @@
   Cell (const octave_value_list& ovl);
 
   Cell (octave_idx_type n, octave_idx_type m,
-        const octave_value& val = resize_fill_value ())
+        const octave_value& val = Matrix ())
     : Array<octave_value> (dim_vector (n, m), val) { }
 
-  Cell (const dim_vector& dv, const octave_value& val = resize_fill_value ())
+  Cell (const dim_vector& dv, const octave_value& val = Matrix ())
     : Array<octave_value> (dv, val) { }
 
   Cell (const Array<octave_value>& c)
@@ -86,7 +86,7 @@
   using Array<octave_value>::assign;
 
   void assign (const octave_value_list& idx, const Cell& rhs,
-               const octave_value& fill_val = resize_fill_value ());
+               const octave_value& fill_val = Matrix ());
 
   Cell reshape (const dim_vector& new_dims) const
     { return Array<octave_value>::reshape (new_dims); }
@@ -110,10 +110,16 @@
   bool any_element_is_nan (void) const { return false; }
   bool is_true (void) const { return false; }
 
-  static octave_value resize_fill_value (void) { return Matrix (); }
+  octave_value resize_fill_value (void) const
+  {
+    static Matrix rfv;
+    return rfv;
+  }
 
   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
+++ b/src/DLD-FUNCTIONS/__contourc__.cc
@@ -335,8 +335,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/__delaunayn__.cc
+++ b/src/DLD-FUNCTIONS/__delaunayn__.cc
@@ -124,7 +124,7 @@
       boolT ismalloc = false;
 
       // Qhull flags argument is not const char*
-      OCTAVE_LOCAL_BUFFER (char, flags, 9 + options.length());
+      OCTAVE_LOCAL_BUFFER (char, flags, 9 + options.length ());
 
       sprintf (flags, "qhull d %s", options.c_str ());
 
@@ -224,8 +224,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/__dispatch__.cc
+++ b/src/DLD-FUNCTIONS/__dispatch__.cc
@@ -131,8 +131,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/__dsearchn__.cc
+++ b/src/DLD-FUNCTIONS/__dsearchn__.cc
@@ -40,7 +40,7 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  int nargin = args.length();
+  int nargin = args.length ();
   octave_value_list retval;
 
   if (nargin != 2)
@@ -49,18 +49,18 @@
       return retval;
     }
 
-  Matrix x = args(0).matrix_value().transpose ();
-  Matrix xi = args(1).matrix_value().transpose ();
+  Matrix x = args(0).matrix_value ().transpose ();
+  Matrix xi = args(1).matrix_value ().transpose ();
 
   if (! error_state)
     {
-      if (x.rows() != xi.rows() || x.columns() < 1)
+      if (x.rows () != xi.rows () || x.columns () < 1)
         error ("__dsearch__: number of rows of X and XI must match");
       else
         {
-          octave_idx_type n = x.rows();
-          octave_idx_type nx = x.columns();
-          octave_idx_type nxi = xi.columns();
+          octave_idx_type n = x.rows ();
+          octave_idx_type nx = x.columns ();
+          octave_idx_type nxi = xi.columns ();
 
           ColumnVector idx (nxi);
           double *pidx = idx.fortran_vec ();
@@ -110,8 +110,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/__fltk_uigetfile__.cc
+++ b/src/DLD-FUNCTIONS/__fltk_uigetfile__.cc
@@ -58,15 +58,15 @@
 
   octave_value_list retval (3, octave_value (0));
 
-  std::string file_filter = args(0).string_value();
-  std::string title = args(1).string_value();
-  std::string default_name = args(2).string_value();
-  Matrix pos = args(3).matrix_value();
+  std::string file_filter = args(0).string_value ();
+  std::string title = args(1).string_value ();
+  std::string default_name = args(2).string_value ();
+  Matrix pos = args(3).matrix_value ();
 
   int multi_type = Fl_File_Chooser::SINGLE;
   std::string flabel = "Filename:";
 
-  std::string multi = args(4).string_value();
+  std::string multi = args(4).string_value ();
   if (multi == "on")
     multi_type = Fl_File_Chooser::MULTI;
   else if (multi == "dir")
@@ -92,7 +92,7 @@
   while (fc.shown ())
     Fl::wait ();
 
-  if (fc.value())
+  if (fc.value ())
     {
       int file_count = fc.count ();
       std::string fname;
@@ -109,7 +109,7 @@
         }
       else
         {
-          Cell file_cell = Cell(file_count, 1);
+          Cell file_cell = Cell (file_count, 1);
           for (octave_idx_type n = 1; n <= file_count; n++)
             {
               fname = fc.value (n);
@@ -135,10 +135,8 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
 
 #endif
--- a/src/DLD-FUNCTIONS/__glpk__.cc
+++ b/src/DLD-FUNCTIONS/__glpk__.cc
@@ -168,7 +168,7 @@
   int typx = 0;
   int method;
 
-  clock_t t_start = clock();
+  clock_t t_start = clock ();
 
 #if 0
 #ifdef GLPK_PRE_4_14
@@ -282,7 +282,7 @@
     }
 
   //-- scale the problem data (if required)
-  //-- if (scale && (!presol || method == 1)) lpx_scale_prob(lp);
+  //-- if (scale && (!presol || method == 1)) lpx_scale_prob (lp);
   //-- LPX_K_SCALE=IParam[1]  LPX_K_PRESOL=IParam[16]
   if (lpxIntParam[1] && (! lpxIntParam[16] || lpsolver != 1))
     lpx_scale_prob (lp);
@@ -291,7 +291,7 @@
   if (lpsolver == 1 && ! lpxIntParam[16])
     lpx_adv_basis (lp);
 
-  for(int i = 0; i < NIntP; i++)
+  for (int i = 0; i < NIntP; i++)
     lpx_set_int_parm (lp, IParam[i], lpxIntParam[i]);
 
   for (int i = 0; i < NRealP; i++)
@@ -313,12 +313,12 @@
             errnum = lpx_integer (lp);
           }
         else
-          errnum = lpx_simplex(lp);
+          errnum = lpx_simplex (lp);
       }
      break;
 
     case 'T':
-      errnum = lpx_interior(lp);
+      errnum = lpx_interior (lp);
       break;
 
     default:
@@ -488,7 +488,7 @@
 
   //-- 1nd Input. A column array containing the objective function
   //--            coefficients.
-  volatile int mrowsc = args(0).rows();
+  volatile int mrowsc = args(0).rows ();
 
   Matrix C (args(0).matrix_value ());
 
@@ -531,10 +531,10 @@
         }
 
       for (octave_idx_type j = 0; j < Anc; j++)
-        for (octave_idx_type i = A.cidx(j); i < A.cidx(j+1); i++)
+        for (octave_idx_type i = A.cidx (j); i < A.cidx (j+1); i++)
           {
             nz++;
-            rn(nz) = A.ridx(i) + 1;
+            rn(nz) = A.ridx (i) + 1;
             cn(nz) = j + 1;
             a(nz) = A.data(i);
           }
@@ -856,8 +856,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/__init_fltk__.cc
+++ b/src/DLD-FUNCTIONS/__init_fltk__.cc
@@ -179,7 +179,7 @@
     if (print_mode)
       {
         FILE *fp = octave_popen (print_cmd.c_str (), "w");
-        glps_renderer rend (fileno (fp), print_term);
+        glps_renderer rend (fp, print_term);
 
         rend.draw (gh_manager::get_object (number));
 
@@ -257,7 +257,7 @@
 // Parameter controlling the GUI mode.
 static enum { pan_zoom, rotate_zoom, none } gui_mode;
 
-void script_cb(Fl_Widget*, void* data)
+void script_cb (Fl_Widget*, void* data)
   {
     static_cast<uimenu::properties*> (data)->execute_callback ();
   }
@@ -269,7 +269,7 @@
   fltk_uimenu (int xx, int yy, int ww, int hh)
     {
       menubar = new
-        Fl_Menu_Bar(xx, yy, ww, hh);
+        Fl_Menu_Bar (xx, yy, ww, hh);
     }
 
   int items_to_show (void)
@@ -668,6 +668,14 @@
     callback (window_close, static_cast<void*> (this));
     size_range (4*status_h, 2*status_h);
 
+    // FIXME: The function below is only available in FLTK >= 1.3
+    // At some point support for FLTK 1.1 will be dropped in Octave.
+    // At that point this function should be uncommented.
+    // The current solution is to call xclass() before show() for each window.
+    // Set WM_CLASS which allows window managers to properly group related
+    // windows.  Otherwise, the class is just "FLTK"
+    //default_xclass ("Octave");
+
     begin ();
     {
 
@@ -677,7 +685,7 @@
       uimenu->hide ();
 
       bottom = new Fl_Box (0, hh - status_h, ww, status_h);
-      bottom->box(FL_FLAT_BOX);
+      bottom->box (FL_FLAT_BOX);
 
       ndim = calc_dimensions (gh_manager::get_object (fp.get___myhandle__ ()));
 
@@ -722,8 +730,15 @@
       canvas->mode (FL_DEPTH | FL_DOUBLE );
       if (fp.is_visible ())
         {
+          // FIXME: This code should be removed when Octave drops support
+          // for FLTK 1.1.  Search for default_xclass in this file to find
+          // code that should be uncommented to take its place.
+          //
+          // Set WM_CLASS which allows window managers to properly group
+          // related windows.  Otherwise, the class is just "FLTK"
+          xclass ("Octave");
           show ();
-          if (fp.get_currentaxes ().ok())
+          if (fp.get_currentaxes ().ok ())
             show_canvas ();
           else
             hide_canvas ();
@@ -865,7 +880,7 @@
         else
           hide_menubar ();
 
-        mark_modified();
+        mark_modified ();
       }
   }
 
@@ -1168,12 +1183,12 @@
     pos(2) = ww;
     pos(3) = hh - status_h - menu_h;
 
-    fp.set_position (pos);
+    fp.set_boundingbox (pos, true);
   }
 
   void draw (void)
   {
-    Matrix pos = fp.get_position ().matrix_value ();
+    Matrix pos = fp.get_boundingbox (true);
     Fl_Window::resize (pos(0), pos(1), pos(2), pos(3) + status_h + menu_h);
 
     return Fl_Window::draw ();
@@ -1296,12 +1311,12 @@
                       dynamic_cast<axes::properties&> (ax_obj.get_properties ());
 
                     double x0, y0, x1, y1;
-                    Matrix pos = fp.get_position ().matrix_value ();
+                    Matrix pos = fp.get_boundingbox (true);
                     pixel2pos (ax_obj, pos_x, pos_y, x0, y0);
                     pixel2pos (ax_obj, Fl::event_x (), Fl::event_y (), x1, y1);
 
                     if (gui_mode == pan_zoom)
-                      ap.translate_view (x0 - x1, y0 - y1);
+                      ap.translate_view (x0, x1, y0, y1);
                     else if (gui_mode == rotate_zoom)
                       {
                         double daz, del;
@@ -1390,31 +1405,38 @@
                         axes::properties& ap =
                           dynamic_cast<axes::properties&> (ax_obj.get_properties ());
                         pixel2pos (ax_obj, pos_x, pos_y, x0, y0);
-                        pixel2pos (ax_obj, Fl::event_x (), Fl::event_y (),
-                                   x1, y1);
+                        int pos_x1 = Fl::event_x ();
+                        int pos_y1 = Fl::event_y ();
+                        pixel2pos (ax_obj, pos_x1, pos_y1, x1, y1);
                         Matrix xl (1,2,0);
                         Matrix yl (1,2,0);
-                        if (x0 < x1)
+                        int dx = abs (pos_x - pos_x1);
+                        int dy = abs (pos_y - pos_y1);
+                        // Smallest zoom box must be 4 pixels square
+                        if ((dx > 4) && (dy > 4))
                           {
-                            xl(0) = x0;
-                            xl(1) = x1;
-                          }
-                        else
-                          {
-                            xl(0) = x1;
-                            xl(1) = x0;
+                            if (x0 < x1)
+                              {
+                                xl(0) = x0;
+                                xl(1) = x1;
+                              }
+                            else
+                              {
+                                xl(0) = x1;
+                                xl(1) = x0;
+                              }
+                            if (y0 < y1)
+                              {
+                                yl(0) = y0;
+                                yl(1) = y1;
+                              }
+                            else
+                              {
+                                yl(0) = y1;
+                                yl(1) = y0;
+                              }
+                            ap.zoom (xl, yl);
                           }
-                        if (y0 < y1)
-                          {
-                            yl(0) = y0;
-                            yl(1) = y1;
-                          }
-                        else
-                          {
-                            yl(0) = y1;
-                            yl(1) = y0;
-                          }
-                        ap.zoom (xl, yl);
                         mark_modified ();
                       }
                   }
@@ -1902,8 +1924,8 @@
         if (id == uimenu::properties::ID_LABEL)
           uimenu_set_fltk_label (go);
 
-        graphics_object fig = go.get_ancestor("figure");
-        figure_manager::uimenu_update(fig.get_handle (), go.get_handle (), id);
+        graphics_object fig = go.get_ancestor ("figure");
+        figure_manager::uimenu_update (fig.get_handle (), go.get_handle (), id);
       }
   }
 
@@ -2036,7 +2058,7 @@
     }
 
   return retval;
-#else 
+#else
   error ("mouse_wheel_zoom: not available without OpenGL and FLTK libraries");
   return octave_value ();
 #endif
@@ -2048,6 +2070,7 @@
 @deftypefnx {Built-in Function} {} gui_mode (@var{mode})\n\
 Query or set the GUI mode for the current graphics toolkit.\n\
 The @var{mode} argument can be one of the following strings:\n\
+\n\
 @table @asis\n\
 @item '2d'\n\
 Allows panning and zooming of current axes.\n\
--- a/src/DLD-FUNCTIONS/__lin_interpn__.cc
+++ b/src/DLD-FUNCTIONS/__lin_interpn__.cc
@@ -195,7 +195,7 @@
   for (int i = 0; i < n; i++)
     {
       y[i] = Y[i].data ();
-      size[i] =  V.dims()(i);
+      size[i] =  V.dims ()(i);
     }
 
   OCTAVE_LOCAL_BUFFER (const T *, x, n);
@@ -286,7 +286,7 @@
   // dimension of the problem
   int n = (nargin-1)/2;
 
-  if (args(n).is_single_type())
+  if (args(n).is_single_type ())
     {
       OCTAVE_LOCAL_BUFFER (FloatNDArray, X, n);
       OCTAVE_LOCAL_BUFFER (FloatNDArray, Y, n);
@@ -357,8 +357,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/__magick_read__.cc
+++ b/src/DLD-FUNCTIONS/__magick_read__.cc
@@ -403,9 +403,9 @@
 
 DEFUN_DLD (__magick_read__, args, nargout,
   "-*- texinfo -*-\n\
-@deftypefn  {Function File} {@var{m} =} __magick_read__(@var{fname}, @var{index})\n\
-@deftypefnx {Function File} {[@var{m}, @var{colormap}] =} __magick_read__(@var{fname}, @var{index})\n\
-@deftypefnx {Function File} {[@var{m}, @var{colormap}, @var{alpha}] =} __magick_read__(@var{fname}, @var{index})\n\
+@deftypefn  {Function File} {@var{m} =} __magick_read__ (@var{fname}, @var{index})\n\
+@deftypefnx {Function File} {[@var{m}, @var{colormap}] =} __magick_read__ (@var{fname}, @var{index})\n\
+@deftypefnx {Function File} {[@var{m}, @var{colormap}, @var{alpha}] =} __magick_read__ (@var{fname}, @var{index})\n\
 Read images with ImageMagick++.  In general you should not be using this\n\
 function.  Instead use @code{imread}.\n\
 @seealso{imread}\n\
@@ -428,14 +428,14 @@
   bool all_frames = false;
 
   if (args.length () == 2 && args(1).is_real_type ())
-    frameidx = args(1).int_vector_value();
+    frameidx = args(1).int_vector_value ();
   else if (args.length () == 3 && args(1).is_string ()
-           && args(1).string_value() == "frames")
+           && args(1).string_value () == "frames")
     {
-      if (args(2).is_string () && args(2).string_value() == "all")
+      if (args(2).is_string () && args(2).string_value () == "all")
         all_frames = true;
       else if (args(2).is_real_type ())
-        frameidx = args(2).int_vector_value();
+        frameidx = args(2).int_vector_value ();
     }
   else
     {
@@ -533,10 +533,8 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
 
 #ifdef HAVE_MAGICK
@@ -606,7 +604,7 @@
 
   for (unsigned int ii = 0; ii < nframes; ii++)
     {
-      Magick::Image im(Magick::Geometry (columns, rows), "black");
+      Magick::Image im (Magick::Geometry (columns, rows), "black");
       im.classType (Magick::DirectClass);
       im.depth (1);
 
@@ -873,8 +871,8 @@
 
 DEFUN_DLD (__magick_write__, args, ,
   "-*- texinfo -*-\n\
-@deftypefn  {Function File} {} __magick_write__(@var{fname}, @var{fmt}, @var{img})\n\
-@deftypefnx {Function File} {} __magick_write__(@var{fname}, @var{fmt}, @var{img}, @var{map})\n\
+@deftypefn  {Function File} {} __magick_write__ (@var{fname}, @var{fmt}, @var{img})\n\
+@deftypefnx {Function File} {} __magick_write__ (@var{fname}, @var{fmt}, @var{img}, @var{map})\n\
 Write images with ImageMagick++.  In general you should not be using this\n\
 function.  Instead use @code{imwrite}.\n\
 @seealso{imread}\n\
@@ -903,7 +901,7 @@
                 if (args(3).is_real_type ())
                   write_image (filename, fmt, args(2), args(3));
                 else
-                  write_image (filename, fmt, args(2), octave_value(), args(3));
+                  write_image (filename, fmt, args(2), octave_value (), args(3));
               else
                 write_image (filename, fmt, args(2));
             }
@@ -925,10 +923,8 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
 
 #ifdef HAVE_MAGICK
@@ -1011,7 +1007,7 @@
 
 DEFUN_DLD (__magick_finfo__, args, ,
   "-*- texinfo -*-\n\
-@deftypefn {Loadable Function} {} __magick_finfo__(@var{fname})\n\
+@deftypefn {Loadable Function} {} __magick_finfo__ (@var{fname})\n\
 Read image information with GraphicsMagick++.  In general you should\n\
 not be using this function.  Instead use @code{imfinfo}.\n\
 @seealso{imfinfo, imread}\n\
@@ -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
+++ b/src/DLD-FUNCTIONS/__pchip_deriv__.cc
@@ -59,7 +59,7 @@
   octave_value retval;
   const int nargin = args.length ();
 
-  bool rows = (nargin == 3 && args (2).uint_value() == 2);
+  bool rows = (nargin == 3 && args (2).uint_value () == 2);
 
   if (nargin >= 2)
     {
@@ -163,8 +163,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/__qp__.cc
+++ b/src/DLD-FUNCTIONS/__qp__.cc
@@ -530,8 +530,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/__voronoi__.cc
+++ b/src/DLD-FUNCTIONS/__voronoi__.cc
@@ -329,8 +329,6 @@
 }
 
 /*
-
 ## No test needed for internal helper function.
 %!assert (1)
-
 */
--- a/src/DLD-FUNCTIONS/amd.cc
+++ b/src/DLD-FUNCTIONS/amd.cc
@@ -190,7 +190,7 @@
                     for (octave_idx_type i = 0; i < n_col; i++)
                       Pout.xelem (i) = P[i] + 1;
 
-                    retval (0) = Pout;
+                    retval(0) = Pout;
                   }
                 }
             }
--- a/src/DLD-FUNCTIONS/balance.cc
+++ b/src/DLD-FUNCTIONS/balance.cc
@@ -104,14 +104,14 @@
   // problem dimension
   octave_idx_type nn = args(0).rows ();
 
-  if (nn != args(0).columns())
+  if (nn != args(0).columns ())
     {
       gripe_square_matrix_required ("balance");
       return retval;
     }
 
   bool isfloat = args(0).is_single_type () ||
-    (! AEPcase && args(1).is_single_type());
+    (! AEPcase && args(1).is_single_type ());
 
   bool complex_case = (args(0).is_complex_type () ||
                        (! AEPcase && args(1).is_complex_type ()));
--- a/src/DLD-FUNCTIONS/besselj.cc
+++ b/src/DLD-FUNCTIONS/besselj.cc
@@ -388,21 +388,21 @@
 @table @code\n\
 @item besselj\n\
 Bessel functions of the first kind.  If the argument @var{opt} is supplied,\n\
-the result is multiplied by @code{exp(-abs(imag(@var{x})))}.\n\
+the result is multiplied by @code{exp (-abs (imag (@var{x})))}.\n\
 \n\
 @item bessely\n\
 Bessel functions of the second kind.  If the argument @var{opt} is supplied,\n\
-the result is multiplied by @code{exp(-abs(imag(@var{x})))}.\n\
+the result is multiplied by @code{exp (-abs (imag (@var{x})))}.\n\
 \n\
 @item besseli\n\
 \n\
 Modified Bessel functions of the first kind.  If the argument @var{opt} is\n\
-supplied, the result is multiplied by @code{exp(-abs(real(@var{x})))}.\n\
+supplied, the result is multiplied by @code{exp (-abs (real (@var{x})))}.\n\
 \n\
 @item besselk\n\
 \n\
 Modified Bessel functions of the second kind.  If the argument @var{opt} is\n\
-supplied, the result is multiplied by @code{exp(@var{x})}.\n\
+supplied, the result is multiplied by @code{exp (@var{x})}.\n\
 \n\
 @item besselh\n\
 Compute Hankel functions of the first (@var{k} = 1) or second (@var{k}\n\
@@ -533,8 +533,8 @@
 ---  --------   ---------------------------------------\n\
  0   Ai (Z)     exp ((2/3) * Z * sqrt (Z))\n\
  1   dAi(Z)/dZ  exp ((2/3) * Z * sqrt (Z))\n\
- 2   Bi (Z)     exp (-abs (real ((2/3) * Z *sqrt (Z))))\n\
- 3   dBi(Z)/dZ  exp (-abs (real ((2/3) * Z *sqrt (Z))))\n\
+ 2   Bi (Z)     exp (-abs (real ((2/3) * Z * sqrt (Z))))\n\
+ 3   dBi(Z)/dZ  exp (-abs (real ((2/3) * Z * sqrt (Z))))\n\
 @end group\n\
 @end example\n\
 \n\
@@ -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,69 +863,384 @@
 %! 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)
+
+
+Tests contributed by Robert T. Short.
+Tests are based on the properties and tables in A&S:
+ Abramowitz and Stegun, "Handbook of Mathematical Functions",
+ 1972.
+
+For regular Bessel functions, there are 3 tests. These compare octave
+results against Tables 9.1, 9.2, and 9.4 in A&S. Tables 9.1 and 9.2
+are good to only a few decimal places, so any failures should be
+considered a broken implementation. Table 9.4 is an extended table
+for larger orders and arguments. There are some differences between
+Octave and Table 9.4, mostly in the last decimal place but in a very
+few instances the errors are in the last two places. The comparison
+tolerance has been changed to reflect this.
+
+Similarly for modifed Bessel functions, there are 3 tests. These
+compare octave results against Tables 9.8, 9.9, and 9.11 in A&S.
+Tables 9.8 and 9.9 are good to only a few decimal places, so any
+failures should be considered a broken implementation. Table 9.11 is
+an extended table for larger orders and arguments. There are some
+differences between octave and Table 9.11, mostly in the last decimal
+place but in a very few instances the errors are in the last two
+places. The comparison tolerance has been changed to reflect this.
+
+For spherical Bessel functions, there are also three tests, comparing
+octave results to Tables 10.1, 10.2, and 10.4 in A&S. Very similar
+comments may be made here as in the previous lines. At this time,
+modified spherical Bessel function tests are not included.
+
+% Table 9.1 - J and Y for integer orders 0, 1, 2.
+% Compare against excerpts of Table 9.1, Abramowitz and Stegun.
+%!test
+%! n = 0:2;
+%! z = (0:2.5:17.5)';
+%!
+%! Jt = [[ 1.000000000000000,  0.0000000000,  0.0000000000];
+%!       [-0.048383776468198,  0.4970941025,  0.4460590584];
+%!       [-0.177596771314338, -0.3275791376,  0.0465651163];
+%!       [ 0.266339657880378,  0.1352484276, -0.2302734105];
+%!       [-0.245935764451348,  0.0434727462,  0.2546303137];
+%!       [ 0.146884054700421, -0.1654838046, -0.1733614634];
+%!       [-0.014224472826781,  0.2051040386,  0.0415716780];
+%!       [-0.103110398228686, -0.1634199694,  0.0844338303]];
+%!
+%! Yt = [[-Inf,          -Inf,          -Inf        ];
+%!       [ 0.4980703596,  0.1459181380, -0.38133585 ];
+%!       [-0.3085176252,  0.1478631434,  0.36766288 ];
+%!       [ 0.1173132861, -0.2591285105, -0.18641422 ];
+%!       [ 0.0556711673,  0.2490154242, -0.00586808 ];
+%!       [-0.1712143068, -0.1538382565,  0.14660019 ];
+%!       [ 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);
+
+Table 9.2 - J and Y for integer orders 3-9.
+
+%!test
+%! 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]];
+%!
+%! 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);
+%!
+%! 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.
+
+%!test
+%! Jt = [[ 7.651976866e-01,   2.238907791e-01,  -1.775967713e-01,  -2.459357645e-01,  5.581232767e-02,  1.998585030e-02];
+%!       [ 2.497577302e-04,   7.039629756e-03,   2.611405461e-01,  -2.340615282e-01, -8.140024770e-02, -7.419573696e-02];
+%!       [ 2.630615124e-10,   2.515386283e-07,   1.467802647e-03,   2.074861066e-01, -1.138478491e-01, -5.473217694e-02];
+%!       [ 2.297531532e-17,   7.183016356e-13,   4.796743278e-07,   4.507973144e-03, -1.082255990e-01,  1.519812122e-02];
+%!       [ 3.873503009e-25,   3.918972805e-19,   2.770330052e-11,   1.151336925e-05, -1.167043528e-01,  6.221745850e-02];
+%!       [ 3.482869794e-42,   3.650256266e-33,   2.671177278e-21,   1.551096078e-12,  4.843425725e-02,  8.146012958e-02];
+%!       [ 1.107915851e-60,   1.196077458e-48,   8.702241617e-33,   6.030895312e-21, -1.381762812e-01,  7.270175482e-02];
+%!       [ 2.906004948e-80,   3.224095839e-65,   2.294247616e-45,   1.784513608e-30,  1.214090219e-01, -3.869833973e-02];
+%!       [ 8.431828790e-189,  1.060953112e-158,  6.267789396e-119,  6.597316064e-89,  1.115927368e-21,  9.636667330e-02]];
+%!
+%! Yt = [[ 8.825696420e-02,   5.103756726e-01,  -3.085176252e-01,   5.567116730e-02, -9.806499547e-02, -7.724431337e-02]
+%!       [-2.604058666e+02,  -9.935989128e+00,  -4.536948225e-01,   1.354030477e-01, -7.854841391e-02, -2.948019628e-02]
+%!       [-1.216180143e+08,  -1.291845422e+05,  -2.512911010e+01,  -3.598141522e-01,  5.723897182e-03,  5.833157424e-02]
+%!       [-9.256973276e+14,  -2.981023646e+10,  -4.694049564e+04,  -6.364745877e+00,  4.041280205e-02,  7.879068695e-02]
+%!       [-4.113970315e+22,  -4.081651389e+16,  -5.933965297e+08,  -1.597483848e+03,  1.644263395e-02,  5.124797308e-02]
+%!       [-3.048128783e+39,  -2.913223848e+30,  -4.028568418e+18,  -7.256142316e+09, -1.164572349e-01,  6.138839212e-03]
+%!       [-7.184874797e+57,  -6.661541235e+45,  -9.216816571e+29,  -1.362803297e+18, -4.530801120e-02,  4.074685217e-02]
+%!       [-2.191142813e+77,  -1.976150576e+62,  -2.788837017e+42,  -3.641066502e+27, -2.103165546e-01,  7.650526394e-02]
+%!       [-3.775287810e+185, -3.000826049e+155, -5.084863915e+115, -4.849148271e+85, -3.293800188e+18, -1.669214114e-01]];
+%!
+%! 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);
+
+Table 9.8 - I and K for integer orders 0, 1, 2.
+
+%!test
+%! 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   ]];
+%!
+%! 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 = [tbl;[besseli(n,z2,1),besselk(n,z2,1)]];
 %!
-%!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 (tbl, rtbl, -2e-8);
+
+Table 9.9 - I and K for orders 3-9.
+
+%!test
+%! It = [[  0.0000e+00  0.0000e+00  0.0000e+00  0.0000e+00  0.0000e+00  0.0000e+00  0.0000e+00];
+%!       [  2.8791e-02  6.8654e-03  1.3298e-03  2.1656e-04  3.0402e-05  3.7487e-06  4.1199e-07];
+%!       [  6.1124e-02  2.5940e-02  9.2443e-03  2.8291e-03  7.5698e-04  1.7968e-04  3.8284e-05];
+%!       [  7.4736e-02  4.1238e-02  1.9752e-02  8.3181e-03  3.1156e-03  1.0484e-03  3.1978e-04];
+%!       [  7.9194e-02  5.0500e-02  2.8694e-02  1.4633e-02  6.7449e-03  2.8292e-03  1.0866e-03];
+%!       [  7.9830e-02  5.5683e-02  3.5284e-02  2.0398e-02  1.0806e-02  5.2694e-03  2.3753e-03];
+%!       [  7.8848e-02  5.8425e-02  3.9898e-02  2.5176e-02  1.4722e-02  8.0010e-03  4.0537e-03];
+%!       [  7.7183e-02  5.9723e-02  4.3056e-02  2.8969e-02  1.8225e-02  1.0744e-02  5.9469e-03];
+%!       [  7.5256e-02  6.0155e-02  4.5179e-02  3.1918e-02  2.1240e-02  1.3333e-02  7.9071e-03];
+%!       [  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];
+%!      [  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];
+%!      [  7.3935e-01  1.1069e+00  1.8463e+00  3.4148e+00  6.9684e+00  1.5610e+01  3.8188e+01];
+%!      [  6.0028e-01  8.3395e-01  1.2674e+00  2.1014e+00  3.7891e+00  7.4062e+00  1.5639e+01];
+%!      [  5.1294e-01  6.7680e-01  9.6415e-01  1.4803e+00  2.4444e+00  4.3321e+00  8.2205e+00];
+%!      [  4.5266e-01  5.7519e-01  7.8133e-01  1.1333e+00  1.7527e+00  2.8860e+00  5.0510e+00];
+%!      [  4.0829e-01  5.0414e-01  6.6036e-01  9.1686e-01  1.3480e+00  2.0964e+00  3.4444e+00];
+%!      [  3.7411e-01  4.5162e-01  5.7483e-01  7.7097e-01  1.0888e+00  1.6178e+00  2.5269e+00];
+%!      [  3.4684e-01  4.1114e-01  5.1130e-01  6.6679e-01  9.1137e-01  1.3048e+00  1.9552e+00]];
+%!
+%! n = (3:9);
+%! z = (0:2:20).';
+%! 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);
+
+Table 9.11 - I and K for various integer orders and arguments.
+
+%!test
+%! It = [[   1.266065878e+00    2.279585302e+00    2.723987182e+01    2.815716628e+03     2.93255378e+20     1.07375171e+42 ];
+%!       [   2.714631560e-04    9.825679323e-03    2.157974547e+00    7.771882864e+02     2.27854831e+20     9.47009387e+41 ];
+%!       [   2.752948040e-10    3.016963879e-07    4.580044419e-03    2.189170616e+01     1.07159716e+20     6.49897552e+41 ];
+%!       [   2.370463051e-17    8.139432531e-13    1.047977675e-06    1.043714907e-01     3.07376455e+19     3.47368638e+41 ];
+%!       [   3.966835986e-25    4.310560576e-19    5.024239358e-11    1.250799736e-04     5.44200840e+18     1.44834613e+41 ];
+%!       [   3.539500588e-42    3.893519664e-33    3.997844971e-21    7.787569783e-12     4.27499365e+16     1.20615487e+40 ];
+%!       [   1.121509741e-60    1.255869192e-48    1.180426980e-32    2.042123274e-20     6.00717897e+13     3.84170550e+38 ];
+%!       [   2.934635309e-80    3.353042830e-65    2.931469647e-45    4.756894561e-30     1.76508024e+10     4.82195809e+36 ];
+%!       [   8.473674008e-189   1.082171475e-158   7.093551489e-119   1.082344202e-88     2.72788795e-16     4.64153494e+21 ]];
+%!
+%! Kt = [[   4.210244382e-01    1.138938727e-01    3.691098334e-03    1.778006232e-05     3.41016774e-23     4.65662823e-45 ];
+%!       [   3.609605896e+02    9.431049101e+00    3.270627371e-02    5.754184999e-05     4.36718224e-23     5.27325611e-45 ];
+%!       [   1.807132899e+08    1.624824040e+05    9.758562829e+00    1.614255300e-03     9.15098819e-23     7.65542797e-45 ];
+%!       [   1.403066801e+15    4.059213332e+10    3.016976630e+04    2.656563849e-01     3.11621117e-22     1.42348325e-44 ];
+%!       [   6.294369360e+22    5.770856853e+16    4.827000521e+08    1.787442782e+02     1.70614838e-21     3.38520541e-44 ];
+%!       [   4.706145527e+39    4.271125755e+30    4.112132063e+18    2.030247813e+09     2.00581681e-19     3.97060205e-43 ];
+%!       [   1.114220651e+58    9.940839886e+45    1.050756722e+30    5.938224681e+17     1.29986971e-16     1.20842080e-41 ];
+%!       [   3.406896854e+77    2.979981740e+62    3.394322243e+42    2.061373775e+27     4.00601349e-13     9.27452265e-40 ];
+%!       [   5.900333184e+185   4.619415978e+155   7.039860193e+115   4.596674084e+85     1.63940352e+13     7.61712963e-25 ]];
+%!
+%! 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);
+
+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);
+
+besseli (n,z) = besseli (-n,z);
+
+%!test
+%! 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.
+
+%!test
+%! n = (0:2);
+%! z = [0.1;(2.5:2.5:10.0).'];
+%!
+%! jt = [[ 9.9833417e-01  3.33000119e-02  6.6619061e-04 ];
+%!       [ 2.3938886e-01  4.16212989e-01  2.6006673e-01 ];
+%!       [-1.9178485e-01 -9.50894081e-02  1.3473121e-01 ];
+%!       [    1.2507e-01     -2.9542e-02    -1.3688e-01 ];
+%!       [   -5.4402e-02      7.8467e-02     7.7942e-02 ]];
+%!
+%! yt = [[-9.9500417e+00  -1.0049875e+02 -3.0050125e+03 ];
+%!       [ 3.2045745e-01  -1.1120588e-01 -4.5390450e-01 ];
+%!       [-5.6732437e-02   1.8043837e-01  1.6499546e-01 ];
+%!       [   -4.6218e-02     -1.3123e-01    -6.2736e-03 ];
+%!       [    8.3907e-02      6.2793e-02    -6.5069e-02 ]];
+%!
+%! 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);
+
+Table 10.2 - j and y for orders 3-8.
+Compare against excerpts of Table 10.2, Abramowitzh and Stegun.
+
+ Important note: In A&S, y_4(0.1) = -1.0507e+7, but Octave returns
+ y_4(0.1) = -1.0508e+07 (-10507503.75).  If I compute the same term using
+ a series, the difference is in the eighth significant digit so I left
+ the Octave results in place.
+
+%!test
+%! n = (3:8);
+%! 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];
+%!       [ 2.2982e-01  1.8702e-01  1.0681e-01  4.7967e-02  1.7903e-02  5.7414e-03];
+%!       [-6.1713e-02  7.9285e-02  1.5685e-01  1.5077e-01  1.0448e-01  5.8188e-02];
+%!       [-3.9496e-02 -1.0559e-01 -5.5535e-02  4.4501e-02  1.1339e-01  1.2558e-01]];
+%!
+%! yt = [[-1.5015e+05 -1.0508e+07 -9.4553e+08 -1.0400e+11 -1.3519e+13 -2.0277e+15];
+%!       [-7.9660e-01 -1.7766e+00 -5.5991e+00 -2.2859e+01 -1.1327e+02 -6.5676e+02];
+%!       [-1.5443e-02 -1.8662e-01 -3.2047e-01 -5.1841e-01 -1.0274e+00 -2.5638e+00];
+%!       [ 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);
+%!
+%! assert (jt, j, -5e-5);
+%! assert (yt, y, -5e-5);
+
+Table 10.4 - j and y for various integer orders and arguments.
+
+%!test
+%! jt = [[ 8.414709848e-01    4.546487134e-01   -1.917848549e-01   -5.440211109e-02   -5.247497074e-03   -5.063656411e-03];
+%!       [ 9.256115861e-05    2.635169770e-03    1.068111615e-01   -5.553451162e-02   -2.004830056e-02   -9.290148935e-03];
+%!       [ 7.116552640e-11    6.825300865e-08    4.073442442e-04    6.460515449e-02   -1.503922146e-02   -1.956578597e-04];
+%!       [ 5.132686115e-18    1.606982166e-13    1.084280182e-07    1.063542715e-03   -1.129084539e-02    7.877261748e-03];
+%!       [ 7.537795722e-26    7.632641101e-20    5.427726761e-12    2.308371961e-06   -1.578502990e-02    1.010767128e-02];
+%!       [ 5.566831267e-43    5.836617888e-34    4.282730217e-22    2.512057385e-13   -1.494673454e-03    8.700628514e-03];
+%!       [ 1.538210374e-61    1.660978779e-49    1.210347583e-33    8.435671634e-22   -2.606336952e-02    1.043410851e-02];
+%!       [ 3.615274717e-81    4.011575290e-66    2.857479350e-46    2.230696023e-31    1.882910737e-02    5.797140882e-04];
+%!       [7.444727742e-190   9.367832591e-160   5.535650303e-120    5.832040182e-90    1.019012263e-22    1.088047701e-02]];
+%!
+%! yt = [[ -5.403023059e-01    2.080734183e-01   -5.673243709e-02    8.390715291e-02   -1.929932057e-02   -8.623188723e-03]
+%!       [ -9.994403434e+02   -1.859144531e+01   -3.204650467e-01    9.383354168e-02   -6.971131965e-04    3.720678486e-03]
+%!       [ -6.722150083e+08   -3.554147201e+05   -2.665611441e+01   -1.724536721e-01    1.352468751e-02    1.002577737e-02]
+%!       [ -6.298007233e+15   -1.012182944e+11   -6.288146513e+04   -3.992071745e+00    1.712319725e-02    6.258641510e-03]
+%!       [ -3.239592219e+23   -1.605436493e+17   -9.267951403e+08   -1.211210605e+03    1.375953130e-02    5.631729379e-05]
+%!       [ -2.946428547e+40   -1.407393871e+31   -7.760717570e+18   -6.908318646e+09   -2.241226812e-02   -5.412929349e-03]
+%!       [ -8.028450851e+58   -3.720929322e+46   -2.055758716e+30   -1.510304919e+18    4.978797221e-05   -7.048420407e-04]
+%!       [ -2.739192285e+78   -1.235021944e+63   -6.964109188e+42   -4.528227272e+27   -4.190000150e-02    1.074782297e-02]
+%!       [-6.683079463e+186  -2.655955830e+156  -1.799713983e+116   -8.573226309e+85   -1.125692891e+18   -2.298385049e-02]];
+%!
+%! 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);
 */
--- a/src/DLD-FUNCTIONS/betainc.cc
+++ b/src/DLD-FUNCTIONS/betainc.cc
@@ -32,6 +32,9 @@
 #include "oct-obj.h"
 #include "utils.h"
 
+// FIXME: These functions do not need to be dynamically loaded.  They should
+//        be placed elsewhere in the Octave code hierarchy.
+
 DEFUN_DLD (betainc, args, ,
   "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} betainc (@var{x}, @var{a}, @var{b})\n\
@@ -46,12 +49,11 @@
 \n\
 @smallexample\n\
 @group\n\
-@c spacing appears odd here, but is correct after Makeinfo\n\
-                                     x\n\
-                          1         /\n\
-betainc (x, a, b) = -----------    | t^(a-1) (1-t)^(b-1) dt.\n\
-                     beta (a, b)    /\n\
-                                 t=0\n\
+                                   x\n\
+                          1       /\n\
+betainc (x, a, b) = -----------   | t^(a-1) (1-t)^(b-1) dt.\n\
+                    beta (a, b)   /\n\
+                               t=0\n\
 @end group\n\
 @end smallexample\n\
 \n\
@@ -60,6 +62,7 @@
 If @var{x} has more than one component, both @var{a} and @var{b} must be\n\
 scalars.  If @var{x} is a scalar, @var{a} and @var{b} must be of\n\
 compatible dimensions.\n\
+@seealso{betaincinv, beta, betaln}\n\
 @end deftypefn")
 {
   octave_value retval;
@@ -95,7 +98,7 @@
                         }
                       else
                         {
-                          FloatNDArray b = b_arg.float_array_value ();
+                          Array<float> b = b_arg.float_array_value ();
 
                           if (! error_state)
                             retval = betainc (x, a, b);
@@ -104,7 +107,7 @@
                 }
               else
                 {
-                  FloatNDArray a = a_arg.float_array_value ();
+                  Array<float> a = a_arg.float_array_value ();
 
                   if (! error_state)
                     {
@@ -117,7 +120,7 @@
                         }
                       else
                         {
-                          FloatNDArray b = b_arg.float_array_value ();
+                          Array<float> b = b_arg.float_array_value ();
 
                           if (! error_state)
                             retval = betainc (x, a, b);
@@ -127,7 +130,7 @@
             }
           else
             {
-              FloatNDArray x = x_arg.float_array_value ();
+              Array<float> x = x_arg.float_array_value ();
 
               if (a_arg.is_scalar_type ())
                 {
@@ -144,7 +147,7 @@
                         }
                       else
                         {
-                          FloatNDArray b = b_arg.float_array_value ();
+                          Array<float> b = b_arg.float_array_value ();
 
                           if (! error_state)
                             retval = betainc (x, a, b);
@@ -153,7 +156,7 @@
                 }
               else
                 {
-                  FloatNDArray a = a_arg.float_array_value ();
+                  Array<float> a = a_arg.float_array_value ();
 
                   if (! error_state)
                     {
@@ -166,7 +169,7 @@
                         }
                       else
                         {
-                          FloatNDArray b = b_arg.float_array_value ();
+                          Array<float> b = b_arg.float_array_value ();
 
                           if (! error_state)
                             retval = betainc (x, a, b);
@@ -196,7 +199,7 @@
                         }
                       else
                         {
-                          NDArray b = b_arg.array_value ();
+                          Array<double> b = b_arg.array_value ();
 
                           if (! error_state)
                             retval = betainc (x, a, b);
@@ -205,7 +208,7 @@
                 }
               else
                 {
-                  NDArray a = a_arg.array_value ();
+                  Array<double> a = a_arg.array_value ();
 
                   if (! error_state)
                     {
@@ -218,7 +221,7 @@
                         }
                       else
                         {
-                          NDArray b = b_arg.array_value ();
+                          Array<double> b = b_arg.array_value ();
 
                           if (! error_state)
                             retval = betainc (x, a, b);
@@ -228,7 +231,7 @@
             }
           else
             {
-              NDArray x = x_arg.array_value ();
+              Array<double> x = x_arg.array_value ();
 
               if (a_arg.is_scalar_type ())
                 {
@@ -245,7 +248,7 @@
                         }
                       else
                         {
-                          NDArray b = b_arg.array_value ();
+                          Array<double> b = b_arg.array_value ();
 
                           if (! error_state)
                             retval = betainc (x, a, b);
@@ -254,7 +257,7 @@
                 }
               else
                 {
-                  NDArray a = a_arg.array_value ();
+                  Array<double> a = a_arg.array_value ();
 
                   if (! error_state)
                     {
@@ -267,7 +270,7 @@
                         }
                       else
                         {
-                          NDArray b = b_arg.array_value ();
+                          Array<double> b = b_arg.array_value ();
 
                           if (! error_state)
                             retval = betainc (x, a, b);
@@ -284,50 +287,205 @@
 }
 
 /*
-
-%% test/octave.test/arith/betainc-1.m
+## Double precision
 %!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
+## 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
+## 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")));
+
+%!error betainc ()
+%!error betainc (1)
+%!error betainc (1,2)
+%!error betainc (1,2,3,4)
+*/
+
+DEFUN_DLD (betaincinv, args, ,
+    "-*- texinfo -*-\n\
+@deftypefn {Mapping Function} {} betaincinv (@var{y}, @var{a}, @var{b})\n\
+Compute the inverse of the incomplete Beta function, i.e., @var{x} such that\n\
+\n\
+@example\n\
+@var{y} == betainc (@var{x}, @var{a}, @var{b}) \n\
+@end example\n\
+@seealso{betainc, beta, betaln}\n\
+@end deftypefn")
+{
+  octave_value retval;
+
+  int nargin = args.length ();
+
+  if (nargin == 3)
+    {
+      octave_value x_arg = args(0);
+      octave_value a_arg = args(1);
+      octave_value b_arg = args(2);
+
+      if (x_arg.is_scalar_type ())
+        {
+          double x = x_arg.double_value ();
+
+          if (a_arg.is_scalar_type ())
+            {
+              double a = a_arg.double_value ();
 
-%% test/octave.test/arith/betainc-2.m
-%!error <Invalid call to betainc> betainc();
+              if (! error_state)
+                {
+                  if (b_arg.is_scalar_type ())
+                    {
+                      double b = b_arg.double_value ();
+
+                      if (! error_state)
+                        retval = betaincinv (x, a, b);
+                    }
+                  else
+                    {
+                      Array<double> b = b_arg.array_value ();
+
+                      if (! error_state)
+                        retval = betaincinv (x, a, b);
+                    }
+                }
+            }
+          else
+            {
+              Array<double> a = a_arg.array_value ();
+
+              if (! error_state)
+                {
+                  if (b_arg.is_scalar_type ())
+                    {
+                      double b = b_arg.double_value ();
+
+                      if (! error_state)
+                        retval = betaincinv (x, a, b);
+                    }
+                  else
+                    {
+                      Array<double> b = b_arg.array_value ();
+
+                      if (! error_state)
+                        retval = betaincinv (x, a, b);
+                    }
+                }
+            }
+        }
+      else
+        {
+          Array<double> x = x_arg.array_value ();
 
-%% test/octave.test/arith/betainc-3.m
-%!error <Invalid call to betainc> betainc(1);
+          if (a_arg.is_scalar_type ())
+            {
+              double a = a_arg.double_value ();
+
+              if (! error_state)
+                {
+                  if (b_arg.is_scalar_type ())
+                    {
+                      double b = b_arg.double_value ();
+
+                      if (! error_state)
+                        retval = betaincinv (x, a, b);
+                    }
+                  else
+                    {
+                      Array<double> b = b_arg.array_value ();
+
+                      if (! error_state)
+                        retval = betaincinv (x, a, b);
+                    }
+                }
+            }
+          else
+            {
+              Array<double> a = a_arg.array_value ();
+
+              if (! error_state)
+                {
+                  if (b_arg.is_scalar_type ())
+                    {
+                      double b = b_arg.double_value ();
+
+                      if (! error_state)
+                        retval = betaincinv (x, a, b);
+                    }
+                  else
+                    {
+                      Array<double> b = b_arg.array_value ();
 
-%% test/octave.test/arith/betainc-4.m
-%!error <Invalid call to betainc> betainc(1,2);
+                      if (! error_state)
+                        retval = betaincinv (x, a, b);
+                    }
+                }
+            }
+        }
+
+      // FIXME: It would be better to have an algorithm for betaincinv which
+      // accepted float inputs and returned float outputs.  As it is, we do
+      // extra work to calculate betaincinv to double precision and then throw
+      // that precision away.
+      if (x_arg.is_single_type () || a_arg.is_single_type () ||
+          b_arg.is_single_type ())
+        {
+          retval = Array<float> (retval.array_value ());
+        }
+    }
+  else
+    print_usage ();
+
+  return retval;
+}
 
+/*
+%!assert (betaincinv ([0.875 0.6875], [1 2], 3), [0.5 0.5], sqrt (eps))
+%!assert (betaincinv (0.5, 3, 3), 0.5, sqrt (eps))
+%!assert (betaincinv (0.34375, 4, 3), 0.5, sqrt (eps))
+%!assert (betaincinv (0.2265625, 5, 3), 0.5, sqrt (eps))
+%!assert (betaincinv (0.14453125, 6, 3), 0.5, sqrt (eps))
+%!assert (betaincinv (0.08984375, 7, 3), 0.5, sqrt (eps))
+%!assert (betaincinv (0.0546875, 8, 3), 0.5, sqrt (eps))
+%!assert (betaincinv (0.03271484375, 9, 3), 0.5, sqrt (eps))
+%!assert (betaincinv (0.019287109375, 10, 3), 0.5, sqrt (eps))
+
+## Test class single as well
+%!assert (betaincinv ([0.875 0.6875], [1 2], single (3)), [0.5 0.5], sqrt (eps ("single")))
+%!assert (betaincinv (0.5, 3, single (3)), 0.5, sqrt (eps ("single")))
+%!assert (betaincinv (0.34375, 4, single (3)), 0.5, sqrt (eps ("single")))
+
+## Extreme values
+%!assert (betaincinv (0, 42, 42), 0, sqrt (eps))
+%!assert (betaincinv (1, 42, 42), 1, sqrt (eps))
+
+%!error betaincinv ()
+%!error betaincinv (1, 2)
 */
+
--- a/src/DLD-FUNCTIONS/bsxfun.cc
+++ b/src/DLD-FUNCTIONS/bsxfun.cc
@@ -233,9 +233,9 @@
       for (octave_idx_type j = 1; j < nd; j++)
         {
           if (dva (j) == 1)
-            idx (j) = octave_value (1);
+            idx(j) = octave_value (1);
           else
-            idx (j) = octave_value ((i % dvc(j)) + 1);
+            idx(j) = octave_value ((i % dvc(j)) + 1);
 
           i = i / dvc (j);
         }
@@ -442,7 +442,7 @@
                   octave_value_list idxB;
                   octave_value C;
                   octave_value_list inputs;
-                  Array<int> ra_idx (dim_vector (dvc.length(), 1), 0);
+                  Array<int> ra_idx (dim_vector (dvc.length (), 1), 0);
 
 
                   for (octave_idx_type i = 0; i < ncount; i++)
@@ -549,7 +549,7 @@
                                       result_ComplexNDArray =
                                         ComplexNDArray (result_FloatNDArray);
                                       result_ComplexNDArray.insert
-                                        (tmp(0).complex_array_value(), ra_idx);
+                                        (tmp(0).complex_array_value (), ra_idx);
                                       have_FloatComplexNDArray = false;
                                       have_ComplexNDArray = true;
                                     }
@@ -558,20 +558,20 @@
                                       result_NDArray =
                                         NDArray (result_FloatNDArray);
                                       result_NDArray.insert
-                                        (tmp(0).array_value(), ra_idx);
+                                        (tmp(0).array_value (), ra_idx);
                                       have_FloatNDArray = false;
                                       have_NDArray = true;
                                     }
                                 }
                               else if (tmp(0).is_real_type ())
                                 result_FloatNDArray.insert
-                                  (tmp(0).float_array_value(), ra_idx);
+                                  (tmp(0).float_array_value (), ra_idx);
                               else
                                 {
                                   result_FloatComplexNDArray =
                                     FloatComplexNDArray (result_FloatNDArray);
                                   result_FloatComplexNDArray.insert
-                                    (tmp(0).float_complex_array_value(), ra_idx);
+                                    (tmp(0).float_complex_array_value (), ra_idx);
                                   have_FloatNDArray = false;
                                   have_FloatComplexNDArray = true;
                                 }
@@ -585,14 +585,14 @@
                                   C = do_cat_op (C, tmp(0), ra_idx);
                                 }
                               else if (tmp(0).is_real_type ())
-                                result_NDArray.insert (tmp(0).array_value(),
+                                result_NDArray.insert (tmp(0).array_value (),
                                                        ra_idx);
                               else
                                 {
                                   result_ComplexNDArray =
                                     ComplexNDArray (result_NDArray);
                                   result_ComplexNDArray.insert
-                                    (tmp(0).complex_array_value(), ra_idx);
+                                    (tmp(0).complex_array_value (), ra_idx);
                                   have_NDArray = false;
                                   have_ComplexNDArray = true;
                                 }
@@ -630,7 +630,7 @@
 
 #define BSXEND(T) \
                   (have_ ## T) \
-                    retval (0) = result_ ## T;
+                    retval(0) = result_ ## T;
 
                   if BSXEND(NDArray)
                   else if BSXEND(ComplexNDArray)
@@ -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,14 +779,14 @@
 %!
 %! 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)
-%!     for k = 1:length(int_types)
+%!   for j = 1:length (float_types)
+%!     for k = 1:length (int_types)
 %!
 %!       fun = funs{i};
 %!       f_type = float_types{j};
--- a/src/DLD-FUNCTIONS/ccolamd.cc
+++ b/src/DLD-FUNCTIONS/ccolamd.cc
@@ -103,7 +103,7 @@
 range 1 to\n\
 n).  In the output permutation @var{p}, all columns in set 1 appear\n\
 first, followed by all columns in set 2, and so on.  @code{@var{cmember} =\n\
-ones(1,n)} if not present or empty.\n\
+ones (1,n)} if not present or empty.\n\
 @code{ccolamd (@var{S}, [], 1 : n)} returns @code{1 : n}\n\
 \n\
 @code{@var{p} = ccolamd (@var{S})} is about the same as\n\
@@ -181,14 +181,14 @@
                             <<  CCOLAMD_SUB_VERSION << ", " << CCOLAMD_DATE
                             << ":\nknobs(1): " << User_knobs (0) << ", order for ";
               if ( knobs [CCOLAMD_LU] != 0)
-                octave_stdout << "lu(A)\n";
+                octave_stdout << "lu (A)\n";
               else
-                octave_stdout << "chol(A'*A)\n";
+                octave_stdout << "chol (A'*A)\n";
 
               if (knobs [CCOLAMD_DENSE_ROW] >= 0)
                 octave_stdout << "knobs(2): " << User_knobs (1)
-                              << ", rows with > max(16,"
-                              << knobs [CCOLAMD_DENSE_ROW] << "*sqrt(size(A,2)))"
+                              << ", rows with > max (16,"
+                              << knobs [CCOLAMD_DENSE_ROW] << "*sqrt (size(A,2)))"
                               << " entries removed\n";
               else
                 octave_stdout << "knobs(2): " << User_knobs (1)
@@ -196,8 +196,8 @@
 
               if (knobs [CCOLAMD_DENSE_COL] >= 0)
                 octave_stdout << "knobs(3): " << User_knobs (2)
-                              << ", cols with > max(16,"
-                              << knobs [CCOLAMD_DENSE_COL] << "*sqrt(size(A)))"
+                              << ", cols with > max (16,"
+                              << knobs [CCOLAMD_DENSE_COL] << "*sqrt (size(A)))"
                               << " entries removed\n";
               else
                 octave_stdout << "knobs(3): " << User_knobs (2)
@@ -270,8 +270,8 @@
 
       if (nargin > 2)
         {
-          NDArray in_cmember = args(2).array_value();
-          octave_idx_type cslen = in_cmember.length();
+          NDArray in_cmember = args(2).array_value ();
+          octave_idx_type cslen = in_cmember.length ();
           OCTAVE_LOCAL_BUFFER (octave_idx_type, cmember, cslen);
           for (octave_idx_type i = 0; i < cslen; i++)
             // convert cmember from 1-based to 0-based
@@ -302,9 +302,9 @@
       // return the permutation vector
       NDArray out_perm (dim_vector (1, n_col));
       for (octave_idx_type i = 0; i < n_col; i++)
-        out_perm(i) = p [i] + 1;
+        out_perm(i) = p[i] + 1;
 
-      retval (0) = out_perm;
+      retval(0) = out_perm;
 
       // print stats if spumoni > 0
       if (spumoni > 0)
@@ -372,11 +372,11 @@
 on the ordering.  If @code{@var{cmember}(j) = @var{S}}, then row/column j is\n\
 in constraint set @var{c} (@var{c} must be in the range 1 to n).  In the\n\
 output permutation @var{p}, rows/columns in set 1 appear first, followed\n\
-by all rows/columns in set 2, and so on.  @code{@var{cmember} = ones(1,n)}\n\
-if not present or empty.  @code{csymamd(@var{S},[],1:n)} returns @code{1:n}.\n\
+by all rows/columns in set 2, and so on.  @code{@var{cmember} = ones (1,n)}\n\
+if not present or empty.  @code{csymamd (@var{S},[],1:n)} returns @code{1:n}.\n\
 \n\
-@code{@var{p} = csymamd(@var{S})} is about the same as @code{@var{p} =\n\
-symamd(@var{S})}.  @var{knobs} and its default values differ.\n\
+@code{@var{p} = csymamd (@var{S})} is about the same as @code{@var{p} =\n\
+symamd (@var{S})}.  @var{knobs} and its default values differ.\n\
 \n\
 @code{@var{stats}(4:7)} provide information if CCOLAMD was able to\n\
 continue.  The matrix is OK if @code{@var{stats}(4)} is zero, or 1 if\n\
@@ -433,8 +433,8 @@
 
               if (knobs [CCOLAMD_DENSE_ROW] >= 0)
                 octave_stdout << "knobs(1): " << User_knobs (0)
-                              << ", rows/cols with > max(16,"
-                              << knobs [CCOLAMD_DENSE_ROW] << "*sqrt(size(A,2)))"
+                              << ", rows/cols with > max (16,"
+                              << knobs [CCOLAMD_DENSE_ROW] << "*sqrt (size(A,2)))"
                               << " entries removed\n";
               else
                 octave_stdout << "knobs(1): " << User_knobs (0)
@@ -502,8 +502,8 @@
 
       if (nargin > 2)
         {
-          NDArray in_cmember = args(2).array_value();
-          octave_idx_type cslen = in_cmember.length();
+          NDArray in_cmember = args(2).array_value ();
+          octave_idx_type cslen = in_cmember.length ();
           OCTAVE_LOCAL_BUFFER (octave_idx_type, cmember, cslen);
           for (octave_idx_type i = 0; i < cslen; i++)
             // convert cmember from 1-based to 0-based
@@ -534,9 +534,9 @@
       // return the permutation vector
       NDArray out_perm (dim_vector (1, n_col));
       for (octave_idx_type i = 0; i < n_col; i++)
-        out_perm(i) = perm [i] + 1;
+        out_perm(i) = perm[i] + 1;
 
-      retval (0) = out_perm;
+      retval(0) = out_perm;
 
       // Return the stats vector
       if (nargout == 2)
--- a/src/DLD-FUNCTIONS/cellfun.cc
+++ b/src/DLD-FUNCTIONS/cellfun.cc
@@ -116,42 +116,42 @@
     {
       boolNDArray result (f_args.dims ());
       for (octave_idx_type count = 0; count < k; count++)
-        result(count) = f_args.elem(count).is_empty ();
+        result(count) = f_args.elem (count).is_empty ();
       retval(0) = result;
     }
   else if (name == "islogical")
     {
       boolNDArray result (f_args.dims ());
       for (octave_idx_type  count= 0; count < k; count++)
-        result(count) = f_args.elem(count).is_bool_type ();
+        result(count) = f_args.elem (count).is_bool_type ();
       retval(0) = result;
     }
   else if (name == "isreal")
     {
       boolNDArray result (f_args.dims ());
       for (octave_idx_type  count= 0; count < k; count++)
-        result(count) = f_args.elem(count).is_real_type ();
+        result(count) = f_args.elem (count).is_real_type ();
       retval(0) = result;
     }
   else if (name == "length")
     {
       NDArray result (f_args.dims ());
       for (octave_idx_type  count= 0; count < k; count++)
-        result(count) = static_cast<double> (f_args.elem(count).length ());
+        result(count) = static_cast<double> (f_args.elem (count).length ());
       retval(0) = result;
     }
   else if (name == "ndims")
     {
       NDArray result (f_args.dims ());
       for (octave_idx_type count = 0; count < k; count++)
-        result(count) = static_cast<double> (f_args.elem(count).ndims ());
+        result(count) = static_cast<double> (f_args.elem (count).ndims ());
       retval(0) = result;
     }
   else if (name == "prodofsize" || name == "numel")
     {
       NDArray result (f_args.dims ());
       for (octave_idx_type count = 0; count < k; count++)
-        result(count) = static_cast<double> (f_args.elem(count).numel ());
+        result(count) = static_cast<double> (f_args.elem (count).numel ());
       retval(0) = result;
     }
   else if (name == "size")
@@ -168,7 +168,7 @@
               NDArray result (f_args.dims ());
               for (octave_idx_type count = 0; count < k; count++)
                 {
-                  dim_vector dv = f_args.elem(count).dims ();
+                  dim_vector dv = f_args.elem (count).dims ();
                   if (d < dv.length ())
                     result(count) = static_cast<double> (dv(d));
                   else
@@ -184,10 +184,10 @@
     {
       if (nargin == 3)
         {
-          std::string class_name = args(2).string_value();
+          std::string class_name = args(2).string_value ();
           boolNDArray result (f_args.dims ());
           for (octave_idx_type count = 0; count < k; count++)
-            result(count) = (f_args.elem(count).class_name() == class_name);
+            result(count) = (f_args.elem (count).class_name () == class_name);
 
           retval(0) = result;
         }
@@ -209,7 +209,7 @@
       size_t compare_len = std::max (arg.length (), static_cast<size_t> (2));
 
       if (arg.compare ("uniformoutput", compare_len))
-        uniform_output = args(nargin-1).bool_value();
+        uniform_output = args(nargin-1).bool_value ();
       else if (arg.compare ("errorhandler", compare_len))
         {
           if (args(nargin-1).is_function_handle ()
@@ -239,7 +239,7 @@
       else
         {
           error ("cellfun: unrecognized parameter %s",
-                 arg.c_str());
+                 arg.c_str ());
           break;
         }
 
@@ -257,8 +257,8 @@
 @deftypefnx {Loadable Function} {} cellfun (@var{func}, @var{C})\n\
 @deftypefnx {Loadable Function} {} cellfun (@var{func}, @var{C}, @var{D})\n\
 @deftypefnx {Loadable Function} {[@var{a}, @dots{}] =} cellfun (@dots{})\n\
-@deftypefnx {Loadable Function} {} cellfun (@dots{}, 'ErrorHandler', @var{errfunc})\n\
-@deftypefnx {Loadable Function} {} cellfun (@dots{}, 'UniformOutput', @var{val})\n\
+@deftypefnx {Loadable Function} {} cellfun (@dots{}, \"ErrorHandler\", @var{errfunc})\n\
+@deftypefnx {Loadable Function} {} cellfun (@dots{}, \"UniformOutput\", @var{val})\n\
 \n\
 Evaluate the function named @var{name} on the elements of the cell array\n\
 @var{C}.  Elements in @var{C} are passed on to the named function\n\
@@ -303,7 +303,7 @@
 @example\n\
 @group\n\
 cellfun (\"atan2\", @{1, 0@}, @{0, 1@})\n\
-     @result{}ans = [1.57080   0.00000]\n\
+     @result{} [ 1.57080   0.00000 ]\n\
 @end group\n\
 @end example\n\
 \n\
@@ -317,7 +317,7 @@
   a = x;\n\
   b = x*x;\n\
 endfunction\n\
-[aa, bb] = cellfun(@@twoouts, @{1, 2, 3@})\n\
+[aa, bb] = cellfun (@@twoouts, @{1, 2, 3@})\n\
      @result{}\n\
         aa =\n\
            1 2 3\n\
@@ -330,21 +330,21 @@
 the input arguments.  Input arguments that are singleton (1x1) cells will be\n\
 automatically expanded to the size of the other arguments.\n\
 \n\
-If the parameter 'UniformOutput' is set to true (the default), then the\n\
+If the parameter \"UniformOutput\" is set to true (the default), then the\n\
 function must return scalars which will be concatenated into the return\n\
-array(s).  If 'UniformOutput' is false, the outputs are concatenated into a\n\
+array(s).  If \"UniformOutput\" is false, the outputs are concatenated into a\n\
 cell array (or cell arrays).  For example:\n\
 \n\
 @example\n\
 @group\n\
 cellfun (\"tolower\", @{\"Foo\", \"Bar\", \"FooBar\"@},\n\
-         \"UniformOutput\",false)\n\
-@result{} ans = @{\"foo\", \"bar\", \"foobar\"@}\n\
+         \"UniformOutput\", false)\n\
+@result{} @{\"foo\", \"bar\", \"foobar\"@}\n\
 @end group\n\
 @end example\n\
 \n\
-Given the parameter 'ErrorHandler', then @var{errfunc} defines a function to\n\
-call in case @var{func} generates an error.  The form of the function is\n\
+Given the parameter \"ErrorHandler\", then @var{errfunc} defines a function\n\
+to call in case @var{func} generates an error.  The form of the function is\n\
 \n\
 @example\n\
 function [@dots{}] = errfunc (@var{s}, @dots{})\n\
@@ -360,8 +360,8 @@
 @example\n\
 @group\n\
 function y = foo (s, x), y = NaN; endfunction\n\
-cellfun (\"factorial\", @{-1,2@}, 'ErrorHandler', @@foo)\n\
-@result{} ans = [NaN 2]\n\
+cellfun (\"factorial\", @{-1,2@}, \"ErrorHandler\", @@foo)\n\
+@result{} [NaN 2]\n\
 @end group\n\
 @end example\n\
 \n\
@@ -375,7 +375,7 @@
 @example\n\
 @group\n\
 a = @{@dots{}@}\n\
-v = cellfun (@@(x) det(x), a); # compute determinants\n\
+v = cellfun (@@(x) det (x), a); # compute determinants\n\
 v = cellfun (@@det, a); # faster\n\
 @end group\n\
 @end example\n\
@@ -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
@@ -1042,7 +1043,7 @@
 @example\n\
 @group\n\
 arrayfun (@@atan2, [1, 0], [0, 1])\n\
-@result{} ans = [1.5708   0.0000]\n\
+     @result{} [ 1.5708   0.0000 ]\n\
 @end group\n\
 @end example\n\
 \n\
@@ -1056,12 +1057,12 @@
 @example\n\
 @group\n\
 arrayfun (@@(x,y) x:y, \"abc\", \"def\", \"UniformOutput\", false)\n\
-@result{} ans =\n\
-    @{\n\
-      [1,1] = abcd\n\
-      [1,2] = bcde\n\
-      [1,3] = cdef\n\
-    @}\n\
+@result{}\n\
+   @{\n\
+     [1,1] = abcd\n\
+     [1,2] = bcde\n\
+     [1,3] = cdef\n\
+   @}\n\
 @end group\n\
 @end example\n\
 \n\
@@ -1075,18 +1076,18 @@
 @result{}\n\
 A =\n\
 @{\n\
-  [1,1] =  1\n\
-  [2,1] = [](0x0)\n\
+   [1,1] =  1\n\
+   [2,1] = [](0x0)\n\
 @}\n\
 B =\n\
 @{\n\
-  [1,1] =  1\n\
-  [2,1] = [](0x0)\n\
+   [1,1] =  1\n\
+   [2,1] = [](0x0)\n\
 @}\n\
 C =\n\
 @{\n\
-  [1,1] =  10\n\
-  [2,1] = [](0x0)\n\
+   [1,1] =  10\n\
+   [2,1] = [](0x0)\n\
 @}\n\
 @end group\n\
 @end example\n\
@@ -1115,11 +1116,11 @@
 @group\n\
 function y = ferr (s, x), y = \"MyString\"; endfunction\n\
 arrayfun (@@str2num, [1234],\n\
-           \"UniformOutput\", false, \"ErrorHandler\", @@ferr)\n\
-@result{} ans =\n\
-    @{\n\
+          \"UniformOutput\", false, \"ErrorHandler\", @@ferr)\n\
+@result{}\n\
+   @{\n\
      [1,1] = MyString\n\
-    @}\n\
+   @}\n\
 @end group\n\
 @end example\n\
 \n\
@@ -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
@@ -1785,7 +1790,7 @@
 
               idx(0) = double (i+1);
 
-              retval.xelem(i) = array.single_subsref ("(", idx);
+              retval.xelem (i) = array.single_subsref ("(", idx);
 
               if (error_state)
                 break;
@@ -1810,31 +1815,31 @@
 \n\
 @example\n\
 @group\n\
-num2cell([1,2;3,4])\n\
-     @result{} ans =\n\
-        @{\n\
-          [1,1] =  1\n\
-          [2,1] =  3\n\
-          [1,2] =  2\n\
-          [2,2] =  4\n\
-        @}\n\
-num2cell([1,2;3,4],1)\n\
-     @result{} ans =\n\
-        @{\n\
-          [1,1] =\n\
-             1\n\
-             3\n\
-          [1,2] =\n\
-             2\n\
-             4\n\
-        @}\n\
+num2cell ([1,2;3,4])\n\
+   @result{}\n\
+      @{\n\
+        [1,1] =  1\n\
+        [2,1] =  3\n\
+        [1,2] =  2\n\
+        [2,2] =  4\n\
+      @}\n\
+num2cell ([1,2;3,4],1)\n\
+   @result{}\n\
+      @{\n\
+        [1,1] =\n\
+           1\n\
+           3\n\
+        [1,2] =\n\
+           2\n\
+           4\n\
+      @}\n\
 @end group\n\
 @end example\n\
 \n\
 @seealso{mat2cell}\n\
 @end deftypefn")
 {
-  int nargin =  args.length();
+  int nargin =  args.length ();
   octave_value retval;
 
   if (nargin < 1 || nargin > 2)
@@ -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
@@ -2149,31 +2152,32 @@
 An example of the use of mat2cell is\n\
 \n\
 @example\n\
-mat2cell (reshape(1:16,4,4),[3,1],[3,1])\n\
-@result{} @{\n\
-  [1,1] =\n\
+mat2cell (reshape (1:16,4,4), [3,1], [3,1])\n\
+@result{}\n\
+@{\n\
+   [1,1] =\n\
 \n\
-     1   5   9\n\
-     2   6  10\n\
-     3   7  11\n\
-\n\
-  [2,1] =\n\
+      1   5   9\n\
+      2   6  10\n\
+      3   7  11\n\
 \n\
-     4   8  12\n\
+   [2,1] =\n\
 \n\
-  [1,2] =\n\
+      4   8  12\n\
+\n\
+   [1,2] =\n\
 \n\
-    13\n\
-    14\n\
-    15\n\
+     13\n\
+     14\n\
+     15\n\
 \n\
-  [2,2] = 16\n\
+   [2,2] = 16\n\
 @}\n\
 @end example\n\
 @seealso{num2cell, cell2mat}\n\
 @end deftypefn")
 {
-  int nargin = args.length();
+  int nargin = args.length ();
   octave_value retval;
 
   if (nargin < 2)
@@ -2251,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.
@@ -2430,10 +2432,10 @@
 \n\
 @example\n\
 @group\n\
-  Y = cell (size (X));\n\
-  for i = 1:numel (X)\n\
-    Y@{i@} = X@{i@}(varargin@{:@});\n\
-  endfor\n\
+Y = cell (size (X));\n\
+for i = 1:numel (X)\n\
+  Y@{i@} = X@{i@}(varargin@{:@});\n\
+endfor\n\
 @end group\n\
 @end example\n\
 @seealso{cellslices, cellfun}\n\
--- a/src/DLD-FUNCTIONS/chol.cc
+++ b/src/DLD-FUNCTIONS/chol.cc
@@ -65,9 +65,9 @@
 @deftypefn  {Loadable Function} {@var{R} =} chol (@var{A})\n\
 @deftypefnx {Loadable Function} {[@var{R}, @var{p}] =} chol (@var{A})\n\
 @deftypefnx {Loadable Function} {[@var{R}, @var{p}, @var{Q}] =} chol (@var{S})\n\
-@deftypefnx {Loadable Function} {[@var{R}, @var{p}, @var{Q}] =} chol (@var{S}, 'vector')\n\
-@deftypefnx {Loadable Function} {[@var{L}, @dots{}] =} chol (@dots{}, 'lower')\n\
-@deftypefnx {Loadable Function} {[@var{L}, @dots{}] =} chol (@dots{}, 'upper')\n\
+@deftypefnx {Loadable Function} {[@var{R}, @var{p}, @var{Q}] =} chol (@var{S}, \"vector\")\n\
+@deftypefnx {Loadable Function} {[@var{L}, @dots{}] =} chol (@dots{}, \"lower\")\n\
+@deftypefnx {Loadable Function} {[@var{L}, @dots{}] =} chol (@dots{}, \"upper\")\n\
 @cindex Cholesky factorization\n\
 Compute the Cholesky@tie{}factor, @var{R}, of the symmetric positive definite\n\
 matrix @var{A}, where\n\
@@ -103,7 +103,7 @@
 @end ifnottex\n\
 \n\
 The sparsity preserving permutation is generally returned as a matrix.\n\
-However, given the flag 'vector', @var{Q} will be returned as a vector\n\
+However, given the flag \"vector\", @var{Q} will be returned as a vector\n\
 such that\n\
 @tex\n\
 $ R^T R = A (Q, Q)$.\n\
@@ -116,7 +116,7 @@
 \n\
 @end ifnottex\n\
 \n\
-Called with either a sparse or full matrix and using the 'lower' flag,\n\
+Called with either a sparse or full matrix and using the \"lower\" flag,\n\
 @code{chol} returns the lower triangular factorization such that\n\
 @tex\n\
 $ L L^T = A $.\n\
@@ -129,9 +129,9 @@
 \n\
 @end ifnottex\n\
 \n\
-For full matrices, if the 'lower' flag is set only the lower triangular part\n\
-of the matrix is used for the factorization, otherwise the upper triangular\n\
-part is used.\n\
+For full matrices, if the \"lower\" flag is set only the lower triangular\n\
+part of the matrix is used for the factorization, otherwise the upper\n\
+triangular part is used.\n\
 \n\
 In general the lower triangular factorization is significantly faster for\n\
 sparse matrices.\n\
@@ -204,16 +204,16 @@
                       if (vecout)
                         retval(2) = fact.perm ();
                       else
-                        retval(2) = fact.Q();
+                        retval(2) = fact.Q ();
                     }
 
                   if (nargout > 1 || info == 0)
                     {
-                      retval(1) = fact.P();
+                      retval(1) = fact.P ();
                       if (LLt)
-                        retval(0) = fact.L();
+                        retval(0) = fact.L ();
                       else
-                        retval(0) = fact.R();
+                        retval(0) = fact.R ();
                     }
                   else
                     error ("chol: input matrix must be positive definite");
@@ -233,16 +233,16 @@
                       if (vecout)
                         retval(2) = fact.perm ();
                       else
-                        retval(2) = fact.Q();
+                        retval(2) = fact.Q ();
                     }
 
                   if (nargout > 1 || info == 0)
                     {
-                      retval(1) = fact.P();
+                      retval(1) = fact.P ();
                       if (LLt)
-                        retval(0) = fact.L();
+                        retval(0) = fact.L ();
                       else
-                        retval(0) = fact.R();
+                        retval(0) = fact.R ();
                     }
                   else
                     error ("chol: input matrix must be positive definite");
@@ -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 chol ()
+%!error <matrix must be positive definite> chol ([1, 2; 3, 4])
+%!error <requires square matrix> chol ([1, 2; 3, 4; 5, 6])
+%!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, ,
@@ -627,6 +623,7 @@
 Update or downdate a Cholesky@tie{}factorization.  Given an upper triangular\n\
 matrix @var{R} and a column vector @var{u}, attempt to determine another\n\
 upper triangular matrix @var{R1} such that\n\
+\n\
 @itemize @bullet\n\
 @item\n\
 @var{R1}'*@var{R1} = @var{R}'*@var{R} + @var{u}*@var{u}'\n\
@@ -638,6 +635,7 @@
 @end itemize\n\
 \n\
 If @var{op} is \"-\", @var{info} is set to\n\
+\n\
 @itemize\n\
 @item 0 if the downdate was successful,\n\
 \n\
@@ -786,59 +784,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,
@@ -851,6 +835,7 @@
 @var{A1}, where @w{A1(p,p) = A}, @w{A1(:,j) = A1(j,:)' = u} and\n\
 @w{p = [1:j-1,j+1:n+1]}.  @w{u(j)} should be positive.\n\
 On return, @var{info} is set to\n\
+\n\
 @itemize\n\
 @item 0 if the insertion was successful,\n\
 \n\
@@ -972,14 +957,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 +973,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 ;
@@ -1003,14 +989,15 @@
 %!                -0.13825 ;
 %!                 0.45266 ]);
 %!
-%! R = chol(single(A));
+%! 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 +1005,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 +1070,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, ,
@@ -1197,40 +1183,40 @@
 
 /*
 %!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)
+%! R = chol (A);
 %!
-%!test
-%! 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)
+%! 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 - single(A(p,p)),Inf) < 1e1*eps('single'))
+%! assert (norm (triu (R1)-R1, Inf), 0);
+%! assert (norm (R1'*R1 - Ac(p,p), Inf) < 1e1*eps);
+
+%!test
+%! R = chol (single (A));
 %!
-%!test
-%! R = chol(single(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), single (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(Ac(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 (Ac(p,p)), Inf) < 1e1*eps ("single"));
 */
 
 DEFUN_DLD (cholshift, args, ,
@@ -1338,62 +1324,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/colamd.cc
+++ b/src/DLD-FUNCTIONS/colamd.cc
@@ -226,7 +226,7 @@
 @var{knobs} is an optional one- to three-element input vector.  If @var{S} is\n\
 m-by-n, then rows with more than @code{max(16,@var{knobs}(1)*sqrt(n))}\n\
 entries are ignored.  Columns with more than\n\
-@code{max(16,@var{knobs}(2)*sqrt(min(m,n)))} entries are removed prior to\n\
+@code{max (16,@var{knobs}(2)*sqrt(min(m,n)))} entries are removed prior to\n\
 ordering, and ordered last in the output permutation @var{p}.  Only\n\
 completely dense rows or columns are removed if @code{@var{knobs}(1)} and\n\
 @code{@var{knobs}(2)} are < 0, respectively.  If @code{@var{knobs}(3)} is\n\
@@ -314,8 +314,8 @@
 
               if (knobs [COLAMD_DENSE_ROW] >= 0)
                 octave_stdout << "knobs(1): " << User_knobs (0)
-                              << ", rows with > max(16,"
-                              << knobs [COLAMD_DENSE_ROW] << "*sqrt(size(A,2)))"
+                              << ", rows with > max (16,"
+                              << knobs [COLAMD_DENSE_ROW] << "*sqrt (size(A,2)))"
                               << " entries removed\n";
               else
                 octave_stdout << "knobs(1): " << User_knobs (0)
@@ -323,8 +323,8 @@
 
               if (knobs [COLAMD_DENSE_COL] >= 0)
                 octave_stdout << "knobs(2): " << User_knobs (1)
-                              << ", cols with > max(16,"
-                              << knobs [COLAMD_DENSE_COL] << "*sqrt(size(A)))"
+                              << ", cols with > max (16,"
+                              << knobs [COLAMD_DENSE_COL] << "*sqrt (size(A)))"
                               << " entries removed\n";
               else
                 octave_stdout << "knobs(2): " << User_knobs (1)
@@ -415,7 +415,7 @@
       // return the permutation vector
       NDArray out_perm (dim_vector (1, n_col));
       for (octave_idx_type i = 0; i < n_col; i++)
-        out_perm(i) = p [colbeg [i]] + 1;
+        out_perm(i) = p[colbeg [i]] + 1;
 
       retval(0) = out_perm;
 
@@ -464,7 +464,7 @@
 \n\
 @var{knobs} is an optional one- to two-element input vector.  If @var{S} is\n\
 n-by-n, then rows and columns with more than\n\
-@code{max(16,@var{knobs}(1)*sqrt(n))} entries are removed prior to ordering,\n\
+@code{max (16,@var{knobs}(1)*sqrt(n))} entries are removed prior to ordering,\n\
 and ordered last in the output permutation @var{p}.  No rows/columns are\n\
 removed if @code{@var{knobs}(1) < 0}.  If @code{@var{knobs} (2)} is nonzero,\n\
 @code{stats} and @var{knobs} are printed.  The default is @code{@var{knobs}\n\
@@ -608,7 +608,7 @@
       // return the permutation vector
       NDArray out_perm (dim_vector (1, n_col));
       for (octave_idx_type i = 0; i < n_col; i++)
-        out_perm(i) = perm [post [i]] + 1;
+        out_perm(i) = perm[post [i]] + 1;
 
       retval(0) = out_perm;
 
@@ -651,7 +651,7 @@
 is assumed to be symmetric and the symmetric elimination tree is\n\
 returned.  The argument @var{typ} controls whether a symmetric or\n\
 column elimination tree is returned.  Valid values of @var{typ} are\n\
-'sym' or 'col', for symmetric or column elimination tree respectively\n\
+\"sym\" or \"col\", for symmetric or column elimination tree respectively\n\
 \n\
 Called with a second argument, @code{etree} also returns the postorder\n\
 permutations on the tree.\n\
--- a/src/DLD-FUNCTIONS/config-module.awk
+++ b/src/DLD-FUNCTIONS/config-module.awk
@@ -71,7 +71,7 @@
       }
     printf ("DLD_FUNCTIONS_%s_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED_LDFLAG) %s $(OCT_LINK_OPTS)\n",
             basename, ldflags[i]);
-    printf ("DLD_FUNCTIONS_%s_la_LIBADD = liboctinterp.la ../liboctave/liboctave.la ../libcruft/libcruft.la %s $(OCT_LINK_DEPS)\n",
+    printf ("DLD_FUNCTIONS_%s_la_LIBADD = $(DLD_LIBOCTINTERP_LIBADD) ../liboctave/liboctave.la ../libcruft/libcruft.la %s $(OCT_LINK_DEPS)\n",
             basename, libraries[i]);
   }
 }
--- a/src/DLD-FUNCTIONS/conv2.cc
+++ b/src/DLD-FUNCTIONS/conv2.cc
@@ -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
 %! rand ("seed", 42);
@@ -281,7 +281,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
+++ b/src/DLD-FUNCTIONS/convhulln.cc
@@ -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/daspk.cc
+++ b/src/DLD-FUNCTIONS/daspk.cc
@@ -297,9 +297,9 @@
       if (f_arg.is_cell ())
         {
           Cell c = f_arg.cell_value ();
-          if (c.length() == 1)
+          if (c.length () == 1)
             f_arg = c(0);
-          else if (c.length() == 2)
+          else if (c.length () == 2)
             {
               if (c(0).is_function_handle () || c(0).is_inline_function ())
                 daspk_fcn = c(0).function_value ();
@@ -321,14 +321,14 @@
                     {
                       jac_name = unique_symbol_name ("__daspk_jac__");
                       jname = "function jac = ";
-                      jname.append(jac_name);
+                      jname.append (jac_name);
                       jname.append (" (x, xdot, t, cj) jac = ");
                       daspk_jac = extract_function
                         (c(1), "daspk", jac_name, jname, "; endfunction");
 
                       if (!daspk_jac)
                         {
-                          if (fcn_name.length())
+                          if (fcn_name.length ())
                             clear_function (fcn_name);
                           daspk_fcn = 0;
                         }
@@ -339,7 +339,7 @@
             DASPK_ABORT1 ("incorrect number of elements in cell array");
         }
 
-      if (!daspk_fcn && ! f_arg.is_cell())
+      if (!daspk_fcn && ! f_arg.is_cell ())
         {
           if (f_arg.is_function_handle () || f_arg.is_inline_function ())
             daspk_fcn = f_arg.function_value ();
@@ -377,7 +377,7 @@
                           {
                             jac_name = unique_symbol_name ("__daspk_jac__");
                             jname = "function jac = ";
-                            jname.append(jac_name);
+                            jname.append (jac_name);
                             jname.append (" (x, xdot, t, cj) jac = ");
                             daspk_jac = extract_function
                               (tmp(1), "daspk", jac_name, jname,
@@ -385,7 +385,7 @@
 
                             if (!daspk_jac)
                               {
-                                if (fcn_name.length())
+                                if (fcn_name.length ())
                                   clear_function (fcn_name);
                                 daspk_fcn = 0;
                               }
@@ -446,9 +446,9 @@
       else
         output = dae.integrate (out_times, deriv_output);
 
-      if (fcn_name.length())
+      if (fcn_name.length ())
         clear_function (fcn_name);
-      if (jac_name.length())
+      if (jac_name.length ())
         clear_function (jac_name);
 
       if (! error_state)
--- a/src/DLD-FUNCTIONS/dasrt.cc
+++ b/src/DLD-FUNCTIONS/dasrt.cc
@@ -385,9 +385,9 @@
   if (f_arg.is_cell ())
     {
       Cell c = f_arg.cell_value ();
-      if (c.length() == 1)
+      if (c.length () == 1)
         f_arg = c(0);
-      else if (c.length() == 2)
+      else if (c.length () == 2)
         {
           if (c(0).is_function_handle () || c(0).is_inline_function ())
             dasrt_f = c(0).function_value ();
@@ -409,14 +409,14 @@
                 {
                   jac_name = unique_symbol_name ("__dasrt_jac__");
                   jname = "function jac = ";
-                  jname.append(jac_name);
+                  jname.append (jac_name);
                   jname.append (" (x, xdot, t, cj) jac = ");
                   dasrt_j = extract_function
                     (c(1), "dasrt", jac_name, jname, "; endfunction");
 
                   if (!dasrt_j)
                     {
-                      if (fcn_name.length())
+                      if (fcn_name.length ())
                         clear_function (fcn_name);
                       dasrt_f = 0;
                     }
@@ -427,7 +427,7 @@
         DASRT_ABORT1 ("incorrect number of elements in cell array");
     }
 
-  if (!dasrt_f && ! f_arg.is_cell())
+  if (!dasrt_f && ! f_arg.is_cell ())
     {
       if (f_arg.is_function_handle () || f_arg.is_inline_function ())
         dasrt_f = f_arg.function_value ();
@@ -461,7 +461,7 @@
                       {
                         jac_name = unique_symbol_name ("__dasrt_jac__");
                         jname = "function jac = ";
-                        jname.append(jac_name);
+                        jname.append (jac_name);
                         jname.append (" (x, xdot, t, cj) jac = ");
                         dasrt_j = extract_function
                           (tmp(1), "dasrt", jac_name, jname, "; endfunction");
@@ -487,9 +487,9 @@
 
   argp++;
 
-  if (args(1).is_function_handle() || args(1).is_inline_function())
+  if (args(1).is_function_handle () || args(1).is_inline_function ())
     {
-      dasrt_cf = args(1).function_value();
+      dasrt_cf = args(1).function_value ();
 
       if (! dasrt_cf)
         DASRT_ABORT1 ("expecting function name as argument 2");
@@ -557,9 +557,9 @@
   else
     output = dae.integrate (out_times);
 
-  if (fcn_name.length())
+  if (fcn_name.length ())
     clear_function (fcn_name);
-  if (jac_name.length())
+  if (jac_name.length ())
     clear_function (jac_name);
 
   if (! error_state)
--- a/src/DLD-FUNCTIONS/dassl.cc
+++ b/src/DLD-FUNCTIONS/dassl.cc
@@ -298,9 +298,9 @@
       if (f_arg.is_cell ())
         {
           Cell c = f_arg.cell_value ();
-          if (c.length() == 1)
+          if (c.length () == 1)
             f_arg = c(0);
-          else if (c.length() == 2)
+          else if (c.length () == 2)
             {
               if (c(0).is_function_handle () || c(0).is_inline_function ())
                 dassl_fcn = c(0).function_value ();
@@ -322,14 +322,14 @@
                     {
                         jac_name = unique_symbol_name ("__dassl_jac__");
                         jname = "function jac = ";
-                        jname.append(jac_name);
+                        jname.append (jac_name);
                         jname.append (" (x, xdot, t, cj) jac = ");
                         dassl_jac = extract_function
                           (c(1), "dassl", jac_name, jname, "; endfunction");
 
                         if (!dassl_jac)
                           {
-                            if (fcn_name.length())
+                            if (fcn_name.length ())
                               clear_function (fcn_name);
                             dassl_fcn = 0;
                           }
@@ -340,7 +340,7 @@
             DASSL_ABORT1 ("incorrect number of elements in cell array");
         }
 
-      if (!dassl_fcn && ! f_arg.is_cell())
+      if (!dassl_fcn && ! f_arg.is_cell ())
         {
           if (f_arg.is_function_handle () || f_arg.is_inline_function ())
             dassl_fcn = f_arg.function_value ();
@@ -378,7 +378,7 @@
                           {
                             jac_name = unique_symbol_name ("__dassl_jac__");
                             jname = "function jac = ";
-                            jname.append(jac_name);
+                            jname.append (jac_name);
                             jname.append (" (x, xdot, t, cj) jac = ");
                             dassl_jac = extract_function
                               (tmp(1), "dassl", jac_name, jname,
@@ -386,7 +386,7 @@
 
                             if (!dassl_jac)
                               {
-                                if (fcn_name.length())
+                                if (fcn_name.length ())
                                   clear_function (fcn_name);
                                 dassl_fcn = 0;
                               }
@@ -448,9 +448,9 @@
       else
         output = dae.integrate (out_times, deriv_output);
 
-      if (fcn_name.length())
+      if (fcn_name.length ())
         clear_function (fcn_name);
-      if (jac_name.length())
+      if (jac_name.length ())
         clear_function (jac_name);
 
       if (! error_state)
@@ -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
+++ b/src/DLD-FUNCTIONS/det.cc
@@ -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
+++ b/src/DLD-FUNCTIONS/dlmread.cc
@@ -173,7 +173,7 @@
 The @var{range} parameter may be a 4-element vector containing the upper\n\
 left and lower right corner @code{[@var{R0},@var{C0},@var{R1},@var{C1}]}\n\
 where the lowest index value is zero.  Alternatively, a spreadsheet style\n\
-range such as 'A2..Q15' or 'T1:AA5' can be used.  The lowest alphabetical\n\
+range such as \"A2..Q15\" or \"T1:AA5\" can be used.  The lowest alphabetical\n\
 index 'A' refers to the first column.  The lowest row index is 1.\n\
 \n\
 @var{file} should be a file name or file id given by @code{fopen}.  In the\n\
@@ -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
+++ b/src/DLD-FUNCTIONS/dmperm.cc
@@ -48,7 +48,7 @@
 {
   RowVector ret (n);
   for (octave_idx_type i = 0; i < n; i++)
-    ret.xelem(i) = p[i] + 1;
+    ret.xelem (i) = p[i] + 1;
   return ret;
 }
 
@@ -70,14 +70,14 @@
   if (arg.is_real_type ())
     {
       m = arg.sparse_matrix_value ();
-      csm.nzmax = m.nnz();
+      csm.nzmax = m.nnz ();
       csm.p = m.xcidx ();
       csm.i = m.xridx ();
     }
   else
     {
       cm = arg.sparse_complex_matrix_value ();
-      csm.nzmax = cm.nnz();
+      csm.nzmax = cm.nnz ();
       csm.p = cm.xcidx ();
       csm.i = cm.xridx ();
     }
@@ -153,7 +153,7 @@
 @seealso{colamd, ccolamd}\n\
 @end deftypefn")
 {
-  int nargin = args.length();
+  int nargin = args.length ();
   octave_value_list retval;
 
   if (nargin != 1)
@@ -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,
@@ -202,7 +201,7 @@
 @seealso{dmperm}\n\
 @end deftypefn")
 {
-  int nargin = args.length();
+  int nargin = args.length ();
   octave_value_list retval;
 
   if (nargin != 1)
@@ -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
+++ b/src/DLD-FUNCTIONS/dot.cc
@@ -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, ,
@@ -262,9 +260,9 @@
 \n\
 @example\n\
 @group\n\
-  for i = 1:prod (size (@var{A})(3:end))\n\
-    @var{C}(:,:,i) = @var{A}(:,:,i) * @var{B}(:,:,i)\n\
-  endfor\n\
+for i = 1:prod (size (@var{A})(3:end))\n\
+  @var{C}(:,:,i) = @var{A}(:,:,i) * @var{B}(:,:,i)\n\
+endfor\n\
 @end group\n\
 @end example\n\
 @end deftypefn")
@@ -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
+++ b/src/DLD-FUNCTIONS/eig.cc
@@ -93,7 +93,7 @@
       else if (arg_is_empty > 0)
         return octave_value_list (2, Matrix ());
 
-      if (!(arg_b.is_single_type() || arg_b.is_double_type ()))
+      if (!(arg_b.is_single_type () || arg_b.is_double_type ()))
         {
           gripe_wrong_type_arg ("eig", arg_b);
           return retval;
@@ -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
+++ b/src/DLD-FUNCTIONS/eigs.cc
@@ -184,32 +184,32 @@
 @var{sigma} is a string, it must have one of the following values.\n\
 \n\
 @table @asis\n\
-@item 'lm'\n\
+@item \"lm\"\n\
 Largest Magnitude (default).\n\
 \n\
-@item 'sm'\n\
+@item \"sm\"\n\
 Smallest Magnitude.\n\
 \n\
-@item 'la'\n\
+@item \"la\"\n\
 Largest Algebraic (valid only for real symmetric problems).\n\
 \n\
-@item 'sa'\n\
+@item \"sa\"\n\
 Smallest Algebraic (valid only for real symmetric problems).\n\
 \n\
-@item 'be'\n\
+@item \"be\"\n\
 Both Ends, with one more from the high-end if @var{k} is odd (valid only for\n\
 real symmetric problems).\n\
 \n\
-@item 'lr'\n\
+@item \"lr\"\n\
 Largest Real part (valid only for complex or unsymmetric problems).\n\
 \n\
-@item 'sr'\n\
+@item \"sr\"\n\
 Smallest Real part (valid only for complex or unsymmetric problems).\n\
 \n\
-@item 'li'\n\
+@item \"li\"\n\
 Largest Imaginary part (valid only for complex or unsymmetric problems).\n\
 \n\
-@item 'si'\n\
+@item \"si\"\n\
 Smallest Imaginary part (valid only for complex or unsymmetric problems).\n\
 @end table\n\
 \n\
@@ -270,10 +270,10 @@
 \n\
 @table @code\n\
 @item A * x\n\
-if @var{sigma} is not given or is a string other than 'sm'.\n\
+if @var{sigma} is not given or is a string other than \"sm\".\n\
 \n\
 @item A \\ x\n\
-if @var{sigma} is 0 or 'sm'.\n\
+if @var{sigma} is 0 or \"sm\".\n\
 \n\
 @item (A - sigma * I) \\ x\n\
 for the standard eigenvalue problem, where @code{I} is the identity matrix of\n\
@@ -346,7 +346,7 @@
   if (call_depth > 1)
     {
       error ("eigs: invalid recursive call");
-      if (fcn_name.length())
+      if (fcn_name.length ())
         clear_function (fcn_name);
       return retval;
     }
@@ -393,11 +393,11 @@
         {
           if (args(0).is_sparse_type ())
             {
-              ascm = (args(0).sparse_complex_matrix_value());
+              ascm = (args(0).sparse_complex_matrix_value ());
               a_is_sparse = true;
             }
           else
-            acm = (args(0).complex_matrix_value());
+            acm = (args(0).complex_matrix_value ());
           a_is_complex = true;
           symmetric = false; // ARPACK doesn't special case complex symmetric
           sym_tested = true;
@@ -406,12 +406,12 @@
         {
           if (args(0).is_sparse_type ())
             {
-              asmm = (args(0).sparse_matrix_value());
+              asmm = (args(0).sparse_matrix_value ());
               a_is_sparse = true;
             }
           else
             {
-              amm = (args(0).matrix_value());
+              amm = (args(0).matrix_value ());
             }
         }
 
@@ -547,9 +547,9 @@
   if (!sym_tested && !have_a_fun)
     {
       if (a_is_sparse)
-        symmetric = asmm.is_symmetric();
+        symmetric = asmm.is_symmetric ();
       else
-        symmetric = amm.is_symmetric();
+        symmetric = amm.is_symmetric ();
     }
 
   if (have_b)
@@ -613,7 +613,7 @@
             }
 
           if (nargout < 2)
-            retval (0) = eig_val;
+            retval(0) = eig_val;
           else
             {
               retval(2) = double (info);
@@ -646,7 +646,7 @@
             }
 
           if (nargout < 2)
-            retval (0) = eig_val;
+            retval(0) = eig_val;
           else
             {
               retval(2) = double (info);
@@ -694,7 +694,7 @@
                 }
 
               if (nargout < 2)
-                retval (0) = eig_val;
+                retval(0) = eig_val;
               else
                 {
                   retval(2) = double (info);
@@ -740,7 +740,7 @@
                 }
 
               if (nargout < 2)
-                retval (0) = eig_val;
+                retval(0) = eig_val;
               else
                 {
                   retval(2) = double (info);
@@ -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
+++ b/src/DLD-FUNCTIONS/fft.cc
@@ -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;
+%! N = 64;
+%! n = 4;
 %! t = 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));
+%! answer = zeros (size (t));
 %! answer(n+1) = N/2;
 %! answer(N-n+1) = N/2;
 %!
-%! assert(S, answer, 4*N*eps);
+%! 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;
+%! 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 = 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
+++ b/src/DLD-FUNCTIONS/fft2.cc
@@ -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/fftw.cc
+++ b/src/DLD-FUNCTIONS/fftw.cc
@@ -34,10 +34,10 @@
 
 DEFUN_DLD (fftw, args, ,
   "-*- texinfo -*-\n\
-@deftypefn  {Loadable Function} {@var{method} =} fftw ('planner')\n\
-@deftypefnx {Loadable Function} {} fftw ('planner', @var{method})\n\
-@deftypefnx {Loadable Function} {@var{wisdom} =} fftw ('dwisdom')\n\
-@deftypefnx {Loadable Function} {} fftw ('dwisdom', @var{wisdom})\n\
+@deftypefn  {Loadable Function} {@var{method} =} fftw (\"planner\")\n\
+@deftypefnx {Loadable Function} {} fftw (\"planner\", @var{method})\n\
+@deftypefnx {Loadable Function} {@var{wisdom} =} fftw (\"dwisdom\")\n\
+@deftypefnx {Loadable Function} {} fftw (\"dwisdom\", @var{wisdom})\n\
 \n\
 Manage @sc{fftw} wisdom data.  Wisdom data can be used to significantly\n\
 accelerate the calculation of the FFTs, but implies an initial cost\n\
@@ -47,7 +47,7 @@
 the @code{fftw} function can be used to import wisdom.  For example,\n\
 \n\
 @example\n\
-@var{wisdom} = fftw ('dwisdom')\n\
+@var{wisdom} = fftw (\"dwisdom\")\n\
 @end example\n\
 \n\
 @noindent\n\
@@ -57,7 +57,7 @@
 reimported as follows\n\
 \n\
 @example\n\
-fftw ('dwisdom', @var{wisdom})\n\
+fftw (\"dwisdom\", @var{wisdom})\n\
 @end example\n\
 \n\
 If @var{wisdom} is an empty matrix, then the wisdom used is cleared.\n\
@@ -68,42 +68,42 @@
 wisdom can be treated:\n\
 \n\
 @table @asis\n\
-@item 'estimate'\n\
+@item \"estimate\"\n\
 Specifies that no run-time measurement of the optimal means of\n\
 calculating a particular is performed, and a simple heuristic is used\n\
 to pick a (probably sub-optimal) plan.  The advantage of this method is\n\
 that there is little or no overhead in the generation of the plan, which\n\
 is appropriate for a Fourier transform that will be calculated once.\n\
 \n\
-@item 'measure'\n\
+@item \"measure\"\n\
 In this case a range of algorithms to perform the transform is considered\n\
 and the best is selected based on their execution time.\n\
 \n\
-@item 'patient'\n\
-Similar to 'measure', but a wider range of algorithms is considered.\n\
+@item \"patient\"\n\
+Similar to \"measure\", but a wider range of algorithms is considered.\n\
 \n\
-@item 'exhaustive'\n\
-Like 'measure', but all possible algorithms that may be used to\n\
+@item \"exhaustive\"\n\
+Like \"measure\", but all possible algorithms that may be used to\n\
 treat the transform are considered.\n\
 \n\
-@item 'hybrid'\n\
+@item \"hybrid\"\n\
 As run-time measurement of the algorithm can be expensive, this is a\n\
-compromise where 'measure' is used for transforms up to the size of 8192\n\
-and beyond that the 'estimate' method is used.\n\
+compromise where \"measure\" is used for transforms up to the size of 8192\n\
+and beyond that the \"estimate\" method is used.\n\
 @end table\n\
 \n\
-The default method is 'estimate'.  The current method can\n\
+The default method is \"estimate\".  The current method can\n\
 be queried with\n\
 \n\
 @example\n\
-@var{method} = fftw ('planner')\n\
+@var{method} = fftw (\"planner\")\n\
 @end example\n\
 \n\
 @noindent\n\
 or set by using\n\
 \n\
 @example\n\
-fftw ('planner', @var{method})\n\
+fftw (\"planner\", @var{method})\n\
 @end example\n\
 \n\
 Note that calculated wisdom will be lost when restarting Octave.  However,\n\
@@ -115,7 +115,7 @@
 {
   octave_value retval;
 
-  int nargin = args.length();
+  int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2)
     {
@@ -196,9 +196,9 @@
                     {
                       char *str = fftw_export_wisdom_to_string ();
 
-                      if (arg1.length() < 1)
+                      if (arg1.length () < 1)
                         fftw_forget_wisdom ();
-                      else if (! fftw_import_wisdom_from_string (arg1.c_str()))
+                      else if (! fftw_import_wisdom_from_string (arg1.c_str ()))
                         error ("could not import supplied WISDOM");
 
                       if (!error_state)
@@ -210,9 +210,9 @@
                     {
                       char *str = fftwf_export_wisdom_to_string ();
 
-                      if (arg1.length() < 1)
+                      if (arg1.length () < 1)
                         fftwf_forget_wisdom ();
-                      else if (! fftwf_import_wisdom_from_string (arg1.c_str()))
+                      else if (! fftwf_import_wisdom_from_string (arg1.c_str ()))
                         error ("could not import supplied WISDOM");
 
                       if (!error_state)
--- a/src/DLD-FUNCTIONS/filter.cc
+++ b/src/DLD-FUNCTIONS/filter.cc
@@ -252,7 +252,7 @@
 MArray<T>
 filter (MArray<T>& b, MArray<T>& a, MArray<T>& x, int dim = -1)
 {
-  dim_vector x_dims = x.dims();
+  dim_vector x_dims = x.dims ();
 
   if (dim < 0)
     {
@@ -304,9 +304,9 @@
 \n\
 @smallexample\n\
 @group\n\
-   N                   M\n\
-  SUM a(k+1) y(n-k) = SUM b(k+1) x(n-k)      for 1<=n<=length(x)\n\
-  k=0                 k=0\n\
+ N                   M\n\
+SUM a(k+1) y(n-k) = SUM b(k+1) x(n-k)    for 1<=n<=length(x)\n\
+k=0                 k=0\n\
 @end group\n\
 @end smallexample\n\
 \n\
@@ -315,13 +315,15 @@
 @noindent\n\
 where\n\
 @ifnottex\n\
- N=length(a)-1 and M=length(b)-1.\n\
+N=length(a)-1 and M=length(b)-1.\n\
 @end ifnottex\n\
 @tex\n\
- $a \\in \\Re^{N-1}$, $b \\in \\Re^{M-1}$, and $x \\in \\Re^P$.\n\
+$a \\in \\Re^{N-1}$, $b \\in \\Re^{M-1}$, and $x \\in \\Re^P$.\n\
 @end tex\n\
-over the first non-singleton dimension of @var{x} or over @var{dim} if\n\
-supplied.  An equivalent form of this equation is:\n\
+The result is calculated over the first non-singleton dimension of @var{x}\n\
+or over @var{dim} if supplied.\n\
+\n\
+An equivalent form of the equation is:\n\
 @tex\n\
 $$\n\
 y_n = -\\sum_{k=1}^N c_{k+1} y_{n-k} + \\sum_{k=0}^M d_{k+1} x_{n-k}, \\qquad\n\
@@ -333,9 +335,9 @@
 \n\
 @smallexample\n\
 @group\n\
-            N                   M\n\
-  y(n) = - SUM c(k+1) y(n-k) + SUM d(k+1) x(n-k)  for 1<=n<=length(x)\n\
-           k=1                 k=0\n\
+          N                   M\n\
+y(n) = - SUM c(k+1) y(n-k) + SUM d(k+1) x(n-k)  for 1<=n<=length(x)\n\
+         k=1                 k=0\n\
 @end group\n\
 @end smallexample\n\
 \n\
@@ -370,13 +372,13 @@
 \n\
 @example\n\
 @group\n\
-             M\n\
-            SUM d(k+1) z^(-k)\n\
-            k=0\n\
-  H(z) = ----------------------\n\
-               N\n\
-          1 + SUM c(k+1) z^(-k)\n\
-              k=1\n\
+          M\n\
+         SUM d(k+1) z^(-k)\n\
+         k=0\n\
+H(z) = ---------------------\n\
+            N\n\
+       1 + SUM c(k+1) z^(-k)\n\
+           k=1\n\
 @end group\n\
 @end example\n\
 \n\
@@ -401,7 +403,7 @@
 
   if (nargin == 5)
     {
-      dim = args(4).nint_value() - 1;
+      dim = args(4).nint_value () - 1;
       if (dim < 0 || dim >= x_dims.length ())
         {
           error ("filter: DIM must be a valid dimension");
@@ -661,73 +663,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
+++ b/src/DLD-FUNCTIONS/find.cc
@@ -89,9 +89,9 @@
   octave_value_list retval ((nargout == 0 ? 1 : nargout), Matrix ());
 
 
-  octave_idx_type nc = v.cols();
-  octave_idx_type nr = v.rows();
-  octave_idx_type nz = v.nnz();
+  octave_idx_type nc = v.cols ();
+  octave_idx_type nr = v.rows ();
+  octave_idx_type nz = v.nnz ();
 
   // Search in the default range.
   octave_idx_type start_nc = -1;
@@ -111,9 +111,9 @@
       for (octave_idx_type j = 0; j < nc; j++)
         {
           OCTAVE_QUIT;
-          if (v.cidx(j) == 0 && v.cidx(j+1) != 0)
+          if (v.cidx (j) == 0 && v.cidx (j+1) != 0)
             start_nc = j;
-          if (v.cidx(j+1) >= n_to_find)
+          if (v.cidx (j+1) >= n_to_find)
             {
               end_nc = j + 1;
               break;
@@ -125,9 +125,9 @@
       for (octave_idx_type j = nc; j > 0; j--)
         {
           OCTAVE_QUIT;
-          if (v.cidx(j) == nz && v.cidx(j-1) != nz)
+          if (v.cidx (j) == nz && v.cidx (j-1) != nz)
             end_nc = j;
-          if (nz - v.cidx(j-1) >= n_to_find)
+          if (nz - v.cidx (j-1) >= n_to_find)
             {
               start_nc = j - 1;
               break;
@@ -135,8 +135,8 @@
         }
     }
 
-  count = (n_to_find > v.cidx(end_nc) - v.cidx(start_nc) ?
-           v.cidx(end_nc) - v.cidx(start_nc) : n_to_find);
+  count = (n_to_find > v.cidx (end_nc) - v.cidx (start_nc) ?
+           v.cidx (end_nc) - v.cidx (start_nc) : n_to_find);
 
   // If the original argument was a row vector, force a row vector of
   // the overall indices to be returned.  But see below for scalar
@@ -168,14 +168,14 @@
       // there are elements to be found using the count that we want
       // to find.
       for (octave_idx_type j = start_nc, cx = 0; j < end_nc; j++)
-        for (octave_idx_type i = v.cidx(j); i < v.cidx(j+1); i++ )
+        for (octave_idx_type i = v.cidx (j); i < v.cidx (j+1); i++ )
           {
             OCTAVE_QUIT;
             if (direction < 0 && i < nz - count)
               continue;
-            i_idx(cx) = static_cast<double> (v.ridx(i) + 1);
+            i_idx(cx) = static_cast<double> (v.ridx (i) + 1);
             j_idx(cx) = static_cast<double> (j + 1);
-            idx(cx) = j * nr + v.ridx(i) + 1;
+            idx(cx) = j * nr + v.ridx (i) + 1;
             val(cx) = v.data(i);
             cx++;
             if (cx == count)
@@ -231,7 +231,7 @@
   // There are far fewer special cases to handle for a PermMatrix.
   octave_value_list retval ((nargout == 0 ? 1 : nargout), Matrix ());
 
-  octave_idx_type nc = v.cols();
+  octave_idx_type nc = v.cols ();
   octave_idx_type start_nc, count;
 
   // Determine the range to search.
@@ -347,7 +347,7 @@
 @example\n\
 @group\n\
 find (eye (2))\n\
-     @result{} [ 1; 4 ]\n\
+  @result{} [ 1; 4 ]\n\
 @end group\n\
 @end example\n\
 \n\
@@ -357,8 +357,8 @@
 @example\n\
 @group\n\
 [i, j] = find (2 * eye (2))\n\
-     @result{} i = [ 1; 2 ]\n\
-     @result{} j = [ 1; 2 ]\n\
+    @result{} i = [ 1; 2 ]\n\
+    @result{} j = [ 1; 2 ]\n\
 @end group\n\
 @end example\n\
 \n\
@@ -368,9 +368,9 @@
 @example\n\
 @group\n\
 [i, j, v] = find (3 * eye (2))\n\
-     @result{} i = [ 1; 2 ]\n\
-     @result{} j = [ 1; 2 ]\n\
-     @result{} v = [ 3; 3 ]\n\
+       @result{} i = [ 1; 2 ]\n\
+       @result{} j = [ 1; 2 ]\n\
+       @result{} v = [ 3; 3 ]\n\
 @end group\n\
 @end example\n\
 \n\
@@ -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
+++ b/src/DLD-FUNCTIONS/gammainc.cc
@@ -47,11 +47,11 @@
 \n\
 @example\n\
 @group\n\
-                                 x\n\
-                       1        /\n\
+                                x\n\
+                       1       /\n\
 gammainc (x, a) = ---------    | exp (-t) t^(a-1) dt\n\
-                   gamma (a)    /\n\
-                             t=0\n\
+                  gamma (a)    /\n\
+                            t=0\n\
 @end group\n\
 @end example\n\
 \n\
@@ -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
+++ b/src/DLD-FUNCTIONS/gcd.cc
@@ -76,8 +76,8 @@
 static std::complex<FP>
 simple_gcd (const std::complex<FP>& a, const std::complex<FP>& b)
 {
-  if (! xisinteger (a.real ()) || ! xisinteger(a.imag ())
-      || ! xisinteger (b.real ()) || ! xisinteger(b.imag ()))
+  if (! xisinteger (a.real ()) || ! xisinteger (a.imag ())
+      || ! xisinteger (b.real ()) || ! xisinteger (b.imag ()))
     (*current_liboctave_error_handler)
       ("gcd: all complex parts must be integers");
 
@@ -156,8 +156,8 @@
 extended_gcd (const std::complex<FP>& a, const std::complex<FP>& b,
               std::complex<FP>& x, std::complex<FP>& y)
 {
-  if (! xisinteger (a.real ()) || ! xisinteger(a.imag ())
-      || ! xisinteger (b.real ()) || ! xisinteger(b.imag ()))
+  if (! xisinteger (a.real ()) || ! xisinteger (a.imag ())
+      || ! xisinteger (b.real ()) || ! xisinteger (b.imag ()))
     (*current_liboctave_error_handler)
       ("gcd: all complex parts must be integers");
 
@@ -443,15 +443,14 @@
 individually.  All elements must be ordinary or Gaussian (complex)\n\
 integers.  Note that for Gaussian integers, the gcd is not unique up to\n\
 units (multiplication by 1, -1, @var{i} or -@var{i}), so an arbitrary\n\
-greatest common divisor amongst four possible is returned.  For example,\n\
+greatest common divisor amongst four possible is returned.\n\
 \n\
-@noindent\n\
-and\n\
+Example code:\n\
 \n\
 @example\n\
 @group\n\
 gcd ([15, 9], [20, 18])\n\
-    @result{}  5  9\n\
+   @result{}  5  9\n\
 @end group\n\
 @end example\n\
 \n\
@@ -516,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
+++ b/src/DLD-FUNCTIONS/givens.cc
@@ -56,8 +56,8 @@
 @example\n\
 @group\n\
 givens (1, 1)\n\
-     @result{}   0.70711   0.70711\n\
-         -0.70711   0.70711\n\
+   @result{}   0.70711   0.70711\n\
+       -0.70711   0.70711\n\
 @end group\n\
 @end example\n\
 @end deftypefn")
@@ -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
+++ b/src/DLD-FUNCTIONS/hess.cc
@@ -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
+++ b/src/DLD-FUNCTIONS/hex2num.cc
@@ -44,8 +44,8 @@
 \n\
 @example\n\
 @group\n\
-hex2num ([\"4005bf0a8b145769\";\"4024000000000000\"])\n\
-@result{} [2.7183; 10.000]\n\
+hex2num ([\"4005bf0a8b145769\"; \"4024000000000000\"])\n\
+   @result{} [2.7183; 10.000]\n\
 @end group\n\
 @end example\n\
 @seealso{num2hex, hex2dec, dec2hex}\n\
@@ -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, ,
@@ -130,7 +130,7 @@
 \n\
 @example\n\
 @group\n\
-num2hex ([-1, 1, e, Inf, NaN, NA]);\n\
+num2hex ([-1, 1, e, Inf, NaN, NA])\n\
 @result{} \"bff0000000000000\n\
     3ff0000000000000\n\
     4005bf0a8b145769\n\
@@ -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
+++ b/src/DLD-FUNCTIONS/inv.cc
@@ -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
+++ b/src/DLD-FUNCTIONS/kron.cc
@@ -82,13 +82,13 @@
   octave_idx_type nra = a.rows (), nrb = b.rows (), dla = a.diag_length ();
   octave_idx_type nca = a.cols (), ncb = b.cols ();
 
-  MArray<T> c (dim_vector (nra*nrb, nca*ncb), T());
+  MArray<T> c (dim_vector (nra*nrb, nca*ncb), T ());
 
   for (octave_idx_type ja = 0; ja < dla; ja++)
     for (octave_idx_type jb = 0; jb < ncb; jb++)
       {
         octave_quit ();
-        mx_inline_mul (nrb, &c.xelem(ja*nrb, ja*ncb + jb), a.dgelem (ja), b.data () + nrb*jb);
+        mx_inline_mul (nrb, &c.xelem (ja*nrb, ja*ncb + jb), a.dgelem (ja), b.data () + nrb*jb);
       }
 
   return c;
@@ -110,7 +110,7 @@
         octave_quit ();
         for (octave_idx_type Ai = A.cidx (Aj); Ai < A.cidx (Aj+1); Ai++)
           {
-            octave_idx_type Ci = A.ridx(Ai) * B.rows ();
+            octave_idx_type Ci = A.ridx (Ai) * B.rows ();
             const T v = A.data (Ai);
 
             for (octave_idx_type Bi = B.cidx (Bj); Bi < B.cidx (Bj+1); Bi++)
@@ -250,7 +250,7 @@
 block as\n\
 \n\
 @example\n\
-x = [a(i, j) b]\n\
+x = [ a(i,j)*b ]\n\
 @end example\n\
 \n\
 For example:\n\
@@ -258,9 +258,9 @@
 @example\n\
 @group\n\
 kron (1:4, ones (3, 1))\n\
-      @result{}  1  2  3  4\n\
-          1  2  3  4\n\
-          1  2  3  4\n\
+     @result{}  1  2  3  4\n\
+         1  2  3  4\n\
+         1  2  3  4\n\
 @end group\n\
 @end example\n\
 \n\
@@ -295,8 +295,8 @@
 
 /*
 %!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];
@@ -306,7 +306,6 @@
 %!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
--- a/src/DLD-FUNCTIONS/lookup.cc
+++ b/src/DLD-FUNCTIONS/lookup.cc
@@ -70,7 +70,7 @@
 {
   return std::lexicographical_compare (a.begin (), a.end (),
                                        b.begin (), b.end (),
-                                       icmp_char_lt());
+                                       icmp_char_lt ());
 }
 
 // case-insensitive descending comparator
@@ -79,7 +79,7 @@
 {
   return std::lexicographical_compare (a.begin (), a.end (),
                                        b.begin (), b.end (),
-                                       icmp_char_gt());
+                                       icmp_char_gt ());
 }
 #endif
 
@@ -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
+++ b/src/DLD-FUNCTIONS/lsode.cc
@@ -171,7 +171,7 @@
 @example\n\
 @group\n\
 dx\n\
--- = f(x, t)\n\
+-- = f (x, t)\n\
 dt\n\
 @end group\n\
 @end example\n\
@@ -298,9 +298,9 @@
       if (f_arg.is_cell ())
         {
           Cell c = f_arg.cell_value ();
-          if (c.length() == 1)
+          if (c.length () == 1)
             f_arg = c(0);
-          else if (c.length() == 2)
+          else if (c.length () == 2)
             {
               if (c(0).is_function_handle () || c(0).is_inline_function ())
                 lsode_fcn = c(0).function_value ();
@@ -322,14 +322,14 @@
                     {
                         jac_name = unique_symbol_name ("__lsode_jac__");
                         jname = "function jac = ";
-                        jname.append(jac_name);
+                        jname.append (jac_name);
                         jname.append (" (x, t) jac = ");
                         lsode_jac = extract_function
                           (c(1), "lsode", jac_name, jname, "; endfunction");
 
                       if (!lsode_jac)
                         {
-                          if (fcn_name.length())
+                          if (fcn_name.length ())
                             clear_function (fcn_name);
                           lsode_fcn = 0;
                         }
@@ -340,7 +340,7 @@
             LSODE_ABORT1 ("incorrect number of elements in cell array");
         }
 
-      if (!lsode_fcn && ! f_arg.is_cell())
+      if (!lsode_fcn && ! f_arg.is_cell ())
         {
           if (f_arg.is_function_handle () || f_arg.is_inline_function ())
             lsode_fcn = f_arg.function_value ();
@@ -378,7 +378,7 @@
                           {
                             jac_name = unique_symbol_name ("__lsode_jac__");
                             jname = "function jac = ";
-                            jname.append(jac_name);
+                            jname.append (jac_name);
                             jname.append (" (x, t) jac = ");
                             lsode_jac = extract_function
                               (tmp(1), "lsode", jac_name, jname,
@@ -386,7 +386,7 @@
 
                             if (!lsode_jac)
                               {
-                                if (fcn_name.length())
+                                if (fcn_name.length ())
                                   clear_function (fcn_name);
                                 lsode_fcn = 0;
                               }
@@ -444,9 +444,9 @@
       else
         output = ode.integrate (out_times);
 
-      if (fcn_name.length())
+      if (fcn_name.length ())
         clear_function (fcn_name);
-      if (jac_name.length())
+      if (jac_name.length ())
         clear_function (jac_name);
 
       if (! error_state)
@@ -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
+++ b/src/DLD-FUNCTIONS/lu.cc
@@ -69,7 +69,7 @@
 @deftypefnx {Loadable Function} {[@var{L}, @var{U}, @var{P}, @var{Q}, @var{R}] =} lu (@var{S})\n\
 @deftypefnx {Loadable Function} {[@dots{}] =} lu (@var{S}, @var{thres})\n\
 @deftypefnx {Loadable Function} {@var{y} =} lu (@dots{})\n\
-@deftypefnx {Loadable Function} {[@dots{}] =} lu (@dots{}, 'vector')\n\
+@deftypefnx {Loadable Function} {[@dots{}] =} lu (@dots{}, \"vector\")\n\
 @cindex LU decomposition\n\
 Compute the LU@tie{}decomposition of @var{A}.  If @var{A} is full\n\
 subroutines from\n\
@@ -125,7 +125,7 @@
 pivoting strategy and the second for the symmetric strategy.  By default,\n\
 the values defined by @code{spparms} are used ([0.1, 0.001]).\n\
 \n\
-Given the string argument 'vector', @code{lu} returns the values of @var{P}\n\
+Given the string argument \"vector\", @code{lu} returns the values of @var{P}\n\
 and @var{Q} as vector values, such that for full matrix, @code{@var{A}\n\
 (@var{P},:) = @var{L} * @var{U}}, and @code{@var{R}(@var{P},:) * @var{A}\n\
 (:, @var{Q}) = @var{L} * @var{U}}.\n\
@@ -179,7 +179,7 @@
                 error ("lu: can not define pivoting threshold THRES for full matrices");
               else if (tmp.nelem () == 1)
                 {
-                  thres.resize(1,2);
+                  thres.resize (1,2);
                   thres(0) = tmp(0);
                   thres(1) = tmp(0);
                 }
@@ -226,7 +226,7 @@
                 SparseLU fact (m, Qinit, thres, false, true);
 
                 if (nargout < 2)
-                  retval (0) = fact.Y ();
+                  retval(0) = fact.Y ();
                 else
                   {
                     PermMatrix P = fact.Pr_mat ();
@@ -246,7 +246,7 @@
                 SparseLU fact (m, Qinit, thres, false, true);
 
                 if (vecout)
-                  retval (2) = fact.Pr_vec ();
+                  retval(2) = fact.Pr_vec ();
                 else
                   retval(2) = fact.Pr_mat ();
 
@@ -296,7 +296,7 @@
                 SparseComplexLU fact (m, Qinit, thres, false, true);
 
                 if (nargout < 2)
-                  retval (0) = fact.Y ();
+                  retval(0) = fact.Y ();
                 else
                   {
                     PermMatrix P = fact.Pr_mat ();
@@ -316,7 +316,7 @@
                 SparseComplexLU fact (m, Qinit, thres, false, true);
 
                 if (vecout)
-                  retval (2) = fact.Pr_vec ();
+                  retval(2) = fact.Pr_vec ();
                 else
                   retval(2) = fact.Pr_mat ();
 
@@ -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,
@@ -612,7 +610,7 @@
 as obtained by @code{lu}:\n\
 \n\
 @example\n\
-  [@var{L}, @var{U}, @var{P}] = lu (@var{A});\n\
+[@var{L}, @var{U}, @var{P}] = lu (@var{A});\n\
 @end example\n\
 \n\
 @noindent\n\
@@ -620,14 +618,14 @@
 either as\n\
 \n\
 @example\n\
-  [@var{L1}, @var{U1}] = lu (@var{L}, @var{U}, @var{P}*@var{x}, @var{y})\n\
+[@var{L1}, @var{U1}] = lu (@var{L}, @var{U}, @var{P}*@var{x}, @var{y})\n\
 @end example\n\
 \n\
 @noindent\n\
 or\n\
 \n\
 @example\n\
-  [@var{L1}, @var{U1}, @var{P1}] = lu (@var{L}, @var{U}, @var{P}, @var{x}, @var{y})\n\
+[@var{L1}, @var{U1}, @var{P1}] = lu (@var{L}, @var{U}, @var{P}, @var{x}, @var{y})\n\
 @end example\n\
 \n\
 The first form uses the unpivoted algorithm, which is faster, but less\n\
@@ -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
+++ b/src/DLD-FUNCTIONS/luinc.cc
@@ -91,7 +91,7 @@
 All other fields in @var{opts} are ignored.  The outputs from @code{luinc}\n\
 are the same as for @code{lu}.\n\
 \n\
-Given the string argument 'vector', @code{luinc} returns the values of\n\
+Given the string argument \"vector\", @code{luinc} returns the values of\n\
 @var{p} @var{q} as vector values.\n\
 @seealso{sparse, lu}\n\
 @end deftypefn")
@@ -154,7 +154,7 @@
 
                   if (thresh.nelem () == 1)
                     {
-                      thresh.resize(1,2);
+                      thresh.resize (1,2);
                       thresh(1) = thresh(0);
                     }
                   else if (thresh.nelem () != 2)
@@ -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
+++ b/src/DLD-FUNCTIONS/matrix_type.cc
@@ -39,59 +39,59 @@
 DEFUN_DLD (matrix_type, args, ,
   "-*- texinfo -*-\n\
 @deftypefn  {Loadable Function} {@var{type} =} matrix_type (@var{A})\n\
-@deftypefnx {Loadable Function} {@var{type} =} matrix_type (@var{A}, 'nocompute')\n\
+@deftypefnx {Loadable Function} {@var{type} =} matrix_type (@var{A}, \"nocompute\")\n\
 @deftypefnx {Loadable Function} {@var{A} =} matrix_type (@var{A}, @var{type})\n\
-@deftypefnx {Loadable Function} {@var{A} =} matrix_type (@var{A}, 'upper', @var{perm})\n\
-@deftypefnx {Loadable Function} {@var{A} =} matrix_type (@var{A}, 'lower', @var{perm})\n\
-@deftypefnx {Loadable Function} {@var{A} =} matrix_type (@var{A}, 'banded', @var{nl}, @var{nu})\n\
+@deftypefnx {Loadable Function} {@var{A} =} matrix_type (@var{A}, \"upper\", @var{perm})\n\
+@deftypefnx {Loadable Function} {@var{A} =} matrix_type (@var{A}, \"lower\", @var{perm})\n\
+@deftypefnx {Loadable Function} {@var{A} =} matrix_type (@var{A}, \"banded\", @var{nl}, @var{nu})\n\
 Identify the matrix type or mark a matrix as a particular type.  This allows\n\
 more rapid solutions of linear equations involving @var{A} to be performed.\n\
 Called with a single argument, @code{matrix_type} returns the type of the\n\
 matrix and caches it for future use.  Called with more than one argument,\n\
 @code{matrix_type} allows the type of the matrix to be defined.\n\
 \n\
-If the option 'nocompute' is given, the function will not attempt to guess\n\
+If the option \"nocompute\" is given, the function will not attempt to guess\n\
 the type if it is still unknown.  This is useful for debugging purposes.\n\
 \n\
 The possible matrix types depend on whether the matrix is full or sparse, and\n\
 can be one of the following\n\
 \n\
 @table @asis\n\
-@item 'unknown'\n\
+@item \"unknown\"\n\
 Remove any previously cached matrix type, and mark type as unknown.\n\
 \n\
-@item 'full'\n\
+@item \"full\"\n\
 Mark the matrix as full.\n\
 \n\
-@item 'positive definite'\n\
+@item \"positive definite\"\n\
 Probable full positive definite matrix.\n\
 \n\
-@item 'diagonal'\n\
+@item \"diagonal\"\n\
 Diagonal matrix.  (Sparse matrices only)\n\
 \n\
-@item 'permuted diagonal'\n\
+@item \"permuted diagonal\"\n\
 Permuted Diagonal matrix.  The permutation does not need to be specifically\n\
 indicated, as the structure of the matrix explicitly gives this.  (Sparse\n\
 matrices only)\n\
 \n\
-@item 'upper'\n\
+@item \"upper\"\n\
 Upper triangular.  If the optional third argument @var{perm} is given, the\n\
 matrix is assumed to be a permuted upper triangular with the permutations\n\
 defined by the vector @var{perm}.\n\
 \n\
-@item 'lower'\n\
+@item \"lower\"\n\
 Lower triangular.  If the optional third argument @var{perm} is given, the\n\
 matrix is assumed to be a permuted lower triangular with the permutations\n\
 defined by the vector @var{perm}.\n\
 \n\
-@item 'banded'\n\
-@itemx 'banded positive definite'\n\
+@item \"banded\"\n\
+@itemx \"banded positive definite\"\n\
 Banded matrix with the band size of @var{nl} below the diagonal and @var{nu}\n\
 above it.  If @var{nl} and @var{nu} are 1, then the matrix is tridiagonal and\n\
 treated with specialized code.  In addition the matrix can be marked as\n\
 probably a positive definite.  (Sparse matrices only)\n\
 \n\
-@item 'singular'\n\
+@item \"singular\"\n\
 The matrix is assumed to be singular and will be treated with a minimum norm\n\
 solution.\n\
 \n\
@@ -129,7 +129,7 @@
           autocomp = false;
         }
 
-      if (args(0).is_scalar_type())
+      if (args(0).is_scalar_type ())
         {
           if (nargin == 1)
             retval = octave_value ("Diagonal");
@@ -198,7 +198,7 @@
                 retval = octave_value ("Positive Definite");
               else if (typ == MatrixType::Rectangular)
                 {
-                  if (args(0).rows() == args(0).columns())
+                  if (args(0).rows () == args(0).columns ())
                     retval = octave_value ("Singular");
                   else
                     retval = octave_value ("Rectangular");
@@ -270,7 +270,7 @@
                   else if (str_typ == "unknown")
                     mattyp.invalidate_type ();
                   else
-                    error ("matrix_type: Unknown matrix type %s", str_typ.c_str());
+                    error ("matrix_type: Unknown matrix type %s", str_typ.c_str ());
 
                   if (! error_state)
                     {
@@ -394,7 +394,7 @@
                 retval = octave_value ("Positive Definite");
               else if (typ == MatrixType::Rectangular)
                 {
-                  if (args(0).rows() == args(0).columns())
+                  if (args(0).rows () == args(0).columns ())
                     retval = octave_value ("Singular");
                   else
                     retval = octave_value ("Rectangular");
@@ -436,7 +436,7 @@
                   else if (str_typ == "unknown")
                     mattyp.invalidate_type ();
                   else
-                    error ("matrix_type: Unknown matrix type %s", str_typ.c_str());
+                    error ("matrix_type: Unknown matrix type %s", str_typ.c_str ());
 
                   if (! error_state)
                     {
@@ -477,7 +477,7 @@
                           // Set the matrix type
                           if (args(0).is_single_type ())
                             {
-                              if (args(0).is_complex_type())
+                              if (args(0).is_complex_type ())
                                 retval = octave_value
                                   (args(0).float_complex_matrix_value (),
                                    mattyp);
@@ -488,7 +488,7 @@
                             }
                           else
                             {
-                              if (args(0).is_complex_type())
+                              if (args(0).is_complex_type ())
                                 retval = octave_value
                                   (args(0).complex_matrix_value (),
                                    mattyp);
@@ -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
+++ b/src/DLD-FUNCTIONS/max.cc
@@ -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>
@@ -576,7 +559,7 @@
 @example\n\
 @group\n\
 cummin ([5 4 6 2 3 1])\n\
-    @result{}  5  4  4  2  2  1\n\
+   @result{}  5  4  4  2  2  1\n\
 @end group\n\
 @end example\n\
 \n\
@@ -618,7 +601,7 @@
 @example\n\
 @group\n\
 cummax ([1 3 2 6 4 5])\n\
-    @result{}  1  3  3  6  6  6\n\
+   @result{}  1  3  3  6  6  6\n\
 @end group\n\
 @end example\n\
 \n\
--- a/src/DLD-FUNCTIONS/md5sum.cc
+++ b/src/DLD-FUNCTIONS/md5sum.cc
@@ -49,14 +49,14 @@
   int nargin = args.length ();
 
   if (nargin != 1 && nargin != 2)
-    print_usage();
+    print_usage ();
   else
     {
       bool have_str = false;
-      std::string str = args(0).string_value();
+      std::string str = args(0).string_value ();
 
       if (nargin == 2)
-        have_str = args(1).bool_value();
+        have_str = args(1).bool_value ();
 
       if (!error_state)
         {
--- a/src/DLD-FUNCTIONS/mgorth.cc
+++ b/src/DLD-FUNCTIONS/mgorth.cc
@@ -67,7 +67,7 @@
 {
   octave_value_list retval;
 
-  int nargin = args.length();
+  int nargin = args.length ();
 
   if (nargin != 2 || nargout > 2)
   {
@@ -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
+++ b/src/DLD-FUNCTIONS/nproc.cc
@@ -35,6 +35,7 @@
 \n\
 If called with the optional argument @var{query}, modify how processors\n\
 are counted as follows:\n\
+\n\
 @table @code\n\
 @item all\n\
 total number of processors.\n\
@@ -84,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
+++ b/src/DLD-FUNCTIONS/qr.cc
@@ -113,7 +113,7 @@
 @ifnottex\n\
 \n\
 @example\n\
-@code{min norm(A x - b)}\n\
+min norm(A x - b)\n\
 @end example\n\
 \n\
 @end ifnottex\n\
@@ -200,7 +200,7 @@
 
   int nargin = args.length ();
 
-  if (nargin < 1 || nargin > (args(0).is_sparse_type() ? 3 : 2))
+  if (nargin < 1 || nargin > (args(0).is_sparse_type () ? 3 : 2))
     {
       print_usage ();
       return retval;
@@ -250,7 +250,7 @@
                     {
                       retval(1) = q.R (economy);
                       retval(0) = q.C (args(have_b).complex_matrix_value ());
-                      if (arg.rows() < arg.columns())
+                      if (arg.rows () < arg.columns ())
                         warning ("qr: non minimum norm solution for under-determined problem");
                     }
                   else if (nargout > 1)
@@ -271,7 +271,7 @@
                     {
                       retval(1) = q.R (economy);
                       retval(0) = q.C (args(have_b).matrix_value ());
-                      if (args(0).rows() < args(0).columns())
+                      if (args(0).rows () < args(0).columns ())
                         warning ("qr: non minimum norm solution for under-determined problem");
                     }
                   else if (nargout > 1)
@@ -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, ,
@@ -1176,7 +1161,7 @@
 @var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization of\n\
 @w{[A(:,1:j-1) A(:,j+1:n)]}, i.e., @var{A} with one column deleted\n\
 (if @var{orient} is \"col\"), or the QR@tie{}factorization of\n\
-@w{[A(1:j-1,:);A(j+1:n,:)]}, i.e., @var{A} with one row deleted (if\n   \
+@w{[A(1:j-1,:);A(j+1:n,:)]}, i.e., @var{A} with one row deleted (if\n\
 @var{orient} is \"row\").\n\
 \n\
 The default value of @var{orient} is \"col\".\n\
@@ -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
+++ b/src/DLD-FUNCTIONS/quad.cc
@@ -150,7 +150,7 @@
 #define QUAD_ABORT() \
   do \
     { \
-      if (fcn_name.length()) \
+      if (fcn_name.length ()) \
         clear_function (fcn_name); \
       return retval; \
     } \
@@ -192,7 +192,7 @@
 absolute tolerance, and the second element is the desired relative\n\
 tolerance.  To choose a relative test only, set the absolute\n\
 tolerance to zero.  To choose an absolute test only, set the relative\n\
-tolerance to zero.  Both tolerances default to @code{sqrt(eps)} or\n\
+tolerance to zero.  Both tolerances default to @code{sqrt (eps)} or\n\
 approximately @math{1.5e^{-8}}.\n\
 \n\
 The optional argument @var{sing} is a vector of values at which the\n\
@@ -463,7 +463,7 @@
           retval(0) = val;
         }
 
-      if (fcn_name.length())
+      if (fcn_name.length ())
         clear_function (fcn_name);
     }
   else
@@ -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
+++ b/src/DLD-FUNCTIONS/quadcc.cc
@@ -1485,7 +1485,7 @@
 values if given a vector of input values.  For example,\n\
 \n\
 @example\n\
-   f = @@(x) x .* sin (1./x) .* sqrt (abs (1 - x));\n\
+f = @@(x) x .* sin (1./x) .* sqrt (abs (1 - x));\n\
 @end example\n\
 \n\
 @noindent\n\
@@ -1493,7 +1493,7 @@
 \n\
 @var{a} and @var{b} are the lower and upper limits of integration.  Either\n\
 or both limits may be infinite.  @code{quadcc} handles an inifinite limit\n\
-by substituting the variable of integration with @code{x=tan(pi/2*u)}.\n\
+by substituting the variable of integration with @code{x = tan (pi/2*u)}.\n\
 \n\
 The optional argument @var{tol} defines the relative tolerance used to stop\n\
 the integration procedure.  The default value is @math{1e^{-6}}.\n\
@@ -1505,7 +1505,7 @@
 @code{quadcc} would be as follows\n\
 \n\
 @example\n\
-   int = quadcc (f, a, b, 1.0e-6, [ 1 ]);\n\
+int = quadcc (f, a, b, 1.0e-6, [ 1 ]);\n\
 @end example\n\
 \n\
 The result of the integration is returned in @var{q}.\n\
@@ -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
+++ b/src/DLD-FUNCTIONS/qz.cc
@@ -322,9 +322,9 @@
 @example\n\
 @group\n\
 \n\
-    A * V = B * V * diag (@var{lambda})\n\
-    W' * A = diag (@var{lambda}) * W' * B\n\
-    AA = Q * A * Z, BB = Q * B * Z\n\
+A * V = B * V * diag (@var{lambda})\n\
+W' * A = diag (@var{lambda}) * W' * B\n\
+AA = Q * A * Z, BB = Q * B * Z\n\
 \n\
 @end group\n\
 @end example\n\
@@ -344,6 +344,7 @@
 @item opt\n\
 for ordering eigenvalues of the GEP pencil.  The leading block\n\
 of the revised pencil contains all eigenvalues that satisfy:\n\
+\n\
 @table @asis\n\
 @item \"N\"\n\
 = unordered (default)\n\
@@ -533,7 +534,7 @@
   ComplexMatrix CQ(nn,nn), CZ(nn,nn), CVR(nn,nn), CVL(nn,nn);
   octave_idx_type ilo, ihi, info;
   char compq = (nargout >= 3 ? 'V' : 'N');
-  char compz = (nargout >= 4 ? 'V' : 'N');
+  char compz = ((nargout >= 4 || nargin == 3)? 'V' : 'N');
 
   // Initialize Q, Z to identity if we need either of them.
   if (compq == 'V' || compz == 'V')
@@ -1181,7 +1182,12 @@
 
     case 3:
       if (nargin == 3)
-        retval(2) = CZ;
+        {
+          if (complex_case)
+            retval(2) = CZ;
+          else
+            retval(2) = ZZ;
+        }
       else
         {
           if (complex_case)
@@ -1195,7 +1201,7 @@
         if (complex_case)
           {
 #ifdef DEBUG
-            std::cout << "qz: retval (1) = cbb = " << std::endl;
+            std::cout << "qz: retval(1) = cbb = " << std::endl;
             octave_print_internal (std::cout, cbb, 0);
             std::cout << std::endl << "qz: retval(0) = caa = " <<std::endl;
             octave_print_internal (std::cout, caa, 0);
@@ -1207,7 +1213,7 @@
       else
         {
 #ifdef DEBUG
-          std::cout << "qz: retval (1) = bb = " << std::endl;
+          std::cout << "qz: retval(1) = bb = " << std::endl;
           octave_print_internal (std::cout, bb, 0);
           std::cout << std::endl << "qz: retval(0) = aa = " <<std::endl;
           octave_print_internal (std::cout, aa, 0);
@@ -1242,27 +1248,31 @@
 
 /*
 %!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
-
+%!test
+%! A = [0, 0, -1, 0; 1, 0, 0, 0; -1, 0, -2, -1; 0, -1, 1, 0];
+%! B = [0, 0, 0, 0; 0, 1, 0, 0; 0, 0, 1, 0; 0, 0, 0, 1];
+%! [AA, BB, Q, Z1] = qz (A, B);
+%! [AA, BB, Z2] = qz (A, B, '-');
+%! assert (Z1, Z2);
 */
--- a/src/DLD-FUNCTIONS/rand.cc
+++ b/src/DLD-FUNCTIONS/rand.cc
@@ -1,3 +1,4 @@
+
 /*
 
 Copyright (C) 1996-2012 John W. Eaton
@@ -48,7 +49,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;
 */
 
@@ -60,6 +61,7 @@
   NDArray a;
   int idx = 0;
   dim_vector dims;
+  bool is_single = false;
 
   unwind_protect frame;
   // Restore current distribution on any exit.
@@ -68,6 +70,19 @@
 
   octave_rand::distribution (distribution);
 
+  if (nargin > 0 && args(nargin-1).is_string ())
+    {
+      std::string s_arg = args(nargin-1).string_value ();
+
+      if (s_arg == "single")
+        {
+          is_single = true;
+          nargin--;
+        }
+      else if (s_arg == "double")
+        nargin--;
+    }
+
   if (additional_arg)
     {
       if (nargin == 0)
@@ -75,7 +90,7 @@
           error ("%s: expecting at least one argument", fcn);
           goto done;
         }
-      else if (args(0).is_string())
+      else if (args(0).is_string ())
         additional_arg = false;
       else
         {
@@ -246,7 +261,7 @@
                       octave_rand::seed (d);
                   }
                 else if (args(idx+1).is_string ()
-                         && args(idx+1).string_value() == "reset")
+                         && args(idx+1).string_value () == "reset")
                   octave_rand::reset ();
                 else
                   error ("%s: seed must be a real scalar", fcn);
@@ -254,7 +269,7 @@
             else if (ts == "state" || ts == "twister")
               {
                 if (args(idx+1).is_string ()
-                    && args(idx+1).string_value() == "reset")
+                    && args(idx+1).string_value () == "reset")
                   octave_rand::reset (fcn);
                 else
                   {
@@ -298,27 +313,54 @@
 
   dims.chop_trailing_singletons ();
 
-  if (additional_arg)
+  if (is_single)
     {
-      if (a.length() == 1)
-        return octave_rand::nd_array (dims, a(0));
-      else
+      if (additional_arg)
         {
-          if (a.dims() != dims)
+          if (a.length () == 1)
+            return octave_rand::float_nd_array (dims, a(0));
+          else
             {
-              error ("%s: mismatch in argument size", fcn);
-              return retval;
+              if (a.dims () != dims)
+                {
+                  error ("%s: mismatch in argument size", fcn);
+                  return retval;
+                }
+              octave_idx_type len = a.length ();
+              FloatNDArray m (dims);
+              float *v = m.fortran_vec ();
+              for (octave_idx_type i = 0; i < len; i++)
+                v[i] = octave_rand::float_scalar (a(i));
+              return m;
             }
-          octave_idx_type len = a.length ();
-          NDArray m (dims);
-          double *v = m.fortran_vec ();
-          for (octave_idx_type i = 0; i < len; i++)
-            v[i] = octave_rand::scalar (a(i));
-          return m;
         }
+      else
+        return octave_rand::float_nd_array (dims);
     }
   else
-    return octave_rand::nd_array (dims);
+    {
+      if (additional_arg)
+        {
+          if (a.length () == 1)
+            return octave_rand::nd_array (dims, a(0));
+          else
+            {
+              if (a.dims () != dims)
+                {
+                  error ("%s: mismatch in argument size", fcn);
+                  return retval;
+                }
+              octave_idx_type len = a.length ();
+              NDArray m (dims);
+              double *v = m.fortran_vec ();
+              for (octave_idx_type i = 0; i < len; i++)
+                v[i] = octave_rand::scalar (a(i));
+              return m;
+            }
+        }
+      else
+        return octave_rand::nd_array (dims);
+    }
 }
 
 DEFUN_DLD (rand, args, ,
@@ -332,6 +374,8 @@
 @deftypefnx {Loadable Function} {@var{v} =} rand (\"seed\")\n\
 @deftypefnx {Loadable Function} {} rand (\"seed\", @var{v})\n\
 @deftypefnx {Loadable Function} {} rand (\"seed\", \"reset\")\n\
+@deftypefnx {Loadable Function} {} rand (@dots{}, \"single\")\n\
+@deftypefnx {Loadable Function} {} rand (@dots{}, \"double\")\n\
 Return a matrix with random elements uniformly distributed on the\n\
 interval (0, 1).  The arguments are handled the same as the arguments\n\
 for @code{eye}.\n\
@@ -358,7 +402,10 @@
 \n\
 By default, the generator is initialized from @code{/dev/urandom} if it is\n\
 available, otherwise from CPU time, wall clock time, and the current\n\
-fraction of a second.\n\
+fraction of a second.  Note that this differs from @sc{matlab}, which\n\
+always initializes the state to the same state at startup.  To obtain\n\
+behavior comparable to @sc{matlab}, initialize with a deterministic state\n\
+vector in Octave's startup files (@pxref{Startup Files}).\n\
 \n\
 To compute the pseudo-random sequence, @code{rand} uses the Mersenne\n\
 Twister with a period of @math{2^{19937}-1} (See M. Matsumoto and\n\
@@ -399,6 +446,9 @@
 \n\
 The state or seed of the generator can be reset to a new random value\n\
 using the \"reset\" keyword.\n\
+\n\
+The class of the value returned can be controlled by a trailing \"double\"\n\
+or \"single\" argument.  These are the only valid classes.\n\
 @seealso{randn, rande, randg, randp}\n\
 @end deftypefn")
 {
@@ -415,75 +465,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, ,
@@ -497,6 +546,8 @@
 @deftypefnx {Loadable Function} {@var{v} =} randn (\"seed\")\n\
 @deftypefnx {Loadable Function} {} randn (\"seed\", @var{v})\n\
 @deftypefnx {Loadable Function} {} randn (\"seed\", \"reset\")\n\
+@deftypefnx {Loadable Function} {} randn (@dots{}, \"single\")\n\
+@deftypefnx {Loadable Function} {} randn (@dots{}, \"double\")\n\
 Return a matrix with normally distributed random\n\
 elements having zero mean and variance one.  The arguments are\n\
 handled the same as the arguments for @code{rand}.\n\
@@ -504,6 +555,9 @@
 By default, @code{randn} uses the Marsaglia and Tsang ``Ziggurat technique''\n\
 to transform from a uniform to a normal distribution.\n\
 \n\
+The class of the value returned can be controlled by a trailing \"double\"\n\
+or \"single\" argument.  These are the only valid classes.\n\
+\n\
 Reference: G. Marsaglia and W.W. Tsang,\n\
 @cite{Ziggurat Method for Generating Random Variables},\n\
 J. Statistical Software, vol 5, 2000,\n\
@@ -523,32 +577,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
 */
 
@@ -563,12 +617,17 @@
 @deftypefnx {Loadable Function} {@var{v} =} rande (\"seed\")\n\
 @deftypefnx {Loadable Function} {} rande (\"seed\", @var{v})\n\
 @deftypefnx {Loadable Function} {} rande (\"seed\", \"reset\")\n\
+@deftypefnx {Loadable Function} {} rande (@dots{}, \"single\")\n\
+@deftypefnx {Loadable Function} {} rande (@dots{}, \"double\")\n\
 Return a matrix with exponentially distributed random elements.  The\n\
 arguments are handled the same as the arguments for @code{rand}.\n\
 \n\
 By default, @code{randn} uses the Marsaglia and Tsang ``Ziggurat technique''\n\
 to transform from a uniform to an exponential distribution.\n\
 \n\
+The class of the value returned can be controlled by a trailing \"double\"\n\
+or \"single\" argument.  These are the only valid classes.\n\
+\n\
 Reference: G. Marsaglia and W.W. Tsang,\n\
 @cite{Ziggurat Method for Generating Random Variables},\n\
 J. Statistical Software, vol 5, 2000,\n\
@@ -588,34 +647,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
 */
 
@@ -630,7 +689,9 @@
 @deftypefnx {Loadable Function} {@var{v} =} randg (\"seed\")\n\
 @deftypefnx {Loadable Function} {} randg (\"seed\", @var{v})\n\
 @deftypefnx {Loadable Function} {} randg (\"seed\", \"reset\")\n\
-Return a matrix with @code{gamma(@var{a},1)} distributed random elements.\n\
+@deftypefnx {Loadable Function} {} randg (@dots{}, \"single\")\n\
+@deftypefnx {Loadable Function} {} randg (@dots{}, \"double\")\n\
+Return a matrix with @code{gamma (@var{a},1)} distributed random elements.\n\
 The arguments are handled the same as the arguments for @code{rand},\n\
 except for the argument @var{a}.\n\
 \n\
@@ -709,6 +770,9 @@
 @end example\n\
 \n\
 @end table\n\
+\n\
+The class of the value returned can be controlled by a trailing \"double\"\n\
+or \"single\" argument.  These are the only valid classes.\n\
 @seealso{rand, randn, rande, randp}\n\
 @end deftypefn")
 {
@@ -726,156 +790,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\
@@ -887,6 +960,8 @@
 @deftypefnx {Loadable Function} {@var{v} =} randp (\"seed\")\n\
 @deftypefnx {Loadable Function} {} randp (\"seed\", @var{v})\n\
 @deftypefnx {Loadable Function} {} randp (\"seed\", \"reset\")\n\
+@deftypefnx {Loadable Function} {} randp (@dots{}, \"single\")\n\
+@deftypefnx {Loadable Function} {} randp (@dots{}, \"double\")\n\
 Return a matrix with Poisson distributed random elements with mean value\n\
 parameter given by the first argument, @var{l}.  The arguments\n\
 are handled the same as the arguments for @code{rand}, except for the\n\
@@ -917,6 +992,9 @@
 L. Montanet, et al., @cite{Review of Particle Properties}, Physical Review\n\
 D 50 p1284, 1994.\n\
 @end table\n\
+\n\
+The class of the value returned can be controlled by a trailing \"double\"\n\
+or \"single\" argument.  These are the only valid classes.\n\
 @seealso{rand, randn, rande, randg}\n\
 @end deftypefn")
 {
@@ -934,86 +1012,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
 */
@@ -1027,7 +1105,7 @@
 replacement from @code{1:@var{n}}.  The complexity is O(@var{n}) in\n\
 memory and O(@var{m}) in time, unless @var{m} < @var{n}/5, in which case\n\
 O(@var{m}) memory is used as well.  The randomization is performed using\n\
-rand(). All permutations are equally likely.\n\
+rand().  All permutations are equally likely.\n\
 @seealso{perms}\n\
 @end deftypefn")
 {
--- a/src/DLD-FUNCTIONS/rcond.cc
+++ b/src/DLD-FUNCTIONS/rcond.cc
@@ -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
+++ b/src/DLD-FUNCTIONS/regexp.cc
@@ -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);
@@ -137,7 +231,7 @@
 
       if (sz == 1)
         {
-          string_vector named_tokens = rx_lst.begin()->named_tokens ();
+          string_vector named_tokens = rx_lst.begin ()->named_tokens ();
 
           for (int j = 0; j < named_pats.length (); j++)
             nmap.assign (named_pats(j), named_tokens(j));
@@ -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;
@@ -412,7 +508,7 @@
       Cell cellpat = args(1).cell_value ();
 
       for (int j = 0; j < nargout; j++)
-        newretval[j].resize(cellpat.dims ());
+        newretval[j].resize (cellpat.dims ());
 
       for (octave_idx_type i = 0; i < cellpat.numel (); i++)
         {
@@ -442,7 +538,7 @@
 
 DEFUN_DLD (regexp, args, nargout,
   "-*- texinfo -*-\n\
-@deftypefn  {Loadable Function} {[@var{s}, @var{e}, @var{te}, @var{m}, @var{t}, @var{nm}] =} regexp (@var{str}, @var{pat})\n\
+@deftypefn  {Loadable Function} {[@var{s}, @var{e}, @var{te}, @var{m}, @var{t}, @var{nm}, @var{sp}] =} regexp (@var{str}, @var{pat})\n\
 @deftypefnx {Loadable Function} {[@dots{}] =} regexp (@var{str}, @var{pat}, \"@var{opt1}\", @dots{})\n\
 Regular expression string matching.  Search for @var{pat} in @var{str} and\n\
 return the positions and substrings of any matches, or empty values if there\n\
@@ -457,6 +553,7 @@
 \n\
 @item * + ? @{@}\n\
 Repetition operators, representing\n\
+\n\
 @table @code\n\
 @item *\n\
 Match zero or more times\n\
@@ -487,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\
@@ -561,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\
@@ -629,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")
@@ -640,7 +747,7 @@
   if (nargin < 2)
     print_usage ();
   else if (args(0).is_cell () || args(1).is_cell ())
-    retval = octcellregexp (args, nargout, "regexp");
+    retval = octcellregexp (args, (nargout > 0 ? nargout : 1), "regexp");
   else
     retval = octregexp (args, nargout, "regexp");
 
@@ -648,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)
@@ -782,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
@@ -845,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";
@@ -867,11 +1012,13 @@
 %! assert (a, {"oo"});
 %! assert (b, {"f", " bar"});
 
+%!assert (regexp ("\n", '\n'), 1);
+%!assert (regexp ("\n", "\n"), 1);
 */
 
 DEFUN_DLD (regexpi, args, nargout,
   "-*- texinfo -*-\n\
-@deftypefn  {Loadable Function} {[@var{s}, @var{e}, @var{te}, @var{m}, @var{t}, @var{nm}] =} regexpi (@var{str}, @var{pat})\n\
+@deftypefn  {Loadable Function} {[@var{s}, @var{e}, @var{te}, @var{m}, @var{t}, @var{nm}, @var{sp}] =} regexpi (@var{str}, @var{pat})\n\
 @deftypefnx {Loadable Function} {[@dots{}] =} regexpi (@var{str}, @var{pat}, \"@var{opt1}\", @dots{})\n\
 \n\
 Case insensitive regular expression string matching.  Search for @var{pat} in\n\
@@ -888,7 +1035,7 @@
   if (nargin < 2)
     print_usage ();
   else if (args(0).is_cell () || args(1).is_cell ())
-    retval = octcellregexp (args, nargout, "regexpi", true);
+    retval = octcellregexp (args, (nargout > 0 ? nargout : 1), "regexpi", true);
   else
     retval = octregexp (args, nargout, "regexpi", true);
 
@@ -896,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)
 {
@@ -1041,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
@@ -1088,7 +1241,7 @@
 for the ith set of parentheses in the match string.  For example,\n\
 \n\
 @example\n\
-regexprep(\"Bill Dunn\",'(\\w+) (\\w+)','$2, $1')\n\
+regexprep (\"Bill Dunn\", '(\\w+) (\\w+)', '$2, $1')\n\
 @end example\n\
 \n\
 @noindent\n\
@@ -1158,9 +1311,9 @@
           for (octave_idx_type i = 0; i < dv0.numel (); i++)
             {
               new_args(0) = str(i);
-              if (pat.numel() == 1)
+              if (pat.numel () == 1)
                 new_args(1) = pat(0);
-              if (rep.numel() == 1)
+              if (rep.numel () == 1)
                 new_args(2) = rep(0);
 
               for (octave_idx_type j = 0; j < dv1.numel (); j++)
@@ -1195,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
+++ b/src/DLD-FUNCTIONS/schur.cc
@@ -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
+++ b/src/DLD-FUNCTIONS/spparms.cc
@@ -40,8 +40,8 @@
 @deftypefnx {Loadable Function} {[@var{keys}, @var{vals}] =} spparms ()\n\
 @deftypefnx {Loadable Function} {@var{val} =} spparms (@var{key})\n\
 @deftypefnx {Loadable Function} { } spparms (@var{vals})\n\
-@deftypefnx {Loadable Function} { } spparms ('defaults')\n\
-@deftypefnx {Loadable Function} { } spparms ('tight')\n\
+@deftypefnx {Loadable Function} { } spparms (\"defaults\")\n\
+@deftypefnx {Loadable Function} { } spparms (\"tight\")\n\
 @deftypefnx {Loadable Function} { } spparms (@var{key}, @var{val})\n\
 Query or set the parameters used by the sparse solvers and factorization\n\
 functions.  The first four calls above get information about the current\n\
@@ -97,9 +97,9 @@
 The value of individual keys can be set with\n\
 @code{spparms (@var{key}, @var{val})}.\n\
 The default values can be restored with the special keyword\n\
-'defaults'.  The special keyword 'tight' can be used to set the mmd solvers\n\
-to attempt a sparser solution at the potential cost of longer running\n\
-time.\n\
+\"defaults\".  The special keyword \"tight\" can be used to set the mmd\n\
+solvers to attempt a sparser solution at the potential cost of longer\n\
+running time.\n\
 @end deftypefn")
 {
   octave_value_list retval;
@@ -113,8 +113,8 @@
         retval(0) =  octave_sparse_params::get_vals ();
       else if (nargout == 2)
         {
-          retval (1) = octave_sparse_params::get_vals ();
-          retval (0) = octave_sparse_params::get_keys ();
+          retval(1) = octave_sparse_params::get_vals ();
+          retval(0) = octave_sparse_params::get_keys ();
         }
       else
         error ("spparms: too many output arguments");
@@ -138,7 +138,7 @@
               if (xisnan (val))
                 error ("spparms: KEY not recognized");
               else
-                retval (0) = val;
+                retval(0) = val;
             }
         }
       else
@@ -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
+++ b/src/DLD-FUNCTIONS/sqrtm.cc
@@ -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
+++ b/src/DLD-FUNCTIONS/str2double.cc
@@ -54,15 +54,15 @@
       c = is.peek ();
     }
 
-  if (c == 'I')
+  if (std::toupper (c) == 'I')
     {
       // It's infinity.
       is.get ();
       char c1 = is.get (), c2 = is.get ();
-      if (c1 == 'n' && c2 == 'f')
+      if (std::tolower (c1) == 'n' && std::tolower (c2) == 'f')
         {
           num = octave_Inf;
-          is.peek (); // May sets EOF bit.
+          is.peek (); // May set EOF bit.
         }
       else
         is.setstate (std::ios::failbit); // indicate that read has failed.
@@ -127,13 +127,37 @@
       c = is.peek ();
     }
 
-  // It's i*num or just i.
-  if (is_imag_unit (c))
+  // Imaginary number (i*num or just i), or maybe 'inf'.
+  if (c == 'i')
     {
-      imag = true;
+      // possible infinity.
       is.get ();
       c = is.peek ();
 
+      if (is.eof ())
+        {
+          // just 'i' and string is finished.  Return immediately.
+          imag = true;
+          num = 1.0;
+          if (negative)
+            num = -num;
+          return is;
+        }
+      else
+        { 
+          if (std::tolower (c) != 'n')
+            imag = true;
+          is.unget ();
+        }
+    }
+  else if (c == 'j')
+    imag = true;
+    
+  // It's i*num or just i
+  if (imag)
+    {
+      is.get ();
+      c = is.peek ();
       // Skip spaces after imaginary unit.
       while (isspace (c))
         {
@@ -350,10 +374,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)
@@ -370,13 +393,14 @@
 %!assert (str2double ("NaN"), NaN)
 %!assert (str2double ("NA"), NA)
 %!assert (str2double ("Inf"), Inf)
+%!assert (str2double ("iNF"), Inf)
 %!assert (str2double ("-Inf"), -Inf)
 %!assert (str2double ("Inf*i"), complex (0, Inf))
+%!assert (str2double ("iNF*i"), complex (0, Inf))
 %!assert (str2double ("NaN + Inf*i"), complex (NaN, Inf))
 %!assert (str2double ("Inf - Inf*i"), complex (Inf, -Inf))
 %!assert (str2double ("-i*NaN - Inf"), complex (-Inf, -NaN))
 %!assert (str2double ({"abc", "4i"}), [NaN + 0i, 4i])
 %!assert (str2double ({2, "4i"}), [NaN + 0i, 4i])
-%!assert (str2double (zeros(3,1,2)), NaN (3,1,2))
-
+%!assert (str2double (zeros (3,1,2)), NaN (3,1,2))
 */
--- a/src/DLD-FUNCTIONS/strfind.cc
+++ b/src/DLD-FUNCTIONS/strfind.cc
@@ -164,7 +164,7 @@
      @result{} [1, 3, 5]\n\
 \n\
 strfind (@{\"abababa\", \"bebebe\", \"ab\"@}, \"aba\")\n\
-     @result{} ans =\n\
+     @result{}\n\
         @{\n\
           [1,1] =\n\
 \n\
@@ -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>
@@ -331,7 +329,7 @@
 @example\n\
 @group\n\
 strrep (\"This is a test string\", \"is\", \"&%$\")\n\
-     @result{} \"Th&%$ &%$ a test string\"\n\
+    @result{}  \"Th&%$ &%$ a test string\"\n\
 @end group\n\
 @end example\n\
 \n\
@@ -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
+++ b/src/DLD-FUNCTIONS/sub2ind.cc
@@ -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,
@@ -182,8 +179,8 @@
 @example\n\
 @group\n\
 [r, c] = ind2sub ([3, 3], 8)\n\
-@result{} r =  2\n\
-   c =  3\n\
+    @result{} r =  2\n\
+    @result{} c =  3\n\
 @end group\n\
 @end example\n\
 @seealso{sub2ind}\n\
--- a/src/DLD-FUNCTIONS/svd.cc
+++ b/src/DLD-FUNCTIONS/svd.cc
@@ -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
+++ b/src/DLD-FUNCTIONS/syl.cc
@@ -53,7 +53,7 @@
 @example\n\
 @group\n\
 syl ([1, 2; 3, 4], [5, 6; 7, 8], [9, 10; 11, 12])\n\
-     @result{} [ -0.50000, -0.66667; -0.66667, -0.50000 ]\n\
+   @result{} [ -0.50000, -0.66667; -0.66667, -0.50000 ]\n\
 @end group\n\
 @end example\n\
 @end deftypefn")
@@ -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/symbfact.cc
+++ b/src/DLD-FUNCTIONS/symbfact.cc
@@ -143,29 +143,29 @@
 
   if (args(0).is_real_type ())
     {
-      const SparseMatrix a = args(0).sparse_matrix_value();
-      A->nrow = a.rows();
-      A->ncol = a.cols();
-      A->p = a.cidx();
-      A->i = a.ridx();
-      A->nzmax = a.nnz();
+      const SparseMatrix a = args(0).sparse_matrix_value ();
+      A->nrow = a.rows ();
+      A->ncol = a.cols ();
+      A->p = a.cidx ();
+      A->i = a.ridx ();
+      A->nzmax = a.nnz ();
       A->xtype = CHOLMOD_REAL;
 
-      if (a.rows() > 0 && a.cols() > 0)
-        A->x = a.data();
+      if (a.rows () > 0 && a.cols () > 0)
+        A->x = a.data ();
     }
   else if (args(0).is_complex_type ())
     {
-      const SparseComplexMatrix a = args(0).sparse_complex_matrix_value();
-      A->nrow = a.rows();
-      A->ncol = a.cols();
-      A->p = a.cidx();
-      A->i = a.ridx();
-      A->nzmax = a.nnz();
+      const SparseComplexMatrix a = args(0).sparse_complex_matrix_value ();
+      A->nrow = a.rows ();
+      A->ncol = a.cols ();
+      A->p = a.cidx ();
+      A->i = a.ridx ();
+      A->nzmax = a.nnz ();
       A->xtype = CHOLMOD_COMPLEX;
 
-      if (a.rows() > 0 && a.cols() > 0)
-        A->x = a.data();
+      if (a.rows () > 0 && a.cols () > 0)
+        A->x = a.data ();
     }
   else
     gripe_wrong_type_arg ("symbfact", args(0));
@@ -176,8 +176,8 @@
   if (nargin > 1)
     {
       char ch;
-      std::string str = args(1).string_value();
-      ch = tolower (str.c_str()[0]);
+      std::string str = args(1).string_value ();
+      ch = tolower (str.c_str ()[0]);
       if (ch == 'r')
         A->stype = 0;
       else if (ch == 'c')
@@ -223,13 +223,13 @@
 
       if (cm->status < CHOLMOD_OK)
         {
-          error("matrix corrupted");
+          error ("matrix corrupted");
           goto symbfact_error;
         }
 
       if (CHOLMOD_NAME(postorder) (Parent, n, 0, Post, cm) != n)
         {
-          error("postorder failed");
+          error ("postorder failed");
           goto symbfact_error;
         }
 
@@ -238,7 +238,7 @@
 
       if (cm->status < CHOLMOD_OK)
         {
-          error("matrix corrupted");
+          error ("matrix corrupted");
           goto symbfact_error;
         }
 
@@ -289,7 +289,7 @@
           /* create a copy of the column pointers */
           octave_idx_type *W = First;
           for (octave_idx_type j = 0 ; j < n ; j++)
-            W [j] = L.xcidx(j);
+            W[j] = L.xcidx (j);
 
           // get workspace for computing one row of L
           cholmod_sparse *R = cholmod_allocate_sparse (n, 1, n, false, true,
--- a/src/DLD-FUNCTIONS/symrcm.cc
+++ b/src/DLD-FUNCTIONS/symrcm.cc
@@ -135,9 +135,7 @@
 
       if (smallest != j)
         {
-          CMK_Node tmp = A[j];
-          A[j] = A[smallest];
-          A[smallest] = tmp;
+          std::swap (A[j], A[smallest]);
           j = smallest;
         }
       else
@@ -161,9 +159,7 @@
       octave_idx_type p = PARENT(i);
       if (H[i].deg < H[p].deg)
         {
-          CMK_Node tmp = H[i];
-          H[i] = H[p];
-          H[p] = tmp;
+          std::swap (H[i], H[p]);
 
           i = p;
         }
@@ -182,7 +178,7 @@
   CMK_Node r = H[0];
   H[0] = H[--h];
   if (reorg)
-    H_heapify_min(H, 0, h);
+    H_heapify_min (H, 0, h);
   return r;
 }
 
@@ -422,7 +418,7 @@
 @var{p} is a permutation vector such that\n\
 @code{@var{S}(@var{p}, @var{p})} tends to have its diagonal elements\n\
 closer to the diagonal than @var{S}.  This is a good preordering for LU\n\
-or Cholesky@tie{}factorization of matrices that come from 'long, skinny'\n\
+or Cholesky@tie{}factorization of matrices that come from ``long, skinny''\n\
 problems.  It works for both symmetric and asymmetric @var{S}.\n\
 \n\
 The algorithm represents a heuristic approach to the NP-complete\n\
@@ -601,7 +597,7 @@
                       w.id = r2;
                       w.deg = D[r2];
                       w.dist = v.dist+1;
-                      H_insert(S, s, w);
+                      H_insert (S, s, w);
                       visit[r2] = true;
                     }
                 }
@@ -613,7 +609,7 @@
                       w.id = r1;
                       w.deg = D[r1];
                       w.dist = v.dist+1;
-                      H_insert(S, s, w);
+                      H_insert (S, s, w);
                       visit[r1] = true;
                     }
                 }
@@ -628,7 +624,7 @@
                           w.id = r1;
                           w.deg = D[r1];
                           w.dist = v.dist+1;
-                          H_insert(S, s, w);
+                          H_insert (S, s, w);
                           visit[r1] = true;
                         }
                       j1++;
@@ -642,7 +638,7 @@
                           w.id = r2;
                           w.deg = D[r2];
                           w.dist = v.dist+1;
-                          H_insert(S, s, w);
+                          H_insert (S, s, w);
                           visit[r2] = true;
                         }
                       j2++;
@@ -656,7 +652,7 @@
               OCTAVE_QUIT;
 
               // locate a neighbor of i with minimal degree in O(log(N))
-              v = H_remove_min(S, s, 1);
+              v = H_remove_min (S, s, 1);
 
               // entered the BFS a new level?
               if (v.dist > level)
@@ -699,11 +695,7 @@
   // compute the reverse-ordering
   s = N / 2 - 1;
   for (octave_idx_type i = 0, j = N - 1; i <= s; i++, j--)
-    {
-      double tmp = P.elem(i);
-      P.elem(i) = P.elem(j);
-      P.elem(j) = tmp;
-    }
+    std::swap (P.elem (i), P.elem (j));
 
   // increment all indices, since Octave is not C
   return octave_value (P+1);
--- a/src/DLD-FUNCTIONS/time.cc
+++ b/src/DLD-FUNCTIONS/time.cc
@@ -122,9 +122,7 @@
 }
 
 /*
-
-%!assert(time () > 0);
-
+%!assert (time () > 0)
 */
 
 DEFUN_DLD (gmtime, args, ,
@@ -149,7 +147,7 @@
            yday = 47\n\
            isdst = 0\n\
            zone = CST\n\
-         @}\n\
+        @}\n\
 @end group\n\
 @end example\n\
 @seealso{strftime, strptime, localtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
@@ -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, ,
@@ -213,7 +208,7 @@
            yday = 47\n\
            isdst = 0\n\
            zone = CST\n\
-         @}\n\
+        @}\n\
 @end group\n\
 @end example\n\
 @seealso{strftime, strptime, gmtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
@@ -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, ,
@@ -329,7 +318,7 @@
 @example\n\
 @group\n\
 strftime (\"%r (%Z) %A %e %B %Y\", localtime (time ()))\n\
-     @result{} \"01:15:06 AM (CST) Monday 17 February 1997\"\n\
+      @result{} \"01:15:06 AM (CST) Monday 17 February 1997\"\n\
 @end group\n\
 @end example\n\
 \n\
@@ -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
+++ b/src/DLD-FUNCTIONS/tril.cc
@@ -69,7 +69,7 @@
       for (octave_idx_type j = 0; j < nc; j++)
         {
           octave_idx_type ii = std::min (std::max (zero, j - k), nr);
-          std::fill (rvec, rvec + ii, T());
+          std::fill (rvec, rvec + ii, T ());
           std::copy (avec + ii, avec + nr, rvec + ii);
           avec += nr;
           rvec += nr;
@@ -111,7 +111,7 @@
         {
           octave_idx_type ii = std::min (std::max (zero, j + 1 - k), nr);
           std::copy (avec, avec + ii, rvec);
-          std::fill (rvec + ii, rvec + nr, T());
+          std::fill (rvec + ii, rvec + nr, T ());
           avec += nr;
           rvec += nr;
         }
@@ -134,11 +134,11 @@
     }
 
   Sparse<T> m = a;
-  octave_idx_type nc = m.cols();
+  octave_idx_type nc = m.cols ();
 
   for (octave_idx_type j = 0; j < nc; j++)
-    for (octave_idx_type i = m.cidx(j); i < m.cidx(j+1); i++)
-      if (m.ridx(i) < j-k)
+    for (octave_idx_type i = m.cidx (j); i < m.cidx (j+1); i++)
+      if (m.ridx (i) < j-k)
         m.data(i) = 0.;
 
   m.maybe_compress (true);
@@ -156,11 +156,11 @@
     }
 
   Sparse<T> m = a;
-  octave_idx_type nc = m.cols();
+  octave_idx_type nc = m.cols ();
 
   for (octave_idx_type j = 0; j < nc; j++)
-    for (octave_idx_type i = m.cidx(j); i < m.cidx(j+1); i++)
-      if (m.ridx(i) > j-k)
+    for (octave_idx_type i = m.cidx (j); i < m.cidx (j+1); i++)
+      if (m.ridx (i) > j-k)
         m.data(i) = 0.;
 
   m.maybe_compress (true);
@@ -290,8 +290,8 @@
                 idx_tmp.push_back (ov_idx);
                 ov_idx(1) = static_cast<double> (nc);
                 tmp = tmp.resize (dim_vector (0,0));
-                tmp = tmp.subsasgn("(",idx_tmp, arg.do_index_op (ov_idx));
-                tmp = tmp.resize(dims);
+                tmp = tmp.subsasgn ("(",idx_tmp, arg.do_index_op (ov_idx));
+                tmp = tmp.resize (dims);
 
                 if (lower)
                   {
@@ -305,7 +305,7 @@
                         std::list<octave_value_list> idx;
                         idx.push_back (ov_idx);
 
-                        tmp = tmp.subsasgn ("(", idx, arg.do_index_op(ov_idx));
+                        tmp = tmp.subsasgn ("(", idx, arg.do_index_op (ov_idx));
 
                         if (error_state)
                           return retval;
@@ -323,7 +323,7 @@
                         std::list<octave_value_list> idx;
                         idx.push_back (ov_idx);
 
-                        tmp = tmp.subsasgn ("(", idx, arg.do_index_op(ov_idx));
+                        tmp = tmp.subsasgn ("(", idx, arg.do_index_op (ov_idx));
 
                         if (error_state)
                           return retval;
@@ -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
+++ b/src/DLD-FUNCTIONS/tsearch.cc
@@ -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/DLD-FUNCTIONS/typecast.cc
+++ b/src/DLD-FUNCTIONS/typecast.cc
@@ -95,20 +95,20 @@
 \n\
 @example\n\
 @group\n\
-  \"logical\"\n\
-  \"char\"\n\
-  \"int8\"\n\
-  \"int16\"\n\
-  \"int32\"\n\
-  \"int64\"\n\
-  \"uint8\"\n\
-  \"uint16\"\n\
-  \"uint32\"\n\
-  \"uint64\"\n\
-  \"double\"\n\
-  \"single\"\n\
-  \"double complex\"\n\
-  \"single complex\"\n\
+\"logical\"\n\
+\"char\"\n\
+\"int8\"\n\
+\"int16\"\n\
+\"int32\"\n\
+\"int64\"\n\
+\"uint8\"\n\
+\"uint16\"\n\
+\"uint32\"\n\
+\"uint64\"\n\
+\"double\"\n\
+\"single\"\n\
+\"double complex\"\n\
+\"single complex\"\n\
 @end group\n\
 @end example\n\
 \n\
@@ -129,8 +129,8 @@
 @example\n\
 @group\n\
 @var{x} = uint16 ([1, 65535]);\n\
-typecast (@var{x}, 'uint8')\n\
-@result{} [   0,   1, 255, 255]\n\
+typecast (@var{x}, \"uint8\")\n\
+  @result{} [   0,   1, 255, 255]\n\
 @end group\n\
 @end example\n\
 @seealso{cast, bitunpack, bitpack, swapbytes}\n\
@@ -280,17 +280,17 @@
 \n\
 @example\n\
 @group\n\
-  \"char\"\n\
-  \"int8\"\n\
-  \"int16\"\n\
-  \"int32\"\n\
-  \"int64\"\n\
-  \"uint8\"\n\
-  \"uint16\"\n\
-  \"uint32\"\n\
-  \"uint64\"\n\
-  \"double\"\n\
-  \"single\"\n\
+\"char\"\n\
+\"int8\"\n\
+\"int16\"\n\
+\"int32\"\n\
+\"int64\"\n\
+\"uint8\"\n\
+\"uint16\"\n\
+\"uint32\"\n\
+\"uint64\"\n\
+\"double\"\n\
+\"single\"\n\
 @end group\n\
 @end example\n\
 \n\
@@ -388,17 +388,17 @@
 \n\
 @example\n\
 @group\n\
-  \"char\"\n\
-  \"int8\"\n\
-  \"int16\"\n\
-  \"int32\"\n\
-  \"int64\"\n\
-  \"uint8\"\n\
-  \"uint16\"\n\
-  \"uint32\"\n\
-  \"uint64\"\n\
-  \"double\"\n\
-  \"single\"\n\
+\"char\"\n\
+\"int8\"\n\
+\"int16\"\n\
+\"int32\"\n\
+\"int64\"\n\
+\"uint8\"\n\
+\"uint16\"\n\
+\"uint32\"\n\
+\"uint64\"\n\
+\"double\"\n\
+\"single\"\n\
 @end group\n\
 @end example\n\
 \n\
--- a/src/DLD-FUNCTIONS/urlwrite.cc
+++ b/src/DLD-FUNCTIONS/urlwrite.cc
@@ -55,6 +55,11 @@
 #include <curl/curlver.h>
 #include <curl/easy.h>
 
+// Backwards compatibility for curl < 7.17.0
+#if LIBCURL_VERSION_NUM < 0x071100
+#define CURLOPT_DIRLISTONLY CURLOPT_FTPLISTONLY
+#endif
+
 static int
 write_data (void *buffer, size_t size, size_t nmemb, void *streamp)
 {
@@ -183,7 +188,7 @@
       init (user, passwd, std::cin, octave_stdout);
 
       std::string url = "ftp://" + _host;
-      setopt (CURLOPT_URL, url.c_str());
+      setopt (CURLOPT_URL, url.c_str ());
 
       // Setup the link, with no transfer
       if (!error_state)
@@ -215,7 +220,7 @@
           setopt (CURLOPT_POSTFIELDS, query_string.c_str ());
         }
       else
-        setopt (CURLOPT_URL, url.c_str());
+        setopt (CURLOPT_URL, url.c_str ());
 
       if (!error_state)
         retval = perform (false);
@@ -291,7 +296,7 @@
     {
       struct curl_slist *slist = 0;
       std::string cmd = "cwd " + path;
-      slist = curl_slist_append (slist, cmd.c_str());
+      slist = curl_slist_append (slist, cmd.c_str ());
       setopt (CURLOPT_POSTQUOTE, slist);
       if (! error_state)
         perform ();
@@ -303,7 +308,7 @@
     {
       struct curl_slist *slist = 0;
       std::string cmd = "dele " + file;
-      slist = curl_slist_append (slist, cmd.c_str());
+      slist = curl_slist_append (slist, cmd.c_str ());
       setopt (CURLOPT_POSTQUOTE, slist);
       if (! error_state)
         perform ();
@@ -315,7 +320,7 @@
     {
       struct curl_slist *slist = 0;
       std::string cmd = "rmd " + path;
-      slist = curl_slist_append (slist, cmd.c_str());
+      slist = curl_slist_append (slist, cmd.c_str ());
       setopt (CURLOPT_POSTQUOTE, slist);
       if (! error_state)
         perform ();
@@ -328,7 +333,7 @@
       bool retval = false;
       struct curl_slist *slist = 0;
       std::string cmd = "mkd " + path;
-      slist = curl_slist_append (slist, cmd.c_str());
+      slist = curl_slist_append (slist, cmd.c_str ());
       setopt (CURLOPT_POSTQUOTE, slist);
       if (! error_state)
         retval = perform (curlerror);
@@ -341,9 +346,9 @@
     {
       struct curl_slist *slist = 0;
       std::string cmd = "rnfr " + oldname;
-      slist = curl_slist_append (slist, cmd.c_str());
+      slist = curl_slist_append (slist, cmd.c_str ());
       cmd = "rnto " + newname;
-      slist = curl_slist_append (slist, cmd.c_str());
+      slist = curl_slist_append (slist, cmd.c_str ());
       setopt (CURLOPT_POSTQUOTE, slist);
       if (! error_state)
         perform ();
@@ -354,7 +359,7 @@
   void put (const std::string& file, std::istream& is) const
     {
       std::string url = "ftp://" + rep->host + "/" + file;
-      setopt (CURLOPT_URL, url.c_str());
+      setopt (CURLOPT_URL, url.c_str ());
       setopt (CURLOPT_UPLOAD, 1);
       setopt (CURLOPT_NOBODY, 0);
       set_istream (is);
@@ -364,13 +369,13 @@
       setopt (CURLOPT_NOBODY, 1);
       setopt (CURLOPT_UPLOAD, 0);
       url = "ftp://" + rep->host;
-      setopt (CURLOPT_URL, url.c_str());
+      setopt (CURLOPT_URL, url.c_str ());
     }
 
   void get (const std::string& file, std::ostream& os) const
     {
       std::string url = "ftp://" + rep->host + "/" + file;
-      setopt (CURLOPT_URL, url.c_str());
+      setopt (CURLOPT_URL, url.c_str ());
       setopt (CURLOPT_NOBODY, 0);
       set_ostream (os);
       if (! error_state)
@@ -378,19 +383,19 @@
       set_ostream (octave_stdout);
       setopt (CURLOPT_NOBODY, 1);
       url = "ftp://" + rep->host;
-      setopt (CURLOPT_URL, url.c_str());
+      setopt (CURLOPT_URL, url.c_str ());
     }
 
   void dir (void) const
     {
       std::string url = "ftp://" + rep->host + "/";
-      setopt (CURLOPT_URL, url.c_str());
+      setopt (CURLOPT_URL, url.c_str ());
       setopt (CURLOPT_NOBODY, 0);
       if (! error_state)
         perform ();
       setopt (CURLOPT_NOBODY, 1);
       url = "ftp://" + rep->host;
-      setopt (CURLOPT_URL, url.c_str());
+      setopt (CURLOPT_URL, url.c_str ());
     }
 
   string_vector list (void) const
@@ -398,7 +403,7 @@
       std::ostringstream buf;
       std::string url = "ftp://" + rep->host + "/";
       setopt (CURLOPT_WRITEDATA, static_cast<void*> (&buf));
-      setopt (CURLOPT_URL, url.c_str());
+      setopt (CURLOPT_URL, url.c_str ());
       setopt (CURLOPT_DIRLISTONLY, 1);
       setopt (CURLOPT_NOBODY, 0);
       if (! error_state)
@@ -407,7 +412,7 @@
       url = "ftp://" + rep->host;
       setopt (CURLOPT_WRITEDATA, static_cast<void*> (&octave_stdout));
       setopt (CURLOPT_DIRLISTONLY, 0);
-      setopt (CURLOPT_URL, url.c_str());
+      setopt (CURLOPT_URL, url.c_str ());
 
       // Count number of directory entries
       std::string str = buf.str ();
@@ -415,7 +420,7 @@
       size_t pos = 0;
       while (true)
         {
-          pos = str.find_first_of('\n', pos);
+          pos = str.find_first_of ('\n', pos);
           if (pos == std::string::npos)
             break;
           pos++;
@@ -425,7 +430,7 @@
       pos = 0;
       for (octave_idx_type i = 0; i < n; i++)
         {
-          size_t newpos = str.find_first_of('\n', pos);
+          size_t newpos = str.find_first_of ('\n', pos);
           if (newpos == std::string::npos)
             break;
 
@@ -438,10 +443,10 @@
   void get_fileinfo (const std::string& filename, double& filesize,
                      time_t& filetime, bool& fileisdir) const
     {
-      std::string path = pwd();
+      std::string path = pwd ();
 
       std::string url = "ftp://" + rep->host + "/" + path + "/" + filename;
-      setopt (CURLOPT_URL, url.c_str());
+      setopt (CURLOPT_URL, url.c_str ());
       setopt (CURLOPT_FILETIME, 1);
       setopt (CURLOPT_HEADERFUNCTION, throw_away);
       setopt (CURLOPT_WRITEFUNCTION, throw_away);
@@ -462,11 +467,11 @@
             {
               fileisdir = false;
               time_t ft;
-              curl_easy_getinfo(rep->handle (), CURLINFO_FILETIME, &ft);
+              curl_easy_getinfo (rep->handle (), CURLINFO_FILETIME, &ft);
               filetime = ft;
               double fs;
-              curl_easy_getinfo(rep->handle (),
-                                CURLINFO_CONTENT_LENGTH_DOWNLOAD, &fs);
+              curl_easy_getinfo (rep->handle (),
+                                 CURLINFO_CONTENT_LENGTH_DOWNLOAD, &fs);
               filesize = fs;
             }
         }
@@ -475,7 +480,7 @@
       setopt (CURLOPT_HEADERFUNCTION, 0);
       setopt (CURLOPT_FILETIME, 0);
       url = "ftp://" + rep->host;
-      setopt (CURLOPT_URL, url.c_str());
+      setopt (CURLOPT_URL, url.c_str ());
 
       // The MDTM command seems to reset the path to the root with the
       // servers I tested with, so cd again into the correct path. Make
@@ -498,12 +503,12 @@
       if (! error_state)
         {
           perform ();
-          retval = buf.str();
+          retval = buf.str ();
 
           // Can I assume that the path is alway in "" on the last line
           size_t pos2 = retval.rfind ('"');
           size_t pos1 = retval.rfind ('"', pos2 - 1);
-          retval = retval.substr(pos1 + 1, pos2 - pos1 - 1);
+          retval = retval.substr (pos1 + 1, pos2 - pos1 - 1);
         }
       setopt (CURLOPT_HEADERFUNCTION, 0);
       setopt (CURLOPT_WRITEHEADER, 0);
@@ -531,9 +536,9 @@
           std::string text = param(i+1).string_value ();
 
           // Encode strings.
-          char *enc_name = curl_easy_escape (rep->handle(), name.c_str (),
+          char *enc_name = curl_easy_escape (rep->handle (), name.c_str (),
                                              name.length ());
-          char *enc_text = curl_easy_escape (rep->handle(), text.c_str (),
+          char *enc_text = curl_easy_escape (rep->handle (), text.c_str (),
                                              text.length ());
 
           query << enc_name << "=" << enc_text;
@@ -541,7 +546,7 @@
           curl_free (enc_name);
           curl_free (enc_text);
 
-          if (i < param.numel()-1)
+          if (i < param.numel ()-1)
             query << "&";
         }
 
@@ -603,14 +608,14 @@
 
   curl_handles (void) : map ()
    {
-     curl_global_init(CURL_GLOBAL_DEFAULT);
+     curl_global_init (CURL_GLOBAL_DEFAULT);
    }
 
   ~curl_handles (void)
     {
       // Remove the elements of the map explicitly as they should
       // be deleted before the call to curl_global_cleanup
-      map.erase (begin(), end());
+      map.erase (begin (), end ());
 
       curl_global_cleanup ();
     }
@@ -736,7 +741,7 @@
       return retval;
     }
 
-  std::string url = args(0).string_value();
+  std::string url = args(0).string_value ();
 
   if (error_state)
     {
@@ -745,7 +750,7 @@
     }
 
   // name to store the file if download is succesful
-  std::string filename = args(1).string_value();
+  std::string filename = args(1).string_value ();
 
   if (error_state)
     {
@@ -758,7 +763,7 @@
 
   if (nargin == 4)
     {
-      method = args(2).string_value();
+      method = args(2).string_value ();
 
       if (error_state)
         {
@@ -772,7 +777,7 @@
           return retval;
         }
 
-      param = args(3).cell_value();
+      param = args(3).cell_value ();
 
       if (error_state)
         {
@@ -794,7 +799,7 @@
 
   file_stat fs (filename);
 
-  std::ofstream ofile (filename.c_str(), std::ios::out | std::ios::binary);
+  std::ofstream ofile (filename.c_str (), std::ios::out | std::ios::binary);
 
   if (! ofile.is_open ())
     {
@@ -876,7 +881,7 @@
 @example\n\
 @group\n\
 s = urlread (\"http://www.google.com/search\", \"get\",\n\
-             @{\"query\", \"octave\"@});\n\
+            @{\"query\", \"octave\"@});\n\
 @end group\n\
 @end example\n\
 @seealso{urlwrite}\n\
@@ -896,7 +901,7 @@
       return retval;
     }
 
-  std::string url = args(0).string_value();
+  std::string url = args(0).string_value ();
 
   if (error_state)
     {
@@ -909,7 +914,7 @@
 
   if (nargin == 3)
     {
-      method = args(1).string_value();
+      method = args(1).string_value ();
 
       if (error_state)
         {
@@ -923,7 +928,7 @@
           return retval;
         }
 
-      param = args(2).cell_value();
+      param = args(2).cell_value ();
 
       if (error_state)
         {
@@ -1263,7 +1268,7 @@
           const curl_handle curl = handles.contents (handle);
 
           if (curl.is_valid ())
-            retval = (curl.is_ascii() ? "ascii" : "binary");
+            retval = (curl.is_ascii () ? "ascii" : "binary");
           else
             error ("__ftp_binary__: invalid ftp handle");
         }
@@ -1417,7 +1422,7 @@
 
   if (! curl.mkdir (dir, false))
     warning ("__ftp_mput__: can not create the remote directory ""%s""",
-             (base.length() == 0 ? dir : base +
+             (base.length () == 0 ? dir : base +
               file_ops::dir_sep_str () + dir).c_str ());
 
   curl.cwd (dir);
@@ -1428,7 +1433,7 @@
 
       frame.add_fcn (reset_path, curl);
 
-      std::string realdir = base.length() == 0 ? dir : base +
+      std::string realdir = base.length () == 0 ? dir : base +
                          file_ops::dir_sep_str () + dir;
 
       dir_entry dirlist (realdir);
@@ -1464,7 +1469,7 @@
               else
                 {
                   // FIXME Does ascii mode need to be flagged here?
-                  std::ifstream ifile (realfile.c_str(), std::ios::in |
+                  std::ifstream ifile (realfile.c_str (), std::ios::in |
                                        std::ios::binary);
 
                   if (! ifile.is_open ())
@@ -1487,7 +1492,7 @@
         }
       else
         error ("__ftp_mput__: can not read the directory ""%s""",
-               realdir.c_str());
+               realdir.c_str ());
     }
 
   return retval;
@@ -1542,7 +1547,7 @@
                   else
                     {
                       // FIXME Does ascii mode need to be flagged here?
-                      std::ifstream ifile (file.c_str(), std::ios::in |
+                      std::ifstream ifile (file.c_str (), std::ios::in |
                                            std::ios::binary);
 
                       if (! ifile.is_open ())
@@ -1588,7 +1593,7 @@
 
       if (status < 0)
         error ("__ftp_mget__: can't create directory %s%s%s. %s",
-               target.c_str(), sep.c_str(), dir.c_str(), msg.c_str());
+               target.c_str (), sep.c_str (), dir.c_str (), msg.c_str ());
     }
 
   if (! error_state)
@@ -1616,7 +1621,7 @@
               else
                 {
                   std::string realfile = target + dir + sep + sv(i);
-                  std::ofstream ofile (realfile.c_str(),
+                  std::ofstream ofile (realfile.c_str (),
                                        std::ios::out |
                                        std::ios::binary);
 
@@ -1694,7 +1699,7 @@
                         getallfiles (curl, sv(i), target);
                       else
                         {
-                          std::ofstream ofile ((target + sv(i)).c_str(),
+                          std::ofstream ofile ((target + sv(i)).c_str (),
                                                std::ios::out |
                                                std::ios::binary);
 
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -97,27 +97,27 @@
 
 EXTRA_DIST = \
   Makefile.in \
-  defaults.h.in \
+  defaults.in.h \
   DOCSTRINGS \
   find-defun-files.sh \
+  gendoc.pl \
   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 = \
@@ -286,6 +286,7 @@
   ops.h \
   pager.h \
   parse.h \
+  parse-private.h \
   pr-output.h \
   procstream.h \
   profiler.h \
@@ -486,9 +487,11 @@
 if AMCOND_ENABLE_DYNAMIC_LINKING
   OCT_FILES = $(DLD_FUNCTIONS_LIBS:.la=.oct)
   OCT_STAMP_FILES = $(subst DLD-FUNCTIONS/,DLD-FUNCTIONS/$(am__leading_dot),$(DLD_FUNCTIONS_LIBS:.la=.oct-stamp))
+  DLD_LIBOCTINTERP_LIBADD = liboctinterp.la
 else
   OCT_FILES =
   OCT_STAMP_FILES =
+  DLD_LIBOCTINTERP_LIBADD =
 endif
 
 liboctinterp_la_SOURCES = \
@@ -518,7 +521,7 @@
 
 # Increment these as needed and according to the rules in the libtool manual:
 liboctinterp_current = 1
-liboctinterp_revision = 2
+liboctinterp_revision = 1
 liboctinterp_age = 0
 
 liboctinterp_version_info = $(liboctinterp_current):$(liboctinterp_revision):$(liboctinterp_age)
@@ -578,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
@@ -598,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}\"|" \
@@ -616,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 $@
 
@@ -624,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 \
@@ -658,41 +661,34 @@
 __init_fltk__.lo __init_fltk__.o: \
   AM_CXXFLAGS := $(filter-out $(DLL_CXXDEFS), $(AM_CXXFLAGS) $(GRAPHICS_CFLAGS))
 
-.DOCSTRINGS: gendoc$(BUILD_EXEEXT)
+if AMCOND_BUILD_DOCS
+.DOCSTRINGS: $(ALL_DEF_FILES) gendoc.pl
 	if [ "x$(srcdir)" != "x." ] && [ -f $(srcdir)/DOCSTRINGS ] && [ ! -f DOCSTRINGS ]; then \
 		cp $(srcdir)/DOCSTRINGS DOCSTRINGS; \
 		touch -r $(srcdir)/DOCSTRINGS DOCSTRINGS; \
 	fi
 	@echo "creating .DOCSTRINGS from .cc source files"
-	@./gendoc > $@
+	@$(PERL) $(srcdir)/gendoc.pl $(ALL_DEF_FILES) > $@
 	$(top_srcdir)/build-aux/move-if-change $@ DOCSTRINGS
 	touch $@
 
-doc-files: $(ALL_DEF_FILES)
-	echo $(ALL_DEF_FILES) > $@-t
-	mv $@-t $@
-
-gendoc.cc: doc-files mkgendoc
-	$(srcdir)/mkgendoc doc-files > $@-t
-	mv $@-t $@
-
-gendoc$(BUILD_EXEEXT): gendoc.cc
-	$(BUILD_CXX) $(BUILD_CXXFLAGS) -o $@ $^ $(BUILD_LDFLAGS)
-
 all-local: $(OCT_STAMP_FILES) $(DLD_FUNCTIONS_PKG_ADD_FILE) .DOCSTRINGS
+else
+all-local: $(OCT_STAMP_FILES) $(DLD_FUNCTIONS_PKG_ADD_FILE)
+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
@@ -762,9 +758,6 @@
 CLEANFILES = \
   $(bin_SCRIPTS) \
   $(DLD_FUNCTIONS_PKG_ADD_FILE) \
-  doc-files \
-  gendoc.cc \
-  gendoc$(BUILD_EXEEXT) \
   graphics-props.cc \
   oct-parse.output
 
--- a/src/OPERATORS/op-bm-bm.cc
+++ b/src/OPERATORS/op-bm-bm.cc
@@ -66,7 +66,7 @@
       return octave_value ();
     }
   else
-    return octave_value (v.bool_matrix_value().transpose ());
+    return octave_value (v.bool_matrix_value ().transpose ());
 }
 
 // bool matrix by bool matrix ops.
--- a/src/OPERATORS/op-cdm-cdm.cc
+++ b/src/OPERATORS/op-cdm-cdm.cc
@@ -43,13 +43,13 @@
 DEFUNOP (transpose, complex_diag_matrix)
 {
   CAST_UNOP_ARG (const octave_complex_diag_matrix&);
-  return octave_value (v.complex_diag_matrix_value().transpose ());
+  return octave_value (v.complex_diag_matrix_value ().transpose ());
 }
 
 DEFUNOP (hermitian, complex_diag_matrix)
 {
   CAST_UNOP_ARG (const octave_complex_diag_matrix&);
-  return octave_value (v.complex_diag_matrix_value().hermitian ());
+  return octave_value (v.complex_diag_matrix_value ().hermitian ());
 }
 
 // matrix by matrix ops.
--- a/src/OPERATORS/op-cell.cc
+++ b/src/OPERATORS/op-cell.cc
@@ -46,7 +46,7 @@
       return octave_value ();
     }
   else
-    return octave_value (Cell (v.cell_value().transpose ()));
+    return octave_value (Cell (v.cell_value ().transpose ()));
 }
 
 DEFCATOP_FN (c_c, cell, cell, concat)
--- a/src/OPERATORS/op-chm.cc
+++ b/src/OPERATORS/op-chm.cc
@@ -41,7 +41,7 @@
 {
   CAST_UNOP_ARG (const octave_char_matrix&);
 
-  return octave_value (v.matrix_value().transpose ());
+  return octave_value (v.matrix_value ().transpose ());
 }
 
 DEFNDCATOP_FN (chm_chm, char_matrix, char_matrix, char_array, char_array,
--- a/src/OPERATORS/op-cm-cm.cc
+++ b/src/OPERATORS/op-cm-cm.cc
@@ -51,7 +51,7 @@
       return octave_value ();
     }
   else
-    return octave_value (v.complex_matrix_value().transpose ());
+    return octave_value (v.complex_matrix_value ().transpose ());
 }
 
 DEFUNOP (hermitian, complex_matrix)
@@ -64,7 +64,7 @@
       return octave_value ();
     }
   else
-    return octave_value (v.complex_matrix_value().hermitian ());
+    return octave_value (v.complex_matrix_value ().hermitian ());
 }
 
 DEFNCUNOP_METHOD (incr, complex_matrix, increment)
--- a/src/OPERATORS/op-cm-scm.cc
+++ b/src/OPERATORS/op-cm-scm.cc
@@ -51,7 +51,7 @@
   CAST_BINOP_ARGS (const octave_complex_matrix&,
                    const octave_sparse_complex_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       Complex d = v2.complex_value ();
 
--- a/src/OPERATORS/op-cm-sm.cc
+++ b/src/OPERATORS/op-cm-sm.cc
@@ -50,7 +50,7 @@
 {
   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_sparse_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       double d = v2.scalar_value ();
 
--- a/src/OPERATORS/op-cs-scm.cc
+++ b/src/OPERATORS/op-cs-scm.cc
@@ -48,7 +48,7 @@
 {
   CAST_BINOP_ARGS (const octave_complex&, const octave_sparse_complex_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       Complex d = v2.complex_value ();
 
--- a/src/OPERATORS/op-cs-sm.cc
+++ b/src/OPERATORS/op-cs-sm.cc
@@ -50,7 +50,7 @@
 {
   CAST_BINOP_ARGS (const octave_complex&, const octave_sparse_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       double d = v2.scalar_value ();
 
--- a/src/OPERATORS/op-dm-dm.cc
+++ b/src/OPERATORS/op-dm-dm.cc
@@ -43,7 +43,7 @@
 DEFUNOP (transpose, diag_matrix)
 {
   CAST_UNOP_ARG (const octave_diag_matrix&);
-  return octave_value (v.diag_matrix_value().transpose ());
+  return octave_value (v.diag_matrix_value ().transpose ());
 }
 
 // matrix by matrix ops.
--- a/src/OPERATORS/op-dm-scm.cc
+++ b/src/OPERATORS/op-dm-scm.cc
@@ -43,7 +43,7 @@
 {
   CAST_BINOP_ARGS (const octave_diag_matrix&, const octave_sparse_complex_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -66,7 +66,7 @@
 {
   CAST_BINOP_ARGS (const octave_complex_diag_matrix&, const octave_sparse_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -89,7 +89,7 @@
 {
   CAST_BINOP_ARGS (const octave_complex_diag_matrix&, const octave_sparse_complex_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -142,7 +142,7 @@
 {
   CAST_BINOP_ARGS (const octave_diag_matrix&, const octave_sparse_complex_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -158,7 +158,7 @@
 {
   CAST_BINOP_ARGS (const octave_complex_diag_matrix&, const octave_sparse_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -174,7 +174,7 @@
 {
   CAST_BINOP_ARGS (const octave_complex_diag_matrix&, const octave_sparse_complex_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -190,7 +190,7 @@
 {
   CAST_BINOP_ARGS (const octave_diag_matrix&, const octave_sparse_complex_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -206,7 +206,7 @@
 {
   CAST_BINOP_ARGS (const octave_complex_diag_matrix&, const octave_sparse_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -222,7 +222,7 @@
 {
   CAST_BINOP_ARGS (const octave_complex_diag_matrix&, const octave_sparse_complex_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -240,7 +240,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_diag_matrix&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     // If v1 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -263,7 +263,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_complex_diag_matrix&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     // If v1 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -286,7 +286,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_complex_diag_matrix&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     // If v1 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -294,7 +294,7 @@
 
       return octave_value (d * v2.complex_diag_matrix_value ());
     }
-  else if (v2.rows() == 1 && v2.columns() == 1)
+  else if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, don't bother with further dispatching.
     {
       std::complex<double> d = v2.complex_value ();
@@ -316,7 +316,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_diag_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       double d = v2.scalar_value ();
 
@@ -336,7 +336,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_complex_diag_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       std::complex<double> d = v2.complex_value ();
 
@@ -356,7 +356,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_complex_diag_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       std::complex<double> d = v2.complex_value ();
 
@@ -376,7 +376,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_complex_diag_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -392,7 +392,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_diag_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -408,7 +408,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_complex_diag_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -424,7 +424,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_complex_diag_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -440,7 +440,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_diag_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -456,7 +456,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_complex_diag_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
--- a/src/OPERATORS/op-dm-sm.cc
+++ b/src/OPERATORS/op-dm-sm.cc
@@ -41,7 +41,7 @@
 {
   CAST_BINOP_ARGS (const octave_diag_matrix&, const octave_sparse_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -72,7 +72,7 @@
 {
   CAST_BINOP_ARGS (const octave_diag_matrix&, const octave_sparse_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -88,7 +88,7 @@
 {
   CAST_BINOP_ARGS (const octave_diag_matrix&, const octave_sparse_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     // If v2 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -106,7 +106,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_diag_matrix&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     // If v1 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -129,7 +129,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_diag_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       double d = v2.scalar_value ();
 
@@ -149,7 +149,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_diag_matrix&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     // If v1 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
@@ -165,7 +165,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_diag_matrix&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     // If v1 is a scalar in disguise, return a diagonal matrix rather than
     // a sparse matrix.
     {
--- a/src/OPERATORS/op-fcdm-fcdm.cc
+++ b/src/OPERATORS/op-fcdm-fcdm.cc
@@ -43,13 +43,13 @@
 DEFUNOP (transpose, float_complex_diag_matrix)
 {
   CAST_UNOP_ARG (const octave_float_complex_diag_matrix&);
-  return octave_value (v.float_complex_diag_matrix_value().transpose ());
+  return octave_value (v.float_complex_diag_matrix_value ().transpose ());
 }
 
 DEFUNOP (hermitian, float_complex_diag_matrix)
 {
   CAST_UNOP_ARG (const octave_float_complex_diag_matrix&);
-  return octave_value (v.float_complex_diag_matrix_value().hermitian ());
+  return octave_value (v.float_complex_diag_matrix_value ().hermitian ());
 }
 
 // matrix by matrix ops.
--- a/src/OPERATORS/op-fcm-fcm.cc
+++ b/src/OPERATORS/op-fcm-fcm.cc
@@ -51,7 +51,7 @@
       return octave_value ();
     }
   else
-    return octave_value (v.float_complex_matrix_value().transpose ());
+    return octave_value (v.float_complex_matrix_value ().transpose ());
 }
 
 DEFUNOP (hermitian, float_complex_matrix)
@@ -64,7 +64,7 @@
       return octave_value ();
     }
   else
-    return octave_value (v.float_complex_matrix_value().hermitian ());
+    return octave_value (v.float_complex_matrix_value ().hermitian ());
 }
 
 DEFNCUNOP_METHOD (incr, float_complex_matrix, increment)
--- a/src/OPERATORS/op-fdm-fdm.cc
+++ b/src/OPERATORS/op-fdm-fdm.cc
@@ -43,7 +43,7 @@
 DEFUNOP (transpose, float_diag_matrix)
 {
   CAST_UNOP_ARG (const octave_float_diag_matrix&);
-  return octave_value (v.float_diag_matrix_value().transpose ());
+  return octave_value (v.float_diag_matrix_value ().transpose ());
 }
 
 // matrix by matrix ops.
--- a/src/OPERATORS/op-fm-fm.cc
+++ b/src/OPERATORS/op-fm-fm.cc
@@ -51,7 +51,7 @@
       return octave_value ();
     }
   else
-    return octave_value (v.float_matrix_value().transpose ());
+    return octave_value (v.float_matrix_value ().transpose ());
 }
 
 DEFNCUNOP_METHOD (incr, float_matrix, increment)
--- a/src/OPERATORS/op-int.h
+++ b/src/OPERATORS/op-int.h
@@ -633,7 +633,7 @@
         return octave_value (); \
       } \
     else \
-      return octave_value (v.TYPE ## _array_value().transpose ()); \
+      return octave_value (v.TYPE ## _array_value ().transpose ()); \
   } \
  \
   DEFNCUNOP_METHOD (m_incr, TYPE ## _matrix, increment) \
--- a/src/OPERATORS/op-m-m.cc
+++ b/src/OPERATORS/op-m-m.cc
@@ -51,7 +51,7 @@
       return octave_value ();
     }
   else
-    return octave_value (v.matrix_value().transpose ());
+    return octave_value (v.matrix_value ().transpose ());
 }
 
 DEFNCUNOP_METHOD (incr, matrix, increment)
--- a/src/OPERATORS/op-m-scm.cc
+++ b/src/OPERATORS/op-m-scm.cc
@@ -51,7 +51,7 @@
 {
   CAST_BINOP_ARGS (const octave_matrix&, const octave_sparse_complex_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       Complex d = v2.complex_value ();
 
--- a/src/OPERATORS/op-m-sm.cc
+++ b/src/OPERATORS/op-m-sm.cc
@@ -50,7 +50,7 @@
 {
   CAST_BINOP_ARGS (const octave_matrix&, const octave_sparse_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       double d = v2.scalar_value ();
 
--- a/src/OPERATORS/op-pm-pm.cc
+++ b/src/OPERATORS/op-pm-pm.cc
@@ -37,7 +37,7 @@
 DEFUNOP (transpose, perm_matrix)
 {
   CAST_UNOP_ARG (const octave_perm_matrix&);
-  return octave_value (v.perm_matrix_value().transpose ());
+  return octave_value (v.perm_matrix_value ().transpose ());
 }
 
 DEFBINOP_OP (mul, perm_matrix, perm_matrix, *)
--- a/src/OPERATORS/op-pm-scm.cc
+++ b/src/OPERATORS/op-pm-scm.cc
@@ -39,13 +39,13 @@
 {
   CAST_BINOP_ARGS (const octave_perm_matrix&, const octave_sparse_complex_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       std::complex<double> d = v2.complex_value ();
 
       return octave_value (v1.sparse_matrix_value () * d);
     }
-  else if (v1.rows() == 1 && v1.columns() == 1)
+  else if (v1.rows () == 1 && v1.columns () == 1)
     return octave_value (v2.sparse_complex_matrix_value ());
   else
     return v1.perm_matrix_value  () * v2.sparse_complex_matrix_value ();
@@ -64,13 +64,13 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_perm_matrix&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     {
       std::complex<double> d = v1.scalar_value ();
 
       return octave_value (d * v2.sparse_matrix_value ());
     }
-  else if (v2.rows() == 1 && v2.columns() == 1)
+  else if (v2.rows () == 1 && v2.columns () == 1)
     return octave_value (v1.sparse_complex_matrix_value ());
   else
     return v1.sparse_complex_matrix_value  () * v2.perm_matrix_value ();
--- a/src/OPERATORS/op-pm-sm.cc
+++ b/src/OPERATORS/op-pm-sm.cc
@@ -82,13 +82,13 @@
 {
   CAST_BINOP_ARGS (const octave_perm_matrix&, const octave_sparse_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       double d = v2.scalar_value ();
 
       return octave_value (v1.sparse_matrix_value () * d);
     }
-  else if (v1.rows() == 1 && v1.columns() == 1)
+  else if (v1.rows () == 1 && v1.columns () == 1)
     return octave_value (v2.sparse_matrix_value ());
   else
     return v1.perm_matrix_value  () * v2.sparse_matrix_value ();
@@ -107,13 +107,13 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_perm_matrix&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     {
       double d = v1.scalar_value ();
 
       return octave_value (d * v2.sparse_matrix_value ());
     }
-  else if (v2.rows() == 1 && v2.columns() == 1)
+  else if (v2.rows () == 1 && v2.columns () == 1)
     return octave_value (v1.sparse_matrix_value ());
   else
     return v1.sparse_matrix_value  () * v2.perm_matrix_value ();
--- a/src/OPERATORS/op-range.cc
+++ b/src/OPERATORS/op-range.cc
@@ -47,7 +47,7 @@
 {
   CAST_UNOP_ARG (const octave_range&);
 
-  return octave_value (! v.matrix_value());
+  return octave_value (! v.matrix_value ());
 }
 
 DEFUNOP_OP (uplus, range, /* no-op */)
@@ -57,7 +57,7 @@
 {
   CAST_UNOP_ARG (const octave_range&);
 
-  return octave_value (v.matrix_value().transpose ());
+  return octave_value (v.matrix_value ().transpose ());
 }
 
 DEFBINOP_OP (addrs, range, scalar, +)
--- a/src/OPERATORS/op-s-scm.cc
+++ b/src/OPERATORS/op-s-scm.cc
@@ -51,7 +51,7 @@
 {
   CAST_BINOP_ARGS (const octave_scalar&, const octave_sparse_complex_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       Complex d = v2.complex_value ();
 
--- a/src/OPERATORS/op-s-sm.cc
+++ b/src/OPERATORS/op-s-sm.cc
@@ -47,7 +47,7 @@
 {
   CAST_BINOP_ARGS (const octave_scalar&, const octave_sparse_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       double d = v2.scalar_value ();
 
--- a/src/OPERATORS/op-sbm-sbm.cc
+++ b/src/OPERATORS/op-sbm-sbm.cc
@@ -55,7 +55,7 @@
 DEFUNOP (transpose, sparse_bool_matrix)
 {
   CAST_UNOP_ARG (const octave_sparse_bool_matrix&);
-  return octave_value (v.sparse_bool_matrix_value().transpose ());
+  return octave_value (v.sparse_bool_matrix_value ().transpose ());
 }
 
 // sparse bool matrix by sparse bool matrix ops.
--- a/src/OPERATORS/op-scm-cm.cc
+++ b/src/OPERATORS/op-scm-cm.cc
@@ -69,7 +69,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_complex_matrix&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     {
       Complex d = v1.complex_value ();
 
--- a/src/OPERATORS/op-scm-cs.cc
+++ b/src/OPERATORS/op-scm-cs.cc
@@ -71,7 +71,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_complex&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     {
       Complex d = v1.complex_value ();
 
--- a/src/OPERATORS/op-scm-m.cc
+++ b/src/OPERATORS/op-scm-m.cc
@@ -70,7 +70,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_matrix&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     {
       Complex d = v1.complex_value ();
 
--- a/src/OPERATORS/op-scm-s.cc
+++ b/src/OPERATORS/op-scm-s.cc
@@ -79,7 +79,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_scalar&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     {
       Complex d = v1.complex_value ();
 
--- a/src/OPERATORS/op-scm-scm.cc
+++ b/src/OPERATORS/op-scm-scm.cc
@@ -60,7 +60,7 @@
 {
   CAST_UNOP_ARG (const octave_sparse_complex_matrix&);
   return octave_value
-    (v.sparse_complex_matrix_value().transpose (),
+    (v.sparse_complex_matrix_value ().transpose (),
      v.matrix_type ().transpose ());
 }
 
@@ -68,7 +68,7 @@
 {
   CAST_UNOP_ARG (const octave_sparse_complex_matrix&);
   return octave_value
-    (v.sparse_complex_matrix_value().hermitian (),
+    (v.sparse_complex_matrix_value ().hermitian (),
      v.matrix_type ().transpose ());
 }
 
@@ -100,7 +100,7 @@
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&,
                    const octave_sparse_complex_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       Complex d = v2.complex_value ();
 
@@ -131,7 +131,7 @@
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&,
                    const octave_sparse_complex_matrix&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     {
       Complex d = v1.complex_value ();
 
--- a/src/OPERATORS/op-scm-sm.cc
+++ b/src/OPERATORS/op-scm-sm.cc
@@ -49,7 +49,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_sparse_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       double d = v2.scalar_value ();
 
@@ -79,7 +79,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_sparse_matrix&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     {
       Complex d = v1.complex_value ();
 
--- a/src/OPERATORS/op-sm-cm.cc
+++ b/src/OPERATORS/op-sm-cm.cc
@@ -69,7 +69,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_complex_matrix&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     {
       double d = v1.scalar_value ();
 
--- a/src/OPERATORS/op-sm-cs.cc
+++ b/src/OPERATORS/op-sm-cs.cc
@@ -71,7 +71,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_complex&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     {
       double d = v1.scalar_value ();
 
--- a/src/OPERATORS/op-sm-m.cc
+++ b/src/OPERATORS/op-sm-m.cc
@@ -67,7 +67,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_matrix&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     {
       double d = v1.scalar_value ();
 
--- a/src/OPERATORS/op-sm-s.cc
+++ b/src/OPERATORS/op-sm-s.cc
@@ -73,7 +73,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_scalar&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     {
       double d = v1.scalar_value ();
 
--- a/src/OPERATORS/op-sm-scm.cc
+++ b/src/OPERATORS/op-sm-scm.cc
@@ -49,7 +49,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_sparse_complex_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       Complex d = v2.complex_value ();
 
@@ -79,7 +79,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_sparse_complex_matrix&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     {
       double d = v1.scalar_value ();
 
--- a/src/OPERATORS/op-sm-sm.cc
+++ b/src/OPERATORS/op-sm-sm.cc
@@ -46,7 +46,7 @@
 DEFUNOP (transpose, sparse_matrix)
 {
   CAST_UNOP_ARG (const octave_sparse_matrix&);
-  return octave_value (v.sparse_matrix_value().transpose (),
+  return octave_value (v.sparse_matrix_value ().transpose (),
                        v.matrix_type ().transpose ());
 }
 
@@ -72,7 +72,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_sparse_matrix&);
 
-  if (v2.rows() == 1 && v2.columns() == 1)
+  if (v2.rows () == 1 && v2.columns () == 1)
     {
       double d = v2.scalar_value ();
 
@@ -102,7 +102,7 @@
 {
   CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_sparse_matrix&);
 
-  if (v1.rows() == 1 && v1.columns() == 1)
+  if (v1.rows () == 1 && v1.columns () == 1)
     {
       double d = v1.double_value ();
 
--- a/src/OPERATORS/op-str-str.cc
+++ b/src/OPERATORS/op-str-str.cc
@@ -44,7 +44,7 @@
       return octave_value ();
     }
   else
-    return octave_value (v.char_matrix_value().transpose (),
+    return octave_value (v.char_matrix_value ().transpose (),
                          a.is_sq_string () ? '\'' : '"');
 }
 
--- a/src/OPERATORS/op-struct.cc
+++ b/src/OPERATORS/op-struct.cc
@@ -44,7 +44,7 @@
       return octave_value ();
     }
   else
-    return octave_value (v.map_value().transpose ());
+    return octave_value (v.map_value ().transpose ());
 }
 
 DEFUNOP (scalar_transpose, scalar_struct)
--- a/src/bitfcns.cc
+++ b/src/bitfcns.cc
@@ -42,224 +42,274 @@
 #include "ov-re-mat.h"
 #include "ov-bool.h"
 
-// FIXME -- could probably eliminate some code duplication by
-// clever use of templates.
+#include <functional>
+
+#if !defined (HAVE_CXX_BITWISE_OP_TEMPLATES)
+namespace std 
+{
+  template <typename T>
+  struct bit_and 
+  {
+  public: 
+    T operator() (const T & op1, const T & op2) const { return (op1 & op2); }
+  };
+
+  template <typename T>
+  struct bit_or 
+  {
+  public: 
+    T operator() (const T & op1, const T & op2) const { return (op1 | op2); }
+  };
+
+  template <typename T>
+  struct bit_xor 
+  {
+  public: 
+    T operator() (const T & op1, const T & op2) const { return (op1 ^ op2); }
+  };
+}
+#endif
+
+template <typename OP, typename T>
+octave_value
+bitopxx (const OP& op, const std::string& fname,
+         const Array<T>& x, const Array<T>& y)
+{
+  int nelx = x.numel ();
+  int nely = y.numel ();
+
+  bool is_scalar_op = (nelx == 1 || nely == 1);
+
+  dim_vector dvx = x.dims ();
+  dim_vector dvy = y.dims ();
+
+  bool is_array_op = (dvx == dvy);
+
+  octave_value retval;
+  if (is_array_op || is_scalar_op)
+    {
+      Array<T> result;
+
+      if (nelx != 1)
+        result.resize (dvx);
+      else
+        result.resize (dvy);
+
+      for (int i = 0; i < nelx; i++)
+        if (is_scalar_op)
+          for (int k = 0; k < nely; k++)
+            result(i+k) = op (x(i), y(k));
+        else
+          result(i) = op (x(i), y(i));
 
-#define BITOPX(OP, FNAME, RET) \
-      { \
-        int nelx = x.numel (); \
-        int nely = y.numel (); \
- \
-        bool is_scalar_op = (nelx == 1 || nely == 1); \
- \
-        dim_vector dvx = x.dims (); \
-        dim_vector dvy = y.dims (); \
- \
-        bool is_array_op = (dvx == dvy); \
- \
-        if (is_array_op || is_scalar_op) \
-          { \
-            RET result; \
- \
-            if (nelx != 1) \
-              result.resize (dvx); \
-            else \
-              result.resize (dvy); \
- \
-            for (int i = 0; i < nelx; i++) \
-              if (is_scalar_op) \
-                for (int k = 0; k < nely; k++) \
-                  result(i+k) = x(i) OP y(k); \
-              else \
-                result(i) = x(i) OP y(i); \
- \
-              retval = result; \
-          } \
-        else \
-          error ("%s: size of X and Y must match, or one operand must be a scalar", FNAME); \
-      }
+      retval = result;
+    }
+  else
+    error ("%s: size of X and Y must match, or one operand must be a scalar",
+           fname.c_str ());
+
+  return retval;
+}
+
+// Trampoline function, instantiates the proper template above, with
+// reflective information hardwired. We can't hardwire this information
+// in Fbitxxx DEFUNs below, because at that moment, we still don't have
+// information about which integer types we need to instantiate.
+template<typename T>
+octave_value
+bitopx (const std::string& fname, const Array<T>& x, const Array<T>& y)
+{
+  if (fname == "bitand")
+    return bitopxx (std::bit_and<T>(), fname, x, y);
+  if (fname == "bitor")
+    return bitopxx (std::bit_or<T>(), fname, x, y);
+
+  //else (fname == "bitxor")
+  return bitopxx (std::bit_xor<T>(), fname, x, y);
+}
+
+octave_value
+bitop (const std::string& fname, const octave_value_list& args)
+{
+  octave_value retval;
+
+  int nargin = args.length ();
+
+  if (nargin == 2)
+    {
+      if ((args(0).class_name () == octave_scalar::static_class_name ())
+          || (args(0).class_name () == octave_bool::static_class_name ())
+          || (args(1).class_name () == octave_scalar::static_class_name ())
+          || (args(1).class_name () == octave_bool::static_class_name ()))
+        {
+          bool arg0_is_int = (args(0).class_name () !=
+                              octave_scalar::static_class_name () &&
+                              args(0).class_name () !=
+                              octave_bool::static_class_name ());
+          bool arg1_is_int = (args(1).class_name () !=
+                              octave_scalar::static_class_name () &&
+                              args(1).class_name () !=
+                              octave_bool::static_class_name ());
+
+          if (! (arg0_is_int || arg1_is_int))
+            {
+              uint64NDArray x (args(0).array_value ());
+              uint64NDArray y (args(1).array_value ());
+              if (! error_state)
+                retval = bitopx (fname, x, y).array_value ();
+            }
+          else
+            {
+              int p = (arg0_is_int ? 1 : 0);
+              int q = (arg0_is_int ? 0 : 1);
+
+              NDArray dx = args(p).array_value ();
 
-#define BITOP(OP, FNAME) \
- \
-  octave_value retval; \
- \
-  int nargin = args.length (); \
- \
-  if (nargin == 2) \
-    { \
-      if ((args(0).class_name () == octave_scalar::static_class_name ()) \
-          || (args(0).class_name () == octave_bool::static_class_name ()) \
-          || (args(1).class_name () == octave_scalar::static_class_name ()) \
-          || (args(1).class_name () == octave_bool::static_class_name ())) \
-        { \
-          bool arg0_is_int = (args(0).class_name () !=  \
-                              octave_scalar::static_class_name () && \
-                              args(0).class_name () != \
-                              octave_bool::static_class_name ()); \
-          bool arg1_is_int = (args(1).class_name () !=  \
-                              octave_scalar::static_class_name () && \
-                              args(1).class_name () != \
-                              octave_bool::static_class_name ()); \
-          \
-          if (! (arg0_is_int || arg1_is_int))   \
-            { \
-              uint64NDArray x (args(0).array_value ()); \
-              uint64NDArray y (args(1).array_value ()); \
-              if (! error_state) \
-                BITOPX (OP, FNAME, uint64NDArray); \
-              retval = retval.array_value (); \
-            } \
-          else \
-            { \
-              int p = (arg0_is_int ? 1 : 0); \
-              int q = (arg0_is_int ? 0 : 1); \
- \
-              NDArray dx = args(p).array_value (); \
- \
-              if (args(q).type_id () == octave_uint64_matrix::static_type_id () \
-                  || args(q).type_id () == octave_uint64_scalar::static_type_id ()) \
-                { \
-                  uint64NDArray x (dx); \
-                  uint64NDArray y = args(q).uint64_array_value (); \
-                  if (! error_state) \
-                    BITOPX (OP, FNAME, uint64NDArray); \
-                 } \
-              else if (args(q).type_id () == octave_uint32_matrix::static_type_id () \
-                       || args(q).type_id () == octave_uint32_scalar::static_type_id ()) \
-                { \
-                  uint32NDArray x (dx); \
-                  uint32NDArray y = args(q).uint32_array_value (); \
-                  if (! error_state) \
-                    BITOPX (OP, FNAME, uint32NDArray); \
-                } \
-              else if (args(q).type_id () == octave_uint16_matrix::static_type_id () \
-                       || args(q).type_id () == octave_uint16_scalar::static_type_id ()) \
-                { \
-                  uint16NDArray x (dx); \
-                  uint16NDArray y = args(q).uint16_array_value (); \
-                  if (! error_state) \
-                    BITOPX (OP, FNAME, uint16NDArray); \
-                } \
-              else if (args(q).type_id () == octave_uint8_matrix::static_type_id () \
-                       || args(q).type_id () == octave_uint8_scalar::static_type_id ()) \
-                { \
-                  uint8NDArray x (dx); \
-                  uint8NDArray y = args(q).uint8_array_value (); \
-                  if (! error_state) \
-                    BITOPX (OP, FNAME, uint8NDArray); \
-                } \
-              else if (args(q).type_id () == octave_int64_matrix::static_type_id () \
-                       || args(q).type_id () == octave_int64_scalar::static_type_id ()) \
-                { \
-                  int64NDArray x (dx); \
-                  int64NDArray y = args(q).int64_array_value (); \
-                  if (! error_state) \
-                    BITOPX (OP, FNAME, int64NDArray); \
-                } \
-              else if (args(q).type_id () == octave_int32_matrix::static_type_id () \
-                       || args(q).type_id () == octave_int32_scalar::static_type_id ()) \
-                { \
-                  int32NDArray x (dx); \
-                  int32NDArray y = args(q).int32_array_value (); \
-                  if (! error_state) \
-                    BITOPX (OP, FNAME, int32NDArray); \
-                } \
-              else if (args(q).type_id () == octave_int16_matrix::static_type_id () \
-                       || args(q).type_id () == octave_int16_scalar::static_type_id ()) \
-                { \
-                  int16NDArray x (dx); \
-                  int16NDArray y = args(q).int16_array_value (); \
-                  if (! error_state) \
-                    BITOPX (OP, FNAME, int16NDArray); \
-                } \
-              else if (args(q).type_id () == octave_int8_matrix::static_type_id () \
-                       || args(q).type_id () == octave_int8_scalar::static_type_id ()) \
-                { \
-                  int8NDArray x (dx); \
-                  int8NDArray y = args(q).int8_array_value (); \
-                  if (! error_state) \
-                    BITOPX (OP, FNAME, int8NDArray); \
-                } \
-              else \
-                error ("%s: invalid operand type", FNAME); \
-            } \
-        } \
-      else if (args(0).class_name () == args(1).class_name ()) \
-        { \
-          if (args(0).type_id () == octave_uint64_matrix::static_type_id () \
-              || args(0).type_id () == octave_uint64_scalar::static_type_id ()) \
-            { \
-              uint64NDArray x = args(0).uint64_array_value (); \
-              uint64NDArray y = args(1).uint64_array_value (); \
-              if (! error_state) \
-                BITOPX (OP, FNAME, uint64NDArray); \
-            } \
-          else if (args(0).type_id () == octave_uint32_matrix::static_type_id () \
-                   || args(0).type_id () == octave_uint32_scalar::static_type_id ()) \
-            { \
-              uint32NDArray x = args(0).uint32_array_value (); \
-              uint32NDArray y = args(1).uint32_array_value (); \
-              if (! error_state) \
-                BITOPX (OP, FNAME, uint32NDArray); \
-            } \
-          else if (args(0).type_id () == octave_uint16_matrix::static_type_id () \
-                   || args(0).type_id () == octave_uint16_scalar::static_type_id ()) \
-            { \
-              uint16NDArray x = args(0).uint16_array_value (); \
-              uint16NDArray y = args(1).uint16_array_value (); \
-              if (! error_state) \
-                BITOPX (OP, FNAME, uint16NDArray); \
-            } \
-          else if (args(0).type_id () == octave_uint8_matrix::static_type_id () \
-                   || args(0).type_id () == octave_uint8_scalar::static_type_id ()) \
-            { \
-              uint8NDArray x = args(0).uint8_array_value (); \
-              uint8NDArray y = args(1).uint8_array_value (); \
-              if (! error_state) \
-                BITOPX (OP, FNAME, uint8NDArray); \
-            } \
-          else if (args(0).type_id () == octave_int64_matrix::static_type_id () \
-                   || args(0).type_id () == octave_int64_scalar::static_type_id ()) \
-            { \
-              int64NDArray x = args(0).int64_array_value (); \
-              int64NDArray y = args(1).int64_array_value (); \
-              if (! error_state) \
-                BITOPX (OP, FNAME, int64NDArray); \
-            } \
-          else if (args(0).type_id () == octave_int32_matrix::static_type_id () \
-                   || args(0).type_id () == octave_int32_scalar::static_type_id ()) \
-            { \
-              int32NDArray x = args(0).int32_array_value (); \
-              int32NDArray y = args(1).int32_array_value (); \
-              if (! error_state) \
-                BITOPX (OP, FNAME, int32NDArray); \
-            } \
-          else if (args(0).type_id () == octave_int16_matrix::static_type_id () \
-                   || args(0).type_id () == octave_int16_scalar::static_type_id ()) \
-            { \
-              int16NDArray x = args(0).int16_array_value (); \
-              int16NDArray y = args(1).int16_array_value (); \
-              if (! error_state) \
-                BITOPX (OP, FNAME, int16NDArray); \
-            } \
-          else if (args(0).type_id () == octave_int8_matrix::static_type_id () \
-                   || args(0).type_id () == octave_int8_scalar::static_type_id ()) \
-            { \
-              int8NDArray x = args(0).int8_array_value (); \
-              int8NDArray y = args(1).int8_array_value (); \
-              if (! error_state) \
-                BITOPX (OP, FNAME, int8NDArray); \
-            } \
-          else \
-            error ("%s: invalid operand type", FNAME); \
-        } \
-      else \
-        error ("%s: must have matching operand types", FNAME); \
-    } \
-  else \
-    print_usage (); \
- \
-  return retval
+              if (args(q).type_id () == octave_uint64_matrix::static_type_id ()
+                  || args(q).type_id () == octave_uint64_scalar::static_type_id ())
+                {
+                  uint64NDArray x (dx);
+                  uint64NDArray y = args(q).uint64_array_value ();
+                  if (! error_state)
+                    retval = bitopx (fname, x, y);
+                }
+              else if (args(q).type_id () == octave_uint32_matrix::static_type_id ()
+                       || args(q).type_id () == octave_uint32_scalar::static_type_id ())
+                {
+                  uint32NDArray x (dx);
+                  uint32NDArray y = args(q).uint32_array_value ();
+                  if (! error_state)
+                    retval = bitopx (fname, x, y);
+                }
+              else if (args(q).type_id () == octave_uint16_matrix::static_type_id ()
+                       || args(q).type_id () == octave_uint16_scalar::static_type_id ())
+                {
+                  uint16NDArray x (dx);
+                  uint16NDArray y = args(q).uint16_array_value ();
+                  if (! error_state)
+                    retval = bitopx (fname, x, y);
+                }
+              else if (args(q).type_id () == octave_uint8_matrix::static_type_id ()
+                       || args(q).type_id () == octave_uint8_scalar::static_type_id ())
+                {
+                  uint8NDArray x (dx);
+                  uint8NDArray y = args(q).uint8_array_value ();
+                  if (! error_state)
+                    retval = bitopx (fname, x, y);
+                }
+              else if (args(q).type_id () == octave_int64_matrix::static_type_id ()
+                       || args(q).type_id () == octave_int64_scalar::static_type_id ())
+                {
+                  int64NDArray x (dx);
+                  int64NDArray y = args(q).int64_array_value ();
+                  if (! error_state)
+                    retval = bitopx (fname, x, y);
+                }
+              else if (args(q).type_id () == octave_int32_matrix::static_type_id ()
+                       || args(q).type_id () == octave_int32_scalar::static_type_id ())
+                {
+                  int32NDArray x (dx);
+                  int32NDArray y = args(q).int32_array_value ();
+                  if (! error_state)
+                    retval = bitopx (fname, x, y);
+                }
+              else if (args(q).type_id () == octave_int16_matrix::static_type_id ()
+                       || args(q).type_id () == octave_int16_scalar::static_type_id ())
+                {
+                  int16NDArray x (dx);
+                  int16NDArray y = args(q).int16_array_value ();
+                  if (! error_state)
+                    retval  = bitopx (fname, x, y);
+                }
+              else if (args(q).type_id () == octave_int8_matrix::static_type_id ()
+                       || args(q).type_id () == octave_int8_scalar::static_type_id ())
+                {
+                  int8NDArray x (dx);
+                  int8NDArray y = args(q).int8_array_value ();
+                  if (! error_state)
+                    retval = bitopx (fname, x, y);
+                }
+              else
+                error ("%s: invalid operand type", fname.c_str ());
+            }
+        }
+      else if (args(0).class_name () == args(1).class_name ())
+        {
+          if (args(0).type_id () == octave_uint64_matrix::static_type_id ()
+              || args(0).type_id () == octave_uint64_scalar::static_type_id ())
+            {
+              uint64NDArray x = args(0).uint64_array_value ();
+              uint64NDArray y = args(1).uint64_array_value ();
+              if (! error_state)
+                retval = bitopx (fname, x, y);
+            }
+          else if (args(0).type_id () == octave_uint32_matrix::static_type_id ()
+                   || args(0).type_id () == octave_uint32_scalar::static_type_id ())
+            {
+              uint32NDArray x = args(0).uint32_array_value ();
+              uint32NDArray y = args(1).uint32_array_value ();
+              if (! error_state)
+                retval = bitopx (fname, x, y);
+            }
+          else if (args(0).type_id () == octave_uint16_matrix::static_type_id ()
+                   || args(0).type_id () == octave_uint16_scalar::static_type_id ())
+            {
+              uint16NDArray x = args(0).uint16_array_value ();
+              uint16NDArray y = args(1).uint16_array_value ();
+              if (! error_state)
+                retval = bitopx (fname, x, y);
+            }
+          else if (args(0).type_id () == octave_uint8_matrix::static_type_id ()
+                   || args(0).type_id () == octave_uint8_scalar::static_type_id ())
+            {
+              uint8NDArray x = args(0).uint8_array_value ();
+              uint8NDArray y = args(1).uint8_array_value ();
+              if (! error_state)
+                retval = bitopx (fname, x, y);
+            }
+          else if (args(0).type_id () == octave_int64_matrix::static_type_id ()
+                   || args(0).type_id () == octave_int64_scalar::static_type_id ())
+            {
+              int64NDArray x = args(0).int64_array_value ();
+              int64NDArray y = args(1).int64_array_value ();
+              if (! error_state)
+                retval = bitopx (fname, x, y);
+            }
+          else if (args(0).type_id () == octave_int32_matrix::static_type_id ()
+                   || args(0).type_id () == octave_int32_scalar::static_type_id ())
+            {
+              int32NDArray x = args(0).int32_array_value ();
+              int32NDArray y = args(1).int32_array_value ();
+              if (! error_state)
+                retval = bitopx (fname, x, y);
+            }
+          else if (args(0).type_id () == octave_int16_matrix::static_type_id ()
+                   || args(0).type_id () == octave_int16_scalar::static_type_id ())
+            {
+              int16NDArray x = args(0).int16_array_value ();
+              int16NDArray y = args(1).int16_array_value ();
+              if (! error_state)
+                retval = bitopx (fname, x, y);
+            }
+          else if (args(0).type_id () == octave_int8_matrix::static_type_id ()
+                   || args(0).type_id () == octave_int8_scalar::static_type_id ())
+            {
+              int8NDArray x = args(0).int8_array_value ();
+              int8NDArray y = args(1).int8_array_value ();
+              if (! error_state)
+                retval = bitopx (fname, x, y);
+            }
+          else
+            error ("%s: invalid operand type", fname.c_str ());
+        }
+      else
+        error ("%s: must have matching operand types", fname.c_str ());
+    }
+  else
+    print_usage ();
+
+  return retval;
+}
 
 DEFUN (bitand, args, ,
   "-*- texinfo -*-\n\
@@ -269,7 +319,7 @@
 @seealso{bitor, bitxor, bitset, bitget, bitcmp, bitshift, bitmax}\n\
 @end deftypefn")
 {
-  BITOP (&, "bitand");
+  return bitop ("bitand", args);
 }
 
 DEFUN (bitor, args, ,
@@ -280,7 +330,7 @@
 @seealso{bitor, bitxor, bitset, bitget, bitcmp, bitshift, bitmax}\n\
 @end deftypefn")
 {
-  BITOP (|, "bitor");
+  return bitop ("bitor", args);
 }
 
 DEFUN (bitxor, args, ,
@@ -291,7 +341,7 @@
 @seealso{bitand, bitor, bitset, bitget, bitcmp, bitshift, bitmax}\n\
 @end deftypefn")
 {
-  BITOP (^, "bitxor");
+  return bitop ("bitxor", args);
 }
 
 static int64_t
@@ -665,7 +715,7 @@
   if (cname == "uint8")
     retval = octave_uint8 (std::numeric_limits<uint8_t>::min ());
   else if (cname == "uint16")
-    retval = octave_uint16 (std::numeric_limits<uint16_t>::min());
+    retval = octave_uint16 (std::numeric_limits<uint16_t>::min ());
   else if (cname == "uint32")
     retval = octave_uint32 (std::numeric_limits<uint32_t>::min ());
   else if (cname == "uint64")
--- a/src/comment-list.cc
+++ b/src/comment-list.cc
@@ -88,7 +88,7 @@
 octave_comment_buffer::do_append (const std::string& s,
                                   octave_comment_elt::comment_type t)
 {
-  comment_list->append(s, t);
+  comment_list->append (s, t);
 }
 
 octave_comment_list *
--- a/src/data.cc
+++ b/src/data.cc
@@ -119,7 +119,7 @@
 @example\n\
 @group\n\
 all ([2, 3; 1, 0]))\n\
-     @result{} [ 1, 0 ]\n\
+    @result{} [ 1, 0 ]\n\
 @end group\n\
 @end example\n\
 \n\
@@ -132,27 +132,25 @@
 }
 
 /*
-
 %!test
 %! x = ones (3);
 %! x(1,1) = 0;
-%! assert((all (all (rand (3) + 1) == [1, 1, 1]) == 1
-%! && all (all (x) == [0, 1, 1]) == 1
-%! && all (x, 1) == [0, 1, 1]
-%! && all (x, 2) == [0; 1; 1]));
+%! assert (all (all (rand (3) + 1) == [1, 1, 1]) == 1);
+%! assert (all (all (x) == [0, 1, 1]) == 1);
+%! assert (all (x, 1) == [0, 1, 1]);
+%! assert (all (x, 2) == [0; 1; 1]);
 
 %!test
-%! x = ones (3, 'single');
+%! x = ones (3, "single");
 %! x(1,1) = 0;
-%! assert((all (all (single (rand (3) + 1)) == [1, 1, 1]) == 1
-%! && all (all (x) == [0, 1, 1]) == 1
-%! && all (x, 1) == [0, 1, 1]
-%! && all (x, 2) == [0; 1; 1]));
-
-%!error <Invalid call to all> all ();
-%!error <Invalid call to all> all (1, 2, 3);
-
- */
+%! assert (all (all (single (rand (3) + 1)) == [1, 1, 1]) == 1);
+%! assert (all (all (x) == [0, 1, 1]) == 1);
+%! assert (all (x, 1) == [0, 1, 1]);
+%! assert (all (x, 2) == [0; 1; 1]);
+
+%!error all ()
+%!error all (1, 2, 3)
+*/
 
 DEFUN (any, args, ,
   "-*- texinfo -*-\n\
@@ -168,7 +166,7 @@
 @example\n\
 @group\n\
 any (eye (2, 4))\n\
-     @result{} [ 1, 1, 0, 0 ]\n\
+ @result{} [ 1, 1, 0, 0 ]\n\
 @end group\n\
 @end example\n\
 \n\
@@ -178,7 +176,7 @@
 @example\n\
 @group\n\
 any (eye (2, 4), 2)\n\
-     @result{} [ 1; 1 ]\n\
+ @result{} [ 1; 1 ]\n\
 @end group\n\
 @end example\n\
 @seealso{all}\n\
@@ -188,27 +186,25 @@
 }
 
 /*
-
 %!test
 %! x = zeros (3);
 %! x(3,3) = 1;
-%! assert((all (any (x) == [0, 0, 1]) == 1
-%! && all (any (ones (3)) == [1, 1, 1]) == 1
-%! && any (x, 1) == [0, 0, 1]
-%! && any (x, 2) == [0; 0; 1]));
+%! assert (all (any (x) == [0, 0, 1]) == 1);
+%! assert (all (any (ones (3)) == [1, 1, 1]) == 1);
+%! assert (any (x, 1) == [0, 0, 1]);
+%! assert (any (x, 2) == [0; 0; 1]);
 
 %!test
-%! x = zeros (3,'single');
+%! x = zeros (3, "single");
 %! x(3,3) = 1;
-%! assert((all (any (x) == [0, 0, 1]) == 1
-%! && all (any (ones (3, 'single')) == [1, 1, 1]) == 1
-%! && any (x, 1) == [0, 0, 1]
-%! && any (x, 2) == [0; 0; 1]));
-
-%!error <Invalid call to any> any ();
-%!error <Invalid call to any> any (1, 2, 3);
-
- */
+%! assert (all (any (x) == [0, 0, 1]) == 1);
+%! assert (all (any (ones (3, "single")) == [1, 1, 1]) == 1);
+%! assert (any (x, 1) == [0, 0, 1]);
+%! assert (any (x, 2) == [0; 0; 1]);
+
+%!error any ()
+%!error any (1, 2, 3)
+*/
 
 // These mapping functions may also be useful in other places, eh?
 
@@ -283,19 +279,18 @@
 %! v = [0, pi/6, pi/4, pi/3, -pi/3, -pi/4, -pi/6, 0];
 %! y = [0, rt3, 1, rt3, -rt3, -1, -rt3, 0];
 %! x = [1, 3, 1, 1, 1, 1, 3, 1];
-%! assert(atan2 (y, x), v, sqrt (eps));
+%! assert (atan2 (y, x), v, sqrt (eps));
 
 %!test
 %! rt2 = sqrt (2);
 %! rt3 = sqrt (3);
-%! v = single([0, pi/6, pi/4, pi/3, -pi/3, -pi/4, -pi/6, 0]);
-%! y = single([0, rt3, 1, rt3, -rt3, -1, -rt3, 0]);
-%! x = single([1, 3, 1, 1, 1, 1, 3, 1]);
-%! assert(atan2 (y, x), v, sqrt (eps('single')));
-
-%!error <Invalid call to atan2> atan2 ();
-%!error <Invalid call to atan2> atan2 (1, 2, 3);
-
+%! v = single ([0, pi/6, pi/4, pi/3, -pi/3, -pi/4, -pi/6, 0]);
+%! y = single ([0, rt3, 1, rt3, -rt3, -1, -rt3, 0]);
+%! x = single ([1, 3, 1, 1, 1, 1, 3, 1]);
+%! assert (atan2 (y, x), v, sqrt (eps ("single")));
+
+%!error atan2 ()
+%!error atan2 (1, 2, 3)
 */
 
 
@@ -365,8 +360,8 @@
 \n\
 @example\n\
 @group\n\
-  hypot (hypot (@var{x}, @var{y}), @var{z})\n\
-  hypot (hypot (hypot (@var{x}, @var{y}), @var{z}), @var{w}), etc.\n\
+hypot (hypot (@var{x}, @var{y}), @var{z})\n\
+hypot (hypot (hypot (@var{x}, @var{y}), @var{z}), @var{w}), etc.\n\
 @end group\n\
 @end example\n\
 @end deftypefn")
@@ -397,8 +392,8 @@
 %!assert (size (hypot (rand (2, 3, 4), 1)), [2, 3, 4])
 %!assert (size (hypot (1, rand (2, 3, 4))), [2, 3, 4])
 %!assert (size (hypot (1, 2)), [1, 1])
-%!assert (hypot (1:10, 1:10), sqrt(2) * [1:10], 16*eps)
-%!assert (hypot (single(1:10), single(1:10)), single(sqrt(2) * [1:10]));
+%!assert (hypot (1:10, 1:10), sqrt (2) * [1:10], 16*eps)
+%!assert (hypot (single (1:10), single (1:10)), single (sqrt (2) * [1:10]))
 */
 
 template<typename T, typename ET>
@@ -454,8 +449,8 @@
               // FIXME -- should E be an int value?
               FloatMatrix e;
               map_2_xlog2 (x, f, e);
-              retval (1) = e;
-              retval (0) = f;
+              retval(1) = e;
+              retval(0) = f;
             }
           else if (args(0).is_complex_type ())
             {
@@ -464,8 +459,8 @@
               // FIXME -- should E be an int value?
               FloatNDArray e;
               map_2_xlog2 (x, f, e);
-              retval (1) = e;
-              retval (0) = f;
+              retval(1) = e;
+              retval(0) = f;
             }
         }
       else if (args(0).is_real_type ())
@@ -475,8 +470,8 @@
           // FIXME -- should E be an int value?
           Matrix e;
           map_2_xlog2 (x, f, e);
-          retval (1) = e;
-          retval (0) = f;
+          retval(1) = e;
+          retval(0) = f;
         }
       else if (args(0).is_complex_type ())
         {
@@ -485,8 +480,8 @@
           // FIXME -- should E be an int value?
           NDArray e;
           map_2_xlog2 (x, f, e);
-          retval (1) = e;
-          retval (0) = f;
+          retval(1) = e;
+          retval(0) = f;
         }
       else
         gripe_wrong_type_arg ("log2", args(0));
@@ -498,16 +493,16 @@
 }
 
 /*
-%!assert(log2 ([1/4, 1/2, 1, 2, 4]), [-2, -1, 0, 1, 2]);
-%!assert(log2(Inf), Inf);
-%!assert(isnan(log2(NaN)));
-%!assert(log2(4*i), 2 + log2(1*i));
-%!assert(log2(complex(0,Inf)), Inf + log2(i));
+%!assert (log2 ([1/4, 1/2, 1, 2, 4]), [-2, -1, 0, 1, 2])
+%!assert (log2 (Inf), Inf)
+%!assert (isnan (log2 (NaN)))
+%!assert (log2 (4*i), 2 + log2 (1*i))
+%!assert (log2 (complex (0,Inf)), Inf + log2 (i))
 
 %!test
 %! [f, e] = log2 ([0,-1; 2,-4; Inf,-Inf]);
 %! assert (f, [0,-0.5; 0.5,-0.5; Inf,-Inf]);
-%! assert (e(1:2,:), [0,1;2,3])
+%! assert (e(1:2,:), [0,1;2,3]);
 
 %!test
 %! [f, e] = log2 (complex (zeros (3, 2), [0,-1; 2,-4; Inf,-Inf]));
@@ -620,21 +615,21 @@
 }
 
 /*
-
-%!assert(rem ([1, 2, 3; -1, -2, -3], 2), [1, 0, 1; -1, 0, -1]);
-%!assert(rem ([1, 2, 3; -1, -2, -3], 2 * ones (2, 3)),[1, 0, 1; -1, 0, -1]);
-%!error rem ();
-%!error rem (1, 2, 3);
-%!error rem ([1, 2], [3, 4, 5]);
-%!error rem (i, 1);
-%!assert(rem (uint8([1, 2, 3; -1, -2, -3]), uint8 (2)), uint8([1, 0, 1; -1, 0, -1]));
-%!assert(uint8(rem ([1, 2, 3; -1, -2, -3], 2 * ones (2, 3))),uint8([1, 0, 1; -1, 0, -1]));
-%!error rem (uint(8),int8(5));
-%!error rem (uint8([1, 2]), uint8([3, 4, 5]));
-
+%!assert (rem ([1, 2, 3; -1, -2, -3], 2), [1, 0, 1; -1, 0, -1])
+%!assert (rem ([1, 2, 3; -1, -2, -3], 2 * ones (2, 3)),[1, 0, 1; -1, 0, -1])
+%!assert (rem (uint8 ([1, 2, 3; -1, -2, -3]), uint8 (2)), uint8 ([1, 0, 1; -1, 0, -1]))
+%!assert (uint8 (rem ([1, 2, 3; -1, -2, -3], 2 * ones (2, 3))),uint8 ([1, 0, 1; -1, 0, -1]))
+
+%!error rem (uint (8), int8 (5))
+%!error rem (uint8 ([1, 2]), uint8 ([3, 4, 5]))
+%!error rem ()
+%!error rem (1, 2, 3)
+%!error rem ([1, 2], [3, 4, 5])
+%!error rem (i, 1)
 */
 
 /*
+
 %!assert (size (fmod (zeros (0, 2), zeros (0, 2))), [0, 2])
 %!assert (size (fmod (rand (2, 3, 4), zeros (2, 3, 4))), [2, 3, 4])
 %!assert (size (fmod (rand (2, 3, 4), 1)), [2, 3, 4])
@@ -754,48 +749,48 @@
 
 /*
 ## empty input test
-%!assert (isempty(mod([], [])));
+%!assert (isempty (mod ([], [])))
 
 ## x mod y, y != 0 tests
-%!assert (mod(5, 3), 2);
-%!assert (mod(-5, 3), 1);
-%!assert (mod(0, 3), 0);
-%!assert (mod([-5, 5, 0], [3, 3, 3]), [1, 2, 0]);
-%!assert (mod([-5; 5; 0], [3; 3; 3]), [1; 2; 0]);
-%!assert (mod([-5, 5; 0, 3], [3, 3 ; 3, 1]), [1, 2 ; 0, 0]);
+%!assert (mod (5, 3), 2)
+%!assert (mod (-5, 3), 1)
+%!assert (mod (0, 3), 0)
+%!assert (mod ([-5, 5, 0], [3, 3, 3]), [1, 2, 0])
+%!assert (mod ([-5; 5; 0], [3; 3; 3]), [1; 2; 0])
+%!assert (mod ([-5, 5; 0, 3], [3, 3 ; 3, 1]), [1, 2 ; 0, 0])
 
 ## x mod 0 tests
-%!assert (mod(5, 0), 5);
-%!assert (mod(-5, 0), -5);
-%!assert (mod([-5, 5, 0], [3, 0, 3]), [1, 5, 0]);
-%!assert (mod([-5; 5; 0], [3; 0; 3]), [1; 5; 0]);
-%!assert (mod([-5, 5; 0, 3], [3, 0 ; 3, 1]), [1, 5 ; 0, 0]);
-%!assert (mod([-5, 5; 0, 3], [0, 0 ; 0, 0]), [-5, 5; 0, 3]);
+%!assert (mod (5, 0), 5)
+%!assert (mod (-5, 0), -5)
+%!assert (mod ([-5, 5, 0], [3, 0, 3]), [1, 5, 0])
+%!assert (mod ([-5; 5; 0], [3; 0; 3]), [1; 5; 0])
+%!assert (mod ([-5, 5; 0, 3], [3, 0 ; 3, 1]), [1, 5 ; 0, 0])
+%!assert (mod ([-5, 5; 0, 3], [0, 0 ; 0, 0]), [-5, 5; 0, 3])
 
 ## mixed scalar/matrix tests
-%!assert (mod([-5, 5; 0, 3], 0), [-5, 5; 0, 3]);
-%!assert (mod([-5, 5; 0, 3], 3), [1, 2; 0, 0]);
-%!assert (mod(-5,[0,0; 0,0]), [-5, -5; -5, -5]);
-%!assert (mod(-5,[3,0; 3,1]), [1, -5; 1, 0]);
-%!assert (mod(-5,[3,2; 3,1]), [1, 1; 1, 0]);
+%!assert (mod ([-5, 5; 0, 3], 0), [-5, 5; 0, 3])
+%!assert (mod ([-5, 5; 0, 3], 3), [1, 2; 0, 0])
+%!assert (mod (-5, [0,0; 0,0]), [-5, -5; -5, -5])
+%!assert (mod (-5, [3,0; 3,1]), [1, -5; 1, 0])
+%!assert (mod (-5, [3,2; 3,1]), [1, 1; 1, 0])
 
 ## integer types
-%!assert (mod(uint8(5),uint8(4)),uint8(1))
-%!assert (mod(uint8([1:5]),uint8(4)),uint8([1,2,3,0,1]))
-%!assert (mod(uint8([1:5]),uint8(0)),uint8([1:5]))
-%!error (mod(uint8(5),int8(4)))
+%!assert (mod (uint8 (5), uint8 (4)), uint8 (1))
+%!assert (mod (uint8 ([1:5]), uint8 (4)), uint8 ([1,2,3,0,1]))
+%!assert (mod (uint8 ([1:5]), uint8 (0)), uint8 ([1:5]))
+%!error (mod (uint8 (5), int8 (4)))
 
 ## mixed integer/real types
-%!assert (mod(uint8(5),4),uint8(1))
-%!assert (mod(5,uint8(4)),uint8(1))
-%!assert (mod(uint8([1:5]),4),uint8([1,2,3,0,1]))
+%!assert (mod (uint8 (5), 4), uint8 (1))
+%!assert (mod (5, uint8 (4)), uint8 (1))
+%!assert (mod (uint8 ([1:5]), 4), uint8 ([1,2,3,0,1]))
 
 ## non-integer real numbers
 %!assert (mod (2.1, 0.1), 0)
 %!assert (mod (2.1, 0.2), 0.1, eps)
 */
 
-// FIXME Need to convert the reduction functions of this file for single precision
+// FIXME: Need to convert the reduction functions of this file for single precision
 
 #define NATIVE_REDUCTION_1(FCN, TYPE, DIM) \
   (arg.is_ ## TYPE ## _type ()) \
@@ -1068,39 +1063,37 @@
 }
 
 /*
-
-%!assert (cumprod ([1, 2, 3]), [1, 2, 6]);
-%!assert (cumprod ([-1; -2; -3]), [-1; 2; -6]);
-%!assert (cumprod ([i, 2+i, -3+2i, 4]), [i, -1+2i, -1-8i, -4-32i]);
-%!assert (cumprod ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]), [1, 2, 3; i, 4i, 9i; -1+i, -8+8i, -27+27i]);
-
-%!assert (cumprod (single([1, 2, 3])), single([1, 2, 6]));
-%!assert (cumprod (single([-1; -2; -3])), single([-1; 2; -6]));
-%!assert (cumprod (single([i, 2+i, -3+2i, 4])), single([i, -1+2i, -1-8i, -4-32i]));
-%!assert (cumprod (single([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i])), single([1, 2, 3; i, 4i, 9i; -1+i, -8+8i, -27+27i]));
-
-%!error <Invalid call to cumprod> cumprod ();
-
-%!assert (cumprod ([2, 3; 4, 5], 1), [2, 3; 8, 15]);
-%!assert (cumprod ([2, 3; 4, 5], 2), [2, 6; 4, 20]);
-
-%!assert (cumprod (single([2, 3; 4, 5]), 1), single([2, 3; 8, 15]));
-%!assert (cumprod (single([2, 3; 4, 5]), 2), single([2, 6; 4, 20]));
-
- */
+%!assert (cumprod ([1, 2, 3]), [1, 2, 6])
+%!assert (cumprod ([-1; -2; -3]), [-1; 2; -6])
+%!assert (cumprod ([i, 2+i, -3+2i, 4]), [i, -1+2i, -1-8i, -4-32i])
+%!assert (cumprod ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]), [1, 2, 3; i, 4i, 9i; -1+i, -8+8i, -27+27i])
+
+%!assert (cumprod (single ([1, 2, 3])), single ([1, 2, 6]))
+%!assert (cumprod (single ([-1; -2; -3])), single ([-1; 2; -6]))
+%!assert (cumprod (single ([i, 2+i, -3+2i, 4])), single ([i, -1+2i, -1-8i, -4-32i]))
+%!assert (cumprod (single ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i])), single ([1, 2, 3; i, 4i, 9i; -1+i, -8+8i, -27+27i]))
+
+%!assert (cumprod ([2, 3; 4, 5], 1), [2, 3; 8, 15])
+%!assert (cumprod ([2, 3; 4, 5], 2), [2, 6; 4, 20])
+
+%!assert (cumprod (single ([2, 3; 4, 5]), 1), single ([2, 3; 8, 15]))
+%!assert (cumprod (single ([2, 3; 4, 5]), 2), single ([2, 6; 4, 20]))
+
+%!error cumprod ()
+*/
 
 DEFUN (cumsum, args, ,
   "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {} cumsum (@var{x})\n\
 @deftypefnx {Built-in Function} {} cumsum (@var{x}, @var{dim})\n\
-@deftypefnx {Built-in Function} {} cumsum (@dots{}, 'native')\n\
-@deftypefnx {Built-in Function} {} cumsum (@dots{}, 'double')\n\
-@deftypefnx {Built-in Function} {} cumsum (@dots{}, 'extra')\n\
+@deftypefnx {Built-in Function} {} cumsum (@dots{}, \"native\")\n\
+@deftypefnx {Built-in Function} {} cumsum (@dots{}, \"double\")\n\
+@deftypefnx {Built-in Function} {} cumsum (@dots{}, \"extra\")\n\
 Cumulative sum of elements along dimension @var{dim}.  If @var{dim}\n\
 is omitted, it defaults to the first non-singleton dimension.\n\
 \n\
-See @code{sum} for an explanation of the optional parameters 'native',\n\
-'double', and 'extra'.\n\
+See @code{sum} for an explanation of the optional parameters \"native\",\n\
+\"double\", and \"extra\".\n\
 @seealso{sum, cumprod}\n\
 @end deftypefn")
 {
@@ -1219,26 +1212,24 @@
 }
 
 /*
-
-%!assert (cumsum ([1, 2, 3]), [1, 3, 6]);
-%!assert (cumsum ([-1; -2; -3]), [-1; -3; -6]);
-%!assert (cumsum ([i, 2+i, -3+2i, 4]), [i, 2+2i, -1+4i, 3+4i]);
-%!assert (cumsum ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]), [1, 2, 3; 1+i, 2+2i, 3+3i; 2+2i, 4+4i, 6+6i]);
-
-%!assert (cumsum (single([1, 2, 3])), single([1, 3, 6]));
-%!assert (cumsum (single([-1; -2; -3])), single([-1; -3; -6]));
-%!assert (cumsum (single([i, 2+i, -3+2i, 4])), single([i, 2+2i, -1+4i, 3+4i]));
-%!assert (cumsum (single([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i])), single([1, 2, 3; 1+i, 2+2i, 3+3i; 2+2i, 4+4i, 6+6i]));
-
-%!error <Invalid call to cumsum> cumsum ();
-
-%!assert (cumsum ([1, 2; 3, 4], 1), [1, 2; 4, 6]);
-%!assert (cumsum ([1, 2; 3, 4], 2), [1, 3; 3, 7]);
-
-%!assert (cumsum (single([1, 2; 3, 4]), 1), single([1, 2; 4, 6]));
-%!assert (cumsum (single([1, 2; 3, 4]), 2), single([1, 3; 3, 7]));
-
- */
+%!assert (cumsum ([1, 2, 3]), [1, 3, 6])
+%!assert (cumsum ([-1; -2; -3]), [-1; -3; -6])
+%!assert (cumsum ([i, 2+i, -3+2i, 4]), [i, 2+2i, -1+4i, 3+4i])
+%!assert (cumsum ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]), [1, 2, 3; 1+i, 2+2i, 3+3i; 2+2i, 4+4i, 6+6i])
+
+%!assert (cumsum (single ([1, 2, 3])), single ([1, 3, 6]))
+%!assert (cumsum (single ([-1; -2; -3])), single ([-1; -3; -6]))
+%!assert (cumsum (single ([i, 2+i, -3+2i, 4])), single ([i, 2+2i, -1+4i, 3+4i]))
+%!assert (cumsum (single ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i])), single ([1, 2, 3; 1+i, 2+2i, 3+3i; 2+2i, 4+4i, 6+6i]))
+
+%!assert (cumsum ([1, 2; 3, 4], 1), [1, 2; 4, 6])
+%!assert (cumsum ([1, 2; 3, 4], 2), [1, 3; 3, 7])
+
+%!assert (cumsum (single ([1, 2; 3, 4]), 1), single ([1, 2; 4, 6]))
+%!assert (cumsum (single ([1, 2; 3, 4]), 2), single ([1, 3; 3, 7]))
+
+%!error cumsum ()
+*/
 
 DEFUN (diag, args, ,
   "-*- texinfo -*-\n\
@@ -1256,10 +1247,10 @@
 @example\n\
 @group\n\
 diag ([1, 2, 3], 1)\n\
-     @result{}  0  1  0  0\n\
-         0  0  2  0\n\
-         0  0  0  3\n\
-         0  0  0  0\n\
+   @result{}  0  1  0  0\n\
+       0  0  2  0\n\
+       0  0  0  3\n\
+       0  0  0  0\n\
 @end group\n\
 @end example\n\
 \n\
@@ -1277,7 +1268,7 @@
   int nargin = args.length ();
 
   if (nargin == 1 && args(0).is_defined ())
-    retval = args(0).diag();
+    retval = args(0).diag ();
   else if (nargin == 2 && args(0).is_defined () && args(1).is_defined ())
     {
       octave_idx_type k = args(1).int_value ();
@@ -1285,29 +1276,19 @@
       if (error_state)
         error ("diag: invalid argument K");
       else
-        retval = args(0).diag(k);
+        retval = args(0).diag (k);
     }
   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)
-            {
-              if (arg0.is_cell ())
-                {
-                  Cell rhs = arg0.cell_value ();
-                  Cell tmp (m, n);
-
-                  for (octave_idx_type i = 0; i < rhs.numel (); i++)
-                    tmp.xelem (i, i) = rhs.xelem (i);
-
-                  retval = tmp;
-                }
-              else
-                retval = arg0.diag ().resize (dim_vector (m, n), true);
-            }
+            retval = arg0.diag (m, n);
           else
             error ("diag: invalid dimensions");
         }
@@ -1322,51 +1303,59 @@
 
 /*
 
-%!assert(full (diag ([1; 2; 3])), [1, 0, 0; 0, 2, 0; 0, 0, 3]);
-%!assert(diag ([1; 2; 3], 1), [0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]);
-%!assert(diag ([1; 2; 3], 2), [0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0]);
-%!assert(diag ([1; 2; 3],-1), [0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]);
-%!assert(diag ([1; 2; 3],-2), [0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0]);
-
-%!assert(diag ([1, 0, 0; 0, 2, 0; 0, 0, 3]), [1; 2; 3]);
-%!assert(diag ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0], 1), [1; 2; 3]);
-%!assert(diag ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0], -1), [1; 2; 3]);
-%!assert(diag (ones(1, 0), 2), zeros (2));
-%!assert(diag (1:3, 4, 2), [1, 0; 0, 2; 0, 0; 0, 0]);
-
-%!assert(full (diag (single([1; 2; 3]))), single([1, 0, 0; 0, 2, 0; 0, 0, 3]));
-%!assert(diag (single([1; 2; 3]), 1), single([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]));
-%!assert(diag (single([1; 2; 3]), 2), single([0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0]));
-%!assert(diag (single([1; 2; 3]),-1), single([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]));
-%!assert(diag (single([1; 2; 3]),-2), single([0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0]));
-
-%!assert(diag (single([1, 0, 0; 0, 2, 0; 0, 0, 3])), single([1; 2; 3]));
-%!assert(diag (single([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]), 1), single([1; 2; 3]));
-%!assert(diag (single([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]), -1), single([1; 2; 3]));
-
-%!assert(diag (int8([1; 2; 3])), int8([1, 0, 0; 0, 2, 0; 0, 0, 3]));
-%!assert(diag (int8([1; 2; 3]), 1), int8([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]));
-%!assert(diag (int8([1; 2; 3]), 2), int8([0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0]));
-%!assert(diag (int8([1; 2; 3]),-1), int8([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]));
-%!assert(diag (int8([1; 2; 3]),-2), int8([0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0]));
-
-%!assert(diag (int8([1, 0, 0; 0, 2, 0; 0, 0, 3])), int8([1; 2; 3]));
-%!assert(diag (int8([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]), 1), int8([1; 2; 3]));
-%!assert(diag (int8([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]), -1), int8([1; 2; 3]));
+%!assert (full (diag ([1; 2; 3])), [1, 0, 0; 0, 2, 0; 0, 0, 3])
+%!assert (diag ([1; 2; 3], 1), [0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0])
+%!assert (diag ([1; 2; 3], 2), [0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0])
+%!assert (diag ([1; 2; 3],-1), [0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0])
+%!assert (diag ([1; 2; 3],-2), [0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0])
+
+%!assert (diag ([1, 0, 0; 0, 2, 0; 0, 0, 3]), [1; 2; 3])
+%!assert (diag ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0], 1), [1; 2; 3])
+%!assert (diag ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0], -1), [1; 2; 3])
+%!assert (diag (ones (1, 0), 2), zeros (2))
+%!assert (diag (1:3, 4, 2), [1, 0; 0, 2; 0, 0; 0, 0])
+
+%!assert (full (diag (single ([1; 2; 3]))), single ([1, 0, 0; 0, 2, 0; 0, 0, 3]))
+%!assert (diag (single ([1; 2; 3]), 1), single ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]))
+%!assert (diag (single ([1; 2; 3]), 2), single ([0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0]))
+%!assert (diag (single ([1; 2; 3]),-1), single ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]))
+%!assert (diag (single ([1; 2; 3]),-2), single ([0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0]))
+
+%!assert (diag (single ([1, 0, 0; 0, 2, 0; 0, 0, 3])), single ([1; 2; 3]))
+%!assert (diag (single ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]), 1), single ([1; 2; 3]))
+%!assert (diag (single ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]), -1), single ([1; 2; 3]))
+
+%!assert (diag (int8 ([1; 2; 3])), int8 ([1, 0, 0; 0, 2, 0; 0, 0, 3]))
+%!assert (diag (int8 ([1; 2; 3]), 1), int8 ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]))
+%!assert (diag (int8 ([1; 2; 3]), 2), int8 ([0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0]))
+%!assert (diag (int8 ([1; 2; 3]),-1), int8 ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]))
+%!assert (diag (int8 ([1; 2; 3]),-2), int8 ([0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0]))
+
+%!assert (diag (int8 ([1, 0, 0; 0, 2, 0; 0, 0, 3])), int8 ([1; 2; 3]))
+%!assert (diag (int8 ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]), 1), int8 ([1; 2; 3]))
+%!assert (diag (int8 ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]), -1), int8 ([1; 2; 3]))
 
 ## 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], 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 ();
-%!error <Invalid call to diag> diag (1,2,3,4);
-%!error diag (ones (2), 3, 3);
-%!error diag (1:3, -4, 3);
-
- */
+%!error <Invalid call to diag> diag ()
+%!error <Invalid call to diag> diag (1,2,3,4)
+%!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\
@@ -1381,50 +1370,48 @@
 }
 
 /*
-
-%!assert (prod ([1, 2, 3]), 6);
-%!assert (prod ([-1; -2; -3]), -6);
-%!assert (prod ([i, 2+i, -3+2i, 4]), -4 - 32i);
-%!assert (prod ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]), [-1+i, -8+8i, -27+27i]);
-
-%!assert (prod (single([1, 2, 3])), single(6));
-%!assert (prod (single([-1; -2; -3])), single(-6));
-%!assert (prod (single([i, 2+i, -3+2i, 4])), single(-4 - 32i));
-%!assert (prod (single([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i])), single([-1+i, -8+8i, -27+27i]));
-
-%!error <Invalid call to prod> prod ();
-
-%!assert (prod ([1, 2; 3, 4], 1), [3, 8]);
-%!assert (prod ([1, 2; 3, 4], 2), [2; 12]);
-%!assert (prod (zeros (1, 0)), 1);
-%!assert (prod (zeros (1, 0), 1), zeros (1, 0));
-%!assert (prod (zeros (1, 0), 2), 1);
-%!assert (prod (zeros (0, 1)), 1);
-%!assert (prod (zeros (0, 1), 1), 1);
-%!assert (prod (zeros (0, 1), 2), zeros (0, 1));
-%!assert (prod (zeros (2, 0)), zeros (1, 0));
-%!assert (prod (zeros (2, 0), 1), zeros (1, 0));
-%!assert (prod (zeros (2, 0), 2), [1; 1]);
-%!assert (prod (zeros (0, 2)), [1, 1]);
-%!assert (prod (zeros (0, 2), 1), [1, 1]);
-%!assert (prod (zeros (0, 2), 2), zeros(0, 1));
-
-%!assert (prod (single([1, 2; 3, 4]), 1), single([3, 8]));
-%!assert (prod (single([1, 2; 3, 4]), 2), single([2; 12]));
-%!assert (prod (zeros (1, 0, 'single')), single(1));
-%!assert (prod (zeros (1, 0, 'single'), 1), zeros (1, 0, 'single'));
-%!assert (prod (zeros (1, 0, 'single'), 2), single(1));
-%!assert (prod (zeros (0, 1, 'single')), single(1));
-%!assert (prod (zeros (0, 1, 'single'), 1), single(1));
-%!assert (prod (zeros (0, 1, 'single'), 2), zeros (0, 1, 'single'));
-%!assert (prod (zeros (2, 0, 'single')), zeros (1, 0, 'single'));
-%!assert (prod (zeros (2, 0, 'single'), 1), zeros (1, 0, 'single'));
-%!assert (prod (zeros (2, 0, 'single'), 2), single([1; 1]));
-%!assert (prod (zeros (0, 2, 'single')), single([1, 1]));
-%!assert (prod (zeros (0, 2, 'single'), 1), single([1, 1]));
-%!assert (prod (zeros (0, 2, 'single'), 2), zeros(0, 1, 'single'));
-
- */
+%!assert (prod ([1, 2, 3]), 6)
+%!assert (prod ([-1; -2; -3]), -6)
+%!assert (prod ([i, 2+i, -3+2i, 4]), -4 - 32i)
+%!assert (prod ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]), [-1+i, -8+8i, -27+27i])
+
+%!assert (prod (single ([1, 2, 3])), single (6))
+%!assert (prod (single ([-1; -2; -3])), single (-6))
+%!assert (prod (single ([i, 2+i, -3+2i, 4])), single (-4 - 32i))
+%!assert (prod (single ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i])), single ([-1+i, -8+8i, -27+27i]))
+
+%!assert (prod ([1, 2; 3, 4], 1), [3, 8])
+%!assert (prod ([1, 2; 3, 4], 2), [2; 12])
+%!assert (prod (zeros (1, 0)), 1)
+%!assert (prod (zeros (1, 0), 1), zeros (1, 0))
+%!assert (prod (zeros (1, 0), 2), 1)
+%!assert (prod (zeros (0, 1)), 1)
+%!assert (prod (zeros (0, 1), 1), 1)
+%!assert (prod (zeros (0, 1), 2), zeros (0, 1))
+%!assert (prod (zeros (2, 0)), zeros (1, 0))
+%!assert (prod (zeros (2, 0), 1), zeros (1, 0))
+%!assert (prod (zeros (2, 0), 2), [1; 1])
+%!assert (prod (zeros (0, 2)), [1, 1])
+%!assert (prod (zeros (0, 2), 1), [1, 1])
+%!assert (prod (zeros (0, 2), 2), zeros (0, 1))
+
+%!assert (prod (single ([1, 2; 3, 4]), 1), single ([3, 8]))
+%!assert (prod (single ([1, 2; 3, 4]), 2), single ([2; 12]))
+%!assert (prod (zeros (1, 0, "single")), single (1))
+%!assert (prod (zeros (1, 0, "single"), 1), zeros (1, 0, "single"))
+%!assert (prod (zeros (1, 0, "single"), 2), single (1))
+%!assert (prod (zeros (0, 1, "single")), single (1))
+%!assert (prod (zeros (0, 1, "single"), 1), single (1))
+%!assert (prod (zeros (0, 1, "single"), 2), zeros (0, 1, "single"))
+%!assert (prod (zeros (2, 0, "single")), zeros (1, 0, "single"))
+%!assert (prod (zeros (2, 0, "single"), 1), zeros (1, 0, "single"))
+%!assert (prod (zeros (2, 0, "single"), 2), single ([1; 1]))
+%!assert (prod (zeros (0, 2, "single")), single ([1, 1]))
+%!assert (prod (zeros (0, 2, "single"), 1), single ([1, 1]))
+%!assert (prod (zeros (0, 2, "single"), 2), zeros (0, 1, "single"))
+
+%!error prod ()
+*/
 
 static bool
 all_scalar_1x1 (const octave_value_list& args)
@@ -1847,7 +1834,7 @@
           for (int j = 0; j < n_args; j++)
             {
               // Can't fast return here to skip empty matrices as something
-              // like cat(1,[],single([])) must return an empty matrix of
+              // like cat (1,[],single ([])) must return an empty matrix of
               // the right type.
               tmp = do_cat_op (tmp, args (j), ra_idx);
 
@@ -1885,7 +1872,7 @@
 new matrices.  For example:\n\
 \n\
 @example\n\
-@var{hcat} = [ @var{array1}, @var{array2}, @dots{} ];\n\
+@var{hcat} = [ @var{array1}, @var{array2}, @dots{} ]\n\
 @end example\n\
 @seealso{cat, vertcat}\n\
 @end deftypefn")
@@ -1894,194 +1881,195 @@
 }
 
 /*
-%% test concatenation with all zero matrices
-%!assert(horzcat ('', 65*ones(1,10)), 'AAAAAAAAAA');
-%!assert(horzcat (65*ones(1,10), ''), 'AAAAAAAAAA');
-
-%!assert (class (horzcat (int64(1), int64(1))), 'int64')
-%!assert (class (horzcat (int64(1), int32(1))), 'int64')
-%!assert (class (horzcat (int64(1), int16(1))), 'int64')
-%!assert (class (horzcat (int64(1), int8(1))), 'int64')
-%!assert (class (horzcat (int64(1), uint64(1))), 'int64')
-%!assert (class (horzcat (int64(1), uint32(1))), 'int64')
-%!assert (class (horzcat (int64(1), uint16(1))), 'int64')
-%!assert (class (horzcat (int64(1), uint8(1))), 'int64')
-%!assert (class (horzcat (int64(1), single(1))), 'int64')
-%!assert (class (horzcat (int64(1), double(1))), 'int64')
-%!assert (class (horzcat (int64(1), cell(1))), 'cell')
-%!assert (class (horzcat (int64(1), true)), 'int64')
-%!assert (class (horzcat (int64(1), 'a')), 'char')
-
-%!assert (class (horzcat (int32(1), int64(1))), 'int32')
-%!assert (class (horzcat (int32(1), int32(1))), 'int32')
-%!assert (class (horzcat (int32(1), int16(1))), 'int32')
-%!assert (class (horzcat (int32(1), int8(1))), 'int32')
-%!assert (class (horzcat (int32(1), uint64(1))), 'int32')
-%!assert (class (horzcat (int32(1), uint32(1))), 'int32')
-%!assert (class (horzcat (int32(1), uint16(1))), 'int32')
-%!assert (class (horzcat (int32(1), uint8(1))), 'int32')
-%!assert (class (horzcat (int32(1), single(1))), 'int32')
-%!assert (class (horzcat (int32(1), double(1))), 'int32')
-%!assert (class (horzcat (int32(1), cell(1))), 'cell')
-%!assert (class (horzcat (int32(1), true)), 'int32')
-%!assert (class (horzcat (int32(1), 'a')), 'char')
-
-%!assert (class (horzcat (int16(1), int64(1))), 'int16')
-%!assert (class (horzcat (int16(1), int32(1))), 'int16')
-%!assert (class (horzcat (int16(1), int16(1))), 'int16')
-%!assert (class (horzcat (int16(1), int8(1))), 'int16')
-%!assert (class (horzcat (int16(1), uint64(1))), 'int16')
-%!assert (class (horzcat (int16(1), uint32(1))), 'int16')
-%!assert (class (horzcat (int16(1), uint16(1))), 'int16')
-%!assert (class (horzcat (int16(1), uint8(1))), 'int16')
-%!assert (class (horzcat (int16(1), single(1))), 'int16')
-%!assert (class (horzcat (int16(1), double(1))), 'int16')
-%!assert (class (horzcat (int16(1), cell(1))), 'cell')
-%!assert (class (horzcat (int16(1), true)), 'int16')
-%!assert (class (horzcat (int16(1), 'a')), 'char')
-
-%!assert (class (horzcat (int8(1), int64(1))), 'int8')
-%!assert (class (horzcat (int8(1), int32(1))), 'int8')
-%!assert (class (horzcat (int8(1), int16(1))), 'int8')
-%!assert (class (horzcat (int8(1), int8(1))), 'int8')
-%!assert (class (horzcat (int8(1), uint64(1))), 'int8')
-%!assert (class (horzcat (int8(1), uint32(1))), 'int8')
-%!assert (class (horzcat (int8(1), uint16(1))), 'int8')
-%!assert (class (horzcat (int8(1), uint8(1))), 'int8')
-%!assert (class (horzcat (int8(1), single(1))), 'int8')
-%!assert (class (horzcat (int8(1), double(1))), 'int8')
-%!assert (class (horzcat (int8(1), cell(1))), 'cell')
-%!assert (class (horzcat (int8(1), true)), 'int8')
-%!assert (class (horzcat (int8(1), 'a')), 'char')
-
-%!assert (class (horzcat (uint64(1), int64(1))), 'uint64')
-%!assert (class (horzcat (uint64(1), int32(1))), 'uint64')
-%!assert (class (horzcat (uint64(1), int16(1))), 'uint64')
-%!assert (class (horzcat (uint64(1), int8(1))), 'uint64')
-%!assert (class (horzcat (uint64(1), uint64(1))), 'uint64')
-%!assert (class (horzcat (uint64(1), uint32(1))), 'uint64')
-%!assert (class (horzcat (uint64(1), uint16(1))), 'uint64')
-%!assert (class (horzcat (uint64(1), uint8(1))), 'uint64')
-%!assert (class (horzcat (uint64(1), single(1))), 'uint64')
-%!assert (class (horzcat (uint64(1), double(1))), 'uint64')
-%!assert (class (horzcat (uint64(1), cell(1))), 'cell')
-%!assert (class (horzcat (uint64(1), true)), 'uint64')
-%!assert (class (horzcat (uint64(1), 'a')), 'char')
-
-%!assert (class (horzcat (uint32(1), int64(1))), 'uint32')
-%!assert (class (horzcat (uint32(1), int32(1))), 'uint32')
-%!assert (class (horzcat (uint32(1), int16(1))), 'uint32')
-%!assert (class (horzcat (uint32(1), int8(1))), 'uint32')
-%!assert (class (horzcat (uint32(1), uint64(1))), 'uint32')
-%!assert (class (horzcat (uint32(1), uint32(1))), 'uint32')
-%!assert (class (horzcat (uint32(1), uint16(1))), 'uint32')
-%!assert (class (horzcat (uint32(1), uint8(1))), 'uint32')
-%!assert (class (horzcat (uint32(1), single(1))), 'uint32')
-%!assert (class (horzcat (uint32(1), double(1))), 'uint32')
-%!assert (class (horzcat (uint32(1), cell(1))), 'cell')
-%!assert (class (horzcat (uint32(1), true)), 'uint32')
-%!assert (class (horzcat (uint32(1), 'a')), 'char')
-
-%!assert (class (horzcat (uint16(1), int64(1))), 'uint16')
-%!assert (class (horzcat (uint16(1), int32(1))), 'uint16')
-%!assert (class (horzcat (uint16(1), int16(1))), 'uint16')
-%!assert (class (horzcat (uint16(1), int8(1))), 'uint16')
-%!assert (class (horzcat (uint16(1), uint64(1))), 'uint16')
-%!assert (class (horzcat (uint16(1), uint32(1))), 'uint16')
-%!assert (class (horzcat (uint16(1), uint16(1))), 'uint16')
-%!assert (class (horzcat (uint16(1), uint8(1))), 'uint16')
-%!assert (class (horzcat (uint16(1), single(1))), 'uint16')
-%!assert (class (horzcat (uint16(1), double(1))), 'uint16')
-%!assert (class (horzcat (uint16(1), cell(1))), 'cell')
-%!assert (class (horzcat (uint16(1), true)), 'uint16')
-%!assert (class (horzcat (uint16(1), 'a')), 'char')
-
-%!assert (class (horzcat (uint8(1), int64(1))), 'uint8')
-%!assert (class (horzcat (uint8(1), int32(1))), 'uint8')
-%!assert (class (horzcat (uint8(1), int16(1))), 'uint8')
-%!assert (class (horzcat (uint8(1), int8(1))), 'uint8')
-%!assert (class (horzcat (uint8(1), uint64(1))), 'uint8')
-%!assert (class (horzcat (uint8(1), uint32(1))), 'uint8')
-%!assert (class (horzcat (uint8(1), uint16(1))), 'uint8')
-%!assert (class (horzcat (uint8(1), uint8(1))), 'uint8')
-%!assert (class (horzcat (uint8(1), single(1))), 'uint8')
-%!assert (class (horzcat (uint8(1), double(1))), 'uint8')
-%!assert (class (horzcat (uint8(1), cell(1))), 'cell')
-%!assert (class (horzcat (uint8(1), true)), 'uint8')
-%!assert (class (horzcat (uint8(1), 'a')), 'char')
-
-%!assert (class (horzcat (single(1), int64(1))), 'int64')
-%!assert (class (horzcat (single(1), int32(1))), 'int32')
-%!assert (class (horzcat (single(1), int16(1))), 'int16')
-%!assert (class (horzcat (single(1), int8(1))), 'int8')
-%!assert (class (horzcat (single(1), uint64(1))), 'uint64')
-%!assert (class (horzcat (single(1), uint32(1))), 'uint32')
-%!assert (class (horzcat (single(1), uint16(1))), 'uint16')
-%!assert (class (horzcat (single(1), uint8(1))), 'uint8')
-%!assert (class (horzcat (single(1), single(1))), 'single')
-%!assert (class (horzcat (single(1), double(1))), 'single')
-%!assert (class (horzcat (single(1), cell(1))), 'cell')
-%!assert (class (horzcat (single(1), true)), 'single')
-%!assert (class (horzcat (single(1), 'a')), 'char')
-
-%!assert (class (horzcat (double(1), int64(1))), 'int64')
-%!assert (class (horzcat (double(1), int32(1))), 'int32')
-%!assert (class (horzcat (double(1), int16(1))), 'int16')
-%!assert (class (horzcat (double(1), int8(1))), 'int8')
-%!assert (class (horzcat (double(1), uint64(1))), 'uint64')
-%!assert (class (horzcat (double(1), uint32(1))), 'uint32')
-%!assert (class (horzcat (double(1), uint16(1))), 'uint16')
-%!assert (class (horzcat (double(1), uint8(1))), 'uint8')
-%!assert (class (horzcat (double(1), single(1))), 'single')
-%!assert (class (horzcat (double(1), double(1))), 'double')
-%!assert (class (horzcat (double(1), cell(1))), 'cell')
-%!assert (class (horzcat (double(1), true)), 'double')
-%!assert (class (horzcat (double(1), 'a')), 'char')
-
-%!assert (class (horzcat (cell(1), int64(1))), 'cell')
-%!assert (class (horzcat (cell(1), int32(1))), 'cell')
-%!assert (class (horzcat (cell(1), int16(1))), 'cell')
-%!assert (class (horzcat (cell(1), int8(1))), 'cell')
-%!assert (class (horzcat (cell(1), uint64(1))), 'cell')
-%!assert (class (horzcat (cell(1), uint32(1))), 'cell')
-%!assert (class (horzcat (cell(1), uint16(1))), 'cell')
-%!assert (class (horzcat (cell(1), uint8(1))), 'cell')
-%!assert (class (horzcat (cell(1), single(1))), 'cell')
-%!assert (class (horzcat (cell(1), double(1))), 'cell')
-%!assert (class (horzcat (cell(1), cell(1))), 'cell')
-%!assert (class (horzcat (cell(1), true)), 'cell')
-%!assert (class (horzcat (cell(1), 'a')), 'cell')
-
-%!assert (class (horzcat (true, int64(1))), 'int64')
-%!assert (class (horzcat (true, int32(1))), 'int32')
-%!assert (class (horzcat (true, int16(1))), 'int16')
-%!assert (class (horzcat (true, int8(1))), 'int8')
-%!assert (class (horzcat (true, uint64(1))), 'uint64')
-%!assert (class (horzcat (true, uint32(1))), 'uint32')
-%!assert (class (horzcat (true, uint16(1))), 'uint16')
-%!assert (class (horzcat (true, uint8(1))), 'uint8')
-%!assert (class (horzcat (true, single(1))), 'single')
-%!assert (class (horzcat (true, double(1))), 'double')
-%!assert (class (horzcat (true, cell(1))), 'cell')
-%!assert (class (horzcat (true, true)), 'logical')
-%!assert (class (horzcat (true, 'a')), 'char')
-
-%!assert (class (horzcat ('a', int64(1))), 'char')
-%!assert (class (horzcat ('a', int32(1))), 'char')
-%!assert (class (horzcat ('a', int16(1))), 'char')
-%!assert (class (horzcat ('a', int8(1))), 'char')
-%!assert (class (horzcat ('a', int64(1))), 'char')
-%!assert (class (horzcat ('a', int32(1))), 'char')
-%!assert (class (horzcat ('a', int16(1))), 'char')
-%!assert (class (horzcat ('a', int8(1))), 'char')
-%!assert (class (horzcat ('a', single(1))), 'char')
-%!assert (class (horzcat ('a', double(1))), 'char')
-%!assert (class (horzcat ('a', cell(1))), 'cell')
-%!assert (class (horzcat ('a', true)), 'char')
-%!assert (class (horzcat ('a', 'a')), 'char')
-
-%!assert (class (horzcat (cell(1), struct('foo', 'bar'))), 'cell')
-%!error horzcat (struct('foo', 'bar'), cell(1));
+## Test concatenation with all zero matrices
+%!assert (horzcat ("", 65*ones (1,10)), "AAAAAAAAAA");
+%!assert (horzcat (65*ones (1,10), ""), "AAAAAAAAAA");
+
+%!assert (class (horzcat (int64 (1), int64 (1))), "int64")
+%!assert (class (horzcat (int64 (1), int32 (1))), "int64")
+%!assert (class (horzcat (int64 (1), int16 (1))), "int64")
+%!assert (class (horzcat (int64 (1), int8 (1))), "int64")
+%!assert (class (horzcat (int64 (1), uint64 (1))), "int64")
+%!assert (class (horzcat (int64 (1), uint32 (1))), "int64")
+%!assert (class (horzcat (int64 (1), uint16 (1))), "int64")
+%!assert (class (horzcat (int64 (1), uint8 (1))), "int64")
+%!assert (class (horzcat (int64 (1), single (1))), "int64")
+%!assert (class (horzcat (int64 (1), double (1))), "int64")
+%!assert (class (horzcat (int64 (1), cell (1))), "cell")
+%!assert (class (horzcat (int64 (1), true)), "int64")
+%!assert (class (horzcat (int64 (1), "a")), "char")
+
+%!assert (class (horzcat (int32 (1), int64 (1))), "int32")
+%!assert (class (horzcat (int32 (1), int32 (1))), "int32")
+%!assert (class (horzcat (int32 (1), int16 (1))), "int32")
+%!assert (class (horzcat (int32 (1), int8 (1))), "int32")
+%!assert (class (horzcat (int32 (1), uint64 (1))), "int32")
+%!assert (class (horzcat (int32 (1), uint32 (1))), "int32")
+%!assert (class (horzcat (int32 (1), uint16 (1))), "int32")
+%!assert (class (horzcat (int32 (1), uint8 (1))), "int32")
+%!assert (class (horzcat (int32 (1), single (1))), "int32")
+%!assert (class (horzcat (int32 (1), double (1))), "int32")
+%!assert (class (horzcat (int32 (1), cell (1))), "cell")
+%!assert (class (horzcat (int32 (1), true)), "int32")
+%!assert (class (horzcat (int32 (1), "a")), "char")
+
+%!assert (class (horzcat (int16 (1), int64 (1))), "int16")
+%!assert (class (horzcat (int16 (1), int32 (1))), "int16")
+%!assert (class (horzcat (int16 (1), int16 (1))), "int16")
+%!assert (class (horzcat (int16 (1), int8 (1))), "int16")
+%!assert (class (horzcat (int16 (1), uint64 (1))), "int16")
+%!assert (class (horzcat (int16 (1), uint32 (1))), "int16")
+%!assert (class (horzcat (int16 (1), uint16 (1))), "int16")
+%!assert (class (horzcat (int16 (1), uint8 (1))), "int16")
+%!assert (class (horzcat (int16 (1), single (1))), "int16")
+%!assert (class (horzcat (int16 (1), double (1))), "int16")
+%!assert (class (horzcat (int16 (1), cell (1))), "cell")
+%!assert (class (horzcat (int16 (1), true)), "int16")
+%!assert (class (horzcat (int16 (1), "a")), "char")
+
+%!assert (class (horzcat (int8 (1), int64 (1))), "int8")
+%!assert (class (horzcat (int8 (1), int32 (1))), "int8")
+%!assert (class (horzcat (int8 (1), int16 (1))), "int8")
+%!assert (class (horzcat (int8 (1), int8 (1))), "int8")
+%!assert (class (horzcat (int8 (1), uint64 (1))), "int8")
+%!assert (class (horzcat (int8 (1), uint32 (1))), "int8")
+%!assert (class (horzcat (int8 (1), uint16 (1))), "int8")
+%!assert (class (horzcat (int8 (1), uint8 (1))), "int8")
+%!assert (class (horzcat (int8 (1), single (1))), "int8")
+%!assert (class (horzcat (int8 (1), double (1))), "int8")
+%!assert (class (horzcat (int8 (1), cell (1))), "cell")
+%!assert (class (horzcat (int8 (1), true)), "int8")
+%!assert (class (horzcat (int8 (1), "a")), "char")
+
+%!assert (class (horzcat (uint64 (1), int64 (1))), "uint64")
+%!assert (class (horzcat (uint64 (1), int32 (1))), "uint64")
+%!assert (class (horzcat (uint64 (1), int16 (1))), "uint64")
+%!assert (class (horzcat (uint64 (1), int8 (1))), "uint64")
+%!assert (class (horzcat (uint64 (1), uint64 (1))), "uint64")
+%!assert (class (horzcat (uint64 (1), uint32 (1))), "uint64")
+%!assert (class (horzcat (uint64 (1), uint16 (1))), "uint64")
+%!assert (class (horzcat (uint64 (1), uint8 (1))), "uint64")
+%!assert (class (horzcat (uint64 (1), single (1))), "uint64")
+%!assert (class (horzcat (uint64 (1), double (1))), "uint64")
+%!assert (class (horzcat (uint64 (1), cell (1))), "cell")
+%!assert (class (horzcat (uint64 (1), true)), "uint64")
+%!assert (class (horzcat (uint64 (1), "a")), "char")
+
+%!assert (class (horzcat (uint32 (1), int64 (1))), "uint32")
+%!assert (class (horzcat (uint32 (1), int32 (1))), "uint32")
+%!assert (class (horzcat (uint32 (1), int16 (1))), "uint32")
+%!assert (class (horzcat (uint32 (1), int8 (1))), "uint32")
+%!assert (class (horzcat (uint32 (1), uint64 (1))), "uint32")
+%!assert (class (horzcat (uint32 (1), uint32 (1))), "uint32")
+%!assert (class (horzcat (uint32 (1), uint16 (1))), "uint32")
+%!assert (class (horzcat (uint32 (1), uint8 (1))), "uint32")
+%!assert (class (horzcat (uint32 (1), single (1))), "uint32")
+%!assert (class (horzcat (uint32 (1), double (1))), "uint32")
+%!assert (class (horzcat (uint32 (1), cell (1))), "cell")
+%!assert (class (horzcat (uint32 (1), true)), "uint32")
+%!assert (class (horzcat (uint32 (1), "a")), "char")
+
+%!assert (class (horzcat (uint16 (1), int64 (1))), "uint16")
+%!assert (class (horzcat (uint16 (1), int32 (1))), "uint16")
+%!assert (class (horzcat (uint16 (1), int16 (1))), "uint16")
+%!assert (class (horzcat (uint16 (1), int8 (1))), "uint16")
+%!assert (class (horzcat (uint16 (1), uint64 (1))), "uint16")
+%!assert (class (horzcat (uint16 (1), uint32 (1))), "uint16")
+%!assert (class (horzcat (uint16 (1), uint16 (1))), "uint16")
+%!assert (class (horzcat (uint16 (1), uint8 (1))), "uint16")
+%!assert (class (horzcat (uint16 (1), single (1))), "uint16")
+%!assert (class (horzcat (uint16 (1), double (1))), "uint16")
+%!assert (class (horzcat (uint16 (1), cell (1))), "cell")
+%!assert (class (horzcat (uint16 (1), true)), "uint16")
+%!assert (class (horzcat (uint16 (1), "a")), "char")
+
+%!assert (class (horzcat (uint8 (1), int64 (1))), "uint8")
+%!assert (class (horzcat (uint8 (1), int32 (1))), "uint8")
+%!assert (class (horzcat (uint8 (1), int16 (1))), "uint8")
+%!assert (class (horzcat (uint8 (1), int8 (1))), "uint8")
+%!assert (class (horzcat (uint8 (1), uint64 (1))), "uint8")
+%!assert (class (horzcat (uint8 (1), uint32 (1))), "uint8")
+%!assert (class (horzcat (uint8 (1), uint16 (1))), "uint8")
+%!assert (class (horzcat (uint8 (1), uint8 (1))), "uint8")
+%!assert (class (horzcat (uint8 (1), single (1))), "uint8")
+%!assert (class (horzcat (uint8 (1), double (1))), "uint8")
+%!assert (class (horzcat (uint8 (1), cell (1))), "cell")
+%!assert (class (horzcat (uint8 (1), true)), "uint8")
+%!assert (class (horzcat (uint8 (1), "a")), "char")
+
+%!assert (class (horzcat (single (1), int64 (1))), "int64")
+%!assert (class (horzcat (single (1), int32 (1))), "int32")
+%!assert (class (horzcat (single (1), int16 (1))), "int16")
+%!assert (class (horzcat (single (1), int8 (1))), "int8")
+%!assert (class (horzcat (single (1), uint64 (1))), "uint64")
+%!assert (class (horzcat (single (1), uint32 (1))), "uint32")
+%!assert (class (horzcat (single (1), uint16 (1))), "uint16")
+%!assert (class (horzcat (single (1), uint8 (1))), "uint8")
+%!assert (class (horzcat (single (1), single (1))), "single")
+%!assert (class (horzcat (single (1), double (1))), "single")
+%!assert (class (horzcat (single (1), cell (1))), "cell")
+%!assert (class (horzcat (single (1), true)), "single")
+%!assert (class (horzcat (single (1), "a")), "char")
+
+%!assert (class (horzcat (double (1), int64 (1))), "int64")
+%!assert (class (horzcat (double (1), int32 (1))), "int32")
+%!assert (class (horzcat (double (1), int16 (1))), "int16")
+%!assert (class (horzcat (double (1), int8 (1))), "int8")
+%!assert (class (horzcat (double (1), uint64 (1))), "uint64")
+%!assert (class (horzcat (double (1), uint32 (1))), "uint32")
+%!assert (class (horzcat (double (1), uint16 (1))), "uint16")
+%!assert (class (horzcat (double (1), uint8 (1))), "uint8")
+%!assert (class (horzcat (double (1), single (1))), "single")
+%!assert (class (horzcat (double (1), double (1))), "double")
+%!assert (class (horzcat (double (1), cell (1))), "cell")
+%!assert (class (horzcat (double (1), true)), "double")
+%!assert (class (horzcat (double (1), "a")), "char")
+
+%!assert (class (horzcat (cell (1), int64 (1))), "cell")
+%!assert (class (horzcat (cell (1), int32 (1))), "cell")
+%!assert (class (horzcat (cell (1), int16 (1))), "cell")
+%!assert (class (horzcat (cell (1), int8 (1))), "cell")
+%!assert (class (horzcat (cell (1), uint64 (1))), "cell")
+%!assert (class (horzcat (cell (1), uint32 (1))), "cell")
+%!assert (class (horzcat (cell (1), uint16 (1))), "cell")
+%!assert (class (horzcat (cell (1), uint8 (1))), "cell")
+%!assert (class (horzcat (cell (1), single (1))), "cell")
+%!assert (class (horzcat (cell (1), double (1))), "cell")
+%!assert (class (horzcat (cell (1), cell (1))), "cell")
+%!assert (class (horzcat (cell (1), true)), "cell")
+%!assert (class (horzcat (cell (1), "a")), "cell")
+
+%!assert (class (horzcat (true, int64 (1))), "int64")
+%!assert (class (horzcat (true, int32 (1))), "int32")
+%!assert (class (horzcat (true, int16 (1))), "int16")
+%!assert (class (horzcat (true, int8 (1))), "int8")
+%!assert (class (horzcat (true, uint64 (1))), "uint64")
+%!assert (class (horzcat (true, uint32 (1))), "uint32")
+%!assert (class (horzcat (true, uint16 (1))), "uint16")
+%!assert (class (horzcat (true, uint8 (1))), "uint8")
+%!assert (class (horzcat (true, single (1))), "single")
+%!assert (class (horzcat (true, double (1))), "double")
+%!assert (class (horzcat (true, cell (1))), "cell")
+%!assert (class (horzcat (true, true)), "logical")
+%!assert (class (horzcat (true, "a")), "char")
+
+%!assert (class (horzcat ("a", int64 (1))), "char")
+%!assert (class (horzcat ("a", int32 (1))), "char")
+%!assert (class (horzcat ("a", int16 (1))), "char")
+%!assert (class (horzcat ("a", int8 (1))), "char")
+%!assert (class (horzcat ("a", int64 (1))), "char")
+%!assert (class (horzcat ("a", int32 (1))), "char")
+%!assert (class (horzcat ("a", int16 (1))), "char")
+%!assert (class (horzcat ("a", int8 (1))), "char")
+%!assert (class (horzcat ("a", single (1))), "char")
+%!assert (class (horzcat ("a", double (1))), "char")
+%!assert (class (horzcat ("a", cell (1))), "cell")
+%!assert (class (horzcat ("a", true)), "char")
+%!assert (class (horzcat ("a", "a")), "char")
+
+%!assert (class (horzcat (cell (1), struct ("foo", "bar"))), "cell")
+
+%!error horzcat (struct ("foo", "bar"), cell (1))
 */
 
 DEFUN (vertcat, args, ,
@@ -2094,7 +2082,7 @@
 new matrices.  For example:\n\
 \n\
 @example\n\
-@var{vcat} = [ @var{array1}; @var{array2}; @dots{} ];\n\
+@var{vcat} = [ @var{array1}; @var{array2}; @dots{} ]\n\
 @end example\n\
 @seealso{cat, horzcat}\n\
 @end deftypefn")
@@ -2104,8 +2092,8 @@
 
 /*
 %!test
-%! c = {'foo'; 'bar'; 'bazoloa'};
-%! assert (vertcat (c, 'a', 'bc', 'def'), {'foo'; 'bar'; 'bazoloa'; 'a'; 'bc'; 'def'});
+%! c = {"foo"; "bar"; "bazoloa"};
+%! assert (vertcat (c, "a", "bc", "def"), {"foo"; "bar"; "bazoloa"; "a"; "bc"; "def"});
 */
 
 DEFUN (cat, args, ,
@@ -2119,17 +2107,17 @@
 A = ones (2, 2);\n\
 B = zeros (2, 2);\n\
 cat (2, A, B)\n\
-    @result{} 1 1 0 0\n\
-       1 1 0 0\n\
+  @result{} 1 1 0 0\n\
+     1 1 0 0\n\
 @end group\n\
 @end example\n\
 \n\
 Alternatively, we can concatenate @var{A} and @var{B} along the\n\
-second dimension the following way:\n\
+second dimension in the following way:\n\
 \n\
 @example\n\
 @group\n\
-[A, B].\n\
+[A, B]\n\
 @end group\n\
 @end example\n\
 \n\
@@ -2140,16 +2128,15 @@
 @example\n\
 @group\n\
 cat (4, ones (2, 2), zeros (2, 2))\n\
-    @result{} ans =\n\
-\n\
-       ans(:,:,1,1) =\n\
-\n\
-         1 1\n\
-         1 1\n\
-\n\
-       ans(:,:,1,2) =\n\
-         0 0\n\
-         0 0\n\
+  @result{} ans(:,:,1,1) =\n\
+\n\
+       1 1\n\
+       1 1\n\
+\n\
+     ans(:,:,1,2) =\n\
+\n\
+       0 0\n\
+       0 0\n\
 @end group\n\
 @end example\n\
 @seealso{horzcat, vertcat}\n\
@@ -2178,132 +2165,131 @@
 }
 
 /*
-
 %!function ret = __testcat (t1, t2, tr, cmplx)
-%! assert (cat (1, cast ([], t1), cast([], t2)), cast ([], tr));
-%!
-%! assert (cat (1, cast (1, t1), cast (2, t2)), cast ([1; 2], tr));
-%! assert (cat (1, cast (1, t1), cast ([2; 3], t2)), cast ([1; 2; 3], tr));
-%! assert (cat (1, cast ([1; 2], t1), cast (3, t2)), cast ([1; 2; 3], tr));
-%! assert (cat (1, cast ([1; 2], t1), cast ([3; 4], t2)), cast ([1; 2; 3; 4], tr));
-%! assert (cat (2, cast (1, t1), cast (2, t2)), cast ([1, 2], tr));
-%! assert (cat (2, cast (1, t1), cast ([2, 3], t2)), cast ([1, 2, 3], tr));
-%! assert (cat (2, cast ([1, 2], t1), cast (3, t2)), cast ([1, 2, 3], tr));
-%! assert (cat (2, cast ([1, 2], t1), cast ([3, 4], t2)), cast ([1, 2, 3, 4], tr));
-%!
-%! assert ([cast(1, t1); cast(2, t2)], cast ([1; 2], tr));
-%! assert ([cast(1, t1); cast([2; 3], t2)], cast ([1; 2; 3], tr));
-%! assert ([cast([1; 2], t1); cast(3, t2)], cast ([1; 2; 3], tr));
-%! assert ([cast([1; 2], t1); cast([3; 4], t2)], cast ([1; 2; 3; 4], tr));
-%! assert ([cast(1, t1), cast(2, t2)], cast ([1, 2], tr));
-%! assert ([cast(1, t1), cast([2, 3], t2)], cast ([1, 2, 3], tr));
-%! assert ([cast([1, 2], t1), cast(3, t2)], cast ([1, 2, 3], tr));
-%! assert ([cast([1, 2], t1), cast([3, 4], t2)], cast ([1, 2, 3, 4], tr));
-%!
-%! if (nargin == 3 || cmplx)
-%!   assert (cat (1, cast (1i, t1), cast (2, t2)), cast ([1i; 2], tr));
-%!   assert (cat (1, cast (1i, t1), cast ([2; 3], t2)), cast ([1i; 2; 3], tr));
-%!   assert (cat (1, cast ([1i; 2], t1), cast (3, t2)), cast ([1i; 2; 3], tr));
-%!   assert (cat (1, cast ([1i; 2], t1), cast ([3; 4], t2)), cast ([1i; 2; 3; 4], tr));
-%!   assert (cat (2, cast (1i, t1), cast (2, t2)), cast ([1i, 2], tr));
-%!   assert (cat (2, cast (1i, t1), cast ([2, 3], t2)), cast ([1i, 2, 3], tr));
-%!   assert (cat (2, cast ([1i, 2], t1), cast (3, t2)), cast ([1i, 2, 3], tr));
-%!   assert (cat (2, cast ([1i, 2], t1), cast ([3, 4], t2)), cast ([1i, 2, 3, 4], tr));
-%!
-%!   assert ([cast(1i, t1); cast(2, t2)], cast ([1i; 2], tr));
-%!   assert ([cast(1i, t1); cast([2; 3], t2)], cast ([1i; 2; 3], tr));
-%!   assert ([cast([1i; 2], t1); cast(3, t2)], cast ([1i; 2; 3], tr));
-%!   assert ([cast([1i; 2], t1); cast([3; 4], t2)], cast ([1i; 2; 3; 4], tr));
-%!   assert ([cast(1i, t1), cast(2, t2)], cast ([1i, 2], tr));
-%!   assert ([cast(1i, t1), cast([2, 3], t2)], cast ([1i, 2, 3], tr));
-%!   assert ([cast([1i, 2], t1), cast(3, t2)], cast ([1i, 2, 3], tr));
-%!   assert ([cast([1i, 2], t1), cast([3, 4], t2)], cast ([1i, 2, 3, 4], tr));
-%!
-%!   assert (cat (1, cast (1, t1), cast (2i, t2)), cast ([1; 2i], tr));
-%!   assert (cat (1, cast (1, t1), cast ([2i; 3], t2)), cast ([1; 2i; 3], tr));
-%!   assert (cat (1, cast ([1; 2], t1), cast (3i, t2)), cast ([1; 2; 3i], tr));
-%!   assert (cat (1, cast ([1; 2], t1), cast ([3i; 4], t2)), cast ([1; 2; 3i; 4], tr));
-%!   assert (cat (2, cast (1, t1), cast (2i, t2)), cast ([1, 2i], tr));
-%!   assert (cat (2, cast (1, t1), cast ([2i, 3], t2)), cast ([1, 2i, 3], tr));
-%!   assert (cat (2, cast ([1, 2], t1), cast (3i, t2)), cast ([1, 2, 3i], tr));
-%!   assert (cat (2, cast ([1, 2], t1), cast ([3i, 4], t2)), cast ([1, 2, 3i, 4], tr));
-%!
-%!   assert ([cast(1, t1); cast(2i, t2)], cast ([1; 2i], tr));
-%!   assert ([cast(1, t1); cast([2i; 3], t2)], cast ([1; 2i; 3], tr));
-%!   assert ([cast([1; 2], t1); cast(3i, t2)], cast ([1; 2; 3i], tr));
-%!   assert ([cast([1; 2], t1); cast([3i; 4], t2)], cast ([1; 2; 3i; 4], tr));
-%!   assert ([cast(1, t1), cast(2i, t2)], cast ([1, 2i], tr));
-%!   assert ([cast(1, t1), cast([2i, 3], t2)], cast ([1, 2i, 3], tr));
-%!   assert ([cast([1, 2], t1), cast(3i, t2)], cast ([1, 2, 3i], tr));
-%!   assert ([cast([1, 2], t1), cast([3i, 4], t2)], cast ([1, 2, 3i, 4], tr));
-%!
-%!   assert (cat (1, cast (1i, t1), cast (2i, t2)), cast ([1i; 2i], tr));
-%!   assert (cat (1, cast (1i, t1), cast ([2i; 3], t2)), cast ([1i; 2i; 3], tr));
-%!   assert (cat (1, cast ([1i; 2], t1), cast (3i, t2)), cast ([1i; 2; 3i], tr));
-%!   assert (cat (1, cast ([1i; 2], t1), cast ([3i; 4], t2)), cast ([1i; 2; 3i; 4], tr));
-%!   assert (cat (2, cast (1i, t1), cast (2i, t2)), cast ([1i, 2i], tr));
-%!   assert (cat (2, cast (1i, t1), cast ([2i, 3], t2)), cast ([1i, 2i, 3], tr));
-%!   assert (cat (2, cast ([1i, 2], t1), cast (3i, t2)), cast ([1i, 2, 3i], tr));
-%!   assert (cat (2, cast ([1i, 2], t1), cast ([3i, 4], t2)), cast ([1i, 2, 3i, 4], tr));
-%!
-%!   assert ([cast(1i, t1); cast(2i, t2)], cast ([1i; 2i], tr));
-%!   assert ([cast(1i, t1); cast([2i; 3], t2)], cast ([1i; 2i; 3], tr));
-%!   assert ([cast([1i; 2], t1); cast(3i, t2)], cast ([1i; 2; 3i], tr));
-%!   assert ([cast([1i; 2], t1); cast([3i; 4], t2)], cast ([1i; 2; 3i; 4], tr));
-%!   assert ([cast(1i, t1), cast(2i, t2)], cast ([1i, 2i], tr));
-%!   assert ([cast(1i, t1), cast([2i, 3], t2)], cast ([1i, 2i, 3], tr));
-%!   assert ([cast([1i, 2], t1), cast(3i, t2)], cast ([1i, 2, 3i], tr));
-%!   assert ([cast([1i, 2], t1), cast([3i, 4], t2)], cast ([1i, 2, 3i, 4], tr));
-%! endif
-%! ret = true;
+%!  assert (cat (1, cast ([], t1), cast ([], t2)), cast ([], tr));
+%! 
+%!  assert (cat (1, cast (1, t1), cast (2, t2)), cast ([1; 2], tr));
+%!  assert (cat (1, cast (1, t1), cast ([2; 3], t2)), cast ([1; 2; 3], tr));
+%!  assert (cat (1, cast ([1; 2], t1), cast (3, t2)), cast ([1; 2; 3], tr));
+%!  assert (cat (1, cast ([1; 2], t1), cast ([3; 4], t2)), cast ([1; 2; 3; 4], tr));
+%!  assert (cat (2, cast (1, t1), cast (2, t2)), cast ([1, 2], tr));
+%!  assert (cat (2, cast (1, t1), cast ([2, 3], t2)), cast ([1, 2, 3], tr));
+%!  assert (cat (2, cast ([1, 2], t1), cast (3, t2)), cast ([1, 2, 3], tr));
+%!  assert (cat (2, cast ([1, 2], t1), cast ([3, 4], t2)), cast ([1, 2, 3, 4], tr));
+%! 
+%!  assert ([cast(1, t1); cast(2, t2)], cast ([1; 2], tr));
+%!  assert ([cast(1, t1); cast([2; 3], t2)], cast ([1; 2; 3], tr));
+%!  assert ([cast([1; 2], t1); cast(3, t2)], cast ([1; 2; 3], tr));
+%!  assert ([cast([1; 2], t1); cast([3; 4], t2)], cast ([1; 2; 3; 4], tr));
+%!  assert ([cast(1, t1), cast(2, t2)], cast ([1, 2], tr));
+%!  assert ([cast(1, t1), cast([2, 3], t2)], cast ([1, 2, 3], tr));
+%!  assert ([cast([1, 2], t1), cast(3, t2)], cast ([1, 2, 3], tr));
+%!  assert ([cast([1, 2], t1), cast([3, 4], t2)], cast ([1, 2, 3, 4], tr));
+%! 
+%!  if (nargin == 3 || cmplx)
+%!    assert (cat (1, cast (1i, t1), cast (2, t2)), cast ([1i; 2], tr));
+%!    assert (cat (1, cast (1i, t1), cast ([2; 3], t2)), cast ([1i; 2; 3], tr));
+%!    assert (cat (1, cast ([1i; 2], t1), cast (3, t2)), cast ([1i; 2; 3], tr));
+%!    assert (cat (1, cast ([1i; 2], t1), cast ([3; 4], t2)), cast ([1i; 2; 3; 4], tr));
+%!    assert (cat (2, cast (1i, t1), cast (2, t2)), cast ([1i, 2], tr));
+%!    assert (cat (2, cast (1i, t1), cast ([2, 3], t2)), cast ([1i, 2, 3], tr));
+%!    assert (cat (2, cast ([1i, 2], t1), cast (3, t2)), cast ([1i, 2, 3], tr));
+%!    assert (cat (2, cast ([1i, 2], t1), cast ([3, 4], t2)), cast ([1i, 2, 3, 4], tr));
+%! 
+%!    assert ([cast(1i, t1); cast(2, t2)], cast ([1i; 2], tr));
+%!    assert ([cast(1i, t1); cast([2; 3], t2)], cast ([1i; 2; 3], tr));
+%!    assert ([cast([1i; 2], t1); cast(3, t2)], cast ([1i; 2; 3], tr));
+%!    assert ([cast([1i; 2], t1); cast([3; 4], t2)], cast ([1i; 2; 3; 4], tr));
+%!    assert ([cast(1i, t1), cast(2, t2)], cast ([1i, 2], tr));
+%!    assert ([cast(1i, t1), cast([2, 3], t2)], cast ([1i, 2, 3], tr));
+%!    assert ([cast([1i, 2], t1), cast(3, t2)], cast ([1i, 2, 3], tr));
+%!    assert ([cast([1i, 2], t1), cast([3, 4], t2)], cast ([1i, 2, 3, 4], tr));
+%! 
+%!    assert (cat (1, cast (1, t1), cast (2i, t2)), cast ([1; 2i], tr));
+%!    assert (cat (1, cast (1, t1), cast ([2i; 3], t2)), cast ([1; 2i; 3], tr));
+%!    assert (cat (1, cast ([1; 2], t1), cast (3i, t2)), cast ([1; 2; 3i], tr));
+%!    assert (cat (1, cast ([1; 2], t1), cast ([3i; 4], t2)), cast ([1; 2; 3i; 4], tr));
+%!    assert (cat (2, cast (1, t1), cast (2i, t2)), cast ([1, 2i], tr));
+%!    assert (cat (2, cast (1, t1), cast ([2i, 3], t2)), cast ([1, 2i, 3], tr));
+%!    assert (cat (2, cast ([1, 2], t1), cast (3i, t2)), cast ([1, 2, 3i], tr));
+%!    assert (cat (2, cast ([1, 2], t1), cast ([3i, 4], t2)), cast ([1, 2, 3i, 4], tr));
+%! 
+%!    assert ([cast(1, t1); cast(2i, t2)], cast ([1; 2i], tr));
+%!    assert ([cast(1, t1); cast([2i; 3], t2)], cast ([1; 2i; 3], tr));
+%!    assert ([cast([1; 2], t1); cast(3i, t2)], cast ([1; 2; 3i], tr));
+%!    assert ([cast([1; 2], t1); cast([3i; 4], t2)], cast ([1; 2; 3i; 4], tr));
+%!    assert ([cast(1, t1), cast(2i, t2)], cast ([1, 2i], tr));
+%!    assert ([cast(1, t1), cast([2i, 3], t2)], cast ([1, 2i, 3], tr));
+%!    assert ([cast([1, 2], t1), cast(3i, t2)], cast ([1, 2, 3i], tr));
+%!    assert ([cast([1, 2], t1), cast([3i, 4], t2)], cast ([1, 2, 3i, 4], tr));
+%! 
+%!    assert (cat (1, cast (1i, t1), cast (2i, t2)), cast ([1i; 2i], tr));
+%!    assert (cat (1, cast (1i, t1), cast ([2i; 3], t2)), cast ([1i; 2i; 3], tr));
+%!    assert (cat (1, cast ([1i; 2], t1), cast (3i, t2)), cast ([1i; 2; 3i], tr));
+%!    assert (cat (1, cast ([1i; 2], t1), cast ([3i; 4], t2)), cast ([1i; 2; 3i; 4], tr));
+%!    assert (cat (2, cast (1i, t1), cast (2i, t2)), cast ([1i, 2i], tr));
+%!    assert (cat (2, cast (1i, t1), cast ([2i, 3], t2)), cast ([1i, 2i, 3], tr));
+%!    assert (cat (2, cast ([1i, 2], t1), cast (3i, t2)), cast ([1i, 2, 3i], tr));
+%!    assert (cat (2, cast ([1i, 2], t1), cast ([3i, 4], t2)), cast ([1i, 2, 3i, 4], tr));
+%! 
+%!    assert ([cast(1i, t1); cast(2i, t2)], cast ([1i; 2i], tr));
+%!    assert ([cast(1i, t1); cast([2i; 3], t2)], cast ([1i; 2i; 3], tr));
+%!    assert ([cast([1i; 2], t1); cast(3i, t2)], cast ([1i; 2; 3i], tr));
+%!    assert ([cast([1i; 2], t1); cast([3i; 4], t2)], cast ([1i; 2; 3i; 4], tr));
+%!    assert ([cast(1i, t1), cast(2i, t2)], cast ([1i, 2i], tr));
+%!    assert ([cast(1i, t1), cast([2i, 3], t2)], cast ([1i, 2i, 3], tr));
+%!    assert ([cast([1i, 2], t1), cast(3i, t2)], cast ([1i, 2, 3i], tr));
+%!    assert ([cast([1i, 2], t1), cast([3i, 4], t2)], cast ([1i, 2, 3i, 4], tr));
+%!  endif
+%!  ret = true;
 %!endfunction
 
-%!assert (__testcat('double', 'double', 'double'))
-%!assert (__testcat('single', 'double', 'single'))
-%!assert (__testcat('double', 'single', 'single'))
-%!assert (__testcat('single', 'single', 'single'))
-
-%!assert (__testcat('double', 'int8', 'int8', false))
-%!assert (__testcat('int8', 'double', 'int8', false))
-%!assert (__testcat('single', 'int8', 'int8', false))
-%!assert (__testcat('int8', 'single', 'int8', false))
-%!assert (__testcat('int8', 'int8', 'int8', false))
-%!assert (__testcat('double', 'int16', 'int16', false))
-%!assert (__testcat('int16', 'double', 'int16', false))
-%!assert (__testcat('single', 'int16', 'int16', false))
-%!assert (__testcat('int16', 'single', 'int16', false))
-%!assert (__testcat('int16', 'int16', 'int16', false))
-%!assert (__testcat('double', 'int32', 'int32', false))
-%!assert (__testcat('int32', 'double', 'int32', false))
-%!assert (__testcat('single', 'int32', 'int32', false))
-%!assert (__testcat('int32', 'single', 'int32', false))
-%!assert (__testcat('int32', 'int32', 'int32', false))
-%!assert (__testcat('double', 'int64', 'int64', false))
-%!assert (__testcat('int64', 'double', 'int64', false))
-%!assert (__testcat('single', 'int64', 'int64', false))
-%!assert (__testcat('int64', 'single', 'int64', false))
-%!assert (__testcat('int64', 'int64', 'int64', false))
-
-%!assert (__testcat('double', 'uint8', 'uint8', false))
-%!assert (__testcat('uint8', 'double', 'uint8', false))
-%!assert (__testcat('single', 'uint8', 'uint8', false))
-%!assert (__testcat('uint8', 'single', 'uint8', false))
-%!assert (__testcat('uint8', 'uint8', 'uint8', false))
-%!assert (__testcat('double', 'uint16', 'uint16', false))
-%!assert (__testcat('uint16', 'double', 'uint16', false))
-%!assert (__testcat('single', 'uint16', 'uint16', false))
-%!assert (__testcat('uint16', 'single', 'uint16', false))
-%!assert (__testcat('uint16', 'uint16', 'uint16', false))
-%!assert (__testcat('double', 'uint32', 'uint32', false))
-%!assert (__testcat('uint32', 'double', 'uint32', false))
-%!assert (__testcat('single', 'uint32', 'uint32', false))
-%!assert (__testcat('uint32', 'single', 'uint32', false))
-%!assert (__testcat('uint32', 'uint32', 'uint32', false))
-%!assert (__testcat('double', 'uint64', 'uint64', false))
-%!assert (__testcat('uint64', 'double', 'uint64', false))
-%!assert (__testcat('single', 'uint64', 'uint64', false))
-%!assert (__testcat('uint64', 'single', 'uint64', false))
-%!assert (__testcat('uint64', 'uint64', 'uint64', false))
+%!assert (__testcat ("double", "double", "double"))
+%!assert (__testcat ("single", "double", "single"))
+%!assert (__testcat ("double", "single", "single"))
+%!assert (__testcat ("single", "single", "single"))
+
+%!assert (__testcat ("double", "int8", "int8", false))
+%!assert (__testcat ("int8", "double", "int8", false))
+%!assert (__testcat ("single", "int8", "int8", false))
+%!assert (__testcat ("int8", "single", "int8", false))
+%!assert (__testcat ("int8", "int8", "int8", false))
+%!assert (__testcat ("double", "int16", "int16", false))
+%!assert (__testcat ("int16", "double", "int16", false))
+%!assert (__testcat ("single", "int16", "int16", false))
+%!assert (__testcat ("int16", "single", "int16", false))
+%!assert (__testcat ("int16", "int16", "int16", false))
+%!assert (__testcat ("double", "int32", "int32", false))
+%!assert (__testcat ("int32", "double", "int32", false))
+%!assert (__testcat ("single", "int32", "int32", false))
+%!assert (__testcat ("int32", "single", "int32", false))
+%!assert (__testcat ("int32", "int32", "int32", false))
+%!assert (__testcat ("double", "int64", "int64", false))
+%!assert (__testcat ("int64", "double", "int64", false))
+%!assert (__testcat ("single", "int64", "int64", false))
+%!assert (__testcat ("int64", "single", "int64", false))
+%!assert (__testcat ("int64", "int64", "int64", false))
+
+%!assert (__testcat ("double", "uint8", "uint8", false))
+%!assert (__testcat ("uint8", "double", "uint8", false))
+%!assert (__testcat ("single", "uint8", "uint8", false))
+%!assert (__testcat ("uint8", "single", "uint8", false))
+%!assert (__testcat ("uint8", "uint8", "uint8", false))
+%!assert (__testcat ("double", "uint16", "uint16", false))
+%!assert (__testcat ("uint16", "double", "uint16", false))
+%!assert (__testcat ("single", "uint16", "uint16", false))
+%!assert (__testcat ("uint16", "single", "uint16", false))
+%!assert (__testcat ("uint16", "uint16", "uint16", false))
+%!assert (__testcat ("double", "uint32", "uint32", false))
+%!assert (__testcat ("uint32", "double", "uint32", false))
+%!assert (__testcat ("single", "uint32", "uint32", false))
+%!assert (__testcat ("uint32", "single", "uint32", false))
+%!assert (__testcat ("uint32", "uint32", "uint32", false))
+%!assert (__testcat ("double", "uint64", "uint64", false))
+%!assert (__testcat ("uint64", "double", "uint64", false))
+%!assert (__testcat ("single", "uint64", "uint64", false))
+%!assert (__testcat ("uint64", "single", "uint64", false))
+%!assert (__testcat ("uint64", "uint64", "uint64", false))
 
 %!assert (cat (3, [], [1,2;3,4]), [1,2;3,4])
 %!assert (cat (3, [1,2;3,4], []), [1,2;3,4])
@@ -2313,12 +2299,12 @@
 %!assert (cat (3, [], [], 1, 2), cat (3, 1, 2))
 %!assert (cat (3, [], [], [1,2;3,4]), [1,2;3,4])
 %!assert (cat (4, [], [], [1,2;3,4]), [1,2;3,4])
+
+%!assert ([zeros(3,2,2); ones(1,2,2)], repmat ([0;0;0;1],[1,2,2]) )
+%!assert ([zeros(3,2,2); ones(1,2,2)], vertcat (zeros (3,2,2), ones (1,2,2)) )
+
 %!error <dimension mismatch> cat (3, cat (3, [], []), [1,2;3,4])
 %!error <dimension mismatch> cat (3, zeros (0, 0, 2), [1,2;3,4])
-
-%!assert ([zeros(3,2,2); ones(1,2,2)], repmat([0;0;0;1],[1,2,2]) )
-%!assert ([zeros(3,2,2); ones(1,2,2)], vertcat(zeros(3,2,2), ones(1,2,2)) )
-
 */
 
 static octave_value
@@ -2354,7 +2340,7 @@
 @deftypefn {Built-in Function} {} permute (@var{A}, @var{perm})\n\
 Return the generalized transpose for an N-D array object @var{A}.\n\
 The permutation vector @var{perm} must contain the elements\n\
-@code{1:ndims(A)} (in any order, but each element must appear only once).\n\
+@code{1:ndims (A)} (in any order, but each element must appear only once).\n\
 @seealso{ipermute}\n\
 @end deftypefn")
 {
@@ -2405,8 +2391,8 @@
 \n\
 @example\n\
 @group\n\
-  ndims (ones (4, 1, 2, 1))\n\
-     @result{} 3\n\
+ndims (ones (4, 1, 2, 1))\n\
+    @result{} 3\n\
 @end group\n\
 @end example\n\
 @end deftypefn")
@@ -2430,16 +2416,16 @@
 return the number of elements that would result from the indexing\n\
 \n\
 @example\n\
-  @var{a}(@var{idx1}, @var{idx2}, @dots{})\n\
+@var{a}(@var{idx1}, @var{idx2}, @dots{})\n\
 @end example\n\
 \n\
 Note that the indices do not have to be numerical.  For example,\n\
 \n\
 @example\n\
 @group\n\
-  @var{a} = 1;\n\
-  @var{b} = ones (2, 3);\n\
-  numel (@var{a}, @var{b});\n\
+@var{a} = 1;\n\
+@var{b} = ones (2, 3);\n\
+numel (@var{a}, @var{b})\n\
 @end group\n\
 @end example\n\
 \n\
@@ -2482,11 +2468,11 @@
 @example\n\
 @group\n\
 size ([1, 2; 3, 4; 5, 6])\n\
-     @result{} [ 3, 2 ]\n\
+   @result{} [ 3, 2 ]\n\
 \n\
 [nr, nc] = size ([1, 2; 3, 4; 5, 6])\n\
-     @result{} nr = 3\n\
-     @result{} nc = 2\n\
+    @result{} nr = 3\n\
+    @result{} nc = 2\n\
 @end group\n\
 @end example\n\
 \n\
@@ -2496,7 +2482,7 @@
 @example\n\
 @group\n\
 size ([1, 2; 3, 4; 5, 6], 2)\n\
-     @result{} 2\n\
+    @result{} 2\n\
 @end group\n\
 @end example\n\
 \n\
@@ -2623,7 +2609,7 @@
 {
   octave_value retval;
 
-  if (args.length() == 1)
+  if (args.length () == 1)
     retval = args(0).nzmax ();
   else
     print_usage ();
@@ -2669,31 +2655,32 @@
   "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {} sum (@var{x})\n\
 @deftypefnx {Built-in Function} {} sum (@var{x}, @var{dim})\n\
-@deftypefnx {Built-in Function} {} sum (@dots{}, 'native')\n\
-@deftypefnx {Built-in Function} {} sum (@dots{}, 'double')\n\
-@deftypefnx {Built-in Function} {} sum (@dots{}, 'extra')\n\
+@deftypefnx {Built-in Function} {} sum (@dots{}, \"native\")\n\
+@deftypefnx {Built-in Function} {} sum (@dots{}, \"double\")\n\
+@deftypefnx {Built-in Function} {} sum (@dots{}, \"extra\")\n\
 Sum of elements along dimension @var{dim}.  If @var{dim} is\n\
 omitted, it defaults to the first non-singleton dimension.\n\
 \n\
-If the optional argument 'native' is given, then the sum is performed\n\
+If the optional argument \"native\" is given, then the sum is performed\n\
 in the same type as the original argument, rather than in the default\n\
 double type.  For example:\n\
 \n\
 @example\n\
 @group\n\
 sum ([true, true])\n\
-  @result{} 2\n\
-sum ([true, true], 'native')\n\
-  @result{} true\n\
+   @result{} 2\n\
+sum ([true, true], \"native\")\n\
+   @result{} true\n\
 @end group\n\
 @end example\n\
 \n\
-On the contrary, if 'double' is given, the sum is performed in double\n\
+On the contrary, if \"double\" is given, the sum is performed in double\n\
 precision even for single precision inputs.\n\
 \n\
-For double precision inputs, 'extra' indicates that a more accurate algorithm\n\
-than straightforward summation is to be used.  For single precision inputs,\n\
-'extra' is the same as 'double'.  Otherwise, 'extra' has no effect.\n\
+For double precision inputs, \"extra\" indicates that a more accurate\n\
+algorithm than straightforward summation is to be used.  For single precision\n\
+inputs, \"extra\" is the same as \"double\".  Otherwise, \"extra\" has no\n\
+effect.\n\
 @seealso{cumsum, sumsq, prod}\n\
 @end deftypefn")
 {
@@ -2822,64 +2809,62 @@
 }
 
 /*
-
-%!assert (sum([true,true]), 2)
-%!assert (sum([true,true],'native'), true)
-%!assert (sum(int8([127,10,-20])), 117);
-%!assert (sum(int8([127,10,-20]),'native'), int8(107));
-
-%!assert(sum ([1, 2, 3]), 6)
-%!assert(sum ([-1; -2; -3]), -6);
-%!assert(sum ([i, 2+i, -3+2i, 4]), 3+4i);
-%!assert(sum ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]), [2+2i, 4+4i, 6+6i]);
-
-%!assert(sum (single([1, 2, 3])), single(6))
-%!assert(sum (single([-1; -2; -3])), single(-6));
-%!assert(sum (single([i, 2+i, -3+2i, 4])), single(3+4i));
-%!assert(sum (single([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i])), single([2+2i, 4+4i, 6+6i]));
-
-%!error <Invalid call to sum> sum ();
-
-%!assert (sum ([1, 2; 3, 4], 1), [4, 6]);
-%!assert (sum ([1, 2; 3, 4], 2), [3; 7]);
-%!assert (sum (zeros (1, 0)), 0);
-%!assert (sum (zeros (1, 0), 1), zeros(1, 0));
-%!assert (sum (zeros (1, 0), 2), 0);
-%!assert (sum (zeros (0, 1)), 0);
-%!assert (sum (zeros (0, 1), 1), 0);
-%!assert (sum (zeros (0, 1), 2), zeros(0, 1));
-%!assert (sum (zeros (2, 0)),  zeros(1, 0));
-%!assert (sum (zeros (2, 0), 1), zeros(1, 0));
-%!assert (sum (zeros (2, 0), 2),  [0; 0]);
-%!assert (sum (zeros (0, 2)), [0, 0]);
-%!assert (sum (zeros (0, 2), 1), [0, 0]);
-%!assert (sum (zeros (0, 2), 2), zeros(0, 1));
-%!assert (sum (zeros (2, 2, 0, 3)), zeros(1, 2, 0, 3));
-%!assert (sum (zeros (2, 2, 0, 3), 2), zeros(2, 1, 0, 3));
-%!assert (sum (zeros (2, 2, 0, 3), 3), zeros(2, 2, 1, 3));
-%!assert (sum (zeros (2, 2, 0, 3), 4), zeros(2, 2, 0));
-%!assert (sum (zeros (2, 2, 0, 3), 7), zeros(2, 2, 0, 3));
-
-%!assert (sum (single([1, 2; 3, 4]), 1), single([4, 6]));
-%!assert (sum (single([1, 2; 3, 4]), 2), single([3; 7]));
-%!assert (sum (zeros (1, 0, 'single')), single(0));
-%!assert (sum (zeros (1, 0, 'single'), 1), zeros(1, 0, 'single'));
-%!assert (sum (zeros (1, 0, 'single'), 2), single(0));
-%!assert (sum (zeros (0, 1, 'single')), single(0));
-%!assert (sum (zeros (0, 1, 'single'), 1), single(0));
-%!assert (sum (zeros (0, 1, 'single'), 2), zeros(0, 1, 'single'));
-%!assert (sum (zeros (2, 0, 'single')),  zeros(1, 0, 'single'));
-%!assert (sum (zeros (2, 0, 'single'), 1), zeros(1, 0, 'single'));
-%!assert (sum (zeros (2, 0, 'single'), 2),  single([0; 0]));
-%!assert (sum (zeros (0, 2, 'single')), single([0, 0]));
-%!assert (sum (zeros (0, 2, 'single'), 1), single([0, 0]));
-%!assert (sum (zeros (0, 2, 'single'), 2), zeros(0, 1, 'single'));
-%!assert (sum (zeros (2, 2, 0, 3, 'single')), zeros(1, 2, 0, 3, 'single'));
-%!assert (sum (zeros (2, 2, 0, 3, 'single'), 2), zeros(2, 1, 0, 3, 'single'));
-%!assert (sum (zeros (2, 2, 0, 3, 'single'), 3), zeros(2, 2, 1, 3, 'single'));
-%!assert (sum (zeros (2, 2, 0, 3, 'single'), 4), zeros(2, 2, 0, 'single'));
-%!assert (sum (zeros (2, 2, 0, 3, 'single'), 7), zeros(2, 2, 0, 3, 'single'));
-
+%!assert (sum ([true,true]), 2)
+%!assert (sum ([true,true],"native"), true)
+%!assert (sum (int8 ([127,10,-20])), 117)
+%!assert (sum (int8 ([127,10,-20]),'native'), int8 (107))
+
+%!assert (sum ([1, 2, 3]), 6)
+%!assert (sum ([-1; -2; -3]), -6)
+%!assert (sum ([i, 2+i, -3+2i, 4]), 3+4i)
+%!assert (sum ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]), [2+2i, 4+4i, 6+6i])
+
+%!assert (sum (single ([1, 2, 3])), single (6))
+%!assert (sum (single ([-1; -2; -3])), single (-6))
+%!assert (sum (single ([i, 2+i, -3+2i, 4])), single (3+4i))
+%!assert (sum (single ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i])), single ([2+2i, 4+4i, 6+6i]))
+
+%!assert (sum ([1, 2; 3, 4], 1), [4, 6])
+%!assert (sum ([1, 2; 3, 4], 2), [3; 7])
+%!assert (sum (zeros (1, 0)), 0)
+%!assert (sum (zeros (1, 0), 1), zeros (1, 0))
+%!assert (sum (zeros (1, 0), 2), 0)
+%!assert (sum (zeros (0, 1)), 0)
+%!assert (sum (zeros (0, 1), 1), 0)
+%!assert (sum (zeros (0, 1), 2), zeros (0, 1))
+%!assert (sum (zeros (2, 0)),  zeros (1, 0))
+%!assert (sum (zeros (2, 0), 1), zeros (1, 0))
+%!assert (sum (zeros (2, 0), 2),  [0; 0])
+%!assert (sum (zeros (0, 2)), [0, 0])
+%!assert (sum (zeros (0, 2), 1), [0, 0])
+%!assert (sum (zeros (0, 2), 2), zeros (0, 1))
+%!assert (sum (zeros (2, 2, 0, 3)), zeros (1, 2, 0, 3))
+%!assert (sum (zeros (2, 2, 0, 3), 2), zeros (2, 1, 0, 3))
+%!assert (sum (zeros (2, 2, 0, 3), 3), zeros (2, 2, 1, 3))
+%!assert (sum (zeros (2, 2, 0, 3), 4), zeros (2, 2, 0))
+%!assert (sum (zeros (2, 2, 0, 3), 7), zeros (2, 2, 0, 3))
+
+%!assert (sum (single ([1, 2; 3, 4]), 1), single ([4, 6]))
+%!assert (sum (single ([1, 2; 3, 4]), 2), single ([3; 7]))
+%!assert (sum (zeros (1, 0, "single")), single (0))
+%!assert (sum (zeros (1, 0, "single"), 1), zeros (1, 0, "single"))
+%!assert (sum (zeros (1, 0, "single"), 2), single (0))
+%!assert (sum (zeros (0, 1, "single")), single (0))
+%!assert (sum (zeros (0, 1, "single"), 1), single (0))
+%!assert (sum (zeros (0, 1, "single"), 2), zeros (0, 1, "single"))
+%!assert (sum (zeros (2, 0, "single")),  zeros (1, 0, "single"))
+%!assert (sum (zeros (2, 0, "single"), 1), zeros (1, 0, "single"))
+%!assert (sum (zeros (2, 0, "single"), 2),  single ([0; 0]))
+%!assert (sum (zeros (0, 2, "single")), single ([0, 0]))
+%!assert (sum (zeros (0, 2, "single"), 1), single ([0, 0]))
+%!assert (sum (zeros (0, 2, "single"), 2), zeros (0, 1, "single"))
+%!assert (sum (zeros (2, 2, 0, 3, "single")), zeros (1, 2, 0, 3, "single"))
+%!assert (sum (zeros (2, 2, 0, 3, "single"), 2), zeros (2, 1, 0, 3, "single"))
+%!assert (sum (zeros (2, 2, 0, 3, "single"), 3), zeros (2, 2, 1, 3, "single"))
+%!assert (sum (zeros (2, 2, 0, 3, "single"), 4), zeros (2, 2, 0, "single"))
+%!assert (sum (zeros (2, 2, 0, 3, "single"), 7), zeros (2, 2, 0, 3, "single"))
+
+%!error sum ()
 */
 
 DEFUN (sumsq, args, ,
@@ -2904,24 +2889,22 @@
 }
 
 /*
-
-%!assert(sumsq ([1, 2, 3]), 14)
-%!assert(sumsq ([-1; -2; 4i]), 21);
-%!assert(sumsq ([1, 2, 3; 2, 3, 4; 4i, 6i, 2]), [21, 49, 29]);
-
-%!assert(sumsq (single([1, 2, 3])), single(14))
-%!assert(sumsq (single([-1; -2; 4i])), single(21));
-%!assert(sumsq (single([1, 2, 3; 2, 3, 4; 4i, 6i, 2])), single([21, 49, 29]));
-
-%!error <Invalid call to sumsq> sumsq ();
-
-%!assert (sumsq ([1, 2; 3, 4], 1), [10, 20]);
-%!assert (sumsq ([1, 2; 3, 4], 2), [5; 25]);
-
-%!assert (sumsq (single([1, 2; 3, 4]), 1), single([10, 20]));
-%!assert (sumsq (single([1, 2; 3, 4]), 2), single([5; 25]));
-
- */
+%!assert (sumsq ([1, 2, 3]), 14)
+%!assert (sumsq ([-1; -2; 4i]), 21)
+%!assert (sumsq ([1, 2, 3; 2, 3, 4; 4i, 6i, 2]), [21, 49, 29])
+
+%!assert (sumsq (single ([1, 2, 3])), single (14))
+%!assert (sumsq (single ([-1; -2; 4i])), single (21))
+%!assert (sumsq (single ([1, 2, 3; 2, 3, 4; 4i, 6i, 2])), single ([21, 49, 29]))
+
+%!assert (sumsq ([1, 2; 3, 4], 1), [10, 20])
+%!assert (sumsq ([1, 2; 3, 4], 2), [5; 25])
+
+%!assert (sumsq (single ([1, 2; 3, 4]), 1), single ([10, 20]))
+%!assert (sumsq (single ([1, 2; 3, 4]), 2), single ([5; 25]))
+
+%!error sumsq ()
+*/
 
 DEFUN (islogical, args, ,
   "-*- texinfo -*-\n\
@@ -2944,20 +2927,18 @@
 DEFALIAS (isbool, islogical);
 
 /*
-
-%!assert (islogical(true), true)
-%!assert (islogical(false), true)
-%!assert (islogical([true, false]), true)
-%!assert (islogical(1), false)
-%!assert (islogical(1i), false)
-%!assert (islogical([1,1]), false)
-%!assert (islogical(single(1)), false)
-%!assert (islogical(single(1i)), false)
-%!assert (islogical(single([1,1])), false)
-%!assert (islogical(sparse ([true, false])), true)
-%!assert (islogical(sparse ([1, 0])), false)
-
- */
+%!assert (islogical (true), true)
+%!assert (islogical (false), true)
+%!assert (islogical ([true, false]), true)
+%!assert (islogical (1), false)
+%!assert (islogical (1i), false)
+%!assert (islogical ([1,1]), false)
+%!assert (islogical (single (1)), false)
+%!assert (islogical (single (1i)), false)
+%!assert (islogical (single ([1,1])), false)
+%!assert (islogical (sparse ([true, false])), true)
+%!assert (islogical (sparse ([1, 0])), false)
+*/
 
 DEFUN (isinteger, args, ,
   "-*- texinfo -*-\n\
@@ -3029,8 +3010,7 @@
 @example\n\
 @group\n\
 complex ([1, 2], [3, 4])\n\
-@result{}\n\
-   1 + 3i   2 + 4i\n\
+  @result{} [ 1 + 3i   2 + 4i ]\n\
 @end group\n\
 @end example\n\
 @seealso{real, imag, iscomplex}\n\
@@ -3110,7 +3090,7 @@
                 {
                   SparseComplexMatrix result;
                   if (re_val.nnz () == 0)
-                    result = Complex(0, 1) * SparseComplexMatrix (im_val);
+                    result = Complex (0, 1) * SparseComplexMatrix (im_val);
                   else
                     {
                       result = SparseComplexMatrix (im_val.dims (), re_val (0));
@@ -3120,10 +3100,10 @@
                       for (octave_idx_type j = 0; j < nc; j++)
                         {
                           octave_idx_type off = j * nr;
-                          for (octave_idx_type i = im_val.cidx(j);
-                               i < im_val.cidx(j + 1); i++)
-                            result.data (im_val.ridx(i) + off) =
-                              result.data (im_val.ridx(i) + off) +
+                          for (octave_idx_type i = im_val.cidx (j);
+                               i < im_val.cidx (j + 1); i++)
+                            result.data (im_val.ridx (i) + off) =
+                              result.data (im_val.ridx (i) + off) +
                               Complex (0, im_val.data (i));
                         }
                     }
@@ -3136,17 +3116,17 @@
                     result = SparseComplexMatrix (re_val);
                   else
                     {
-                      result = SparseComplexMatrix (re_val.rows(), re_val.cols(), Complex(0, im_val (0)));
+                      result = SparseComplexMatrix (re_val.rows (), re_val.cols (), Complex (0, im_val (0)));
                       octave_idx_type nr = re_val.rows ();
                       octave_idx_type nc = re_val.cols ();
 
                       for (octave_idx_type j = 0; j < nc; j++)
                         {
                           octave_idx_type off = j * nr;
-                          for (octave_idx_type i = re_val.cidx(j);
-                               i < re_val.cidx(j + 1); i++)
-                            result.data (re_val.ridx(i) + off) =
-                              result.data (re_val.ridx(i) + off) +
+                          for (octave_idx_type i = re_val.cidx (j);
+                               i < re_val.cidx (j + 1); i++)
+                            result.data (re_val.ridx (i) + off) =
+                              result.data (re_val.ridx (i) + off) +
                               re_val.data (i);
                         }
                     }
@@ -3156,8 +3136,8 @@
                 {
                   if (re_val.dims () == im_val.dims ())
                     {
-                      SparseComplexMatrix result = SparseComplexMatrix(re_val)
-                        + Complex(0, 1) * SparseComplexMatrix (im_val);
+                      SparseComplexMatrix result = SparseComplexMatrix (re_val)
+                        + Complex (0, 1) * SparseComplexMatrix (im_val);
                       retval = octave_value (new octave_sparse_complex_matrix (result));
                     }
                   else
@@ -3363,21 +3343,19 @@
 }
 
 /*
-
-%!assert (isnumeric(1), true)
-%!assert (isnumeric(1i), true)
-%!assert (isnumeric([1,1]), true)
-%!assert (isnumeric(single(1)), true)
-%!assert (isnumeric(single(1i)), true)
-%!assert (isnumeric(single([1,1])), true)
-%!assert (isnumeric(int8(1)), true)
-%!assert (isnumeric(uint8([1,1])), true)
-%!assert (isnumeric("Hello World"), false)
-%!assert (isnumeric(true), false)
-%!assert (isnumeric(false), false)
-%!assert (isnumeric([true, false]), false)
-%!assert (isnumeric(sparse ([true, false])), false)
-
+%!assert (isnumeric (1), true)
+%!assert (isnumeric (1i), true)
+%!assert (isnumeric ([1,1]), true)
+%!assert (isnumeric (single (1)), true)
+%!assert (isnumeric (single (1i)), true)
+%!assert (isnumeric (single ([1,1])), true)
+%!assert (isnumeric (int8 (1)), true)
+%!assert (isnumeric (uint8 ([1,1])), true)
+%!assert (isnumeric ("Hello World"), false)
+%!assert (isnumeric (true), false)
+%!assert (isnumeric (false), false)
+%!assert (isnumeric ([true, false]), false)
+%!assert (isnumeric (sparse ([true, false])), false)
 */
 
 DEFUN (ismatrix, args, ,
@@ -3405,30 +3383,28 @@
 }
 
 /*
-
-%!assert(ismatrix ([]));
-%!assert(ismatrix (1));
-%!assert(ismatrix ([1, 2, 3]));
-%!assert(ismatrix ([1, 2; 3, 4]));
-%!assert(ismatrix (zeros (3, 2, 4)));
-
-%!assert(ismatrix (single([])));
-%!assert(ismatrix (single(1)));
-%!assert(ismatrix (single([1, 2, 3])));
-%!assert(ismatrix (single([1, 2; 3, 4])));
-
-%!assert(ismatrix ("t"));
-%!assert(ismatrix ("test"));
-%!assert(ismatrix (["test"; "ing"]));
+%!assert (ismatrix ([]))
+%!assert (ismatrix (1))
+%!assert (ismatrix ([1, 2, 3]))
+%!assert (ismatrix ([1, 2; 3, 4]))
+%!assert (ismatrix (zeros (3, 2, 4)))
+
+%!assert (ismatrix (single ([])))
+%!assert (ismatrix (single (1)))
+%!assert (ismatrix (single ([1, 2, 3])))
+%!assert (ismatrix (single ([1, 2; 3, 4])))
+
+%!assert (ismatrix ("t"))
+%!assert (ismatrix ("test"))
+%!assert (ismatrix (["test"; "ing"]))
 
 %!test
 %! s.a = 1;
-%! assert(ismatrix (s), false);
-
-%!error <Invalid call to ismatrix> ismatrix ();
-%!error <Invalid call to ismatrix> ismatrix ([1, 2; 3, 4], 2);
-
- */
+%! assert (ismatrix (s), false);
+
+%!error ismatrix ()
+%!error ismatrix ([1, 2; 3, 4], 2)
+*/
 
 static octave_value
 fill_matrix (const octave_value_list& args, int val, const char *fcn)
@@ -3882,23 +3858,21 @@
 }
 
 /*
-
-%!assert(ones (3), [1, 1, 1; 1, 1, 1; 1, 1, 1]);
-%!assert(ones (2, 3), [1, 1, 1; 1, 1, 1]);
-%!assert(ones (3, 2), [1, 1; 1, 1; 1, 1]);
-%!assert(size (ones (3, 4, 5)),  [3, 4, 5]);
-
-%!assert(ones (3,'single'), single([1, 1, 1; 1, 1, 1; 1, 1, 1]));
-%!assert(ones (2, 3,'single'), single([1, 1, 1; 1, 1, 1]));
-%!assert(ones (3, 2,'single'), single([1, 1; 1, 1; 1, 1]));
-%!assert(size (ones (3, 4, 5, 'single')),  [3, 4, 5]);
-
-%!assert(ones (3,'int8'), int8([1, 1, 1; 1, 1, 1; 1, 1, 1]));
-%!assert(ones (2, 3,'int8'), int8([1, 1, 1; 1, 1, 1]));
-%!assert(ones (3, 2,'int8'), int8([1, 1; 1, 1; 1, 1]));
-%!assert(size (ones (3, 4, 5, 'int8')),  [3, 4, 5]);
-
- */
+%!assert (ones (3), [1, 1, 1; 1, 1, 1; 1, 1, 1])
+%!assert (ones (2, 3), [1, 1, 1; 1, 1, 1])
+%!assert (ones (3, 2), [1, 1; 1, 1; 1, 1])
+%!assert (size (ones (3, 4, 5)), [3, 4, 5])
+
+%!assert (ones (3, "single"), single ([1, 1, 1; 1, 1, 1; 1, 1, 1]))
+%!assert (ones (2, 3, "single"), single ([1, 1, 1; 1, 1, 1]))
+%!assert (ones (3, 2, "single"), single ([1, 1; 1, 1; 1, 1]))
+%!assert (size (ones (3, 4, 5, "single")), [3, 4, 5])
+
+%!assert (ones (3, "int8"), int8 ([1, 1, 1; 1, 1, 1; 1, 1, 1]))
+%!assert (ones (2, 3, "int8"), int8 ([1, 1, 1; 1, 1, 1]))
+%!assert (ones (3, 2, "int8"), int8 ([1, 1; 1, 1; 1, 1]))
+%!assert (size (ones (3, 4, 5, "int8")), [3, 4, 5])
+*/
 
 DEFUN (zeros, args, ,
   "-*- texinfo -*-\n\
@@ -3926,23 +3900,21 @@
 }
 
 /*
-
-%!assert(zeros (3), [0, 0, 0; 0, 0, 0; 0, 0, 0]);
-%!assert(zeros (2, 3), [0, 0, 0; 0, 0, 0]);
-%!assert(zeros (3, 2), [0, 0; 0, 0; 0, 0]);
-%!assert(size (zeros (3, 4, 5)),  [3, 4, 5]);
-
-%!assert(zeros (3,'single'), single([0, 0, 0; 0, 0, 0; 0, 0, 0]));
-%!assert(zeros (2, 3,'single'), single([0, 0, 0; 0, 0, 0]));
-%!assert(zeros (3, 2,'single'), single([0, 0; 0, 0; 0, 0]));
-%!assert(size (zeros (3, 4, 5, 'single')),  [3, 4, 5]);
-
-%!assert(zeros (3,'int8'), int8([0, 0, 0; 0, 0, 0; 0, 0, 0]));
-%!assert(zeros (2, 3,'int8'), int8([0, 0, 0; 0, 0, 0]));
-%!assert(zeros (3, 2,'int8'), int8([0, 0; 0, 0; 0, 0]));
-%!assert(size (zeros (3, 4, 5, 'int8')),  [3, 4, 5]);
-
- */
+%!assert (zeros (3), [0, 0, 0; 0, 0, 0; 0, 0, 0])
+%!assert (zeros (2, 3), [0, 0, 0; 0, 0, 0])
+%!assert (zeros (3, 2), [0, 0; 0, 0; 0, 0])
+%!assert (size (zeros (3, 4, 5)), [3, 4, 5])
+
+%!assert (zeros (3, "single"), single ([0, 0, 0; 0, 0, 0; 0, 0, 0]))
+%!assert (zeros (2, 3, "single"), single ([0, 0, 0; 0, 0, 0]))
+%!assert (zeros (3, 2, "single"), single ([0, 0; 0, 0; 0, 0]))
+%!assert (size (zeros (3, 4, 5, "single")), [3, 4, 5])
+
+%!assert (zeros (3, "int8"), int8 ([0, 0, 0; 0, 0, 0; 0, 0, 0]))
+%!assert (zeros (2, 3, "int8"), int8 ([0, 0, 0; 0, 0, 0]))
+%!assert (zeros (3, 2, "int8"), int8 ([0, 0; 0, 0; 0, 0]))
+%!assert (size (zeros (3, 4, 5, "int8")), [3, 4, 5])
+*/
 
 DEFUN (Inf, args, ,
   "-*- texinfo -*-\n\
@@ -3963,9 +3935,8 @@
 \n\
 @example\n\
 @group\n\
-[1/0 e^800]\n\
-@result{}\n\
-Inf   Inf\n\
+[ 1/0 e^800 ]\n\
+@result{} Inf   Inf\n\
 @end group\n\
 @end example\n\
 \n\
@@ -3986,23 +3957,21 @@
 DEFALIAS (inf, Inf);
 
 /*
-
-%!assert(inf (3), [Inf, Inf, Inf; Inf, Inf, Inf; Inf, Inf, Inf]);
-%!assert(inf (2, 3), [Inf, Inf, Inf; Inf, Inf, Inf]);
-%!assert(inf (3, 2), [Inf, Inf; Inf, Inf; Inf, Inf]);
-%!assert(size (inf (3, 4, 5)),  [3, 4, 5]);
-
-%!assert(inf (3,'single'), single([Inf, Inf, Inf; Inf, Inf, Inf; Inf, Inf, Inf]));
-%!assert(inf (2, 3,'single'), single([Inf, Inf, Inf; Inf, Inf, Inf]));
-%!assert(inf (3, 2,'single'), single([Inf, Inf; Inf, Inf; Inf, Inf]));
-%!assert(size (inf (3, 4, 5, 'single')),  [3, 4, 5]);
-
-%!error(inf (3,'int8'));
-%!error(inf (2, 3,'int8'));
-%!error(inf (3, 2,'int8'));
-%!error(inf (3, 4, 5, 'int8'));
-
- */
+%!assert (inf (3), [Inf, Inf, Inf; Inf, Inf, Inf; Inf, Inf, Inf])
+%!assert (inf (2, 3), [Inf, Inf, Inf; Inf, Inf, Inf])
+%!assert (inf (3, 2), [Inf, Inf; Inf, Inf; Inf, Inf])
+%!assert (size (inf (3, 4, 5)), [3, 4, 5])
+
+%!assert (inf (3, "single"), single ([Inf, Inf, Inf; Inf, Inf, Inf; Inf, Inf, Inf]))
+%!assert (inf (2, 3, "single"), single ([Inf, Inf, Inf; Inf, Inf, Inf]))
+%!assert (inf (3, 2, "single"), single ([Inf, Inf; Inf, Inf; Inf, Inf]))
+%!assert (size (inf (3, 4, 5, "single")), [3, 4, 5])
+
+%!error (inf (3, "int8"))
+%!error (inf (2, 3, "int8"))
+%!error (inf (3, 2, "int8"))
+%!error (inf (3, 4, 5, "int8"))
+*/
 
 DEFUN (NaN, args, ,
   "-*- texinfo -*-\n\
@@ -4047,22 +4016,21 @@
 DEFALIAS (nan, NaN);
 
 /*
-%!assert(NaN (3), [NaN, NaN, NaN; NaN, NaN, NaN; NaN, NaN, NaN]);
-%!assert(NaN (2, 3), [NaN, NaN, NaN; NaN, NaN, NaN]);
-%!assert(NaN (3, 2), [NaN, NaN; NaN, NaN; NaN, NaN]);
-%!assert(size (NaN (3, 4, 5)),  [3, 4, 5]);
-
-%!assert(NaN (3,'single'), single([NaN, NaN, NaN; NaN, NaN, NaN; NaN, NaN, NaN]));
-%!assert(NaN (2, 3,'single'), single([NaN, NaN, NaN; NaN, NaN, NaN]));
-%!assert(NaN (3, 2,'single'), single([NaN, NaN; NaN, NaN; NaN, NaN]));
-%!assert(size (NaN (3, 4, 5, 'single')),  [3, 4, 5]);
-
-%!error(NaN (3,'int8'));
-%!error(NaN (2, 3,'int8'));
-%!error(NaN (3, 2,'int8'));
-%!error(NaN (3, 4, 5, 'int8'));
-
- */
+%!assert (NaN (3), [NaN, NaN, NaN; NaN, NaN, NaN; NaN, NaN, NaN])
+%!assert (NaN (2, 3), [NaN, NaN, NaN; NaN, NaN, NaN])
+%!assert (NaN (3, 2), [NaN, NaN; NaN, NaN; NaN, NaN])
+%!assert (size (NaN (3, 4, 5)), [3, 4, 5])
+
+%!assert (NaN (3, "single"), single ([NaN, NaN, NaN; NaN, NaN, NaN; NaN, NaN, NaN]))
+%!assert (NaN (2, 3, "single"), single ([NaN, NaN, NaN; NaN, NaN, NaN]))
+%!assert (NaN (3, 2, "single"), single ([NaN, NaN; NaN, NaN; NaN, NaN]))
+%!assert (size (NaN (3, 4, 5, "single")), [3, 4, 5])
+
+%!error (NaN (3, "int8"))
+%!error (NaN (2, 3, "int8"))
+%!error (NaN (3, 2, "int8"))
+%!error (NaN (3, 4, 5, "int8"))
+*/
 
 DEFUN (e, args, ,
   "-*- texinfo -*-\n\
@@ -4119,7 +4087,7 @@
 for single precision.\n\
 \n\
 When called with no arguments, return a scalar with the value\n\
-@code{eps(1.0)}.\n\
+@code{eps (1.0)}.\n\
 Given a single argument @var{x}, return the distance between @var{x} and\n\
 the next largest value.\n\
 When called with more than one argument the first two arguments are taken as\n\
@@ -4140,7 +4108,7 @@
 
           if (! error_state)
             {
-              val  = ::fabsf(val);
+              val = ::fabsf (val);
               if (xisnan (val) || xisinf (val))
                 retval = fill_matrix (octave_value ("single"),
                                       lo_ieee_nan_value (),
@@ -4165,7 +4133,7 @@
 
           if (! error_state)
             {
-              val  = ::fabs(val);
+              val = ::fabs (val);
               if (xisnan (val) || xisinf (val))
                 retval = fill_matrix (octave_value_list (),
                                       lo_ieee_nan_value (),
@@ -4192,29 +4160,26 @@
 }
 
 /*
-
-%!assert(eps(1/2),2^(-53))
-%!assert(eps(1),2^(-52))
-%!assert(eps(2),2^(-51))
-%!assert(eps(realmax),2^971)
-%!assert(eps(0),2^(-1074))
-%!assert(eps(realmin/2),2^(-1074))
-%!assert(eps(realmin/16),2^(-1074))
-%!assert(eps(Inf),NaN)
-%!assert(eps(NaN),NaN)
-%!assert(eps(single(1/2)),single(2^(-24)))
-%!assert(eps(single(1)),single(2^(-23)))
-%!assert(eps(single(2)),single(2^(-22)))
-%!assert(eps(realmax('single')),single(2^104))
-%!assert(eps(single(0)),single(2^(-149)))
-%!assert(eps(realmin('single')/2),single(2^(-149)))
-%!assert(eps(realmin('single')/16),single(2^(-149)))
-%!assert(eps(single(Inf)),single(NaN))
-%!assert(eps(single(NaN)),single(NaN))
-
+%!assert (eps (1/2), 2^(-53))
+%!assert (eps (1), 2^(-52))
+%!assert (eps (2), 2^(-51))
+%!assert (eps (realmax), 2^971)
+%!assert (eps (0), 2^(-1074))
+%!assert (eps (realmin/2), 2^(-1074))
+%!assert (eps (realmin/16), 2^(-1074))
+%!assert (eps (Inf), NaN)
+%!assert (eps (NaN), NaN)
+%!assert (eps (single (1/2)), single (2^(-24)))
+%!assert (eps (single (1)), single (2^(-23)))
+%!assert (eps (single (2)), single (2^(-22)))
+%!assert (eps (realmax ("single")), single (2^104))
+%!assert (eps (single (0)), single (2^(-149)))
+%!assert (eps (realmin ("single")/2), single (2^(-149)))
+%!assert (eps (realmin ("single")/16), single (2^(-149)))
+%!assert (eps (single (Inf)), single (NaN))
+%!assert (eps (single (NaN)), single (NaN))
 */
 
-
 DEFUN (pi, args, ,
   "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {} pi\n\
@@ -4276,7 +4241,7 @@
 for single precision.\n\
 \n\
 When called with no arguments, return a scalar with the value\n\
-@code{realmax(\"double\")}.\n\
+@code{realmax (\"double\")}.\n\
 When called with a single argument, return a square matrix with the dimension\n\
 specified.  When called with more than one scalar argument the first two\n\
 arguments are taken as the number of rows and columns and any further\n\
@@ -4309,7 +4274,7 @@
 for single precision.\n\
 \n\
 When called with no arguments, return a scalar with the value\n\
-@code{realmin(\"double\")}.\n\
+@code{realmin (\"double\")}.\n\
 When called with a single argument, return a square matrix with the dimension\n\
 specified.  When called with more than one scalar argument the first two\n\
 arguments are taken as the number of rows and columns and any further\n\
@@ -4389,11 +4354,9 @@
 }
 
 /*
-
-%!assert(single(NA('double')),NA('single'))
-%!assert(double(NA('single')),NA('double'))
-
- */
+%!assert (single (NA ("double")), NA ("single"))
+%!assert (double (NA ("single")), NA ("double"))
+*/
 
 DEFUN (false, args, ,
   "-*- texinfo -*-\n\
@@ -4558,9 +4521,9 @@
 @example\n\
 @group\n\
 eye (3)\n\
-     @result{}  1  0  0\n\
-         0  1  0\n\
-         0  0  1\n\
+ @result{}  1  0  0\n\
+     0  1  0\n\
+     0  0  1\n\
 @end group\n\
 @end example\n\
 \n\
@@ -4642,21 +4605,18 @@
   return retval;
 }
 
-
 /*
-
-%!assert (full (eye(3)), [1, 0, 0; 0, 1, 0; 0, 0, 1]);
-%!assert (full (eye(2, 3)), [1, 0, 0; 0, 1, 0]);
-
-%!assert (full (eye(3,'single')), single([1, 0, 0; 0, 1, 0; 0, 0, 1]));
-%!assert (full (eye(2, 3,'single')), single([1, 0, 0; 0, 1, 0]));
-
-%!assert (eye(3,'int8'), int8([1, 0, 0; 0, 1, 0; 0, 0, 1]));
-%!assert (eye(2, 3,'int8'), int8([1, 0, 0; 0, 1, 0]));
-
-%!error <Invalid call to eye> eye (1, 2, 3);
-
- */
+%!assert (full (eye (3)), [1, 0, 0; 0, 1, 0; 0, 0, 1])
+%!assert (full (eye (2, 3)), [1, 0, 0; 0, 1, 0])
+
+%!assert (full (eye (3,"single")), single ([1, 0, 0; 0, 1, 0; 0, 0, 1]))
+%!assert (full (eye (2, 3,"single")), single ([1, 0, 0; 0, 1, 0]))
+
+%!assert (eye (3, "int8"), int8 ([1, 0, 0; 0, 1, 0; 0, 0, 1]))
+%!assert (eye (2, 3, "int8"), int8 ([1, 0, 0; 0, 1, 0]))
+
+%!error eye (1, 2, 3)
+*/
 
 template <class MT>
 static octave_value
@@ -4765,24 +4725,18 @@
 
 
 /*
-
 %!test
 %! x1 = linspace (1, 2);
 %! x2 = linspace (1, 2, 10);
 %! x3 = linspace (1, -2, 10);
-%! assert((size (x1) == [1, 100] && x1(1) == 1 && x1(100) == 2
-%! && size (x2) == [1, 10] && x2(1) == 1 && x2(10) == 2
-%! && size (x3) == [1, 10] && x3(1) == 1 && x3(10) == -2));
-
-
-% assert(linspace ([1, 2; 3, 4], 5, 6), linspace (1, 5, 6));
-
-%!error <Invalid call to linspace> linspace ();
-%!error <Invalid call to linspace> linspace (1, 2, 3, 4);
-
-%!test
-%! fail("linspace ([1, 2; 3, 4], 5, 6)","warning");
-
+%! assert (size (x1) == [1, 100] && x1(1) == 1 && x1(100) == 2);
+%! 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))
+
+%!error linspace ()
+%!error linspace (1, 2, 3, 4)
 */
 
 // FIXME -- should accept dimensions as separate args for N-d
@@ -4802,7 +4756,7 @@
 In other words, the statement\n\
 \n\
 @example\n\
-  y = resize (x, dv);\n\
+y = resize (x, dv)\n\
 @end example\n\
 \n\
 @noindent\n\
@@ -4810,10 +4764,12 @@
 \n\
 @example\n\
 @group\n\
-  y = zeros (dv, class (x));\n\
-  sz = min (dv, size (x));\n\
-  for i = 1:length (sz), idx@{i@} = 1:sz(i); endfor\n\
-  y(idx@{:@}) = x(idx@{:@});\n\
+y = zeros (dv, class (x));\n\
+sz = min (dv, size (x));\n\
+for i = 1:length (sz)\n\
+  idx@{i@} = 1:sz(i);\n\
+endfor\n\
+y(idx@{:@}) = x(idx@{:@});\n\
 @end group\n\
 @end example\n\
 \n\
@@ -4892,8 +4848,8 @@
 @example\n\
 @group\n\
 reshape ([1, 2, 3, 4], 2, 2)\n\
-     @result{}  1  3\n\
-         2  4\n\
+      @result{}  1  3\n\
+          2  4\n\
 @end group\n\
 @end example\n\
 \n\
@@ -4996,25 +4952,23 @@
 }
 
 /*
-
-%!assert(size (reshape (ones (4, 4), 2, 8)), [2, 8])
-%!assert(size (reshape (ones (4, 4), 8, 2)), [8, 2])
-%!assert(size (reshape (ones (15, 4), 1, 60)), [1, 60])
-%!assert(size (reshape (ones (15, 4), 60, 1)), [60, 1])
-
-%!assert(size (reshape (ones (4, 4, 'single'), 2, 8)), [2, 8])
-%!assert(size (reshape (ones (4, 4, 'single'), 8, 2)), [8, 2])
-%!assert(size (reshape (ones (15, 4, 'single'), 1, 60)), [1, 60])
-%!assert(size (reshape (ones (15, 4, 'single'), 60, 1)), [60, 1])
+%!assert (size (reshape (ones (4, 4), 2, 8)), [2, 8])
+%!assert (size (reshape (ones (4, 4), 8, 2)), [8, 2])
+%!assert (size (reshape (ones (15, 4), 1, 60)), [1, 60])
+%!assert (size (reshape (ones (15, 4), 60, 1)), [60, 1])
+
+%!assert (size (reshape (ones (4, 4, "single"), 2, 8)), [2, 8])
+%!assert (size (reshape (ones (4, 4, "single"), 8, 2)), [8, 2])
+%!assert (size (reshape (ones (15, 4, "single"), 1, 60)), [1, 60])
+%!assert (size (reshape (ones (15, 4, "single"), 60, 1)), [60, 1])
 
 %!test
 %! s.a = 1;
-%! fail("reshape (s, 2, 3)");
-
-%!error <Invalid call to reshape> reshape ();
-%!error reshape (1, 2, 3, 4);
-
- */
+%! fail ("reshape (s, 2, 3)");
+
+%!error reshape ()
+%!error reshape (1, 2, 3, 4)
+*/
 
 DEFUN (vec, args, ,
   "-*- texinfo -*-\n\
@@ -5068,20 +5022,18 @@
 }
 
 /*
-
-%!assert(vec ([1, 2; 3, 4]), [1; 3; 2; 4])
-%!assert(vec ([1, 3, 2, 4]), [1; 3; 2; 4]);
-%!assert(vec ([1, 2, 3, 4], 2), [1, 2, 3, 4]);
-%!assert(vec ([1, 2; 3, 4]), vec ([1, 2; 3, 4], 1));
-%!assert(vec ([1, 2; 3, 4], 1), [1; 3; 2; 4]);
-%!assert(vec ([1, 2; 3, 4], 2), [1, 3, 2, 4]);
-%!assert(vec ([1, 3; 2, 4], 3), reshape ([1, 2, 3, 4], 1, 1, 4));
-%!assert(vec ([1, 3; 2, 4], 3), shiftdim (vec ([1, 3; 2, 4]), -2));
-
-%!error vec ();
-%!error vec (1, 2, 3);
-%!error vec ([1, 2; 3, 4], 0);
-
+%!assert (vec ([1, 2; 3, 4]), [1; 3; 2; 4])
+%!assert (vec ([1, 3, 2, 4]), [1; 3; 2; 4])
+%!assert (vec ([1, 2, 3, 4], 2), [1, 2, 3, 4])
+%!assert (vec ([1, 2; 3, 4]), vec ([1, 2; 3, 4], 1))
+%!assert (vec ([1, 2; 3, 4], 1), [1; 3; 2; 4])
+%!assert (vec ([1, 2; 3, 4], 2), [1, 3, 2, 4])
+%!assert (vec ([1, 3; 2, 4], 3), reshape ([1, 2, 3, 4], 1, 1, 4))
+%!assert (vec ([1, 3; 2, 4], 3), shiftdim (vec ([1, 3; 2, 4]), -2))
+
+%!error vec ()
+%!error vec (1, 2, 3)
+%!error vec ([1, 2; 3, 4], 0)
 */
 
 DEFUN (squeeze, args, ,
@@ -5246,53 +5198,59 @@
 /*
 %!shared x
 %! x = [1, -3, 4, 5, -7];
-%!assert(norm(x,1), 20);
-%!assert(norm(x,2), 10);
-%!assert(norm(x,3), 8.24257059961711, -4*eps);
-%!assert(norm(x,Inf), 7);
-%!assert(norm(x,-Inf), 1);
-%!assert(norm(x,"inf"), 7);
-%!assert(norm(x,"fro"), 10, -eps);
-%!assert(norm(x), 10);
-%!assert(norm([1e200, 1]), 1e200);
-%!assert(norm([3+4i, 3-4i, sqrt(31)]), 9, -4*eps);
+%!assert (norm (x,1), 20)
+%!assert (norm (x,2), 10)
+%!assert (norm (x,3), 8.24257059961711, -4*eps)
+%!assert (norm (x,Inf), 7)
+%!assert (norm (x,-Inf), 1)
+%!assert (norm (x,"inf"), 7)
+%!assert (norm (x,"fro"), 10, -eps)
+%!assert (norm (x), 10)
+%!assert (norm ([1e200, 1]), 1e200)
+%!assert (norm ([3+4i, 3-4i, sqrt(31)]), 9, -4*eps)
 %!shared m
 %! m = magic (4);
-%!assert(norm(m,1), 34);
-%!assert(norm(m,2), 34, -eps);
-%!assert(norm(m,Inf), 34);
-%!assert(norm(m,"inf"), 34);
+%!assert (norm (m,1), 34)
+%!assert (norm (m,2), 34, -eps)
+%!assert (norm (m,Inf), 34)
+%!assert (norm (m,"inf"), 34)
 %!shared m2, flo, fhi
 %! m2 = [1,2;3,4];
 %! flo = 1e-300;
 %! fhi = 1e+300;
-%!assert (norm(flo*m2,"fro"), sqrt(30)*flo, -eps)
-%!assert (norm(fhi*m2,"fro"), sqrt(30)*fhi, -eps)
+%!assert (norm (flo*m2,"fro"), sqrt (30)*flo, -eps)
+%!assert (norm (fhi*m2,"fro"), sqrt (30)*fhi, -eps)
 
 %!shared x
-%! x = single([1, -3, 4, 5, -7]);
-%!assert(norm(x,1), single(20));
-%!assert(norm(x,2), single(10));
-%!assert(norm(x,3), single(8.24257059961711), -4*eps('single'));
-%!assert(norm(x,Inf), single(7));
-%!assert(norm(x,-Inf), single(1));
-%!assert(norm(x,"inf"), single(7));
-%!assert(norm(x,"fro"), single(10), -eps('single'));
-%!assert(norm(x), single(10));
-%!assert(norm(single([1e200, 1])), single(1e200));
-%!assert(norm(single([3+4i, 3-4i, sqrt(31)])), single(9), -4*eps('single'));
+%! x = single ([1, -3, 4, 5, -7]);
+%!assert (norm (x,1), single (20))
+%!assert (norm (x,2), single (10))
+%!assert (norm (x,3), single (8.24257059961711), -4*eps ("single"))
+%!assert (norm (x,Inf), single (7))
+%!assert (norm (x,-Inf), single (1))
+%!assert (norm (x,"inf"), single (7))
+%!assert (norm (x,"fro"), single (10), -eps ("single"))
+%!assert (norm (x), single (10))
+%!assert (norm (single ([1e200, 1])), single (1e200))
+%!assert (norm (single ([3+4i, 3-4i, sqrt(31)])), single (9), -4*eps ("single"))
 %!shared m
-%! m = single(magic (4));
-%!assert(norm(m,1), single(34));
-%!assert(norm(m,2), single(34), -eps('single'));
-%!assert(norm(m,Inf), single(34));
-%!assert(norm(m,"inf"), single(34));
+%! m = single (magic (4));
+%!assert (norm (m,1), single (34))
+%!assert (norm (m,2), single (34), -eps ("single"))
+%!assert (norm (m,Inf), single (34))
+%!assert (norm (m,"inf"), single (34))
 %!shared m2, flo, fhi
-%! m2 = single([1,2;3,4]);
-%! flo = single(1e-300);
-%! 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'))
+%! m2 = single ([1,2;3,4]);
+%! flo = single (1e-300);
+%! 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
@@ -5349,25 +5307,23 @@
 }
 
 /*
-
-%!assert (2.', 2);
-%!assert (2i.',2i);
-%!assert ([1:4].',[1;2;3;4]);
-%!assert ([1;2;3;4].',[1:4]);
-%!assert ([1,2;3,4].',[1,3;2,4]);
-%!assert ([1,2i;3,4].',[1,3;2i,4]);
-
-%!assert (transpose ([1,2;3,4]),[1,3;2,4]);
-
-%!assert (single(2).', single(2));
-%!assert (single(2i).',single(2i));
-%!assert (single([1:4]).',single([1;2;3;4]));
-%!assert (single([1;2;3;4]).',single([1:4]));
-%!assert (single([1,2;3,4]).',single([1,3;2,4]));
-%!assert (single([1,2i;3,4]).',single([1,3;2i,4]));
-
-%!assert (transpose (single([1,2;3,4])),single([1,3;2,4]));
-
+%!assert (2.', 2)
+%!assert (2i.', 2i)
+%!assert ([1:4].', [1;2;3;4])
+%!assert ([1;2;3;4].', [1:4])
+%!assert ([1,2;3,4].', [1,3;2,4])
+%!assert ([1,2i;3,4].', [1,3;2i,4])
+
+%!assert (transpose ([1,2;3,4]), [1,3;2,4])
+
+%!assert (single (2).', single (2))
+%!assert (single (2i).', single (2i))
+%!assert (single ([1:4]).', single ([1;2;3;4]))
+%!assert (single ([1;2;3;4]).', single ([1:4]))
+%!assert (single ([1,2;3,4]).', single ([1,3;2,4]))
+%!assert (single ([1,2i;3,4]).', single ([1,3;2i,4]))
+
+%!assert (transpose (single ([1,2;3,4])), single ([1,3;2,4]))
 */
 
 DEFUN (ctranspose, args, ,
@@ -5382,25 +5338,23 @@
 }
 
 /*
-
-%!assert (2', 2);
-%!assert (2i',-2i);
-%!assert ([1:4]',[1;2;3;4]);
-%!assert ([1;2;3;4]',[1:4]);
-%!assert ([1,2;3,4]',[1,3;2,4]);
-%!assert ([1,2i;3,4]',[1,3;-2i,4]);
-
-%!assert (ctranspose ([1,2i;3,4]),[1,3;-2i,4]);
-
-%!assert (single(2)', single(2));
-%!assert (single(2i)',single(-2i));
-%!assert (single([1:4])',single([1;2;3;4]));
-%!assert (single([1;2;3;4])',single([1:4]));
-%!assert (single([1,2;3,4])',single([1,3;2,4]));
-%!assert (single([1,2i;3,4])',single([1,3;-2i,4]));
-
-%!assert (ctranspose (single([1,2i;3,4])),single([1,3;-2i,4]));
-
+%!assert (2', 2)
+%!assert (2i', -2i)
+%!assert ([1:4]', [1;2;3;4])
+%!assert ([1;2;3;4]', [1:4])
+%!assert ([1,2;3,4]', [1,3;2,4])
+%!assert ([1,2i;3,4]', [1,3;-2i,4])
+
+%!assert (ctranspose ([1,2i;3,4]), [1,3;-2i,4])
+
+%!assert (single (2)', single (2))
+%!assert (single (2i)', single (-2i))
+%!assert (single ([1:4])', single ([1;2;3;4]))
+%!assert (single ([1;2;3;4])', single ([1:4]))
+%!assert (single ([1,2;3,4])', single ([1,3;2,4]))
+%!assert (single ([1,2i;3,4])', single ([1,3;-2i,4]))
+
+%!assert (ctranspose (single ([1,2i;3,4])), single ([1,3;-2i,4]))
 */
 
 static octave_value
@@ -5455,7 +5409,7 @@
 cumulatively from left to right:\n\
 \n\
 @example\n\
-  (@dots{}((x1 + x2) + x3) + @dots{})\n\
+(@dots{}((x1 + x2) + x3) + @dots{})\n\
 @end example\n\
 \n\
 At least one argument is required.\n\
@@ -5486,7 +5440,7 @@
 cumulatively from left to right:\n\
 \n\
 @example\n\
-  (@dots{}((x1 * x2) * x3) * @dots{})\n\
+(@dots{}((x1 * x2) * x3) * @dots{})\n\
 @end example\n\
 \n\
 At least one argument is required.\n\
@@ -5523,7 +5477,7 @@
   "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} mldivide (@var{x}, @var{y})\n\
 Return the matrix left division of @var{x} and @var{y}.\n\
-This function and @w{@xcode{x \\ y}} are equivalent.\n\
+This function and @w{@xcode{x @xbackslashchar{} y}} are equivalent.\n\
 @seealso{mrdivide, ldivide}\n\
 @end deftypefn")
 {
@@ -5598,7 +5552,7 @@
 cumulatively from left to right:\n\
 \n\
 @example\n\
-  (@dots{}((x1 .* x2) .* x3) .* @dots{})\n\
+(@dots{}((x1 .* x2) .* x3) .* @dots{})\n\
 @end example\n\
 \n\
 At least one argument is required.\n\
@@ -5640,7 +5594,7 @@
   "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} ldivide (@var{x}, @var{y})\n\
 Return the element-by-element left division of @var{x} and @var{y}.\n\
-This function and @w{@xcode{x .\\ y}} are equivalent.\n\
+This function and @w{@xcode{x .@xbackslashchar{} y}} are equivalent.\n\
 @seealso{rdivide, mldivide}\n\
 @end deftypefn")
 {
@@ -5657,7 +5611,7 @@
 cumulatively from left to right:\n\
 \n\
 @example\n\
-  (@dots{}((x1 & x2) & x3) & @dots{})\n\
+(@dots{}((x1 & x2) & x3) & @dots{})\n\
 @end example\n\
 \n\
 At least one argument is required.\n\
@@ -5678,7 +5632,7 @@
 cumulatively from left to right:\n\
 \n\
 @example\n\
-  (@dots{}((x1 | x2) | x3) | @dots{})\n\
+(@dots{}((x1 | x2) | x3) | @dots{})\n\
 @end example\n\
 \n\
 At least one argument is required.\n\
@@ -5694,10 +5648,14 @@
 DEFUN (tic, args, nargout,
   "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {} tic ()\n\
+@deftypefnx {Built-in Function} {@var{id} =} tic ()\n\
 @deftypefnx {Built-in Function} {} toc ()\n\
+@deftypefnx {Built-in Function} {} toc (@var{id})\n\
+@deftypefnx {Built-in Function} {@var{val} =} toc (@dots{})\n\
 Set or check a wall-clock timer.  Calling @code{tic} without an\n\
-output argument sets the timer.  Subsequent calls to @code{toc}\n\
-return the number of seconds since the timer was set.  For example,\n\
+output argument sets the internal timer state.  Subsequent calls\n\
+to @code{toc} return the number of seconds since the timer was set.\n\
+For example,\n\
 \n\
 @example\n\
 @group\n\
@@ -5711,38 +5669,23 @@
 will set the variable @code{elapsed_time} to the number of seconds since\n\
 the most recent call to the function @code{tic}.\n\
 \n\
-If called with one output argument then this function returns a scalar\n\
-of type @code{uint64} and the wall-clock timer is not started.\n\
+If called with one output argument, @code{tic} returns a scalar\n\
+of type @code{uint64} that may be later passed to @code{toc}.\n\
 \n\
 @example\n\
 @group\n\
-t = tic; sleep (5); (double (tic ()) - double (t)) * 1e-6\n\
-     @result{} 5\n\
+id = tic; sleep (5); toc (id)\n\
+      @result{} 5.0010\n\
 @end group\n\
 @end example\n\
 \n\
-Nested timing with @code{tic} and @code{toc} is not supported.\n\
-Therefore @code{toc} will always return the elapsed time from the most\n\
-recent call to @code{tic}.\n\
+Calling @code{tic} and @code{toc} this way allows nested timing calls.\n\
 \n\
 If you are more interested in the CPU time that your process used, you\n\
 should use the @code{cputime} function instead.  The @code{tic} and\n\
 @code{toc} functions report the actual wall clock time that elapsed\n\
 between the calls.  This may include time spent processing other jobs or\n\
-doing nothing at all.  For example:\n\
-\n\
-@example\n\
-@group\n\
-tic (); sleep (5); toc ()\n\
-     @result{} 5\n\
-t = cputime (); sleep (5); cputime () - t\n\
-     @result{} 0\n\
-@end group\n\
-@end example\n\
-\n\
-@noindent\n\
-(This example also illustrates that the CPU timer may have a fairly\n\
-coarse resolution.)\n\
+doing nothing at all.\n\
 @end deftypefn")
 {
   octave_value retval;
@@ -5757,7 +5700,13 @@
   double tmp = now.double_value ();
 
   if (nargout > 0)
-    retval = static_cast<octave_uint64> (1e6 * tmp);
+    {
+      double ip = 0.0;
+      double frac = modf (tmp, &ip);
+      uint64_t microsecs = static_cast<uint64_t> (CLOCKS_PER_SEC * frac);
+      microsecs += CLOCKS_PER_SEC * static_cast<uint64_t> (ip);
+      retval = octave_uint64 (microsecs);
+    }
   else
     tic_toc_timestamp = tmp;
 
@@ -5766,7 +5715,9 @@
 
 DEFUN (toc, args, nargout,
   "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {} toc ()\n\
+@deftypefn  {Built-in Function} {} toc ()\n\
+@deftypefnx {Built-in Function} {} toc (@var{id})\n\
+@deftypefnx {Built-in Function} {@var{val} =} toc (@dots{})\n\
 See tic.\n\
 @end deftypefn")
 {
@@ -5774,30 +5725,59 @@
 
   int nargin = args.length ();
 
-  if (nargin != 0)
-    warning ("tic: ignoring extra arguments");
-
-  if (tic_toc_timestamp < 0)
-    {
-      warning ("toc called before timer set");
-      if (nargout > 0)
-        retval = Matrix ();
-    }
+  double start_time = tic_toc_timestamp;
+
+  if (nargin > 1)
+    print_usage ();
   else
     {
-      octave_time now;
-
-      double tmp = now.double_value () - tic_toc_timestamp;
-
-      if (nargout > 0)
-        retval = tmp;
-      else
-        octave_stdout << "Elapsed time is " << tmp << " seconds.\n";
+      if (nargin == 1)
+        {
+          octave_uint64 id = args(0).uint64_scalar_value ();
+
+          if (! error_state)
+            {
+              uint64_t val = id.value ();
+
+              start_time
+                = (static_cast<double> (val / CLOCKS_PER_SEC)
+                   + static_cast<double> (val % CLOCKS_PER_SEC) / CLOCKS_PER_SEC);
+
+              // FIXME -- should we also check to see whether the start
+              // time is after the beginning of this Octave session?
+            }
+          else
+            error ("toc: invalid ID");
+        }
+
+      if (! error_state)
+        {
+          if (start_time < 0)
+            error ("toc called before timer set");
+          else
+            {
+              octave_time now;
+
+              double tmp = now.double_value () - start_time;
+
+              if (nargout > 0)
+                retval = tmp;
+              else
+                octave_stdout << "Elapsed time is " << tmp << " seconds.\n";
+            }
+        }
     }
 
   return retval;
 }
 
+/*
+%!shared id
+%! id = tic ();
+%!assert (isa (id, "uint64"))
+%!assert (isa (toc (id), "double"))
+*/
+
 DEFUN (cputime, args, ,
   "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {[@var{total}, @var{user}, @var{system}] =} cputime ();\n\
@@ -5858,9 +5838,9 @@
 
 #endif
 
-  retval (2) = sys;
-  retval (1) = usr;
-  retval (0) = sys + usr;
+  retval(2) = sys;
+  retval(1) = usr;
+  retval(0) = sys + usr;
 
   return retval;
 }
@@ -5879,16 +5859,16 @@
 @example\n\
 @group\n\
 sort ([1, 2; 2, 3; 3, 1])\n\
-     @result{}  1  1\n\
-         2  2\n\
-         3  3\n\
+   @result{}  1  1\n\
+       2  2\n\
+       3  3\n\
 @end group\n\
 @end example\n\
 \n\
 If the optional argument @var{dim} is given, then the matrix is sorted\n\
 along the dimension defined by @var{dim}.  The optional argument @code{mode}\n\
 defines the order in which the values will be sorted.  Valid values of\n\
-@code{mode} are `ascend' or `descend'.\n\
+@code{mode} are \"ascend\" or \"descend\".\n\
 \n\
 The @code{sort} function may also be used to produce a matrix\n\
 containing the original row indices of the elements in the sorted\n\
@@ -5897,12 +5877,12 @@
 @example\n\
 @group\n\
 [s, i] = sort ([1, 2; 2, 3; 3, 1])\n\
-     @result{} s = 1  1\n\
-            2  2\n\
-            3  3\n\
-     @result{} i = 1  3\n\
-            2  1\n\
-            3  2\n\
+  @result{} s = 1  1\n\
+         2  2\n\
+         3  3\n\
+  @result{} i = 1  3\n\
+         2  1\n\
+         3  2\n\
 @end group\n\
 @end example\n\
 \n\
@@ -5915,9 +5895,9 @@
 @example\n\
 @group\n\
 sort ([1+i; 1; 1-i])\n\
-     @result{} 1 + 0i\n\
-        1 - 1i\n\
-        1 + 1i\n\
+    @result{} 1 + 0i\n\
+       1 - 1i\n\
+       1 + 1i\n\
 @end group\n\
 @end example\n\
 \n\
@@ -5952,7 +5932,7 @@
     {
       if (args(1).is_string ())
         {
-          std::string mode = args(1).string_value();
+          std::string mode = args(1).string_value ();
           if (mode == "ascend")
             smode = ASCENDING;
           else if (mode == "descend")
@@ -5980,7 +5960,7 @@
           error ("sort: MODE must be a string");
           return retval;
         }
-      std::string mode = args(2).string_value();
+      std::string mode = args(2).string_value ();
       if (mode == "ascend")
         smode = ASCENDING;
       else if (mode == "descend")
@@ -6013,8 +5993,8 @@
 
       Array<octave_idx_type> sidx;
 
-      retval (0) = arg.sort (sidx, dim, smode);
-      retval (1) = idx_vector (sidx, dv(dim)); // No checking, the extent is known.
+      retval(0) = arg.sort (sidx, dim, smode);
+      retval(1) = idx_vector (sidx, dv(dim)); // No checking, the extent is known.
     }
   else
     retval(0) = arg.sort (dim, smode);
@@ -6023,8 +6003,7 @@
 }
 
 /*
-
-%% Double
+## Double
 %!assert (sort ([NaN, 1, -1, 2, Inf]), [-1, 1, 2, Inf, NaN])
 %!assert (sort ([NaN, 1, -1, 2, Inf], 1), [NaN, 1, -1, 2, Inf])
 %!assert (sort ([NaN, 1, -1, 2, Inf], 2), [-1, 1, 2, Inf, NaN])
@@ -6040,10 +6019,10 @@
 
 %!test
 %! [v, i] = sort ([NaN, 1, -1, Inf, 1]);
-%! assert (v, [-1, 1, 1, Inf, NaN])
-%! assert (i, [3, 2, 5, 4, 1])
-
-%% Complex
+%! assert (v, [-1, 1, 1, Inf, NaN]);
+%! assert (i, [3, 2, 5, 4, 1]);
+
+## Complex
 %!assert (sort ([NaN, 1i, -1, 2, Inf]), [1i, -1, 2, Inf, NaN])
 %!assert (sort ([NaN, 1i, -1, 2, Inf], 1), [NaN, 1i, -1, 2, Inf])
 %!assert (sort ([NaN, 1i, -1, 2, Inf], 2), [1i, -1, 2, Inf, NaN])
@@ -6059,48 +6038,48 @@
 
 %!test
 %! [v, i] = sort ([NaN, 1i, -1, Inf, 1, 1i]);
-%! assert (v, [1, 1i, 1i, -1, Inf, NaN])
-%! assert (i, [5, 2, 6, 3, 4, 1])
-
-%% Single
-%!assert (sort (single([NaN, 1, -1, 2, Inf])), single([-1, 1, 2, Inf, NaN]))
-%!assert (sort (single([NaN, 1, -1, 2, Inf]), 1), single([NaN, 1, -1, 2, Inf]))
-%!assert (sort (single([NaN, 1, -1, 2, Inf]), 2), single([-1, 1, 2, Inf, NaN]))
-%!assert (sort (single([NaN, 1, -1, 2, Inf]), 3), single([NaN, 1, -1, 2, Inf]))
-%!assert (sort (single([NaN, 1, -1, 2, Inf]), "ascend"), single([-1, 1, 2, Inf, NaN]))
-%!assert (sort (single([NaN, 1, -1, 2, Inf]), 2, "ascend"), single([-1, 1, 2, Inf, NaN]))
-%!assert (sort (single([NaN, 1, -1, 2, Inf]), "descend"), single([NaN, Inf, 2, 1, -1]))
-%!assert (sort (single([NaN, 1, -1, 2, Inf]), 2, "descend"), single([NaN, Inf, 2, 1, -1]))
-%!assert (sort (single([3, 1, 7, 5; 8, 2, 6, 4])), single([3, 1, 6, 4; 8, 2, 7, 5]))
-%!assert (sort (single([3, 1, 7, 5; 8, 2, 6, 4]), 1), single([3, 1, 6, 4; 8, 2, 7, 5]))
-%!assert (sort (single([3, 1, 7, 5; 8, 2, 6, 4]), 2), single([1, 3, 5, 7; 2, 4, 6, 8]))
-%!assert (sort (single(1)), single(1))
+%! assert (v, [1, 1i, 1i, -1, Inf, NaN]);
+%! assert (i, [5, 2, 6, 3, 4, 1]);
+
+## Single
+%!assert (sort (single ([NaN, 1, -1, 2, Inf])), single ([-1, 1, 2, Inf, NaN]))
+%!assert (sort (single ([NaN, 1, -1, 2, Inf]), 1), single ([NaN, 1, -1, 2, Inf]))
+%!assert (sort (single ([NaN, 1, -1, 2, Inf]), 2), single ([-1, 1, 2, Inf, NaN]))
+%!assert (sort (single ([NaN, 1, -1, 2, Inf]), 3), single ([NaN, 1, -1, 2, Inf]))
+%!assert (sort (single ([NaN, 1, -1, 2, Inf]), "ascend"), single ([-1, 1, 2, Inf, NaN]))
+%!assert (sort (single ([NaN, 1, -1, 2, Inf]), 2, "ascend"), single ([-1, 1, 2, Inf, NaN]))
+%!assert (sort (single ([NaN, 1, -1, 2, Inf]), "descend"), single ([NaN, Inf, 2, 1, -1]))
+%!assert (sort (single ([NaN, 1, -1, 2, Inf]), 2, "descend"), single ([NaN, Inf, 2, 1, -1]))
+%!assert (sort (single ([3, 1, 7, 5; 8, 2, 6, 4])), single ([3, 1, 6, 4; 8, 2, 7, 5]))
+%!assert (sort (single ([3, 1, 7, 5; 8, 2, 6, 4]), 1), single ([3, 1, 6, 4; 8, 2, 7, 5]))
+%!assert (sort (single ([3, 1, 7, 5; 8, 2, 6, 4]), 2), single ([1, 3, 5, 7; 2, 4, 6, 8]))
+%!assert (sort (single (1)), single (1))
 
 %!test
-%! [v, i] = sort (single([NaN, 1, -1, Inf, 1]));
-%! assert (v, single([-1, 1, 1, Inf, NaN]))
-%! assert (i, [3, 2, 5, 4, 1])
-
-%% Single Complex
-%!assert (sort (single([NaN, 1i, -1, 2, Inf])), single([1i, -1, 2, Inf, NaN]))
-%!assert (sort (single([NaN, 1i, -1, 2, Inf]), 1), single([NaN, 1i, -1, 2, Inf]))
-%!assert (sort (single([NaN, 1i, -1, 2, Inf]), 2), single([1i, -1, 2, Inf, NaN]))
-%!assert (sort (single([NaN, 1i, -1, 2, Inf]), 3), single([NaN, 1i, -1, 2, Inf]))
-%!assert (sort (single([NaN, 1i, -1, 2, Inf]), "ascend"), single([1i, -1, 2, Inf, NaN]))
-%!assert (sort (single([NaN, 1i, -1, 2, Inf]), 2, "ascend"), single([1i, -1, 2, Inf, NaN]))
-%!assert (sort (single([NaN, 1i, -1, 2, Inf]), "descend"), single([NaN, Inf, 2, -1, 1i]))
-%!assert (sort (single([NaN, 1i, -1, 2, Inf]), 2, "descend"), single([NaN, Inf, 2, -1, 1i]))
-%!assert (sort (single([3, 1i, 7, 5; 8, 2, 6, 4])), single([3, 1i, 6, 4; 8, 2, 7, 5]))
-%!assert (sort (single([3, 1i, 7, 5; 8, 2, 6, 4]), 1), single([3, 1i, 6, 4; 8, 2, 7, 5]))
-%!assert (sort (single([3, 1i, 7, 5; 8, 2, 6, 4]), 2), single([1i, 3, 5, 7; 2, 4, 6, 8]))
-%!assert (sort (single(1i)),single( 1i))
+%! [v, i] = sort (single ([NaN, 1, -1, Inf, 1]));
+%! assert (v, single ([-1, 1, 1, Inf, NaN]));
+%! assert (i, [3, 2, 5, 4, 1]);
+
+## Single Complex
+%!assert (sort (single ([NaN, 1i, -1, 2, Inf])), single ([1i, -1, 2, Inf, NaN]))
+%!assert (sort (single ([NaN, 1i, -1, 2, Inf]), 1), single ([NaN, 1i, -1, 2, Inf]))
+%!assert (sort (single ([NaN, 1i, -1, 2, Inf]), 2), single ([1i, -1, 2, Inf, NaN]))
+%!assert (sort (single ([NaN, 1i, -1, 2, Inf]), 3), single ([NaN, 1i, -1, 2, Inf]))
+%!assert (sort (single ([NaN, 1i, -1, 2, Inf]), "ascend"), single ([1i, -1, 2, Inf, NaN]))
+%!assert (sort (single ([NaN, 1i, -1, 2, Inf]), 2, "ascend"), single ([1i, -1, 2, Inf, NaN]))
+%!assert (sort (single ([NaN, 1i, -1, 2, Inf]), "descend"), single ([NaN, Inf, 2, -1, 1i]))
+%!assert (sort (single ([NaN, 1i, -1, 2, Inf]), 2, "descend"), single ([NaN, Inf, 2, -1, 1i]))
+%!assert (sort (single ([3, 1i, 7, 5; 8, 2, 6, 4])), single ([3, 1i, 6, 4; 8, 2, 7, 5]))
+%!assert (sort (single ([3, 1i, 7, 5; 8, 2, 6, 4]), 1), single ([3, 1i, 6, 4; 8, 2, 7, 5]))
+%!assert (sort (single ([3, 1i, 7, 5; 8, 2, 6, 4]), 2), single ([1i, 3, 5, 7; 2, 4, 6, 8]))
+%!assert (sort (single (1i)), single (1i))
 
 %!test
-%! [v, i] = sort (single([NaN, 1i, -1, Inf, 1, 1i]));
-%! assert (v, single([1, 1i, 1i, -1, Inf, NaN]))
-%! assert (i, [5, 2, 6, 3, 4, 1])
-
-%% Bool
+%! [v, i] = sort (single ([NaN, 1i, -1, Inf, 1, 1i]));
+%! assert (v, single ([1, 1i, 1i, -1, Inf, NaN]));
+%! assert (i, [5, 2, 6, 3, 4, 1]);
+
+## Bool
 %!assert (sort ([true, false, true, false]), [false, false, true, true])
 %!assert (sort ([true, false, true, false], 1), [true, false, true, false])
 %!assert (sort ([true, false, true, false], 2), [false, false, true, true])
@@ -6113,10 +6092,10 @@
 
 %!test
 %! [v, i] = sort ([true, false, true, false]);
-%! assert (v, [false, false, true, true])
-%! assert (i, [2, 4, 1, 3])
-
-%% Sparse Double
+%! assert (v, [false, false, true, true]);
+%! assert (i, [2, 4, 1, 3]);
+
+## Sparse Double
 %!assert (sort (sparse ([0, NaN, 1, 0, -1, 2, Inf])), sparse ([-1, 0, 0, 1, 2, Inf, NaN]))
 %!assert (sort (sparse ([0, NaN, 1, 0, -1, 2, Inf]), 1), sparse ([0, NaN, 1, 0, -1, 2, Inf]))
 %!assert (sort (sparse ([0, NaN, 1, 0, -1, 2, Inf]), 2), sparse ([-1, 0, 0, 1, 2, Inf, NaN]))
@@ -6128,17 +6107,17 @@
 
 %!shared a
 %! a = randn (10, 10);
-%! a (a < 0) = 0;
+%! a(a < 0) = 0;
 %!assert (sort (sparse (a)), sparse (sort (a)))
 %!assert (sort (sparse (a), 1), sparse (sort (a, 1)))
 %!assert (sort (sparse (a), 2), sparse (sort (a, 2)))
 %!test
 %! [v, i] = sort (a);
 %! [vs, is] = sort (sparse (a));
-%! assert (vs, sparse (v))
-%! assert (is, i)
-
-%% Sparse Complex
+%! assert (vs, sparse (v));
+%! assert (is, i);
+
+## Sparse Complex
 %!assert (sort (sparse ([0, NaN, 1i, 0, -1, 2, Inf])), sparse ([0, 0, 1i, -1, 2, Inf, NaN]))
 %!assert (sort (sparse ([0, NaN, 1i, 0, -1, 2, Inf]), 1), sparse ([0, NaN, 1i, 0, -1, 2, Inf]))
 %!assert (sort (sparse ([0, NaN, 1i, 0, -1, 2, Inf]), 2), sparse ([0, 0, 1i, -1, 2, Inf, NaN]))
@@ -6150,7 +6129,7 @@
 
 %!shared a
 %! a = randn (10, 10);
-%! a (a < 0) = 0;
+%! a(a < 0) = 0;
 %! a = 1i * a;
 %!assert (sort (sparse (a)), sparse (sort (a)))
 %!assert (sort (sparse (a), 1), sparse (sort (a, 1)))
@@ -6158,30 +6137,30 @@
 %!test
 %! [v, i] = sort (a);
 %! [vs, is] = sort (sparse (a));
-%! assert (vs, sparse (v))
-%! assert (is, i)
-
-%% Sparse Bool
+%! assert (vs, sparse (v));
+%! assert (is, i);
+
+## Sparse Bool
 %!assert (sort (sparse ([true, false, true, false])), sparse ([false, false, true, true]))
-%!assert (sort (sparse([true, false, true, false]), 1), sparse ([true, false, true, false]))
+%!assert (sort (sparse ([true, false, true, false]), 1), sparse ([true, false, true, false]))
 %!assert (sort (sparse ([true, false, true, false]), 2), sparse ([false, false, true, true]))
 %!assert (sort (sparse ([true, false, true, false]), 3), sparse ([true, false, true, false]))
-%!assert (sort (sparse ([true, false, true, false]), "ascend"), sparse([false, false, true, true]))
-%!assert (sort (sparse ([true, false, true, false]), 2, "ascend"), sparse([false, false, true, true]))
+%!assert (sort (sparse ([true, false, true, false]), "ascend"), sparse ([false, false, true, true]))
+%!assert (sort (sparse ([true, false, true, false]), 2, "ascend"), sparse ([false, false, true, true]))
 %!assert (sort (sparse ([true, false, true, false]), "descend"), sparse ([true, true, false, false]))
-%!assert (sort (sparse ([true, false, true, false]), 2, "descend"), sparse([true, true, false, false]))
+%!assert (sort (sparse ([true, false, true, false]), 2, "descend"), sparse ([true, true, false, false]))
 
 %!test
-%! [v, i] = sort (sparse([true, false, true, false]));
-%! assert (v, sparse([false, false, true, true]))
-%! assert (i, [2, 4, 1, 3])
-
-%% Cell string array
+%! [v, i] = sort (sparse ([true, false, true, false]));
+%! assert (v, sparse ([false, false, true, true]));
+%! assert (i, [2, 4, 1, 3]);
+
+## Cell string array
 %!shared a, b, c
 %! a = {"Alice", "Cecile", "Eric", "Barry", "David"};
 %! b = {"Alice", "Barry", "Cecile", "David", "Eric"};
 %! c = {"Eric", "David", "Cecile", "Barry", "Alice"};
-%!assert (sort (a), b);
+%!assert (sort (a), b)
 %!assert (sort (a, 1), a)
 %!assert (sort (a, 2), b)
 %!assert (sort (a, 3), a)
@@ -6192,11 +6171,10 @@
 
 %!test
 %! [v, i] = sort (a);
-%! assert (i, [1, 4, 2, 5, 3])
-
-%!error <Invalid call to sort> sort ();
-%!error <Invalid call to sort> sort (1, 2, 3, 4);
-
+%! assert (i, [1, 4, 2, 5, 3]);
+
+%!error sort ()
+%!error sort (1, 2, 3, 4)
 */
 
 // Sort the rows of the matrix @var{a} according to the order
@@ -6224,7 +6202,7 @@
 
   if (nargin > 1)
     {
-      std::string mode = args(1).string_value();
+      std::string mode = args(1).string_value ();
       if (mode == "ascend")
         smode = ASCENDING;
       else if (mode == "descend")
@@ -6359,32 +6337,32 @@
 %! um = [3, 1; 2, 4];
 %! sv = [1, 2, 3, 4];
 %! uv = [2, 1, 4, 3];
-%!assert(issorted (sm, "rows"));
-%!assert(!issorted (um, "rows"));
-%!assert(issorted (sv));
-%!assert(!issorted (uv));
-%!assert(issorted (sv'));
-%!assert(!issorted (uv'));
-%!assert(issorted (sm, "rows", "ascending"));
-%!assert(!issorted (um, "rows", "ascending"));
-%!assert(issorted (sv, "ascending"));
-%!assert(!issorted (uv, "ascending"));
-%!assert(issorted (sv', "ascending"));
-%!assert(!issorted (uv', "ascending"));
-%!assert(!issorted (sm, "rows", "descending"));
-%!assert(issorted (flipud (sm), "rows", "descending"));
-%!assert(!issorted (sv, "descending"));
-%!assert(issorted (fliplr (sv), "descending"));
-%!assert(!issorted (sv', "descending"));
-%!assert(issorted (fliplr (sv)', "descending"));
-%!assert(!issorted (um, "rows", "either"));
-%!assert(!issorted (uv, "either"));
-%!assert(issorted (sm, "rows", "either"));
-%!assert(issorted (flipud (sm), "rows", "either"));
-%!assert(issorted (sv, "either"));
-%!assert(issorted (fliplr (sv), "either"));
-%!assert(issorted (sv', "either"));
-%!assert(issorted (fliplr (sv)', "either"));
+%!assert (issorted (sm, "rows"))
+%!assert (!issorted (um, "rows"))
+%!assert (issorted (sv))
+%!assert (!issorted (uv))
+%!assert (issorted (sv'))
+%!assert (!issorted (uv'))
+%!assert (issorted (sm, "rows", "ascending"))
+%!assert (!issorted (um, "rows", "ascending"))
+%!assert (issorted (sv, "ascending"))
+%!assert (!issorted (uv, "ascending"))
+%!assert (issorted (sv', "ascending"))
+%!assert (!issorted (uv', "ascending"))
+%!assert (!issorted (sm, "rows", "descending"))
+%!assert (issorted (flipud (sm), "rows", "descending"))
+%!assert (!issorted (sv, "descending"))
+%!assert (issorted (fliplr (sv), "descending"))
+%!assert (!issorted (sv', "descending"))
+%!assert (issorted (fliplr (sv)', "descending"))
+%!assert (!issorted (um, "rows", "either"))
+%!assert (!issorted (uv, "either"))
+%!assert (issorted (sm, "rows", "either"))
+%!assert (issorted (flipud (sm), "rows", "either"))
+%!assert (issorted (sv, "either"))
+%!assert (issorted (fliplr (sv), "either"))
+%!assert (issorted (sv', "either"))
+%!assert (issorted (fliplr (sv)', "either"))
 */
 
 DEFUN (nth_element, args, ,
@@ -6483,7 +6461,7 @@
   else if (idx.extent (n) > n)
     error ("accumarray: index out of range");
 
-  NDT retval (dim_vector (n, 1), T());
+  NDT retval (dim_vector (n, 1), T ());
 
   if (vals.numel () == 1)
     retval.idx_add (idx, vals (0));
@@ -6676,7 +6654,7 @@
 
   rdv(dim) = n;
 
-  NDT retval (rdv, T());
+  NDT retval (rdv, T ());
 
   if (idx.length () != vals_dim(dim))
     error ("accumdim: dimension mismatch");
@@ -7090,21 +7068,16 @@
 }
 
 /*
-
 %!assert (diff ([1, 2, 3, 4]), [1, 1, 1])
 %!assert (diff ([1, 3, 7, 19], 2), [2, 8])
 %!assert (diff ([1, 2; 5, 4; 8, 7; 9, 6; 3, 1]), [4, 2; 3, 3; 1, -1; -6, -5])
 %!assert (diff ([1, 2; 5, 4; 8, 7; 9, 6; 3, 1], 3), [-1, -5; -5, 0])
-%!assert (isempty (diff (1)));
-
-%!error diff ([1, 2; 3, 4], -1);
-
-%!error diff ("foo");
-
-%!error diff ();
-
-%!error diff (1, 2, 3, 4);
-
+%!assert (isempty (diff (1)))
+
+%!error diff ()
+%!error diff (1, 2, 3, 4)
+%!error diff ("foo")
+%!error diff ([1, 2; 3, 4], -1)
 */
 
 template <class T>
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -209,7 +209,7 @@
       // Problem because parse_dbfunction_params() can only pass out a
       // single function
     }
-  else if (args(0).is_string())
+  else if (args(0).is_string ())
     {
       symbol_name = args(0).string_value ();
       if (error_state)
@@ -223,7 +223,7 @@
     {
       if (args(i).is_string ())
         {
-          int line = atoi (args(i).string_value().c_str ());
+          int line = atoi (args(i).string_value ().c_str ());
           if (error_state)
             break;
           lines[list_idx++] = line;
@@ -655,12 +655,16 @@
       for (bp_table::fname_line_map_iterator it = bp_list.begin ();
            it != bp_list.end (); it++)
         {
-          octave_stdout << "breakpoint in " << it->first << " at line(s) ";
-
           bp_table::intmap m = it->second;
 
           size_t nel = m.size ();
 
+          octave_stdout << "breakpoint in " << it->first;
+          if (nel > 1)
+            octave_stdout << " at lines ";
+          else
+            octave_stdout << " at line ";
+
           for (size_t j = 0; j < nel; j++)
             octave_stdout << m[j] << ((j < nel - 1) ? ", " : ".");
 
@@ -792,11 +796,15 @@
   "-*- texinfo -*-\n\
 @deftypefn  {Loadable Function} {} dbtype ()\n\
 @deftypefnx {Loadable Function} {} dbtype (\"startl:endl\")\n\
+@deftypefnx {Loadable Function} {} dbtype (\"startl:end\")\n\
 @deftypefnx {Loadable Function} {} dbtype (\"@var{func}\")\n\
+@deftypefnx {Loadable Function} {} dbtype (\"@var{func}\", \"startl\")\n\
 @deftypefnx {Loadable Function} {} dbtype (\"@var{func}\", \"startl:endl\")\n\
+@deftypefnx {Loadable Function} {} dbtype (\"@var{func}\", \"startl:end\")\n\
 When in debugging mode and called with no arguments, list the script file\n\
 being debugged with line numbers.  An optional range specification,\n\
 specified as a string, can be used to list only a portion of the file.\n\
+The special keyword \"end\" is a valid line number specification.\n\
 \n\
 When called with the name of a function, list that script file\n\
 with line numbers.\n\
@@ -823,40 +831,46 @@
           break;
 
         case 1: // (dbtype func) || (dbtype start:end)
-          dbg_fcn = get_user_code (argv[1]);
+          {
+            std::string arg = argv[1];
+
+            size_t ind = arg.find (':');
 
-          if (dbg_fcn)
-            do_dbtype (octave_stdout, dbg_fcn->name (), 0, INT_MAX);
-          else
-            {
-              dbg_fcn = get_user_code ();
+            if (ind != std::string::npos)  // (dbtype start:end)
+              {  
+                dbg_fcn = get_user_code ();
 
-              if (dbg_fcn)
-                {
-                  std::string arg = argv[1];
-
-                  size_t ind = arg.find (':');
+                if (dbg_fcn)
+                  {
+                    std::string start_str = arg.substr (0, ind);
+                    std::string end_str = arg.substr (ind + 1);
 
-                  if (ind != std::string::npos)
-                    {
-                      std::string start_str = arg.substr (0, ind);
-                      std::string end_str = arg.substr (ind + 1);
+                    int start, end;
+                    start = atoi (start_str.c_str ());
+                    if (end_str == "end")
+                      end = INT_MAX;
+                    else
+                      end = atoi (end_str.c_str ());
 
-                      int start = atoi (start_str.c_str ());
-                      int end = atoi (end_str.c_str ());
+                    if (std::min (start, end) <= 0)
+                      error ("dbtype: start and end lines must be >= 1\n");
 
-                      if (std::min (start, end) <= 0)
-                        error ("dbtype: start and end lines must be >= 1\n");
+                    if (start <= end)
+                      do_dbtype (octave_stdout, dbg_fcn->name (), start, end);
+                    else
+                      error ("dbtype: start line must be less than end line\n");
+                  }
+              }
+            else  // (dbtype func)
+              {
+                dbg_fcn = get_user_code (arg);
 
-                      if (start <= end)
-                        do_dbtype (octave_stdout, dbg_fcn->name (), start, end);
-                      else
-                        error ("dbtype: start line must be less than end line\n");
-                    }
-                  else
-                    error ("dbtype: line specification must be `start:end'");
-                }
-            }
+                if (dbg_fcn)
+                  do_dbtype (octave_stdout, dbg_fcn->name (), 0, INT_MAX);
+                else
+                  error ("dbtype: function <%s> not found\n", arg.c_str ());
+              }
+          }
           break;
 
         case 2: // (dbtype func start:end) , (dbtype func start)
@@ -865,8 +879,7 @@
           if (dbg_fcn)
             {
               std::string arg = argv[2];
-              int start = 0;
-              int end = 0;
+              int start, end;
               size_t ind = arg.find (':');
 
               if (ind != std::string::npos)
@@ -875,8 +888,10 @@
                   std::string end_str = arg.substr (ind + 1);
 
                   start = atoi (start_str.c_str ());
-                  end = atoi (end_str.c_str ());
-
+                  if (end_str == "end")
+                    end = INT_MAX;
+                  else
+                    end = atoi (end_str.c_str ());
                 }
               else
                 {
@@ -892,6 +907,9 @@
               else
                 error ("dbtype: start line must be less than end line\n");
             }
+          else
+            error ("dbtype: function <%s> not found\n", argv[1].c_str ());
+
           break;
 
         default:
--- a/src/defaults.cc
+++ b/src/defaults.cc
@@ -294,6 +294,16 @@
 }
 
 static void
+set_default_texi_macros_file (void)
+{
+  std::string def_file = subst_octave_home (OCTAVE_TEXI_MACROS_FILE);
+
+  std::string env_file = octave_env::getenv ("OCTAVE_TEXI_MACROS_FILE");
+
+  Vtexi_macros_file = env_file.empty () ? def_file : env_file;
+}
+
+static void
 set_default_info_file (void)
 {
   std::string std_info_file = subst_octave_home (OCTAVE_INFOFILE);
@@ -393,6 +403,8 @@
 
   set_default_doc_cache_file ();
 
+  set_default_texi_macros_file ();
+
   set_default_info_file ();
 
   set_default_info_prog ();
@@ -425,7 +437,6 @@
 }
 
 /*
-%!error (EDITOR (1, 2));
 %!test
 %! orig_val = EDITOR ();
 %! old_val = EDITOR ("X");
@@ -433,6 +444,8 @@
 %! assert (EDITOR (), "X");
 %! EDITOR (orig_val);
 %! assert (EDITOR (), orig_val);
+
+%!error (EDITOR (1, 2))
 */
 
 DEFUN (EXEC_PATH, args, nargout,
@@ -460,7 +473,6 @@
 }
 
 /*
-%!error (EXEC_PATH (1, 2));
 %!test
 %! orig_val = EXEC_PATH ();
 %! old_val = EXEC_PATH ("X");
@@ -468,6 +480,8 @@
 %! assert (EXEC_PATH (), "X");
 %! EXEC_PATH (orig_val);
 %! assert (EXEC_PATH (), orig_val);
+
+%!error (EXEC_PATH (1, 2))
 */
 
 DEFUN (IMAGE_PATH, args, nargout,
@@ -487,7 +501,6 @@
 }
 
 /*
-%!error (IMAGE_PATH (1, 2));
 %!test
 %! orig_val = IMAGE_PATH ();
 %! old_val = IMAGE_PATH ("X");
@@ -495,6 +508,8 @@
 %! assert (IMAGE_PATH (), "X");
 %! IMAGE_PATH (orig_val);
 %! assert (IMAGE_PATH (), orig_val);
+
+%!error (IMAGE_PATH (1, 2))
 */
 
 DEFUN (OCTAVE_HOME, args, ,
@@ -514,8 +529,8 @@
 }
 
 /*
-%!error OCTAVE_HOME (1);
-%!assert (ischar (OCTAVE_HOME ()));
+%!assert (ischar (OCTAVE_HOME ()))
+%!error OCTAVE_HOME (1)
 */
 
 DEFUNX ("OCTAVE_VERSION", FOCTAVE_VERSION, args, ,
@@ -537,6 +552,6 @@
 }
 
 /*
-%!error OCTAVE_VERSION (1);
-%!assert (ischar (OCTAVE_VERSION ()));
+%!assert (ischar (OCTAVE_VERSION ()))
+%!error OCTAVE_VERSION (1)
 */
rename from src/defaults.h.in
rename to src/defaults.in.h
--- a/src/defaults.h.in
+++ b/src/defaults.in.h
@@ -56,6 +56,10 @@
 #define OCTAVE_DOC_CACHE_FILE %OCTAVE_DOC_CACHE_FILE%
 #endif
 
+#ifndef OCTAVE_TEXI_MACROS_FILE
+#define OCTAVE_TEXI_MACROS_FILE %OCTAVE_TEXI_MACROS_FILE%
+#endif
+
 #ifndef OCTAVE_EXEC_PREFIX
 #define OCTAVE_EXEC_PREFIX %OCTAVE_EXEC_PREFIX%
 #endif
--- a/src/defun.cc
+++ b/src/defun.cc
@@ -194,7 +194,7 @@
     for (int i = 0; i < nout; i++)
       isargout[i] = true;
 
-  for (int i = std::max(nargout, 1); i < nout; i++)
+  for (int i = std::max (nargout, 1); i < nout; i++)
     isargout[i] = false;
 }
 
--- a/src/dirfns.cc
+++ b/src/dirfns.cc
@@ -554,6 +554,7 @@
 them, or an empty cell array if no patterns match.  The pattern strings are\n\
 interpreted as filename globbing patterns (as they are used by Unix shells).\n\
 Within a pattern\n\
+\n\
 @table @code\n\
 @itemx *\n\
 matches any string, including the null string,\n\
@@ -570,25 +571,25 @@
 \n\
 @example\n\
 ls\n\
-     @result{}\n\
-        file1  file2  file3  myfile1 myfile1b\n\
+   @result{}\n\
+      file1  file2  file3  myfile1 myfile1b\n\
 glob (\"*file1\")\n\
-     @result{}\n\
-        @{\n\
-          [1,1] = file1\n\
-          [2,1] = myfile1\n\
-        @}\n\
+   @result{}\n\
+      @{\n\
+        [1,1] = file1\n\
+        [2,1] = myfile1\n\
+      @}\n\
 glob (\"myfile?\")\n\
-     @result{}\n\
-        @{\n\
-          [1,1] = myfile1\n\
-        @}\n\
+   @result{}\n\
+      @{\n\
+        [1,1] = myfile1\n\
+      @}\n\
 glob (\"file[12]\")\n\
-     @result{}\n\
-        @{\n\
-          [1,1] = file1\n\
-          [2,1] = file2\n\
-        @}\n\
+   @result{}\n\
+      @{\n\
+        [1,1] = file1\n\
+        [2,1] = file2\n\
+      @}\n\
 @end example\n\
 @seealso{ls, dir, readdir}\n\
 @end deftypefn")
@@ -616,35 +617,34 @@
 
 /*
 %!test
-%!  tmpdir = tmpnam;
-%!  filename = {"file1", "file2", "file3", "myfile1", "myfile1b"};
-%!  if (mkdir (tmpdir))
-%!    cwd = pwd;
-%!    cd (tmpdir);
-%!    if strcmp (canonicalize_file_name (pwd), ...
-%!               canonicalize_file_name (tmpdir))
-%!      a = 0;
-%!      for n = 1:5
-%!        save (filename{n}, "a");
-%!      endfor
-%!    else
-%!      rmdir (tmpdir);
-%!      error ("Couldn't change to temporary dir");
-%!    endif
-%!  else
-%!    error ("Couldn't create temporary directory");
-%!  endif
-%!  result1 = glob ("*file1");
-%!  result2 = glob ("myfile?");
-%!  result3 = glob ("file[12]");
-%!  for n = 1:5
-%!    delete (filename{n});
-%!  endfor
-%!  cd (cwd);
-%!  rmdir (tmpdir);
-%!  assert (result1, {"file1"; "myfile1"});
-%!  assert (result2, {"myfile1"});
-%!  assert (result3, {"file1"; "file2"});
+%! tmpdir = tmpnam;
+%! filename = {"file1", "file2", "file3", "myfile1", "myfile1b"};
+%! if (mkdir (tmpdir))
+%!   cwd = pwd;
+%!   cd (tmpdir);
+%!   if strcmp (canonicalize_file_name (pwd), canonicalize_file_name (tmpdir))
+%!     a = 0;
+%!     for n = 1:5
+%!       save (filename{n}, "a");
+%!     endfor
+%!   else
+%!     rmdir (tmpdir);
+%!     error ("Couldn't change to temporary dir");
+%!   endif
+%! else
+%!   error ("Couldn't create temporary directory");
+%! endif
+%! result1 = glob ("*file1");
+%! result2 = glob ("myfile?");
+%! result3 = glob ("file[12]");
+%! for n = 1:5
+%!   delete (filename{n});
+%! endfor
+%! cd (cwd);
+%! rmdir (tmpdir);
+%! assert (result1, {"file1"; "myfile1"});
+%! assert (result2, {"myfile1"});
+%! assert (result3, {"file1"; "file2"});
 */
 
 DEFUNX ("fnmatch", Ffnmatch, args, ,
@@ -687,10 +687,10 @@
 DEFUN (filesep, args, ,
   "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {} filesep ()\n\
-@deftypefnx {Built-in Function} {} filesep ('all')\n\
+@deftypefnx {Built-in Function} {} filesep (\"all\")\n\
 Return the system-dependent character used to separate directory names.\n\
 \n\
-If 'all' is given, the function returns all valid file separators in\n\
+If \"all\" is given, the function returns all valid file separators in\n\
 the form of a string.  The list of file separators is system-dependent.\n\
 It is @samp{/} (forward slash) under UNIX or @w{Mac OS X}, @samp{/} and\n\
 @samp{\\} (forward and backward slashes) under Windows.\n\
--- a/src/display.cc
+++ b/src/display.cc
@@ -41,6 +41,23 @@
 
 display_info *display_info::instance = 0;
 
+#if defined (HAVE_FRAMEWORK_CARBON) && ! defined (HAVE_CARBON_CGDISPLAYBITSPERPIXEL)
+// FIXME - This will only work for MacOS > 10.5. For earlier versions
+// this code is not needed (use CGDisplayBitsPerPixel instead).
+size_t DisplayBitsPerPixel (CGDirectDisplayID display)
+{
+  CGDisplayModeRef mode = CGDisplayCopyDisplayMode (display);
+  CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding (mode);
+
+  if (CFStringCompare (pixelEncoding, CFSTR (IO32BitDirectPixels), 0) == 0)
+    return 32;
+  else if (CFStringCompare (pixelEncoding, CFSTR (IO16BitDirectPixels), 0) == 0)
+    return 16;
+  else 
+    return 8;
+}
+#endif
+
 void
 display_info::init (bool query)
 {
@@ -72,16 +89,21 @@
 
       if (display)
         {
+#  if defined (HAVE_CARBON_CGDISPLAYBITSPERPIXEL)
+          // For MacOS < 10.7 use the line below
           dp = CGDisplayBitsPerPixel (display);
+#  else
+          // For MacOS > 10.5 use the line below
+          dp = DisplayBitsPerPixel (display);
+#  endif
 
           ht = CGDisplayPixelsHigh (display);
           wd = CGDisplayPixelsWide (display);
 
           CGSize sz_mm = CGDisplayScreenSize (display);
-
-          // On modern Mac systems (>= 10.5) CGSize is a struct keeping 2
-          // CGFloat values, but the CGFloat typedef is not present on
-          // older systems, so use double instead.
+          // For MacOS >= 10.6, CGSize is a struct keeping 2 CGFloat values,
+          // but the CGFloat typedef is not present on older systems,
+          // so use double instead.
           double ht_mm = sz_mm.height;
           double wd_mm = sz_mm.width;
 
--- a/src/dynamic-ld.cc
+++ b/src/dynamic-ld.cc
@@ -342,7 +342,7 @@
     {
       warning_with_id ("Octave:reload-forces-clear",
                        "reloading %s clears the following functions:",
-                       oct_file.file_name().c_str ());
+                       oct_file.file_name ().c_str ());
 
       octave_shlib_list::remove (oct_file, do_clear_function);
     }
--- a/src/error.cc
+++ b/src/error.cc
@@ -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);
@@ -838,7 +838,7 @@
 @end deftypefn")
 {
   octave_value retval;
-  int nargin = args.length();
+  int nargin = args.length ();
 
   if (nargin != 1)
     print_usage ();
@@ -850,9 +850,9 @@
         {
           if (err.contains ("message") && err.contains ("identifier"))
             {
-              std::string msg = err.contents("message").string_value ();
-              std::string id = err.contents("identifier").string_value ();
-              int len = msg.length();
+              std::string msg = err.contents ("message").string_value ();
+              std::string id = err.contents ("identifier").string_value ();
+              int len = msg.length ();
 
               std::string file;
               std::string nm;
@@ -863,21 +863,21 @@
 
               if (err.contains ("stack"))
                 {
-                  err_stack = err.contents("stack").map_value ();
+                  err_stack = err.contents ("stack").map_value ();
 
                   if (err_stack.numel () > 0)
                     {
                       if (err_stack.contains ("file"))
-                        file = err_stack.contents("file")(0).string_value ();
+                        file = err_stack.contents ("file")(0).string_value ();
 
                       if (err_stack.contains ("name"))
-                        nm = err_stack.contents("name")(0).string_value ();
+                        nm = err_stack.contents ("name")(0).string_value ();
 
                       if (err_stack.contains ("line"))
-                        l = err_stack.contents("line")(0).nint_value ();
+                        l = err_stack.contents ("line")(0).nint_value ();
 
                       if (err_stack.contains ("column"))
-                        c = err_stack.contents("column")(0).nint_value ();
+                        c = err_stack.contents ("column")(0).nint_value ();
                     }
                 }
 
@@ -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;
@@ -1487,7 +1515,7 @@
   "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {@var{lasterr} =} lasterror ()\n\
 @deftypefnx {Built-in Function} {} lasterror (@var{err})\n\
-@deftypefnx {Built-in Function} {} lasterror ('reset')\n\
+@deftypefnx {Built-in Function} {} lasterror (\"reset\")\n\
 Query or set the last error message structure.  When called without\n\
 arguments, return a structure containing the last error message and other\n\
 information related to this error.  The elements of the structure are:\n\
@@ -1523,13 +1551,13 @@
 as input.  Any fields of @var{err} that match those above are set while any\n\
 unspecified fields are initialized with default values.\n\
 \n\
-If @code{lasterror} is called with the argument 'reset', all fields are\n\
+If @code{lasterror} is called with the argument \"reset\", all fields are\n\
 set to their default values.\n\
 @seealso{lasterr}\n\
 @end deftypefn")
 {
   octave_value retval;
-  int nargin = args.length();
+  int nargin = args.length ();
 
   unwind_protect frame;
 
@@ -1547,17 +1575,17 @@
 
       if (nargin == 1)
         {
-          if (args(0).is_string())
+          if (args(0).is_string ())
             {
               if (args(0).string_value () == "reset")
                 {
-                  Vlast_error_message = std::string();
-                  Vlast_error_id = std::string();
+                  Vlast_error_message = std::string ();
+                  Vlast_error_id = std::string ();
 
                   Vlast_error_stack = initialize_last_error_stack ();
                 }
               else
-                error("lasterror: unrecognized string argument");
+                error ("lasterror: unrecognized string argument");
             }
           else if (args(0).is_map ())
             {
@@ -1572,47 +1600,47 @@
               if (! error_state && new_err.contains ("message"))
                 {
                   const std::string tmp =
-                    new_err.getfield("message").string_value ();
+                    new_err.getfield ("message").string_value ();
                   new_error_message = tmp;
                 }
 
               if (! error_state && new_err.contains ("identifier"))
                 {
                   const std::string tmp =
-                    new_err.getfield("identifier").string_value ();
+                    new_err.getfield ("identifier").string_value ();
                   new_error_id = tmp;
                 }
 
               if (! error_state && new_err.contains ("stack"))
                 {
                   octave_scalar_map new_err_stack =
-                    new_err.getfield("stack").scalar_map_value ();
+                    new_err.getfield ("stack").scalar_map_value ();
 
                   if (! error_state && new_err_stack.contains ("file"))
                     {
                       const std::string tmp =
-                        new_err_stack.getfield("file").string_value ();
+                        new_err_stack.getfield ("file").string_value ();
                       new_error_file = tmp;
                     }
 
                   if (! error_state && new_err_stack.contains ("name"))
                     {
                       const std::string tmp =
-                        new_err_stack.getfield("name").string_value ();
+                        new_err_stack.getfield ("name").string_value ();
                       new_error_name = tmp;
                     }
 
                   if (! error_state && new_err_stack.contains ("line"))
                     {
                       const int tmp =
-                        new_err_stack.getfield("line").nint_value ();
+                        new_err_stack.getfield ("line").nint_value ();
                       new_error_line = tmp;
                     }
 
                   if (! error_state && new_err_stack.contains ("column"))
                     {
                       const int tmp =
-                        new_err_stack.getfield("column").nint_value ();
+                        new_err_stack.getfield ("column").nint_value ();
                       new_error_column = tmp;
                     }
                 }
@@ -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/file-io.cc
+++ b/src/file-io.cc
@@ -43,7 +43,9 @@
 #include <cstdio>
 
 #include <iostream>
+#include <locale>
 #include <stack>
+#include <stdexcept>
 #include <vector>
 
 #include <fcntl.h>
@@ -215,7 +217,7 @@
 Close the specified file.  If successful, @code{fclose} returns 0,\n\
 otherwise, it returns -1.  The second form of the @code{fclose} call closes\n\
 all open files except @code{stdout}, @code{stderr}, and @code{stdin}.\n\
-@seealso{fopen, fseek, ftell}\n\
+@seealso{fopen, freport}\n\
 @end deftypefn")
 {
   octave_value retval = -1;
@@ -234,6 +236,7 @@
   "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} fclear (@var{fid})\n\
 Clear the stream state for the specified file.\n\
+@seealso{fopen}\n\
 @end deftypefn")
 {
   octave_value retval;
@@ -300,7 +303,8 @@
 
 DEFUN (fgetl, args, ,
   "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {} fgetl (@var{fid}, @var{len})\n\
+@deftypefn  {Built-in Function} {@var{str} =} fgetl (@var{fid})\n\
+@deftypefnx {Built-in Function} {@var{str} =} fgetl (@var{fid}, @var{len})\n\
 Read characters from a file, stopping after a newline, or EOF,\n\
 or @var{len} characters have been read.  The characters read, excluding\n\
 the possible trailing newline, are returned as a string.\n\
@@ -309,7 +313,9 @@
 character.\n\
 \n\
 If there are no more characters to read, @code{fgetl} returns @minus{}1.\n\
-@seealso{fread, fscanf}\n\
+\n\
+To read a line and return the terminating newline see @code{fgets}.\n\
+@seealso{fgets, fscanf, fread, fopen}\n\
 @end deftypefn")
 {
   static std::string who = "fgetl";
@@ -348,8 +354,8 @@
 
 DEFUN (fgets, args, ,
   "-*- texinfo -*-\n\
-@deftypefn  {Built-in Function} {} fgets (@var{fid})\n\
-@deftypefnx {Built-in Function} {} fgets (@var{fid}, @var{len})\n\
+@deftypefn  {Built-in Function} {@var{str} =} fgets (@var{fid})\n\
+@deftypefnx {Built-in Function} {@var{str} =} fgets (@var{fid}, @var{len})\n\
 Read characters from a file, stopping after a newline, or EOF,\n\
 or @var{len} characters have been read.  The characters read, including\n\
 the possible trailing newline, are returned as a string.\n\
@@ -358,7 +364,9 @@
 character.\n\
 \n\
 If there are no more characters to read, @code{fgets} returns @minus{}1.\n\
-@seealso{fputs, fopen, fread, fscanf}\n\
+\n\
+To read a line and discard the terminating newline see @code{fgetl}.\n\
+@seealso{fputs, fgetl, fscanf, fread, fopen}\n\
 @end deftypefn")
 {
   static std::string who = "fgets";
@@ -397,14 +405,19 @@
 
 DEFUN (fskipl, args, ,
   "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {} fskipl (@var{fid}, @var{count})\n\
-Skip a given number of lines, i.e., discards characters until an end-of-line\n\
-is met exactly @var{count}-times, or end-of-file occurs.\n\
+@deftypefn  {Built-in Function} {@var{nlines} =} fskipl (@var{fid})\n\
+@deftypefnx {Built-in Function} {@var{nlines} =} fskipl (@var{fid}, @var{count})\n\
+@deftypefnx {Built-in Function} {@var{nlines} =} fskipl (@var{fid}, Inf)\n\
+Read and skip @var{count} lines from the file descriptor @var{fid}.\n\
+@code{fskipl} discards characters until an end-of-line is encountered exactly\n\
+@var{count}-times, or until the end-of-file marker is found.\n\
+\n\
+If @var{count} is omitted, it defaults to 1.  @var{count} may also be\n\
+@code{Inf}, in which case lines are skipped until the end of the file.\n\
+This form is suitable for counting the number of lines in a file.\n\
+\n\
 Returns the number of lines skipped (end-of-line sequences encountered).\n\
-If @var{count} is omitted, it defaults to 1. @var{count} may also be\n\
-@code{Inf}, in which case lines are skipped to the end of file.\n\
-This form is suitable for counting lines in a file.\n\
-@seealso{fgetl, fgets}\n\
+@seealso{fgetl, fgets, fscanf, fopen}\n\
 @end deftypefn")
 {
   static std::string who = "fskipl";
@@ -656,7 +669,7 @@
 @noindent\n\
 however, conversions are currently only supported for @samp{native}\n\
 @samp{ieee-be}, and @samp{ieee-le} formats.\n\
-@seealso{fclose, fgets, fputs, fread, fseek, ferror, fprintf, fscanf, ftell, fwrite}\n\
+@seealso{fclose, fgets, fgetl, fscanf, fread, fputs, fdisp, fprintf, fwrite, fskipl, fseek, frewind, ftell, feof, ferror, fclear, fflush, freport}\n\
 @end deftypefn")
 {
   octave_value_list retval;
@@ -741,6 +754,7 @@
      @print{}       3     r  myfile\n\
 @end group\n\
 @end example\n\
+@seealso{fopen, fclose}\n\
 @end deftypefn")
 {
   octave_value_list retval;
@@ -761,6 +775,7 @@
 Move the file pointer to the beginning of the file @var{fid}, returning\n\
 0 for success, and -1 if an error was encountered.  It is equivalent to\n\
 @code{fseek (@var{fid}, 0, SEEK_SET)}.\n\
+@seealso{fseek, ftell, fopen}\n\
 @end deftypefn")
 {
   octave_value retval;
@@ -787,18 +802,19 @@
 
 DEFUN (fseek, args, ,
   "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {} fseek (@var{fid}, @var{offset}, @var{origin})\n\
+@deftypefn  {Built-in Function} {} fseek (@var{fid}, @var{offset})\n\
+@deftypefnx {Built-in Function} {} fseek (@var{fid}, @var{offset}, @var{origin})\n\
+@deftypefnx {Built-in Function} {@var{status} =} fseek (@dots{})\n\
 Set the file pointer to any location within the file @var{fid}.\n\
 \n\
 The pointer is positioned @var{offset} characters from the @var{origin},\n\
 which may be one of the predefined variables @w{@code{SEEK_CUR}} (current\n\
 position), @w{@code{SEEK_SET}} (beginning), or @w{@code{SEEK_END}} (end of\n\
 file) or strings \"cof\", \"bof\" or \"eof\".  If @var{origin} is omitted,\n\
-@w{@code{SEEK_SET}} is assumed.  The offset must be zero, or a value returned\n\
-by @code{ftell} (in which case @var{origin} must be @w{@code{SEEK_SET}}).\n\
+@w{@code{SEEK_SET}} is assumed.  @var{offset} may be positive, negative, or zero but not all combinations of @var{origin} and @var{offset} can be realized.\n\
 \n\
 Return 0 on success and -1 on error.\n\
-@seealso{ftell, fopen, fclose}\n\
+@seealso{fskipl, frewind, ftell, fopen}\n\
 @end deftypefn")
 {
   octave_value retval = -1;
@@ -828,7 +844,7 @@
 @deftypefn {Built-in Function} {} ftell (@var{fid})\n\
 Return the position of the file pointer as the number of characters\n\
 from the beginning of the file @var{fid}.\n\
-@seealso{fseek, fopen, fclose}\n\
+@seealso{fseek, feof, fopen}\n\
 @end deftypefn")
 {
   octave_value retval = -1;
@@ -854,7 +870,7 @@
 This function is just like @code{printf}, except that the output is\n\
 written to the stream @var{fid} instead of @code{stdout}.\n\
 If @var{fid} is omitted, the output is written to @code{stdout}.\n\
-@seealso{printf, sprintf, fread, fscanf, fopen, fclose}\n\
+@seealso{fputs, fdisp, fwrite, fscanf, printf, sprintf, fopen}\n\
 @end deftypefn")
 {
   static std::string who = "fprintf";
@@ -965,7 +981,7 @@
 Write a string to a file with no formatting.\n\
 \n\
 Return a non-negative number on success and EOF on error.\n\
-@seealso{scanf, sscanf, fread, fprintf, fgets, fscanf}\n\
+@seealso{fdisp, fprintf, fwrite, fopen}\n\
 @end deftypefn")
 {
   static std::string who = "fputs";
@@ -993,6 +1009,7 @@
 Write a string to the standard output with no formatting.\n\
 \n\
 Return a non-negative number on success and EOF on error.\n\
+@seealso{fputs, disp}\n\
 @end deftypefn")
 {
   static std::string who = "puts";
@@ -1070,7 +1087,7 @@
 DEFUN (fscanf, args, ,
   "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {[@var{val}, @var{count}, @var{errmsg}] =} fscanf (@var{fid}, @var{template}, @var{size})\n\
-@deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}, @var{errmsg}] =} fscanf (@var{fid}, @var{template}, \"C\")\n\
+@deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}] =} fscanf (@var{fid}, @var{template}, @var{locale})\n\
 In the first form, read from @var{fid} according to @var{template},\n\
 returning the result in the matrix @var{val}.\n\
 \n\
@@ -1109,13 +1126,16 @@
 with each conversion specifier in @var{template} corresponding to a\n\
 single scalar return value.  This form is more `C-like', and also\n\
 compatible with previous versions of Octave.  The number of successful\n\
-conversions is returned in @var{count}\n\
+conversions is returned in @var{count}.  It permits to explicitly\n\
+specify a locale to take into account language specific features, \n\
+such as decimal separator.  This operation restores the previous locales\n\
+setting at the end of the conversion.\n\
 @ifclear OCTAVE_MANUAL\n\
 \n\
 See the Formatted Input section of the GNU Octave manual for a\n\
 complete description of the syntax of the template string.\n\
 @end ifclear\n\
-@seealso{scanf, sscanf, fread, fprintf, fgets, fputs}\n\
+@seealso{fgets, fgetl, fread, scanf, sscanf, fopen}\n\
 @end deftypefn")
 {
   static std::string who = "fscanf";
@@ -1131,7 +1151,25 @@
       if (! error_state)
         {
           if (args(1).is_string ())
-            retval = os.oscanf (args(1), who);
+            {
+              std::locale oldloc;
+              try
+                {
+                  // Use args(2) val as the new locale setting. Keep
+                  // old val for restoring afterwards.
+                  oldloc = 
+                    os.imbue (std::locale (args(2).string_value ().c_str ()));
+
+                }
+              catch (std::runtime_error)
+                {
+                  // Display a warning if the specified locale is unknown
+                  warning ("fscanf: invalid locale. Try `locale -a' for a list of supported values.");
+                  oldloc = std::locale::classic ();
+                }
+              retval = os.oscanf (args(1), who);
+              os.imbue (oldloc);
+            }
           else
             ::error ("%s: format TEMPLATE must be a string", who.c_str ());
         }
@@ -1199,7 +1237,7 @@
 DEFUN (sscanf, args, ,
   "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {[@var{val}, @var{count}, @var{errmsg}, @var{pos}] =} sscanf (@var{string}, @var{template}, @var{size})\n\
-@deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}, @var{errmsg}] =} sscanf (@var{string}, @var{template}, \"C\")\n\
+@deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}] =} sscanf (@var{string}, @var{template}, @var{locale})\n\
 This is like @code{fscanf}, except that the characters are taken from the\n\
 string @var{string} instead of from a stream.  Reaching the end of the\n\
 string is treated as an end-of-file condition.  In addition to the values\n\
@@ -1224,8 +1262,22 @@
 
           if (os.is_valid ())
             {
-              if (args(1).is_string ())
-                retval = os.oscanf (args(1), who);
+              if (args(1).is_string ()) 
+                {
+                  // Use args(2) val as the new locale setting. As the os
+                  // object is short lived, we don't need to restore
+                  // locale afterwards.
+                  try
+                    {  
+                      os.imbue (std::locale (args(2).string_value ().c_str ()));
+                    }
+                  catch (std::runtime_error)
+                    {
+                      // Display a warning if the specified locale is unknown
+                      warning ("sscanf: invalid locale. Try `locale -a' for a list of supported values.");
+                    }
+                  retval = os.oscanf (args(1), who);
+                }              
               else
                 ::error ("%s: format TEMPLATE must be a string", who.c_str ());
             }
@@ -1293,10 +1345,16 @@
   return retval;
 }
 
+/*
+%!test
+%! assert (sscanf ("1,2", "%f", "C"), 1)
+%! assert (sscanf ("1,2", "%f", "fr_FR"), 1.2)
+*/
+
 DEFUN (scanf, args, nargout,
   "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {[@var{val}, @var{count}, @var{errmsg}] =} scanf (@var{template}, @var{size})\n\
-@deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}, @var{errmsg}]] =} scanf (@var{template}, \"C\")\n\
+@deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}] =} scanf (@var{template}, @var{locale})\n\
 This is equivalent to calling @code{fscanf} with @var{fid} = @code{stdin}.\n\
 \n\
 It is currently not useful to call @code{scanf} in interactive\n\
@@ -1546,7 +1604,7 @@
 \n\
 The data read from the file is returned in @var{val}, and the number of\n\
 values read is returned in @code{count}\n\
-@seealso{fwrite, fopen, fclose}\n\
+@seealso{fwrite, fgets, fgetl, fscanf, fopen}\n\
 @end deftypefn")
 {
   octave_value_list retval;
@@ -1663,7 +1721,7 @@
 \n\
 The behavior of @code{fwrite} is undefined if the values in @var{data}\n\
 are too large to fit in the specified precision.\n\
-@seealso{fread, fopen, fclose}\n\
+@seealso{fread, fputs, fprintf, fopen}\n\
 @end deftypefn")
 {
   octave_value retval = -1;
@@ -1716,7 +1774,7 @@
 file and 0 otherwise.  Note that it will only return 1 if the end of the\n\
 file has already been encountered, not if the next read operation will\n\
 result in an end-of-file condition.\n\
-@seealso{fread, fopen, fclose}\n\
+@seealso{fread, fopen}\n\
 @end deftypefn")
 {
   octave_value retval = -1;
@@ -1738,7 +1796,8 @@
 
 DEFUNX ("ferror", Fferror, args, ,
   "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} ferror (@var{fid}, \"clear\")\n\
+@deftypefn  {Built-in Function} {[@var{err}, @var{msg}] =} ferror (@var{fid})\n\
+@deftypefnx {Built-in Function} {[@var{err}, @var{msg}] =} ferror (@var{fid}, \"clear\")\n\
 Return 1 if an error condition has been encountered for the file ID\n\
 @var{fid} and 0 otherwise.  Note that it will only return 1 if an error\n\
 has already been encountered, not if the next operation will result in\n\
@@ -1746,6 +1805,7 @@
 \n\
 The second argument is optional.  If it is supplied, also clear the\n\
 error condition.\n\
+@seealso{fclear, fopen}\n\
 @end deftypefn")
 {
   octave_value_list retval;
@@ -1810,9 +1870,10 @@
 while (ischar (s = fgets (fid)))\n\
   fputs (stdout, s);\n\
 endwhile\n\
-     @print{} drwxr-xr-x  33 root  root  3072 Feb 15 13:28 etc\n\
-     @print{} drwxr-xr-x   3 root  root  1024 Feb 15 13:28 lib\n\
-     @print{} drwxrwxrwt  15 root  root  2048 Feb 17 14:53 tmp\n\
+\n\
+   @print{} drwxr-xr-x  33 root  root  3072 Feb 15 13:28 etc\n\
+   @print{} drwxr-xr-x   3 root  root  1024 Feb 15 13:28 lib\n\
+   @print{} drwxrwxrwt  15 root  root  2048 Feb 17 14:53 tmp\n\
 @end group\n\
 @end example\n\
 @end deftypefn")
@@ -2183,6 +2244,7 @@
 @deftypefnx {Built-in Function} {} SEEK_END ()\n\
 Return the numerical value to pass to @code{fseek} to perform\n\
 one of the following actions:\n\
+\n\
 @table @code\n\
 @item SEEK_SET\n\
 Position file relative to the beginning.\n\
new file mode 100755
--- /dev/null
+++ b/src/gendoc.pl
@@ -0,0 +1,73 @@
+#! /usr/bin/perl -w
+#
+# Copyright (C) 2012 Rik Wehbring
+#
+# 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/>.
+
+unless (@ARGV > 1) { die "Usage: $0 df-file1 ..." }
+
+print <<__END_OF_MSG__;
+### DO NOT EDIT!
+###
+### This file is generated automatically from Octave source files.
+### Edit source files directly and run make to update this file.
+
+__END_OF_MSG__
+
+DFFILE: foreach $df_fname (@ARGV)
+{
+  open (DF_FH, $df_fname) or die "Unable to open $df_fname";
+
+  $src_fname = "";
+  @func_list = ();
+  @docstr = ();
+
+  LINE: while (<DF_FH>)
+  {
+    if (/XDEFUN_FILE_NAME \("([^"]+)"/)
+    {
+      $src_fname = $1;
+      next LINE;
+    }
+    if (/XDEF/ and ! /XDEFALIAS/) 
+    {
+      ## Decode 4 or 5 part macro definition.
+      ($func, $str) = /\("?(\w+)"?,[^,]+,[^,]+,(?:[^,]+,)?\s*"(.*)"\)\s*$/ ;
+
+      unless ($func) { die "Unable to parse $df_fname at line $.\n" }
+
+      push (@func_list, $func);
+      ## Do escape sequence expansion
+      $str =~ s/(?<!\\)\\n/\n/g;
+      $str =~ s/\\([^\\])/$1/g;
+      $str =~ s/\\\\/\\/g;
+      push (@docstr, $str);
+    }
+  }
+  close (DF_FH);
+
+  ## Print results in DOCSTRING format
+  foreach $i (0 .. $#func_list)
+  {
+    $func = $func_list[$i];
+    print "$func\n";
+    print "\@c $func $src_fname\n";
+    print $docstr[$i],"\n";
+  }
+
+}
+
--- a/src/gl-render.cc
+++ b/src/gl-render.cc
@@ -236,7 +236,7 @@
 
 public:
 
-  opengl_tesselator (void) : glu_tess (0), fill() { init (); }
+  opengl_tesselator (void) : glu_tess (0), fill () { init (); }
 
   virtual ~opengl_tesselator (void)
     { if (glu_tess) gluDeleteTess (glu_tess); }
@@ -416,7 +416,7 @@
 protected:
   void begin (GLenum type)
     {
-      //printf("patch_tesselator::begin (%d)\n", type);
+      //printf ("patch_tesselator::begin (%d)\n", type);
       first = true;
 
       if (color_mode == 2 || light_mode == 2)
@@ -432,7 +432,7 @@
 
   void end (void)
     {
-      //printf("patch_tesselator::end\n");
+      //printf ("patch_tesselator::end\n");
       glEnd ();
       renderer->set_polygon_offset (false);
     }
@@ -441,7 +441,7 @@
     {
       vertex_data::vertex_data_rep *v
           = reinterpret_cast<vertex_data::vertex_data_rep *> (data);
-      //printf("patch_tesselator::vertex (%g, %g, %g)\n", v->coords(0), v->coords(1), v->coords(2));
+      //printf ("patch_tesselator::vertex (%g, %g, %g)\n", v->coords(0), v->coords(1), v->coords(2));
 
       // FIXME: why did I need to keep the first vertex of the face
       // in JHandles? I think it's related to the fact that the
@@ -481,7 +481,7 @@
   void combine (GLdouble xyz[3], void *data[4], GLfloat w[4],
                 void **out_data)
     {
-      //printf("patch_tesselator::combine\n");
+      //printf ("patch_tesselator::combine\n");
 
       vertex_data::vertex_data_rep *v[4];
       int vmax = 4;
@@ -508,14 +508,14 @@
           cc.resize (1, 3, 0.0);
           for (int ic = 0; ic < 3; ic++)
             for (int iv = 0; iv < vmax; iv++)
-              cc(ic) += (w[iv] * v[iv]->color(ic));
+              cc(ic) += (w[iv] * v[iv]->color (ic));
         }
 
       if (v[0]->normal.numel () > 0)
         {
           for (int in = 0; in < 3; in++)
             for (int iv = 0; iv < vmax; iv++)
-              nn(in) += (w[iv] * v[iv]->normal(in));
+              nn(in) += (w[iv] * v[iv]->normal (in));
         }
 
       for (int iv = 0; iv < vmax; iv++)
@@ -552,6 +552,9 @@
 
   const base_properties& props = go.get_properties ();
 
+  if (! toolkit)
+    toolkit = props.get_toolkit ();
+
   if (go.isa ("figure"))
     draw_figure (dynamic_cast<const figure::properties&> (props));
   else if (go.isa ("axes"))
@@ -587,8 +590,6 @@
 void
 opengl_renderer::draw_figure (const figure::properties& props)
 {
-  toolkit = props.get_toolkit ();
-
   // Initialize OpenGL context
 
   init_gl_context (props.is___enhanced__ (), props.get_color_rgb ());
@@ -606,8 +607,6 @@
   const figure::properties& figProps =
     dynamic_cast<const figure::properties&> (fig.get_properties ());
 
-  toolkit = figProps.get_toolkit ();
-
   // Initialize OpenGL context 
 
   init_gl_context (figProps.is___enhanced__ (),
@@ -642,7 +641,7 @@
 
   // Clear background
 
-  if (c.length() >= 3)
+  if (c.length () >= 3)
     {
       glClearColor (c(0), c(1), c(2), 1);
       glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -808,7 +807,7 @@
 
   glMatrixMode (GL_MODELVIEW);
   glLoadIdentity ();
-  glScaled(1, 1, -1);
+  glScaled (1, 1, -1);
   glMultMatrixd (x_mat1.data ());
   glMatrixMode (GL_PROJECTION);
   glLoadIdentity ();
@@ -1017,14 +1016,14 @@
         {
           render_tickmarks (xticks, x_min, x_max, ypTick, ypTick,
                             zpTick, zpTickN, 0., 0.,
-                            signum(zpTick-zpTickN)*fz*xticklen,
+                            signum (zpTick-zpTickN)*fz*xticklen,
                             0, mirror);
         }
       else
         {
           render_tickmarks (xticks, x_min, x_max, ypTick, ypTickN,
                             zpTick, zpTick, 0.,
-                            signum(ypTick-ypTickN)*fy*xticklen,
+                            signum (ypTick-ypTickN)*fy*xticklen,
                             0., 0, mirror);
         }
 
@@ -1036,11 +1035,11 @@
 
           if (tick_along_z)
             render_ticktexts (xticks, xticklabels, x_min, x_max, ypTick,
-                              zpTick+signum(zpTick-zpTickN)*fz*xtickoffset,
+                              zpTick+signum (zpTick-zpTickN)*fz*xtickoffset,
                               0, halign, valign, wmax, hmax);
           else
             render_ticktexts (xticks, xticklabels, x_min, x_max,
-                              ypTick+signum(ypTick-ypTickN)*fy*xtickoffset,
+                              ypTick+signum (ypTick-ypTickN)*fy*xtickoffset,
                               zpTick, 0, halign, valign, wmax, hmax);
         }
 
@@ -1056,12 +1055,12 @@
           if (tick_along_z)
             render_tickmarks (xmticks, x_min, x_max, ypTick, ypTick,
                               zpTick, zpTickN, 0., 0.,
-                              signum(zpTick-zpTickN)*fz*xticklen/2,
+                              signum (zpTick-zpTickN)*fz*xticklen/2,
                               0, mirror);
           else
             render_tickmarks (xmticks, x_min, x_max, ypTick, ypTickN,
                               zpTick, zpTick, 0.,
-                              signum(ypTick-ypTickN)*fy*xticklen/2,
+                              signum (ypTick-ypTickN)*fy*xticklen/2,
                               0., 0, mirror);
         }
 
@@ -1124,12 +1123,12 @@
       if (tick_along_z)
         render_tickmarks (yticks, y_min, y_max, xpTick, xpTick,
                           zpTick, zpTickN, 0., 0.,
-                          signum(zpTick-zpTickN)*fz*yticklen,
+                          signum (zpTick-zpTickN)*fz*yticklen,
                           1, mirror);
       else
         render_tickmarks (yticks, y_min, y_max, xpTick, xpTickN,
                           zpTick, zpTick,
-                          signum(xPlaneN-xPlane)*fx*yticklen,
+                          signum (xPlaneN-xPlane)*fx*yticklen,
                           0., 0., 1, mirror);
 
       // tick texts
@@ -1141,11 +1140,11 @@
 
           if (tick_along_z)
             render_ticktexts (yticks, yticklabels, y_min, y_max, xpTick,
-                              zpTick+signum(zpTick-zpTickN)*fz*ytickoffset,
+                              zpTick+signum (zpTick-zpTickN)*fz*ytickoffset,
                               1, halign, valign, wmax, hmax);
           else
             render_ticktexts (yticks, yticklabels, y_min, y_max,
-                              xpTick+signum(xpTick-xpTickN)*fx*ytickoffset,
+                              xpTick+signum (xpTick-xpTickN)*fx*ytickoffset,
                               zpTick, 1, halign, valign, wmax, hmax);
         }
 
@@ -1161,12 +1160,12 @@
           if (tick_along_z)
             render_tickmarks (ymticks, y_min, y_max, xpTick, xpTick,
                               zpTick, zpTickN, 0., 0.,
-                              signum(zpTick-zpTickN)*fz*yticklen/2,
+                              signum (zpTick-zpTickN)*fz*yticklen/2,
                               1, mirror);
           else
             render_tickmarks (ymticks, y_min, y_max, xpTick, xpTickN,
                               zpTick, zpTick,
-                              signum(xpTick-xpTickN)*fx*yticklen/2,
+                              signum (xpTick-xpTickN)*fx*yticklen/2,
                               0., 0., 1, mirror);
         }
 
@@ -1221,12 +1220,12 @@
           if (xisinf (fy))
             render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlane,
                               yPlane, yPlane,
-                              signum(xPlaneN-xPlane)*fx*zticklen,
+                              signum (xPlaneN-xPlane)*fx*zticklen,
                               0., 0., 2, mirror);
           else
             render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlaneN,
                               yPlane, yPlane, 0.,
-                              signum(yPlane-yPlaneN)*fy*zticklen,
+                              signum (yPlane-yPlaneN)*fy*zticklen,
                               0., 2, false);
         }
       else
@@ -1234,12 +1233,12 @@
           if (xisinf (fx))
             render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlane,
                               yPlaneN, yPlane, 0.,
-                              signum(yPlaneN-yPlane)*fy*zticklen,
+                              signum (yPlaneN-yPlane)*fy*zticklen,
                               0., 2, mirror);
           else
             render_tickmarks (zticks, z_min, z_max, xPlane, xPlane,
                               yPlaneN, yPlane,
-                              signum(xPlane-xPlaneN)*fx*zticklen,
+                              signum (xPlane-xPlaneN)*fx*zticklen,
                               0., 0., 2, false);
         }
 
@@ -1253,22 +1252,22 @@
             {
               if (xisinf (fy))
                 render_ticktexts (zticks, zticklabels, z_min, z_max,
-                                  xPlaneN+signum(xPlaneN-xPlane)*fx*ztickoffset,
+                                  xPlaneN+signum (xPlaneN-xPlane)*fx*ztickoffset,
                                   yPlane, 2, halign, valign, wmax, hmax);
               else
                 render_ticktexts (zticks, zticklabels, z_min, z_max, xPlaneN,
-                                  yPlane+signum(yPlane-yPlaneN)*fy*ztickoffset,
+                                  yPlane+signum (yPlane-yPlaneN)*fy*ztickoffset,
                                   2, halign, valign, wmax, hmax);
             }
           else
             {
               if (xisinf (fx))
                 render_ticktexts (zticks, zticklabels, z_min, z_max, xPlane,
-                                  yPlaneN+signum(yPlaneN-yPlane)*fy*ztickoffset,
+                                  yPlaneN+signum (yPlaneN-yPlane)*fy*ztickoffset,
                                   2, halign, valign, wmax, hmax);
               else
                 render_ticktexts (zticks, zticklabels, z_min, z_max,
-                                  xPlane+signum(xPlane-xPlaneN)*fx*ztickoffset,
+                                  xPlane+signum (xPlane-xPlaneN)*fx*ztickoffset,
                                   yPlaneN, 2, halign, valign, wmax, hmax);
             }
         }
@@ -1286,12 +1285,12 @@
               if (xisinf (fy))
                 render_tickmarks (zmticks, z_min, z_max, xPlaneN, xPlane,
                                   yPlane, yPlane,
-                                  signum(xPlaneN-xPlane)*fx*zticklen/2,
+                                  signum (xPlaneN-xPlane)*fx*zticklen/2,
                                   0., 0., 2, mirror);
               else
                 render_tickmarks (zmticks, z_min, z_max, xPlaneN, xPlaneN,
                                   yPlane, yPlane, 0.,
-                                  signum(yPlane-yPlaneN)*fy*zticklen/2,
+                                  signum (yPlane-yPlaneN)*fy*zticklen/2,
                                   0., 2, false);
             }
           else
@@ -1299,12 +1298,12 @@
               if (xisinf (fx))
                 render_tickmarks (zmticks, z_min, z_max, xPlane, xPlane,
                                   yPlaneN, yPlane, 0.,
-                                  signum(yPlaneN-yPlane)*fy*zticklen/2,
+                                  signum (yPlaneN-yPlane)*fy*zticklen/2,
                                   0., 2, mirror);
               else
                 render_tickmarks (zmticks, z_min, z_max, xPlane, xPlane,
                                   yPlaneN, yPlaneN,
-                                  signum(xPlane-xPlaneN)*fx*zticklen/2,
+                                  signum (xPlane-xPlaneN)*fx*zticklen/2,
                                   0., 0., 2, false);
             }
         }
@@ -2105,16 +2104,16 @@
   bool has_facecolor = false;
   bool has_facealpha = false;
 
-  int fc_mode = ((props.facecolor_is("none")
+  int fc_mode = ((props.facecolor_is ("none")
                   || props.facecolor_is_rgb ()) ? 0 :
-                 (props.facecolor_is("flat") ? 1 : 2));
+                 (props.facecolor_is ("flat") ? 1 : 2));
   int fl_mode = (props.facelighting_is ("none") ? 0 :
                  (props.facelighting_is ("flat") ? 1 : 2));
   int fa_mode = (props.facealpha_is_double () ? 0 :
                  (props.facealpha_is ("flat") ? 1 : 2));
-  int ec_mode = ((props.edgecolor_is("none")
+  int ec_mode = ((props.edgecolor_is ("none")
                   || props.edgecolor_is_rgb ()) ? 0 :
-                 (props.edgecolor_is("flat") ? 1 : 2));
+                 (props.edgecolor_is ("flat") ? 1 : 2));
   int el_mode = (props.edgelighting_is ("none") ? 0 :
                  (props.edgelighting_is ("flat") ? 1 : 2));
   int ea_mode = (props.edgealpha_is_double () ? 0 :
@@ -2470,7 +2469,7 @@
   glEnable (GL_BLEND);
   glEnable (GL_ALPHA_TEST);
   glRasterPos3d (pos(0), pos(1), pos.numel () > 2 ? pos(2) : 0.0);
-  glBitmap(0, 0, 0, 0, bbox(0), bbox(1), 0);
+  glBitmap (0, 0, 0, 0, bbox(0), bbox(1), 0);
   glDrawPixels (bbox(2), bbox(3),
                 GL_RGBA, GL_UNSIGNED_BYTE, props.get_pixels ().data ());
   glDisable (GL_ALPHA_TEST);
@@ -2554,7 +2553,7 @@
   else // clip to viewport
     {
       GLfloat vp[4];
-      glGetFloatv(GL_VIEWPORT, vp);
+      glGetFloatv (GL_VIEWPORT, vp);
       // FIXME -- actually add the code to do it!
 
     }
@@ -2863,7 +2862,7 @@
       glEnd ();
       break;
     case 'x':
-      glBegin(GL_LINES);
+      glBegin (GL_LINES);
       glVertex2f (-sz/2, -sz/2);
       glVertex2f (sz/2, sz/2);
       glVertex2f (-sz/2, sz/2);
@@ -2888,7 +2887,7 @@
 
         glBegin (GL_POLYGON);
         for (double ang = 0; ang < (2*M_PI); ang += ang_step)
-          glVertex2d (sz*cos(ang)/3, sz*sin(ang)/3);
+          glVertex2d (sz*cos (ang)/3, sz*sin (ang)/3);
         glEnd ();
       }
       break;
@@ -2898,7 +2897,7 @@
       glVertex2d (-sz/2, sz/2);
       glVertex2d (sz/2, sz/2);
       glVertex2d (sz/2, -sz/2);
-      glEnd();
+      glEnd ();
       break;
     case 'o':
       {
@@ -2906,7 +2905,7 @@
 
         glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
         for (double ang = 0; ang < (2*M_PI); ang += ang_step)
-          glVertex2d (sz*cos(ang)/2, sz*sin(ang)/2);
+          glVertex2d (sz*cos (ang)/2, sz*sin (ang)/2);
         glEnd ();
       }
       break;
@@ -2916,7 +2915,7 @@
       glVertex2d (sz/2, 0);
       glVertex2d (0, sz/2);
       glVertex2d (-sz/2, 0);
-      glEnd();
+      glEnd ();
       break;
     case 'v':
       glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
@@ -2950,14 +2949,14 @@
       {
         double ang;
         double r;
-        double dr = 1.0 - sin(M_PI/10)/sin(3*M_PI/10)*1.02;
+        double dr = 1.0 - sin (M_PI/10)/sin (3*M_PI/10)*1.02;
 
         glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
         for (int i = 0; i < 2*5; i++)
           {
             ang = (-0.5 + double(i+1)/5) * M_PI;
-            r = 1.0 - (dr * fmod(double(i+1), 2.0));
-            glVertex2d (sz*r*cos(ang)/2, sz*r*sin(ang)/2);
+            r = 1.0 - (dr * fmod (double(i+1), 2.0));
+            glVertex2d (sz*r*cos (ang)/2, sz*r*sin (ang)/2);
           }
         glEnd ();
       }
@@ -2966,14 +2965,14 @@
       {
         double ang;
         double r;
-        double dr = 1.0 - 0.5/sin(M_PI/3)*1.02;
+        double dr = 1.0 - 0.5/sin (M_PI/3)*1.02;
 
         glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
         for (int i = 0; i < 2*6; i++)
           {
             ang = (0.5 + double(i+1)/6.0) * M_PI;
-            r = 1.0 - (dr * fmod(double(i+1), 2.0));
-            glVertex2d (sz*r*cos(ang)/2, sz*r*sin(ang)/2);
+            r = 1.0 - (dr * fmod (double(i+1), 2.0));
+            glVertex2d (sz*r*cos (ang)/2, sz*r*sin (ang)/2);
           }
         glEnd ();
       }
--- a/src/gl-render.h
+++ b/src/gl-render.h
@@ -90,6 +90,7 @@
                              const graphics_object& go);
 
   virtual void init_gl_context (bool enhanced, const Matrix& backgroundColor);
+  virtual void setup_opengl_transformation (const axes::properties& props);
 
   virtual void set_color (const Matrix& c);
   virtual void set_polygon_offset (bool on, double offset = 0.0);
@@ -168,8 +169,6 @@
   unsigned int make_marker_list (const std::string& m, double size,
                                  bool filled) const;
 
-  void setup_opengl_transformation (const axes::properties& props);
-
   void draw_axes_planes (const axes::properties& props);
   void draw_axes_boxes (const axes::properties& props);
 
--- a/src/gl2ps-renderer.cc
+++ b/src/gl2ps-renderer.cc
@@ -43,14 +43,6 @@
     {
       in_draw = true;
 
-      FILE *fp = fdopen (fid, "wb");
-
-      if (! fp)
-        {
-          error ("gl2ps-renderer: fdopen failed");
-          return;
-        }
-
       GLint buffsize = 0, state = GL2PS_OVERFLOW;
       GLint viewport[4];
 
@@ -72,11 +64,15 @@
       GLint gl2ps_text = 0;
       if (term.find ("notxt") != std::string::npos) gl2ps_text = GL2PS_NO_TEXT;
 
+      // Default sort order optimizes for 3D plots
+      GLint gl2ps_sort = GL2PS_BSP_SORT;
+      if (term.find ("is2D") != std::string::npos) gl2ps_sort = GL2PS_NO_SORT;
+
       while (state == GL2PS_OVERFLOW)
         {
           buffsize += 1024*1024;
           gl2psBeginPage ("glps_renderer figure", "Octave", viewport,
-                          gl2ps_term, GL2PS_BSP_SORT,
+                          gl2ps_term, gl2ps_sort,
                           (GL2PS_SILENT | GL2PS_SIMPLE_LINE_OFFSET
                            | GL2PS_NO_BLENDING | GL2PS_OCCLUSION_CULL
                            | GL2PS_BEST_ROOT | gl2ps_text
@@ -88,8 +84,6 @@
           state = gl2psEndPage ();
         }
 
-      gnulib::fclose (fp);
-
       in_draw = 0;
     }
   else
@@ -223,7 +217,7 @@
 
   // FIXME: handle margin and surrounding box
 
-  glRasterPos3d (pos(0), pos(1), pos(2));
+  glRasterPos3d (pos(0), pos(1), pos.numel () > 2 ? pos(2) : 0.0);
 
   octave_value string_prop = props.get_string ();
 
--- a/src/gl2ps-renderer.h
+++ b/src/gl2ps-renderer.h
@@ -31,8 +31,8 @@
 glps_renderer : public opengl_renderer
 {
 public:
-  glps_renderer (const int _fid, const std::string& _term)
-    : opengl_renderer () , fid (_fid), term (_term),
+  glps_renderer (FILE *_fp, const std::string& _term)
+    : opengl_renderer () , fp (_fp), term (_term),
     fontsize (), fontname () { }
 
   ~glps_renderer (void) { }
@@ -52,13 +52,14 @@
   void draw_pixels (GLsizei w, GLsizei h, GLenum format,
                     GLenum type, const GLvoid *data);
 
-  void set_linestyle (const std::string& s, bool use_stipple)
+  void set_linestyle (const std::string& s, bool use_stipple = false)
   {
     opengl_renderer::set_linestyle (s, use_stipple);
-    if (use_stipple)
+
+    if (s == "-" && ! use_stipple)
+      gl2psDisable (GL2PS_LINE_STIPPLE);
+    else
       gl2psEnable (GL2PS_LINE_STIPPLE);
-    else
-      gl2psDisable (GL2PS_LINE_STIPPLE);
   }
 
   void set_polygon_offset (bool on, double offset = 0.0)
@@ -77,7 +78,7 @@
 
 private:
   int alignment_to_mode (int ha, int va) const;
-  int fid;
+  FILE *fp;
   caseless_str term;
   double fontsize;
   std::string fontname;
--- a/src/graphics.cc
+++ b/src/graphics.cc
@@ -1037,27 +1037,27 @@
 {
   double tmp_rgb[3] = {0, 0, 0};
   bool retval = true;
-  unsigned int len = str.length();
+  unsigned int len = str.length ();
 
   std::transform (str.begin (), str.end (), str.begin (), tolower);
 
-  if (str.compare(0, len, "blue", 0, len) == 0)
+  if (str.compare (0, len, "blue", 0, len) == 0)
     tmp_rgb[2] = 1;
-  else if (str.compare(0, len, "black", 0, len) == 0
-           || str.compare(0, len, "k", 0, len) == 0)
+  else if (str.compare (0, len, "black", 0, len) == 0
+           || str.compare (0, len, "k", 0, len) == 0)
     tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0;
-  else if (str.compare(0, len, "red", 0, len) == 0)
+  else if (str.compare (0, len, "red", 0, len) == 0)
     tmp_rgb[0] = 1;
-  else if (str.compare(0, len, "green", 0, len) == 0)
+  else if (str.compare (0, len, "green", 0, len) == 0)
     tmp_rgb[1] = 1;
-  else if (str.compare(0, len, "yellow", 0, len) == 0)
+  else if (str.compare (0, len, "yellow", 0, len) == 0)
     tmp_rgb[0] = tmp_rgb[1] = 1;
-  else if (str.compare(0, len, "magenta", 0, len) == 0)
+  else if (str.compare (0, len, "magenta", 0, len) == 0)
     tmp_rgb[0] = tmp_rgb[2] = 1;
-  else if (str.compare(0, len, "cyan", 0, len) == 0)
+  else if (str.compare (0, len, "cyan", 0, len) == 0)
     tmp_rgb[1] = tmp_rgb[2] = 1;
-  else if (str.compare(0, len, "white", 0, len) == 0
-           || str.compare(0, len, "w", 0, len) == 0)
+  else if (str.compare (0, len, "white", 0, len) == 0
+           || str.compare (0, len, "w", 0, len) == 0)
     tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1;
   else
     retval = false;
@@ -1123,7 +1123,7 @@
 
       if (m.numel () == 3)
         {
-          color_values col (m (0), m (1), m(2));
+          color_values col (m(0), m(1), m(2));
           if (! error_state)
             {
               if (current_type != color_t || col != color_val)
@@ -1271,7 +1271,7 @@
                 } \
             }
 
-          if (data.is_double_type() || data.is_bool_type ())
+          if (data.is_double_type () || data.is_bool_type ())
             CHECK_ARRAY_EQUAL (double, , NDArray)
           else if (data.is_single_type ())
             CHECK_ARRAY_EQUAL (float, float_, FloatNDArray)
@@ -1428,7 +1428,7 @@
     // complete validation will be done at execution-time
     return true;
   else if (v.is_cell () && v.length () > 0
-           && (v.rows() == 1 || v.columns () == 1)
+           && (v.rows () == 1 || v.columns () == 1)
            && v.cell_value ()(0).is_function_handle ())
     return true;
   else if (v.is_empty ())
@@ -1967,13 +1967,13 @@
 }
 
 /*
-%!# test set with name, value pairs
+## test set with name, value pairs
 %!test
-%!  set(gcf, "visible", "off");
-%!  h = plot (1:10, 10:-1:1);
-%!  set (h, "linewidth", 10, "marker", "x");
-%!  assert (get (h, "linewidth"), 10);
-%!  assert (get (h, "marker"), "x");
+%! set (gcf, "visible", "off");
+%! h = plot (1:10, 10:-1:1);
+%! set (h, "linewidth", 10, "marker", "x");
+%! assert (get (h, "linewidth"), 10);
+%! assert (get (h, "marker"), "x");
 */
 
 // Set properties given in two cell arrays containing names and values.
@@ -1983,7 +1983,7 @@
 {
   if (names.numel () != values.columns ())
     {
-      error("set: number of names must match number of value columns (%d != %d)",
+      error ("set: number of names must match number of value columns (%d != %d)",
             names.numel (), values.columns ());
     }
 
@@ -2002,34 +2002,34 @@
 }
 
 /*
-%!# test set with cell array arguments
+## test set with cell array arguments
 %!test
-%!  set (gcf, "visible", "off");
-%!  h = plot (1:10, 10:-1:1);
-%!  set (h, {"linewidth", "marker"}, {10, "x"});
-%!  assert (get(h, "linewidth"), 10);
-%!  assert (get(h, "marker"), "x");
-
-%!# test set with multiple handles and cell array arguments
+%! set (gcf, "visible", "off");
+%! h = plot (1:10, 10:-1:1);
+%! set (h, {"linewidth", "marker"}, {10, "x"});
+%! assert (get (h, "linewidth"), 10);
+%! assert (get (h, "marker"), "x");
+
+## test set with multiple handles and cell array arguments
 %!test
-%!  set (gcf, "visible", "off");
-%!  h = plot (1:10, 10:-1:1, 1:10, 1:10);
-%!  set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"});
-%!  assert (get (h, "linewidth"), {10; 5});
-%!  assert (get (h, "marker"), {"x"; "o"});
-%!  set (h, {"linewidth", "marker"}, {10, "x"});
-%!  assert (get (h, "linewidth"), {10; 10});
-%!  assert (get (h, "marker"), {"x"; "x"});
+%! set (gcf, "visible", "off");
+%! h = plot (1:10, 10:-1:1, 1:10, 1:10);
+%! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"});
+%! assert (get (h, "linewidth"), {10; 5});
+%! assert (get (h, "marker"), {"x"; "o"});
+%! set (h, {"linewidth", "marker"}, {10, "x"});
+%! assert (get (h, "linewidth"), {10; 10});
+%! assert (get (h, "marker"), {"x"; "x"});
 
 %!error <set: number of graphics handles must match number of value rows>
-%!  set (gcf, "visible", "off");
-%!  h = plot (1:10, 10:-1:1, 1:10, 1:10);
-%!  set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"; 7, "."});
+%! set (gcf, "visible", "off");
+%! h = plot (1:10, 10:-1:1, 1:10, 1:10);
+%! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"; 7, "."});
 
 %!error <set: number of names must match number of value columns>
-%!  set (gcf, "visible", "off");
-%!  h = plot (1:10, 10:-1:1, 1:10, 1:10);
-%!  set (h, {"linewidth"}, {10, "x"; 5, "o"});
+%! set (gcf, "visible", "off");
+%! h = plot (1:10, 10:-1:1, 1:10, 1:10);
+%! set (h, {"linewidth"}, {10, "x"; 5, "o"});
 */
 
 // Set properties given in a struct array
@@ -2051,16 +2051,16 @@
 }
 
 /*
-%!# test set with struct arguments
+## test set with struct arguments
 %!test
-%!  set (gcf, "visible", "off");
-%!  h = plot (1:10, 10:-1:1);
-%!  set (h, struct ("linewidth", 10, "marker", "x"));
-%!  assert (get (h, "linewidth"), 10);
-%!  assert (get (h, "marker"), "x");
-%!  h = plot (1:10, 10:-1:1, 1:10, 1:10);
-%!  set (h, struct ("linewidth", {5, 10}));
-%!  assert (get(h, "linewidth"), {10; 10});
+%! set (gcf, "visible", "off");
+%! h = plot (1:10, 10:-1:1);
+%! set (h, struct ("linewidth", 10, "marker", "x"));
+%! assert (get (h, "linewidth"), 10);
+%! assert (get (h, "marker"), "x");
+%! h = plot (1:10, 10:-1:1, 1:10, 1:10);
+%! set (h, struct ("linewidth", {5, 10}));
+%! assert (get (h, "linewidth"), {10; 10});
 */
 
 // Set a property to a value or to its (factory) default value.
@@ -2101,15 +2101,15 @@
 }
 
 /*
-%!# test setting of default values
+## test setting of default values
 %!test
-%!  set (gcf, "visible", "off");
-%!  h = plot (1:10, 10:-1:1);
-%!  set (0, "defaultlinelinewidth", 20);
-%!  set (h, "linewidth", "default");
-%!  assert (get (h, "linewidth"), 20);
-%!  set (h, "linewidth", "factory");
-%!  assert (get (h, "linewidth"), 0.5);
+%! set (gcf, "visible", "off");
+%! h = plot (1:10, 10:-1:1);
+%! set (0, "defaultlinelinewidth", 20);
+%! set (h, "linewidth", "default");
+%! assert (get (h, "linewidth"), 20);
+%! set (h, "linewidth", "factory");
+%! assert (get (h, "linewidth"), 0.5);
 */
 
 static double
@@ -3029,6 +3029,8 @@
   else if (xunits.compare ("normalized"))
     {
       ss = Matrix (1, 4, 1.0);
+      ss(0) = 0;
+      ss(1) = 0;
     }
   else if (xunits.compare ("points"))
     {
@@ -3041,6 +3043,33 @@
   set_screensize (ss);
 }
 
+Matrix
+root_figure::properties::get_boundingbox (bool, const Matrix&) const
+{
+  Matrix screen_size = screen_size_pixels ();
+  Matrix pos = Matrix (1, 4, 0);
+  pos(2) = screen_size(0);
+  pos(3) = screen_size(1);
+  return pos;
+}
+
+/*
+%!test
+%! set (0, "units", "pixels");
+%! sz = get (0, "screensize") - [1, 1, 0, 0];
+%! dpi = get (0, "screenpixelsperinch");
+%! set (0, "units", "inches");
+%! assert (get (0, "screensize"), sz / dpi, 0.5 / dpi);
+%! set (0, "units", "centimeters");
+%! assert (get (0, "screensize"), sz / dpi * 2.54, 0.5 / dpi * 2.54);
+%! set (0, "units", "points");
+%! assert (get (0, "screensize"), sz / dpi * 72, 0.5 / dpi * 72);
+%! set (0, "units", "normalized");
+%! assert (get (0, "screensize"), [0.0, 0.0, 1.0, 1.0]);
+%! set (0, "units", "pixels");
+%! assert (get (0, "screensize"), sz + [1, 1, 0, 0]);
+*/
+
 void
 root_figure::properties::remove_child (const graphics_handle& gh)
 {
@@ -3225,10 +3254,11 @@
   if (! error_state)
     {
       Matrix old_bb, new_bb;
-
-      old_bb = get_boundingbox ();
-      position.set (v, true, do_notify_toolkit);
-      new_bb = get_boundingbox ();
+      bool modified = false;
+
+      old_bb = get_boundingbox (true);
+      modified = position.set (v, false, do_notify_toolkit);
+      new_bb = get_boundingbox (true);
 
       if (old_bb != new_bb)
         {
@@ -3239,7 +3269,11 @@
             }
         }
 
-      mark_modified ();
+      if (modified)
+        {
+          position.run_listeners (POSTSET);
+          mark_modified ();
+        }
     }
 }
 
@@ -3465,11 +3499,12 @@
   Matrix pos = get_paperposition ().matrix_value ();
   Matrix sz = get_papersize ().matrix_value ();
 
-  pos (0) = pos (0) / sz(0);
-  pos (1) = pos (1) / sz(1);
-  pos (2) = pos (2) / sz(0);
-  pos (3) = pos (3) / sz(1);
-
+  pos(0) /= sz(0);
+  pos(1) /= sz(1);
+  pos(2) /= sz(0);
+  pos(3) /= sz(1);
+
+  std::string porient = get_paperorientation ();
   caseless_str punits = get_paperunits ();
   caseless_str typ = get_papertype ();
 
@@ -3477,33 +3512,37 @@
     {
       if (old_paperunits.compare ("centimeters"))
         {
-          sz (0) = sz (0) / 2.54;
-          sz (1) = sz (1) / 2.54;
+          sz(0) /= 2.54;
+          sz(1) /= 2.54;
         }
       else if (old_paperunits.compare ("points"))
         {
-          sz (0) = sz (0) / 72.0;
-          sz (1) = sz (1) / 72.0;
+          sz(0) /= 72.0;
+          sz(1) /= 72.0;
         }
 
       if (punits.compare ("centimeters"))
         {
-          sz(0) = sz(0) * 2.54;
-          sz(1) = sz(1) * 2.54;
-        }
-      else if (old_paperunits.compare ("points"))
-        {
-          sz (0) = sz (0) * 72.0;
-          sz (1) = sz (1) * 72.0;
+          sz(0) *= 2.54;
+          sz(1) *= 2.54;
+        }
+      else if (punits.compare ("points"))
+        {
+          sz(0) *= 72.0;
+          sz(1) *= 72.0;
         }
     }
   else
-    sz = papersize_from_type (punits, typ);
-
-  pos (0) = pos (0) * sz(0);
-  pos (1) = pos (1) * sz(1);
-  pos (2) = pos (2) * sz(0);
-  pos (3) = pos (3) * sz(1);
+    {
+      sz = papersize_from_type (punits, typ);
+      if (porient == "landscape")
+        std::swap (sz(0), sz(1));
+    }
+
+  pos(0) *= sz(0);
+  pos(1) *= sz(1);
+  pos(2) *= sz(0);
+  pos(3) *= sz(1);
 
   papersize.set (octave_value (sz));
   paperposition.set (octave_value (pos));
@@ -3513,18 +3552,193 @@
 figure::properties::update_papertype (void)
 {
   caseless_str typ = get_papertype ();
-
   if (! typ.compare ("<custom>"))
-    // Call papersize.set rather than set_papersize to avoid loops between
-    // update_papersize and update_papertype
-    papersize.set (octave_value (papersize_from_type (get_paperunits (), typ)));
+    {
+      Matrix sz = papersize_from_type (get_paperunits (), typ);
+      if (get_paperorientation () == "landscape")
+        std::swap (sz(0), sz(1));
+      // Call papersize.set rather than set_papersize to avoid loops
+      // between update_papersize and update_papertype
+      papersize.set (octave_value (sz));
+    }
 }
 
 void
 figure::properties::update_papersize (void)
 {
-  papertype.set ("<custom>");
-}
+  Matrix sz = get_papersize ().matrix_value ();
+  if (sz(0) > sz(1))
+    {
+      std::swap (sz(0), sz(1));
+      papersize.set (octave_value (sz));
+      paperorientation.set (octave_value ("landscape"));
+    }
+  else
+    {
+      paperorientation.set ("portrait");
+    }
+  std::string punits = get_paperunits ();
+  if (punits == "centimeters")
+    {
+      sz(0) /= 2.54;
+      sz(1) /= 2.54;
+    }
+  else if (punits == "points")
+    {
+      sz(0) /= 72.0;
+      sz(1) /= 72.0;
+    }
+  if (punits == "normalized")
+    {
+      caseless_str typ = get_papertype ();
+      if (get_papertype () == "<custom>")
+        error ("set: can't set the papertype to <custom> when the paperunits is normalized");
+    }
+  else
+    {
+      // TODO - the papersizes info is also in papersize_from_type().
+      // Both should be rewritten to avoid the duplication.
+      std::string typ = "<custom>";
+      const double mm2in = 1.0 / 25.4;
+      const double tol = 0.01;
+
+      if (std::abs (sz(0) - 8.5) + std::abs (sz(1) - 11.0) < tol)
+        typ = "usletter";
+      else if (std::abs (sz(0) - 8.5) + std::abs (sz(1) - 14.0) < tol)
+        typ = "uslegal";
+      else if (std::abs (sz(0) - 11.0) + std::abs (sz(1) - 17.0) < tol)
+        typ = "tabloid";
+      else if (std::abs (sz(0) - 841.0 * mm2in) + std::abs (sz(1) - 1198.0 * mm2in) < tol)
+        typ = "a0";
+      else if (std::abs (sz(0) - 594.0 * mm2in) + std::abs (sz(1) - 841.0 * mm2in) < tol)
+        typ = "a1";
+      else if (std::abs (sz(0) - 420.0 * mm2in) + std::abs (sz(1) - 594.0 * mm2in) < tol)
+        typ = "a2";
+      else if (std::abs (sz(0) - 297.0 * mm2in) + std::abs (sz(1) - 420.0 * mm2in) < tol)
+        typ = "a3";
+      else if (std::abs (sz(0) - 210.0 * mm2in) + std::abs (sz(1) - 297.0 * mm2in) < tol)
+        typ = "a4";
+      else if (std::abs (sz(0) - 148.0 * mm2in) + std::abs (sz(1) - 210.0 * mm2in) < tol)
+        typ = "a5";
+      else if (std::abs (sz(0) - 1029.0 * mm2in) + std::abs (sz(1) - 1456.0 * mm2in) < tol)
+        typ = "b0";
+      else if (std::abs (sz(0) - 728.0 * mm2in) + std::abs (sz(1) - 1028.0 * mm2in) < tol)
+        typ = "b1";
+      else if (std::abs (sz(0) - 514.0 * mm2in) + std::abs (sz(1) - 728.0 * mm2in) < tol)
+        typ = "b2";
+      else if (std::abs (sz(0) - 364.0 * mm2in) + std::abs (sz(1) - 514.0 * mm2in) < tol)
+        typ = "b3";
+      else if (std::abs (sz(0) - 257.0 * mm2in) + std::abs (sz(1) - 364.0 * mm2in) < tol)
+        typ = "b4";
+      else if (std::abs (sz(0) - 182.0 * mm2in) + std::abs (sz(1) - 257.0 * mm2in) < tol)
+        typ = "b5";
+      else if (std::abs (sz(0) - 9.0)  + std::abs (sz(1) - 12.0) < tol)
+        typ = "arch-a";
+      else if (std::abs (sz(0) - 12.0) + std::abs (sz(1) - 18.0) < tol)
+        typ = "arch-b";
+      else if (std::abs (sz(0) - 18.0) + std::abs (sz(1) - 24.0) < tol)
+        typ = "arch-c";
+      else if (std::abs (sz(0) - 24.0) + std::abs (sz(1) - 36.0) < tol)
+        typ = "arch-d";
+      else if (std::abs (sz(0) - 36.0) + std::abs (sz(1) - 48.0) < tol)
+        typ = "arch-e";
+      else if (std::abs (sz(0) - 8.5)  + std::abs (sz(1) - 11.0) < tol)
+        typ = "a";
+      else if (std::abs (sz(0) - 11.0) + std::abs (sz(1) - 17.0) < tol)
+        typ = "b";
+      else if (std::abs (sz(0) - 17.0) + std::abs (sz(1) - 22.0) < tol)
+        typ = "c";
+      else if (std::abs (sz(0) - 22.0) + std::abs (sz(1) - 34.0) < tol)
+        typ = "d";
+      else if (std::abs (sz(0) - 34.0) + std::abs (sz(1) - 43.0) < tol)
+        typ = "e";
+      // Call papertype.set rather than set_papertype to avoid loops between
+      // update_papersize and update_papertype
+      papertype.set (typ);
+    }
+  if (punits == "centimeters")
+    {
+      sz(0) *= 2.54;
+      sz(1) *= 2.54;
+    }
+  else if (punits == "points")
+    {
+      sz(0) *= 72.0;
+      sz(1) *= 72.0;
+    }
+  if (get_paperorientation () == "landscape")
+    {
+      std::swap (sz(0), sz(1));
+      papersize.set (octave_value (sz));
+    }
+}
+
+/*
+%!test
+%! figure (1, "visible", "off");
+%! set (1, "paperunits", "inches");
+%! set (1, "papersize", [5, 4])
+%! set (1, "paperunits", "points");
+%! assert (get (1, "papersize"), [5, 4] * 72, 1)
+%! papersize = get (gcf, "papersize");
+%! set (1, "papersize", papersize + 1);
+%! set (1, "papersize", papersize)
+%! assert (get (1, "papersize"), [5, 4] * 72, 1)
+%! close (1)
+%!test
+%! figure (1, "visible", "off");
+%! set (1, "paperunits", "inches");
+%! set (1, "papersize", [5, 4])
+%! set (1, "paperunits", "centimeters");
+%! assert (get (1, "papersize"), [5, 4] * 2.54, 2.54/72)
+%! papersize = get (gcf, "papersize");
+%! set (1, "papersize", papersize + 1);
+%! set (1, "papersize", papersize)
+%! assert (get (1, "papersize"), [5, 4] * 2.54, 2.54/72)
+%! close (1)
+*/
+
+void
+figure::properties::update_paperorientation (void)
+{
+  std::string porient = get_paperorientation ();
+  Matrix sz = get_papersize ().matrix_value ();
+  Matrix pos = get_paperposition ().matrix_value ();
+  if ((sz(0) > sz(1) && porient == "portrait")
+      || (sz(0) < sz(1) && porient == "landscape"))
+    {
+      std::swap (sz(0), sz(1));
+      std::swap (pos(0), pos(1));
+      std::swap (pos(2), pos(3));
+      // Call papertype.set rather than set_papertype to avoid loops
+      // between update_papersize and update_papertype
+      papersize.set (octave_value (sz));
+      paperposition.set (octave_value (pos));
+    }
+}
+
+/*
+%!test
+%! figure (1, "visible", false);
+%! tol = 100 * eps ();
+%! ## UPPER case and MiXed case is part of test and should not be changed.
+%! set (gcf (), "paperorientation", "PORTRAIT");
+%! set (gcf (), "paperunits", "inches");
+%! set (gcf (), "papertype", "USletter");
+%! assert (get (gcf (), "papersize"), [8.5, 11.0], tol);
+%! set (gcf (), "paperorientation", "Landscape");
+%! assert (get (gcf (), "papersize"), [11.0, 8.5], tol);
+%! set (gcf (), "paperunits", "centimeters");
+%! assert (get (gcf (), "papersize"), [11.0, 8.5] * 2.54, tol);
+%! set (gcf (), "papertype", "a4");
+%! assert (get (gcf (), "papersize"), [29.7, 21.0], tol);
+%! set (gcf (), "paperunits", "inches", "papersize", [8.5, 11.0]);
+%! assert (get (gcf (), "papertype"), "usletter");
+%! assert (get (gcf (), "paperorientation"), "portrait");
+%! set (gcf (), "papersize", [11.0, 8.5]);
+%! assert (get (gcf (), "papertype"), "usletter");
+%! assert (get (gcf (), "paperorientation"), "landscape");
+*/
 
 void
 figure::properties::set_units (const octave_value& v)
@@ -3543,9 +3757,20 @@
 void
 figure::properties::update_units (const caseless_str& old_units)
 {
-  set_position (convert_position (get_position ().matrix_value (), old_units,
-                                  get_units (), screen_size_pixels ()));
-}
+  position.set (convert_position (get_position ().matrix_value (), old_units,
+                                  get_units (), screen_size_pixels ()), false);
+}
+
+/*
+%!test
+%! figure (1, "visible", false);
+%! set (0, "units", "pixels");
+%! rsz = get (0, "screensize");
+%! set (gcf (), "units", "pixels");
+%! fsz = get (gcf (), "position");
+%! set (gcf (), "units", "normalized");
+%! assert (get (gcf (), "position"), (fsz - [1, 1, 0, 0]) ./ rsz([3, 4, 3, 4]));
+*/
 
 std::string
 figure::properties::get_title (void) const
@@ -3738,20 +3963,20 @@
                  {
                    axes::properties& props =
                      dynamic_cast<axes::properties&> (go.get_properties ());
-                   if (props.autopos_tag_is("subplot"))
+                   if (props.autopos_tag_is ("subplot"))
                      {
                        Matrix outpos = go.get ("outerposition").matrix_value ();
-                       bool l_align=(std::abs (outpos(0)-ref_outbox(0)) < 1e-15);
-                       bool b_align=(std::abs (outpos(1)-ref_outbox(1)) < 1e-15);
-                       bool r_align=(std::abs (outpos(0)+outpos(2)-ref_outbox(2)) < 1e-15);
-                       bool t_align=(std::abs (outpos(1)+outpos(3)-ref_outbox(3)) < 1e-15);
+                       bool l_align = (std::abs (outpos(0)-ref_outbox(0)) < 1e-15);
+                       bool b_align = (std::abs (outpos(1)-ref_outbox(1)) < 1e-15);
+                       bool r_align = (std::abs (outpos(0)+outpos(2)-ref_outbox(2)) < 1e-15);
+                       bool t_align = (std::abs (outpos(1)+outpos(3)-ref_outbox(3)) < 1e-15);
                        if (l_align || b_align || r_align || t_align)
                          {
-                           aligned.push_back(kids(i));
-                           l_aligned.push_back(l_align);
-                           b_aligned.push_back(b_align);
-                           r_aligned.push_back(r_align);
-                           t_aligned.push_back(t_align);
+                           aligned.push_back (kids(i));
+                           l_aligned.push_back (l_align);
+                           b_aligned.push_back (b_align);
+                           r_aligned.push_back (r_align);
+                           t_aligned.push_back (t_align);
                            // FIXME: the temporarily deleted tags should be
                            //        protected from interrupts
                            props.set_autopos_tag ("none");
@@ -3760,7 +3985,7 @@
                  }
              }
            // Determine a minimum box which aligns the subplots
-           Matrix ref_box(1, 4, 0.);
+           Matrix ref_box (1, 4, 0.);
            ref_box(2) = 1.;
            ref_box(3) = 1.;
            for (size_t i = 0; i < aligned.size (); i++)
@@ -4059,7 +4284,7 @@
   xticklabelmode = "auto";
   yticklabelmode = "auto";
   zticklabelmode = "auto";
-  color = "none";
+  color = color_values ("white");
   xcolor = color_values ("black");
   ycolor = color_values ("black");
   zcolor = color_values ("black");
@@ -4315,7 +4540,7 @@
 inline void
 normalize (ColumnVector& v)
 {
-  double fact = 1.0/sqrt(v(0)*v(0)+v(1)*v(1)+v(2)*v(2));
+  double fact = 1.0 / sqrt (v(0)*v(0)+v(1)*v(1)+v(2)*v(2));
   scale (v, fact, fact, fact);
 }
 
@@ -4354,7 +4579,7 @@
       0,1,1,1,
       1,1,1,1};
   Matrix m (4, 8);
-  memcpy (m.fortran_vec (), data, sizeof(double)*32);
+  memcpy (m.fortran_vec (), data, sizeof (double)*32);
   return m;
 }
 
@@ -4362,7 +4587,7 @@
 cam2xform (const Array<double>& m)
 {
   ColumnVector retval (4, 1.0);
-  memcpy (retval.fortran_vec (), m.fortran_vec (), sizeof(double)*3);
+  memcpy (retval.fortran_vec (), m.fortran_vec (), sizeof (double)*3);
   return retval;
 }
 
@@ -4393,7 +4618,7 @@
                   && cameratargetmode_is ("auto")
                   && cameraupvectormode_is ("auto")
                   && cameraviewanglemode_is ("auto"));
-  bool dowarp = (autocam && dataaspectratiomode_is("auto")
+  bool dowarp = (autocam && dataaspectratiomode_is ("auto")
                  && plotboxaspectratiomode_is ("auto"));
 
   ColumnVector c_eye (xform_vector ());
@@ -4415,17 +4640,17 @@
     {
       Matrix tview = get_view ().matrix_value ();
       double az = tview(0), el = tview(1);
-      double d = 5*sqrt(pb(0)*pb(0)+pb(1)*pb(1)+pb(2)*pb(2));
+      double d = 5 * sqrt (pb(0)*pb(0)+pb(1)*pb(1)+pb(2)*pb(2));
 
       if (el == 90 || el == -90)
-        c_eye(2) = d*signum(el);
+        c_eye(2) = d*signum (el);
       else
         {
           az *= M_PI/180.0;
           el *= M_PI/180.0;
-          c_eye(0) = d*cos(el)*sin(az);
-          c_eye(1) = -d*cos(el)*cos(az);
-          c_eye(2) = d*sin(el);
+          c_eye(0) = d * cos (el) * sin (az);
+          c_eye(1) = -d* cos (el) * cos (az);
+          c_eye(2) = d * sin (el);
         }
       c_eye(0) = c_eye(0)*(xlimits(1)-xlimits(0))/(xd*pb(0))+c_center(0);
       c_eye(1) = c_eye(1)*(ylimits(1)-ylimits(0))/(yd*pb(1))+c_center(1);
@@ -4444,9 +4669,9 @@
       if (el == 90 || el == -90)
         {
           c_upv(0) =
-            -signum(el)*sin(az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0);
+            -signum (el) *sin (az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0);
           c_upv(1) =
-            signum(el)*cos(az*M_PI/180.0)*(ylimits(1)-ylimits(0))/pb(1);
+            signum (el) * cos (az*M_PI/180.0)*(ylimits(1)-ylimits(0))/pb(1);
         }
       else
         c_upv(2) = 1;
@@ -4483,7 +4708,7 @@
 
   if (std::abs (dot (f, UP)) > 1e-15)
     {
-      double fa = 1/sqrt(1-f(2)*f(2));
+      double fa = 1 / sqrt(1-f(2)*f(2));
       scale (UP, fa, fa, fa);
     }
 
@@ -4641,7 +4866,7 @@
     xPlane = (dir(2) < 0 ? x_min : x_max);
 
   xPlaneN = (xPlane == x_min ? x_max : x_min);
-  fx = (x_max-x_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1));
+  fx = (x_max-x_min) / sqrt (dir(0)*dir(0)+dir(1)*dir(1));
 
   p1 = xform.transform ((x_min+x_max)/2, y_min, (z_min+z_max)/2, false);
   p2 = xform.transform ((x_min+x_max)/2, y_max, (z_min+z_max)/2, false);
@@ -4669,11 +4894,11 @@
     yPlane = (dir(2) < 0 ? y_min : y_max);
 
   yPlaneN = (yPlane == y_min ? y_max : y_min);
-  fy = (y_max-y_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1));
-
-  p1 = xform.transform((x_min+x_max)/2, (y_min+y_max)/2, z_min, false);
-  p2 = xform.transform((x_min+x_max)/2, (y_min+y_max)/2, z_max, false);
-  dir(0) = xround(p2(0)-p1(0));
+  fy = (y_max-y_min) / sqrt (dir(0)*dir(0)+dir(1)*dir(1));
+
+  p1 = xform.transform ((x_min+x_max)/2, (y_min+y_max)/2, z_min, false);
+  p2 = xform.transform ((x_min+x_max)/2, (y_min+y_max)/2, z_max, false);
+  dir(0) = xround (p2(0)-p1(0));
   dir(1) = xround (p2(1)-p1(1));
   dir(2) = (p2(2)-p1(2));
   if (dir(0) == 0 && dir(1) == 0)
@@ -4697,7 +4922,7 @@
     zPlane = (dir(2) < 0 ? z_min : z_max);
 
   zPlaneN = (zPlane == z_min ? z_max : z_min);
-  fz = (z_max-z_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1));
+  fz = (z_max-z_min) / sqrt (dir(0)*dir(0)+dir(1)*dir(1));
 
   unwind_protect frame;
   frame.protect_var (updating_axes_layout);
@@ -4747,34 +4972,31 @@
   }
 
   Matrix viewmat = get_view ().matrix_value ();
-  nearhoriz = std::abs(viewmat(1)) <= 5;
-
-  update_ticklengths ();
-}
-
-void
-axes::properties::update_ticklengths (void)
+  nearhoriz = std::abs (viewmat(1)) <= 5;
+
+  update_ticklength ();
+}
+
+void
+axes::properties::update_ticklength (void)
 {
   bool mode2d = (((xstate > AXE_DEPTH_DIR ? 1 : 0) +
                   (ystate > AXE_DEPTH_DIR ? 1 : 0) +
                   (zstate > AXE_DEPTH_DIR ? 1 : 0)) == 2);
+
   if (tickdirmode_is ("auto"))
-  {
-    // FIXME: tickdir should be updated (code below comes
-    //        from JHandles)
-    //autoMode++;
-    //TickDir.set(mode2d ? "in" : "out", true);
-    //autoMode--;
-  }
-
-  //double ticksign = (tickdir_is ("in") ? -1 : 1);
-  double ticksign = (tickdirmode_is ("auto") ?
-                     (mode2d ? -1 : 1) :
-                     (tickdir_is ("in") ? -1 : 1));
-  // FIXME: use ticklength property
-  xticklen = ticksign*7;
-  yticklen = ticksign*7;
-  zticklen = ticksign*7;
+    tickdir.set (mode2d ? "in" : "out", true);
+
+  double ticksign = (tickdir_is ("in") ? -1 : 1);
+
+  Matrix bbox = get_boundingbox (true);
+  Matrix ticklen = get_ticklength ().matrix_value ();
+  ticklen(0) = ticklen(0) * std::max (bbox(2), bbox(3));
+  ticklen(1) = ticklen(1) * std::max (bbox(2), bbox(3));
+
+  xticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1));
+  yticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1));
+  zticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1));
 
   xtickoffset = (mode2d ? std::max (0., xticklen) : std::abs (xticklen)) + 5;
   ytickoffset = (mode2d ? std::max (0., yticklen) : std::abs (yticklen)) + 5;
@@ -4786,6 +5008,24 @@
   update_title_position ();
 }
 
+/*
+## FIXME: A demo can't be called in a C++ file.  This should be made a test
+## or moved to a .m file where it can be called.
+%!demo
+%! clf;
+%! subplot (2,1,1);
+%! plot (rand (3));
+%! xlabel xlabel;
+%! ylabel ylabel;
+%! title title;
+%! subplot (2,1,2);
+%! plot (rand (3));
+%! set (gca, "ticklength", get (gca, "ticklength") * 2, "tickdir", "out");
+%! xlabel xlabel;
+%! ylabel ylabel;
+%! title title;
+*/
+
 static bool updating_xlabel_position = false;
 
 void
@@ -4839,9 +5079,9 @@
 
       bool tick_along_z = nearhoriz || xisinf (fy);
       if (tick_along_z)
-        p(2) += (signum(zpTick-zpTickN)*fz*xtickoffset);
+        p(2) += (signum (zpTick-zpTickN)*fz*xtickoffset);
       else
-        p(1) += (signum(ypTick-ypTickN)*fy*xtickoffset);
+        p(1) += (signum (ypTick-ypTickN)*fy*xtickoffset);
 
       p = xform.transform (p(0), p(1), p(2), false);
 
@@ -4930,9 +5170,9 @@
 
       bool tick_along_z = nearhoriz || xisinf (fx);
       if (tick_along_z)
-        p(2) += (signum(zpTick-zpTickN)*fz*ytickoffset);
+        p(2) += (signum (zpTick-zpTickN)*fz*ytickoffset);
       else
-        p(0) += (signum(xpTick-xpTickN)*fx*ytickoffset);
+        p(0) += (signum (xpTick-xpTickN)*fx*ytickoffset);
 
       p = xform.transform (p(0), p(1), p(2), false);
 
@@ -5024,18 +5264,18 @@
           p = graphics_xform::xform_vector (xPlaneN, yPlane,
                                             (zpTickN+zpTick)/2);
           if (xisinf (fy))
-            p(0) += (signum(xPlaneN-xPlane)*fx*ztickoffset);
+            p(0) += (signum (xPlaneN-xPlane)*fx*ztickoffset);
           else
-            p(1) += (signum(yPlane-yPlaneN)*fy*ztickoffset);
+            p(1) += (signum (yPlane-yPlaneN)*fy*ztickoffset);
         }
       else
         {
           p = graphics_xform::xform_vector (xPlane, yPlaneN,
                                             (zpTickN+zpTick)/2);
           if (xisinf (fx))
-            p(1) += (signum(yPlaneN-yPlane)*fy*ztickoffset);
+            p(1) += (signum (yPlaneN-yPlane)*fy*ztickoffset);
           else
-            p(0) += (signum(xPlane-xPlaneN)*fx*ztickoffset);
+            p(0) += (signum (xPlane-xPlaneN)*fx*ztickoffset);
         }
 
       p = xform.transform (p(0), p(1), p(2), false);
@@ -5119,7 +5359,7 @@
 
       p = xform.untransform (p(0), p(1), p(2), true);
 
-      title_props.set_position (p.extract_n(0, 3).transpose ());
+      title_props.set_position (p.extract_n (0, 3).transpose ());
       title_props.set_positionmode ("auto");
     }
 }
@@ -5372,7 +5612,7 @@
           text::properties& text_props = reinterpret_cast<text::properties&>
             (gh_manager::get_object (text_handle).get_properties ());
 
-          Matrix text_pos = text_props.get_position ().matrix_value ();
+          Matrix text_pos = text_props.get_data_position ();
           text_pos = xform.transform (text_pos(0), text_pos(1), text_pos(2));
           if (text_props.get_string ().is_empty ())
             {
@@ -5389,7 +5629,7 @@
               bool ignore_vertical = false;
               if (only_text_height)
                 {
-                  double text_rotation = text_props.get_rotation();
+                  double text_rotation = text_props.get_rotation ();
                   if (text_rotation == 0. || text_rotation == 180.)
                       ignore_horizontal = true;
                   else if (text_rotation == 90. || text_rotation == 270.)
@@ -5437,9 +5677,9 @@
   graphics_object obj = gh_manager::get_object (get_parent ());
   Matrix parent_bb = obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
   caseless_str new_units = get_units ();
-  position.set (octave_value (convert_position (get_position().matrix_value(), old_units, new_units, parent_bb)), false);
-  outerposition.set (octave_value (convert_position (get_outerposition().matrix_value(), old_units, new_units, parent_bb)), false);
-  tightinset.set (octave_value (convert_position (get_tightinset().matrix_value(), old_units, new_units, parent_bb)), false);
+  position.set (octave_value (convert_position (get_position ().matrix_value (), old_units, new_units, parent_bb)), false);
+  outerposition.set (octave_value (convert_position (get_outerposition ().matrix_value (), old_units, new_units, parent_bb)), false);
+  tightinset.set (octave_value (convert_position (get_tightinset ().matrix_value (), old_units, new_units, parent_bb)), false);
 }
 
 void
@@ -5475,7 +5715,7 @@
   double parent_height = box_pix_height;
 
   if (fontunits_is ("normalized") && parent_height <= 0)
-    parent_height = get_boundingbox (true).elem(3);
+    parent_height = get_boundingbox (true).elem (3);
 
   return convert_font_size (fs, get_fontunits (), "points", parent_height);
 }
@@ -5688,8 +5928,17 @@
           // FIXME -- maybe this test should also be relative?
           if (std::abs (min_val - max_val) < sqrt (DBL_EPSILON))
             {
-              min_val *= 0.9;
-              max_val *= 1.1;
+              // Widen range when too small
+              if (min_val >= 0)
+                {
+                  min_val *= 0.9;
+                  max_val *= 1.1;
+                }
+              else
+                {
+                  min_val *= 1.1;
+                  max_val *= 0.9;
+                }
             }
           if (min_val > 0)
             {
@@ -5919,7 +6168,7 @@
           hmax = std::max (hmax, ext(1));
 #else
           //FIXME: find a better approximation
-          int len = ticklabels(i).length();
+          int len = ticklabels(i).length ();
           wmax = std::max (wmax, 0.5*fontsize*len);
           hmax = fontsize;
 #endif
@@ -6037,7 +6286,7 @@
   double val;
 
 #define FIX_LIMITS \
-  if (limits.numel() == 4) \
+  if (limits.numel () == 4) \
     { \
       val = limits(0); \
       if (! (xisinf (val) || xisnan (val))) \
@@ -6054,7 +6303,7 @@
     } \
   else \
     { \
-      limits.resize(4, 1); \
+      limits.resize (4, 1); \
       limits(0) = min_val; \
       limits(1) = max_val; \
       limits(2) = min_pos; \
@@ -6463,11 +6712,8 @@
   double max_neg_y = -octave_Inf;
   get_children_limits (miny, maxy, min_pos_y, max_neg_y, kids, 'y');
 
-  if (! (xscale_is ("log") && xlims(0) < 0 && xlims(1) < 0))
-    xlims = do_zoom (x, factor, xlims, xscale_is ("log"));
-
-  if (! (yscale_is ("log") && ylims(0) < 0 && ylims(1) < 0))
-    ylims = do_zoom (y, factor, ylims, yscale_is ("log"));
+  xlims = do_zoom (x, factor, xlims, xscale_is ("log"));
+  ylims = do_zoom (y, factor, ylims, yscale_is ("log"));
 
   zoom (xlims, ylims, push_to_zoom_stack);
 }
@@ -6475,14 +6721,6 @@
 void
 axes::properties::zoom (const Matrix& xl, const Matrix& yl, bool push_to_zoom_stack)
 {
-  // FIXME: Do we need error checking here?
-  Matrix xlims = get_xlim ().matrix_value ();
-  Matrix ylims = get_ylim ().matrix_value ();
-
-  if ((xscale_is ("log") && xlims(0) < 0 && xlims(1) < 0)
-      || (yscale_is ("log") && ylims(0) < 0 && ylims(1) < 0))
-    return;
-
   if (push_to_zoom_stack)
     {
       zoom_stack.push_front (xlimmode.get ());
@@ -6501,8 +6739,68 @@
   update_ylim (false);
 }
 
-void
-axes::properties::translate_view (double delta_x, double delta_y)
+static Matrix
+do_translate (double x0, double x1, const Matrix& lims, bool is_logscale)
+{
+  Matrix new_lims = lims;
+
+  double lo = lims(0);
+  double hi = lims(1);
+
+  bool is_negative = lo < 0 && hi < 0;
+
+  double delta;
+
+  if (is_logscale)
+    {
+      if (is_negative)
+        {
+          double tmp = hi;
+          hi = std::log10 (-lo);
+          lo = std::log10 (-tmp);
+          x0 = -x0;
+          x1 = -x1;
+        }
+      else
+        {
+          hi = std::log10 (hi);
+          lo = std::log10 (lo);
+        }
+
+      delta = std::log10 (x0) - std::log10 (x1);
+    }
+  else
+    {
+      delta = x0 - x1;
+    }
+
+  // Perform the translation
+  lo += delta;
+  hi += delta;
+
+  if (is_logscale)
+    {
+      if (is_negative)
+        {
+          double tmp = -std::pow (10.0, hi);
+          hi = -std::pow (10.0, lo);
+          lo = tmp;
+        }
+      else
+        {
+          lo = std::pow (10.0, lo);
+          hi = std::pow (10.0, hi);
+        }
+    }
+
+  new_lims(0) = lo;
+  new_lims(1) = hi;
+
+  return new_lims;
+}
+
+void
+axes::properties::translate_view (double x0, double x1, double y0, double y1)
 {
   // FIXME: Do we need error checking here?
   Matrix xlims = get_xlim ().matrix_value ();
@@ -6522,17 +6820,8 @@
   double max_neg_y = -octave_Inf;
   get_children_limits (miny, maxy, min_pos_y, max_neg_y, kids, 'y');
 
-  if (! xscale_is ("log"))
-    {
-      xlims (0) += delta_x;
-      xlims (1) += delta_x;
-    }
-
-  if (! yscale_is ("log"))
-    {
-      ylims (0) += delta_y;
-      ylims (1) += delta_y;
-    }
+  xlims = do_translate (x0, x1, xlims, xscale_is ("log"));
+  ylims = do_translate (y0, y1, ylims, yscale_is ("log"));
 
   zoom (xlims, ylims, false);
 }
@@ -6542,17 +6831,17 @@
 {
   Matrix v = get_view ().matrix_value ();
 
-  v (1) += delta_el;
+  v(1) += delta_el;
 
   if(v(1) > 90)
     v(1) = 90;
   if(v(1) < -90)
     v(1) = -90;
 
-  v (0) = fmod(v(0) - delta_az + 720,360);
-
-  set_view(v);
-  update_transform();
+  v(0) = fmod (v(0) - delta_az + 720,360);
+
+  set_view (v);
+  update_transform ();
 }
 
 void
@@ -6645,13 +6934,21 @@
 Matrix
 text::properties::get_extent_matrix (void) const
 {
+  // FIXME: Should this function also add the (x,y) base position?
   return extent.get ().matrix_value ();
 }
 
 octave_value
 text::properties::get_extent (void) const
 {
+  // FIXME: This doesn't work right for 3D plots.
+  // (It doesn't in Matlab either, at least not in version 6.5.)
   Matrix m = extent.get ().matrix_value ();
+  Matrix pos = get_position ().matrix_value ();
+  Matrix p = convert_text_position (pos, *this, get_units (), "pixels");
+
+  m(0) += p(0);
+  m(1) += p(1);
 
   return convert_text_position (m, *this, "pixels", get_units ());
 }
@@ -6699,6 +6996,10 @@
 
   renderer.text_to_pixels (sv.join ("\n"), pixels, bbox,
                            halign, valign, get_rotation ());
+  /* The bbox is relative to the text's position.
+     We'll leave it that way, because get_position () does not return
+     valid results when the text is first constructed.
+     Conversion to proper coordinates is performed in get_extent. */
   set_extent (bbox);
 
 #endif
@@ -6756,7 +7057,7 @@
       graphics_object go (gh_manager::get_object (get___myhandle__ ()));
       graphics_object ax (go.get_ancestor ("axes"));
 
-      parent_height = ax.get_properties ().get_boundingbox (true).elem(3);
+      parent_height = ax.get_properties ().get_boundingbox (true).elem (3);
     }
 
   return convert_font_size (fs, get_fontunits (), "points", parent_height);
@@ -6776,7 +7077,7 @@
 octave_value
 patch::properties::get_color_data (void) const
 {
-  octave_value fvc = get_facevertexcdata();
+  octave_value fvc = get_facevertexcdata ();
   if (fvc.is_undefined () || fvc.is_empty ())
     return Matrix ();
   else
@@ -6956,7 +7257,7 @@
       update_type = 'a';
     }
 
-  if (limits.numel() == 4)
+  if (limits.numel () == 4)
     {
       val = limits(0);
       if (! (xisinf (val) || xisnan (val)))
@@ -6973,7 +7274,7 @@
     }
   else
     {
-      limits.resize(4,1);
+      limits.resize (4,1);
       limits(0) = min_val;
       limits(1) = max_val;
       limits(2) = min_pos;
@@ -7179,7 +7480,7 @@
 void
 uicontrol::properties::set_style (const octave_value& st)
 {
-  if (get___object__ ().is_empty())
+  if (get___object__ ().is_empty ())
     style = st;
   else
     error ("set: cannot change the style of a uicontrol object after creation.");
@@ -7242,7 +7543,7 @@
   double parent_height = box_pix_height;
 
   if (fontunits_is ("normalized") && parent_height <= 0)
-    parent_height = get_boundingbox (false).elem(3);
+    parent_height = get_boundingbox (false).elem (3);
 
   return convert_font_size (fs, get_fontunits (), "points", parent_height);
 }
@@ -7378,7 +7679,7 @@
   double parent_height = box_pix_height;
 
   if (fontunits_is ("normalized") && parent_height <= 0)
-    parent_height = get_boundingbox (false).elem(3);
+    parent_height = get_boundingbox (false).elem (3);
 
   return convert_font_size (fs, get_fontunits (), "points", parent_height);
 }
@@ -8127,7 +8428,7 @@
                         }
                       else
                         {
-                          error("set: number of graphics handles must match number of value rows (%d != %d)",
+                          error ("set: number of graphics handles must match number of value rows (%d != %d)",
                                 hcv.length (), args(2).cell_value ().rows ());
                           break;
 
@@ -8214,7 +8515,7 @@
 
   if (nargin == 1 || nargin == 2)
     {
-      if (args(0).is_empty())
+      if (args(0).is_empty ())
         {
           retval = Matrix ();
           return retval;
@@ -8359,7 +8660,7 @@
 }
 
 /*
-%!assert (get (findobj (0, 'Tag', 'nonexistenttag'), 'nonexistentproperty'), [])
+%!assert (get (findobj (0, "Tag", "nonexistenttag"), "nonexistentproperty"), [])
 */
 
 // Return all properties from the graphics handle @var{h}.
@@ -8617,7 +8918,7 @@
   if ((go.isa ("line") || go.isa ("patch")) && ! go.get("zdata").is_empty ())
     nd = 3;
 
-  Matrix kids = go.get_properties().get_children ();
+  Matrix kids = go.get_properties ().get_children ();
 
   for (octave_idx_type i = 0; i < kids.length (); i++)
     {
@@ -8625,9 +8926,9 @@
 
       if (hnd.ok ())
         {
-          const graphics_object& kid = gh_manager::get_object(hnd);
-
-          if (kid.valid_object())
+          const graphics_object& kid = gh_manager::get_object (hnd);
+
+          if (kid.valid_object ())
             nd = calc_dimensions (kid);
 
           if (nd == 3)
@@ -9556,7 +9857,7 @@
   if (obj)
     retval = obj.get (caseless_str (property));
   else
-    error ("%s: invalid handle (= %g)", func.c_str(), handle);
+    error ("%s: invalid handle (= %g)", func.c_str (), handle);
 
   return retval;
 }
@@ -9578,7 +9879,7 @@
         ret = true;
     }
   else
-    error ("%s: invalid handle (= %g)", func.c_str(), handle);
+    error ("%s: invalid handle (= %g)", func.c_str (), handle);
 
   return ret;
 }
@@ -9646,11 +9947,11 @@
 }
 
 static void
-cleanup_waitfor_postset_listener(const octave_value& listener)
+cleanup_waitfor_postset_listener (const octave_value& listener)
 { do_cleanup_waitfor_listener (listener, POSTSET); }
 
 static void
-cleanup_waitfor_predelete_listener(const octave_value& listener)
+cleanup_waitfor_predelete_listener (const octave_value& listener)
 { do_cleanup_waitfor_listener (listener, PREDELETE); }
 
 static octave_value_list
rename from src/graphics.h.in
rename to src/graphics.in.h
--- a/src/graphics.h.in
+++ b/src/graphics.in.h
@@ -222,10 +222,7 @@
     {
       Matrix retval (m.rows (), m.cols ());
 
-      if (m.any_element_is_positive ())
-        do_scale (m.data (), retval.fortran_vec (), m.numel ());
-      else
-        do_neg_scale (m.data (), retval.fortran_vec (), m.numel ());
+      do_scale (m.data (), retval.fortran_vec (), m.numel ());
 
       return retval;
     }
@@ -234,10 +231,7 @@
     {
       NDArray retval (m.dims ());
 
-      if (m.any_element_is_positive ())
-        do_scale (m.data (), retval.fortran_vec (), m.numel ());
-      else
-        do_neg_scale (m.data (), retval.fortran_vec (), m.numel ());
+      do_scale (m.data (), retval.fortran_vec (), m.numel ());
 
       return retval;
     }
@@ -255,13 +249,47 @@
   void do_scale (const double *src, double *dest, int n) const
     {
       for (int i = 0; i < n; i++)
-        dest[i] = log10(src[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;
     }
 
-  void do_neg_scale (const double *src, double *dest, int n) const
+  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]);
+        dest[i] = -log10 (-src[i]);
     }
 };
 
@@ -270,12 +298,13 @@
 public:
   scaler (void) : rep (new base_scaler ()) { }
 
-  scaler (const scaler& s) : rep (s.rep->clone()) { }
+  scaler (const scaler& s) : rep (s.rep->clone ()) { }
 
   scaler (const std::string& s)
     : rep (s == "log"
            ? new log_scaler ()
-           : (s == "linear" ? new lin_scaler () : new base_scaler ()))
+           : (s == "neglog" ? new neg_log_scaler ()
+              : (s == "linear" ? new lin_scaler () : new base_scaler ())))
     { }
 
   ~scaler (void) { delete rep; }
@@ -318,6 +347,8 @@
 
       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
@@ -433,8 +464,8 @@
             }
           if (found)
             {
-              for (int j = i; j < l.length() - 1; j++)
-                l(j) = l (j + 1);
+              for (int j = i; j < l.length () - 1; j++)
+                l(j) = l(j + 1);
 
               l.resize (l.length () - 1);
             }
@@ -2310,7 +2341,7 @@
 
   ~gtk_manager (void) { }
 
-  static void create_instance (void);
+  OCTINTERP_API static void create_instance (void);
 
   static bool instance_ok (void)
   {
@@ -2331,7 +2362,7 @@
 
   static void cleanup_instance (void) { delete instance; instance = 0; }
 
-  static gtk_manager *instance;
+  OCTINTERP_API static gtk_manager *instance;
 
   // The name of the default toolkit.
   std::string dtk;
@@ -3123,6 +3154,9 @@
   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.
 
@@ -3340,7 +3374,7 @@
       callback_property closerequestfcn , "closereq"
       handle_property currentaxes S , graphics_handle ()
       array_property colormap , jet_colormap ()
-      radio_property paperorientation , "{portrait}|landscape|rotated"
+      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 , ""
@@ -3663,7 +3697,7 @@
     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 delta_x, double delta_y);
+    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);
@@ -3790,7 +3824,7 @@
       radio_property projection , "{orthographic}|perpective"
       radio_property tickdir mu , "{in}|out"
       radio_property tickdirmode u , "{auto}|manual"
-      array_property ticklength , default_axes_ticklength ()
+      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"
@@ -3814,9 +3848,32 @@
     void init (void);
 
   private:
-    void update_xscale (void) { sx = get_xscale (); }
-    void update_yscale (void) { sy = get_yscale (); }
-    void update_zscale (void) { sz = get_zscale (); }
+
+    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 (); }
@@ -3840,9 +3897,9 @@
     void update_ydir (void) { update_camera (); update_axes_layout (); }
     void update_zdir (void) { update_camera (); update_axes_layout (); }
 
-    void update_ticklengths (void);
-    void update_tickdir (void) { update_ticklengths (); }
-    void update_tickdirmode (void) { update_ticklengths (); }
+    void update_ticklength (void);
+    void update_tickdir (void) { update_ticklength (); }
+    void update_tickdirmode (void) { update_ticklength (); }
 
     void update_xtick (void)
       {
@@ -3968,6 +4025,8 @@
 
       fix_limits (xlim);
 
+      update_xscale ();
+
       if (do_clr_zoom)
         zoom_stack.clear ();
 
@@ -3983,6 +4042,8 @@
 
       fix_limits (ylim);
 
+      update_yscale ();
+
       if (do_clr_zoom)
         zoom_stack.clear ();
 
@@ -3998,6 +4059,8 @@
 
       fix_limits (zlim);
 
+      update_zscale ();
+
       zoom_stack.clear ();
 
       update_axes_layout ();
@@ -4172,13 +4235,38 @@
   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 mu , Matrix (1, 3, 0.0)
+      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)
@@ -4224,7 +4312,6 @@
   protected:
     void init (void)
       {
-        position.add_constraint (dim_vector (1, 2));
         position.add_constraint (dim_vector (1, 3));
         cached_units = get_units ();
         update_font ();
@@ -4326,9 +4413,9 @@
       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()
+      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"
@@ -4723,11 +4810,11 @@
 
     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()
+      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"
@@ -4795,7 +4882,7 @@
     BEGIN_PROPERTIES (uimenu)
       any_property __object__ , Matrix ()
       string_property accelerator , ""
-      callback_property callback , Matrix()
+      callback_property callback , Matrix ()
       bool_property checked , "off"
       bool_property enable , "on"
       color_property foregroundcolor , color_values (0, 0, 0)
@@ -4843,7 +4930,7 @@
 
     BEGIN_PROPERTIES (uicontextmenu)
       any_property __object__ , Matrix ()
-      callback_property callback , Matrix()
+      callback_property callback , Matrix ()
       array_property position , Matrix (1, 2, 0.0)
     END_PROPERTIES
 
@@ -5136,7 +5223,7 @@
     BEGIN_PROPERTIES (uipushtool)
       any_property __object__ , Matrix ()
       array_property cdata , Matrix ()
-      callback_property clickedcallback , Matrix()
+      callback_property clickedcallback , Matrix ()
       bool_property enable , "on"
       bool_property separator , "off"
       string_property tooltipstring , ""
@@ -5186,10 +5273,10 @@
     BEGIN_PROPERTIES (uitoggletool)
       any_property __object__ , Matrix ()
       array_property cdata , Matrix ()
-      callback_property clickedcallback , Matrix()
+      callback_property clickedcallback , Matrix ()
       bool_property enable , "on"
-      callback_property offcallback , Matrix()
-      callback_property oncallback , Matrix()
+      callback_property offcallback , Matrix ()
+      callback_property oncallback , Matrix ()
       bool_property separator , "off"
       bool_property state , "off"
       string_property tooltipstring , ""
--- a/src/help.cc
+++ b/src/help.cc
@@ -71,6 +71,11 @@
 // (--doc-cache-file file)
 std::string Vdoc_cache_file;
 
+// Name of the file containing local Texinfo macros that are prepended
+// to doc strings before processing.
+// (--texi-macros-file)
+std::string Vtexi_macros_file;
+
 // Name of the info file specified on command line.
 // (--info-file file)
 std::string Vinfo_file;
@@ -139,14 +144,14 @@
     "-*- texinfo -*-\n\
 @deftypefn {Operator} {} #\n\
 Begin comment character.\n\
-@seealso{%, #@{}\n\
+@seealso{%, #@\\{}\n\
 @end deftypefn"),
 
   pair_type ("%",
     "-*- texinfo -*-\n\
 @deftypefn {Operator} {} %\n\
 Begin comment character.\n\
-@seealso{#, %@{}\n\
+@seealso{#, %@\\{}\n\
 @end deftypefn"),
 
   pair_type ("#{",
@@ -155,7 +160,7 @@
 Begin block comment.  There must be nothing else, other than\n\
 whitespace, in the line both before and after @code{#@{}.\n\
 It is possible to nest block comments.\n\
-@seealso{%@{, #@}, #}\n\
+@seealso{%@\\{, #@\\}, #}\n\
 @end deftypefn"),
 
   pair_type ("%{",
@@ -164,7 +169,7 @@
 Begin block comment.  There must be nothing else, other than\n\
 whitespace, in the line both before and after @code{%@{}.\n\
 It is possible to nest block comments.\n\
-@seealso{#@{, %@}, %}\n\
+@seealso{#@\\{, %@\\}, %}\n\
 @end deftypefn"),
 
   pair_type ("#}",
@@ -173,7 +178,7 @@
 Close block comment.  There must be nothing else, other than\n\
 whitespace, in the line both before and after @code{#@}}.\n\
 It is possible to nest block comments.\n\
-@seealso{%@}, #@{, #}\n\
+@seealso{%@\\}, #@\\{, #}\n\
 @end deftypefn"),
 
   pair_type ("%}",
@@ -182,7 +187,7 @@
 Close block comment.  There must be nothing else, other than\n\
 whitespace, in the line both before and after @code{%@}}.\n\
 It is possible to nest block comments.\n\
-@seealso{#@}, %@{, %}\n\
+@seealso{#@\\}, %@\\{, %}\n\
 @end deftypefn"),
 
   pair_type ("...",
@@ -587,7 +592,7 @@
 @example\n\
 @group\n\
 global @var{x};\n\
-if isempty (@var{x})\n\
+if (isempty (@var{x}))\n\
   x = 1;\n\
 endif\n\
 @end group\n\
@@ -1291,6 +1296,30 @@
   return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (doc_cache_file);
 }
 
+DEFUN (texi_macros_file, args, nargout,
+  "-*- texinfo -*-\n\
+@deftypefn  {Built-in Function} {@var{val} =} texi_macros_file ()\n\
+@deftypefnx {Built-in Function} {@var{old_val} =} texi_macros_file (@var{new_val})\n\
+@deftypefnx {Built-in Function} {} texi_macros_file (@var{new_val}, \"local\")\n\
+Query or set the internal variable that specifies the name of the\n\
+file containing Texinfo macros that are prepended to documentation strings\n\
+before they are passed to makeinfo.  The default value is \n\
+@file{@var{octave-home}/share/octave/@var{version}/etc/macros.texi},\n\
+in which @var{octave-home} is the root directory of the Octave installation,\n\
+and @var{version} is the Octave version number.\n\
+The default value may be overridden by the environment variable\n\
+@w{@env{OCTAVE_TEXI_MACROS_FILE}}, or the command line argument\n\
+@samp{--texi-macros-file NAME}.\n\
+\n\
+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{makeinfo_program}\n\
+@end deftypefn")
+{
+  return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (texi_macros_file);
+}
+
 DEFUN (info_file, args, nargout,
   "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {@var{val} =} info_file ()\n\
@@ -1349,7 +1378,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{info_file, info_program, doc, help}\n\
+@seealso{texi_macros_file, info_file, info_program, doc, help}\n\
 @end deftypefn")
 {
   return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (makeinfo_program);
--- a/src/help.h
+++ b/src/help.h
@@ -36,6 +36,11 @@
 // (--doc-cache-file file)
 extern std::string Vdoc_cache_file;
 
+// Name of the file containing local Texinfo macros that are prepended
+// to doc strings before processing.
+// (--texi-macros-file)
+extern std::string Vtexi_macros_file;
+
 // Name of the info file specified on command line.
 // (--info-file file)
 extern std::string Vinfo_file;
--- a/src/input.cc
+++ b/src/input.cc
@@ -1539,9 +1539,9 @@
 @end example\n\
 \n\
 @noindent\n\
-returns the help string associated with the sub-function @code{mysubfunc}\n\
+returns the help string associated with the subfunction @code{mysubfunc}\n\
 of the function @code{myfunc}.  Another use of @code{filemarker} is when\n\
-debugging it allows easier placement of breakpoints within sub-functions.\n\
+debugging it allows easier placement of breakpoints within subfunctions.\n\
 For example,\n\
 \n\
 @example\n\
--- a/src/lex.ll
+++ b/src/lex.ll
@@ -68,6 +68,7 @@
 #include "lex.h"
 #include "ov.h"
 #include "parse.h"
+#include "parse-private.h"
 #include "pt-all.h"
 #include "symtab.h"
 #include "token.h"
@@ -764,8 +765,8 @@
 %}
 
 \?{IDENT}{S}* |
-\?{IDENT}.{IDENT}{S}* {
-    LEXER_DEBUG ("\?{IDENT}{S}* | \?{IDENT}.{IDENT}{S}*");
+\?{IDENT}\.{IDENT}{S}* {
+    LEXER_DEBUG ("\\?{IDENT}{S}*|\\?{IDENT}\\.{IDENT}{S}*");
 
     int id_tok = handle_meta_identifier ();
 
@@ -1113,8 +1114,7 @@
 
   parser_end_of_input = false;
 
-  while (! symtab_context.empty ())
-    symtab_context.pop ();
+  parser_symtab_context.clear ();
 
   // We do want a prompt by default.
   promptflag = 1;
@@ -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.
@@ -1497,17 +1501,33 @@
           lexer_flags.at_beginning_of_statement = true;
           break;
 
+        case static_kw:
+          if ((reading_fcn_file || reading_script_file
+               || reading_classdef_file)
+              && ! curr_fcn_file_full_name.empty ())
+            warning_with_id ("Octave:deprecated-keyword",
+                             "the `static' keyword is obsolete and will be removed from a future version of Octave; please use `persistent' instead; near line %d of file `%s'",
+                             input_line_number,
+                             curr_fcn_file_full_name.c_str ());
+          else
+            warning_with_id ("Octave:deprecated-keyword",
+                             "the `static' keyword is obsolete and will be removed from a future version of Octave; please use `persistent' instead; near line %d",
+                             input_line_number);
+          // fall through ...
+
+        case persistent_kw:
+          break;
+
         case case_kw:
         case elseif_kw:
         case global_kw:
-        case static_kw:
         case until_kw:
           break;
 
         case end_kw:
-          if (! reading_classdef_file
-              && (inside_any_object_index ()
-                  || (lexer_flags.defining_func
+          if (inside_any_object_index ()
+              || (! reading_classdef_file
+                  && (lexer_flags.defining_func
                       && ! (lexer_flags.looking_at_return_list
                             || lexer_flags.parsed_function_name.top ()))))
             return 0;
@@ -3451,7 +3471,14 @@
 bool
 is_keyword (const std::string& s)
 {
-  return octave_kw_hash::in_word_set (s.c_str (), s.length ()) != 0;
+  // Parsing function names like "set.property_name" inside
+  // classdef-style class definitions is simplified by handling the
+  // "set" and "get" portions of the names using the same mechanism as
+  // is used for keywords.  However, they are not really keywords in
+  // the language, so omit them from the list of possible keywords.
+
+  return (octave_kw_hash::in_word_set (s.c_str (), s.length ()) != 0
+          && ! (s == "set" || s == "get"));
 }
 
 DEFUN (iskeyword, args, ,
@@ -3474,10 +3501,22 @@
 
   if (argc == 1)
     {
+      // Neither set and get are keywords.  See the note in the
+      // is_keyword function for additional details.
+
       string_vector lst (TOTAL_KEYWORDS);
 
+      int j = 0;
+
       for (int i = 0; i < TOTAL_KEYWORDS; i++)
-        lst[i] = wordlist[i].name;
+        {
+          std::string tmp = wordlist[i].name;
+
+          if (! (tmp == "set" || tmp == "get"))
+            lst[j++] = tmp;
+        }
+
+      lst.resize (j);
 
       retval = Cell (lst.sort ());
     }
@@ -3675,7 +3714,7 @@
     case TRY: std::cerr << "TRY\n"; break;
     case CATCH: std::cerr << "CATCH\n"; break;
     case GLOBAL: std::cerr << "GLOBAL\n"; break;
-    case STATIC: std::cerr << "STATIC\n"; break;
+    case PERSISTENT: std::cerr << "PERSISTENT\n"; break;
     case FCN_HANDLE: std::cerr << "FCN_HANDLE\n"; break;
     case END_OF_INPUT: std::cerr << "END_OF_INPUT\n\n"; break;
     case LEXICAL_ERROR: std::cerr << "LEXICAL_ERROR\n\n"; break;
--- a/src/load-path.cc
+++ b/src/load-path.cc
@@ -519,13 +519,40 @@
   else
     xpath = sys_path;
 
-  do_set (xpath, false);
+  do_set (xpath, false, true);
 }
 
 void
-load_path::do_clear (void)
+load_path::do_clear (std::set<std::string>& new_elts)
 {
-  dir_info_list.clear ();
+  bool warn_default_path_clobbered = false;
+  for (dir_info_list_iterator i = dir_info_list.begin ();
+       i != dir_info_list.end ();
+       /* conditionally advance iterator in loop body */)
+    {
+      //Don't remove it if it's gonna be added again, but remove it from
+      //list of items to add, to avoid duplicates later on
+      std::set<std::string>::iterator j = new_elts.find (i->dir_name);
+      if (j != new_elts.end ())
+        {
+          new_elts.erase (j);
+          i++;
+        }
+      else
+        {
+          //Warn if removing a default directory and not immediately adding
+          //it back again
+          if (i->is_init)
+            warn_default_path_clobbered = true;
+          i = dir_info_list.erase (i);
+        }
+    }
+
+  if (warn_default_path_clobbered)
+    warning_with_id ("Octave:remove-init-dir",
+                     "default load path altered.  Some built-in functions may "
+                     "not be found.  Try restoredefaultpath() to recover it.");
+
   fcn_map.clear ();
   private_fcn_map.clear ();
   method_map.clear ();
@@ -565,9 +592,10 @@
 }
 
 void
-load_path::do_set (const std::string& p, bool warn)
+load_path::do_set (const std::string& p, bool warn, bool is_init)
 {
-  std::list<std::string> elts = split_path (p);
+  std::list<std::string> elts_l = split_path (p);
+  std::set<std::string> elts(elts_l.begin (), elts_l.end ());
 
   // Temporarily disable add hook.
 
@@ -576,12 +604,12 @@
 
   add_hook = 0;
 
-  do_clear ();
-
-  for (std::list<std::string>::const_iterator i = elts.begin ();
+  do_clear (elts);
+
+  for (std::set<std::string>::const_iterator i = elts.begin ();
        i != elts.end ();
        i++)
-    do_append (*i, warn);
+    do_append (*i, warn, is_init);
 
   // Restore add hook and execute for all newly added directories.
   frame.run_top ();
@@ -599,10 +627,10 @@
 }
 
 void
-load_path::do_append (const std::string& dir, bool warn)
+load_path::do_append (const std::string& dir, bool warn, bool is_init)
 {
   if (! dir.empty ())
-    do_add (dir, true, warn);
+    do_add (dir, true, warn, is_init);
 }
 
 void
@@ -631,7 +659,8 @@
 }
 
 void
-load_path::do_add (const std::string& dir_arg, bool at_end, bool warn)
+load_path::do_add (const std::string& dir_arg, bool at_end, bool warn,
+                   bool is_init)
 {
   size_t len = dir_arg.length ();
 
@@ -656,6 +685,7 @@
           if (fs.is_dir ())
             {
               dir_info di (dir);
+              di.is_init = is_init;
 
               if (! error_state)
                 {
@@ -2137,7 +2167,7 @@
 directory names separated by @code{pathsep} are also accepted.  For example:\n\
 \n\
 @example\n\
-addpath (\"dir1:/dir2:~/dir3\");\n\
+addpath (\"dir1:/dir2:~/dir3\")\n\
 @end example\n\
 @seealso{path, rmpath, genpath, pathdef, savepath, pathsep}\n\
 @end deftypefn")
@@ -2248,7 +2278,7 @@
 directory names separated by @code{pathsep} are also accepted.  For example:\n\
 \n\
 @example\n\
-rmpath (\"dir1:/dir2:~/dir3\");\n\
+rmpath (\"dir1:/dir2:~/dir3\")\n\
 @end example\n\
 @seealso{path, addpath, genpath, pathdef, savepath, pathsep}\n\
 @end deftypefn")
--- a/src/load-path.h
+++ b/src/load-path.h
@@ -56,7 +56,10 @@
   static void clear (void)
   {
     if (instance_ok ())
-      instance->do_clear ();
+      {
+        std::set<std::string> no_new_elts;
+        instance->do_clear (no_new_elts);
+      }
   }
 
   static void set (const std::string& p, bool warn = false)
@@ -294,14 +297,14 @@
     // constructor for any other purpose.
     dir_info (void)
       : dir_name (), abs_dir_name (), is_relative (false),
-        dir_mtime (), dir_time_last_checked (), all_files (),
-        fcn_files (), private_file_map (), method_file_map ()
+        is_init (false), dir_mtime (), dir_time_last_checked (),
+        all_files (), fcn_files (), private_file_map (), method_file_map ()
       { }
 
     dir_info (const std::string& d)
       : dir_name (d), abs_dir_name (), is_relative (false),
-        dir_mtime (), dir_time_last_checked (), all_files (),
-        fcn_files (), private_file_map (), method_file_map ()
+        is_init (false), dir_mtime (), dir_time_last_checked (),
+        all_files (), fcn_files (), private_file_map (), method_file_map ()
     {
       initialize ();
     }
@@ -309,6 +312,7 @@
     dir_info (const dir_info& di)
       : dir_name (di.dir_name), abs_dir_name (di.abs_dir_name),
         is_relative (di.is_relative),
+        is_init (di.is_init),
         dir_mtime (di.dir_mtime),
         dir_time_last_checked (di.dir_time_last_checked),
         all_files (di.all_files), fcn_files (di.fcn_files),
@@ -324,6 +328,7 @@
           dir_name = di.dir_name;
           abs_dir_name = di.abs_dir_name;
           is_relative = di.is_relative;
+          is_init = di.is_init;
           dir_mtime = di.dir_mtime;
           dir_time_last_checked = di.dir_time_last_checked;
           all_files = di.all_files;
@@ -340,6 +345,7 @@
     std::string dir_name;
     std::string abs_dir_name;
     bool is_relative;
+    bool is_init; //Was this directory set by init? Warn when clearing it.
     octave_time dir_mtime;
     octave_time dir_time_last_checked;
     string_vector all_files;
@@ -471,15 +477,16 @@
 
   void do_initialize (bool set_initial_path);
 
-  void do_clear (void);
+  void do_clear (std::set<std::string>& new_elts);
 
-  void do_set (const std::string& p, bool warn);
+  void do_set (const std::string& p, bool warn, bool is_init=false);
 
-  void do_append (const std::string& dir, bool warn);
+  void do_append (const std::string& dir, bool warn, bool is_init=false);
 
   void do_prepend (const std::string& dir, bool warn);
 
-  void do_add (const std::string& dir, bool at_end, bool warn);
+  void do_add (const std::string& dir, bool at_end, bool warn,
+               bool is_init=false);
 
   void remove_fcn_map (const std::string& dir, const string_vector& fcn_files);
 
--- a/src/load-save.cc
+++ b/src/load-save.cc
@@ -649,7 +649,7 @@
   std::string orig_fname = "";
 
   // Function called with Matlab-style ["filename", options] syntax
-  if (argc > 1 && ! argv[1].empty () && argv[1].at(0) != '-')
+  if (argc > 1 && ! argv[1].empty () && argv[1].at (0) != '-')
     {
       orig_fname = argv[1];
       i++;
@@ -1001,7 +1001,7 @@
     {
       std::string empty_str;
 
-      if (pat.match(m.key (p)))
+      if (pat.match (m.key (p)))
         {
           do_save (os, m.contents (p), m.key (p), empty_str,
                    0, fmt, save_as_floats);
@@ -1532,6 +1532,7 @@
 \n\
 The list of variables to save may use wildcard patterns containing\n\
 the following special characters:\n\
+\n\
 @table @code\n\
 @item ?\n\
 Match any single character.\n\
--- a/src/ls-hdf5.cc
+++ b/src/ls-hdf5.cc
@@ -749,7 +749,7 @@
 int
 load_hdf5_empty (hid_t loc_id, const char *name, dim_vector &d)
 {
-  if (!hdf5_check_attr(loc_id, "OCTAVE_EMPTY_MATRIX"))
+  if (! hdf5_check_attr (loc_id, "OCTAVE_EMPTY_MATRIX"))
     return 0;
 
   hsize_t hdims, maxdims;
@@ -840,7 +840,7 @@
       || val.type_id () == octave_lazy_index::static_type_id ())
     val = val.full_value ();
 
-  std::string t = val.type_name();
+  std::string t = val.type_name ();
 #if HAVE_HDF5_18
   data_id = H5Gcreate (loc_id, name.c_str (), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
 #else
--- a/src/ls-mat4.cc
+++ b/src/ls-mat4.cc
@@ -344,18 +344,18 @@
 
             read_mat_binary_data (is, dtmp, prec, nr, swap, flt_fmt);
             for (octave_idx_type i = 0; i < nr - 1; i++)
-              r.xelem(i) = dtmp[i] - 1;
+              r.xelem (i) = dtmp[i] - 1;
             nr_new = dtmp[nr - 1];
             read_mat_binary_data (is, dtmp, prec, nr, swap, flt_fmt);
             for (octave_idx_type i = 0; i < nr - 1; i++)
-              c.xelem(i) = dtmp[i] - 1;
+              c.xelem (i) = dtmp[i] - 1;
             nc_new = dtmp[nr - 1];
             read_mat_binary_data (is, dtmp, prec, nr - 1, swap, flt_fmt);
             read_mat_binary_data (is, ctmp, prec, 1, swap, flt_fmt);
             read_mat_binary_data (is, ctmp, prec, nr - 1, swap, flt_fmt);
 
             for (octave_idx_type i = 0; i < nr - 1; i++)
-              data.xelem(i) = Complex (dtmp[i], ctmp[i]);
+              data.xelem (i) = Complex (dtmp[i], ctmp[i]);
             read_mat_binary_data (is, ctmp, prec, 1, swap, flt_fmt);
 
             SparseComplexMatrix smc = SparseComplexMatrix (data, r, c,
@@ -373,11 +373,11 @@
 
             read_mat_binary_data (is, dtmp, prec, nr, swap, flt_fmt);
             for (octave_idx_type i = 0; i < nr - 1; i++)
-              r.xelem(i) = dtmp[i] - 1;
+              r.xelem (i) = dtmp[i] - 1;
             nr_new = dtmp[nr - 1];
             read_mat_binary_data (is, dtmp, prec, nr, swap, flt_fmt);
             for (octave_idx_type i = 0; i < nr - 1; i++)
-              c.xelem(i) = dtmp[i] - 1;
+              c.xelem (i) = dtmp[i] - 1;
             nc_new = dtmp[nr - 1];
             read_mat_binary_data (is, data.fortran_vec (), prec, nr - 1, swap, flt_fmt);
             read_mat_binary_data (is, dtmp, prec, 1, swap, flt_fmt);
@@ -509,7 +509,7 @@
           for (octave_idx_type j = 0; j < ncol; j++)
             buf[j*nrow+i] = static_cast<double> (*s++ & 0x00FF);
         }
-      os.write (reinterpret_cast<char *> (buf), nrow*ncol*sizeof(double));
+      os.write (reinterpret_cast<char *> (buf), nrow*ncol*sizeof (double));
     }
   else if (tc.is_range ())
     {
@@ -537,27 +537,27 @@
           SparseComplexMatrix m = tc.sparse_complex_matrix_value ();
 
           for (octave_idx_type i = 0; i < len; i++)
-            dtmp [i] = m.ridx(i) + 1;
+            dtmp[i] = m.ridx (i) + 1;
           os.write (reinterpret_cast<const char *> (dtmp), 8 * len);
           ds = nr;
           os.write (reinterpret_cast<const char *> (&ds), 8);
 
           octave_idx_type ii = 0;
           for (octave_idx_type j = 0; j < nc; j++)
-            for (octave_idx_type i = m.cidx(j); i < m.cidx(j+1); i++)
+            for (octave_idx_type i = m.cidx (j); i < m.cidx (j+1); i++)
               dtmp[ii++] = j + 1;
           os.write (reinterpret_cast<const char *> (dtmp), 8 * len);
           ds = nc;
           os.write (reinterpret_cast<const char *> (&ds), 8);
 
           for (octave_idx_type i = 0; i < len; i++)
-            dtmp [i] = std::real (m.data(i));
+            dtmp[i] = std::real (m.data (i));
           os.write (reinterpret_cast<const char *> (dtmp), 8 * len);
           ds = 0.;
           os.write (reinterpret_cast<const char *> (&ds), 8);
 
           for (octave_idx_type i = 0; i < len; i++)
-            dtmp [i] = std::imag (m.data(i));
+            dtmp[i] = std::imag (m.data (i));
           os.write (reinterpret_cast<const char *> (dtmp), 8 * len);
           os.write (reinterpret_cast<const char *> (&ds), 8);
         }
@@ -566,14 +566,14 @@
           SparseMatrix m = tc.sparse_matrix_value ();
 
           for (octave_idx_type i = 0; i < len; i++)
-            dtmp [i] = m.ridx(i) + 1;
+            dtmp[i] = m.ridx (i) + 1;
           os.write (reinterpret_cast<const char *> (dtmp), 8 * len);
           ds = nr;
           os.write (reinterpret_cast<const char *> (&ds), 8);
 
           octave_idx_type ii = 0;
           for (octave_idx_type j = 0; j < nc; j++)
-            for (octave_idx_type i = m.cidx(j); i < m.cidx(j+1); i++)
+            for (octave_idx_type i = m.cidx (j); i < m.cidx (j+1); i++)
               dtmp[ii++] = j + 1;
           os.write (reinterpret_cast<const char *> (dtmp), 8 * len);
           ds = nc;
--- a/src/ls-mat5.cc
+++ b/src/ls-mat5.cc
@@ -667,7 +667,7 @@
   else
     {
       // Why did mathworks decide to not have dims for a workspace!!!
-      dims.resize(2);
+      dims.resize (2);
       dims(0) = 1;
       dims(1) = 1;
     }
@@ -863,24 +863,24 @@
         // Octave can handle both "/" and "\" as a directry seperator
         // and so can ignore the seperator field of m0. I think the
         // sentinel field is also save to ignore.
-        Octave_map m0 = tc2.map_value();
-        Octave_map m1 = m0.contents("function_handle")(0).map_value();
-        std::string ftype = m1.contents("type")(0).string_value();
-        std::string fname = m1.contents("function")(0).string_value();
-        std::string fpath = m1.contents("file")(0).string_value();
+        Octave_map m0 = tc2.map_value ();
+        Octave_map m1 = m0.contents ("function_handle")(0).map_value ();
+        std::string ftype = m1.contents ("type")(0).string_value ();
+        std::string fname = m1.contents ("function")(0).string_value ();
+        std::string fpath = m1.contents ("file")(0).string_value ();
 
         if (ftype == "simple" || ftype == "scopedfunction")
           {
-            if (fpath.length() == 0)
+            if (fpath.length () == 0)
               // We have a builtin function
               tc = make_fcn_handle (fname);
             else
               {
                 std::string mroot =
-                  m0.contents("matlabroot")(0).string_value();
+                  m0.contents ("matlabroot")(0).string_value ();
 
                 if ((fpath.length () >= mroot.length ()) &&
-                    fpath.substr(0, mroot.length()) == mroot &&
+                    fpath.substr (0, mroot.length ()) == mroot &&
                     OCTAVE_EXEC_PREFIX != mroot)
                   {
                     // If fpath starts with matlabroot, and matlabroot
@@ -942,7 +942,7 @@
                         else
                           {
                             warning ("load: can't find the file %s",
-                                     fpath.c_str());
+                                     fpath.c_str ());
                             goto skip_ahead;
                           }
                       }
@@ -966,7 +966,7 @@
                     else
                       {
                         warning ("load: can't find the file %s",
-                                 fpath.c_str());
+                                 fpath.c_str ());
                         goto skip_ahead;
                       }
                   }
@@ -979,13 +979,13 @@
           }
         else if (ftype == "anonymous")
           {
-            Octave_map m2 = m1.contents("workspace")(0).map_value();
-            uint32NDArray MCOS = m2.contents("MCOS")(0).uint32_array_value();
+            Octave_map m2 = m1.contents ("workspace")(0).map_value ();
+            uint32NDArray MCOS = m2.contents ("MCOS")(0).uint32_array_value ();
             octave_idx_type off = static_cast<octave_idx_type>(MCOS(4).double_value ());
-            m2 = subsys_ov.map_value();
-            m2 = m2.contents("MCOS")(0).map_value();
-            tc2 = m2.contents("MCOS")(0).cell_value()(1 + off).cell_value()(1);
-            m2 = tc2.map_value();
+            m2 = subsys_ov.map_value ();
+            m2 = m2.contents ("MCOS")(0).map_value ();
+            tc2 = m2.contents ("MCOS")(0).cell_value ()(1 + off).cell_value ()(1);
+            m2 = tc2.map_value ();
 
             unwind_protect_safe frame;
 
@@ -1000,15 +1000,15 @@
             octave_call_stack::push (local_scope, 0);
             frame.add_fcn (octave_call_stack::pop);
 
-            if (m2.nfields() > 0)
+            if (m2.nfields () > 0)
               {
                 octave_value tmp;
 
-                for (Octave_map::iterator p0 = m2.begin() ;
-                     p0 != m2.end(); p0++)
+                for (Octave_map::iterator p0 = m2.begin () ;
+                     p0 != m2.end (); p0++)
                   {
-                    std::string key = m2.key(p0);
-                    octave_value val = m2.contents(p0)(0);
+                    std::string key = m2.key (p0);
+                    octave_value val = m2.contents (p0)(0);
 
                     symbol_table::varref (key, local_scope, 0) = val;
                   }
@@ -1219,8 +1219,8 @@
                 // inline is not an object in Octave but rather an
                 // overload of a function handle. Special case.
                 tc =
-                  new octave_fcn_inline (m.contents("expr")(0).string_value(),
-                                         m.contents("args")(0).string_value());
+                  new octave_fcn_inline (m.contents ("expr")(0).string_value (),
+                                         m.contents ("args")(0).string_value ());
               }
             else
               {
@@ -1236,7 +1236,7 @@
 
                     tc = cls;
                     if (load_path::find_method (classname, "loadobj") !=
-                        std::string())
+                        std::string ())
                       {
                         octave_value_list tmp = feval ("loadobj", tc, 1);
 
@@ -1277,7 +1277,7 @@
             boolNDArray out (dims);
 
             for (octave_idx_type i = 0; i < nel; i++)
-              out (i) = in(i).bool_value ();
+              out(i) = in(i).bool_value ();
 
             tc = out;
           }
@@ -1563,7 +1563,7 @@
 
       if (tc.is_uint8_type ())
         {
-          const uint8NDArray itmp = tc.uint8_array_value();
+          const uint8NDArray itmp = tc.uint8_array_value ();
           octave_idx_type ilen = itmp.numel ();
 
           // Why should I have to initialize outbuf as just overwrite
@@ -2620,11 +2620,11 @@
           write_mat5_array (os, ::imag (m_cmplx), save_as_floats);
         }
     }
-  else if (tc.is_map () || tc.is_inline_function() || tc.is_object ())
+  else if (tc.is_map () || tc.is_inline_function () || tc.is_object ())
     {
       if (tc.is_inline_function () || tc.is_object ())
         {
-          std::string classname = tc.is_object() ? tc.class_name () : "inline";
+          std::string classname = tc.is_object () ? tc.class_name () : "inline";
           size_t namelen = classname.length ();
 
           if (namelen > max_namelen)
@@ -2642,7 +2642,7 @@
       Octave_map m;
 
       if (tc.is_object () &&
-          load_path::find_method (tc.class_name (), "saveobj") != std::string())
+          load_path::find_method (tc.class_name (), "saveobj") != std::string ())
         {
           octave_value_list tmp = feval ("saveobj", tc, 1);
           if (! error_state)
--- a/src/ls-mat5.h
+++ b/src/ls-mat5.h
@@ -48,7 +48,7 @@
 extern int
 read_mat5_binary_file_header (std::istream& is, bool& swap,
                               bool quiet = false,
-                              const std::string& filename = std::string());
+                              const std::string& filename = std::string ());
 extern std::string
 read_mat5_binary_element (std::istream& is, const std::string& filename,
                           bool swap, bool& global, octave_value& tc);
--- a/src/ls-oct-ascii.cc
+++ b/src/ls-oct-ascii.cc
@@ -110,7 +110,7 @@
               while (is.get (c) && (c == ' ' || c == '\t' || c == ':'))
                 ; // Skip whitespace and the colon.
 
-              is.putback(c);
+              is.putback (c);
               retval = read_until_newline (is, false);
               break;
             }
@@ -323,7 +323,7 @@
   if (mark_as_global)
     os << "# type: global " << val.type_name () << "\n";
   else
-    os << "# type: " << val.type_name() << "\n";
+    os << "# type: " << val.type_name () << "\n";
 
   if (! precision)
     precision = Vsave_precision;
--- a/src/ls-oct-ascii.h
+++ b/src/ls-oct-ascii.h
@@ -74,7 +74,7 @@
                  const bool next_only = false)
 {
   bool status = false;
-  value = T();
+  value = T ();
 
   char c;
   while (is.get (c))
--- a/src/mappers.cc
+++ b/src/mappers.cc
@@ -112,7 +112,7 @@
 %!test
 %! x = single ([1, rt3/2, rt2/2, 1/2, 0, -1/2, -rt2/2, -rt3/2, -1]);
 %! v = single ([0, pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6, pi]);
-%! assert (acos (x), v, sqrt (eps ('single')));
+%! assert (acos (x), v, sqrt (eps ("single")));
 
 %!error acos ()
 %!error acos (1, 2)
@@ -143,7 +143,7 @@
 %!test
 %! x = single ([1, 0, -1, 0]);
 %! v = single ([0, pi/2*i, pi*i, pi/2*i]);
-%! assert (acosh (x), v, sqrt (eps ('single')));
+%! assert (acosh (x), v, sqrt (eps ("single")));
 
 %!error acosh ()
 %!error acosh (1, 2)
@@ -213,7 +213,7 @@
 %!   assert (arg (single (-1)), single (pi));
 %! endif
 %!assert (arg (single (-i)), single (-pi/2))
-%!assert (arg (single ([1, i; -1, -i])), single ([0, pi/2; pi, -pi/2]), 2e1*eps ('single'))
+%!assert (arg (single ([1, i; -1, -i])), single ([0, pi/2; pi, -pi/2]), 2e1*eps ("single"))
 
 %!error arg ()
 %!error arg (1, 2)
@@ -272,7 +272,7 @@
 %!test
 %! v = single ([0, pi/2*i, 0, -pi/2*i]);
 %! x = single ([0, i, 0, -i]);
-%! assert (asinh (x), v,  sqrt (eps ('single')));
+%! assert (asinh (x), v,  sqrt (eps ("single")));
 
 %!error asinh ()
 %!error asinh (1, 2)
@@ -307,7 +307,7 @@
 %!test
 %! v = single ([0, pi/6, pi/4, pi/3, -pi/3, -pi/4, -pi/6, 0]);
 %! x = single ([0, rt3/3, 1, rt3, -rt3, -1, -rt3/3, 0]);
-%! assert (atan (x), v, sqrt (eps ('single')));
+%! assert (atan (x), v, sqrt (eps ("single")));
 
 %!error atan ()
 %!error atan (1, 2)
@@ -338,7 +338,7 @@
 %!test
 %! v = single ([0, 0]);
 %! x = single ([0, 0]);
-%! assert (atanh (x), v, sqrt (eps ('single')));
+%! assert (atanh (x), v, sqrt (eps ("single")));
 
 %!error atanh ()
 %!error atanh (1, 2)
@@ -386,7 +386,7 @@
 @example\n\
 @group\n\
 ceil ([-2.7, 2.7])\n\
-   @result{}  -2   3\n\
+    @result{} -2    3\n\
 @end group\n\
 @end example\n\
 @seealso{floor, round, fix}\n\
@@ -402,16 +402,16 @@
 }
 
 /*
-%% double precision
+## double precision
 %!assert (ceil ([2, 1.1, -1.1, -1]), [2, 2, -1, -1])
 
-%% complex double precison
+## complex double precison
 %!assert (ceil ([2+2i, 1.1+1.1i, -1.1-1.1i, -1-i]), [2+2i, 2+2i, -1-i, -1-i])
 
-%% single precision
+## single precision
 %!assert (ceil (single ([2, 1.1, -1.1, -1])), single ([2, 2, -1, -1]))
 
-%% complex single precision
+## complex single precision
 %!assert (ceil (single ([2+2i, 1.1+1.1i, -1.1-1.1i, -1-i])), single ([2+2i, 2+2i, -1-i, -1-i]))
 
 %!error ceil ()
@@ -488,7 +488,7 @@
 %! rt3 = sqrt (3);
 %! x = single ([0, pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6, pi]);
 %! v = single ([1, rt3/2, rt2/2, 1/2, 0, -1/2, -rt2/2, -rt3/2, -1]);
-%! assert (cos (x), v, sqrt (eps ('single')));
+%! assert (cos (x), v, sqrt (eps ("single")));
 
 %!error cos ()
 %!error cos (1, 2)
@@ -519,7 +519,7 @@
 %!test
 %! x = single ([0, pi/2*i, pi*i, 3*pi/2*i]);
 %! v = single ([1, 0, -1, 0]);
-%! assert (cosh (x), v, sqrt (eps ('single')));
+%! assert (cosh (x), v, sqrt (eps ("single")));
 
 %!error cosh ()
 %!error cosh (1, 2)
@@ -538,17 +538,16 @@
 \n\
 @example\n\
 @group\n\
-@c spacing appears odd here, but is correct after Makeinfo\n\
-                          z\n\
-                         /\n\
-erf (z) = (2/sqrt (pi)) | e^(-t^2) dt\n\
-                         /\n\
-                      t=0\n\
+                        z\n\
+              2        /\n\
+erf (z) = --------- *  | e^(-t^2) dt\n\
+          sqrt (pi)    /\n\
+                    t=0\n\
 @end group\n\
 @end example\n\
 \n\
 @end ifnottex\n\
-@seealso{erfc, erfcx, erfinv}\n\
+@seealso{erfc, erfcx, erfinv, erfcinv}\n\
 @end deftypefn")
 {
   octave_value retval;
@@ -568,10 +567,10 @@
 %!test
 %! x = [0,.5,1];
 %! v = [0, .520499877813047, .842700792949715];
-%! assert (all (abs (erf (x)-v) < 1.e-10));
-%! assert (all (abs (erf (-x)+v) < 1.e-10));
-%! assert (all (abs (erfc (x)+v-1) < 1.e-10));
-%! assert (all (abs (erfinv (v)-x) < 1.e-10));
+%! assert (erf (x), v, 1.e-10);
+%! assert (erf (-x), -v, 1.e-10);
+%! assert (erfc (x), 1-v, 1.e-10);
+%! assert (erfinv (v), x, 1.e-10);
 
 %!test
 %! a = -1i*sqrt (single (-1/(6.4187*6.4187)));
@@ -580,10 +579,10 @@
 %!test
 %! x = single ([0,.5,1]);
 %! v = single ([0, .520499877813047, .842700792949715]);
-%! assert (all (abs (erf (x)-v) < 1.e-6));
-%! assert (all (abs (erf (-x)+v) < 1.e-6));
-%! assert (all (abs (erfc (x)+v-1) < 1.e-6));
-%! assert (all (abs (erfinv (v)-x) < 1.e-6));
+%! assert (erf (x), v, 1.e-6);
+%! assert (erf (-x), -v, 1.e-6);
+%! assert (erfc (x), 1-v, 1.e-6);
+%! assert (erfinv (v), x, 1.e-6);
 
 %!error erf ()
 %!error erf (1, 2)
@@ -595,9 +594,9 @@
 Compute the inverse error function, i.e., @var{y} such that\n\
 \n\
 @example\n\
-  erf (@var{y}) == @var{x}\n\
+erf (@var{y}) == @var{x}\n\
 @end example\n\
-@seealso{erf, erfc, erfcx}\n\
+@seealso{erf, erfc, erfcx, erfcinv}\n\
 @end deftypefn")
 {
   octave_value retval;
@@ -610,16 +609,16 @@
 }
 
 /*
-%% middle region
+## middle region
 %!assert (erf (erfinv ([-0.9 -0.3 0 0.4 0.8])), [-0.9 -0.3 0 0.4 0.8], eps)
-%!assert (erf (erfinv (single ([-0.9 -0.3 0 0.4 0.8]))), single ([-0.9 -0.3 0 0.4 0.8]), 1e-8)
-%% tail region
+%!assert (erf (erfinv (single ([-0.9 -0.3 0 0.4 0.8]))), single ([-0.9 -0.3 0 0.4 0.8]), eps ("single"))
+## tail region
 %!assert (erf (erfinv ([-0.999 -0.99 0.9999 0.99999])), [-0.999 -0.99 0.9999 0.99999], eps)
-%!assert (erf (erfinv (single ([-0.999 -0.99 0.9999 0.99999]))), single ([-0.999 -0.99 0.9999 0.99999]), 1e-8)
-%% backward - loss of accuracy
+%!assert (erf (erfinv (single ([-0.999 -0.99 0.9999 0.99999]))), single ([-0.999 -0.99 0.9999 0.99999]), eps ("single"))
+## backward - loss of accuracy
 %!assert (erfinv (erf ([-3 -1 -0.4 0.7 1.3 2.8])), [-3 -1 -0.4 0.7 1.3 2.8], -1e-12)
 %!assert (erfinv (erf (single ([-3 -1 -0.4 0.7 1.3 2.8]))), single ([-3 -1 -0.4 0.7 1.3 2.8]), -1e-4)
-%% exceptional
+## exceptional
 %!assert (erfinv ([-1, 1, 1.1, -2.1]), [-Inf, Inf, NaN, NaN])
 %!error erfinv (1+2i)
 
@@ -627,6 +626,44 @@
 %!error erfinv (1, 2)
 */
 
+DEFUN (erfcinv, args, ,
+    "-*- texinfo -*-\n\
+@deftypefn {Mapping Function} {} erfcinv (@var{x})\n\
+Compute the inverse complementary error function, i.e., @var{y} such that\n\
+\n\
+@example\n\
+erfc (@var{y}) == @var{x}\n\
+@end example\n\
+@seealso{erfc, erf, erfcx, erfinv}\n\
+@end deftypefn")
+{
+  octave_value retval;
+  if (args.length () == 1)
+    retval = args(0).erfcinv ();
+  else
+    print_usage ();
+
+  return retval;
+}
+
+/*
+## middle region
+%!assert (erfc (erfcinv ([1.9 1.3 1 0.6 0.2])), [1.9 1.3 1 0.6 0.2], eps)
+%!assert (erfc (erfcinv (single ([1.9 1.3 1 0.6 0.2]))), single ([1.9 1.3 1 0.6 0.2]), eps ("single"))
+## tail region
+%!assert (erfc (erfcinv ([0.001 0.01 1.9999 1.99999])), [0.001 0.01 1.9999 1.99999], eps)
+%!assert (erfc (erfcinv (single ([0.001 0.01 1.9999 1.99999]))), single ([0.001 0.01 1.9999 1.99999]), eps ("single"))
+## backward - loss of accuracy
+%!assert (erfcinv (erfc ([-3 -1 -0.4 0.7 1.3 2.8])), [-3 -1 -0.4 0.7 1.3 2.8], -1e-12)
+%!assert (erfcinv (erfc (single ([-3 -1 -0.4 0.7 1.3 2.8]))), single ([-3 -1 -0.4 0.7 1.3 2.8]), -1e-4)
+## exceptional
+%!assert (erfcinv ([2, 0, -0.1, 2.1]), [-Inf, Inf, NaN, NaN])
+%!error erfcinv (1+2i)
+
+%!error erfcinv ()
+%!error erfcinv (1, 2)
+*/
+
 DEFUN (erfc, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} erfc (@var{z})\n\
@@ -637,7 +674,7 @@
 @ifnottex\n\
 @w{@code{1 - erf (@var{z})}}.\n\
 @end ifnottex\n\
-@seealso{erfcx, erf, erfinv}\n\
+@seealso{erfcinv, erfcx, erf, erfinv}\n\
 @end deftypefn")
 {
   octave_value retval;
@@ -674,7 +711,7 @@
 @end example\n\
 \n\
 @end ifnottex\n\
-@seealso{erfc, erf, erfinv}\n\
+@seealso{erfc, erf, erfinv, erfcinv}\n\
 @end deftypefn")
 {
   octave_value retval;
@@ -687,7 +724,7 @@
 }
 
 /*
-%% FIXME: Need a test for erfcx
+## FIXME: Need a test for erfcx
 
 %!error erfcx ()
 %!error erfcx (1, 2)
@@ -720,8 +757,8 @@
 /*
 %!assert (exp ([0, 1, -1, -1000]), [1, e, 1/e, 0], sqrt (eps))
 %!assert (exp (1+i), e * (cos (1) + sin (1) * i), sqrt (eps))
-%!assert (exp (single ([0, 1, -1, -1000])), single ([1, e, 1/e, 0]), sqrt (eps ('single')))
-%!assert (exp (single (1+i)), single (e * (cos (1) + sin (1) * i)), sqrt (eps ('single')))
+%!assert (exp (single ([0, 1, -1, -1000])), single ([1, e, 1/e, 0]), sqrt (eps ("single")))
+%!assert (exp (single (1+i)), single (e * (cos (1) + sin (1) * i)), sqrt (eps ("single")))
 
 %!assert (exp ([Inf, -Inf, NaN]), [Inf 0 NaN])
 %!assert (exp (single ([Inf, -Inf, NaN])), single ([Inf 0 NaN]))
@@ -812,7 +849,7 @@
 @example\n\
 @group\n\
 fix ([-2.7, 2.7])\n\
-   @result{} -2   2\n\
+   @result{} -2    2\n\
 @end group\n\
 @end example\n\
 @seealso{ceil, floor, round}\n\
@@ -847,7 +884,7 @@
 @example\n\
 @group\n\
 floor ([-2.7, 2.7])\n\
-     @result{} -3   2\n\
+     @result{} -3    2\n\
 @end group\n\
 @end example\n\
 @seealso{ceil, round, fix}\n\
@@ -885,12 +922,11 @@
 \n\
 @example\n\
 @group\n\
-@c spacing appears odd here, but is correct after Makeinfo\n\
-              infinity\n\
-             /\n\
+             infinity\n\
+            /\n\
 gamma (z) = | t^(z-1) exp (-t) dt.\n\
-             /\n\
-          t=0\n\
+            /\n\
+         t=0\n\
 @end group\n\
 @end example\n\
 \n\
@@ -924,7 +960,7 @@
 %!test
 %! x = single ([.5, 1, 1.5, 2, 3, 4, 5]);
 %! v = single ([sqrt(pi), 1, .5*sqrt(pi), 1, 2, 6, 24]);
-%! assert (gamma (x), v, sqrt (eps ('single')));
+%! assert (gamma (x), v, sqrt (eps ("single")));
 
 %!test
 %! x = [-1, 0, 1, Inf];
@@ -961,7 +997,7 @@
 %!assert (imag (single (1)), single (0))
 %!assert (imag (single (i)), single (1))
 %!assert (imag (single (1+i)), single (1))
-%!assert (imag (single ([i, 1; 1, i])), full (eye (2,'single')))
+%!assert (imag (single ([i, 1; 1, i])), full (eye (2,"single")))
 
 %!error imag ()
 %!error imag (1, 2)
@@ -992,7 +1028,7 @@
 %! result(toascii ("A":"Z") + 1) = true;
 %! result(toascii ("0":"9") + 1) = true;
 %! result(toascii ("a":"z") + 1) = true;
-%! assert (all (isalnum (charset) == result));
+%! assert (isalnum (charset), result);
 
 %!error isalnum ()
 %!error isalnum (1, 2)
@@ -1022,7 +1058,7 @@
 %! result = false (1, 128);
 %! result(toascii ("A":"Z") + 1) = true;
 %! result(toascii ("a":"z") + 1) = true;
-%! assert (all (isalpha (charset) == result));
+%! assert (isalpha (charset), result);
 
 %!error isalpha ()
 %!error isalpha (1, 2)
@@ -1049,7 +1085,7 @@
 %!test
 %! charset = char (0:127);
 %! result = true (1, 128);
-%! assert (all (isascii (charset) == result));
+%! assert (isascii (charset), result);
 
 %!error isascii ()
 %!error isascii (1, 2)
@@ -1078,7 +1114,7 @@
 %! result = false (1, 128);
 %! result(1:32) = true;
 %! result(128) = true;
-%! assert (all (iscntrl (charset) == result));
+%! assert (iscntrl (charset), result);
 
 %!error iscntrl ()
 %!error iscntrl (1, 2)
@@ -1106,7 +1142,7 @@
 %! charset = char (0:127);
 %! result = false (1, 128);
 %! result(toascii ("0":"9") + 1) = true;
-%! assert (all (isdigit (charset) == result));
+%! assert (isdigit (charset), result);
 
 %!error isdigit ()
 %!error isdigit (1, 2)
@@ -1122,7 +1158,7 @@
 @example\n\
 @group\n\
 isinf ([13, Inf, NA, NaN])\n\
-     @result{} [ 0, 1, 0, 0 ]\n\
+      @result{} [ 0, 1, 0, 0 ]\n\
 @end group\n\
 @end example\n\
 @seealso{isfinite, isnan, isna}\n\
@@ -1141,13 +1177,13 @@
 %!assert (isinf (Inf))
 %!assert (!isinf (NaN))
 %!assert (!isinf (NA))
-%!assert (isinf (rand(1,10)), false (1,10))
+%!assert (isinf (rand (1,10)), false (1,10))
 %!assert (isinf ([NaN -Inf -1 0 1 Inf NA]), [false, true, false, false, false, true, false])
 
 %!assert (isinf (single (Inf)))
 %!assert (!isinf (single (NaN)))
 %!assert (!isinf (single (NA)))
-%!assert (isinf (single (rand(1,10))), false (1,10))
+%!assert (isinf (single (rand (1,10))), false (1,10))
 %!assert (isinf (single ([NaN -Inf -1 0 1 Inf NA])), [false, true, false, false, false, true, false])
 
 %!error isinf ()
@@ -1177,7 +1213,7 @@
 %! charset = char (0:127);
 %! result = false (1, 128);
 %! result(34:127) = true;
-%! assert (all (isgraph (charset) == result));
+%! assert (isgraph (charset), result);
 
 %!error isgraph ()
 %!error isgraph (1, 2)
@@ -1205,7 +1241,7 @@
 %! charset = char (0:127);
 %! result = false (1, 128);
 %! result(toascii ("a":"z") + 1) = true;
-%! assert (all (islower (charset) == result));
+%! assert (islower (charset), result);
 
 %!error islower ()
 %!error islower (1, 2)
@@ -1240,13 +1276,13 @@
 %!assert (!isna (Inf))
 %!assert (!isna (NaN))
 %!assert (isna (NA))
-%!assert (isna (rand(1,10)), false (1,10))
+%!assert (isna (rand (1,10)), false (1,10))
 %!assert (isna ([NaN -Inf -1 0 1 Inf NA]), [false, false, false, false, false, false, true])
 
 %!assert (!isna (single (Inf)))
 %!assert (!isna (single (NaN)))
 %!assert (isna (single (NA)))
-%!assert (isna (single (rand(1,10))), false (1,10))
+%!assert (isna (single (rand (1,10))), false (1,10))
 %!assert (isna (single ([NaN -Inf -1 0 1 Inf NA])), [false, false, false, false, false, false, true])
 
 %!error isna ()
@@ -1263,7 +1299,7 @@
 @example\n\
 @group\n\
 isnan ([13, Inf, NA, NaN])\n\
-     @result{} [ 0, 0, 1, 1 ]\n\
+      @result{} [ 0, 0, 1, 1 ]\n\
 @end group\n\
 @end example\n\
 @seealso{isna, isinf, isfinite}\n\
@@ -1282,13 +1318,13 @@
 %!assert (!isnan (Inf))
 %!assert (isnan (NaN))
 %!assert (isnan (NA))
-%!assert (isnan (rand(1,10)), false (1,10))
+%!assert (isnan (rand (1,10)), false (1,10))
 %!assert (isnan ([NaN -Inf -1 0 1 Inf NA]), [true, false, false, false, false, false, true])
 
 %!assert (!isnan (single (Inf)))
 %!assert (isnan (single (NaN)))
 %!assert (isnan (single (NA)))
-%!assert (isnan (single (rand(1,10))), false (1,10))
+%!assert (isnan (single (rand (1,10))), false (1,10))
 %!assert (isnan (single ([NaN -Inf -1 0 1 Inf NA])), [true, false, false, false, false, false, true])
 
 %!error isnan ()
@@ -1318,7 +1354,7 @@
 %! charset = char (0:127);
 %! result = false (1, 128);
 %! result(33:127) = true;
-%! assert (all (isprint (charset) == result));
+%! assert (isprint (charset), result);
 
 %!error isprint ()
 %!error isprint (1, 2)
@@ -1349,7 +1385,7 @@
 %! result(59:65) = true;
 %! result(92:97) = true;
 %! result(124:127) = true;
-%! assert (all (ispunct (charset) == result));
+%! assert (ispunct (charset), result);
 
 %!error ispunct ()
 %!error ispunct (1, 2)
@@ -1378,7 +1414,7 @@
 %! charset = char (0:127);
 %! result = false (1, 128);
 %! result(toascii (" \f\n\r\t\v") + 1) = true;
-%! assert (all (isspace (charset) == result));
+%! assert (isspace (charset), result);
 
 %!error isspace ()
 %!error isspace (1, 2)
@@ -1406,7 +1442,7 @@
 %! charset = char (0:127);
 %! result = false (1, 128);
 %! result(toascii ("A":"Z") + 1) = true;
-%! assert (all (isupper (charset) == result));
+%! assert (isupper (charset), result);
 
 %!error isupper ()
 %!error isupper (1, 2)
@@ -1436,7 +1472,7 @@
 %! result(toascii ("A":"F") + 1) = true;
 %! result(toascii ("0":"9") + 1) = true;
 %! result(toascii ("a":"f") + 1) = true;
-%! assert (all (isxdigit (charset) == result));
+%! assert (isxdigit (charset), result);
 
 %!error isxdigit ()
 %!error isxdigit (1, 2)
@@ -1462,30 +1498,30 @@
 /*
 %!test
 %! a = -1i*sqrt (-1/(6.4187*6.4187));
-%! assert (lgamma(a), lgamma(real(a)));
+%! assert (lgamma (a), lgamma (real (a)));
 
 %!test
 %! x = [.5, 1, 1.5, 2, 3, 4, 5];
 %! v = [sqrt(pi), 1, .5*sqrt(pi), 1, 2, 6, 24];
-%! assert (lgamma(x), log(v), sqrt (eps))
+%! assert (lgamma (x), log (v), sqrt (eps))
 
 %!test
 %! a = single (-1i*sqrt (-1/(6.4187*6.4187)));
-%! assert (lgamma(a), lgamma(real(a)));
+%! assert (lgamma (a), lgamma (real (a)));
 
 %!test
 %! x = single ([.5, 1, 1.5, 2, 3, 4, 5]);
 %! v = single ([sqrt(pi), 1, .5*sqrt(pi), 1, 2, 6, 24]);
-%! assert (lgamma(x), log(v), sqrt (eps ('single')))
+%! assert (lgamma (x), log (v), sqrt (eps ("single")))
 
 %!test
 %! x = [-1, 0, 1, Inf];
 %! v = [Inf, Inf, 0, Inf];
-%! assert (lgamma(x), v);
-%! assert (lgamma(single (x)), single (v));
+%! assert (lgamma (x), v);
+%! assert (lgamma (single (x)), single (v));
 
-%!error lgamma()
-%!error lgamma(1,2)
+%!error lgamma ()
+%!error lgamma (1,2)
 */
 
 DEFUN (log, args, ,
@@ -1514,10 +1550,10 @@
 
 /*
 %!assert (log ([1, e, e^2]), [0, 1, 2], sqrt (eps))
-%!assert (log ([-0.5, -1.5, -2.5]), log([0.5, 1.5, 2.5]) + pi*1i, sqrt (eps))
+%!assert (log ([-0.5, -1.5, -2.5]), log ([0.5, 1.5, 2.5]) + pi*1i, sqrt (eps))
 
-%!assert (log (single ([1, e, e^2])), single ([0, 1, 2]), sqrt (eps ('single')))
-%!assert (log (single ([-0.5, -1.5, -2.5])), single (log([0.5, 1.5, 2.5]) + pi*1i), 4*eps ('single'))
+%!assert (log (single ([1, e, e^2])), single ([0, 1, 2]), sqrt (eps ("single")))
+%!assert (log (single ([-0.5, -1.5, -2.5])), single (log ([0.5, 1.5, 2.5]) + pi*1i), 4*eps ("single"))
 
 %!error log ()
 %!error log (1, 2)
@@ -1541,7 +1577,7 @@
 
 /*
 %!assert (log10 ([0.01, 0.1, 1, 10, 100]), [-2, -1, 0, 1, 2], sqrt (eps))
-%!assert (log10 (single ([0.01, 0.1, 1, 10, 100])), single ([-2, -1, 0, 1, 2]), sqrt (eps ('single')))
+%!assert (log10 (single ([0.01, 0.1, 1, 10, 100])), single ([-2, -1, 0, 1, 2]), sqrt (eps ("single")))
 
 %!error log10 ()
 %!error log10 (1, 2)
@@ -1572,7 +1608,7 @@
 
 /*
 %!assert (log1p ([0, 2*eps, -2*eps]), [0, 2*eps, -2*eps], 1e-29)
-%!assert (log1p (single ([0, 2*eps, -2*eps])), single([0, 2*eps, -2*eps]), 1e-29)
+%!assert (log1p (single ([0, 2*eps, -2*eps])), single ([0, 2*eps, -2*eps]), 1e-29)
 
 %!error log1p ()
 %!error log1p (1, 2)
@@ -1603,7 +1639,7 @@
 %!assert (real (single (1)), single (1))
 %!assert (real (single (i)), single (0))
 %!assert (real (single (1+i)), single (1))
-%!assert (real (single ([1, i; i, 1])), full (eye (2,'single')))
+%!assert (real (single ([1, i; i, 1])), full (eye (2,"single")))
 
 %!error real ()
 %!error real (1, 2)
@@ -1619,7 +1655,7 @@
 @example\n\
 @group\n\
 round ([-2.7, 2.7])\n\
-     @result{} -3   3\n\
+     @result{} -3    3\n\
 @end group\n\
 @end example\n\
 @seealso{ceil, floor, fix, roundb}\n\
@@ -1773,7 +1809,7 @@
 %!test
 %! x = single ([0, pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6, pi]);
 %! v = single ([0, 1/2, rt2/2, rt3/2, 1, rt3/2, rt2/2, 1/2, 0]);
-%! assert (sin (x), v, sqrt (eps ('single')));
+%! assert (sin (x), v, sqrt (eps ("single")));
 
 %!error sin ()
 %!error sin (1, 2)
@@ -1804,7 +1840,7 @@
 %!test
 %! x = single ([0, pi/2*i, pi*i, 3*pi/2*i]);
 %! v = single ([0, i, 0, -i]);
-%! assert (sinh (x), v, sqrt (eps ('single')));
+%! assert (sinh (x), v, sqrt (eps ("single")));
 
 %!error sinh ()
 %!error sinh (1, 2)
@@ -1836,8 +1872,8 @@
 
 %!assert (sqrt (single (4)), single (2))
 %!assert (sqrt (single (-1)), single (i))
-%!assert (sqrt (single (1+i)), single (exp (0.5 * log (1+i))), sqrt (eps ('single')))
-%!assert (sqrt (single ([4, -4; i, 1-i])), single ([2, 2i; exp(0.5 * log (i)), exp(0.5 * log (1-i))]), sqrt (eps ('single')))
+%!assert (sqrt (single (1+i)), single (exp (0.5 * log (1+i))), sqrt (eps ("single")))
+%!assert (sqrt (single ([4, -4; i, 1-i])), single ([2, 2i; exp(0.5 * log (i)), exp(0.5 * log (1-i))]), sqrt (eps ("single")))
 
 %!error sqrt ()
 %!error sqrt (1, 2)
@@ -1872,7 +1908,7 @@
 %!test
 %! x = single ([0, pi/6, pi/4, pi/3, 2*pi/3, 3*pi/4, 5*pi/6, pi]);
 %! v = single ([0, rt3/3, 1, rt3, -rt3, -1, -rt3/3, 0]);
-%! assert (tan (x), v,  sqrt (eps ('single')));
+%! assert (tan (x), v,  sqrt (eps ("single")));
 
 %!error tan ()
 %!error tan (1, 2)
@@ -1903,7 +1939,7 @@
 %!test
 %! x = single ([0, pi*i]);
 %! v = single ([0, 0]);
-%! assert (tanh (x), v, sqrt (eps ('single')));
+%! assert (tanh (x), v, sqrt (eps ("single")));
 
 %!error tanh ()
 %!error tanh (1, 2)
@@ -1956,7 +1992,7 @@
 @example\n\
 @group\n\
 tolower (\"MiXeD cAsE 123\")\n\
-     @result{} \"mixed case 123\"\n\
+      @result{} \"mixed case 123\"\n\
 @end group\n\
 @end example\n\
 @seealso{toupper}\n\
@@ -1974,25 +2010,25 @@
 DEFALIAS (lower, tolower);
 
 /*
-%!assert (tolower("OCTAVE"), "octave")
-%!assert (tolower("123OCTave!_&"), "123octave!_&")
-%!assert (tolower({"ABC", "DEF", {"GHI", {"JKL"}}}), {"abc", "def", {"ghi", {"jkl"}}})
-%!assert (tolower(["ABC"; "DEF"]), ["abc"; "def"])
-%!assert (tolower({["ABC"; "DEF"]}), {["abc";"def"]})
-%!assert (tolower(68), "d")
-%!assert (tolower({[68, 68; 68, 68]}), {["dd";"dd"]})
+%!assert (tolower ("OCTAVE"), "octave")
+%!assert (tolower ("123OCTave!_&"), "123octave!_&")
+%!assert (tolower ({"ABC", "DEF", {"GHI", {"JKL"}}}), {"abc", "def", {"ghi", {"jkl"}}})
+%!assert (tolower (["ABC"; "DEF"]), ["abc"; "def"])
+%!assert (tolower ({["ABC"; "DEF"]}), {["abc";"def"]})
+%!assert (tolower (68), "d")
+%!assert (tolower ({[68, 68; 68, 68]}), {["dd";"dd"]})
 %!test
-%!  a(3,3,3,3) = "D";
-%!  assert(tolower(a)(3,3,3,3), "d");
+%! a(3,3,3,3) = "D";
+%! assert (tolower (a)(3,3,3,3), "d");
 
 %!test
 %! charset = char (0:127);
 %! result = charset;
-%! result(toascii ("A":"Z") + 1) = result(toascii ("a":"z") + 1);
-%! assert (all (tolower (charset) == result));
+%! result (toascii ("A":"Z") + 1) = result (toascii ("a":"z") + 1);
+%! assert (tolower (charset), result);
 
-%!error <Invalid call to tolower> tolower()
-%!error <Invalid call to tolower> lower()
+%!error <Invalid call to tolower> lower ()
+%!error <Invalid call to tolower> tolower ()
 %!error tolower (1, 2)
 */
 
@@ -2007,7 +2043,7 @@
 @example\n\
 @group\n\
 toupper (\"MiXeD cAsE 123\")\n\
-     @result{} \"MIXED CASE 123\"\n\
+      @result{} \"MIXED CASE 123\"\n\
 @end group\n\
 @end example\n\
 @seealso{tolower}\n\
@@ -2033,16 +2069,16 @@
 %!assert (toupper (100), "D")
 %!assert (toupper ({[100, 100; 100, 100]}), {["DD";"DD"]})
 %!test
-%!  a(3,3,3,3) = "d";
-%!  assert(toupper (a)(3,3,3,3), "D");
+%! a(3,3,3,3) = "d";
+%! assert (toupper (a)(3,3,3,3), "D");
 %!test
 %! charset = char (0:127);
 %! result = charset;
-%! result(toascii  ("a":"z") + 1) = result(toascii  ("A":"Z") + 1);
-%! assert (all (toupper (charset) == result));
+%! result (toascii  ("a":"z") + 1) = result (toascii  ("A":"Z") + 1);
+%! assert (toupper (charset), result);
 
-%!error <Invalid call to toupper> toupper()
-%!error <Invalid call to toupper> upper()
+%!error <Invalid call to toupper> toupper ()
+%!error <Invalid call to toupper> upper ()
 %!error toupper (1, 2)
 */
 
--- a/src/mex.cc
+++ b/src/mex.cc
@@ -397,7 +397,7 @@
     mwSize n = 1;
 
     // Force dims and ndims to be cached.
-    get_dimensions();
+    get_dimensions ();
 
     for (mwIndex i = ndims - 1; i > 0; i--)
       n *= dims[i];
@@ -1188,7 +1188,7 @@
         for (size_t i = 0; i < tmp_len; i++)
           cpr[m*i+j] = static_cast<mxChar> (ptr[i]);
 
-        for (size_t i = tmp_len; i < nc; i++)
+        for (size_t i = tmp_len; i < static_cast<size_t>(nc); i++)
           cpr[m*i+j] = static_cast<mxChar> (' ');
       }
   }
@@ -1576,12 +1576,12 @@
 
           for (mwIndex i = 0; i < nzmax; i++)
             {
-              val.xdata(i) = ppr[i];
-              val.xridx(i) = ir[i];
+              val.xdata (i) = ppr[i];
+              val.xridx (i) = ir[i];
             }
 
           for (mwIndex i = 0; i < get_n () + 1; i++)
-            val.xcidx(i) = jc[i];
+            val.xcidx (i) = jc[i];
 
           retval = val;
         }
@@ -1603,12 +1603,12 @@
 
               for (mwIndex i = 0; i < nzmax; i++)
                 {
-                  val.xdata(i) = Complex (ppr[i], ppi[i]);
-                  val.xridx(i) = ir[i];
+                  val.xdata (i) = Complex (ppr[i], ppi[i]);
+                  val.xridx (i) = ir[i];
                 }
 
               for (mwIndex i = 0; i < get_n () + 1; i++)
-                val.xcidx(i) = jc[i];
+                val.xcidx (i) = jc[i];
 
               retval = val;
             }
@@ -1621,12 +1621,12 @@
 
               for (mwIndex i = 0; i < nzmax; i++)
                 {
-                  val.xdata(i) = ppr[i];
-                  val.xridx(i) = ir[i];
+                  val.xdata (i) = ppr[i];
+                  val.xridx (i) = ir[i];
                 }
 
               for (mwIndex i = 0; i < get_n () + 1; i++)
-                val.xcidx(i) = jc[i];
+                val.xcidx (i) = jc[i];
 
               retval = val;
             }
@@ -3463,7 +3463,7 @@
   mxArray *m = 0;
   octave_value ret = get_property_from_handle (handle, property, "mexGet");
 
-  if (!error_state && ret.is_defined())
+  if (!error_state && ret.is_defined ())
     m = ret.as_mxArray ();
   return m;
 }
--- a/src/mk-errno-list
+++ b/src/mk-errno-list
@@ -41,7 +41,7 @@
 
 t = "#if defined (%s)\n    { \"%s\", %s, },\n#endif\n"
 errstr = ""
-for k in errorcode.keys():
+for k in errorcode.keys ():
     errstr += t % tuple(3*[errorcode[k]])
 
 for l in stdin:
deleted file mode 100755
--- a/src/mkgendoc
+++ /dev/null
@@ -1,124 +0,0 @@
-#! /bin/sh
-#
-# Copyright (C) 1999-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/>.
-
-SED=${SED:-'sed'}
-
-if test $# -ne 1; then
-  echo "usage: mkgendoc f1" 1>&2
-  exit 1
-fi
-
-DOC_FILES=`cat $1`
-
-if test -z "$DOC_FILES"; then
-  echo "mkgendoc: DOC_FILES is empty!" 1>&2
-  exit 1
-fi
-
-cat << \EOF
-// DO NOT EDIT!  Generated automatically by mkgendoc
-
-#if defined (__DECCXX)
-#define __USE_STD_IOSTREAM
-#endif
-
-#include <iostream>
-#include <string>
-
-#define XDEFUN_FILE_NAME(name) \
-  std::string file_name = name;
-
-#define XDEFUN_DLD_INTERNAL(name, args_name, nargout_name, doc) \
-  print_doc_string (#name, file_name, doc);
-
-#define XDEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, doc) \
-  print_doc_string (name, file_name, doc);
-
-#define XDEFUN_INTERNAL(name, args_name, nargout_name, doc) \
-  print_doc_string (#name, file_name, doc);
-
-#define XDEFCONSTFUN_INTERNAL(name, args_name, nargout_name, doc) \
-  print_doc_string (#name, file_name, doc);
-
-#define XDEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc) \
-  print_doc_string (name, file_name, doc);
-
-#define XDEFALIAS_INTERNAL(alias, name)
-
-#define XDEFVAR_INTERNAL(name, sname, defn, protect, chg_fcn, doc) \
-  print_doc_string (#name, file_name, doc);
-
-#define XDEFCONST_INTERNAL(name, defn, doc) \
-  print_doc_string (#name, file_name, doc);
-
-static void
-print_doc_string (const std::string& name, const std::string& file_name,
-                  const std::string& doc)
-{
-  std::cout << "";
-
-  size_t len = name.length ();
-
-  if (name[0] == '"' && name[len-1] == '"')
-    std::cout << name.substr (1, len-2) << "\n";
-  else
-    std::cout << name << "\n";
-
-  std::cout << "@c " << name << " " << file_name << "\n" << doc << "\n";
-}
-
-EOF
-
-for file in $DOC_FILES; do
-  fcn=`echo $file | $SED 's,.*/,,; s/\.df//; s/-/_/g;'`
-  echo "static void"
-  echo "print_${fcn}_doc_strings (void)"
-  echo "{"
-  cat $file
-  echo "}"
-  echo ""
-done
-
-cat << \EOF
-
-int
-main (void)
-{
-  std::cout
-    << "### DO NOT EDIT!\n"
-    << "###\n"
-    << "### This file is generated automatically from the Octave sources.\n"
-    << "### Edit those files instead and run make to update this file.\n"
-    << std::endl;
-
-EOF
-
-for file in $DOC_FILES; do
-  fcn=`echo $file | $SED 's,.*/,,; s/\.df//; s/-/_/g;'`
-  echo "  print_${fcn}_doc_strings ();"
-done
-
-cat << \EOF
-
-  return 0;
-}
-EOF
-
-exit 0
rename from src/mkoctfile.cc.in
rename to src/mkoctfile.in.cc
rename from src/mkoctfile.in
rename to src/mkoctfile.in.sh
rename from src/mxarray.h.in
rename to src/mxarray.in.h
rename from src/oct-conf.h.in
rename to src/oct-conf.in.h
rename from src/oct-errno.cc.in
rename to src/oct-errno.in.cc
--- a/src/oct-map.cc
+++ b/src/oct-map.cc
@@ -152,7 +152,7 @@
   string_vector retval(n);
 
   for (iterator p = begin (); p != end (); p++)
-    retval.xelem(p->second) = p->first;
+    retval.xelem (p->second) = p->first;
 
   return retval;
 }
@@ -197,7 +197,7 @@
 
   octave_idx_type nf = nfields ();
   for (octave_idx_type i = 0; i < nf; i++)
-    retval.xvals[i] = xvals[perm.xelem(i)];
+    retval.xvals[i] = xvals[perm.xelem (i)];
 
   return retval;
 }
@@ -215,7 +215,7 @@
         {
           octave_idx_type nf = nfields ();
           for (octave_idx_type i = 0; i < nf; i++)
-            retval.xvals[i] = xvals[perm.xelem(i)];
+            retval.xvals[i] = xvals[perm.xelem (i)];
         }
       else
         error ("orderfields: structs must have same fields up to order");
@@ -247,7 +247,7 @@
   for (octave_idx_type i = 0; i < nf; i++)
     {
       xvals.push_back (Cell (dimensions));
-      xvals[i].xelem(0) = m.xvals[i];
+      xvals[i].xelem (0) = m.xvals[i];
     }
 }
 
@@ -308,7 +308,7 @@
 
   octave_idx_type nf = nfields ();
   for (octave_idx_type i = 0; i < nf; i++)
-    retval.xvals[i] = xvals[perm.xelem(i)];
+    retval.xvals[i] = xvals[perm.xelem (i)];
 
   return retval;
 }
@@ -326,7 +326,7 @@
         {
           octave_idx_type nf = nfields ();
           for (octave_idx_type i = 0; i < nf; i++)
-            retval.xvals[i] = xvals[perm.xelem(i)];
+            retval.xvals[i] = xvals[perm.xelem (i)];
         }
       else
         error ("orderfields: structs must have same fields up to order");
@@ -448,10 +448,10 @@
 }
 
 /*
-%!# test preservation of xkeys by squeeze
+## test preservation of xkeys by squeeze
 %!test
-%!  x(1,1,1,1).d = 10; x(3,5,1,7).a = "b"; x(2,4,1,7).f = 27;
-%!  assert (fieldnames (squeeze (x)), {"d"; "a"; "f"});
+%! x(1,1,1,1).d = 10;  x(3,5,1,7).a = "b";  x(2,4,1,7).f = 27;
+%! assert (fieldnames (squeeze (x)), {"d"; "a"; "f"});
 */
 
 octave_map
@@ -482,10 +482,10 @@
 }
 
 /*
-%!# test preservation of key order by permute
+## test preservation of key order by permute
 %!test
-%!  x(1,1,1,1).d = 10; x(3,5,1,7).a = "b"; x(2,4,1,7).f = 27;
-%!  assert (fieldnames (permute (x, [3, 4, 1, 2])), {"d"; "a"; "f"});
+%! x(1,1,1,1).d = 10;  x(3,5,1,7).a = "b";  x(2,4,1,7).f = 27;
+%! assert (fieldnames (permute (x, [3, 4, 1, 2])), {"d"; "a"; "f"});
 */
 
 octave_map
@@ -507,12 +507,12 @@
 }
 
 /*
-%!# test preservation of key order by transpose
+## test preservation of key order by transpose
 %!test
-%!  x(1,1).d = 10; x(3,5).a = "b"; x(2,4).f = 27;
-%!  assert (fieldnames (transpose (x)), {"d"; "a"; "f"});
-%!  assert (fieldnames (x'), {"d"; "a"; "f"});
-%!  assert (fieldnames (x.'), {"d"; "a"; "f"});
+%! x(1,1).d = 10;  x(3,5).a = "b";  x(2,4).f = 27;
+%! assert (fieldnames (transpose (x)), {"d"; "a"; "f"});
+%! assert (fieldnames (x'), {"d"; "a"; "f"});
+%! assert (fieldnames (x.'), {"d"; "a"; "f"});
 */
 
 octave_map
@@ -542,10 +542,10 @@
 }
 
 /*
-%!# test preservation of key order by reshape
+## test preservation of key order by reshape
 %!test
-%!  x(1,1).d = 10; x(4,6).a = "b"; x(2,4).f = 27;
-%!  assert (fieldnames (reshape (x, 3, 8)), {"d"; "a"; "f"});
+%! x(1,1).d = 10;  x(4,6).a = "b";  x(2,4).f = 27;
+%! assert (fieldnames (reshape (x, 3, 8)), {"d"; "a"; "f"});
 */
 
 void
@@ -557,7 +557,7 @@
       for (octave_idx_type i = 0; i < nf; i++)
         {
           if (fill)
-            xvals[i].resize (dv, Cell::resize_fill_value ());
+            xvals[i].resize (dv, Matrix ());
           else
             xvals[i].resize (dv);
         }
@@ -591,7 +591,7 @@
       retval.xvals.push_back (Cell (rd));
       assert (retval.xvals[j].numel () == n);
       for (octave_idx_type i = 0; i < n; i++)
-        retval.xvals[j].xelem(i) = map_list[i].xvals[j];
+        retval.xvals[j].xelem (i) = map_list[i].xvals[j];
     }
 }
 
@@ -804,23 +804,23 @@
 }
 
 /*
-%!# test preservation of key order by concatenation
+## test preservation of key order by concatenation
 %!test
-%!  x(1, 1).d = 10; x(4, 6).a = "b"; x(2, 4).f = 27;
-%!  y(1, 6).f = 11; y(1, 6).a = "c"; y(1, 6).d = 33;
-%!  assert (fieldnames ([x; y]), {"d"; "a"; "f"});
+%! x(1, 1).d = 10;  x(4, 6).a = "b";  x(2, 4).f = 27;
+%! y(1, 6).f = 11;  y(1, 6).a = "c";  y(1, 6).d = 33;
+%! assert (fieldnames ([x; y]), {"d"; "a"; "f"});
 
 %!test
-%!  s = struct ();
-%!  sr = [s,s];
-%!  sc = [s;s];
-%!  sm = [s,s;s,s];
-%!  assert (nfields (sr), 0);
-%!  assert (nfields (sc), 0);
-%!  assert (nfields (sm), 0);
-%!  assert (size (sr), [1, 2]);
-%!  assert (size (sc), [2, 1]);
-%!  assert (size (sm), [2, 2]);
+%! s = struct ();
+%! sr = [s,s];
+%! sc = [s;s];
+%! sm = [s,s;s,s];
+%! assert (nfields (sr), 0);
+%! assert (nfields (sc), 0);
+%! assert (nfields (sm), 0);
+%! assert (size (sr), [1, 2]);
+%! assert (size (sc), [2, 1]);
+%! assert (size (sm), [2, 2]);
 */
 
 octave_map
@@ -1160,7 +1160,7 @@
       for (octave_idx_type i = 0; i < nf; i++)
         {
           if (&xvals[i] != &ref)
-            xvals[i].resize (dimensions, Cell::resize_fill_value ());
+            xvals[i].resize (dimensions, Matrix ());
         }
 
       optimize_dimensions ();
@@ -1257,10 +1257,10 @@
 }
 
 /*
-%!# test preservation of key order by indexing
+## test preservation of key order by indexing
 %!test
-%!  x(1, 1).d = 10; x(4, 6).a = "b"; x(2, 4).f = 27;
-%!  assert (fieldnames (x([1, 2], [2:5])), {"d"; "a"; "f"});
+%! x(1, 1).d = 10;  x(4, 6).a = "b";  x(2, 4).f = 27;
+%! assert (fieldnames (x([1, 2], [2:5])), {"d"; "a"; "f"});
 */
 
 octave_map
@@ -1278,7 +1278,7 @@
               break;
             }
 
-          contents(pa).insert (rb.contents(pb), ra_idx);
+          contents(pa).insert (rb.contents (pb), ra_idx);
         }
     }
   else
@@ -1426,7 +1426,7 @@
 string_vector
 Octave_map::keys (void) const
 {
-  assert (nfields () == key_list.size ());
+  assert (static_cast<size_t>(nfields ()) == key_list.size ());
 
   return string_vector (key_list);
 }
@@ -1489,7 +1489,7 @@
               Cell tmp = contents(p);
 
               if (fill)
-                tmp.resize (dv, Cell::resize_fill_value ());
+                tmp.resize (dv, Matrix ());
               else
                 tmp.resize (dv);
 
@@ -1559,8 +1559,8 @@
     }
   else
     {
-      string_vector a_keys = a.keys().sort ();
-      string_vector b_keys = b.keys().sort ();
+      string_vector a_keys = a.keys ().sort ();
+      string_vector b_keys = b.keys ().sort ();
 
       octave_idx_type a_len = a_keys.length ();
       octave_idx_type b_len = b_keys.length ();
@@ -1585,7 +1585,7 @@
 Octave_map&
 Octave_map::maybe_delete_elements (const octave_value_list& idx)
 {
-  string_vector t_keys = keys();
+  string_vector t_keys = keys ();
   octave_idx_type len = t_keys.length ();
 
   if (len > 0)
@@ -1601,7 +1601,7 @@
         }
 
       if (!error_state)
-        dimensions = contents(t_keys[0]).dims();
+        dimensions = contents(t_keys[0]).dims ();
     }
 
   return *this;
@@ -1669,7 +1669,7 @@
       if (tmp_dims != dimensions)
         {
           for (iterator p = begin (); p != end (); p++)
-            contents(p).resize (tmp_dims, Cell::resize_fill_value ());
+            contents(p).resize (tmp_dims, Matrix ());
 
           dimensions = tmp_dims;
         }
--- a/src/oct-obj.cc
+++ b/src/oct-obj.cc
@@ -157,7 +157,7 @@
     retval(k++) = elem (i);
 
   for (octave_idx_type i = 0; i < lst_len; i++)
-    retval(k++) = lst(i);
+    retval(k++) = lst (i);
 
   for (octave_idx_type i = offset + rep_length; i < len; i++)
     retval(k++) = elem (i);
--- a/src/oct-obj.h
+++ b/src/oct-obj.h
@@ -91,8 +91,7 @@
 
   bool empty (void) const { return length () == 0; }
 
-  void resize (octave_idx_type n, const octave_value& rfv
-               = Array<octave_value>::resize_fill_value ())
+  void resize (octave_idx_type n, const octave_value& rfv = octave_value ())
   {
     data.resize (dim_vector (1, n), rfv);
   }
@@ -127,7 +126,7 @@
 
   bool has_magic_colon (void) const;
 
-  string_vector make_argv (const std::string& = std::string()) const;
+  string_vector make_argv (const std::string& = std::string ()) const;
 
   void stash_name_tags (const string_vector& nm) { names = nm; }
 
--- a/src/oct-parse.yy
+++ b/src/oct-parse.yy
@@ -68,6 +68,7 @@
 #include "toplev.h"
 #include "pager.h"
 #include "parse.h"
+#include "parse-private.h"
 #include "pt-all.h"
 #include "pt-eval.h"
 #include "symtab.h"
@@ -114,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;
@@ -126,7 +132,7 @@
 static bool endfunction_found = false;
 
 // Keep track of symbol table information when parsing functions.
-std::stack<symbol_table::scope_id> symtab_context;
+symtab_context parser_symtab_context;
 
 // Name of the current class when we are parsing class methods or
 // constructors.
@@ -365,12 +371,10 @@
     { \
       global_command = 0; \
       yyerrok; \
-      if (! symtab_context.empty ()) \
-        { \
-          symbol_table::set_scope (symtab_context.top ()); \
-          symtab_context.pop (); \
-        } \
-      if (interactive || forced_interactive) \
+      if (! parser_symtab_context.empty ()) \
+        parser_symtab_context.pop (); \
+      if ((interactive || forced_interactive)   \
+          && ! get_input_from_eval_string)      \
         YYACCEPT; \
       else \
         YYABORT; \
@@ -446,7 +450,7 @@
 %token <tok_val> BREAK CONTINUE FUNC_RET
 %token <tok_val> UNWIND CLEANUP
 %token <tok_val> TRY CATCH
-%token <tok_val> GLOBAL STATIC
+%token <tok_val> GLOBAL PERSISTENT
 %token <tok_val> FCN_HANDLE
 %token <tok_val> PROPERTIES METHODS EVENTS ENUMERATION
 %token <tok_val> METAQUERY
@@ -462,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
@@ -908,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;
@@ -997,9 +1001,9 @@
                     $$ = make_decl_command (GLOBAL, $1, $3);
                     lexer_flags.looking_at_decl_list = false;
                   }
-                | STATIC parsing_decl_list decl1
+                | PERSISTENT parsing_decl_list decl1
                   {
-                    $$ = make_decl_command (STATIC, $1, $3);
+                    $$ = make_decl_command (PERSISTENT, $1, $3);
                     lexer_flags.looking_at_decl_list = false;
                   }
                 ;
@@ -1224,9 +1228,12 @@
                     if (max_function_depth < current_function_depth)
                       max_function_depth = current_function_depth;
 
-                    symtab_context.push (symbol_table::current_scope ());
+                    parser_symtab_context.push ();
+
                     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 ();
@@ -1246,7 +1253,7 @@
 
                     if (lexer_flags.looking_at_function_handle)
                       {
-                        symtab_context.push (symbol_table::current_scope ());
+                        parser_symtab_context.push ();
                         symbol_table::set_scope (symbol_table::alloc_scope ());
                         lexer_flags.looking_at_function_handle--;
                         lexer_flags.looking_at_anon_fcn_args = true;
@@ -1395,11 +1402,13 @@
                   }
                 | GET '.' identifier
                   {
+                    lexer_flags.parsed_function_name.top () = true;
                     lexer_flags.maybe_classdef_get_set_method = false;
                     $$ = $3;
                   }
                 | SET '.' identifier
                   {
+                    lexer_flags.parsed_function_name.top () = true;
                     lexer_flags.maybe_classdef_get_set_method = false;
                     $$ = $3;
                   }
@@ -1671,6 +1680,12 @@
                   { $$ = $1; }
                 ;
 
+opt_comma       : // empty
+                  { $$ = 0; }
+                | ','
+                  { $$ = ','; }
+                ;
+
 %%
 
 // Generic error messages.
@@ -2122,12 +2137,10 @@
 
   symbol_table::scope_id fcn_scope = symbol_table::current_scope ();
 
-  if (symtab_context.empty ())
+  if (parser_symtab_context.empty ())
     panic_impossible ();
 
-  symbol_table::set_scope (symtab_context.top ());
-
-  symtab_context.pop ();
+  parser_symtab_context.pop ();
 
   stmt->set_print_flag (false);
 
@@ -2824,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
@@ -2863,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)
@@ -2939,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);
@@ -2970,17 +2999,17 @@
 static void
 recover_from_parsing_function (void)
 {
-  if (symtab_context.empty ())
+  if (parser_symtab_context.empty ())
     panic_impossible ();
 
-  symbol_table::set_scope (symtab_context.top ());
-  symtab_context.pop ();
+  parser_symtab_context.pop ();
 
   if (reading_fcn_file && current_function_depth == 1
       && ! parsing_subfunctions)
     parsing_subfunctions = true;
 
   current_function_depth--;
+  function_scopes.pop_back ();
 
   lexer_flags.defining_func--;
   lexer_flags.parsed_function_name.pop ();
@@ -3089,9 +3118,9 @@
       retval = new tree_global_command (lst, l, c);
       break;
 
-    case STATIC:
+    case PERSISTENT:
       if (current_function_depth > 0)
-        retval = new tree_static_command (lst, l, c);
+        retval = new tree_persistent_command (lst, l, c);
       else
         {
           if (reading_script_file)
@@ -3175,7 +3204,7 @@
 {
   if (current_function_depth > 0)
     {
-      tree_statement *tmp = t->back();
+      tree_statement *tmp = t->back ();
 
       if (tmp->is_expression ())
         warning_with_id
@@ -3450,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);
@@ -3460,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;
@@ -3515,7 +3546,11 @@
 
               reading_classdef_file = true;
               reading_fcn_file = false;
-              reading_script_file = false;
+              // FIXME -- Should classdef files be handled as
+              // scripts or separately?  Currently, without setting up
+              // for reading script files, parsing classdef files
+              // fails.
+              reading_script_file = true;
             }
           else
             {
@@ -3573,12 +3608,7 @@
 
           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 ());
+                   file_type.c_str (), ff.c_str ());
         }
       else
         {
@@ -3662,7 +3692,7 @@
 string_vector
 autoloaded_functions (void)
 {
-  string_vector names (autoload_map.size());
+  string_vector names (autoload_map.size ());
 
   octave_idx_type i = 0;
   typedef std::map<std::string, std::string>::const_iterator am_iter;
@@ -4217,9 +4247,9 @@
 @group\n\
 @var{f} = @@exp;\n\
 feval (@var{f}, 1)\n\
-     @result{} 2.7183\n\
+    @result{} 2.7183\n\
 @var{f} (1)\n\
-     @result{} 2.7183\n\
+    @result{} 2.7183\n\
 @end group\n\
 @end example\n\
 \n\
@@ -4290,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);
@@ -4304,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;
@@ -4457,7 +4489,7 @@
 value 3.1416 available.\n\
 \n\
 @example\n\
-eval(\"a = acos(-1);\");\n\
+eval (\"a = acos(-1);\");\n\
 @end example\n\
 \n\
 If an error occurs during the evaluation of @var{try} the @var{catch}\n\
@@ -4551,6 +4583,11 @@
 %!endfunction
 %!assert (__f(), 2)
 
+% bug #35645
+%!test
+%! [a,] = gcd (1,2);
+%! [a,b,] = gcd (1, 2);
+
 */
 
 DEFUN (assignin, args, ,
--- a/src/oct-stream.cc
+++ b/src/oct-stream.cc
@@ -1107,9 +1107,12 @@
 
     case 'i':
       {
-        int c1 = is.get ();
-
-        if (! is.eof ())
+        int c1 = EOF;
+
+        while (is && (c1 = is.get ()) != EOF && isspace (c1))
+          /* skip whitespace */;
+
+        if (c1 != EOF)
           {
             if (c1 == '0')
               {
@@ -2135,7 +2138,7 @@
               else
                 {
                   if (tmp.is_defined ())
-                    retval (num_values++) = tmp;
+                    retval(num_values++) = tmp;
 
                   if (! ok ())
                     break;
--- a/src/oct-stream.h
+++ b/src/oct-stream.h
@@ -371,6 +371,12 @@
 
   virtual std::ostream *output_stream (void) { return 0; }
 
+  // If the derived class is locale-aware, it must implement this function 
+  // in order to set a new locale. By default, this function avoids messing 
+  // with locales and ignores its input argument.
+  virtual std::locale imbue ( const std::locale &)
+    { return std::locale::classic (); }
+
   // Return TRUE if this stream is open.
 
   bool is_open (void) const { return open_state; }
@@ -613,7 +619,23 @@
   {
     return rep ? rep->output_stream () : 0;
   }
-
+  
+  std::locale imbue (const std::locale & loc )
+    {
+      if (!rep) return std::locale::classic ();
+      
+      std::istream *is = rep->input_stream ();
+      std::ostream *os = rep->output_stream ();
+      
+      if (os) 
+        {
+          if (is)
+            (void) is->imbue (loc);
+          return os->imbue (loc);
+        }
+      return is ? is->imbue (loc) : std::locale::classic ();
+    }
+  
   void clearerr (void) { if (rep) rep->clearerr (); }
 
 private:
rename from src/octave-config.cc.in
rename to src/octave-config.in.cc
--- a/src/octave-config.cc.in
+++ b/src/octave-config.in.cc
@@ -167,7 +167,7 @@
   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["PREFIX"] = (OCTAVE_HOME.empty () ? PREFIX : OCTAVE_HOME);
   vars["STARTUPFILEDIR"] =substitute_prefix (%OCTAVE_STARTUPFILEDIR%, PREFIX, OCTAVE_HOME);
   vars["VERSION"] = %OCTAVE_VERSION%;
 }
rename from src/octave-config.in
rename to src/octave-config.in.sh
--- a/src/octave.cc
+++ b/src/octave.cc
@@ -150,7 +150,8 @@
 #define NO_SITE_FILE_OPTION 11
 #define NO_WINDOW_SYSTEM_OPTION 12
 #define PERSIST_OPTION 13
-#define TRADITIONAL_OPTION 14
+#define TEXI_MACROS_FILE_OPTION 14
+#define TRADITIONAL_OPTION 15
 struct option long_opts[] =
   {
     { "braindead",        no_argument,       0, TRADITIONAL_OPTION },
@@ -176,6 +177,7 @@
     { "persist",          no_argument,       0, PERSIST_OPTION },
     { "quiet",            no_argument,       0, 'q' },
     { "silent",           no_argument,       0, 'q' },
+    { "texi-macros-file", required_argument, 0, TEXI_MACROS_FILE_OPTION },
     { "traditional",      no_argument,       0, TRADITIONAL_OPTION },
     { "verbose",          no_argument,       0, 'V' },
     { "version",          no_argument,       0, 'v' },
@@ -317,6 +319,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 +446,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;
     }
@@ -532,6 +536,7 @@
   --path PATH, -p PATH    Add PATH to head of function search path.\n\
   --persist               Go interactive after --eval or reading from FILE.\n\
   --silent, -q            Don't print message at startup.\n\
+  --texi-macros-file FILE Use Texinfo macros in FILE for makeinfo command.\n\
   --traditional           Set variables for closer MATLAB compatibility.\n\
   --verbose, -V           Enable verbose output in some cases.\n\
   --version, -v           Print version number and exit.\n\
@@ -809,6 +814,11 @@
           persist = true;
           break;
 
+        case TEXI_MACROS_FILE_OPTION:
+          if (optarg)
+            bind_internal_variable ("texi_macros_file", optarg);
+          break;
+
         case TRADITIONAL_OPTION:
           traditional = true;
           break;
@@ -982,8 +992,8 @@
 }
 
 /*
-%!error argv (1);
-%!assert (iscellstr (argv ()));
+%!assert (iscellstr (argv ()))
+%!error argv (1)
 */
 
 DEFUN (program_invocation_name, args, ,
@@ -1009,8 +1019,8 @@
 }
 
 /*
-%!error program_invocation_name (1);
-%!assert (ischar (program_invocation_name ()));
+%!assert (ischar (program_invocation_name ()))
+%!error program_invocation_name (1)
 */
 
 DEFUN (program_name, args, ,
@@ -1032,6 +1042,6 @@
 }
 
 /*
-%!error program_name (1);
-%!assert (ischar (program_name ()));
+%!assert (ischar (program_name ()))
+%!error program_name (1)
 */
--- a/src/octave.gperf
+++ b/src/octave.gperf
@@ -60,6 +60,7 @@
   methods_kw,
   otherwise_kw,
   parfor_kw,
+  persistent_kw,
   properties_kw,
   return_kw,
   set_kw,
@@ -106,11 +107,11 @@
 methods, METHODS, methods_kw
 otherwise, OTHERWISE, otherwise_kw
 parfor, PARFOR, parfor_kw
-persistent, STATIC, static_kw
+persistent, PERSISTENT, persistent_kw
 properties, PROPERTIES, properties_kw
 return, FUNC_RET, return_kw
 set, SET, set_kw
-static, STATIC, static_kw
+static, PERSISTENT, static_kw
 switch, SWITCH, switch_kw
 try, TRY, try_kw
 until, UNTIL, until_kw
--- a/src/ops.h
+++ b/src/ops.h
@@ -341,12 +341,6 @@
     return octave_value (f (v1.CONCAT2(e1, _value) (), v2.CONCAT2(e2, _value) ())); \
   }
 
-#define BINOP_NONCONFORMANT(msg) \
-  gripe_nonconformant (msg, \
-                       a1.rows (), a1.columns (), \
-                       a2.rows (), a2.columns ()); \
-  return octave_value ()
-
 #define CATOPDECL(name, a1, a2) \
   static octave_value \
   CONCAT2(oct_catop_, name) (octave_base_value& a1, const octave_base_value& a2, \
--- a/src/ov-base-diag.cc
+++ b/src/ov-base-diag.cc
@@ -217,7 +217,7 @@
 
   if (numel () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  type_name (), "real scalar");
 
       retval = helper_getreal (el_type (matrix (0, 0)));
@@ -241,7 +241,7 @@
 
   if (numel () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  type_name (), "real scalar");
 
       retval = helper_getreal (el_type (matrix (0, 0)));
@@ -262,7 +262,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  type_name (), "complex scalar");
 
       retval = matrix (0, 0);
@@ -283,7 +283,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  type_name (), "complex scalar");
 
       retval = matrix (0, 0);
--- a/src/ov-base-int.cc
+++ b/src/ov-base-int.cc
@@ -239,11 +239,11 @@
 octave_base_int_matrix<T>::save_binary (std::ostream& os, bool&)
 {
   dim_vector d = this->dims ();
-  if (d.length() < 1)
+  if (d.length () < 1)
     return false;
 
   // Use negative value for ndims to differentiate with old format!!
-  int32_t tmp = - d.length();
+  int32_t tmp = - d.length ();
   os.write (reinterpret_cast<char *> (&tmp), 4);
   for (int i=0; i < d.length (); i++)
     {
@@ -251,7 +251,7 @@
       os.write (reinterpret_cast<char *> (&tmp), 4);
     }
 
-  os.write (reinterpret_cast<const char *> (this->matrix.data()), this->byte_size());
+  os.write (reinterpret_cast<const char *> (this->matrix.data ()), this->byte_size ());
 
   return true;
 }
@@ -303,7 +303,7 @@
   if (swap)
     {
       int nel = dv.numel ();
-      int bytes = nel / m.byte_size();
+      int bytes = nel / m.byte_size ();
       for (int i = 0; i < nel; i++)
         switch (bytes)
           {
@@ -364,7 +364,7 @@
     }
 
   retval = H5Dwrite (data_hid, save_type_hid, H5S_ALL, H5S_ALL,
-                     H5P_DEFAULT, this->matrix.data()) >= 0;
+                     H5P_DEFAULT, this->matrix.data ()) >= 0;
 
   H5Dclose (data_hid);
   H5Sclose (space_hid);
@@ -381,7 +381,7 @@
   dim_vector dv;
   int empty = load_hdf5_empty (loc_id, name, dv);
   if (empty > 0)
-    this->matrix.resize(dv);
+    this->matrix.resize (dv);
   if (empty)
       return (empty > 0);
 
@@ -422,7 +422,7 @@
 
   T m (dv);
   if (H5Dread (data_hid, save_type_hid, H5S_ALL, H5S_ALL,
-               H5P_DEFAULT, m.fortran_vec()) >= 0)
+               H5P_DEFAULT, m.fortran_vec ()) >= 0)
     {
       retval = true;
       this->matrix = m;
@@ -501,7 +501,7 @@
 bool
 octave_base_int_scalar<T>::save_binary (std::ostream& os, bool&)
 {
-  os.write (reinterpret_cast<char *> (&(this->scalar)), this->byte_size());
+  os.write (reinterpret_cast<char *> (&(this->scalar)), this->byte_size ());
   return true;
 }
 
@@ -511,11 +511,11 @@
                                         oct_mach_info::float_format)
 {
   T tmp;
-  if (! is.read (reinterpret_cast<char *> (&tmp), this->byte_size()))
+  if (! is.read (reinterpret_cast<char *> (&tmp), this->byte_size ()))
     return false;
 
   if (swap)
-    switch (this->byte_size())
+    switch (this->byte_size ())
       {
       case 8:
         swap_bytes<8> (&tmp);
--- a/src/ov-base-mat.cc
+++ b/src/ov-base-mat.cc
@@ -475,7 +475,7 @@
       // Set up the pointer to the proper place.
       void *here = reinterpret_cast<void *> (&matrix(n));
       // Ask x to store there if it can.
-      return x.get_rep().fast_elem_insert_self (here, btyp);
+      return x.get_rep ().fast_elem_insert_self (here, btyp);
     }
   else
     return false;
--- a/src/ov-base-mat.h
+++ b/src/ov-base-mat.h
@@ -53,7 +53,7 @@
 
   octave_base_matrix (const MT& m, const MatrixType& t = MatrixType ())
     : octave_base_value (), matrix (m),
-      typ (t.is_known () ? new MatrixType(t) : 0), idx_cache ()
+      typ (t.is_known () ? new MatrixType (t) : 0), idx_cache ()
   {
     if (matrix.ndims () == 0)
       matrix.resize (dim_vector (0, 0));
@@ -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
+++ b/src/ov-base-scalar.cc
@@ -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
+++ b/src/ov-base-scalar.h
@@ -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
+++ b/src/ov-base-sparse.cc
@@ -370,13 +370,13 @@
           // at all the nonzero values and display them with the same
           // formatting rules that apply to columns of a matrix.
 
-          for (octave_idx_type i = matrix.cidx(j); i < matrix.cidx(j+1); i++)
+          for (octave_idx_type i = matrix.cidx (j); i < matrix.cidx (j+1); i++)
             {
               os << "\n";
-              os << "  (" << matrix.ridx(i)+1 <<
+              os << "  (" << matrix.ridx (i)+1 <<
                 ", "  << j+1 << ") -> ";
 
-              octave_print_internal (os, matrix.data(i), pr_as_read_syntax);
+              octave_print_internal (os, matrix.data (i), pr_as_read_syntax);
             }
         }
     }
--- a/src/ov-base.cc
+++ b/src/ov-base.cc
@@ -1117,7 +1117,15 @@
 {
   gripe_wrong_type_arg ("octave_base_value::diag ()", type_name ());
 
-  return octave_value();
+  return octave_value ();
+}
+
+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
@@ -1125,7 +1133,7 @@
 {
   gripe_wrong_type_arg ("octave_base_value::sort ()", type_name ());
 
-  return octave_value();
+  return octave_value ();
 }
 
 octave_value
@@ -1134,7 +1142,7 @@
 {
   gripe_wrong_type_arg ("octave_base_value::sort ()", type_name ());
 
-  return octave_value();
+  return octave_value ();
 }
 
 sortmode
@@ -1183,6 +1191,7 @@
       "cosh",
       "erf",
       "erfinv",
+      "erfcinv",
       "erfc",
       "exp",
       "expm1",
@@ -1538,11 +1547,11 @@
 @example\n\
 @group\n\
 s = speye (3);\n\
-sparse_auto_mutate (false)\n\
+sparse_auto_mutate (false);\n\
 s(:, 1) = 1;\n\
 typeinfo (s)\n\
 @result{} sparse matrix\n\
-sparse_auto_mutate (true)\n\
+sparse_auto_mutate (true);\n\
 s(1, :) = 1;\n\
 typeinfo (s)\n\
 @result{} matrix\n\
@@ -1558,14 +1567,13 @@
 }
 
 /*
-
 %!test
- s = speye(3);
- sparse_auto_mutate (false);
- s(:, 1) = 1;
- assert (typeinfo (s), "sparse matrix");
- sparse_auto_mutate (true);
- s(1, :) = 1;
- assert (typeinfo (s), "matrix");
-
+%! s = speye (3);
+%! sparse_auto_mutate (false);
+%! s(:, 1) = 1;
+%! assert (typeinfo (s), "sparse matrix");
+%! sparse_auto_mutate (true);
+%! s(1, :) = 1;
+%! assert (typeinfo (s), "matrix");
+%! sparse_auto_mutate (false);
 */
--- a/src/ov-base.h
+++ b/src/ov-base.h
@@ -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,
@@ -686,6 +688,7 @@
       umap_cosh,
       umap_erf,
       umap_erfinv,
+      umap_erfcinv,
       umap_erfc,
       umap_erfcx,
       umap_exp,
--- a/src/ov-bool-mat.cc
+++ b/src/ov-bool-mat.cc
@@ -97,7 +97,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "bool matrix", "real scalar");
 
       retval = matrix (0, 0);
@@ -115,7 +115,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "bool matrix", "real scalar");
 
       retval = matrix (0, 0);
@@ -135,7 +135,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "bool matrix", "complex scalar");
 
       retval = matrix (0, 0);
@@ -155,7 +155,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "bool matrix", "complex scalar");
 
       retval = matrix (0, 0);
@@ -329,11 +329,11 @@
 {
 
   dim_vector d = dims ();
-  if (d.length() < 1)
+  if (d.length () < 1)
     return false;
 
   // Use negative value for ndims to differentiate with old format!!
-  int32_t tmp = - d.length();
+  int32_t tmp = - d.length ();
   os.write (reinterpret_cast<char *> (&tmp), 4);
   for (int i = 0; i < d.length (); i++)
     {
@@ -469,7 +469,7 @@
   dim_vector dv;
   int empty = load_hdf5_empty (loc_id, name, dv);
   if (empty > 0)
-    matrix.resize(dv);
+    matrix.resize (dv);
   if (empty)
     return (empty > 0);
 
@@ -577,11 +577,10 @@
 }
 
 /*
-%!shared m, s, c
+%!test
 %! m = eye (2) != 0;
 %! s = !0;
 %! c = {"double", "single", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64", "logical"};
-%!test
 %! for i = 1:numel (c)
 %!   assert (logical (eye (2, c{i})), m)
 %!   assert (logical (eye (1, c{i})), s)
--- a/src/ov-bool-sparse.cc
+++ b/src/ov-bool-sparse.cc
@@ -100,7 +100,7 @@
   if (numel () > 0)
     {
       if (numel () > 1)
-        gripe_implicit_conversion ("Octave:array-as-scalar",
+        gripe_implicit_conversion ("Octave:array-to-scalar",
                                    "bool sparse matrix", "real scalar");
 
       retval = matrix (0, 0);
@@ -121,7 +121,7 @@
   if (rows () > 0 && columns () > 0)
     {
       if (numel () > 1)
-        gripe_implicit_conversion ("Octave:array-as-scalar",
+        gripe_implicit_conversion ("Octave:array-to-scalar",
                                    "bool sparse matrix", "complex scalar");
 
       retval = matrix (0, 0);
@@ -163,7 +163,7 @@
 NDArray
 octave_sparse_bool_matrix::array_value (bool) const
 {
-  return NDArray (Matrix(matrix.matrix_value ()));
+  return NDArray (Matrix (matrix.matrix_value ()));
 }
 
 charNDArray
@@ -174,8 +174,8 @@
   octave_idx_type nr = matrix.rows ();
 
   for (octave_idx_type j = 0; j < nc; j++)
-    for (octave_idx_type i = matrix.cidx(j); i < matrix.cidx(j+1); i++)
-      retval(matrix.ridx(i) + nr * j) = static_cast<char>(matrix.data (i));
+    for (octave_idx_type i = matrix.cidx (j); i < matrix.cidx (j+1); i++)
+      retval(matrix.ridx (i) + nr * j) = static_cast<char>(matrix.data (i));
 
   return retval;
 }
@@ -209,7 +209,7 @@
 octave_sparse_bool_matrix::save_binary (std::ostream& os, bool&)
 {
   dim_vector d = this->dims ();
-  if (d.length() < 1)
+  if (d.length () < 1)
     return false;
 
   // Ensure that additional memory is deallocated
@@ -238,14 +238,14 @@
   for (int i = 0; i < nc+1; i++)
     {
       octave_quit ();
-      itmp = matrix.cidx(i);
+      itmp = matrix.cidx (i);
       os.write (reinterpret_cast<char *> (&itmp), 4);
     }
 
   for (int i = 0; i < nz; i++)
     {
       octave_quit ();
-      itmp = matrix.ridx(i);
+      itmp = matrix.ridx (i);
       os.write (reinterpret_cast<char *> (&itmp), 4);
     }
 
@@ -300,7 +300,7 @@
         return false;
       if (swap)
         swap_bytes<4> (&tmp);
-      m.cidx(i) = tmp;
+      m.cidx (i) = tmp;
     }
 
   for (int i = 0; i < nz; i++)
@@ -310,7 +310,7 @@
         return false;
       if (swap)
         swap_bytes<4> (&tmp);
-      m.ridx(i) = tmp;
+      m.ridx (i) = tmp;
     }
 
   if (error_state || ! is)
@@ -440,7 +440,7 @@
 
   H5Sclose (space_hid);
 
-  hdims[0] = m.cols() + 1;
+  hdims[0] = m.cols () + 1;
   hdims[1] = 1;
 
   space_hid = H5Screate_simple (2, hdims, 0);
@@ -551,7 +551,7 @@
   dim_vector dv;
   int empty = load_hdf5_empty (loc_id, name, dv);
   if (empty > 0)
-    matrix.resize(dv);
+    matrix.resize (dv);
   if (empty)
     return (empty > 0);
 
@@ -782,12 +782,12 @@
 
   for (mwIndex i = 0; i < nz; i++)
     {
-      pr[i] = matrix.data(i);
-      ir[i] = matrix.ridx(i);
+      pr[i] = matrix.data (i);
+      ir[i] = matrix.ridx (i);
     }
 
   for (mwIndex i = 0; i < columns () + 1; i++)
-    jc[i] = matrix.cidx(i);
+    jc[i] = matrix.cidx (i);
 
   return retval;
 }
--- a/src/ov-bool.cc
+++ b/src/ov-bool.cc
@@ -89,14 +89,14 @@
   if (fill)
     {
       boolNDArray retval (dv, false);
-      if (dv.numel())
+      if (dv.numel ())
         retval(0) = scalar;
       return retval;
     }
   else
     {
       boolNDArray retval (dv);
-      if (dv.numel())
+      if (dv.numel ())
         retval(0) = scalar;
       return retval;
     }
--- a/src/ov-cell.cc
+++ b/src/ov-cell.cc
@@ -944,7 +944,7 @@
     return false;
 
   // Use negative value for ndims
-  int32_t di = - d.length();
+  int32_t di = - d.length ();
   os.write (reinterpret_cast<char *> (&di), 4);
   for (int i = 0; i < d.length (); i++)
     {
@@ -1155,7 +1155,7 @@
   dim_vector dv;
   int empty = load_hdf5_empty (loc_id, name, dv);
   if (empty > 0)
-    matrix.resize(dv);
+    matrix.resize (dv);
   if (empty)
     return (empty > 0);
 
@@ -1395,24 +1395,24 @@
 \n\
 @example\n\
 @group\n\
-  s = struct('name', @{'Peter', 'Hannah', 'Robert'@},\n\
-             'age', @{23, 16, 3@});\n\
-  c = struct2cell(s)\n\
-     @result{} c = @{1x1x3 Cell Array@}\n\
-  c(1,1,:)(:)\n\
-     @result{} ans =\n\
-        @{\n\
-          [1,1] = Peter\n\
-          [2,1] = Hannah\n\
-          [3,1] = Robert\n\
-        @}\n\
-  c(2,1,:)(:)\n\
-     @result{} ans =\n\
-        @{\n\
-          [1,1] = 23\n\
-          [2,1] = 16\n\
-          [3,1] = 3\n\
-        @}\n\
+s = struct (\"name\", @{\"Peter\", \"Hannah\", \"Robert\"@},\n\
+           \"age\", @{23, 16, 3@});\n\
+c = struct2cell (s)\n\
+   @result{} c = @{1x1x3 Cell Array@}\n\
+c(1,1,:)(:)\n\
+   @result{}\n\
+      @{\n\
+        [1,1] = Peter\n\
+        [2,1] = Hannah\n\
+        [3,1] = Robert\n\
+      @}\n\
+c(2,1,:)(:)\n\
+   @result{}\n\
+      @{\n\
+        [1,1] = 23\n\
+        [2,1] = 16\n\
+        [3,1] = 3\n\
+      @}\n\
 @end group\n\
 @end example\n\
 \n\
@@ -1471,14 +1471,14 @@
 
 /*
 %!test
-%!  keys = cellstr (char (floor (rand (11,10)*24+65)))';
-%!  vals = cellfun(@(x) mat2cell(rand (19,1), ones (19,1), 1), ...
-%!           mat2cell([1:11]', ones(11,1), 1), "uniformoutput", false)';
-%!  s = struct ([keys; vals]{:});
-%!  t = cell2struct ([vals{:}], keys, 2);
-%!  assert (s, t);
-%!  assert (struct2cell (s), [vals{:}]');
-%!  assert (fieldnames (s), keys');
+%! keys = cellstr (char (floor (rand (11,10)*24+65)))';
+%! vals = cellfun (@(x) mat2cell (rand (19,1), ones (19,1), 1), ...
+%!          mat2cell ([1:11]', ones (11,1), 1), "uniformoutput", false)';
+%! s = struct ([keys; vals]{:});
+%! t = cell2struct ([vals{:}], keys, 2);
+%! assert (s, t);
+%! assert (struct2cell (s), [vals{:}]');
+%! assert (fieldnames (s), keys');
 */
 
 mxArray *
--- a/src/ov-ch-mat.cc
+++ b/src/ov-ch-mat.cc
@@ -57,7 +57,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "character matrix", "real scalar");
 
       retval = static_cast<unsigned char> (matrix (0, 0));
@@ -75,7 +75,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "character matrix", "real scalar");
 
       retval = static_cast<unsigned char> (matrix (0, 0));
@@ -95,7 +95,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "character matrix", "complex scalar");
 
       retval = static_cast<unsigned char> (matrix (0, 0));
@@ -115,7 +115,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "character matrix", "complex scalar");
 
       retval = static_cast<unsigned char> (matrix (0, 0));
--- a/src/ov-class.cc
+++ b/src/ov-class.cc
@@ -142,7 +142,7 @@
                         = parent.parent_class_name_list ();
 
                       for (octave_idx_type i = 0; i < p_nel; i++)
-                        c(i) = octave_value (pmap.index(i), pcnm, plist);
+                        c(i) = octave_value (pmap.index (i), pcnm, plist);
 
                       map.assign (pcnm, c);
                     }
@@ -187,7 +187,7 @@
                         = parent.parent_class_name_list ();
 
                       for (octave_idx_type i = 0; i < p_nel; i++)
-                        c(i) = octave_value (pmap.index(i), pcnm, plist);
+                        c(i) = octave_value (pmap.index (i), pcnm, plist);
 
                       map.assign (pcnm, c);
                     }
@@ -521,7 +521,7 @@
 
         case '.':
           {
-            if (map.numel() > 0)
+            if (map.numel () > 0)
               {
                 Cell t = dotref (idx.front ());
 
@@ -705,7 +705,7 @@
 
           if (tmp.length () > 1)
             error ("expecting single return value from @%s/subsasgn",
-                   class_name().c_str ());
+                   class_name ().c_str ());
 
           else
             retval = tmp(0);
@@ -914,7 +914,7 @@
                   {
                     if (t_rhs.is_empty ())
                       {
-                        map.delete_elements (idx.front());
+                        map.delete_elements (idx.front ());
 
                         if (! error_state)
                           {
@@ -999,7 +999,7 @@
 
       if (!error_state && tmp.length () >= 1)
         {
-          if (tmp(0).is_object())
+          if (tmp(0).is_object ())
             error ("subsindex function must return a valid index vector");
           else
             // Index vector returned by subsindex is zero based
@@ -1012,7 +1012,7 @@
     }
   else
     error ("no subsindex method defined for class %s",
-           class_name().c_str ());
+           class_name ().c_str ());
 
   return retval;
 }
@@ -1136,7 +1136,7 @@
         }
     }
   else
-    error ("no char method defined for class %s", class_name().c_str ());
+    error ("no char method defined for class %s", class_name ().c_str ());
 
   return retval;
 }
@@ -1274,10 +1274,10 @@
     {
       std::string  key = map.key (p);
       Cell         val = map.contents (p);
-      if ( val(0).is_object() )
+      if ( val(0).is_object () )
         {
           dbgstr = "blork";
-          if( key == val(0).class_name() )
+          if( key == val(0).class_name () )
             {
               might_have_inheritance = true;
               dbgstr = "cork";
@@ -1444,7 +1444,7 @@
 bool
 octave_class::save_binary (std::ostream& os, bool& save_as_floats)
 {
-  int32_t classname_len = class_name().length ();
+  int32_t classname_len = class_name ().length ();
 
   os.write (reinterpret_cast<char *> (&classname_len), 4);
   os << class_name ();
@@ -1462,7 +1462,7 @@
   else
     m = map_value ();
 
-  int32_t len = m.nfields();
+  int32_t len = m.nfields ();
   os.write (reinterpret_cast<char *> (&len), 4);
 
   octave_map::iterator i = m.begin ();
@@ -2189,7 +2189,7 @@
 
   if (fcn && fcn->is_class_constructor ())
     {
-      for (int i = 0; i < args.length(); i++)
+      for (int i = 0; i < args.length (); i++)
         {
           std::string class_name = args(i).string_value ();
 
@@ -2241,7 +2241,7 @@
 
   if (fcn && fcn->is_class_constructor ())
     {
-      for (int i = 0; i < args.length(); i++)
+      for (int i = 0; i < args.length (); i++)
         {
           std::string class_name = args(i).string_value ();
 
--- a/src/ov-class.h
+++ b/src/ov-class.h
@@ -136,7 +136,7 @@
   octave_value reshape (const dim_vector& new_dims) const
     {
       octave_class retval = octave_class (*this);
-      retval.map = retval.map_value().reshape (new_dims);
+      retval.map = retval.map_value ().reshape (new_dims);
       return octave_value (new octave_class (retval));
     }
 
--- a/src/ov-complex.cc
+++ b/src/ov-complex.cc
@@ -65,8 +65,8 @@
 octave_base_value::type_conv_info
 octave_complex::numeric_demotion_function (void) const
 {
-  return octave_base_value::type_conv_info(default_numeric_demotion_function,
-                                           octave_float_complex::static_type_id ());
+  return octave_base_value::type_conv_info (default_numeric_demotion_function,
+                                            octave_float_complex::static_type_id ());
 }
 
 octave_base_value *
@@ -225,7 +225,7 @@
 {
   if (fill)
     {
-      ComplexNDArray retval (dv, ComplexNDArray::resize_fill_value ());
+      ComplexNDArray retval (dv, Complex (0));
 
       if (dv.numel ())
         retval(0) = scalar;
@@ -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
+++ b/src/ov-complex.h
@@ -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-mat.cc
+++ b/src/ov-cx-mat.cc
@@ -73,8 +73,8 @@
 octave_base_value::type_conv_info
 octave_complex_matrix::numeric_demotion_function (void) const
 {
-  return octave_base_value::type_conv_info(default_numeric_demotion_function,
-                                           octave_float_complex_matrix::static_type_id ());
+  return octave_base_value::type_conv_info (default_numeric_demotion_function,
+                                            octave_float_complex_matrix::static_type_id ());
 }
 
 octave_base_value *
@@ -108,7 +108,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "complex matrix", "real scalar");
 
       retval = std::real (matrix (0, 0));
@@ -130,7 +130,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "complex matrix", "real scalar");
 
       retval = std::real (matrix (0, 0));
@@ -178,7 +178,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "complex matrix", "complex scalar");
 
       retval = matrix (0, 0);
@@ -198,7 +198,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "complex matrix", "complex scalar");
 
       retval = matrix (0, 0);
@@ -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)
 {
@@ -419,11 +437,11 @@
 octave_complex_matrix::save_binary (std::ostream& os, bool& save_as_floats)
 {
   dim_vector d = dims ();
-  if (d.length() < 1)
+  if (d.length () < 1)
     return false;
 
   // Use negative value for ndims to differentiate with old format!!
-  int32_t tmp = - d.length();
+  int32_t tmp = - d.length ();
   os.write (reinterpret_cast<char *> (&tmp), 4);
   for (int i = 0; i < d.length (); i++)
     {
@@ -626,7 +644,7 @@
   dim_vector dv;
   int empty = load_hdf5_empty (loc_id, name, dv);
   if (empty > 0)
-    matrix.resize(dv);
+    matrix.resize (dv);
   if (empty)
       return (empty > 0);
 
--- a/src/ov-cx-mat.h
+++ b/src/ov-cx-mat.h
@@ -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-cx-sparse.cc
+++ b/src/ov-cx-sparse.cc
@@ -114,7 +114,7 @@
   if (numel () > 0)
     {
       if (numel () > 1)
-        gripe_implicit_conversion ("Octave:array-as-scalar",
+        gripe_implicit_conversion ("Octave:array-to-scalar",
                                    "complex sparse matrix", "real scalar");
 
       retval = std::real (matrix (0, 0));
@@ -150,7 +150,7 @@
   if (numel () > 0)
     {
       if (numel () > 1)
-        gripe_implicit_conversion ("Octave:array-as-scalar",
+        gripe_implicit_conversion ("Octave:array-to-scalar",
                                    "complex sparse matrix", "real scalar");
 
       retval = matrix (0, 0);
@@ -188,8 +188,8 @@
       octave_idx_type nr = matrix.rows ();
 
       for (octave_idx_type j = 0; j < nc; j++)
-        for (octave_idx_type i = matrix.cidx(j); i < matrix.cidx(j+1); i++)
-          retval(matrix.ridx(i) + nr * j) =
+        for (octave_idx_type i = matrix.cidx (j); i < matrix.cidx (j+1); i++)
+          retval(matrix.ridx (i) + nr * j) =
             static_cast<char>(std::real (matrix.data (i)));
     }
 
@@ -228,7 +228,7 @@
                                            bool&save_as_floats)
 {
   dim_vector d = this->dims ();
-  if (d.length() < 1)
+  if (d.length () < 1)
     return false;
 
   // Ensure that additional memory is deallocated
@@ -275,18 +275,18 @@
    for (int i = 0; i < nc+1; i++)
      {
        octave_quit ();
-       itmp = matrix.cidx(i);
+       itmp = matrix.cidx (i);
        os.write (reinterpret_cast<char *> (&itmp), 4);
      }
 
    for (int i = 0; i < nz; i++)
      {
        octave_quit ();
-       itmp = matrix.ridx(i);
+       itmp = matrix.ridx (i);
        os.write (reinterpret_cast<char *> (&itmp), 4);
      }
 
-   write_doubles (os, reinterpret_cast<const double *> (matrix.data()), st, 2 * nz);
+   write_doubles (os, reinterpret_cast<const double *> (matrix.data ()), st, 2 * nz);
 
   return true;
 }
@@ -334,7 +334,7 @@
         return false;
       if (swap)
         swap_bytes<4> (&tmp);
-      m.cidx(i) = tmp;
+      m.cidx (i) = tmp;
     }
 
   for (int i = 0; i < nz; i++)
@@ -344,7 +344,7 @@
         return false;
       if (swap)
         swap_bytes<4> (&tmp);
-      m.ridx(i) = tmp;
+      m.ridx (i) = tmp;
     }
 
   if (! is.read (reinterpret_cast<char *> (&ctmp), 1))
@@ -476,7 +476,7 @@
 
   H5Sclose (space_hid);
 
-  hdims[0] = m.cols() + 1;
+  hdims[0] = m.cols () + 1;
   hdims[1] = 1;
 
   space_hid = H5Screate_simple (2, hdims, 0);
@@ -622,7 +622,7 @@
   dim_vector dv;
   int empty = load_hdf5_empty (loc_id, name, dv);
   if (empty > 0)
-    matrix.resize(dv);
+    matrix.resize (dv);
   if (empty)
     return (empty > 0);
 
@@ -862,14 +862,14 @@
 
   for (mwIndex i = 0; i < nz; i++)
     {
-      Complex val = matrix.data(i);
+      Complex val = matrix.data (i);
       pr[i] = std::real (val);
       pi[i] = std::imag (val);
-      ir[i] = matrix.ridx(i);
+      ir[i] = matrix.ridx (i);
     }
 
-  for (mwIndex i = 0; i < columns() + 1; i++)
-    jc[i] = matrix.cidx(i);
+  for (mwIndex i = 0; i < columns () + 1; i++)
+    jc[i] = matrix.cidx (i);
 
   return retval;
 }
--- a/src/ov-fcn-handle.cc
+++ b/src/ov-fcn-handle.cc
@@ -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
@@ -398,14 +401,14 @@
 
   std::streampos pos = is.tellg ();
   std::string octaveroot = extract_keyword (is, "octaveroot", true);
-  if (octaveroot.length() == 0)
+  if (octaveroot.length () == 0)
     {
       is.seekg (pos);
       is.clear ();
     }
   pos = is.tellg ();
   std::string fpath = extract_keyword (is, "path", true);
-  if (fpath.length() == 0)
+  if (fpath.length () == 0)
     {
       is.seekg (pos);
       is.clear ();
@@ -530,7 +533,7 @@
       else
         nmbuf << nm;
 
-      std::string buf_str = nmbuf.str();
+      std::string buf_str = nmbuf.str ();
       int32_t tmp = buf_str.length ();
       os.write (reinterpret_cast<char *> (&tmp), 4);
       os.write (buf_str.c_str (), buf_str.length ());
@@ -595,11 +598,11 @@
 
   size_t anl = anonymous.length ();
 
-  if (nm.length() >= anl && nm.substr (0, anl) == anonymous)
+  if (nm.length () >= anl && nm.substr (0, anl) == anonymous)
     {
       octave_idx_type len = 0;
 
-      if (nm.length() > anl)
+      if (nm.length () > anl)
         {
           std::istringstream nm_is (nm.substr (anl));
           nm_is >> len;
@@ -1288,7 +1291,6 @@
 #endif
 
 /*
-
 %!test
 %! a = 2;
 %! f = @(x) a + x;
@@ -1302,26 +1304,25 @@
 %! hdld2 = hdld;
 %! hbi2 = hbi;
 %! modes = {"-text", "-binary"};
-%! if (!isempty(findstr(octave_config_info ("DEFS"),"HAVE_HDF5")))
+%! if (!isempty (findstr (octave_config_info ("DEFS"), "HAVE_HDF5")))
 %!   modes(end+1) = "-hdf5";
 %! endif
 %! for i = 1:numel (modes)
 %!   mode = modes{i};
-%!   nm = tmpnam();
+%!   nm = tmpnam ();
 %!   unwind_protect
 %!     save (mode, nm, "f2", "g2", "hm2", "hdld2", "hbi2");
 %!     clear f2 g2 hm2 hdld2 hbi2
 %!     load (nm);
-%!     assert (f(2),f2(2));
-%!     assert (g(2),g2(2));
-%!     assert (g(3),g2(3));
+%!     assert (f (2), f2 (2));
+%!     assert (g (2), g2 (2));
+%!     assert (g (3), g2 (3));
 %!     unlink (nm);
 %!     save (mode, nm, "f2", "g2", "hm2", "hdld2", "hbi2");
 %!   unwind_protect_cleanup
 %!     unlink (nm);
 %!   end_unwind_protect
 %! endfor
-
 */
 
 void
@@ -1592,7 +1593,7 @@
 %!      "&", "and";
 %!      "|", "or"};
 %! for i = 1:rows (x)
-%!   assert (functions (str2func (x{i,1})).function, x{i,2})
+%!   assert (functions (str2func (x{i,1})).function, x{i,2});
 %! endfor
 */
 
@@ -1635,8 +1636,8 @@
                     {
                       m.setfield ("type", "subfunction");
                       Cell parentage (dim_vector (1, 2));
-                      parentage.elem(0) = fh_nm;
-                      parentage.elem(1) = fcn->parent_fcn_name ();
+                      parentage.elem (0) = fh_nm;
+                      parentage.elem (1) = fcn->parent_fcn_name ();
                       m.setfield ("parentage", octave_value (parentage));
                     }
                   else if (fcn->is_private_function ())
@@ -1759,7 +1760,6 @@
 }
 
 /*
-
 %!function y = __testrecursionfunc (f, x, n)
 %!  if (nargin < 3)
 %!    n = 0;
@@ -1768,12 +1768,11 @@
 %!    y = f (x);
 %!  else
 %!    n++;
-%!    y = __testrecursionfunc (@(x) f(2*x), x, n);
+%!    y = __testrecursionfunc (@(x) f (2*x), x, n);
 %!  endif
 %!endfunction
 %!
 %!assert (__testrecursionfunc (@(x) x, 1), 8)
-
 */
 
 DEFUN (is_function_handle, args, ,
@@ -1802,12 +1801,11 @@
 %!assert (is_function_handle (fh))
 %!assert (! is_function_handle ({fh}))
 %!assert (! is_function_handle (1))
-%!error is_function_handle ();
-%!error is_function_handle (1, 2);
 
+%!error is_function_handle ()
+%!error is_function_handle (1, 2)
 */
 
-
 octave_fcn_binder::octave_fcn_binder (const octave_value& f,
                                       const octave_value& root,
                                       const octave_value_list& templ,
--- a/src/ov-fcn-inline.cc
+++ b/src/ov-fcn-inline.cc
@@ -825,9 +825,9 @@
 %! fn = inline ("x.^2 + 1");
 %!assert (feval (fn, 6), 37)
 %!assert (fn (6), 37)
-%% FIXME: Need tests for other 2 calling forms of inline()
+## FIXME: Need tests for other 2 calling forms of inline()
 
-%% Test input validation 
+## Test input validation 
 %!error inline ()
 %!error <STR argument must be a string> inline (1)
 %!error <N must be an integer> inline ("2", ones (2,2))
@@ -867,7 +867,7 @@
 %!assert (formula (fn), "x.^2 + 1")
 %!assert (formula (fn), char (fn))
 
-%% Test input validation
+## Test input validation
 %!error formula ()
 %!error formula (1, 2)
 %!error <FUN must be an inline function> formula (1)
@@ -914,7 +914,7 @@
 %!assert (argnames (inline ("1e-3*y + 2e4*z")), {"y"; "z"})
 %!assert (argnames (inline ("2", 2)), {"x"; "P1"; "P2"})
 
-%% Test input validation
+## Test input validation
 %!error argnames ()
 %!error argnames (1, 2)
 %!error <FUN must be an inline function> argnames (1)
@@ -1012,9 +1012,8 @@
 %!assert (vectorize ("1e-3*y + 2e4*z"), "1e-3.*y + 2e4.*z")
 %!assert (vectorize ("2**x^5"), "2.**x.^5")
 
-%% Test input validation
+## Test input validation
 %!error vectorize ()
 %!error vectorize (1, 2)
 %!error <FUN must be a string or inline function> vectorize (1)
 */
-
--- a/src/ov-float.cc
+++ b/src/ov-float.cc
@@ -79,7 +79,7 @@
 {
   if (fill)
     {
-      FloatNDArray retval (dv, NDArray::resize_fill_value());
+      FloatNDArray retval (dv, 0);
 
       if (dv.numel ())
         retval(0) = scalar;
@@ -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;
@@ -285,6 +291,7 @@
       SCALAR_MAPPER (atanh, rc_atanh);
       SCALAR_MAPPER (erf, ::erff);
       SCALAR_MAPPER (erfinv, ::erfinv);
+      SCALAR_MAPPER (erfcinv, ::erfcinv);
       SCALAR_MAPPER (erfc, ::erfcf);
       SCALAR_MAPPER (erfcx, ::erfcx);
       SCALAR_MAPPER (gamma, xgamma);
--- a/src/ov-float.h
+++ b/src/ov-float.h
@@ -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
+++ b/src/ov-flt-complex.cc
@@ -210,7 +210,7 @@
 {
   if (fill)
     {
-      FloatComplexNDArray retval (dv, FloatComplexNDArray::resize_fill_value ());
+      FloatComplexNDArray retval (dv, FloatComplex (0));
 
       if (dv.numel ())
         retval(0) = scalar;
@@ -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
+++ b/src/ov-flt-complex.h
@@ -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
+++ b/src/ov-flt-cx-mat.cc
@@ -97,7 +97,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "complex matrix", "real scalar");
 
       retval = std::real (matrix (0, 0));
@@ -119,7 +119,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "complex matrix", "real scalar");
 
       retval = std::real (matrix (0, 0));
@@ -167,7 +167,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "complex matrix", "complex scalar");
 
       retval = matrix (0, 0);
@@ -187,7 +187,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "complex matrix", "complex scalar");
 
       retval = matrix (0, 0);
@@ -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)
 {
@@ -408,11 +426,11 @@
 octave_float_complex_matrix::save_binary (std::ostream& os, bool&)
 {
   dim_vector d = dims ();
-  if (d.length() < 1)
+  if (d.length () < 1)
     return false;
 
   // Use negative value for ndims to differentiate with old format!!
-  int32_t tmp = - d.length();
+  int32_t tmp = - d.length ();
   os.write (reinterpret_cast<char *> (&tmp), 4);
   for (int i = 0; i < d.length (); i++)
     {
@@ -593,7 +611,7 @@
   dim_vector dv;
   int empty = load_hdf5_empty (loc_id, name, dv);
   if (empty > 0)
-    matrix.resize(dv);
+    matrix.resize (dv);
   if (empty)
       return (empty > 0);
 
--- a/src/ov-flt-cx-mat.h
+++ b/src/ov-flt-cx-mat.h
@@ -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
+++ b/src/ov-flt-re-mat.cc
@@ -96,7 +96,7 @@
 
   if (numel () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "real matrix", "real scalar");
 
       retval = matrix (0, 0);
@@ -114,7 +114,7 @@
 
   if (numel () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "real matrix", "real scalar");
 
       retval = matrix (0, 0);
@@ -148,7 +148,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "real matrix", "complex scalar");
 
       retval = matrix (0, 0);
@@ -168,7 +168,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "real matrix", "complex scalar");
 
       retval = matrix (0, 0);
@@ -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;
@@ -441,11 +459,11 @@
 {
 
   dim_vector d = dims ();
-  if (d.length() < 1)
+  if (d.length () < 1)
     return false;
 
   // Use negative value for ndims to differentiate with old format!!
-  int32_t tmp = - d.length();
+  int32_t tmp = - d.length ();
   os.write (reinterpret_cast<char *> (&tmp), 4);
   for (int i = 0; i < d.length (); i++)
     {
@@ -606,7 +624,7 @@
   dim_vector dv;
   int empty = load_hdf5_empty (loc_id, name, dv);
   if (empty > 0)
-    matrix.resize(dv);
+    matrix.resize (dv);
   if (empty)
       return (empty > 0);
 
@@ -766,6 +784,7 @@
       RC_ARRAY_MAPPER (atanh, FloatComplex, rc_atanh);
       ARRAY_MAPPER (erf, float, ::erff);
       ARRAY_MAPPER (erfinv, float, ::erfinv);
+      ARRAY_MAPPER (erfcinv, float, ::erfcinv);
       ARRAY_MAPPER (erfc, float, ::erfcf);
       ARRAY_MAPPER (erfcx, float, ::erfcx);
       ARRAY_MAPPER (gamma, float, xgamma);
@@ -841,9 +860,8 @@
 }
 
 /*
-
-%!assert (class (single(1)), "single")
-%!assert (class (single(1 + i)), "single")
+%!assert (class (single (1)), "single")
+%!assert (class (single (1 + i)), "single")
 %!assert (class (single (int8 (1))), "single")
 %!assert (class (single (uint8 (1))), "single")
 %!assert (class (single (int16 (1))), "single")
@@ -865,6 +883,4 @@
 %! y = single (x);
 %! assert (class (x), "double");
 %! assert (class (y), "single");
-
 */
-
--- a/src/ov-flt-re-mat.h
+++ b/src/ov-flt-re-mat.h
@@ -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-int16.cc
+++ b/src/ov-int16.cc
@@ -84,13 +84,10 @@
 }
 
 /*
-
 %!assert (class (int16 (1)), "int16")
 %!assert (int16 (1.25), int16 (1))
 %!assert (int16 (1.5), int16 (2))
 %!assert (int16 (-1.5), int16 (-2))
 %!assert (int16 (2^17), int16 (2^16-1))
 %!assert (int16 (-2^17), int16 (-2^16))
-
 */
-
--- a/src/ov-int32.cc
+++ b/src/ov-int32.cc
@@ -84,13 +84,10 @@
 }
 
 /*
-
 %!assert (class (int32 (1)), "int32")
 %!assert (int32 (1.25), int32 (1))
 %!assert (int32 (1.5), int32 (2))
 %!assert (int32 (-1.5), int32 (-2))
 %!assert (int32 (2^33), int32 (2^32-1))
 %!assert (int32 (-2^33), int32 (-2^32))
-
 */
-
--- a/src/ov-int64.cc
+++ b/src/ov-int64.cc
@@ -84,13 +84,10 @@
 }
 
 /*
-
 %!assert (class (int64 (1)), "int64")
 %!assert (int64 (1.25), int64 (1))
 %!assert (int64 (1.5), int64 (2))
 %!assert (int64 (-1.5), int64 (-2))
 %!assert (int64 (2^65), int64 (2^64-1))
 %!assert (int64 (-2^65), int64 (-2^64))
-
 */
-
--- a/src/ov-int8.cc
+++ b/src/ov-int8.cc
@@ -84,12 +84,10 @@
 }
 
 /*
-
 %!assert (class (int8 (1)), "int8")
 %!assert (int8 (1.25), int8 (1))
 %!assert (int8 (1.5), int8 (2))
 %!assert (int8 (-1.5), int8 (-2))
 %!assert (int8 (2^9), int8 (2^8-1))
 %!assert (int8 (-2^9), int8 (-2^8))
-
 */
--- a/src/ov-intx.h
+++ b/src/ov-intx.h
@@ -104,7 +104,7 @@
 
       if (numel () > 0)
         {
-          gripe_implicit_conversion ("Octave:array-as-scalar",
+          gripe_implicit_conversion ("Octave:array-to-scalar",
                                      type_name (), "real scalar");
 
           retval = matrix(0).double_value ();
@@ -123,7 +123,7 @@
 
       if (numel () > 0)
         {
-          gripe_implicit_conversion ("Octave:array-as-scalar",
+          gripe_implicit_conversion ("Octave:array-to-scalar",
                                      type_name (), "real scalar");
 
           retval = matrix(0).float_value ();
@@ -145,7 +145,7 @@
       Matrix retval;
       dim_vector dv = dims ();
       if (dv.length () > 2)
-        error ("invalid conversion of %s to Matrix", type_name().c_str ());
+        error ("invalid conversion of %s to Matrix", type_name ().c_str ());
       else
         {
           retval = Matrix (dv(0), dv(1));
@@ -163,7 +163,7 @@
       FloatMatrix retval;
       dim_vector dv = dims ();
       if (dv.length () > 2)
-        error ("invalid conversion of %s to FloatMatrix", type_name().c_str ());
+        error ("invalid conversion of %s to FloatMatrix", type_name ().c_str ());
       else
         {
           retval = FloatMatrix (dv(0), dv(1));
@@ -179,9 +179,9 @@
   complex_matrix_value (bool = false) const
     {
       ComplexMatrix retval;
-      dim_vector dv = dims();
+      dim_vector dv = dims ();
       if (dv.length () > 2)
-        error ("invalid conversion of %s to Matrix", type_name().c_str ());
+        error ("invalid conversion of %s to Matrix", type_name ().c_str ());
       else
         {
           retval = ComplexMatrix (dv(0), dv(1));
@@ -197,9 +197,9 @@
   float_complex_matrix_value (bool = false) const
     {
       FloatComplexMatrix retval;
-      dim_vector dv = dims();
+      dim_vector dv = dims ();
       if (dv.length () > 2)
-        error ("invalid conversion of %s to FloatMatrix", type_name().c_str ());
+        error ("invalid conversion of %s to FloatMatrix", type_name ().c_str ());
       else
         {
           retval = FloatComplexMatrix (dv(0), dv(1));
@@ -289,12 +289,12 @@
   // Use matrix_ref here to clear index cache.
   void increment (void)
    {
-     matrix_ref() += OCTAVE_INT_T (1);
+     matrix_ref () += OCTAVE_INT_T (1);
    }
 
   void decrement (void)
    {
-     matrix_ref() -= OCTAVE_INT_T (1);
+     matrix_ref () -= OCTAVE_INT_T (1);
    }
 
   void changesign (void)
@@ -479,14 +479,14 @@
       if (fill)
         {
           intNDArray<OCTAVE_INT_T> retval (dv, 0);
-          if (dv.numel())
+          if (dv.numel ())
             retval(0) = scalar;
           return retval;
         }
       else
         {
           intNDArray<OCTAVE_INT_T> retval (dv);
-          if (dv.numel())
+          if (dv.numel ())
             retval(0) = scalar;
           return retval;
         }
--- a/src/ov-null-mat.cc
+++ b/src/ov-null-mat.cc
@@ -96,6 +96,7 @@
 delete array elements.  This function should be used when overloading\n\
 indexed assignment for user-defined classes instead of @code{isempty}, to\n\
 distinguish the cases:\n\
+\n\
 @table @asis\n\
 @item @code{A(I) = []}\n\
 This should delete elements if @code{I} is nonempty.\n\
@@ -119,7 +120,6 @@
 }
 
 /*
-
 %!assert (isnull ([]), true)
 %!assert (isnull ([1]), false)
 %!assert (isnull (zeros (0,3)), false)
@@ -130,5 +130,4 @@
 %!test
 %! x = [];
 %! assert (isnull (x), false);
-
 */
--- a/src/ov-oncleanup.cc
+++ b/src/ov-oncleanup.cc
@@ -211,17 +211,15 @@
 }
 
 /*
-
 %!test
 %! old_wstate = warning ("query");
 %! unwind_protect
 %!   trigger = onCleanup (@() warning ("on", "__MY_WARNING__"));
 %!   warning ("off", "__MY_WARNING__");
 %!   assert ((warning ("query", "__MY_WARNING__")).state, "off");
-%!   clear trigger
+%!   clear trigger;
 %!   assert ((warning ("query", "__MY_WARNING__")).state, "on");
 %! unwind_protect_cleanup
 %!   warning (old_wstate);
 %! end_unwind_protect
-
 */
--- a/src/ov-perm.cc
+++ b/src/ov-perm.cc
@@ -135,7 +135,7 @@
 
   if (numel () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  type_name (), "real scalar");
 
       retval = matrix (0, 0);
@@ -153,7 +153,7 @@
 
   if (numel () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  type_name (), "real scalar");
 
       retval = matrix (0, 0);
@@ -173,7 +173,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  type_name (), "complex scalar");
 
       retval = matrix (0, 0);
@@ -193,7 +193,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  type_name (), "complex scalar");
 
       retval = matrix (0, 0);
--- a/src/ov-range.cc
+++ b/src/ov-range.cc
@@ -175,7 +175,7 @@
 
   if (nel > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "range", "real scalar");
 
       retval = range.base ();
@@ -195,7 +195,7 @@
 
   if (nel > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "range", "real scalar");
 
       retval = range.base ();
@@ -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
@@ -277,7 +284,7 @@
 
   if (nel > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "range", "complex scalar");
 
       retval = range.base ();
@@ -299,7 +306,7 @@
 
   if (nel > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "range", "complex scalar");
 
       retval = range.base ();
@@ -328,7 +335,7 @@
 {
   NDArray retval = array_value ();
   if (fill)
-    retval.resize (dv, NDArray::resize_fill_value ());
+    retval.resize (dv, 0);
   else
     retval.resize (dv);
   return retval;
@@ -670,7 +677,7 @@
 %! warn_state = warning ("query", "Octave:noninteger-range-as-index");
 %! unwind_protect
 %!   allow_noninteger_range_as_index (false);
-%!   fail ('x(2.1:5)');
+%!   fail ("x(2.1:5)");
 %!   assert (x(2:5), 1:4);
 %!   allow_noninteger_range_as_index (true);
 %!   warning ("off", "Octave:noninteger-range-as-index");
--- a/src/ov-range.h
+++ b/src/ov-range.h
@@ -118,10 +118,10 @@
   size_t byte_size (void) const { return 3 * sizeof (double); }
 
   octave_value reshape (const dim_vector& new_dims) const
-    { return NDArray (array_value().reshape (new_dims)); }
+    { return NDArray (array_value ().reshape (new_dims)); }
 
   octave_value permute (const Array<int>& vec, bool inv = false) const
-    { return NDArray (array_value().permute (vec, inv)); }
+    { return NDArray (array_value ().permute (vec, inv)); }
 
   octave_value squeeze (void) const { return range; }
 
@@ -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
+++ b/src/ov-re-mat.cc
@@ -89,8 +89,8 @@
 octave_base_value::type_conv_info
 octave_matrix::numeric_demotion_function (void) const
 {
-  return octave_base_value::type_conv_info(default_numeric_demotion_function,
-                                           octave_float_matrix::static_type_id ());
+  return octave_base_value::type_conv_info (default_numeric_demotion_function,
+                                            octave_float_matrix::static_type_id ());
 }
 
 octave_base_value *
@@ -111,7 +111,7 @@
 
   if (numel () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "real matrix", "real scalar");
 
       retval = matrix (0, 0);
@@ -129,7 +129,7 @@
 
   if (numel () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "real matrix", "real scalar");
 
       retval = matrix (0, 0);
@@ -163,7 +163,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "real matrix", "complex scalar");
 
       retval = matrix (0, 0);
@@ -183,7 +183,7 @@
 
   if (rows () > 0 && columns () > 0)
     {
-      gripe_implicit_conversion ("Octave:array-as-scalar",
+      gripe_implicit_conversion ("Octave:array-to-scalar",
                                  "real matrix", "complex scalar");
 
       retval = matrix (0, 0);
@@ -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
@@ -543,11 +561,11 @@
 {
 
   dim_vector d = dims ();
-  if (d.length() < 1)
+  if (d.length () < 1)
     return false;
 
   // Use negative value for ndims to differentiate with old format!!
-  int32_t tmp = - d.length();
+  int32_t tmp = - d.length ();
   os.write (reinterpret_cast<char *> (&tmp), 4);
   for (int i = 0; i < d.length (); i++)
     {
@@ -729,7 +747,7 @@
   dim_vector dv;
   int empty = load_hdf5_empty (loc_id, name, dv);
   if (empty > 0)
-    matrix.resize(dv);
+    matrix.resize (dv);
   if (empty)
       return (empty > 0);
 
@@ -889,6 +907,7 @@
       RC_ARRAY_MAPPER (atanh, Complex, rc_atanh);
       ARRAY_MAPPER (erf, double, ::erf);
       ARRAY_MAPPER (erfinv, double, ::erfinv);
+      ARRAY_MAPPER (erfcinv, double, ::erfcinv);
       ARRAY_MAPPER (erfc, double, ::erfc);
       ARRAY_MAPPER (erfcx, double, ::erfcx);
       ARRAY_MAPPER (gamma, double, xgamma);
@@ -981,7 +1000,6 @@
 }
 
 /*
-
 %!assert (class (double (single (1))), "double")
 %!assert (class (double (single (1 + i))), "double")
 %!assert (class (double (int8 (1))), "double")
@@ -1010,5 +1028,4 @@
 %! y = double (x);
 %! assert (class (x), "single");
 %! assert (class (y), "double");
-
 */
--- a/src/ov-re-mat.h
+++ b/src/ov-re-mat.h
@@ -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-re-sparse.cc
+++ b/src/ov-re-sparse.cc
@@ -100,7 +100,7 @@
   if (numel () > 0)
     {
       if (numel () > 1)
-        gripe_implicit_conversion ("Octave:array-as-scalar",
+        gripe_implicit_conversion ("Octave:array-to-scalar",
                                    "real sparse matrix", "real scalar");
 
       retval = matrix (0, 0);
@@ -122,7 +122,7 @@
   if (rows () > 0 && columns () > 0)
     {
       if (numel () > 1)
-        gripe_implicit_conversion ("Octave:array-as-scalar",
+        gripe_implicit_conversion ("Octave:array-to-scalar",
                                    "real sparse matrix", "complex scalar");
 
       retval = matrix (0, 0);
@@ -160,8 +160,8 @@
   octave_idx_type nr = matrix.rows ();
 
   for (octave_idx_type j = 0; j < nc; j++)
-    for (octave_idx_type i = matrix.cidx(j); i < matrix.cidx(j+1); i++)
-      retval(matrix.ridx(i) + nr * j) = static_cast<char>(matrix.data (i));
+    for (octave_idx_type i = matrix.cidx (j); i < matrix.cidx (j+1); i++)
+      retval(matrix.ridx (i) + nr * j) = static_cast<char>(matrix.data (i));
 
   return retval;
 }
@@ -216,8 +216,8 @@
       bool warned = false;
 
       for (octave_idx_type j = 0; j < nc; j++)
-        for (octave_idx_type i = matrix.cidx(j);
-             i < matrix.cidx(j+1); i++)
+        for (octave_idx_type i = matrix.cidx (j);
+             i < matrix.cidx (j+1); i++)
           {
             octave_quit ();
 
@@ -246,7 +246,7 @@
                         }
                     }
 
-                  chm (matrix.ridx(i) + j * nr) =
+                  chm (matrix.ridx (i) + j * nr) =
                     static_cast<char> (ival);
                 }
           }
@@ -261,7 +261,7 @@
 octave_sparse_matrix::save_binary (std::ostream& os, bool&save_as_floats)
 {
   dim_vector d = this->dims ();
-  if (d.length() < 1)
+  if (d.length () < 1)
     return false;
 
   // Ensure that additional memory is deallocated
@@ -308,18 +308,18 @@
    for (int i = 0; i < nc+1; i++)
      {
        octave_quit ();
-       itmp = matrix.cidx(i);
+       itmp = matrix.cidx (i);
        os.write (reinterpret_cast<char *> (&itmp), 4);
      }
 
    for (int i = 0; i < nz; i++)
      {
        octave_quit ();
-       itmp = matrix.ridx(i);
+       itmp = matrix.ridx (i);
        os.write (reinterpret_cast<char *> (&itmp), 4);
      }
 
-   write_doubles (os, matrix.data(), st, nz);
+   write_doubles (os, matrix.data (), st, nz);
 
   return true;
 }
@@ -367,7 +367,7 @@
         return false;
       if (swap)
         swap_bytes<4> (&tmp);
-      m.xcidx(i) = tmp;
+      m.xcidx (i) = tmp;
     }
 
   for (int i = 0; i < nz; i++)
@@ -377,7 +377,7 @@
         return false;
       if (swap)
         swap_bytes<4> (&tmp);
-      m.xridx(i) = tmp;
+      m.xridx (i) = tmp;
     }
 
   if (! is.read (reinterpret_cast<char *> (&ctmp), 1))
@@ -506,7 +506,7 @@
 
   H5Sclose (space_hid);
 
-  hdims[0] = m.cols() + 1;
+  hdims[0] = m.cols () + 1;
   hdims[1] = 1;
 
   space_hid = H5Screate_simple (2, hdims, 0);
@@ -637,7 +637,7 @@
   dim_vector dv;
   int empty = load_hdf5_empty (loc_id, name, dv);
   if (empty > 0)
-    matrix.resize(dv);
+    matrix.resize (dv);
   if (empty)
     return (empty > 0);
 
@@ -857,22 +857,22 @@
 mxArray *
 octave_sparse_matrix::as_mxArray (void) const
 {
-  mwSize nz = nzmax();
-  mwSize nr = rows();
-  mwSize nc = columns();
+  mwSize nz = nzmax ();
+  mwSize nr = rows ();
+  mwSize nc = columns ();
   mxArray *retval = new mxArray (mxDOUBLE_CLASS, nr, nc, nz, mxREAL);
   double *pr = static_cast<double *> (retval->get_data ());
-  mwIndex *ir = retval->get_ir();
-  mwIndex *jc = retval->get_jc();
+  mwIndex *ir = retval->get_ir ();
+  mwIndex *jc = retval->get_jc ();
 
   for (mwIndex i = 0; i < nz; i++)
     {
-      pr[i] = matrix.data(i);
-      ir[i] = matrix.ridx(i);
+      pr[i] = matrix.data (i);
+      ir[i] = matrix.ridx (i);
     }
 
   for (mwIndex i = 0; i < nc + 1; i++)
-    jc[i] = matrix.cidx(i);
+    jc[i] = matrix.cidx (i);
 
   return retval;
 }
@@ -910,6 +910,7 @@
       ARRAY_MAPPER (atanh, Complex, rc_atanh);
       ARRAY_MAPPER (erf, double, ::erf);
       ARRAY_MAPPER (erfinv, double, ::erfinv);
+      ARRAY_MAPPER (erfcinv, double, ::erfcinv);
       ARRAY_MAPPER (erfc, double, ::erfc);
       ARRAY_MAPPER (gamma, double, xgamma);
       ARRAY_MAPPER (lgamma, Complex, rc_lgamma);
--- a/src/ov-scalar.cc
+++ b/src/ov-scalar.cc
@@ -67,8 +67,8 @@
 octave_base_value::type_conv_info
 octave_scalar::numeric_demotion_function (void) const
 {
-  return octave_base_value::type_conv_info(default_numeric_demotion_function,
-                                           octave_float_scalar::static_type_id ());
+  return octave_base_value::type_conv_info (default_numeric_demotion_function,
+                                            octave_float_scalar::static_type_id ());
 }
 
 octave_value
@@ -94,7 +94,7 @@
 {
   if (fill)
     {
-      NDArray retval (dv, NDArray::resize_fill_value());
+      NDArray retval (dv, 0);
 
       if (dv.numel ())
         retval(0) = scalar;
@@ -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;
@@ -301,6 +307,7 @@
       SCALAR_MAPPER (atanh, rc_atanh);
       SCALAR_MAPPER (erf, ::erf);
       SCALAR_MAPPER (erfinv, ::erfinv);
+      SCALAR_MAPPER (erfcinv, ::erfcinv);
       SCALAR_MAPPER (erfc, ::erfc);
       SCALAR_MAPPER (erfcx, ::erfcx);
       SCALAR_MAPPER (gamma, xgamma);
--- a/src/ov-scalar.h
+++ b/src/ov-scalar.h
@@ -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-str-mat.cc
+++ b/src/ov-str-mat.cc
@@ -143,7 +143,7 @@
 {
   charNDArray retval (matrix);
   if (fill)
-    retval.resize (dv, charNDArray::resize_fill_value ());
+    retval.resize (dv, 0);
   else
     retval.resize (dv);
   return octave_value (retval, is_sq_string () ? '\'' : '"');
@@ -252,7 +252,7 @@
       octave_idx_type nr = chm.rows ();
       retval.clear (nr, 1);
       for (octave_idx_type i = 0; i < nr; i++)
-        retval.xelem(i) = chm.row_as_string (i);
+        retval.xelem (i) = chm.row_as_string (i);
     }
   else
     error ("cellstr: cannot convert multidimensional arrays");
@@ -465,11 +465,11 @@
                                      bool& /* save_as_floats */)
 {
   dim_vector d = dims ();
-  if (d.length() < 1)
+  if (d.length () < 1)
     return false;
 
   // Use negative value for ndims to differentiate with old format!!
-  int32_t tmp = - d.length();
+  int32_t tmp = - d.length ();
   os.write (reinterpret_cast<char *> (&tmp), 4);
   for (int i=0; i < d.length (); i++)
     {
@@ -615,7 +615,7 @@
   dim_vector dv;
   int empty = load_hdf5_empty (loc_id, name, dv);
   if (empty > 0)
-    matrix.resize(dv);
+    matrix.resize (dv);
   if (empty)
     return (empty > 0);
 
--- a/src/ov-struct.cc
+++ b/src/ov-struct.cc
@@ -154,7 +154,7 @@
 
     case '.':
       {
-        if (map.numel() > 0)
+        if (map.numel () > 0)
           {
             const Cell t = dotref (idx.front ());
 
@@ -220,7 +220,7 @@
 
     case '.':
       {
-        if (map.numel() > 0)
+        if (map.numel () > 0)
           {
             const Cell t = dotref (idx.front (), auto_add);
 
@@ -249,7 +249,8 @@
 
 /*
 %!test
-%! x(1).a.a = 1; x(2).a.a = 2;
+%! x(1).a.a = 1;
+%! x(2).a.a = 2;
 %! assert (size (x), [1, 2]);
 %! assert (x(1).a.a, 1);
 %! assert (x(2).a.a, 2);
@@ -480,7 +481,7 @@
               }
             else
               {
-                if (t_rhs.is_map() || t_rhs.is_object ())
+                if (t_rhs.is_map () || t_rhs.is_object ())
                   {
                     octave_map rhs_map = t_rhs.map_value ();
 
@@ -501,9 +502,9 @@
                   }
                 else
                   {
-                    if (t_rhs.is_null_value())
+                    if (t_rhs.is_null_value ())
                       {
-                        map.delete_elements (idx.front());
+                        map.delete_elements (idx.front ());
 
                         if (! error_state)
                           {
@@ -691,25 +692,6 @@
   return dims.length () == 2 && dims (0) == 1 && dims (1) == 1;
 }
 
-/*
-%!shared x
-%! x(1).a=1; x(2).a=2; x(1).b=3; x(2).b=3;
-%!assert(struct('a',1,'b',3),x(1))
-%!assert(isempty(x([])))
-%!assert(isempty(struct('a',{},'b',{})))
-%!assert(struct('a',{1,2},'b',{3,3}),x)
-%!assert(struct('a',{1,2},'b',3),x)
-%!assert(struct('a',{1,2},'b',{3}),x)
-%!assert(struct('b',3,'a',{1,2}),x)
-%!assert(struct('b',{3},'a',{1,2}),x)
-%!test x=struct([]);
-%!assert(size(x),[0,0]);
-%!assert(isstruct(x));
-%!assert(isempty(fieldnames(x)));
-%!fail("struct('a',{1,2},'b',{1,2,3})","dimensions of parameter 2 do not match those of parameter 4")
-%!fail("struct(1,2,3,4)","struct: expecting alternating \"field\", VALUE pairs");
-%!fail("struct('1',2,'3')","struct: expecting alternating \"field\", VALUE pairs");
-*/
 
 bool
 octave_struct::save_ascii (std::ostream& os)
@@ -841,7 +823,7 @@
     return false;
 
   // Use negative value for ndims
-  int32_t di = - d.length();
+  int32_t di = - d.length ();
   os.write (reinterpret_cast<char *> (&di), 4);
   for (int i = 0; i < d.length (); i++)
     {
@@ -1097,7 +1079,7 @@
       // itself.
       const octave_scalar_map *sm_ptr;
       void *here = reinterpret_cast<void *>(&sm_ptr);
-      return (x.get_rep().fast_elem_insert_self (here, btyp_struct)
+      return (x.get_rep ().fast_elem_insert_self (here, btyp_struct)
               && map.fast_elem_insert (n, *sm_ptr));
     }
 
@@ -1189,7 +1171,8 @@
 
 /*
 %!test
-%! x(1).a.a = 1; x(2).a.a = 2;
+%! x(1).a.a = 1;
+%! x(2).a.a = 2;
 %! assert (size (x), [1, 2]);
 %! assert (x(1).a.a, 1);
 %! assert (x(2).a.a, 2);
@@ -1712,25 +1695,6 @@
   else
     return false;
 }
-/*
-%!shared x
-%! x(1).a=1; x(2).a=2; x(1).b=3; x(2).b=3;
-%!assert(struct('a',1,'b',3),x(1))
-%!assert(isempty(x([])))
-%!assert(isempty(struct('a',{},'b',{})))
-%!assert(struct('a',{1,2},'b',{3,3}),x)
-%!assert(struct('a',{1,2},'b',3),x)
-%!assert(struct('a',{1,2},'b',{3}),x)
-%!assert(struct('b',3,'a',{1,2}),x)
-%!assert(struct('b',{3},'a',{1,2}),x)
-%!test x=struct([]);
-%!assert(size(x),[0,0]);
-%!assert(isstruct(x));
-%!assert(isempty(fieldnames(x)));
-%!fail("struct('a',{1,2},'b',{1,2,3})","dimensions of parameter 2 do not match those of parameter 4")
-%!fail("struct(1,2,3,4)","struct: expecting alternating \"field\", VALUE pairs");
-%!fail("struct('1',2,'3')","struct: expecting alternating \"field\", VALUE pairs");
-*/
 
 DEFUN (struct, args, ,
   "-*- texinfo -*-\n\
@@ -1874,6 +1838,26 @@
   return octave_value (map);
 }
 
+/*
+%!shared x
+%! x(1).a=1;  x(2).a=2;  x(1).b=3;  x(2).b=3;
+%!assert (struct ("a",1, "b",3), x(1))
+%!assert (isempty (x([])))
+%!assert (isempty (struct ("a",{}, "b",{})))
+%!assert (struct ("a",{1,2}, "b",{3,3}), x)
+%!assert (struct ("a",{1,2}, "b",3), x)
+%!assert (struct ("a",{1,2}, "b",{3}), x)
+%!assert (struct ("b",3, "a",{1,2}), x)
+%!assert (struct ("b",{3}, "a",{1,2}), x)
+%!test x = struct ([]);
+%!assert (size (x), [0,0])
+%!assert (isstruct (x))
+%!assert (isempty (fieldnames (x)))
+%!fail ('struct ("a",{1,2},"b",{1,2,3})', 'dimensions of parameter 2 do not match those of parameter 4')
+%!fail ('struct (1,2,3,4)', 'struct: expecting alternating "field", VALUE pairs')
+%!fail ('struct ("1",2,"3")', 'struct: expecting alternating "field", VALUE pairs')
+*/
+
 DEFUN (isstruct, args, ,
   "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} isstruct (@var{x})\n\
@@ -1928,10 +1912,10 @@
 }
 
 /*
-%!# test preservation of fieldname order
+## test preservation of fieldname order
 %!test
-%!  x(3).d=1; x(2).a=2; x(1).b=3; x(2).c=3;
-%!  assert(fieldnames(x), {"d"; "a"; "b"; "c"});
+%! x(3).d=1;  x(2).a=2; x(1).b=3;  x(2).c=3;
+%! assert (fieldnames (x), {"d"; "a"; "b"; "c"});
 */
 
 DEFUN (isfield, args, ,
@@ -2012,15 +1996,15 @@
 }
 
 /*
-%!# test isfield
+## test isfield
 %!test
-%!  x(3).d=1; x(2).a=2; x(1).b=3; x(2).c=3;
-%!  assert (isfield (x, 'b'));
-%!assert (isfield (struct('a', '1'), 'a'));
-%!assert (isfield ({1}, 'c'), false);
-%!assert (isfield (struct('a', '1'), 10), false);
-%!assert (isfield (struct('a', 'b'), "a "), false);
-%!assert (isfield (struct('a', 1, 'b', 2), {'a', 'c'}), [true, false]);
+%! x(3).d=1;  x(2).a=2;  x(1).b=3;  x(2).c=3;
+%! assert (isfield (x, "b"));
+%!assert (isfield (struct ("a", "1"), "a"))
+%!assert (isfield ({1}, "c"), false)
+%!assert (isfield (struct ("a", "1"), 10), false)
+%!assert (isfield (struct ("a", "b"), "a "), false)
+%!assert (isfield (struct ("a", 1, "b", 2), {"a", "c"}), [true, false])
 */
 
 DEFUN (cell2struct, args, ,
@@ -2033,15 +2017,15 @@
 \n\
 @example\n\
 @group\n\
-A = cell2struct (@{'Peter', 'Hannah', 'Robert';\n\
+A = cell2struct (@{\"Peter\", \"Hannah\", \"Robert\";\n\
                    185, 170, 168@},\n\
-                 @{'Name','Height'@}, 1);\n\
+                 @{\"Name\",\"Height\"@}, 1);\n\
 A(1)\n\
-     @result{} ans =\n\
-        @{\n\
-          Name   = Peter\n\
-          Height = 185\n\
-        @}\n\
+   @result{}\n\
+      @{\n\
+        Name   = Peter\n\
+        Height = 185\n\
+      @}\n\
 \n\
 @end group\n\
 @end example\n\
@@ -2138,15 +2122,15 @@
 }
 
 /*
-%!# test cell2struct versus struct2cell
+## test cell2struct versus struct2cell
 %!test
-%!  keys = cellstr (char (floor (rand (100,10)*24+65)))';
-%!  vals = mat2cell(rand (100,1), ones (100,1), 1)';
-%!  s = struct ([keys; vals]{:});
-%!  t = cell2struct (vals, keys, 2);
-%!  assert (s, t);
-%!  assert (struct2cell (s), vals');
-%!  assert (fieldnames (s), keys');
+%! keys = cellstr (char (floor (rand (100,10)*24+65)))';
+%! vals = mat2cell (rand (100,1), ones (100,1), 1)';
+%! s = struct ([keys; vals]{:});
+%! t = cell2struct (vals, keys, 2);
+%! assert (s, t);
+%! assert (struct2cell (s), vals');
+%! assert (fieldnames (s), keys');
 
 %!assert (cell2struct ({1; 2}, {"a"; "b"}), struct ("a", 1, "b", 2));
 
@@ -2206,12 +2190,12 @@
 }
 
 /*
-%!# test rmfield
+## test rmfield
 %!test
-%!  x(3).d=1; x(2).a=2; x(1).b=3; x(2).c=3; x(6).f="abc123";
-%!  y = rmfield (x, {"a", "f"});
-%!  assert (fieldnames (y), {"d"; "b"; "c"});
-%!  assert (size (y), [1, 6]);
+%! x(3).d=1;  x(2).a=2;  x(1).b=3;  x(2).c=3;  x(6).f="abc123";
+%! y = rmfield (x, {"a", "f"});
+%! assert (fieldnames (y), {"d"; "b"; "c"});
+%! assert (size (y), [1, 6]);
 */
 
 DEFUN (struct_levels_to_print, args, nargout,
--- a/src/ov-typeinfo.cc
+++ b/src/ov-typeinfo.cc
@@ -620,72 +620,88 @@
 }
 
 /*
-%!error typeinfo ("foo", 1);
+%!assert (iscellstr (typeinfo ()))
 
-%!assert (iscellstr (typeinfo ()));
+%!assert (typeinfo ({"cell"}), "cell")
 
-%!assert (typeinfo (false), "bool");
-%!assert (typeinfo ([true, false]), "bool matrix");
-
-%!assert (typeinfo (1:2), "range");
+%!assert (typeinfo (1), "scalar")
+%!assert (typeinfo (double (1)), "scalar")
+%!assert (typeinfo (i), "complex scalar")
 
-%!assert (typeinfo ("string"), "string");
-%!assert (typeinfo ('string'), "sq_string");
-
+%!assert (typeinfo ([1, 2]), "matrix")
+%!assert (typeinfo (double ([1, 2])), "matrix")
 %!assert (typeinfo (diag ([1, 2])), "diagonal matrix")
+%!assert (typeinfo ([i, 2]), "complex matrix")
 %!assert (typeinfo (diag ([i, 2])), "complex diagonal matrix")
-%!assert (typeinfo (single (diag ([1, 2]))), "float diagonal matrix")
-%!assert (typeinfo (single (diag ([i, 2]))), "float complex diagonal matrix")
-%!assert (typeinfo (diag (single ([1, 2]))), "float diagonal matrix")
-%!assert (typeinfo (diag (single ([i, 2]))), "float complex diagonal matrix")
+
+%!assert (typeinfo (1:2), "range")
 
-%!assert (typeinfo ([]), "null_matrix");
-%!assert (typeinfo (""), "null_string");
-%!assert (typeinfo (''), "null_sq_string");
+%!assert (typeinfo (false), "bool")
+%!assert (typeinfo ([true, false]), "bool matrix")
+
+%!assert (typeinfo ("string"), "string")
+%!assert (typeinfo ('string'), "sq_string")
 
-%!assert (typeinfo (1), "scalar");
-%!assert (typeinfo (double (1)), "scalar");
-%!assert (typeinfo ([1, 2]), "matrix");
-%!assert (typeinfo (double ([1, 2])), "matrix");
-
-%!assert (typeinfo (i), "complex scalar");
-%!assert (typeinfo ([i, 2]), "complex matrix");
-
-%!assert (typeinfo (single (1)), "float scalar");
-%!assert (typeinfo (single ([1, 2])), "float matrix");
+%!assert (typeinfo (int8 (1)), "int8 scalar")
+%!assert (typeinfo (int16 (1)), "int16 scalar")
+%!assert (typeinfo (int32 (1)), "int32 scalar")
+%!assert (typeinfo (int64 (1)), "int64 scalar")
+%!assert (typeinfo (uint8 (1)), "uint8 scalar")
+%!assert (typeinfo (uint16 (1)), "uint16 scalar")
+%!assert (typeinfo (uint32 (1)), "uint32 scalar")
+%!assert (typeinfo (uint64 (1)), "uint64 scalar")
 
-%!assert (typeinfo (single (i)), "float complex scalar");
-%!assert (typeinfo (single ([i, 2])), "float complex matrix");
-
-%!assert (typeinfo (sparse (eye (10))), "sparse matrix");
-%!assert (typeinfo (sparse (i * eye (10))), "sparse complex matrix");
-%!assert (typeinfo (logical (sparse (i * eye (10)))), "sparse bool matrix");
+%!assert (typeinfo (int8 ([1,2])), "int8 matrix")
+%!assert (typeinfo (int16 ([1,2])), "int16 matrix")
+%!assert (typeinfo (int32 ([1,2])), "int32 matrix")
+%!assert (typeinfo (int64 ([1,2])), "int64 matrix")
+%!assert (typeinfo (uint8 ([1,2])), "uint8 matrix")
+%!assert (typeinfo (uint16 ([1,2])), "uint16 matrix")
+%!assert (typeinfo (uint32 ([1,2])), "uint32 matrix")
+%!assert (typeinfo (uint64 ([1,2])), "uint64 matrix")
 
-%!assert (typeinfo (int8 (1)), "int8 scalar");
-%!assert (typeinfo (int16 (1)), "int16 scalar");
-%!assert (typeinfo (int32 (1)), "int32 scalar");
-%!assert (typeinfo (int64 (1)), "int64 scalar");
-%!assert (typeinfo (uint8 (1)), "uint8 scalar");
-%!assert (typeinfo (uint16 (1)), "uint16 scalar");
-%!assert (typeinfo (uint32 (1)), "uint32 scalar");
-%!assert (typeinfo (uint64 (1)), "uint64 scalar");
+%!assert (typeinfo (sparse ([true, false])), "sparse bool matrix")
+%!assert (typeinfo (logical (sparse (i * eye (10)))), "sparse bool matrix")
+%!assert (typeinfo (sparse ([1,2])), "sparse matrix")
+%!assert (typeinfo (sparse (eye (10))), "sparse matrix")
+%!assert (typeinfo (sparse ([i,2])), "sparse complex matrix")
+%!assert (typeinfo (sparse (i * eye (10))), "sparse complex matrix")
+
+%!test
+%! s(2).a = 1;
+%! assert (typeinfo (s), "struct");
 
 %!test
 %! s.a = 1;
 %! assert (typeinfo (s), "scalar struct");
 
-%!test
-%! s(2).a = 1;
-%! assert (typeinfo (s), "struct");
+## FIXME: This doesn't work as a test for comma-separated list
+%!#test
+%! clist = {1, 2, 3};
+%! assert (typeinfo (clist{:}), "cs-list");
 
-%!assert (typeinfo ({"cell"}), "cell");
+%!assert (typeinfo (@sin), "function handle")
+%!assert (typeinfo (@(x) x), "function handle")
+
+%!assert (typeinfo (inline ("x^2")), "inline function")
 
-%!assert (typeinfo (@sin), "function handle");
-%!assert (typeinfo (@(x) x), "function handle");
+%!assert (typeinfo (single (1)), "float scalar")
+%!assert (typeinfo (single (i)), "float complex scalar")
+%!assert (typeinfo (single ([1, 2])), "float matrix")
 
-%!assert (typeinfo (inline ('x^2')), "inline function");
+%!assert (typeinfo (single (diag ([1, 2]))), "float diagonal matrix")
+%!assert (typeinfo (diag (single ([1, 2]))), "float diagonal matrix")
+%!assert (typeinfo (single (diag ([i, 2]))), "float complex diagonal matrix")
+%!assert (typeinfo (diag (single ([i, 2]))), "float complex diagonal matrix")
 
+%!assert (typeinfo (eye(3)(:,[1 3 2])), "permutation matrix")
 %!test
 %! [l, u, p] = lu (rand (3));
 %! assert (typeinfo (p), "permutation matrix");
+
+%!assert (typeinfo ([]), "null_matrix")
+%!assert (typeinfo (""), "null_string")
+%!assert (typeinfo (''), "null_sq_string")
+
+%!error typeinfo ("foo", 1)
 */
--- a/src/ov-uint16.cc
+++ b/src/ov-uint16.cc
@@ -84,13 +84,10 @@
 }
 
 /*
-
 %!assert (class (uint16 (1)), "uint16")
 %!assert (uint16 (1.25), uint16 (1))
 %!assert (uint16 (1.5), uint16 (2))
 %!assert (uint16 (-1.5), uint16 (0))
 %!assert (uint16 (2^17), uint16 (2^16-1))
 %!assert (uint16 (-2^17), uint16 (0))
-
 */
-
--- a/src/ov-uint32.cc
+++ b/src/ov-uint32.cc
@@ -84,12 +84,10 @@
 }
 
 /*
-
 %!assert (class (uint32 (1)), "uint32")
 %!assert (uint32 (1.25), uint32 (1))
 %!assert (uint32 (1.5), uint32 (2))
 %!assert (uint32 (-1.5), uint32 (0))
 %!assert (uint32 (2^33), uint32 (2^32-1))
 %!assert (uint32 (-2^33), uint32 (0))
-
 */
--- a/src/ov-uint64.cc
+++ b/src/ov-uint64.cc
@@ -84,12 +84,10 @@
 }
 
 /*
-
 %!assert (class (uint64 (1)), "uint64")
 %!assert (uint64 (1.25), uint64 (1))
 %!assert (uint64 (1.5), uint64 (2))
 %!assert (uint64 (-1.5), uint64 (0))
 %!assert (uint64 (2^65), uint64 (2^64-1))
 %!assert (uint64 (-2^65), uint64 (0))
-
 */
--- a/src/ov-uint8.cc
+++ b/src/ov-uint8.cc
@@ -84,12 +84,10 @@
 }
 
 /*
-
 %!assert (class (uint8 (1)), "uint8")
 %!assert (uint8 (1.25), uint8 (1))
 %!assert (uint8 (1.5), uint8 (2))
 %!assert (uint8 (-1.5), uint8 (0))
 %!assert (uint8 (2^9), uint8 (2^8-1))
 %!assert (uint8 (-2^9), uint8 (0))
-
 */
--- a/src/ov-usr-fcn.cc
+++ b/src/ov-usr-fcn.cc
@@ -51,6 +51,7 @@
 #include "parse.h"
 #include "profiler.h"
 #include "variables.h"
+#include "ov-fcn-handle.h"
 
 // Whether to optimize subsasgn method calls.
 static bool Voptimize_subsasgn_calls = true;
@@ -187,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)
@@ -259,10 +261,10 @@
       std::string ff_name = fcn_file_in_path (file_name);
 
       if (Vfcn_file_dir == ff_name.substr (0, Vfcn_file_dir.length ()))
-        system_fcn_file = 1;
+        system_fcn_file = true;
     }
   else
-    system_fcn_file = 0;
+    system_fcn_file = false;
 }
 
 bool
@@ -386,10 +388,12 @@
   // Save old and set current symbol table context, for
   // eval_undefined_error().
 
-  octave_call_stack::push (this, local_scope, call_depth);
+  int context = active_context ();
+
+  octave_call_stack::push (this, local_scope, context);
   frame.add_fcn (octave_call_stack::pop);
 
-  if (call_depth > 0)
+  if (call_depth > 0 && ! is_anonymous_function ())
     {
       symbol_table::push_context ();
 
@@ -632,12 +636,15 @@
 DEFUN (nargin, args, ,
   "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {} nargin ()\n\
-@deftypefnx {Built-in Function} {} nargin (@var{fcn_name})\n\
+@deftypefnx {Built-in Function} {} nargin (@var{fcn})\n\
 Within a function, return the number of arguments passed to the function.\n\
 At the top level, return the number of command line arguments passed to\n\
-Octave.  If called with the optional argument @var{fcn_name}, return the\n\
-maximum number of arguments the named function can accept, or -1 if the\n\
-function accepts a variable number of arguments.\n\
+Octave.\n\
+\n\
+If called with the optional argument @var{fcn}, a function name or handle,\n\
+return the declared number of arguments that the function can accept.\n\
+If the last argument is @var{varargin} the returned value is negative.\n\
+This feature does not work on builtin functions.\n\
 @seealso{nargout, varargin, isargout, varargout, nthargout}\n\
 @end deftypefn")
 {
@@ -647,40 +654,37 @@
 
   if (nargin == 1)
     {
-      std::string fname = args(0).string_value ();
+      octave_value func = args(0);
 
-      if (! error_state)
+      if (func.is_string ())
         {
-          octave_value fcn_val = symbol_table::find_function (fname);
-
-          if (fcn_val.is_user_function ())
-            {
-              octave_user_function *fcn = fcn_val.user_function_value (true);
+          std::string name = func.string_value ();
+          func = symbol_table::find_function (name);
+          if (func.is_undefined ())
+            error ("nargout: invalid function name: %s", name.c_str ());
+        }
 
-              if (fcn)
-                {
-                  if (fcn->takes_varargs ())
-                    retval = -1;
-                  else
-                    {
-                      tree_parameter_list *param_list = fcn->parameter_list ();
+      octave_function *fcn_val = func.function_value ();
+      if (fcn_val)
+        {
+          octave_user_function *fcn = fcn_val->user_function_value (true);
 
-                      retval = param_list ? param_list->length () : 0;
-                    }
-                }
-              else
-                error ("nargin: loading user-defined function failed");
+          if (fcn)
+            {
+              tree_parameter_list *param_list = fcn->parameter_list ();
+
+              retval = param_list ? param_list->length () : 0;
+              if (fcn->takes_varargs ())
+                retval = -1 - retval;
             }
           else
             {
-              // FIXME -- what about built-in functions or functions
-              // defined in .oct files or .mex files?
-
-              error ("nargin: FCN_NAME must be a user-defined function");
+              // Matlab gives up for histc, so maybe it's ok we give up somtimes too.
+              error ("nargin: nargin information not available for builtin functions");
             }
         }
       else
-        error ("nargin: FCN_NAME must be a string");
+        error ("nargin: FCN must be a string or function handle");
     }
   else if (nargin == 0)
     {
@@ -698,11 +702,12 @@
 DEFUN (nargout, args, ,
   "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {} nargout ()\n\
-@deftypefnx {Built-in Function} {} nargout (@var{fcn_name})\n\
+@deftypefnx {Built-in Function} {} nargout (@var{fcn})\n\
 Within a function, return the number of values the caller expects to\n\
-receive.  If called with the optional argument @var{fcn_name}, return the\n\
-maximum number of values the named function can produce, or -1 if the\n\
-function can produce a variable number of values.\n\
+receive.  If called with the optional argument @var{fcn}, a function\n\
+name or handle, return the number of declared output values that the\n\
+function can produce.  If the final output argument is @var{varargout}\n\
+the returned value is negative.\n\
 \n\
 For example,\n\
 \n\
@@ -721,7 +726,25 @@
 will cause @code{nargout} to return 2 inside the function\n\
 @code{f}.\n\
 \n\
-At the top level, @code{nargout} is undefined.\n\
+In the second usage,\n\
+\n\
+@example\n\
+nargout (@@histc) \% or nargout ('histc')\n\
+@end example\n\
+\n\
+@noindent\n\
+will return 2, because @code{histc} has two outputs, whereas\n\
+\n\
+@example\n\
+nargout (@@deal)\n\
+@end example\n\
+\n\
+@noindent\n\
+will return -1, because @code{deal} has a variable number of outputs.\n\
+\n\
+At the top level, @code{nargout} with no argument is undefined.\n\
+@code{nargout} does not work on builtin functions.\n\
+@code{nargout} returns -1 for all anonymous functions.\n\
 @seealso{nargin, varargin, isargout, varargout, nthargout}\n\
 @end deftypefn")
 {
@@ -731,30 +754,58 @@
 
   if (nargin == 1)
     {
-      std::string fname = args(0).string_value ();
+      octave_value func = args(0);
 
-      if (! error_state)
+      if (func.is_string ())
+        {
+          std::string name = func.string_value ();
+          func = symbol_table::find_function (name);
+          if (func.is_undefined ())
+            error ("nargout: invalid function name: %s", name.c_str ());
+        }
+
+      if (func.is_inline_function ())
         {
-          octave_value fcn_val = symbol_table::find_user_function (fname);
+          retval = 1;
+          return retval;
+        }
+
+      if (func.is_function_handle ())
+        {
+          octave_fcn_handle *fh = func.fcn_handle_value ();
+          std::string fh_nm = fh->fcn_name ();
 
-          octave_user_function *fcn = fcn_val.user_function_value (true);
+          if (fh_nm == octave_fcn_handle::anonymous)
+            {
+              retval = -1;
+              return retval;
+            }
+        }
+
+      octave_function *fcn_val = func.function_value ();
+      if (fcn_val)
+        {
+          octave_user_function *fcn = fcn_val->user_function_value (true);
 
           if (fcn)
             {
+              tree_parameter_list *ret_list = fcn->return_list ();
+          
+              retval = ret_list ? ret_list->length () : 0;
+
               if (fcn->takes_var_return ())
-                retval = -1;
-              else
-                {
-                  tree_parameter_list *ret_list = fcn->return_list ();
-
-                  retval = ret_list ? ret_list->length () : 0;
-                }
+                retval = -1 - retval;
             }
           else
-            error ("nargout: invalid function");
+            {
+              // JWE said this information is not available (currently, 2011-03-10)
+              // without making intrusive changes to Octave.
+              // Matlab gives up for histc, so maybe it's ok we give up somtimes too.
+              error ("nargout: nargout information not available for builtin functions.");
+            }
         }
       else
-        error ("nargout: FCN_NAME must be a string");
+        error ("nargout: FCN must be a string or function handle");
     }
   else if (nargin == 0)
     {
@@ -820,7 +871,7 @@
 the tilde (~) special output argument.  Functions can use @code{isargout} to\n\
 avoid performing unnecessary calculations for outputs which are unwanted.\n\
 \n\
-If @var{k} is outside the range @code{1:max(nargout)}, the function returns\n\
+If @var{k} is outside the range @code{1:max (nargout)}, the function returns\n\
 false.  @var{k} can also be an array, in which case the function works\n\
 element-by-element and a logical array is returned.  At the top level,\n\
 @code{isargout} returns an error.\n\
--- a/src/ov-usr-fcn.h
+++ b/src/ov-usr-fcn.h
@@ -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; }
@@ -272,11 +278,15 @@
   {
     return anonymous_function
       ? (cname.empty ()
-         ? (! dispatch_class().empty ())
+         ? (! dispatch_class ().empty ())
          : cname == dispatch_class ())
       : 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.cc
+++ b/src/ov.cc
@@ -1531,7 +1531,7 @@
   if (retval.length () > 2 || (retval(0) != 1 && retval(1) != 1))
     {
       if (!force_vector_conversion)
-        gripe_implicit_conversion ("Octave:array-as-vector",
+        gripe_implicit_conversion ("Octave:array-to-vector",
                                    my_type.c_str (), wanted_type.c_str ());
       retval = dim_vector (nel, 1);
     }
@@ -2751,7 +2751,7 @@
                 type_string[k] = '.';
               else
                 {
-                  error("%s: invalid indexing type `%s'", name, item.c_str ());
+                  error ("%s: invalid indexing type `%s'", name, item.c_str ());
                   return;
                 }
             }
@@ -2810,13 +2810,13 @@
 \n\
 @example\n\
 @group\n\
-val = magic(3)\n\
-     @result{} val = [ 8   1   6\n\
-                3   5   7\n\
-                4   9   2 ]\n\
+val = magic (3)\n\
+    @result{} val = [ 8   1   6\n\
+               3   5   7\n\
+               4   9   2 ]\n\
 idx.type = \"()\";\n\
 idx.subs = @{\":\", 1:2@};\n\
-subsref(val, idx)\n\
+subsref (val, idx)\n\
      @result{} [ 8   1\n\
           3   5\n\
           4   9 ]\n\
@@ -2873,13 +2873,13 @@
 \n\
 @example\n\
 @group\n\
-val = magic(3);\n\
+val = magic (3);\n\
 idx.type = \"()\";\n\
 idx.subs = @{\":\", 1:2@};\n\
 subsasgn (val, idx, 0)\n\
-     @result{} [ 0   0   6\n\
-          0   0   7\n\
-          0   0   2 ]\n\
+     @result{}  [ 0   0   6\n\
+           0   0   7\n\
+           0   0   2 ]\n\
 @end group\n\
 @end example\n\
 \n\
@@ -2944,7 +2944,7 @@
 %!      0    8    0   18    0
 %!      0    0   14    0    0
 %!      0   10   15   20    0];
-%! assert (a,b);
+%! assert (a, b);
 
 %!test
 %! c = num2cell (reshape ([1:25],5,5));
@@ -2957,7 +2957,7 @@
 %! assert ({ subsref(c, idx1) }, {13});
 %! assert ({ subsref(c, idx2p) }, {7 9 17 19});
 %! assert ({ subsref(c, idx3p) }, num2cell ([1:5, 21:25]));
-%! assert (subsref(c, idx4), c);
+%! assert (subsref (c, idx4), c);
 %! c = subsasgn (c, idx1, 0);
 %! c = subsasgn (c, idx2, 0);
 %! c = subsasgn (c, idx3, 0);
@@ -2989,7 +2989,6 @@
 %! t.b = "There";
 %! t.c = 163;
 %! assert (s, t);
-
 */
 
 DEFUN (is_sq_string, args, ,
@@ -3010,10 +3009,11 @@
 }
 
 /*
-%!assert (is_sq_string ('foo'), true);
-%!assert (is_sq_string ("foo"), false);
-%!assert (is_sq_string (1.0), false);
-%!assert (is_sq_string ({2.0}), false);
+%!assert (is_sq_string ('foo'), true)
+%!assert (is_sq_string ("foo"), false)
+%!assert (is_sq_string (1.0), false)
+%!assert (is_sq_string ({2.0}), false)
+
 %!error is_sq_string ()
 %!error is_sq_string ('foo', 2)
 */
@@ -3036,10 +3036,11 @@
 }
 
 /*
-%!assert (is_dq_string ("foo"), true);
-%!assert (is_dq_string ('foo'), false);
-%!assert (is_dq_string (1.0), false);
-%!assert (is_dq_string ({2.0}), false);
+%!assert (is_dq_string ("foo"), true)
+%!assert (is_dq_string ('foo'), false)
+%!assert (is_dq_string (1.0), false)
+%!assert (is_dq_string ({2.0}), false)
+
 %!error is_dq_string ()
 %!error is_dq_string ("foo", 2)
 */
--- a/src/ov.h
+++ b/src/ov.h
@@ -194,8 +194,8 @@
   octave_value (float d);
   octave_value (const Array<octave_value>& a, bool is_cs_list = false);
   octave_value (const Cell& c, bool is_cs_list = false);
-  octave_value (const Matrix& m, const MatrixType& t = MatrixType());
-  octave_value (const FloatMatrix& m, const MatrixType& t = MatrixType());
+  octave_value (const Matrix& m, const MatrixType& t = MatrixType ());
+  octave_value (const FloatMatrix& m, const MatrixType& t = MatrixType ());
   octave_value (const NDArray& nda);
   octave_value (const FloatNDArray& nda);
   octave_value (const Array<double>& m);
@@ -208,8 +208,8 @@
   octave_value (const FloatColumnVector& v);
   octave_value (const Complex& C);
   octave_value (const FloatComplex& C);
-  octave_value (const ComplexMatrix& m, const MatrixType& t = MatrixType());
-  octave_value (const FloatComplexMatrix& m, const MatrixType& t = MatrixType());
+  octave_value (const ComplexMatrix& m, const MatrixType& t = MatrixType ());
+  octave_value (const FloatComplexMatrix& m, const MatrixType& t = MatrixType ());
   octave_value (const ComplexNDArray& cnda);
   octave_value (const FloatComplexNDArray& cnda);
   octave_value (const Array<Complex>& m);
@@ -222,7 +222,7 @@
   octave_value (const FloatComplexColumnVector& v);
   octave_value (const PermMatrix& p);
   octave_value (bool b);
-  octave_value (const boolMatrix& bm, const MatrixType& t = MatrixType());
+  octave_value (const boolMatrix& bm, const MatrixType& t = MatrixType ());
   octave_value (const boolNDArray& bnda);
   octave_value (const Array<bool>& bnda);
   octave_value (char c, char type = '\'');
@@ -315,7 +315,7 @@
     {
       if (rep->count > 1)
         {
-	  octave_base_value *r = rep->unique_clone ();
+          octave_base_value *r = rep->unique_clone ();
 
           if (--rep->count == 0)
             delete rep;
@@ -458,7 +458,7 @@
 
   int ndims (void) const { return rep->ndims (); }
 
-  bool all_zero_dims (void) const { return dims().all_zero (); }
+  bool all_zero_dims (void) const { return dims ().all_zero (); }
 
   octave_idx_type numel (void) const
     { return rep->numel (); }
@@ -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,
@@ -1117,6 +1120,7 @@
   MAPPER_FORWARD (cosh)
   MAPPER_FORWARD (erf)
   MAPPER_FORWARD (erfinv)
+  MAPPER_FORWARD (erfcinv)
   MAPPER_FORWARD (erfc)
   MAPPER_FORWARD (erfcx)
   MAPPER_FORWARD (exp)
--- a/src/pager.cc
+++ b/src/pager.cc
@@ -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);
new file mode 100644
--- /dev/null
+++ b/src/parse-private.h
@@ -0,0 +1,96 @@
+/*
+
+Copyright (C) 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_parse_private_h)
+#define octave_parse_private_h 1
+
+#include <stack>
+
+#include "symtab.h"
+
+// Keep track of symbol table information when parsing functions.
+class symtab_context
+{
+private:
+
+  class frame
+  {
+  public:
+    frame (symbol_table::scope_id s, symbol_table::scope_id c)
+      : m_scope (s), m_context (c) { }
+
+    frame (const frame& f) : m_scope (f.m_scope), m_context (f.m_context) { }
+
+    frame& operator = (const frame& f)
+    {
+      if (&f != this)
+        {
+          m_scope = f.m_scope;
+          m_context = f.m_context;
+        }
+
+      return *this;
+    }
+
+    ~frame (void) { }
+
+    symbol_table::scope_id scope (void) const { return m_scope; }
+    symbol_table::scope_id context (void) const { return m_context; }
+
+  private:
+
+    symbol_table::scope_id m_scope;
+    symbol_table::scope_id m_context;
+  };
+
+  std::stack<frame> frame_stack;
+
+public:
+  symtab_context (void) : frame_stack () { }
+
+  void clear (void)
+  {
+    while (! frame_stack.empty ())
+      frame_stack.pop ();
+  }
+
+  bool empty (void) const { return frame_stack.empty (); }
+
+  void pop (void)
+  {
+    frame tmp = frame_stack.top ();
+
+    symbol_table::set_scope_and_context (tmp.scope (), tmp.context ());
+
+    frame_stack.pop ();
+  }
+
+  void push (void)
+  {
+    frame_stack.push (frame (symbol_table::current_scope (),
+                             symbol_table::current_context ()));
+  }
+};
+
+extern symtab_context parser_symtab_context;
+
+#endif
--- a/src/parse.h
+++ b/src/parse.h
@@ -62,9 +62,6 @@
 // TRUE means input is coming from startup file.
 extern bool input_from_startup_file;
 
-// Keep track of symbol table information when parsing functions.
-extern std::stack<symbol_table::scope_id> symtab_context;
-
 // Name of the current class when we are parsing class methods or
 // constructors.
 extern std::string current_class_name;
--- a/src/pr-output.cc
+++ b/src/pr-output.cc
@@ -303,8 +303,8 @@
   else
     os << std::setw (0) << "e+";
 
-  os << std::setw (pef.f.ex - 2) << std::setfill('0') << ex
-     << std::setfill(' ');
+  os << std::setw (pef.f.ex - 2) << std::setfill ('0') << ex
+     << std::setfill (' ');
 
   os.flags (oflags);
 
@@ -360,7 +360,7 @@
     {
       std::ostringstream buf;
       buf.flags (std::ios::fixed);
-      buf << std::setprecision (0) << xround(val);
+      buf << std::setprecision (0) << xround (val);
       s = buf.str ();
     }
   else
@@ -375,7 +375,7 @@
       std::ostringstream buf2;
       buf2.flags (std::ios::fixed);
       buf2 << std::setprecision (0) << static_cast<int>(n);
-      s = buf2.str();
+      s = buf2.str ();
 
       while (1)
         {
@@ -407,15 +407,15 @@
           if (n < 0 && d < 0)
             {
               // Double negative, string can be two characters longer..
-              if (buf.str().length() > static_cast<unsigned int>(len + 2) &&
+              if (buf.str ().length () > static_cast<unsigned int>(len + 2) &&
                   m > 1)
                 break;
             }
-          else if (buf.str().length() > static_cast<unsigned int>(len) &&
+          else if (buf.str ().length () > static_cast<unsigned int>(len) &&
                    m > 1)
             break;
 
-          s = buf.str();
+          s = buf.str ();
         }
 
       if (lastd < 0.)
@@ -427,7 +427,7 @@
           buf.flags (std::ios::fixed);
           buf << std::setprecision (0) << static_cast<int>(lastn)
                << "/" << static_cast<int>(lastd);
-          s = buf.str();
+          s = buf.str ();
         }
     }
 
@@ -460,7 +460,7 @@
     os.flags (static_cast<std::ios::fmtflags>
               (prf.f.fmt | prf.f.up | prf.f.sp));
 
-  if (fw > 0 && s.length() > static_cast<unsigned int>(fw))
+  if (fw > 0 && s.length () > static_cast<unsigned int>(fw))
     os << "*";
   else
     os << s;
@@ -2004,8 +2004,8 @@
 }
 
 template <typename NDA_T, typename ELT_T, typename MAT_T>
-void print_nd_array(std::ostream& os, const NDA_T& nda,
-                    bool pr_as_read_syntax)
+void print_nd_array (std::ostream& os, const NDA_T& nda,
+                     bool pr_as_read_syntax)
 {
 
   if (nda.is_empty ())
@@ -2964,8 +2964,8 @@
 /* static */ inline void
 pr_int (std::ostream& os, const T& d, int fw = 0)
 {
-  size_t sz = d.byte_size();
-  const unsigned char * tmpi = d.iptr();
+  size_t sz = d.byte_size ();
+  const unsigned char * tmpi = d.iptr ();
 
   // Unless explicitly asked for, always print in big-endian
   // format for hex and bit formats.
@@ -3376,8 +3376,8 @@
 \n\
 @example\n\
 @group\n\
-   r = rats(hilb(4));\n\
-   x = str2num(r)\n\
+r = rats (hilb (4));\n\
+x = str2num (r)\n\
 @end group\n\
 @end example\n\
 \n\
@@ -3554,13 +3554,13 @@
 %! foo.char = repmat ("- Hello World -", [3, 20]);
 %! foo.cell = {foo.real, foo.complex, foo.char};
 %! fields = fieldnames (foo);
-%! for f = 1:numel(fields)
-%!   format loose
+%! for f = 1:numel (fields)
+%!   format loose;
 %!   loose = disp (foo.(fields{f}));
-%!   format compact
+%!   format compact;
 %!   compact = disp (foo.(fields{f}));
 %!   expected = strrep (loose, "\n\n", "\n");
-%!   assert (expected, compact)
+%!   assert (expected, compact);
 %! endfor
 */
 
--- a/src/procstream.h
+++ b/src/procstream.h
@@ -108,10 +108,10 @@
   oprocstream (void) : std::ostream (0), procstreambase () { }
 
   oprocstream (const std::string& name, int mode = std::ios::out)
-    : std::ostream (0), procstreambase(name, mode) { }
+    : std::ostream (0), procstreambase (name, mode) { }
 
   oprocstream (const char *name, int mode = std::ios::out)
-    : std::ostream (0), procstreambase(name, mode) { }
+    : std::ostream (0), procstreambase (name, mode) { }
 
   ~oprocstream (void) { }
 
--- a/src/pt-binop.cc
+++ b/src/pt-binop.cc
@@ -302,7 +302,6 @@
 }
 
 /*
-
 %!test
 %! x = 0;
 %! do_braindead_shortcircuit_evaluation (0);
@@ -313,6 +312,4 @@
 %! if (1 | (x = 0))
 %! endif
 %! assert (x, 1);
-
 */
-
--- a/src/pt-bp.cc
+++ b/src/pt-bp.cc
@@ -111,7 +111,7 @@
 }
 
 void
-tree_breakpoint::visit_static_command (tree_static_command& cmd)
+tree_breakpoint::visit_persistent_command (tree_persistent_command& cmd)
 {
   do_decl_command (cmd);
 }
--- a/src/pt-bp.h
+++ b/src/pt-bp.h
@@ -58,7 +58,7 @@
 
   void visit_global_command (tree_global_command&);
 
-  void visit_static_command (tree_static_command&);
+  void visit_persistent_command (tree_persistent_command&);
 
   void visit_decl_elt (tree_decl_elt&);
 
--- a/src/pt-check.cc
+++ b/src/pt-check.cc
@@ -105,7 +105,7 @@
 }
 
 void
-tree_checker::visit_static_command (tree_static_command& cmd)
+tree_checker::visit_persistent_command (tree_persistent_command& cmd)
 {
   do_decl_command (cmd);
 }
--- a/src/pt-check.h
+++ b/src/pt-check.h
@@ -51,7 +51,7 @@
 
   void visit_global_command (tree_global_command&);
 
-  void visit_static_command (tree_static_command&);
+  void visit_persistent_command (tree_persistent_command&);
 
   void visit_decl_elt (tree_decl_elt&);
 
--- a/src/pt-decl.cc
+++ b/src/pt-decl.cc
@@ -132,16 +132,16 @@
 // Static.
 
 tree_command *
-tree_static_command::dup (symbol_table::scope_id scope,
+tree_persistent_command::dup (symbol_table::scope_id scope,
                           symbol_table::context_id context) const
 {
   return
-    new tree_static_command (init_list ? init_list->dup (scope, context) : 0,
-                             line (), column ());
+    new tree_persistent_command (init_list ? init_list->dup (scope, context) : 0,
+                                 line (), column ());
 }
 
 void
-tree_static_command::accept (tree_walker& tw)
+tree_persistent_command::accept (tree_walker& tw)
 {
-  tw.visit_static_command (*this);
+  tw.visit_persistent_command (*this);
 }
--- a/src/pt-decl.h
+++ b/src/pt-decl.h
@@ -207,20 +207,20 @@
   tree_global_command& operator = (const tree_global_command&);
 };
 
-// Static.
+// Persistent.
 
 class
-tree_static_command : public tree_decl_command
+tree_persistent_command : public tree_decl_command
 {
 public:
 
-  tree_static_command (int l = -1, int c = -1)
-    : tree_decl_command ("static", l, c) { }
+  tree_persistent_command (int l = -1, int c = -1)
+    : tree_decl_command ("persistent", l, c) { }
 
-  tree_static_command (tree_decl_init_list *t, int l = -1, int c = -1)
-    : tree_decl_command ("static", t, l, c) { }
+  tree_persistent_command (tree_decl_init_list *t, int l = -1, int c = -1)
+    : tree_decl_command ("persistent", t, l, c) { }
 
-  ~tree_static_command (void) { }
+  ~tree_persistent_command (void) { }
 
   tree_command *dup (symbol_table::scope_id scope,
                      symbol_table::context_id context) const;
@@ -233,9 +233,9 @@
 
   // No copying!
 
-  tree_static_command (const tree_static_command&);
+  tree_persistent_command (const tree_persistent_command&);
 
-  tree_static_command& operator = (const tree_static_command&);
+  tree_persistent_command& operator = (const tree_persistent_command&);
 };
 
 #endif
--- a/src/pt-eval.cc
+++ b/src/pt-eval.cc
@@ -215,7 +215,7 @@
 }
 
 void
-tree_evaluator::visit_static_command (tree_static_command& cmd)
+tree_evaluator::visit_persistent_command (tree_persistent_command& cmd)
 {
   if (debug_mode)
     do_breakpoint (cmd.is_breakpoint ());
@@ -1207,7 +1207,6 @@
 }
 
 /*
-%!error (max_recursion_depth (1, 2));
 %!test
 %! orig_val = max_recursion_depth ();
 %! old_val = max_recursion_depth (2*orig_val);
@@ -1215,6 +1214,8 @@
 %! assert (max_recursion_depth (), 2*orig_val);
 %! max_recursion_depth (orig_val);
 %! assert (max_recursion_depth (), orig_val);
+
+%!error (max_recursion_depth (1, 2))
 */
 
 DEFUN (silent_functions, args, nargout,
@@ -1236,7 +1237,6 @@
 }
 
 /*
-%!error (silent_functions (1, 2));
 %!test
 %! orig_val = silent_functions ();
 %! old_val = silent_functions (! orig_val);
@@ -1244,4 +1244,6 @@
 %! assert (silent_functions (), ! orig_val);
 %! silent_functions (orig_val);
 %! assert (silent_functions (), orig_val);
+
+%!error (silent_functions (1, 2))
 */
--- a/src/pt-eval.h
+++ b/src/pt-eval.h
@@ -60,7 +60,7 @@
 
   void visit_global_command (tree_global_command&);
 
-  void visit_static_command (tree_static_command&);
+  void visit_persistent_command (tree_persistent_command&);
 
   void visit_decl_elt (tree_decl_elt&);
 
--- a/src/pt-except.h
+++ b/src/pt-except.h
@@ -137,13 +137,13 @@
   // body of code.
   tree_statement_list *cleanup_code;
 
-  // Comment preceding TRY token.
+  // Comment preceding UNWIND_PROTECT token.
   octave_comment_list *lead_comm;
 
-  // Comment preceding CATCH token.
+  // Comment preceding UNWIND_PROTECT_CLEANUP token.
   octave_comment_list *mid_comm;
 
-  // Comment preceding END_TRY_CATCH token.
+  // Comment preceding END_UNWIND_PROTECT token.
   octave_comment_list *trail_comm;
 
   // No copying!
--- a/src/pt-id.cc
+++ b/src/pt-id.cc
@@ -49,10 +49,12 @@
     return;
 
   if (l == -1 && c == -1)
-    ::error ("`%s' undefined", name ().c_str ());
+    ::error_with_id ("Octave:undefined-function",
+                     "`%s' undefined", name ().c_str ());
   else
-    ::error ("`%s' undefined near line %d column %d",
-             name ().c_str (), l, c);
+    ::error_with_id ("Octave:undefined-function",
+                     "`%s' undefined near line %d column %d",
+                     name ().c_str (), l, c);
 }
 
 octave_value_list
@@ -114,7 +116,7 @@
 octave_lvalue
 tree_identifier::lvalue (void)
 {
-  return octave_lvalue (&(xsym().varref ()));
+  return octave_lvalue (&(xsym ().varref ()));
 }
 
 tree_identifier *
--- a/src/pt-id.h
+++ b/src/pt-id.h
@@ -63,9 +63,9 @@
   // accessing it through sym so that this function may remain const.
   std::string name (void) const { return sym.name (); }
 
-  bool is_defined (void) { return xsym().is_defined (); }
+  bool is_defined (void) { return xsym ().is_defined (); }
 
-  virtual bool is_variable (void) { return xsym().is_variable (); }
+  virtual bool is_variable (void) { return xsym ().is_variable (); }
 
   virtual bool is_black_hole (void) { return false; }
 
@@ -87,14 +87,14 @@
   octave_value
   do_lookup (const octave_value_list& args = octave_value_list ())
   {
-    return xsym().find (args);
+    return xsym ().find (args);
   }
 
-  void mark_global (void) { xsym().mark_global (); }
+  void mark_global (void) { xsym ().mark_global (); }
 
-  void mark_as_static (void) { xsym().init_persistent (); }
+  void mark_as_static (void) { xsym ().init_persistent (); }
 
-  void mark_as_formal_parameter (void) { xsym().mark_formal (); }
+  void mark_as_formal_parameter (void) { xsym ().mark_formal (); }
 
   // We really need to know whether this symbol referst to a variable
   // or a function, but we may not know that yet.
@@ -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-idx.cc
+++ b/src/pt-idx.cc
@@ -601,13 +601,13 @@
 
 /*
 %!test
-%! clear x
-%! clear y
+%! clear x;
+%! clear y;
 %! y = 3;
 %! x(y(end)) = 1;
 %! assert (x, [0, 0, 1]);
-%! clear x
-%! clear y
+%! clear x;
+%! clear y;
 %! y = {3};
 %! x(y{end}) = 1;
 %! assert (x, [0, 0, 1]);
--- a/src/pt-mat.cc
+++ b/src/pt-mat.cc
@@ -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++)
@@ -1110,7 +1110,7 @@
                     }
                 }
 
-              ctmp = (*(tmp.begin() -> begin()));
+              ctmp = (*(tmp.begin () -> begin ()));
 
             found_non_empty:
 
@@ -1193,198 +1193,198 @@
 }
 
 /*
-%% test concatenation with all zero matrices
-%!assert([ '' 65*ones(1,10) ], 'AAAAAAAAAA');
-%!assert([ 65*ones(1,10) '' ], 'AAAAAAAAAA');
+## test concatenation with all zero matrices
+%!assert ([ "" 65*ones(1,10) ], "AAAAAAAAAA");
+%!assert ([ 65*ones(1,10) "" ], "AAAAAAAAAA");
 
 %!test
-%! c = {'foo'; 'bar'; 'bazoloa'};
-%! assert ([c; 'a'; 'bc'; 'def'], {'foo'; 'bar'; 'bazoloa'; 'a'; 'bc'; 'def'});
+%! c = {"foo"; "bar"; "bazoloa"};
+%! assert ([c; "a"; "bc"; "def"], {"foo"; "bar"; "bazoloa"; "a"; "bc"; "def"});
 
-%!assert (class ([int64(1), int64(1)]), 'int64')
-%!assert (class ([int64(1), int32(1)]), 'int64')
-%!assert (class ([int64(1), int16(1)]), 'int64')
-%!assert (class ([int64(1), int8(1)]), 'int64')
-%!assert (class ([int64(1), uint64(1)]), 'int64')
-%!assert (class ([int64(1), uint32(1)]), 'int64')
-%!assert (class ([int64(1), uint16(1)]), 'int64')
-%!assert (class ([int64(1), uint8(1)]), 'int64')
-%!assert (class ([int64(1), single(1)]), 'int64')
-%!assert (class ([int64(1), double(1)]), 'int64')
-%!assert (class ([int64(1), cell(1)]), 'cell')
-%!assert (class ([int64(1), true]), 'int64')
-%!assert (class ([int64(1), 'a']), 'char')
+%!assert (class ([int64(1), int64(1)]), "int64")
+%!assert (class ([int64(1), int32(1)]), "int64")
+%!assert (class ([int64(1), int16(1)]), "int64")
+%!assert (class ([int64(1), int8(1)]), "int64")
+%!assert (class ([int64(1), uint64(1)]), "int64")
+%!assert (class ([int64(1), uint32(1)]), "int64")
+%!assert (class ([int64(1), uint16(1)]), "int64")
+%!assert (class ([int64(1), uint8(1)]), "int64")
+%!assert (class ([int64(1), single(1)]), "int64")
+%!assert (class ([int64(1), double(1)]), "int64")
+%!assert (class ([int64(1), cell(1)]), "cell")
+%!assert (class ([int64(1), true]), "int64")
+%!assert (class ([int64(1), "a"]), "char")
 
-%!assert (class ([int32(1), int64(1)]), 'int32')
-%!assert (class ([int32(1), int32(1)]), 'int32')
-%!assert (class ([int32(1), int16(1)]), 'int32')
-%!assert (class ([int32(1), int8(1)]), 'int32')
-%!assert (class ([int32(1), uint64(1)]), 'int32')
-%!assert (class ([int32(1), uint32(1)]), 'int32')
-%!assert (class ([int32(1), uint16(1)]), 'int32')
-%!assert (class ([int32(1), uint8(1)]), 'int32')
-%!assert (class ([int32(1), single(1)]), 'int32')
-%!assert (class ([int32(1), double(1)]), 'int32')
-%!assert (class ([int32(1), cell(1)]), 'cell')
-%!assert (class ([int32(1), true]), 'int32')
-%!assert (class ([int32(1), 'a']), 'char')
+%!assert (class ([int32(1), int64(1)]), "int32")
+%!assert (class ([int32(1), int32(1)]), "int32")
+%!assert (class ([int32(1), int16(1)]), "int32")
+%!assert (class ([int32(1), int8(1)]), "int32")
+%!assert (class ([int32(1), uint64(1)]), "int32")
+%!assert (class ([int32(1), uint32(1)]), "int32")
+%!assert (class ([int32(1), uint16(1)]), "int32")
+%!assert (class ([int32(1), uint8(1)]), "int32")
+%!assert (class ([int32(1), single(1)]), "int32")
+%!assert (class ([int32(1), double(1)]), "int32")
+%!assert (class ([int32(1), cell(1)]), "cell")
+%!assert (class ([int32(1), true]), "int32")
+%!assert (class ([int32(1), "a"]), "char")
 
-%!assert (class ([int16(1), int64(1)]), 'int16')
-%!assert (class ([int16(1), int32(1)]), 'int16')
-%!assert (class ([int16(1), int16(1)]), 'int16')
-%!assert (class ([int16(1), int8(1)]), 'int16')
-%!assert (class ([int16(1), uint64(1)]), 'int16')
-%!assert (class ([int16(1), uint32(1)]), 'int16')
-%!assert (class ([int16(1), uint16(1)]), 'int16')
-%!assert (class ([int16(1), uint8(1)]), 'int16')
-%!assert (class ([int16(1), single(1)]), 'int16')
-%!assert (class ([int16(1), double(1)]), 'int16')
-%!assert (class ([int16(1), cell(1)]), 'cell')
-%!assert (class ([int16(1), true]), 'int16')
-%!assert (class ([int16(1), 'a']), 'char')
+%!assert (class ([int16(1), int64(1)]), "int16")
+%!assert (class ([int16(1), int32(1)]), "int16")
+%!assert (class ([int16(1), int16(1)]), "int16")
+%!assert (class ([int16(1), int8(1)]), "int16")
+%!assert (class ([int16(1), uint64(1)]), "int16")
+%!assert (class ([int16(1), uint32(1)]), "int16")
+%!assert (class ([int16(1), uint16(1)]), "int16")
+%!assert (class ([int16(1), uint8(1)]), "int16")
+%!assert (class ([int16(1), single(1)]), "int16")
+%!assert (class ([int16(1), double(1)]), "int16")
+%!assert (class ([int16(1), cell(1)]), "cell")
+%!assert (class ([int16(1), true]), "int16")
+%!assert (class ([int16(1), "a"]), "char")
 
-%!assert (class ([int8(1), int64(1)]), 'int8')
-%!assert (class ([int8(1), int32(1)]), 'int8')
-%!assert (class ([int8(1), int16(1)]), 'int8')
-%!assert (class ([int8(1), int8(1)]), 'int8')
-%!assert (class ([int8(1), uint64(1)]), 'int8')
-%!assert (class ([int8(1), uint32(1)]), 'int8')
-%!assert (class ([int8(1), uint16(1)]), 'int8')
-%!assert (class ([int8(1), uint8(1)]), 'int8')
-%!assert (class ([int8(1), single(1)]), 'int8')
-%!assert (class ([int8(1), double(1)]), 'int8')
-%!assert (class ([int8(1), cell(1)]), 'cell')
-%!assert (class ([int8(1), true]), 'int8')
-%!assert (class ([int8(1), 'a']), 'char')
+%!assert (class ([int8(1), int64(1)]), "int8")
+%!assert (class ([int8(1), int32(1)]), "int8")
+%!assert (class ([int8(1), int16(1)]), "int8")
+%!assert (class ([int8(1), int8(1)]), "int8")
+%!assert (class ([int8(1), uint64(1)]), "int8")
+%!assert (class ([int8(1), uint32(1)]), "int8")
+%!assert (class ([int8(1), uint16(1)]), "int8")
+%!assert (class ([int8(1), uint8(1)]), "int8")
+%!assert (class ([int8(1), single(1)]), "int8")
+%!assert (class ([int8(1), double(1)]), "int8")
+%!assert (class ([int8(1), cell(1)]), "cell")
+%!assert (class ([int8(1), true]), "int8")
+%!assert (class ([int8(1), "a"]), "char")
 
-%!assert (class ([uint64(1), int64(1)]), 'uint64')
-%!assert (class ([uint64(1), int32(1)]), 'uint64')
-%!assert (class ([uint64(1), int16(1)]), 'uint64')
-%!assert (class ([uint64(1), int8(1)]), 'uint64')
-%!assert (class ([uint64(1), uint64(1)]), 'uint64')
-%!assert (class ([uint64(1), uint32(1)]), 'uint64')
-%!assert (class ([uint64(1), uint16(1)]), 'uint64')
-%!assert (class ([uint64(1), uint8(1)]), 'uint64')
-%!assert (class ([uint64(1), single(1)]), 'uint64')
-%!assert (class ([uint64(1), double(1)]), 'uint64')
-%!assert (class ([uint64(1), cell(1)]), 'cell')
-%!assert (class ([uint64(1), true]), 'uint64')
-%!assert (class ([uint64(1), 'a']), 'char')
+%!assert (class ([uint64(1), int64(1)]), "uint64")
+%!assert (class ([uint64(1), int32(1)]), "uint64")
+%!assert (class ([uint64(1), int16(1)]), "uint64")
+%!assert (class ([uint64(1), int8(1)]), "uint64")
+%!assert (class ([uint64(1), uint64(1)]), "uint64")
+%!assert (class ([uint64(1), uint32(1)]), "uint64")
+%!assert (class ([uint64(1), uint16(1)]), "uint64")
+%!assert (class ([uint64(1), uint8(1)]), "uint64")
+%!assert (class ([uint64(1), single(1)]), "uint64")
+%!assert (class ([uint64(1), double(1)]), "uint64")
+%!assert (class ([uint64(1), cell(1)]), "cell")
+%!assert (class ([uint64(1), true]), "uint64")
+%!assert (class ([uint64(1), "a"]), "char")
 
-%!assert (class ([uint32(1), int64(1)]), 'uint32')
-%!assert (class ([uint32(1), int32(1)]), 'uint32')
-%!assert (class ([uint32(1), int16(1)]), 'uint32')
-%!assert (class ([uint32(1), int8(1)]), 'uint32')
-%!assert (class ([uint32(1), uint64(1)]), 'uint32')
-%!assert (class ([uint32(1), uint32(1)]), 'uint32')
-%!assert (class ([uint32(1), uint16(1)]), 'uint32')
-%!assert (class ([uint32(1), uint8(1)]), 'uint32')
-%!assert (class ([uint32(1), single(1)]), 'uint32')
-%!assert (class ([uint32(1), double(1)]), 'uint32')
-%!assert (class ([uint32(1), cell(1)]), 'cell')
-%!assert (class ([uint32(1), true]), 'uint32')
-%!assert (class ([uint32(1), 'a']), 'char')
+%!assert (class ([uint32(1), int64(1)]), "uint32")
+%!assert (class ([uint32(1), int32(1)]), "uint32")
+%!assert (class ([uint32(1), int16(1)]), "uint32")
+%!assert (class ([uint32(1), int8(1)]), "uint32")
+%!assert (class ([uint32(1), uint64(1)]), "uint32")
+%!assert (class ([uint32(1), uint32(1)]), "uint32")
+%!assert (class ([uint32(1), uint16(1)]), "uint32")
+%!assert (class ([uint32(1), uint8(1)]), "uint32")
+%!assert (class ([uint32(1), single(1)]), "uint32")
+%!assert (class ([uint32(1), double(1)]), "uint32")
+%!assert (class ([uint32(1), cell(1)]), "cell")
+%!assert (class ([uint32(1), true]), "uint32")
+%!assert (class ([uint32(1), "a"]), "char")
 
-%!assert (class ([uint16(1), int64(1)]), 'uint16')
-%!assert (class ([uint16(1), int32(1)]), 'uint16')
-%!assert (class ([uint16(1), int16(1)]), 'uint16')
-%!assert (class ([uint16(1), int8(1)]), 'uint16')
-%!assert (class ([uint16(1), uint64(1)]), 'uint16')
-%!assert (class ([uint16(1), uint32(1)]), 'uint16')
-%!assert (class ([uint16(1), uint16(1)]), 'uint16')
-%!assert (class ([uint16(1), uint8(1)]), 'uint16')
-%!assert (class ([uint16(1), single(1)]), 'uint16')
-%!assert (class ([uint16(1), double(1)]), 'uint16')
-%!assert (class ([uint16(1), cell(1)]), 'cell')
-%!assert (class ([uint16(1), true]), 'uint16')
-%!assert (class ([uint16(1), 'a']), 'char')
+%!assert (class ([uint16(1), int64(1)]), "uint16")
+%!assert (class ([uint16(1), int32(1)]), "uint16")
+%!assert (class ([uint16(1), int16(1)]), "uint16")
+%!assert (class ([uint16(1), int8(1)]), "uint16")
+%!assert (class ([uint16(1), uint64(1)]), "uint16")
+%!assert (class ([uint16(1), uint32(1)]), "uint16")
+%!assert (class ([uint16(1), uint16(1)]), "uint16")
+%!assert (class ([uint16(1), uint8(1)]), "uint16")
+%!assert (class ([uint16(1), single(1)]), "uint16")
+%!assert (class ([uint16(1), double(1)]), "uint16")
+%!assert (class ([uint16(1), cell(1)]), "cell")
+%!assert (class ([uint16(1), true]), "uint16")
+%!assert (class ([uint16(1), "a"]), "char")
 
-%!assert (class ([uint8(1), int64(1)]), 'uint8')
-%!assert (class ([uint8(1), int32(1)]), 'uint8')
-%!assert (class ([uint8(1), int16(1)]), 'uint8')
-%!assert (class ([uint8(1), int8(1)]), 'uint8')
-%!assert (class ([uint8(1), uint64(1)]), 'uint8')
-%!assert (class ([uint8(1), uint32(1)]), 'uint8')
-%!assert (class ([uint8(1), uint16(1)]), 'uint8')
-%!assert (class ([uint8(1), uint8(1)]), 'uint8')
-%!assert (class ([uint8(1), single(1)]), 'uint8')
-%!assert (class ([uint8(1), double(1)]), 'uint8')
-%!assert (class ([uint8(1), cell(1)]), 'cell')
-%!assert (class ([uint8(1), true]), 'uint8')
-%!assert (class ([uint8(1), 'a']), 'char')
+%!assert (class ([uint8(1), int64(1)]), "uint8")
+%!assert (class ([uint8(1), int32(1)]), "uint8")
+%!assert (class ([uint8(1), int16(1)]), "uint8")
+%!assert (class ([uint8(1), int8(1)]), "uint8")
+%!assert (class ([uint8(1), uint64(1)]), "uint8")
+%!assert (class ([uint8(1), uint32(1)]), "uint8")
+%!assert (class ([uint8(1), uint16(1)]), "uint8")
+%!assert (class ([uint8(1), uint8(1)]), "uint8")
+%!assert (class ([uint8(1), single(1)]), "uint8")
+%!assert (class ([uint8(1), double(1)]), "uint8")
+%!assert (class ([uint8(1), cell(1)]), "cell")
+%!assert (class ([uint8(1), true]), "uint8")
+%!assert (class ([uint8(1), "a"]), "char")
 
-%!assert (class ([single(1), int64(1)]), 'int64')
-%!assert (class ([single(1), int32(1)]), 'int32')
-%!assert (class ([single(1), int16(1)]), 'int16')
-%!assert (class ([single(1), int8(1)]), 'int8')
-%!assert (class ([single(1), uint64(1)]), 'uint64')
-%!assert (class ([single(1), uint32(1)]), 'uint32')
-%!assert (class ([single(1), uint16(1)]), 'uint16')
-%!assert (class ([single(1), uint8(1)]), 'uint8')
-%!assert (class ([single(1), single(1)]), 'single')
-%!assert (class ([single(1), double(1)]), 'single')
-%!assert (class ([single(1), cell(1)]), 'cell')
-%!assert (class ([single(1), true]), 'single')
-%!assert (class ([single(1), 'a']), 'char')
+%!assert (class ([single(1), int64(1)]), "int64")
+%!assert (class ([single(1), int32(1)]), "int32")
+%!assert (class ([single(1), int16(1)]), "int16")
+%!assert (class ([single(1), int8(1)]), "int8")
+%!assert (class ([single(1), uint64(1)]), "uint64")
+%!assert (class ([single(1), uint32(1)]), "uint32")
+%!assert (class ([single(1), uint16(1)]), "uint16")
+%!assert (class ([single(1), uint8(1)]), "uint8")
+%!assert (class ([single(1), single(1)]), "single")
+%!assert (class ([single(1), double(1)]), "single")
+%!assert (class ([single(1), cell(1)]), "cell")
+%!assert (class ([single(1), true]), "single")
+%!assert (class ([single(1), "a"]), "char")
 
-%!assert (class ([double(1), int64(1)]), 'int64')
-%!assert (class ([double(1), int32(1)]), 'int32')
-%!assert (class ([double(1), int16(1)]), 'int16')
-%!assert (class ([double(1), int8(1)]), 'int8')
-%!assert (class ([double(1), uint64(1)]), 'uint64')
-%!assert (class ([double(1), uint32(1)]), 'uint32')
-%!assert (class ([double(1), uint16(1)]), 'uint16')
-%!assert (class ([double(1), uint8(1)]), 'uint8')
-%!assert (class ([double(1), single(1)]), 'single')
-%!assert (class ([double(1), double(1)]), 'double')
-%!assert (class ([double(1), cell(1)]), 'cell')
-%!assert (class ([double(1), true]), 'double')
-%!assert (class ([double(1), 'a']), 'char')
+%!assert (class ([double(1), int64(1)]), "int64")
+%!assert (class ([double(1), int32(1)]), "int32")
+%!assert (class ([double(1), int16(1)]), "int16")
+%!assert (class ([double(1), int8(1)]), "int8")
+%!assert (class ([double(1), uint64(1)]), "uint64")
+%!assert (class ([double(1), uint32(1)]), "uint32")
+%!assert (class ([double(1), uint16(1)]), "uint16")
+%!assert (class ([double(1), uint8(1)]), "uint8")
+%!assert (class ([double(1), single(1)]), "single")
+%!assert (class ([double(1), double(1)]), "double")
+%!assert (class ([double(1), cell(1)]), "cell")
+%!assert (class ([double(1), true]), "double")
+%!assert (class ([double(1), "a"]), "char")
 
-%!assert (class ([cell(1), int64(1)]), 'cell')
-%!assert (class ([cell(1), int32(1)]), 'cell')
-%!assert (class ([cell(1), int16(1)]), 'cell')
-%!assert (class ([cell(1), int8(1)]), 'cell')
-%!assert (class ([cell(1), uint64(1)]), 'cell')
-%!assert (class ([cell(1), uint32(1)]), 'cell')
-%!assert (class ([cell(1), uint16(1)]), 'cell')
-%!assert (class ([cell(1), uint8(1)]), 'cell')
-%!assert (class ([cell(1), single(1)]), 'cell')
-%!assert (class ([cell(1), double(1)]), 'cell')
-%!assert (class ([cell(1), cell(1)]), 'cell')
-%!assert (class ([cell(1), true]), 'cell')
-%!assert (class ([cell(1), 'a']), 'cell')
+%!assert (class ([cell(1), int64(1)]), "cell")
+%!assert (class ([cell(1), int32(1)]), "cell")
+%!assert (class ([cell(1), int16(1)]), "cell")
+%!assert (class ([cell(1), int8(1)]), "cell")
+%!assert (class ([cell(1), uint64(1)]), "cell")
+%!assert (class ([cell(1), uint32(1)]), "cell")
+%!assert (class ([cell(1), uint16(1)]), "cell")
+%!assert (class ([cell(1), uint8(1)]), "cell")
+%!assert (class ([cell(1), single(1)]), "cell")
+%!assert (class ([cell(1), double(1)]), "cell")
+%!assert (class ([cell(1), cell(1)]), "cell")
+%!assert (class ([cell(1), true]), "cell")
+%!assert (class ([cell(1), "a"]), "cell")
 
-%!assert (class ([true, int64(1)]), 'int64')
-%!assert (class ([true, int32(1)]), 'int32')
-%!assert (class ([true, int16(1)]), 'int16')
-%!assert (class ([true, int8(1)]), 'int8')
-%!assert (class ([true, uint64(1)]), 'uint64')
-%!assert (class ([true, uint32(1)]), 'uint32')
-%!assert (class ([true, uint16(1)]), 'uint16')
-%!assert (class ([true, uint8(1)]), 'uint8')
-%!assert (class ([true, single(1)]), 'single')
-%!assert (class ([true, double(1)]), 'double')
-%!assert (class ([true, cell(1)]), 'cell')
-%!assert (class ([true, true]), 'logical')
-%!assert (class ([true, 'a']), 'char')
+%!assert (class ([true, int64(1)]), "int64")
+%!assert (class ([true, int32(1)]), "int32")
+%!assert (class ([true, int16(1)]), "int16")
+%!assert (class ([true, int8(1)]), "int8")
+%!assert (class ([true, uint64(1)]), "uint64")
+%!assert (class ([true, uint32(1)]), "uint32")
+%!assert (class ([true, uint16(1)]), "uint16")
+%!assert (class ([true, uint8(1)]), "uint8")
+%!assert (class ([true, single(1)]), "single")
+%!assert (class ([true, double(1)]), "double")
+%!assert (class ([true, cell(1)]), "cell")
+%!assert (class ([true, true]), "logical")
+%!assert (class ([true, "a"]), "char")
 
-%!assert (class (['a', int64(1)]), 'char')
-%!assert (class (['a', int32(1)]), 'char')
-%!assert (class (['a', int16(1)]), 'char')
-%!assert (class (['a', int8(1)]), 'char')
-%!assert (class (['a', int64(1)]), 'char')
-%!assert (class (['a', int32(1)]), 'char')
-%!assert (class (['a', int16(1)]), 'char')
-%!assert (class (['a', int8(1)]), 'char')
-%!assert (class (['a', single(1)]), 'char')
-%!assert (class (['a', double(1)]), 'char')
-%!assert (class (['a', cell(1)]), 'cell')
-%!assert (class (['a', true]), 'char')
-%!assert (class (['a', 'a']), 'char')
+%!assert (class (["a", int64(1)]), "char")
+%!assert (class (["a", int32(1)]), "char")
+%!assert (class (["a", int16(1)]), "char")
+%!assert (class (["a", int8(1)]), "char")
+%!assert (class (["a", int64(1)]), "char")
+%!assert (class (["a", int32(1)]), "char")
+%!assert (class (["a", int16(1)]), "char")
+%!assert (class (["a", int8(1)]), "char")
+%!assert (class (["a", single(1)]), "char")
+%!assert (class (["a", double(1)]), "char")
+%!assert (class (["a", cell(1)]), "cell")
+%!assert (class (["a", true]), "char")
+%!assert (class (["a", "a"]), "char")
 
-%!assert (class ([cell(1), struct('foo', 'bar')]), 'cell')
-%!error [struct('foo', 'bar'), cell(1)];
+%!assert (class ([cell(1), struct("foo", "bar")]), "cell")
+%!error [struct("foo", "bar"), cell(1)]
 */
 
 DEFUN (string_fill_char, args, nargout,
@@ -1400,9 +1400,9 @@
 @group\n\
 string_fill_char (\"X\");\n\
 [ \"these\"; \"are\"; \"strings\" ]\n\
-     @result{} \"theseXX\"\n\
-        \"areXXXX\"\n\
-        \"strings\"\n\
+      @result{}  \"theseXX\"\n\
+          \"areXXXX\"\n\
+          \"strings\"\n\
 @end group\n\
 @end example\n\
 \n\
@@ -1415,9 +1415,8 @@
 }
 
 /*
-%!error (string_fill_char (1, 2));
-%% string_fill_char() function call must be outside of %!test block
-%% due to the way a %!test block is wrapped inside a function
+## string_fill_char() function call must be outside of %!test block
+## due to the way a %!test block is wrapped inside a function
 %!shared orig_val, old_val
 %! orig_val = string_fill_char ();
 %! old_val  = string_fill_char ("X");
@@ -1427,4 +1426,6 @@
 %! assert (["these"; "are"; "strings"], ["theseXX"; "areXXXX"; "strings"]);
 %! string_fill_char (orig_val);
 %! assert (string_fill_char (), orig_val);
+
+%!error (string_fill_char (1, 2))
 */
--- a/src/pt-pr-code.cc
+++ b/src/pt-pr-code.cc
@@ -165,7 +165,7 @@
 }
 
 void
-tree_print_code::visit_static_command (tree_static_command& cmd)
+tree_print_code::visit_persistent_command (tree_persistent_command& cmd)
 {
   do_decl_command (cmd);
 }
--- a/src/pt-pr-code.h
+++ b/src/pt-pr-code.h
@@ -67,7 +67,7 @@
 
   void visit_global_command (tree_global_command&);
 
-  void visit_static_command (tree_static_command&);
+  void visit_persistent_command (tree_persistent_command&);
 
   void visit_decl_elt (tree_decl_elt&);
 
--- a/src/pt-select.cc
+++ b/src/pt-select.cc
@@ -123,7 +123,7 @@
 {
   octave_value label_value = label->rvalue1 ();
 
-  if (! error_state && label_value.is_defined() )
+  if (! error_state && label_value.is_defined () )
     {
       if (label_value.is_cell ())
         {
--- a/src/pt-walk.h
+++ b/src/pt-walk.h
@@ -30,7 +30,7 @@
 class tree_colon_expression;
 class tree_continue_command;
 class tree_global_command;
-class tree_static_command;
+class tree_persistent_command;
 class tree_decl_elt;
 class tree_decl_init_list;
 class tree_simple_for_command;
@@ -92,7 +92,7 @@
   visit_global_command (tree_global_command&) = 0;
 
   virtual void
-  visit_static_command (tree_static_command&) = 0;
+  visit_persistent_command (tree_persistent_command&) = 0;
 
   virtual void
   visit_decl_elt (tree_decl_elt&) = 0;
--- a/src/sighandlers.cc
+++ b/src/sighandlers.cc
@@ -252,7 +252,7 @@
 
   octave_signals_caught[SIGCHLD] = true;
 }
-#endif /* defined(SIGCHLD) */
+#endif /* defined (SIGCHLD) */
 
 #ifdef SIGFPE
 #if defined (__alpha__)
@@ -268,8 +268,8 @@
       octave_interrupt_state++;
     }
 }
-#endif /* defined(__alpha__) */
-#endif /* defined(SIGFPE) */
+#endif /* defined (__alpha__) */
+#endif /* defined (SIGFPE) */
 
 #if defined (SIGHUP) || defined (SIGTERM)
 static void
@@ -401,7 +401,7 @@
   if (pipe_handler_error_count++ > 100 && octave_interrupt_state >= 0)
     octave_interrupt_state++;
 }
-#endif /* defined(SIGPIPE) */
+#endif /* defined (SIGPIPE) */
 
 #ifdef USE_W32_SIGINT
 static BOOL CALLBACK
@@ -409,7 +409,7 @@
 {
   const char *sig_name;
 
-  switch(sig)
+  switch (sig)
     {
       case CTRL_BREAK_EVENT:
         sig_name = "Ctrl-Break";
@@ -431,7 +431,7 @@
         break;
     }
 
-  switch(sig)
+  switch (sig)
     {
       case CTRL_BREAK_EVENT:
       case CTRL_C_EVENT:
@@ -439,13 +439,15 @@
         break;
 
       case CTRL_CLOSE_EVENT:
+        clean_up_and_exit (0);
+        break;
       case CTRL_LOGOFF_EVENT:
       case CTRL_SHUTDOWN_EVENT:
       default:
         // We should do the following:
         //    clean_up_and_exit (0);
         // We can't because we aren't running in the normal Octave thread.
-        user_abort(sig_name, sig);
+        user_abort (sig_name, sig);
         break;
     }
 
@@ -957,9 +959,10 @@
 }
 
 /*
-%!error SIG (1);
-%!assert (isstruct (SIG ()));
-%!assert (! isempty (SIG ()));
+%!assert (isstruct (SIG ()))
+%!assert (! isempty (SIG ()))
+
+%!error SIG (1)
 */
 
 DEFUN (debug_on_interrupt, args, nargout,
@@ -981,7 +984,6 @@
 }
 
 /*
-%!error (debug_on_interrupt (1, 2));
 %!test
 %! orig_val = debug_on_interrupt ();
 %! old_val = debug_on_interrupt (! orig_val);
@@ -989,6 +991,8 @@
 %! assert (debug_on_interrupt (), ! orig_val);
 %! debug_on_interrupt (orig_val);
 %! assert (debug_on_interrupt (), orig_val);
+
+%!error (debug_on_interrupt (1, 2))
 */
 
 DEFUN (sighup_dumps_octave_core, args, nargout,
@@ -1009,7 +1013,6 @@
 }
 
 /*
-%!error (sighup_dumps_octave_core (1, 2));
 %!test
 %! orig_val = sighup_dumps_octave_core ();
 %! old_val = sighup_dumps_octave_core (! orig_val);
@@ -1017,6 +1020,8 @@
 %! assert (sighup_dumps_octave_core (), ! orig_val);
 %! sighup_dumps_octave_core (orig_val);
 %! assert (sighup_dumps_octave_core (), orig_val);
+
+%!error (sighup_dumps_octave_core (1, 2))
 */
 
 DEFUN (sigterm_dumps_octave_core, args, nargout,
@@ -1037,7 +1042,6 @@
 }
 
 /*
-%!error (sigterm_dumps_octave_core (1, 2));
 %!test
 %! orig_val = sigterm_dumps_octave_core ();
 %! old_val = sigterm_dumps_octave_core (! orig_val);
@@ -1045,4 +1049,6 @@
 %! assert (sigterm_dumps_octave_core (), ! orig_val);
 %! sigterm_dumps_octave_core (orig_val);
 %! assert (sigterm_dumps_octave_core (), orig_val);
+
+%!error (sigterm_dumps_octave_core (1, 2))
 */
--- a/src/sparse-xdiv.cc
+++ b/src/sparse-xdiv.cc
@@ -117,7 +117,7 @@
 INSTANTIATE_MX_DIV_CONFORM (SparseComplexMatrix, DiagMatrix);
 INSTANTIATE_MX_DIV_CONFORM (SparseComplexMatrix, ComplexDiagMatrix);
 
-// Right division functions.  X / Y = X * inv(Y) = (inv (Y') * X')'
+// Right division functions.  X / Y = X * inv (Y) = (inv (Y') * X')'
 //
 //                  Y / X:   m   cm   sm  scm
 //                   +--   +---+----+----+----+
@@ -384,10 +384,10 @@
 
 
   for (octave_idx_type j = 0; j < nc; j++)
-    for (octave_idx_type i = b.cidx(j); i < b.cidx(j+1); i++)
+    for (octave_idx_type i = b.cidx (j); i < b.cidx (j+1); i++)
       {
         octave_quit ();
-        result.elem (b.ridx(i), j) = a / b.data (i);
+        result.elem (b.ridx (i), j) = a / b.data (i);
       }
 
   return result;
@@ -399,13 +399,13 @@
   octave_idx_type nr = b.rows ();
   octave_idx_type nc = b.cols ();
 
-  ComplexMatrix  result (nr, nc, Complex(octave_NaN, octave_NaN));
+  ComplexMatrix  result (nr, nc, Complex (octave_NaN, octave_NaN));
 
   for (octave_idx_type j = 0; j < nc; j++)
-    for (octave_idx_type i = b.cidx(j); i < b.cidx(j+1); i++)
+    for (octave_idx_type i = b.cidx (j); i < b.cidx (j+1); i++)
       {
         octave_quit ();
-        result.elem (b.ridx(i), j) = a / b.data (i);
+        result.elem (b.ridx (i), j) = a / b.data (i);
       }
 
   return result;
@@ -420,10 +420,10 @@
   ComplexMatrix result (nr, nc, (a / 0.0));
 
   for (octave_idx_type j = 0; j < nc; j++)
-    for (octave_idx_type i = b.cidx(j); i < b.cidx(j+1); i++)
+    for (octave_idx_type i = b.cidx (j); i < b.cidx (j+1); i++)
       {
         octave_quit ();
-        result.elem (b.ridx(i), j) = a / b.data (i);
+        result.elem (b.ridx (i), j) = a / b.data (i);
       }
 
   return result;
@@ -438,16 +438,16 @@
   ComplexMatrix result (nr, nc, (a / 0.0));
 
   for (octave_idx_type j = 0; j < nc; j++)
-    for (octave_idx_type i = b.cidx(j); i < b.cidx(j+1); i++)
+    for (octave_idx_type i = b.cidx (j); i < b.cidx (j+1); i++)
       {
         octave_quit ();
-        result.elem (b.ridx(i), j) = a / b.data (i);
+        result.elem (b.ridx (i), j) = a / b.data (i);
       }
 
   return result;
 }
 
-// Left division functions.  X \ Y = inv(X) * Y
+// Left division functions.  X \ Y = inv (X) * Y
 //
 //               Y  \  X :   sm  scm  dm  dcm
 //                   +--   +---+----+
--- a/src/sparse-xpow.cc
+++ b/src/sparse-xpow.cc
@@ -250,7 +250,7 @@
           for (octave_idx_type i = 0; i < nr; i++)
             {
               octave_quit ();
-              result (i, j) = std::pow (atmp, b(i,j));
+              result(i, j) = std::pow (atmp, b(i,j));
             }
         }
 
@@ -265,7 +265,7 @@
           for (octave_idx_type i = 0; i < nr; i++)
             {
               octave_quit ();
-              result (i, j) = std::pow (a, b(i,j));
+              result(i, j) = std::pow (a, b(i,j));
             }
         }
 
@@ -290,7 +290,7 @@
       for (octave_idx_type i = 0; i < nr; i++)
         {
           octave_quit ();
-          result (i, j) = std::pow (atmp, b(i,j));
+          result(i, j) = std::pow (atmp, b(i,j));
         }
     }
 
@@ -323,13 +323,13 @@
           Complex btmp (b);
 
           for (octave_idx_type j = 0; j < nc; j++)
-            for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
+            for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
               {
                 octave_quit ();
 
                 Complex atmp (a.data (i));
 
-                result (a.ridx(i), j) = std::pow (atmp, btmp);
+                result(a.ridx (i), j) = std::pow (atmp, btmp);
               }
 
           retval = octave_value (result);
@@ -339,10 +339,10 @@
           Matrix result (nr, nc, (std::pow (0.0, b)));
 
           for (octave_idx_type j = 0; j < nc; j++)
-            for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
+            for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
               {
                 octave_quit ();
-                result (a.ridx(i), j) = std::pow (a.data (i), b);
+                result(a.ridx (i), j) = std::pow (a.data (i), b);
               }
 
           retval = octave_value (result);
@@ -407,11 +407,11 @@
 
   int convert_to_complex = 0;
   for (octave_idx_type j = 0; j < nc; j++)
-    for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
+    for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
       {
         if (a.data(i) < 0.0)
           {
-            double btmp = b (a.ridx(i), j);
+            double btmp = b (a.ridx (i), j);
             if (static_cast<int> (btmp) != btmp)
               {
                 convert_to_complex = 1;
@@ -429,15 +429,15 @@
 
   if (convert_to_complex)
     {
-      SparseComplexMatrix complex_result (nr, nc, Complex(1.0, 0.0));
+      SparseComplexMatrix complex_result (nr, nc, Complex (1.0, 0.0));
 
       for (octave_idx_type j = 0; j < nc; j++)
         {
-          for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
+          for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
             {
               octave_quit ();
-              complex_result.xelem(a.ridx(i), j) =
-                std::pow (Complex(a.data(i)), Complex(b(a.ridx(i), j)));
+              complex_result.xelem (a.ridx (i), j) =
+                std::pow (Complex (a.data (i)), Complex (b(a.ridx (i), j)));
             }
         }
       complex_result.maybe_compress (true);
@@ -449,11 +449,11 @@
 
       for (octave_idx_type j = 0; j < nc; j++)
         {
-          for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
+          for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
             {
               octave_quit ();
-              result.xelem(a.ridx(i), j) = std::pow (a.data(i),
-                                                     b (a.ridx(i), j));
+              result.xelem (a.ridx (i), j) = std::pow (a.data (i),
+                                                       b(a.ridx (i), j));
             }
         }
       result.maybe_compress (true);
@@ -507,13 +507,13 @@
       return octave_value ();
     }
 
-  SparseComplexMatrix result (nr, nc, Complex(1.0, 0.0));
+  SparseComplexMatrix result (nr, nc, Complex (1.0, 0.0));
   for (octave_idx_type j = 0; j < nc; j++)
     {
-      for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
+      for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
         {
           octave_quit ();
-          result.xelem(a.ridx(i), j) = std::pow (a.data(i), b (a.ridx(i), j));
+          result.xelem (a.ridx(i), j) = std::pow (a.data (i), b(a.ridx (i), j));
         }
     }
 
@@ -581,20 +581,20 @@
       if (xisint (b))
         {
           for (octave_idx_type j = 0; j < nc; j++)
-            for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
+            for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
               {
                 octave_quit ();
-                result (a.ridx(i), j) =
+                result (a.ridx (i), j) =
                   std::pow (a.data (i), static_cast<int> (b));
               }
         }
       else
         {
           for (octave_idx_type j = 0; j < nc; j++)
-            for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
+            for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
               {
                 octave_quit ();
-                result (a.ridx(i), j) = std::pow (a.data (i), b);
+                result (a.ridx (i), j) = std::pow (a.data (i), b);
               }
         }
 
@@ -647,20 +647,20 @@
       return octave_value ();
     }
 
-  SparseComplexMatrix result (nr, nc, Complex(1.0, 0.0));
+  SparseComplexMatrix result (nr, nc, Complex (1.0, 0.0));
   for (octave_idx_type j = 0; j < nc; j++)
     {
-      for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
+      for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
         {
           octave_quit ();
-          double btmp = b (a.ridx(i), j);
+          double btmp = b(a.ridx (i), j);
           Complex tmp;
 
           if (xisint (btmp))
-            result.xelem(a.ridx(i), j) = std::pow (a.data (i),
+            result.xelem (a.ridx (i), j) = std::pow (a.data (i),
                                               static_cast<int> (btmp));
           else
-            result.xelem(a.ridx(i), j) = std::pow (a.data (i), btmp);
+            result.xelem (a.ridx (i), j) = std::pow (a.data (i), btmp);
         }
     }
 
@@ -715,13 +715,13 @@
       return octave_value ();
     }
 
-  SparseComplexMatrix result (nr, nc, Complex(1.0, 0.0));
+  SparseComplexMatrix result (nr, nc, Complex (1.0, 0.0));
   for (octave_idx_type j = 0; j < nc; j++)
     {
-      for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
+      for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
         {
           octave_quit ();
-          result.xelem(a.ridx(i), j) = std::pow (a.data (i), b (a.ridx(i), j));
+          result.xelem (a.ridx (i), j) = std::pow (a.data (i), b(a.ridx (i), j));
         }
     }
   result.maybe_compress (true);
--- a/src/sparse.cc
+++ b/src/sparse.cc
@@ -48,7 +48,7 @@
 @seealso{ismatrix}\n\
 @end deftypefn")
 {
-   if (args.length() != 1)
+   if (args.length () != 1)
      {
        print_usage ();
        return octave_value ();
@@ -78,7 +78,8 @@
 \n\
 @strong{Note}: if multiple values are specified with the same\n\
 @var{i}, @var{j} indices, the corresponding values in @var{s} will\n\
-be added.\n\
+be added.  See @code{accumarray} for an example of how to produce different\n\
+behavior, such as taking the minimum instead.\n\
 \n\
 The following are all equivalent:\n\
 \n\
@@ -93,12 +94,12 @@
 Given the option \"unique\". if more than two values are specified for the\n\
 same @var{i}, @var{j} indices, the last specified value will be used.\n\
 \n\
-@code{sparse(@var{m}, @var{n})} is equivalent to\n\
+@code{sparse (@var{m}, @var{n})} is equivalent to\n\
 @code{sparse ([], [], [], @var{m}, @var{n}, 0)}\n\
 \n\
 If any of @var{sv}, @var{i} or @var{j} are scalars, they are expanded\n\
 to have a common size.\n\
-@seealso{full}\n\
+@seealso{full, accumarray}\n\
 @end deftypefn")
 {
    octave_value retval;
@@ -226,9 +227,9 @@
 @b{and} that the following conditions are met:\n\
 \n\
 @itemize\n\
-@item the assignment does not decrease nnz(@var{S}).\n\
+@item the assignment does not decrease nnz (@var{S}).\n\
 \n\
-@item after the assignment, nnz(@var{S}) does not exceed @var{nz}.\n\
+@item after the assignment, nnz (@var{S}) does not exceed @var{nz}.\n\
 \n\
 @item no index is out of bounds.\n\
 @end itemize\n\
--- a/src/strfns.cc
+++ b/src/strfns.cc
@@ -64,13 +64,13 @@
 @example\n\
 @group\n\
 char ([97, 98, 99], \"\", @{\"98\", \"99\", 100@}, \"str1\", [\"ha\", \"lf\"])\n\
-     @result{} [\"abc    \"\n\
-         \"       \"\n\
-         \"98     \"\n\
-         \"99     \"\n\
-         \"d      \"\n\
-         \"str1   \"\n\
-         \"half   \"]\n\
+   @result{} [\"abc    \"\n\
+       \"       \"\n\
+       \"98     \"\n\
+       \"99     \"\n\
+       \"d      \"\n\
+       \"str1   \"\n\
+       \"half   \"]\n\
 @end group\n\
 @end example\n\
 @seealso{strvcat, cellstr}\n\
@@ -152,23 +152,23 @@
 
 /*
 %!assert (char (), '');
-%!assert (char (100) == "d");
-%!assert (all(char (100,100) == ["d";"d"]));
-%!assert (all(char ({100,100}) == ["d";"d"]));
-%!assert (all(char ([100,100]) == ["dd"]));
-%!assert (all(char ({100,{100}}) == ["d";"d"]));
-%!assert (all(char (100, [], 100) == ["d";" ";"d"]))
-%!assert (all(char ({100, [], 100}) == ["d";" ";"d"]))
-%!assert (all(char ({100,{100, {""}}}) == ["d";"d";" "]))
-%!assert (all(char (["a";"be"], {"c", 100}) == ["a";"be";"c";"d"]))
-%!assert(strcmp (char ("a", "bb", "ccc"), ["a  "; "bb "; "ccc"]));
-%!assert(strcmp (char ([65, 83, 67, 73, 73]), "ASCII"));
+%!assert (char (100), "d");
+%!assert (char (100,100), ["d";"d"])
+%!assert (char ({100,100}), ["d";"d"])
+%!assert (char ([100,100]), ["dd"])
+%!assert (char ({100,{100}}), ["d";"d"])
+%!assert (char (100, [], 100), ["d";" ";"d"])
+%!assert (char ({100, [], 100}), ["d";" ";"d"])
+%!assert (char ({100,{100, {""}}}), ["d";"d";" "])
+%!assert (char (["a";"be"], {"c", 100}), ["a";"be";"c";"d"])
+%!assert (char ("a", "bb", "ccc"), ["a  "; "bb "; "ccc"])
+%!assert (char ([65, 83, 67, 73, 73]), "ASCII")
 
 %!test
 %! x = char ("foo", "bar", "foobar");
-%! assert((strcmp (x(1,:), "foo   ")
-%! && strcmp (x(2,:), "bar   ")
-%! && strcmp (x(3,:), "foobar")));
+%! assert (x(1,:), "foo   ");
+%! assert (x(2,:), "bar   ");
+%! assert (x(3,:), "foobar");
 */
 
 DEFUN (strvcat, args, ,
@@ -195,12 +195,12 @@
 @example\n\
 @group\n\
 strvcat ([97, 98, 99], \"\", @{\"98\", \"99\", 100@}, \"str1\", [\"ha\", \"lf\"])\n\
-     @result{} [\"abc    \"\n\
-         \"98     \"\n\
-         \"99     \"\n\
-         \"d      \"\n\
-         \"str1   \"\n\
-         \"half   \"]\n\
+      @result{} [\"abc    \"\n\
+          \"98     \"\n\
+          \"99     \"\n\
+          \"d      \"\n\
+          \"str1   \"\n\
+          \"half   \"]\n\
 @end group\n\
 @end example\n\
 @seealso{char, strcat, cstrcat}\n\
@@ -286,18 +286,19 @@
 }
 
 /*
-%!error <Invalid call to strvcat> strvcat()
 %!assert (strvcat (""), "");
 %!assert (strvcat (100) == "d");
-%!assert (all(strvcat (100,100) == ["d";"d"]));
-%!assert (all(strvcat ({100,100}) == ["d";"d"]));
-%!assert (all(strvcat ([100,100]) == ["dd"]));
-%!assert (all(strvcat ({100,{100}}) == ["d";"d"]));
-%!assert (all(strvcat (100, [], 100) == ["d";"d"]))
-%!assert (all(strvcat ({100, [], 100}) == ["d";"d"]))
-%!assert (all(strvcat ({100,{100, {""}}}) == ["d";"d"]))
-%!assert (all(strvcat (["a";"be"], {"c", 100}) == ["a";"be";"c";"d"]))
-%!assert(strcmp (strvcat ("a", "bb", "ccc"), ["a  "; "bb "; "ccc"]));
+%!assert (strvcat (100,100), ["d";"d"])
+%!assert (strvcat ({100,100}), ["d";"d"])
+%!assert (strvcat ([100,100]), ["dd"])
+%!assert (strvcat ({100,{100}}), ["d";"d"])
+%!assert (strvcat (100, [], 100), ["d";"d"])
+%!assert (strvcat ({100, [], 100}), ["d";"d"])
+%!assert (strvcat ({100,{100, {""}}}), ["d";"d"])
+%!assert (strvcat (["a";"be"], {"c", 100}), ["a";"be";"c";"d"])
+%!assert (strvcat ("a", "bb", "ccc"), ["a  "; "bb "; "ccc"])
+
+%!error strvcat ()
 */
 
 
@@ -321,19 +322,20 @@
 }
 
 /*
-%!assert (ischar ("a"), logical (1));
-%!assert (ischar (["ab";"cd"]), logical (1));
-%!assert (ischar ({"ab"}), logical (0));
-%!assert (ischar (1), logical (0));
-%!assert(ischar ([1, 2]), logical (0));
-%!assert(ischar ([]), logical (0));
-%!assert(ischar ([1, 2; 3, 4]), logical (0));
-%!assert(ischar (""), logical (1));
-%!assert(ischar ("test"), logical (1));
-%!assert(ischar (["test"; "ing"]), logical (1));
-%!assert(ischar (struct ("foo", "bar")), logical (0));
-%!error <Invalid call to ischar> ischar ();
-%!error <Invalid call to ischar> ischar ("test", 1);
+%!assert (ischar ("a"), true)
+%!assert (ischar (["ab";"cd"]), true)
+%!assert (ischar ({"ab"}), false)
+%!assert (ischar (1), false)
+%!assert (ischar ([1, 2]), false)
+%!assert (ischar ([]), false)
+%!assert (ischar ([1, 2; 3, 4]), false)
+%!assert (ischar (""), true)
+%!assert (ischar ("test"), true)
+%!assert (ischar (["test"; "ing"]), true)
+%!assert (ischar (struct ("foo", "bar")), false)
+
+%!error ischar ()
+%!error ischar ("test", 1)
 */
 
 static octave_value
@@ -589,51 +591,51 @@
 }
 
 /*
-%!error <Invalid call to strcmp> strcmp ();
-%!error <Invalid call to strcmp> strcmp ("foo", "bar", 3);
-%!
 %!shared x
-%!  x = char (zeros (0, 2));
-%!assert (strcmp ('', x) == false);
-%!assert (strcmp (x, '') == false);
-%!assert (strcmp (x, x) == true);
-## %!assert (strcmp ({''}, x) == true);
-## %!assert (strcmp ({x}, '') == false);
-## %!assert (strcmp ({x}, x) == true);
-## %!assert (strcmp ('', {x}) == false);
-## %!assert (strcmp (x, {''}) == false);
-## %!assert (strcmp (x, {x}) == true);
-## %!assert (all (strcmp ({x; x}, '') == [false; false]));
-## %!assert (all (strcmp ({x; x}, {''}) == [false; false]));
-## %!assert (all (strcmp ('', {x; x}) == [false; false]));
-## %!assert (all (strcmp ({''}, {x; x}) == [false; false]));
-%!assert (strcmp ({'foo'}, x) == false);
-%!assert (strcmp ({'foo'}, 'foo') == true);
-%!assert (strcmp ({'foo'}, x) == false);
-%!assert (strcmp (x, {'foo'}) == false);
-%!assert (strcmp ('foo', {'foo'}) == true);
-%!assert (strcmp (x, {'foo'}) == false);
+%! x = char (zeros (0, 2));
+%!assert (strcmp ("", x), false)
+%!assert (strcmp (x, ""), false)
+%!assert (strcmp (x, x), true)
+## %!assert (strcmp ({""}, x), true)
+## %!assert (strcmp ({x}, ""), false)
+## %!assert (strcmp ({x}, x), true)
+## %!assert (strcmp ("", {x}), false)
+## %!assert (strcmp (x, {""}), false)
+## %!assert (strcmp (x, {x}), true)
+## %!assert (strcmp ({x; x}, ""), [false; false])
+## %!assert (strcmp ({x; x}, {""}), [false; false])
+## %!assert (strcmp ("", {x; x}), [false; false])
+## %!assert (strcmp ({""}, {x; x}), [false; false])
+%!assert (strcmp ({"foo"}, x), false)
+%!assert (strcmp ({"foo"}, "foo"), true)
+%!assert (strcmp ({"foo"}, x), false)
+%!assert (strcmp (x, {"foo"}), false)
+%!assert (strcmp ("foo", {"foo"}), true)
+%!assert (strcmp (x, {"foo"}), false)
 %!shared y
-%!  y = char (zeros (2, 0));
-%!assert (strcmp ('', y) == false);
-%!assert (strcmp (y, '') == false);
-%!assert (strcmp (y, y) == true);
-%!assert (all (strcmp ({''}, y) == [true; true]));
-%!assert (strcmp ({y}, '') == true);
-%!assert (all (strcmp ({y}, y) == [true; true]));
-%!assert (all (strcmp ('', {y}) == [true; true]));
-%!assert (all (strcmp (y, {''}) == [true; true]));
-%!assert (all (strcmp (y, {y}) == [true; true]));
-%!assert (all (strcmp ({y; y}, '') == [true; true]));
-%!assert (all (strcmp ({y; y}, {''}) == [true; true]));
-%!assert (all (strcmp ('', {y; y}) == [true; true]));
-%!assert (all (strcmp ({''}, {y; y}) == [true; true]));
-%!assert (all (strcmp ({'foo'}, y) == [false; false]));
-%!assert (all (strcmp ({'foo'}, y) == [false; false]));
-%!assert (all (strcmp (y, {'foo'}) == [false; false]));
-%!assert (all (strcmp (y, {'foo'}) == [false; false]));
-%!assert (strcmp ("foobar", "foobar"), true);
-%!assert (strcmp ("fooba", "foobar"), false);
+%! y = char (zeros (2, 0));
+%!assert (strcmp ("", y), false)
+%!assert (strcmp (y, ""), false)
+%!assert (strcmp (y, y), true)
+%!assert (strcmp ({""}, y), [true; true])
+%!assert (strcmp ({y}, ""), true)
+%!assert (strcmp ({y}, y), [true; true])
+%!assert (strcmp ("", {y}), true)
+%!assert (strcmp (y, {""}), [true; true])
+%!assert (strcmp (y, {y}), [true; true])
+%!assert (strcmp ({y; y}, ""), [true; true])
+%!assert (strcmp ({y; y}, {""}), [true; true])
+%!assert (strcmp ("", {y; y}), [true; true])
+%!assert (strcmp ({""}, {y; y}), [true; true])
+%!assert (strcmp ({"foo"}, y), [false; false])
+%!assert (strcmp ({"foo"}, y), [false; false])
+%!assert (strcmp (y, {"foo"}), [false; false])
+%!assert (strcmp (y, {"foo"}), [false; false])
+%!assert (strcmp ("foobar", "foobar"), true)
+%!assert (strcmp ("fooba", "foobar"), false)
+
+%!error strcmp ()
+%!error strcmp ("foo", "bar", 3)
 */
 
 // Apparently, Matlab ignores the dims with strncmp. It also
@@ -665,7 +667,7 @@
 @example\n\
 @group\n\
 strncmp (\"abce\", \"abcd\", 3)\n\
-     @result{} 1\n\
+      @result{} 1\n\
 @end group\n\
 @end example\n\
 \n\
@@ -712,15 +714,16 @@
 }
 
 /*
-%!error <Invalid call to strncmp> strncmp ();
-%!error <Invalid call to strncmp> strncmp ("abc", "def");
-%!assert (strncmp ("abce", "abc", 3) == 1)
-%!assert (strncmp (100, 100, 1) == 0)
-%!assert (all (strncmp ("abce", {"abcd", "bca", "abc"}, 3) == [1, 0, 1]))
-%!assert (all (strncmp ("abc",  {"abcd", "bca", "abc"}, 4) == [0, 0, 0]))
-%!assert (all (strncmp ({"abcd", "bca", "abc"},"abce", 3) == [1, 0, 1]))
-%!assert (all (strncmp ({"abcd", "bca", "abc"},{"abcd", "bca", "abe"}, 3) == [1, 1, 0]))
-%!assert (all (strncmp("abc", {"abcd", 10}, 2) == [1, 0]))
+%!assert (strncmp ("abce", "abc", 3), true)
+%!assert (strncmp (100, 100, 1), false)
+%!assert (strncmp ("abce", {"abcd", "bca", "abc"}, 3), logical ([1, 0, 1]))
+%!assert (strncmp ("abc",  {"abcd", "bca", "abc"}, 4), logical ([0, 0, 0]))
+%!assert (strncmp ({"abcd", "bca", "abc"},"abce", 3), logical ([1, 0, 1]))
+%!assert (strncmp ({"abcd", "bca", "abc"},{"abcd", "bca", "abe"}, 3), logical ([1, 1, 0]))
+%!assert (strncmp ("abc", {"abcd", 10}, 2), logical ([1, 0]))
+
+%!error strncmp ()
+%!error strncmp ("abc", "def")
 */
 
 // case-insensitive character equality functor
@@ -783,7 +786,7 @@
 }
 
 /*
-%!assert (strcmpi("abc123", "ABC123"), logical(1));
+%!assert (strcmpi ("abc123", "ABC123"), true)
 */
 
 // Like strncmp.
@@ -850,16 +853,18 @@
 }
 
 /*
-%!assert (strncmpi("abc123", "ABC456", 3), logical(1));
+%!assert (strncmpi ("abc123", "ABC456", 3), true)
 */
 
 DEFUN (list_in_columns, args, ,
   "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {} list_in_columns (@var{arg}, @var{width})\n\
+@deftypefn {Built-in Function} {} list_in_columns (@var{arg}, @var{width}, @var{prefix})\n\
 Return a string containing the elements of @var{arg} listed in\n\
-columns with an overall maximum width of @var{width}.  The argument\n\
-@var{arg} must be a cell array of character strings or a character array.\n\
-If @var{width} is not specified, the width of the terminal screen is used.\n\
+columns with an overall maximum width of @var{width} and optional\n\
+prefix @var{prefix}.  The argument @var{arg} must be a cell array\n\
+of character strings or a character array.  If @var{width} is not\n\
+specified or is an empty matrix, or less than or equal to zero,\n\
+the width of the terminal screen is used.\n\
 Newline characters are used to break the lines in the output string.\n\
 For example:\n\
 @c Set example in small font to prevent overfull line\n\
@@ -867,9 +872,9 @@
 @smallexample\n\
 @group\n\
 list_in_columns (@{\"abc\", \"def\", \"ghijkl\", \"mnop\", \"qrs\", \"tuv\"@}, 20)\n\
-     @result{} ans = abc     mnop\n\
-            def     qrs\n\
-            ghijkl  tuv\n\
+     @result{} abc     mnop\n\
+        def     qrs\n\
+        ghijkl  tuv\n\
 \n\
 whos ans\n\
      @result{}\n\
@@ -890,48 +895,79 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
+  if (nargin < 1 || nargin > 3)
     {
-      string_vector s = args(0).all_strings ();
+      print_usage ();
+      return retval;
+    }
+
+  string_vector s = args(0).all_strings ();
 
-      if (! error_state)
-        {
-          std::ostringstream buf;
+  if (error_state)
+    {
+      error ("list_in_columns: expecting cellstr or char array");
+      return retval;
+    }
+
+  int width = -1;
+
+  if (nargin > 1 && ! args(1).is_empty ())
+    {
+      width = args(1).int_value ();
 
-          if (nargin == 1)
-            // Let list_in_columns query terminal width.
-            s.list_in_columns (buf);
-          else
-            {
-              int width = args(1).int_value ();
+      if (error_state)
+        {
+          error ("list_in_columns: WIDTH must be an integer");
+          return retval;
+        }
+    }
+                
+  std::string prefix;
 
-              if (! error_state)
-                s.list_in_columns (buf, width);
-              else
-                error ("list_in_columns: WIDTH must be an integer");
+  if (nargin > 2)
+    {
+      if (args(2).is_string ())
+        {
+          prefix = args(2).string_value ();
+
+          if (error_state)
+            {
+              error ("list_in_columns: PREFIX must be a character string");
+              return retval;
             }
-
-          retval = buf.str ();
         }
       else
-        error ("list_in_columns: expecting cellstr or char array");
+        {
+          error ("list_in_columns: PREFIX must be a character string");
+          return retval;
+        }
     }
-  else
-    print_usage ();
+
+  std::ostringstream buf;
+
+  s.list_in_columns (buf, width, prefix);
+
+  retval = buf.str ();
 
   return retval;
 }
 
 /*
-%!error <Invalid call to list_in_columns> list_in_columns ();
-%!error <Invalid call to list_in_columns> list_in_columns (["abc", "def"], 20, 2);
-%!error <invalid conversion from string to real scalar> list_in_columns (["abc", "def"], "a");
+%!test
+%! input  = {"abc", "def", "ghijkl", "mnop", "qrs", "tuv"};
+%! result = "abc     mnop\ndef     qrs\nghijkl  tuv\n";
+%! assert (list_in_columns (input, 20), result);
+%!test
+%! input  = ["abc"; "def"; "ghijkl"; "mnop"; "qrs"; "tuv"];
+%! result = "abc     mnop  \ndef     qrs   \nghijkl  tuv   \n";
+%! assert (list_in_columns (input, 20), result);
 %!test
-%!  input  = {"abc", "def", "ghijkl", "mnop", "qrs", "tuv"};
-%!  result = "abc     mnop\ndef     qrs\nghijkl  tuv\n";
-%!  assert (list_in_columns (input, 20) == result);
-%!test
-%!  input  = ["abc"; "def"; "ghijkl"; "mnop"; "qrs"; "tuv"];
-%!  result = "abc     mnop  \ndef     qrs   \nghijkl  tuv   \n";
-%!  assert (list_in_columns (input, 20) == result);
+%! input  = ["abc"; "def"; "ghijkl"; "mnop"; "qrs"; "tuv"];
+%! result = "  abc     mnop  \n  def     qrs   \n  ghijkl  tuv   \n";
+%! assert (list_in_columns (input, 20, "  "), result);
+
+%!error list_in_columns ()
+%!error list_in_columns (["abc", "def"], 20, 2)
+%!error list_in_columns (["abc", "def"], 20, "  ", 3)
+%!error <invalid conversion from string to real scalar> list_in_columns (["abc", "def"], "a")
 */
--- a/src/symtab.cc
+++ b/src/symtab.cc
@@ -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_loc = get_instance (fv->scope ());
+
+  symbol_table *parent_table = get_instance (parent_scope);
+
+  parent_table->add_nest_child (*fcn_table_loc);
+}
+
 octave_value
 symbol_table::find (const std::string& name,
                     const octave_value_list& args,
@@ -1195,7 +1201,7 @@
           std::string fcn_scope = name.substr (0, pos);
           scope_id stored_scope = xcurrent_scope;
           xcurrent_scope = xtop_scope;
-          octave_value parent = find_function (name.substr(0, pos),
+          octave_value parent = find_function (name.substr (0, pos),
                                                octave_value_list (), false);
 
           if (parent.is_defined ())
@@ -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\
@@ -1531,11 +1575,10 @@
 %! assert (ignore_function_time_stamp (), "system");
 %! ignore_function_time_stamp (old_state);
 
-%% Test input validation
+## Test input validation
 %!error (ignore_function_time_stamp ("all", "all"))
 %!error (ignore_function_time_stamp ("UNKNOWN_VALUE"))
 %!error (ignore_function_time_stamp (42))
-
 */
 
 DEFUN (__current_scope__, , ,
--- a/src/symtab.h
+++ b/src/symtab.h
@@ -206,22 +206,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);
@@ -229,6 +233,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 ());
@@ -237,7 +244,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);
@@ -245,6 +252,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
@@ -252,9 +262,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 ());
       }
 
@@ -272,11 +283,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 ();
@@ -285,9 +297,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 ();
@@ -295,22 +310,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 ());
       }
 
@@ -355,31 +381,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;
@@ -388,6 +432,8 @@
 
       fcn_info *finfo;
 
+      bool valid;
+
       octave_refcount<size_t> count;
 
     private:
@@ -401,10 +447,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)
@@ -432,39 +479,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);
     }
@@ -500,8 +558,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
     {
@@ -928,7 +994,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;
@@ -1009,7 +1075,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)
           {
@@ -1034,7 +1100,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
@@ -1074,7 +1141,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);
 
@@ -1084,7 +1151,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;
 
@@ -1095,7 +1162,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);
 
@@ -1263,6 +1330,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)
   {
@@ -1620,7 +1698,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);
@@ -1672,7 +1750,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));
       }
 
@@ -1694,7 +1773,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));
       }
 
@@ -1924,7 +2004,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;
     }
@@ -1953,6 +2034,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);
@@ -1961,6 +2045,12 @@
   // Map from symbol names to symbol info.
   std::map<std::string, symbol_record> table;
 
+  // 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;
 
@@ -2000,8 +2090,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) { }
 
@@ -2017,7 +2110,7 @@
           {
             if (! instance && create)
               {
-                symbol_table *inst = new symbol_table ();
+                symbol_table *inst = new symbol_table (scope);
 
                 if (inst)
                   {
@@ -2041,7 +2134,7 @@
               {
                 if (create)
                   {
-                    retval = new symbol_table ();
+                    retval = new symbol_table (scope);
 
                     if (retval)
                       all_instances[scope] = retval;
@@ -2063,6 +2156,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)
   {
     table[sr.name ()] = sr;
@@ -2072,7 +2172,7 @@
   do_dup_scope (symbol_table& new_symbol_table) const
   {
     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)
@@ -2126,8 +2226,17 @@
   {
     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)
@@ -2207,15 +2316,15 @@
   void do_push_context (void)
   {
     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)
   {
     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++;
       }
@@ -2224,7 +2333,7 @@
   void do_clear_variables (void)
   {
     for (table_iterator p = table.begin (); p != table.end (); p++)
-      p->second.clear ();
+      p->second.clear (my_scope);
   }
 
   void do_clear_objects (void)
@@ -2233,8 +2342,8 @@
       {
         symbol_record& sr = p->second;
         octave_value& val = sr.varref ();
-        if (val.is_object())
-          p->second.clear ();
+        if (val.is_object ())
+          p->second.clear (my_scope);
       }
   }
 
@@ -2268,7 +2377,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)
@@ -2308,7 +2417,7 @@
         if (sr.is_defined () || sr.is_global ())
           {
             if (pattern.match (sr.name ()))
-              sr.clear ();
+              sr.clear (my_scope);
           }
       }
   }
@@ -2324,7 +2433,7 @@
         if (sr.is_defined () || sr.is_global ())
           {
             if (pattern.is_match (sr.name ()))
-              sr.clear ();
+              sr.clear (my_scope);
           }
       }
   }
@@ -2462,6 +2571,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/syscalls.cc
+++ b/src/syscalls.cc
@@ -269,10 +269,11 @@
 until (done)\n\
 fclose (out);\n\
 waitpid (pid);\n\
-     @print{} these\n\
-     @print{} strings\n\
-     @print{} some\n\
-     @print{} are\n\
+\n\
+   @print{} these\n\
+   @print{} strings\n\
+   @print{} some\n\
+   @print{} are\n\
 @end example\n\
 \n\
 Note that @code{popen2}, unlike @code{popen}, will not \"reap\" the\n\
@@ -290,7 +291,7 @@
 
   if (nargin >= 1 && nargin <= 3)
     {
-      std::string exec_file = args(0).string_value();
+      std::string exec_file = args(0).string_value ();
 
       if (! error_state)
         {
@@ -323,7 +324,7 @@
 
           if (! error_state)
             {
-              bool sync_mode = (nargin == 3 ? args(2).bool_value() : false);
+              bool sync_mode = (nargin == 3 ? args(2).bool_value () : false);
 
               if (! error_state)
                 {
@@ -368,46 +369,44 @@
 }
 
 /*
-
 %!test
-%!  if (isunix())
-%!    [in, out, pid] = popen2 ("sort", "-r");
-%!    EAGAIN = errno ("EAGAIN");
-%!  else
-%!    [in, out, pid] = popen2 ("sort", "/R");
-%!    EAGAIN = errno ("EINVAL");
-%!  endif
-%!  fputs (in, "these\nare\nsome\nstrings\n");
-%!  fclose (in);
-%!  done = false;
-%!  str = {};
-%!  idx = 0;
-%!  errs = 0;
-%!  do
-%!     if (!isunix())
-%!       errno (0);
-%!     endif
-%!     s = fgets (out);
-%!     if (ischar (s))
-%!       idx++;
-%!       str{idx} = s;
-%!     elseif (errno () == EAGAIN)
-%!       fclear (out);
-%!       sleep (0.1);
-%!       if (++errs == 100)
-%!         done = true;
-%!       endif
-%!     else
+%! if (isunix ())
+%!   [in, out, pid] = popen2 ("sort", "-r");
+%!   EAGAIN = errno ("EAGAIN");
+%! else
+%!   [in, out, pid] = popen2 ("sort", "/R");
+%!   EAGAIN = errno ("EINVAL");
+%! endif
+%! fputs (in, "these\nare\nsome\nstrings\n");
+%! fclose (in);
+%! done = false;
+%! str = {};
+%! idx = 0;
+%! errs = 0;
+%! do
+%!   if (!isunix ())
+%!     errno (0);
+%!   endif
+%!   s = fgets (out);
+%!   if (ischar (s))
+%!     idx++;
+%!     str{idx} = s;
+%!   elseif (errno () == EAGAIN)
+%!     fclear (out);
+%!     sleep (0.1);
+%!     if (++errs == 100)
 %!       done = true;
 %!     endif
-%!  until (done)
-%!  fclose (out);
-%!  if (isunix())
-%!    assert(str,{"these\n","strings\n","some\n","are\n"})
-%!  else
-%!    assert(str,{"these\r\n","strings\r\n","some\r\n","are\r\n"})
-%!  end
-
+%!   else
+%!     done = true;
+%!   endif
+%! until (done)
+%! fclose (out);
+%! if (isunix ())
+%!   assert (str, {"these\n","strings\n","some\n","are\n"});
+%! else
+%!   assert (str, {"these\r\n","strings\r\n","some\r\n","are\r\n"});
+%! endif
 */
 
 DEFUNX ("fcntl", Ffcntl, args, ,
@@ -949,25 +948,25 @@
 \n\
 @example\n\
 [s, err, msg] = stat (\"/vmlinuz\")\n\
-      @result{} s =\n\
-        @{\n\
-          atime = 855399756\n\
-          rdev = 0\n\
-          ctime = 847219094\n\
-          uid = 0\n\
-          size = 389218\n\
-          blksize = 4096\n\
-          mtime = 847219094\n\
-          gid = 6\n\
-          nlink = 1\n\
-          blocks = 768\n\
-          mode = -rw-r--r--\n\
-          modestr = -rw-r--r--\n\
-          ino = 9316\n\
-          dev = 2049\n\
-        @}\n\
-     @result{} err = 0\n\
-     @result{} msg =\n\
+  @result{} s =\n\
+     @{\n\
+       atime = 855399756\n\
+       rdev = 0\n\
+       ctime = 847219094\n\
+       uid = 0\n\
+       size = 389218\n\
+       blksize = 4096\n\
+       mtime = 847219094\n\
+       gid = 6\n\
+       nlink = 1\n\
+       blocks = 768\n\
+       mode = -rw-r--r--\n\
+       modestr = -rw-r--r--\n\
+       ino = 9316\n\
+       dev = 2049\n\
+     @}\n\
+  @result{} err = 0\n\
+  @result{} msg =\n\
 @end example\n\
 @end deftypefn")
 {
@@ -1203,13 +1202,13 @@
 @example\n\
 @group\n\
 uname ()\n\
-     @result{} @{\n\
-           sysname = x86_64\n\
-           nodename = segfault\n\
-           release = 2.6.15-1-amd64-k8-smp\n\
-           version = Linux\n\
-           machine = #2 SMP Thu Feb 23 04:57:49 UTC 2006\n\
-         @}\n\
+   @result{} @{\n\
+         sysname = x86_64\n\
+         nodename = segfault\n\
+         release = 2.6.15-1-amd64-k8-smp\n\
+         version = Linux\n\
+         machine = #2 SMP Thu Feb 23 04:57:49 UTC 2006\n\
+      @}\n\
 @end group\n\
 @end example\n\
 \n\
@@ -1595,8 +1594,10 @@
 
 DEFUNX ("canonicalize_file_name", Fcanonicalize_file_name, args, ,
   "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {[@var{cname}, @var{status}, @var{msg}]} canonicalize_file_name (@var{name})\n\
-Return the canonical name of file @var{name}.\n\
+@deftypefn {Built-in Function} {[@var{cname}, @var{status}, @var{msg}] =} canonicalize_file_name (@var{fname})\n\
+Return the canonical name of file @var{fname}.  If the file does not exist\n\
+the empty string (\"\") is returned.\n\
+@seealso{make_absolute_filename, is_absolute_filename, is_rooted_relative_filename}\n\
 @end deftypefn")
 {
   octave_value_list retval;
--- a/src/sysdep.cc
+++ b/src/sysdep.cc
@@ -124,21 +124,21 @@
       mod_info.dwSize = sizeof (mod_info);
 
       if (Module32First (h, &mod_info))
-	{
-	  do
-	    {
-	      std::string mod_name (mod_info.szModule);
+        {
+          do
+            {
+              std::string mod_name (mod_info.szModule);
 
-	      if (mod_name.find ("octinterp") != std::string::npos)
-		{
-		  bin_dir = mod_info.szExePath;
-		  if (bin_dir[bin_dir.length () - 1] != '\\')
-		    bin_dir.append (1, '\\');
-		  break;
-		}
-	    }
-	  while (Module32Next (h, &mod_info));
-	}
+              if (mod_name.find ("octinterp") != std::string::npos)
+                {
+                  bin_dir = mod_info.szExePath;
+                  if (bin_dir[bin_dir.length () - 1] != '\\')
+                    bin_dir.append (1, '\\');
+                  break;
+                }
+            }
+          while (Module32Next (h, &mod_info));
+       }
 
       CloseHandle (h);
     }
@@ -255,7 +255,7 @@
 void
 sysdep_init (void)
 {
-#if defined (__386BSD__) || defined (__FreeBSD__) || defined(__NetBSD__)
+#if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__)
   BSD_init ();
 #elif defined (__MINGW32__)
   MINGW_init ();
@@ -608,7 +608,7 @@
 DEFALIAS (setenv, putenv);
 
 /*
-%!assert (ischar (getenv ("OCTAVE_HOME")));
+%!assert (ischar (getenv ("OCTAVE_HOME")))
 %!test
 %! setenv ("dummy_variable_that_cannot_matter", "foobar");
 %! assert (getenv ("dummy_variable_that_cannot_matter"), "foobar");
@@ -722,9 +722,10 @@
 }
 
 /*
-%!error (pause (1, 2));
 %!test
 %! pause (1);
+
+%!error (pause (1, 2))
 */
 
 DEFUN (sleep, args, ,
@@ -757,10 +758,11 @@
 }
 
 /*
-%!error (sleep ());
-%!error (sleep (1, 2));
 %!test
 %! sleep (1);
+
+%!error (sleep ())
+%!error (sleep (1, 2))
 */
 
 DEFUN (usleep, args, ,
@@ -800,10 +802,11 @@
 }
 
 /*
-%!error (usleep ());
-%!error (usleep (1, 2));
 %!test
 %! usleep (1000);
+
+%!error (usleep ())
+%!error (usleep (1, 2))
 */
 
 // FIXME -- maybe this should only return 1 if IEEE floating
@@ -823,7 +826,7 @@
 }
 
 /*
-%!assert (islogical (isieee ()));
+%!assert (islogical (isieee ()))
 */
 
 DEFUN (native_float_format, , ,
@@ -838,7 +841,7 @@
 }
 
 /*
-%!assert (ischar (native_float_format ()));
+%!assert (ischar (native_float_format ()))
 */
 
 DEFUN (tilde_expand, args, ,
--- a/src/toplev.cc
+++ b/src/toplev.cc
@@ -962,7 +962,7 @@
               PROCESS_INFORMATION pi;
               ZeroMemory (&si, sizeof (si));
               ZeroMemory (&pi, sizeof (pi));
-              OCTAVE_LOCAL_BUFFER (char, xcmd_str, cmd_str.length()+1);
+              OCTAVE_LOCAL_BUFFER (char, xcmd_str, cmd_str.length ()+1);
               strcpy (xcmd_str, cmd_str.c_str ());
 
               if (! CreateProcess (0, xcmd_str, 0, 0, FALSE, 0, 0, 0, &si, &pi))
@@ -1484,12 +1484,13 @@
 }
 
 /*
-%!error octave_config_info (1, 2);
-%!assert (ischar (octave_config_info ("version")));
+%!assert (ischar (octave_config_info ("version")))
 %!test
 %! x = octave_config_info ();
 %! assert (isstruct (x));
 %! assert (! isempty (x));
+
+%!error octave_config_info (1, 2)
 */
 
 #if defined (__GNUG__) && defined (DEBUG_NEW_DELETE)
--- a/src/txt-eng-ft.cc
+++ b/src/txt-eng-ft.cc
@@ -240,7 +240,7 @@
 ft_render::ft_render (void)
     : text_processor (), face (0), bbox (1, 4, 0.0),
       xoffset (0), yoffset (0), multiline_halign (0),
-      multiline_align_xoffsets(), mode (MODE_BBOX),
+      multiline_align_xoffsets (), mode (MODE_BBOX),
       red (0), green (0), blue (0)
 {
 }
@@ -314,7 +314,7 @@
       FT_UInt glyph_index, previous = 0;
 
       if (mode == MODE_BBOX)
-        multiline_align_xoffsets.clear();
+        multiline_align_xoffsets.clear ();
       else if (mode == MODE_RENDER)
         xoffset += multiline_align_xoffsets[line_index];
 
@@ -333,7 +333,7 @@
                 case MODE_RENDER:
                   if (str[i] == '\n')
                     {
-                    glyph_index = FT_Get_Char_Index(face, ' ');
+                    glyph_index = FT_Get_Char_Index (face, ' ');
                     if (!glyph_index || FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT))
                       {
                         gripe_missing_glyph (' ');
@@ -376,8 +376,8 @@
                         for (int c = 0; c < bitmap.width; c++)
                           {
                             unsigned char pix = bitmap.buffer[r*bitmap.width+c];
-                            if (x0+c < 0 || x0+c >= pixels.dim2()
-                                || y0-r < 0 || y0-r >= pixels.dim3())
+                            if (x0+c < 0 || x0+c >= pixels.dim2 ()
+                                || y0-r < 0 || y0-r >= pixels.dim3 ())
                               {
                                 //::error ("out-of-bound indexing!!");
                               }
@@ -397,7 +397,7 @@
                 case MODE_BBOX:
                   if (str[i] == '\n')
                     {
-                      glyph_index = FT_Get_Char_Index(face, ' ');
+                      glyph_index = FT_Get_Char_Index (face, ' ');
                       if (! glyph_index
                           || FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT))
                       {
@@ -405,7 +405,7 @@
                       }
                     else
                       {
-                        multiline_align_xoffsets.push_back(box_line_width);
+                        multiline_align_xoffsets.push_back (box_line_width);
                         // Reset the pixel width for this newline, so we don't
                         // allocate a bounding box larger than the horizontal
                         // width of the multi-line
@@ -465,9 +465,9 @@
       if (mode == MODE_BBOX)
         {
           /* Push last the width associated with the last line */
-          multiline_align_xoffsets.push_back(box_line_width);
+          multiline_align_xoffsets.push_back (box_line_width);
 
-          for (unsigned int i = 0; i < multiline_align_xoffsets.size(); i++)
+          for (unsigned int i = 0; i < multiline_align_xoffsets.size (); i++)
             {
             /* Center align */
             if (multiline_halign == 1)
@@ -529,7 +529,7 @@
 
               Array<idx_vector> idx (dim_vector (3, 1));
               idx(0) = idx_vector (':');
-              idx(1) = idx_vector (pixels.dim2()-1, -1, -1);
+              idx(1) = idx_vector (pixels.dim2 ()-1, -1, -1);
               idx(2) = idx_vector (':');
               pixels = uint8NDArray (pixels.index (idx));
             }
@@ -538,8 +538,8 @@
             {
               Array<idx_vector> idx (dim_vector (3, 1));
               idx(0) = idx_vector (':');
-              idx(1) = idx_vector (pixels.dim2()-1, -1, -1);
-              idx(2)=  idx_vector (pixels.dim3()-1, -1, -1);
+              idx(1) = idx_vector (pixels.dim2 ()-1, -1, -1);
+              idx(2)=  idx_vector (pixels.dim3 ()-1, -1, -1);
               pixels = uint8NDArray (pixels.index (idx));
             }
           break;
@@ -554,7 +554,7 @@
               Array<idx_vector> idx (dim_vector (3, 1));
               idx(0) = idx_vector (':');
               idx(1) = idx_vector (':');
-              idx(2) = idx_vector (pixels.dim3()-1, -1, -1);
+              idx(2) = idx_vector (pixels.dim3 ()-1, -1, -1);
               pixels = uint8NDArray (pixels.index (idx));
             }
           break;
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -117,14 +117,14 @@
 }
 
 /*
-%!error isvarname ();
-%!error isvarname ("foo", "bar");
+%!assert (isvarname ("foo"), true)
+%!assert (isvarname ("_foo"), true)
+%!assert (isvarname ("_1"), true)
+%!assert (isvarname ("1foo"), false)
+%!assert (isvarname (""), false)
 
-%!assert (isvarname ("foo"), true);
-%!assert (isvarname ("_foo"), true);
-%!assert (isvarname ("_1"), true);
-%!assert (isvarname ("1foo"), false);
-%!assert (isvarname (""), false);
+%!error isvarname ()
+%!error isvarname ("foo", "bar");
 */
 
 // Return TRUE if F and G are both names for the same file.
@@ -339,9 +339,6 @@
 }
 
 /*
-%!error file_in_loadpath ();
-%!error file_in_loadpath ("foo", "bar", 1);
-
 %!test
 %! f = file_in_loadpath ("plot.m");
 %! assert (ischar (f));
@@ -354,6 +351,9 @@
 %!test
 %! lst = file_in_loadpath ("$$probably_!!_not_&&_a_!!_file$$", "all");
 %! assert (lst, {});
+
+%!error file_in_loadpath ()
+%!error file_in_loadpath ("foo", "bar", 1)
 */
 
 DEFUN (file_in_path, args, ,
@@ -422,10 +422,6 @@
 }
 
 /*
-%!error file_in_path ();
-%!error file_in_path ("foo");
-%!error file_in_path ("foo", "bar", "baz", 1);
-
 %!test
 %! f = file_in_path (path (), "plot.m");
 %! assert (ischar (f));
@@ -438,6 +434,10 @@
 %!test
 %! lst = file_in_path (path (), "$$probably_!!_not_&&_a_!!_file$$", "all");
 %! assert (lst, {});
+
+%!error file_in_path ()
+%!error file_in_path ("foo")
+%!error file_in_path ("foo", "bar", "baz", 1)
 */
 
 std::string
@@ -674,19 +674,19 @@
 }
 
 /*
-%!error do_string_escapes ();
-%!error do_string_escapes ("foo", "bar");
+%!assert (do_string_escapes ('foo\nbar'), "foo\nbar")
+%!assert (do_string_escapes ("foo\\nbar"), "foo\nbar")
+%!assert (do_string_escapes ("foo\\nbar"), ["foo", char(10), "bar"])
+%!assert ("foo\nbar", ["foo", char(10), "bar"])
 
-%!assert (do_string_escapes ('foo\nbar'), "foo\nbar");
-%!assert (do_string_escapes ("foo\\nbar"), "foo\nbar");
-%!assert (do_string_escapes ("foo\\nbar"), ["foo", char(10), "bar"]);
-%!assert ("foo\nbar", ["foo", char(10), "bar"]);
+%!assert (do_string_escapes ('\a\b\f\n\r\t\v'), "\a\b\f\n\r\t\v")
+%!assert (do_string_escapes ("\\a\\b\\f\\n\\r\\t\\v"), "\a\b\f\n\r\t\v")
+%!assert (do_string_escapes ("\\a\\b\\f\\n\\r\\t\\v"),
+%!        char ([7, 8, 12, 10, 13, 9, 11]))
+%!assert ("\a\b\f\n\r\t\v", char ([7, 8, 12, 10, 13, 9, 11]))
 
-%!assert (do_string_escapes ('\a\b\f\n\r\t\v'), "\a\b\f\n\r\t\v");
-%!assert (do_string_escapes ("\\a\\b\\f\\n\\r\\t\\v"), "\a\b\f\n\r\t\v");
-%!assert (do_string_escapes ("\\a\\b\\f\\n\\r\\t\\v"),
-%!        char ([7, 8, 12, 10, 13, 9, 11]));
-%!assert ("\a\b\f\n\r\t\v", char ([7, 8, 12, 10, 13, 9, 11]));
+%!error do_string_escapes ()
+%!error do_string_escapes ("foo", "bar")
 */
 
 const char *
@@ -796,17 +796,17 @@
 }
 
 /*
-%!error undo_string_escapes ();
-%!error undo_string_escapes ("foo", "bar");
+%!assert (undo_string_escapes ("foo\nbar"), 'foo\nbar')
+%!assert (undo_string_escapes ("foo\nbar"), "foo\\nbar")
+%!assert (undo_string_escapes (["foo", char(10), "bar"]), "foo\\nbar")
 
-%!assert (undo_string_escapes ("foo\nbar"), 'foo\nbar');
-%!assert (undo_string_escapes ("foo\nbar"), "foo\\nbar");
-%!assert (undo_string_escapes (["foo", char(10), "bar"]), "foo\\nbar");
+%!assert (undo_string_escapes ("\a\b\f\n\r\t\v"), '\a\b\f\n\r\t\v')
+%!assert (undo_string_escapes ("\a\b\f\n\r\t\v"), "\\a\\b\\f\\n\\r\\t\\v")
+%!assert (undo_string_escapes (char ([7, 8, 12, 10, 13, 9, 11])),
+%!        "\\a\\b\\f\\n\\r\\t\\v")
 
-%!assert (undo_string_escapes ("\a\b\f\n\r\t\v"), '\a\b\f\n\r\t\v');
-%!assert (undo_string_escapes ("\a\b\f\n\r\t\v"), "\\a\\b\\f\\n\\r\\t\\v");
-%!assert (undo_string_escapes (char ([7, 8, 12, 10, 13, 9, 11])),
-%!        "\\a\\b\\f\\n\\r\\t\\v");
+%!error undo_string_escapes ()
+%!error undo_string_escapes ("foo", "bar")
 */
 
 DEFUN (is_absolute_filename, args, ,
@@ -828,10 +828,10 @@
 }
 
 /*
-%!error is_absolute_filename ();
-%!error is_absolute_filename ("foo", "bar");
+## FIXME: We need system-dependent tests here.
 
-FIXME -- we need system-dependent tests here.
+%!error is_absolute_filename ()
+%!error is_absolute_filename ("foo", "bar")
 */
 
 DEFUN (is_rooted_relative_filename, args, ,
@@ -853,17 +853,18 @@
 }
 
 /*
-%!error is_rooted_relative_filename ();
-%!error is_rooted_relative_filename ("foo", "bar");
+## FIXME: We need system-dependent tests here.
 
-FIXME -- we need system-dependent tests here.
+%!error is_rooted_relative_filename ()
+%!error is_rooted_relative_filename ("foo", "bar")
 */
 
 DEFUN (make_absolute_filename, args, ,
   "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} make_absolute_filename (@var{file})\n\
-Return the full name of @var{file}, relative to the current directory.\n\
-@seealso{is_absolute_filename, is_rooted_relative_filename, isdir}\n\
+Return the full name of @var{file} beginning from the root of the file\n\
+system.  No check is done for the existence of @var{file}.\n\
+@seealso{canonicalize_file_name, is_absolute_filename, is_rooted_relative_filename, isdir}\n\
 @end deftypefn")
 {
   octave_value retval = std::string ();
@@ -884,10 +885,10 @@
 }
 
 /*
-%!error make_absolute_filename ();
-%!error make_absolute_filename ("foo", "bar");
+## FIXME: We need system-dependent tests here.
 
-FIXME -- we need system-dependent tests here.
+%!error make_absolute_filename ()
+%!error make_absolute_filename ("foo", "bar")
 */
 
 DEFUN (find_dir_in_path, args, ,
@@ -931,10 +932,10 @@
 }
 
 /*
-%!error find_dir_in_path ();
-%!error find_dir_in_path ("foo", "bar", 1);
+## FIXME: We need system-dependent tests here.
 
-FIXME -- need to create tests using current path, pathsep, and dirsep.
+%!error find_dir_in_path ()
+%!error find_dir_in_path ("foo", "bar", 1)
 */
 
 DEFUNX ("errno", Ferrno, args, ,
@@ -982,9 +983,7 @@
 }
 
 /*
-%!error errno ("foo", 1);
-
-%!assert (isnumeric (errno ()));
+%!assert (isnumeric (errno ()))
 
 %!test
 %! lst = errno_list ();
@@ -994,6 +993,8 @@
 %! errno (oldval);
 %! newval = errno ();
 %! assert (oldval, newval);
+
+%!error errno ("foo", 1)
 */
 
 DEFUN (errno_list, args, ,
@@ -1013,9 +1014,9 @@
 }
 
 /*
-%!error errno_list ("foo");
+%!assert (isstruct (errno_list ()))
 
-%!assert (isstruct (errno_list ()));
+%!error errno_list ("foo")
 */
 
 static void
@@ -1331,11 +1332,11 @@
 }
 
 /*
-%!error isindex ();
+%!assert (isindex ([1, 2, 3]))
+%!assert (isindex (1:3))
+%!assert (isindex ([1, 2, -3]), false)
 
-%!assert (isindex ([1, 2, 3]));
-%!assert (isindex (1:3));
-%!assert (isindex ([1, 2, -3]), false);
+%!error isindex ()
 */
 
 octave_value_list
--- a/src/variables.cc
+++ b/src/variables.cc
@@ -361,7 +361,7 @@
 @group\n\
 global x\n\
 isglobal (\"x\")\n\
-     @result{} 1\n\
+   @result{} 1\n\
 @end group\n\
 @end example\n\
 @seealso{isvarname, exist}\n\
@@ -580,17 +580,17 @@
 
 /*
 %!test
-%!  if (isunix ())
-%!    assert (exist ("/tmp") == 7);
-%!    assert (exist ("/tmp", "file") == 7);
-%!    assert (exist ("/tmp", "dir") == 7);
-%!    assert (exist ("/bin/sh") == 2);
-%!    assert (exist ("/bin/sh", "file") == 2);
-%!    assert (exist ("/bin/sh", "dir") == 0);
-%!    assert (exist ("/dev/null") == 2);
-%!    assert (exist ("/dev/null", "file") == 2);
-%!    assert (exist ("/dev/null", "dir") == 0);
-%!  endif
+%! if (isunix ())
+%!   assert (exist ("/tmp") == 7);
+%!   assert (exist ("/tmp", "file") == 7);
+%!   assert (exist ("/tmp", "dir") == 7);
+%!   assert (exist ("/bin/sh") == 2);
+%!   assert (exist ("/bin/sh", "file") == 2);
+%!   assert (exist ("/bin/sh", "dir") == 0);
+%!   assert (exist ("/dev/null") == 2);
+%!   assert (exist ("/dev/null", "file") == 2);
+%!   assert (exist ("/dev/null", "dir") == 0);
+%! endif
 */
 
 octave_value
@@ -1336,7 +1336,7 @@
     param_names(pos_t) = "Type";
 
     for (size_t i = 0; i < param_string.length (); i++)
-      param_length(i) = param_names(i) . length ();
+      param_length(i) = param_names(i).length ();
 
     // The attribute column needs size 5.
     param_length(pos_a) = 5;
@@ -1519,7 +1519,7 @@
             // Push parameter into list ...
             idx += text.length ();
             param.text=text;
-            param.line.assign (text.length(), ' ');
+            param.line.assign (text.length (), ' ');
             params.push_back (param);
           }
       }
@@ -1798,6 +1798,7 @@
 @table @asis\n\
 @item Attr\n\
 Attributes of the listed variable.  Possible attributes are:\n\
+\n\
 @table @asis\n\
 @item blank\n\
 Variable in local scope\n\
@@ -1975,7 +1976,7 @@
 {
   octave_value_list retval;
 
-  if (args.length() == 1)
+  if (args.length () == 1)
     {
       std::string name = args(0).string_value ();
 
@@ -2011,7 +2012,7 @@
 {
   octave_value retval;
 
-  if (args.length() == 1)
+  if (args.length () == 1)
     {
       std::string name = args(0).string_value ();
 
@@ -2298,6 +2299,7 @@
 clear the function definition.\n\
 \n\
 The following options are available in both long and short form\n\
+\n\
 @table @code\n\
 @item -all, -a\n\
 Clears all local and global user-defined variables and all functions\n\
rename from src/version.h.in
rename to src/version.in.h
--- a/src/zfstream.cc
+++ b/src/zfstream.cc
@@ -52,41 +52,41 @@
 /*****************************************************************************/
 
 // Default constructor
-gzfilebuf::gzfilebuf()
+gzfilebuf::gzfilebuf ()
 : file(0), io_mode(std::ios_base::openmode(0)), own_fd(false),
   buffer(0), buffer_size(BIGBUFSIZE), own_buffer(true)
 {
   // No buffers to start with
-  this->disable_buffer();
+  this->disable_buffer ();
 }
 
 // Destructor
-gzfilebuf::~gzfilebuf()
+gzfilebuf::~gzfilebuf ()
 {
   // Sync output buffer and close only if responsible for file
   // (i.e. attached streams should be left open at this stage)
-  this->sync();
+  this->sync ();
   if (own_fd)
-    this->close();
+    this->close ();
   // Make sure internal buffer is deallocated
-  this->disable_buffer();
+  this->disable_buffer ();
 }
 
 // Set compression level and strategy
 int
-gzfilebuf::setcompression(int comp_level,
-                          int comp_strategy)
+gzfilebuf::setcompression (int comp_level,
+                           int comp_strategy)
 {
-  return gzsetparams(file, comp_level, comp_strategy);
+  return gzsetparams (file, comp_level, comp_strategy);
 }
 
 // Open gzipped file
 gzfilebuf*
-gzfilebuf::open(const char *name,
-                std::ios_base::openmode mode)
+gzfilebuf::open (const char *name,
+                 std::ios_base::openmode mode)
 {
   // Fail if file already open
-  if (this->is_open())
+  if (this->is_open ())
     return 0;
   // Don't support simultaneous read/write access (yet)
   if ((mode & std::ios_base::in) && (mode & std::ios_base::out))
@@ -94,15 +94,15 @@
 
   // Build mode string for gzopen and check it [27.8.1.3.2]
   char char_mode[6] = "\0\0\0\0\0";
-  if (!this->open_mode(mode, char_mode))
+  if (! this->open_mode (mode, char_mode))
     return 0;
 
   // Attempt to open file
-  if ((file = gzopen(name, char_mode)) == 0)
+  if ((file = gzopen (name, char_mode)) == 0)
     return 0;
 
   // On success, allocate internal buffer and set flags
-  this->enable_buffer();
+  this->enable_buffer ();
   io_mode = mode;
   own_fd = true;
   return this;
@@ -110,11 +110,11 @@
 
 // Attach to gzipped file
 gzfilebuf*
-gzfilebuf::attach(int fd,
-                  std::ios_base::openmode mode)
+gzfilebuf::attach (int fd,
+                   std::ios_base::openmode mode)
 {
   // Fail if file already open
-  if (this->is_open())
+  if (this->is_open ())
     return 0;
   // Don't support simultaneous read/write access (yet)
   if ((mode & std::ios_base::in) && (mode & std::ios_base::out))
@@ -122,15 +122,15 @@
 
   // Build mode string for gzdopen and check it [27.8.1.3.2]
   char char_mode[6] = "\0\0\0\0\0";
-  if (!this->open_mode(mode, char_mode))
+  if (! this->open_mode (mode, char_mode))
     return 0;
 
   // Attempt to attach to file
-  if ((file = gzdopen(fd, char_mode)) == 0)
+  if ((file = gzdopen (fd, char_mode)) == 0)
     return 0;
 
   // On success, allocate internal buffer and set flags
-  this->enable_buffer();
+  this->enable_buffer ();
   io_mode = mode;
   own_fd = false;
   return this;
@@ -138,23 +138,23 @@
 
 // Close gzipped file
 gzfilebuf*
-gzfilebuf::close()
+gzfilebuf::close ()
 {
   // Fail immediately if no file is open
-  if (!this->is_open())
+  if (! this->is_open ())
     return 0;
   // Assume success
   gzfilebuf* retval = this;
   // Attempt to sync and close gzipped file
-  if (this->sync() == -1)
+  if (this->sync () == -1)
     retval = 0;
-  if (gzclose(file) < 0)
+  if (gzclose (file) < 0)
     retval = 0;
   // File is now gone anyway (postcondition [27.8.1.3.8])
   file = 0;
   own_fd = false;
   // Destroy internal buffer if it exists
-  this->disable_buffer();
+  this->disable_buffer ();
   return retval;
 }
 
@@ -162,8 +162,8 @@
 
 // Convert int open mode to mode string
 bool
-gzfilebuf::open_mode(std::ios_base::openmode mode,
-                     char* c_mode) const
+gzfilebuf::open_mode (std::ios_base::openmode mode,
+                      char* c_mode) const
 {
   // FIXME -- do we need testb?
   // bool testb = mode & std::ios_base::binary;
@@ -178,13 +178,13 @@
   // excessive though - keeping it at the default level
   // To change back, just append "9" to the next three mode strings
   if (!testi && testo && !testt && !testa)
-    strcpy(c_mode, "w");
+    strcpy (c_mode, "w");
   if (!testi && testo && !testt && testa)
-    strcpy(c_mode, "a");
+    strcpy (c_mode, "a");
   if (!testi && testo && testt && !testa)
-    strcpy(c_mode, "w");
+    strcpy (c_mode, "w");
   if (testi && !testo && !testt && !testa)
-    strcpy(c_mode, "r");
+    strcpy (c_mode, "r");
   // No read/write mode yet
 //  if (testi && testo && !testt && !testa)
 //    strcpy(c_mode, "r+");
@@ -192,24 +192,24 @@
 //    strcpy(c_mode, "w+");
 
   // Mode string should be empty for invalid combination of flags
-  if (strlen(c_mode) == 0)
+  if (strlen (c_mode) == 0)
     return false;
 
-  strcat(c_mode, "b");
+  strcat (c_mode, "b");
 
   return true;
 }
 
 // Determine number of characters in internal get buffer
 std::streamsize
-gzfilebuf::showmanyc()
+gzfilebuf::showmanyc ()
 {
   // Calls to underflow will fail if file not opened for reading
-  if (!this->is_open() || !(io_mode & std::ios_base::in))
+  if (! this->is_open () || !(io_mode & std::ios_base::in))
     return -1;
   // Make sure get area is in use
-  if (this->gptr() && (this->gptr() < this->egptr()))
-    return std::streamsize(this->egptr() - this->gptr());
+  if (this->gptr () && (this->gptr () < this->egptr ()))
+    return std::streamsize (this->egptr () - this->gptr ());
   else
     return 0;
 }
@@ -221,142 +221,142 @@
 gzfilebuf::int_type
 gzfilebuf::pbackfail (gzfilebuf::int_type c)
 {
-  if (this->is_open())
+  if (this->is_open ())
     {
-      if (gzseek (file, this->gptr() - this->egptr() - 1, SEEK_CUR) < 0)
-        return traits_type::eof();
+      if (gzseek (file, this->gptr () - this->egptr () - 1, SEEK_CUR) < 0)
+        return traits_type::eof ();
 
       // Invalidates contents of the buffer
       enable_buffer ();
 
       // Attempt to fill internal buffer from gzipped file
       // (buffer must be guaranteed to exist...)
-      int bytes_read = gzread(file, buffer, buffer_size);
+      int bytes_read = gzread (file, buffer, buffer_size);
       // Indicates error or EOF
       if (bytes_read <= 0)
         {
           // Reset get area
-          this->setg(buffer, buffer, buffer);
-          return traits_type::eof();
+          this->setg (buffer, buffer, buffer);
+          return traits_type::eof ();
         }
 
       // Make all bytes read from file available as get area
-      this->setg(buffer, buffer, buffer + bytes_read);
+      this->setg (buffer, buffer, buffer + bytes_read);
 
       // If next character in get area differs from putback character
       // flag a failure
-      gzfilebuf::int_type ret = traits_type::to_int_type(*(this->gptr()));
+      gzfilebuf::int_type ret = traits_type::to_int_type (*(this->gptr ()));
       if (ret != c)
-        return traits_type::eof();
+        return traits_type::eof ();
       else
         return ret;
     }
   else
-    return traits_type::eof();
+    return traits_type::eof ();
 }
 
 // Fill get area from gzipped file
 gzfilebuf::int_type
-gzfilebuf::underflow()
+gzfilebuf::underflow ()
 {
   // If something is left in the get area by chance, return it
   // (this shouldn't normally happen, as underflow is only supposed
   // to be called when gptr >= egptr, but it serves as error check)
-  if (this->gptr() && (this->gptr() < this->egptr()))
-    return traits_type::to_int_type(*(this->gptr()));
+  if (this->gptr () && (this->gptr () < this->egptr ()))
+    return traits_type::to_int_type (*(this->gptr ()));
 
   // If the file hasn't been opened for reading, produce error
-  if (!this->is_open() || !(io_mode & std::ios_base::in))
-    return traits_type::eof();
+  if (! this->is_open () || !(io_mode & std::ios_base::in))
+    return traits_type::eof ();
 
   // Copy the final characters to the front of the buffer
   int stash = 0;
-  if (this->eback() && buffer && buffer_size > STASHED_CHARACTERS)
+  if (this->eback () && buffer && buffer_size > STASHED_CHARACTERS)
     {
       char_type *ptr1 = buffer;
-      char_type *ptr2 = this->egptr() - STASHED_CHARACTERS + 1;
-      if (ptr2 > this->eback())
+      char_type *ptr2 = this->egptr () - STASHED_CHARACTERS + 1;
+      if (ptr2 > this->eback ())
         while (stash++ <= STASHED_CHARACTERS)
           *ptr1++ = *ptr2++;
     }
 
   // Attempt to fill internal buffer from gzipped file
   // (buffer must be guaranteed to exist...)
-  int bytes_read = gzread(file, buffer + stash, buffer_size - stash);
+  int bytes_read = gzread (file, buffer + stash, buffer_size - stash);
 
   // Indicates error or EOF
   if (bytes_read <= 0)
   {
     // Reset get area
-    this->setg(buffer, buffer, buffer);
-    return traits_type::eof();
+    this->setg (buffer, buffer, buffer);
+    return traits_type::eof ();
   }
   // Make all bytes read from file plus the stash available as get area
-  this->setg(buffer, buffer + stash, buffer + bytes_read + stash);
+  this->setg (buffer, buffer + stash, buffer + bytes_read + stash);
 
   // Return next character in get area
-  return traits_type::to_int_type(*(this->gptr()));
+  return traits_type::to_int_type (*(this->gptr ()));
 }
 
 // Write put area to gzipped file
 gzfilebuf::int_type
-gzfilebuf::overflow(int_type c)
+gzfilebuf::overflow (int_type c)
 {
   // Determine whether put area is in use
-  if (this->pbase())
+  if (this->pbase ())
   {
     // Double-check pointer range
-    if (this->pptr() > this->epptr() || this->pptr() < this->pbase())
-      return traits_type::eof();
+    if (this->pptr () > this->epptr () || this->pptr () < this->pbase ())
+      return traits_type::eof ();
     // Add extra character to buffer if not EOF
-    if (!traits_type::eq_int_type(c, traits_type::eof()))
+    if (! traits_type::eq_int_type (c, traits_type::eof ()))
     {
-      *(this->pptr()) = traits_type::to_char_type(c);
-      this->pbump(1);
+      *(this->pptr ()) = traits_type::to_char_type (c);
+      this->pbump (1);
     }
     // Number of characters to write to file
-    int bytes_to_write = this->pptr() - this->pbase();
+    int bytes_to_write = this->pptr () - this->pbase ();
     // Overflow doesn't fail if nothing is to be written
     if (bytes_to_write > 0)
     {
       // If the file hasn't been opened for writing, produce error
-      if (!this->is_open() || !(io_mode & std::ios_base::out))
-        return traits_type::eof();
+      if (! this->is_open () || !(io_mode & std::ios_base::out))
+        return traits_type::eof ();
       // If gzipped file won't accept all bytes written to it, fail
-      if (gzwrite(file, this->pbase(), bytes_to_write) != bytes_to_write)
-        return traits_type::eof();
+      if (gzwrite (file, this->pbase (), bytes_to_write) != bytes_to_write)
+        return traits_type::eof ();
       // Reset next pointer to point to pbase on success
-      this->pbump(-bytes_to_write);
+      this->pbump (-bytes_to_write);
     }
   }
   // Write extra character to file if not EOF
-  else if (!traits_type::eq_int_type(c, traits_type::eof()))
+  else if (! traits_type::eq_int_type (c, traits_type::eof ()))
   {
     // If the file hasn't been opened for writing, produce error
-    if (!this->is_open() || !(io_mode & std::ios_base::out))
-      return traits_type::eof();
+    if (! this->is_open () || !(io_mode & std::ios_base::out))
+      return traits_type::eof ();
     // Impromptu char buffer (allows "unbuffered" output)
-    char_type last_char = traits_type::to_char_type(c);
+    char_type last_char = traits_type::to_char_type (c);
     // If gzipped file won't accept this character, fail
-    if (gzwrite(file, &last_char, 1) != 1)
-      return traits_type::eof();
+    if (gzwrite (file, &last_char, 1) != 1)
+      return traits_type::eof ();
   }
 
   // If you got here, you have succeeded (even if c was EOF)
   // The return value should therefore be non-EOF
-  if (traits_type::eq_int_type(c, traits_type::eof()))
-    return traits_type::not_eof(c);
+  if (traits_type::eq_int_type (c, traits_type::eof ()))
+    return traits_type::not_eof (c);
   else
     return c;
 }
 
 // Assign new buffer
 std::streambuf*
-gzfilebuf::setbuf(char_type* p,
-                  std::streamsize n)
+gzfilebuf::setbuf (char_type* p,
+                   std::streamsize n)
 {
   // First make sure stuff is sync'ed, for safety
-  if (this->sync() == -1)
+  if (this->sync () == -1)
     return 0;
   // If buffering is turned off on purpose via setbuf(0,0), still allocate one...
   // "Unbuffered" only really refers to put [27.8.1.4.10], while get needs at
@@ -365,36 +365,36 @@
   if (!p || !n)
   {
     // Replace existing buffer (if any) with small internal buffer
-    this->disable_buffer();
+    this->disable_buffer ();
     buffer = 0;
     buffer_size = 0;
     own_buffer = true;
-    this->enable_buffer();
+    this->enable_buffer ();
   }
   else
   {
     // Replace existing buffer (if any) with external buffer
-    this->disable_buffer();
+    this->disable_buffer ();
     buffer = p;
     buffer_size = n;
     own_buffer = false;
-    this->enable_buffer();
+    this->enable_buffer ();
   }
   return this;
 }
 
 // Write put area to gzipped file (i.e. ensures that put area is empty)
 int
-gzfilebuf::sync()
+gzfilebuf::sync ()
 {
-  return traits_type::eq_int_type(this->overflow(), traits_type::eof()) ? -1 : 0;
+  return traits_type::eq_int_type (this->overflow (), traits_type::eof ()) ? -1 : 0;
 }
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
 // Allocate internal buffer
 void
-gzfilebuf::enable_buffer()
+gzfilebuf::enable_buffer ()
 {
   // If internal buffer required, allocate one
   if (own_buffer && !buffer)
@@ -405,55 +405,55 @@
       // Allocate internal buffer
       buffer = new char_type[buffer_size];
       // Get area starts empty and will be expanded by underflow as need arises
-      this->setg(buffer, buffer, buffer);
+      this->setg (buffer, buffer, buffer);
       // Setup entire internal buffer as put area.
       // The one-past-end pointer actually points to the last element of the buffer,
       // so that overflow(c) can safely add the extra character c to the sequence.
       // These pointers remain in place for the duration of the buffer
-      this->setp(buffer, buffer + buffer_size - 1);
+      this->setp (buffer, buffer + buffer_size - 1);
     }
     else
     {
       // Even in "unbuffered" case, (small?) get buffer is still required
       buffer_size = SMALLBUFSIZE;
       buffer = new char_type[buffer_size];
-      this->setg(buffer, buffer, buffer);
+      this->setg (buffer, buffer, buffer);
       // "Unbuffered" means no put buffer
-      this->setp(0, 0);
+      this->setp (0, 0);
     }
   }
   else
   {
     // If buffer already allocated, reset buffer pointers just to make sure no
     // stale chars are lying around
-    this->setg(buffer, buffer, buffer);
-    this->setp(buffer, buffer + buffer_size - 1);
+    this->setg (buffer, buffer, buffer);
+    this->setp (buffer, buffer + buffer_size - 1);
   }
 }
 
 // Destroy internal buffer
 void
-gzfilebuf::disable_buffer()
+gzfilebuf::disable_buffer ()
 {
   // If internal buffer exists, deallocate it
   if (own_buffer && buffer)
   {
     // Preserve unbuffered status by zeroing size
-    if (!this->pbase())
+    if (! this->pbase ())
       buffer_size = 0;
     delete[] buffer;
     buffer = 0;
-    this->setg(0, 0, 0);
-    this->setp(0, 0);
+    this->setg (0, 0, 0);
+    this->setp (0, 0);
   }
   else
   {
     // Reset buffer pointers to initial state if external buffer exists
-    this->setg(buffer, buffer, buffer);
+    this->setg (buffer, buffer, buffer);
     if (buffer)
-      this->setp(buffer, buffer + buffer_size - 1);
+      this->setp (buffer, buffer + buffer_size - 1);
     else
-      this->setp(0, 0);
+      this->setp (0, 0);
   }
 }
 
@@ -461,17 +461,17 @@
 
 // Seek functions
 gzfilebuf::pos_type
-gzfilebuf::seekoff(off_type off, std::ios_base::seekdir way,
+gzfilebuf::seekoff (off_type off, std::ios_base::seekdir way,
                    std::ios_base::openmode)
 {
   pos_type ret = pos_type (off_type (-1));
 
-  if (this->is_open())
+  if (this->is_open ())
     {
       off_type computed_off = off;
 
       if ((io_mode & std::ios_base::in) && way == std::ios_base::cur)
-        computed_off += this->gptr() - this->egptr();
+        computed_off += this->gptr () - this->egptr ();
 
       if (way == std::ios_base::beg)
         ret = pos_type (gzseek (file, computed_off, SEEK_SET));
@@ -493,7 +493,7 @@
 }
 
 gzfilebuf::pos_type
-gzfilebuf::seekpos(pos_type sp, std::ios_base::openmode)
+gzfilebuf::seekpos (pos_type sp, std::ios_base::openmode)
 {
   pos_type ret = pos_type (off_type (-1));
 
@@ -515,111 +515,111 @@
 /*****************************************************************************/
 
 // Default constructor initializes stream buffer
-gzifstream::gzifstream()
-: std::istream(0), sb()
-{ this->init(&sb); }
+gzifstream::gzifstream ()
+: std::istream (0), sb ()
+{ this->init (&sb); }
 
 // Initialize stream buffer and open file
-gzifstream::gzifstream(const char* name,
-                       std::ios_base::openmode mode)
-: std::istream(0), sb()
+gzifstream::gzifstream (const char* name,
+                        std::ios_base::openmode mode)
+: std::istream (0), sb ()
 {
-  this->init(&sb);
-  this->open(name, mode);
+  this->init (&sb);
+  this->open (name, mode);
 }
 
 // Initialize stream buffer and attach to file
-gzifstream::gzifstream(int fd,
-                       std::ios_base::openmode mode)
-: std::istream(0), sb()
+gzifstream::gzifstream (int fd,
+                        std::ios_base::openmode mode)
+: std::istream (0), sb ()
 {
-  this->init(&sb);
-  this->attach(fd, mode);
+  this->init (&sb);
+  this->attach (fd, mode);
 }
 
 // Open file and go into fail() state if unsuccessful
 void
-gzifstream::open(const char* name,
-                 std::ios_base::openmode mode)
+gzifstream::open (const char* name,
+                  std::ios_base::openmode mode)
 {
-  if (!sb.open(name, mode | std::ios_base::in))
-    this->setstate(std::ios_base::failbit);
+  if (! sb.open (name, mode | std::ios_base::in))
+    this->setstate (std::ios_base::failbit);
   else
-    this->clear();
+    this->clear ();
 }
 
 // Attach to file and go into fail() state if unsuccessful
 void
-gzifstream::attach(int fd,
-                   std::ios_base::openmode mode)
+gzifstream::attach (int fd,
+                    std::ios_base::openmode mode)
 {
-  if (!sb.attach(fd, mode | std::ios_base::in))
-    this->setstate(std::ios_base::failbit);
+  if (! sb.attach (fd, mode | std::ios_base::in))
+    this->setstate (std::ios_base::failbit);
   else
-    this->clear();
+    this->clear ();
 }
 
 // Close file
 void
-gzifstream::close()
+gzifstream::close ()
 {
-  if (!sb.close())
-    this->setstate(std::ios_base::failbit);
+  if (! sb.close ())
+    this->setstate (std::ios_base::failbit);
 }
 
 /*****************************************************************************/
 
 // Default constructor initializes stream buffer
-gzofstream::gzofstream()
-: std::ostream(0), sb()
-{ this->init(&sb); }
+gzofstream::gzofstream ()
+: std::ostream (0), sb ()
+{ this->init (&sb); }
 
 // Initialize stream buffer and open file
-gzofstream::gzofstream(const char* name,
-                       std::ios_base::openmode mode)
-: std::ostream(0), sb()
+gzofstream::gzofstream (const char* name,
+                        std::ios_base::openmode mode)
+: std::ostream (0), sb ()
 {
-  this->init(&sb);
-  this->open(name, mode);
+  this->init (&sb);
+  this->open (name, mode);
 }
 
 // Initialize stream buffer and attach to file
-gzofstream::gzofstream(int fd,
-                       std::ios_base::openmode mode)
-: std::ostream(0), sb()
+gzofstream::gzofstream (int fd,
+                        std::ios_base::openmode mode)
+: std::ostream (0), sb ()
 {
-  this->init(&sb);
-  this->attach(fd, mode);
+  this->init (&sb);
+  this->attach (fd, mode);
 }
 
 // Open file and go into fail() state if unsuccessful
 void
-gzofstream::open(const char* name,
-                 std::ios_base::openmode mode)
+gzofstream::open (const char* name,
+                  std::ios_base::openmode mode)
 {
-  if (!sb.open(name, mode | std::ios_base::out))
-    this->setstate(std::ios_base::failbit);
+  if (! sb.open (name, mode | std::ios_base::out))
+    this->setstate (std::ios_base::failbit);
   else
-    this->clear();
+    this->clear ();
 }
 
 // Attach to file and go into fail() state if unsuccessful
 void
-gzofstream::attach(int fd,
-                   std::ios_base::openmode mode)
+gzofstream::attach (int fd,
+                    std::ios_base::openmode mode)
 {
-  if (!sb.attach(fd, mode | std::ios_base::out))
-    this->setstate(std::ios_base::failbit);
+  if (! sb.attach (fd, mode | std::ios_base::out))
+    this->setstate (std::ios_base::failbit);
   else
-    this->clear();
+    this->clear ();
 }
 
 // Close file
 void
-gzofstream::close()
+gzofstream::close ()
 {
-  if (!sb.close())
-    this->setstate(std::ios_base::failbit);
+  if (! sb.close ())
+    this->setstate (std::ios_base::failbit);
 }
 
 #endif // HAVE_ZLIB
--- a/src/zfstream.h
+++ b/src/zfstream.h
@@ -53,11 +53,11 @@
 {
 public:
   //  Default constructor.
-  gzfilebuf();
+  gzfilebuf ();
 
   //  Destructor.
   virtual
-  ~gzfilebuf();
+  ~gzfilebuf ();
 
   /**
    *  @brief  Set compression level and strategy on the fly.
@@ -71,15 +71,15 @@
    *  setcompressionlevel(level).
   */
   int
-  setcompression(int comp_level,
-                 int comp_strategy = Z_DEFAULT_STRATEGY);
+  setcompression (int comp_level,
+                  int comp_strategy = Z_DEFAULT_STRATEGY);
 
   /**
    *  @brief  Check if file is open.
    *  @return  True if file is open.
   */
   bool
-  is_open() const { return (file != 0); }
+  is_open () const { return (file != 0); }
 
   /**
    *  @brief  Open gzipped file.
@@ -88,8 +88,8 @@
    *  @return  @c this on success, NULL on failure.
   */
   gzfilebuf*
-  open(const char* name,
-       std::ios_base::openmode mode);
+  open (const char* name,
+        std::ios_base::openmode mode);
 
   /**
    *  @brief  Attach to already open gzipped file.
@@ -98,15 +98,15 @@
    *  @return  @c this on success, NULL on failure.
   */
   gzfilebuf*
-  attach(int fd,
-         std::ios_base::openmode mode);
+  attach (int fd,
+          std::ios_base::openmode mode);
 
   /**
    *  @brief  Close gzipped file.
    *  @return  @c this on success, NULL on failure.
   */
   gzfilebuf*
-  close();
+  close ();
 
 protected:
   /**
@@ -114,8 +114,8 @@
    *  @return  True if valid mode flag combination.
   */
   bool
-  open_mode(std::ios_base::openmode mode,
-            char* c_mode) const;
+  open_mode (std::ios_base::openmode mode,
+             char* c_mode) const;
 
   /**
    *  @brief  Number of characters available in stream buffer.
@@ -125,7 +125,7 @@
    *  These characters can be read without accessing the gzipped file.
   */
   virtual std::streamsize
-  showmanyc();
+  showmanyc ();
 
   /**
    *  @brief  Fill get area from gzipped file.
@@ -135,7 +135,7 @@
    *  buffer. Always buffered.
   */
   virtual int_type
-  underflow();
+  underflow ();
 
   /**
    *  @brief  Write put area to gzipped file.
@@ -147,7 +147,7 @@
    *  character at a time.
   */
   virtual int_type
-  overflow(int_type c = traits_type::eof());
+  overflow (int_type c = traits_type::eof ());
 
   /**
    *  @brief  Installs external stream buffer.
@@ -158,8 +158,8 @@
    *  Call setbuf(0,0) to enable unbuffered output.
   */
   virtual std::streambuf*
-  setbuf(char_type* p,
-         std::streamsize n);
+  setbuf (char_type* p,
+          std::streamsize n);
 
   /**
    *  @brief  Flush stream buffer to file.
@@ -168,7 +168,7 @@
    *  This calls underflow(EOF) to do the job.
   */
   virtual int
-  sync();
+  sync ();
 
   /**
    *  @brief  Alters the stream positions.
@@ -176,9 +176,9 @@
    *  Each derived class provides its own appropriate behavior.
    */
   virtual pos_type
-  seekoff(off_type off, std::ios_base::seekdir way,
-          std::ios_base::openmode mode =
-          std::ios_base::in|std::ios_base::out);
+  seekoff (off_type off, std::ios_base::seekdir way,
+           std::ios_base::openmode mode =
+           std::ios_base::in|std::ios_base::out);
 
   /**
    *  @brief  Alters the stream positions.
@@ -186,11 +186,11 @@
    *  Each derived class provides its own appropriate behavior.
    */
   virtual pos_type
-  seekpos(pos_type sp, std::ios_base::openmode mode =
-          std::ios_base::in|std::ios_base::out);
+  seekpos (pos_type sp, std::ios_base::openmode mode =
+           std::ios_base::in|std::ios_base::out);
 
   virtual int_type
-  pbackfail (int_type c = traits_type::eof());
+  pbackfail (int_type c = traits_type::eof ());
 
 //
 // Some future enhancements
@@ -215,7 +215,7 @@
    *  reset to their original state.
   */
   void
-  enable_buffer();
+  enable_buffer ();
 
   /**
    *  @brief  Destroy internal buffer.
@@ -225,7 +225,7 @@
    *  case, it will also reset the buffer pointers.
   */
   void
-  disable_buffer();
+  disable_buffer ();
 
   /**
    *  Underlying file pointer.
@@ -282,7 +282,7 @@
 {
 public:
   //  Default constructor
-  gzifstream();
+  gzifstream ();
 
   /**
    *  @brief  Construct stream on gzipped file to be opened.
@@ -290,8 +290,8 @@
    *  @param  mode  Open mode flags (forced to contain ios::in).
   */
   explicit
-  gzifstream(const char* name,
-             std::ios_base::openmode mode = std::ios_base::in);
+  gzifstream (const char* name,
+              std::ios_base::openmode mode = std::ios_base::in);
 
   /**
    *  @brief  Construct stream on already open gzipped file.
@@ -299,14 +299,14 @@
    *  @param  mode  Open mode flags (forced to contain ios::in).
   */
   explicit
-  gzifstream(int fd,
-             std::ios_base::openmode mode = std::ios_base::in);
+  gzifstream (int fd,
+              std::ios_base::openmode mode = std::ios_base::in);
 
   /**
    *  Obtain underlying stream buffer.
   */
   gzfilebuf*
-  rdbuf() const
+  rdbuf () const
   { return const_cast<gzfilebuf*>(&sb); }
 
   /**
@@ -314,7 +314,7 @@
    *  @return  True if file is open.
   */
   bool
-  is_open() { return sb.is_open(); }
+  is_open () { return sb.is_open (); }
 
   /**
    *  @brief  Open gzipped file.
@@ -329,8 +329,8 @@
    *  convenience.
   */
   void
-  open(const char* name,
-       std::ios_base::openmode mode = std::ios_base::in);
+  open (const char* name,
+        std::ios_base::openmode mode = std::ios_base::in);
 
   /**
    *  @brief  Attach to already open gzipped file.
@@ -341,8 +341,8 @@
    *  in state fail().
   */
   void
-  attach(int fd,
-         std::ios_base::openmode mode = std::ios_base::in);
+  attach (int fd,
+          std::ios_base::openmode mode = std::ios_base::in);
 
   /**
    *  @brief  Close gzipped file.
@@ -350,7 +350,7 @@
    *  Stream will be in state fail() if close failed.
   */
   void
-  close();
+  close ();
 
 private:
   /**
@@ -371,7 +371,7 @@
 {
 public:
   //  Default constructor
-  gzofstream();
+  gzofstream ();
 
   /**
    *  @brief  Construct stream on gzipped file to be opened.
@@ -379,8 +379,8 @@
    *  @param  mode  Open mode flags (forced to contain ios::out).
   */
   explicit
-  gzofstream(const char* name,
-             std::ios_base::openmode mode = std::ios_base::out);
+  gzofstream (const char* name,
+              std::ios_base::openmode mode = std::ios_base::out);
 
   /**
    *  @brief  Construct stream on already open gzipped file.
@@ -388,14 +388,14 @@
    *  @param  mode  Open mode flags (forced to contain ios::out).
   */
   explicit
-  gzofstream(int fd,
-             std::ios_base::openmode mode = std::ios_base::out);
+  gzofstream (int fd,
+              std::ios_base::openmode mode = std::ios_base::out);
 
   /**
    *  Obtain underlying stream buffer.
   */
   gzfilebuf*
-  rdbuf() const
+  rdbuf () const
   { return const_cast<gzfilebuf*>(&sb); }
 
   /**
@@ -403,7 +403,7 @@
    *  @return  True if file is open.
   */
   bool
-  is_open() { return sb.is_open(); }
+  is_open () { return sb.is_open (); }
 
   /**
    *  @brief  Open gzipped file.
@@ -418,8 +418,8 @@
    *  convenience.
   */
   void
-  open(const char* name,
-       std::ios_base::openmode mode = std::ios_base::out);
+  open (const char* name,
+        std::ios_base::openmode mode = std::ios_base::out);
 
   /**
    *  @brief  Attach to already open gzipped file.
@@ -430,8 +430,8 @@
    *  in state fail().
   */
   void
-  attach(int fd,
-         std::ios_base::openmode mode = std::ios_base::out);
+  attach (int fd,
+          std::ios_base::openmode mode = std::ios_base::out);
 
   /**
    *  @brief  Close gzipped file.
@@ -439,7 +439,7 @@
    *  Stream will be in state fail() if close failed.
   */
   void
-  close();
+  close ();
 
 private:
   /**
@@ -467,9 +467,9 @@
                  const gzomanip2<Ta,Tb>&);
 
     // Constructor
-    gzomanip2(gzofstream& (*f)(gzofstream&, T1, T2),
-              T1 v1,
-              T2 v2);
+    gzomanip2 (gzofstream& (*f)(gzofstream&, T1, T2),
+               T1 v1,
+               T2 v2);
   private:
     // Underlying manipulator function
     gzofstream&
@@ -484,18 +484,18 @@
 
 // Manipulator function thunks through to stream buffer
 inline gzofstream&
-setcompression(gzofstream &gzs, int l, int s = Z_DEFAULT_STRATEGY)
+setcompression (gzofstream &gzs, int l, int s = Z_DEFAULT_STRATEGY)
 {
-  (gzs.rdbuf())->setcompression(l, s);
+  (gzs.rdbuf ())->setcompression (l, s);
   return gzs;
 }
 
 // Manipulator constructor stores arguments
 template<typename T1, typename T2>
   inline
-  gzomanip2<T1,T2>::gzomanip2(gzofstream &(*f)(gzofstream &, T1, T2),
-                              T1 v1,
-                              T2 v2)
+  gzomanip2<T1,T2>::gzomanip2 (gzofstream &(*f)(gzofstream &, T1, T2),
+                               T1 v1,
+                               T2 v2)
   : func(f), val1(v1), val2(v2)
   { }
 
@@ -507,7 +507,7 @@
 
 // Insert this onto stream to simplify setting of compression level
 inline gzomanip2<int,int>
-setcompression(int l, int s = Z_DEFAULT_STRATEGY)
+setcompression (int l, int s = Z_DEFAULT_STRATEGY)
 { return gzomanip2<int,int>(&setcompression, l, s); }
 
 #endif // HAVE_ZLIB
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -23,6 +23,7 @@
 FCN_FILES = \
   fntests.m \
   test_args.m \
+  test_bug_31371.m \
   test_diag_perm.m \
   test_error.m \
   test_eval-catch.m \
@@ -49,10 +50,13 @@
   test_unwind.m \
   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)
new file mode 100644
--- /dev/null
+++ b/test/bug-35448/fA.m
@@ -0,0 +1,10 @@
+# fA.m
+function y = fA (x, f)
+  global gfun
+  if nargin < 2
+    y = fA (x, gfun);
+  else
+    w = feval (f, x);
+    y = feval (@fB, w);
+  endif
+endfunction
new file mode 100644
--- /dev/null
+++ b/test/bug-35448/fB.m
@@ -0,0 +1,4 @@
+# fB.m
+function y = fB (x)
+  y = x;
+endfunction
new file mode 100644
--- /dev/null
+++ b/test/bug-35448/fC.m
@@ -0,0 +1,4 @@
+# fC.m
+function y = fC (x)
+  y = x;
+endfunction
new file mode 100644
--- /dev/null
+++ b/test/bug-35448/module.mk
@@ -0,0 +1,7 @@
+bug_35448_FCN_FILES = \
+  bug-35448/fA.m \
+  bug-35448/fB.m \
+  bug-35448/fC.m \
+  bug-35448/test_bug_35448.m
+
+FCN_FILES += $(bug_35448_FCN_FILES)
new file mode 100644
--- /dev/null
+++ b/test/bug-35448/test_bug_35448.m
@@ -0,0 +1,11 @@
+%!test
+%! global gfun
+%! gfun = @fB;
+%! y = fA (e);
+%! assert (y, e);
+
+%!test
+%! global gfun
+%! gfun = @fC;
+%! y = fA (e);
+%! assert (y, e);
new file mode 100644
--- /dev/null
+++ b/test/bug-36025/@testclass/one.m
@@ -0,0 +1,4 @@
+% function ONE return item "X"
+
+function a=one(m)
+  a=m.x;
new file mode 100644
--- /dev/null
+++ b/test/bug-36025/@testclass/testclass.m
@@ -0,0 +1,3 @@
+function m=testclass(x,y)
+m=struct('x',x,'y',y); 
+m=class(m,"testclass"); 
new file mode 100644
--- /dev/null
+++ b/test/bug-36025/@testclass/two.m
@@ -0,0 +1,4 @@
+% function TWO returns item "Y"
+
+function a=one(m)
+  a=m.y;
new file mode 100644
--- /dev/null
+++ b/test/bug-36025/module.mk
@@ -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)
new file mode 100644
--- /dev/null
+++ b/test/bug-36025/test_bug_36025.m
@@ -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);
--- a/test/classes/@Dork/Dork.m
+++ b/test/classes/@Dork/Dork.m
@@ -5,7 +5,7 @@
   else
     s.gack = 0;
     if nargin == 0
-      s0 = Snork();
+      s0 = Snork ();
     elseif nargin==1
       s0 = Snork(gick);
     else
--- a/test/classes/@Dork/getStash.m
+++ b/test/classes/@Dork/getStash.m
@@ -1,5 +1,5 @@
 function [ out ] = getStash(cls)
 
-  out = myStash();
+  out = myStash ();
         
 end
--- a/test/classes/@Dork/private/myStash.m
+++ b/test/classes/@Dork/private/myStash.m
@@ -1,4 +1,4 @@
-function [ out ] = myStash()
+function [ out ] = myStash ()
 
   out = 2;
 
--- a/test/classes/@Gork/Gork.m
+++ b/test/classes/@Gork/Gork.m
@@ -4,9 +4,9 @@
     return;
   end
 
-  drk  = Dork();
-  prk  = Pork();
-  blrk = Blork();
+  drk  = Dork ();
+  prk  = Pork ();
+  blrk = Blork ();
   s.Cork = Cork(17);  % Aggregation.
   s.gark = -2;
   s.gyrk = -3;
--- a/test/classes/@Pork/Pork.m
+++ b/test/classes/@Pork/Pork.m
@@ -5,7 +5,7 @@
   else
     s.gurk = 0;
     if nargin == 0
-      s0 = Spork();
+      s0 = Spork ();
     elseif nargin==1
       s0 = Spork(geek);
     else
--- a/test/classes/@Pork/private/myStash.m
+++ b/test/classes/@Pork/private/myStash.m
@@ -1,4 +1,4 @@
-function [ out ] = myStash()
+function [ out ] = myStash ()
 
   out = 4;
 
--- a/test/classes/@Snork/getStash.m
+++ b/test/classes/@Snork/getStash.m
@@ -1,5 +1,5 @@
 function [ out ] = getStash(cls)
 
-  out = myStash();
+  out = myStash ();
         
 end
--- a/test/classes/@Snork/private/myStash.m
+++ b/test/classes/@Snork/private/myStash.m
@@ -1,4 +1,4 @@
-function [ out ] = myStash()
+function [ out ] = myStash ()
 
   out = 1;
         
--- a/test/classes/@Spork/getStash.m
+++ b/test/classes/@Spork/getStash.m
@@ -1,5 +1,5 @@
 function [ out ] = getStash(cls)
 
-  out = myStash();
+  out = myStash ();
         
 end
--- a/test/classes/@Spork/private/myStash.m
+++ b/test/classes/@Spork/private/myStash.m
@@ -1,4 +1,4 @@
-function [ out ] = myStash()
+function [ out ] = myStash ()
 
   out = 3;
         
--- a/test/fntests.m
+++ b/test/fntests.m
@@ -26,7 +26,7 @@
 currdir = canonicalize_file_name (".");
 
 if (nargin == 1)
-  xdir = argv(){1};
+  xdir = argv (){1};
 else
   xdir = ".";
 endif
@@ -242,7 +242,7 @@
 warning ("on", "quiet");
 try
   page_screen_output (0);
-  warning ("off", "Octave:deprecated-functions");
+  warning ("off", "Octave:deprecated-function");
   fid = fopen ("fntests.log", "wt");
   if (fid < 0)
     error ("could not open fntests.log for writing");
@@ -265,26 +265,30 @@
     dxf += xf;
     dsk += sk;
   endfor
-  printf ("\nSummary:\n\n  PASS %6d\n", dp);
+  puts ("\nSummary:\n\n");
   nfail = dn - dp;
-  printf ("  FAIL %6d\n", nfail);
+  printf ("  PASS    %6d\n", dp);
+  printf ("  FAIL    %6d\n", nfail);
   if (dxf > 0)
-    if (dxf > 1)
-      t1 = "were";
-      t2 = "failures";
-    else
-      t1 = "was";
-      t2 = "failure";
-    endif
-    printf ("\nThere %s %d expected %s (see fntests.log for details).\n",
-            t1, dxf, t2);
-    puts ("\nExpected failures are known bugs.  Please help improve Octave\n");
-    puts ("by contributing fixes for them.\n");
+    printf ("  XFAIL   %6d\n", dxf);
   endif
   if (dsk > 0)
-    printf ("\nThere were %d skipped tests (see fntests.log for details).\n", dsk);
-    puts ("Skipped tests are features that are disabled in this version of Octave\n");
-    puts ("because the needed libraries were not present when Octave was built.\n");
+    printf ("  SKIPPED %6d\n", dsk);
+  endif
+  puts ("\n");
+  puts ("See the file test/fntests.log for additional details.\n");
+  if (dxf > 0)
+    puts ("\n");
+    puts ("Expected failures (listed as XFAIL above) are known bugs.\n");
+    puts ("Please help improve Octave by contributing fixes for them.\n");
+  endif
+  if (dsk > 0)
+    puts ("\n");
+    puts ("Tests are most often skipped because the features they require\n");
+    puts ("have been disabled.  Features are most often disabled because\n");
+    puts ("they require dependencies that were not present when Octave\n");
+    puts ("was built.  The configure script should have printed a summary\n");
+    puts ("at the end of its run indicating which dependencies were not found.\n");
   endif
 
   ## Weed out deprecated and private functions
new file mode 100644
--- /dev/null
+++ b/test/nest/arg_nest.m
@@ -0,0 +1,8 @@
+# arg_nest.m
+function x = arg_nest
+  x = 1;
+  A (x);
+  function A (x)
+    x = 2;
+  endfunction
+endfunction
new file mode 100644
--- /dev/null
+++ b/test/nest/arg_ret.m
@@ -0,0 +1,7 @@
+function a = arg_ret
+  a = 10;
+  f;
+  function a = f
+    a = 5;
+  endfunction
+endfunction
new file mode 100644
--- /dev/null
+++ b/test/nest/module.mk
@@ -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)
+
new file mode 100644
--- /dev/null
+++ b/test/nest/no_closure.m
@@ -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
new file mode 100644
--- /dev/null
+++ b/test/nest/persistent_nest.m
@@ -0,0 +1,10 @@
+# persistent_nest
+function y = persistent_nest ()
+  persistent x = 0;
+  g;
+  y = x;
+
+  function g
+    x = x + 1;
+  end
+end
new file mode 100644
--- /dev/null
+++ b/test/nest/recursive_nest.m
@@ -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
new file mode 100644
--- /dev/null
+++ b/test/nest/recursive_nest2.m
@@ -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
new file mode 100644
--- /dev/null
+++ b/test/nest/recursive_nest3.m
@@ -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
new file mode 100644
--- /dev/null
+++ b/test/nest/scope0.m
@@ -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
new file mode 100644
--- /dev/null
+++ b/test/nest/scope1.m
@@ -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
new file mode 100644
--- /dev/null
+++ b/test/nest/scope2.m
@@ -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
new file mode 100644
--- /dev/null
+++ b/test/nest/scope3.m
@@ -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
new file mode 100644
--- /dev/null
+++ b/test/nest/script_nest.m
@@ -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
new file mode 100644
--- /dev/null
+++ b/test/nest/script_nest_script.m
@@ -0,0 +1,2 @@
+# script_nest_script.m
+x = 5;
new file mode 100644
--- /dev/null
+++ b/test/nest/test_nest.m
@@ -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)
+
new file mode 100644
--- /dev/null
+++ b/test/nest/varg_nest.m
@@ -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
new file mode 100644
--- /dev/null
+++ b/test/nest/varg_nest2.m
@@ -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
new file mode 100644
--- /dev/null
+++ b/test/test_bug_31371.m
@@ -0,0 +1,41 @@
+%!test
+%! % Work around MATLAB bug where f(x)(y) is invalid syntax
+%! % (This bug does not apply to Octave)
+%!
+%! C = @(fcn,x) fcn(x);
+%! C2 = @(fcn,x,y) fcn(x,y);
+%! 
+%! % Church Booleans
+%! T = @(t,f) t;
+%! F = @(t,f) f;
+%! 
+%! % Church Numerals
+%! Zero  = @(fcn,x) x;
+%! One   = @(fcn,x) fcn(x);
+%! Two   = @(fcn,x) fcn(fcn(x));
+%! Three = @(fcn,x) fcn(fcn(fcn(x)));
+%! Four  = @(fcn,x) fcn(fcn(fcn(fcn(x))));
+%! 
+%! % Arithmetic Operations
+%! Inc = @(a) @(f,x) f(a(f,x)); % Increment
+%! Add = @(a,b) @(f,x) a(f,b(f,x));
+%! Mult = @(a,b) @(f,x) a(@(x) b(f,x),x);
+%! Dec = @(a) @(f,x) C(a(@(g) @(h) h(g(f)), @(u) x), @(u) u); % Decrement
+%! Sub = @(a,b) b(Dec, a);
+%! 
+%! % Renderer - Convert church numeral to "real" number
+%! Render = @(n) n(@(n) n+1,0);
+%! 
+%! % Predicates
+%! Iszero = @(n) n(@(x) F, T);
+%! 
+%! % Y combinator implements recursion
+%! Ycomb = @(f) C(@(g) f(@(x) C(g(g), x)), ...
+%!                @(g) f(@(x) C(g(g), x)));
+%!
+%! Factorial = Ycomb(@(f) @(n) C(C2(Iszero(n), ...
+%!                   @(d) One, @(d) Mult(n, f(Dec(n)))),0));
+%! 
+%! assert (Render (Factorial (Two)), 2)
+%! assert (Render (Factorial (Three)), 6)
+%! assert (Render (Factorial (Four)), 24)
--- a/test/test_io.m
+++ b/test/test_io.m
@@ -250,6 +250,12 @@
 
 %!assert (sscanf (['ab'; 'cd'], '%s'), 'acbd')
 
+%!assert (sscanf ('02:08:30', '%i:%i:%i'), [2; 0]);
+%!assert (sscanf ('02:08:30', '%d:%d:%d'), [2; 8; 30]);
+
+%!assert (sscanf ('0177 08', '%i'), [127; 0; 8]);
+%!assert (sscanf ('0177 08', '%d'), [177; 8]);
+
 %!test
 %! [val, count, msg, pos] = sscanf ("3I2", "%f");
 %! assert (val, 3);